From 83a80c1e25d21701bf408b2c27e7dc49d72e4f7b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergi=20Hern=C3=A0ndez=20Juan?= <shernand@iri.upc.edu> Date: Wed, 21 Oct 2015 15:01:32 +0000 Subject: [PATCH] Completed the example with the alarm test. Removed an invalid field from the TBatteryInfo structure. --- src/examples/segway_battery_test.cpp | 31 +++++++--------------------- src/segway_battery.h | 1 - 2 files changed, 8 insertions(+), 24 deletions(-) diff --git a/src/examples/segway_battery_test.cpp b/src/examples/segway_battery_test.cpp index afe380b..47da02f 100755 --- a/src/examples/segway_battery_test.cpp +++ b/src/examples/segway_battery_test.cpp @@ -7,12 +7,12 @@ #include <signal.h> std::string battery_dev="A900WSG1"; -/* + bool condition1(TBatteryInfo *info) { - if(info->current_in>0)// battery is discharging + if(info->battery_current<0)// battery is discharging { - if(info->rem_capacity<29990) + if(info->remaining_capacity<29990) return true; else return false; @@ -23,33 +23,24 @@ bool condition1(TBatteryInfo *info) bool condition2(TBatteryInfo *info) { - if(info->current_in>0)// battery is discharging + if(info->battery_current<0)// battery is discharging { - if(info->rem_capacity<29000) + if(info->remaining_capacity<29000) return true; else return false; } else return false; -}*/ +} int main(int argc, char *argv[]) { - int i=0; - try{ std::string cond1_event_id,cond1_name; std::string cond2_event_id,cond2_name; CSegway_Battery battery(battery_dev); - for(i=0;i<10;i++) - { - std::cout << battery << std::endl; - sleep(1); - } - -/* battery.enable_alarm_sound(); cond1_name="condition1"; cond1_event_id=battery.create_alarm(cond1_name,condition1,1); @@ -60,19 +51,13 @@ int main(int argc, char *argv[]) while(!battery.finish()) { try{ - std::cout << "Battery voltage: " << battery.get_current_voltage() << " V" << std::endl; - std::cout << "Battery temperature: " << battery.get_current_temperature() << " ºC" << std::endl; - std::cout << "Input current: " << battery.get_input_current() << " mA" << std::endl; - std::cout << "Output current: " << battery.get_output_current() << " mA" << std::endl; - std::cout << "Remaining capacity: " << battery.get_remaining_capacity() << " mAh" << std::endl; - std::cout << "Time to fully charged: " << battery.get_time_to_charged() << " min" << std::endl; - std::cout << "Time to fully discharged: " << battery.get_time_to_discharged() << " min" << std::endl; + std::cout << battery << std::endl; sleep(1); }catch(CException &e){ std::cout << e.what() << std::endl; } } - battery.disable_alarm_sound();*/ + battery.disable_alarm_sound(); }catch(CException &e){ std::cout << e.what() << std::endl; } diff --git a/src/segway_battery.h b/src/segway_battery.h index d149903..a9a4ee1 100755 --- a/src/segway_battery.h +++ b/src/segway_battery.h @@ -42,7 +42,6 @@ typedef struct TBatteryStatus status; double design_capacity; double design_voltage; - unsigned short int battery_status; unsigned short int pack_status; double cell4_voltage; double cell3_voltage; -- GitLab