root/branches/maintenance/3.0/Modelica/StateGraph.mo

Revision 1159, 135.2 kB (checked in by dietmarw, 5 weeks ago)

fixes #100 (in maintenance/3.0) by changing the annotation to a vendor specific annotation

From: Dietmar Winkler <Dietmar.Winkler@…>

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1within Modelica;
2package StateGraph
3  "Library of hierarchical state machine components to model discrete event and reactive systems"
4
5extends Modelica.Icons.Library2;
6
7annotation (
8  version="0.87",
9  versionDate="2004-06-23",
10  Documentation(info="<html>
11<p>
12Library <b>StateGraph</b> is a <b>free</b> Modelica package providing
13components to model <b>discrete event</b> and <b>reactive</b>
14systems in a convenient
15way. It is based on the JGraphChart method and
16takes advantage of Modelica features for
17the \"action\" language. JGraphChart is a further development of
18Grafcet to include elements of StateCharts that are not present
19in Grafcet/Sequential Function Charts. Therefore, the StateGraph
20library has a similar modeling power as StateCharts but avoids
21some deficiences of StateCharts.
22</p>
23<p>
24For an introduction, have especially a look at:
25</p>
26<ul>
27<li> <a href=\"Modelica://Modelica.StateGraph.UsersGuide\">StateGraph.UsersGuide</a>
28     discusses the most important aspects how to use this library.</li>
29<li> <a href=\"Modelica://Modelica.StateGraph.Examples\">StateGraph.Examples</a>
30     contains examples that demonstrate the usage of this library.</li>
31</ul>
32<p>
33A typical model generated with this library is shown
34in the next figure where on the left hand side a two-tank
35system with a tank controller and on the right hand side the
36top-level part of the tank controller as a StateGraph is shown:
37</p>
38<p>
39<img src=\"../Images/StateGraph/Examples/ControlledTanks1_small.png\"> 
40<img src=\"../Images/StateGraph/Examples/ControlledTanks2_small.png\">
41</p>
42<p>
43The unique feature of the StateGraph library with respect to JGraphCharts,
44Grafcet, Sequential Function Charts, and StateCharts, is Modelica's
45\"single assignment rule\" that requires that every variable is defined
46by exactly one equation. This leads to a different \"action\" definition
47as in these formalisms. The advantage is that the translator can either
48determine a useful evaluation sequence by equation sorting or
49reports an error if this is not possible, e.g., because a model
50would lead to a non-determinism or to a dead-lock. As a side effect,
51this leads also to simpler and more easier to understand models and
52global variables are no longer needed (whereas in JGraphCharts,
53Grafcet, Sequential Function Charts and StateCharts global variables
54are nearly always needed).
55</p>
56<p>
57The StateGraph library is currently available in a beta release.
58The available components will most likely not be changed for the
59release version. It is planned to improve the convenience of
60building models with the StateGraph library for the release version
61(this may require to introduce some additional annotations).
62It is planned to include the StateGraph library in the
63Modelica standard library.
64It is most useful to combine this libray with the Modelica libraries
65</p>
66<ul>
67<li><b>Modelica.Blocks.Logical</b> that provides 
68    components available in PLCs (programmable logic controllers). </li>
69<li><b>UserInteraction</b> that provides components to
70    interactively communicate with models in a running simulation.</li>
71</ul>
72 
73<p>
74Copyright &copy; 1998-2008, Modelica Association and DLR
75</p>
76<p>
77<i>This Modelica package is <b>free</b> software; it can be redistributed and/or modified
78under the terms of the <b>Modelica license</b>, see the license conditions
79and the accompanying <b>disclaimer</b> 
80<a href=\"Modelica://Modelica.UsersGuide.ModelicaLicense\">here</a>.</i>
81</p><br>
82 
83</HTML>
84")
85  ,
86    Icon(coordinateSystem(preserveAspectRatio=true, extent={{-100,-100},{100,
87            100}}), graphics={
88        Rectangle(extent={{-88,-20},{-50,-54}}, lineColor={0,0,0}),
89        Line(points={{-50,-38},{-24,-38}}, color={0,0,0}),
90        Polygon(
91          points={{-24,-32},{-12,-38},{-24,-44},{-24,-32}},
92          lineColor={0,0,0},
93          fillColor={0,0,0},
94          fillPattern=FillPattern.Solid),
95        Line(points={{-12,-6},{-12,-76}}, color={0,0,0}),
96        Line(points={{-12,-38},{14,-38}}, color={0,0,0}),
97        Polygon(
98          points={{14,-32},{26,-38},{14,-44},{14,-32}},
99          lineColor={0,0,0},
100          fillColor={0,0,0},
101          fillPattern=FillPattern.Solid),
102        Rectangle(extent={{26,-22},{64,-56}}, lineColor={0,0,0})}));
103
104package UsersGuide "User's Guide of StateGraph Library"
105
106  annotation (__Dymola_DocumentationClass=true, Documentation(info="<html>
107<p>
108Library <b>StateGraph</b> is a <b>free</b> Modelica package providing
109components to model <b>discrete event</b> and <b>reactive</b> 
110systems in a convenient
111way. This package contains the <b>User's Guide</b> for
112the library and has the following content:
113</p>
114<ol>
115<li><a href=\"Modelica://Modelica.StateGraph.UsersGuide.OverView\">Overview of library</a>
116     gives an overview of the library.</li>
117<li> <a href=\"Modelica://Modelica.StateGraph.UsersGuide.FirstExample\">A first example</a>
118     demonstrates at hand of a first example how to use this library.</li>
119<li> <a href=\"Modelica://Modelica.StateGraph.UsersGuide.ApplicationExample\">An
120     application example</a> demonstrates varies features at hand of the
121     control of a two tank system.</li>
122<li><a href=\"Modelica://Modelica.StateGraph.UsersGuide.ReleaseNotes\">Release Notes</a>
123    summarizes the differences between different versions of this library.</li>
124<li><a href=\"Modelica://Modelica.StateGraph.UsersGuide.Literature\">Literature</a>
125    provides references that have been used to design and implement this
126    library.</li>
127<li><a href=\"Modelica://Modelica.StateGraph.UsersGuide.Contact\">Contact</a> 
128    provides information about the authors of the library as well as
129    acknowledgments.</li>
130</ol>
131</html>"));
132
133  class OverView "Overview of library"
134
135    annotation (Documentation(info="<html>
136<p>
137In this section, an overview of the most important features
138of this library is given.
139</p>
140<h4><font color=\"#008000\">Steps and Transitions</font></h4>
141<p>
142A <b>StateGraph</b> is an enhanced finite state machine.
143It is based on the JGraphChart method and
144takes advantage of Modelica features for
145the \"action\" language. JGraphChart is a further development of
146Grafcet to include elements of StateCharts that are not present
147in Grafcet/Sequential Function Charts. Therefore, the StateGraph
148library has a similar modeling power as StateCharts but avoids
149some deficiences of StateCharts.
150</p>
151<p>
152The basic elements of StateGraphs are <b>steps</b> and <b>transitions</b>:
153</p>
154<p align=\"center\">
155<img src=\"../Images/StateGraph/UsersGuide/StepAndTransition1.png\">
156</p>
157<p>
158<b>Steps</b> represent the possible states a StateGraph can have.
159If a step is active the Boolean variable <b>active</b> of
160the step is <b>true</b>. If it is deactivated,
161<b>active</b> = <b>false</b>. At the initial time, all \"usual\"
162steps are deactivated. The <b>InitialStep</b> objects are steps
163that are activated at the initial time. They are characterized
164by a double box (see figure above).
165</p>
166<p>
167<b>Transitions</b> are used to change the state of a StateGraph.
168When the step connected to the input of a transition is active,
169the step connected to the output of this transition is deactivated
170and the transition condition becomes true, then the
171transition fires. This means that the step connected to the input to the
172transition is deactivated and the step connected to the output
173of the transition is activated.
174</p>
175<p>
176The transition <b>condition</b> is defined via the parameter menu
177of the transition object. Clicking on object \"transition1\" in
178the above figure, results in the following menu:
179</p>
180<p align=\"center\">
181<img src=\"../Images/StateGraph/UsersGuide/StepAndTransition2.png\">
182</p>
183<p>
184In the input field \"<b>condition</b>\", any type of time varying
185Boolean expression can be given (in Modelica notation, this is
186a modification of the time varying variable <b>condition</b>).
187Whenever this condition is true, the transition can fire.
188Additionally, it is possible to activate a timer, via
189<b>enableTimer</b> (see menu above) and provide a
190<b>waitTime</b>. In this case the firing of the transition
191is delayed according to the provided waitTime. The transition
192condition and the waitTime are displayed in the transition icon.
193</p>
194<p>
195In the above example, the simulation starts at <b>initialStep</b>.
196After 1 second, <b>transition1</b> fires and <b>step1</b> becomes
197active. After another second <b>transition2</b> fires and
198<b>initialStep</b> becomes again active. After a further
199second <b>step1</b> becomes again active, and so on.
200</p>
201<p>
202In JGrafcharts, Grafcet and Sequential Function Charts, the
203network of steps and transitions is drawn from top to bottom.
204In StateGraphs, no particular direction is defined, since
205steps and transitions are blocks with input and output connectors
206that can be arbitrarily placed and connected. Usually, it is
207most practical to define the network from left to right,
208as in the example above, since then it is easy to read the
209labels on the icons.
210</p>
211<h4><font color=\"#008000\">Conditions and Actions</font></h4>
212<p>
213With the block <b>TransitionWithSignal</b>, the firing condition
214can be provided as Boolean input signal, instead as entry in the
215menu of the transition. An example is given in the next
216figure:
217</p>
218<p align=\"center\">
219<img src=\"../Images/StateGraph/UsersGuide/StepAndTransition3.png\">
220</p>
221<p>
222Component \"step\" is an instance of \"StepWithSignal\" that is
223a usual step where the active flag is available as Boolean
224output signal. To this output, component \"Timer\" from
225library \"Modelica.Blocks.Logical\" is connected. It measures the
226time from the time instant where the Boolean input (i.e., the
227active flag of the step) became true upto the current
228time instant. The timer is connected to a comparison
229component. The output is true, once the timer reaches
2301 second. This signal is used as condition input of the
231transition. As a result, \"transition2\" fires, once step
232\"step\" has been active for 1 second.
233Of course, any other
234Modelica block with a Boolean output signal can be
235connected to the condition input of such a transition block
236as well.
237</p>
238<p>
239Conditions of a transition can either be computed by
240a network of logical blocks from the Logical library as
241in the figure above, or via the \"SetBoolean\" component
242any type of logical expression can be defined in textual
243form, as shown in the next figure:
244</p>
245<p align=\"center\">
246<img src=\"../Images/StateGraph/UsersGuide/StepAndTransition4.png\">
247</p>
248<p>
249With the block \"<b>SetBoolean</b>\", a time varying expression
250can be provided as modification to the output signal <b>y</b>
251(see block with icon text \"timer.y > 1\" in the figure above).
252The output signal can be in turn connected to the condition
253input of a TransitionWithSignal block.
254</p>
255<p>
256The \"<b>SetBoolean</b>\" block can also be used to
257compute a Boolean signal depending on the active step.
258In the figure above, the output of the block with the
259icon text \"step.active\" is
260true, when \"step\" is active, otherwise it is false
261(note, the icon text of \"SetBoolean\" displays the modification
262of the output signal \"y\").
263This signal can then be used to compute desired <b>actions</b> 
264in the physical systems model. For example, if a <b>valve</b>
265shall be open, when the StateGraph is in \"step1\" or
266in \"step4\", a \"SetBoolean\" block may be connected to the
267valve model using the following condition:
268</p>
269<pre>
270    valve = step1.active <b>or</b> step2.active
271</pre> 
272<p>
273Via the Modelica operators <b>edge</b>(..) and <b>change</b>(..),
274conditions depending on rising and falling edges of
275Boolean expressions can be used when needed.
276</p>
277<p>
278In JGrafcharts, Grafcet, Sequential Function Charts and StateCharts,
279<b>actions</b> are formulated <b>within a step</b>. Such actions are
280distinguished as <b>entry</b>, <b>normal</b>, <b>exit</b> and
281<b>abort</b> actions. For example, a valve might be opened by
282an entry action of a step and might be closed by an exit
283action of the same step. In StateGraphs, this is (fortunately)
284<b>not possible</b>
285due to Modelicas \"single assignment rule\" that requires that every
286variable is defined by exactly one equation. Instead, the
287approach explained above is used. For example, via the
288\"SetBoolean\" component, the valve variable is set to true
289when the StateGraph is in particular steps.
290</p>
291<p>
292This feature of a StateGraph is <b>very useful</b>, since it allows
293a Modelica translator to <b>guarantee</b> that a given StateGraph
294has always <b>deterministic</b> behaviour without conflicts.
295In the other methodologies this is much more cumbersome. For example,
296if two steps are executed in parallel and both step actions
297modify the same variable, the result is either non-deterministic
298or non-obvious rules have to be defined which action
299takes priority. In a StateGraph, such a situation is detected by
300the translator resulting in an error, since there are two equations
301to compute one variable. Additional benefits of the StateGraph
302approach are:
303</p>
304<ul>
305<li> A JGrafchart or a StateChart need to potentially access
306     variables in a step that are defined in
307     higher hierarchical levels of a model. Therefore, mostly <b>global
308     variables</b> are used in the whole network, even if the
309     network is structured hierarchically. In StateGraphs this
310     is not necessary, since the physical systems outside
311     of a StateGraph might access the step or transition state
312     via a hierarchical name. This means that <b>no global variables</b>
313     are needed, because the local variables in the StateGraph
314     are accessed from local variables outside of the StateGraph.
315     </li>
316<li> It is simpler for a user to understand the information that
317     is provided in the non-graphical definition, since every
318     variable is defined at exactly one place. In the other
319     methodologies, the setting and re-setting of the same
320     variable is cluttered within the whole network.
321    </li>
322</ul>
323<p>
324To emphasize this important difference between these methodologies,
325consider the case that a state machine has the following
326hierarchy:
327</p>
328<pre>
329   stateMachine.superstate1.superstate2.step1
330</pre>
331<p>
332Within \"step1\" a StateChart would, e.g., access variable
333\"stateMachine.openValve\", say as \"entry action: openValve = true\".
334This typical usage has the severe drawback that it is not possible
335to use the hierarchical state \"superstate1\" as component in another
336context, because \"step1\" references a particular name outside of this
337component.
338</p>
339<p>
340In a StateGraph, there would be typically a \"SetBoolean\" component
341in the \"stateMachine\" component stating:
342</p>
343<pre>
344    openValve = superstate1.superstate2.step1.active;
345</pre>
346<p>
347As a result, the \"superstate1\" component can be used in
348another context, because it does not depend on the environment
349where it is used.
350</p>
351<h4><font color=\"#008000\">Execution Model</font></h4>
352<p>
353The execution model of a StateGraph follows from its
354Modelica implementation: Given the states of all steps, i.e.,
355whether a step is active or not active, the equations of all
356steps, transitions, transition conditions, actions etc. are
357sorted resulting in an execution sequence to compute
358essentially the new values of the steps. If conflicts occur,
359e.g., if there are more equations as variables, of if there
360are algebraic loops between Boolean variables, an exception
361is raised. Once all equations have been processed, the
362<b>active</b> variable of all steps are updated to the newly
363calculated values. Afterwards, the equations are again
364evaluated. The iteration stops, once no step changes
365its state anymore, i.e., once no transition fires anymore.
366Then, simulation continuous until a new event is triggered,
367(when a relation changes its value).
368</p>
369<p>
370With the Modelica \"sampled(..)\" operator, a StateGraph might also
371be executed within a discrete controller that is called
372at regular time instants. In a future version of the StateGraph
373library, this might be more directly supported.
374</p>
375<h4><font color=\"#008000\">Parallel and Alternative Execution</font></h4>
376<p>
377Parallel activities can be defined by
378component <b>Parallel</b> and alternative activities
379can be defined by component <b>Alternative</b>.
380An example for both components is given in the next figure.
381</p>
382<p align=\"center\">
383<img src=\"../Images/StateGraph/UsersGuide/Parallel1.png\">
384</p>
385<p>
386Here, the branch from \"step2\" to \"step5\" is executed in parallel
387to \"step1\". A transition connected to the output of a parallel
388branch component can only fire if the final steps
389in all parallel branches are active simultaneously.
390The figure above is a screen-shot from the animation of the
391StateGraph: Whenever a step is active or a transition can fire,
392the corresponding component is marked in <b>green</b> color.
393</p>
394<p>
395The three branches within \"step2\" to \"step5\" are
396executed alternatively, depending which transition condition
397of \"transition3\", \"transition4\", \"transition4a\" fires first.
398Since all three transitions fire after 1 second, they are all
399candidates for the active branch. If two or more transitions
400would fire at the same time instant, a priority selection
401is made: The alternative and parallel components have a
402vector of connectors. Every branch has to be connected to
403exactly one entry of the connector vector. The entry with
404the lowest number has the highest priority.
405</p>
406<p>
407Parallel, Alternative and Step components have vectors of
408connectors. The dimensions of these vectors are set in the
409corresponding parameter menu. E.g. in a \"Parallel\" component:
410</p>
411<p align=\"center\">
412<img src=\"../Images/StateGraph/UsersGuide/Parallel2.png\">
413</p>
414<p>
415Currently in Dymola the following menu pops up, when a branch
416is connected to a vector of components in order to define
417the vector index to which the component shall be connected:
418</p>
419<p align=\"center\">
420<img src=\"../Images/StateGraph/UsersGuide/Parallel3.png\">
421</p>
422<h4><font color=\"#008000\">CompositeSteps, Suspend and Resume Port</font></h4>
423<p>
424A StateGraph can be hierarchically structured by using a <b>CompositeStep</b>.
425This is a component that inherits from <b>PartialCompositeStep</b>.
426An example is given in the next figure (from Examples.ControlledTanks):
427</p>
428<p align=\"center\">
429<img src=\"../Images/StateGraph/UsersGuide/CompositeStep1.png\">
430</p>
431<p>
432The CompositeStep component contains a local StateGraph that is
433entered by one or more input transitions and that is left
434by one or more output transitions. Also, other needed signals
435may enter a CompositeStep. The CompositeStep has similiar properties
436as a \"usual\" step: The CompositeStep is <b>active</b> once at least
437one step within the CompositeStep is active. Variable <b>active</b>
438defines the state of the CompositeStep.
439</p>
440<p>
441Additionally, a CompositeStep has a <b>suspend</b> port. Whenever the
442transition connected to this port fires, the CompositeStep is left
443at once. When leaving the CompositeStep via the suspend port, the internal
444state of the CompositeStep is saved, i.e., the active flags of all
445steps within the CompositeStep. The CompositeStep might be entered via
446its <b>resume</b> port. In this case the internal state from the
447suspend transition is reconstructed and the CompositeStep continues
448the execution that it had before the suspend transition fired
449(this corresponds to the history ports of StateCharts or JGrafCharts).
450</p>
451<p>
452A CompositeStep may contain other CompositeSteps. At every level,
453a CompositeStep and all of its content can be left via its suspend ports
454(actually, there
455is a vector of suspend connectors, i.e., a CompositeStep might
456be aborted due to different transitions).
457</p>
458</html>
459"));
460  end OverView;
461
462  class FirstExample "A first example"
463
464    annotation (Documentation(info="<html>
465<p>
466A first example will be given here (not yet done).
467</p>
468</html>
469"));
470  end FirstExample;
471
472  class ApplicationExample "An application example"
473
474    annotation (Documentation(info="<html>
475<p>
476In this section a more realistic, still simple, application example
477is given, to demonstrate various features of the StateGraph library.
478This example shows the control of a two tank system from the master thesis
479of Isolde Dressler
480(<a href=\"Modelica://Modelica.StateGraph.UsersGuide.Literature\">see literature</a>).
481</p>
482<p>
483In the following figure the top level of the model is shown.
484This model is available as StateGraph.Examples.ControlledTanks.
485</p>
486<p align=\"center\">
487<img src=\"../Images/StateGraph/Examples/ControlledTanks1.png\">
488</p>
489<p>
490In the right part of the figure, two tanks are shown. At the top part,
491a large fluid source is present from which fluid can be filled in
492<b>tank1</b> when <b>valve1</b> is open. Tank1 can be emptied via
493<b>valve2</b> that is located in the bottom of tank2 and
494fills a second <b>tank2</b> which in turn is emptied via
495<b>valve3</b>. The actual levels of the tanks are measured
496and are provided as signals <b>level1</b> and <b>level2</b>
497to the <b>tankController</b>.
498</p>
499<p>
500The <b>tankController</b> is controlled by three buttons,
501<b>start</b>, <b>stop</b> and <b>shut</b> (for shutdown)
502that are mutually exclusive. This means that whenever one button is
503pressed (i.e., its state is <b>true</b>) then the other two
504buttons are not pressed (i.e., their states are <b>false</b>).
505When button <b>start</b> is pressed, the \"normal\" operation
506to fill and to empty the two tanks is processed:
507</p>
508<ol>
509<li> Valve 1 is opened and tank 1 is filled.</li>
510<li> When tank 1 reaches its fill level limit,
511     valve 1 is closed. </li>
512<li> After a waiting time, valve 2 is
513     opened and the fluid flows from tank 1 into tank 2.</li>
514<li> When tank 1 is empty, valve 2 is closed. </li>
515<li> After a waiting time, valve 3 is opened and
516     the fluid flows out of tank 2</li>
517<li> When tank 2 is empty, valve 3 is closed</liI>
518</ol>
519<p>
520The above \"normal\" process can be influenced by the following
521buttons:
522</p>
523<ul>
524<li> Button <b>start</b> starts the above process.
525     When this button is pressed after a \"stop\" or
526     \"shut\" operation, the process operation continues.
527     </li>.
528<li> Button <b>stop</b> stops the above process by
529     closing all valves. Then, the controller waits for
530     further input (either \"start\" or \"shut\" operation).</li>
531<li> Button <b>shut</b> is used to shutdown the process,
532     by emptying at once both tanks. When this is achieved,
533     the process goes back to its start configuration.
534     Clicking on \"start\", restarts the process.</li>
535</ul> 
536<p>
537The implementation of the <b>tankController</b> is shown in
538the next figure:
539</p>
540<p align=\"center\">
541<img src=\"../Images/StateGraph/Examples/ControlledTanks2.png\">
542</p>
543<p>
544When the \"<b>start</b>\" button is pressed, the stateGraph is
545within the CompositeStep \"<b>makeProduct</b>\". During normal
546operation this CompositeStep is only left, once tank2 is empty.
547Afterwards, the CompositeStep is at once re-entered.
548</p>
549<p>
550When the \"<b>stop</b>\" button is pressed, the \"makeProduct\"
551CompositeStep is at once terminated via the \"<b>suspend</b>\" port
552and the stateGraph waits in step \"<b>s2</b>\" for further
553commands. When the \"<b>start</b>\" button is pressed, the CompositeStep
554is re-entered via its <b>resume</b> port and the \"normal\"
555operation continues at the state where it was aborted by the
556suspend transition. If the \"<b>shut</b>\" button is pressed,
557the stateGraph waits in the \"<b>emptyTanks</b>\" step, until
558both tanks are empty and then waits at the initial step
559\"<b>s1</b>\" for further input.
560</p>
561<p>
562The opening and closing of valves is <b>not</b> directly
563defined in the stateGraph. Instead via the \"<b>setValveX</b>\"
564components, the Boolean state of the valves are computed.
565For example, the output y of \"setValve2\" is computed as:
566</p>
567<pre>
568  y = makeProduct.fillTank2.active or emptyTanks.active
569</pre>
570<p>
571i.e., valve2 is open, when step \"makeProduct.fillTank2 or when
572step \"emptyTanks\" is active. Otherwise, valve2 is closed.
573</p>
574</html>
575"));
576  end ApplicationExample;
577
578  class ReleaseNotes "Release notes"
579
580    annotation (Documentation(info="<html>
581<h4>Version 0.87, 2004-06-23</h4>
582<ul>
583<li> Included in Modelica standard library 2.0 Beta 1 with the new block connectors.
584     Changed all the references to the block connectors and the Logical library
585     correspondingly.</li>
586</ul>
587<h4>Version 0.86, 2004-06-20</h4>
588<ul>
589<li> New components \"Alternative\" and \"Parallel\" for alternative and
590     parallel execution paths.</li>
591<li> A step has now a vector of input and output connectors in order
592     that multiple connections to and from a step are possible</li>
593<li> Removed components \"AlternativeSplit\", \"AlternativeJoin\",
594     \"ParallelSplit\" and \"ParallelJoin\" since the newly introduced
595     components (\"Alternative\", \"Parallel\", vector connectors of steps)
596     have the same modeling power but are safer and more convenient.</li>
597<li> Removed the timer in a step (attach instead Logical.Timer to
598     the \"active\" port of a \"StepWithSignal\" component). Note, that in
599     most cases it is more convenient and more efficient to use the
600     built-in timer of a transition.</li>
601<li> Component \"StepInitial\" renamed to \"InitialStep\".</li>
602<li> New component \"Timer\" within sublibrary Logical.</li>
603<li> Updated and improved documentation of the library.</li>
604</ul>
605<h4>Version 0.85, 2004-06-17</h4>
606<ul>
607<li> Renamed \"MacroStep\" to \"CompositeStep\" and the ports of the MacroStep
608     from \"abort\" to \"suspend\" and \"histoy\" to \"resume\".</li>
609<li> Nested \"CompositeStep\" components are supported, based on the
610     experimental feature of nested inner/outer components
611     introduced by Dymola. This means that CompositeSteps can
612     be suspended and resumed at every level.</li>
613<li> New example \"Examples.ShowExceptions\" to demonstrate the new
614     feature of nested CompositeSteps.</li>
615<li> New package \"Logical\". It contains all components of
616     ModelicaAdditions.Blocks.Logical, but with new block connectors
617     and nicer icons. Additionally, logical blocks are also added.</li>
618<li> Improved icons for several components of the StateGraph library.</li>
619</ul>
620<h4>Version 0.83, 2004-05-21</h4>
621<ul>
622<li> The \"abort\" and \"history\" connectors are no longer visible in the
623     diagram layer of a CompositeStep since it is not allowed to connect
624     to them in a CompositeStep.</li>
625<li> Made the diagram/icon size of a CompositeStep smaller (from 200/-200 to
626     150/-150).</li>
627<li> Improved icons for \"SetBoolean/SetInteger/SetReal\" components.</li>
628<li> Renamed \"ParameterReal\" to \"SetRealParameter\".</li>
629</ul>
630<h4>Version 0.82, 2004-05-18</h4>
631<p>
632Implemented a first version that is provided to other people.
633</p>
634</html>
635"));
636  equation
637
638  end ReleaseNotes;
639
640  class Literature "Literature"
641
642    annotation (Documentation(info="<html>
643<p>
644The StateGraph library is based on the following references:
645</p>
646<dl>
647<dt>Arzen K.-E. (2004):</dt>
648<dd> <b>JGrafchart User Manual. Version 1.5</b>.
649     Department of Automatic Control, Lund Institute of Technology,
650     Lund, Sweden, Feb. 13<br>&nbsp;</dd>
651<dt>Dressler I. (2004):</dt>
652<dd> <b>Code Generation From JGrafchart to Modelica</b>.
653     Master thesis, supervisor: Karl-Erik Arzen,
654     Department of Automatic Control, Lund Institute of Technology,
655     Lund, Sweden, March 30<br>&nbsp;</dd>
656<dt>Elmqvist H., Mattsson S.E., Otter M. (2001):</dt>
657<dd> <b>Object-Oriented and Hybrid Modeling in Modelica</b>.
658     Journal Europeen des systemes automatises (JESA),
659     Volume 35 - n. 1.<br>&nbsp;</dd>
660<dt>Mosterman P., Otter M., Elmqvist H. (1998):</dt>
661<dd> <b>Modeling Petri Nets as Local Constraint Equations for
662     Hybrid Systems using Modelica</b>.
663     SCSC'98, Reno, Nevada, USA,
664     Society for Computer Simulation International, pp. 314-319.
665     </dd>
666</dl>
667</html>
668"));
669
670  end Literature;
671
672  class Contact "Contact"
673
674    annotation (Documentation(info="<html>
675<dl>
676<dt><b>Main Author:</b>
677<dd><a href=\"http://www.robotic.dlr.de/Martin.Otter/\">Martin Otter</a><br>
678    Deutsches Zentrum f&uuml;r Luft und Raumfahrt e.V. (DLR)<br>
679    Institut f&uuml;r Robotik und Mechatronik<br> 
680    Abteilung f&uuml;r Entwurfsorientierte Regelungstechnik<br>
681    Postfach 1116<br>
682    D-82230 Wessling<br>
683    Germany<br>
684    email: <A HREF=\"mailto:Martin.Otter@dlr.de\">Martin.Otter@dlr.de</A><br>
685</dl>
686<p><b>Acknowledgements:</b></p>
687<ul>
688<li> The development of this library was strongly motivated by the
689     master thesis of Isolde Dressler
690     (<a href=\"Modelica://Modelica.StateGraph.UsersGuide.Literature\">see literature</a>),
691     in which
692     a compiler from JGrafChart to Modelica was designed and
693     implemented. This project was supervised by Karl-Erik Arzen
694     from Departement of Automatic Control, Lund Institut of
695     Technology, Lund, Sweden.</li>
696<li> This library profits also from the experience gained
697     in the focused research program (Schwerpunktprogramm)
698     \"Continuous-Discrete Dynamic Systems\" (KONDISK), sponsored by the
699     Deutsche Forschungsgemeinschaft under grants OT174/1-2 and EN152/22-2.
700     This support is most gratefully acknowledged.
701 </li>
702<li> The implementation of the basic components of this library by describing
703     finite state machines with equations is based on
704     (Elmqvist, Mattsson and Otter, 2001),
705     which in turn uses ideas from (Mosterman, Otter and Elmqvist, 1998),
706     see <a href=\"Modelica://Modelica.StateGraph.UsersGuide.Literature\">literature</a></li>
707</ul>
708</html>
709"));
710
711  end Contact;
712
713end UsersGuide;
714
715package Examples
716    "Examples to demonstrate the usage of the components of the StateGraph library"
717
718  model FirstExample "A first simple StateGraph example"
719    extends Modelica.Icons.Example;
720    InitialStep initialStep annotation (Placement(transformation(extent={{-48,0},
721                {-28,20}}, rotation=0)));
722    Transition transition1(enableTimer=true, waitTime=1) 
723      annotation (Placement(transformation(extent={{-20,0},{0,20}}, rotation=0)));
724    Step step annotation (Placement(transformation(extent={{10,0},{30,20}},
725              rotation=0)));
726    Transition transition2(enableTimer=true, waitTime=1) 
727      annotation (Placement(transformation(extent={{40,0},{60,20}}, rotation=0)));
728  equation
729
730    annotation (
731      Diagram(graphics),
732      experiment(StopTime=5),
733        Documentation(info="<html>
734 
735</html>"));
736    connect(initialStep.outPort[1], transition1.inPort) 
737      annotation (Line(points={{-27.5,10},{-14,10}}, color={0,0,0}));
738
739    connect(transition1.outPort, step.inPort[1]) 
740      annotation (Line(points={{-8.5,10},{9,10}}, color={0,0,0}));
741    connect(step.outPort[1], transition2.inPort) 
742      annotation (Line(points={{30.5,10},{46,10}}, color={0,0,0}));
743    connect(transition2.outPort, initialStep.inPort[1]) annotation (Line(points=
744             {{51.5,10},{70,10},{70,32},{-62,32},{-62,10},{-49,10}}, color={0,0,
745              0}));
746  end FirstExample;
747
748  model FirstExample_Variant2
749      "A variant of the first simple StateGraph example"
750    extends Modelica.Icons.Example;
751    InitialStep initialStep annotation (Placement(transformation(extent={{-70,0},
752                {-50,20}}, rotation=0)));
753    Transition transition1(enableTimer=true, waitTime=1) 
754      annotation (Placement(transformation(extent={{-42,0},{-22,20}}, rotation=
755                0)));
756    StepWithSignal step
757              annotation (Placement(transformation(extent={{-14,0},{6,20}},
758              rotation=0)));
759    TransitionWithSignal transition2
760      annotation (Placement(transformation(extent={{52,0},{72,20}}, rotation=0)));
761    Modelica.Blocks.Logical.Timer timer annotation (Placement(transformation(
762              extent={{6,-40},{26,-20}}, rotation=0)));
763    Modelica.Blocks.Logical.GreaterEqualThreshold greaterEqual(threshold=1) 
764      annotation (Placement(transformation(extent={{36,-40},{56,-20}}, rotation=
765               0)));
766  equation
767
768    annotation (
769      Diagram(graphics),
770      experiment(StopTime=5),
771        Documentation(info="<html>
772 
773</html>"));
774    connect(initialStep.outPort[1], transition1.inPort) 
775      annotation (Line(points={{-49.5,10},{-36,10}}, color={0,0,0}));
776
777    connect(transition1.outPort, step.inPort[1]) 
778      annotation (Line(points={{-30.5,10},{-15,10}}, color={0,0,0}));
779    connect(step.active, timer.u) annotation (Line(points={{-4,-1},{-4,-30},{4,
780              -30}}, color={255,0,255}));
781    connect(step.outPort[1], transition2.inPort) 
782      annotation (Line(points={{6.5,10},{58,10}}, color={0,0,0}));
783    connect(timer.y, greaterEqual.u) 
784      annotation (Line(points={{27,-30},{34,-30}}, color={0,0,255}));
785    connect(greaterEqual.y, transition2.condition) annotation (Line(points={{57,
786              -30},{62,-30},{62,-2}}, color={255,0,255}));
787    connect(transition2.outPort, initialStep.inPort[1]) annotation (Line(points=
788             {{63.5,10},{82,10},{82,32},{-80,32},{-80,10},{-71,10}}, color={0,0,
789              0}));
790  end FirstExample_Variant2;
791
792  model FirstExample_Variant3
793      "A variant of the first simple StateGraph example"
794    extends Modelica.Icons.Example;
795    InitialStep initialStep annotation (Placement(transformation(extent={{-