<?php /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ require_once "internals.php"; require_once "lib/RetriggerController.php"; require_once "lib/DB/TaskQueue.php"; require_once "lib/DB/QueuedTask.php"; require_once "lib/Slack.php"; init_database(); if ($unit = GET_int("unit")) { $queue = new TaskQueue($unit); if ($queue->has_active_task()) { Slack::log("requesting new task, while old task is still running!"); $task = $queue->get_active_task(); $task->reportError("Requested new task, while this task was still running."); } if (!$queue->has_queued_tasks()) { if (!RetriggerController::fillQueue($unit)) { die("No tasks to schedule"); } } $task = $queue->get_oldest_available_queued_task(); if (!$task) { echo json_encode(array("task" => "sleep 60", "id" => 0)); die; } $task->setStarted(); echo json_encode(array("task" => $task->task(), "id" => $task->id)); die;
$qTasks = mysql_query("SELECT * FROM control_tasks WHERE control_unit_id =" . $unit->id) or die(mysql_error()); if (mysql_num_rows($qTasks) == 0) { echo "<td>/"; } else { echo "<td>"; while ($task = mysql_fetch_object($qTasks)) { $machine = Machine::FromId($task->machine_id); $mode = Mode::FromId($task->mode_id); echo $machine->description(); echo $mode ? " with " . $mode->name() : ""; echo "<br>"; } } $queue = new TaskQueue($unit->id); echo "<td>"; if ($queue->has_active_task()) { $active = $queue->get_active_task(); echo "running"; echo "<span title='" . date("G:i d/m/Y", $active->start_time()) . "'> started " . time_ago($active->start_time()) . " ago</span>"; } else { echo "not running"; } echo "<td>"; if ($queue->has_queued_tasks()) { $tasks = $queue->get_queued_tasks(); $count = count($tasks); echo $count . " tasks"; if ($count > 0 && !$queue->has_active_task()) { $min = $tasks[0]->available_time(); $min_task = $task[0]; foreach ($tasks as $task) {