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
b7237dcd
Commit
b7237dcd
authored
2 years ago
by
Martin Christoph Hierholzer
Browse files
Options
Downloads
Patches
Plain Diff
TestFacility: fix not sending initial values for Void variables
parent
fb5f36c8
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/TestFacility.cc
+29
-19
29 additions, 19 deletions
src/TestFacility.cc
with
29 additions
and
19 deletions
src/TestFacility.cc
+
29
−
19
View file @
b7237dcd
...
...
@@ -22,38 +22,48 @@ namespace ChimeraTK {
void
TestFacility
::
runApplication
()
const
{
app
.
testFacilityRunApplicationCalled
=
true
;
// send default values for all control system variables
for
(
auto
&
pv
:
pvManager
->
getAllProcessVariables
())
{
callForTypeNoVoid
(
pv
->
getValueType
(),
[
&
pv
,
this
](
auto
arg
)
{
// Applies only to writeable variables. @todo FIXME It should also NOT apply for application-to-controlsystem
// variables with a return channel, despite being writeable here!
callForType
(
pv
->
getValueType
(),
[
&
pv
,
this
](
auto
arg
)
{
using
T
=
decltype
(
arg
);
// Applies only to writeable variables.
// @todo FIXME It should also NOT apply for application-to-controlsystem variables with a return channel,
// despite being writeable here!
if
(
!
pv
->
isWriteable
())
return
;
// Safety check against incorrect usage
if
(
pv
->
getVersionNumber
()
!=
VersionNumber
(
nullptr
))
{
throw
ChimeraTK
::
logic_error
(
"The variable '"
+
pv
->
getName
()
+
"' has been written before TestFacility::runApplication() was called. Instead use "
"TestFacility::setScalarDefault() resp. setArrayDefault() to set initial values."
);
}
typedef
decltype
(
arg
)
T
;
// Get the PV accessor
auto
pv_casted
=
boost
::
dynamic_pointer_cast
<
NDRegisterAccessor
<
T
>>
(
pv
);
auto
table
=
boost
::
fusion
::
at_key
<
T
>
(
defaults
.
table
);
// If default value has been stored, copy the default value to the PV.
if
(
table
.
find
(
pv
->
getName
())
!=
table
.
end
())
{
/// Since pv_casted is the undecorated PV (lacking the TestableModeAccessorDecorator), we need to copy the
/// value also to the decorator. We still have to write through the undecorated PV, otherwise the tests are
/// stalled. @todo It is not understood why this happens!
/// Decorated accessors are stored in different maps for scalars are arrays...
if
(
pv_casted
->
getNumberOfSamples
()
==
1
)
{
// scalar
auto
accessor
=
this
->
getScalar
<
T
>
(
pv
->
getName
());
accessor
=
table
.
at
(
pv
->
getName
())[
0
];
}
else
{
// array
auto
accessor
=
this
->
getArray
<
T
>
(
pv
->
getName
());
accessor
=
table
.
at
(
pv
->
getName
());
if
constexpr
(
!
std
::
is_same
<
T
,
ChimeraTK
::
Void
>::
value
)
{
auto
table
=
boost
::
fusion
::
at_key
<
T
>
(
defaults
.
table
);
if
(
table
.
find
(
pv
->
getName
())
!=
table
.
end
())
{
/// Since pv_casted is the undecorated PV (lacking the TestableModeAccessorDecorator), we need to copy the
/// value also to the decorator. We still have to write through the undecorated PV, otherwise the tests are
/// stalled. @todo It is not understood why this happens!
/// Decorated accessors are stored in different maps for scalars are arrays...
if
(
pv_casted
->
getNumberOfSamples
()
==
1
)
{
// scalar
auto
accessor
=
this
->
getScalar
<
T
>
(
pv
->
getName
());
accessor
=
table
.
at
(
pv
->
getName
())[
0
];
}
else
{
// array
auto
accessor
=
this
->
getArray
<
T
>
(
pv
->
getName
());
accessor
=
table
.
at
(
pv
->
getName
());
}
// copy value also to undecorated PV
pv_casted
->
accessChannel
(
0
)
=
table
.
at
(
pv
->
getName
());
}
// copy value also to undecorated PV
pv_casted
->
accessChannel
(
0
)
=
table
.
at
(
pv
->
getName
());
}
// Write the initial value. This must be done even if no default value has been stored, since it is expected
// by the application.
pv_casted
->
write
();
...
...
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