ChimeraTK-DeviceAccess-DoocsBackend 01.11.02
Loading...
Searching...
No Matches
DoocsBackendStringRegisterAccessor.h
Go to the documentation of this file.
1/*
2 * DoocsBackendStringRegisterAccessor.h
3 *
4 * Created on: May 3, 2016
5 * Author: Martin Hierholzer
6 */
7
8#ifndef MTCA4U_DOOCS_BACKEND_STRING_REGISTER_ACCESSOR_H
9#define MTCA4U_DOOCS_BACKEND_STRING_REGISTER_ACCESSOR_H
10
12
13#include <doocs/EqCall.h>
14
15#include <type_traits>
16
17namespace ChimeraTK {
18
19 template<typename UserType>
21 public:
23
24 protected:
25 DoocsBackendStringRegisterAccessor(boost::shared_ptr<DoocsBackend> backend, const std::string& path,
26 const std::string& registerPathName, size_t numberOfWords, size_t wordOffsetInRegister, AccessModeFlags flags);
27
28 void doPostRead(TransferType type, bool hasNewData) override;
29
30 void doPreWrite(TransferType type, VersionNumber version) override;
31
32 friend class DoocsBackend;
33 };
34
35 /**********************************************************************************************************************/
36
37 template<typename UserType>
39 boost::shared_ptr<DoocsBackend> backend, const std::string& path, const std::string& registerPathName,
40 size_t numberOfWords, size_t wordOffsetInRegister, AccessModeFlags flags)
42 backend, path, registerPathName, numberOfWords, wordOffsetInRegister, flags) {
43 // check UserType
44 if(typeid(UserType) != typeid(std::string)) {
45 this->shutdown();
46 throw ChimeraTK::logic_error("Trying to access a string DOOCS property with a non-string user data type.");
47 }
48 // check data type
49 if(DoocsBackendRegisterAccessor<UserType>::src.type() != DATA_TEXT &&
50 DoocsBackendRegisterAccessor<UserType>::src.type() != DATA_STRING) {
51 this->shutdown();
52 throw ChimeraTK::logic_error(std::string("DOOCS data type ") +
53 std::to_string(DoocsBackendRegisterAccessor<UserType>::dst.type()) +
54 " not supported by DoocsBackendStringRegisterAccessor."); // LCOV_EXCL_LINE (already prevented in the Backend)
55 }
56 }
57
58 /**********************************************************************************************************************/
59
60 template<typename UserType>
64
65 /**********************************************************************************************************************/
66
67 template<>
68 void DoocsBackendStringRegisterAccessor<std::string>::doPostRead(TransferType type, bool hasNewData) {
70 if(!hasNewData) return;
71
72 // copy data into our buffer
73 NDRegisterAccessor<std::string>::buffer_2D[0][0] = DoocsBackendRegisterAccessor<std::string>::dst.get_string();
74 }
75
76 /**********************************************************************************************************************/
77
78 template<>
79 void DoocsBackendStringRegisterAccessor<std::string>::doPreWrite(TransferType type, VersionNumber version) {
81
82 // copy data into our buffer
83 DoocsBackendRegisterAccessor<std::string>::src.set(NDRegisterAccessor<std::string>::buffer_2D[0][0].c_str());
84 }
85
86 /**********************************************************************************************************************/
87
88 template<typename UserType>
90 TransferType, bool) { // LCOV_EXCL_LINE (already prevented in constructor)
91 throw ChimeraTK::logic_error("Trying to access a string DOOCS property with a non-string user data "
92 "type."); // LCOV_EXCL_LINE
93 } // LCOV_EXCL_LINE
94
95 /**********************************************************************************************************************/
96
97 template<typename UserType>
99 TransferType, VersionNumber) { // LCOV_EXCL_LINE (already prevented in constructor)
100 throw ChimeraTK::logic_error("Trying to access a string DOOCS property with a non-string user data "
101 "type."); // LCOV_EXCL_LINE
102 } // LCOV_EXCL_LINE
103
104} // namespace ChimeraTK
105
106#endif /* MTCA4U_DOOCS_BACKEND_STRING_REGISTER_ACCESSOR_H */
Backend to access DOOCS control system servers.
void shutdown()
All implementations must call this function in their destructor.
void doPostRead(TransferType, bool hasNewData) override
void doPreWrite(TransferType, VersionNumber) override
DoocsBackendStringRegisterAccessor(boost::shared_ptr< DoocsBackend > backend, const std::string &path, const std::string &registerPathName, size_t numberOfWords, size_t wordOffsetInRegister, AccessModeFlags flags)
void doPreWrite(TransferType type, VersionNumber version) override
void doPostRead(TransferType type, bool hasNewData) override