Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » M2M (model-to-model transformation) » Problem with rules with "distinct"
Problem with rules with "distinct" [message #39857] Tue, 22 May 2007 08:28 Go to next message
Eclipse UserFriend
Originally posted by: tristan.faure.c-s.fr

I have this code

rule Package2System {
from
p : UML!Package (p.oclIsTypeOf(UML!Package))
using {
seq : Sequence(UML!Operations) = p.getOperations() ;
}
to
s : _IF!System (
id <- p.name,
signal <- completesignal,
signal <- callsignal,
signal <- returnsignal,
process <- p.getProcesses(),
process <- thisModule.createGroupManager()
),
completesignal : _IF!Signal (
id <- 'u2i__complete'
),
callsignal : distinct _IF!Signal foreach (e in seq)(
id <- 'u2i__call_' + e.owner.name + '_' + e.name,
-- default parameters for a call signal
fparameters <- thisModule.newVariable ('waiting','pid'),
fparameters <- thisModule.newVariable ('caller','pid'),
fparameters <- thisModule.newVariable ('callerObj','pid'),
fparameters <- thisModule.newVariable ('callee','pid')
--fparameters <- e.ownedParameter
),
returnsignal : distinct _IF!Signal foreach (i in seq)(
id <- 'u2i__return_' + i.owner.name + '_' + i.name,
-- default parameters for a return signal
fparameters <- thisModule.newVariable ('callerObj','pid'),
fparameters <- thisModule.newVariable ('callee','pid')
--fparameters <- i.ownedParameter->select (a | a.name = 'return')
)
}

the code commented (fparameters <- ...) means that i want that each
parameter of the current operation (the sequence) will be inserted here
using this matched rule :

rule Parameter2Variables {
from
p : UML!Parameter (p.name.size() <> 0)
to
v : _IF!Vars (
name <- p.name,
type <- p.type.name
}
}

But this doesn't work except if i make a restriction on the parameter like
this :
fparameters <- e.ownedParameter.first()

I don't understand why when there is some parameter they can't be added :(
because of the distinct ???
Re: [ATL] Problem with rules with "distinct" [message #39918 is a reply to message #39857] Tue, 22 May 2007 09:24 Go to previous messageGo to next message
Ã?ric Vépa is currently offline Ã?ric VépaFriend
Messages: 16
Registered: July 2009
Junior Member
Hi Tristan,

Do not forget to prefix your subject with the [ATL] prefix.

Can we see the definition of the class _IF!Signal from your KM3
metamodel ? It will be easier to help you with these informations.

--
Éric Vépa

SODIUS
6, rue de Cornouaille
44319 Nantes - France
Email: evepa@sodius.com

www.mdworkbench.com
Draw more value from your models

Tristan FAURE wrote:
> I have this code
>
> rule Package2System {
> from
> p : UML!Package (p.oclIsTypeOf(UML!Package))
> using {
> seq : Sequence(UML!Operations) = p.getOperations() ;
> }
> to
> s : _IF!System (
> id <- p.name,
> signal <- completesignal,
> signal <- callsignal,
> signal <- returnsignal,
> process <- p.getProcesses(),
> process <- thisModule.createGroupManager()
> ),
> completesignal : _IF!Signal (
> id <- 'u2i__complete'
> ),
> callsignal : distinct _IF!Signal foreach (e in seq)(
> id <- 'u2i__call_' + e.owner.name + '_' + e.name,
> -- default parameters for a call signal
> fparameters <- thisModule.newVariable ('waiting','pid'),
> fparameters <- thisModule.newVariable ('caller','pid'),
> fparameters <- thisModule.newVariable ('callerObj','pid'),
> fparameters <- thisModule.newVariable ('callee','pid')
> --fparameters <- e.ownedParameter
> ),
> returnsignal : distinct _IF!Signal foreach (i in seq)(
> id <- 'u2i__return_' + i.owner.name + '_' + i.name,
> -- default parameters for a return signal
> fparameters <- thisModule.newVariable ('callerObj','pid'),
> fparameters <- thisModule.newVariable ('callee','pid')
> --fparameters <- i.ownedParameter->select (a | a.name =
> 'return')
> )
> }
>
> the code commented (fparameters <- ...) means that i want that each
> parameter of the current operation (the sequence) will be inserted here
> using this matched rule :
>
> rule Parameter2Variables {
> from
> p : UML!Parameter (p.name.size() <> 0) to v :
> _IF!Vars (
> name <- p.name,
> type <- p.type.name
> }
> }
>
> But this doesn't work except if i make a restriction on the parameter
> like this :
> fparameters <- e.ownedParameter.first()
>
> I don't understand why when there is some parameter they can't be added
> :( because of the distinct ???
>
>
Re: [ATL] Problem with rules with "distinct" [message #39949 is a reply to message #39918] Tue, 22 May 2007 09:28 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: tristan.faure.c-s.fr

Hi sorry for the [ATL] i forgot

so the signal:
<eClassifiers xsi:type="ecore:EClass" name="Signal"
eSuperTypes="#//Element">
<eStructuralFeatures xsi:type="ecore:EReference" name="fparameters"
upperBound="-1"
eType="#//Vars" containment="true"/>
</eClassifiers>

and Vars :

<eClassifiers xsi:type="ecore:EClass" name="Vars">
<eStructuralFeatures xsi:type="ecore:EAttribute" name="type"
lowerBound="1" eType="ecore:EDataType
http://www.eclipse.org/emf/2002/Ecore#//EString"/>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="name"
lowerBound="1" eType="ecore:EDataType
http://www.eclipse.org/emf/2002/Ecore#//EString"/>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="mode"
eType="#//ParametersMode"/>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="value"
lowerBound="1" eType="ecore:EDataType
http://www.eclipse.org/emf/2002/Ecore#//EString"/>
</eClassifiers>
Re: [ATL] Problem with rules with "distinct" [message #40043 is a reply to message #39949] Tue, 22 May 2007 11:06 Go to previous messageGo to next message
Frédéric Jouault is currently offline Frédéric JouaultFriend
Messages: 572
Registered: July 2009
Senior Member
Hello,

Is the issue you mention here different from the one you posted in:
http://dev.eclipse.org/newslists/news.eclipse.modeling.m2m/m sg00816.html
?

If not, please see my answer to your other post. Otherwise, could you
please first confirm that the first issue has been solved, and that this
is a different one?


Thanks,

Frédéric Jouault


Tristan FAURE wrote:
> Hi sorry for the [ATL] i forgot
>
> so the signal:
> <eClassifiers xsi:type="ecore:EClass" name="Signal"
> eSuperTypes="#//Element">
> <eStructuralFeatures xsi:type="ecore:EReference" name="fparameters"
> upperBound="-1"
> eType="#//Vars" containment="true"/>
> </eClassifiers>
>
> and Vars :
>
> <eClassifiers xsi:type="ecore:EClass" name="Vars">
> <eStructuralFeatures xsi:type="ecore:EAttribute" name="type"
> lowerBound="1" eType="ecore:EDataType
> http://www.eclipse.org/emf/2002/Ecore#//EString"/>
> <eStructuralFeatures xsi:type="ecore:EAttribute" name="name"
> lowerBound="1" eType="ecore:EDataType
> http://www.eclipse.org/emf/2002/Ecore#//EString"/>
> <eStructuralFeatures xsi:type="ecore:EAttribute" name="mode"
> eType="#//ParametersMode"/>
> <eStructuralFeatures xsi:type="ecore:EAttribute" name="value"
> lowerBound="1" eType="ecore:EDataType
> http://www.eclipse.org/emf/2002/Ecore#//EString"/>
> </eClassifiers>
>
Re: [ATL] Problem with rules with "distinct" [message #40103 is a reply to message #40043] Tue, 22 May 2007 12:51 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: tristan.faure.c-s.fr

I think I don't have the same problem of Pirit present here
http://dev.eclipse.org/newslists/news.eclipse.modeling.m2m/m sg00815.html

My probleme is that I iterate on all operations in a package
for each operation I had some predefined signals.

And i have to iterate on the parameters of the iterate operations. In the
other problem I have the impression that Pirit tried to iterate on the
same collection. Here I iterate on an element from the collection iterated.

I don't know if you understand what I mean :$

I put the necessary code with comments

-- I use all the operations of the package
using {
seq : Sequence(UML!Operations) = p.getOperations() ;
}

s : _IF!System (
id <- p.name,
-- here I had the signals in my signal collection in System
signal <- completesignal,
signal <- callsignal,
signal <- returnsignal,
),

completesignal : _IF!Signal (
id <- 'u2i__complete'
),

-- I create a signal for each operation
callsignal : distinct _IF!Signal foreach (e in seq)(
id <- 'u2i__call_' + e.owner.name + '_' + e.name,
-- default parameters for a call signal
fparameters <- thisModule.newVariable ('waiting','pid'),
fparameters <- thisModule.newVariable ('caller','pid'),
fparameters <- thisModule.newVariable ('callerObj','pid'),
fparameters <- thisModule.newVariable ('callee','pid'),
-- I want to add in my collection fparameters in the signal generated the
parameters of the operation iterated using my matched rule
Parameter2Variable
fparameters <- e.ownedParameter
),
....

And I constated that there is no problem when i use the method first() on
the collection and where there is just one parameter . . .

regards and sorry :/
Re: [ATL] Problem with rules with "distinct" [message #40132 is a reply to message #40103] Tue, 22 May 2007 12:56 Go to previous messageGo to next message
Frédéric Jouault is currently offline Frédéric JouaultFriend
Messages: 572
Registered: July 2009
Senior Member
Hello,

Well, I am not 100% sure that your problem is the same.

However, if you did not use "distinct"-"foreach", it is possible that
you would not have such a problem. The main issue is the relatively
cryptic semantics of this construct, which is why it has been deprecated
in favor of lazy rules.

Could you please try to use lazy rules instead?


Regards,

Frédéric Jouault


Tristan FAURE wrote:
> I think I don't have the same problem of Pirit present here
> http://dev.eclipse.org/newslists/news.eclipse.modeling.m2m/m sg00815.html
>
> My probleme is that I iterate on all operations in a package
> for each operation I had some predefined signals.
> And i have to iterate on the parameters of the iterate operations. In
> the other problem I have the impression that Pirit tried to iterate on
> the same collection. Here I iterate on an element from the collection
> iterated.
>
> I don't know if you understand what I mean :$
>
> I put the necessary code with comments
>
> -- I use all the operations of the package
> using {
> seq : Sequence(UML!Operations) = p.getOperations() ;
> }
>
> s : _IF!System (
> id <- p.name,
> -- here I had the signals in my signal collection in System
> signal <- completesignal,
> signal <- callsignal,
> signal <- returnsignal,
> ),
>
> completesignal : _IF!Signal (
> id <- 'u2i__complete'
> ),
>
> -- I create a signal for each operation
> callsignal : distinct _IF!Signal foreach (e in seq)(
> id <- 'u2i__call_' + e.owner.name + '_' + e.name,
> -- default parameters for a call signal
> fparameters <- thisModule.newVariable ('waiting','pid'),
> fparameters <- thisModule.newVariable ('caller','pid'),
> fparameters <- thisModule.newVariable ('callerObj','pid'),
> fparameters <- thisModule.newVariable ('callee','pid'),
> -- I want to add in my collection fparameters in the signal generated
> the parameters of the operation iterated using my matched rule
> Parameter2Variable
> fparameters <- e.ownedParameter
> ),
> ....
>
> And I constated that there is no problem when i use the method first()
> on the collection and where there is just one parameter . . .
>
> regards and sorry :/
>
Re: [ATL] Problem with rules with "distinct" [message #40197 is a reply to message #40132] Tue, 22 May 2007 13:15 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: tristan.faure.c-s.fr

I love you :)

In fact I didn't understand what was the use of lazy rule and i already
have a matched rule Operation2

with this i can have Operation2... => match rule
and Operation2Signal => lazy rule

thank you so much !!!!
Re: [ATL] Problem with rules with "distinct" [message #40564 is a reply to message #40197] Tue, 22 May 2007 14:36 Go to previous message
Frédéric Jouault is currently offline Frédéric JouaultFriend
Messages: 572
Registered: July 2009
Senior Member
> I love you :)
>
> In fact I didn't understand what was the use of lazy rule and i already
> have a matched rule Operation2
>
> with this i can have Operation2... => match rule
> and Operation2Signal => lazy rule
>
> thank you so much !!!!

You are welcome :-).


Best regards,

Frédéric Jouault
Previous Topic:[ATL] Modeling with KM3: How to model an enumeration that uses numeric values.
Next Topic:[ATL] Is Datatype Double not supported?
Goto Forum:
  


Current Time: Thu Apr 25 23:01:45 GMT 2024

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

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

Back to the top