@@ -177,12 +177,7 @@ encode_storage(Req, _Properties) when
177
177
% % @private
178
178
% %------------------------------------------------------------------------------
179
179
encode_transport (? GET_IP_UDP_RMCP_STATISTICS , Properties ) ->
180
- Clear = proplists :get_value (clear_statistics , Properties , false ),
181
- C =
182
- case Clear of
183
- true -> 1 ;
184
- false -> 0
185
- end ,
180
+ C = get_encoded_bool (clear_statistics , Properties ),
186
181
<<0 :4 , ? IPMI_REQUESTED_CHANNEL :4 , 0 :7 , C :1 >>;
187
182
encode_transport (? SET_LAN_CONFIGURATION_PARAMETERS , Properties ) ->
188
183
P = proplists :get_value (parameter , Properties ),
@@ -239,11 +234,7 @@ encode_transport(?SET_LAN_CONFIGURATION_PARAMETERS, Properties) ->
239
234
oem1 -> 6 ;
240
235
oem2 -> 7
241
236
end ,
242
- A =
243
- case proplists :get_value (acknowledge , Properties , false ) of
244
- true -> 1 ;
245
- false -> 0
246
- end ,
237
+ A = get_encoded_bool (acknowledge , Properties ),
247
238
To = proplists :get_value (timeout , Properties , 0 ),
248
239
R = proplists :get_value (retries , Properties , 0 ),
249
240
<<0 :4 , S :4 , A :1 , 0 :4 , T :3 , To :8 , 0 :5 , R :3 >>;
@@ -291,18 +282,8 @@ encode_chassis(?CHASSIS_IDENTIFY, Properties) ->
291
282
<<0 :8 , 0 :7 , 1 :1 >>
292
283
end ;
293
284
encode_chassis (? SET_CHASSIS_CAPABILITIES , Properties ) ->
294
- Lockout = proplists :get_bool (lockout , Properties ),
295
- L =
296
- case Lockout of
297
- true -> 1 ;
298
- false -> 0
299
- end ,
300
- Intrusion = proplists :get_bool (intrusion , Properties ),
301
- I =
302
- case Intrusion of
303
- true -> 1 ;
304
- false -> 0
305
- end ,
285
+ L = get_encoded_bool (lockout , Properties ),
286
+ I = get_encoded_bool (intrusion , Properties ),
306
287
F = proplists :get_value (fru_address , Properties ),
307
288
Sdr = proplists :get_value (sdr_address , Properties ),
308
289
Sel = proplists :get_value (sel_address , Properties ),
@@ -324,30 +305,10 @@ encode_chassis(?SET_POWER_RESTORE_POLICY, Properties) ->
324
305
end ,
325
306
<<0 :5 , P :3 >>;
326
307
encode_chassis (? SET_FRONT_PANEL_ENABLES , Properties ) ->
327
- Standby = proplists :get_bool (disable_standby , Properties ),
328
- S =
329
- case Standby of
330
- true -> 1 ;
331
- false -> 0
332
- end ,
333
- Diagnostic = proplists :get_bool (disable_diagnostic_interrupt , Properties ),
334
- D =
335
- case Diagnostic of
336
- true -> 1 ;
337
- false -> 0
338
- end ,
339
- Reset = proplists :get_bool (disable_reset , Properties ),
340
- R =
341
- case Reset of
342
- true -> 1 ;
343
- false -> 0
344
- end ,
345
- Power = proplists :get_bool (disable_power , Properties ),
346
- P =
347
- case Power of
348
- true -> 1 ;
349
- false -> 0
350
- end ,
308
+ S = get_encoded_bool (disable_standby , Properties ),
309
+ D = get_encoded_bool (disable_diagnostic_interrupt , Properties ),
310
+ R = get_encoded_bool (disable_reset , Properties ),
311
+ P = get_encoded_bool (disable_power , Properties ),
351
312
<<0 :4 , S :1 , D :1 , R :1 , P :1 >>;
352
313
encode_chassis (? SET_POWER_CYCLE_INTERVAL , Properties ) ->
353
314
I = proplists :get_value (interval , Properties , 0 ),
@@ -392,12 +353,8 @@ encode_picmg(?GET_FRU_ACTIVATION_POLICY, Properties) ->
392
353
<<? PICMG_ID :8 , FruId :8 >>;
393
354
encode_picmg (? SET_FRU_ACTIVATION , Properties ) ->
394
355
FruId = proplists :get_value (fru_id , Properties ),
395
- Activate = proplists :get_value (activate , Properties ),
396
- <<? PICMG_ID :8 , FruId :8 ,
397
- (case Activate of
398
- true -> 1 ;
399
- false -> 0
400
- end ):8 >>;
356
+ Activate = get_encoded_bool (activate , Properties ),
357
+ <<? PICMG_ID :8 , FruId :8 , Activate :8 >>;
401
358
encode_picmg (? FRU_CONTROL , Properties ) ->
402
359
FruId = proplists :get_value (fru_id , Properties ),
403
360
Control = proplists :get_value (control , Properties ),
@@ -523,3 +480,9 @@ encode_picmg_site_type(pmc) -> 16#08;
523
480
encode_picmg_site_type (rear_transition_module ) -> 16#09 ;
524
481
encode_picmg_site_type (mch ) -> 16#0a ;
525
482
encode_picmg_site_type (power_module ) -> 16#0b .
483
+
484
+ get_encoded_bool (Prop , List ) ->
485
+ case proplists :get_bool (Prop , List ) of
486
+ true -> 1 ;
487
+ false -> 0
488
+ end .
0 commit comments