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

View file

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

View file

@ -12,7 +12,7 @@
</tr>
<?php
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, "DMR Slot 1")."</td>";
echo"<td>".getActualLink($logLines, "DMR Slot 2")."</td>";