Genericity
This page describes genericity and its support in MetaDepth, to be inspected at the discretion of the reviewers of MODELS'10. The MetaDepth version needed can be downloaded here (please note that it is not the version in the download page). You can also download all files from the submmitted paper here. Decompress this zip in the same directory as the metaDepth jar. To run MetaDepth simply type "java -jar metaDepth.jar" on the command line. For a short tutorial on the use of MetaDepth go to the Documentation section.
MetaDepth support for genericity is based on generic concepts. A concept can be used to: (i) define behaviours on the generic types of the concept, (ii) bind the concept against a model or meta-model, (iii) use the concept to constrain the parameters of a template. EOL behaviors can now be based on concrete types, on generic types found in a concept, or on generic types in templates. The following are practical examples of the use of genericity:
- Petri nets. You can load the PetriNet
meta-model by typing load "PetriNet". To check that it was loaded correctly, type dump. Now the meta-model can
be instantiated, the producer consumer example can be found at ProducerConsumer.mdepth,
and can be loaded with load "ProducerConsumer". Now, the instance can be simulated. You can load the EOL
simulator by typing load EOL "PetriNetSim". The simulator can be found here.
Altogether, the following listing shows the commands you need to execute, at any point you can inspect the models with dump,
and enter/exit the context of models with context name:
load "PetriNet" load "ProducerConsumer" load EOL "PetriNetSim" - Token Holder Semantics. The Petri nets semantics can be lifted to a concept.
For this purpose, you can load the TokenHolder concept by typing
load "TokenHolder". Then, load the PetriNet meta-model again, and check that it is actually a bind for the concept.
You can do it with the command bind, you will find the necessary command
here. Load it by typing load "bindPetriNetTokenHolder".
Then, load the ProducerConsumer PetriNet, and simulate it with the
TokenHolder simulator. This simulator lifts the Petri net simulator by
using the generic types of the concept. Altogether the following listing shows the commands you need to execute:
load "TokenHolder" load "PetriNet" load "bindPetriNetTokenHolder" load "ProducerConsumer" load EOL "TokenHolderSim"
Having defined this concept, it is applicable to any meta-model fulfilling its requirement. For example, you can try loading the ProductionSystem metamodel (a DSL containing machines, conveyors and parts), a Factory model with a generator of pieces, an assembly machine and a packaging machine. You can bind the ProductionSystem meta-model, and then simulate the Factory with the same TokenHolder simulator. Please note that concepts help lifting the definition of semantics and to build families of meta-models sharing a common semantics.load "TokenHolder" load "ProductionSystem" load "Factory" load "bindProductionSystemTokenHolder" load EOL "TokenHolderSim" - Model Templates. Templates at the model level help in making models modular
and to define modelling patterns. For example, this file contains
Petri net components for the modular definition of the Producer/Consumer system. Hence, you can load the PetriNet meta-model
by typing load "PetriNet", and then load the component definitions
with load "ProducerConsumerTemplate". You can inspect the models in memory with dump, to see the internals
of a template instance, you have to enter its context. For example, you can type context ProdCons, and then dump.
Now you can simulate the system with load EOL "PetriNetSim".
load "PetriNet" load "ProducerConsumerTemplate" context ProdCons load EOL "PetriNetSim" - Meta-Model Templates and Semantic Mixin Layers. Sometimes a DSL needs a certain
infrastructure for its simulation. This infrastructure is not part of the language, but of the simulator. Meta-Model templates
can be used to incorporate this infrastructure to any meta-model fulfilling certain requirements. Hence, we can define a generic
behaviour on the types of the template. We call this a semantic mixin layer.
As an example, assume we want to simulate timed token-holder instances, where processes (transitions) do not fire immediatelly, but after a delay. The simulator needs to hold the list of scheduled events, ordered by simulation time. In addition, each event should point to the associated process. We can define a mixin layer to provide such infrasttructure to meta-models. This time for comodity, the complete example is in this file. Once you have loaded the file, go to the context TFactory, and simulate it with the simulator for TimedSched mixins.load "TimedSched" context TFactory load EOL "TimedSchedSim"
- [FSAconcept.mdepth] is a modular definition of a Finite State Automaton, where the automaton is independent of the alphabet used. So we can freely exchange the alphabet but keep the same automaton. The FSA simulator can be found here