java.lang.Object
pl.polsl.rtsa.controller.TriggerDetector
Rising-edge trigger for the oscilloscope view.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic intfindRisingEdge(double[] samples, double threshold) Find the first rising-edge crossing ofthresholdinsamples.static intfindRisingEdge(double[] samples, double threshold, int minIdx, int maxIdx) Find the first rising-edge crossing within a bounded search range.static int[]windowAroundTrigger(int triggerIdx, int totalLen, int windowLen) Extract the visible window around a trigger point.
-
Constructor Details
-
TriggerDetector
private TriggerDetector()
-
-
Method Details
-
findRisingEdge
public static int findRisingEdge(double[] samples, double threshold) Find the first rising-edge crossing ofthresholdinsamples.- Parameters:
samples- voltage sample arraythreshold- trigger threshold voltage (V)- Returns:
- index of the first sample at or just after the crossing,
or
-1if no rising edge was found
-
findRisingEdge
public static int findRisingEdge(double[] samples, double threshold, int minIdx, int maxIdx) Find the first rising-edge crossing within a bounded search range.Use this overload to guarantee the crossing leaves enough room for an unclamped window (so the trigger display is perfectly stable).
- Parameters:
samples- voltage sample arraythreshold- trigger threshold voltage (V)minIdx- earliest index to consider (inclusive, ≥ 1)maxIdx- latest index to consider (exclusive)- Returns:
- index of the first qualifying crossing, or
-1
-
windowAroundTrigger
public static int[] windowAroundTrigger(int triggerIdx, int totalLen, int windowLen) Extract the visible window around a trigger point.Returns the start and end indices (inclusive) of a sub-array centred on the trigger crossing. The window size is determined by the total number of samples divided by the zoom factor.
- Parameters:
triggerIdx- index returned byfindRisingEdge(double[], double)totalLen- total length of the sample arraywindowLen- desired number of visible samples- Returns:
- int[2] = { startIdx, endIdx } clamped to [0, totalLen-1]
-