speed up list generator

This commit is contained in:
dg9vh 2016-05-13 21:36:44 +00:00
parent 7af20b03d9
commit 5b55fa135d
3 changed files with 12 additions and 5 deletions

View file

@ -87,7 +87,9 @@ function getLog() {
$logLines = array(); $logLines = array();
if ($log = fopen(MMDVMLOGFILE,'r')) { if ($log = fopen(MMDVMLOGFILE,'r')) {
while ($logLine = fgets($log)) { while ($logLine = fgets($log)) {
array_push($logLines, $logLine); if (!strpos($logLine, "Debug") && !strpos($logLine,"Received a NAK")) {
array_push($logLines, $logLine);
}
} }
fclose($log); fclose($log);
} }
@ -225,20 +227,25 @@ function getLastHeard($logLines) {
$lastHeard = array(); $lastHeard = array();
$heardCalls = array(); $heardCalls = array();
$heardList = getHeardList($logLines); $heardList = getHeardList($logLines);
$counter = 0;
foreach ($heardList as $listElem) { foreach ($heardList as $listElem) {
if ( ($listElem[1] == "D-Star") || ($listElem[1] == "YSF") || (startsWith($listElem[1], "DMR")) ) { if ( ($listElem[1] == "D-Star") || ($listElem[1] == "YSF") || (startsWith($listElem[1], "DMR")) ) {
if(!(array_search($listElem[2]."#".$listElem[1].$listElem[3], $heardCalls) > -1)) { if(!(array_search($listElem[2]."#".$listElem[1].$listElem[3], $heardCalls) > -1)) {
array_push($heardCalls, $listElem[2]."#".$listElem[1].$listElem[3]); array_push($heardCalls, $listElem[2]."#".$listElem[1].$listElem[3]);
array_push($lastHeard, $listElem); array_push($lastHeard, $listElem);
$counter++;
}
if ($counter == LHLINES) {
return $lastHeard;
} }
} }
} }
return $lastHeard; return $lastHeard;
} }
function getActualMode($logLines, $mmdvmconfigs) { function getActualMode($metaLastHeard, $mmdvmconfigs) {
// returns mode of repeater actual working in // returns mode of repeater actual working in
$lastHeard = getLastHeard($logLines); $lastHeard = $metaLastHeard;
array_multisort($lastHeard,SORT_DESC); array_multisort($lastHeard,SORT_DESC);
$listElem = $lastHeard[0]; $listElem = $lastHeard[0];
@ -364,4 +371,5 @@ function getActualLink($logLines, $mode) {
//Some basic inits //Some basic inits
$mmdvmconfigs = getMMDVMConfig(); $mmdvmconfigs = getMMDVMConfig();
$logLines = getLog(); $logLines = getLog();
$lastHeard = getLastHeard($logLines);
?> ?>

View file

@ -1,5 +1,4 @@
<?php <?php
$lastHeard = getLastHeard($logLines);
?> ?>
<div class="panel panel-default"> <div class="panel panel-default">
<!-- Standard-Panel-Inhalt --> <!-- Standard-Panel-Inhalt -->

View file

@ -12,7 +12,7 @@
</tr> </tr>
<?php <?php
echo"<tr>"; echo"<tr>";
echo"<td>".getActualMode($logLines, $mmdvmconfigs)."</td>"; echo"<td>".getActualMode($lastHeard, $mmdvmconfigs)."</td>";
echo"<td>".getActualLink($logLines, "D-Star")."</td>"; echo"<td>".getActualLink($logLines, "D-Star")."</td>";
echo"<td>".getActualLink($logLines, "DMR Slot 1")."</td>"; echo"<td>".getActualLink($logLines, "DMR Slot 1")."</td>";
echo"<td>".getActualLink($logLines, "DMR Slot 2")."</td>"; echo"<td>".getActualLink($logLines, "DMR Slot 2")."</td>";