Device: Make IO system thread-safe
parent
3b6b4f0541
commit
92589c2ce7
|
|
@ -432,6 +432,7 @@ optional<bool> Device::getDigitalIO(IO type, size_t number /* = 1 */) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::lock_guard<std::mutex> lk(ioMutex);
|
||||||
switch(type) {
|
switch(type) {
|
||||||
case IO::EthernetActivation:
|
case IO::EthernetActivation:
|
||||||
if(getEthernetActivationLineCount() < number)
|
if(getEthernetActivationLineCount() < number)
|
||||||
|
|
@ -481,6 +482,7 @@ bool Device::setDigitalIO(IO type, size_t number, bool value) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::lock_guard<std::mutex> lk(ioMutex);
|
||||||
switch(type) {
|
switch(type) {
|
||||||
case IO::EthernetActivation:
|
case IO::EthernetActivation:
|
||||||
if(getEthernetActivationLineCount() < number)
|
if(getEthernetActivationLineCount() < number)
|
||||||
|
|
|
||||||
|
|
@ -144,6 +144,8 @@ protected:
|
||||||
int messagePollingCallbackID = 0;
|
int messagePollingCallbackID = 0;
|
||||||
int internalHandlerCallbackID = 0;
|
int internalHandlerCallbackID = 0;
|
||||||
device_eventhandler_t report;
|
device_eventhandler_t report;
|
||||||
|
|
||||||
|
std::mutex ioMutex;
|
||||||
optional<bool> ethActivationStatus;
|
optional<bool> ethActivationStatus;
|
||||||
optional<bool> usbHostPowerStatus;
|
optional<bool> usbHostPowerStatus;
|
||||||
optional<bool> backupPowerEnabled;
|
optional<bool> backupPowerEnabled;
|
||||||
|
|
|
||||||
|
|
@ -95,6 +95,7 @@ protected:
|
||||||
void handleDeviceStatus(const std::shared_ptr<Message>& message) override {
|
void handleDeviceStatus(const std::shared_ptr<Message>& message) override {
|
||||||
if(!message || message->data.size() < sizeof(neovifire2_status_t))
|
if(!message || message->data.size() < sizeof(neovifire2_status_t))
|
||||||
return;
|
return;
|
||||||
|
std::lock_guard<std::mutex> lk(ioMutex);
|
||||||
const neovifire2_status_t* status = reinterpret_cast<const neovifire2_status_t*>(message->data.data());
|
const neovifire2_status_t* status = reinterpret_cast<const neovifire2_status_t*>(message->data.data());
|
||||||
backupPowerEnabled = status->backupPowerEnabled;
|
backupPowerEnabled = status->backupPowerEnabled;
|
||||||
backupPowerGood = status->backupPowerGood;
|
backupPowerGood = status->backupPowerGood;
|
||||||
|
|
|
||||||
|
|
@ -98,6 +98,7 @@ protected:
|
||||||
void handleDeviceStatus(const std::shared_ptr<Message>& message) override {
|
void handleDeviceStatus(const std::shared_ptr<Message>& message) override {
|
||||||
if(!message || message->data.size() < sizeof(fire2vnet_status_t))
|
if(!message || message->data.size() < sizeof(fire2vnet_status_t))
|
||||||
return;
|
return;
|
||||||
|
std::lock_guard<std::mutex> lk(ioMutex);
|
||||||
const fire2vnet_status_t* status = reinterpret_cast<const fire2vnet_status_t*>(message->data.data());
|
const fire2vnet_status_t* status = reinterpret_cast<const fire2vnet_status_t*>(message->data.data());
|
||||||
ethActivationStatus = status->ethernetActivationLineEnabled;
|
ethActivationStatus = status->ethernetActivationLineEnabled;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -121,6 +121,7 @@ protected:
|
||||||
void handleDeviceStatus(const std::shared_ptr<Message>& message) override {
|
void handleDeviceStatus(const std::shared_ptr<Message>& message) override {
|
||||||
if(!message || message->data.size() < sizeof(radgalaxy_status_t))
|
if(!message || message->data.size() < sizeof(radgalaxy_status_t))
|
||||||
return;
|
return;
|
||||||
|
std::lock_guard<std::mutex> lk(ioMutex);
|
||||||
const radgalaxy_status_t* status = reinterpret_cast<const radgalaxy_status_t*>(message->data.data());
|
const radgalaxy_status_t* status = reinterpret_cast<const radgalaxy_status_t*>(message->data.data());
|
||||||
ethActivationStatus = status->ethernetActivationLineEnabled;
|
ethActivationStatus = status->ethernetActivationLineEnabled;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -80,6 +80,7 @@ protected:
|
||||||
void handleDeviceStatus(const std::shared_ptr<Message>& message) override {
|
void handleDeviceStatus(const std::shared_ptr<Message>& message) override {
|
||||||
if(!message || message->data.size() < sizeof(radgigalog_status_t))
|
if(!message || message->data.size() < sizeof(radgigalog_status_t))
|
||||||
return;
|
return;
|
||||||
|
std::lock_guard<std::mutex> lk(ioMutex);
|
||||||
const radgigalog_status_t* status = reinterpret_cast<const radgigalog_status_t*>(message->data.data());
|
const radgigalog_status_t* status = reinterpret_cast<const radgigalog_status_t*>(message->data.data());
|
||||||
ethActivationStatus = status->ethernetActivationLineEnabled;
|
ethActivationStatus = status->ethernetActivationLineEnabled;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -84,6 +84,7 @@ protected:
|
||||||
void handleDeviceStatus(const std::shared_ptr<Message>& message) override {
|
void handleDeviceStatus(const std::shared_ptr<Message>& message) override {
|
||||||
if(!message || message->data.size() < sizeof(radgigastar_status_t))
|
if(!message || message->data.size() < sizeof(radgigastar_status_t))
|
||||||
return;
|
return;
|
||||||
|
std::lock_guard<std::mutex> lk(ioMutex);
|
||||||
const radgigastar_status_t* status = reinterpret_cast<const radgigastar_status_t*>(message->data.data());
|
const radgigastar_status_t* status = reinterpret_cast<const radgigastar_status_t*>(message->data.data());
|
||||||
ethActivationStatus = status->ethernetActivationLineEnabled;
|
ethActivationStatus = status->ethernetActivationLineEnabled;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -58,6 +58,7 @@ protected:
|
||||||
void handleDeviceStatus(const std::shared_ptr<Message>& message) override {
|
void handleDeviceStatus(const std::shared_ptr<Message>& message) override {
|
||||||
if(!message || message->data.size() < sizeof(valuecan4_2el_status_t))
|
if(!message || message->data.size() < sizeof(valuecan4_2el_status_t))
|
||||||
return;
|
return;
|
||||||
|
std::lock_guard<std::mutex> lk(ioMutex);
|
||||||
const valuecan4_2el_status_t* status = reinterpret_cast<const valuecan4_2el_status_t*>(message->data.data());
|
const valuecan4_2el_status_t* status = reinterpret_cast<const valuecan4_2el_status_t*>(message->data.data());
|
||||||
ethActivationStatus = status->ethernetActivationLineEnabled;
|
ethActivationStatus = status->ethernetActivationLineEnabled;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue