Table of Contents
Using Parameters in Components
Software components are intended for composition “as-is” without the intention to modify them in source-code. The SmartMDSD Toolchain foresees “component parameters” to configure foreseen variation points.
Parameters are defined in Tier 2 as re-usable domain models or within a software component. Their values can be customized durin system composition.
This page will describe the steps to setup a component with parameters. We will configure the component parameters in a component project and will customize it during system composition.
Note that there are two types of component parameters:
- Parameters modeled at Tier 2 / Domain Models
- They can be re-used by multiple components.
- Use this if you want to provide a general way to parameterize a variety of software components (composability).
- Can be configured at design-time and run-time (e.g. by the sequencer)
- Parameters modeled at Tier 3 in a specific software component
- These parameters are specific to one component. No re-use of a parameter definition by another component.
- There are two sub-types of parameters:
- Extended Parameters
- Can be configured at design-time and run-time (e.g. by the sequencer)
- Internal Parameters
- Can be configured at design-time only
This HowTo will describe the use of component internal parameters. If you want to model parameters at Tier 2, model them in a domain project (model file .parameters)
Modeling the Component Parameters in a Component Project
Step 1: Create a Component Project
Step 2: Model the Component with Component Parameters
- Import CommBasicObjects in to Component Project as it provides DefaultCoordinationService
- Drag and drop the CoordinationSlavePort and link DefaultCoordinationService
- Drag and drop the ComponentParameters and link it to CoordinationSlavePort
Step 3: Assign the initial values to Component Parameters
- Double click on ComponentParameterConfigParam to get code window.
- Model the InternalParameter with name
- Add variables with datatype and initial values.
Step 4 : Using Component Parameters in Code
Accessing parameter in Task (ConfigTask)
Code to access the parameter in the Task :
int ConfigTask::on_execute() { double maxVel = COMP->getGlobalState().getRobot().getMaxVel(); //OR double maxvel2 = COMP->getParameters().getRobot().getMaxVel(); return 0; }
Customizing the Component Parameters in the System
Step 1: Create a System Project
Step 2: Import and Model Component
- Import component(s) into the system
- Create an instance of your component.
- Model the component with required services and provided services
Step 3:Using Parameters in Components
Step 4: Customize the Component Parameters
You can use the parameter in the system either from the parameter model (file suffix .componentParameters) or via the component parameter editor view. See the below animation for a usage demonstration how to define the parameter values:
The below screenshot shows another example using the component parameter editor view. Select the