Esempio n. 1
0
                <TH>Temp</TH>
                <TH>Alarm Type</TH>
                <TH>Time Raised</TH>
                <TH>Updated</TH>
                <TH>Description</TH>
            </TR>
            <?php 
        while (list($serial, $alarm) = each($alarms)) {
            while (list($id, $alarm) = each($alarms[$serial])) {
                //$text .= $s['name'].':'.$alarm['description'].'. Active since '.$alarm['time_raised'];
                //append each alarm
                echo '<TR>' . makeTD('Alarm', 'Alarm!', null, 'icon-warning.gif') . '<TD>';
                echo color($list[$serial]['name'], $list[$serial]['color']);
                echo '</TD><TD>';
                if (isset($toggleUnits)) {
                    echo Utils::myRound(Utils::toCelcius($alarm['Fahrenheit']), 2) . 'C';
                } else {
                    echo $alarm['Fahrenheit'] . 'F';
                }
                echo '</TD><TD>' . $alarm['alarm_type'] . '</TD><TD>' . $alarm['time_raised'] . '</TD><TD>' . $alarm['time_updated'] . '</TD><TD>' . $alarm['description'] . '</TD></TR>';
            }
            //echo makeTD($content, $text, 'red', 'icon-warning.gif');
        }
        ?>
            </TABLE>
            <?php 
    }
}
?>
    
    <!-- show stats table? -->
Esempio n. 2
0
 /**
  * Normally gets info about all sensors
  *  If no list supplied, gets all sensors whether or not they are described
  *
  * if sensor SerialNumber array is supplied, just gets 
  * the requested ones
  *
  *  Returned structure is
  *  array[serialNumber][dataAboutit]
  *  dataAboutIt includes name, description, allowed min, max, alarms, etc
  *  (all columns of the metadata table)
  */
 function listSensors($sensors = null, $units = null)
 {
     $result = array();
     if (!isset($units)) {
         $units = $conf['data']['units'];
     }
     //        $q = 'SELECT DISTINCT b.* FROM ' . $this->_params['table']. " a , ". $this->_params['table_meta']. " b where a.SerialNumber = b.SerialNumber ";
     $q = 'SELECT * FROM ' . $this->_params['table_meta'] . ' b ';
     if (isset($sensors) && is_array($sensors)) {
         $q .= ' WHERE b.SerialNumber in (';
         $q .= $this->makeInList($sensors);
         $q .= ')';
     }
     $q .= ' order by b.name asc';
     //echo "Running query : $q";
     /* Run the query. */
     $qr = $this->_db->query($q);
     if (!DB::isError($qr)) {
         $row = $qr->fetchRow(DB_FETCHMODE_ASSOC);
         //echo "Got row";
         while ($row && !DB::isError($row)) {
             //print_r($row);
             if ($units == 'Celcius') {
                 $row['max'] = Utils::toCelcius($row['max']);
                 $row['min'] = Utils::toCelcius($row['min']);
             }
             $result[$row['SerialNumber']] = $row;
             $row = $qr->fetchRow(DB_FETCHMODE_ASSOC);
         }
     }
     unset($qr);
     //just to clear things up
     if ($sensors == null) {
         //now, if sensor list is null, get the real list of readings from the table..
         //Cause until now the list is based on the metadata contents
         //This will add fake defaults to the resulting array for any non-described sensors
         //This way a new sensor will be displayed before it is described
         //and the array sort will remain unchanged
         $distinctList = $this->listDistinctSensors();
         while (list($num, $ser) = each($distinctList)) {
             if (!isset($result[$ser])) {
                 //echo "Adding fake entry for ".$ser;
                 $result[$ser] = $this->makeFakeArray($ser);
             }
         }
     } else {
         if (isset($sensors) && is_array($sensors)) {
             //now check for sensors that were not describecd
             //but were passed in on the list
             reset($sensors);
             while (list($num, $ser) = each($sensors)) {
                 if (!isset($result[$ser])) {
                     //put a fake in there
                     //echo "calling make fake array with $ser";
                     $result[$ser] = $this->makeFakeArray($ser);
                 }
             }
         }
     }
     //echo "Done<P>Returning";
     //print_r($result);
     return $result;
 }