4.2.3 Custom Condition |
The C:\Program Files\RAYLASE\ProcessDataAnalyzer\API\SampleCode\SampleApplications\CustomCondition implements the ICondition interface. It is a simple example of a custom condition that can be loaded in the Process Data Analyzer server and will check the signals against the implemented conditions. If the Check returns true, a trace is saved.
The parameters of each condition can be adapted from the Configurations.cs file. The implemented conditions are:
Pre-Condition: Must be valid for any of the conditions to apply: Laser power [%] must be within a pre-defined range and the gate must be active.
Condition 1: Trigger a trace when the commanded or the measured field position is within pre-defined squares while gate is on.
Condition 2: Trigger a trace when the difference between commanded and measured position is greater than a pre-defined threshold.
Condition 3: Trigger a trace when the commanded or measured velocity is greater than a pre-defined threshold.
This example application cannot be run "standalone" as the Process Data Analyzer server must be correctly configured and set up to use the CustomCondition.dll.
For a reference on how to configure the control cards and signals to be streamed, refer to the 4.2.2 Custom Trigger Streaming
To implement a custom condition DLL, the ICondition must be implemented. Create a new library project in C#/.NET, add a reference to the file C:\Program Files\RAYLASE\ProcessDataAnalyzer\API\Library\Protos\ICondition.cs and derive it in a new class.
The Initialize will be executed once when the condition is loaded in the Process Data Analyzer server. This example will read the JSON configuration file and create bigger chunks of the supplied detection area squares in order to speed up the position check.
The Check method is called on each new timestamp with all signals that changed at the current timestamp. If more timestamps are needed, they must be manually kept, processed and deleted. The method should return true if the condition is met. This will cause the Process Data Analyzer server to save a trace file with the configured length (see 4.2.2 Custom Trigger Streaming) to disc.
Since it is not ensured that all configured signals are available at each timestamp, the method must be able to handle missing signals. If virtual signals are used, refer to the VirtualSignal. Currently the mapping of virtual signals can only be done manually. The virtual signal index is part of the Process Data Analyzer's Configuration.json. Use the same virtual signal index in the condition to get the according configured virtual signal. For control card signals, refer to the BuiltInSignal enum for the possible signal names.