Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » ATL » Problem collect ATL emftvm(exception error on collect)
Problem collect ATL emftvm [message #1806230] Mon, 06 May 2019 14:31 Go to next message
Jérémy Cavron is currently offline Jérémy CavronFriend
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 #1806310 is a reply to message #1806230] Tue, 07 May 2019 15:26 Go to previous messageGo to next message
Jérémy Cavron is currently offline Jérémy CavronFriend
Messages: 8
Registered: May 2019
Location: France
Junior Member
I have always problem. I search solutions.
I succeded for my emty model. it was in my metamodel. "a containment not check".
I write other topic for other problems, but the big problem is the same.
ask me for informations.

Thank Jérémy
Re: Problem collect ATL emftvm [message #1806477 is a reply to message #1806310] Thu, 09 May 2019 14:45 Go to previous messageGo to next message
Jérémy Cavron is currently offline Jérémy CavronFriend
Messages: 8
Registered: May 2019
Location: France
Junior Member
Sorry. That's not where the problem came from. It came from the following rule
...
lazy rule boxes {
	from
		boxes : OclAny
		using {
.....

I had put Set(String) and OclAny it's working.


However, I had already done it at the beginning of the week. To nothing to understand.


It's solved, I close. how we close this post?

thank
Re: Problem collect ATL emftvm [message #1806508 is a reply to message #1806477] Fri, 10 May 2019 04:49 Go to previous messageGo to next message
Dennis Wagelaar is currently offline Dennis WagelaarFriend
Messages: 581
Registered: September 2012
Location: Belgium
Senior Member

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 Go to previous messageGo to next message
Jérémy Cavron is currently offline Jérémy CavronFriend
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

Re: Problem collect ATL emftvm [message #1806582 is a reply to message #1806565] Fri, 10 May 2019 16:08 Go to previous messageGo to next message
Dennis Wagelaar is currently offline Dennis WagelaarFriend
Messages: 581
Registered: September 2012
Location: Belgium
Senior Member

You need to put
model;
on the last line of the do block: if you have a do block, you must specify the return value of the rule invocation.


Cheers,
Dennis
Re: Problem collect ATL emftvm [message #1806618 is a reply to message #1806582] Sun, 12 May 2019 07:55 Go to previous message
Jérémy Cavron is currently offline Jérémy CavronFriend
Messages: 8
Registered: May 2019
Location: France
Junior Member
Hi Dennis,
and thank you.

I tested your suggestion at home, it didn't work. I was desperate.
I test at work and it works.
thousand thanks Dennis and have a good day

[Updated on: Mon, 13 May 2019 06:51]

Report message to a moderator

Previous Topic:How Eclipse resolves URIs ?
Next Topic:KM3 uri not found
Goto Forum:
  


Current Time: Sat Nov 11 08:19:56 GMT 2023

Powered by FUDForum. Page generated in 0.01473 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top