Package org.harctoolbox.harchardware.ir
Class GlobalCache
java.lang.Object
org.harctoolbox.harchardware.ir.GlobalCache
- All Implemented Interfaces:
Closeable,AutoCloseable,IWeb,IHarcHardware,ICapture,IIrReader,IIrSenderStop,IRawIrSender,ITransmitter
public class GlobalCache
extends Object
implements IHarcHardware, IRawIrSender, IIrSenderStop, ITransmitter, ICapture, IWeb
This class implements the GlobalCache TCP Unified TCP API (Version 1.1),
according to the official API documentation.
This covers the models GC-100, iTach, Flex and Global Connect.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classstatic enumPossible arguments to the set_IR command.static enumclass -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intstatic final intstatic final Stringstatic final intstatic final intstatic final StringFields 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
repeatMax -
Constructor Summary
ConstructorsConstructorDescriptionGlobalCache(String hostname) GlobalCache(String hostname, boolean verbose) GlobalCache(String hostname, boolean verbose, boolean compressed) GlobalCache(String hostIp, boolean verbose, Integer timeout) GlobalCache(String hostIp, boolean verbose, Integer timeout, boolean compressed) GlobalCache(InetAddress inetAddress, boolean verbose, Integer timeout, boolean compressed) GlobalCache(InetAddress inetAddress, boolean verbose, Integer portNumber, Integer timeout) GlobalCache(InetAddress inetAddress, Integer portIsNotUsed, boolean verbose, Integer timeout) -
Method Summary
Modifier and TypeMethodDescriptionorg.harctoolbox.ircore.ModulatedIrSequencecapture()Listens to the device and returns a sequence.voidclose()static StringString[]getIp()getIr(int module, int connector) intgetModuleSecondNumber(int moduleNumber) getNet()getSerial(int module) getSerialPort(int portNumber) Returns a serial port from the GlobalCache.intgetState(int connector) intgetState(int module, int connector) Returns a default Transmitter for the device.getTransmitter(String str) 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 an URI to be used for browsing the device, possibly containing user and password information.Returns the hardware version (not the version of the driver software).getVersion(int module) booleanisValid()Checks validity of an instance.static AmxBeaconListener.Nodestatic AmxBeaconListener.NodelistenBeacon(int timeout) static voidstatic AmxBeaconListenernewListener(AmxBeaconListener.Callback callback) newTransmitter(int cardinal) newTransmitter(int module, int port) final voidopen()Opens the device with previously set parameters.static org.harctoolbox.ircore.IrSignalParses a string intended as command to a GlobalCache and return it as a IrSignal.booleanpulseState(int connector) booleanpulseState(int module, int connector) booleanbooleansendIr(org.harctoolbox.ircore.IrSignal code) booleansendIr(org.harctoolbox.ircore.IrSignal code, int connector) booleansendIr(org.harctoolbox.ircore.IrSignal code, int count, int connector) booleansendIr(org.harctoolbox.ircore.IrSignal code, int count, int module, int connector) booleansendIr(org.harctoolbox.ircore.IrSignal code, int count, Transmitter transmitter) sendIrString(org.harctoolbox.ircore.IrSignal code, int count, int module, int connector) static StringsendIrString(org.harctoolbox.ircore.IrSignal code, int count, int module, int connector, int sendIndex, boolean compressed) Formats a string suitable for sending to a GlobalCache.voidsetBeginTimeout(int timeout) voidsetBlink(int arg) voidsetCaptureMaxSize(int integer) voidsetCompressed(boolean compressed) voidsetDebug(int debug) Sets a debug parameter.voidsetEndingTimeout(int integer) setIr(int module, int connector, GlobalCache.IrConfiguration mode) setSerial(int baudrate) setSerial(int module, int baudrate) booleansetState(int connector, boolean onOff) booleansetState(int connector, int state) booleansetState(int module, int connector, int state) voidsetTimeout(int timeout) Set timeout in milliseconds.voidsetVerbose(boolean verbose) Sets a verbosity flag, causing commands to be executed verbosely.booleanSignals the capturing device that it should stop capturing.booleanstopIr(int module, int connector) booleanstopIr(Transmitter transmitter) Stops ongoing IR transmission.booleantoggleState(int connector) booleantoggleState(int module, int connector)
-
Field Details
-
DEFAULT_IP
- See Also:
-
defaultGlobalCachePort
public static final int defaultGlobalCachePort- See Also:
-
sendIrPrefix
- See Also:
-
connectorMin
public static final int connectorMin- See Also:
-
connectorsPerModule
public static final int connectorsPerModule- See Also:
-
maxCompressedLetters
public static final int maxCompressedLetters- See Also:
-
-
Constructor Details
-
GlobalCache
public GlobalCache(InetAddress inetAddress, boolean verbose, Integer timeout, boolean compressed) throws IOException - Throws:
IOException
-
GlobalCache
public GlobalCache(String hostIp, boolean verbose, Integer timeout, boolean compressed) throws UnknownHostException, IOException - Throws:
UnknownHostExceptionIOException
-
GlobalCache
public GlobalCache(InetAddress inetAddress, Integer portIsNotUsed, boolean verbose, Integer timeout) throws IOException - Throws:
IOException
-
GlobalCache
public GlobalCache(InetAddress inetAddress, boolean verbose, Integer portNumber, Integer timeout) throws IOException - Throws:
IOException
-
GlobalCache
public GlobalCache(String hostIp, boolean verbose, Integer timeout) throws UnknownHostException, IOException - Throws:
UnknownHostExceptionIOException
-
GlobalCache
- Throws:
UnknownHostExceptionIOException
-
GlobalCache
public GlobalCache(String hostname, boolean verbose, boolean compressed) throws UnknownHostException, IOException - Throws:
UnknownHostExceptionIOException
-
GlobalCache
- Throws:
UnknownHostExceptionIOException
-
-
Method Details
-
expandIP
-
sendIrString
public static String sendIrString(org.harctoolbox.ircore.IrSignal code, int count, int module, int connector, int sendIndex, boolean compressed) throws NoSuchTransmitterException Formats a string suitable for sending to a GlobalCache.- Parameters:
code-count-module-connector-sendIndex-compressed-- Returns:
- Throws:
NoSuchTransmitterException
-
listenBeacon
-
listenBeacon
-
newListener
-
parse
public static org.harctoolbox.ircore.IrSignal parse(String gcString) throws org.harctoolbox.ircore.InvalidArgumentException Parses a string intended as command to a GlobalCache and return it as a IrSignal. Presently only the uncompressed form is parsed.- Parameters:
gcString-- Returns:
- IrSignal representing the signal, with begin and repeat part.
- Throws:
org.harctoolbox.ircore.InvalidArgumentException
-
main
- Throws:
org.harctoolbox.ircore.InvalidArgumentException
-
getUri
Description copied from interface:IWebReturns an URI to be used for browsing the device, possibly containing user and password information. -
getSerialPort
Returns a serial port from the GlobalCache.- Parameters:
portNumber- 1-based port number, i.e. use 1 for first, not 0.- Returns:
- serial port implementing ICommandLineDevice
- Throws:
NoSuchTransmitterException
-
getTransmitter
public GlobalCache.GlobalCacheIrTransmitter getTransmitter(String str) throws NoSuchTransmitterException Description copied from interface:ITransmitterParses the String argument, and returns a transmitter accordingly. Syntax and semantics may vary.- Specified by:
getTransmitterin interfaceITransmitter- Parameters:
str- String describing desired port. Syntax is dependent on the implementing class.- Returns:
- Transmitter
- Throws:
NoSuchTransmitterException
-
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 interfaceITransmitter- Returns:
- Transmitter
-
newTransmitter
public GlobalCache.GlobalCacheIrTransmitter newTransmitter(int module, int port) throws NoSuchTransmitterException - Throws:
NoSuchTransmitterException
-
newTransmitter
public GlobalCache.GlobalCacheIrTransmitter newTransmitter(int cardinal) throws NoSuchTransmitterException - 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)
-
setTimeout
public void setTimeout(int timeout) 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.
-
open
Description copied from interface:IHarcHardwareOpens the device with previously set parameters.- Specified by:
openin interfaceIHarcHardware- Throws:
IOExceptionUnknownHostException
-
getIp
-
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- 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
-
setCompressed
public void setCompressed(boolean compressed) -
stopIr
-
stopIr
Description copied from interface:IIrSenderStopStops ongoing IR transmission.- Specified by:
stopIrin interfaceIIrSenderStop- Returns:
- if false, command failed.
- Throws:
IOExceptionNoSuchTransmitterException
-
sendIr
- Throws:
IOException
-
sendIrString
public String sendIrString(org.harctoolbox.ircore.IrSignal code, int count, int module, int connector) throws NoSuchTransmitterException - Throws:
NoSuchTransmitterException
-
sendIr
public boolean sendIr(org.harctoolbox.ircore.IrSignal code, int count, int module, int connector) throws NoSuchTransmitterException, IOException -
sendIr
public boolean sendIr(org.harctoolbox.ircore.IrSignal code, int count, int connector) throws IOException, NoSuchTransmitterException -
sendIr
public boolean sendIr(org.harctoolbox.ircore.IrSignal code, int connector) throws IOException, NoSuchTransmitterException -
sendIr
public boolean sendIr(org.harctoolbox.ircore.IrSignal code) throws IOException, NoSuchTransmitterException -
sendIr
public boolean sendIr(org.harctoolbox.ircore.IrSignal code, int count, Transmitter transmitter) throws NoSuchTransmitterException, IOException - Specified by:
sendIrin interfaceIRawIrSender- Returns:
- if false, command failed.
- Throws:
NoSuchTransmitterExceptionIOException
-
getDevices
-
getVersion
- 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
-
getNet
- Throws:
IOException
-
setNet
- Throws:
IOException
-
getIr
-
getModuleSecondNumber
public int getModuleSecondNumber(int moduleNumber) -
getIrModules
-
getSerialModules
-
getRelayModules
-
setIr
public String setIr(int module, int connector, String modestr) throws IOException, NoSuchTransmitterException -
setIr
public String setIr(int module, int connector, GlobalCache.IrConfiguration mode) throws IOException, NoSuchTransmitterException -
getSerial
- Throws:
IOException
-
getSerial
- Throws:
IOException
-
setSerial
- Throws:
IOException
-
setSerial
- Throws:
IOException
-
setSerial
- Throws:
IOException
-
setSerial
- Throws:
IOException
-
getState
-
getState
-
toggleState
public boolean toggleState(int module, int connector) throws IOException, NoSuchTransmitterException -
toggleState
-
setState
public boolean setState(int module, int connector, int state) throws IOException, NoSuchTransmitterException -
setState
-
setState
public boolean setState(int connector, boolean onOff) throws IOException, NoSuchTransmitterException -
pulseState
- Parameters:
module-connector-- Returns:
- Throws:
IOExceptionNoSuchTransmitterException
-
pulseState
- Parameters:
connector-- Returns:
- Throws:
IOExceptionNoSuchTransmitterException
-
setBlink
- Throws:
IOException
-
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.
-
capture
public org.harctoolbox.ircore.ModulatedIrSequence capture() throws org.harctoolbox.ircore.InvalidArgumentExceptionDescription 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. -
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
-
setBeginTimeout
- Specified by:
setBeginTimeoutin interfaceIIrReader- Throws:
IOException
-
setCaptureMaxSize
public void setCaptureMaxSize(int integer) - Specified by:
setCaptureMaxSizein interfaceIIrReader
-
setEndingTimeout
public void setEndingTimeout(int integer) - Specified by:
setEndingTimeoutin interfaceIIrReader
-