How to create a system model

From WeizmannWiki
Jump to: navigation, search

The System Model provides details on the classes and objects that participate in the LSCs. Once defined, the system model can be used for playing in a specification and for playing out the resulting application.

A system model can be created manually from the 'System Model' view, or by importing it from a set of LSCs.

Create system model manually

Using the 'System Model' view, you can manually create the classes and objects participating in the LSCs. As a result, the corresponding Java code will be generated. The generated code is used for play-out.

System model class

To define a system model class, select the 'Classes' tab, right-click the 'Classes'entry and select 'Add Class':

SystemModel.addClass.png

The 'System Model Class' dialog will open:

SystemModel.addClassDialog.png

  • Name - The name of the new class.
  • Extends - The class that the new class extends; e.g., if the class represents a button that should be displayed in a GUI, it can extend the Swing button implementation, javax.swing.JButton. This field can be left empty, if the class does not extend any other class.
  • GUI - Mark this flag in case you intend to show the class in a GUI.
  • Create Object - If checked upon creation of the class, an object of the type of this class will be created. This object appears in the Objects tab and can be updated or removed. The default name that is given to this object is the name of the class with the first letter in lowercase. If an object with that name already exists in the system model, PlayGo will add an "_X" suffix to the object name, where X starts with 0 and increases until PlayGo finds a name of an object that does not yet exist in the system model. Uncheck this field if you do not want to automatically create an object for the newly created class.


To remove a class from the system model, select the class to be removed, right-click it and select 'Remove':


SystemModel.classRemove.png


As a result, the class will be removed, as well as all the objects of that class type.

Add method

To define a method for an existing class, select the class, right-click it and chose 'Add Method':

SystemModel.classAddMethod.png

As a result, the 'System Model Method' dialog will open:

SystemModel.classAddMethod.jpg

  • Name - The name of the new method.
  • Arguments - The types of the input arguments that the method expects to recieve. If several arguments are desired, they should be separated by commas.
  • Return Type - The return type of the method. If not specified, it is assumed that the method return type is void.
  • Class - The class that this method belongs to. This field is disabled, and appears here for documentation purposes.
  • Call Super - If checked, the generated Java code for this method will include a call to the corresponding method in the super class.
  • Action on Property - This field is important when using a synthesis strategy for play-out. For synthesis purposes it is important to know which property this method changes (specified in the next field) and what kind of operation it carries out: sets the property value, increments its value or decrements it.
  • Changed Property - This field is important when using a synthesis strategy for play-out. For synthesis purposes it is important to know which property this method changes.

Add property

To define a property for an existing class, select the class, right-click it and chose 'Add Property':

SystemModel.classAddProperty.jpg

As a result the 'System Model Property' dialog will open:

SystemModel.classAddPropertyDialog.jpg

  • Name - The name of the property
  • Type - The Jave type of the property (e.g., String). The basic supported types are available in the drop-down menu.
  • Default Value - Enter here the default value of the property (e.g., open).
  • Class - The class that this property belongs to. This field is disabled, and appears here for documentation purposes.

System model object

To define a system model object, select the 'Objects' tab, right-click the 'Objects' entry and select 'Add Object':

SystemModel.addObject.jpg

As a result, the 'System Model Object' dialog will open:

SystemModel.addObjectDialog.jpg

  • Represents - The name of the class this object represents.
  • Name - The name of the object. Note that this should be a valid Java identifer.
  • Change icon: Setting this field will effect the way the lifeline representing the object will appear in LSCs. 


To remove an object from the system model, select the object to be removed, right-click it and select 'Remove':

SystemModel.objectRemove.jpg


You can update the object's name by right-clicking the object and selecting 'Update':

SystemModel.objectUpdate.jpg

Add method

You can add a method to the class represented by this object by right-clicking the object and selecting 'Add Method'. As a result the 'System Model Method' dialog will open. Refer to how to add a method to a system model class for details on this dialog.

Add property

You can add a property to the class represented by this object by right-clicking the object and selecting 'Add Property'. As a result the 'System Model Property' dialog will open. Refer to how to add a property to a system model class for details on this dialog.

Import system model from LSCs

You can create a system model by importing a file containing LSCs. The LSCs are analyzed automatically and the corresponding classes and objects participating in the imported LSCs are added to the system model.

The system model is enriched with the imported classes and objects; i.e., classes and objects that may already appear in your system model will be retained. If the imported file contains a class with a name that exists in the system model, the existing class will be enriched with new elements defined in the imported class.

To import a system model from LSC file, click the 'Import System Model from Model File' icon on the 'System Model' view toolbar:

SystemModel.importFromModelFile.jpg

A file chooser dialog will open, allowing you to choose the model file to import. Choose the model file and click 'OK'. As a result, the classes and objects that are defined in the model file, including their methods and properties, will be added to the system model, and the corresponding Java code will be generated.


Note that when importing a model file, PlayGo does not parse opaque expressions that may be included in the file. This means that if the LSC contains an opaque-expression-based condition (e.g., heater.getTemperature().equals("24")), the expression is not parsed, and so the properties participating in this condition (e.g. temperature) may not appear in the imported class (e.g., the heater object may not include the property temperature).