Changeset 164 in flair-src for trunk/lib/FlairSensorActuator/src
- Timestamp:
- Mar 6, 2017, 10:12:13 PM (8 years ago)
- Location:
- trunk/lib/FlairSensorActuator/src
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/lib/FlairSensorActuator/src/BatteryMonitor.cpp
r15 r164 20 20 #include <Label.h> 21 21 #include <DoubleSpinBox.h> 22 #include <SpinBox.h> 22 23 23 24 using std::string; … … 31 32 : GroupBox(position, name) { 32 33 battery = new Label(this->NewRow(), "battery"); 33 battery_thresh = new DoubleSpinBox(this->LastRowLastCol(), "threshold", " V", 34 0, 24, .1, 1); 34 battery_thresh = new DoubleSpinBox(this->LastRowLastCol(), "threshold", " V",0, 24, .1, 1); 35 thresholdTime = new SpinBox(this->LastRowLastCol(), "threshold time", " s",1, 3600, 1, 10); 36 isUnderThershold=false; 35 37 } 36 38 … … 39 41 float BatteryMonitor::GetVoltage(void) const { return batteryvalue; } 40 42 41 bool BatteryMonitor::IsBatteryLow(void) const { 42 if (batteryvalue < battery_thresh->Value()) 43 bool BatteryMonitor::IsBatteryLow(void) { 44 if (batteryvalue <= battery_thresh->Value() && !isUnderThershold) { 45 isUnderThershold=true; 46 underThersholdStartTime=GetTime(); 47 } 48 if (batteryvalue > battery_thresh->Value()) { 49 isUnderThershold=false; 50 } 51 if(isUnderThershold && GetTime() > underThersholdStartTime + (Time)(thresholdTime->Value())*(Time)1000000000) { 43 52 return true; 44 else 45 return false; 53 } 54 55 return false; 46 56 } 47 57 -
trunk/lib/FlairSensorActuator/src/BatteryMonitor.h
r15 r164 21 21 class Label; 22 22 class DoubleSpinBox; 23 class SpinBox; 23 24 } 24 25 } … … 56 57 * 57 58 */ 58 bool IsBatteryLow(void) const;59 bool IsBatteryLow(void); 59 60 60 61 /*! … … 77 78 float batteryvalue; 78 79 gui::DoubleSpinBox *battery_thresh; 80 gui::SpinBox *thresholdTime; 79 81 gui::Label *battery; 82 core::Time underThersholdStartTime; 83 bool isUnderThershold; 80 84 }; 81 85 } // end namespace sensor
Note:
See TracChangeset
for help on using the changeset viewer.