[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [henshin-user] Node Attribute Self Reference [SOLVED]

Hi Kristopher,


thank you for your reply.  Sorry for the late response. I was out of office until today.


I actually did it exactly as you described in your first mail. It seems my rule had some kind of hickup. I deleted it and made it new and then it worked.

Thank you for your effort.


Kind regard,
Jürgen



Dipl.-Ing. Jürgen Freund
Arbeitsgruppe Ähnlichkeitsmechanik

Telefon: +49 (0)711 685 69530
E-Mail:  freund@xxxxxxxxxxxxxxxxxxxx

Postadresse:
Universität Stuttgart
Institut für Statik und Dynamik der Luft- und Raumfahrtkonstruktionen
Pfaffenwaldring 27 - Zimmer 01.002
70569 Stuttgart
On 13.01.2017 14:07, Kristopher Born wrote:

Hello Jürgen,

 

I had been able to reproduce the Exception.

 

Most likely this happens when the variable x is not added as a rule parameter.

 

That’s what I implied with the following statement:
Additionally the rule have to be extended by the variable x. You can easily achieve this in the graphical editor by editing the rule name: E.g. “ruleName(var x:EDouble)”. ”

 

To describe this more in detail I created a picture depicting the discrepancy:

https://www.dropbox.com/sh/q1jy481ez81xdfm/AACcd08cpizSGThcIwXOibKOa?dl=0&preview=simpleRule.JPG

The rule “increaseAmount_WRONG” does not contain the rule parameter x and results in the exception.

The rule “increaseAmount(var x:EDouble)” does contain the rule parameter x and works fine.

 

You can download the project from the following link to further inspect it:

https://www.dropbox.com/sh/q1jy481ez81xdfm/AACcd08cpizSGThcIwXOibKOa?dl=0

 

If you have further problems or this doesn’t solve the problem feel free to ask.

 

Best regards,

Kristopher

 

Von: henshin-user-bounces@xxxxxxxxxxx [mailto:henshin-user-bounces@xxxxxxxxxxx] Im Auftrag von Juergen Freund
Gesendet: Donnerstag, 12. Januar 2017 15:50
An: henshin-user@xxxxxxxxxxx
Betreff: Re: [henshin-user] Node Attribute Self Reference

 

Hello Kristopher,

thank you for your answer.

I changed my rule according to your description, but now I get the following error:

java.lang.RuntimeException: ReferenceError: "x" is not defined in <eval> at line number 1


Regards,
Jürgen



Dipl.-Ing. Jürgen Freund
Arbeitsgruppe Ähnlichkeitsmechanik
 
Telefon: +49 (0)711 685 69530
E-Mail:  freund@xxxxxxxxxxxxxxxxxxxx
 
Postadresse:
Universität Stuttgart
Institut für Statik und Dynamik der Luft- und Raumfahrtkonstruktionen
Pfaffenwaldring 27 - Zimmer 01.002
70569 Stuttgart

On 12.01.2017 15:33, Kristopher Born wrote:

Hello Jürgen,

 

it is possible to achieve your aim. You are already on the right track.

 

Instead of “attribute = attribute + 5” you should use “attribute = x -> x + 5”.

Additionally the rule have to be extended by the variable x. You can easily achieve this in the graphical editor by editing the rule name: E.g. “ruleName(var x:EDouble)”.

By that your “NodeWithAttribute” is matched and the variable x is set to the attributes value of the matched node. As result of the rule application the new value of the attribute will be “x+1”.  The keyterm “->” disjoins the part for matching (here x), the LHS and the part for the state after the rule application (here x+1), the RHS.

 

You can find an example of that in the rule “transferMoney” in the bank example: https://www.eclipse.org/henshin/examples.php?example=bank

 

If my answer isn’t detailed enough please help me to improve it ;-)

 

Kind regards,

Kristopher

 

 

Von: henshin-user-bounces@xxxxxxxxxxx [mailto:henshin-user-bounces@xxxxxxxxxxx] Im Auftrag von Juergen Freund
Gesendet: Donnerstag, 12. Januar 2017 15:12
An: henshin-user@xxxxxxxxxxx
Betreff: [henshin-user] Node Attribute Self Reference

 

Hi all,

I wanted to ask if it is possible to reference an attribute to itself within a node.

e.g.:

    I have a rule where I search for a specific Node with an attribute and if this node is found I want to add 5 to that attribute
    and I do not matter which value it had before.

     ------------------------------------
    | <<preserve>>                |
    | :NodeWithAttribute          |
     ------------------------------------
    | attribute = attribute + 5 |
     ------------------------------------

Is this somehow possible for example with the _javascript_ Engine?


Regards,
Jürgen




-- 
Dipl.-Ing. Jürgen Freund
Arbeitsgruppe Ähnlichkeitsmechanik
 
Telefon: +49 (0)711 685 69530
E-Mail:  freund@xxxxxxxxxxxxxxxxxxxx
 
Postadresse:
Universität Stuttgart
Institut für Statik und Dynamik der Luft- und Raumfahrtkonstruktionen
Pfaffenwaldring 27 - Zimmer 01.002
70569 Stuttgart




_______________________________________________
henshin-user mailing list
henshin-user@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/henshin-user

 



_______________________________________________
henshin-user mailing list
henshin-user@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/henshin-user