public final class IrSignal extends Object implements Cloneable
The "count" semantic: The "count" argument in functions like toModulatedIrSequece(int count) is interpreted like this: If the intro sequence is null, then "count" copies or the repeat sequence are used, otherwise count-1. It is believed that this interpretation is consistent with the heuristic meaning of 'sending a signal "count" times'.
The "repetitions" semantic: "repetition" number of copies of the repeat sequence are used.
This class is immutable.
IrSequence| Modifier and Type | Class and Description |
|---|---|
static class |
IrSignal.Pass |
| Constructor and Description |
|---|
IrSignal()
Constructs an IrSignal of zero length.
|
IrSignal(int[] durations,
int noIntro,
int noRepeat,
double frequency)
Constructs an IrSignal from its arguments.
|
IrSignal(int[] durations,
int noIntro,
int noRepeat,
Double frequency,
Double dutyCycle)
Constructs an IrSignal from its arguments.
|
IrSignal(IrSequence introSequence,
Double frequency,
Double dutyCycle)
Constructs an IrSignal from its arguments.
|
IrSignal(IrSequence irSequence,
int noIntro,
int noRepeat,
Double frequency,
Double dutyCycle) |
IrSignal(IrSequence introSequence,
IrSequence repeatSequence,
IrSequence endingSequence,
Double frequency)
Constructs an IrSignal from its arguments.
|
IrSignal(IrSequence introSequence,
IrSequence repeatSequence,
IrSequence endingSequence,
Double frequency,
Double dutyCycle)
Constructs an IrSignal from its arguments.
|
IrSignal(IrSignal irSignal,
Double newFrequency) |
IrSignal(ModulatedIrSequence introSequence)
Convenience constructor for IrSignals having only an intro sequence.
|
IrSignal(ModulatedIrSequence sequence,
int beginningLength,
int repeatLength,
int noRepeats)
Constructs an IrSignal.
|
IrSignal(String introSequence,
String repeatSequence,
String endingSequence,
Double frequency,
Double dutyCycle)
Constructs an IrSignal from its arguments.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
approximatelyEquals(IrSignal irSignal)
Compares two ModulatedIrSequences for (approximate) equality.
|
boolean |
approximatelyEquals(IrSignal irSignal,
double absoluteTolerance,
double relativeTolerance,
double frequencyTolerance)
Compares two ModulatedIrSequences for (approximate) equality.
|
IrSignal |
clone() |
boolean |
containsZeros()
Returns true if and only if the sequence contains durations of zero length.
|
double |
getDouble(IrSignal.Pass pass,
int i) |
double |
getDuration(int count)
Computes the duration in microseconds of the intro sequence,
repetitions repeats of the repeat sequence, plus the ending sequence.
|
Double |
getDutyCycle() |
double |
getEndingDouble(int i) |
int[] |
getEndingInts() |
int |
getEndingLength() |
int[] |
getEndingPulses()
Returns the data in the intro sequence, as a sequence of pulses in the used frequency.
|
ModulatedIrSequence |
getEndingSequence() |
Double |
getFrequency() |
String |
getFrequencyAsString() |
Double |
getFrequencyWithDefault() |
double |
getGap()
Returns max gap of intro- and repeat sequences.
|
double |
getIntroDouble(int i)
Returns the i'th data in the intro sequence, as double.
|
int[] |
getIntroInts()
Returns the data in the intro sequence, as a sequence of microsecond durations.
|
int |
getIntroLength()
Returns length of Intro sequence, in number of flashes and gaps.
|
int[] |
getIntroPulses()
Returns the data in the intro sequence, as a sequence of pulses in the used frequency.
|
ModulatedIrSequence |
getIntroSequence() |
int |
getLength(IrSignal.Pass pass) |
double |
getRepeatDouble(int i) |
int[] |
getRepeatInts() |
int |
getRepeatLength() |
int[] |
getRepeatPulses()
Returns the data in the intro sequence, as a sequence of pulses in the used frequency.
|
ModulatedIrSequence |
getRepeatSequence() |
double |
getTotalDuration()
Computes the duration in microseconds of the intro sequence,
one repeat sequence, plus the ending sequence.
|
boolean |
introOnly() |
boolean |
isEmpty() |
boolean |
repeatOnly() |
int |
repeatsPerCountSemantic(int count)
Returns the number of repetitions according to the count semantics.
|
void |
replaceZeros(double replacement)
Replace all zero durations.
|
void |
replaceZeros(int replacement)
Replace all zero durations.
|
int[] |
toIntArray(int i) |
List<IrSequence> |
toIrSequences() |
ModulatedIrSequence |
toModulatedIrSequence()
Returns a ModulatedIrSequence consisting of one intro sequence,
one repeat sequence, followed by one ending sequence.
|
ModulatedIrSequence |
toModulatedIrSequence(boolean intro,
int repetitions,
boolean ending)
Returns a ModulatedIrSequence consisting of zero or one intro sequence,
repetition number of repeat sequence, and zero or one ending sequence.
|
ModulatedIrSequence |
toModulatedIrSequence(int count)
Returns a ModulatedIrSequence consisting of one intro sequence,
count or count-1 number of repeat sequence, dependent on if intro is empty or not, followed by one ending sequence.
|
IrSignal |
toOneShot(int count)
Returns an IrSignal consisting of count repetitions (count semantic) as the intro sequence,
while repeat and ending are empty.
|
String |
toString() |
String |
toString(boolean alternatingSigns)
Generates nice string.
|
public static final IrSignal EMPTY
public IrSignal(IrSequence introSequence, IrSequence repeatSequence, IrSequence endingSequence, Double frequency, Double dutyCycle)
frequency - dutyCycle - introSequence - repeatSequence - endingSequence - public IrSignal(String introSequence, String repeatSequence, String endingSequence, Double frequency, Double dutyCycle) throws OddSequenceLengthException
frequency - dutyCycle - introSequence - repeatSequence - endingSequence - OddSequenceLengthExceptionpublic IrSignal(IrSequence introSequence, Double frequency, Double dutyCycle)
introSequence - frequency - dutyCycle - public IrSignal(IrSequence introSequence, IrSequence repeatSequence, IrSequence endingSequence, Double frequency)
frequency - introSequence - repeatSequence - endingSequence - public IrSignal(ModulatedIrSequence introSequence)
introSequence - public IrSignal(ModulatedIrSequence sequence, int beginningLength, int repeatLength, int noRepeats) throws InvalidArgumentException
sequence - beginningLength - Length of the intro sequencerepeatLength - Length of the repeat sequencenoRepeats - Number of occurrences of the repeat sequenceInvalidArgumentExceptionpublic IrSignal(int[] durations,
int noIntro,
int noRepeat,
double frequency)
throws InvalidArgumentException
durations - noIntro - noRepeat - frequency - InvalidArgumentExceptionpublic IrSignal(int[] durations,
int noIntro,
int noRepeat,
Double frequency,
Double dutyCycle)
throws InvalidArgumentException
durations - Integer array of durations. Signs of the entries are ignored,noIntro - Number of entries belonging to the intro sequence.noRepeat - Number of entries belonging to the repeat sequence.frequency - Modulation frequency in Hz. Use null for defaultdutyCycle - Duty cycle of modulation pulse, between 0 and 1. Use null for not specified.InvalidArgumentExceptionpublic IrSignal(IrSequence irSequence, int noIntro, int noRepeat, Double frequency, Double dutyCycle) throws InvalidArgumentException
InvalidArgumentExceptionpublic IrSignal()
public Double getFrequency()
public Double getFrequencyWithDefault()
public Double getDutyCycle()
public int getIntroLength()
IrSequencepublic int[] getIntroInts()
IrSequencepublic double getIntroDouble(int i)
i - indexIrSequencepublic int[] getIntroPulses()
IrSequencepublic int getRepeatLength()
public int[] getRepeatInts()
public double getRepeatDouble(int i)
public int[] getRepeatPulses()
IrSequencepublic int getEndingLength()
public int[] getEndingInts()
public double getEndingDouble(int i)
public int[] getEndingPulses()
IrSequencepublic double getTotalDuration()
public double getDuration(int count)
count - Uses count semantic.public double getDouble(IrSignal.Pass pass, int i)
public int getLength(IrSignal.Pass pass)
public boolean introOnly()
public boolean repeatOnly()
public String toString(boolean alternatingSigns)
alternatingSigns - if true generate alternating signs, otherwise remove signs.public String getFrequencyAsString()
public int repeatsPerCountSemantic(int count)
count - public boolean isEmpty()
public boolean containsZeros()
public void replaceZeros(double replacement)
replacement - Duration in micro seconds to replace zero durations with.public void replaceZeros(int replacement)
replacement - Duration in pulses to replace zero durations with.
If frequency == 0, interpret as microseconds instead.public double getGap()
public ModulatedIrSequence toModulatedIrSequence()
public ModulatedIrSequence toModulatedIrSequence(int count)
count - Number of times to send signal. Must be > 0.public ModulatedIrSequence toModulatedIrSequence(boolean intro, int repetitions, boolean ending)
intro - inclusion of intro sequence?repetitions - number of repetitions (repeat semantic)ending - inclusion of ending sequence.public List<IrSequence> toIrSequences()
public IrSignal toOneShot(int count)
count - Number of times to send signal. Must be > 0.public boolean approximatelyEquals(IrSignal irSignal, double absoluteTolerance, double relativeTolerance, double frequencyTolerance)
irSignal - to be compared against this.absoluteTolerance - tolerance threshold in microseconds.relativeTolerance - relative threshold, between 0 and 1.frequencyTolerance - tolerance (absolute) for frequency in Hz.public boolean approximatelyEquals(IrSignal irSignal)
irSignal - to be compared against this.public ModulatedIrSequence getIntroSequence()
public ModulatedIrSequence getRepeatSequence()
public ModulatedIrSequence getEndingSequence()
public int[] toIntArray(int i)
Copyright © 2019. All rights reserved.