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
|
|||
|
|||
Questions on coding
In my model, I try to record the time an item go through the whole system. In real case, the procrossors will have random breakdown, so I hope to record the breakdown start time and end time if the item is in procrossing in the server by using labels. However, I don't know how to get the item's label in the coding in the timetable[onDown] tigger, does anyone have help on the coding?
My coding in timetable[onDown] tigger now: treenode current = ownerobject(c); treenode members = var_s(current,"members"); double tablerow = parval(1); { //************* PickOption Start *************\\ /**Set Label*/ setlabelnum( /** \nObject: */ /**/current/**/, /** \nLabel: */ /**/"breakdown start time"/**/, /** \nValue: */ /**/duniform(1,3)/**/ ); /**\n\n*/ } //******* PickOption End *******\\ |
#2
|
||||
|
||||
Hello Jack,
you can copy the code to the Down and Resume function or OnDown and OnResume. The trick is to find the pointer to the Flowitem in the Processor, since it isn't declared in the functions. As long as a flowitem exists in the Processor, it will be the first object in the processor. Code:
treenode item = first(downobject);// pointer to a possible flowitem in the Processor if (objectexists(item)) // test, if there is a flowitem { setlabelnum(item,"breakdown start time",time()); //write the value "start time" or "end time" } Jörg |
The Following User Says Thank You to Jörg Vogel For This Useful Post: | ||
Jack Lai (02-06-2012) |
#3
|
|||
|
|||
Thanks for your reply. However, my program is still wrong, an error message [unknown variable downobject] is occurred. Can you show me the whole coding of your program.
Actually, I don't understand the code[treenode item = first(downobject)] How this code can point to flowitem? Also, I hope the program can get the value of start time and end time. Can you show me an example of how to get the value from a label in the ondown function. Many thanks! Jack |
#4
|
||||
|
||||
If your Code shows this error message, please share the complete text with us. Maybe we can figur out, what is wrong ;-)
For questions about commands you allways can have a look in Help -> Commands. "first" creates a reference to the first object, which is in the object you name in the braces. I understand this is really hard, if you don´t got any experience with programming. Maybe you just start with having a look on whats happening while using some options of picklists;-)
__________________
Hemmi |
#5
|
||||
|
||||
Hello Jack,
the Triggers OnDown and OnResume don't work with my code. In those functions it is not so easy to get a pointer to the involved member. Jörg |
#6
|
||||
|
||||
Hello Jack,
in the Down Function or Resume Function you find in the code a pointer to the downobject. In your model is the Processor3 the downobject. A processing flowitem is the content of the processor. Therefore the processor is the container for the flowitem. first(container) is a reference to the first object in the container. Other commands to reference objects in the container are, last(container) and rank(container, list number). Jörg |
The Following User Says Thank You to Jörg Vogel For This Useful Post: | ||
Jack Lai (02-06-2012) |
Thread | Thread Starter | Forum | Replies | Last Post |
Two questions that are raised | David Chan | Container Terminal (CT) Library | 6 | 01-22-2010 09:23 AM |
Questions of TrafficControl ? | Li Chin | Q&A | 0 | 01-15-2009 07:32 AM |
Need help for coding on lifts. | chrisquek | Q&A | 5 | 11-25-2008 03:00 AM |
A pitfall in Flexsim coding | AlanZhang | Gripes and Goodies | 7 | 05-16-2008 03:37 PM |