PDA

View Full Version : WatchExpressionList


Jason Lightfoot
09-03-2008, 04:58 PM
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

Jason Lightfoot
08-01-2009, 05:08 AM
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/forum/showthread.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.

LINWEIXU
08-04-2009, 01:00 AM
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

Tom David
08-04-2009, 01:17 AM
Please have a look into this thread:

http://www.flexsim.com/community/forum/showthread.php?t=1020

Jason Lightfoot
11-09-2010, 08:52 AM
Updated the .t file to prevent v5 type checking errors and provide a better message format.