public class

DataPipeline

extends Object
implements SourceCallback
java.lang.Object
   ↳ com.openxc.DataPipeline

Class Overview

A pipeline that ferries data from VehicleDataSources to VehicleDataSinks. A DataPipeline accepts two types of components - sources and sinks. The sources (implementing VehicleDataSource call the receive(VehicleMessage) method on the this class when new values arrive. The DataPipeline then passes this value on to all currently registered data sinks. The Pipeline can have an optional Operator, which implements a few callbacks to check the status of the pipeline - e.g. if some source in the pipeline is active.

Summary

Nested Classes
interface DataPipeline.Operator  
Public Constructors
DataPipeline()
DataPipeline(DataPipeline.Operator operator)
Public Methods
VehicleDataSink addSink(VehicleDataSink sink)
Add a new sink to the pipeline.
VehicleDataSource addSource(VehicleDataSource source)
Add a new source to the pipeline.
void clearSinks()
Remove and stop all sinks in the pipeline.
void clearSources()
Remove and stop all sources in the pipeline.
KeyedMessage get(MessageKey key)
Return the last received value for the keyed message if known.
int getMessageCount()
List<VehicleDataSink> getSinks()
List<VehicleDataSource> getSources()
boolean isActive()
boolean isActive(VehicleDataSource skipSource)
Return true if at least one source is active.
void receive(VehicleMessage message)
Accept new values from data sources and send it out to all registered sinks.
void removeSink(VehicleDataSink sink)
Remove a previously added sink from the pipeline.
void removeSource(VehicleDataSource source)
Remove a previously added source from the pipeline.
void sourceConnected(VehicleDataSource source)
At least one source is active - notify the operator.
void sourceDisconnected(VehicleDataSource source)
At least one source is not active - if all sources are inactive, notify the operator.
void stop()
Clear all sources and sinks from the pipeline and stop all of them.
String toString()
[Expand]
Inherited Methods
From class java.lang.Object
From interface com.openxc.sources.SourceCallback

Public Constructors

public DataPipeline ()

public DataPipeline (DataPipeline.Operator operator)

Public Methods

public VehicleDataSink addSink (VehicleDataSink sink)

Add a new sink to the pipeline.

public VehicleDataSource addSource (VehicleDataSource source)

Add a new source to the pipeline. The source is given a reference to this DataPipeline as its callback.

public void clearSinks ()

Remove and stop all sinks in the pipeline.

public void clearSources ()

Remove and stop all sources in the pipeline.

public KeyedMessage get (MessageKey key)

Return the last received value for the keyed message if known.

Parameters
key the key of the message to retreive, if any available.
Returns
  • a VehicleMessage with the last known value, or null if no value has been received.

public int getMessageCount ()

Returns
  • number of messages received since instantiation.

public List<VehicleDataSink> getSinks ()

public List<VehicleDataSource> getSources ()

public boolean isActive ()

public boolean isActive (VehicleDataSource skipSource)

Return true if at least one source is active.

Parameters
skipSource don't consider this data source when determining if the pipeline is active.

public void receive (VehicleMessage message)

Accept new values from data sources and send it out to all registered sinks. This method is required to implement the SourceCallback interface. If any data sink throws a DataSinkException when receiving data, it will be removed from the list of sinks.

Parameters
message the new measurement.

public void removeSink (VehicleDataSink sink)

Remove a previously added sink from the pipeline. Once removed, the sink will no longer receive any new messages from the pipeline's sources. The sink's stop() method is also called.

Parameters
sink if the value is null, it is ignored.

public void removeSource (VehicleDataSource source)

Remove a previously added source from the pipeline. Once removed, the source should no longer use this pipeline for its callback.

Parameters
source if the value is null, it is ignored.

public void sourceConnected (VehicleDataSource source)

At least one source is active - notify the operator.

public void sourceDisconnected (VehicleDataSource source)

At least one source is not active - if all sources are inactive, notify the operator.

public void stop ()

Clear all sources and sinks from the pipeline and stop all of them.

public String toString ()