Download Modeling with TDL
Transcript
IncDecSample2 is based on the previous example but uses an array type instead of the basic integer type. In this extended example, both tasks of M1, namely inc and dec, produce two values. Therefore, we define an array type. Adding new types. New TDL types are added by right-clicking on the Types folder in the tree and selecting ‘New Type’ from the pop-up menu. This creates a new type type1. In the inspector, we can choose the ‘Category’ of our new type. We can either define the type to be an ‘alias’ for an already existing type, an ‘array’ or a ‘struct’. For array types, we have to specify the element’s type of the array with the ‘Designator’ property, and its ‘Length’. In our example, we need an integer array with length 2. Struct types, have no additional property, but would require the specification of structure members. To add a new member to a struct type, right-click on the type in the tree and select ‘Add struct member’ from the pop-up menu. We use the integer array consisting of two integers for our actuators a1, a2, and for the output ports of task inc and dec in M1, as well as for actuator a and all ports of task sum in M2. TDL ports that use an array data type expect multiplexed Simulink® signals, and ports using a struct data type expect a Simulink® bus as in- or output. Note, that an output port or actuator of type array or struct cannot be initialized by a value defined with its ‘Initial Value’ property. An initializer function must be used instead. Creating initializer functions. To create an initializer function for a port, right-click on the port in the tree and select ‘New init function’ from the pop-up menu. 74 • Guided Tour of the TDL:VisualCreator tool Modeling with TDL