It is currently Tue Feb 07, 2012 7:46 pm

All times are UTC



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.





 Page 1 of 1 [ 8 posts ] 
Author Message
 Post subject: Instantiate objects with port->port link
PostPosted: Thu Jan 15, 2009 10:16 pm 

Joined: Wed Dec 10, 2008 10:51 pm
Posts: 138
I can define two classes with an association between them, and instantiate them by creating the objects. I know I can set the association by associating a link between the two objects and the association.

Is it not possible to do the same thing with ports and links? The "Select Association to Instantiate" menu option is ghosted. I set the cardinality correctly. Is this not possible, or am I missing something? Any attempt to do this results in the link not being set. It seems silly to have to do this programatically.


Offline
 Profile  
 
 Post subject:
PostPosted: Thu Jan 15, 2009 11:36 pm 
User avatar

Joined: Thu Sep 13, 2007 7:34 pm
Posts: 397
Location: London
I think you must be missing something but I'm not sure what it is. What do you mean by cardinality? If you provide an example model it would be easier to help you.


Offline
 Profile  
 
 Post subject:
PostPosted: Fri Jan 16, 2009 3:52 pm 

Joined: Wed Dec 10, 2008 10:51 pm
Posts: 138
Yes, I came to the same conclusion late last night. Basically, I have 1 instance of ClassA associated to multiple instances of ClassB. I added ports with contracts on both ClassA and ClassB. I tried several things but either resulted in errors at compile time or crashing at runtime. I tried playing with one of the samples posted here, but it calls the function programatically rather than sending an event with the Send Action element. I couldn't get it to work with Send Action. I also couldn't get it to work programatically with multiplicity greater than 1.

I would still like to know how to use ports properly, but I've concluded I'm over using them anyway. I'm going to remove all but 1 and replace them with associations.


Offline
 Profile  
 
 Post subject:
PostPosted: Fri Jan 16, 2009 4:26 pm 
User avatar

Joined: Thu Sep 13, 2007 7:34 pm
Posts: 397
Location: London
It takes a bit of practice to get the right mix of ports usage but as a general rule they should not be dynamically connected and therefore you should never have to handcode a connection. Overuse of ports is a common problem when you first discover how they can be used. The next stage is often underuse. It's a bit like inheritance in C++ in that respect.


Offline
 Profile  
 
 Post subject:
PostPosted: Sat Jan 24, 2009 8:33 pm 

Joined: Wed Dec 10, 2008 10:51 pm
Posts: 138
Ok. I think I have a much better understanding of when to use ports, and found a situation where ports are a good fit. I still have a quick question though. I have 1 object that needs to call a function on a port on any one of 29 objects of the same class. I know I use the OUT_PORT macro to call a function when there's only 1 object at the other end. But what do I do if there are multiple? I want to specify which object the call goes to.

I assume its something to do with port multiplicity and the OUT_PORT_AT macro. Do I place the 29 multiplicity on the single object, or on the 29 objects?


Offline
 Profile  
 
 Post subject:
PostPosted: Sat Jan 24, 2009 9:10 pm 
User avatar

Joined: Thu Sep 13, 2007 7:34 pm
Posts: 397
Location: London
I can't say I use Port multiplicity often but is this what you want?


Attachments:
File comment: Port Multiplicity
supportZip.zip [19.95 KiB]
Downloaded 27 times
Offline
 Profile  
 
 Post subject:
PostPosted: Sat Jan 24, 2009 9:15 pm 

Joined: Wed Dec 10, 2008 10:51 pm
Posts: 138
I'm going to just stop posting for now. I should have tried what I suggested. I was right. That works. I don't know why I didn't get it to work the first time I tried a couple weeks ago.


Offline
 Profile  
 
 Post subject:
PostPosted: Sat Jan 24, 2009 9:40 pm 
User avatar

Joined: Thu Sep 13, 2007 7:34 pm
Posts: 397
Location: London
Even if you know the answer to a question any little example and answer, a question generates, may well help others.


Offline
 Profile  
 
Display posts from previous:  Sort by  
 Page 1 of 1 [ 8 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 0 guests


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

Search for:


suspicion-preferred