void LightScheduler_WakeUp(void) { int i; Time time; TimeService_GetTime(&time); Day today = time.dayOfWeek; int minuteOfDay = time.minuteOfDay; for (i = 0; i < MAX_EVENTS; i++) { ScheduledLightEvent * event = &eventList[i]; /* if (eventIsReadyToExecute(&time, event)) */ /* operateLight(event); */ /* resetRandomize(event); */ if (event->id == UNUSED) continue; if (!matchesDay(&time, event)) continue; if (minuteOfDay == event->minuteOfDay + event->randomMinutes) { operateLight(event); resetRandomize(event); } } }
void LightScheduler_WakeUp(void) { Time time; TimeService_GetTime(&time); processEventDueNow(&time, &scheduledEvent); }
TEST(FakeTimeService, Create) { Time time; TimeService_GetTime(&time); LONGS_EQUAL(TIME_UNKNOWN, time.minuteOfDay); LONGS_EQUAL(TIME_UNKNOWN, time.dayOfWeek); }
void LightScheduler_Wakeup(void) { int i; Time time; TimeService_GetTime(&time); for (i = 0; i < MAX_EVENTS; i++) { processEventDueNow(&time, &scheduledEvents[i]); } }
void LightScheduler_WakeUp(void) { Time time; TimeService_GetTime(&time); if (scheduledEvent.id == UNUSED) return; if (time.minuteOfDay != scheduledEvent.minuteOfDay) return; LightController_On(scheduledEvent.id); }
void LightScheduler_WakeUp(void) { int i; Time time; TimeService_GetTime(&time); for (i = 0; i < MAX_EVENTS; i++) { ScheduledLightEvent * event = &eventList[i]; if (eventIsReadyToExecute(&time, event)) { operateLight(event); resetRandomize(event); } } }
void LightScheduler_WakeUp(void) { int i; Time time; TimeService_GetTime(&time); Day today = time.dayOfWeek; int minuteOfDay = time.minuteOfDay; for (i = 0; i < MAX_EVENTS; i++) { /* if (eventIsReadyToExecute()) */ /* operateLight(); */ ScheduledLightEvent * event = &eventList[i]; if (event->id != UNUSED) { /* if (matchesDay(time, event)) */ Day day = event->day; if ( (day == EVERYDAY) || (day == today) || (day == WEEKEND && (SATURDAY == today || SUNDAY == today)) || (day == WEEKDAY && (today >= MONDAY && today <= FRIDAY))) { /* it's the right day */ if (minuteOfDay == event->minuteOfDay + event->randomMinutes) { /* operateLight(event); */ if (TURN_ON == event->event) LightController_TurnOn(event->id); else if (TURN_OFF == event->event) LightController_TurnOff(event->id); /* resetRandomize(event); */ if (event->randomize == RANDOM_ON) event->randomMinutes = RandomMinute_Get(); else event->randomMinutes = 0; } } } } }
void LightScheduler_WakeUp(void) { int i; Time time; TimeService_GetTime(&time); Day td = time.dayOfWeek; int min = time.minuteOfDay; for (i = 0; i < MAX_EVENTS; i++) { ScheduledLightEvent * se = &eventList[i]; if (se->id != UNUSED) { Day d = se->day; if ( (d == EVERYDAY) || (d == td) || (d == WEEKEND && (SATURDAY == td || SUNDAY == td)) || (d == WEEKDAY && (td >= MONDAY && td <= FRIDAY))) { /* it's the right day */ if (min == se->minuteOfDay + se->randomMinutes) { if (TURN_ON == se->event) LightController_TurnOn(se->id); else if (TURN_OFF == se->event) LightController_TurnOff(se->id); if (se->randomize == RANDOM_ON) se->randomMinutes = RandomMinute_Get(); else se->randomMinutes = 0; } } } } }
void CheckThatTimeDoesNotMatch(Day day) { TimeService_GetTime(&time); CHECK(!Time_MatchesDayOfWeek(&time, day)); }
void CheckThatTimeMatches(Day day) { TimeService_GetTime(&time); CHECK(Time_MatchesDayOfWeek(&time, day)); }