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 |
|
Downloads |
Tips and Tricks Share helpful modeling ideas |
#1
|
|||
|
|||
Displaying the simulation time with the various date/time formats.
This can be accomplished with the use of a VisualTool object. Simply drag a VisualTool into your model and set it display text. Under "Text Display", choose "Display Time". The code inside gives good ideas about how to display on-screen texts.
If you want to compute the week and day using code, you can do following: Code:
double startTime = 0; int week = (time()-startTime)/7/24/3600; int day = (time()-startTime-7*24*3600*week)/24/3600; Code:
treenode current = ownerobject(c); treenode textnode = parnode(1); /**Display Time. Format - Week w, Day d*/ double startTime = 0; int week = (time()-startTime)/7/24/3600; int day = (time()-startTime-7*24*3600*week)/24/3600; string timetext = concat( "Week ", numtostring(week,0,0),", Day ", numtostring(day,0,0) ); setnodestr(textnode, timetext); |
The Following 5 Users Say Thank You to Regan Blackett For This Useful Post: | ||
stmyint (11-13-2012) |
#3
|
|||
|
|||
It does work for me, code assumes you're working on seconds, so it may take a while to change days/weeks if you're running the model slow (86400 time units for each day).. you can change the 3600 on the model for 60 to work in minutes... or 1 in hours, etc...
regards, Pablo Concha E. |
The Following User Says Thank You to Pablo Concha For This Useful Post: | ||
Dan Cremer (08-19-2008) |
#6
|
|||
|
|||
Quote:
I think this works... (working on minutes).... Code:
treenode current = ownerobject(c); treenode textnode = parnode(1); /**Display Time. Format - Week w, Day d*/ double startTime = 0; int week = (time()-startTime)/7/24/60; int day = (time()-startTime-7*24*60*week)/24/60; string daystr; switch(day) { case 0: daystr = "Monday";break; case 1: daystr = "Tuesday";break; case 2: daystr = "Wednesday";break; case 3: daystr = "Thursday";break; case 4: daystr = "Friday";break; case 5: daystr = "Saturday";break; case 6: daystr = "Sunday";break; } string timetext = concat( "Week ", numtostring(week,0,0),", ", daystr ); setnodestr(textnode, timetext); Pablo Concha E. |
The Following 3 Users Say Thank You to Pablo Concha For This Useful Post: | ||
stmyint (11-13-2012) |
#8
|
||||
|
||||
You can do this with a hotlinkx on a static control in a GUI.
Use setviewtext(c,timetext) instead of setnodestr(textnode, timetext) See the attached model. |
The Following User Says Thank You to Phil BoBo For This Useful Post: | ||
Albert Munoz (10-26-2010) |
#9
|
|||
|
|||
Thanks Phil,
I am having trouble opening the attached model, when I open it, the system console displayes the following message; exception: Exception caught in flexscript execution of VIEW:/nodefunctions/menucommands/File/openmodel line 44 instruction 109. Discontinuing execution. |
#12
|
|||
|
|||
Sorry, I am running on Version 5.00 in a computer where I have no admin priviledges. I have contacted the admin of the university faculty where the licenses are stored, hopefully this can be remedied soon.
Thanks Albert |
#13
|
||||
|
||||
Hello,
through the search function I found this article. It was helpful but I have an other problem. So I´ll open this thread again. It is possible to show the right calendar date with the visualtool? If I will start a simulation run, for example at the 1th January 2012 - how I can show that. Many thanks in advance for your help regards Michael |