Public Member Functions | |
EpicsConnection (const std::string applicationName, const int applicationPartition) | |
~EpicsConnection () | |
bool | supportsDestination (const base::RmsDestination &candidateDestination) |
void | sendString (const base::RmsDestination &dest, const std::string &messageString) |
void | sendMessage (const base::RmsDestination &dest, const base::RmsMessage &message) |
void | addListener (const base::RmsDestination &dest, ProviderListener *listener) |
void | removeListener (const base::RmsDestination &dest, ProviderListener *listener) |
bool | ping (const base::RmsDestination &pingDestination) |
void | close () |
base::RmsDestination | getMessageSource () |
const std::string | getUUID () |
Static Public Attributes | |
static const std::string | PV_DELIMITER |
Protected Attributes | |
util::UUIDGenerator * | _uuidGenerator |
base::RmsDestination | _messageSource |
Private Member Functions | |
std::string | getDestinationPVFromDest (const base::RmsDestination &dest) const |
std::string | getMonitoringPVFromDest (const base::RmsDestination &dest) const |
EpicsMessenger * | getPVHandle (std::string pvName) |
Private Attributes | |
std::map< std::string, EpicsMessenger * > | _cachedPVs |
struct ca_client_context * | _caCurrentContext |
boost::mutex | _epicsLock |
Manages the interface to EPICS. Responsibilities include registering listeners with EPICS, creating EpicsMessengers objects when needed to talk to PVs and translating destination objects into PV names.
Definition at line 41 of file EpicsConnection.h.
gov::fnal::cd::rms::provider::EpicsConnection::EpicsConnection | ( | const std::string | applicationName, |
const int | applicationPartition | ||
) |
Create a new EpicsConnection given the application name and partition.
applicationName | The name of the application generating/receiving messages. |
applicationPartition | The partition of the application that is generating/receiving messages. |
Definition at line 27 of file EpicsConnection.cpp.
References _caCurrentContext, gov::fnal::cd::rms::provider::RmsConnection::_messageSource, gov::fnal::cd::rms::provider::RmsConnection::_uuidGenerator, and gov::fnal::cd::rms::base::RmsDestination::TARGET_PROPERTY_NAME.
gov::fnal::cd::rms::provider::EpicsConnection::~EpicsConnection | ( | ) |
Destructor, call close() and have it clean up everything.
Definition at line 49 of file EpicsConnection.cpp.
References close().
|
virtual |
Add a listener to a particular PV represented by a destination.
dest | The destination that we will be listening to. |
listener | The listener that will be called when messages are posted to the PV. |
If the target is empty, return the PV for the monitoring outbox.
Implements gov::fnal::cd::rms::provider::RmsConnection.
Definition at line 164 of file EpicsConnection.cpp.
References _epicsLock, gov::fnal::cd::rms::provider::EpicsMessenger::addListener(), om::cout, allTimeWatchdog::endl, getDestinationPVFromDest(), getMonitoringPVFromDest(), getPVHandle(), string, and gov::fnal::cd::rms::base::RmsDestination::TARGET_PROPERTY_NAME.
|
virtual |
Free the memory allocated for the UUID generator and delete any instances of the EpicsMessenger class that were created. Finally, call ca_context_destroy().
Implements gov::fnal::cd::rms::provider::RmsConnection.
Definition at line 266 of file EpicsConnection.cpp.
References _cachedPVs, _caCurrentContext, _epicsLock, gov::fnal::cd::rms::provider::RmsConnection::_uuidGenerator, and string.
Referenced by ~EpicsConnection().
|
private |
Translate a destination object into an Epics PV.
dest | The destination object that will be translated into a PV. |
The heartbeat channel is a special case. For each target, their will be one heartbeat channel. All heartbeat messages will be pushed out to the outbox.
Definition at line 302 of file EpicsConnection.cpp.
References gov::fnal::cd::rms::base::RmsDestination::CHANNEL_PROPERTY_NAME, gov::fnal::cd::rms::base::RmsDestination::ENVIRONMENT_PROPERTY_NAME, gov::fnal::cd::rms::base::RmsDestination::HEARTBEAT_CHANNEL, gov::fnal::cd::rms::base::RmsDestination::PARTITION_PROPERTY_NAME, PV_DELIMITER, string, and gov::fnal::cd::rms::base::RmsDestination::TARGET_PROPERTY_NAME.
Referenced by addListener(), ping(), removeListener(), sendMessage(), sendString(), and supportsDestination().
|
inlineinherited |
Get a copy of the message source.
Definition at line 112 of file RmsConnection.h.
References gov::fnal::cd::rms::provider::RmsConnection::_messageSource.
|
private |
Find the name of the monitoring outbox that a message should be posted to when sending to a particular destination.
dest | The destination that the message is going to |
There is no monitoring outbox for the heartbeat channel
Definition at line 357 of file EpicsConnection.cpp.
References gov::fnal::cd::rms::base::RmsDestination::CHANNEL_PROPERTY_NAME, gov::fnal::cd::rms::base::RmsDestination::ENVIRONMENT_PROPERTY_NAME, gov::fnal::cd::rms::base::RmsDestination::HEARTBEAT_CHANNEL, gov::fnal::cd::rms::base::RmsDestination::PARTITION_PROPERTY_NAME, PV_DELIMITER, gov::fnal::cd::rms::base::RmsDestination::SOURCE_PROPERTY_NAME, string, and gov::fnal::cd::rms::base::RmsDestination::TARGET_PROPERTY_NAME.
Referenced by addListener(), removeListener(), sendMessage(), and supportsDestination().
|
private |
Obtain a handle to a particular PV. If the handle has already been created, find it in the _cachedPVs table and return it. Otherwise, create a new one and insert it into the _cachedPVs table.
pvName | The name of the PV to get a handle for. |
Definition at line 403 of file EpicsConnection.cpp.
References _cachedPVs, _caCurrentContext, _epicsLock, and gov::fnal::cd::rms::provider::RmsConnection::_uuidGenerator.
Referenced by addListener(), removeListener(), sendMessage(), sendString(), and supportsDestination().
|
inlineinherited |
Get a new human readbale UUID from the UUID generator.
Definition at line 121 of file RmsConnection.h.
References gov::fnal::cd::rms::provider::RmsConnection::_uuidGenerator, gov::fnal::cd::rms::provider::RmsConnection::close(), and gov::fnal::cd::rms::util::UUIDGenerator::getUUIDHex().
|
virtual |
Try to connect to a PV to verify that it exists and is runing.
pingDestination | The destination that we are going to ping. |
Implements gov::fnal::cd::rms::provider::RmsConnection.
Definition at line 241 of file EpicsConnection.cpp.
References _caCurrentContext, _epicsLock, getDestinationPVFromDest(), fillBadChanDBTables::result, and string.
|
virtual |
Remove a listener from the EpicsConnection so that it no longer receives messages.
dest | The destination to remove. |
listener | The listener to remove. |
If the target is empty, return the PV for the monitoring outbox.
Implements gov::fnal::cd::rms::provider::RmsConnection.
Definition at line 203 of file EpicsConnection.cpp.
References _epicsLock, om::cout, allTimeWatchdog::endl, getDestinationPVFromDest(), getMonitoringPVFromDest(), getPVHandle(), gov::fnal::cd::rms::provider::EpicsMessenger::removeListener(), string, and gov::fnal::cd::rms::base::RmsDestination::TARGET_PROPERTY_NAME.
|
virtual |
Send an RmsMessage to a particular destination.
dest | The destination that the message is going to |
message | The RmsMessage that is being sent |
Implements gov::fnal::cd::rms::provider::RmsConnection.
Definition at line 118 of file EpicsConnection.cpp.
References _epicsLock, om::cout, allTimeWatchdog::endl, getDestinationPVFromDest(), getMonitoringPVFromDest(), getPVHandle(), gov::fnal::cd::rms::provider::EpicsMessenger::sendMessage(), and string.
|
virtual |
Send a string to a particular destination.
dest | The destination that the message is going to |
messageString | The string that is being sent |
Implements gov::fnal::cd::rms::provider::RmsConnection.
Definition at line 91 of file EpicsConnection.cpp.
References _epicsLock, om::cout, allTimeWatchdog::endl, getDestinationPVFromDest(), getPVHandle(), gov::fnal::cd::rms::provider::EpicsMessenger::sendMessage(), and string.
|
virtual |
Determine if the given destination can be reached with the EPICS provider.
dest | The destination to check to see if messages can be sent to it. |
Implements gov::fnal::cd::rms::provider::RmsConnection.
Definition at line 62 of file EpicsConnection.cpp.
References getDestinationPVFromDest(), getMonitoringPVFromDest(), getPVHandle(), and string.
|
private |
A set of handles to PVs that have been used.
Definition at line 67 of file EpicsConnection.h.
Referenced by close(), and getPVHandle().
|
private |
The EPICS context.
Definition at line 72 of file EpicsConnection.h.
Referenced by close(), EpicsConnection(), getPVHandle(), and ping().
|
private |
Lock for the EPICS code as EpicsMessenger is not thread safe.
Definition at line 78 of file EpicsConnection.h.
Referenced by addListener(), close(), getPVHandle(), ping(), removeListener(), sendMessage(), and sendString().
|
protectedinherited |
A destination to hold the application name and application partition that is passed into the constructor.
Definition at line 141 of file RmsConnection.h.
Referenced by EpicsConnection(), gov::fnal::cd::rms::provider::RmsConnection::getMessageSource(), and gov::fnal::cd::rms::provider::LocalhostConnection::LocalhostConnection().
|
protectedinherited |
All providers will need to generate UUIDs.
Definition at line 135 of file RmsConnection.h.
Referenced by close(), EpicsConnection(), getPVHandle(), gov::fnal::cd::rms::provider::RmsConnection::getUUID(), and gov::fnal::cd::rms::provider::LocalhostConnection::LocalhostConnection().
|
static |
The character that is to be used as a delimiter in PV names.
The character that is used a delimiter is PV names.
Definition at line 47 of file EpicsConnection.h.
Referenced by getDestinationPVFromDest(), and getMonitoringPVFromDest().