public class AlarmSender
extends java.lang.Object
implements java.lang.Runnable
The sending is done by a dedicated thread to avoid blocking the caller. Alarms are queued and published in a FIFO order. The size of the queue is limited to that is enough for testing purposes of this class. If the queues is full, the caller methods waits until there is enough room in the queue.
AlarmSender objects notify the listener whenever an alarm has been published.
Life cycle:
| Constructor and Description |
|---|
AlarmSender(ContainerServices svcs,
java.lang.String name)
Constructor
|
AlarmSender(ContainerServices svcs,
java.lang.String name,
long timeBetweenAlarms)
Constructor
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
addListener(AlarmSentListener listener)
Add a listener
|
int |
alarmsWaiting()
Return the number of alars queued and waiting to be sent
|
void |
close()
Close the sender and the thread
|
boolean |
removeListener(AlarmSentListener listener)
Remove a listener
|
void |
run()
The thread to get alarms from queue and publish them into the NC
|
void |
send(ParallelAlarmSender.AlarmToSend alarmToSend)
Send the specified alarm to the alarm service.
|
protected void |
sendSynch(SenderPanelUtils.Triplet triplet,
SenderPanelUtils.AlarmDescriptorType descriptor,
java.util.Properties props)
Synchronously publishes the specified alarm in the source NC.
|
void |
start()
Start the thread.
|
public AlarmSender(ContainerServices svcs, java.lang.String name) throws ACSASFactoryNotInitedEx, SourceCreationErrorEx
svcs - The ContainerServicesname - The name of the senderSourceCreationErrorExACSASFactoryNotInitedExpublic AlarmSender(ContainerServices svcs, java.lang.String name, long timeBetweenAlarms) throws ACSASFactoryNotInitedEx, SourceCreationErrorEx
svcs - The ContainerServicesname - The name of the senderThe - time between sending 2 alarmsSourceCreationErrorExACSASFactoryNotInitedExprotected void sendSynch(SenderPanelUtils.Triplet triplet, SenderPanelUtils.AlarmDescriptorType descriptor, java.util.Properties props)
Sending alarms through this method should be generally avoided, preferring
#send(Triplet, AlarmDescriptorType, Properties) instead.
triplet - The triplet in the form FF,FM,FCThe - descriptorprops - The user propertiesFaultStateCreationErrorExACSASFactoryNotInitedExpublic void send(ParallelAlarmSender.AlarmToSend alarmToSend) throws java.lang.InterruptedException
This method return immediately: each alarm is queued and sent later on by the thread.
If the queue of alarms contains more then , the caller waits until the thread frees the queue.
alarmToSend - The alarm to send to the alarm serverjava.lang.InterruptedException - If interrupted while awaiting to put the alarm in the queuepublic boolean addListener(AlarmSentListener listener)
listener - The listener to notify when an alarm has been senttrue if this set did not already contain the specified elementpublic boolean removeListener(AlarmSentListener listener)
listener - The listener to notify when an alarm has been senttrue if this set contained the specified elementpublic void start()
public void close()
public int alarmsWaiting()
public void run()
run in interface java.lang.Runnable