1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76
|
//
// Copyright (c) 1997, 2005, 2006 by Mike Romberg ( mike.romberg@noaa.gov )
//
// This file may be distributed under terms of the GPL
//
#ifndef _BTRYMETER_H_
#define _BTRYMETER_H_
#include "fieldmeter.h"
#include "xosview.h"
#include <string>
class BtryMeter : public FieldMeter {
public:
BtryMeter( XOSView *parent );
~BtryMeter( void );
const char *name( void ) const { return "BtryMeter"; }
void checkevent( void );
void checkResources( void );
// some basic fields of 'info','alarm','state'
// XXX: should be private
struct acpi_batt {
int alarm; // in mWh
int design_capacity; // in mWh
int last_full_capacity; // in mWh
int charging_state; // charged=0,discharging=-1,charging=1
int present_rate; // in mW, 0=unknown
int remaining_capacity; // in mW
};
acpi_batt battery;
static bool has_source( void );
protected:
void getpwrinfo( void );
private:
bool getapminfo( void );
bool getacpi_or_sys_info( void );
bool use_apm;
bool use_acpi;
bool use_syspower;
bool acpi_battery_present(const std::string& filename);
bool acpi_parse_battery(const std::string& filename);
bool sys_battery_present(const std::string& filename);
bool sys_parse_battery(const std::string& filename);
static bool has_acpi(void);
static bool has_apm(void);
static bool has_syspower(void);
void handle_apm_state(void);
void handle_acpi_state(void);
int apm_battery_state;
int old_apm_battery_state;
int acpi_charge_state;
int old_acpi_charge_state;
int acpi_sum_cap;
int acpi_sum_remain;
int acpi_sum_rate;
int acpi_sum_alarm;
};
#endif
|