Code cleanup

This commit is contained in:
dg9vh 2016-05-05 22:45:33 +02:00
parent 38020c74dd
commit 5378637aed
2 changed files with 7 additions and 12 deletions

View file

@ -35,7 +35,6 @@ function getHeardList($logLines) {
$duration = ""; $duration = "";
$loss = ""; $loss = "";
$ber = ""; $ber = "";
$endmode = "";
//removing invalid lines //removing invalid lines
if(strpos($logLine,"BS_Dwn_Act")) { if(strpos($logLine,"BS_Dwn_Act")) {
continue; continue;
@ -50,6 +49,8 @@ function getHeardList($logLines) {
$duration = strtok($lineTokens[2], " "); $duration = strtok($lineTokens[2], " ");
$loss = $lineTokens[3]; $loss = $lineTokens[3];
// if RF-Packet, no LOSS would be reported, so BER is in LOSS position
if (startsWith($loss,"BER")) { if (startsWith($loss,"BER")) {
$ber = substr($loss, 5); $ber = substr($loss, 5);
$loss = ""; $loss = "";
@ -57,6 +58,7 @@ function getHeardList($logLines) {
$loss = strtok($loss, " "); $loss = strtok($loss, " ");
$ber = substr($lineTokens[4], 5); $ber = substr($lineTokens[4], 5);
} }
switch (substr($logLine, 27, strpos($logLine,",") - 27)) { switch (substr($logLine, 27, strpos($logLine,",") - 27)) {
case "D-Star": case "D-Star":
$dstarduration = $duration; $dstarduration = $duration;
@ -80,6 +82,7 @@ function getHeardList($logLines) {
break; break;
} }
} }
$timestamp = substr($logLine, 3, 19); $timestamp = substr($logLine, 3, 19);
$mode = substr($logLine, 27, strpos($logLine,",") - 27); $mode = substr($logLine, 27, strpos($logLine,",") - 27);
$callsign2 = substr($logLine, strpos($logLine,"from") + 5, strpos($logLine,"to") - strpos($logLine,"from") - 6); $callsign2 = substr($logLine, strpos($logLine,"from") + 5, strpos($logLine,"to") - strpos($logLine,"from") - 6);
@ -88,10 +91,12 @@ function getHeardList($logLines) {
$callsign = substr($callsign2, 0, strpos($callsign2,"/")); $callsign = substr($callsign2, 0, strpos($callsign2,"/"));
} }
$callsign = trim($callsign); $callsign = trim($callsign);
$id =""; $id ="";
if ($mode == "D-Star") { if ($mode == "D-Star") {
$id = substr($callsign2, strpos($callsign2,"/") + 1); $id = substr($callsign2, strpos($callsign2,"/") + 1);
} }
$target = substr($logLine, strpos($logLine, "to") + 3); $target = substr($logLine, strpos($logLine, "to") + 3);
$source = "RF"; $source = "RF";
if (strpos($logLine,"network") > 0 ) { if (strpos($logLine,"network") > 0 ) {
@ -120,8 +125,8 @@ function getHeardList($logLines) {
$ber = $ysfber; $ber = $ysfber;
break; break;
} }
// Callsign or ID should be less than 8 chars long, otherwise it could be errorneous
if ( strlen($callsign) < 8 ) { if ( strlen($callsign) < 8 ) {
array_push($heardList, array($timestamp, $mode, $callsign, $id, $target, $source, $duration, $loss, $ber)); array_push($heardList, array($timestamp, $mode, $callsign, $id, $target, $source, $duration, $loss, $ber));
$duration = ""; $duration = "";
@ -152,7 +157,6 @@ function getActualMode($logLines) {
foreach ($logLines as $logLine) { foreach ($logLines as $logLine) {
if (strpos($logLine, "Mode set to")) { if (strpos($logLine, "Mode set to")) {
return substr($logLine, 39); return substr($logLine, 39);
//break;
} }
} }
return "Idle"; return "Idle";
@ -214,14 +218,6 @@ function getActualLink($logLines, $mode) {
array_multisort($logLines,SORT_DESC); array_multisort($logLines,SORT_DESC);
switch ($mode) { switch ($mode) {
case "D-Star": case "D-Star":
/*
foreach ($logLines as $logLine) {
if (strpos($logLine, "D-Star link status set to")) {
return substr($logLine, 54, strlen($logLine) - 56);
}
}
return "not linked";
*/
return getDSTARLinks(); return getDSTARLinks();
break; break;
case "DMR Slot 1": case "DMR Slot 1":

View file

@ -24,7 +24,6 @@ $lastHeard = getLastHeard($logLines);
<?php <?php
for ($i = 0; ($i < LHLINES) AND ($i < count($lastHeard)); $i++) { for ($i = 0; ($i < LHLINES) AND ($i < count($lastHeard)); $i++) {
$listElem = $lastHeard[$i]; $listElem = $lastHeard[$i];
//$timestamp, $mode, $callsign, $id, $target
echo"<tr>"; echo"<tr>";
echo"<td>$listElem[0]</td>"; echo"<td>$listElem[0]</td>";
echo"<td>$listElem[1]</td>"; echo"<td>$listElem[1]</td>";