Operator Generator

Primitive operator image not displayed. Problem loading file: ../../image/tk$com.ibm.streams.timeseries/op$com.ibm.streams.timeseries.generators$Generator.svg

The Generator operator generates a sine, triangular, sawtooth, or a pulse train representation of a time series.

The Generator operator generates sine, triangular, sawtooth, or a pulse train signals that you can use as input for testing operators in the TimeSeries Toolkit. The generated signals are represented as a univariate or a vector time series.

Behavior in a consistent region

The Generator operator can be the start of a consistent region. The Generator operator can support both periodic and operator-driver regions.
  • If the consistent region trigger is periodic, drain processing will only be able to occur
once the current iteration has completed.
  • If the consistent region trigger is operator-driven, drain process will occur at the end
of each iteration. Note: If the samplingRate parameter is set to a small value, checkpointing will occur very frequently, which might cause application performance to degrade.

Exceptions

The Generator operator throws an exception in the following cases:

  • The value that is specified by the humpSize parameter is greater than 1.0 or less than 0.
  • The value that is specified by the samplingRate, frequency, or iterations parameter is 0.

Examples

The following example shows how to generate a sine signal:


composite Main {
  graph	
  stream<list<float64> data, list<int64> timeStamp> GenerateSineWaveListStream = Generator()
  {
	samplingRate: 60u;
    frequency   : 3.0;
    typeOfSignal: sine;
    output GenerateSineWaveStream: 
    	data=generatedTimeSeries();
  }

  () as writer1 = FileSink(GenerateSineWaveStream)
  {
    param
      file   : "sineWave.result";
      format : csv;
  }
}

Summary

Ports
This operator has 0 input ports and 1 output port.
Windowing
This operator does not accept any windowing configurations.
Parameters
This operator supports 8 parameters.

Required: frequency, samplingRate

Optional: amplitude, humpSize, initDelay, iterations, triggerCount, typeOfSignal

Metrics
This operator does not report any metrics.

Properties

Implementation
C++
Threading
Never - Operator never provides a single threaded execution context.

Output Ports

Assignments
This operator allows any SPL expression of the correct type to be assigned to output attributes.
Output Functions
GenFunct
<any T> T generatedTimeSeries()

Returns the generated samples either as a univariate or as a vector time series. The number of samples that are returned is equal to the sampling rate.

<any T> T AsIs(T v)

The default function for output attributes. By default, this function assigns the output attribute to the value of the input attribute with the same name.

Ports (0)

This port submits a tuple that contains the generated signal data. If the generatedTimeSeries output function is assigned to an attribute of type list<float64>, then a tuple that contains the entire generated signal is submitted. If the generatedTimeSeries output function is assigned to an attribute of type float64, then each tuple represents a single data point of the generated signal. Additional output tuple attributes are assigned from input attributes.

Properties

Parameters

Required: frequency, samplingRate

Optional: amplitude, humpSize, initDelay, iterations, triggerCount, typeOfSignal

amplitude

Specifies the amplitude of the generated wave. In the case of a pulse train wave, this will specify the height of the pulse.

Properties

frequency

Specifies the frequency (period) of the generated signal in Hertz. If the parameter value is 0, the compiler generates an error.

Properties

humpSize

Specifies the hump size of the generated pulse train wave. This parameter is valid only for pulse train signals and is ignored for other types of signals. The valid values are in the range 0 - 1.0. If the parameter value is 0, a flat pule train signal is generated with no hump.

Properties

initDelay

Specifies the initial waiting time in seconds before the operator starts generating the signals. The default value is 0f.

Properties

iterations

Specifies the number of signals to be generated. If this value is not specified, signals are generated indefinitely.

Properties

samplingRate

Specifies the sampling rate of the generated signal. The sampling rate is defined as the number of input time series used to represent a signal of one second. If this parameter value is 0u, the compiler generates an error.

Properties

triggerCount

Specifies the number of iterations that are submitted before the Generator operator starts to drain the pipeline and establish a conssitent state. The parameter must be greater than zero and must be set if the Generator operator is the start operator of an operatorDriven consisten region.

Properties

typeOfSignal
Specifies the type of the output wave form. The supported values are:
  • sine
  • triangular
  • sawtooth
  • pulsetrain

The amplitude of the generated sine, triangular, and sawtooth waves varies between +1 and -1. The default value is sine.

Properties

Code Templates

Generator

stream<${schema}> ${outputStream} = Generator() 
{
	param
		frequency: ${frequencyExpression};
		samplingRate: ${samplingRateExpression};
		iterations: ${iterationsExpression};
	output
		${outputStream}: ${outputExpression};
}
      

Libraries

No description for library.
Library Name: tsatapi
Library Path: ../../../impl/lib/
Include Path: ../../../impl/include
No description for library.
Library Name: types
Library Path: ../../../impl/lib/
Include Path: ../../../impl/include
No description for library.
Library Name: utils
Library Path: ../../../impl/lib/
Include Path: ../../../impl/include
No description for library.
Library Name: analytics
Library Path: ../../../impl/lib/
Include Path: ../../../impl/include