1 package org.metricshub.ipmi.core.coding.commands.chassis;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25 import org.metricshub.ipmi.core.coding.commands.ResponseData;
26 import org.metricshub.ipmi.core.common.TypeConverter;
27
28
29
30
31 public class GetChassisStatusResponseData implements ResponseData {
32
33 public static final String FRONT_PANEL_BUTTON_CAPABILITIES_NOT_SET_MESSAGE = "Front Panel Button Capabilities not set";
34
35 private byte currentPowerState;
36
37 private byte lastPowerEvent;
38
39 private byte miscChassisState;
40
41 private boolean isFrontPanelButtonCapabilitiesSet;
42
43 private byte frontPanelButtonCapabilities;
44
45 public GetChassisStatusResponseData() {
46 setFrontPanelButtonCapabilitiesSet(false);
47 }
48
49 public void setCurrentPowerState(byte currentPowerState) {
50 this.currentPowerState = currentPowerState;
51 }
52
53 public byte getCurrentPowerState() {
54 return currentPowerState;
55 }
56
57 public PowerRestorePolicy getPowerRestorePolicy() {
58 switch ((currentPowerState & TypeConverter.intToByte(0x60)) >> 5) {
59 case 0:
60 return PowerRestorePolicy.PoweredOff;
61 case 1:
62 return PowerRestorePolicy.PowerRestored;
63 case 2:
64 return PowerRestorePolicy.PoweredUp;
65 default:
66 throw new IllegalArgumentException("Invalid Power Restore Policy");
67 }
68 }
69
70
71
72
73
74 public boolean isPowerControlFault() {
75 return ((currentPowerState & TypeConverter.intToByte(0x10)) != 0);
76 }
77
78
79
80
81 public boolean isPowerFault() {
82 return ((currentPowerState & TypeConverter.intToByte(0x8)) != 0);
83 }
84
85
86
87
88
89 public boolean isInterlock() {
90 return ((currentPowerState & TypeConverter.intToByte(0x4)) != 0);
91 }
92
93
94
95
96
97 public boolean isPowerOverload() {
98 return ((currentPowerState & TypeConverter.intToByte(0x2)) != 0);
99 }
100
101
102
103
104 public boolean isPowerOn() {
105 return ((currentPowerState & TypeConverter.intToByte(0x1)) != 0);
106 }
107
108 public void setLastPowerEvent(byte lastPowerEvent) {
109 this.lastPowerEvent = lastPowerEvent;
110 }
111
112 public byte getLastPowerEvent() {
113 return lastPowerEvent;
114 }
115
116
117
118
119 public boolean wasIpmiPowerOn() {
120 return ((lastPowerEvent & TypeConverter.intToByte(0x10)) != 0);
121 }
122
123
124
125
126 public boolean wasPowerFault() {
127 return ((lastPowerEvent & TypeConverter.intToByte(0x8)) != 0);
128 }
129
130
131
132
133
134 public boolean wasInterlock() {
135 return ((lastPowerEvent & TypeConverter.intToByte(0x4)) != 0);
136 }
137
138
139
140
141 public boolean wasPowerOverload() {
142 return ((lastPowerEvent & TypeConverter.intToByte(0x2)) != 0);
143 }
144
145
146
147
148 public boolean acFailed() {
149 return ((lastPowerEvent & TypeConverter.intToByte(0x1)) != 0);
150
151 }
152
153 public void setMiscChassisState(byte miscChassisState) {
154 this.miscChassisState = miscChassisState;
155 }
156
157 public byte getMiscChassisState() {
158 return miscChassisState;
159 }
160
161
162
163
164 public boolean isChassisIdentifyCommandSupported() {
165 return ((miscChassisState & TypeConverter.intToByte(0x40)) != 0);
166 }
167
168 public ChassisIdentifyState getChassisIdentifyState() {
169 if (!isChassisIdentifyCommandSupported()) {
170 throw new IllegalAccessError(
171 "Chassis Idetify command and state not supported");
172 }
173
174 return ChassisIdentifyState.parseInt((miscChassisState & TypeConverter
175 .intToByte(0x30)) >> 4);
176 }
177
178
179
180
181 public boolean coolingFaultDetected() {
182 return ((miscChassisState & TypeConverter.intToByte(0x8)) != 0);
183 }
184
185
186
187
188 public boolean driveFaultDetected() {
189 return ((miscChassisState & TypeConverter.intToByte(0x4)) != 0);
190 }
191
192
193
194
195
196 public boolean isFrontPanelLockoutActive() {
197 return ((miscChassisState & TypeConverter.intToByte(0x2)) != 0);
198 }
199
200
201
202
203 public boolean isChassisIntrusionActive() {
204 return ((miscChassisState & TypeConverter.intToByte(0x1)) != 0);
205 }
206
207 public void setFrontPanelButtonCapabilities(
208 byte frontPanelButtonCapabilities) {
209 this.frontPanelButtonCapabilities = frontPanelButtonCapabilities;
210 setFrontPanelButtonCapabilitiesSet(true);
211 }
212
213 public byte getFrontPanelButtonCapabilities() {
214 return frontPanelButtonCapabilities;
215 }
216
217
218
219
220
221
222 public boolean isStandbyButtonDisableAllowed()
223 throws IllegalAccessException {
224 if (!isFrontPanelButtonCapabilitiesSet()) {
225 throw new IllegalAccessException(FRONT_PANEL_BUTTON_CAPABILITIES_NOT_SET_MESSAGE);
226 }
227 return ((frontPanelButtonCapabilities & TypeConverter.intToByte(0x80)) != 0);
228 }
229
230
231
232
233
234
235 public boolean isDiagnosticInterruptButtonDisableAllowed()
236 throws IllegalAccessException {
237 if (!isFrontPanelButtonCapabilitiesSet()) {
238 throw new IllegalAccessException(FRONT_PANEL_BUTTON_CAPABILITIES_NOT_SET_MESSAGE);
239 }
240 return ((frontPanelButtonCapabilities & TypeConverter.intToByte(0x40)) != 0);
241 }
242
243
244
245
246
247
248 public boolean isResetButtonDisableAllowed() throws IllegalAccessException {
249 if (!isFrontPanelButtonCapabilitiesSet()) {
250 throw new IllegalAccessException(FRONT_PANEL_BUTTON_CAPABILITIES_NOT_SET_MESSAGE);
251 }
252 return ((frontPanelButtonCapabilities & TypeConverter.intToByte(0x20)) != 0);
253 }
254
255
256
257
258
259
260
261
262 public boolean isPowerOffButtonDisableAllowed()
263 throws IllegalAccessException {
264 if (!isFrontPanelButtonCapabilitiesSet()) {
265 throw new IllegalAccessException(FRONT_PANEL_BUTTON_CAPABILITIES_NOT_SET_MESSAGE);
266 }
267 return ((frontPanelButtonCapabilities & TypeConverter.intToByte(0x10)) != 0);
268 }
269
270
271
272
273
274
275 public boolean isStandbyButtonDisabled() throws IllegalAccessException {
276 if (!isFrontPanelButtonCapabilitiesSet()) {
277 throw new IllegalAccessException(FRONT_PANEL_BUTTON_CAPABILITIES_NOT_SET_MESSAGE);
278 }
279 return ((frontPanelButtonCapabilities & TypeConverter.intToByte(0x8)) != 0);
280 }
281
282
283
284
285
286
287 public boolean isDiagnosticInterruptButtonDisabled()
288 throws IllegalAccessException {
289 if (!isFrontPanelButtonCapabilitiesSet()) {
290 throw new IllegalAccessException(FRONT_PANEL_BUTTON_CAPABILITIES_NOT_SET_MESSAGE);
291 }
292 return ((frontPanelButtonCapabilities & TypeConverter.intToByte(0x4)) != 0);
293 }
294
295
296
297
298
299
300 public boolean isResetButtonDisabled() throws IllegalAccessException {
301 if (!isFrontPanelButtonCapabilitiesSet()) {
302 throw new IllegalAccessException(FRONT_PANEL_BUTTON_CAPABILITIES_NOT_SET_MESSAGE);
303 }
304 return ((frontPanelButtonCapabilities & TypeConverter.intToByte(0x2)) != 0);
305 }
306
307
308
309
310
311
312
313
314 public boolean isPowerOffButtonDisabled() throws IllegalAccessException {
315 if (!isFrontPanelButtonCapabilitiesSet()) {
316 throw new IllegalAccessException(
317 FRONT_PANEL_BUTTON_CAPABILITIES_NOT_SET_MESSAGE);
318 }
319 return ((frontPanelButtonCapabilities & TypeConverter.intToByte(0x1)) != 0);
320 }
321
322 private void setFrontPanelButtonCapabilitiesSet(
323 boolean isFrontPanelButtonCapabilitiesSet) {
324 this.isFrontPanelButtonCapabilitiesSet = isFrontPanelButtonCapabilitiesSet;
325 }
326
327 public boolean isFrontPanelButtonCapabilitiesSet() {
328 return isFrontPanelButtonCapabilitiesSet;
329 }
330
331 }