libsensors_chip.h
Go to the documentation of this file.
00001 /*
00002  * Software License Agreement (BSD License)
00003  *
00004  * Copyright (c) 2014, Open Source Robotics Foundation, Inc
00005  * All rights reserved.
00006  *
00007  * Redistribution and use in source and binary forms, with or without
00008  * modification, are permitted provided that the following conditions
00009  * are met:
00010  *
00011  *  * Redistributions of source code must retain the above copyright
00012  *    notice, this list of conditions and the following disclaimer.
00013  *  * Redistributions in binary form must reproduce the above
00014  *    copyright notice, this list of conditions and the following
00015  *    disclaimer in the documentation and/or other materials provided
00016  *    with the distribution.
00017  *  * Neither the name of the Open Source Robotics Foundation nor the
00018  *    names of its contributors may be used to endorse or promote
00019  *    products derived from this software without specific prior
00020  *    written permission.
00021  *
00022  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00023  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00024  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
00025  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
00026  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
00027  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
00028  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00029  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00030  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00031  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
00032  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00033  * POSSIBILITY OF SUCH DAMAGE.
00034  */
00035 
00036 /*
00037  * Author: Mitchell Wills
00038  */
00039 
00040 #ifndef SENSOR_CHIP_H_
00041 #define SENSOR_CHIP_H_
00042 
00043 #include <stdlib.h>
00044 #include <sensors/sensors.h>
00045 #include <vector>
00046 #include <boost/shared_ptr.hpp>
00047 
00048 #include <diagnostic_updater/diagnostic_updater.h>
00049 
00050 class SensorChipSubFeature;
00051 class SensorChipFeature;
00052 class SensorChip;
00053 
00054 typedef boost::shared_ptr<SensorChip> SensorChipPtr;
00055 typedef boost::shared_ptr<SensorChipFeature> SensorChipFeaturePtr;
00056 typedef boost::shared_ptr<SensorChipSubFeature> SensorChipSubFeaturePtr;
00057 
00058 
00062 class SensorChip{
00063 private:
00064   std::string name_;
00065   sensors_chip_name const * internal_name_;
00066 public:
00067   SensorChip(sensors_chip_name const *chip_name,
00068       const std::vector<std::string> &ignore);
00069   const std::string &getName() const {return name_;}
00070   std::vector<SensorChipFeaturePtr> features_;
00071 
00072   friend class SensorChipFeature;
00073   friend class SensorChipSubFeature;
00074 };
00075 
00076 
00080 class SensorChipFeature {
00081 private:
00082   std::string name_;
00083   std::string label_;
00084   std::string full_name_;
00085   std::string full_label_;
00086   const SensorChip& chip_;
00087   sensors_feature const *feature_;
00088   void enumerate_subfeatures();
00089 
00090 public:
00091   std::vector<SensorChipSubFeaturePtr> sub_features_;
00092   SensorChipFeature(const SensorChip& chip, sensors_feature const *feature);
00093   SensorChipSubFeaturePtr getSubFeatureByType(sensors_subfeature_type type);
00094 
00095   const std::string &getFeatureName() const {return name_;};
00096   const std::string &getFeatureLabel() const {return label_;};
00097   const std::string &getFullName() const {return full_name_;};
00098   const std::string &getFullLabel() const {return full_label_;};
00099   sensors_feature_type getType(){return feature_->type;};
00100   std::string getChipName(){return chip_.getName();};
00101 
00106   virtual void buildStatus(diagnostic_updater::DiagnosticStatusWrapper &stat) = 0;
00107 
00108   friend class SensorChipSubFeature;
00109 };
00110 
00111 
00115 class SensorChipSubFeature {
00116 private:
00117   std::string name_;
00118   const SensorChipFeature& feature_;
00119   sensors_subfeature const *subfeature_;
00120 public:
00121   SensorChipSubFeature(const SensorChipFeature& feature,
00122       sensors_subfeature const *subfeature);
00123   const std::string &getName() { return name_; }
00124   sensors_subfeature_type getType() { return subfeature_->type; }
00125   double getValue();
00126 };
00127 
00128 
00129 class FanSensor : public SensorChipFeature{
00130  public:
00131   FanSensor(const SensorChip& chip, sensors_feature const *feature) :
00132     SensorChipFeature(chip, feature) {}
00133   virtual void buildStatus(diagnostic_updater::DiagnosticStatusWrapper &stat);
00134 };
00135 
00136 
00137 class TempSensor : public SensorChipFeature{
00138  public:
00139   TempSensor(const SensorChip& chip, sensors_feature const *feature) :
00140     SensorChipFeature(chip, feature) {}
00141   virtual void buildStatus(diagnostic_updater::DiagnosticStatusWrapper &stat);
00142 };
00143 
00144 
00145 class VoltageSensor : public SensorChipFeature{
00146  public:
00147   VoltageSensor(const SensorChip& chip, sensors_feature const *feature) :
00148     SensorChipFeature(chip, feature) {}
00149   virtual void buildStatus(diagnostic_updater::DiagnosticStatusWrapper &stat);
00150 };
00151 
00152 
00156 class OtherSensor : public SensorChipFeature{
00157  public:
00158   OtherSensor(const SensorChip& chip, sensors_feature const *feature) :
00159     SensorChipFeature(chip, feature) {}
00160   virtual void buildStatus(diagnostic_updater::DiagnosticStatusWrapper &stat);
00161 };
00162 
00163 
00164 #endif


libsensors_monitor
Author(s): Mitchell Wills
autogenerated on Fri Feb 12 2016 01:51:18