Difference between revisions of "The Latex to LSC Compiler"
(51 intermediate revisions by one user not shown) | |||
Line 13: | Line 13: | ||
After extracting the zip file you will find the following directory structure (the structure includes only directories relevant to this tutorial). Directories are marked with (D) and files with (F): | After extracting the zip file you will find the following directory structure (the structure includes only directories relevant to this tutorial). Directories are marked with (D) and files with (F): | ||
+ | <div><span style="font-family:courier new,courier,monospace;">(D) PlayGo_4.0_19042017</span></div><div style="margin-left: 40px;"><span style="font-family:courier new,courier,monospace;">|</span></div><div style="margin-left: 40px;"><span style="font-family:courier new,courier,monospace;">(D) playgo</span></div><div style="margin-left: 80px;"><span style="font-family:courier new,courier,monospace;">|</span></div><div style="margin-left: 80px;"><span style="font-family:courier new,courier,monospace;">(F) playgo.exe</span></div><div style="margin-left: 40px;"><span style="font-family:courier new,courier,monospace;">(D) workspace</span></div><div style="margin-left: 80px;"><span style="font-family:courier new,courier,monospace;">|</span></div><div style="margin-left: 80px;"><span style="font-family:courier new,courier,monospace;">(D) Latex2Lsc</span></div><div style="margin-left: 120px;"><span style="font-family:courier new,courier,monospace;">|</span></div><div style="margin-left: 120px;"><span style="font-family:courier new,courier,monospace;">(F) LSC.tex</span></div><div style="margin-left: 120px;"><span style="font-family:courier new,courier,monospace;">(F) GeneratedLSC.lsc</span></div><div style="margin-left: 120px;"><span style="font-family:courier new,courier,monospace;">(D) src</span></div><div style="margin-left: 160px;"><span style="font-family:courier new,courier,monospace;">|</span></div><div style="margin-left: 160px;"><span style="font-family:courier new,courier,monospace;">(F) Latex2PlayGoCompiler.java</span></div> | ||
+ | <br/>Executin playgo.exe will start PlayGo. | ||
− | + | == General links: == | |
− | + | [https://weizmann.box.com/s/irjrbvlipdol1vm64v0kf7uju00lqzn1 PlayGo userguide]. | |
− | + | [http://wiki.weizmann.ac.il/playgo/index.php/Main_Page PlayGo homepage] - more information and tutorials. | |
− | + | = Latex Con-LSC = | |
− | + | == The Latex Con-LSC Language == | |
− | + | Our group has developed a dedicated Latex package for easily creating diagrams with a simple textual notation, and presenting them graphically. | |
− | < | + | The package, called '''pgf-playgo-lsc''', is built upon the ''pgf<ref>T. Tantau and C. Feuersnger, “pgf—Create PostScript and PDF graphics in TEX,” Version 3.01a, 08 2015. [Online]. Available: https://www.ctan.org/pkg/pgf</ref>'' and ''pgf-uml''<ref>X. Yuan, “pgf-umlsd—Draw UML Sequence Diagrams,” Version 0.7, 02 2014. [Online]. Available: https://www.ctan.org/pkg/pgf-umlsd</ref> packages. The package imlements only part of the PlayGo LSC idioms. The complete list of the supported idioms in Latex Con-LSC is given in the package manual. The language semantics is defined in the [https://weizmann.box.com/s/irjrbvlipdol1vm64v0kf7uju00lqzn1 PlayGo userguide], except for the context idioms that are given in the paper. |
− | + | The package repository and download link can be found at [http://github.com/eggsterino/pgf-playgo-lsc http://github.com/eggsterino/pgf-playgo-lsc]. | |
− | + | Here we present an example for creating an LSC chart using pgf-playgo-lsc: | |
− | < | + | {| cellspacing="1" cellpadding="1" style="border-top: 1px solid; border-left: 0px; border-right: 0px; border-bottom: 1px solid;width: 600px" |
+ | |- | ||
+ | | style="vertical-align: top; width: 520px; border:none;" | <div>\begin{LSCnameddiagram}</div><div style="margin-left: 80px;">[title width=p{65px}]<br/></div><div style="margin-left: 80px;">{Turn lights off when motion has stopped}</div><div style="margin-left: 80px;"><br/></div><div style="margin-left: 40px;">\newlifeline {light} {light}</div><div style="margin-left: 40px;">\newlifeline {office} {office}</div><div style="margin-left: 40px;">\newlifeline {mSensor} {mSensor}</div><div style="margin-left: 40px;"><br/></div><div style="margin-left: 40px;"></div><div style="margin-left: 40px;">\coldmonitor {mSensor} {motionStopped()} {office}</div><div style="margin-left: 40px;">\hotexecute {office} {setOff()} {light}</div><div style="margin-left: 40px;"><br/></div><div>\end{LSCnameddiagram}</div> | ||
+ | | style="border: none; vertical-align: middle;" | | ||
+ | [[File:Latex-LSC.jpg|200px|Compiled pgf-playgo-lsc chart]] | ||
− | + | Figure 1 - The compiled Latex representation of the code on the left. | |
− | < | + | |} |
+ | <div></div><div><br/></div><div>Please note that the LSC.tex file must have at least one LSC diagram. Also, no Latex command should appear outside the \begin \end scope.</div> | ||
− | + | == The Latex2PlayGo Compiler == | |
− | + | The Latex2PlayGo Compiler takes the Latex charts given in the LSC.tex file and compiles them to a PlayGo LSC file named GeneratedLSC.lsc. The compiler source code is the Latex2PlayGoCompiler.java file. Executing the compiler can be done in two ways: | |
− | + | #Compiling the file using ''javac'' and running it with ''java''. | |
+ | #In PlayGo - Right click the source file and choose "Run as > Java Application". | ||
− | = | + | = PlayGo = |
− | + | == Preparing the PlayGo Project == | |
− | + | Before we can execcute the generated LSCs, we need to prepare the project: | |
− | = | + | #Start PlayGo by executing playgo.exe. |
+ | #Refresh the project (Select the project root and press F5). | ||
+ | #On the right panel you have a window called "System Model". | ||
+ | #Locate the red X button. | ||
+ | #Press the button on the left to generate a system model from the scenarios. | ||
+ | #On the file selection window select GeneratedLSC.lsc. | ||
+ | #Click the button on the right of the red X button. | ||
+ | #Refresh the project (In the Package Explorer window: Right click on project name and then select Refresh) | ||
+ | |||
+ | The project is ready for a run. | ||
+ | |||
+ | == Running the Project == | ||
+ | |||
+ | Required steps: | ||
+ | |||
+ | #Main menu: PlayGo -> Play-Out -> Play-Out.... | ||
+ | #Delete any model under Behaviour Unit. | ||
+ | #Now press the add model and select GeneratedLSC. | ||
+ | #Press OK | ||
+ | |||
+ | Now you will notice that nothing happens. The reason is that due to a language requirement, each diagram starts with a monitor event. In the above example: the motionStopped() will be triggered only if the system (i.e. the sensor) will trigger the event. For the purpose of simulations and testings, PlayGo allows simulating system and user events from one lifeline to another. | ||
+ | |||
+ | For example, let us assume that we want to trigger the motionStopped event. In order to do so we neet to: | ||
+ | |||
+ | #Run the project. | ||
+ | #In the System Model window -> Objects: | ||
+ | ##Right click mSensor and select "Call other object". | ||
+ | ##Right click office and select "motionStopperd". | ||
+ | |||
+ | = References = | ||
+ | |||
+ | <references /> |
Latest revision as of 17:51, 29 May 2017
This page explains how to write Contextul LSCs (Con-LSC) in Latex, compile them into PlayGo LSC instances, and finally execute them.
In nutshell, these are the required steps:
- Download the PlayGo Environment.
- Add Latex Con-LSCs to LSC.tex.
- Execute the Latex2PlayGo compiler.
- Import the compiled file in PlayGo and execute it.
Contents
The PlayGo Environment
First you need to download (here) a PlayGo version that includes a template project and the Latex2PlayGo compiler.
After extracting the zip file you will find the following directory structure (the structure includes only directories relevant to this tutorial). Directories are marked with (D) and files with (F):
Executin playgo.exe will start PlayGo.
General links:
PlayGo homepage - more information and tutorials.
Latex Con-LSC
The Latex Con-LSC Language
Our group has developed a dedicated Latex package for easily creating diagrams with a simple textual notation, and presenting them graphically.
The package, called pgf-playgo-lsc, is built upon the pgf[1] and pgf-uml[2] packages. The package imlements only part of the PlayGo LSC idioms. The complete list of the supported idioms in Latex Con-LSC is given in the package manual. The language semantics is defined in the PlayGo userguide, except for the context idioms that are given in the paper.
The package repository and download link can be found at http://github.com/eggsterino/pgf-playgo-lsc.
Here we present an example for creating an LSC chart using pgf-playgo-lsc:
\begin{LSCnameddiagram} [title width=p{65px}] {Turn lights off when motion has stopped} \newlifeline {light} {light} \newlifeline {office} {office} \newlifeline {mSensor} {mSensor} \coldmonitor {mSensor} {motionStopped()} {office} \hotexecute {office} {setOff()} {light} \end{LSCnameddiagram}
|
Figure 1 - The compiled Latex representation of the code on the left. |
The Latex2PlayGo Compiler
The Latex2PlayGo Compiler takes the Latex charts given in the LSC.tex file and compiles them to a PlayGo LSC file named GeneratedLSC.lsc. The compiler source code is the Latex2PlayGoCompiler.java file. Executing the compiler can be done in two ways:
- Compiling the file using javac and running it with java.
- In PlayGo - Right click the source file and choose "Run as > Java Application".
PlayGo
Preparing the PlayGo Project
Before we can execcute the generated LSCs, we need to prepare the project:
- Start PlayGo by executing playgo.exe.
- Refresh the project (Select the project root and press F5).
- On the right panel you have a window called "System Model".
- Locate the red X button.
- Press the button on the left to generate a system model from the scenarios.
- On the file selection window select GeneratedLSC.lsc.
- Click the button on the right of the red X button.
- Refresh the project (In the Package Explorer window: Right click on project name and then select Refresh)
The project is ready for a run.
Running the Project
Required steps:
- Main menu: PlayGo -> Play-Out -> Play-Out....
- Delete any model under Behaviour Unit.
- Now press the add model and select GeneratedLSC.
- Press OK
Now you will notice that nothing happens. The reason is that due to a language requirement, each diagram starts with a monitor event. In the above example: the motionStopped() will be triggered only if the system (i.e. the sensor) will trigger the event. For the purpose of simulations and testings, PlayGo allows simulating system and user events from one lifeline to another.
For example, let us assume that we want to trigger the motionStopped event. In order to do so we neet to:
- Run the project.
- In the System Model window -> Objects:
- Right click mSensor and select "Call other object".
- Right click office and select "motionStopperd".
References
- ↑ T. Tantau and C. Feuersnger, “pgf—Create PostScript and PDF graphics in TEX,” Version 3.01a, 08 2015. [Online]. Available: https://www.ctan.org/pkg/pgf
- ↑ X. Yuan, “pgf-umlsd—Draw UML Sequence Diagrams,” Version 0.7, 02 2014. [Online]. Available: https://www.ctan.org/pkg/pgf-umlsd