Already error state? => Still in error state! if (in_array($item['id'], $error)) { array_push($detected, "communication"); } } } else { // Sections OK? if ((($status[0]['sw3000_state'] & 0x0F) != 0x0F) && (($status[0]['sw3000_state'] & 0x0F) != 0x00)) { array_push($detected, "section"); } // Battery OK? if (($status[0]['sw3000_state'] & 0x8F00) != 0x8F00) { // These could be jitter, please check previous log_realtime (60 - 900 secs ago) $prev_status = db_fetch_lance_logrt($item['id'], 1, convert_datetime($status[0]['t'] - 900, TRUE), convert_datetime($status[0]['t'] - 60, TRUE)); // Previous log_realtime available if (is_array($prev_status)) { // Same error? if (($prev_status[0]['sw3000_state'] & 0x8F00) != 0x8F00) { array_push($detected, "battery"); } } else { // No previoius state? => Already error state? => Still in error state! if (in_array($item['id'], $error)) { array_push($detected, "battery"); } } } // Switch enabled when measurement is disabled if ((!($status[0]['mcu_state'] & 0x0001)) && ((($status[0]['sw3000_state'] & 0x06) == 0x06) || (($status[0]['sw3000_state'] & 0x09) == 0x09))){ array_push($detected, "sw_en_meas_dis"); } // Switch disabled when measurements are enabled (key switch must not be active) if (($status[0]['mcu_state'] & 0x0001) && !((($status[0]['sw3000_state'] & 0x06) == 0x06) || (($status[0]['sw3000_state'] & 0x09) == 0x09)) && !($status[0]['rc_state'] & 0x0008)){ array_push($detected, "sw_dis_meas_en"); } } // Error detected? if (empty($detected)) { if (in_array($item['id'], $error)) { DBG("switch3000_check: " . $item['id'] . ": ok"); // Remove from zkl_logerror table db_delete("zkl_logerror", "zkl='" . $item['id'] . "' AND task_id='" . $task['id'] . "'"); } } else { DBG("switch3000_check: " . $item['id'] . ": " . implode(",", $detected) . (in_array($item['id'], $error) ? "; mail sent before" : "")); if (!in_array($item['id'], $error)) { // Store in zkl_logerror table db_store("zkl_logerror", array("zkl","tijd","task_id"), array($item['id'], $now, $task['id'])); array_push($switch3000_check, array(id => $item['id'], 'detected' => $detected)); } } } } } } if (!empty($switch3000_check)) { foreach($switch3000_check as $item) { // Fetch equipment info $item_info = db_fetch_lance($item['id'], "", 1); // Fetch owner info $cust_info = db_fetch_customer($item_info['eigenaar'], 1); // Set owner language (When service email has been selected => else default) $service_email = ""; if (strlen($cust_info['service_email'])) { i18n_settext_language($cust_info['i18n'], $_PAGE_INFO['base_path'] . "locale/"); // Set email $service_email = $cust_info['service_email']; } // Define subject $subject = "MTinfo" . " " . strtolower(_("Error")) . ": " . $item_info['idcode'] . " (" . $cust_info['bedrijfsnaam'] . ")"; // Define content $content = ""; $content .= "

"; $content .= _("Dear MTinfo user") . ",

"; $content .= _("The SWITCH 3000 of the following equipment has errors"); $content .= ": " . $item_info['idcode'] . "
"; $content .= "


"; $content .= _("Please contact") . " Dual Inventive!

"; $content .= _("Best regards") . ",

"; $content .= "MTinfo"; $content .= "

"; // Send mail (high priority) send_mail("", "", $_PAGE_INFO['ini']['comm']['dev_error'], $_PAGE_INFO['ini']['report']['no-reply'], $subject, $content, "", "", 1); } } // Set handled flag $handled = 1; ?>