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
Fields inherited from interface org.harctoolbox.harchardware.ir.IIrReader
DEFAULT_BEGIN_TIMEOUT, DEFAULT_CAPTURE_MAXSIZE, DEFAULT_ENDING_TIMEOUT
Fields inherited from interface org.harctoolbox.harchardware.ir.IRawIrSender
repeatMax
Fields inherited from interface org.harctoolbox.harchardware.ir.IRemoteCommandIrSender
repeatMax
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionorg.harctoolbox.ircore.ModulatedIrSequence
capture()
Listens to the device and returns a sequence.void
close()
static String
void
String[]
getCommands
(String remote) Returns an array of command names for the remote given in the argument.int
int
long
getParameter
(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).boolean
boolean
boolean
boolean
isValid()
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) void
open()
Opens the device with previously set parameters.Reads a line of text.readString
(boolean wait) Reads a line of text.boolean
ready()
Tells whether this stream is ready to be read.org.harctoolbox.ircore.IrSequence
receive()
Listens to the device and returns a sequence.void
reset()
boolean
sendIr
(org.harctoolbox.ircore.IrSignal irSignal, int count) boolean
sendIr
(org.harctoolbox.ircore.IrSignal irSignal, int count, Transmitter transmitter) boolean
sendIrCommand
(String remote, String command, int count, Transmitter transmitter) Sends the command to the hardware, to be sent count number of times.boolean
sendIrCommandRepeat
(String remote, String command, Transmitter transmitter) Like sendIr, but sends the IR signal until stopped by stopIr.boolean
sendIrRepeat
(org.harctoolbox.ircore.IrSignal irSignal, Transmitter transmitter) Like sendCcf, but continues the transmission until interrupted by a stopIr command.void
sendString
(String cmd) Sends a command (a String) to the instance.void
setBeginTimeout
(int beginTimeout) void
setCaptureMaxSize
(int maxCaptureLength) void
setDebug
(int debug) Sets a debug parameter.void
setEndingTimeout
(int endingTimeout) void
setFallbackFrequency
(int fallbackFrequency) void
void
setLed
(int led, boolean state) void
setLineEnding
(String lineEnding) void
setParameter
(String parameterName, int newValue) void
setTimeout
(int timeout) Deprecated.void
void
setUseReceiveForCapture
(boolean val) void
setVerbose
(boolean verbose) Sets a verbosity flag, causing commands to be executed verbosely.boolean
Signals the capturing device that it should stop capturing.boolean
stopIr
(Transmitter transmitter) Stops ongoing IR transmission.boolean
Signals 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:
HarcHardwareException
IOException
-
-
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:
IOException
HarcHardwareException
-
expandIP
-
setUseReceiveForCapture
- Throws:
HarcHardwareException
-
setUseReceiveForCapture
public void setUseReceiveForCapture() -
close
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Throws:
IOException
-
getVersion
Description copied from interface:IHarcHardware
Returns the hardware version (not the version of the driver software). May be null if no relevant information available.- Specified by:
getVersion
in interfaceIHarcHardware
- Returns:
- Version string. Semantics can vary.
- Throws:
IOException
-
setVerbose
public void setVerbose(boolean verbose) Description copied from interface:IHarcHardware
Sets 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:
setVerbose
in interfaceIHarcHardware
- Parameters:
verbose
- on or off
-
setDebug
public void setDebug(int debug) Description copied from interface:IHarcHardware
Sets a debug parameter. Exact semantic depends on the implementation.- Specified by:
setDebug
in interfaceIHarcHardware
-
setTimeout
Deprecated.Description copied from interface:IHarcHardware
Set timeout in milliseconds. Exact semantics may be dependent on the hardware.- Specified by:
setTimeout
in interfaceIHarcHardware
- Parameters:
timeout
- Timeout in milliseconds.- Throws:
IOException
HarcHardwareException
-
getBeginTimeout
- Returns:
- the beginTimeout
-
setBeginTimeout
- Specified by:
setBeginTimeout
in interfaceIIrReader
- Parameters:
beginTimeout
- the beginTimeout to set- Throws:
IOException
HarcHardwareException
-
getMaxCaptureLength
public int getMaxCaptureLength()- Returns:
- the maxCaptureLength
-
setCaptureMaxSize
- Specified by:
setCaptureMaxSize
in interfaceIIrReader
- Parameters:
maxCaptureLength
- the maxCaptureLength to set- Throws:
IOException
HarcHardwareException
-
getEndingTimeout
public int getEndingTimeout()- Returns:
- the endingTimeout
-
setEndingTimeout
- Specified by:
setEndingTimeout
in interfaceIIrReader
- Parameters:
endingTimeout
- the endingTimeout to set- Throws:
IOException
HarcHardwareException
-
setLineEnding
- Parameters:
lineEnding
- the lineEnding to set
-
isValid
public boolean isValid()Description copied from interface:IHarcHardware
Checks validity of an instance. Exact meaning can vary.- Specified by:
isValid
in 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:
sendIr
in interfaceIRawIrSender
- Returns:
- if false, command failed.
- Throws:
IOException
NoSuchTransmitterException
HarcHardwareException
-
sendIr
public boolean sendIr(org.harctoolbox.ircore.IrSignal irSignal, int count) throws IOException, HarcHardwareException - Throws:
IOException
HarcHardwareException
-
open
Description copied from interface:IHarcHardware
Opens the device with previously set parameters.- Specified by:
open
in interfaceIHarcHardware
- Throws:
IOException
HarcHardwareException
-
waitFor
public void waitFor(String goal, String areUThere, int delay, int tries) throws IOException, HarcHardwareException - Throws:
IOException
HarcHardwareException
-
capture
public org.harctoolbox.ircore.ModulatedIrSequence capture() throws IOException, HarcHardwareException, org.harctoolbox.ircore.OddSequenceLengthExceptionDescription copied from interface:ICapture
Listens to the device and returns a sequence. Requires the device to be previously opened. Should itself neither open or close the device.- Specified by:
capture
in interfaceICapture
- Returns:
- Captured sequence, or null by timeout.
- Throws:
IOException
HarcHardwareException
- if the device is not in valid/open state.org.harctoolbox.ircore.OddSequenceLengthException
-
stopCapture
public boolean stopCapture()Description copied from interface:ICapture
Signals the capturing device that it should stop capturing. May not be implemented in all hardware.- Specified by:
stopCapture
in interfaceICapture
- Returns:
- status
-
receive
Description copied from interface:IReceive
Listens to the device and returns a sequence. Requires the device to be previously opened. Should itself neither open or close the device.- Specified by:
receive
in 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:IReceive
Signals the receiving device that it should stop receiving. May not be implemented in all hardware.- Specified by:
stopReceive
in interfaceIReceive
- Returns:
- status
-
reset
- Throws:
IOException
HarcHardwareException
-
sendString
Description copied from interface:ICommandLineDevice
Sends a command (a String) to the instance.- Specified by:
sendString
in interfaceICommandLineDevice
- Parameters:
cmd
- Command string to be sent.- Throws:
IOException
HarcHardwareException
-
readString
Description copied from interface:ICommandLineDevice
Reads 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:
readString
in 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:ICommandLineDevice
Reads 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:
readString
in 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:ICommandLineDevice
Tells 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:
ready
in 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:
flushInput
in interfaceICommandLineDevice
- Throws:
IOException
-
getTransmitter
Description copied from interface:IRawIrSender
Returns a default Transmitter for the device. May be null if the device ignores the Transmitter argument in sendIr.- Specified by:
getTransmitter
in interfaceIRawIrSender
- Specified by:
getTransmitter
in interfaceIRemoteCommandIrSender
- Specified by:
getTransmitter
in interfaceITransmitter
- Returns:
- Transmitter
-
stopIr
Description copied from interface:IIrSenderStop
Stops ongoing IR transmission.- Specified by:
stopIr
in interfaceIIrSenderStop
- Returns:
- if false, command failed.
- Throws:
NoSuchTransmitterException
IOException
-
getTransmitter
Description copied from interface:ITransmitter
Parses the String argument, and returns a transmitter accordingly. Syntax and semantics may vary.- Specified by:
getTransmitter
in interfaceITransmitter
- Parameters:
connector
- String describing desired port. Syntax is dependent on the implementing class.- Returns:
- Transmitter
- Throws:
NoSuchTransmitterException
-
getTransmitterNames
Description copied from interface:ITransmitter
Return 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:
getTransmitterNames
in 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:IRawIrSenderRepeat
Like sendCcf, but continues the transmission until interrupted by a stopIr command. Particular implementations, or hardware, might limit the number of transmissions, though.- Specified by:
sendIrRepeat
in interfaceIRawIrSenderRepeat
- Returns:
- if false, command failed.
- Throws:
NoSuchTransmitterException
IOException
-
getRemotes
Description copied from interface:IRemoteCommandIrSender
Returns an array of "remote" names.- Specified by:
getRemotes
in interfaceIRemoteCommandIrSender
- Returns:
- Throws:
IOException
-
getCommands
Description copied from interface:IRemoteCommandIrSender
Returns an array of command names for the remote given in the argument.- Specified by:
getCommands
in 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:IRemoteCommandIrSender
Sends the command to the hardware, to be sent count number of times.- Specified by:
sendIrCommand
in interfaceIRemoteCommandIrSender
count
- Number of times to repeat the command- Returns:
- success
- Throws:
IOException
NoSuchTransmitterException
-
sendIrCommandRepeat
public boolean sendIrCommandRepeat(String remote, String command, Transmitter transmitter) throws IOException, NoSuchTransmitterException Description copied from interface:IRemoteCommandIrSender
Like sendIr, but sends the IR signal until stopped by stopIr. An implementation, or a hardware, may limit the number of repeats though.- Specified by:
sendIrCommandRepeat
in interfaceIRemoteCommandIrSender
- Returns:
- Throws:
IOException
NoSuchTransmitterException
-
setLed
- Throws:
IOException
HarcHardwareException
-
setLcd
- Throws:
IOException
HarcHardwareException
-
getParameter
- Throws:
IOException
HarcHardwareException
-
setParameter
public void setParameter(String parameterName, int newValue) throws IOException, HarcHardwareException - Throws:
IOException
HarcHardwareException
-