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
67c0bdcd
Commit
67c0bdcd
authored
7 years ago
by
Martin Christoph Hierholzer
Browse files
Options
Downloads
Patches
Plain Diff
neccessary update for the latest DeviceAccess changes
parent
440f83a6
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
src/DoocsPVFactory.cc
+18
-18
18 additions, 18 deletions
src/DoocsPVFactory.cc
tests/src/testDoocsSpectrum.cpp
+11
-11
11 additions, 11 deletions
tests/src/testDoocsSpectrum.cpp
with
29 additions
and
29 deletions
src/DoocsPVFactory.cc
+
18
−
18
View file @
67c0bdcd
...
...
@@ -13,7 +13,7 @@ namespace ChimeraTK {
DoocsPVFactory
::
DoocsPVFactory
(
EqFct
*
const
eqFct
,
DoocsUpdater
&
updater
,
boost
::
shared_ptr
<
ControlSystemPVManager
>
const
&
csPVManager
)
boost
::
shared_ptr
<
ControlSystemPVManager
>
const
&
csPVManager
)
:
_eqFct
(
eqFct
),
_updater
(
updater
),
_controlSystemPVManager
(
csPVManager
)
{
assert
(
eqFct
!=
nullptr
);
}
...
...
@@ -24,8 +24,8 @@ namespace ChimeraTK {
auto
processVariable
=
_controlSystemPVManager
->
getProcessVariable
(
propertyDescription
.
source
);
// the DoocsProcessScalar needs the real ProcessScalar type, not just ProcessVariable
auto
processArray
=
getDecorator
<
DOOCS_PRIMITIVE_T
>
(
*
processVariable
,
decoratorType
);
auto
processArray
=
getDecorator
<
DOOCS_PRIMITIVE_T
>
(
processVariable
,
decoratorType
);
assert
(
processArray
->
getNumberOfChannels
()
==
1
);
boost
::
shared_ptr
<
D_fct
>
doocsPV
;
// Histories seem to be supported by DOOCS only for property names shorter than 64 characters, so disable history for longer names.
...
...
@@ -49,7 +49,7 @@ namespace ChimeraTK {
if
(
!
processArray
->
isWriteable
()
||
!
propertyDescription
.
isWriteable
){
doocsPV
->
set_ro_access
();
}
return
doocsPV
;
}
...
...
@@ -58,7 +58,7 @@ namespace ChimeraTK {
AutoPropertyDescription
const
&
propertyDescription
,
DecoratorType
/*decoratorType*/
){
auto
processVariable
=
_controlSystemPVManager
->
getProcessVariable
(
propertyDescription
.
source
);
// FIXME: Use a decorator, but this has to be tested and implemented for strings first
// the DoocsProcessArray needs the real ProcessScalar type, not just ProcessVariable
boost
::
shared_ptr
<
mtca4u
::
NDRegisterAccessor
<
std
::
string
>
>
processArray
...
...
@@ -67,7 +67,7 @@ namespace ChimeraTK {
throw
std
::
invalid_argument
(
std
::
string
(
"DoocsPVFactory::createDoocsArray : processArray is of the wrong type "
)
+
processVariable
->
getValueType
().
name
());
}
assert
(
processArray
->
getNumberOfChannels
()
==
1
);
assert
(
processArray
->
getNumberOfSamples
()
==
1
);
// array of strings is not supported
boost
::
shared_ptr
<
D_fct
>
doocsPV
(
new
DoocsProcessScalar
<
std
::
string
,
D_string
>
(
_eqFct
,
propertyDescription
.
name
.
c_str
(),
processArray
,
_updater
)
);
...
...
@@ -76,7 +76,7 @@ namespace ChimeraTK {
if
(
!
processArray
->
isWriteable
()
||
!
propertyDescription
.
isWriteable
){
doocsPV
->
set_ro_access
();
}
return
doocsPV
;
}
...
...
@@ -89,18 +89,18 @@ namespace ChimeraTK {
// config file with the data from the accessors. The spectrum will keep the data updated.
boost
::
shared_ptr
<
mtca4u
::
NDRegisterAccessor
<
float
>
>
startAccessor
;
boost
::
shared_ptr
<
mtca4u
::
NDRegisterAccessor
<
float
>
>
incrementAccessor
;
if
(
spectrumDescription
.
startSource
!=
""
){
startAccessor
=
getDecorator
<
float
>
(
*
_controlSystemPVManager
->
getProcessVariable
(
spectrumDescription
.
startSource
)
);
startAccessor
=
getDecorator
<
float
>
(
_controlSystemPVManager
->
getProcessVariable
(
spectrumDescription
.
startSource
)
);
start
=
startAccessor
->
accessData
(
0
);
}
if
(
spectrumDescription
.
incrementSource
!=
""
){
incrementAccessor
=
getDecorator
<
float
>
(
*
_controlSystemPVManager
->
getProcessVariable
(
spectrumDescription
.
incrementSource
)
);
incrementAccessor
=
getDecorator
<
float
>
(
_controlSystemPVManager
->
getProcessVariable
(
spectrumDescription
.
incrementSource
)
);
increment
=
incrementAccessor
->
accessData
(
0
);
}
// assert(processArray->getNumberOfChannels() == 1);
boost
::
shared_ptr
<
D_fct
>
doocsPV
(
new
DoocsSpectrum
(
_eqFct
,
spectrumDescription
.
name
,
getDecorator
<
float
>
(
*
processVariable
),
_updater
,
startAccessor
,
incrementAccessor
)
);
boost
::
shared_ptr
<
D_fct
>
doocsPV
(
new
DoocsSpectrum
(
_eqFct
,
spectrumDescription
.
name
,
getDecorator
<
float
>
(
processVariable
),
_updater
,
startAccessor
,
incrementAccessor
)
);
// set read only mode if configures in the xml file or for output variables
if
(
!
processVariable
->
isWriteable
()
||
!
spectrumDescription
.
isWriteable
){
...
...
@@ -110,7 +110,7 @@ namespace ChimeraTK {
// can use static cast, we know it's a D_spectrum, we just created it
auto
spectrum
=
boost
::
static_pointer_cast
<
D_spectrum
>
(
doocsPV
);
spectrum
->
spectrum_parameter
(
spectrum
->
spec_time
(),
start
,
increment
,
spectrum
->
spec_status
()
);
return
doocsPV
;
}
...
...
@@ -134,12 +134,12 @@ namespace ChimeraTK {
boost
::
shared_ptr
<
D_fct
>
DoocsPVFactory
::
autoCreate
(
std
::
shared_ptr
<
PropertyDescription
>
const
&
propertyDescription
){
// do auto creation
auto
autoPropertyDescription
=
std
::
static_pointer_cast
<
AutoPropertyDescription
>
(
propertyDescription
);
auto
pvName
=
autoPropertyDescription
->
source
;
auto
processVariable
=
_controlSystemPVManager
->
getProcessVariable
(
pvName
);
std
::
type_info
const
&
valueType
=
processVariable
->
getValueType
();
/* TODO:
/* TODO:
- create functions "createDoocsArray" and "createDoocsSpectrum"
- first use spectrum here for 1D, then switch to array (tests need to be adapted)
- create spectrum, array and d_int/float/double upon request from 1d (scalar for D_array and 1D)
...
...
@@ -182,7 +182,7 @@ namespace ChimeraTK {
boost
::
shared_ptr
<
D_fct
>
DoocsPVFactory
::
typedCreateDoocsArray
(
ArrayDescription
const
&
arrayDescription
){
auto
processVariable
=
_controlSystemPVManager
->
getProcessVariable
(
arrayDescription
.
source
);
boost
::
shared_ptr
<
D_fct
>
doocsPV
(
new
DoocsProcessArray
<
DOOCS_T
,
DOOCS_PRIMITIVE_T
>
(
_eqFct
,
arrayDescription
.
name
,
getDecorator
<
DOOCS_PRIMITIVE_T
>
(
*
processVariable
),
_updater
)
);
boost
::
shared_ptr
<
D_fct
>
doocsPV
(
new
DoocsProcessArray
<
DOOCS_T
,
DOOCS_PRIMITIVE_T
>
(
_eqFct
,
arrayDescription
.
name
,
getDecorator
<
DOOCS_PRIMITIVE_T
>
(
processVariable
),
_updater
)
);
// set read only mode if configures in the xml file or for output variables
if
(
!
processVariable
->
isWriteable
()
||
!
arrayDescription
.
isWriteable
){
...
...
@@ -191,7 +191,7 @@ namespace ChimeraTK {
return
doocsPV
;
}
boost
::
shared_ptr
<
D_fct
>
DoocsPVFactory
::
createDoocsArray
(
std
::
shared_ptr
<
ArrayDescription
>
const
&
arrayDescription
){
if
(
arrayDescription
->
dataType
==
ArrayDescription
::
DataType
::
Auto
){
// leave the desision which array to produce to the auto creation algorithm. We need it there anyway
...
...
@@ -227,6 +227,6 @@ namespace ChimeraTK {
throw
std
::
invalid_argument
(
"Sorry, your type is not supported yet."
);
}
}
}
// namespace
This diff is collapsed.
Click to expand it.
tests/src/testDoocsSpectrum.cpp
+
11
−
11
View file @
67c0bdcd
...
...
@@ -26,7 +26,7 @@ public:
void
sendToDevice
(){
DoocsSpectrum
::
sendToDevice
();
}
};
// use boost meta-programming to use test case templates
...
...
@@ -48,22 +48,22 @@ BOOST_AUTO_TEST_CASE_TEMPLATE( toDeviceTest, T, simple_test_types ){
boost
::
shared_ptr
<
mtca4u
::
NDRegisterAccessor
<
T
>
>
deviceVariable
=
devManager
->
createProcessArray
<
T
>
(
controlSystemToDevice
,
"toDeviceVariable"
,
arraySize
);
boost
::
shared_ptr
<
mtca4u
::
NDRegisterAccessor
<
T
>
>
controlSystemVariable
=
boost
::
shared_ptr
<
mtca4u
::
NDRegisterAccessor
<
T
>
>
controlSystemVariable
=
csManager
->
getProcessArray
<
T
>
(
"toDeviceVariable"
);
DoocsUpdater
updater
;
// Write to the doocs spectrum and send it.
// We use the 'testable' version which exposes sendToDevice, which otherwise is
// We use the 'testable' version which exposes sendToDevice, which otherwise is
// protected.
TestableDoocsSpectrum
doocsSpectrum
(
NULL
,
"someName"
,
getDecorator
<
float
>
(
*
controlSystemVariable
),
updater
);
TestableDoocsSpectrum
doocsSpectrum
(
NULL
,
"someName"
,
getDecorator
<
float
>
(
controlSystemVariable
),
updater
);
// create unique signature for each template parameter
// negative factor for signed values
T
sign
=
(
std
::
numeric_limits
<
T
>::
is_signed
?
-
1
:
1
);
// integer size offset for integer, fractional offset for floating type
T
offset
=
(
std
::
numeric_limits
<
T
>::
is_integer
?
sizeof
(
T
)
:
1.
/
sizeof
(
T
)
);
for
(
size_t
i
=
0
;
i
<
arraySize
;
++
i
){
doocsSpectrum
.
fill_spectrum
(
i
,
sign
*
static_cast
<
T
>
(
i
*
i
)
+
offset
);
}
...
...
@@ -71,11 +71,11 @@ BOOST_AUTO_TEST_CASE_TEMPLATE( toDeviceTest, T, simple_test_types ){
// receive on the device side and check that the value has arrived
deviceVariable
->
readNonBlocking
();
std
::
vector
<
T
>
&
deviceVector
=
deviceVariable
->
accessChannel
(
0
);
for
(
size_t
i
=
0
;
i
<
arraySize
;
++
i
){
std
::
stringstream
errorMessage
;
errorMessage
<<
"i = "
<<
i
<<
", deviceVector[i] = "
errorMessage
<<
"i = "
<<
i
<<
", deviceVector[i] = "
<<
deviceVector
[
i
]
<<
" expected "
<<
sign
*
static_cast
<
T
>
(
i
*
i
)
+
offset
;
BOOST_CHECK_MESSAGE
(
deviceVector
[
i
]
==
sign
*
static_cast
<
T
>
(
i
*
i
)
+
offset
,
...
...
@@ -94,13 +94,13 @@ BOOST_AUTO_TEST_CASE_TEMPLATE( fromDeviceTest, T, simple_test_types ){
typename
boost
::
shared_ptr
<
mtca4u
::
NDRegisterAccessor
<
T
>
>
deviceVariable
=
devManager
->
createProcessArray
<
T
>
(
deviceToControlSystem
,
"fromDeviceVariable"
,
arraySize
);
typename
boost
::
shared_ptr
<
mtca4u
::
NDRegisterAccessor
<
T
>
>
controlSystemVariable
=
typename
boost
::
shared_ptr
<
mtca4u
::
NDRegisterAccessor
<
T
>
>
controlSystemVariable
=
csManager
->
getProcessArray
<
T
>
(
"fromDeviceVariable"
);
DoocsUpdater
updater
;
// initialise the doocs spectrum
DoocsSpectrum
doocsSpectrum
(
NULL
,
"someName"
,
getDecorator
<
float
>
(
*
controlSystemVariable
),
updater
,
nullptr
,
nullptr
);
DoocsSpectrum
doocsSpectrum
(
NULL
,
"someName"
,
getDecorator
<
float
>
(
controlSystemVariable
),
updater
,
nullptr
,
nullptr
);
for
(
size_t
i
=
0
;
i
<
arraySize
;
++
i
){
doocsSpectrum
.
fill_spectrum
(
i
,
0
);
}
...
...
@@ -123,9 +123,9 @@ BOOST_AUTO_TEST_CASE_TEMPLATE( fromDeviceTest, T, simple_test_types ){
}
updater
.
update
();
// The actual vector buffer has changed. We have to get the new reference.
csVector
=
controlSystemVariable
->
accessChannel
(
0
);
csVector
=
controlSystemVariable
->
accessChannel
(
0
);
for
(
size_t
i
=
0
;
i
<
arraySize
;
++
i
){
BOOST_CHECK
(
csVector
[
i
]
==
sign
*
static_cast
<
T
>
(
i
*
i
)
+
offset
);
BOOST_CHECK
(
doocsSpectrum
.
read_spectrum
(
i
)
==
sign
*
static_cast
<
T
>
(
i
*
i
)
+
offset
);
...
...
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