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