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).
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.