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 processEventsDueNow(Time * time, ScheduledLightEvent * event)
{
    if (eventIsReadyToExecute(time, event))
    {
        operateLight(event);
        resetRandomize(event);
    }
}
Beispiel #3
0
static void setEventSchedule(ScheduledLightEvent * event,
        int id, Day day, int minute, int control, int randomize)
{
        event->id = id;
        event->day = day;
        event->minuteOfDay = minute;
        event->event = control;
        event->randomize = randomize;
        resetRandomize(event);
}
void LightScheduler_Randomize(int id, Day day, int minuteOfDay)
{
    int i;
    for (i = 0; i < MAX_EVENTS; i++)
    {
        ScheduledLightEvent * e = &eventList[i];
        if (e->id == id && e->day == day && e->minuteOfDay == minuteOfDay)
        {
            e->randomize = RANDOM_ON;
            resetRandomize(e);
        }
    }
}
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);
        }
    }
}
static void scheduleEvent(int id, Day day, int minuteOfDay, int event,
        int randomize)
{
    int i;

    for (i = 0; i < MAX_EVENTS; i++)
    {
        if (eventList[i].id == UNUSED)
        {
            eventList[i].id = id;
            eventList[i].day = day;
            eventList[i].minuteOfDay = minuteOfDay;
            eventList[i].event = event;
            eventList[i].randomize = randomize;
            resetRandomize(&eventList[i]);
            break;
        }
    }
}