Go Back   Flexsim Community Forum > Flexsim Software > Tips and Tricks
FAQ Downloads Calendar Search Mark Forums Read vBExperience Register

Tips and Tricks Share helpful modeling ideas

Reply
 
Thread Tools Display Modes
  #1  
Old 08-03-2007
Regan Blackett Regan Blackett is offline
Flexsim Consultant, Forum Moderator
 
Join Date: Jul 2007
Posts: 13
Thanks: 0
Thanked 7 Times in 3 Posts
Downloads: 15
Uploads: 1
Rep Power: 64
Regan Blackett will become famous soon enoughRegan Blackett will become famous soon enough
Default 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;
In order to display week and day in the VisualTool, replace the code in the Text Display with the following:
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);
Reply With Quote
The Following 2 Users Say Thank You to Regan Blackett For This Useful Post:
Brandon Peterson (10-24-2008), Pablo Concha (08-11-2008)
  #2  
Old 08-11-2008
Dan Cremer Dan Cremer is offline
Flexsim User
 
Join Date: Aug 2008
Posts: 3
Thanks: 1
Thanked 0 Times in 0 Posts
Downloads: 0
Uploads: 0
Rep Power: 0
Dan Cremer is on a distinguished road
Default Displaying dates

Regan:
This did not work. When I started running the model, the date did not change from "Week 0, Day 0".
Reply With Quote
  #3  
Old 08-11-2008
Pablo Concha Pablo Concha is offline
Flexsim User
 
Join Date: Aug 2007
Posts: 51
Thanks: 62
Thanked 31 Times in 21 Posts
Downloads: 98
Uploads: 1
Rep Power: 102
Pablo Concha is a jewel in the roughPablo Concha is a jewel in the roughPablo Concha is a jewel in the roughPablo Concha is a jewel in the rough
Default

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.
Reply With Quote
The Following User Says Thank You to Pablo Concha For This Useful Post:
Dan Cremer (08-19-2008)
  #4  
Old 08-19-2008
Dan Cremer Dan Cremer is offline
Flexsim User
 
Join Date: Aug 2008
Posts: 3
Thanks: 1
Thanked 0 Times in 0 Posts
Downloads: 0
Uploads: 0
Rep Power: 0
Dan Cremer is on a distinguished road
Default THANKS

I meant to thank you sooner for your reply.
Reply With Quote
  #5  
Old 10-24-2008
JMEngelhart JMEngelhart is offline
Flexsim User
 
Join Date: Sep 2008
Posts: 22
Thanks: 0
Thanked 3 Times in 3 Posts
Downloads: 8
Uploads: 0
Rep Power: 29
JMEngelhart is on a distinguished road
Default

How about if I want to display the Day of the week - ie: Sunday, Monday, etc.?
Reply With Quote
  #6  
Old 10-27-2008
Pablo Concha Pablo Concha is offline
Flexsim User
 
Join Date: Aug 2007
Posts: 51
Thanks: 62
Thanked 31 Times in 21 Posts
Downloads: 98
Uploads: 1
Rep Power: 102
Pablo Concha is a jewel in the roughPablo Concha is a jewel in the roughPablo Concha is a jewel in the roughPablo Concha is a jewel in the rough
Default

Quote:
Originally Posted by JMEngelhart View Post
How about if I want to display the Day of the week - ie: Sunday, Monday, etc.?
Hello,

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);
regards,

Pablo Concha E.
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On

Forum Jump


All times are GMT -6. The time now is 11:49 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Powered by NuWiki v1.3 RC1 Copyright ©2006-2007, NuHit, LLC
Copyright 1993-2010 Flexsim Software Products, Inc.