How to use the results calculated by the previous module to control the variant modules in the system composer (software architecture)?

1 次查看(过去 30 天)
I am trying to use variant components to build my software architecture. The plan is to use the signal a calculated by the previous calculation module (Planning) to control the selection of variant components, such as selecting component_1 when v=1, and if v=2, select component_2. At present, after consulting the reference documents, it seems that the control variables for the variants can only be used in MATLAB ® Variables, Simulink Parameter object or Simulink The VariantControl object is used for control. And my quantity is the signal, how should this be achieved?
It should be noted that due to project requirements, I am unable to use programming methods likes M-function or S-function. I can only use the built-in module functions of SIMULINK.

采纳的回答

Josh Kahn
Josh Kahn 2024-8-29
编辑:Josh Kahn 2024-8-29
Hey @鑫鹏,
What you are modeling appears to be a service-oriented architecture. Are you able to upgrade from R2021b? In R2022a, we introduced client-server ports that can be used to make function calls between components. Your "variants" would then be encapsulated functions that you would call out to conditionally. You can do this using If Action subsystems, example attached.
Using the interface editor, you can design your service interface and function calls:
In the example, the delegator calls the correct function depending on the logic you define and merges the outputs
The Estimation server has two functions that you can then populate with your logic. This model is an export-function style model which means it only runs when called (needs to be integrated with an external scheduler such as Stateflow) because of the root-level client/server ports but the other models can be rate based. You can also split up the Estimator into separate blocks with their own client-server ports, I chose to just use one for simplicity but depending on the complexity of your implementation, you may wish to model the choices as separate components. Alternatively, you can use subsystem reference in the estimation server to divide it out at the implementation layer instead.
Here are some additional resources:
If Action Subsystems
YouTube Livestream on Software Architecture modeling in System Composer
MathWorks Software Architecture Solutions Page
Josh

更多回答(1 个)

Swastik Sarkar
Swastik Sarkar 2024-8-28
Hi @鑫鹏,
Variant components are used to indicate alternate designs for a component within an architecture. They are not suited for conditional execution of components. More details can be found in the documentation below:
To achieve conditional execution of components, consider creating a wrapper around the components by including them as "Enabled Subsystems" in Simulink. This method allows for control over the execution of components based on specific conditions.
Further information about "Enabled Subsystems" and their implementation can be found in the documentation below:
Hope this information helps.

类别

Help CenterFile Exchange 中查找有关 System Composer 的更多信息

产品


版本

R2021b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by