Package org.harctoolbox.harchardware.ir
Class GirsClient<T extends ICommandLineDevice & IHarcHardware>
java.lang.Object
org.harctoolbox.harchardware.ir.GirsClient<T>
- Type Parameters:
T-
- All Implemented Interfaces:
Closeable,AutoCloseable,ICommandLineDevice,IHarcHardware,ICapture,IIrReader,IIrSenderStop,IRawIrSender,IRawIrSenderRepeat,IReceive,IRemoteCommandIrSender,ITransmitter
public class GirsClient<T extends ICommandLineDevice & IHarcHardware>
extends Object
implements IHarcHardware, IReceive, IRawIrSender, IRawIrSenderRepeat, IRemoteCommandIrSender, IIrSenderStop, ITransmitter, ICapture, ICommandLineDevice, Closeable
-
Field Summary
FieldsFields inherited from interface org.harctoolbox.harchardware.ir.IIrReader
DEFAULT_BEGIN_TIMEOUT, DEFAULT_CAPTURE_MAXSIZE, DEFAULT_ENDING_TIMEOUTFields inherited from interface org.harctoolbox.harchardware.ir.IRawIrSender
repeatMaxFields inherited from interface org.harctoolbox.harchardware.ir.IRemoteCommandIrSender
repeatMax -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionorg.harctoolbox.ircore.ModulatedIrSequencecapture()Listens to the device and returns a sequence.voidclose()static StringvoidString[]getCommands(String remote) Returns an array of command names for the remote given in the argument.intintlonggetParameter(String parameterName) String[]Returns an array of "remote" names.Returns a default Transmitter for the device.getTransmitter(String connector) Parses the String argument, and returns a transmitter accordingly.String[]Return possible name of transmitters, that are guaranteed to work with the getTransmitter(String).Returns the hardware version (not the version of the driver software).booleanbooleanbooleanbooleanisValid()Checks validity of an instance.static GirsClient<LocalSerialPortBuffered>newInstance(String portName, boolean verbose, Integer timeout) static GirsClient<TcpSocketPort>newInstance(InetAddress inetAddress, Integer portnumber, boolean verbose, Integer timeout) voidopen()Opens the device with previously set parameters.Reads a line of text.readString(boolean wait) Reads a line of text.booleanready()Tells whether this stream is ready to be read.org.harctoolbox.ircore.IrSequencereceive()Listens to the device and returns a sequence.voidreset()booleansendIr(org.harctoolbox.ircore.IrSignal irSignal, int count) booleansendIr(org.harctoolbox.ircore.IrSignal irSignal, int count, Transmitter transmitter) booleansendIrCommand(String remote, String command, int count, Transmitter transmitter) Sends the command to the hardware, to be sent count number of times.booleansendIrCommandRepeat(String remote, String command, Transmitter transmitter) Like sendIr, but sends the IR signal until stopped by stopIr.booleansendIrRepeat(org.harctoolbox.ircore.IrSignal irSignal, Transmitter transmitter) Like sendCcf, but continues the transmission until interrupted by a stopIr command.voidsendString(String cmd) Sends a command (a String) to the instance.voidsetBeginTimeout(int beginTimeout) voidsetCaptureMaxSize(int maxCaptureLength) voidsetDebug(int debug) Sets a debug parameter.voidsetEndingTimeout(int endingTimeout) voidsetFallbackFrequency(int fallbackFrequency) voidvoidsetLed(int led, boolean state) voidsetLineEnding(String lineEnding) voidsetParameter(String parameterName, int newValue) voidsetTimeout(int timeout) Deprecated.voidvoidsetUseReceiveForCapture(boolean val) voidsetVerbose(boolean verbose) Sets a verbosity flag, causing commands to be executed verbosely.booleanSignals the capturing device that it should stop capturing.booleanstopIr(Transmitter transmitter) Stops ongoing IR transmission.booleanSignals the receiving device that it should stop receiving.void
-
Field Details
-
DEFAULT_BAUD
public static final int DEFAULT_BAUD- See Also:
-
DEFAULT_PORT
public static final int DEFAULT_PORT- See Also:
-
-
Constructor Details
-
GirsClient
- Throws:
HarcHardwareExceptionIOException
-
-
Method Details
-
newInstance
public static GirsClient<TcpSocketPort> newInstance(InetAddress inetAddress, Integer portnumber, boolean verbose, Integer timeout) throws UnknownHostException, HarcHardwareException, IOException -
newInstance
public static GirsClient<LocalSerialPortBuffered> newInstance(String portName, boolean verbose, Integer timeout) throws IOException, HarcHardwareException - Throws:
IOExceptionHarcHardwareException
-
expandIP
-
setUseReceiveForCapture
- Throws:
HarcHardwareException
-
setUseReceiveForCapture
public void setUseReceiveForCapture() -
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
IOException
-
getVersion
Description copied from interface:IHarcHardwareReturns the hardware version (not the version of the driver software). May be null if no relevant information available.- Specified by:
getVersionin interfaceIHarcHardware- Returns:
- Version string. Semantics can vary.
- Throws:
IOException
-
setVerbose
public void setVerbose(boolean verbose) Description copied from interface:IHarcHardwareSets a verbosity flag, causing commands to be executed verbosely. Exact semantic depends on the implementation. Typically, all communication with the device is echoed to stderr.- Specified by:
setVerbosein interfaceIHarcHardware- Parameters:
verbose- on or off
-
setDebug
public void setDebug(int debug) Description copied from interface:IHarcHardwareSets a debug parameter. Exact semantic depends on the implementation.- Specified by:
setDebugin interfaceIHarcHardware
-
setTimeout
Deprecated.Description copied from interface:IHarcHardwareSet timeout in milliseconds. Exact semantics may be dependent on the hardware.- Specified by:
setTimeoutin interfaceIHarcHardware- Parameters:
timeout- Timeout in milliseconds.- Throws:
IOExceptionHarcHardwareException
-
getBeginTimeout
- Returns:
- the beginTimeout
-
setBeginTimeout
- Specified by:
setBeginTimeoutin interfaceIIrReader- Parameters:
beginTimeout- the beginTimeout to set- Throws:
IOExceptionHarcHardwareException
-
getMaxCaptureLength
public int getMaxCaptureLength()- Returns:
- the maxCaptureLength
-
setCaptureMaxSize
- Specified by:
setCaptureMaxSizein interfaceIIrReader- Parameters:
maxCaptureLength- the maxCaptureLength to set- Throws:
IOExceptionHarcHardwareException
-
getEndingTimeout
public int getEndingTimeout()- Returns:
- the endingTimeout
-
setEndingTimeout
- Specified by:
setEndingTimeoutin interfaceIIrReader- Parameters:
endingTimeout- the endingTimeout to set- Throws:
IOExceptionHarcHardwareException
-
setLineEnding
- Parameters:
lineEnding- the lineEnding to set
-
isValid
public boolean isValid()Description copied from interface:IHarcHardwareChecks validity of an instance. Exact meaning can vary.- Specified by:
isValidin interfaceIHarcHardware- Returns:
- validity of the instance.
-
getModules
-
hasModule
-
hasCaptureModule
public boolean hasCaptureModule() -
hasTransmitModule
public boolean hasTransmitModule() -
setFallbackFrequency
public void setFallbackFrequency(int fallbackFrequency) - Parameters:
fallbackFrequency- the fallbackFrequency to set
-
sendIr
public boolean sendIr(org.harctoolbox.ircore.IrSignal irSignal, int count, Transmitter transmitter) throws IOException, HarcHardwareException - Specified by:
sendIrin interfaceIRawIrSender- Returns:
- if false, command failed.
- Throws:
IOExceptionNoSuchTransmitterExceptionHarcHardwareException
-
sendIr
public boolean sendIr(org.harctoolbox.ircore.IrSignal irSignal, int count) throws IOException, HarcHardwareException - Throws:
IOExceptionHarcHardwareException
-
open
Description copied from interface:IHarcHardwareOpens the device with previously set parameters.- Specified by:
openin interfaceIHarcHardware- Throws:
IOExceptionHarcHardwareException
-
waitFor
public void waitFor(String goal, String areUThere, int delay, int tries) throws IOException, HarcHardwareException - Throws:
IOExceptionHarcHardwareException
-
capture
public org.harctoolbox.ircore.ModulatedIrSequence capture() throws IOException, HarcHardwareException, org.harctoolbox.ircore.OddSequenceLengthExceptionDescription copied from interface:ICaptureListens to the device and returns a sequence. Requires the device to be previously opened. Should itself neither open or close the device.- Specified by:
capturein interfaceICapture- Returns:
- Captured sequence, or null by timeout.
- Throws:
IOExceptionHarcHardwareException- if the device is not in valid/open state.org.harctoolbox.ircore.OddSequenceLengthException
-
stopCapture
public boolean stopCapture()Description copied from interface:ICaptureSignals the capturing device that it should stop capturing. May not be implemented in all hardware.- Specified by:
stopCapturein interfaceICapture- Returns:
- status
-
receive
Description copied from interface:IReceiveListens to the device and returns a sequence. Requires the device to be previously opened. Should itself neither open or close the device.- Specified by:
receivein interfaceIReceive- Returns:
- Captured sequence, or null by timeout.
- Throws:
HarcHardwareException- if the device is not in valid/open state.IOException
-
stopReceive
public boolean stopReceive()Description copied from interface:IReceiveSignals the receiving device that it should stop receiving. May not be implemented in all hardware.- Specified by:
stopReceivein interfaceIReceive- Returns:
- status
-
reset
- Throws:
IOExceptionHarcHardwareException
-
sendString
Description copied from interface:ICommandLineDeviceSends a command (a String) to the instance.- Specified by:
sendStringin interfaceICommandLineDevice- Parameters:
cmd- Command string to be sent.- Throws:
IOExceptionHarcHardwareException
-
readString
Description copied from interface:ICommandLineDeviceReads a line of text. A line is considered to be terminated by any one of a line feed ('\n'), a carriage return ('\r'), or a carriage return followed immediately by a linefeed.- Specified by:
readStringin interfaceICommandLineDevice- Returns:
- A String containing the contents of the line, not including any line-termination characters, or null if no input available.
- Throws:
IOException
-
readString
Description copied from interface:ICommandLineDeviceReads a line of text. A line is considered to be terminated by any one of a line feed ('\n'), a carriage return ('\r'), or a carriage return followed immediately by a linefeed.- Specified by:
readStringin interfaceICommandLineDevice- Parameters:
wait- if true, wait until something arrives, otherwise return null if nothing there.- Returns:
- A String containing the contents of the line, not including any line-termination characters, or null if no input available.
- Throws:
IOException
-
ready
Description copied from interface:ICommandLineDeviceTells whether this stream is ready to be read. A buffered character stream is ready if the buffer is not empty, or if the underlying character stream is ready.- Specified by:
readyin interfaceICommandLineDevice- Returns:
- True if the next read() is guaranteed not to block for input, false otherwise. Note that returning false does not guarantee that the next read will block.
- Throws:
IOException- If an I/O error occurs
-
flushInput
- Specified by:
flushInputin interfaceICommandLineDevice- Throws:
IOException
-
getTransmitter
Description copied from interface:IRawIrSenderReturns a default Transmitter for the device. May be null if the device ignores the Transmitter argument in sendIr.- Specified by:
getTransmitterin interfaceIRawIrSender- Specified by:
getTransmitterin interfaceIRemoteCommandIrSender- Specified by:
getTransmitterin interfaceITransmitter- Returns:
- Transmitter
-
stopIr
Description copied from interface:IIrSenderStopStops ongoing IR transmission.- Specified by:
stopIrin interfaceIIrSenderStop- Returns:
- if false, command failed.
- Throws:
NoSuchTransmitterExceptionIOException
-
getTransmitter
Description copied from interface:ITransmitterParses the String argument, and returns a transmitter accordingly. Syntax and semantics may vary.- Specified by:
getTransmitterin interfaceITransmitter- Parameters:
connector- String describing desired port. Syntax is dependent on the implementing class.- Returns:
- Transmitter
- Throws:
NoSuchTransmitterException
-
getTransmitterNames
Description copied from interface:ITransmitterReturn possible name of transmitters, that are guaranteed to work with the getTransmitter(String). This may be generated by inquiring the device, producing correct result, or it may be some static function, describing transmitters not necessarily present on the actually deployed device.- Specified by:
getTransmitterNamesin interfaceITransmitter- Returns:
- Array of strings that are guaranteed to work with the getTransmitter(String)
-
sendIrRepeat
public boolean sendIrRepeat(org.harctoolbox.ircore.IrSignal irSignal, Transmitter transmitter) throws NoSuchTransmitterException, IOException Description copied from interface:IRawIrSenderRepeatLike sendCcf, but continues the transmission until interrupted by a stopIr command. Particular implementations, or hardware, might limit the number of transmissions, though.- Specified by:
sendIrRepeatin interfaceIRawIrSenderRepeat- Returns:
- if false, command failed.
- Throws:
NoSuchTransmitterExceptionIOException
-
getRemotes
Description copied from interface:IRemoteCommandIrSenderReturns an array of "remote" names.- Specified by:
getRemotesin interfaceIRemoteCommandIrSender- Returns:
- Throws:
IOException
-
getCommands
Description copied from interface:IRemoteCommandIrSenderReturns an array of command names for the remote given in the argument.- Specified by:
getCommandsin interfaceIRemoteCommandIrSender- Parameters:
remote- The "remote" to search in- Returns:
- Throws:
IOException
-
sendIrCommand
public boolean sendIrCommand(String remote, String command, int count, Transmitter transmitter) throws IOException, NoSuchTransmitterException Description copied from interface:IRemoteCommandIrSenderSends the command to the hardware, to be sent count number of times.- Specified by:
sendIrCommandin interfaceIRemoteCommandIrSendercount- Number of times to repeat the command- Returns:
- success
- Throws:
IOExceptionNoSuchTransmitterException
-
sendIrCommandRepeat
public boolean sendIrCommandRepeat(String remote, String command, Transmitter transmitter) throws IOException, NoSuchTransmitterException Description copied from interface:IRemoteCommandIrSenderLike sendIr, but sends the IR signal until stopped by stopIr. An implementation, or a hardware, may limit the number of repeats though.- Specified by:
sendIrCommandRepeatin interfaceIRemoteCommandIrSender- Returns:
- Throws:
IOExceptionNoSuchTransmitterException
-
setLed
- Throws:
IOExceptionHarcHardwareException
-
setLcd
- Throws:
IOExceptionHarcHardwareException
-
getParameter
- Throws:
IOExceptionHarcHardwareException
-
setParameter
public void setParameter(String parameterName, int newValue) throws IOException, HarcHardwareException - Throws:
IOExceptionHarcHardwareException
-