ATTENTION

This 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

Go Back   FlexSim Community Forum > FlexSim Software > Q&A
Downloads

Q&A Using Flexsim and building models

  #1  
Old 05-13-2012
David Platt David Platt is offline
Flexsim User
 
Join Date: May 2012
Posts: 5
Downloads: 4
Uploads: 0
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 0
David Platt is on a distinguished road
Default 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  
Old 05-14-2012
Jens Mühlheimer Jens Mühlheimer is offline
Flexsim User
 
Join Date: Jul 2008
Location: Stuttgart, Germany
Posts: 140
Downloads: 8
Uploads: 0
Thanks: 40
Thanked 35 Times in 27 Posts
Rep Power: 174
Jens Mühlheimer will become famous soon enoughJens Mühlheimer will become famous soon enough
Default

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  
Old 05-15-2012
David Platt David Platt is offline
Flexsim User
 
Join Date: May 2012
Posts: 5
Downloads: 4
Uploads: 0
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 0
David Platt is on a distinguished road
Default 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  
Old 05-15-2012
Steven Hamoen's Avatar
Steven Hamoen Steven Hamoen is offline
Talumis, Flexsim Distributor, The Netherlands
 
Join Date: Aug 2007
Location: Soest, NL
Posts: 854
Downloads: 43
Uploads: 0
Thanks: 391
Thanked 661 Times in 379 Posts
Rep Power: 684
Steven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond repute
Default

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  
Old 05-15-2012
David Platt David Platt is offline
Flexsim User
 
Join Date: May 2012
Posts: 5
Downloads: 4
Uploads: 0
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 0
David Platt is on a distinguished road
Default 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??
  #6  
Old 05-16-2012
James Perry James Perry is offline
Flexsim User
 
Join Date: Apr 2012
Posts: 3
Downloads: 0
Uploads: 0
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 0
James Perry is on a distinguished road
Default

All you should need to do is open the input port on item it is being sent to. For example,

Code:
openip(outobject(current, 1),1);
  #7  
Old 05-16-2012
Phil BoBo's Avatar
Phil BoBo Phil BoBo is offline
Flexsim Development
 
Join Date: Jan 2008
Posts: 756
Downloads: 109
Uploads: 18
Thanks: 385
Thanked 1,483 Times in 525 Posts
Rep Power: 1174
Phil BoBo has a reputation beyond reputePhil BoBo has a reputation beyond reputePhil BoBo has a reputation beyond reputePhil BoBo has a reputation beyond reputePhil BoBo has a reputation beyond reputePhil BoBo has a reputation beyond reputePhil BoBo has a reputation beyond reputePhil BoBo has a reputation beyond reputePhil BoBo has a reputation beyond reputePhil BoBo has a reputation beyond reputePhil BoBo has a reputation beyond repute
Default

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  
Old 12-17-2012
Christian Seiler Christian Seiler is offline
Flexsim User
 
Join Date: Jul 2011
Posts: 1
Downloads: 0
Uploads: 0
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 0
Christian Seiler is on a distinguished road
Default

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:
/**zum naechsten Prozess weitergeben*/
treenode item = parnode(1);
treenode current = ownerobject(c);




int vergleich = getlabelnum(item,"Beendet");
int spalte_start = (vergleich-0.5)*2;
string teil = getname(item);
treenode stab = node(concat("/Tools/GlobalTables/MengenTakte>variables/data/",teil),model());
string stab_name = concat("/Tools/GlobalTables/MengenTakte>variables/data/",teil);


int ende = getrank(last(stab));




for (int index = spalte_start+1; index <= ende;index++)
{
treenode tester = node(concat(stab_name,"/",numtostring(index)),model());
int naechster = getnodenum (tester);

if ( naechster == 1)
{
int habs = index;
string naechster_Prozess = gettableheader("MengenTakte",2,habs);

int ports = nrop(current);

for (int index1 = 1;index1 <= ports;index1++)
{
string vergleich3 = concat("zu_",naechster_Prozess);

string vergleich2 = getname(outobject(current,index1));
if (comparetext(vergleich3,vergleich2) == 1)
{
return index1;
break;
}
else if (index1 == ports && comparetext(vergleich3,vergleich2) == 0)
{
string suchen = concat("/",naechster_Prozess,"_Container");
treenode naechste_Anlage = node(suchen,model());
treenode Eingang = node(concat("/",vergleich3),naechste_Anlage);
string versuch = getname(naechste_Anlage);

contextdragconnection(current,naechste_Anlage,"A") ;
contextdragconnection(naechste_Anlage,Eingang,"A") ;
return nrop(current);
break;
}

}
break;
}

}
  #9  
Old 12-17-2012
Jason Lightfoot Jason Lightfoot is offline
Flexsim Consultant
 
Join Date: Aug 2007
Location: Somerset, UK
Posts: 719
Downloads: 20
Uploads: 0
Thanks: 123
Thanked 953 Times in 446 Posts
Rep Power: 773
Jason Lightfoot has a reputation beyond reputeJason Lightfoot has a reputation beyond reputeJason Lightfoot has a reputation beyond reputeJason Lightfoot has a reputation beyond reputeJason Lightfoot has a reputation beyond reputeJason Lightfoot has a reputation beyond reputeJason Lightfoot has a reputation beyond reputeJason Lightfoot has a reputation beyond reputeJason Lightfoot has a reputation beyond reputeJason Lightfoot has a reputation beyond reputeJason Lightfoot has a reputation beyond repute
Default

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


All times are GMT -6.
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2020, vBulletin Solutions Inc.
Copyright 1993-2018 FlexSim Software Products, Inc.