Disable Schedule Entries
During the testing or development of your project, you may have created schedules that were never executed. They could be stuck in the past in a "Manual Pending" state, for example.
Use the following script to check and disable schedule entries in the past.
Clean schedule entries
Python |
def cleanSchedules(startDate, endDate, debugMode): f = system.mes.object.filter.createFilter() f.setMESObjectTypeName("OperationsRequest") objs = system.mes.loadMESObjects(f) faultList = system.mes.object.list.createList() for obj in objs: if "Pending" in obj.getSegmentScheduleState() and obj.getBeginDateTime().before(endDate) and obj.getBeginDateTime().after(startDate): print "Sched [%s] [%s] BeginDateTime [%s]" % (obj.getName(), obj.getSegmentScheduleState(), obj.getBeginDateTime()) if not debugMode: obj.setSegmentScheduleState("Failed") faultList.add(obj) system.mes.saveMESObjects(faultList) #Months begin at 0, not 1 #https://docs.inductiveautomation.com/display/DOC81/system.date.getDate startDate = system.date.getDate(2024, 0, 1) endDate = system.date.getDate(2024, 11, 31) print "From ", startDate, " To ", endDate debugMode = True #Set debugMode to False to commit changes cleanSchedules(startDate, endDate, debugMode) |