public class IrSignal extends Object
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 | Field and Description |
---|---|
protected double |
dutyCycle
Duty cycle of the modulation.
|
protected IrSequence |
endingSequence
Ending sequence, sent at the end of transmission.
|
protected double |
frequency
Modulation frequency in Hz.
|
protected IrSequence |
introSequence
Intro sequence, always sent once.
|
protected EnumMap<Pass,IrSequence> |
map
"Table" for mapping Pass to intro, repeat, or ending sequence.
|
protected IrSequence |
repeatSequence
Repeat sequence, sent after the intro sequence if the signal is repeating.
|
Constructor and Description |
---|
IrSignal()
Constructs an IrSignal of zero length.
|
IrSignal(double frequency,
double dutyCycle,
IrSequence introSequence,
IrSequence repeatSequence,
IrSequence endingSequence)
Constructs an IrSignal from its arguments.
|
IrSignal(double frequency,
double dutyCycle,
String introSequence,
String repeatSequence,
String endingSequence)
Constructs an IrSignal from its arguments.
|
IrSignal(int[] ccf)
Creates an IrSignal from a CCF array.
|
IrSignal(int[] durations,
int noIntroBursts,
int noRepeatBursts,
int frequency)
Constructs an IrSignal from its arguments.
|
IrSignal(int[] durations,
int noIntroBursts,
int noRepeatBursts,
int frequency,
double dutyCycle)
Constructs an IrSignal from its arguments.
|
IrSignal(IrpMaster irpMaster,
String protocolName,
HashMap<String,Long> parameters)
Constructs an IrSignal from its arguments.
|
IrSignal(String ccf)
Creates an IrSignal from a CCF string.
|
IrSignal(String[] ccf,
int begin)
Creates an IrSignal from a CCF array.
|
IrSignal(String protocolsIniPath,
int offset,
String... args)
Intended to construct an IrSignal from the args of a main-routine,
for example for exporting.
|
IrSignal(String protocolsIniPath,
String protocolName,
HashMap<String,Long> parameters)
Convenience version of the constructor with an IrpMaster instance.
|
IrSignal(String protocolsIniPath,
String protocolName,
String parameters)
Constructs an IrSignal from its arguments.
|
Modifier and Type | Method and Description |
---|---|
String |
ccfString()
Computes the CCF form, if possible.
|
boolean |
containsZeros()
Returns true if and only if the sequence contains durations of zero length.
|
double |
getDouble(Pass pass,
int i) |
double |
getDuration()
Computes the duration in microseconds of the intro sequence,
one repeat sequence, plus the ending sequence.
|
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() |
int |
getEndingBursts() |
double |
getEndingDouble(int i) |
int[] |
getEndingInts(boolean alternatingSigns) |
int |
getEndingLength() |
int[] |
getEndingPulses() |
ModulatedIrSequence |
getEndingSequence() |
double |
getFrequency() |
double |
getGap()
Returns max gap of intro- and repeat sequences.
|
int |
getIntroBursts()
Returns number of burst pairs in the intro sequence.
|
double |
getIntroDouble(int i)
Returns the i'th data in the intro sequence, as double.
|
int[] |
getIntroInts(boolean alternatingSigns)
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(Pass pass) |
int |
getRepeatBursts() |
double |
getRepeatDouble(int i) |
int[] |
getRepeatInts(boolean alternatingSigns) |
int |
getRepeatLength() |
int[] |
getRepeatPulses() |
ModulatedIrSequence |
getRepeatSequence() |
boolean |
isEmpty() |
boolean |
isEqual(IrSignal irSignal)
Compares two ModulatedIrSequences for (approximate) equality.
|
boolean |
isEqual(IrSignal irSignal,
double absoluteTolerance,
double relativeTolerance,
double frequencyTolerance)
Compares two ModulatedIrSequences for (approximate) equality.
|
static void |
main(String[] args)
Just for testing.
|
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()
Equivalent to toIntArray(1)
|
int[] |
toIntArray(int repetitions)
Returns an integer array of one intro sequence, repeat number of repeat sequence, followed by one ending sequence.
|
int[] |
toIntArrayCount(int count)
Returns an integer array 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.
|
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 |
toPrintString() |
String |
toPrintString(boolean alternatingSigns) |
String |
toPrintString(boolean alternatingSigns,
boolean noSigns,
String separator)
Analog to the IrSequence toPrintString.
|
String |
toString() |
String |
toString(boolean alternatingSigns)
Generates nice string.
|
protected IrSequence introSequence
protected IrSequence repeatSequence
protected IrSequence endingSequence
protected EnumMap<Pass,IrSequence> map
protected double frequency
protected double dutyCycle
public IrSignal(double frequency, double dutyCycle, IrSequence introSequence, IrSequence repeatSequence, IrSequence endingSequence)
frequency
- dutyCycle
- introSequence
- repeatSequence
- endingSequence
- public IrSignal(int[] durations, int noIntroBursts, int noRepeatBursts, int frequency)
durations
- noIntroBursts
- noRepeatBursts
- frequency
- public IrSignal(double frequency, double dutyCycle, String introSequence, String repeatSequence, String endingSequence) throws IncompatibleArgumentException
frequency
- dutyCycle
- introSequence
- repeatSequence
- endingSequence
- IncompatibleArgumentException
public IrSignal(int[] durations, int noIntroBursts, int noRepeatBursts, int frequency, double dutyCycle)
durations
- Integer array of durations. Signs of the entries are ignored,noIntroBursts
- Number of bursts (half the number of entries) belonging to the intro sequence.noRepeatBursts
- Number of bursts (half the number of entries) belonging to the intro sequence.frequency
- Modulation frequency in Hz.dutyCycle
- Duty cycle of modulation pulse, between 0 and 1. Use -1 for not specified.public IrSignal()
public IrSignal(String ccf) throws IrpMasterException
ccf
- String supposed to represent a valid CCF signal.IrpMasterException
- Error in CCFPronto
public IrSignal(int[] ccf) throws IrpMasterException
ccf
- Integer array supposed to represent a valid CCF signal.IrpMasterException
- Error in CCFPronto
public IrSignal(String[] ccf, int begin) throws IrpMasterException
begin
- starting indexccf
- String array supposed to represent a valid CCF signal.IrpMasterException
- Error in CCFPronto
public IrSignal(String protocolsIniPath, int offset, String... args) throws IrpMasterException, FileNotFoundException, UnassignedException
protocolsIniPath
- Path to Protocols.ini of the IrpMaster. There is no default.offset
- How many initial elements of the argument vector to ignore.args
- String array, typically the arguments of main.IrpMasterException
FileNotFoundException
UnassignedException
IrpMaster
,
Protocol
public IrSignal(String protocolsIniPath, String protocolName, HashMap<String,Long> parameters) throws FileNotFoundException, IrpMasterException
protocolsIniPath
- Path to IrpProtocols.iniprotocolName
- name of protocolparameters
- Dictionary of parameter valuesFileNotFoundException
IrpMasterException
public IrSignal(IrpMaster irpMaster, String protocolName, HashMap<String,Long> parameters) throws IrpMasterException
irpMaster
- protocolName
- name of protocolparameters
- Dictionary of parameter valuesIrpMasterException
public IrSignal(String protocolsIniPath, String protocolName, String parameters) throws FileNotFoundException, IrpMasterException
protocolsIniPath
- Path to IrpProtocols.iniprotocolName
- name of protocolparameters
- String of parameter assignments like "D=12 F=34"FileNotFoundException
IrpMasterException
public final double getFrequency()
public final double getDutyCycle()
public final int getIntroLength()
IrSequence
public final int getIntroBursts()
IrSequence
public final int[] getIntroInts(boolean alternatingSigns)
alternatingSigns
- IrSequence
public final int[] getIntroPulses()
IrSequence
public final double getIntroDouble(int i)
i
- indexIrSequence
public final int getRepeatLength()
public final int getRepeatBursts()
public final int[] getRepeatInts(boolean alternatingSigns)
public final int[] getRepeatPulses()
public final double getRepeatDouble(int i)
public final int getEndingLength()
public final int getEndingBursts()
public final int[] getEndingInts(boolean alternatingSigns)
public final int[] getEndingPulses()
public final double getEndingDouble(int i)
public final double getDuration()
public final double getDuration(int count)
count
- Uses count semantic.public final double getDouble(Pass pass, int i)
public final int getLength(Pass pass)
public String toString(boolean alternatingSigns)
alternatingSigns
- if true generate alternating signs, otherwise remove signs.public String toPrintString(boolean alternatingSigns, boolean noSigns, String separator)
alternatingSigns
- If true, generated signs will have alternating signs, ignoring original signs, otherwise signs are preserved.noSigns
- If true, suppress explict signsseparator
- separator between the numbersIrSequence
public String toPrintString(boolean alternatingSigns)
public String toPrintString()
public final int repeatsPerCountSemantic(int count)
count
- public final int[] toIntArray(int repetitions)
repetitions
- Number of times of to include the repeat sequence.public final int[] toIntArray()
public final int[] toIntArrayCount(int count)
count
- Number of times of the "signal" to send, according to the count semantic.public final boolean isEmpty()
public final boolean containsZeros()
public final 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 final double getGap()
public final ModulatedIrSequence toModulatedIrSequence(int count)
count
- Number of times to send signal. Must be > 0.public final 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 final IrSignal toOneShot(int count)
count
- Number of times to send signal. Must be > 0.public boolean isEqual(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 isEqual(IrSignal irSignal)
irSignal
- to be compared against this.public final ModulatedIrSequence getIntroSequence()
public final ModulatedIrSequence getRepeatSequence()
public final ModulatedIrSequence getEndingSequence()
public final String ccfString() throws IncompatibleArgumentException
IncompatibleArgumentException
Pronto
public static void main(String[] args)
args
- Copyright © 2016. All rights reserved.