NDS3  1.0.0
API reference manual
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
pvBaseInImpl.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 NDSPVBASEINIMPL_H
11 #define NDSPVBASEINIMPL_H
12 
13 #include <string>
14 #include <set>
15 #include <mutex>
16 #include "nds3/definitions.h"
17 #include "nds3/impl/baseImpl.h"
18 #include "nds3/impl/pvBaseImpl.h"
19 
20 namespace nds
21 {
22 
23 class PVBase;
24 class PVBaseOutImpl;
25 
29 class PVBaseInImpl: public PVBaseImpl
30 {
31 public:
37  PVBaseInImpl(const std::string& name, const inputPvType_t pvType);
38 
39  virtual void initialize(FactoryBaseImpl& controlSystem);
40 
41  virtual void deinitialize();
42 
43  virtual void read(timespec* pTimestamp, std::int32_t* pValue) const;
44  virtual void read(timespec* pTimestamp, double* pValue) const;
45  virtual void read(timespec* pTimestamp, std::vector<std::int8_t>* pValue) const;
46  virtual void read(timespec* pTimestamp, std::vector<std::uint8_t>* pValue) const;
47  virtual void read(timespec* pTimestamp, std::vector<std::int32_t>* pValue) const;
48  virtual void read(timespec* pTimestamp, std::vector<double>* pValue) const;
49  virtual void read(timespec* pTimestamp, std::string* pValue) const;
50 
58  template<typename T>
59  void push(const timespec& timestamp, const T& value);
60 
69  void subscribeReceiver(PVBaseOutImpl* pReceiver);
70 
76  void unsubscribeReceiver(PVBaseOutImpl* pReceiver);
77 
83  void replicateTo(PVBaseInImpl* pDestination);
84 
90  void stopReplicationTo(PVBaseInImpl* pDestination);
91 
99  void setDecimation(const std::uint32_t decimation);
100 
110  void replicateFrom(const std::string& sourceInputPVName);
111 
112  virtual dataDirection_t getDataDirection() const;
113 
114  virtual std::string buildFullExternalName(const FactoryBaseImpl& controlSystem) const;
115  virtual std::string buildFullExternalNameFromPort(const FactoryBaseImpl& controlSystem) const;
116 
117 protected:
118  std::string buildFullExternalName(const FactoryBaseImpl& controlSystem, const bool bStopAtPort) const;
119 
120  inputPvType_t m_pvType;
121 
125  typedef std::set<PVBaseOutImpl*> subscribersList_t;
126 
131 
135  typedef std::set<PVBaseInImpl*> destinationList_t;
136 
141 
143 
144  std::uint32_t m_decimationFactor;
145  std::uint32_t m_decimationCount;
146 
147 private:
148  parameters_t commandReplicate(const parameters_t& parameters);
149  parameters_t commandDecimation(const parameters_t& parameters);
150 
151 };
152 
153 }
154 #endif // NDSPVBASEINIMPL_H
destinationList_t m_replicationDestinationPVs
List of PVs to which the data must be pushed or written.
Definition: pvBaseInImpl.h:140
PVBaseInImpl(const std::string &name, const inputPvType_t pvType)
Constructor.
std::set< PVBaseOutImpl * > subscribersList_t
List of subscribed PVs.
Definition: pvBaseInImpl.h:125
std::uint32_t m_decimationFactor
Decimation factor.
Definition: pvBaseInImpl.h:144
std::uint32_t m_decimationCount
Keeps track of the received data/vs data pushed to the control system.
Definition: pvBaseInImpl.h:145
void replicateTo(PVBaseInImpl *pDestination)
Replicate the data written to this PV to another input PV.
void unsubscribeReceiver(PVBaseOutImpl *pReceiver)
Unsubscribe an output PV from this PV.
virtual void read(timespec *pTimestamp, std::int32_t *pValue) const
Called when the control system wants to read the value.
virtual void deinitialize()
Deregister the PV from the control system.
This is the base class for objects that interact with specific control systems and has to be allocate...
Definition: factoryBaseImpl.h:51
void replicateFrom(const std::string &sourceInputPVName)
Specifies an input PV from which the data must be copied.
void stopReplicationTo(PVBaseInImpl *pDestination)
Stop the replication of data to the specified destination PV.
Base class for all the PVs.
Definition: pvBaseImpl.h:25
virtual void initialize(FactoryBaseImpl &controlSystem)
Register the PV with the control system.
virtual dataDirection_t getDataDirection() const
Retrieve the data direction.
Defines all the enumeration and common types used across the NDS library.
Base class for all the output PVs.
Definition: pvBaseOutImpl.h:26
dataDirection_t
Defines in which direction the data is being transferred.
Definition: definitions.h:92
Base class for all the PVs.
Definition: pvBaseInImpl.h:29
void subscribeReceiver(PVBaseOutImpl *pReceiver)
Subscribe an output PV to this PV.
std::vector< std::string > parameters_t
List of strings passed as parameters to nodes' commands.
Definition: definitions.h:204
subscribersList_t m_subscriberOutputPVs
List of subscribed PVs.
Definition: pvBaseInImpl.h:130
std::mutex m_lockSubscribersList
Lock the access to m_subscriberOutputPVs.
Definition: pvBaseInImpl.h:142
void setDecimation(const std::uint32_t decimation)
Set the decimation factor.
void push(const timespec &timestamp, const T &value)
Pushes data to the control system and to the subscribed PVs.
std::set< PVBaseInImpl * > destinationList_t
List of destination input PVs.
Definition: pvBaseInImpl.h:135
inputPvType_t
Defines an input PV's role: this information is used to build the PV's external name when using the N...
Definition: definitions.h:118