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
Modifier and TypeClassDescriptionstatic class
static enum
Possible arguments to the set_IR command.static enum
class
-
Field Summary
Modifier and TypeFieldDescriptionstatic final int
static final int
static final String
static final int
static final int
static final String
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
-
Constructor Summary
ConstructorDescriptionGlobalCache
(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.ModulatedIrSequence
capture()
Listens to the device and returns a sequence.void
close()
static String
String[]
getIp()
getIr
(int module, int connector) int
getModuleSecondNumber
(int moduleNumber) getNet()
getSerial
(int module) getSerialPort
(int portNumber) Returns a serial port from the GlobalCache.int
getState
(int connector) int
getState
(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) boolean
isValid()
Checks validity of an instance.static AmxBeaconListener.Node
static AmxBeaconListener.Node
listenBeacon
(int timeout) static void
static AmxBeaconListener
newListener
(AmxBeaconListener.Callback callback) newTransmitter
(int cardinal) newTransmitter
(int module, int port) final void
open()
Opens the device with previously set parameters.static org.harctoolbox.ircore.IrSignal
Parses a string intended as command to a GlobalCache and return it as a IrSignal.boolean
pulseState
(int connector) boolean
pulseState
(int module, int connector) boolean
boolean
sendIr
(org.harctoolbox.ircore.IrSignal code) boolean
sendIr
(org.harctoolbox.ircore.IrSignal code, int connector) boolean
sendIr
(org.harctoolbox.ircore.IrSignal code, int count, int connector) boolean
sendIr
(org.harctoolbox.ircore.IrSignal code, int count, int module, int connector) boolean
sendIr
(org.harctoolbox.ircore.IrSignal code, int count, Transmitter transmitter) sendIrString
(org.harctoolbox.ircore.IrSignal code, int count, int module, int connector) static String
sendIrString
(org.harctoolbox.ircore.IrSignal code, int count, int module, int connector, int sendIndex, boolean compressed) Formats a string suitable for sending to a GlobalCache.void
setBeginTimeout
(int timeout) void
setBlink
(int arg) void
setCaptureMaxSize
(int integer) void
setCompressed
(boolean compressed) void
setDebug
(int debug) Sets a debug parameter.void
setEndingTimeout
(int integer) setIr
(int module, int connector, GlobalCache.IrConfiguration mode) setSerial
(int baudrate) setSerial
(int module, int baudrate) boolean
setState
(int connector, boolean onOff) boolean
setState
(int connector, int state) boolean
setState
(int module, int connector, int state) void
setTimeout
(int timeout) Set timeout in milliseconds.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
(int module, int connector) boolean
stopIr
(Transmitter transmitter) Stops ongoing IR transmission.boolean
toggleState
(int connector) boolean
toggleState
(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:
UnknownHostException
IOException
-
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:
UnknownHostException
IOException
-
GlobalCache
- Throws:
UnknownHostException
IOException
-
GlobalCache
public GlobalCache(String hostname, boolean verbose, boolean compressed) throws UnknownHostException, IOException - Throws:
UnknownHostException
IOException
-
GlobalCache
- Throws:
UnknownHostException
IOException
-
-
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:IWeb
Returns 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:ITransmitter
Parses the String argument, and returns a transmitter accordingly. Syntax and semantics may vary.- Specified by:
getTransmitter
in interfaceITransmitter
- Parameters:
str
- String describing desired port. Syntax is dependent on the implementing class.- Returns:
- Transmitter
- Throws:
NoSuchTransmitterException
-
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 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: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)
-
setTimeout
public void setTimeout(int timeout) 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.
-
open
Description copied from interface:IHarcHardware
Opens the device with previously set parameters.- Specified by:
open
in interfaceIHarcHardware
- Throws:
IOException
UnknownHostException
-
getIp
-
close
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- 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
-
setCompressed
public void setCompressed(boolean compressed) -
stopIr
-
stopIr
Description copied from interface:IIrSenderStop
Stops ongoing IR transmission.- Specified by:
stopIr
in interfaceIIrSenderStop
- Returns:
- if false, command failed.
- Throws:
IOException
NoSuchTransmitterException
-
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:
sendIr
in interfaceIRawIrSender
- Returns:
- if false, command failed.
- Throws:
NoSuchTransmitterException
IOException
-
getDevices
-
getVersion
- 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
-
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:
IOException
NoSuchTransmitterException
-
pulseState
- Parameters:
connector
-- Returns:
- Throws:
IOException
NoSuchTransmitterException
-
setBlink
- Throws:
IOException
-
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.
-
capture
public org.harctoolbox.ircore.ModulatedIrSequence capture() throws org.harctoolbox.ircore.InvalidArgumentExceptionDescription 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. -
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
-
setBeginTimeout
- Specified by:
setBeginTimeout
in interfaceIIrReader
- Throws:
IOException
-
setCaptureMaxSize
public void setCaptureMaxSize(int integer) - Specified by:
setCaptureMaxSize
in interfaceIIrReader
-
setEndingTimeout
public void setEndingTimeout(int integer) - Specified by:
setEndingTimeout
in interfaceIIrReader
-