GUIDE ATL [message #1841680] |
Tue, 25 May 2021 11:09  |
Eclipse User |
|
|
|
I wrote this rule in ATL :
rule ListOfPart2MExpert {
from nomenclature : ListOfPart!CI
to ME : MExpert!MExpert(),
p :MExpert!pou (
name<-'POU_Principal',
pouType<-'program' --,
),
a :MExpert!localVars(),
variable:MExpert!variables(
name <-nomenclature.nature
),
t:MExpert!type(
REAL<- if nomenclature.type='WORD'
then
VR
else
OclUndefined
endif,
BOOL<- if nomenclature.type='STRING'
then
VB
else
OclUndefined
endif
),
VR :MExpert!REAL(),
VB :MExpert!BOOL(),
b :MExpert!FBD()
}
and I got that :
<pou name="POU_Principal" pouType="program"/>
<localVars/>
<variables name="Type"/>
<type/>
<REAL/>
<BOOL/>
<FBD/>
<MExpert/>
<pou name="POU_Principal" pouType="program"/>
<localVars/>
<variables name="Unité"/>
<type/>
<REAL/>
<BOOL/>
<FBD/>
<MExpert/>
<pou name="POU_Principal" pouType="program"/>
<localVars/>
<variables name="Offset"/>
<type/>
<REAL/>
<BOOL/>
<FBD/>
<MExpert/>
<pou name="POU_Principal" pouType="program"/>
<localVars/>
<variables name="Date"/>
<type/>
<REAL/>
<BOOL/>
<FBD/>
<MExpert/>
<pou name="POU_Principal" pouType="program"/>
<localVars/>
<variables name="Donnée_1"/>
<type/>
<REAL/>
<BOOL/>
<FBD/>
<MExpert/>
<pou name="POU_Principal" pouType="program"/>
<localVars/>
<variables name="Donnée_2"/>
<type/>
<REAL/>
<BOOL/>
<FBD/>
<MExpert/>
<pou name="POU_Principal" pouType="program"/>
<localVars/>
<variables name="Donnée_3"/>
<type/>
<REAL/>
<BOOL/>
<FBD/>
<MExpert/>
<pou name="POU_Principal" pouType="program"/>
<localVars/>
<variables name="Donnée_4"/>
<type/>
<REAL/>
<BOOL/>
<FBD/>
<MExpert/>
<pou name="POU_Principal" pouType="program"/>
<localVars/>
<variables name="Nom"/>
<type/>
<REAL/>
<BOOL/>
<FBD/>
But my objectif is to get this structure
<pou name="POU_Principal" pouType="program">
<interface>
<localVars>
<variable name="Val4_MxIn">
<type>
<REAL />
</type>
</variable>
<variable name="Val5_MiOu">
<type>
<REAL />
</type>
</variable>
<variable name="Val6_MxOu">
<type>
<REAL />
</type>
</variable>
<variable name="Val7_BOOL">
<type>
<BOOL />
</type>
</variable>
<variable name="Sortie_1_BOOL">
<type>
<BOOL />
</type>
</variable>
<variable name="Sortie_2_REAL">
<type>
<REAL />
</type>
</variable>
<variable name="Sortie_3_BOOL">
<type>
<BOOL />
</type>
</variable>
<variable name="Sortie_4_UINT">
<type>
<UINT />
</type>
</variable>
<variable name="Exemple_Temperature">
<type>
<derived name="FB_Scaling" />
</type>
</variable>
</localVars>
</interface>
as you notice, these lines <pou name="POU_Principal" pouType="program"/>
<localVars/>
<FBD/>
<MExpert/>
repeat until the end
|
|
|
|
|
|
|
|
Re: GUIDE ATL [message #1841851 is a reply to message #1841786] |
Tue, 01 June 2021 05:21   |
Eclipse User |
|
|
|
I made some modification to the transformation code and to the metamodel of MExpert,
The code :
rule ListOfPart2MExpert {
from nomenclature : ListOfPart!CI
to p :MExpert!pou (
name<-'POU_Principal',
pouType<-'program' ,
interface<-a
),
a :MExpert!Interface(
localVars<-l
),
l :MExpert!localVars(
variable<-v
),
v :MExpert!variables(
name <-nomenclature.nature,
type<-t
),
t :MExpert!type(
REAL<- if nomenclature.type='WORD'
then
VR
else
OclUndefined
endif,
BOOL<- if nomenclature.type='STRING'
then
VB
else
OclUndefined
endif
),
VR :MExpert!REAL(),
VB :MExpert!BOOL()
}
And I got this
<?xml version="1.0" encoding="ISO-8859-1"?>
<xmi:XMI xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns="MachineExpert">
<pou name="POU_Principal" pouType="program">
<interface>
<localVars>
<variable name="Type">
<type/>
</variable>
</localVars>
</interface>
</pou>
<REAL/>
<BOOL/>
<pou name="POU_Principal" pouType="program">
<interface>
<localVars>
<variable name="Unité">
<type/>
</variable>
</localVars>
</interface>
</pou>
<REAL/>
<BOOL/>
<pou name="POU_Principal" pouType="program">
<interface>
<localVars>
<variable name="Offset">
<type/>
</variable>
</localVars>
</interface>
</pou>
<REAL/>
<BOOL/>
<pou name="POU_Principal" pouType="program">
<interface>
<localVars>
<variable name="Date">
<type/>
</variable>
</localVars>
</interface>
</pou>
<REAL/>
<BOOL/>
<pou name="POU_Principal" pouType="program">
<interface>
<localVars>
<variable name="Donnée_1">
<type/>
</variable>
</localVars>
</interface>
</pou>
<REAL/>
<BOOL/>
<pou name="POU_Principal" pouType="program">
<interface>
<localVars>
<variable name="Donnée_2">
<type/>
</variable>
</localVars>
</interface>
</pou>
<REAL/>
<BOOL/>
<pou name="POU_Principal" pouType="program">
<interface>
<localVars>
<variable name="Donnée_3">
<type/>
</variable>
</localVars>
</interface>
</pou>
<REAL/>
<BOOL/>
<pou name="POU_Principal" pouType="program">
<interface>
<localVars>
<variable name="Donnée_4">
<type/>
</variable>
</localVars>
</interface>
</pou>
<REAL/>
<BOOL/>
<pou name="POU_Principal" pouType="program">
<interface>
<localVars>
<variable name="Nom">
<type/>
</variable>
</localVars>
</interface>
</pou>
<REAL/>
<BOOL/>
</xmi:XMI>
Attachment: Capture1.PNG
(Size: 53.31KB, Downloaded 114 times)
|
|
|
Re: GUIDE ATL [message #1841909 is a reply to message #1841851] |
Wed, 02 June 2021 15:36   |
Eclipse User |
|
|
|
You appear to understand the principle now, where you need to assign values to the containment properties (interface, localVars, variable, ...) in order to have contained XMI elements.
However, none of the "if nomenclature.type=..." conditions in your transformation code seem to trigger, as no values are assigned to the REAL or BOOL property. You can debug this situation by inserting the "debug()" helper method into your code. Also, the VR and VB models elements are always created, whereas you likely meant to only create the value object of the applicable type instead of all of them. This can be achieved by using lazy rules.
Here's a reworked example (assumes you use EMFTVM):
rule ListOfPart2MExpert {
from nomenclature : ListOfPart!CI
to p :MExpert!pou (
name<-'POU_Principal',
pouType<-'program' ,
interface<-a
),
a :MExpert!Interface(
localVars<-l
),
l :MExpert!localVars(
variable<-v
),
v :MExpert!variables(
name <-nomenclature.nature,
type<-t
),
t :MExpert!type(
REAL<- thisModule.RealValue(nomenclature),
BOOL<- thisModule.BoolValue(nomenclature)
)
}
lazy rule RealValue {
from nomenclature : ListOfPart!CI (
nomenclature.type.debug('RealValue')='WORD')
to VR :MExpert!REAL
}
lazy rule BoolValue {
from nomenclature : ListOfPart!CI (
nomenclature.type.debug('RealValue')='STRING')
to VR :MExpert!BOOL
}
|
|
|
Re: GUIDE ATL [message #1841915 is a reply to message #1841909] |
Thu, 03 June 2021 03:13   |
Eclipse User |
|
|
|
This code allows me to have this structure:
<?xml version="1.0" encoding="ISO-8859-1"?>
<xmi:XMI xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns="MachineExpert">
<pou name="POU_Principal" pouType="program">
<interface>
<localVars>
<variable name="Type">
<type>
<REAL/>
<BOOL/>
</type>
</variable>
</localVars>
</interface>
</pou>
<pou name="POU_Principal" pouType="program">
<interface>
<localVars>
<variable name="Unité">
<type>
<REAL/>
<BOOL/>
</type>
</variable>
</localVars>
</interface>
</pou>
<pou name="POU_Principal" pouType="program">
<interface>
<localVars>
<variable name="Offset">
<type>
<REAL/>
<BOOL/>
</type>
</variable>
</localVars>
</interface>
</pou>
<pou name="POU_Principal" pouType="program">
<interface>
<localVars>
<variable name="Date">
<type>
<REAL/>
<BOOL/>
</type>
</variable>
</localVars>
</interface>
</pou>
<pou name="POU_Principal" pouType="program">
<interface>
<localVars>
<variable name="Donnée_1">
<type>
<REAL/>
<BOOL/>
</type>
</variable>
</localVars>
</interface>
</pou>
<pou name="POU_Principal" pouType="program">
<interface>
<localVars>
<variable name="Donnée_2">
<type>
<REAL/>
<BOOL/>
</type>
</variable>
</localVars>
</interface>
</pou>
<pou name="POU_Principal" pouType="program">
<interface>
<localVars>
<variable name="Donnée_3">
<type>
<REAL/>
<BOOL/>
</type>
</variable>
</localVars>
</interface>
</pou>
<pou name="POU_Principal" pouType="program">
<interface>
<localVars>
<variable name="Donnée_4">
<type>
<REAL/>
<BOOL/>
</type>
</variable>
</localVars>
</interface>
</pou>
<pou name="POU_Principal" pouType="program">
<interface>
<localVars>
<variable name="Nom">
<type>
<REAL/>
<BOOL/>
</type>
</variable>
</localVars>
</interface>
</pou>
</xmi:XMI>
and it's not quite the structure I'm looking for. I still tried to improve my code:
rule ListOfPart2MExpert {
from nomenclature : ListOfPart!Instance
to p :MExpert!pou (
name<-'POU_Principal',
pouType<-'program' ,
interface<-a
),
a :MExpert!Interface(
localVars<-l
),
l : MExpert!localVars (
variable<-v
),
v : distinct MExpert!variables foreach(e in nomenclature.ci)(
name <- e.nature,
type <- t
),
t: distinct MExpert!type foreach(e in nomenclature.ci)(
REAL<- VR,
BOOL<- VB
),
VR :distinct MExpert!REAL foreach(e in nomenclature.ci)(
REAL<- if e.type='WORD'
then
VR
else
OclUndefined
endif
),
VB :distinct MExpert!BOOL foreach(e in nomenclature.ci)(
BOOL<- if e.type='STRING'
then
VB
else
OclUndefined
endif
)
}
and I get this structure:
<pou xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns="MachineExpert" name="POU_Principal" pouType="program">
<interface>
<localVars>
<variable name="Type">
<type>
<REAL/>
<BOOL/>
</type>
</variable>
<variable name="Unité">
<type>
<REAL/>
<BOOL/>
</type>
</variable>
<variable name="Offset">
<type>
<REAL/>
<BOOL/>
</type>
</variable>
<variable name="Date">
<type>
<REAL/>
<BOOL/>
</type>
</variable>
<variable name="Donnée_1">
<type>
<REAL/>
<BOOL/>
</type>
</variable>
<variable name="Donnée_2">
<type>
<REAL/>
<BOOL/>
</type>
</variable>
<variable name="Donnée_3">
<type>
<REAL/>
<BOOL/>
</type>
</variable>
<variable name="Donnée_4">
<type>
<REAL/>
<BOOL/>
</type>
</variable>
<variable name="Nom">
<type>
<REAL/>
<BOOL/>
</type>
</variable>
</localVars>
</interface>
</pou>
It only remains to succeed in distinguishing between a "STRING" and a "WORD"
|
|
|
Re: GUIDE ATL [message #1841922 is a reply to message #1841909] |
Thu, 03 June 2021 10:15   |
Eclipse User |
|
|
|
I finally managed to put it on the right structure and now it makes the difference between a BOOL and a REAL. Except that it adds me tags at the end of the program but that will not affecte my progress in the project. If you have any ideas how to remove them that will be nice ...
The problem was that I had to write #STRING instead of 'STRING'
rule Variables2MExpert {
from nomenclature : ListOfPart!Instance
to
p :MExpert!pou (
name<-'POU_Principal',
pouType<-'program' ,
interface<-a
),
a :MExpert!Interface(
localVars<-l
),
l : MExpert!localVars (
variable<-v
),
v : distinct MExpert!variables foreach(e in nomenclature.ci)(
name <- e.nature,
type <- t
),
t :distinct MExpert!type foreach(e in nomenclature.ci)(
BOOL<-if (e.type=#STRING)
then
VB
else
OclUndefined
endif,
REAL<-if (e.type=#WORD)
then
VR
else
OclUndefined
endif
),
VB :distinct MExpert!BOOL foreach(e in nomenclature.ci),
VR :distinct MExpert!REAL foreach(e in nomenclature.ci)
}
and this is the result
<?xml version="1.0" encoding="ISO-8859-1"?>
<xmi:XMI xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns="MachineExpert">
<pou name="POU_Principal" pouType="program">
<interface>
<localVars>
<variable name="Type">
<type>
<BOOL/>
</type>
</variable>
<variable name="Unité">
<type>
<BOOL/>
</type>
</variable>
<variable name="Offset">
<type>
<REAL/>
</type>
</variable>
<variable name="Date">
<type>
<BOOL/>
</type>
</variable>
<variable name="Donnée_1">
<type>
<REAL/>
</type>
</variable>
<variable name="Donnée_2">
<type>
<REAL/>
</type>
</variable>
<variable name="Donnée_3">
<type>
<REAL/>
</type>
</variable>
<variable name="Donnée_4">
<type>
<REAL/>
</type>
</variable>
<variable name="Nom">
<type>
<BOOL/>
</type>
</variable>
</localVars>
</interface>
</pou>
<BOOL/>
<BOOL/>
<BOOL/>
<BOOL/>
<BOOL/>
<REAL/>
<REAL/>
<REAL/>
<REAL/>
</xmi:XMI>
|
|
|
|
Powered by
FUDForum. Page generated in 0.06327 seconds