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
|
|||
|
|||
WatchExpressionList
This model was put together to solve Nico Zahn's problem about how to put a global variable in a watchlist (in another forum thread)
In the attached model I've changed an instance of the standard watchlist to evaluate Flexscript expressions instead. It can be edited from the Watchlist option of the tools menu. The object is called WatchExpressionList inside /Tools/Watchers and can be copied between models (or saved and loaded as a .t file). The examples I've used trigger the watch when the queue size is greater (or no longer greater) than 4, or when the global variable 'variable1' changes (I used a script window to increment it manually for testing). Be aware that these can slow the model down quite a bit, because they fire for every event and the expressions are switched as Flexscript. It would be nice to be able to toggle between C and Flexscript, and provide an edit window instead of typing into the table cell, which would mean some watchtable GUI changes. If I get a chance to update it with those changes I will post it here. Jason |
The Following 3 Users Say Thank You to Jason Lightfoot For This Useful Post: | ||
Tom David (09-03-2008) |
#2
|
|||
|
|||
Attached is a .t file containing the node that should go into /Tools/Watchers within the model by editing the tree and using Load Into Node. You will need to run updatetoolsmenu to get it to show in the Watchlist entries, then just open it for editing as normal through the Tools menu. If you don't have a Watcher folder within /Tools, the easiest method would be to add a watch list via the Flexsim Tools menu and then load into the Watchlist object that it creates.
The example watchexpression within the object will fire for the first events with a new time that is greater than 20 time units (secs). This was added to offer another answer to the question posed here: http://www.flexsim.com/community/for...ead.php?t=1026 Note that the action code only fires when the value of the expression is evaluted to have changed. If the expression was just time()>20 the action code would fire only once - at the first event past 20. If you want the code to fire for every event (including those with duplicate times) change the expression to !getnodenum(next(c))) which will just toggle the value returned - ensuring it changes every time. Last edited by Jason Lightfoot; 08-01-2009 at 06:55 AM. |
#3
|
|||
|
|||
treenode current = ownerobject(c);
treenode watchtablerow = parnode(1); double newval = parval(2); treenode olditem = parnode(3); // node containing old value double oldval = getnodenum(olditem); i often see "ownerobject(c) parval() parnode(); " what mean "ownerobject(c)"? How should I use them("ownerobject(c) parval() parnode(); ")? thank you Last edited by Tom David; 08-06-2009 at 01:37 AM. Reason: Useless Quote |
#4
|
||||
|
||||
__________________
tom the (A)tom: "We have solved our problems ... now we have to fight the solutions." |
#5
|
|||
|
|||
v5 Update
Updated the .t file to prevent v5 type checking errors and provide a better message format.
|
The Following User Says Thank You to Jason Lightfoot For This Useful Post: | ||
Nico Zahn (11-11-2010) |