Topic
  • 7 replies
  • Latest Post - ‏2010-02-25T17:53:22Z by SystemAdmin
Babel Troyano
Babel Troyano
4 Posts

Pinned topic Tcl - Setting Realized Attribute of the port to null

‏2010-02-24T15:56:58Z |
Hello,

I'm writing a tcl script to remove the content of the Realized attributed of the ports.

What I do is next:

u2::SetValue $port Realized ""

where port is the entity containing the port I want to change.

It does not generate any error. But it does not work.

If I tried to change the Behavior Port Attribute in the same way, ¡¡It works!!

u2::SetValue $p isBehaviorPort true
How can I set null the Realized or Required Attribute?
Updated on 2010-02-25T17:53:22Z at 2010-02-25T17:53:22Z by SystemAdmin
  • SystemAdmin
    SystemAdmin
    147 Posts

    Re: Tcl - Setting Realized Attribute of the port to null

    ‏2010-02-24T17:32:35Z  
    Realized is a list of entity references, not a value, so in principle you should use u2::SetEntity/GetEntity/GetEntities (rather than u2::SetValue/GetValue).

    However IIRC the Realized/Required aren't conventional references. In particular if you delete them then in the model you will have problems that where the port symbol appears on a diagram the required/realized symbols doesn't update.

    What exactly are you trying to do?
  • Babel Troyano
    Babel Troyano
    4 Posts

    Re: Tcl - Setting Realized Attribute of the port to null

    ‏2010-02-25T08:36:19Z  
    Realized is a list of entity references, not a value, so in principle you should use u2::SetEntity/GetEntity/GetEntities (rather than u2::SetValue/GetValue).

    However IIRC the Realized/Required aren't conventional references. In particular if you delete them then in the model you will have problems that where the port symbol appears on a diagram the required/realized symbols doesn't update.

    What exactly are you trying to do?
    Hello Ian,

    thank you very much for your reply.

    I know Realized/Required is a list of entities. I tried to simplify the explanation of the problem, and maybe it was a little confusing.

    The point is that I want to delete an interface programmatically , and the interface is referenced in the realized attribute of the port. Therefore I would like to remove this reference, once the interface has been deleted. But I do not know how todo this.

    I also noticed that the port symbol appears on some diagrams, but it is not a problem because I already know how to deal with this information to avoid errors. Actually, I have deleted the port symbols on those diagramas, but the realized attribute still remains in the attribute.

    Babel.
  • SystemAdmin
    SystemAdmin
    147 Posts

    Re: Tcl - Setting Realized Attribute of the port to null

    ‏2010-02-25T13:52:46Z  
    Hello Ian,

    thank you very much for your reply.

    I know Realized/Required is a list of entities. I tried to simplify the explanation of the problem, and maybe it was a little confusing.

    The point is that I want to delete an interface programmatically , and the interface is referenced in the realized attribute of the port. Therefore I would like to remove this reference, once the interface has been deleted. But I do not know how todo this.

    I also noticed that the port symbol appears on some diagrams, but it is not a problem because I already know how to deal with this information to avoid errors. Actually, I have deleted the port symbols on those diagramas, but the realized attribute still remains in the attribute.

    Babel.
    I'm not sure Tau allows you to do this. Maybe you should raise a support case (assuming you're on maintenance) to ask this formally.

    Anyway that's why I asked what you were trying to achieve: what does the user want to do which means you are writing a script to delete an interface and all references to it? If I understand this I might be able to suggest an alternative approach.

    Regards
    Ian
  • Babel Troyano
    Babel Troyano
    4 Posts

    Re: Tcl - Setting Realized Attribute of the port to null

    ‏2010-02-25T14:38:58Z  
    I'm not sure Tau allows you to do this. Maybe you should raise a support case (assuming you're on maintenance) to ask this formally.

    Anyway that's why I asked what you were trying to achieve: what does the user want to do which means you are writing a script to delete an interface and all references to it? If I understand this I might be able to suggest an alternative approach.

    Regards
    Ian
    Ok, thanks again.

    I'll think about it.
    Babel.
  • SystemAdmin
    SystemAdmin
    147 Posts

    Re: Tcl - Setting Realized Attribute of the port to null

    ‏2010-02-25T15:04:15Z  
    Ok, thanks again.

    I'll think about it.
    Babel.
    If you want you can email me on: ian dot barnard at uk dot ibm dot com
  • Babel Troyano
    Babel Troyano
    4 Posts

    Re: Tcl - Setting Realized Attribute of the port to null

    ‏2010-02-25T17:10:57Z  
    If you want you can email me on: ian dot barnard at uk dot ibm dot com
    Thanks again, Ian

    About your question why do I want to delete some interfaces and its references? Well, I think it could be long to explain, but to resume, we are trying to keep some part of our development code in a TAU model . In this moment, we have a script to import this information, but sometimes the data within TAU model could be obsolete. So we must delete those interfaces and the related ports (yes, and more things). I was able to delete all the references of the interface related to the port (even the portSymbols), but the attribute realized/required.

    The good news is that I found a way to get it. Probably you'll say it is really weird, but it works.

    TAU stores all its data in a XML (xmi) file. If you analyze the xml file, you will be able to understand how TAU stores the information (metamodel). In case of ports there is a section for realized ports (<rRealized> ... </rRealized>) and other for required ports (<rRequired>...</rRequired) which are directly related to realized and required attributes.
    So, what I do is:

    1 - I use u2::XMLEncode method to get the port definition into a string,

    set xmlPortDefinition u2::XMLEncode $pEntityPort

    2 - Then I remove the part where the interface is referenced (for example <Realized>..</Realized)

    3- Finally, I use u2::XMLDecode method to replace the port with the new string

    set ActiveModel std::GetModels -kind U2 -project $std::activeproject
    set newEntity u2::XMLDecode $ActiveModel $newXmlPortDefinition
    set res u2::Replace $pEntityPort $newEntity
    Yes, it is weird, but I check the model after the script execution and no errors were found.

    Thanks for your interest.
    Babel
  • SystemAdmin
    SystemAdmin
    147 Posts

    Re: Tcl - Setting Realized Attribute of the port to null

    ‏2010-02-25T17:53:22Z  
    Thanks again, Ian

    About your question why do I want to delete some interfaces and its references? Well, I think it could be long to explain, but to resume, we are trying to keep some part of our development code in a TAU model . In this moment, we have a script to import this information, but sometimes the data within TAU model could be obsolete. So we must delete those interfaces and the related ports (yes, and more things). I was able to delete all the references of the interface related to the port (even the portSymbols), but the attribute realized/required.

    The good news is that I found a way to get it. Probably you'll say it is really weird, but it works.

    TAU stores all its data in a XML (xmi) file. If you analyze the xml file, you will be able to understand how TAU stores the information (metamodel). In case of ports there is a section for realized ports (<rRealized> ... </rRealized>) and other for required ports (<rRequired>...</rRequired) which are directly related to realized and required attributes.
    So, what I do is:

    1 - I use u2::XMLEncode method to get the port definition into a string,

    set xmlPortDefinition u2::XMLEncode $pEntityPort

    2 - Then I remove the part where the interface is referenced (for example <Realized>..</Realized)

    3- Finally, I use u2::XMLDecode method to replace the port with the new string

    set ActiveModel std::GetModels -kind U2 -project $std::activeproject
    set newEntity u2::XMLDecode $ActiveModel $newXmlPortDefinition
    set res u2::Replace $pEntityPort $newEntity
    Yes, it is weird, but I check the model after the script execution and no errors were found.

    Thanks for your interest.
    Babel
    That's a very creative solution...well done!

    Another useful trick sometimes is to use u2 textual form and parse it to create model definitions, really useful for constructing expressions and more complicated model structures like operation definitions.

    Regards
    Ian