EpicsMessenger.h
Go to the documentation of this file.
1 #ifndef _RMS_EPICSMESSENGER_H
2 #define _RMS_EPICSMESSENGER_H
3 
4 #include <rms/provider/ProviderListener.h>
5 #include <rms/provider/MessageAssembler.h>
6 #include <rms/provider/MessageSplitter.h>
7 #include <rms/provider/MessageFragment.h>
8 #include <rms/util/UUIDGenerator.h>
9 
10 #include <cadef.h>
11 
12 #include <string>
13 #include <vector>
14 #include <iostream>
15 
16 /**
17  * The declaration for ca_detach_context() is missing
18  * from cadef.h, so we'll declare it here so we can
19  * use it without modifying EPICS.
20  */
21 void epicsShareAPI ca_detach_context();
22 
23 namespace gov {
24 
25 namespace fnal {
26 
27 namespace cd {
28 
29 namespace rms {
30 
31 namespace provider {
32 
33 /**
34  * This class provides functionality to communicate with EPICS waveform
35  * process variables. It automatically splits up messages that are too
36  * long into the necessary number of fragments and automatically assembles
37  * fragments into messages on input.
38  *
39  * Note that this class is _NOT_ thread safe.
40  *
41  * @author Kurt Biery
42  * @author Steve Foulkes
43  * @version $Revision: 1.1.1.1 $ $Date: 2009/10/09 20:03:00 $
44  */
45 
47  public:
48  EpicsMessenger(std::string pvName, struct ca_client_context *caContext,
49  int maxSize, util::UUIDGenerator *uuidGenerator);
51 
52  std::string getName() const;
53 
54  void sendMessage(const std::string& messageText);
55 
56  void addListener(ProviderListener *listener);
57 
58  void removeListener(ProviderListener *listener);
59 
60  void monitorChanged(char *data);
61  void notifyListeners(std::string messageText);
62 
63  void close();
64 
65  private:
66  /**
67  * Flag to indicate the first time that a listener is added.
68  */
70 
71  /**
72  * The length of time (in seconds) to use when waiting for
73  * pending operations to complete.
74  */
75  static const double _PEND_OP_TIMEOUT = 2.0;
76 
77  /**
78  * The channel access context that we're using for communication.
79  */
80  struct ca_client_context *_caContext;
81 
82  /**
83  * The channel that we'll use to access the process variable.
84  */
85  chid _pvChannel;
86 
87  /**
88  * Handle to the channel subscription.
89  */
91 
92  /**
93  * The name of the process variable.
94  */
96 
97  /**
98  * The maximum number of bytes that we can write to an underlying
99  * EPICS waveform record at one time.
100  */
102 
103  /**
104  * The list of listeners interested in being notified when
105  * the process variable value changes.
106  */
107  std::vector <ProviderListener *> _listenerList;
108 
109  /**
110  * The list of message assemblers that are active.
111  */
112  std::vector <MessageAssembler *> _assemblerList;
113 
114  /**
115  * Generator UUIDs for messages
116  */
118 };
119 
120 }; // end of namespace provider
121 
122 }; // end of namespace rms
123 
124 }; // end of namespace cd
125 
126 }; // end of namespace fnal
127 
128 }; // end of namespace gov
129 
130 #endif
void epicsShareAPI ca_detach_context()
EpicsMessenger(std::string pvName, struct ca_client_context *caContext, int maxSize, util::UUIDGenerator *uuidGenerator)
std::vector< ProviderListener * > _listenerList
std::vector< MessageAssembler * > _assemblerList
const XML_Char const XML_Char * data
Definition: expat.h:268
void removeListener(ProviderListener *listener)
void addListener(ProviderListener *listener)
Definition: fnal.py:1
void sendMessage(const std::string &messageText)
void notifyListeners(std::string messageText)
c cd(1)
enum BeamMode string