PDA

View Full Version : Named Connections


Jason Lightfoot
12-21-2010, 07:10 PM
Having one object refer to another is usually done through (multiple) centerport connections. This requires you to know the port numbers you want (defines make this easier) and if you delete and replace objects you'll likely need to go back through and re-rank the ports.

Attached is a library and example model that uses a simple command to retrieve the object you want WITHOUT using port connections:
getconnected(current,"MyConnectionName")

There are commands to add connections too, and a GUI to manage them for the whole model (in the example model it's mapped to the Model Control GUI). The Named Connections page of that GUI can be added to the list of pages on an objects GUI/Properties tabcontrol.

Two types of connection are made:
1) A bidirectional link (coupling) that is destroyed when either of the two connected objects are destroyed. This link can have different connection names at each end, so the same link could be called 'child' on one and 'parent' on the other, Customer/Supplier, etc...
2) A single direction pointer to the other object. If that object is then destroyed, the pointer's value will be NULL.

In the example the names are UnLoadPosition, LoadPosition, UnloadingOperator, RepositioningTransporter, FRsToMove, FRsToUnload, FRsUsingForReference

I've not put it to extensive use yet, so any feedback/testing is welcome.

Thanks and happy holidays!