Problem collect ATL emftvm [message #1806230] |
Mon, 06 May 2019 14:31 |
Jérémy Cavron Messages: 8 Registered: May 2019 Location: France |
Junior Member |
|
|
Hi,
I have a problem with an ATL transformation. If I run only with ATL, everything works. But when I go through emftvm, I have the following error:
Exception in thread "main" org.eclipse.m2m.atl.emftvm.util.VMException: java.lang.IllegalArgumentException: Cannot add/remove OclUndefined to/from multi-valued field Model::models
at rule BlackBox2Modelica@applier#13(./transformations/concept2modelica.atl#[22:3-22:68])
Local variables: [__trace__: TRACE!TraceLink = 117e949d:TRACE!TraceLink, BlackBox: MMConcept!BlackBox = entree-sorties V2VM:MMConcept!BlackBox, Mod: MMModelica!Model = V2VM:MMModelica!Model]
at static EMFTVM!ExecEnv::main() : Object(./transformations/concept2modelica.atl)
Local variables: []
The multi-package input metamodel. I think that's where the problem comes from.
Can you help me?
ATL file :
--Auteur : Cavron Jérémy
-- Version : 1
------------------------------------------------------------------------------------------------------------
-- @path MMConcept=/Concept2Modelica/metamodels/modeleConceptuel.ecore
-- @path MMModelica=/Concept2Modelica/metamodels/ModelicaMin.ecore
-- @atlcompiler emftvm
module concept2modelica;
create OUTModelica : MMModelica from INConcept : MMConcept;
----------Rules-----------Rules--------------Rules------------------Rules----------------------------Rules-------------------Rules-
-- Règle de transformation BlackBox vers Modelica --
rule BlackBox2Modelica {
from
BlackBox : MMConcept!BlackBox
to
Mod : MMModelica!Model (
name <- BlackBox.box.name,
models <- BlackBox.box.boxes -> collect (c | thisModule.boxes(c))
)
}
-- Règle de transformation des boxes --
unique lazy rule boxes {
from
boxes : Set(String)
using {
EQUAIN : Sequence(MMConcept!Equations) = MMConcept!Equations.allInstances();
GRAPHOUT : Sequence(MMConcept!Graph) = MMConcept!Graph.allInstances();
EQUAOUT : MMModelica!Equation = MMModelica!Equation;
LABEL : Set(MMConcept!Label) = Set{};
STATE : Set(MMConcept!State) = Set{};
VALUE : Sequence(String) = Sequence{};
NAME : Set(String) = Set{};
}
to model : MMModelica!Model()
do {
model.name <- boxes.name.debug('Nom : ');
model.interfaces <- boxes.interfaces -> collect(e | thisModule.interface(e));
-- Boucle sur les équations
for(i in EQUAIN){
if(i.name = boxes.name) {
NAME <- i.name;
LABEL <- i.label;
for(e in LABEL){
VALUE <- VALUE.append(e.value);
}
EQUAOUT<- VALUE;
model.equations <- EQUAOUT -> collect(e | thisModule.equation(e));
}
}
-- Boucle sur les graphes
for(i in GRAPHOUT){
if(i.name = boxes.name) {
NAME <- i.name;
STATE <- i.state;
for(e in STATE){
VALUE <- VALUE.append(e.name);
}
EQUAOUT<- VALUE;
model.equations <- EQUAOUT -> collect(e | thisModule.equation(e));
}
}
}
}
-- Règle de transformation des interfaces --
unique lazy rule interface {
from
inter : Set(String)
to
Mod : MMModelica!Interface (
name <- inter.name,
type <- inter.type,
kind <- inter.kind,
description <- inter.comment
)
}
-- Règle de transformation des équations --
lazy rule equation {
from
equ : Sequence(String)
to
Mod : MMModelica!Equation (
value <- equ
)
}
thank
-
Attachment: concept.PNG
(Size: 18.79KB, Downloaded 78 times) -
Attachment: model.png
(Size: 14.63KB, Downloaded 91 times)
|
|
|
|
|
Re: Problem collect ATL emftvm [message #1806508 is a reply to message #1806477] |
Fri, 10 May 2019 04:49 |
|
You cannot close a forum topic, but perhaps you can add "SOLVED" to the topic title?
The reason you got your error before is that lazy rules type-check their input at run-time: no match means it does nothing and returns OclUndefined. Probably Collection(String) would have worked?
Cheers,
Dennis
|
|
|
Re: Problem collect ATL emftvm [message #1806565 is a reply to message #1806508] |
Fri, 10 May 2019 11:57 |
Jérémy Cavron Messages: 8 Registered: May 2019 Location: France |
Junior Member |
|
|
ok Dennis. And thank you very much.
Yes I think that also.
But no, I always problem with
for(i in EQUAIN){} in "do" ancher
I show all example and I see a "do" in lazy rule to : https://wiki.eclipse.org/ATL/EMFTVM.. It's weird. ATL compiler it's ok. but not emftvm compiler for me
I put collection
just test with that and not working
unique lazy rule boxe {
from
boxe : OclAny
using {
EQUAIN : OclAny = MMConcept!Equations.allInstances();
GRAPHOUT : Sequence(MMConcept!Graph) = MMConcept!Graph.allInstances();
EQUAOUT : MMModelica!Equation = MMModelica!Equation;
LABEL : Set(MMConcept!Label) = Set{};
STATE : Set(MMConcept!State) = Set{};
VALUE : Sequence(String) = Sequence{};
NAME : Set(String) = Set{};
}
to model : MMModelica!Model(
name <- boxe.name,
interfaces <- boxe.interfaces -> collect(e | thisModule.interface(e))
)
do{
for(equa in EQUAIN){
equa.debug('test');
}
}
this code is executed with :
models <- BlackBox.box.boxes -> collect (c | thisModule.boxe(c))
And I have my debug answer but an exception :
test: V2VM_cont:MMConcept!Equations
test: V2VM_regles:MMConcept!Equations
test: V2VM_cont:MMConcept!Equations
test: V2VM_regles:MMConcept!Equations
test: V2VM_cont:MMConcept!Equations
test: V2VM_regles:MMConcept!Equations
Cannot add/remove OclUndefined to/from multi-valued field Model::models
the exception is also if I put :
....
do{
'hello'.debug('test');
}
.....
if I remove code in "do", it's ok. but I would like this code ^^
Thank
[Updated on: Fri, 10 May 2019 13:12] Report message to a moderator
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.01473 seconds