From 39dad5af40b24980d6acb8c24eafe5865802591f Mon Sep 17 00:00:00 2001 From: dg9vh Date: Thu, 12 May 2016 13:55:02 +0000 Subject: [PATCH] fix current Mode, renice printing of freq., TNX to Ron, VE1AIC --- include/functions.php | 26 +++++++++++++++++++------- include/repeaterinfo.php | 10 +++++----- include/tools.php | 5 +++++ 3 files changed, 29 insertions(+), 12 deletions(-) diff --git a/include/functions.php b/include/functions.php index 9f7baae..e95a7f7 100644 --- a/include/functions.php +++ b/include/functions.php @@ -211,15 +211,27 @@ function getLastHeard($logLines) { return $lastHeard; } -function getActualMode($logLines) { +function getActualMode($logLines, $mmdvmconfigs) { // returns mode of repeater actual working in - array_multisort($logLines,SORT_DESC); - foreach ($logLines as $logLine) { - if (strpos($logLine, "Mode set to")) { - return substr($logLine, 39); - } + $lastHeard = getLastHeard($logLines); + array_multisort($lastHeard,SORT_DESC); + $listElem = $lastHeard[0]; + + $timestamp = new DateTime($listElem[0]); + $mode = $listElem[1]; + if (startsWith($mode, "DMR")) { + $mode = "DMR"; + } + + $now = new DateTime(); + $hangtime = getConfigItem("General", "ModeHang", $mmdvmconfigs); + $timestamp->add(new DateInterval('PT' . $hangtime . 'S')); + + if ($now->format('U') > $timestamp->format('U')) { + return idle; + } else { + return $mode; } - return "Idle"; } function getDSTARLinks() { diff --git a/include/repeaterinfo.php b/include/repeaterinfo.php index 82192f6..5000acc 100644 --- a/include/repeaterinfo.php +++ b/include/repeaterinfo.php @@ -12,7 +12,7 @@ "; - echo"".getActualMode($logLines).""; + echo"".getActualMode($logLines, $mmdvmconfigs).""; echo"".getActualLink($logLines, "D-Star").""; echo"".getActualLink($logLines, "DMR Slot 1").""; echo"".getActualLink($logLines, "DMR Slot 2").""; @@ -23,8 +23,8 @@ - - + + @@ -43,8 +43,8 @@ "; echo""; - echo""; - echo""; + echo""; + echo""; if (getEnabled("DMR", $mmdvmconfigs) == 1) { echo""; if (getEnabled("DMR Network", $mmdvmconfigs) == 1) { diff --git a/include/tools.php b/include/tools.php index ccfa6fd..994476d 100644 --- a/include/tools.php +++ b/include/tools.php @@ -28,4 +28,9 @@ function format_time($seconds) { function startsWith($haystack, $needle) { return $needle === "" || strrpos($haystack, $needle, -strlen($haystack)) !== false; } + +function getMHZ($freq) { + return substr($freq,0,3) . "." . substr($freq,3,3) . "." . substr($freq,6) . " Mhz"; +} + ?> \ No newline at end of file
LocationTX-Frq.Rx-Frq.TX-Freq.Rx-Freq. ".getConfigItem("Info", "Location", $mmdvmconfigs)."".getConfigItem("Info", "TXFrequency", $mmdvmconfigs)."".getConfigItem("Info", "RXFrequency", $mmdvmconfigs)."".getMHZ(getConfigItem("Info", "TXFrequency", $mmdvmconfigs))."".getMHZ(getConfigItem("Info", "RXFrequency", $mmdvmconfigs))."".getConfigItem("DMR", "ColorCode", $mmdvmconfigs)."