Class StreamHelper
-
- All Implemented Interfaces:
public class StreamHelper
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public classStreamHelper.GlitchRemovingResultContains durations without any glitch. It contains count of detected glitchs.
-
Field Summary
Fields Modifier and Type Field Description public final static intSPLITTER_DURATIONpublic final static doubleDURATION_TOLERANCEpublic final static intDEFAULT_GLITCH_VALUE_THRESHOLDpublic final static intDEFAULT_MAX_PULSE_VALUE
-
Constructor Summary
Constructors Constructor Description StreamHelper()
-
Method Summary
Modifier and Type Method Description static intgetCurrentGlitchThreshold()return used glitch threshold value in µs static intgetCurrentMaxPulseValueThreshold()Return used max pulse value threshold in µs static List<Integer>bitstreamToDurations(String bitstream, int samplingRate)Return a list of durations(in µs) and the first duration is the duration of a 1, not a 0 static intnumberOfBitsInDuration(int duration, int durationBit, double tolerance)Compute the number of bits in a duration, knowing the duration of 1 bit and a tolerance static StringreconstructRealBitstream(List<Integer> durations, int durationBit0, int durationBit1, double tolerance)Reconstruct a bitstream from a list of durations to the real datarate knowing the duration of the bits and a tolerance static List<List<Integer>>splitInCodewords(List<Integer> durations, int splitDuration)Method to split a list of durations in a list of codeword (a codeword is a list of duration also) static voidconvertDurationsUnsigned2Signed(boolean firstPolarity, List<Integer> durations)Convert an array of unsigned pulses to signed pulses the input is alterated by the method !! static StringconvertDurationsUnsigned2Signed(String durations, String separator)Convert a string which contains a suit of unsigned pulses to a string with signed pulses We consider that the first pulse is positive static List<Integer>convertLegacyRxDurationBytes2IntegerArray(Array<byte> bufferPulseWidths)static List<Integer>convertRxDurationBytes2IntegerArray(Array<byte> bufferPulseWidths)static RfDurationsconvertLegacyRxDurationBytes2Integer(Array<byte> bufferPulseWidths)static RfDurationsconvertRxDurationBytes2Integer(Array<byte> bufferPulseWidths)static List<Integer>concatenateDurations(List<Integer> durations)Return a new array, concatenated all consecutive pulses with the same polarity. static List<Integer>mergeRfDurations(List<out IPulses> durations)Concatenate all durations hosted by RfDurations in an arraylist. static voidupdateGlitchThresholdValue(int thresholdMicroSeconds)static voidupdateMaxPulseValueThreshold(int value)static StreamHelper.GlitchRemovingResultremoveGlitchsIfNeeded(List<Integer> durations)Remove glitchs hosted in given durations list. static booleanisGlitch(int duration)static booleanisBigPulse(int pulse)static RfDurationsbuildRfDurations(List<Integer> durations)from a list of durations, build a RfDurations object. -
-
Method Detail
-
getCurrentGlitchThreshold
static int getCurrentGlitchThreshold()
return used glitch threshold value in µs
-
getCurrentMaxPulseValueThreshold
static int getCurrentMaxPulseValueThreshold()
Return used max pulse value threshold in µs
-
bitstreamToDurations
static List<Integer> bitstreamToDurations(String bitstream, int samplingRate)
Return a list of durations(in µs) and the first duration is the duration of a 1, not a 0
-
numberOfBitsInDuration
static int numberOfBitsInDuration(int duration, int durationBit, double tolerance)
Compute the number of bits in a duration, knowing the duration of 1 bit and a tolerance
-
reconstructRealBitstream
static String reconstructRealBitstream(List<Integer> durations, int durationBit0, int durationBit1, double tolerance)
Reconstruct a bitstream from a list of durations to the real datarate knowing the duration of the bits and a tolerance
-
splitInCodewords
static List<List<Integer>> splitInCodewords(List<Integer> durations, int splitDuration)
Method to split a list of durations in a list of codeword (a codeword is a list of duration also)
- Parameters:
durations- List of durationssplitDuration- Minimum duration between 2 codewords
-
convertDurationsUnsigned2Signed
static void convertDurationsUnsigned2Signed(boolean firstPolarity, List<Integer> durations)
Convert an array of unsigned pulses to signed pulses the input is alterated by the method !! with a first polarity positive: [50, 100, 50, 100, 250] Result: [50, -100, 50, -100, 250]
-
convertDurationsUnsigned2Signed
static String convertDurationsUnsigned2Signed(String durations, String separator)
Convert a string which contains a suit of unsigned pulses to a string with signed pulses We consider that the first pulse is positive
-
convertLegacyRxDurationBytes2IntegerArray
static List<Integer> convertLegacyRxDurationBytes2IntegerArray(Array<byte> bufferPulseWidths)
-
convertRxDurationBytes2IntegerArray
static List<Integer> convertRxDurationBytes2IntegerArray(Array<byte> bufferPulseWidths)
-
convertLegacyRxDurationBytes2Integer
static RfDurations convertLegacyRxDurationBytes2Integer(Array<byte> bufferPulseWidths)
- Parameters:
bufferPulseWidths- 16 bits unsigned Pulse widths [Low byte first, high byte, Low byte, high byte, ...- Returns:
RfDurations
-
convertRxDurationBytes2Integer
static RfDurations convertRxDurationBytes2Integer(Array<byte> bufferPulseWidths)
- Parameters:
bufferPulseWidths- 16 bits signed Pulse widths [Low byte first, high byte, Low byte, high byte, ...- Returns:
RfDurations
-
concatenateDurations
static List<Integer> concatenateDurations(List<Integer> durations)
Return a new array, concatenated all consecutive pulses with the same polarity. Input: [-1, -1, +2, -1, +2, -1, 5, 5, 5, -3] Will return [-2, +2, -1, +2, -1, 15, -3]
-
mergeRfDurations
static List<Integer> mergeRfDurations(List<out IPulses> durations)
Concatenate all durations hosted by RfDurations in an arraylist.
-
updateGlitchThresholdValue
static void updateGlitchThresholdValue(int thresholdMicroSeconds)
-
updateMaxPulseValueThreshold
static void updateMaxPulseValueThreshold(int value)
-
removeGlitchsIfNeeded
static StreamHelper.GlitchRemovingResult removeGlitchsIfNeeded(List<Integer> durations)
Remove glitchs hosted in given durations list. Check unittests to see all supported cases. Example: [200] -> [200] [25] -> [25] [] -> [] [500, 250, 50, 100, 550, 400] -> [500, 400, 550, 400] [ +, -, +, -, +, -] -> [ +, -, +, -] [500, 500, 50, 025, 100, 100] -> [500, 675, 100] -> [500, 775] [ +, -, +, -, +, -] [ +, -, -] [ +, -]
-
isGlitch
static boolean isGlitch(int duration)
-
isBigPulse
static boolean isBigPulse(int pulse)
-
buildRfDurations
static RfDurations buildRfDurations(List<Integer> durations)
from a list of durations, build a RfDurations object.
-
-
-
-