Open dvojtise opened 6 years ago
From @zzhang03 on November 29, 2017 9:34
The error message is as follows: Error occured when starting execution engine: railway.Position cannot be cast to org.ttc.railway.xsrail.xsrail.railway.Position (see inner exception).
and the code reporting this error is at org.ttc.railway.xsrail.xsrail.railway.impl.SwitchPositionImpl.eSet(SwitchPositionImpl.java:300) This is in the project which is corresponding to org.gemoc.sample.legacyfsm.xsfsm.xsfsm in FSM example The code section is: @Override public void eSet(int featureID, Object newValue) { switch (featureID) { ... case RailwayPackage.SWITCH_POSITION__POSITION: setPosition((Position)newValue); //*****cast failure return; ... } super.eSet(featureID, newValue); }
It seems that the model is being executed using the XSRAIL language (corresponding to XSFSM), but the model is registered using the original metamodel and the system wants to cast the class defined in original metamodel (newValue: railway.Position) to a class defined in XSRAIL (Position: org.ttc.railway.xsrail.xsrail.railway.Position) which leads to the error. But I checked the FSM example and the models are also registered using the original metamodel and are executed using XSFSM.
Could you give me some suggestions about what could cause the error? Thank you.
on this version of the studio (I believe that yo are still on the non eclipse build) the genmodel call was sometime failing
you can try to find the genmodel file and manually launch the generate model code
From @zzhang03 on November 29, 2017 9:59
Sorry, I forgot to mention that I'm using gemoc 2.3.0 for linux 64 bit. I think genmodel isn't the problem. I don't have any trouble running FSM, I'm just trying to implement my own semantics on another metamodel and mimic the steps of FSM example. However I don't really know how FSM projects are created. So I tried to create FSM example from scratch by deleting all the other projects except the metamodel, edit and editor projects, and then recreate other projects by myself. But it also give me some errors. So there must be something wrong about how I created the projects.
From @jdeantoni on November 29, 2017 10:17
Hi,
it is difficult to answer with the information provided. However, you can have a look at this tutorial: https://github.com/gemoc/MODELS2017Tutorial It explains the steps needed to create the 2 melange projects (and the xsfsm.xsfsm, trace, etc.) Also, to create the k3dsa project, you main use wizards from the melange file.
my two cents j
the steps for the LegacyFSM example are more or less as follow
fsm
and remove the direct reference to the ecore (not required anymore since we use the extends)note: in newest version of the studio the steps may vary a bit since it provides more templates option when creating gemoc projects also you can vary
as a complement, GEMOC features support a range of "language definition styles". It depends on how you want to create your language, which kind of engines and what should remain in the final result (ie. where are defined the editors and animators). to give you an overview of the "styles"
engine variants:
language definition:
From @zzhang03 on November 30, 2017 11:19
Hi, Thank you for your thoughtful reply. I has been able to correct some errors in my projects. I appreciate your help. Regarding the error I mentioned above in this issue, however, I had to manually modified the code and now my simulation engine could run. I'm not sure whether this is a bug in the platform. It seems that the error occured because "Position" is a "Datatype" (Enumeration) in the metamodel, not a "Class". Let me explain using FSM example so that you could understand what I'm saying (but FSM example doesn't contain error of course). The error exists in the project which is corresponding to the xsfsm.xsfsm project in FSM example. The location is in an eSet() function of a xsfsm.xsfsm/src/org.gemoc.sample.legacyfsm.xsfsm.xsfsm.fsm.impl/xxxImpl.java file. eSet() will take an Object newValue and cast it to a class defined in xsfsm.xsfsm. In my case, for the "Class" cases in ecore when I print newValue.getClass() in eSet(), it will give me "xsfsm.xsfsm.fsm.impl.xxxImpl" so that this kind of newValue could be successfully cast to the corresponding class defined in xsfsm.xsfsm. But for a "Datatype" xxx in ecore, when I print newValue.getClass(), it will just give me "fsm.xxx" which is defined in the original fsm.model/src. Since there are no inheritance relationship between fsm.xxx defined in fsm.model/src and xsfsm.xxx defined in xsfsm.xsfsm/src, the type cast in eSet() would throw an error. Moreover, there would be no xxxImpl.java file generated for 'Datatype' in xsfsm.xsfsm/src/org.gemoc.sample.legacyfsm.xsfsm.xsfsm.fsm.impl folder.
Since the type cast problem doesn't occur for "Class" in ecore metamodel in my case, I assume that this error wasn't because I implemented the projects wrongly. Please let me know your opinion about this issue if it was because I made some mistakes. Thanks a lot.
it sounds to me that this is a Melange issue (https://github.com/diverse-project/melange) that doesn't deal correctly with the EDatatype/Enumeration
it would be cool to have a small example that illustrate the issue and report it to Melange project (may need to test it on latest versions of Melange, may be you can try to update your your gemoc studio with a newer version of Melange ? (do a backup first if the upgrade doesn't work smoothly))
From @zzhang03 on December 1, 2017 16:18
Sure, I will do the test.
At 2017-12-01 17:56:49, "Didier Vojtisek" notifications@github.com wrote:
it sounds to me that this is a Melange issue (https://github.com/diverse-project/melange) that doesn't deal correctly with the EDatatype/Enumeration
it would be cool to have a small example that illustrate the issue and report it to Melange project (may need to test it on latest versions of Melange, may be you can try to update your your gemoc studio with a newer version of Melange ? (do a backup first if the upgrade doesn't work smoothly))
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.
The new K3FSM official example is now provided with a complete documentation including a DIY (Do It Yourself) section allowing to reproduce the example from scratch (http://download.eclipse.org/gemoc/docs/nightly/K3FSM-example.html#K3FSM-example-DIY)
However, the old LegacyFSM example still miss this DIY section (BTW this example need to be renamed; see #84 )
From @zzhang03 on November 29, 2017 4:0
Hi gemoc team,
Could you give a brief tutorial about the steps to create FSM example from scratch (with metamodel, edit and editor projects only)? I'm trying to add semantics to the TTC 2015 train benchmark case using the metamodel in the figure 3 of http://ceur-ws.org/Vol-1524/paper2.pdf but I'm getting errors. I think I did something wrong when creating the projects and I'm really confused about how should I create the k3dsa and the 2 melange projects (and the xsfsm.xsfsm, trace, etc.)
Copied from original issue: gemoc/gemoc-studio#59