Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
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