Comparing Model.dateTime to shiftparameters

Comparing Model.dateTime to shiftparameters

maxBYAWH
Participant Participant
107 Views
2 Replies
Message 1 of 3

Comparing Model.dateTime to shiftparameters

maxBYAWH
Participant
Participant

Hi,

 

I have a processflow where certain machines are performing tasks repetitively and Modelparameters that describe a certain shiftperiod (starthour & endhour). I am searching for an efficient way to stop the processflow logic block from looping when the model is outside of this shiftperiod. Currently I am doing this by comparing the dateTime.hour + dateTimeMinutes to the shift start/end, but this does not seem very efficient to me, even more so when more precision than minutes is needed or if I want doubles as a possibility for my start/endhour parameters.

 

What is the best alternative?

 

image.png

 
 
 
0 Likes
Accepted solutions (1)
108 Views
2 Replies
Replies (2)
Message 2 of 3

FelixMoehlmann
Collaborator
Collaborator
Accepted solution

You could also use the fractional part of the "totalDays" property.

double startHour = Model.parameters.StartTime;
double hourOfDay = Math.frac(Model.dateTime.totalDays)*24;
double delay = startHour - hourOfDay;
if(delay < 0) {
	delay += 24;
}
return delay;
Message 3 of 3

maxBYAWH
Participant
Participant

Aah did not think of that. Great easy solution. Thanks!

0 Likes