Пример #1
0
function fnGetNewEvents()
{
    $GetNewEventsSQL = "SELECT `intThresholdEventID` FROM `tblthresholdevents` WHERE ((booIsNew>=1));";
    #$fnGNESQL = "SELECT `intThresholdEventID` FROM `tblthresholdevents` WHERE ((booIsNew>=1))";
    echo "<br>GetNewEventsSQL: " . $GetNewEventsSQL;
    $linkgnea = mysqli_connect('localhost', 'root', '', 'climatecontroldata');
    $GetNewEvents = mysqli_query($linkgnea, $GetNewEventsSQL);
    $rsNewRows = mysqli_num_rows($GetNewEvents);
    $rsNewEvents = mysqli_fetch_assoc($GetNewEvents);
    #$rsNewEvents = mysqli_fetch_array($NewEvents, MYSQL_ASSOC);
    echo "num of new records found:  " . $rsNewRows;
    # printf ("%s (%s)\n", $rsNewRows["intThresholdEventID"]);
    #$gnedata[]=$rsNewEvents;
    echo mysqli_error($linkgnea);
    #die();
    #if (isset($rsNewRows) AND $rsNewRows >= 1)
    #{
    echo "in dispatch loop";
    #$booExistingEvents = 1;
    echo "num of new records found:  " . $rsNewRows;
    #foreach($GetNewEvents as $rsNewRows)
    #$i = 0;
    #while ($i <= $rsNewRows) {
    #	if ($i < $rsNewRows)
    #for($i=0; $i < $rsNewRows; $i=$i+1) {
    #looping like a bitch, *sigh*
    #$rsfnGED = mysqli_fetch_assoc($EventData);
    #$GNEkeys = @array_keys($rsNewEvents['intThresholdEventID']);
    #
    #F**k it, not cycling to the next record
    # Will either spam out and go ham looping forever
    # or it wont get any data  i think the issue is we have multi columned data coming thorugh
    # with multiple rows
    # i mean technically even if it only updates one at a time -- it will probably be running every `10-15 seconds.
    # okay got it back running twice to update 1 record?!
    # will need to look into this more later, moving on for now.
    #10/26/15
    for ($i = 0; $i <= 1; $i++) {
        echo "<b><b>i is" . $i;
        #f ($i > $rsNewRows) { die(); }
        $GNEretVal = $rsNewEvents['intThresholdEventID'];
        #$GNEretVal = $rsNewEvents[$i];
        #$retVal2 = $rsNewEvents[$i];
        echo "<br>KKK i= " . $i;
        echo "<br>GNEretVal = " . $GNEretVal;
        #$i = $i + 1;
        echo "<br>detected and dispatched {$rsNewEvents}=" . $GNEretVal;
        $booClearFlagTrue = fnClearNewFlag($GNEretVal);
        $intThresholdEventID = $GNEretVal;
        #$intThresholdEventID = $GNEretVal;
        fnFlagEventInProccess($intThresholdEventID, 0);
        echo "<br> fnFixClimate(" . $intThresholdEventID . ");";
        echo "<br>fnFlagEventInProccess(" . $intThresholdEventID . ",0)";
        $retVal1 = fnFixClimate($intThresholdEventID);
        #$i++;
        echo "<br> " . $intThresholdEventID;
    }
    #mysqli_next_result($linkgnea);
    echo "OIUAUHSDSIUADHADSD";
    echo "KKKKKKKKKKKKKOOOOOOOOOOO";
    #AAA111
}
Пример #2
0
#Lookup Sensor w/ SensorID passed
#Verify if individual threshhold is set for sensor, if not look at sensor type threshhold
#Record threshold min/max values into memory then make sure the $sensorValue falls between them.
# 10/25/15 -
$booExistingEvents = fnGetExistingEvents($intSensorID, $sensorValue);
if ($booExistingEvents == 1) {
    echo "in sensor.php with InProcess Threshold Event for SensorID";
    fnLogClimateData($intSensorID, $sensorValue);
    #We know Event is already dispatched and in process
    #Now we need to monitor its progres and terminate repair if we are by threshold<br>
    #Think we will be better determining whether sensor value was greater than threshold or below... then we know when we pass the median in which direction we are good.
    $intMinValTH = fnChkSensorTH($intSensorID, 0);
    $intMaxValTH = fnChkSensorTH($intSensorID, 1);
    $intMedValTH = round(($intMaxValTH - $intMinValTH) / 2, 2) + $intMinValTH;
    if ($sensorValue <= $intMedValTH * 0.1 + $intMedValTH) {
        if ($sensorValue >= $intMedValTH - $intMedValTH * 0.1) {
            echo "Reached Operational Value";
            $intThresholdEventID = fnGetExistingEventID($intSensorID);
            fnFlagEventInProccess($intThresholdEventID, 1);
        }
    }
    echo "<br><br>!SensorVal: " . $sensorValue . " TopVal: " . ($intMedValTH * 0.1 + $intMedValTH) . " LowVal: " . ($intMedValTH - $intMedValTH * 0.1);
    # Trying to be within 10% above or below median value
} else {
    if (!isset($sensorValue)) {
        echo "<br>No Sensor Value Detected!";
    } else {
        fnChkSensorValue($intSensorID, $sensorValue);
        echo "<br>SensorID = " . $intSensorID . "<br>Sensor Value = " . $sensorValue;
    }
}