function fnFixClimate($intThresholdEventID) { #Looks up Sensor info for ThresholdEvent (including Thresholds and RelayMapping) #Looks up appropriate Relay to activate via RelayMapping table for that particular sensor #More TBD (do we run shell script w/ parameters to activate relay off PLC board) # $booFlagSuccess = fnFlagEventInProccess($intThresholdEventID, 0); $intSensorID = fnGetEventData($intThresholdEventID, 1); $intRelayID = fnGetRelayNum($intSensorID); return @$strFixResult; }
function fnGetValueChangeDir($intThresholdEventID) { $intOriginalEventValue = fnGetEventData($intThresholdEventID, 4); # I think 4 is the right column for captured value of event #tblSensorData.Value Where tblSensorData.SensorID=tblThresholdEvents.SensorID # SORT DESC BY tblSensorData.DataID TOP 1 # if original value > current value, return a 0, if the original value was less than the current value then return a 1 # if we want a true historical view on this we could look for the SensorData entry that corresponded with the same TimeStamp as the<br> # thresholdevent that was logged return booChangeDir; #0 is a negative change was needed to get back into target levels, a 1 means a positive change was needed }
<?php include 'base.php'; $intThresholdEventID = $_GET['evtid']; $intSensorID = fnGetEventData($intThresholdEventID, 1); $intMinValTH = fnChkSensorTH($intSensorID, 0); $intMaxValTH = fnChkSensorTH($intSensorID, 1); $intMedValTH = round(($intMaxValTH - $intMinValTH) / 2, 2) + $intMinValTH; $intRelayID = fnGetRelayNum($intSensorID); $intOrigValue = fnGetEventData($intThresholdEventID, 3); echo "<br>" . $intSensorID . " - " . $intMinValTH . " - " . $intMaxValTH . " - " . $intMedValTH . " - " . $intOrigValue; echo "<br><br>!!! - fnGetEventData({$intThresholdEventID}, 1): " . $intSensorID; echo "<br>Relay " . $intRelayID;