Showing results for 
Search instead for 
Do you mean 
Reply

Find the index of time interval for multiple days

I would like to divide the time into a lot of 15-minute intervals and use i to be its index. Originally, I just run the model for an 8 hour shift. So I use the code below to find i. It works, so i=1 ,2, 3, ..., 32. (8 hours have 32 15-minute intervals)

 

a:=time_to_num(timeofDay(EventController.AbsSimTime))-8*3600; --the simulation begins at 2013/1/1 8:00 am, AbsSimTime is absolute time which equals 0 at 2013/1/1 0:00 am
i:=a//900;

 

Now I need to run the model for a lot of days. I need the i to be indexed by i=1,2,...,32,33,......... Which function I should use to replace the function "TimeofDay"?

 

Thanks

CSW

3 REPLIES

Re: Find the index of time interval for multiple days

you could use the ShiftCalendar:

i:= time_to_num(shiftCalendar.calculateWorkingDuration(eventController.start,eventController.absSimTime))//900

Steffen Bangsow
freelance simulation specialist  
web: www.bangsow.eu
mail: steffen@bangsow.net


Betreff: Find the index of time interval for multiple days

Hi CSW,

Steffen's solution considers that you only need interval-numbers during the working times; so e.g. you only have one 8hr-shift every day, then every day:

  • 16:00-24:00-8:00 would not have any interval-numbers (or more precisely the same interval-number as 15:45-16:00 of the previous day!),and
  • 8:00-16:00 would have 32*(numDays - 1) + {1..32} as interval numbers.

In case you need an interval number for every 15min-interval of each day, disregarding the shift-model, you could simply use

iIntervalNumber := time_to_num(EventController.SimTime) // 900;

The SimTime-attribute starts at 0, no matter what you set as starting datetime of the eventcontroller (so you don't have to subtract the 8hr like you did).

Regards,
Alex

____________________________________________________________
Alex Dilg, Consultant at SimPlan AG (www.SimPlan.de)
This post was good and/or helpful to you? Please provide some Kudos, thank you!
This answered your question? Please mark it as "Accepted Solution", thank you!

Re: Find the index of time interval for multiple days


if timeofday(eventcontroller.abssimtime)>=21600 /*(600hrs)*/ and timeofday(eventcontroller.abssimtime)<=50400/*(1400HRS)*/ then
tm:=timeofday(eventcontroller.abssimtime);
value:=tm\\900;
             if value=0 then
                   i:=i+1;
             end;

end;

 

Sachin