CentraleSupélec LMF, UMR CNRS 9021
Département informatique Laboratoire Méthodes Formelles
Bât Breguet, 3 rue Joliot-Curie Bât 650 Ada Lovelace, Université Paris Sud
91190 Gif-sur-Yvette, France Rue Noetzlin, 91190 Gif-sur-Yvette, France
Résultats du 4 décembre 2019

Archive des trois projets à importer (Import > General > Existing projects into workspace > Select archive file).

Le métamodèle des automates

L'instance utilisée pour les tests

<?xml version="1.0" encoding="ASCII"?>
<stateMachine:StateMachine
    xmi:version="2.0"
    xmlns:xmi="http://www.omg.org/XMI"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:stateMachine="http://www.example.org/stateMachine"
    xsi:schemaLocation="http://www.example.org/stateMachine stateMachine.ecore"
    name="machine">
  <states name="A"
      isInitial="true">
    <transitions
        guard="//@inputs.0"
        output="//@outputs.0"
        target="//@states.1"/>
  </states>
  <states name="B">
    <transitions
        guard="//@inputs.1"
        output="//@outputs.1"
        target="//@states.0"/>
  </states>
  <inputs name="a"/>
  <inputs name="b"/>
  <outputs name="x"/>
  <outputs name="y"/>
</stateMachine:StateMachine>

Le métamodèle objet

La transformation QVT operational

modeltype FSM "strict" uses stateMachine('http://www.example.org/stateMachine');
modeltype OBJ "strict" uses objectModel('http://www.example.org/objectModel');

transformation Machine2Object(in fsm:FSM, out obj:OBJ);

main() {
  fsm.rootObjects()[StateMachine]->map toObject();
}

mapping StateMachine::toObject() : FSMClass {
  // Fail is the state machine does not have exactly one initial state.
  assert(self.states->select(s | s.isInitial)->size() = 1)
    with log ("Erreur état initial");
  result.name := self.name ;
  result.states := self.states->map toObject();
  result.initialState := self.states->select(s | s.isInitial).resolveoneIn(State::toObject); 
}

mapping State::toObject() : StateClass {
	result.name := self.name;
	result.transitions := self.transitions->map toObject() ;
}

mapping Transition::toObject() : TransitionClass {
	result.guard := self.guard.name;
	result.action := self.output.name;
	result.target := self.target.late resolveoneIn(State::toObject);
}