";
echo "
";
// CSS definitions
?>
';
echo "\n";
echo "\n";
?>
";
echo "";
echo "";
echo "
";
echo "";
echo "";
}
else {
// Result
$result = "";
// Start
$start = microtime_float();
// Specific customer, remove DIPB and IB Luik
$customer = " AND klant NOT IN(20,76)";
if ((isset($_GET['customer'])) && ($_GET['customer'] != -1)) {
$customer .= " AND klant=" . (int)$_GET['customer'];
}
// Specific project
$project = "";
if ((isset($_GET['project'])) && ($_GET['project'] != -1)) {
$project = " AND id=" . (int)$_GET['project'];
}
// Get all released/ready for releas rc projects
$projects = array_sort(db_fetch("project", '*', "(sstatus='vrijgegeven' OR sstatus='verzoek tot vrijgeven') AND type='RC' AND parent IS NULL AND status != 'afgesloten'" . $customer . $project), "naam");
if (is_array($projects)) {
$equip = array();
$equip_id = array();
// Collect all devices
foreach($projects as $project) {
// Retrieve available active equipment on this project
$project_equip = db_fetch_project_lances($project['id'], "", array(array("gsm","gprs"),"kortsluiting schakelen","meting"), 1, array("actief"), array("actief"));
if (is_array($project_equip)) {
foreach($project_equip as $item) {
if (!in_array($item['id'], $equip_id)) {
array_push($equip, $item);
array_push($equip_id, $item['id']);
}
}
}
}
// Get non-cached status
$equip = tcpclient_non_cached_status($equip, FALSE, (3 * TCP_TIMEOUT));
foreach($projects as $project) {
// Retrieve available active equipment on this project
$project_equip = db_fetch_project_lances($project['id'], "", array(array("gsm","gprs"),"kortsluiting schakelen","meting"), 1, array("actief"), array("actief"));
if (!is_array($project_equip)) {
// no RC devices on this project
continue;
}
// Get customer info
$project_cust = db_fetch_customer($project['klant'], 1);
$result .= " " . $project['naam'] . " (" . $project_cust['bedrijfsnaam'] . ")
";
foreach($project_equip as $item) {
$pos = array_search($item['id'], $equip_id);
if ($pos !== FALSE) {
if ($equip[$pos]['found']) {
// Get measurement
$measurement = ($equip[$pos]['status']['mcu']['status'] & 0x0001) == 0x0001;
// Get switch status (Switch = 1 => Short circuit = 1!!!! (non-inverted))
$switch = $equip[$pos]['status']['switch3000']['on'];
$switchErr = (($equip[$pos]['status']['mcu']['switch3000 status'] & 0xF0) != 0);
// Get key (0: operational, 1: on, 2:off)
$key = ($equip[$pos]['status']['switch3000']['key']['on']) ? 1 : (($equip[$pos]['status']['switch3000']['key']['off']) ? 2 : 0);
// Get battery values
$batt_main = $equip[$pos]['status']['batt']['1']['V'];
$batt_backup = $equip[$pos]['status']['batt']['0']['V'];
// Detection?
switch(($equip[$pos]['status']['detection']['ok']) . $switch) {
case "11":
$detection = 1;
break;
default:
$detection = 0;
break;
}
$result .= " " . $item['idcode'];
$result .= ", " . $item['serienr'];
$result .= (($equip[$pos]['status']['mcu']['persistent'] & 0x80) ? ', released' : ', NOT RELEASED');
$result .= ", Meas.: " . (($measurement) ? "ON" : "OFF");
$result .= ", Det.: " . (($detection) ? "OK" : "NOK");
$result .= ", Sw.: " . (!$switchErr ? (($switch) ? "ON" : "OFF") : "ERROR" );
$result .= ", Keysw.: ";
switch($key) {
case 1:
$result .= "On";
break;
case 2:
$result .= "Off";
break;
default:
$result .= "Oper";
break;
}
$result .= ", Bat. main: " . round($batt_main, 2) . " V";
$result .= ", Bat. bckp: " . round($batt_backup, 2) . " V";
$result .= "
";
}
else {
$result .= " " . $item['idcode'] . ": No status response withing 6 secs
";
}
}
else {
$result .= " " . $item['idcode'] . ": Error
";
}
}
}
}
else {
$result .= "No released RC projects!!!
";
}
$exec = (microtime_float() - $start);
echo "Date/Time: " . date('Y-m-d H:i:s') . ", Execution time: " . $exec . "
";
echo $result;
}