source: flair-src/trunk/lib/FlairSensorActuator/src/BatteryMonitor.cpp@ 3

Last change on this file since 3 was 3, checked in by Sanahuja Guillaume, 8 years ago

sensoractuator

File size: 1.4 KB
RevLine 
[3]1// %flair:license{
2// This file is part of the Flair framework distributed under the
3// CECILL-C License, Version 1.0.
4// %flair:license}
5// created: 2014/01/24
6// filename: BatteryMonitor.cpp
7//
8// author: Guillaume Sanahuja
9// Copyright Heudiasyc UMR UTC/CNRS 7253
10//
11// version: $Id: $
12//
13// purpose: Base class for battery monitor
14//
15//
16/*********************************************************************/
17
18
19#include "BatteryMonitor.h"
20#include <Layout.h>
21#include <Label.h>
22#include <DoubleSpinBox.h>
23
24using std::string;
25using namespace flair::core;
26using namespace flair::gui;
27
28namespace flair { namespace sensor {
29
30BatteryMonitor::BatteryMonitor(const gui::LayoutPosition* position,string name) : GroupBox(position,name) {
31 battery=new Label(this->NewRow(),"battery");
32 battery_thresh=new DoubleSpinBox(this->LastRowLastCol(),"threshold"," V",0,24,.1,1);
33}
34
35BatteryMonitor::~BatteryMonitor() {
36
37}
38
39float BatteryMonitor::GetVoltage(void) const {
40 return batteryvalue;
41}
42
43bool BatteryMonitor::IsBatteryLow(void) const {
44 if(batteryvalue<battery_thresh->Value())
45 return true;
46 else
47 return false;
48}
49
50void BatteryMonitor::SetBatteryValue(float value) {
51 batteryvalue=value;
52 if(value>0) {
53 battery->SetText("battery: %.1fV",value);
54 } else {
55 battery->SetText("battery: unreadable");
56 }
57}
58
59} // end namespace sensor
60} // end namespace flair
Note: See TracBrowser for help on using the repository browser.