Package xal.tools.correlator
Class PeriodicPoster<T>
java.lang.Object
xal.tools.correlator.PeriodicPoster<T>
- All Implemented Interfaces:
ActionListener
,EventListener
PerodicPoster is an auxiliary class for posting correlations periodically.
Unlike the TimedBroadcaster, it strictly only posts the most recent best
correlation within a given time interval. Other correlations within that same
time period will be dropped. The poster will repeat forever until it is
stopped.
- Author:
- tap
-
Constructor Summary
ConstructorsConstructorDescriptionPeriodicPoster
(Correlator<?, T, ? extends SourceAgent<T>> aCorrelator, double period) Creates a new instance of PeriodicPoster -
Method Summary
Modifier and TypeMethodDescriptionvoid
actionPerformed
(ActionEvent event) Implement ActionListener interface to rebroadcast the best correlation.void
addCorrelationNoticeListener
(CorrelationNotice<T> listener) Add the listener of re-broadcast correlation notices.void
dispose()
Dispose of the posterCorrelator<?,
T, ? extends SourceAgent<T>> Get the associated correlatordouble
Get the timer periodboolean
Determine if the poster is runningvoid
removeCorrelationNoticeListener
(CorrelationNotice<T> listener) Remove the listener of re-broadcast correlationsvoid
restart()
Restart postingvoid
setPeriod
(double period) Set the timer periodvoid
start()
Start the timervoid
stop()
Stop posting
-
Constructor Details
-
PeriodicPoster
Creates a new instance of PeriodicPoster- Parameters:
aCorrelator
- The correlator providing the correlations.period
- The posting period.
-
-
Method Details
-
getCorrelator
Get the associated correlator- Returns:
- the correlator providing the correlations.
-
getPeriod
public double getPeriod()Get the timer period- Returns:
- The timer period.
-
setPeriod
public void setPeriod(double period) Set the timer period- Parameters:
period
- The new timer period.
-
isRunning
public boolean isRunning()Determine if the poster is running- Returns:
- true if the poster is running and false if not.
-
start
public void start()Start the timer -
stop
public void stop()Stop posting -
restart
public void restart()Restart posting -
dispose
public void dispose()Dispose of the poster -
addCorrelationNoticeListener
Add the listener of re-broadcast correlation notices.- Parameters:
listener
- A listener of the correlation notice.
-
removeCorrelationNoticeListener
Remove the listener of re-broadcast correlations- Parameters:
listener
- A listener of the correlation notice.
-
actionPerformed
Implement ActionListener interface to rebroadcast the best correlation.- Specified by:
actionPerformed
in interfaceActionListener
- Parameters:
event
- The timer event indicating that it is time to post a correlation.
-