Пример #1
0
function schedule_outputValves($storedSchedule)
{
    // get which valves are open
    $valvesCurrentlyOpen = operateValves_getCurrentlyOpenValves();
    // iterate through all valves
    for ($valveIndex = 0; $valveIndex < count($storedSchedule->valves); $valveIndex++) {
        // style for valve
        $valveStyle = "float: left";
        // output valve
        schedule_outputValve($storedSchedule, $valveStyle, $valveIndex, $valvesCurrentlyOpen[$valveIndex]);
    }
}
Пример #2
0
function operateValves_performActions($schedule)
{
    // log entry
    logger_logEvent('Checking required valve commands');
    // convert schedule to a per-valve array of time ranges (start/end)
    // each range is represented by offset, in minutes, into the week
    $weeklyValveSchedule = operateValves_getWeeklyValveSchedule($schedule);
    // generate a list of valves that need to be open right now
    $valvesRequiredToBeOpen = operateValves_getListOfValvesCurrentlyRequiredOpen($weeklyValveSchedule);
    // get a list of valves that are currently open
    $valvesCurrentlyOpen = operateValves_getCurrentlyOpenValves();
    //
    // get command lists
    //
    // command lists
    $valvesToOpen = array();
    $valvesToClose = array();
    // get the commands
    operateValves_getValveCommands($valvesRequiredToBeOpen, $valvesCurrentlyOpen, $valvesToOpen, $valvesToClose);
    // execute the commands
    operateValves_executeValveCommands($valvesToOpen, $valvesToClose);
    // update currently open valves. TODO get from hardware
    operateValves_updateCurrentlyOpenValves($valvesRequiredToBeOpen);
    // print
    logger_logEvent('Currently open valves: ' . arrayToString($valvesCurrentlyOpen, ", "));
    logger_logEvent('Valves required to be open: ' . arrayToString($valvesRequiredToBeOpen, ", "));
    logger_logEvent('Opening these valves: ' . arrayToString($valvesToOpen, ", "));
    logger_logEvent('Closing these valves: ' . arrayToString($valvesToClose, ", "));
}