Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
ApplicationCore
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ChimeraTK Mirror
ApplicationCore
Commits
dd37387f
Commit
dd37387f
authored
5 years ago
by
Martin Killenberg
Browse files
Options
Downloads
Patches
Plain Diff
device is re-initialised after exception
parent
e41b3f35
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/DeviceModule.cc
+5
-0
5 additions, 0 deletions
src/DeviceModule.cc
tests/executables_src/testDeviceInitialisationHandler.cpp
+55
-76
55 additions, 76 deletions
tests/executables_src/testDeviceInitialisationHandler.cpp
with
60 additions
and
76 deletions
src/DeviceModule.cc
+
5
−
0
View file @
dd37387f
...
...
@@ -298,6 +298,11 @@ namespace ChimeraTK {
deviceError
.
setCurrentVersionNumber
({});
deviceError
.
writeAll
();
errorCondVar
.
notify_all
();
// re-initialise the device before continuing
for
(
auto
&
initHandler
:
initialisationHandlers
)
{
initHandler
(
this
);
}
}
}
catch
(...)
{
...
...
This diff is collapsed.
Click to expand it.
tests/executables_src/testDeviceInitialisationHandler.cpp
+
55
−
76
View file @
dd37387f
...
...
@@ -11,7 +11,7 @@
#include
"DeviceModule.h"
//#include "ScalarAccessor.h"
#include
"TestFacility.h"
//
#include "
StatusMonitor
.h"
#include
"
ExceptionDevice
.h"
#include
<ChimeraTK/Device.h>
...
...
@@ -22,6 +22,16 @@ void initialiseReg1(ctk::DeviceModule * dev){
dev
->
device
.
write
<
int32_t
>
(
"/REG1"
,
42
);
}
void
initialiseReg2
(
ctk
::
DeviceModule
*
dev
){
// the initialisation of reg 2 must happen after the initialisation of reg1
dev
->
device
.
write
<
int32_t
>
(
"/REG2"
,
dev
->
device
.
read
<
int32_t
>
(
"/REG1"
)
+
5
);
}
void
initialiseReg3
(
ctk
::
DeviceModule
*
dev
){
// the initialisation of reg 3 must happen after the initialisation of reg2
dev
->
device
.
write
<
int32_t
>
(
"/REG3"
,
dev
->
device
.
read
<
int32_t
>
(
"/REG2"
)
+
5
);
}
/* dummy application */
struct
TestApplication
:
public
ctk
::
Application
{
TestApplication
()
:
Application
(
"testSuite"
)
{}
...
...
@@ -29,7 +39,7 @@ struct TestApplication : public ctk::Application {
void
defineConnections
()
{}
// the setup is done in the tests
ctk
::
ControlSystemModule
cs
;
ctk
::
DeviceModule
dev
{
this
,
"(
d
ummy?map=test.map)"
,
&
initialiseReg1
};
ctk
::
DeviceModule
dev
{
this
,
"(
ExceptionD
ummy?map=test.map)"
,
&
initialiseReg1
};
};
/*********************************************************************************************************************/
...
...
@@ -44,79 +54,48 @@ BOOST_AUTO_TEST_CASE(testBasicInitialisation) {
//app.dumpConnections();
ctk
::
Device
dummy
;
dummy
.
open
(
"(dummy?map=test.map)"
);
BOOST_CHECK_EQUAL
(
dummy
.
read
<
int32_t
>
(
"REG1"
),
42
);
// auto error = test.getScalar<double_t>(std::string("/MAX_MONITOR.ERROR.THRESHOLD"));
// error = 50.1;
// error.write();
// test.stepApplication();
// auto watch = test.getScalar<double_t>(std::string("/WATCH"));
// watch = 40.1;
// watch.write();
// test.stepApplication();
// auto status = test.getScalar<uint16_t>(std::string("/STATUS"));
// status.readLatest();
// //should be in OK state.
// BOOST_CHECK_EQUAL(status,ChimeraTK::States::OK);
// //set watch value exceeding warning level
// watch = 46.1;
// watch.write();
// test.stepApplication();
// status.readLatest();
// //should be in WARNING state.
// BOOST_CHECK_EQUAL(status,ChimeraTK::States::WARNING);
// //set watch value exceeding error level
// watch = 51.1;
// watch.write();
// test.stepApplication();
// status.readLatest();
// //should be in ERROR state.
// BOOST_CHECK_EQUAL(status,ChimeraTK::States::ERROR);
// //increase error value greater than watch
// error = 60.1;
// error.write();
// test.stepApplication();
// status.readLatest();
// //should be in WARNING state.
// BOOST_CHECK_EQUAL(status,ChimeraTK::States::WARNING);
// //increase warning value greater than watch
// warning = 55.1;
// warning.write();
// test.stepApplication();
// status.readLatest();
// //should be in OK state.
// BOOST_CHECK_EQUAL(status,ChimeraTK::States::OK);
// //set watch value exceeding error level
// watch = 65.1;
// watch.write();
// test.stepApplication();
// status.readLatest();
// //should be in ERROR state.
// BOOST_CHECK_EQUAL(status,ChimeraTK::States::ERROR);
// //decrease watch value lower than error level but still greater than warning level
// watch = 58.1;
// watch.write();
// test.stepApplication();
// status.readLatest();
// //should be in WARNING state.
// BOOST_CHECK_EQUAL(status,ChimeraTK::States::WARNING);
// //decrease watch value lower than warning level
// watch = 54.1;
// watch.write();
// test.stepApplication();
// status.readLatest();
// //should be in OK state.
// BOOST_CHECK_EQUAL(status,ChimeraTK::States::OK);
dummy
.
open
(
"(ExceptionDummy?map=test.map)"
);
auto
reg1
=
dummy
.
getScalarRegisterAccessor
<
int32_t
>
(
"/REG1"
);
reg1
.
read
();
// ********************************************************
// REQUIRED TEST 1: After opening the device is initialised
// ********************************************************
BOOST_CHECK_EQUAL
(
reg1
,
42
);
reg1
=
0
;
reg1
.
write
();
// check that accessing an exception triggers a reconnection with re-initialisation
auto
dummyBackend
=
boost
::
dynamic_pointer_cast
<
ExceptionDummy
>
(
ctk
::
BackendFactory
::
getInstance
().
createBackend
(
"(ExceptionDummy?map=test.map)"
));
dummyBackend
->
throwExceptionWrite
=
true
;
// FIXME: Due to a bug it is /REG2/REG2 instead of just /REG2. This will fails once the bug has been solved.
auto
reg2_cs
=
test
.
getScalar
<
int32_t
>
(
"/REG2/REG2"
);
reg2_cs
=
19
;
reg2_cs
.
write
();
test
.
stepApplication
();
auto
reg2
=
dummy
.
getScalarRegisterAccessor
<
int32_t
>
(
"/REG2"
);
reg2
.
read
();
BOOST_CHECK_EQUAL
(
reg2
,
0
);
BOOST_CHECK_EQUAL
(
reg1
,
0
);
dummyBackend
->
throwExceptionWrite
=
false
;
// now the device should work again and be re-initialised
reg2_cs
=
20
;
reg2_cs
.
write
();
test
.
stepApplication
();
reg2
.
read
();
BOOST_CHECK_EQUAL
(
reg2
,
20
);
// ****************************************************************
// REQUIRED TEST 2: After an exception the device is re-initialised
// ****************************************************************
reg1
.
read
();
BOOST_CHECK_EQUAL
(
reg1
,
42
);
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment