Package xal.tools.correlator
Class Correlator<S,R,A extends SourceAgent<R>>
java.lang.Object
xal.tools.correlator.Correlator<S,R,A>
- Direct Known Subclasses:
ChannelCorrelator
The Correlator is the class that is used to setup monitoring of correlated
events. It is the sole entry point to the outside world. When correlations
are found, the Correlator broadcasts the correlation.
Note that all time is in seconds unless otherwise stated.
- Author:
- tap
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected double
protected CorrelationTester<R>
protected MessageCenter
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
Correlator
(double aBinTimespan) Creates new Correlatorprotected
Correlator
(double aBinTimespan, CorrelationFilter<R> aFilter) Correlator constructor -
Method Summary
Modifier and TypeMethodDescriptionvoid
addListener
(CorrelationNotice<R> listener) Register the listener as a receiver of Correlation notices from this correlator.protected void
Add a source to monitor.protected void
addSource
(S source, String sourceName, RecordFilter<R> recordFilter) Add a source to monitor.double
Maximum time span allowed for events to be considered correlatedvoid
dispose()
Dispose of the correlator and its overheadfetchCorrelationWithTimeout
(double aTimeout) fetchCorrelationWithTimeout()
is a convenience method that allows the user a simple way to fetch a correlation without handling events and implementing a listener.Get all the names of all the sources managed by this correlatorprotected Collection<A>
Get all of the channel agents managed by this correlatorboolean
See if we already manage this channelboolean
Determine if the correlator is runningvoid
monitorWithTimeout
(double timeout) Monitor and post the best partial correlation if the timeout is exceeded.protected abstract A
newSourceAgent
(S source, String sourceName, RecordFilter<R> recordFilter) int
Number of channels being managedvoid
pulseMonitorWithTimeout
(double timeout) Monitor until the timeout or until a complete correlation is foundprotected void
Register for notices.void
Stop managing all registered sourcesvoid
removeListener
(CorrelationNotice<R> listener) Unregister the listener as a receiver of Correlation notices from this correlator.void
removeSource
(String sourceName) Stop managing the specified source.void
setBinTimespan
(double timespan) Set the maximum time span allowed for events to be considered correlatedvoid
setCorrelationFilter
(CorrelationFilter<R> newFilter) Set the correlation filter to the one specified.void
Start monitoring the managed sources.void
Stop monitoring the managed sources.
-
Field Details
-
localCenter
-
binTimespan
protected double binTimespan -
correlationTester
-
-
Constructor Details
-
Correlator
protected Correlator(double aBinTimespan) Creates new Correlator -
Correlator
Correlator constructor
-
-
Method Details
-
registerEvents
protected void registerEvents()Register for notices. -
addListener
Register the listener as a receiver of Correlation notices from this correlator.- Parameters:
listener
- to register for receiving events
-
removeListener
Unregister the listener as a receiver of Correlation notices from this correlator.- Parameters:
listener
- to remove from receiving events
-
binTimespan
public double binTimespan()Maximum time span allowed for events to be considered correlated- Returns:
- the bin timespan
-
setBinTimespan
public void setBinTimespan(double timespan) Set the maximum time span allowed for events to be considered correlated- Parameters:
timespan
- of the bins
-
setCorrelationFilter
Set the correlation filter to the one specified.- Parameters:
newFilter
- The correlation filter to use.
-
getSourceAgents
Get all of the channel agents managed by this correlator- Returns:
- collection of source agents
-
getNamesOfSources
Get all the names of all the sources managed by this correlator- Returns:
- names of the sources
-
numSources
public int numSources()Number of channels being managed- Returns:
- number of sources
-
hasSource
See if we already manage this channel- Parameters:
sourceName
- name of source to test- Returns:
- true if the named source is in this correlator and false if not
-
addSource
Add a source to monitor. The name provided with each source must be unique to that source. Subclasses need to wrap this method to enforce the source type.- Parameters:
source
- to addsourceName
- name of source to add
-
addSource
Add a source to monitor. If we already monitor a source as determined by the source name, then do nothing. The record filter is used to determine whether or not to accept a reading of the specified source when the event is handled. You can create your own custom filter or use a pre-built one. Subclasses need to wrap this method to enforce the source type.- Parameters:
source
- to addsourceName
- name of source to addrecordFilter
- filter for the source
-
newSourceAgent
-
removeSource
Stop managing the specified source.- Parameters:
sourceName
- name of source to remove
-
removeAllSources
public void removeAllSources()Stop managing all registered sources -
pulseMonitorWithTimeout
public void pulseMonitorWithTimeout(double timeout) Monitor until the timeout or until a complete correlation is found- Parameters:
timeout
- time to wait in seconds
-
monitorWithTimeout
public void monitorWithTimeout(double timeout) Monitor and post the best partial correlation if the timeout is exceeded. The timeout is rescheduled after every post.- Parameters:
timeout
- time to wait in seconds
-
startMonitoring
public void startMonitoring()Start monitoring the managed sources. -
stopMonitoring
public void stopMonitoring()Stop monitoring the managed sources. -
isRunning
public boolean isRunning()Determine if the correlator is running- Returns:
- true if the correlator is running and false otherwise.
-
dispose
public void dispose()Dispose of the correlator and its overhead -
fetchCorrelationWithTimeout
fetchCorrelationWithTimeout()
is a convenience method that allows the user a simple way to fetch a correlation without handling events and implementing a listener. The method spawns a fetch and blocks until a correlation is retrieved or the timeout has expired. The resulting correlation is returned. If no correlation was found within the timeout, null is returned.- Parameters:
aTimeout
- timeout for fetching a correlation- Returns:
- fetched correlation or null if none within the timeout
-