The Latex to LSC Compiler

From WeizmannWiki
Revision as of 20:46, 29 May 2017 by Achiya (Talk | contribs)

Jump to: navigation, search

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:

  1. Download the PlayGo Environment.
  2. Add Latex Con-LSCs to LSC.tex.
  3. Execute the Latex2PlayGo compiler.
  4. Import the compiled file in PlayGo and execute it.

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):

(D) PlayGo_4.0_19042017
(D) playgo
(F) playgo.exe
(D) workspace
(D) Latex2Lsc
(F) LSC.tex
(F) GeneratedLSC.lsc
(D) src

Executin playgo.exe will start PlayGo.

General links:

PlayGo userguide.

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 [1].

Here we present an example for creating an LSC chart using pgf-playgo-lsc:

[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}


Compiled pgf-playgo-lsc chart

Figure 1 - The compiled Latex representation of the code on the left.

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.

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 file. Executing the compiler can be done in two ways:

  1. Compiling the file using javac and running it with java.
  2. In PlayGo - Right click the source file and choose "Run as > Java Application".


Preparing the PlayGo Project

Before we can execcute the generated LSCs, we need to prepare the project:

  1. Start PlayGo by executing playgo.exe.
  2. Refresh the project (Select the project root and press F5).
  3. On the right panel you have a window called "System Model".
  4. Locate the red X button.
  5. Press the button on the left to generate a system model from the scenarios.
  6. On the file selection window select GeneratedLSC.lsc.
  7. Click the button on the right of the red X button.
  8. 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:

  1. Main menu: PlayGo -> Play-Out -> Play-Out....
  2. Delete any model under Behaviour Unit.
  3. Now press the add model and select GeneratedLSC.
  4. 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:

  1. Run the project.
  2. In the System Model window -> Objects:
    1. Right click mSensor and select "Call other object".
    2. Right click office and select "motionStopperd".


  1. T. Tantau and C. Feuersnger, “pgf—Create PostScript and PDF graphics in TEX,” Version 3.01a, 08 2015. [Online]. Available:
  2. X. Yuan, “pgf-umlsd—Draw UML Sequence Diagrams,” Version 0.7, 02 2014. [Online]. Available: