Class TriggerDetector

java.lang.Object
pl.polsl.rtsa.controller.TriggerDetector

public final class TriggerDetector extends Object
Rising-edge trigger for the oscilloscope view.
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    private
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static int
    findRisingEdge(double[] samples, double threshold)
    Find the first rising-edge crossing of threshold in samples.
    static int
    findRisingEdge(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.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • TriggerDetector

      private TriggerDetector()
  • Method Details

    • findRisingEdge

      public static int findRisingEdge(double[] samples, double threshold)
      Find the first rising-edge crossing of threshold in samples.
      Parameters:
      samples - voltage sample array
      threshold - trigger threshold voltage (V)
      Returns:
      index of the first sample at or just after the crossing, or -1 if 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 array
      threshold - 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 by findRisingEdge(double[], double)
      totalLen - total length of the sample array
      windowLen - desired number of visible samples
      Returns:
      int[2] = { startIdx, endIdx } clamped to [0, totalLen-1]