ATTENTIONThis FlexSim Community Forum is read-only. Please post any new questions, ideas, or discussions to our new community (we call it Answers) at https://answers.flexsim.com/. Our new Question & Answer site brings a modern, mobile-friendly interface and more focus on getting answers quickly. There are a few differences between how our new Q&A community works vs. a classic, threaded-conversation-style forum like the one below, so be sure to read our Answers Best Practices. |
flexsim.com |
#1
|
|||
|
|||
Dynamic Drawn Connections
I am using the “contextdragconnection” command to create connections on the fly. I have 120 fixed resources “A” (queues) connected to 120 fixed resources “B”. Each new production run is potentially configured differently, i.e. any “A” can be connected to any “B”. I could hard wire the connections and manage the ports for flowitems using labels on the flowitems. But this gives me a very messy set of connections approx (14,400 connections).
Instead I dynamically draw the appropriate connection. I can draw the connection ok but NO ITEMS WILL FLOW DOWN IT. If I reset the model and leave the connection in place then the flowitems will flow down the connection on the second run. Why? I have searched through the manual for clues as to why this may be happening but can’t find any help. I create the connection between “A” and “B” when the 1st flowitem enters the fixed resource “A”. I only create 1 connection (i.e. when nrop ==0) and would normally remove it on reset. |
#2
|
|||
|
|||
Did you write your code directly in the OnReset trigger or did you use the senddelayedmessage command and put the code in the OnMessage Trigger?
|
#3
|
|||
|
|||
Code executed onentry
I wrote the code in the OnEntry trigger connected to the fixed resource (queue).
The first thing I do is test to see if the item needs placing on a pallet then I test to see if the connection from the queue to the pallet has already been drawn. If the connection needs drawing I use the “contextdragconnection” to draw the connection to the fixed resource. I am then expecting the flowitem to leave by this connection. I don't use messaging at all, mainly because of the comment in the manual that advises to avoid sending message to the same object. My code is: treenode item = parnode(1); treenode current = ownerobject(c); { /**If the item is to be loaded onto Pallet Draw Connection to Pallet*/ double pallet = getlabelnum(item, "PalletStation"); if(pallet > 0) { //Do this only for the first item if(nrop(current) == 0) { contextdragconnection(current, node(concat("/PalletStack", numtostring(pallet, 1, 0)), model()), "A"); } } } |
#4
|
||||
|
||||
I don't know where you read about avoiding sending message to the same object, because that isn't true. The only thing is, that you should NOT use "sendmessage" but always "senddelayedmessage" with a delay time of 0. The difference is that with senddelayedmessage your current code is finished before the message is executed. With the "sendmessage" it is like a function call and is executed immidiately, after which the rest of the code is executed (which may or may not interfere with the same things you just did in your onmessage trigger)
|
#5
|
|||
|
|||
Using Delayed message
Tried using the delayed message.
On Entry - senddelayedmessage with 0 delay to current object (Note only do this if the connection does not exist) On Message I draw the connection. The connection was drawn. However, the arrow heads on both ends of the connection are red, rather than red to green. On reset the arrow heads on the connection change (the connection is red-green). And if I reset and run the model with this connection in place it works. Do I need to release something?? |
#7
|
||||
|
||||
Using openip() is a bad idea on discrete objects, as explained in the command documentation for that command.
Dynamically adding port connections in the OnEntry trigger is also a bad idea because it messes with the internal workings of the objects. (You could get unintended consequences that will be very hard to debug even though it may seem to be working when you first make the change.) If you want to move an item from one object to another but don't want to deal with thousands of connections, just use moveobject() instead of ports. |
The Following 2 Users Say Thank You to Phil BoBo For This Useful Post: | ||
naren nataraj (10-01-2012) |
#8
|
|||
|
|||
hello,
i´m a big fan of this forum, but mostly a quiet reader & only part-time flexsim user. sry for bringing this thread back up, but i´m currently busy making these dynamic connections work. so far so good, but the model has to be restarted before the freshly made connections begin working. i´m connecting the processors one by one along the material flow as the items progress through the factory. everytime an item creates a never before used path, the path is created but as mentioned above, i have to restart the model code sample: Quote:
|
#9
|
|||
|
|||
You could try adding this for each connection, but as Phil says - you can use moveobject() instead of ports:
contextdragconnection(fromobj,toobj,"A"); assertsubnode(getvarnode(fromobj,"outwaitinfo"),"" ,DATATYPE_NUMBER); receiveitem(toobj); |
Thread | Thread Starter | Forum | Replies | Last Post |
Connections Types | Flavio Brito | Q&A | 1 | 01-06-2011 10:21 AM |
More port connections | juan alberto | Q&A | 2 | 12-28-2010 05:47 AM |
Named Connections | Jason Lightfoot | User Development | 0 | 12-21-2010 08:10 PM |
Automated creation of connections between ports | Matthias Hofmann | Q&A | 3 | 06-25-2008 03:04 AM |
improve Connections method | qin tian | Gripes and Goodies | 7 | 03-26-2008 09:42 AM |