Skip to content
Snippets Groups Projects
Commit dd11913a authored by Martin Killenberg's avatar Martin Killenberg
Browse files

improved places where DeviceModule changes...

improved places where DeviceModule changes testableMode_deviceInitialisationCounter. Now matches with deviceHasError.
parent 5a165dc8
No related branches found
No related tags found
No related merge requests found
......@@ -285,10 +285,6 @@ namespace ChimeraTK {
// to terminate this thread before waking up other threads waiting on the condition variable.
try {
while(true) {
// increment special testable mode counter to make sure the initialisation completes within one
// "application step"
++owner->testableMode_deviceInitialisationCounter; // matched below with a decrement
// [Spec: 2.3.1] (Re)-open the device.
owner->testableModeUnlock("Open/recover device");
do {
......@@ -312,10 +308,6 @@ namespace ChimeraTK {
firstAttempt = false;
owner->testableModeLock("Initialise device");
// decrement special testable mode counter, was incremented manually above to make sure initialisation completes
// within one "application step"
--owner->testableMode_deviceInitialisationCounter;
std::unique_lock<std::mutex> errorLock(errorMutex);
// [Spec: 2.3.2] Run initialisation handlers
......@@ -367,6 +359,9 @@ namespace ChimeraTK {
deviceError.writeAll();
deviceHasError = false;
// decrement special testable mode counter, was incremented manually above to make sure initialisation completes
// within one "application step"
--owner->testableMode_deviceInitialisationCounter;
// [Spec: 2.3.6+2.3.7] send the trigger that the device is available again
deviceBecameFunctional.write();
......@@ -389,6 +384,10 @@ namespace ChimeraTK {
errorLock.unlock(); // We must not hold the error lock when getting the testable mode mutex to avoid deadlocks!
owner->testableModeLock("Process exception");
// increment special testable mode counter to make sure the initialisation completes within one
// "application step"
++owner->testableMode_deviceInitialisationCounter; // matched above with a decrement
errorLock.lock(); // we need both locks to modify the queue, so get it again.
auto popResult = errorQueue.pop(error);
......@@ -431,6 +430,11 @@ namespace ChimeraTK {
deviceError.message = "Attempting to open device...";
deviceError.setCurrentVersionNumber({});
deviceError.writeAll();
// Increment special testable mode counter to make sure the initialisation completes within one
// "application step". Start with counter increased (device not initialised yet, wait).
// We can to this here without testable mode lock because the application is still single threaded.
++owner->testableMode_deviceInitialisationCounter; // released and increased in handeException loop
}
/*********************************************************************************************************************/
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment