Changeset 164 in flair-src for trunk/lib/FlairSensorActuator/src


Ignore:
Timestamp:
03/06/17 22:12:13 (7 years ago)
Author:
Sanahuja Guillaume
Message:

batterie

Location:
trunk/lib/FlairSensorActuator/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/FlairSensorActuator/src/BatteryMonitor.cpp

    r15 r164  
    2020#include <Label.h>
    2121#include <DoubleSpinBox.h>
     22#include <SpinBox.h>
    2223
    2324using std::string;
     
    3132    : GroupBox(position, name) {
    3233  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;
    3537}
    3638
     
    3941float BatteryMonitor::GetVoltage(void) const { return batteryvalue; }
    4042
    41 bool BatteryMonitor::IsBatteryLow(void) const {
    42   if (batteryvalue < battery_thresh->Value())
     43bool 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) {
    4352    return true;
    44   else
    45     return false;
     53  }
     54   
     55  return false;
    4656}
    4757
  • trunk/lib/FlairSensorActuator/src/BatteryMonitor.h

    r15 r164  
    2121class Label;
    2222class DoubleSpinBox;
     23class SpinBox;
    2324}
    2425}
     
    5657  *
    5758  */
    58   bool IsBatteryLow(void) const;
     59  bool IsBatteryLow(void);
    5960
    6061  /*!
     
    7778  float batteryvalue;
    7879  gui::DoubleSpinBox *battery_thresh;
     80  gui::SpinBox *thresholdTime;
    7981  gui::Label *battery;
     82  core::Time underThersholdStartTime;
     83  bool isUnderThershold;
    8084};
    8185} // end namespace sensor
Note: See TracChangeset for help on using the changeset viewer.