1 |
788fa6d8
|
horkym
|
<?php
|
2 |
|
|
|
3 |
|
|
function process_traffic_matrix($parser, $traffic, $idRecordTimeTable, $idRecordTable, &$insertRTT, &$insertRT, $date) {
|
4 |
|
|
$times = array();
|
5 |
|
|
|
6 |
|
|
for ($i = 0; $i < $parser->HOW_MANY_INTERVALS; $i++) {
|
7 |
|
|
$times[$i] = array();
|
8 |
|
|
$times[$i][0] = new DateTime($date);
|
9 |
|
|
$times[$i][1] = new DateTime($date);
|
10 |
|
|
|
11 |
|
|
$fromSec = (int) (($i * $parser->intervalMilli) / 1000);
|
12 |
|
|
$toSec = (int) (($i + 1) * $parser->intervalMilli / 1000);
|
13 |
|
|
|
14 |
|
|
$fromHours = (int) ($fromSec / 3600);
|
15 |
|
|
$fromMinutes = (int) (($fromSec - $fromHours * 3600) / 60);
|
16 |
|
|
$fromSeconds = (int) ($fromSec - $fromHours * 3600 - $fromMinutes * 60);
|
17 |
|
|
|
18 |
|
|
$toHours = (int) ($toSec / 3600);
|
19 |
|
|
$toMinutes = (int) (($toSec - $toHours * 3600) / 60);
|
20 |
|
|
$toSeconds = (int) ($toSec - $toHours * 3600 - $toMinutes * 60);
|
21 |
|
|
|
22 |
|
|
$times[$i][0]->setTime($fromHours, $fromMinutes, $fromSeconds);
|
23 |
|
|
$times[$i][1]->setTime($toHours, $toMinutes, $toSeconds);
|
24 |
|
|
}
|
25 |
|
|
|
26 |
|
|
foreach ($traffic as $device => $timeIntervals) {
|
27 |
|
|
for ($t = 0; $t < $parser->HOW_MANY_INTERVALS; $t++) {
|
28 |
|
|
if ($timeIntervals[$t] != NULL) {
|
29 |
|
|
for ($d = 0; $d < 2; $d++) {
|
30 |
|
|
$dataExists = FALSE;
|
31 |
|
|
|
32 |
|
|
for ($v = 0; $v < 11; $v++) {
|
33 |
|
|
if ($timeIntervals[$t][$d][$v][0] > 0) {
|
34 |
|
|
$dataExists = TRUE;
|
35 |
|
|
$insertRT[] = "('".$idRecordTable++."', '".$timeIntervals[$t][$d][$v][0]."', '".($timeIntervals[$t][$d][$v][1] / $timeIntervals[$t][$d][$v][0])."', '$v', '$idRecordTimeTable')";
|
36 |
|
|
}
|
37 |
|
|
}
|
38 |
|
|
|
39 |
|
|
if ($dataExists) {
|
40 |
|
|
$insertRTT[] = "('".$idRecordTimeTable++."', '".$times[$t][0]->format("Y-m-d H:i:s.u")."', '".$times[$t][1]->format("Y-m-d H:i:s.u")."', '".($d + 1)."', '$device')";
|
41 |
|
|
}
|
42 |
|
|
}
|
43 |
|
|
}
|
44 |
|
|
}
|
45 |
|
|
}
|
46 |
|
|
}
|
47 |
|
|
|
48 |
|
|
?>
|