Uploaded image for project: 'Runtime'
  1. Runtime
  2. RUNTIME-1475

Monitoring graphs should use ExtJS graph API

XMLWordPrintable

    • Icon: New Feature New Feature
    • Resolution: Fixed
    • Icon: Major Major
    • 4.0RC2
    • None
    • None
    • None

      function temperaturesJSON($fromDate, $toDate)
      	{
      		global $SONDES;
      		
      		// Let us export at the json format
      		$cmd = "rrdtool xport --start ".$fromDate." --end ".$toDate." --json ";
      		
      		$i = 1;
              foreach ($SONDES as $name => $Sonde)
      		{
      			$cmd .= _temperaturesJSON($i, $name);
      			$i++;
      		}
      		$cmd .= _temperaturesJSON($i, "out");
      		$val = shell_exec($cmd);
      		
      		// Let us repair the json, so it will effectively be a json
      		$val = str_replace(' data:', ' "data":', $val);
      		$val = str_replace(' about:', ' "about":', $val);
      		$val = str_replace(' meta:', ' "meta":', $val);
      		$val = str_replace(' start:', ' "start":', $val);
      		$val = str_replace(' step:', ' "step":', $val);
      		$val = str_replace(' end:', ' "end":', $val);
      		$val = str_replace(' legend:', ' "legend":', $val);
      		$val = str_replace("'", '"', $val);
      		
      		// Now let us convert to the json format for extjs
      		$obj = json_decode($val);
      		$startTime = $obj->meta->start;
      		$step = $obj->meta->step;
      		
      		$currentTime = $startTime;
      		
      		$newObj = array( "data" => array() );
      		
      		foreach ($obj->data as $index => $array)
      		{
      			$newArray = array( "time" => $currentTime*1000 );
      			
      			foreach ($obj->meta->legend as $legendIndex => $legendName)
      			{
      				$newArray[$legendName] = $array[$legendIndex] != null ? $array[$legendIndex] : undefined;
      			}
      			
      			$newObj['data'][] = $newArray;	
      			
      			$currentTime += $step;
      		}
      		// ok we can return it now
      		$retVal = json_encode($newObj);
      		return $retVal;
      	}
      
      

            sprieul Simon Prieul (Inactive)
            raphael Raphaël Franchet
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: