# Signal Calculation Service¶

## Idea¶

The Signal Calculation Service processes sensor time series data of an entity. The service aggregates, modifies, smoothes and transforms the original sensor data for further analysis or storage along with the original data.

The service enables a user to carry out following tasks:

• Detect missing sensor values.
• Replace missing sensor values with interpolated ones.
• Compute a new physical parameter from available sensor readings.
• Aggregate sensor values over a sliding window.

## Basics¶

In addition to one or multiple time series (original sensor data in IoT model format) as input, the service uses a specific configuration for the signal calculation. The configuration information consists of the following parts:

• Operation
A common operation for processing the time series
• Parameter
Parameters of the operation
• Operands
A set of operands, each defining the entity, the property set and the property of the time series data to operate on.
• Result
Defines the output format as an IoT model time series: Entity, property set and property of the resulting time series.

The service executes the operation on the original sensor data and responds with the calculated time series (so-called soft sensors).

### Operations¶

The Signal Calculation Service executes the following operations:

• One-argument mathematics
• Absolute: Absolute value of a numeric value
• Lg: Logarithm in base 10 value of a numeric value
• Ln: Logarithm in base e value of a numeric value
• Exp: Exponential value of a numeric value
• Cos: Cosine value of a numeric value
• ArcCos: Arc cosine value of a numeric value
• Cosh: Cosine hyperbolic value of a numeric value
• Sin: Sine value of a numeric value
• ArcSin: Arc sine value of a numeric value
• Sinh: Sine hyperbolic value of a numeric value
• Tan: Tangent value of a numeric value
• ArcTan: Arc tangent value of a numeric value
• Tanh: Tangent hyperbolic value of a numeric value
• Sqrt: Square root value of a numeric value
• Not: Negation value of a numeric value
• IsNull: Checks if null
• SignNegation: Changes the sign of a numeric value
• Two-arguments mathematics
• Subtract: Subtracts two numeric values
• Multiply: Multiplies two numeric values
• Divide: Divides two numeric values
• Power: Raises the first Operand to the power of the second
• LessThan: Compares two numeric values
• GreaterThan: Compares two numeric values
• GreaterThanOrEquals: Compares two numeric values
• LessThanOrEquals: Compares two numeric values
• Equals: Checks if two values are equal
• NotEquals: Checks if two values are not equal
• And: Applies boolean logic on two values
• Or: Applies boolean logic on two values
• Multiple arguments mathematics
• Min: Compares multiple numeric values and generates minimum
• Max: Compares multiple numeric values and generates maximum
• Mean: Generates mean of multiple numeric values
• Median: Generates median of multiple numeric values
• Sum: Generates sum of multiple numeric values
• Filter
Removes all entries of a time series where the selected boolean property is set to "true".
• Merge
Merges two or more time series. The output time series will contain existing time stamps plus new "interpolated" time stamps, depending on the selected mode:
• Last-Non-Null
If a non-synchronized time stamp is found, then for each time series the last non-null value is taken for the new time stamp.
• Linear-Interpolation
If a non-synchronized time stamp is found, then for each time series the interpolated value between the latest two consecutive values is taken for the new time stamp.
• Resample
Obtain interpolated values from existing time series data at specific and equidistant, user defined timestamps
• Constants
Uses constants for applying other operations
• Constants
Converts a features type into another type
• One-argument String
• Capitalize: Makes the first letter of a string uppercase
• LowerCase: Makes all letters of a string lowercase
• UpperCase: Makes all letters of a string uppercase
• Md5Checksum: Generates the MD5 hash of a string
• RemoveDiacritic: Deletes the diacritic characters from a string
• RemoveDuplicates: Deletes the duplicated characters from a string
• Reverse: Reverses the order of characters from a string
• ToEmpty: Converts the string to empty string
• Length: Returns the number of characters of a string.
• Two-arguments String
• CapitalizeBy: Converts the second operand to uppercase on the first operand
• RemoveChars: Removes the second parameter from the first one
• Concat: Concatenates two strings
• Compare: Compares two strings
• RegexMatcher: Checks if a string (first argument) respects a given regex (second parameters) and return a Boolean value.
• Count: Returns the number of appearances of the second parameter into the first operand
• IndexOf: Returns the index of the second argument into the first one
• LastIndexOfChar: Returns the last index of the second argument into the first one
• SubString: Returns a substring of first argument starting from the given index (second argument)
• Three-arguments String
• Replace: Searches on a string (first operand) a given string (second operand) and replaces it with a given string (third operand).
• RegexReplace: Searches on a string (first operand) a given regex (second operand) and replaces it with a given string (third operand).
• SubStringInterval: Returns a sub-string of a string (first operand) starting from the given start index (second operand) and end index (third operand).
• One-argument DateTime
• IsWeekend: Check if a DateTime is on a weekend.
• IsWorkDay: Check if a DateTime is on a work day.
• GetYears: Returns the number of years from a given DateTime.
• GetMonths: Returns the number of months from a given DateTime.
• GetDays: Returns the number of days from a given DateTime.
• GetHours: Returns the number of hours from a given DateTime.
• GetMinutes: Returns the number of minutes from a given DateTime.
• GetSeconds: Returns the number of seconds from a given DateTime.
• GetMilliseconds: Returns the number of milliseconds from a given DateTime.
• Two-arguments DateTime
• AddDateTime: The operation adds two DateTime values
• AddYears: Returns a new DateTime that adds the specified number of years to the value of the instance.
• AddMonths: Returns a new DateTime that adds the specified number of months to the value of the instance.
• AddDays: Returns a new DateTime that adds the specified number of days to the value of the instance.
• AddHours: Returns a new DateTime that adds the specified number of hours to the value of the instance.
• AddMinutes: Returns a new DateTime that adds the specified number of minutes to the value of the instance.
• AddSeconds: Returns a new DateTime that adds the specified number of seconds to the value of the instance.
• AddMilliseconds: Returns a new DateTime that adds the specified number of milliseconds to the value of the instance.
• SubtractDateTime: The operation subtracts two DateTime values and return milliseconds interval.
• SubtractYears: Returns a new DateTime that subtracts the specified number of years to the value of this instance.
• SubtractMonths: Returns a new DateTime that subtracts the specified number of months to the value of this instance.
• SubtractDays: Returns a new DateTime that subtracts the specified number of days to the value of this instance.
• SubtractHours: Returns a new DateTime that subtracts the specified number of hours to the value of this instance.
• SubtractMinutes: Returns a new DateTime that subtracts the specified number of minutes to the value of this instance.
• SubtractSeconds: Returns a new DateTime that subtracts the specified number of seconds to the value of this instance.
• SubtractMilliseconds: Returns a new DateTime that subtracts the specified number of milliseconds to the value of this instance.
• LessThanDateTime: The operations compares two DateTime values.
• GreaterThanDateTime: The operations compares two DateTime values.
• GreaterThanOrEqualsDateTime: The operations compares two DateTime values.
• EqualsDateTime: The operation checks if two DateTime values are or not equal
• NotEqualsDateTime: The operation checks if two DateTime values are or not equal
• Observation Windows and Aggregators
• Time window: Collects a consecutive sequence of entries from on a time interval and applies a list of aggregate functions
• Length window: Collects a consecutive sequence having a fix number of entries and applies a list of aggregate functions
• Delay
• Events based: Shifts to the right the events from the input with the specified number
• Time period based: Delays the time of the entries with the specified milliseconds received in the request
• Generator
• Continuous: Generates every given period of time a simple entry containing only the timestamp
• Temporal: Generates copies of the input entries based on the period parameter and number of events received as input

All operation inputs and outputs use one of the data types Integer64, Double or Boolean. If one of the operands is Null, the result is Null.

## Features¶

The Signal Calculation Service exposes its API for realizing the following tasks:

• Apply a mathematical operation to specified properties of time series.
• Filter time series by specified boolean properties.
• Merge multiple time series.

## Example Scenario¶

The manager of a brewery wants to calculate the average temperature of a component of his production line.

Collect time series data of the relevant temperature sensor of the production line using the IoT Time Series Service. Feed the Signal Caculation Service API with the time series of the desired time period and generate a median. Evaluate the resulting response.

### Requirements¶

• The production line is connected to MindSphere.