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() |
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.
|
String |
toPrintString() |
String |
toPrintString(boolean alternatingSigns)
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 - IncompatibleArgumentExceptionpublic 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 CCFProntopublic IrSignal(int[] ccf)
throws IrpMasterException
ccf - Integer array supposed to represent a valid CCF signal.IrpMasterException - Error in CCFProntopublic IrSignal(String[] ccf, int begin) throws IrpMasterException
begin - starting indexccf - String array supposed to represent a valid CCF signal.IrpMasterException - Error in CCFProntopublic 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.IrpMasterExceptionFileNotFoundExceptionUnassignedExceptionIrpMaster,
Protocolpublic IrSignal(String protocolsIniPath, String protocolName, HashMap<String,Long> parameters) throws FileNotFoundException, IrpMasterException
protocolsIniPath - Path to IrpProtocols.iniprotocolName - name of protocolparameters - Dictionary of parameter valuesFileNotFoundExceptionIrpMasterExceptionpublic IrSignal(IrpMaster irpMaster, String protocolName, HashMap<String,Long> parameters) throws IrpMasterException
irpMaster - protocolName - name of protocolparameters - Dictionary of parameter valuesIrpMasterExceptionpublic 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"FileNotFoundExceptionIrpMasterExceptionpublic double getFrequency()
public double getDutyCycle()
public int getIntroLength()
IrSequencepublic int getIntroBursts()
IrSequencepublic int[] getIntroInts(boolean alternatingSigns)
alternatingSigns - IrSequencepublic int[] getIntroPulses()
IrSequencepublic double getIntroDouble(int i)
i - indexIrSequencepublic int getRepeatLength()
public int getRepeatBursts()
public int[] getRepeatInts(boolean alternatingSigns)
public int[] getRepeatPulses()
public double getRepeatDouble(int i)
public int getEndingLength()
public int getEndingBursts()
public int[] getEndingInts(boolean alternatingSigns)
public int[] getEndingPulses()
public double getEndingDouble(int i)
public double getDuration()
public double getDuration(int count)
count - Uses count semantic.public double getDouble(Pass pass, int i)
public int getLength(Pass pass)
public String toString(boolean alternatingSigns)
alternatingSigns - if true generate alternating signs, otherwise remove signs.public String toPrintString(boolean alternatingSigns)
alternatingSigns - If true, generated signs will have alternating signs, ignoring original signs, otherwise signs are preserved.IrSequencepublic String toPrintString()
public int repeatsPerCountSemantic(int count)
count - public int[] toIntArray(int repetitions)
repetitions - Number of times of to include the repeat sequence.public int[] toIntArray()
public int[] toIntArrayCount(int count)
count - Number of times of the "signal" to send, according to the count semantic.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(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 ModulatedIrSequence getIntroSequence()
public ModulatedIrSequence getRepeatSequence()
public ModulatedIrSequence getEndingSequence()
public String ccfString() throws IncompatibleArgumentException
IncompatibleArgumentExceptionProntopublic static void main(String[] args)
args - Copyright © 2015. All rights reserved.