question

MarcPost avatar image
0 Likes"
MarcPost asked Puerta answered

Display future exit time on text

I have been trying to state on a text the expected finish time of a heating process. To do so, I have obtained the entry time in seconds via process flow using “getmodelunit(CURRENT_TIME)” and added the time required for the process in a label I assigned to the processor (Hora).

time.png

I wanted to display that label on time format (HH:MM:SS), but I have not been able to complete the code correctly. Please note that the model units are in minutes.

Object current = ownerobject(c);

treenode textnode = param(1);

/***popup:DisplayLabelValue*/

/**Display Label Value*/

string starttext = /** \nText: *//***tag:text*//**/"Hora Fin H1: "/**/;

Object involved = node(/** \nObject: *//***tag:object*//**/"H PIT 1"/**/,model());

string labelname = /** \nLabel: *//***tag:label*//**/"Hora"/**/;

double timeinseconds = involved.Hora;

int cumulative = 0;

int daynumber = (timeinseconds / (3600 * 24)) + 1;

cumulative += (daynumber-1) * 3600 * 24;

int hournumber = (timeinseconds - cumulative) / 3600;

cumulative += hournumber * 3600;

int minutenumber = (timeinseconds - cumulative) / 60;

cumulative += minutenumber * 60;

int secondnumber = timeinseconds - cumulative;

string hourstring = string.fromNum(hournumber, 0);

string minutestring = string.fromNum(minutenumber, 0);

string secondstring = string.fromNum(secondnumber, 0);

if (hournumber < 10) hourstring = concat("0", hourstring);

if (minutenumber < 10) minutestring = concat("0", minutestring);

if (secondnumber < 10) secondstring = concat("0", secondstring);

string timetext = concat("Day ",

string.fromNum(daynumber, 0),", ",

hourstring,":",

minutestring,":",

secondstring);

textnode.value = starttext + timetext;

Any help on this matter is sincerely appreciated.

Thank you in advance.

FlexSim 21.0.10
timeprocesstextdisplay
time.png (72.5 KiB)
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

Jason Lightfoot avatar image
2 Likes"
Jason Lightfoot answered

Use Model.dateTime to which you can apply an additional time and format string.

5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

José Antonio MD avatar image
2 Likes"
José Antonio MD answered

Hello @MarcPost ,

You should use "Model.time" instead of "getmodelunit(CURRENT_TIME)". See the attached example.23.1. DIT Example.fsm


I hope I have been helpful.



231-dit-example.fsm (30.1 KiB)
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

Puerta avatar image
1 Like"
Puerta answered

Hello,

I had to make a couple adjustments but it worked. Thank you very much!

5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.