acmestudio.org Forum Index acmestudio.org
Forum for discussion of things Acme and AcmeStudio
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Creation of collections in rules in Armani rules

 
Post new topic   Reply to topic    acmestudio.org Forum Index -> AcmeStudio Users
View previous topic :: View next topic  
Author Message
Carl Gamble



Joined: 05 Sep 2006
Posts: 14
Location: Newcastle upon Tyne, UK

PostPosted: Fri Mar 06, 2009 10:01 am    Post subject: Creation of collections in rules in Armani rules Reply with quote

I have been trying to use the "collect" and "select" statements to generate a collection for use in an armani rule, but so far have not been able to produce a rule that type checks.

Below is a copy of the rule that so far I think has come closest.

Code:

rule AllChoiceGroupsHaveChoiceMakers = invariant forall name : string in
    {collect port : string in {select p : Port in self.PORTS | satisfiesType(p, PortTWSClientUnicast)}  | name != ""} |
        exists p2 : PortTWSClientUnicast in self.PORTS |
             p2.ChoiceGroup == name AND p2.GroupChoiceMaker == Yes;


And here are the fragments of the family definition that the rule references, including the rule

Code:

    Component Type CompTWSClient extends CompTWSCommon with {
        rule AllChoiceGroupsHaveChoiceMakers = invariant forall name : string in
    {collect port : string in {select p : Port in self.PORTS | satisfiesType(p, PortTWSClientUnicast)}  | name != ""} |
        exists p2 : PortTWSClientUnicast in self.PORTS |
             p2.ChoiceGroup == name AND p2.GroupChoiceMaker == Yes;
    }

    Port Type PortTWSCommon = {
   ...
    }

    Port Type PortTWSClient extends PortTWSCommon with {
   ...
    }

    Port Type PortTWSClientMulticast extends PortTWSClient with {
   ...
    }


    Port Type PortTWSClientUnicast extends PortTWSClient with {

        Property ChoiceGroup : string;

        Property GroupChoiceMaker : TSafeBoolean;

    }


The purpose of the rule is to check that for each value assigned to the ChoiceGroup property of the ports of a particular component, there exists one or more ports on that component that has ChoiceGroup equal to that value and the GroupChoiceMaker property equals "yes"

I am using the collect and select operators to build the collection of ChoiceGroup properties, at least I am trying to, and it is this bit that I think that I am having trouble with.

Do you have any guidance on where I am going wrong?
Back to top
View user's profile Send private message Visit poster's website
acme
Site Admin


Joined: 19 Jan 2006
Posts: 33

PostPosted: Fri Mar 13, 2009 3:37 pm    Post subject: Reply with quote

Carl

I'm having trouble parsing both the Acme and the English Smile Maybe we could break this down somewhat.

1. select p in self.ports | satisfiesType (p, PTWSCU) gives you the set of ports in the component that satisfy PTWSCU. Let's call this <S> for now.

2. collect n : string in <S> | name != "". This is where I have trouble (BTW, port is a keyword and so you can't use it as a quantifier name). The problem is, where does name come from> Also, the declaration of n is not correct. Collect is used to collect substructure, and so the syntax of it should be something like:

collect Reference : TypeRef in SetReference | predicate

So, from the Armani LRM, you can say something like:

1. collect c.ports : set{port} in self.components | satisfiesType (c, Filter): This will form a set of set-of-ports of components that satisfy the Filter type in a system. So, the declaration c.ports both declares a variable c and then immediately references its substructure. So, c can be used in the predicate afterwards.

2. { collect v.x : int in { [x=4; y=6], [x=5; y=7]; [x=5; y=8] } | v.y – v.x = 2 }
This will return the set { 4, 5 }. Again, the type of v here will be a record [x: int; y : int] and so it can be used in the expression v.y - v.x = 2

Maybe you could clarify what it is you are trying to accomplish in simpler terms so that we can work it out.

OK, full disclosure here. I have just checked the parser and it seems that collect is not implemented. If you were to successfully get it to parse, it would throw and unsupported operation exception. We're looking at how this should be implemented now.
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic   Reply to topic    acmestudio.org Forum Index -> AcmeStudio Users All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group