Heating and Ventilation Control
/HV_readOperationState
Keine Erläuterungen gefunden.
<?php /* published under GPL www.gnu.org/licenses/gpl.html */ function HV_readOperationState($opModFile){ include_once("readFilenames.php"); global $debug; $year = date('Y'); $month = date('m'); if(isset($_GET['month'])){$month=$_GET['month'];} $path = "./".$year."-".$month."/"; if($debug){echo "<p><aj>HV_readOperationState</aj>: ".$year." ".$month." ".$path."</p>";} // read logfile $files = readFilenames($path,".txt"); sort($files); $file = $files[count($files)-1]; $date=substr( $file, strpos($file,"_") ); $actFile = $path."actuatorsLog".$date; $sensFile = $path."sensorsLog".$date; list($sensors,$timeStamp) = lastData($sensFile); list($actuators,$timeStamp) = lastData($actFile); $operationMode = readOperationMode($opModFile); if($debug){ echo "<p><aj>HV_readOperationState( )</aj></p>\n"; print_r($sensors); echo "<br>"; print_r($actuators); echo "<br>"; print_r($operationMode); echo "<br>"; } return array($timeStamp,$sensors,$actuators,$operationMode); } function HV_readOperationMode($opModFile){ global $debug; $fid = fopen($opModFile,"r"); $opModStr = trim(fgets($fid,2048)); fclose($fid); $opModStr = substr($opModStr,1); $opModStr = substr($opModStr,0,strlen($opModStr)-2); $opModStr = str_replace("\"","",$opModStr); $tmp = explode(",",$opModStr); for($m=0;$m<count($tmp);$m++){ $thisM = explode(":",$tmp[$m]); $operationMode[trim($thisM[0])] = trim($thisM[1]); } #m if($debug){ echo "<p><aj>HV_readOperationMode( )</aj></p>\n"; } return $operationMode; } function lastData($file){ global $debug; if (file_exists($file)){ /* get first line of logfile for varNames */ $cmd = "head -1 ".$file; exec($cmd,$output); if($debug){echo $cmd."<br>";} $varNames = explode("\t",$output[0]); #for($v=0;$v<count($varNames);$v++){ # $ColNo[$varNames[$v]] = $v; #} #v /* get last line of data */ $cmd = "tail -1 ".$file; exec($cmd,$output); if($debug){echo $cmd."<br>";} $values = explode("\t",$output[1]); for($v=1;$v<count($varNames);$v++){ $data[$varNames[$v]] = $values[$v]; } #v /* timeStamp of logfile */ $timeStamp = $values[0]; } else { echo "<p>FILE ".$file." NOT FOUND</p>"; } #fi return array($data,$timeStamp); } ?>
python
php
Der gesamte Sourcecode darf gemäß GNU General Public License weiterverbreitet werden.