ChimeraTK-DeviceAccess-TangoBackend 00.01.02
Loading...
Searching...
No Matches
RegisterCatalogue.cc
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Deutsches Elektronen-Synchrotron DESY, MSK, ChimeraTK Project <chimeratk-support@desy.de>
2// SPDX-License-Identifier: LGPL-3.0-or-later
3
4#include "RegisterCatalogue.h"
5namespace util {
6 using Dt = ChimeraTK::DataType::TheType;
7
8 static ChimeraTK::DataType mapTangoToUserType(int tangoType) {
9 static const std::map<Tango::CmdArgType, ChimeraTK::DataType::TheType> typeMap{
10 {Tango::DEV_BOOLEAN, Dt::Boolean},
11 {Tango::DEV_SHORT, Dt::int16},
12 {Tango::DEV_LONG, Dt::int32},
13 {Tango::DEV_FLOAT, Dt::float32},
14 {Tango::DEV_DOUBLE, Dt::float64},
15 {Tango::DEV_USHORT, Dt::uint16},
16 {Tango::DEV_ULONG, Dt::uint32},
17 {Tango::DEV_STRING, Dt::string},
18 {Tango::DEV_STATE, Dt::uint8},
19 {Tango::DEV_UCHAR, Dt::uint8},
20 {Tango::DEV_LONG64, Dt::int64},
21 {Tango::DEV_ULONG64, Dt::uint64},
22 {Tango::DEV_ENUM, Dt::int64},
23 };
24
25 try {
26 // Compatibility with older tango servers (There used to be DEV_INT which no longer exists)
27 // FIXME: Do we really need this or is this handled by Tango
28 if(tangoType == 27) {
29 tangoType = static_cast<int>(Tango::DEV_LONG);
30 }
31
32 return typeMap.at(static_cast<Tango::CmdArgType>(tangoType));
33 }
34 catch(std::out_of_range&) {
35 throw ChimeraTK::logic_error("Unmappable Tango type " + std::to_string(tangoType));
36 }
37 }
38} // namespace util
39
40/**********************************************************************************************************************/
41/**********************************************************************************************************************/
42/**********************************************************************************************************************/
43
44namespace ChimeraTK {
45 std::unique_ptr<ChimeraTK::BackendRegisterInfoBase> TangoRegisterInfo::clone() const {
46 return std::unique_ptr<ChimeraTK::BackendRegisterInfoBase>(new TangoRegisterInfo(*this));
47 }
48
49 /********************************************************************************************************************/
50
51 TangoRegisterInfo::TangoRegisterInfo(Tango::AttributeInfoEx& info)
52 : descriptor(util::mapTangoToUserType(info.data_type)), attributeInfo(info) {}
53} // namespace ChimeraTK
ChimeraTK::DataType::TheType Dt
std::unique_ptr< ChimeraTK::BackendRegisterInfoBase > clone() const override