Changeset 12afe34 for src/webapp


Ignore:
Timestamp:
Apr 27, 2017, 11:49:07 AM (10 years ago)
Author:
Joachim Langenbach <joachim.langenbach@…>
Branches:
debian/bullseye, debian/jessie
Children:
f553e71
Parents:
7b68139 (diff), c84f87e (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'master' into debian/jessie

Location:
src/webapp
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • src/webapp/webclient/javascript/main.js

    r7b68139 r12afe34  
    11/*
    22
    3     Copyright (C) 2016 EngSaS - Engineering Solutions and Services Langenbach. All rights reserved.
     3    Copyright (C) 2016 - 2017 EngSaS - Engineering Solutions and Services Langenbach. All rights reserved.
    44
    55    This library is free software; you can redistribute it and/or
    … …  
    122122$(document).ready(function() {
    123123        displayDataGet();
    124         setInterval(displayDataGet, 15000);
    125        
     124        setInterval(displayDataGet, 10000);
     125
    126126        $.getJSON("../webservice/tileserver.php?/map.json", mapSetup);
    127127       
  • src/webapp/webservice/inc/Config.php

    r7b68139 r12afe34  
    11<?php
    22/*
    3     Copyright (C) 2016 EngSaS - Engineering Solutions and Services Langenbach. All rights reserved.
     3    Copyright (C) 2016 - 2017 EngSaS - Engineering Solutions and Services Langenbach. All rights reserved.
    44
    55    This program is free software: you can redistribute it and/or modify
    … …  
    4747                if(array_key_exists("datadirectory", $this->_config))
    4848                        return addTrailingSlash($this->_config["datadirectory"]);
    49                 return __DIR__ ."/../data/";
     49                return "/var/lib/gnuboat/";
    5050        }
    5151
  • src/webapp/webservice/index.php

    r7b68139 r12afe34  
    11<?php
    22/*
    3     Copyright (C) 2016 EngSaS - Engineering Solutions and Services Langenbach. All rights reserved.
     3    Copyright (C) 2016 - 2017 EngSaS - Engineering Solutions and Services Langenbach. All rights reserved.
    44
    55    This program is free software: you can redistribute it and/or modify
    … …  
    3838);
    3939
    40 function addRrdData($interval, $period, &$result, &$lastTime){
     40function addRrdData($interval, $period, &$result, &$lastValid){
    4141        global $dbFile;
    4242        global $debug;
    4343        global $configRound;
     44        $lastValid = false;
    4445
    45         $data = rrd_fetch($dbFile, array( "AVERAGE", "--resolution", $interval, "--start", "-". $period, "--end", "start+". $period));
     46        $endTime = floor(time() / $interval) * $interval;
     47        $startTime = $endTime - $period;
     48        $data = rrd_fetch($dbFile, array("AVERAGE", "--resolution", $interval, "--start", $startTime, "--end", $endTime));
     49        // $data = rrd_fetch($dbFile, array("AVERAGE", "--resolution", $interval, "--start", "-". $period, "--end", "start+". $period, "--align-start"));
    4650        if($data === false){
    4751                echo json_encode($result);
    … …  
    5155                else
    5256                        error_log($message);
     57                return;
    5358        }
    5459
    … …  
    7681                echo "<p>Variables: ". $itemCount ."; Timeframes: ". $timeframesCount ."</p>\n";
    7782        }
    78         $keysTimeframes = array_keys($data[$keyTimeframes]);
    79         for($i = 0; $i < $timeframesCount; $i++){
    80                 $time = $keysTimeframes[$i];
     83        foreach($data[$keys[0]] as $timeframe => $value){
    8184                $allValid = true;
     85                $gpsFix = false;
    8286                $tmp = array();
    8387                foreach($keys as $key){
    8488                        if($key == "gpsfix"){
    85                                 switch($data[$key][$time]){
    86                                         case 1:
     89                                switch($data[$key][$timeframe]){
     90                                        case 2:
    8791                                                $tmp[$key] = "2D";
     92                                                $gpsFix = true;
    8893                                                break;
    89                                         case 2:
     94                                        case 3:
    9095                                                $tmp[$key] = "3D";
     96                                                $gpsFix = true;
    9197                                                break;
    9298                                        default:
    … …  
    95101                        }
    96102                        else{
    97                                 $tmp[$key] = $data[$key][$time];
     103                                $tmp[$key] = $data[$key][$timeframe];
    98104                                if(!is_numeric($tmp[$key]) || is_nan($tmp[$key])){
    99105                                        $allValid = false;
    … …  
    108114                // only add the timeframe to the track, if the values are valid and we had a gps fix at that time
    109115                if($allValid){
    110                         if(!array_key_exists($time, $result["track"])){
    111                                 $result["track"][$time] = $tmp;
    112                         }
    113                         $lastTime = $time;
     116                        $lastValid = $tmp;
     117                        if($gpsFix){
     118                                if(!array_key_exists($timeframe, $result["track"])){
     119                                        $result["track"][$timeframe] = $tmp;
     120                                }
     121                        }
    114122                }
    115123                else{
    … …  
    121129                }
    122130        }
    123 
    124131        ksort($result["track"]);
    125132}
    … …  
    165172                exit;
    166173        }
    167         // Fetch entries of the last 30 seconds
    168         addRrdData("5s", "30s", $result, $lastTime);
    169         if($lastTime > -1){
    170                 $result["lastvalid"] = $result["track"][$lastTime];
     174        // Fetch entries of the last 30s with maximum (available) resolution of 2s
     175        addRrdData("2", "240", $result, $lastValid);
     176        if($lastValid){
     177                $result["lastvalid"] = $lastValid;
    171178        }
    172         addRrdData("15s", "5minutes", $result, $lastTime);
    173         addRrdData("30s", "12h", $result, $lastTime);
     179        // Fetch entries of the last 1h with maximum (available) resolution of 10s
     180        addRrdData("10", "36000", $result, $lastTime);
     181        // Fetch entries of the last 24h with maximum (available) resolution of 60s
     182        addRrdData("60", "86400", $result, $lastTime);
    174183}
    175184
    176185if($debug > 0){
    177         echo json_encode($result,  JSON_PRETTY_PRINT);
     186        echo json_encode($result,  JSON_PRETTY_PRINT) ."\n";
    178187}
    179188else{
    180         echo json_encode($result);
     189        echo json_encode($result) ."\n";
    181190}
    182191
Note: See TracChangeset for help on using the changeset viewer.