Skip to main content

Function generator module "functiongenerator"

Description

THE "functiongenerator" MODULE IS MERELY A TEST MODULE FOR INTERNAL PURPOSES!

It is used for the temporally correct production of channel data.

Production here is based on complete data blocks.

Interfaces & protocols used

  • NONE

JSON configuration

The following section describes the entire JSON configuration of the module and explains the individual parameters.

Example configuration (typical configuration)

{
"module": "FunctionGenerator",
"factory": "functiongenerator",
"config":{
"maximumProductionCount":-1,
"maximumTimestampDeviation":-1,
"rtPriority":80,
"samplesPerBlock":1,
"timeoutSeconds":1,
"timeoutNanoseconds":0,
"startDate":"1970-01-01T00:00:00Z",
"channels":[
{
"name": "Some Sine Channel",
"dataType": "float",
"bufferSize":1024,
"function": "sine",
"amplitude":1.0,
"offset":0.0,
"frequency":1.0,
"onOffRatio":0.5
},
{
"name": "Some Message Channel",
"dataType": "string",
"function": "messages",
"messages":[
{
"timestamp":"1970-01-01T00:00:05Z",
"text": "Hello, "
},
{
"timestamp":"1970-01-01T00:00:10Z",
"text": "World!"
}
]
},
{
"name": "Some Data Points",
"dataType": "int32",
"function": "datapoints",
"datapoints":[
{
"timestamp":"1970-01-01T00:00:01Z",
"value":42
},
{
"timestamp":"1970-01-01T00:00:02Z",
"value":24
}
]
},
{
"name": "Some Gps Locations",
"dataType": "gpslocation",
"function": "gpslocations",
"gpslocations":[
{
"timestamp":"1970-01-01T00:00:01Z",
"latitude":60.1234567,
"longitude":15.7654321,
"altitude":123.4
},
{
"timestamp":"1970-01-01T00:00:02Z",
"latitude":61.1234567,
"longitude":16.7654321,
"altitude":234.5
}
]
}
]
}
}

Global module parameters

Parameter nameRequiredData typeMeaningful value rangeDefaultDescription
maximumProductionCountNoINT-1, 1 --1Maximum number of produced samples (-1 - infinite)
maximumTimestampDeviationNoINT-1, 1 --1Maximum timestamp deviation [ns] from which the current smartCORE timestamp is used as the new starting point for the production of contiguous blocks (-1 - the start time is ALWAYS used as the time base)
rtPriorityNoINT20 - 8080Priority of the production thread
bufferSizeNoINT1 -1024Global buffer size of samples for all channels
samplesPerBlockNoINT1 -1Number of samples produced within a block
timeoutSecondsNoINT1 -1Production clock (specification of seconds)
timeoutNanosecondsNoINT1 -0Production clock (specification of nanoseconds)
startDateNoSTRINGUTC Zulu String or "now""now"Production start time. For reproducible results and in the context of "messages", "datapoints" and "gpslocations", a constant specification as a UTC Zulu string is appropriate, while "now" specifies the current smartCORE timestamp as the start time.
channelsJAJSON Array of JSON Objectssee below

Configuration of a channel (JSON object within "channels")

Parameter nameRequiredData typeMeaningful value rangeDefaultDescription
nameYESSTRINGname of the channel
dataTypeYESSTRINGsee belowdata type of the channel
bufferSizeNoINT1 -global "bufferSize" of the modulebuffer size of the created channel
functionYESSTRINGsee belowfunction to be produced
...additional parameters (see below)

Supported channel data types 'dataType'

Note: Not all data types can be used in combination with all function specifications "function".

  • string (UTF-8 encoded)
  • bytearray
  • double
  • float
  • int64, int32, int16, int8
  • uint64, uint32, uint16, uint8
  • bool
  • gpslocation

Supported functions 'function'

  • linear
  • sine
  • sawtooth
  • triangle
  • rectangle
  • messages
  • datapoints
  • gpslocations

Mathematical functions

The following functions represent mathematical functions

  • linear
  • sine
  • sawtooth
  • triangle
  • rectangle

They have the following parameters in common

Parameter NameRequiredData TypeMeaningful Value RangeDefaultDescription
amplitudeNoFLOAT- 0.0 -1.0The amplitude (or multiplicative scaling) of the function
offsetNoFLOAT- 0.0 -0.0The additive offset of the function
frequencyNoFLOAT0.0 -1.0The frequency of the function [Hz]
onOffRatioNoFLOAT-1.0 - 1.00.5The ratio between the on and off state of a rectangular function within a period; if the value is negative, the function is switched off at the start of a period

Function for the production of messages

This function can generally be used to produce several specified string or byte array messages. For this purpose, it is advisable to specify the global parameter "startDate" as a UTC Zulu string and thus an absolute time base, as the production times of the messages are also specified in absolute terms.

A single JSON array "messages" of JSON objects is specified, these objects are parameterized as follows:

Parameter NameRequiredData TypeMeaningful Value RangeDefaultDescription
timestampYESSTRINGZulu UTC StringAbsolute production time
textJASTRINGText of the message (always UTF-8 encoded)

Function for the production of discrete data points 'datapoints'

This function can generally be used to produce several specified data points (samples) of SCALARER and DATA TYPES SHOWABLE IN JSON. For this purpose, it is advisable to specify the global parameter "startDate" as a UTC Zulu string and thus an absolute time base, as the production times of the data points are also specified in absolute terms.

A single JSON array "datapoints" of JSON objects is specified, these objects are parameterized as follows:

Parameter NameRequiredData TypeMeaningful Value RangeDefaultDescription
timestampYESSTRINGZulu UTC StringAbsolute production time
valueYES...Value of the data point represented in JSON

Function for the production of 3D GPS locations 'gpslocations'

This function can usually be used to produce several specified GPS locations. For this purpose, it is advisable to specify the global parameter "startDate" as a UTC Zulu string and thus an absolute time base, as the production times of the GPS locations are also specified in absolute terms.

A single JSON array "gpslocations" of JSON objects is specified, these objects are parameterized as follows:

Parameter nameRequiredData typeMeaningful value rangeDefaultDescription
timestampYESSTRINGZulu UTC StringAbsolute production time
latitudeJAFLOATlatitude
longitudeJAFLOATlongitude
altitudeJAFLOATgeographic altitude

Module information

InformationValue
AuthorsoptiMEAS Measurement and Automation Systems GmbH
since smartCORE0.1
Module typeProducer
DependenciesNONE