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
4057cb57
Commit
4057cb57
authored
5 years ago
by
Martin Christoph Hierholzer
Browse files
Options
Downloads
Patches
Plain Diff
allow setting startup values for control system variables through the TestFacility
parent
71dfcdac
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
include/TestFacility.h
+42
-3
42 additions, 3 deletions
include/TestFacility.h
with
42 additions
and
3 deletions
include/TestFacility.h
+
42
−
3
View file @
4057cb57
...
...
@@ -35,12 +35,26 @@ namespace ChimeraTK {
Application
::
getInstance
().
initialise
();
}
/** Start the application. This simply calls Application::run(). Since the
* application is in testable mode, it
* will be ??? TODO define precisely what happens on start up */
/** Start the application in testable mode. */
void
runApplication
()
const
{
// send default values for all control system variables
for
(
auto
&
pv
:
pvManager
->
getAllProcessVariables
())
{
callForType
(
pv
->
getValueType
(),
[
&
pv
,
this
](
auto
arg
)
{
if
(
!
pv
->
isWriteable
())
return
;
typedef
decltype
(
arg
)
T
;
auto
pv_casted
=
boost
::
dynamic_pointer_cast
<
NDRegisterAccessor
<
T
>>
(
pv
);
auto
table
=
boost
::
fusion
::
at_key
<
T
>
(
defaults
.
table
);
if
(
table
.
find
(
pv
->
getName
())
!=
table
.
end
())
{
pv_casted
->
accessChannel
(
0
)
=
table
.
at
(
pv
->
getName
());
}
pv_casted
->
write
();
});
}
// start the application
Application
::
getInstance
().
run
();
// set thread name
Application
::
registerThread
(
"TestThread"
);
// wait until all devices are opened
Application
::
testableModeUnlock
(
"waitDevicesToOpen"
);
while
(
true
)
{
boost
::
this_thread
::
yield
();
...
...
@@ -166,6 +180,26 @@ namespace ChimeraTK {
return
acc
;
}
/** Set default value for scalar process variable. */
template
<
typename
T
>
void
setScalarDefault
(
const
ChimeraTK
::
RegisterPath
&
name
,
const
T
&
value
)
{
std
::
vector
<
T
>
vv
;
vv
.
push_back
(
value
);
setArrayDefaults
(
name
,
vv
);
}
/** Set default value for array process variable. */
template
<
typename
T
>
void
setArrayDefault
(
const
ChimeraTK
::
RegisterPath
&
name
,
const
std
::
vector
<
T
>&
value
)
{
// check if PV exists
auto
pv
=
pvManager
->
getProcessArray
<
T
>
(
name
);
if
(
pv
==
nullptr
)
{
throw
ChimeraTK
::
logic_error
(
"Process variable '"
+
name
+
"' does not exist."
);
}
// store default value in map
boost
::
fusion
::
at_key
<
T
>
(
defaults
.
table
)[
name
]
=
value
;
}
protected
:
boost
::
shared_ptr
<
ControlSystemPVManager
>
pvManager
;
...
...
@@ -182,6 +216,11 @@ namespace ChimeraTK {
template
<
typename
UserType
>
using
ArrayMap
=
std
::
map
<
std
::
string
,
ChimeraTK
::
OneDRegisterAccessor
<
UserType
>>
;
mutable
ChimeraTK
::
TemplateUserTypeMap
<
ArrayMap
>
arrayMap
;
// default values for process variables
template
<
typename
UserType
>
using
Defaults
=
std
::
map
<
std
::
string
,
std
::
vector
<
UserType
>>
;
ChimeraTK
::
TemplateUserTypeMap
<
Defaults
>
defaults
;
};
}
/* namespace ChimeraTK */
...
...
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