Package org.harctoolbox.irp
Class Duration
java.lang.Object
org.harctoolbox.irp.IrpObject
org.harctoolbox.irp.Duration
- All Implemented Interfaces:
Serializable
,Floatable
,IrStreamItem
,XmlExport
This class implements Durations in Chapter 3 and 4.
Depends on its Protocol (GeneralSpec and NameEngine), except for this, it is immutable.
- See Also:
-
Field Summary
Modifier and TypeFieldDescriptionprotected NameOrNumber
protected Double
protected Double
protected String
protected Double
-
Constructor Summary
ModifierConstructorDescriptionprotected
Duration
(double us) protected
protected
Duration
(IrpParser.Name_or_numberContext ctx, String unit) protected
Duration
(NameOrNumber nameOrNumber, String unit) -
Method Summary
Modifier and TypeMethodDescriptionallDurationsInMicros
(GeneralSpec generalSpec, NameEngine nameEngine) Delivers a set of all the contained durations in microseconds.boolean
constant
(NameEngine nameEngine) void
decode
(RecognizeData recognizeData, List<BitSpec> bitSpecStack, boolean isLast) endingDurationType
(DurationType last, boolean gapFlashBitSpecs) boolean
double
evaluate
(GeneralSpec generalSpec, NameEngine nameEngine) double
evaluate
(GeneralSpec generalSpec, NameEngine nameEngine, double elapsed) void
evaluate
(RenderData renderData, List<BitSpec> bitSpecStack) protected abstract Duration
evaluatedDuration
(GeneralSpec generalSpec, NameEngine nameEngine) Deliver an "evaluated" Duration (variables resolved) of the same subclass.abstract double
evaluateWithSign
(GeneralSpec generalSpec, NameEngine nameEngine, double elapsed) extractPass
(IrSignal.Pass pass, IrStream.PassExtractorState state) double
getUnit()
guessParameterLength
(String name) Tries to infer the bit-length of the parameter with name as the argument.boolean
int
hashCode()
boolean
interleavingOk
(DurationType last, boolean gapFlashBitSpecs) boolean
interleavingOk
(DurationType toCheck, DurationType last, boolean gapFlashBitSpecs) final boolean
isEmpty
(NameEngine nameEngine) protected abstract boolean
isOn()
static boolean
isOn
(int index) microSeconds
(GeneralSpec generalSpec, NameEngine nameEngine) static Duration
newDuration
(String str) static Duration
static Duration
static Duration
newDuration
(ParserDriver parserDriver) boolean
Computes the number of encoded bits, which may differ from the number of payload bits, in the case of redundancy.Upper limit of the number of (interleaving) durations in the rendered signal.propertiesMap
(int noProperites) propertiesMap
(GeneralSpec generalSpec, NameEngine nameEngine) protected void
recognize
(RecognizeData recognizeData, double actual, double wanted, boolean isLast) void
render
(RenderData renderData, List<BitSpec> bitSpecs) startingDuratingType
(DurationType last, boolean gapFlashBitSpecs) double
toFloat
(GeneralSpec generalSpec, NameEngine nameEngine) Produces a floating result.toIrpString
(int radix) Returns a computed IRP (-segment) string representation of current IrpObject.int
weight()
Returns a (somewhat arbitrary) measure of the complexity of the object.Methods inherited from class org.harctoolbox.irp.IrpObject
createParameterSpecs, getParseTree, numberOfBitSpecs, numberOfInfiniteRepeats, prerender, propertiesMap, toDocument, toIrpString, toString, toString, toStringTree, toStringTree, toTreeViewer, toTreeViewer, toTreeViewer, updateStateWhenEntering, updateStateWhenExiting
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.harctoolbox.irp.IrStreamItem
createParameterSpecs, numberOfBitSpecs, numberOfInfiniteRepeats, propertiesMap, substituteConstantVariables, updateStateWhenEntering, updateStateWhenExiting
Methods inherited from interface org.harctoolbox.xml.XmlExport
toDocument
-
Field Details
-
us
-
time_periods
-
time_units
-
nameOrNumber
-
unit
-
-
Constructor Details
-
Duration
-
Duration
protected Duration(double us) -
Duration
-
Duration
-
-
Method Details
-
newDuration
-
newDuration
-
newDuration
-
newDuration
-
isOn
public static boolean isOn(int index) -
constant
- Specified by:
constant
in interfaceFloatable
- Specified by:
constant
in interfaceIrStreamItem
-
hashCode
public int hashCode() -
equals
-
evaluateWithSign
public abstract double evaluateWithSign(GeneralSpec generalSpec, NameEngine nameEngine, double elapsed) throws NameUnassignedException, IrpInvalidArgumentException -
evaluate
public double evaluate(GeneralSpec generalSpec, NameEngine nameEngine, double elapsed) throws NameUnassignedException, IrpInvalidArgumentException -
evaluate
public double evaluate(GeneralSpec generalSpec, NameEngine nameEngine) throws NameUnassignedException, IrpInvalidArgumentException -
evaluatedDuration
protected abstract Duration evaluatedDuration(GeneralSpec generalSpec, NameEngine nameEngine) throws NameUnassignedException, IrpInvalidArgumentException Deliver an "evaluated" Duration (variables resolved) of the same subclass.- Parameters:
generalSpec
-nameEngine
-- Returns:
- Throws:
NameUnassignedException
IrpInvalidArgumentException
-
isEmpty
public final boolean isEmpty(NameEngine nameEngine) throws NameUnassignedException, IrpInvalidArgumentException - Specified by:
isEmpty
in interfaceIrStreamItem
- Throws:
NameUnassignedException
IrpInvalidArgumentException
-
toFloat
public double toFloat(GeneralSpec generalSpec, NameEngine nameEngine) throws NameUnassignedException, IrpInvalidArgumentException Description copied from interface:Floatable
Produces a floating result.- Specified by:
toFloat
in interfaceFloatable
- Returns:
- Floating representation of class.
- Throws:
NameUnassignedException
IrpInvalidArgumentException
-
render
- Specified by:
render
in interfaceIrStreamItem
- Throws:
NameUnassignedException
-
decode
public void decode(RecognizeData recognizeData, List<BitSpec> bitSpecStack, boolean isLast) throws SignalRecognitionException - Specified by:
decode
in interfaceIrStreamItem
- Throws:
SignalRecognitionException
-
evaluate
public void evaluate(RenderData renderData, List<BitSpec> bitSpecStack) throws NameUnassignedException - Specified by:
evaluate
in interfaceIrStreamItem
- Throws:
NameUnassignedException
-
extractPass
- Specified by:
extractPass
in interfaceIrStreamItem
-
toElement
-
toIrpString
Description copied from class:IrpObject
Returns a computed IRP (-segment) string representation of current IrpObject. Numerical parameters, but not durations etc, will be printed using the radix in the argument.- Specified by:
toIrpString
in interfaceFloatable
- Specified by:
toIrpString
in interfaceIrStreamItem
- Specified by:
toIrpString
in classIrpObject
- Parameters:
radix
- Radix for parameters.- Returns:
- Formatted string.
-
numberOfBareDurations
- Specified by:
numberOfBareDurations
in interfaceIrStreamItem
-
numberOfDurations
Description copied from interface:IrStreamItem
Upper limit of the number of (interleaving) durations in the rendered signal. Only intended to be used on intro/repeat/ending IrStreams.- Specified by:
numberOfDurations
in interfaceIrStreamItem
- Returns:
- number of durations (not necessarily interleaving), or null if not possible to determine.
-
numberOfBits
Description copied from interface:IrStreamItem
Computes the number of encoded bits, which may differ from the number of payload bits, in the case of redundancy.- Specified by:
numberOfBits
in interfaceIrStreamItem
- Overrides:
numberOfBits
in classIrpObject
- Returns:
-
recognize
protected void recognize(RecognizeData recognizeData, double actual, double wanted, boolean isLast) throws SignalRecognitionException - Throws:
SignalRecognitionException
-
isOn
protected abstract boolean isOn() -
interleavingOk
- Specified by:
interleavingOk
in interfaceIrStreamItem
- Returns:
-
interleavingOk
- Specified by:
interleavingOk
in interfaceIrStreamItem
-
endingDurationType
- Specified by:
endingDurationType
in interfaceIrStreamItem
-
startingDuratingType
- Specified by:
startingDuratingType
in interfaceIrStreamItem
-
weight
public int weight()Description copied from class:IrpObject
Returns a (somewhat arbitrary) measure of the complexity of the object. Can be used for determining if a decode is "simpler" than another decode.- Specified by:
weight
in interfaceIrStreamItem
- Specified by:
weight
in classIrpObject
- Returns:
- non-negative integer.
-
getUnit
-
getTimeInUnits
- Throws:
InvalidArgumentException
-
hasExtent
public boolean hasExtent()- Specified by:
hasExtent
in interfaceIrStreamItem
-
assignmentVariables
- Specified by:
assignmentVariables
in interfaceIrStreamItem
-
propertiesMap
- Specified by:
propertiesMap
in interfaceIrStreamItem
-
microSeconds
- Specified by:
microSeconds
in interfaceIrStreamItem
-
nonConstantBitFieldLength
public boolean nonConstantBitFieldLength()- Specified by:
nonConstantBitFieldLength
in interfaceIrStreamItem
-
guessParameterLength
Description copied from interface:IrStreamItem
Tries to infer the bit-length of the parameter with name as the argument.- Specified by:
guessParameterLength
in interfaceIrStreamItem
- Parameters:
name
- Name of parameter sought.- Returns:
- length if success, null if failure.
-
allDurationsInMicros
Description copied from interface:IrStreamItem
Delivers a set of all the contained durations in microseconds. Dumb, in that it does not consider consecutive flashes or consecutive gaps. Also, durations that cannot be statically computed may be omitted, as well as duration arising from extents.- Specified by:
allDurationsInMicros
in interfaceIrStreamItem
- Returns:
-
numberOfBitSpecs
Integer numberOfBitSpecs() -
propertiesMap
-