Book a Demo

Author Topic: Using Collections to manage SysML Signals & Messages  (Read 5891 times)

dcocks

  • EA Novice
  • *
  • Posts: 7
  • Karma: +0/-0
    • View Profile
Using Collections to manage SysML Signals & Messages
« on: February 26, 2019, 09:42:47 am »
I am trying to use the API to manage which Messages are carried by a Signal. The messages are stored in a Collection and this Collection construct does not appear to allow me to add an existing message onto this collection. There is an AddNew operation to create a new object (that does not work either; it returns "nothing") but there is no way to add an existing message to the collection. Apparently, you can only delete from a collection; you cannot add to it. As we manage large sets of interfaces, we need to move messages from one signal to another. I see no automated way to do this.

Any suggestions?

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Using Collections to manage SysML Signals & Messages
« Reply #1 on: February 26, 2019, 10:00:42 am »
Hmm. Just out of the blue: a message is created by adding a Message as new connector to a life line object's connectors collection. There shouldn't be any issue with that. You probably need to double check the connector type you tried to create. Best is to post (parts of) the code you used.

q.

dcocks

  • EA Novice
  • *
  • Posts: 7
  • Karma: +0/-0
    • View Profile
Re: Using Collections to manage SysML Signals & Messages
« Reply #2 on: February 27, 2019, 08:08:47 am »
Sorry, let me be more explicit.  On an IBD I have a connector between proxy ports on two blocks. I am using API calls in Excel VB to read the signals on that connector. The user can then choose to add or remove signals. This needs to be automated because it is part of a more complicate tool for balancing I/O across connectors and I/F block Receptions on ports on multiple diagrams. To remove an unwanted signal from connector oConn, identified by the signal's element ID (nID):
       Dim cSigs as EA.Collection
       Set cSigs = oConn.ConveyedItems
        For j = 1 To cSigs.Count
          Set oTestSig = cSigs(j - 1)
          If oTestSig.ElementID = nID Then
            cSigs.Delete (j - 1)
            cSigs.Refresh
          End If
        Next j
That is easy because the delete operation is supported by EA collections such as ConveyedItems. The challenge is to ADD a signal to the connector. I know the EA element (I have its elementID, GUID, etc.) but I find no way to add to a collection. There is an AddNew operation, but I don't want to create some new signal; I want to link an existing signal onto this connector. Does AddNew just create a placeholder object in the list that can then be assigned to the object of interest? How would that be coded up?

I hope this illustrates what I am up against, but you really don't need to be familiar with IBDs and signals to appreciate the problem. Collections are used throughout EA. Tagged values, attributes, and lots of other things use this same construct. It would be a terrible limitation of the EA API if there is no way to manage collections since they are so ubiquitous.

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Using Collections to manage SysML Signals & Messages
« Reply #3 on: February 27, 2019, 11:34:35 am »
So I know what you're talking about. I don't have SysML but conveyed items are also available in plain UML. I'll give that a shot tomorrow.

q.

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Using Collections to manage SysML Signals & Messages
« Reply #4 on: February 27, 2019, 09:39:40 pm »
As usual (and expected) the conveyed items boil down to an entry in t_xref. Which then made me look into the help (that's how I work xD).

Quote
EaCollection ConveyedItems —
An EaCollection of EaElement objects which are conveyed by the connector. This applies to Information Flow connectors only.

I just think that SysML messages are based on Information Flows. So there should be your anchor.

q.

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Using Collections to manage SysML Signals & Messages
« Reply #5 on: February 28, 2019, 03:10:37 am »
EA.Collections are weird creatures.
You cannot add existing elements to an EA.Collection. You can only add newly created items, and not all collections.
Unfortunately the help won't tell us which collections allow for creation of new items, and which don't.

Reading the manual actually helps.
It says this on connector.ConveyedItems

Quote
To add another element to the conveyed Collection, use 'AddNew (ElementGUID,NULL)', where 'ElementGUID' is the GUID of the element to be added.

Have you tried that?

Geert

dcocks

  • EA Novice
  • *
  • Posts: 7
  • Karma: +0/-0
    • View Profile
Re: Using Collections to manage SysML Signals & Messages
« Reply #6 on: March 07, 2019, 10:20:42 am »
The GUID does work! I'm glad you could find that documented, but none of the material I could find, including Thomas Killian's book) mentioned it. Thanks for your help with this.

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Using Collections to manage SysML Signals & Messages
« Reply #7 on: March 07, 2019, 03:27:33 pm »
The GUID does work! I'm glad you could find that documented, but none of the material I could find, including Thomas Killian's book) mentioned it. Thanks for your help with this.
The first thing you should look at is the manual. That's where I found it.

Geert

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Using Collections to manage SysML Signals & Messages
« Reply #8 on: March 07, 2019, 07:00:16 pm »
I just spotted a flaw in your
Code: [Select]
        For j = 1 To cSigs.Count
          Set oTestSig = cSigs(j - 1)
          If oTestSig.ElementID = nID Then
            cSigs.Delete (j - 1)
            cSigs.Refresh
          End If
        Next j


That won't work (or should not work). To delete multiple elements from a collection take them from the last to the first. Finally (if ever needed) do the refresh. Else you're just indexing the wrong elements.

q.

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: Using Collections to manage SysML Signals & Messages
« Reply #9 on: March 08, 2019, 10:07:44 am »
Should be fine if you just remove the Refresh.