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 08-23-2011
Frans Zeng Frans Zeng is offline
Flexsim User
 
Join Date: Apr 2010
Location: Wuhan, China
Posts: 28
Downloads: 16
Uploads: 0
Thanks: 17
Thanked 1 Time in 1 Post
Rep Power: 123
Frans Zeng is on a distinguished road
Default How to get the "loadtime" value of TaskExecuter by using code?

Hi, all.
In my projects, I want to get the "loadtime" value of TaskExecuter, the loadtime is on the TE's attribute tree, and here is my code:

int loadtime = getnodenum(node("/BasicTE1>variables/loadtime/1",model()));

BasicTE1 is name of object in my model.
The aboving code returns 0, but I have set the value of "loadtime" of BasicTE1 to 120 (for example). That is to say, I cann't get the correct value of "loadtime" by using the aboving code.

How to do that?

Thanks in advance.
  #2  
Old 08-23-2011
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

Code:
treenode item=<an item>;    //loadtime expects an item to be passed in
treenode station=<anobject>;  // loadtime expects a station 
treenode te=node("/BasicTE1",model());  // if you can assume it's located in the model - if it travels on networks within a hierarchy you cannot assume this.
double loadtime = nodefunction(getvarnode(te,"loadtime"),item,station);
The Following User Says Thank You to Jason Lightfoot For This Useful Post:
Frans Zeng (08-23-2011)
  #3  
Old 08-23-2011
Frans Zeng Frans Zeng is offline
Flexsim User
 
Join Date: Apr 2010
Location: Wuhan, China
Posts: 28
Downloads: 16
Uploads: 0
Thanks: 17
Thanked 1 Time in 1 Post
Rep Power: 123
Frans Zeng is on a distinguished road
Default thanks

Thanks Jason, I appreciate your advice. It is exactly what I am looking for!
But I have another question, I don't catch the meaning of the two parameters, i.e. 'item' and 'station' in your code.
I have checked the Flexsim Command Documentation and found the following words about nodefunction, "Any parameters that need to be passed to the function are passed as par1, par2, etc."
In my opinion, the loadtime is an inherent attribute of TaskExecuter, so I don't need to pass any parameters to the function.

The last question, can I use the similar code to get other variables of TE, such as maxspeed and maxcontent?
  #4  
Old 08-24-2011
Sebastian Hemmann's Avatar
Sebastian Hemmann Sebastian Hemmann is offline
Flexsim User
 
Join Date: Sep 2009
Location: Braunschweig (Germany)
Posts: 439
Downloads: 52
Uploads: 0
Thanks: 472
Thanked 217 Times in 154 Posts
Rep Power: 319
Sebastian Hemmann is a splendid one to beholdSebastian Hemmann is a splendid one to beholdSebastian Hemmann is a splendid one to beholdSebastian Hemmann is a splendid one to beholdSebastian Hemmann is a splendid one to beholdSebastian Hemmann is a splendid one to beholdSebastian Hemmann is a splendid one to behold
Default

Think for maxspeed and maxcontent it would be possible to use getvarnum() because both are variables that are setted as numbers.
__________________
Hemmi
The Following 2 Users Say Thank You to Sebastian Hemmann For This Useful Post:
Kris Geisberger (08-24-2011)
  #5  
Old 08-24-2011
Kris Geisberger Kris Geisberger is offline
Flexsim Canada, Forum Moderator
 
Join Date: Aug 2007
Location: Canada
Posts: 209
Downloads: 54
Uploads: 1
Thanks: 99
Thanked 389 Times in 133 Posts
Rep Power: 451
Kris Geisberger has much to be proud ofKris Geisberger has much to be proud ofKris Geisberger has much to be proud ofKris Geisberger has much to be proud ofKris Geisberger has much to be proud ofKris Geisberger has much to be proud ofKris Geisberger has much to be proud ofKris Geisberger has much to be proud ofKris Geisberger has much to be proud ofKris Geisberger has much to be proud of
Default

Frans,
Quote:
In my opinion, the loadtime is an inherent attribute of TaskExecuter, so I don't need to pass any parameters to the function.
Yes... when Flexsim executes the code, but by using nodefunction you are executing the code yourself, it will not give you the result of a previous execution. So you need to pass item and station references into the nodefunction command IF your loadtime code uses them to determine the return value.
The Following 2 Users Say Thank You to Kris Geisberger For This Useful Post:
Sebastian Hemmann (08-24-2011)


Thread Thread Starter Forum Replies Last Post
Taskexecuter state "blocked"? Tom David Q&A 4 03-09-2012 12:56 PM
Is it possible one object comprised of the function of "combiner" and "separetor"? Vic Li Q&A 1 08-19-2008 04:41 AM
about "no select" and "show parameter window from side bar" qin tian Gripes and Goodies 3 03-21-2008 08:10 AM
Which variable stores "Properties -> General ->Flags -> Protected" information? KelvinHo Q&A 1 03-06-2008 06:18 AM
"Getting Started" and "Tutorial" models for v4.01 Cliff King Product Announcements 0 12-10-2007 07:34 PM


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.