Skip to content

Commit

Permalink
fix type casting for schedule samples (see #420)
Browse files Browse the repository at this point in the history
  • Loading branch information
JoelBender committed Aug 25, 2021
1 parent c6fca99 commit c3094d2
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 16 deletions.
34 changes: 22 additions & 12 deletions samples/LocalScheduleObject1.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,16 @@ def do_now(self, args):
y = _localtime()
print("y: {}".format(y))

def do_dc(self, args):
"""dc"""
args = args.split()
if _debug:
TestConsoleCmd._debug("do_dc %r", args)

for so in schedule_objects:
print(so.objectName)
so.debug_contents()


#
# __main__
Expand Down Expand Up @@ -103,7 +113,7 @@ def main():
objectName="Schedule 1",
presentValue=Integer(8),
effectivePeriod=DateRange(startDate=(0, 1, 1, 1), endDate=(254, 12, 31, 2),),
weeklySchedule=[
weeklySchedule=ArrayOf(DailySchedule, 7)([
DailySchedule(
daySchedule=[
TimeValue(time=(8, 0, 0, 0), value=Integer(8)),
Expand All @@ -113,7 +123,7 @@ def main():
]
),
]
* 7,
* 7),
scheduleDefault=Integer(0),
)
_log.debug(" - so: %r", so)
Expand All @@ -129,7 +139,7 @@ def main():
objectName="Schedule 2",
presentValue=CharacterString(""),
effectivePeriod=DateRange(startDate=(0, 1, 1, 1), endDate=(254, 12, 31, 2),),
exceptionSchedule=[
exceptionSchedule=ArrayOf(SpecialEvent)([
SpecialEvent(
period=SpecialEventPeriod(
calendarEntry=CalendarEntry(date=Date("2000-01-01").value,),
Expand All @@ -140,7 +150,7 @@ def main():
],
eventPriority=1,
),
],
]),
scheduleDefault=CharacterString("Don't panic."),
)
_log.debug(" - so: %r", so)
Expand All @@ -155,7 +165,7 @@ def main():
objectName="Schedule 3",
presentValue=CharacterString(""),
effectivePeriod=DateRange(startDate=(0, 1, 1, 1), endDate=(254, 12, 31, 2),),
exceptionSchedule=[
exceptionSchedule=ArrayOf(SpecialEvent)([
SpecialEvent(
period=SpecialEventPeriod(
calendarEntry=CalendarEntry(weekNDay=xtob("FF.FF.05"),),
Expand All @@ -165,7 +175,7 @@ def main():
],
eventPriority=1,
),
],
]),
scheduleDefault=CharacterString("Keep working."),
)
_log.debug(" - so: %r", so)
Expand All @@ -181,15 +191,15 @@ def main():
objectName="Schedule 4",
presentValue=Real(73.5),
effectivePeriod=DateRange(startDate=(0, 1, 1, 1), endDate=(254, 12, 31, 2),),
weeklySchedule=[
weeklySchedule=ArrayOf(DailySchedule, 7)([
DailySchedule(
daySchedule=[
TimeValue(time=(9, 0, 0, 0), value=Real(78.0)),
TimeValue(time=(10, 0, 0, 0), value=Null()),
]
),
]
* 7,
* 7),
scheduleDefault=Real(72.0),
listOfObjectPropertyReferences=SequenceOf(DeviceObjectPropertyReference)(
[
Expand All @@ -212,7 +222,7 @@ def main():
objectName="Schedule 5",
presentValue=Integer(0),
effectivePeriod=DateRange(startDate=(0, 1, 1, 1), endDate=(254, 12, 31, 2),),
exceptionSchedule=[
exceptionSchedule=ArrayOf(SpecialEvent)([
SpecialEvent(
period=SpecialEventPeriod(
calendarEntry=CalendarEntry(weekNDay=xtob("FF.FF.FF"),),
Expand Down Expand Up @@ -260,7 +270,7 @@ def main():
listOfTimeValues=[TimeValue(time=(1, 0, 0, 0), value=Integer(1)),],
eventPriority=5,
),
],
]),
scheduleDefault=Integer(0),
)
_log.debug(" - so: %r", so)
Expand All @@ -278,15 +288,15 @@ def main():
objectName="Schedule 6",
presentValue=Integer(0),
effectivePeriod=DateRange(startDate=(0, 1, 1, 1), endDate=(254, 12, 31, 2),),
exceptionSchedule=[
exceptionSchedule=ArrayOf(SpecialEvent)([
SpecialEvent(
period=SpecialEventPeriod(
calendarEntry=CalendarEntry(weekNDay=xtob("FF.FF.FF"),),
),
listOfTimeValues=ltv,
eventPriority=1,
),
],
]),
scheduleDefault=Integer(0),
)
_log.debug(" - so: %r", so)
Expand Down
8 changes: 4 additions & 4 deletions samples/LocalScheduleObject2.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def do_except(self, args):
start_time = Time(start_string).value
stop_time = Time(stop_string).value

exception_schedule = [
exception_schedule = ArrayOf(SpecialEvent)([
SpecialEvent(
period=SpecialEventPeriod(
calendarEntry=CalendarEntry(date=except_date)
Expand All @@ -92,7 +92,7 @@ def do_except(self, args):
],
eventPriority=1,
)
]
])
if _debug:
TestConsoleCmd._debug(" - exception_schedule: %r", exception_schedule)

Expand Down Expand Up @@ -152,7 +152,7 @@ def main():
objectName="Test Schedule",
presentValue=Real(8.0),
effectivePeriod=DateRange(startDate=(0, 1, 1, 1), endDate=(254, 12, 31, 2)),
weeklySchedule=[
weeklySchedule=ArrayOf(DailySchedule, 7)([
DailySchedule(
daySchedule=[
TimeValue(time=(8, 0, 0, 0), value=Real(8.0)),
Expand All @@ -161,7 +161,7 @@ def main():
]
)
]
* 7,
* 7),
listOfObjectPropertyReferences=ListOf(DeviceObjectPropertyReference)(
[
DeviceObjectPropertyReference(
Expand Down

0 comments on commit c3094d2

Please sign in to comment.