Ignore:
Timestamp:
Mar 6, 2017, 10:12:13 PM (5 years ago)
Author:
Sanahuja Guillaume
Message:

batterie

File:
1 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
Note: See TracChangeset for help on using the changeset viewer.