Shifts Variables

Hello there,

I'm currently using v8.1.24 and I want to reach out exist next shift variables.

I'm getting the current shift variables with that script;

import system
import datetime
import java.util.Date
import java.util.Calendar	

def ScheduleActive(dtValue, schedule):
# Retur True if scheduler (scheduleName) is active at given time point (dtValue)
#	dtValue 		...	time point that is checked (datetime)
#	schedule 		...	schedule that is checked (BasicSchedule)

	cal = java.util.Calendar.getInstance()  
	cal.setTime(dtValue); 
#	schedule = system.user.getSchedule(scheduleName)
	
	if schedule.observeHolidays:
		holidays = system.user.getHolidays()
		for holiday in holidays:
			if system.date.midnight(holiday.getDate()) == system.date.midnight(dtValue):
				return {"Active":False, "startDate": None, "endDate": None} # today is a holiday
					
	timeline = schedule.getScheduleForDay(cal)
	midnight = system.date.midnight(dtValue)
	msTime = system.date.millisBetween(midnight, dtValue)

	if timeline != None:
		segment = timeline.getSegment(msTime, False, True)
		if segment != None:
			tzOffset = system.date.getTimezoneRawOffset()
			startDate = system.date.fromMillis(system.date.toMillis(midnight)+segment.getStart()) 
			endDate = system.date.fromMillis(system.date.toMillis(midnight)+segment.getEnd())
			return {"Active":True, "startDate": startDate, "endDate":endDate}
		else:
			return {"Active":False, "startDate": None, "endDate": None}
		
	else:
		return {"Active":False, "startDate": None, "endDate": None}

How can i get next 1 hour shift variables?

Does anybody have any idea about that?

Thanks in advance.

I'm not sure what you're asking. How does it fit into that script ?

I can recommend a few things though:
It's good that you're documenting your function, but I suggest doing it like this (or something like this) instead:

def ScheduleActive(dtValue, schedule):
	"""
	Parameters:
		dtValue (datetime):			time point that is checked
		schedule (BasicSchedule):	schedule that is checked
	Return:
		True if scheduler (scheduleName) is active at given time point (dtValue)
	"""

Also note that the documented return doesn't match the actual return of the function. Be very careful with that.

Hi Pascal,

Thank you for your reply.

I basicly want to get next shift variables such as name, start time, end time.

Is there a built-in concept of shifts in ignition that I don't know about ?
Or are you talking about the alarm schedules ?

The component name is Schedule Management and it is belong to vision.

In that example, currently I'm in the Tuesday 08:00 am - 04:05 pm shift which name is Ass_1.

I want to get next scheduled shift variables with using script.

Judging from the methods used in your script, it looks like you've already found this documentation:
https://files.inductiveautomation.com/sdk/javadoc/ignition81/8.1.20/com/inductiveautomation/ignition/common/user/schedule/BasicScheduleModel.html