|
It is currently Wed Feb 08, 2012 11:58 pm
|
View unanswered posts | View active topics
| Welcome |
|
Welcome to RHAPSODY4YOU
You are currently viewing our boards as a guest, which gives you limited access to view most discussions and access our other features. By joining our free community, you will have access to post topics, respond to polls, upload and download content, and access many other special features. Registration is fast, simple, and absolutely free, so please, register to join our community today. |
 |
|
 |
|
| Author |
Message |
|
bitblit
|
Post subject: Single event, multiple ports Posted: Tue Dec 23, 2008 5:22 pm |
Joined: Wed Dec 10, 2008 10:51 pm Posts: 138
|
|
I have state driven class that responds to the same class of events differently, depending on from which port it was received from. I have two questions.
First, can I just use a single port and react differently depending on which object the event came from? If so, whats the recommended approach?
Second, what is the recommended approach to respond to the same event from different ports? Is there an attribute that I can read to determine from which the port it came from? Do I poll the ports?
I prefer to solve this using this forum and the native Rhapsody tools, rather than reverse engineer the generated code. Whenever I reverse engineer the code I seem to find a kludgey work around, and then find a more elegant preferred solution later requiring a slight redesign to cleanup my model and code.
|
|
|
|
 |
|
Farquad
|
Post subject: Posted: Tue Dec 23, 2008 5:40 pm |
Joined: Thu Sep 13, 2007 7:34 pm Posts: 397 Location: London
|
|
"First, can I just use a single port and react differently depending on which object the event came from? If so, whats the recommended approach? "
I guess you've got to pass a handle to the sender as a parameter in the event.
"Second, what is the recommended approach to respond to the same event from different ports? Is there an attribute that I can read to determine from which the port it came from? Do I poll the ports?"
See attached model and OXFPortMacros.h in <rhapsody>\Share\LangCpp\oxf.
|
|
|
|
 |
|
bitblit
|
Post subject: Posted: Tue Dec 23, 2008 6:05 pm |
Joined: Wed Dec 10, 2008 10:51 pm Posts: 138
|
|
Thanks. I expected that was the answer to my first question. Just thought I would ask.
It would have taken a long time to figure out the answer to the second question. So, is IS_PORT a macro that returns true if the event generating that transition is from the specified port? If so, that's easier than I expected. I was barking up a similar tree, but would have ended up with more code and less UML artifacts. Thanks again.
|
|
|
|
 |
|
bitblit
|
Post subject: Posted: Tue Dec 23, 2008 6:16 pm |
Joined: Wed Dec 10, 2008 10:51 pm Posts: 138
|
|
Nevermind. It works. That is really cool.
|
|
|
|
 |
|
bitblit
|
Post subject: Posted: Sat Dec 27, 2008 3:03 pm |
Joined: Wed Dec 10, 2008 10:51 pm Posts: 138
|
|
I have another quick question. My model worked, but now I'm playing with the port multiplicity a little bit. I had 3 ports flowing data through a composite class to a single object. I combined the 3 ports into a single port with multiplicity set to 3, which makes sense since its the same data. Its just from one of 3 different objects.
I know I check to see where the event came from by using IS_PORT_AT. However, how do I forward from one multiple port to another? The data goes from a single port on one of three objects, to a 3xport on the composite class, which should be forwarded to the 3xport on the inner object (part).
|
|
|
|
 |
|
Farquad
|
Post subject: Posted: Sat Dec 27, 2008 9:28 pm |
Joined: Thu Sep 13, 2007 7:34 pm Posts: 397 Location: London
|
I think you want to relay the messages?
 [/img]
|
|
|
|
 |
|
bitblit
|
Post subject: Posted: Sat Dec 27, 2008 9:54 pm |
Joined: Wed Dec 10, 2008 10:51 pm Posts: 138
|
|
Thats exactly what I'm looking for. I must have forgot to set the behavioral ports. Thanks again.
|
|
|
|
 |
|
bitblit
|
Post subject: Posted: Sat Dec 27, 2008 11:16 pm |
Joined: Wed Dec 10, 2008 10:51 pm Posts: 138
|
|
I started making the changes suggested by your previous message. But, somewhere along the line, I got an error that I can't troubleshoot. The compile completes with no errors and 2 known warnings (ports with no contracts). When I try to run it with animation enabled, I get an error immediately after the animation controls appear saying "No relation named <class>> defined." I deleted all instances of the class that was listed and the error still persisted. I could not find where any reference to this relation existed, but the error still occured. It finally went away after I set instrumentation to None, recompiled, and set instrumentation back to Animation. The source and compiled code should be exactly the same, so I think this was an error from the Rhapsody tool itself. I have no idea what caused this error, but I do know the workaround.
|
|
|
|
 |
|
BorgesW
|
Post subject: Posted: Mon Jan 05, 2009 2:31 pm |
Joined: Fri Dec 05, 2008 4:55 pm Posts: 15
|
bitblit wrote: It finally went away after I set instrumentation to None, recompiled, and set instrumentation back to Animation. The source and compiled code should be exactly the same, so I think this was an error from the Rhapsody tool itself.
Often times (and I really do mean often), when you get a weird error you just have to re-generate the code, and re-compile the code, and the error will go away. This has solved so many weird problems that these days, whenever something weird happens, that is the first thing I do.
I'm not sure what you mean by "source and compiled code should be exactly the same" ... but you said it was fixed when you set the animation to None, re-compiled and then back to Animation and re-compiled. I think the code just needed to be re-generated and re-compiled, which was done automatically when you switched back and forth between Animation and None.
|
|
|
|
 |
|
|
 |
|
 |
|
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 post attachments in this forum
|
|