Modelica.StateGraph.Interfaces

Connectors and partial models

Information



Extends from Modelica.Icons.InterfacesPackage (Icon for packages containing interfaces).

Package Content

NameDescription
Modelica.StateGraph.Interfaces.Step_in Step_in Input port of a step
Modelica.StateGraph.Interfaces.Step_out Step_out Output port of a step
Modelica.StateGraph.Interfaces.Transition_in Transition_in Input port of a transition
Modelica.StateGraph.Interfaces.Transition_out Transition_out Output port of a transition
Modelica.StateGraph.Interfaces.CompositeStep_resume CompositeStep_resume Input port of a step (used for resume connector of a CompositeStep)
Modelica.StateGraph.Interfaces.CompositeStep_suspend CompositeStep_suspend Output port of a step (used for suspend connector of a CompositeStep)
Modelica.StateGraph.Interfaces.CompositeStepStatePort_in CompositeStepStatePort_in Communication port between a CompositeStep and the ordinary steps within the CompositeStep (suspend/resume are inputs)
Modelica.StateGraph.Interfaces.CompositeStepStatePort_out CompositeStepStatePort_out Communication port between a CompositeStep and the ordinary steps within the CompositeStep (suspend/resume are outputs)
Modelica.StateGraph.Interfaces.PartialStep PartialStep Partial step with one input and one output transition port
Modelica.StateGraph.Interfaces.PartialTransition PartialTransition Partial transition with input and output connections
Modelica.StateGraph.Interfaces.PartialStateGraphIcon PartialStateGraphIcon Icon for a StateGraph object
CompositeStepState Communication channel between CompositeSteps and steps in the CompositeStep


Modelica.StateGraph.Interfaces.Step_in Modelica.StateGraph.Interfaces.Step_in

Input port of a step

Modelica.StateGraph.Interfaces.Step_in

Information



Contents

TypeNameDescription
output Booleanoccupiedtrue, if step is active
input Booleansettrue, if transition fires and step is activated

Modelica definition

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;

Modelica.StateGraph.Interfaces.Step_out Modelica.StateGraph.Interfaces.Step_out

Output port of a step

Modelica.StateGraph.Interfaces.Step_out

Information



Contents

TypeNameDescription
output Booleanavailabletrue, if step is active
input Booleanresettrue, if transition fires and step is deactivated

Modelica definition

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;

Modelica.StateGraph.Interfaces.Transition_in Modelica.StateGraph.Interfaces.Transition_in

Input port of a transition

Modelica.StateGraph.Interfaces.Transition_in

Information



Contents

TypeNameDescription
input Booleanavailabletrue, if step connected to the transition input is active
output Booleanresettrue, if transition fires and the step connected to the transition input is deactivated

Modelica definition

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;

Modelica.StateGraph.Interfaces.Transition_out Modelica.StateGraph.Interfaces.Transition_out

Output port of a transition

Modelica.StateGraph.Interfaces.Transition_out

Information



Contents

TypeNameDescription
input Booleanoccupiedtrue, if step connected to the transition output is active
output Booleansettrue, if transition fires and step connected to the transition output becomes active

Modelica definition

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;

Modelica.StateGraph.Interfaces.CompositeStep_resume Modelica.StateGraph.Interfaces.CompositeStep_resume

Input port of a step (used for resume connector of a CompositeStep)

Information



Contents

TypeNameDescription
output Booleanoccupiedtrue, if step is active
input Booleansettrue, if transition fires and step is activated

Modelica definition

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;

Modelica.StateGraph.Interfaces.CompositeStep_suspend Modelica.StateGraph.Interfaces.CompositeStep_suspend

Output port of a step (used for suspend connector of a CompositeStep)

Information



Contents

TypeNameDescription
output Booleanavailabletrue, if step is active
input Booleanresettrue, if transition fires and step is deactived

Modelica definition

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;

Modelica.StateGraph.Interfaces.CompositeStepStatePort_in

Communication port between a CompositeStep and the ordinary steps within the CompositeStep (suspend/resume are inputs)

Information



Contents

TypeNameDescription
input Booleansuspend= true, if suspend transition of CompositeStep fires
input Booleanresume= true, if resume transition of CompositeStep fires
RealactiveStepsDummyDummy variable in order that connector fulfills restriction of connector
flow RealactiveStepsNumber of active steps in the CompositeStep

Modelica definition

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;

Modelica.StateGraph.Interfaces.CompositeStepStatePort_out

Communication port between a CompositeStep and the ordinary steps within the CompositeStep (suspend/resume are outputs)

Information



Contents

TypeNameDescription
output Booleansuspend= true, if suspend transition of CompositeStep fires
output Booleanresume= true, if resume transition of CompositeStep fires
RealactiveStepsDummyDummy variable in order that connector fulfills restriction of connector
flow RealactiveStepsNumber of active steps in the CompositeStep

Modelica definition

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;

Modelica.StateGraph.Interfaces.PartialStep Modelica.StateGraph.Interfaces.PartialStep

Partial step with one input and one output transition port

Modelica.StateGraph.Interfaces.PartialStep

Information



Parameters

TypeNameDefaultDescription
IntegernIn1Number of input connections
IntegernOut1Number of output connections

Connectors

TypeNameDescription
Step_ininPort[nIn]Vector of step input connectors
Step_outoutPort[nOut]Vector of step output connectors

Modelica definition

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;

Modelica.StateGraph.Interfaces.PartialTransition Modelica.StateGraph.Interfaces.PartialTransition

Partial transition with input and output connections

Modelica.StateGraph.Interfaces.PartialTransition

Information



Parameters

TypeNameDefaultDescription
Timer
BooleanenableTimerfalse= true, if timer is enabled
TimewaitTime0Wait time before transition fires [s]

Connectors

TypeNameDescription
Transition_ininPortVector of transition input connectors
Transition_outoutPortVector of transition output connectors

Modelica definition

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;

Modelica.StateGraph.Interfaces.PartialStateGraphIcon Modelica.StateGraph.Interfaces.PartialStateGraphIcon

Icon for a StateGraph object

Information



Modelica definition

partial block PartialStateGraphIcon "Icon for a StateGraph object"

end PartialStateGraphIcon;

Modelica.StateGraph.Interfaces.CompositeStepState

Communication channel between CompositeSteps and steps in the CompositeStep

Information



Connectors

TypeNameDescription
CompositeStepStatePort_outsubgraphStatePort 

Modelica definition

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;

Modelica.StateGraph.Interfaces.PartialStep.OuterStatePort

Connectors

TypeNameDescription
CompositeStepStatePort_insubgraphStatePort 

Modelica definition

model OuterStatePort
  CompositeStepStatePort_in subgraphStatePort;
end OuterStatePort;

Automatically generated Fri Nov 12 16:27:51 2010.