Changeset 8a5cdba for src/webservice/htdocs/SiWeather
- Timestamp:
- Sep 8, 2015, 8:47:09 PM (11 years ago)
- Branches:
- master
- Children:
- d83a844
- Parents:
- 7271978
- Location:
- src/webservice/htdocs/SiWeather/Webservice
- Files:
-
- 2 edited
-
WebserviceApi.php (modified) (4 diffs)
-
WebserviceConfig.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
src/webservice/htdocs/SiWeather/Webservice/WebserviceApi.php
r7271978 r8a5cdba 80 80 81 81 /** 82 * @brief Registers a new weather station 83 * 84 * @note Call this function with a big timeout > 2seconds, because we use another webservice 85 * to fetch location data. This fetch runs already 2seconds. 86 * @note Requires php-pecl-uuid 87 */ 82 * @brief Registers a new weather station 83 * 84 * @note Call this function with a big timeout > 2seconds, because we use another webservice 85 * to fetch location data. This fetch runs already max. 2 seconds. 86 * @note Requires php-pecl-uuid 87 * @note Requires php-pecl-rrd 88 */ 88 89 public static function stationsRegister(){ 89 90 $geoLocationRadius = 5; … … 97 98 98 99 if(!function_exists("uuid_create")){ 100 error_log("pecl uuid extension not installed!"); 99 101 echo json_encode 100 102 ( … … 102 104 "result" => "missinguuidcreate", 103 105 "message" => "The function uuid_create() from pecl package http://pecl.php.net/package/uuid is not installed, but needed!", 106 ] 107 ); 108 return; 109 } 110 111 if(!function_exists("rrd_create") || !function_exists("rrd_update")){ 112 error_log("pecl rrd extension not installed!"); 113 echo json_encode 114 ( 115 [ 116 "result" => "missingrrd", 117 "message" => "The function rrd_create() or rrd_update() from pecl package http://pecl.php.net/package/rrd is not installed, but needed!", 104 118 ] 105 119 ); … … 305 319 } 306 320 321 // creating rrd file 322 $webserviceConfig = new WebserviceConfig(); 323 $rrdFileName = $webserviceConfig->dataDirectory() . $uuid .".rrd"; 324 $rrdCreator = new \RRDCreator($rrdFileName, "now", 900); 325 $rrdCreator->addDataSource("Temp:GAUGE:1320:-100:100"); 326 $rrdCreator->addDataSource("Humidity:GAUGE:1320:0:100"); 327 $rrdCreator->addDataSource("Pressure:GAUGE:1320:800:1200"); 328 $rrdCreator->addDataSource("WindSpeed:GAUGE:1320:0:999"); 329 $rrdCreator->addDataSource("Winddirection:GAUGE:1320:1:360"); 330 $rrdCreator->addDataSource("Rainfall:GAUGE:1320:0:999"); 331 $rrdCreator->addArchive("AVERAGE:0.5:1:96"); 332 $rrdCreator->addArchive("AVERAGE:0.5:4:96"); 333 $rrdCreator->addArchive("AVERAGE:0.5:8:360"); 334 $rrdCreator->addArchive("AVERAGE:0.5:16:2190"); 335 $rrdCreator->addArchive("AVERAGE:0.5:24:146000"); 336 $rrdCreator->addArchive("AVERAGE:0.5:48:146000"); 337 $rrdCreator->addArchive("AVERAGE:0.5:96:146000"); 338 $rrdCreator->addArchive("MIN:0.5:4:96"); 339 $rrdCreator->addArchive("MIN:0.5:8:360"); 340 $rrdCreator->addArchive("MIN:0.5:16:2190"); 341 $rrdCreator->addArchive("MIN:0.5:24:146000"); 342 $rrdCreator->addArchive("MIN:0.5:48:146000"); 343 $rrdCreator->addArchive("MIN:0.5:96:146000"); 344 $rrdCreator->addArchive("MAX:0.5:4:96"); 345 $rrdCreator->addArchive("MAX:0.5:8:360"); 346 $rrdCreator->addArchive("MAX:0.5:16:2190"); 347 $rrdCreator->addArchive("MAX:0.5:24:146000"); 348 $rrdCreator->addArchive("MAX:0.5:48:146000"); 349 $rrdCreator->addArchive("MAX:0.5:96:146000"); 350 if(!$rrdCreator->save()){ 351 $db->query("ROLLBACK"); 352 $errorMessage = rrd_error(); 353 echo json_encode 354 ( 355 [ 356 "result" => "failed", 357 "message" => "Could not create rrd files for this station: ". $errorMessage, 358 ] 359 ); 360 return; 361 } 362 307 363 // finish transaction 308 364 $db->exec("COMMIT"); -
src/webservice/htdocs/SiWeather/Webservice/WebserviceConfig.php
r7271978 r8a5cdba 66 66 67 67 public function dataDirectory(){ 68 return __DIR__ ."/../../../". $this->_config["dataDirectory"]; 68 $directory = __DIR__ ."/../../../". $this->_config["dataDirectory"]; 69 if(substr($directory, strlen($directory) - 1, 1) != "/"){ 70 $directory .= "/"; 71 } 72 return $directory; 69 73 } 70 74
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/siweather/chrome/site/your_project_logo.png)