Skip to content
Dimitris Kolovos edited this page Apr 12, 2017 · 43 revisions

Welcome

Welcome to the Epsilon's PTC Integrity Modeler wiki. This wiki provides instructions on how to install the Epsilon EMC driver for accessing PTC IM models in Eclipse. Use the menu below to navigate to the desired section. For first-time visitors, we suggest starting with section "How to install and run Epsilon with PTC Integrity Modeler support" and then proceeding to the tutorials provided in section "How to create and run a new script".

How to install and run Epsilon with PTC Integrity Modeler support

Install Eclipse with Modelling Tools

You need to download and install a copy of the Eclipse Modeling Distribution. For this driver you need to download the Windows 32-bit installation. You can download the Mars version of the Eclipse Modeling Distribution here.

Extract the contents of the zip archive to a place in your hard disk. File eclipse.exe used to run the Eclipse IDE. In the first screen you will be asked to select a workspace in your hard disk where your projects will be (or are) stored.

Install Epsilon

You need to install the Epsilon suite in the Eclipse IDE you've downloaded.

  1. Run Eclipse by navigating to the folder where you had the zip file extracted and run the "eclipse.exe" file.
  2. Select the workspace.
  3. Navigate to Help --> Install new software... from the top menu.
  4. In the window that opens click the "Add..." button.
  5. From the next screen select the Epsilon Core and Epsilon Core Development Tools packages for installation as shown in the screenshot below. Click Next.
  6. Click Next in the next screen.
  7. Accept the license agreement and click Finish.
  8. Eclipse will install Epsilon and will ask you to accept installation from unsigned sources. Click OK and when prompted to restart click yes.

NB: Epsilon requires Java to be installed. You need to download and install a 32-bit Java version (JRE or JDK) to work with PTC models. Download Java from here. Step by step instructions on how to install Java are available from Oracle's website here.

Install the PTC Integrity Modeler (IM) driver

Before using Epsilon to access your PTC IM models you need to install the PTC IM driver for Epsilon. Step by step instructions follow.

  1. Run Eclipse by navigating to the folder where you had the zip file extracted and run the "eclipse.exe" file.
  2. Select the workspace.
  3. Navigate to Help --> Install new software... from the top menu.
  4. In the window that opens click the "Add..." button.
  5. From the next screen select the Epsilon PTC IM Driver package for installation as shown in the screenshot below. Click Next.
  6. Click Next in the next screen.
  7. Accept the license agreement and click Finish.
  8. Eclipse will install Epsilon and will ask you to accept installation from unsigned sources. Click OK and when prompted to restart click yes.

How to run Eclipse with Epsilon and PTC IM support

Double click the eclipse.exe file located in the folder you have extracted the Eclipse zip archive. Select your workspace. Assuming you have Eclipse, Epsilon and the PTC IM driver installed as described in the previous steps) you are ready to create new projects and Epsilon scripts to manage your models.

How to create and run a new script

Epsilon consists of a number of model management languages each of which offers different model management functionality. For example, the Epsilon Generation Language (EGL) can be used to generate textual artefacts (e.g. code) from models. The base (core) language of Epsilon is the Epsilon Object Language (EOL) and all other languages in Epsilon use it as an embedded expression language. The are many languages available in Epsilon, among others the Epsilon Validation Language (EVL) for check constraints in models, the Epsilon Transformation Language (ETL) for model-to-model transformation, the Epsilon Merging Language (EML) for model merging, etc. The Epsilon website and the Epsilon Book contain a complete list of the available Epsilon languages, documentation and examples.

Create a project

Before you can create an Epsilon script you need to create a Project.

  1. Open Eclipse and click File --> New --> Project...
  2. From the window that opens expand the General folder and select Project.
  3. Click Next.
  4. Give a name to your project (e.g. MyProject) and click Finish.

Create and run an EOL script

As EOL is the core language of Epsilon and is reused in all other languages of the platform, the first tutorial will be on how to create and run an EOL script to query a model.

  1. Create a new EOL file.

    • Click File --> New --> Other...
    • Navigate to the Epsilon folder in the wizard and select the EOL Program entry. Click Next.
    • Select the project where the script should be saved (e.g. MyProject) and give a name to the script (e.g. myEOLScript.eol).
    • Click Finish. The script file is created.
  2. Start writing commands to query your models. For example, the following script gets all the elements of type Class in the model and prints their names (property/attribute name of the element).

     	var allClasses = Class.all();
     	("Number of classes: " + allClasses.size()).println();
     	for (c in allClasses) {
     		c.name.println();
     	} 
    

The method all() returns all the elements of the preceding type. The method size() returns the size of the collection. The attribute name of the elements is accessed by typing the .name command after the element. All the available methods along with examples can be found at the Epsilon Book and the Epsilon website.

  1. Run the script by creating a Run Configuration.
    • Right click on the script file under the project and select Run As --> Run configurations...

    • From the wizard that opens double click on the EOL Program entry in the list on the left to create a new run configuration for your script.

    • Click on the run configuration generated under the EOL Program entry (this should have the name of your script filename (e.g. myEOLScript).

    • On the right panel navigate to the Models tab.

    • Click the Add... button.

    • Select the PTC IM Model entry as shown in the screenshot below.

    • A new window opens where model information should be provided as shown in the screenshot below.

      • Name: The name that will be used to refer to the model in Epsilon scripts. This is only useful when a script needs to access more than one models at the same time. If all other cases, any name (e.g. M) should do.

      • Reference: The model as this appears in the Model Explorer in PTC IM. This should be populated by clicking the Open Model button (See screenshot below). The Server, Repository and Version fields are populated automatically.

      • If you don't want to run the script on the whole model but just on a specific element (and its descendants) then click the Select element as root. If you know the id of the element you can directly type it in the Id of the root element field. if not, open the model in the Integrity Modeler and select the desired root element. Return to the run configuration window and click the Find ID button to automatically retrieve the id of the selected element.

      • Click OK.

    • Click Apply and Run.

    • The results of running the script on the model should be presented in the Console view of Eclipse as shown below. You can open the Console view in case it is not visible by navigating to Window --> Show View --> Console.

Download an example that queries the Traffic Lights example model provided by PTC IM from here.

Create and run an EVL script

EVL is a language for expressing validation constraints for models. The following instructions describe the creation and execution of an EVL script.

  1. Create a new EVL file.

    • Click File --> New --> Other...
    • Navigate to the Epsilon folder in the wizard and select the EVL Validation entry. Click Next.
    • Select the project where the script should be saved (e.g. MyProject) and give a new to the script (e.g. myEVLScript.evl).
    • Click Finish. The script file is created.
  2. Start writing constraints and critiques to run against your models. When violated, a critique produces a warning while a constraint produces an error. The following script checks that all the elements of type Class in the model have a name (property/attribute name of the element). As a constraint, it will raise errors for all the Classes that violate the rule.

     context Class {
     	constraint HasName {
     		check: self.name <> ""
     		message: "Class " + self + " does not have a name."
     	} 
     }
    

    The context Class statement defines the elements which the script will be run against (in this case, all elements of type Class). The check statement defines the rule (the name of the current assessed - self - element is not an empty string). The message statement defines the (error/warning) message that should be provided to the user when a specific element violates the rule. Constraints/critiques can be more complex and include guards and fixes like the one that follows:

     context Class {
     	critique NameShouldStartWithUpperCase {
     		guard : self.satisfies("HasName")
     	    
     	    check : self.name.substring(0,1) = self.name.substring(0,1).toUpperCase()
     	    
     	    message : "The name of class " + self.name + " should start with an upper-case letter"
     	  	
     		fix {
     			title : "Rename class " + self.name + " to " + self.name.firstToUpperCase()
     		do {
     			self.name = self.name.firstToUpperCase();
     		   }
             }
     	}
     }
    

    This critique checks if the name of a Class element starts with an uppercase setter. The guard defines another rule that it is a prerequisite for this critique (a Class should have a non-empty name to start with for this critique to be meaningful). The fix proposes a solution to the user through the user interface (title statement) and executes a block of EOL statements if selected (do statement). All the available methods along with examples of EVL can be found in the Epsilon Book and the Epsilon website.

  3. Run the script by creating a Run Configuration.

    • Right click on the script file under the project and select Run As --> Run configurations...

    • From the wizard that opens double click on the EVL Validation entry in the list on the left to create a new run configuration for your script.

    • Click on the run configuration generated under the EVL Validation entry (this should have the name of your script filename (e.g. myEVLScript).

    • On the right panel navigate to the Models tab.

    • Click the Add... button.

    • Select the PTC IM Model entry as shown in the screenshot below.

    • A new window opens where model information should be provided as shown in the screenshot below.

      • Name: The name of the model that will be used in Epsilon Scripts (e.g. M)

      • Reference: The model as this appears in the Model Explorer in PTC IM. This should be populated by clicking the Open Model button (See screenshot below). The Server, Repository and Version fields are populated automatically.

      • If you don't want to run the script on the whole model but just on a specific element (and its descendants) then click the Select element as root. If you know the id of the element you can directly type it in the Id of the root element field. if not, open the model in the Integrity Modeler and select the desired root element. Return to the run configuration window and click the Find ID button to automatically retrieve the id of the selected element.

      • Click OK.

    • Click Apply and Run.

    • The results of running the script on the model should be presented in the Validation view of Eclipse as shown below. You can open the Validation view in case it is not visible by navigating to Window --> Show View --> Other --> Validation (located in the Epsilon folder).

  4. To identify the element that caused a constraint/critique to fail the user can double click on an error/warning. This will open the PTC IM and select the element on the diagram/project automatically.

NB: By default, an EVL script will produce no output if no constraint is failed. If models are large and/or the script contains a lot of constraints/critiques then the script might take a bit of time to execute. A good practice to find when the script has finished running is to add a post statement at the end of your EVL file to print a message (e.g. Validation finished), as shown below. This message is printed in the Console view (not in the Validation view).