NDS3  1.0.0
API reference manual
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
pvBaseImpl.h
1 /*
2  * Nominal Device Support v3 (NDS3)
3  *
4  * Copyright (c) 2015 Cosylab d.d.
5  *
6  * For more information about the license please refer to the license.txt
7  * file included in the distribution.
8  */
9 
10 #ifndef NDSPVBASEIMPL_H
11 #define NDSPVBASEIMPL_H
12 
13 #include <string>
14 #include "nds3/definitions.h"
15 #include "nds3/impl/baseImpl.h"
16 
17 namespace nds
18 {
19 
20 class PVBase;
21 
25 class NDS3_API PVBaseImpl: public BaseImpl
26 {
27 public:
28  PVBaseImpl(const std::string& name);
29 
35  virtual void initialize(FactoryBaseImpl& controlSystem);
36 
40  virtual void deinitialize();
41 
50  virtual void read(timespec* pTimestamp, std::int32_t* pValue) const;
51  virtual void read(timespec* pTimestamp, double* pValue) const;
52  virtual void read(timespec* pTimestamp, std::vector<std::int8_t>* pValue) const;
53  virtual void read(timespec* pTimestamp, std::vector<std::uint8_t>* pValue) const;
54  virtual void read(timespec* pTimestamp, std::vector<std::int32_t>* pValue) const;
55  virtual void read(timespec* pTimestamp, std::vector<double>* pValue) const;
56  virtual void read(timespec* pTimestamp, std::string* pValue) const;
57 
66  virtual void write(const timespec& timestamp, const std::int32_t& value);
67  virtual void write(const timespec& timestamp, const double& value);
68  virtual void write(const timespec& timestamp, const std::vector<std::int8_t>& value);
69  virtual void write(const timespec& timestamp, const std::vector<std::uint8_t>& value);
70  virtual void write(const timespec& timestamp, const std::vector<std::int32_t>& value);
71  virtual void write(const timespec& timestamp, const std::vector<double>& value);
72  virtual void write(const timespec& timestamp, const std::string& value);
73 
79  virtual dataDirection_t getDataDirection() const = 0;
80 
86  virtual dataType_t getDataType() const = 0;
87 
93  void setDescription(const std::string& description);
94 
100  void setUnits(const std::string& units);
101 
108  void setScanType(const scanType_t scanType, const double periodSeconds);
109 
115  void setMaxElements(const size_t maxElements);
116 
122  void setEnumeration(const enumerationStrings_t& enumerations);
123 
130  void processAtInit(const bool bProcessAtInit);
131 
137  const std::string& getDescription() const;
138 
144  const std::string& getUnits() const;
145 
151  scanType_t getScanType() const;
152 
158  double getScanPeriodSeconds() const;
159 
166  size_t getMaxElements() const;
167 
173  const enumerationStrings_t& getEnumerations() const;
174 
182  bool getProcessAtInit() const;
183 
190  template<typename T>
192  {
193  const int type =
194  int(std::is_same<T, std::int32_t>::value) * (int)dataType_t::dataInt32 +
195  int(std::is_same<T, double>::value) * (int)dataType_t::dataFloat64 +
196  int(std::is_same<T, std::vector<std::int8_t> >::value) * (int)dataType_t::dataInt8Array +
197  int(std::is_same<T, std::vector<std::uint8_t> >::value) * (int)dataType_t::dataUint8Array +
198  int(std::is_same<T, std::vector<std::int32_t> >::value) * (int)dataType_t::dataInt32Array +
199  int(std::is_same<T, std::vector<double> >::value) * (int)dataType_t::dataFloat64Array +
200  int(std::is_same<T, std::string>::value) * (int)dataType_t::dataString;
201 
202  static_assert(type != 0, "Undefined data type");
203  return(dataType_t)type;
204  }
205 
206 protected:
207  std::string m_description;
208  std::string m_units;
211  size_t m_maxElements;
214 };
215 
216 }
217 #endif // NDSPVBASEIMPL_H
scanType_t
Specify how to get the PV value.
Definition: definitions.h:68
std::string m_description
The PV's description.
Definition: pvBaseImpl.h:207
bool m_bProcessAtInit
True if the PV has to be processed during the device initialization.
Definition: pvBaseImpl.h:213
size_t m_maxElements
Maximum number of elements that can be stored in the PV.
Definition: pvBaseImpl.h:211
Array of signed 32 bit integers.
Array of unsigned 8 bit integers.
Array of 64 bit floats.
Signed integer, 32 bits.
This is the base class for objects that interact with specific control systems and has to be allocate...
Definition: factoryBaseImpl.h:51
std::string m_units
Engineering units.
Definition: pvBaseImpl.h:208
Base class for all the PVs.
Definition: pvBaseImpl.h:25
Defines all the enumeration and common types used across the NDS library.
double m_periodicScanSeconds
The interval between data polling (in seconds).
Definition: pvBaseImpl.h:210
std::list< std::string > enumerationStrings_t
List of strings used for enumeration in PVs that support the enumeration field.
Definition: definitions.h:288
dataDirection_t
Defines in which direction the data is being transferred.
Definition: definitions.h:92
scanType_t m_scanType
The PV's scan type.
Definition: pvBaseImpl.h:209
dataType_t
PV data types.
Definition: definitions.h:53
static dataType_t getDataTypeForCPPType()
Return the data type enumerator for the type in the template.
Definition: pvBaseImpl.h:191
Array of signed 8 bit integers.
enumerationStrings_t m_enumeration
List of strings used for enumeration.
Definition: pvBaseImpl.h:212