mirror of
https://github.com/intrepidcs/libicsneo.git
synced 2026-08-05 09:28:40 +02:00
Device: Make IO system thread-safe
This commit is contained in:
@@ -432,6 +432,7 @@ optional<bool> Device::getDigitalIO(IO type, size_t number /* = 1 */) {
|
||||
return false;
|
||||
}
|
||||
|
||||
std::lock_guard<std::mutex> lk(ioMutex);
|
||||
switch(type) {
|
||||
case IO::EthernetActivation:
|
||||
if(getEthernetActivationLineCount() < number)
|
||||
@@ -481,6 +482,7 @@ bool Device::setDigitalIO(IO type, size_t number, bool value) {
|
||||
return false;
|
||||
}
|
||||
|
||||
std::lock_guard<std::mutex> lk(ioMutex);
|
||||
switch(type) {
|
||||
case IO::EthernetActivation:
|
||||
if(getEthernetActivationLineCount() < number)
|
||||
|
||||
@@ -144,6 +144,8 @@ protected:
|
||||
int messagePollingCallbackID = 0;
|
||||
int internalHandlerCallbackID = 0;
|
||||
device_eventhandler_t report;
|
||||
|
||||
std::mutex ioMutex;
|
||||
optional<bool> ethActivationStatus;
|
||||
optional<bool> usbHostPowerStatus;
|
||||
optional<bool> backupPowerEnabled;
|
||||
|
||||
@@ -95,6 +95,7 @@ protected:
|
||||
void handleDeviceStatus(const std::shared_ptr<Message>& message) override {
|
||||
if(!message || message->data.size() < sizeof(neovifire2_status_t))
|
||||
return;
|
||||
std::lock_guard<std::mutex> lk(ioMutex);
|
||||
const neovifire2_status_t* status = reinterpret_cast<const neovifire2_status_t*>(message->data.data());
|
||||
backupPowerEnabled = status->backupPowerEnabled;
|
||||
backupPowerGood = status->backupPowerGood;
|
||||
|
||||
@@ -98,6 +98,7 @@ protected:
|
||||
void handleDeviceStatus(const std::shared_ptr<Message>& message) override {
|
||||
if(!message || message->data.size() < sizeof(fire2vnet_status_t))
|
||||
return;
|
||||
std::lock_guard<std::mutex> lk(ioMutex);
|
||||
const fire2vnet_status_t* status = reinterpret_cast<const fire2vnet_status_t*>(message->data.data());
|
||||
ethActivationStatus = status->ethernetActivationLineEnabled;
|
||||
}
|
||||
|
||||
@@ -121,6 +121,7 @@ protected:
|
||||
void handleDeviceStatus(const std::shared_ptr<Message>& message) override {
|
||||
if(!message || message->data.size() < sizeof(radgalaxy_status_t))
|
||||
return;
|
||||
std::lock_guard<std::mutex> lk(ioMutex);
|
||||
const radgalaxy_status_t* status = reinterpret_cast<const radgalaxy_status_t*>(message->data.data());
|
||||
ethActivationStatus = status->ethernetActivationLineEnabled;
|
||||
}
|
||||
|
||||
@@ -80,6 +80,7 @@ protected:
|
||||
void handleDeviceStatus(const std::shared_ptr<Message>& message) override {
|
||||
if(!message || message->data.size() < sizeof(radgigalog_status_t))
|
||||
return;
|
||||
std::lock_guard<std::mutex> lk(ioMutex);
|
||||
const radgigalog_status_t* status = reinterpret_cast<const radgigalog_status_t*>(message->data.data());
|
||||
ethActivationStatus = status->ethernetActivationLineEnabled;
|
||||
}
|
||||
|
||||
@@ -84,6 +84,7 @@ protected:
|
||||
void handleDeviceStatus(const std::shared_ptr<Message>& message) override {
|
||||
if(!message || message->data.size() < sizeof(radgigastar_status_t))
|
||||
return;
|
||||
std::lock_guard<std::mutex> lk(ioMutex);
|
||||
const radgigastar_status_t* status = reinterpret_cast<const radgigastar_status_t*>(message->data.data());
|
||||
ethActivationStatus = status->ethernetActivationLineEnabled;
|
||||
}
|
||||
|
||||
@@ -58,6 +58,7 @@ protected:
|
||||
void handleDeviceStatus(const std::shared_ptr<Message>& message) override {
|
||||
if(!message || message->data.size() < sizeof(valuecan4_2el_status_t))
|
||||
return;
|
||||
std::lock_guard<std::mutex> lk(ioMutex);
|
||||
const valuecan4_2el_status_t* status = reinterpret_cast<const valuecan4_2el_status_t*>(message->data.data());
|
||||
ethActivationStatus = status->ethernetActivationLineEnabled;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user