Class: Buffer

OSH.Buffer

Represents the buffer element which is in charge of synchronizing data.

Constructor

new Buffer(options)

Parameters:
Name Type Description
options Object

The options object

Properties
Name Type Description
replayFactor Object

defines the replay speed of the buffer in order to synchronize data

Source:

Methods

addDataSource(dataSourceId, options)

Adds a new dataSource into the buffer.

Parameters:
Name Type Description
dataSourceId

The dataSource to add

options

syncMasterTime | bufferingTime | timeOut | name

Source:

addEntity(entity, options)

Adds an entity which contains one or more dataSources.
The dataSources are then added to the buffer using OSH.Buffer.addDataSource

Parameters:
Name Type Description
entity

The entity to add

options

The options object passed to the OSH.Buffer.addDataSource

Source:

buffering(name, bufferingTime)

This method is responsible of buffering data, that is to say it will timeOut the whole process to wait after more data.

Parameters:
Name Type Description
name

The name of the current dataSource which needs to be buffered

bufferingTime

The buffering time

Source:

cancelAll()

Cancels all current running/pending jobs. This function loop over the
datasources and cancel them one by one.

Source:

cancelDataSource(dataSourceId)

Cancels the dataSource. Cancels means to clear the data contained into the buffer and change the status to CANCEL

Parameters:
Name Type Description
dataSourceId

The dataSource to cancel

Source:

dispatchData(dataSourceId, data)

Dispatches the data through the EventManager. If the data to process is synchronized, it will launch a OSH.EventManager.EVENT.CURRENT_MASTER_TIME event
with {timeStamp:xxx} as parameter. In all case, it launches a OSH.EventManager.EVENT.DATA-dataSourceId event with {data:data} as parameter.

Parameters:
Name Type Description
dataSourceId

The dataSourceId of the data. It will be used as concatenated String into the fire method.

data

The data to fire

Source:

processData()

[TODO] This is an internal method.

Source:

processSyncData()

[TODO] This is an internal method.

Source:

push(event)

Pushes a data into the buffer. This method is used as internal method by the OSH.Buffer.startObservers.
The event contains the necessary elements to process the data.

Parameters:
Name Type Description
event

The event object received from the OSH.EventManager

Properties
Name Type Description
dataSourceId

The dataSource id to process

syncMasterTime

A boolean used to check if the data has to be synchronized with another data. If the value
is FALSE, the data will pass through the buffer and send back immediately.

data

The raw data provided by the DataSource

Properties
Name Type Description
timeStamp

The timeStamp of the data. It will be used in case of the syncMasterTime is set to TRUE.

Source:

start()

Starts the buffer and starts the observers.

Source:

startAll()

Starts all dataSources. The method loops over all datasources and
calls the OSH.Buffer.startDataSource.

Source:

startDataSource(dataSourceId)

Starts buffering the dataSource.

Parameters:
Name Type Description
dataSourceId

the dataSource to start

Source:

startObservers()

Starts observing the data stream.

Source:

stop()

Stops the buffer and stops the observers.

Source:

stopObservers()

Stops observing the data stream.

Source: