new OSH.Buffer(options)
| Name | Type | Description | ||||||
|---|---|---|---|---|---|---|---|---|
options |
Object |
The options object
|
Example
var buffer = new OSH.Buffer({
replayFactor: 1
});
Methods
-
addDataSource(dataSourceId, options)
-
Adds a new dataSource into the buffer.
Name Type Description dataSourceIdThe dataSource to add
optionssyncMasterTime | bufferingTime | timeOut | name
-
addEntity(entity, options)
-
Adds an entity which contains one or more dataSources.
The dataSources are then added to the buffer using OSH.Buffer.addDataSourceName Type Description entityThe entity to add
optionsThe options object passed to the OSH.Buffer.addDataSource
-
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.
Name Type Description nameThe name of the current dataSource which needs to be buffered
bufferingTimeThe buffering time
-
cancelAll()
-
Cancels all current running/pending jobs. This function loop over the
datasources and cancel them one by one. -
cancelDataSource(dataSourceId)
-
Cancels the dataSource. Cancels means to clear the data contained into the buffer and change the status to CANCEL
Name Type Description dataSourceIdThe dataSource to cancel
-
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.Name Type Description dataSourceIdThe dataSourceId of the data. It will be used as concatenated String into the fire method.
dataThe data to fire
-
processData()
-
[TODO] This is an internal method.
-
processSyncData()
-
[TODO] This is an internal method.
-
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.Name Type Description eventThe event object received from the OSH.EventManager
Name Type Description dataSourceIdThe dataSource id to process
syncMasterTimeA 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.dataThe raw data provided by the DataSource
Name Type Description timeStampThe timeStamp of the data. It will be used in case of the syncMasterTime is set to TRUE.
-
start()
-
Starts the buffer and starts the observers.
-
startAll()
-
Starts all dataSources. The method loops over all datasources and
calls the OSH.Buffer.startDataSource. -
startDataSource(dataSourceId)
-
Starts buffering the dataSource.
Name Type Description dataSourceIdthe dataSource to start
-
startObservers()
-
Starts observing the data stream.
-
stop()
-
Stops the buffer and stops the observers.
-
stopObservers()
-
Stops observing the data stream.