BatteryModel.h 3 KB
Newer Older
1 2 3
/*
   Project: batmon

4
   Copyright (C) 2006-2014 GNUstep Application Project
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24

   Author: Riccardo Mottola

   Created: 2006-01-14 23:58:48 +0100 by Riccardo

   This application is free software; you can redistribute it and/or
   modify it under the terms of the GNU General Public
   License as published by the Free Software Foundation; either
   version 2 of the License, or (at your option) any later version.

   This application is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   Library General Public License for more details.

   You should have received a copy of the GNU General Public
   License along with this library; if not, write to the Free
   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA.
*/

25 26
#import <Foundation/NSObject.h>

27 28 29 30 31 32 33
#if defined (linux)
#define DEV_SYS_POWERSUPPLY  @"/sys/class/power_supply"
#define DEV_PROC_PMU  @"/proc/pmu"
#endif



34 35 36 37 38 39 40 41 42 43 44
typedef enum
  {
    BMBStateUnknown = 0,
    BMBStateCharging,
    BMBStateDischarging,
    BMBStateHigh,
    BMBStateLow,
    BMBStateCritical,
    BMBStateFull,
    BMBStateMissing
  } BMBatteryStates;
45 46 47 48 49 50 51 52 53 54 55

@class NSString;

@interface BatteryModel : NSObject
{
#if defined (linux)
    @private char     batteryStatePath0[1024];
    @private char     batteryInfoPath0[1024];
    @private char     apmPath[1024];
    @private NSString *batterySysAcpiString;

56
    /* ACPI on Linux, using files in /sys : modern kernels and laptops*/
57
    @private BOOL     useACPIsys;
58 59 60 61 62

    /* ACPI on Linux, using files in /proc, now as fallback */
    @private BOOL     useACPIproc; 

    /* APM on linux, for old kernels, older laptops, non-x86 machines, netbooks, embedded devices */
63
    @private BOOL     useAPM;
64 65 66 67 68

    /* PMU: Power management Unit, specific for powermac, ibooks Apple laptops*/
    @private BOOL     usePMU;
#endif

69 70 71 72 73 74 75
    @private BOOL     useWattHours;
    @private float    volts;
    @private float    amps;
    @private float    watts;
    @private float    desCap;
    @private float    lastCap;
    @private float    currCap;
76
    @private float    critCap;
77 78 79 80
    @private float    warnCap;
    @private float    chargePercent;
    @private float    timeRemaining;
    @private BOOL     isCharging;
81
    @private BOOL     isCritical;
82 83
    @private float    critPercent;
    @private float    warnPercent;
84
    @private BMBatteryStates batteryState;
85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102
  
    @private NSString *batteryType;
    @private NSString *batteryManufacturer;

}

- (void)update;
- (float)volts;
- (float)amps;
- (float)watts;
- (float)timeRemaining;
- (float)remainingCapacity;
- (float)warningCapacity;
- (float)lastCapacity;
- (float)designCapacity;
- (float)chargePercent;

- (BOOL)isCritical;
103
- (BOOL)isWarning;
104 105 106 107 108 109 110 111 112 113 114
- (BOOL)isCharging;

- (BOOL)isUsingWattHours;

- (NSString *)state;
- (NSString *)batteryType;
- (NSString *)manufacturer;

@end


115 116 117 118 119 120
@interface BatteryModel (PlatformSpecific)

- (void)initPlatformSpecific;
- (void)updatePlatformSpecific;

@end