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
9f9deb22
Commit
9f9deb22
authored
7 years ago
by
Martin Christoph Hierholzer
Browse files
Options
Downloads
Patches
Plain Diff
added convenience read and write functions for tests
parent
ec366499
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
include/TestFacility.h
+33
-0
33 additions, 0 deletions
include/TestFacility.h
tests/executables_src/testTestFacilities.cc
+35
-0
35 additions, 0 deletions
tests/executables_src/testTestFacilities.cc
with
68 additions
and
0 deletions
include/TestFacility.h
+
33
−
0
View file @
9f9deb22
...
@@ -110,6 +110,39 @@ namespace ChimeraTK {
...
@@ -110,6 +110,39 @@ namespace ChimeraTK {
return
boost
::
fusion
::
at_key
<
T
>
(
arrayMap
.
table
)[
name
];
return
boost
::
fusion
::
at_key
<
T
>
(
arrayMap
.
table
)[
name
];
}
}
/** Convenience function to write a scalar process variable in a single call */
template
<
typename
TYPE
>
void
writeScalar
(
const
std
::
string
&
name
,
const
TYPE
value
)
{
auto
acc
=
getScalar
<
TYPE
>
(
name
);
acc
=
value
;
acc
.
write
();
}
/** Convenience function to write an array process variable in a single call */
template
<
typename
TYPE
>
void
writeArray
(
const
std
::
string
&
name
,
const
std
::
vector
<
TYPE
>
&
value
)
{
auto
acc
=
getArray
<
TYPE
>
(
name
);
acc
=
value
;
acc
.
write
();
}
/** Convenience function to read the latest value of a scalar process variable in a single call */
template
<
typename
TYPE
>
TYPE
readScalar
(
const
std
::
string
&
name
)
{
auto
acc
=
getScalar
<
TYPE
>
(
name
);
acc
.
readLatest
();
return
acc
;
}
/** Convenience function to read the latest value of an array process variable in a single call */
template
<
typename
TYPE
>
std
::
vector
<
TYPE
>
readArray
(
const
std
::
string
&
name
)
{
auto
acc
=
getArray
<
TYPE
>
(
name
);
acc
.
readLatest
();
return
acc
;
}
protected
:
protected
:
boost
::
shared_ptr
<
ControlSystemPVManager
>
pvManager
;
boost
::
shared_ptr
<
ControlSystemPVManager
>
pvManager
;
...
...
This diff is collapsed.
Click to expand it.
tests/executables_src/testTestFacilities.cc
+
35
−
0
View file @
9f9deb22
...
@@ -810,3 +810,38 @@ BOOST_AUTO_TEST_CASE_TEMPLATE( testWithTriggerFanOut, T, test_types ) {
...
@@ -810,3 +810,38 @@ BOOST_AUTO_TEST_CASE_TEMPLATE( testWithTriggerFanOut, T, test_types ) {
BOOST_CHECK
(
index
.
readNonBlocking
()
==
false
);
BOOST_CHECK
(
index
.
readNonBlocking
()
==
false
);
}
}
/*********************************************************************************************************************/
/* test convenience read functions */
BOOST_AUTO_TEST_CASE_TEMPLATE
(
testConvenienceRead
,
T
,
test_types
)
{
std
::
cout
<<
"*********************************************************************************************************************"
<<
std
::
endl
;
std
::
cout
<<
"==> testConvenienceRead<"
<<
typeid
(
T
).
name
()
<<
">"
<<
std
::
endl
;
TestApplication
<
T
>
app
;
app
.
cs
(
"input"
)
>>
app
.
blockingReadTestModule
.
someInput
;
app
.
blockingReadTestModule
.
someOutput
>>
app
.
cs
(
"output"
);
app
.
asyncReadTestModule
.
connectTo
(
app
.
cs
[
"async"
]);
// avoid runtime warning
app
.
readAnyTestModule
.
connectTo
(
app
.
cs
[
"readAny"
]);
// avoid runtime warning
ctk
::
TestFacility
test
;
auto
pvOutput
=
test
.
getScalar
<
T
>
(
"output"
);
test
.
runApplication
();
// test blocking read when taking control in the test thread (note: the blocking read is executed in the app module!)
for
(
int
i
=
0
;
i
<
5
;
++
i
)
{
test
.
writeScalar
<
T
>
(
"input"
,
120
+
i
);
test
.
stepApplication
();
CHECK_TIMEOUT
(
test
.
readScalar
<
T
>
(
"output"
)
==
120
+
i
,
200
);
}
// same with array function (still a scalar variable behind, but this does not matter)
for
(
int
i
=
0
;
i
<
5
;
++
i
)
{
std
::
vector
<
T
>
myValue
{
120
+
i
};
test
.
writeArray
<
T
>
(
"input"
,
myValue
);
test
.
stepApplication
();
CHECK_TIMEOUT
(
test
.
readArray
<
T
>
(
"output"
)
==
std
::
vector
<
T
>
{
120
+
i
},
200
);
}
}
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