Skip to content
Snippets Groups Projects
Commit 67c0bdcd authored by Martin Christoph Hierholzer's avatar Martin Christoph Hierholzer
Browse files

neccessary update for the latest DeviceAccess changes

parent 440f83a6
No related branches found
No related tags found
No related merge requests found
......@@ -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
......@@ -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 );
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment