]>
Commit | Line | Data |
---|---|---|
1c79356b A |
1 | /* |
2 | * Copyright (c) 2000 Apple Computer, Inc. All rights reserved. | |
3 | * | |
4 | * @APPLE_LICENSE_HEADER_START@ | |
5 | * | |
43866e37 | 6 | * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. |
1c79356b | 7 | * |
43866e37 A |
8 | * This file contains Original Code and/or Modifications of Original Code |
9 | * as defined in and that are subject to the Apple Public Source License | |
10 | * Version 2.0 (the 'License'). You may not use this file except in | |
11 | * compliance with the License. Please obtain a copy of the License at | |
12 | * http://www.opensource.apple.com/apsl/ and read it before using this | |
13 | * file. | |
14 | * | |
15 | * The Original Code and all software distributed under the License are | |
16 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER | |
1c79356b A |
17 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, |
18 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, | |
43866e37 A |
19 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. |
20 | * Please see the License for the specific language governing rights and | |
21 | * limitations under the License. | |
1c79356b A |
22 | * |
23 | * @APPLE_LICENSE_HEADER_END@ | |
24 | */ | |
25 | #include <libkern/c++/OSObject.h> | |
26 | #include <IOKit/IOTypes.h> | |
27 | #include <IOKit/IOReturn.h> | |
d52fe63f | 28 | #include "IOPM.h" |
1c79356b A |
29 | |
30 | class ApplePMU; | |
31 | ||
1c79356b A |
32 | const unsigned long kSecondsPerHour = (60*60); |
33 | const unsigned long kTenMinutesInSeconds = (10 * 60); | |
34 | ||
35 | // our battery (power source) object | |
36 | ||
37 | class IOPMPowerSource : public OSObject | |
38 | { | |
39 | OSDeclareDefaultStructors(IOPMPowerSource) | |
40 | ||
41 | protected: | |
42 | ||
43 | UInt32 bFlags; | |
44 | UInt32 bTimeRemaining; | |
45 | UInt16 bCurCapacity; | |
46 | UInt16 bMaxCapacity; | |
47 | SInt16 bCurrent; | |
48 | UInt16 bVoltage; | |
49 | UInt16 bBatteryIndex; | |
50 | ||
51 | public: | |
52 | ||
53 | IOPMPowerSource * nextInList; | |
54 | ||
55 | bool init (unsigned short whichBatteryIndex); | |
56 | unsigned long capacityPercentRemaining (void); | |
57 | bool atWarnLevel (void); | |
58 | bool depleted (void); | |
59 | ||
60 | // accessors | |
61 | ||
62 | bool isInstalled (void); | |
63 | bool isCharging (void); | |
64 | bool acConnected (void); | |
65 | unsigned long timeRemaining (void); | |
66 | unsigned long maxCapacity (void); | |
67 | unsigned long curCapacity (void); | |
68 | long currentDrawn (void); | |
69 | unsigned long voltage (void); | |
70 | ||
71 | // calculations | |
72 | ||
73 | // function updateStatus is called whenever the system needs | |
74 | // to obtain the latest power source state...must be overridden | |
75 | // by subclasses. | |
76 | virtual void updateStatus (void); | |
77 | }; | |
78 | ||
79 | ||
80 |