Table of Contents

Class RecorderModule

Namespace
Loehnert.Lisrt.IO.Beckhoff.Recording
Assembly
Loehnert.Lisrt.IO.Beckhoff.dll

Represents a module for recording IRecordable.

public class RecorderModule : LisrtModule, INotifyPropertyChangedEx, ILisrtModule, INotifyPropertyChanged, IHasServiceView
Inheritance
PropertyChangedBase
RecorderModule
Implements
INotifyPropertyChangedEx
Inherited Members
PropertyChangedBase.Refresh()
PropertyChangedBase.IsNotifying
PropertyChangedBase.PropertyChanged

Examples

This example shows the usage of the RecorderModule
// Create an ADS-IO Master and add an oversampling terminal for 100 kS/s
// and an analog input terminal for current.
var ioMaster = new EthercatAdsIOMasterModule("AdsMaster");

var oversamplingTerminal = new EL3702(samplesCount: 100, sampleCycleTimeInMicroSeconds: 10.0);
oversamplingTerminal.Inputs[0].Name = "Voltage1";

var analogInputTerminal = new EL3024();
analogInputTerminal.Inputs[2].Name = "Current1";
// Analog and digital non-oversampling inputs must be activated
analogInputTerminal.Inputs[2].IsRecordable = true;

ioMaster.Terminals.Add(new EK1200());
ioMaster.Terminals.Add(oversamplingTerminal);
ioMaster.Terminals.Add(analogInputTerminal);

// Create a recorder for the two required inputs
var channelsToRecord = new IRecordable[]
{
    oversamplingTerminal.Inputs[0],
    analogInputTerminal.Inputs[2],
};
var recorder = new RecorderModule("Recorder", channelsToRecord);

// Record 1000 milliseconds
var recordingTask = recorder.RecordAsync(recordTimeInMS: 1000);
var recordedWaveforms = recordingTask.Result;
IWaveform voltage1 = recordedWaveforms["Voltage1"];
This example shows how to record
var recordingTask = recorder.RecordAsync(recordTimeInMS: 1000);

// Do some stuff

recorder.Stop(); // only required if you want to stop before the record time elapsed
var waveformsByKey = recordingTask.Result;

// Do anything with the record. E. g. plot it into a window.
Plotter.Plot(waveformsByKey.Values);

Constructors

RecorderModule(string, IEnumerable<IRecordable>)

Initializes a new instance of the RecorderModule class.

public RecorderModule(string name, IEnumerable<IRecordable> recordables)

Parameters

name string

Name of the module.

recordables IEnumerable<IRecordable>

Recordable objects.

Exceptions

ArgumentNullException

Thrown when recordables is null.

ArgumentException

Thrown when an item of recordables is of type DigitalInput and the IsRecordable property is false or an item of recordables is of type RecordableAnalogInput and the IsRecordable property is false.

Properties

Icon

Gets an icon which is representative for the module.

public override Uri Icon { get; }

Property Value

Uri

Methods

RecordAsync(int)

Asynchronously records the recordables.

public Task<IReadOnlyDictionary<string, IWaveform>> RecordAsync(int recordTimeInMS)

Parameters

recordTimeInMS int

Time for recording in milliseconds.

Returns

Task<IReadOnlyDictionary<string, IWaveform>>

A Task representing the asynchronous recording.

Exceptions

ArgumentOutOfRangeException

Thrown when recordTimeInMS is 0 (zero) or less.

InvalidOperationException

Thrown when the recorder is still recording.

OperationCanceledException

Thrown when the task is canceled.

TimeBetweenPointsDiffersException

Thrown when the time spans between the points of a waveform aren't equal. This occurs, for example, if timing configuration of an oversampling input terminal (e.g. EL3702) is wrong.

RecordAsync(int, CancellationToken)

Asynchronously records the recordables.

public Task<IReadOnlyDictionary<string, IWaveform>> RecordAsync(int recordTimeInMS, CancellationToken cancellationToken)

Parameters

recordTimeInMS int

Time for recording in milliseconds.

cancellationToken CancellationToken

A cancellation token for canceling the recording task.

Returns

Task<IReadOnlyDictionary<string, IWaveform>>

A Task representing the asynchronous recording.

Exceptions

ArgumentOutOfRangeException

Thrown when recordTimeInMS is 0 (zero) or less.

InvalidOperationException

Thrown when the recorder is still recording.

OperationCanceledException

Thrown when the task is canceled.

TimeBetweenPointsDiffersException

Thrown when the time spans between the points of a waveform aren't equal. This occurs, for example, if timing configuration of an oversampling input terminal (e.g. EL3702) is wrong.

ShowServiceView()

Shows the service window.

public void ShowServiceView()

Stop()

Stops recording.

public void Stop()

Remarks

This method doesn't wait for the recording to finish. To await the recording use for example Wait() or Result of the task returned by RecordAsync(int).