Hamburger Hamburger

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

1/HvcLightControl.py
2/HvcHCSR04ultrasonic.py
3/HvcPV.py
4/HvcMotorDriver.py
5/HvcRollerShutter.py
6/manGenMqttMap.py
7/HvcReadSPI.py
8/HvcMqtt.py
9/HvcTables.py
10/HvcMain.py
11/HvcSetGPIO.py
12/HvcWifiRelay.py
13/HvcOperationMode.py
14/HvcControl.py
15/HvcRaw2phys.py
16/HvcWeather.py
17/HvcOneWire.py
18/makeDoc.py
19/HvcFronius.py
20/EnergyManager.py
21/HvcSendI2C.py

php

1/HV_colorMap.php
2/HV_Admin_Login.php
3/HV_readOperationState.php
4/HV_setParameters.php
5/HV_config.php
6/EM_handleJSON.php
7/index.php
8/readFilenames.php
9/HV_restart.php
10/HV_moveGate.php
11/HV_showLog.php
12/HV_RollerShutter.php
13/EM_editParameter.php
14/HV_serviceLog.php
15/HV_H2Olevel.php
16/HV_TempCal.php
17/HV_Fronius.php
18/EM_plot.php
19/readNamedData.php
20/HV_composeH2Oplot.php
21/HVdoc.php
22/HV_showWeatherForecast.php
23/HV_showHouse.php

Der gesamte Sourcecode darf gemäß GNU General Public License weiterverbreitet werden.