]>
Commit | Line | Data |
---|---|---|
1c79356b A |
1 | /* |
2 | * Copyright (c) 1998-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 | ||
23 | #include <IOKit/pwr_mgt/IOPMPowerSource.h> | |
24 | ||
25 | #define super OSObject | |
26 | ||
27 | OSDefineMetaClassAndStructors(IOPMPowerSource, OSObject) | |
28 | ||
29 | // ********************************************************************************** | |
30 | // init | |
31 | // | |
32 | // ********************************************************************************** | |
33 | bool IOPMPowerSource::init (unsigned short whichBatteryIndex) | |
34 | { | |
35 | if (!super::init ()) | |
36 | return false; | |
37 | ||
38 | bBatteryIndex = whichBatteryIndex; | |
39 | nextInList = 0; | |
40 | ||
41 | return true; | |
42 | } | |
43 | ||
44 | // ********************************************************************************** | |
45 | // capacityPercentRemaining | |
46 | // | |
47 | // ********************************************************************************** | |
48 | unsigned long IOPMPowerSource::capacityPercentRemaining (void) | |
49 | { | |
50 | unsigned long percentage = 0; | |
51 | ||
52 | if (bMaxCapacity > 0) | |
53 | percentage = (bCurCapacity * 100) / bMaxCapacity; | |
54 | ||
55 | // always return a non-zero value unless the real capacity IS zero. | |
56 | if (percentage == 0 && bCurCapacity > 0) | |
57 | percentage = 1; | |
58 | ||
59 | return percentage; | |
60 | } | |
61 | ||
62 | // ********************************************************************************** | |
63 | // atWarnLevel | |
64 | // | |
65 | // ********************************************************************************** | |
66 | bool IOPMPowerSource::atWarnLevel (void) | |
67 | { | |
68 | return bFlags & kBatteryAtWarn; | |
69 | } | |
70 | ||
71 | // ********************************************************************************** | |
72 | // acConnected | |
73 | // | |
74 | // ********************************************************************************** | |
75 | bool IOPMPowerSource::acConnected (void) | |
76 | { | |
77 | return bFlags & kACInstalled; | |
78 | } | |
79 | ||
80 | // ********************************************************************************** | |
81 | // depleted | |
82 | // | |
83 | // ********************************************************************************** | |
84 | bool IOPMPowerSource::depleted (void) | |
85 | { | |
86 | return bFlags & kBatteryDepleted; | |
87 | } | |
88 | ||
89 | // ********************************************************************************** | |
90 | // isInstalled | |
91 | // | |
92 | // ********************************************************************************** | |
93 | bool IOPMPowerSource::isInstalled (void) | |
94 | { | |
95 | return bFlags & kBatteryInstalled; | |
96 | } | |
97 | ||
98 | // ********************************************************************************** | |
99 | // isCharging | |
100 | // | |
101 | // ********************************************************************************** | |
102 | bool IOPMPowerSource::isCharging (void) | |
103 | { | |
104 | return bFlags & kBatteryCharging; | |
105 | } | |
106 | ||
107 | // ********************************************************************************** | |
108 | // timeRemaining | |
109 | // | |
110 | // ********************************************************************************** | |
111 | unsigned long IOPMPowerSource::timeRemaining (void) | |
112 | { | |
113 | return bTimeRemaining; | |
114 | } | |
115 | ||
116 | // ********************************************************************************** | |
117 | // maxCapacity | |
118 | // | |
119 | // ********************************************************************************** | |
120 | unsigned long IOPMPowerSource::maxCapacity (void) | |
121 | { | |
122 | return bMaxCapacity; | |
123 | } | |
124 | ||
125 | // ********************************************************************************** | |
126 | // curCapacity | |
127 | // | |
128 | // ********************************************************************************** | |
129 | unsigned long IOPMPowerSource::curCapacity (void) | |
130 | { | |
131 | return bCurCapacity; | |
132 | } | |
133 | ||
134 | // ********************************************************************************** | |
135 | // currentDrawn | |
136 | // | |
137 | // ********************************************************************************** | |
138 | long IOPMPowerSource::currentDrawn (void) | |
139 | { | |
140 | return bCurrent; | |
141 | } | |
142 | ||
143 | // ********************************************************************************** | |
144 | // voltage | |
145 | // | |
146 | // ********************************************************************************** | |
147 | ||
148 | unsigned long IOPMPowerSource::voltage (void) | |
149 | { | |
150 | return bVoltage; | |
151 | } | |
152 | ||
153 | // ********************************************************************************** | |
154 | // updateStatus | |
155 | // | |
156 | // ********************************************************************************** | |
157 | ||
158 | void IOPMPowerSource::updateStatus (void) | |
159 | { | |
160 | ||
161 | } | |
162 | ||
163 | ||
164 | ||
165 | ||
166 |