Call Sequence
-
Sets the flag whether live data is written to the datapool
[PUT] https://localhost/api/InputStream/dataPoolEnabled
-
Creates a live stream.
[POST] https://localhost/api/InputStream
- Starts the newly created live stream. Starting also creates a new ConfigDoc
[PUT] https://localhost/api/InputStream/{source}/start
-
Adds a timespan to the livestream
[POST] https://localhost/api/InputStream/{source}/timeSpan
-
Adds a parameter to the livestream
[POST] https://localhost/api/InputStream/{source}/parameter
-
Adds parameter data to the livestream
[POST] https://localhost/api/InputStream/{source}/data
-
Stops the live stream
[PUT] https://localhost/api/InputStream/{source}/stop
Example Code
this.client.CreateLiveStream(new CreateLiveStreamRequest(this.Source));
var name = $"Weather data {DateTime.Now:dd MM yyyy hh mm ss}";
this.client.StartLiveStream(this.Source, new StartLiveStreamRequest(name, name));
this.lastLapEndtime = DateTime.Now.ToEpochNanoseconds();
this.paramDefDocs = new List<IRegnoParamDefDoc>();
this.processingSubscription?.Dispose();
var requests = new List<AddParameterRequest>();
for (var i = 0; i < this.NumberOfParameters; i++)
{
requests.Add(new AddParameterRequest("{this.ParameterNamePrefix}{i}",
$"{this.ParameterNamePrefix}{i}",
"Weather",
-100,
100,
"C",
"%0.2f",
$"{this.ParameterNamePrefix}{i}:Weather",
new double[0],
"C",
"%0.2f"));
}
this.paramDefDocs.AddRange(this.client.AddParameters(this.Source, requests));
this.lastSampleTime = DateTime.Now.ToEpochNanoseconds();
this.processingSubscription = Observable.Interval(TimeSpan.FromMilliseconds(Interval)).Subscribe(
a =>
{
this.Tick(Interval * SpeedFactor * 1000000);
});
private void SendParameterData(long endTime)
{
var interval = (long)(1.0 / this.Frequency * 1000000000);
var newTime = this.lastSampleTime;
var payloads = new List<SamplesPayload>();
for (var i = 1; i <= this.paramDefDocs.Count; i++)
{
var paramDefDoc = this.paramDefDocs[i - 1];
var sampleTimes = new List<long>();
while (time < endTime)
{
time += interval;
var secs = (double)time / 1000000000;
var value = Math.Sin(secs / i + 1 % Math.PI);
value *= (i * 10) % 101;
sampleValuesDouble.Add(value);
sampleTimes.Add(time);
}
payloads.Add(new SamplesPayload(sampleTimes.ToArray(), sampleValuesDouble.ToArray()));
}
this.PublishSamplesPayloads(payloads, paramDefDocs);
this.lastSampleTime = newTime;
}
private void PublishSamplesPayloads(IReadOnlyList<SamplesPayload> payloads, IReadOnlyList<IRegnoParamDefDoc> paramDefDocs)
{
if (payloads.Count != paramDefDocs.Count)
{
throw new ArgumentException();
}
var requests = payloads.Select((t, i) => new AddParameterDataRequest(paramDefDocs[i].Id, t)).ToList();
this.client.AddParameterData(this.Source, requests);
}
AddEventRequest
{
"$schema": "http://json-schema.org/draft-04/schema#",
"type": "object",
"properties": {
"name": {
"type": "string"
},
"description": {
"type": "string"
},
"group": {
"type": "string"
},
"eventIdentifier": {
"type": "string"
},
"priority": {
"type": "string",
"enum": [
"Unknown",
"High",
"Low",
"Medium",
"Debug"
]
}
},
"required": [
"name",
"description",
"group",
"eventIdentifier",
"priority"
]
}
AddEventDataRequest
{
"$schema": "http://json-schema.org/draft-04/schema#",
"type": "object",
"properties": {
"eventDefDocId": {
"type": "string"
},
"name": {
"type": "string"
},
"description": {
"type": "string"
},
"group": {
"type": "string"
},
"eventIdentifier": {
"type": "string"
},
"time": {
"type": "integer"
},
"status": {
"type": "string"
},
"priorityType": {
"type": "string",
"enum": [
"Unknown",
"High",
"Low",
"Medium",
"Debug"
]
}
},
"required": [
"eventDefDocId",
"name",
"description",
"group",
"eventIdentifier",
"time",
"status",
"priorityType"
]
}
AddMediaDataRequest
{
"$schema": "http://json-schema.org/draft-04/schema#",
"type": "object",
"properties": {
"mediaType": {
"type": "string",
"enum": [
"Video",
"Audio"
]
},
"name": {
"type": "string"
},
"description": {
"type": "string"
},
"time": {
"type": "integer"
},
"source": {
"type": "string"
},
"timeOffset": {
"type": "integer"
},
"notes": {
"type": "string"
}
},
"required": [
"mediaType",
"name",
"description",
"time",
"source",
"timeOffset",
"notes"
]
}
AddParameterRequest sourceId must be {name:group}. e.g. if name = Speed and group = Car then SourceId = Speed:Car
{
"$schema": "http://json-schema.org/draft-04/schema#",
"type": "object",
"properties": {
"name": {
"type": "string"
},
"description": {
"type": "string"
},
"group": {
"type": "string"
},
"min": {
"type": "integer"
},
"max": {
"type": "integer"
},
"units": {
"type": "string"
},
"format": {
"type": "string"
},
"sourceId": {
"type": "string"
},
"frequencies": {
"type": "array",
"items": [{
"type": "number"
}]
},
"instanceUnits": {
"type": "string"
},
"instanceFormat": {
"type": "string"
}
},
"required": [
"name",
"description",
"group",
"min",
"max",
"units",
"format",
"sourceId",
"frequencies"
]
}
AddParameterDataRequest
sample array depends on dataType. e.g. if dataType is "Double" set "sampleValuesDouble".
{
"$schema": "http://json-schema.org/draft-04/schema#",
"type": "object",
"properties": {
"paramDefDocId": {
"type": "string"
},
"payload": {
"type": "object",
"properties": {
"sampleTimes": {
"type": "array",
"items": [{
"type": "number"
}]
},
"sampleValuesByte": {
"type": "array",
"items": [{
"type": "integer"
}]
},
"sampleValuesShort": {
"type": "array",
"items": [{
"type": "integer"
}]
},
"sampleValuesLong": {
"type": "array",
"items": [{
"type": "integer"
}]
},
"sampleValuesFloat": {
"type": "array",
"items": [{
"type": "number"
}]
},
"sampleValuesInteger": {
"type": "array",
"items": [{
"type": "integer"
}]
},
"sampleValuesDouble": {
"type": "array",
"items": [{
"type": "number"
}]
},
"dataType": {
"type": "string",
"enum": [
"Double",
"Long",
"Byte",
"Short",
"Float",
"Integer"
]
}
},
"required": [
"sampleTimes",
"dataType"
]
}
},
"required": [
"paramDefDocId",
"payload"
]
}
AddTimespanRequest
{
"$schema": "http://json-schema.org/draft-04/schema#",
"type": "object",
"properties": {
"type": {
"type": "string",
"enum": [
"Interval",
"Lap",
"Year",
"Month",
"Day",
"Hour",
"Minute",
"Second",
"Version",
"Revision",
"Period",
"Measurement",
"Test",
"Run",
"Experiment",
"Result"
]
},
"name": {
"type": "string"
},
"startTime": {
"type": "integer"
},
"endTime": {
"type": "integer"
},
"duration": {
"type": "integer"
},
"source": {
"type": "string"
}
},
"required": [
"type",
"name",
"startTime",
"endTime",
"source"
]
}
CreateLiveStreamRequest
{
"$schema": "http://json-schema.org/draft-04/schema#",
"type": "object",
"properties": {
"source": {
"type": "string"
}
},
"required": [
"source"
]
}
StartLiveStreamRequest
{
"$schema": "http://json-schema.org/draft-04/schema#",
"type": "object",
"properties": {
"name": {
"type": "string"
},
"description": {
"type": "string"
},
"startTime": {
"type": "integer"
},
"sourceType": {
"type": "string",
"enum": [
"Data",
"Configuration",
"Exprtiment",
"Simulation",
"Run",
"Period",
"Session",
"Event",
"Day",
"Month",
"Year",
"Lap",
"Audio",
"Video",
"Metrics"
]
},
"tags": {
"type": "array",
"items": [
{
"type": "object",
"properties": {
"key": {
"type": "string"
},
"value": {
"type": "string"
}
},
"required": [
"key",
"value"
]
}
]
}
},
"required": [
"name",
"description"
]
}