BOSWatch/www/parser.php

148 lines
2.7 KiB
PHP
Raw Normal View History

<?php
//Data from TRBOS-FMS http://www.lfs-bw.de/Fachthemen/Digitalfunk-Funk/Documents/Pruefstelle/TRBOS-FMS.pdf
2015-04-08 08:01:12 +02:00
function parse($mode, $data)
{
//Data for Service Parsing
$service = array(
"0" => "Unbekannt",
"1" => "Polizei",
"2" => "Bundesgrenzschutz",
"3" => "Bundeskriminalamt",
"4" => "Katastrophenschutz",
"5" => "Zoll",
"6" => "Feuerwehr",
"7" => "Technisches Hilfswerk",
"8" => "Arbeiter-Samariter-Bund",
"9" => "Deutsches Rotes Kreuz",
"a" => "Johanniter-Unfall-Hilfe",
"b" => "Malteser-Hilfsdienst",
"c" => "Deutsche Lebensrettungsgesellschaft",
"d" => "Rettungsdienst",
"e" => "Zivilschutz",
"f" => "Fernwirktelegramm",
);
2015-04-08 08:01:12 +02:00
//Data for Country Parsing
$country = array(
"0" => "Sachsen",
"1" => "Bund",
"2" => "Baden-W<>rttemberg",
"3" => "Bayern I",
"4" => "Berlin",
"5" => "Bremen",
"6" => "Hamburg",
"7" => "Hessen",
"8" => "Niedersachsen",
"9" => "Nordrhein-Westfalen",
"a" => "Rheinland-Pflaz",
"b" => "Schleswig-Holstein",
"c" => "Saarland",
"d" => "Bayern II",
"e" => "Meck-Pom/Sachsen-Anhalt",
"f" => "Brandenburg/Th<54>ringen",
);
2015-04-08 08:01:12 +02:00
//Data for Location Parsing
$location = array(
"11" => "testLoc",
"22" => "testLoc",
"33" => "testLoc"
);
//Data for Vehicle Parsing
$vehicle = array(
"1111" => "testVeh",
"2222" => "testVeh",
"3333" => "testVeh"
);
//Data for ZVEI Parsing
2015-04-08 10:17:50 +02:00
$zvei = array(
2015-04-08 08:01:12 +02:00
"12345" => "testZvei",
"23456" => "testZvei",
"34567" => "testZvei",
);
2015-04-08 08:01:12 +02:00
switch ($mode) {
2015-04-08 08:18:53 +02:00
//Parse Service
case "service":
2015-04-08 10:17:50 +02:00
$data = substr($data,0,1);
2015-04-08 08:14:18 +02:00
if (array_key_exists($data, $service))
{
2015-04-08 10:17:50 +02:00
return $service[$data];
2015-04-08 08:01:12 +02:00
}else
{
return $data;
}
break;
2015-04-08 08:01:12 +02:00
2015-04-08 08:18:53 +02:00
//Parse Country
case "country":
2015-04-08 10:17:50 +02:00
$data = substr($data,1,1);
2015-04-08 08:14:18 +02:00
if (array_key_exists($data, $country))
{
2015-04-08 10:17:50 +02:00
return $country[$data];
2015-04-08 08:01:12 +02:00
}else
{
return $data;
}
break;
2015-04-08 08:18:53 +02:00
//Parse Location
2015-04-08 08:01:12 +02:00
case "location":
2015-04-08 10:17:50 +02:00
$data = substr($data,2,2);
2015-04-08 08:14:18 +02:00
if (array_key_exists($data, $location))
{
2015-04-08 10:17:50 +02:00
return $location[$data];
2015-04-08 08:01:12 +02:00
}else
{
return $data;
}
break;
2015-04-08 08:18:53 +02:00
//Parse Vehicle
2015-04-08 08:01:12 +02:00
case "vehicle":
2015-04-08 10:17:50 +02:00
$data = substr($data,4,4);
2015-04-08 08:14:18 +02:00
if (array_key_exists($data, $vehicle))
{
2015-04-08 10:17:50 +02:00
return $vehicle[$data];
2015-04-08 08:01:12 +02:00
}else
{
return $data;
}
break;
2015-04-08 08:18:53 +02:00
//Parse direction
case "direction":
2015-04-08 10:17:50 +02:00
if (substr($data,9,1) == 1)
2015-04-08 08:14:18 +02:00
{
return "L->F";
2015-04-08 10:17:50 +02:00
}elseif (substr($data,9,1) == 0)
2015-04-08 08:14:18 +02:00
{
return "F->L";
2015-04-08 08:01:12 +02:00
}else
2015-04-08 10:17:50 +02:00
{
2015-04-08 08:01:12 +02:00
return "ERR!";
}
break;
2015-04-08 08:18:53 +02:00
//Parse Zvei
2015-04-08 08:01:12 +02:00
case "zvei":
2015-04-08 08:14:18 +02:00
if (array_key_exists($data, $zvei))
{
2015-04-08 08:01:12 +02:00
return $data ." - ". $zvei[$data];
}else
{
return $data;
}
break;
default:
return "Parser: mode error!";
}
}
?>