dasmon_listener package
Submodules
dasmon_listener.amq_consumer module
DASMON ActiveMQ consumer class
@author: M. Doucet, Oak Ridge National Laboratory @copyright: 2014 Oak Ridge National Laboratory
- class dasmon_listener.amq_consumer.Client(brokers, user, passcode, queues=None, consumer_name='amq_consumer')[source]
Bases:
object
ActiveMQ client Holds the connection to a broker
- get_connection(listener=None)[source]
Establish and return a connection to ActiveMQ
- Parameters:
listener – listener object
- listen_and_wait(waiting_period=1.0)[source]
Listen for the next message from the brokers. This method will simply return once the connection is terminated.
- Parameters:
waiting_period – sleep time between connection to a broker
- send(destination, message, persistent='false')[source]
Send a message to a queue. This send method is used for heartbeats and doesn’t need AMQ persistent messages.
- Parameters:
destination – name of the queue
message – message content
persistent – true, to set persistent header
- class dasmon_listener.amq_consumer.Listener[source]
Bases:
ConnectionListener
Base listener class for an ActiveMQ client
A fully implemented class should overload the on_message() method to process incoming messages.
- dasmon_listener.amq_consumer.notify_users(instrument_id, signal)[source]
Find users who need to be notified and send them a message
- Parameters:
instrument_id – Instrument object
signal – Signal object
- dasmon_listener.amq_consumer.process_SMS(instrument_id, headers, data)[source]
Process SMS process information The message content looks like this:
- {u’start_sec’: u’1460394343’,
u’src_id’: u’SMS_32162’, u’msg_type’: u’2686451712’, u’facility’: u’SNS’, u’timestamp’: u’1460394348’, u’dest_id’: u’’, u’start_nsec’: u’554801929’, u’instrument’: u’BL16B’, u’reason’: u’SMS run stopped’, u’run_number’: u’3014’}
- Parameters:
instrument_id – Instrument object
data – data dictionary
- dasmon_listener.amq_consumer.process_ack(data=None, headers=None)[source]
Process a ping request ack
- Parameters:
data – data that came in with the ack
- dasmon_listener.amq_consumer.process_signal(instrument_id, data)[source]
Process and store signal messages.
Asserted signals look like this: {
“msg_type”: “2147483648”, “src_name”: “DASMON.0”, “timestamp”: “1375464085”, “sig_name”: “SID_SVP_HIGH”, “sig_source”: “DAS”, “sig_message”: “SV Pressure too high!”, “sig_level”: “3”
}
Retracted signals look like this: {
“msg_type”: “2147483649”, “src_name”: “DASMON.0”, “timestamp”: “1375464079”, “sig_name”: “SID_SVP_HIGH”
}
- Parameters:
instrument_id – Instrument object
data – data dictionary
- dasmon_listener.amq_consumer.send_message(sender, recipients, subject, message)[source]
Send an email message
- Parameters:
sender – email of the sender
recipients – list of recipient emails
subject – subject of the message
message – content of the message
- dasmon_listener.amq_consumer.store_and_cache(instrument_id, key_id, value, timestamp=None, cache_only=False)[source]
Protected store and cache process. Store and cache a DASMON parameter
- Parameters:
instrument_id – Instrument object
key_id – key Parameter object
value – value for the given key
cache_only – only update cache
dasmon_listener.listener_daemon module
DASMON listener daemon