blob: 08b1ef3805ce5046d7f0af9e03afeb5a800cb487 [file] [log] [blame]
Vishwanatha Subbanna307d80b2017-06-28 15:56:09 +05301#include "occ_status.hpp"
Vishwanatha Subbanna6add0b82017-07-21 19:02:37 +05302#include "occ_sensor.hpp"
Vishwanatha Subbanna307d80b2017-06-28 15:56:09 +05303namespace open_power
4{
5namespace occ
6{
7
8// Handles updates to occActive property
9bool Status::occActive(bool value)
10{
Vishwanatha Subbanna32e84e92017-06-28 19:17:28 +053011 if (value != this->occActive())
12 {
13 if (value)
14 {
15 // Bind the device
16 device.bind();
Vishwanatha Subbannaee4d83d2017-06-29 18:35:00 +053017
18 // And watch for errors
19 device.addErrorWatch();
Vishwanatha Subbanna32e84e92017-06-28 19:17:28 +053020 }
21 else
22 {
Vishwanatha Subbannaee4d83d2017-06-29 18:35:00 +053023 // Stop watching for errors
24 device.removeErrorWatch();
25
26 // Do the unbind.
Vishwanatha Subbanna32e84e92017-06-28 19:17:28 +053027 device.unBind();
28 }
29 }
Vishwanatha Subbanna307d80b2017-06-28 15:56:09 +053030 return Base::Status::occActive(value);
31}
32
Vishwanatha Subbannaee4d83d2017-06-29 18:35:00 +053033// Callback handler when a device error is reported.
34void Status::deviceErrorHandler()
35{
36 // This would deem OCC inactive
37 this->occActive(false);
38}
39
Vishwanatha Subbanna307d80b2017-06-28 15:56:09 +053040} // namespace occ
41} // namespace open_power