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
bd02a801
Commit
bd02a801
authored
7 years ago
by
Martin Christoph Hierholzer
Browse files
Options
Downloads
Patches
Plain Diff
added tests for direct connections between device and control system
parent
73e01c15
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
tests/executables_src/testControlSystemAccessors.cc
+86
-1
86 additions, 1 deletion
tests/executables_src/testControlSystemAccessors.cc
tests/executables_src/testDeviceAccessors.cc
+2
-0
2 additions, 0 deletions
tests/executables_src/testDeviceAccessors.cc
with
88 additions
and
1 deletion
tests/executables_src/testControlSystemAccessors.cc
+
86
−
1
View file @
bd02a801
...
...
@@ -13,6 +13,8 @@
#include
<boost/test/test_case_template.hpp>
#include
<boost/mpl/list.hpp>
#include
<mtca4u/BackendFactory.h>
#include
<mtca4u/Device.h>
#include
<ChimeraTK/ControlSystemAdapter/PVManager.h>
#include
<ChimeraTK/ControlSystemAdapter/ControlSystemPVManager.h>
#include
<ChimeraTK/ControlSystemAdapter/DevicePVManager.h>
...
...
@@ -21,6 +23,7 @@
#include
"ScalarAccessor.h"
#include
"ApplicationModule.h"
#include
"ControlSystemModule.h"
#include
"DeviceModule.h"
using
namespace
boost
::
unit_test_framework
;
namespace
ctk
=
ChimeraTK
;
...
...
@@ -31,6 +34,17 @@ typedef boost::mpl::list<int8_t,uint8_t,
int32_t
,
uint32_t
,
float
,
double
>
test_types
;
#define CHECK_TIMEOUT(condition, maxMilliseconds) \
{ \
std::chrono::steady_clock::time_point t0 = std::chrono::steady_clock::now(); \
while(!(condition)) { \
bool timeout_reached = (std::chrono::steady_clock::now()-t0) > std::chrono::milliseconds(maxMilliseconds); \
BOOST_CHECK( !timeout_reached ); \
if(timeout_reached) break; \
usleep(1000); \
} \
}
/*********************************************************************************************************************/
/* the ApplicationModule for the test is a template of the user type */
...
...
@@ -49,7 +63,9 @@ struct TestModule : public ctk::ApplicationModule {
template
<
typename
T
>
struct
TestApplication
:
public
ctk
::
Application
{
TestApplication
()
:
Application
(
"testSuite"
)
{}
TestApplication
()
:
Application
(
"testSuite"
)
{
mtca4u
::
BackendFactory
::
getInstance
().
setDMapFilePath
(
"test.dmap"
);
}
~
TestApplication
()
{
shutdown
();
}
using
Application
::
makeConnections
;
// we call makeConnections() manually in the tests to catch exceptions etc.
...
...
@@ -57,6 +73,8 @@ struct TestApplication : public ctk::Application {
TestModule
<
T
>
testModule
{
this
,
"TestModule"
,
"The test module"
};
ctk
::
ControlSystemModule
cs
;
ctk
::
DeviceModule
dev
{
"Dummy0"
};
};
/*********************************************************************************************************************/
...
...
@@ -321,3 +339,70 @@ BOOST_AUTO_TEST_CASE_TEMPLATE( testMultipleRePublications, T, test_types ) {
}
/*********************************************************************************************************************/
/* test direct control system to device connections */
BOOST_AUTO_TEST_CASE_TEMPLATE
(
testDirectCStoDev
,
T
,
test_types
)
{
TestApplication
<
T
>
app
;
auto
pvManagers
=
ctk
::
createPVManager
();
app
.
setPVManager
(
pvManagers
.
second
);
app
.
cs
(
"myFeeder"
,
typeid
(
T
),
1
)
>>
app
.
dev
(
"/MyModule/actuator"
);
app
.
initialise
();
app
.
run
();
mtca4u
::
Device
dev
;
dev
.
open
(
"Dummy0"
);
BOOST_CHECK_EQUAL
(
pvManagers
.
first
->
getAllProcessVariables
().
size
(),
1
);
auto
myFeeder
=
pvManagers
.
first
->
getProcessArray
<
T
>
(
"/myFeeder"
);
BOOST_CHECK
(
myFeeder
->
getName
()
==
"/myFeeder"
);
myFeeder
->
accessData
(
0
)
=
18
;
myFeeder
->
write
();
CHECK_TIMEOUT
(
dev
.
read
<
T
>
(
"/MyModule/actuator"
)
==
18
,
3000
);
myFeeder
->
accessData
(
0
)
=
20
;
myFeeder
->
write
();
CHECK_TIMEOUT
(
dev
.
read
<
T
>
(
"/MyModule/actuator"
)
==
20
,
3000
);
}
/*********************************************************************************************************************/
/* test direct control system to control system connections */
BOOST_AUTO_TEST_CASE_TEMPLATE
(
testDirectCStoCS
,
T
,
test_types
)
{
TestApplication
<
T
>
app
;
auto
pvManagers
=
ctk
::
createPVManager
();
app
.
setPVManager
(
pvManagers
.
second
);
app
.
cs
(
"mySender"
,
typeid
(
T
),
1
)
>>
app
.
cs
(
"myReceiver"
);
app
.
initialise
();
app
.
run
();
BOOST_CHECK_EQUAL
(
pvManagers
.
first
->
getAllProcessVariables
().
size
(),
2
);
auto
mySender
=
pvManagers
.
first
->
getProcessArray
<
T
>
(
"/mySender"
);
BOOST_CHECK
(
mySender
->
getName
()
==
"/mySender"
);
auto
myReceiver
=
pvManagers
.
first
->
getProcessArray
<
T
>
(
"/myReceiver"
);
BOOST_CHECK
(
myReceiver
->
getName
()
==
"/myReceiver"
);
mySender
->
accessData
(
0
)
=
22
;
mySender
->
write
();
myReceiver
->
read
();
BOOST_CHECK_EQUAL
(
myReceiver
->
accessData
(
0
),
22
);
mySender
->
accessData
(
0
)
=
23
;
mySender
->
write
();
myReceiver
->
read
();
BOOST_CHECK_EQUAL
(
myReceiver
->
accessData
(
0
),
23
);
mySender
->
accessData
(
0
)
=
24
;
mySender
->
write
();
myReceiver
->
read
();
BOOST_CHECK_EQUAL
(
myReceiver
->
accessData
(
0
),
24
);
}
This diff is collapsed.
Click to expand it.
tests/executables_src/testDeviceAccessors.cc
+
2
−
0
View file @
bd02a801
...
...
@@ -63,6 +63,8 @@ struct TestApplication : public ctk::Application {
TestModule
<
T
>
testModule
{
this
,
"testModule"
,
"The test module"
};
ctk
::
DeviceModule
devMymodule
{
"Dummy0"
,
"MyModule"
};
ctk
::
DeviceModule
dev
{
"Dummy0"
};
// note: direct device-to-controlsystem connections are tested in testControlSystemAccessors!
};
/*********************************************************************************************************************/
...
...
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