« Back

Switching concepts: Switching the name does not work

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
Switching concepts: Switching the name does not work
community documentation adoscript trigger
Answer
3/27/14 11:42 AM
Hello,

we have a problem regarding switching the name of the processes. The processes have been summarized into one concept in order to minimize the modelling toolbar.
Here we used the switching function in GraphRep (Datatype: Enumeration) of ADO to realize it.

The problem now is that the default value is the process "AnyProcess" and the name is "AnyProcess“. But if we switch the visualisation of the process to, for example, a ManualProcess, the name also has has to switch to "ManualProcess".

We tried to realize it with the SET-function in GraphRep. At first we defined a variable (n) which is the name.
Then, if the user changes the visualization oft he process to a Manual Process (in the Notebook by changing the value oft he Enumeration "Processtype") we set the name for example to "ManualProcess".

Pseudo Code: 
IF (pt:ManualProcess)
SET name:"ManualProcess"

But that does not work - we hope we can fix it with your help - thanks in advance.

Kind regards

Endrju Selimaj & Sobhi Ahmad
Attachment

Attachment

Attachments: Enumeration.PNG (12.8k), Read only.PNG (7.1k)

RE: Switching concepts: Switching the name does not work
Answer
2/27/14 7:48 AM as a reply to Endrju S. & Sobhi A..
Dear Endrju & Sobhi,

thank you for your message. I understand that you do want to update the default object name that is generated when creating a new instance of a class to correspond to the value selected in the enumeration field value. To accomplish this, you need to add an event that captures the attribute value change and perform the update accordingly. An important aspect to consider is that the "Name" attribute is used to check for the uniqueness condition within a model (unique name per class needed). You can of course update any other attribute without the restriction of above. Please find the detail on the 2 events that can be used today, as well as an example implementation as code and implementing library.

The GraphRep also considers this change, and shows the "Name" and "Type" value. You can use this of course also to show a completely different representation using the AVAL statement to read values from the attribute and use this in IF statements to change the representation.

-----------------------------------------------------------------
This event is triggered after an attribute value has been changed.

Event name "SetAttributeValue"
    instid : integer [ID of the changed instance]
    attrid : integer [Attribute ID.]
    modelid : integer [ID of the model containing the changed instance.]
    attrtypeid : integer [Attribute type code:
         0 INTEGER
         1 DOUBLE
         2 STRING
         3 DISTRIBUTION
         4 TIME
         5 ENUMERATION
         6 ENUMERATIONLIST
         7 CORE_LONGSTRING
         8 PROGRAMCALL
         9 INTERREF
        10 EXPRESSION
        11 RECORD
        12 ATTRPROFREF
        13 DATE
        14 DATETIME
        15 CLOB]
        oldval : string [The original value (as string) This is the Core internal value (not UI value) For attributes of type RECORD this is always an empty string. The new value can be determined via the "Core" MessagePort]
Exit value    --    

-----------------------------------------------------------------
This event is triggered when an attribute value has been edited in a notebook, in the tabular modeling or via a "quick edit" field on the drawing area. It is similar to the "SetAttributeValue" event. The difference is, that attribute value changes which are not initiated by the user, e.g. by import, trigger a "SetAttributeValue" event, but not an "AfterEditAttributeValue" event.

Event name    "AfterEditAttributeValue"
    instid : integer [ID of the changed instance]
    attrid : integer [Attribute ID]
    modelid : integer [ID of the model containing the changed instance]
    attrtypeid : integer    [Attribute type code:
         0 INTEGER
         1 DOUBLE
         2 STRING
         3 DISTRIBUTION
         4 TIME
         5 ENUMERATION
         6 ENUMERATIONLIST
         7 LONGSTRING
         8 PROGRAMCALL
         9 INTERREF
        10 EXPRESSION
        11 RECORD
        12 ATTRPROFREF
        13 DATE
        14 DATETIME
        15 CLOB]
Exit value    --
-----------------------------------------------------------------

Example implementation
 1ON_EVENT "AfterEditAttributeValue" {
 2  # Parameters set by event
 3  # instid : integer
 4  # attrid : integer
 5  # modelid : integer
 6  # attrtypeid : integer
 7  # 0. Check for class name and only listen/perform action if the class is "Car"
 8  CC "Core" GET_CLASS_ID objid: (instid)
 9  SETL nCurrentClassID: (classid)
10  CC "Core" GET_CLASS_NAME classid: (nCurrentClassID)
11  SETL sCurrentClassName: (classname)
12  IF (sCurrentClassName = "Car") {
13    # 1. Check for attribute name and only listen/perform action if attribute is "Type"
14    CC "Core" GET_ATTR_NAME attrid: (attrid)
15    SETL sAttrName: (attrname)
16    IF (sAttrName = "Type") {
17      # 2. Get current value of attribute "Type"
18      CC "Core" GET_ATTR_VAL objid: (instid) attrid: (attrid)
19      SETL sTypeValue: (val)
20      # 3. Set an arbitrary attribute value with the exact same value as type
21      CC "Core" SET_ATTR_VAL objid: (instid) attrname: ("Additional name") val: (val)
22      # 4. Set "Name" attribute and also consider the ID (similiar behaviour as for default name creation of instances)
23      CC "Core" SET_ATTR_VAL objid: (instid) attrname: ("Name") val: (val + "-" + STR instid)
24    }
25  } 
26}
Attachments: SetAttributeValue Demonstration Library.abl (9.9k)

RE: Switching concepts: Switching the name does not work
Answer
3/8/14 8:20 PM as a reply to Wilfrid Utz.
With your proposal we achieved a big step forward, thank you very much for that.