NDS3  1.0.0
API reference manual
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
tangoInterfaceImpl.h
1 #ifdef NDS3_TANGO
2 
3 #ifndef NDSTANGOINTERFACEIMPL_H
4 #define NDSTANGOINTERFACEIMPL_H
5 
6 #include <string>
7 #include <vector>
8 #include <set>
9 #include <tango.h>
10 #include "nds3/impl/interfaceBaseImpl.h"
11 
12 namespace nds
13 {
14 
15 class PVBaseImpl;
16 class NdsDeviceClass;
17 class NdsDevice;
18 
24 class TangoInterfaceImpl: public InterfaceBaseImpl
25 {
26 public:
27  TangoInterfaceImpl(const std::string& portName, NdsDevice* pDevice);
28 
29  virtual void registerPV(std::shared_ptr<PVBaseImpl> pv);
30  virtual void deregisterPV(std::shared_ptr<PVBaseImpl> pv);
31 
32  virtual void registrationTerminated();
33 
34  virtual void push(std::shared_ptr<PVBaseImpl> pv, const timespec& timestamp, const std::int8_t& value);
35  virtual void push(std::shared_ptr<PVBaseImpl> pv, const timespec& timestamp, const std::uint8_t& value);
36  virtual void push(std::shared_ptr<PVBaseImpl> pv, const timespec& timestamp, const std::int32_t& value);
37  virtual void push(std::shared_ptr<PVBaseImpl> pv, const timespec& timestamp, const std::uint32_t& value);
38  virtual void push(std::shared_ptr<PVBaseImpl> pv, const timespec& timestamp, const double& value);
39  virtual void push(std::shared_ptr<PVBaseImpl> pv, const timespec& timestamp, const std::vector<std::int8_t> & value);
40  virtual void push(std::shared_ptr<PVBaseImpl> pv, const timespec& timestamp, const std::vector<std::uint8_t> & value);
41  virtual void push(std::shared_ptr<PVBaseImpl> pv, const timespec& timestamp, const std::vector<std::int32_t> & value);
42  virtual void push(std::shared_ptr<PVBaseImpl> pv, const timespec& timestamp, const std::vector<double> & value);
43 
44 private:
45  NdsDevice* m_pDevice;
46 
47 };
48 
49 
54 class NdsDeviceClass: public Tango::DeviceClass
55 {
56 public:
57  NdsDeviceClass(std::string& name, allocateDriver_t allocateDriverFunction, deallocateDriver_t deallocateDriverFunction);
58 
59 
60  virtual void command_factory();
61  virtual void attribute_factory(vector<Tango::Attr*>& attributes);
62  virtual void device_factory(const Tango::DevVarStringArray* dev_list);
63 
64 
65 protected:
66  allocateDriver_t m_allocateDriverFunction;
67  deallocateDriver_t m_deallocateDriverFunction;
68 };
69 
70 
78 class NdsDevice: public TANGO_BASE_CLASS
79 {
80 public:
81  NdsDevice(Tango::DeviceClass* pClass, string &name);
82  ~NdsDevice();
83 
84  virtual void init_device();
85 
86  virtual void delete_device();
87 
88  void setRootNode(std::shared_ptr<NodeImpl> pRootNode);
89 
90  virtual Tango::DevState get_state();
91 
92 protected:
93  Tango::DeviceClass* m_pClass;
94  std::string m_parameter;
95  std::shared_ptr<NodeImpl> m_pRootNode;
96 
97  void* m_pDevice;
98 };
99 
100 
106 class NdsAttributeBase
107 {
108 public:
109 
115  static timeval NDSTimeToTangoTime(const timespec& time);
116 
122  static timespec TangoTimeToNDSTime(const timeval& time);
123 
124 protected:
125  NdsAttributeBase(std::shared_ptr<PVBaseImpl> pv);
126 
127  void setAttributeProperties(Tango::Attr& attr);
128 
129  std::shared_ptr<PVBaseImpl> m_pPV;
130 
131 };
132 
133 
138 template <typename ndsType_t, typename tangoType_t>
139 class NdsAttributeScalar: public NdsAttributeBase, public Tango::Attr
140 {
141 public:
142  NdsAttributeScalar(const std::string& name, std::shared_ptr<PVBaseImpl> pPV, Tango::CmdArgType dataType, Tango::AttrWriteType writeType);
143 
144  virtual void read(Tango::DeviceImpl *dev,Tango::Attribute &att);
145  virtual void write(Tango::DeviceImpl *dev,Tango::WAttribute &att);
146  virtual bool is_allowed(Tango::DeviceImpl *dev,Tango::AttReqType ty);
147 
148 private:
149  tangoType_t m_value;
150 };
151 
152 
157 template <typename ndsType_t, typename tangoType_t>
158 class NdsAttributeSpectrum: public NdsAttributeBase, public Tango::SpectrumAttr
159 {
160 public:
161  NdsAttributeSpectrum(const std::string& name, std::shared_ptr<PVBaseImpl> pPV, Tango::CmdArgType dataType, Tango::AttrWriteType writeType, size_t maxLength);
162 
163  virtual void read(Tango::DeviceImpl *dev,Tango::Attribute &att);
164  virtual void write(Tango::DeviceImpl *dev,Tango::WAttribute &att);
165  virtual bool is_allowed(Tango::DeviceImpl *dev,Tango::AttReqType ty);
166 
167 private:
168  std::vector<tangoType_t> m_value;
169 };
170 
176 /*
177 class OnClass : public Tango::Command
178 {
179 public:
180  OnClass();
181  ~OnClass();
182  virtual CORBA::Any *execute (Tango::DeviceImpl *dev, const CORBA::Any &any);
183  virtual bool is_allowed (Tango::DeviceImpl *dev, const CORBA::Any &any);
184 };
185 
186 class OffClass : public Tango::Command
187 {
188 public:
189  OffClass();
190  ~OffClass();
191  virtual CORBA::Any *execute (Tango::DeviceImpl *dev, const CORBA::Any &any);
192  virtual bool is_allowed (Tango::DeviceImpl *dev, const CORBA::Any &any);
193 };
194 
195 class StartClass : public Tango::Command
196 {
197 public:
198  StartClass();
199  ~StartClass();
200  virtual CORBA::Any *execute (Tango::DeviceImpl *dev, const CORBA::Any &any);
201  virtual bool is_allowed (Tango::DeviceImpl *dev, const CORBA::Any &any);
202 };
203 
204 class StopClass : public Tango::Command
205 {
206 public:
207  StopClass();
208  ~StopClass();
209  virtual CORBA::Any *execute (Tango::DeviceImpl *dev, const CORBA::Any &any);
210  virtual bool is_allowed (Tango::DeviceImpl *dev, const CORBA::Any &any);
211 };
212 
213 class ResetClass : public Tango::Command
214 {
215 public:
216  ResetClass();
217  ~ResetClass();
218  virtual CORBA::Any *execute (Tango::DeviceImpl *dev, const CORBA::Any &any);
219  virtual bool is_allowed (Tango::DeviceImpl *dev, const CORBA::Any &any);
220 };
221 
222 
223 */
224 
225 }
226 
227 #endif // NDSTANGOINTERFACEIMPL_H
228 
229 #endif // NDS3_TANGO
230 
std::function< void(void *)> deallocateDriver_t
Definition for the function executed to deallocate a driver.
Definition: definitions.h:244
std::function< void *(Factory &factory, const std::string &deviceName, const namedParameters_t &parameters)> allocateDriver_t
Definition for the function executed to allocate a driver.
Definition: definitions.h:224