EpicsConnection.h
Go to the documentation of this file.
1 #ifndef _RMS_EPICSCONNECTION_H
2 #define _RMS_EPICSCONNECTION_H
3 
4 #include <rms/base/RmsDestination.h>
5 #include <rms/base/RmsMessage.h>
6 #include <rms/provider/RmsConnection.h>
7 #include <rms/provider/EpicsMessenger.h>
8 #include <rms/util/UUIDGenerator.h>
9 #include <rms/util/ReentrantGetEnv.h>
10 
11 #include <boost/shared_ptr.hpp>
12 #include <boost/thread/mutex.hpp>
13 
14 #include <cadef.h>
15 
16 #include <string>
17 #include <set>
18 #include <map>
19 #include <fstream>
20 
21 namespace gov {
22 
23 namespace fnal {
24 
25 namespace cd {
26 
27 namespace rms {
28 
29 namespace provider {
30 
31 /**
32  * Manages the interface to EPICS. Responsibilities include
33  * registering listeners with EPICS, creating EpicsMessengers
34  * objects when needed to talk to PVs and translating destination
35  * objects into PV names.
36  *
37  * @author Kurt Biery
38  * @author Steve Foulkes
39  * @version $Revision: 1.1.1.1 $ $Date: 2009/10/09 20:03:00 $
40  */
42  public:
43  /**
44  * The character that is to be used as a delimiter
45  * in PV names.
46  */
47  static const std::string PV_DELIMITER;
48 
49  EpicsConnection (const std::string applicationName,
50  const int applicationPartition);
52 
53  bool supportsDestination(const base::RmsDestination& candidateDestination);
54  void sendString(const base::RmsDestination& dest, const std::string& messageString);
55  void sendMessage(const base::RmsDestination& dest, const base::RmsMessage& message);
56  void addListener(const base::RmsDestination& dest, ProviderListener *listener);
57  void removeListener(const base::RmsDestination& dest, ProviderListener *listener);
58 
59  bool ping(const base::RmsDestination& pingDestination);
60 
61  void close();
62 
63  private:
64  /**
65  * A set of handles to PVs that have been used.
66  */
67  std::map <std::string, EpicsMessenger *> _cachedPVs;
68 
69  /**
70  * The EPICS context.
71  */
72  struct ca_client_context *_caCurrentContext;
73 
74  /**
75  * Lock for the EPICS code as EpicsMessenger is not thread
76  * safe.
77  */
79 
80  std::string getDestinationPVFromDest(const base::RmsDestination& dest) const;
81  std::string getMonitoringPVFromDest(const base::RmsDestination& dest) const;
83 };
84 
85 }; // end of namespace provider
86 
87 }; // end of namespace rms
88 
89 }; // end of namespace cd
90 
91 }; // end of namespace fnal
92 
93 }; // end of namespace gov
94 
95 #endif
bool ping(const base::RmsDestination &pingDestination)
void addListener(const base::RmsDestination &dest, ProviderListener *listener)
void sendMessage(const base::RmsDestination &dest, const base::RmsMessage &message)
std::map< std::string, EpicsMessenger * > _cachedPVs
struct ca_client_context * _caCurrentContext
EpicsConnection(const std::string applicationName, const int applicationPartition)
bool supportsDestination(const base::RmsDestination &candidateDestination)
std::string getMonitoringPVFromDest(const base::RmsDestination &dest) const
Definition: fnal.py:1
void sendString(const base::RmsDestination &dest, const std::string &messageString)
void removeListener(const base::RmsDestination &dest, ProviderListener *listener)
std::string getDestinationPVFromDest(const base::RmsDestination &dest) const
EpicsMessenger * getPVHandle(std::string pvName)
c cd(1)
enum BeamMode string