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
|
|||
|
|||
Network Nodes
Hi there,
Here is a good question, hopefully someone can help me. I have a lot of network nodes connected to each other (rails). Not all of these connections are straight lines. Some of them have been changed into curves by using Spline Points. Now what I do is show the name(number) of this connection by using a "drawtext" command in the OnDrawTrigger. This does work well but I want to be able to place this text right in the middle of the connection. For the straight lines this is not a problem of course. But in the case of a curve it gets a bit harder. So my question is; how can I determine/calculate the positions of points on the curve? For instance to get the halfway point or to get the y position based on a fixed x position. Thank you in advance. Regards, Rachid Kolfin |
#2
|
|||
|
|||
It turns out that there are pretty simple commands that can help you achieve this. If you first define the spline (treenode point = getnetnodespline(NetworkNode, number edge)) then you use the command spline(point, 0.5) to refer to middle point of the curve.
In this case splinex(), spliney() and splinez() will return the middle of the curve compared to the Network Node in which they are. Perhaps there are more people who also did not know this, so maybe this can be helpfull to you. Rachid Kolfin |
The Following 3 Users Say Thank You to Rachid Kolfin For This Useful Post: | ||
Sung Kim (03-03-2010) |
#3
|
||||
|
||||
Help in doing a Rail line Simulation
Hi Rachid Kolfin
We are developing a Rail Line simulation and on reading your post above, it would be great if you could help us in building our model. Basically We are developing the Rail Line right now, and we have got Flexsim to show the different stations on our rail line which are represented by Network Nodes. We are confused on the code on how to connect each node to the other. Basically, i am reading a global table as below. Station X coord Y coord No: of tracks Predecessor NN1 23 45 1 NN2 NN2 36 39 2 NN3, NN4 NN3 78 96 2 NN5, NN6 and so on........ Could you please help us in the code for connecting our Network Nodes.......... Thanks in advance... |
#4
|
|||
|
|||
Same Q/A as here
|
The Following User Says Thank You to Jason Lightfoot For This Useful Post: | ||
Rachid Kolfin (01-24-2011) |
#5
|
||||
|
||||
How to Read the predecessor in code
Hello
Thanks for that, we could get 2 stations NN1 and NN2 connected. This is the code we used. treenode fromobj = rank(model(),4); treenode toobj = rank(model(),3); contextdragconnection(fromobj, toobj , "A"); We are basically reading from a global table, and we have 10,000 + stations. We would like to know how do we change the code in such away that each station is connected to its predecessor by reading the values from the global table... This is the format we use in our global table. Station Name X Coord Y Coord Z Coord Connected To NN1 1 1 0 NN2 NN2 4 5 0 NN3 This is the code we use to read from the global table. treenode nnobj = node("/NetworkNode", library()); treenode tnode; for(int row =1; row<=gettablerows("Nodes");row++) { tnode = createinstance(nnobj, model()); setname(tnode, gettablestr("Nodes", row, 1)); setloc(tnode, gettablenum("Nodes", row, 2), gettablenum("Nodes", row, 3), gettablenum("Nodes", row, 4)); We would like to know how to edit this code so that we would be able to connect NN1 to NN2 and NN2 to NN3. Thanks .. |
#6
|
|||
|
|||
Hello Nischith,
One way you could do this is loop through the table twice: first time create all the nodes from the first column, second time create all the connections. This way you are sure that all the nodes exist when making the connections. you can use the following code to connect the nodes: treenode fromobj = node( concat( "/", gettablestr( "Nodes", row, 1 ) ), model() ); treenode toobj = node( concat( "/", gettablestr( "Nodes", row, 4 ) ), model() ); if( objectexists( fromobj ) && objectexists( toobj ) ) { contextdragconnection(fromobj, toobj , "A"); } Esther |
The Following User Says Thank You to Esther Bennett For This Useful Post: | ||
Nischith Kashyap (01-26-2011) |
#7
|
||||
|
||||
Add Attributes to a link
Hello
Things are going good, and we are able to read and display the different stations and they all are connected the way we want them. Different tracks have different speed limits, and we would like to read from the database the max speed at which the train can pass through but how do we assign an attribute to a link joining two network nodes saying thats the max speed for that link. Thanks for the help. |
#8
|
|||
|
|||
You need to do it in both directions on the output connections of the network nodes as the link is bidirectional by default.
settablenum(connectionsout(<netnode>),<edgenum>,PORT_SPEED,<edgemaxspeed>) |
#9
|
||||
|
||||
How to Access the tree structure via code ??
Hi
We are moving on to the transporter logic, and we have a few aspects which we would like to put into a transporter. 1. How do we access values in the tree structure through code. Basically we would be reading the mean speed of a transporter from a database, and it varies between different transporters. So we would like Flexsim to read from a database and assign the maxspeed and acceleration values in the tree structure. 2. We would also like to show a track being unavailable at a particular instant of time, and hence no transporter is allowed to pass through that track, so they will either have to slow down or stop. Any ideas how we could implement this in code in flexsim ?? Actually there wont be any transporter using that track, but still that track wont be usable at a particular time, and hence we are planning to use the setstate() command to make the train idle or busy....... Thanks |
#10
|
|||
|
|||
1) setvarnum(<traveler>,"maxspeed",<dbspeedvalue>)
2) closenodeedge(<netnode>,<edgenum>) - again this is one direction only. Last edited by Jason Lightfoot; 02-02-2011 at 10:35 AM. Reason: format of user entered parameter in 2) |
#13
|
|||
|
|||
Yes that's right - the output port number is the edge number
|
The Following User Says Thank You to Jason Lightfoot For This Useful Post: | ||
Sebastian Hemmann (02-03-2011) |
#14
|
||||
|
||||
Could you just give a brief idea what is <netnode>,<edgenum>
|
#15
|
||||
|
||||
Help in accessing the tree structure....
Hi
Could you please help me in accessing the tree structure. I basically am reading values from a table, and as time ticks by, the type of a connection out should change.. I have written my code as follows, but there is some error, and i am not able to reach the "type" Please see the attached screen shot of my tree structure, and if you could please help me in my code. My code so far is as follows. for(int row=1; row<=gettablerows("Bondi Junction UP"); row++) { int track1 = 1; { int j = (track1-1)*2+2; //pt("j = "); pf(j); //pr; if (gettablenum("Bondi Junction UP", row, j)==0) { setnodenum(node("/Bondi Junction>connections/connectionsout/To EdgeCliff/type",model()),1); pt("type = "); pf();pr(); } else { setnodenum(node("/Bondi Junction>connections/connectionsout/To EdgeCliff/type",model()),2); } } } for(int row=1; row<=gettablerows("Bondi Junction UP"); row++) { int track2 = 2; { int j = (track2-1)*2+2; //pt("j = "); pf(j); //pr; if (gettablenum("Bondi Junction UP", row, j)==0) { setnodenum(node("/Bondi Junction>connections/connectionsout/To EdgeCliff/type",model()),1); } else { setnodenum(node("/Bondi Junction>connections/connectionsout/To EdgeCliff/type",model()),2); } } } I am putting this code as a user event which repeats every tick, and i would like the NN to pass and not pass the transporter accordingly. I did try this as a user event but it did not show the network nodes getiing blocked and unblocked. Please help... Last edited by Nischith Kashyap; 02-03-2011 at 11:24 PM. |
Thread | Thread Starter | Forum | Replies | Last Post |
draw network nodes using data from an excel sheet | Vinay Mehendiratta | Q&A | 7 | 10-14-2014 08:40 AM |
Animate using flow nodes? | jspeece | Q&A | 1 | 08-20-2009 09:31 AM |
Connecting network nodes in different containers | KelvinHo | Q&A | 1 | 05-28-2008 06:49 AM |
Find all nodes toggled as C++ | Brandon Peterson | Tips and Tricks | 0 | 04-18-2008 03:36 PM |
Expertfit cannot find network key - Flexsim Network License | Kris Geisberger | Q&A | 0 | 02-05-2008 05:10 PM |