Extends from Modelica.Icons.InterfacesPackage (Icon for packages containing interfaces).
Name | Description |
---|---|
Step_in | Input port of a step |
Step_out | Output port of a step |
Transition_in | Input port of a transition |
Transition_out | Output port of a transition |
CompositeStep_resume | Input port of a step (used for resume connector of a CompositeStep) |
CompositeStep_suspend | Output port of a step (used for suspend connector of a CompositeStep) |
CompositeStepStatePort_in | Communication port between a CompositeStep and the ordinary steps within the CompositeStep (suspend/resume are inputs) |
CompositeStepStatePort_out | Communication port between a CompositeStep and the ordinary steps within the CompositeStep (suspend/resume are outputs) |
PartialStep | Partial step with one input and one output transition port |
PartialTransition | Partial transition with input and output connections |
PartialStateGraphIcon | Icon for a StateGraph object |
CompositeStepState | Communication channel between CompositeSteps and steps in the CompositeStep |
Type | Name | Description |
---|---|---|
output Boolean | occupied | true, if step is active |
input Boolean | set | true, if transition fires and step is activated |
connector Step_in "Input port of a step" output Boolean occupied "true, if step is active"; input Boolean set "true, if transition fires and step is activated";end Step_in;
Type | Name | Description |
---|---|---|
output Boolean | available | true, if step is active |
input Boolean | reset | true, if transition fires and step is deactivated |
connector Step_out "Output port of a step" output Boolean available "true, if step is active"; input Boolean reset "true, if transition fires and step is deactivated";end Step_out;
Type | Name | Description |
---|---|---|
input Boolean | available | true, if step connected to the transition input is active |
output Boolean | reset | true, if transition fires and the step connected to the transition input is deactivated |
connector Transition_in "Input port of a transition" input Boolean available "true, if step connected to the transition input is active"; output Boolean reset "true, if transition fires and the step connected to the transition input is deactivated";end Transition_in;
Type | Name | Description |
---|---|---|
input Boolean | occupied | true, if step connected to the transition output is active |
output Boolean | set | true, if transition fires and step connected to the transition output becomes active |
connector Transition_out "Output port of a transition" input Boolean occupied "true, if step connected to the transition output is active"; output Boolean set "true, if transition fires and step connected to the transition output becomes active";end Transition_out;
Type | Name | Description |
---|---|---|
output Boolean | occupied | true, if step is active |
input Boolean | set | true, if transition fires and step is activated |
connector CompositeStep_resume "Input port of a step (used for resume connector of a CompositeStep)" output Boolean occupied "true, if step is active"; input Boolean set "true, if transition fires and step is activated";end CompositeStep_resume;
Type | Name | Description |
---|---|---|
output Boolean | available | true, if step is active |
input Boolean | reset | true, if transition fires and step is deactived |
connector CompositeStep_suspend "Output port of a step (used for suspend connector of a CompositeStep)" output Boolean available "true, if step is active"; input Boolean reset "true, if transition fires and step is deactived";end CompositeStep_suspend;
Type | Name | Description |
---|---|---|
input Boolean | suspend | = true, if suspend transition of CompositeStep fires |
input Boolean | resume | = true, if resume transition of CompositeStep fires |
Real | activeStepsDummy | Dummy variable in order that connector fulfills restriction of connector |
flow Real | activeSteps | Number of active steps in the CompositeStep |
connector CompositeStepStatePort_in "Communication port between a CompositeStep and the ordinary steps within the CompositeStep (suspend/resume are inputs)" input Boolean suspend "= true, if suspend transition of CompositeStep fires"; input Boolean resume "= true, if resume transition of CompositeStep fires"; Real activeStepsDummy "Dummy variable in order that connector fulfills restriction of connector"; flow Real activeSteps "Number of active steps in the CompositeStep";end CompositeStepStatePort_in;
Type | Name | Description |
---|---|---|
output Boolean | suspend | = true, if suspend transition of CompositeStep fires |
output Boolean | resume | = true, if resume transition of CompositeStep fires |
Real | activeStepsDummy | Dummy variable in order that connector fulfills restriction of connector |
flow Real | activeSteps | Number of active steps in the CompositeStep |
connector CompositeStepStatePort_out "Communication port between a CompositeStep and the ordinary steps within the CompositeStep (suspend/resume are outputs)" output Boolean suspend "= true, if suspend transition of CompositeStep fires"; output Boolean resume "= true, if resume transition of CompositeStep fires"; Real activeStepsDummy "Dummy variable in order that connector fulfills restriction of connector"; flow Real activeSteps "Number of active steps in the CompositeStep";end CompositeStepStatePort_out;
Type | Name | Default | Description |
---|---|---|---|
Integer | nIn | 1 | Number of input connections |
Integer | nOut | 1 | Number of output connections |
Type | Name | Description |
---|---|---|
Step_in | inPort[nIn] | Vector of step input connectors |
Step_out | outPort[nOut] | Vector of step output connectors |
partial block PartialStep "Partial step with one input and one output transition port" parameter Integer nIn(min=0) = 1 "Number of input connections"; parameter Integer nOut(min=0) = 1 "Number of output connections"; /* localActive is introduced since component 'Step' has Boolean variable 'active' and component 'StepWithSignal' has connector instance 'active' defined and both components inherit from PartialStep */ output Boolean localActive "= true if step is active, otherwise the step is not active";Interfaces.Step_in inPort[nIn] "Vector of step input connectors"; Interfaces.Step_out outPort[nOut] "Vector of step output connectors"; protected outer Interfaces.CompositeStepState stateGraphRoot;model OuterStatePort CompositeStepStatePort_in subgraphStatePort; end OuterStatePort ; OuterStatePort outerStatePort; Boolean newActive "Value of active in the next iteration"; Boolean oldActive "Value of active when CompositeStep was aborted"; initial equation pre(newActive) = pre(localActive); pre(oldActive) = pre(localActive); equation connect(outerStatePort.subgraphStatePort, stateGraphRoot.subgraphStatePort); // Check that connections to the connector are correct for i in 1:nIn loop assert(cardinality(inPort[i]) <= 1, "Connector is connected to more than one transition (this is not allowed)"); end for; for i in 1:nOut loop assert(cardinality(outPort[i]) <= 1, "Connector is connected to more than one transition (this is not allowed)"); end for; // set active state localActive = pre(newActive); newActive = if outerStatePort.subgraphStatePort.resume then oldActive else ( StateGraph.Temporary.anyTrue(inPort.set) or localActive and not StateGraph.Temporary.anyTrue(outPort.reset)) and not outerStatePort.subgraphStatePort.suspend; // Remember state for suspend action when outerStatePort.subgraphStatePort.suspend then oldActive = localActive; end when; // Report state to CompositeStep outerStatePort.subgraphStatePort.activeSteps = if localActive then 1.0 else 0.0; // Report state to input and output transitions for i in 1:nIn loop inPort[i].occupied = if i == 1 then localActive else inPort[i-1].occupied or inPort[i-1].set; end for; for i in 1:nOut loop outPort[i].available = if i == 1 then localActive else outPort[i-1].available and not outPort[i-1].reset; end for; // Default setting, if an inPort or an outPort is not connected for i in 1:nIn loop if cardinality(inPort[i]) == 0 then inPort[i].set = false; end if; end for; for i in 1:nOut loop if cardinality(outPort[i]) == 0 then outPort[i].reset = false; end if; end for;end PartialStep;
Type | Name | Default | Description |
---|---|---|---|
Timer | |||
Boolean | enableTimer | false | = true, if timer is enabled |
Time | waitTime | 0 | Wait time before transition fires [s] |
Type | Name | Description |
---|---|---|
Transition_in | inPort | Vector of transition input connectors |
Transition_out | outPort | Vector of transition output connectors |
partial block PartialTransition "Partial transition with input and output connections" input Boolean localCondition "= true, if transition may fire"; parameter Boolean enableTimer=false "= true, if timer is enabled"; parameter Modelica.SIunits.Time waitTime(min=0) = 0 "Wait time before transition fires"; output Modelica.SIunits.Time t "= actual waiting time (transition will fire when t > waitTime)"; output Boolean enableFire "= true, if all firing conditions are true"; output Boolean fire "= true, if transition fires";StateGraph.Interfaces.Transition_in inPort "Vector of transition input connectors"; StateGraph.Interfaces.Transition_out outPort "Vector of transition output connectors"; protected Modelica.SIunits.Time t_start "Time instant at which the transition would fire, if waitTime would be zero"; Real t_dummy; initial equation pre(enableFire) = false; equation assert(cardinality(inPort) == 1, "Connector inPort is not connected to exactly one other connector"); assert(cardinality(outPort) == 1, "Connector outPort is not connected to exactly one other connector"); // Handling of Timer if enableTimer then when enableFire then t_start = time; end when; t_dummy = time - t_start; t = if enableFire then t_dummy else 0; fire = enableFire and time >= t_start + waitTime; else t_start = 0; t_dummy = 0; t = 0; fire = enableFire; end if; // Determine fire setting and report it to the connected step enableFire = localCondition and inPort.available and not outPort.occupied; inPort.reset = fire; outPort.set = fire;end PartialTransition;
partial block PartialStateGraphIcon "Icon for a StateGraph object"end PartialStateGraphIcon;
Type | Name | Description |
---|---|---|
CompositeStepStatePort_out | subgraphStatePort |
model CompositeStepState "Communication channel between CompositeSteps and steps in the CompositeStep" output Boolean suspend = false; output Boolean resume = false; CompositeStepStatePort_out subgraphStatePort; /* missingInnerMessage="No \"stateGraphRoot\" component is defined on highest level of the StateGraph. A stateGraphRoot component is automatically introduced. In order to get rid of this message, drag StateGraph.StateGraphRoot into the top level your model."); */ equation suspend = subgraphStatePort.suspend; resume = subgraphStatePort.resume; subgraphStatePort.activeStepsDummy = 0;end CompositeStepState;
Type | Name | Description |
---|---|---|
CompositeStepStatePort_in | subgraphStatePort |
model OuterStatePort CompositeStepStatePort_in subgraphStatePort; end OuterStatePort;