ChimeraTK-ApplicationCore  04.01.00
ChimeraTK::TestFacility Class Reference

Helper class to facilitate tests of applications based on ApplicationCore. More...

#include <TestFacility.h>

+ Collaboration diagram for ChimeraTK::TestFacility:

Public Member Functions

 TestFacility (Application &app, bool enableTestableMode=true)
 The passed application will automatically be put into the testable mode and initialised. More...
 
void runApplication () const
 Start the application in testable mode. More...
 
bool canStepApplication () const
 Check whether data has been sent to the application so stepApplication() can be called. More...
 
void stepApplication (bool waitForDeviceInitialisation=true) const
 Perform a "step" of the application. More...
 
ChimeraTK::VoidRegisterAccessor getVoid (const ChimeraTK::RegisterPath &name) const
 Obtain a void process variable from the application, which is published to the control system. More...
 
template<typename T >
ChimeraTK::ScalarRegisterAccessor< T > getScalar (const ChimeraTK::RegisterPath &name) const
 Obtain a scalar process variable from the application, which is published to the control system. More...
 
template<typename T >
ChimeraTK::OneDRegisterAccessor< T > getArray (const ChimeraTK::RegisterPath &name) const
 Obtain an array-type process variable from the application, which is published to the control system. More...
 
template<typename TYPE >
void writeScalar (const std::string &name, TYPE value)
 Convenience function to write a scalar process variable in a single call. More...
 
template<typename TYPE >
void writeArray (const std::string &name, const std::vector< TYPE > &value)
 Convenience function to write an array process variable in a single call. More...
 
template<typename TYPE >
TYPE readScalar (const std::string &name)
 Convenience function to read the latest value of a scalar process variable in a single call. More...
 
template<typename TYPE >
std::vector< TYPE > readArray (const std::string &name)
 Convenience function to read the latest value of an array process variable in a single call. More...
 
template<typename T >
void setScalarDefault (const ChimeraTK::RegisterPath &name, const T &value)
 Set default value for scalar process variable. More...
 
template<typename T >
void setArrayDefault (const ChimeraTK::RegisterPath &name, const std::vector< T > &value)
 Set default value for array process variable. More...
 
template<typename T >
boost::shared_ptr< ChimeraTK::NDRegisterAccessor< T > > getAccessor (const ChimeraTK::RegisterPath &name) const
 Function to obtain a process variable from the control system. More...
 
boost::shared_ptr< ControlSystemPVManager > getPvManager () const
 

Static Public Member Functions

template<typename T >
static void setConfigScalar (const ChimeraTK::RegisterPath &name, const T &value)
 Set ConfigReader scalar variable for the next instantiated Applicaton. More...
 
template<typename T >
static void setConfigArray (const ChimeraTK::RegisterPath &name, const std::vector< T > &value)
 Set ConfigReader array variable for the next instantiated Applicaton. More...
 

Protected Types

template<typename UserType >
using AccessorMap = std::map< std::string, boost::shared_ptr< ChimeraTK::NDRegisterAccessor< UserType > >>
 
template<typename UserType >
using Defaults = std::map< std::string, std::vector< UserType > >
 
template<typename UserType >
using Vector = std::vector< UserType >
 

Protected Attributes

boost::shared_ptr< ControlSystemPVManager > _pvManager
 
ChimeraTK::TemplateUserTypeMap< AccessorMap_accessorMap
 
ChimeraTK::TemplateUserTypeMap< Defaults_defaults
 
Application_app
 

Static Protected Attributes

static std::map< ChimeraTK::RegisterPath, ChimeraTK::UserTypeVariantNoVoid > _configScalars
 
static std::map< ChimeraTK::RegisterPath, ChimeraTK::UserTypeTemplateVariantNoVoid< Vector > > _configArrays
 

Friends

class ConfigReader
 

Detailed Description

Helper class to facilitate tests of applications based on ApplicationCore.

Definition at line 36 of file TestFacility.h.

Member Typedef Documentation

◆ AccessorMap

template<typename UserType >
using ChimeraTK::TestFacility::AccessorMap = std::map<std::string, boost::shared_ptr<ChimeraTK::NDRegisterAccessor<UserType> >>
protected

Definition at line 129 of file TestFacility.h.

◆ Defaults

template<typename UserType >
using ChimeraTK::TestFacility::Defaults = std::map<std::string, std::vector<UserType> >
protected

Definition at line 134 of file TestFacility.h.

◆ Vector

template<typename UserType >
using ChimeraTK::TestFacility::Vector = std::vector<UserType>
protected

Definition at line 143 of file TestFacility.h.

Constructor & Destructor Documentation

◆ TestFacility()

ChimeraTK::TestFacility::TestFacility ( Application app,
bool  enableTestableMode = true 
)
explicit

The passed application will automatically be put into the testable mode and initialised.

Definition at line 16 of file TestFacility.cc.

+ Here is the call graph for this function:

Member Function Documentation

◆ canStepApplication()

bool ChimeraTK::TestFacility::canStepApplication ( ) const

Check whether data has been sent to the application so stepApplication() can be called.

Definition at line 107 of file TestFacility.cc.

◆ getAccessor()

template<typename T >
boost::shared_ptr< ChimeraTK::NDRegisterAccessor< T > > ChimeraTK::TestFacility::getAccessor ( const ChimeraTK::RegisterPath &  name) const

Function to obtain a process variable from the control system.

For conveniently creating arrays and scalars, see getArray, getScalar and getVoid

Definition at line 254 of file TestFacility.h.

+ Here is the call graph for this function:

◆ getArray()

template<typename T >
ChimeraTK::OneDRegisterAccessor< T > ChimeraTK::TestFacility::getArray ( const ChimeraTK::RegisterPath &  name) const

Obtain an array-type process variable from the application, which is published to the control system.

Definition at line 162 of file TestFacility.h.

+ Here is the caller graph for this function:

◆ getPvManager()

boost::shared_ptr<ControlSystemPVManager> ChimeraTK::TestFacility::getPvManager ( ) const
inline

Definition at line 107 of file TestFacility.h.

◆ getScalar()

template<typename T >
ChimeraTK::ScalarRegisterAccessor< T > ChimeraTK::TestFacility::getScalar ( const ChimeraTK::RegisterPath &  name) const

Obtain a scalar process variable from the application, which is published to the control system.

Definition at line 155 of file TestFacility.h.

+ Here is the caller graph for this function:

◆ getVoid()

ChimeraTK::VoidRegisterAccessor ChimeraTK::TestFacility::getVoid ( const ChimeraTK::RegisterPath &  name) const

Obtain a void process variable from the application, which is published to the control system.

Definition at line 119 of file TestFacility.cc.

+ Here is the caller graph for this function:

◆ readArray()

template<typename TYPE >
std::vector< TYPE > ChimeraTK::TestFacility::readArray ( const std::string &  name)

Convenience function to read the latest value of an array process variable in a single call.

Definition at line 202 of file TestFacility.h.

◆ readScalar()

template<typename TYPE >
TYPE ChimeraTK::TestFacility::readScalar ( const std::string &  name)

Convenience function to read the latest value of a scalar process variable in a single call.

Definition at line 193 of file TestFacility.h.

+ Here is the caller graph for this function:

◆ runApplication()

void ChimeraTK::TestFacility::runApplication ( ) const

Start the application in testable mode.

Since pv_casted is the undecorated PV (lacking the TestableModeAccessorDecorator), we need to copy the value also to the decorator. We still have to write through the undecorated PV, otherwise the tests are stalled.

Todo:
It is not understood why this happens! Decorated accessors are stored in different maps for scalars are arrays...

Definition at line 28 of file TestFacility.cc.

+ Here is the caller graph for this function:

◆ setArrayDefault()

template<typename T >
void ChimeraTK::TestFacility::setArrayDefault ( const ChimeraTK::RegisterPath &  name,
const std::vector< T > &  value 
)

Set default value for array process variable.

Definition at line 223 of file TestFacility.h.

+ Here is the caller graph for this function:

◆ setConfigArray()

template<typename T >
void ChimeraTK::TestFacility::setConfigArray ( const ChimeraTK::RegisterPath &  name,
const std::vector< T > &  value 
)
static

Set ConfigReader array variable for the next instantiated Applicaton.

Definition at line 291 of file TestFacility.h.

◆ setConfigScalar()

template<typename T >
void ChimeraTK::TestFacility::setConfigScalar ( const ChimeraTK::RegisterPath &  name,
const T &  value 
)
static

Set ConfigReader scalar variable for the next instantiated Applicaton.

Definition at line 284 of file TestFacility.h.

◆ setScalarDefault()

template<typename T >
void ChimeraTK::TestFacility::setScalarDefault ( const ChimeraTK::RegisterPath &  name,
const T &  value 
)

Set default value for scalar process variable.

Definition at line 211 of file TestFacility.h.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ stepApplication()

void ChimeraTK::TestFacility::stepApplication ( bool  waitForDeviceInitialisation = true) const

Perform a "step" of the application.

This runs the application until all input provided to it has been processed and all application modules wait for new data in blocking read calls. This function returns only after the application has reached that stated and was paused again. After returning from this function, the result can be checked and new data can be provided to the application. The new data will not be processed until the next call to step().

Definition at line 113 of file TestFacility.cc.

+ Here is the caller graph for this function:

◆ writeArray()

template<typename TYPE >
void ChimeraTK::TestFacility::writeArray ( const std::string &  name,
const std::vector< TYPE > &  value 
)

Convenience function to write an array process variable in a single call.

Definition at line 178 of file TestFacility.h.

◆ writeScalar()

template<typename TYPE >
void ChimeraTK::TestFacility::writeScalar ( const std::string &  name,
TYPE  value 
)

Convenience function to write a scalar process variable in a single call.

Definition at line 169 of file TestFacility.h.

+ Here is the caller graph for this function:

Friends And Related Function Documentation

◆ ConfigReader

friend class ConfigReader
friend

Definition at line 148 of file TestFacility.h.

Member Data Documentation

◆ _accessorMap

ChimeraTK::TemplateUserTypeMap<AccessorMap> ChimeraTK::TestFacility::_accessorMap
mutableprotected

Definition at line 130 of file TestFacility.h.

◆ _app

Application& ChimeraTK::TestFacility::_app
protected

Definition at line 137 of file TestFacility.h.

◆ _configArrays

std::map< ChimeraTK::RegisterPath, ChimeraTK::UserTypeTemplateVariantNoVoid< TestFacility::Vector > > ChimeraTK::TestFacility::_configArrays
staticprotected

Definition at line 146 of file TestFacility.h.

◆ _configScalars

std::map< ChimeraTK::RegisterPath, ChimeraTK::UserTypeVariantNoVoid > ChimeraTK::TestFacility::_configScalars
staticprotected

Definition at line 140 of file TestFacility.h.

◆ _defaults

ChimeraTK::TemplateUserTypeMap<Defaults> ChimeraTK::TestFacility::_defaults
protected

Definition at line 135 of file TestFacility.h.

◆ _pvManager

boost::shared_ptr<ControlSystemPVManager> ChimeraTK::TestFacility::_pvManager
protected

Definition at line 122 of file TestFacility.h.


The documentation for this class was generated from the following files: