Book a Demo

Author Topic: State Sub-machine instances  (Read 4124 times)

frankk

  • EA User
  • **
  • Posts: 96
  • Karma: +0/-0
    • View Profile
State Sub-machine instances
« on: February 27, 2008, 03:17:49 am »
How does one re-use a Sub-machine in another diagram? If I drag from the Project Browser, I get an Object, not a State, which means I can't draw Transitions to it.

Gary W.

  • EA User
  • **
  • Posts: 139
  • Karma: +0/-0
    • View Profile
Re: State Sub-machine instances
« Reply #1 on: February 27, 2008, 07:08:41 am »
Do you get the option of 'object' (i.e. instance-of) versus 'reference' (i.e. link)?

If not, try 'Control + MouseDrag'.  

HTH,
Gary

frankk

  • EA User
  • **
  • Posts: 96
  • Karma: +0/-0
    • View Profile
Re: State Sub-machine instances
« Reply #2 on: March 06, 2008, 07:19:00 am »
Yes, I get that option, and I can create the object. However, it appears to be just a simple State element. I was hoping to get the 'objectname:submachinename' notation for the identifier.

«Midnight»

  • EA Guru
  • *****
  • Posts: 5651
  • Karma: +0/-0
  • That nice Mister Grey
    • View Profile
Re: State Sub-machine instances
« Reply #3 on: March 06, 2008, 07:35:18 am »
No problem Frank,

Open the instance properties and give it a name. You should get the <instanceName>:<classifierName> convention.

This is just like Classes and Objects based on them. Each class has a name (e.g. MyClass). Each instance (object) of the class can also have a name (e.g. myObject:MyClass) but may be anonymous.

The default is anonymous; you must explicitly provide a name if you want one.

David
No, you can't have it!

frankk

  • EA User
  • **
  • Posts: 96
  • Karma: +0/-0
    • View Profile
Re: State Sub-machine instances
« Reply #4 on: March 06, 2008, 07:37:47 am »
When I do it, the new State has the name of the sub-machine as the default. If I want the colon notation, I have to type it explicitly. I.e., it doesn't seem to behave like Classes and Objects.

«Midnight»

  • EA Guru
  • *****
  • Posts: 5651
  • Karma: +0/-0
  • That nice Mister Grey
    • View Profile
Re: State Sub-machine instances
« Reply #5 on: March 06, 2008, 08:07:25 am »
There are two possibilities here Frank.

If you are creating an instance of your state machine, you should get one of the anonymous objects I mentioned earlier. By UML convention this is given a blank name, and displayed as :<classifierName>. You can open the properties dialog for this instance and give it a name, which will then appear as <instanceName>:<classifierName>. This is not an EA-specific policy; this is how UML works.

In this case the part of the name after the colon refers to the classifier, not the instance. Each instance is an (independent) occurrence of the classifier. It may be given a name, or it may be anonymous, but it is still of the same type as the classifier. [Sort of like renaming a pet cat. It will still be a cat.]

Second, if you are creating a "simple link" (to use the EA vernacular) to the object, you are actually referring to the same definition as the one you already have. To be specific, you have not copied the original state machine; the same machine is merely shown on both diagrams. To confirm this check the Project Browser, and you will observe that the state machine only appears once. If you delete it (using only the delete key) from either diagram it will still be present in the Project Browser, and the other diagram. If you rename it in either diagram, it will be renamed in all three places. If you delete it from the Project Browser - please don't actually do this on your working copy; just trust me - it will be gone from the entire EA project.

That's why the non-instance machine seems to always have the same name. There's only one machine, and it has the same name no matter where you reference it.

HTH, David
No, you can't have it!