mirror of
https://github.com/intrepidcs/libicsneo.git
synced 2026-08-05 01:18:36 +02:00
Device: Allow the suppression of disconnects from extensions
This commit is contained in:
+7
-2
@@ -240,13 +240,13 @@ bool Device::open() {
|
||||
while(!stopHeartbeatThread) {
|
||||
// Wait for 110ms for a possible heartbeat
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(110));
|
||||
if(!receivedMessage) {
|
||||
if(!receivedMessage && !heartbeatSuppressed()) {
|
||||
// No heartbeat received, request a status
|
||||
com->sendCommand(Command::RequestStatusUpdate);
|
||||
// The response should come back quickly if the com is quiet
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(10));
|
||||
// Check if we got a message, and if not, if settings are being applied
|
||||
if(!receivedMessage && !settings->applyingSettings) {
|
||||
if(!receivedMessage && !heartbeatSuppressed()) {
|
||||
if(!stopHeartbeatThread && !isDisconnected())
|
||||
report(APIEvent::Type::DeviceDisconnected, APIEvent::Severity::Error);
|
||||
break;
|
||||
@@ -630,6 +630,11 @@ optional<double> Device::getAnalogIO(IO type, size_t number /* = 1 */) {
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
Lifetime Device::suppressDisconnects() {
|
||||
heartbeatSuppressedByUser++;
|
||||
return Lifetime([this] { heartbeatSuppressedByUser--; });
|
||||
}
|
||||
|
||||
void Device::addExtension(std::shared_ptr<DeviceExtension>&& extension) {
|
||||
std::lock_guard<std::mutex> lk(extensionsLock);
|
||||
extensions.push_back(extension);
|
||||
|
||||
Reference in New Issue
Block a user