SV: [gme-users] Problem with enum in OCL

Jesper Berthing jbe at cfsi.dk
Thu Aug 24 09:39:29 CDT 2006


Hi Zoli,
 
Thanks for your reply and solution to the problem.
 
I think that I will use ONE, TWO, THREE, FOUR... as the values of enum attributes such that I can create an function in the interpreter that gets the attribute from the model and returns the integer value.
 
It would be nice if it was possible to assign the #WhatEverYouWrite a value eg. 0, instead of the above "hack". But it works :-)
 
Best regards,
Jesper

________________________________

Fra: gme-users-bounces at list.isis.vanderbilt.edu på vegne af Zoltan Molnar
Sendt: on 8/23/2006 10:04
Til: gme-users
Emne: RE: [gme-users] Problem with enum in OCL



At first sight I realized that in your metamodel (xmp) the Blocking and
Non Blocking enumeration items are assigned values 0 and 1.

Old version of semaphoreType EnumAttribute:
Non Blocking, 0
Blocking, 1

This means you have to use somehow the values (0 or 1 or #0 or #1 ?) in
the constraint instead of the #Blocking and #Non blocking strings.

However, I did one thing: I replaced in semaphoreType's declaration 0
with VALNONBLOCK, and 1 with VALBLOCK and I rewrote the constraint
like this:
self.connectedFCOs( "dst", meta::Signals )-> forAll( c: meta::Semaphore
| c.semaphoreType = #VALBLOCK )

New version of semaphoreType EnumAttribute:
Non Blocking, VALNONBLOCK
Blocking, VALBLOCK

This way it worked.

Am I not sure how the syntax should be modified in order to work with 0s
and 1s as well.

Br, Zoli

> -----Original Message-----
> From: gme-users-bounces at list.isis.vanderbilt.edu
> [mailto:gme-users-bounces at list.isis.vanderbilt.edu] On Behalf
> Of Jesper Berthing
> Sent: Wednesday, August 23, 2006 2:39 PM
> To: gme-users
> Subject: RE: [gme-users] Problem with enum in OCL
>
>
>
> Hi Zoli,
>
> I tryed with the "meta::", but it did not work for me.
> Therefore I have create a new project with two atoms, just
> like I described below. The project is attached to this email.
>
> So if anybody has the time to try it out and possible find
> the mistake in the model I would be very happy. ;-)
>
> Below are some of the tests that I have carried out.
>
> My guess is that #Blocking is not "defined" in the constraint
> in the right way for the expression to be true. If I for
> example use the expression below the constraint is never violated.
>
> let var:ocl::Enumeration = ocl::Enumeration { #Non Blocking,
> #Blocking } in self.connectedFCOs( "dst", meta::Signals )->
> forAll( c: meta::Semaphore
> | c.semaphoreType = var )
>
> The last thing I tried was to attach a enumattribute to the
> Event Atom with the enum definition (#No,0 and #Yes, 1) and
> used the following constraint it is possbile to control when
> the connection is allowed (if both semaphoreType and
> eventType is set to the same (Non Blocking and No) and
> (Blocking and Yes)).
>
> self.connectedFCOs( "dst", meta::Signals )-> forAll( c:
> meta::Semaphore
> | c.semaphoreType = self.eventType )
>
> Of course I could make the enum attribute hidden for the user
> and set the default value to Yes. but that will not help me
> in other cases where I need to check for a certain enum value.
>
> I am using the latest version of GME (6.5.8), if this
> information helps.
>
> regards,
> Jesper
>
> -----Original Message-----
> From: gme-users-bounces at list.isis.vanderbilt.edu on behalf of
> Zoltan Molnar
> Sent: Wed 8/23/2006 6:00 PM
> To: gme-users
> Subject: RE: [gme-users] Problem with enum in OCL
> 
> For me it works although i used the "meta::" prefix for
> Signals and Semaphore like:
> 
> self.connectedFCOs( "dst", meta::Signals )-> forAll( c:
> meta::Semaphore
> | c.semaphoreType = #Blocking )
> 
> Zoli
> 
>
> -----Original Message-----
> From: gme-users-bounces at list.isis.vanderbilt.edu
> [mailto:gme-users-bounces at list.isis.vanderbilt.edu] On Behalf
> Of Jesper Berthing
> Sent: Tuesday, August 22, 2006 2:56 PM
> To: gme-users
> Subject: [gme-users] Problem with enum in OCL
>
>
>
>
> Hi there,
>
> I have two FCOs that can be connected via "Signals", the
> destination FCO has a enum with the name semaphoreType (Non
> Blocking = 0, Blocking = 1). The constraint is used to allow
> connections when the semaphoreType is Blocking and not Non Blocking.
>
> Therefore I have made the following constraint, but it keeps
> returning false when I create the connection between the two
> FCOs. Some how the c.semaphoreType is not equal to #Blocking,
> how come?
>
> self.connectedFCOs( "dst", Signals )->forAll( c : Semaphore |
> c.semaphoreType = #Blocking)
>
> I have used this previous post:
> http://list.isis.vanderbilt.edu/pipermail/gme-users/2005-July/
000812.htm
l in order to figure out that enums are represented using #.


Regards,
Jesper



_______________________________________________
gme-users mailing list
gme-users at list.isis.vanderbilt.edu
http://list.isis.vanderbilt.edu/mailman/listinfo/gme-users


-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/ms-tnef
Size: 8305 bytes
Desc: not available
Url : http://list.isis.vanderbilt.edu/pipermail/gme-users/attachments/20060824/621506dc/attachment.bin


More information about the gme-users mailing list