4.2. Define DSE

The purpose of the DSE project is to define events (called DSE) on AS elements that will trigger EF calls when they occurs. Furthermore, constraints can be defined on these events to define when they may occur.

4.2.1. Create the DSE Project

Like for the DSA Project, right click on any file of the xDSML project and choose GEMOC Languge > Create DSE Project for language to start the wizard.

Create a DSE Project

Figure 4.6. Create a DSE Project


Then :

  1. Select the MarkedGraphL language and click OK.
  2. On the next screen of the wizard, click Next (the project name is already initialized org.gemoc.sample.markedgraph.dse).
  3. On the last screen, complete the required fields:

    • The MarkedGraph Ecore file has already been initialized, just click on Browse.
    • Select the root container : MarkedGraph::MarkedGraph
    • Set the New ECL file basename is already set to 'MarkedGraphL'
Initializing the DSE project

Figure 4.7. Initializing the DSE project


Once the wizard has been completed, the org.gemoc.sample.markedgraph.dse project is created with a template for the MarkedGraphL.ecl file (found in the ecl directory).

Template of the ECL file

Figure 4.8. Template of the ECL file


4.2.2. Define DSE

Replace the content of the ECL file with the following code (explanations on this code are given bellow):

The file MarkedGraphL.ecl. 

import 'platform:/resource/org.gemoc.sample.markedgraph.model/model/markedgraph.ecore'

ECLimport "platform:/plugin/fr.inria.aoste.timesquare.ccslkernel.model/ccsllibrary/kernel.ccslLib"
ECLimport "platform:/plugin/fr.inria.aoste.timesquare.ccslkernel.model/ccsllibrary/CCSL.ccslLib"

package markedgraph

	context MarkedGraph
		def: initIt: Event = self.initialize()

	context Transition
		def: fireIt: Event = self.fire()

	context Place
		inv tokenCountIsNull:
			(self.tokenCount = 0) implies
				(Relation Precedes(self.input.fireIt, self.output.fireIt))
		inv tokenCountIsNotNullDelayRequired:
			(self.tokenCount > 0) implies
				let delay: Integer = self.tokenCount in
				let outputDelayed: Event =
					Expression DelayFor(self.output.fireIt, self.output.fireIt, delay) in
						Relation Precedes(self.input.fireIt, outputDelayed)

	context MarkedGraph
        inv initFirst:
                let firstInit : Event = Expression OneTickAndNoMore(self.initIt) in
                let allFire : Event = Expression Union(self.transitions.fireIt) in
                let firstOfAllFire : Event = Expression OneTickAndNoMore(allFire) in
                Relation Precedes(firstInit, firstOfAllFire)

        inv onlyOneInit:
                let firstInit2 : Event = Expression OneTickAndNoMore(self.initIt) in
                Relation Coincides(self.initIt, firstInit2)

endpackage

Definition of the DSE (events and constraints)

Figure 4.9. Definition of the DSE (events and constraints)


This step has three main purposes:

  1. First, it specifies DSE in the context of metaclasses of the AS. For Marked Graph xDSML, we identify 2 DSE:

    • fireIt: defined in the context of a Transition
    • initIt: defined in the context of a MarkedGraph
  2. Then, it links them to EF from DSA --- when a DSE will occur the associated EF will be executed.

    • fireIt is linked to the EF 'fire' of Transition
    • initIt is linked to the EF 'initialize' of MarkedGraph
  3. Finally, it defines constraints on the DSE to rule the possible scheduling. Constraints generally rely on relations which are defined in MoCC libraries. Here constraints are expressed in CCSL and only relies on relations and expression from the CCSL core library.

    • A first constraint applies on the fireIt events. It is depends on the number of token in a place. Indeed, if there is no tokens, then the fireIt of the output transition can only occur after the fireIt event of the input transition has occured. It is expressed by the first invariant defined in the context of a Place. If there is some tokens in a place, then the fireIt event of the output transition may occur as many times as there is tokens in this place. After, it will only occur when the fireIt on the input transition of the place has occured. It is expressed using the DelayFor expression in the second envariant of Place.
    • Two other constraints are defined in the context of the MarkedGraph element. The first one expresses that the first initIt event must occur before any fireIt event. The second one expresses that the initIt event can occur only one time.

Note

Please notice that, as often, DSE are defined at the language level, but at runtime they are instantiated as MSE on each object instance of the metaclasse they are defined on. For example, there will be one fireIt MSE for each Transition element of MarkedGraph model. For the wikipedia example, there will a fireIt event for transitions t1, t2, t3 and t4. In the same way, constraints apply to the MSE.