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
e6987ae7
Commit
e6987ae7
authored
4 years ago
by
Martin Christoph Hierholzer
Browse files
Options
Downloads
Patches
Plain Diff
fix throwing away readback initial values of bidirectional variables in TestFacility
parent
1e02cc5e
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
include/TestFacility.h
+20
-23
20 additions, 23 deletions
include/TestFacility.h
with
20 additions
and
23 deletions
include/TestFacility.h
+
20
−
23
View file @
e6987ae7
...
...
@@ -103,7 +103,10 @@ namespace ChimeraTK {
if
(
Application
::
getInstance
().
isTestableModeEnabled
())
{
for
(
auto
&
pv
:
pvManager
->
getAllProcessVariables
())
{
if
(
!
pv
->
isReadable
())
continue
;
pv
->
readNonBlocking
();
callForType
(
pv
->
getValueType
(),
[
&
](
auto
t
)
{
typedef
decltype
(
t
)
UserType
;
this
->
getArray
<
UserType
>
(
pv
->
getName
()).
readNonBlocking
();
});
}
}
}
...
...
@@ -124,8 +127,8 @@ namespace ChimeraTK {
template
<
typename
T
>
ChimeraTK
::
ScalarRegisterAccessor
<
T
>
getScalar
(
const
ChimeraTK
::
RegisterPath
&
name
)
const
{
// check for existing accessor in cache
if
(
boost
::
fusion
::
at_key
<
T
>
(
scala
rMap
.
table
).
count
(
name
)
>
0
)
{
return
boost
::
fusion
::
at_key
<
T
>
(
scala
rMap
.
table
)[
name
];
if
(
boost
::
fusion
::
at_key
<
T
>
(
accesso
rMap
.
table
).
count
(
name
)
>
0
)
{
return
boost
::
fusion
::
at_key
<
T
>
(
accesso
rMap
.
table
)[
name
];
}
// obtain accessor from ControlSystemPVManager
...
...
@@ -143,14 +146,14 @@ namespace ChimeraTK {
if
(
pv
->
isWriteable
()
&&
!
Application
::
getInstance
().
testableMode_isPollMode
[
varId
])
{
auto
deco
=
boost
::
make_shared
<
TestableModeAccessorDecorator
<
T
>>
(
pv
,
false
,
true
,
varId
,
varId
);
Application
::
getInstance
().
testableMode_names
[
varId
]
=
"ControlSystem:"
+
name
;
boost
::
fusion
::
at_key
<
T
>
(
scala
rMap
.
table
)[
name
]
.
replace
(
ChimeraTK
::
ScalarRegisterAccessor
<
T
>
(
deco
))
;
boost
::
fusion
::
at_key
<
T
>
(
accesso
rMap
.
table
)[
name
]
=
deco
;
}
else
{
boost
::
fusion
::
at_key
<
T
>
(
scala
rMap
.
table
)[
name
]
.
replace
(
ChimeraTK
::
ScalarRegisterAccessor
<
T
>
(
pv
))
;
boost
::
fusion
::
at_key
<
T
>
(
accesso
rMap
.
table
)[
name
]
=
pv
;
}
// return the accessor as stored in the cache
return
boost
::
fusion
::
at_key
<
T
>
(
scala
rMap
.
table
)[
name
];
return
boost
::
fusion
::
at_key
<
T
>
(
accesso
rMap
.
table
)[
name
];
}
/** Obtain an array-type process variable from the application, which is
...
...
@@ -158,8 +161,8 @@ namespace ChimeraTK {
template
<
typename
T
>
ChimeraTK
::
OneDRegisterAccessor
<
T
>
getArray
(
const
ChimeraTK
::
RegisterPath
&
name
)
const
{
// check for existing accessor in cache
if
(
boost
::
fusion
::
at_key
<
T
>
(
a
rray
Map
.
table
).
count
(
name
)
>
0
)
{
return
boost
::
fusion
::
at_key
<
T
>
(
a
rray
Map
.
table
)[
name
];
if
(
boost
::
fusion
::
at_key
<
T
>
(
a
ccessor
Map
.
table
).
count
(
name
)
>
0
)
{
return
boost
::
fusion
::
at_key
<
T
>
(
a
ccessor
Map
.
table
)[
name
];
}
// obtain accessor from ControlSystemPVManager
...
...
@@ -177,14 +180,14 @@ namespace ChimeraTK {
if
(
pv
->
isWriteable
()
&&
!
Application
::
getInstance
().
testableMode_isPollMode
[
varId
])
{
auto
deco
=
boost
::
make_shared
<
TestableModeAccessorDecorator
<
T
>>
(
pv
,
false
,
true
,
varId
,
varId
);
Application
::
getInstance
().
testableMode_names
[
varId
]
=
"ControlSystem:"
+
name
;
boost
::
fusion
::
at_key
<
T
>
(
a
rray
Map
.
table
)[
name
]
.
replace
(
ChimeraTK
::
OneDRegisterAccessor
<
T
>
(
deco
))
;
boost
::
fusion
::
at_key
<
T
>
(
a
ccessor
Map
.
table
)[
name
]
=
deco
;
}
else
{
boost
::
fusion
::
at_key
<
T
>
(
a
rray
Map
.
table
)[
name
]
.
replace
(
ChimeraTK
::
OneDRegisterAccessor
<
T
>
(
pv
))
;
boost
::
fusion
::
at_key
<
T
>
(
a
ccessor
Map
.
table
)[
name
]
=
pv
;
}
// return the accessor as stored in the cache
return
boost
::
fusion
::
at_key
<
T
>
(
a
rray
Map
.
table
)[
name
];
return
boost
::
fusion
::
at_key
<
T
>
(
a
ccessor
Map
.
table
)[
name
];
}
/** Convenience function to write a scalar process variable in a single call
...
...
@@ -246,19 +249,13 @@ namespace ChimeraTK {
protected
:
boost
::
shared_ptr
<
ControlSystemPVManager
>
pvManager
;
// Cache (possible decorated) accessors to avoid the need to create accessors
// multiple times. This would not work if the accessor is decorated, since the
// buffer would be lost and thus the current value could no longer be
// obtained. This has to be done separately for scalar and array accessors and
// in dependence of the user type. Since this is a cache and does not change
// the logical behaviour of the class, the maps are defined mutable.
// Cache (possible decorated) accessors to avoid the need to create accessors multiple times. This would not work
// if the accessor is decorated, since the buffer would be lost and thus the current value could no longer be
// obtained. This has to be done in dependence of the user type. Since this is a cache and does not change the
// logical behaviour of the class, the maps are defined mutable.
template
<
typename
UserType
>
using
ScalarMap
=
std
::
map
<
std
::
string
,
ChimeraTK
::
ScalarRegisterAccessor
<
UserType
>>
;
mutable
ChimeraTK
::
TemplateUserTypeMap
<
ScalarMap
>
scalarMap
;
template
<
typename
UserType
>
using
ArrayMap
=
std
::
map
<
std
::
string
,
ChimeraTK
::
OneDRegisterAccessor
<
UserType
>>
;
mutable
ChimeraTK
::
TemplateUserTypeMap
<
ArrayMap
>
arrayMap
;
using
AccessorMap
=
std
::
map
<
std
::
string
,
boost
::
shared_ptr
<
ChimeraTK
::
NDRegisterAccessor
<
UserType
>>>
;
mutable
ChimeraTK
::
TemplateUserTypeMap
<
AccessorMap
>
accessorMap
;
// default values for process variables
template
<
typename
UserType
>
...
...
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