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

Fixed bug in testable mode and device initalisation

- Exception handling decorator does not allow to leave testable mode before
  devices are up
- Test facility makes sure that testable mode counter is zero at the end of startApplication()
parent 25ed26af
No related branches found
Tags 01.10.00
No related merge requests found
...@@ -211,6 +211,9 @@ namespace ChimeraTK { ...@@ -211,6 +211,9 @@ namespace ChimeraTK {
template<typename UserType> template<typename UserType>
friend class Accessor; friend class Accessor;
template<typename UserType>
friend class ExceptionHandlingDecorator;
/** Finalise connections, i.e. decide still-undecided details mostly for /** Finalise connections, i.e. decide still-undecided details mostly for
* Device and ControlSystem variables */ * Device and ControlSystem variables */
void finaliseNetworks(); void finaliseNetworks();
......
...@@ -65,6 +65,14 @@ namespace ChimeraTK { ...@@ -65,6 +65,14 @@ namespace ChimeraTK {
if(allOpened) break; if(allOpened) break;
} }
Application::testableModeLock("waitDevicesToOpen"); Application::testableModeLock("waitDevicesToOpen");
// make sure all initial values have been propagated when in testable mode
if(Application::getInstance().isTestableModeEnabled()) {
// call stepApplication() only in testable mode and only if the queues are not empty
if(Application::getInstance().testableMode_counter != 0) {
stepApplication();
}
}
// receive all initial values for the control system variables // receive all initial values for the control system variables
if(Application::getInstance().isTestableModeEnabled()) { if(Application::getInstance().isTestableModeEnabled()) {
for(auto& pv : pvManager->getAllProcessVariables()) { for(auto& pv : pvManager->getAllProcessVariables()) {
......
...@@ -58,9 +58,18 @@ namespace ChimeraTK { ...@@ -58,9 +58,18 @@ namespace ChimeraTK {
deviceModule.writeAfterOpen.push_back(this->_recoveryAccessor); deviceModule.writeAfterOpen.push_back(this->_recoveryAccessor);
return false; return false;
} }
Application::getInstance().testableModeUnlock("waitForDeviceOpen"); // We artificially increase the testabel mode counter so the test does not slip out of testable mode here in case
// the queues are empty. At the moment, the exception handling has to be done before you get the lock back in your test.
// Exception handling cannot be tested in testable mode at the moment.
if(Application::getInstance().isTestableModeEnabled()) {
++Application::getInstance().testableMode_counter;
Application::getInstance().testableModeUnlock("waitForDeviceOpen");
}
boost::this_thread::sleep(boost::posix_time::millisec(DeviceOpenTimeout)); boost::this_thread::sleep(boost::posix_time::millisec(DeviceOpenTimeout));
Application::getInstance().testableModeLock("waitForDeviceOpen"); if(Application::getInstance().isTestableModeEnabled()) {
Application::getInstance().testableModeLock("waitForDeviceOpen");
--Application::getInstance().testableMode_counter;
}
continue; continue;
} }
auto retval = callable(); auto retval = callable();
......
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