Calculating Remaining Shift Time For Shift Handover

Calculating Remaining Shift Time For Shift Handover

ycfuj_work1
Community Visitor Community Visitor
221 Views
1 Reply
Message 1 of 2

Calculating Remaining Shift Time For Shift Handover

ycfuj_work1
Community Visitor
Community Visitor

[FlexSim 25.2]

 

Good Morning, 

 

I have 3 Time Tables, "Morning_Shift", "Afternoon_Shift", & "Night_Shift".

I have a Process Flow with multiple tasks.

I would like the tokens flowing to go through a "Custom Code" that calculates the time remaining in their shift, and a "Decide" to compare:

 

If "token.TimeLeft" is more then "token.TaskTime", the token proceeds to complete the task.

 

If "token.TimeLeft" is less then "token.TaskTime", the token flows to a "Delay" with the time set as "token.TimeLeft + 0.01 (hrs)" to ensure that the next shift has started and the Operators of the next shift will execute the task.

 

Essentially, I don't want tokens to be in the middle of a task when the shift changes. 

 

- Each Task has a "Pull From List" & "Push To List". I understand that the "Decide" should come before the "Pull From List". 

 

Although I am having trouble with the "Custom Code" to calculate the Time Remaining for each shift. It will need to be dynamic enough to refer to which of the 3 shifts are active at the point of calculation.

 

Would you be able to help me on this section?

 

 

0 Likes
222 Views
1 Reply
Reply (1)
Message 2 of 2

FelixMoehlmann
Collaborator
Collaborator

You can get the time of day in hours since midnight with the following expression:

double hourTime = Math.frac(Model.dateTime.totalDays)*24;

The DateTime class can also tell you what day of the week it is (Model.dateTime.dayOfWeek). With those informations you should be able to get the time until the next shift change with a couple of if-conditions and simple calculations.

https://docs.flexsim.com/en/26.0/Reference/CodingInFlexSim/FlexScriptAPIReference/Data/DateTime.html 

0 Likes