Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
B
battery_monitor
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
labrobotica
drivers
battery_monitor
Commits
83a80c1e
Commit
83a80c1e
authored
9 years ago
by
Sergi Hernandez
Browse files
Options
Downloads
Patches
Plain Diff
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
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/examples/segway_battery_test.cpp
+8
-23
8 additions, 23 deletions
src/examples/segway_battery_test.cpp
src/segway_battery.h
+0
-1
0 additions, 1 deletion
src/segway_battery.h
with
8 additions
and
24 deletions
src/examples/segway_battery_test.cpp
+
8
−
23
View file @
83a80c1e
...
@@ -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
->
rem
aining
_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
->
rem
aining
_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
;
}
}
...
...
This diff is collapsed.
Click to expand it.
src/segway_battery.h
+
0
−
1
View file @
83a80c1e
...
@@ -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
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment