Skip to content
Snippets Groups Projects
Commit 83a80c1e authored by Sergi Hernandez's avatar Sergi Hernandez
Browse files

Completed the example with the alarm test.

Removed an invalid field from the TBatteryInfo structure.
parent 863fbb4d
No related branches found
No related tags found
No related merge requests found
...@@ -7,12 +7,12 @@ ...@@ -7,12 +7,12 @@
#include <signal.h> #include <signal.h>
std::string battery_dev="A900WSG1"; std::string battery_dev="A900WSG1";
/*
bool condition1(TBatteryInfo *info) 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; return true;
else else
return false; return false;
...@@ -23,33 +23,24 @@ bool condition1(TBatteryInfo *info) ...@@ -23,33 +23,24 @@ bool condition1(TBatteryInfo *info)
bool condition2(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; return true;
else else
return false; return false;
} }
else else
return false; return false;
}*/ }
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
int i=0;
try{ try{
std::string cond1_event_id,cond1_name; std::string cond1_event_id,cond1_name;
std::string cond2_event_id,cond2_name; std::string cond2_event_id,cond2_name;
CSegway_Battery battery(battery_dev); CSegway_Battery battery(battery_dev);
for(i=0;i<10;i++)
{
std::cout << battery << std::endl;
sleep(1);
}
/*
battery.enable_alarm_sound(); battery.enable_alarm_sound();
cond1_name="condition1"; cond1_name="condition1";
cond1_event_id=battery.create_alarm(cond1_name,condition1,1); cond1_event_id=battery.create_alarm(cond1_name,condition1,1);
...@@ -60,19 +51,13 @@ int main(int argc, char *argv[]) ...@@ -60,19 +51,13 @@ int main(int argc, char *argv[])
while(!battery.finish()) while(!battery.finish())
{ {
try{ try{
std::cout << "Battery voltage: " << battery.get_current_voltage() << " V" << std::endl; std::cout << battery << 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;
sleep(1); sleep(1);
}catch(CException &e){ }catch(CException &e){
std::cout << e.what() << std::endl; std::cout << e.what() << std::endl;
} }
} }
battery.disable_alarm_sound();*/ battery.disable_alarm_sound();
}catch(CException &e){ }catch(CException &e){
std::cout << e.what() << std::endl; std::cout << e.what() << std::endl;
} }
......
...@@ -42,7 +42,6 @@ typedef struct ...@@ -42,7 +42,6 @@ typedef struct
TBatteryStatus status; TBatteryStatus status;
double design_capacity; double design_capacity;
double design_voltage; double design_voltage;
unsigned short int battery_status;
unsigned short int pack_status; unsigned short int pack_status;
double cell4_voltage; double cell4_voltage;
double cell3_voltage; double cell3_voltage;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment