# TimeController
The TimeController is a component allowing the visualization and temporal control of the Toolkit's DataSources. Thus it allows to go back to archive data at specific periods or to switch to real time.
API Reference
# Properties configuration
The control can be done either by passing a DataSource object or a DataSynchronizer object containing several DataSources.
The skipTimeStep
parameter is used to define the period of time you want to go forward or backward.
The value can be expressed in seconds or as a percentage.
The replaySpeedStep
parameter is used to define the speed of acceleration or deceleration of the DataSource.
It will act directly on the replaySpeed
value of the DataSource object.
The debounce
parameter is used to set the measured waiting time between two actions.
For example, if we press forward
several times, this value will allow to take into account either
the first or both actions.
Example: if we click twice on forward at 300ms interval and the debounce
value is 500ms,
then the second `forward' will be ignored. On the other hand, if the debounce value was less than or equal to 300ms,
the second action would also be executed.
The parseTime
parameter allows you to define a function that will customize the time display next to the action buttons.
This can be useful if we want to display the time in ISO UTC or local time for example, or if we want to display
only hours:minutes or also seconds, months etc.
WARNING
For each forward, backward, replay speed and slide action of the slider, a reconnection is automatically performed and an event is launched with the name of the action that has just been performed as the value.
When switching to real time, the reconnection is also automatic. On the other hand, when switching from real time to replay, the last replay parameters are reloaded but the reconnection is not automatic. It is then necessary either to perform an action or to click on the play button.
# Example
<template>
<div id="app">
<div id="container">
</div>
<TimeController
:dataSource="dataSource"
@event='onControlEvent'
:skipTimeStep="'60s'"
:replaySpeedStep=0.1
v-if="dataSource"
></TimeController>
</div>
</template>
<script>
// @ is an alias to /src
import ChartJsView from 'osh-js/core/ui/view/chart/ChartJsView.js';
import CurveLayer from 'osh-js/core/ui/layer/CurveLayer.js';
import SosGetResultJson from 'osh-js/core/datasource/SosGetResultJson.js';
import TimeController from 'osh-js/vue/components/TimeController.vue';
import {isDefined} from 'osh-js/core/utils/Utils.js';
export default {
components: {
TimeController
},
data: function () {
return {
dataSource: null,
view: null
}
},
mounted() {
let chartDataSource = new SosGetResultJson("weather", {
protocol: "ws",
service: "SOS",
endpointUrl: "sensiasoft.net:8181/sensorhub/sos",
offeringID: "urn:mysos:offering04",
observedProperty: "http://sensorml.com/ont/swe/property/Weather",
startTime: (new Date(Date.now() - 60 * 1000 * 60 * 1).toISOString()),
endTime: (new Date(Date.now()).toISOString()),
minTime: (new Date(Date.now() - 60 * 1000 * 60 * 1).toISOString()),
maxTime: (new Date(Date.now()).toISOString()),
replaySpeed: 1.5
});
// #region snippet_curve_layer
let windSpeedLayerCurve = new CurveLayer({
dataSourceId: chartDataSource.id,
getValues: (rec, timeStamp) => {
return {
x: timeStamp,
y: rec.windSpeed
}
},
name: 'Wind Speed (m/s)'
});
// #endregion snippet_curve_layer
// show it in video view
this.view = new ChartJsView({
container: 'container',
layers: [windSpeedLayerCurve],
css: "chart-view",
chartjsProps: {
chartProps: {
scales: {
yAxes: [{
scaleLabel: {
labelString: "Wind Speed (m/s)"
},
ticks: {
maxTicksLimit: 10
}
}],
xAxes: [{
scaleLabel: {
labelString: "Time"
},
ticks: {
maxTicksLimit: 20
}
}],
},
maintainAspectRatio: false
},
datasetsProps: {
backgroundColor: 'rgba(141,242,246, 0.1)'
}
}
});
// start streaming
chartDataSource.connect();
this.dataSource = chartDataSource;
},
methods: {
onControlEvent(eventName) {
}
}
};
</script>
<style>
body, html {
overflow-x: hidden;
margin: 0;
padding: 0px;
background: aliceblue;
width: 100%;
height: 100%;
}
#container {
height: 80%;
margin-bottom: 50px;
}
#app {
width: inherit;
height: inherit;
}
</style>