Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
ControlSystemAdapter-DoocsAdapter
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
ControlSystemAdapter-DoocsAdapter
Commits
a3ed479a
Commit
a3ed479a
authored
7 years ago
by
Martin Killenberg
Browse files
Options
Downloads
Patches
Plain Diff
extended test for CSAdapterEqFct, and fixed implementation for non 1:1 mappings.
parent
2bd41407
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
CMakeLists.txt
+2
-0
2 additions, 0 deletions
CMakeLists.txt
src/CSAdapterEqFct.cc
+11
-31
11 additions, 31 deletions
src/CSAdapterEqFct.cc
tests/EqFctTest.xml
+9
-0
9 additions, 0 deletions
tests/EqFctTest.xml
tests/src/testCSAdapterEqFct.cpp
+32
-0
32 additions, 0 deletions
tests/src/testCSAdapterEqFct.cpp
with
54 additions
and
31 deletions
CMakeLists.txt
+
2
−
0
View file @
a3ed479a
...
...
@@ -67,6 +67,8 @@ if(TESTING_IS_ENABLED)
file
(
GLOB XML_FILES variable
${
CMAKE_SOURCE_DIR
}
/tests/variableTreeXml/*.xml
)
file
(
COPY
${
XML_FILES
}
DESTINATION
${
PROJECT_BINARY_DIR
}
/variableTreeXml
)
file
(
COPY
${
CMAKE_SOURCE_DIR
}
/tests/EqFctTest.xml DESTINATION
${
PROJECT_BINARY_DIR
}
)
#The make coverage command is only available in debug mode
IF
(
CMAKE_BUILD_TYPE STREQUAL
"Debug"
)
configure_file
(
cmake/Makefile.coverage.in
${
PROJECT_BINARY_DIR
}
/Makefile.coverage @ONLY
)
...
...
This diff is collapsed.
Click to expand it.
src/CSAdapterEqFct.cc
+
11
−
31
View file @
a3ed479a
#include
"CSAdapterEqFct.h"
#include
"DoocsPVFactory.h"
#include
"
splitStringAtFirstSlash
.h"
#include
"
VariableMapper
.h"
namespace
ChimeraTK
{
...
...
@@ -46,40 +46,20 @@ namespace ChimeraTK{
// We only need the factory inside this function
DoocsPVFactory
factory
(
this
,
syncUtility_
);
auto
processVariablesInThisLocation
=
getProcessVariablesInThisLocation
(
);
doocsProperties_
.
reserve
(
processVariablesIn
ThisLocation
.
size
()
);
auto
mappingForThisLocation
=
VariableMapper
::
getInstance
().
getPropertiesInLocation
(
fct_name
()
);
doocsProperties_
.
reserve
(
mappingFor
ThisLocation
.
size
()
);
// now create the doocs properties using the factory
for
(
auto
chimeraTKVariable
:
processVariablesInThisLocation
){
doocsProperties_
.
push_back
(
factory
.
create
(
chimeraTKVariable
)
);
// we also have to remember which chimeraTK variables we have to receive
if
(
chimeraTKVariable
->
isReadable
()
){
chimeraTKReceivers_
.
push_back
(
chimeraTKVariable
);
}
}
}
std
::
vector
<
ChimeraTK
::
ProcessVariable
::
SharedPtr
>
CSAdapterEqFct
::
getProcessVariablesInThisLocation
(){
std
::
vector
<
ChimeraTK
::
ProcessVariable
::
SharedPtr
>
pvsInThisLocation
;
auto
allPVs
=
controlSystemPVManager_
->
getAllProcessVariables
();
for
(
auto
&
pvNameAndPropertyDescrition
:
mappingForThisLocation
){
auto
pvName
=
pvNameAndPropertyDescrition
.
first
;
// we just need the pv name, not the description yet. The factory does that for us.
auto
chimeraTkVariable
=
controlSystemPVManager_
->
getProcessVariable
(
pvName
);
for
(
auto
pv
:
allPVs
){
auto
locationAndName
=
splitStringAtFirstSlash
(
pv
->
getName
()
);
if
(
locationAndName
.
first
==
fct_name
()
){
pvsInThisLocation
.
push_back
(
pv
);
}
else
if
(
locationAndName
.
first
==
""
&&
emptyLocationVariablesHandled
==
false
)
{
pvsInThisLocation
.
push_back
(
pv
);
doocsProperties_
.
push_back
(
factory
.
create
(
chimeraTkVariable
)
);
// we also have to remember which chimeraTK variables we have to receive
if
(
chimeraTkVariable
->
isReadable
()
){
chimeraTKReceivers_
.
push_back
(
chimeraTkVariable
);
}
}
// the first location to run this function is getting the PVs with empty location name
emptyLocationVariablesHandled
=
true
;
return
pvsInThisLocation
;
}
}
// namespace ChimeraTK
This diff is collapsed.
Click to expand it.
tests/EqFctTest.xml
0 → 100644
+
9
−
0
View file @
a3ed479a
<?xml version="1.0" encoding="UTF-8"?>
<device_server
xmlns=
"https://github.com/ChimeraTK/ControlSystemAdapter-DoocsAdapter"
>
<location
name=
"test.TO_DEVICE"
>
<property
source=
"/test/TO_DEVICE/INT"
name=
"INT"
/>
</location>
<location
name=
"test.FROM_DEVICE"
>
<property
source=
"/test/FROM_DEVICE/INT"
name=
"INT"
/>
</location>
</device_server>
This diff is collapsed.
Click to expand it.
tests/src/testCSAdapterEqFct.cpp
+
32
−
0
View file @
a3ed479a
...
...
@@ -95,4 +95,36 @@ BOOST_AUTO_TEST_CASE( testCSAdapterEqFct ) {
BOOST_CHECK_EQUAL
(
doocsProperties
[
"FROM_DEVICE.INT "
]
->
value
(),
15
);
}
BOOST_AUTO_TEST_CASE
(
testWithMapping
)
{
// This test is a bit redundant because the mapping is tested separately. Just to see that it
// works after integration.
// This is basically a stripped down copy of the test before, so we leave out all comments
// and just comment what is different.
DoocsAdapter
doocsAdapter
;
BusinessLogic
businessLogic
(
doocsAdapter
.
getDevicePVManager
()
);
// Initialse the mapping with an xml file.
auto
csManager
=
doocsAdapter
.
getControlSystemPVManager
();
VariableMapper
::
getInstance
().
prepareOutput
(
"EqFctTest.xml"
,
getAllVariableNames
(
csManager
)
);
// in the mapping two locations are created
TestableCSAdapterEqFct
toDeviceEqFct
(
42
,
csManager
,
"test.TO_DEVICE"
);
TestableCSAdapterEqFct
fromDeviceEqFct
(
42
,
csManager
,
"test.FROM_DEVICE"
);
BOOST_REQUIRE
(
toDeviceEqFct
.
getDoocsProperties
().
size
()
==
1
);
BOOST_REQUIRE
(
fromDeviceEqFct
.
getDoocsProperties
().
size
()
==
1
);
// extract the two properties and check the name
std
::
map
<
std
::
string
,
D_int
*>
doocsProperties
;
// both properties are called int, but are in different locations
D_int
*
doocsInt
=
dynamic_cast
<
D_int
*>
(
toDeviceEqFct
.
getDoocsProperties
()[
0
].
get
());
BOOST_REQUIRE
(
std
::
string
(
doocsInt
->
property_name
())
==
"INT "
);
doocsInt
=
dynamic_cast
<
D_int
*>
(
fromDeviceEqFct
.
getDoocsProperties
()[
0
].
get
());
BOOST_REQUIRE
(
std
::
string
(
doocsInt
->
property_name
())
==
"INT "
);
}
BOOST_AUTO_TEST_SUITE_END
()
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