public class LedNetProxy extends Object
Modifier and Type | Class and Description |
---|---|
static class |
LedNetProxy.FadeSpeed |
Modifier and Type | Field and Description |
---|---|
private static boolean |
classInit
Class flag signifying if the initUtil method has been called
|
private static String |
CLASSNAME
A holder This classes name (used when logging).
|
static String |
CLASSPATH
The VM classpath (used in some methods)..
|
private static boolean |
connected_ |
private static boolean |
debugging_
Class flag signifying if debugging_ messages are ptinted
|
static String |
DEFAULT_LEDNET_IP
default receiver IP Address.
|
static int |
DEFAULT_LEDNET_PORT
default LEDNET port.
|
private static StringBuffer |
helpMsg_ |
private static DataInputStream |
in_ |
private static Socket |
lednetSocket_
the socket for communication - the protocol spec says to use one socket connection AND HOLD ONTO IT for re-use.
|
private int |
levelCount |
private HashMap<Integer,Integer> |
levels_ |
private static ObjectOutputStream |
out_ |
private String |
receiverIP_
Instantiated class IP for the receiver to communicate with.
|
private int |
receiverPort_
Instantiated class Port for the receiver to communicate with.
|
private HashMap<Integer,Integer> |
reverseLevels_ |
private static int |
socketTimeOut_
the timeout in ms for socket reads.
|
static String |
SYSTEM_FILE_SEPERATOR
A holder for this clients System File Separator.
|
static String |
SYSTEM_LINE_SEPERATOR
A holder for this clients System line termination separator.
|
static String |
USERDIR
The users pwd ditrectory.
|
static String |
USERHOME
The users home ditrectory.
|
Constructor and Description |
---|
LedNetProxy()
Simple class Constructor (using deafult IP and port) that gets all the class command constants
set-up.
|
LedNetProxy(String ip)
Constructor that takes your receivers ip and default port, gets all the class command
constants set-up .
|
LedNetProxy(String ip,
int ipPort)
Constructor that takes your receivers ip and port, gets all the class command
constants set-up .
|
Modifier and Type | Method and Description |
---|---|
void |
christmasFade()
A method to wrap a number of colour change calls (just for fun).
|
void |
christmasFade(int loopTime)
A method to wrap a number of colour change calls (just for fun).
|
void |
christmasFade(int toLevel,
int loopTime,
long pause)
A method to wrap a number of colour change calls (just for fun).
|
void |
christmasFun(int loopTime)
A method to wrap a number of colour change calls (just for fun).
|
void |
christmasFun(int loopTime,
long pause)
A method to wrap a number of colour change calls (just for fun).
|
boolean |
closeSocket()
Closes the socket connection.
|
boolean |
connectSocket()
Connects to the receiver by opening a socket connection through the DEFaULT IP and DEFAULT eISCP port.
|
boolean |
connectSocket(String ip)
Connects to the receiver by opening a socket connection through the DEFAULT LedNet Receiver Port.
|
boolean |
connectSocket(String ip,
int ipPort)
Connects to the receiver by opening a socket connection through the passed in port (or default LedNet Receiver Port).
|
static String |
convertAsciiToBase10(String str) |
static String |
convertAsciiToBase10(String str,
boolean dumpOut) |
static int |
convertHexNumberStringToDecimal(String str)
Converts an HEX number String to its decimal equivalent.
|
static int |
convertHexNumberStringToDecimal(String str,
boolean dumpOut)
Converts an HEX number String to its decimal equivalent.
|
static String |
convertHexToString(byte hex)
Converts a hex byte to an ascii String.
|
static String |
convertHexToString(String hex)
Converts a hex String to an ascii String.
|
static String |
convertHexToString(String hex,
boolean dumpOut)
Converts a hex String to an ascii String.
|
static String |
convertStringToHex(String str)
Converts an ascii decimal String to a hex String.
|
static String |
convertStringToHex(String str,
boolean dumpOut)
Converts an ascii decimal String to a hex String.
|
private int |
daToi(DoubleAdder d)
Function to accepts a java 8 doubleAdder and returns an int primitive.
|
private int |
dToi(double d)
Function to accepts a double and returns an int primitive.
|
void |
dumpExpLevels()
Prints out the non-linear levels from the class var Exponential formula.
|
void |
dumpLevels()
Prints out the non-linear levels from the class var levels_.
|
void |
dumpReverseLevels()
Prints out the reverse non-linear lookup levels from the class var reverseLevels_.
|
private int |
expLedLevel(int v)
LED Level lookup from an exponential formula.
|
void |
fadeBetweenCommand(int r,
int g,
int b,
int w,
int r2,
int g2,
int b2,
int w2,
LedNetProxy.FadeSpeed speed)
Steps the non-linear LedLevel rgbw between the passed values to provide a fade.
|
void |
fadeBetweenCommand(int r,
int g,
int b,
int w,
int r2,
int g2,
int b2,
int w2,
LedNetProxy.FadeSpeed speed,
boolean nonLinear)
Steps the rgbw (linear or non-linear LedLevel ) between the passed values to provide a fade.
|
void |
fun(int loopTime)
A method to wrap a number of colour change calls (just for fun).
|
void |
fun(int loopTime,
long pause)
A method to wrap a number of colour change calls (just for fun).
|
StringBuilder |
getCustomMessage(int r,
int g,
int b,
int w,
int r2,
int g2,
int b2,
int w2,
int speed)
This implements the custom message format - NOT DONE YET.
|
private static StringBuffer |
getHelpMsg()
initializes and gets the helpMsg_
class var.
|
private static String |
getHelpMsgStr()
gets the help as a String.
|
StringBuilder |
getLedNetColourMessage(int r,
int g,
int b,
int w)
Wraps a command in a colour data message (data characters).
|
StringBuilder |
getLedNetOffMessage()
Override helper method to redirect to getLedNetOnOffMessage false.
|
StringBuilder |
getLedNetOnMessage()
Override helper method to redirect to getLedNetOnOffMessage true.
|
StringBuilder |
getLedNetOnOffMessage(boolean on)
Wraps an On or Off command in a data message (data characters).
|
int |
getLevelCount()
Get Method for class field 'levelCount'.
|
String |
getReceiverIP()
Makes Sprinkle doughnuts.
|
int |
getReceiverPort()
Makes glazed doughnuts.
|
private void |
initLevelsMap()
Initializes the class var 'levels_' HashMap of non-linear lookup values for the LED brightness levels.
|
static byte[] |
intToByteArray(int value) |
private int |
ledLevel(int v)
LED Level lookup from the non-linear hashmap setup in
initLevelsMap . |
private int |
ledLevel(int v,
boolean nonLinear)
LED Level lookup from the linear or non-linear hashmap setup in
initLevelsMap . |
private int |
levelsDiff(int l1,
int l2)
The difference between the LED Level lookup from the non-linear hashmap setup in
initLevelsMap . |
private int |
levelsDiff(int l1,
int l2,
boolean nonLinear)
The difference between the LED Level lookup from the linear or non-linear hashmap setup in
initLevelsMap . |
static void |
main(String[] args)
Class main commandLine entry method.
|
Vector<String> |
readQueryResponses()
This method reads responses (possibly more than one) after a command.
|
private int |
reverseLedLevel(int v)
Lookup the linear value from the non-linear hashmap setup in
initLevelsMap . |
String |
right(String value,
int length) |
double |
secondsBetween(String t1,
String t2)
Calculates the seconds between the 2 passed timeStamps.
|
String |
sendColourCommand(int r,
int g,
int b,
int w)
Sends to command to the receiver and does not wait for a reply AND leaves the socket open.
|
String |
sendColourCommand(int r,
int g,
int b,
int w,
boolean waitForResponse,
boolean closeSocket)
Sends to command to the receiver and does not wait for a reply.
|
void |
sendCustomCommand(int r,
int g,
int b,
int w,
int r2,
int g2,
int b2,
int w2,
int speed)
Sends to command to the receiver and does not wait for a reply AND leaves the socket open.
|
void |
sendCustomCommand(int r,
int g,
int b,
int w,
int r2,
int g2,
int b2,
int w2,
int speed,
boolean closeSocket)
Sends to command to the receiver and does not wait for a reply.
|
String |
sendOnOffCommand(boolean on)
Sends the passed in on or off command to LedNet and leaves the socket open.
|
String |
sendOnOffCommand(boolean on,
boolean closeSocket)
Sends to command to the receiver and does not wait for a reply.
|
String |
sendQueryOnOffCommand(boolean on,
boolean closeSocket)
Sends to command to the receiver and then waits for the response(s).
|
void |
setLevelCount(int levelCount)
Set Method for class field 'levelCount'.
|
void |
setReceiverIP(String ip)
Makes Chocolate glazed doughnuts.
|
void |
setReceiverPort(int port)
Makes mini doughnuts.
|
boolean |
sleep(long waitTime)
A method to simply abstract the Try/Catch required to put the current
thread to sleep for the specified time in ms.
|
void |
slowBurn(int toLevel,
int loopTime,
long pause) |
void |
stepBetween(int r,
int g,
int b,
int w,
int r2,
int g2,
int b2,
int w2)
linear Steps the rgbw between the passed values to provide a fade.
|
boolean |
testConnection()
Tests the Connection to the receiver by opening a socket connection through the DEFaULT IP and DEFAULT eISCP port.
|
boolean |
testConnection(String ip)
Tests the Connection to the receiver by opening a socket connection through the specified IP and DEFAULT eISCP port.
|
boolean |
testConnection(String ip,
int ipPort)
test the connection to the receiver by opening a socket connection AND THEN CLOSES it if it was not already open.
|
public static final String SYSTEM_FILE_SEPERATOR
public static final String SYSTEM_LINE_SEPERATOR
private static boolean classInit
private static boolean debugging_
public static final String DEFAULT_LEDNET_IP
private String receiverIP_
public static final int DEFAULT_LEDNET_PORT
private int receiverPort_
private static Socket lednetSocket_
private static int socketTimeOut_
private static ObjectOutputStream out_
private static DataInputStream in_
private static boolean connected_
private static StringBuffer helpMsg_
private HashMap<Integer,Integer> reverseLevels_
private int levelCount
public LedNetProxy()
public LedNetProxy(String ip)
public LedNetProxy(String ip, int ipPort)
public void setReceiverIP(String ip)
public String getReceiverIP()
public void setReceiverPort(int port)
public int getReceiverPort()
public boolean connectSocket()
public boolean connectSocket(String ip)
public boolean connectSocket(String ip, int ipPort)
public boolean testConnection()
public boolean testConnection(String ip)
ip
- is the ip address (as a String) of the AV receiver to connectpublic boolean testConnection(String ip, int ipPort)
testConnection
method (that used the default port) or the testConnection
method (that used the default IP and port).ip
- is the ip address (as a String) of the AV receiver to connectipPort
- is the IP Port of the AV receiver to connect with (Onkyo's default is 60128)public boolean closeSocket()
public static String convertAsciiToBase10(String str)
public static String convertAsciiToBase10(String str, boolean dumpOut)
public static String convertStringToHex(String str)
str
- holding the string to convert to HEXpublic static String convertStringToHex(String str, boolean dumpOut)
str
- holding the string to convert to HEXdumpOut
- flag to turn some debug output on/offpublic static final byte[] intToByteArray(int value)
public static int convertHexNumberStringToDecimal(String str)
str
- holding the Hex Number string to convert to decimalpublic static int convertHexNumberStringToDecimal(String str, boolean dumpOut)
str
- holding the Hex Number string to convert to decimaldumpOut
- boolean flag to turn some debug output on/offpublic static String convertHexToString(byte hex)
hex
- byte holding the HEX string to convert back to decimalpublic static String convertHexToString(String hex)
hex
- the HEX string to convert back to decimalpublic static String convertHexToString(String hex, boolean dumpOut)
hex
- the HEX string to convert backk to decimaldumpOut
- boolean flag to turn some debug output on/offpublic StringBuilder getLedNetColourMessage(int r, int g, int b, int w)
rgbw
- must be one of the 0-255 representing a decimal val for the colourpublic StringBuilder getCustomMessage(int r, int g, int b, int w, int r2, int g2, int b2, int w2, int speed)
public StringBuilder getLedNetOnMessage()
public StringBuilder getLedNetOffMessage()
public StringBuilder getLedNetOnOffMessage(boolean on)
on
- must be true to send on command, or false to send OFF commandpublic String sendOnOffCommand(boolean on)
on
- true or falso to send On or Off.public String sendOnOffCommand(boolean on, boolean closeSocket)
on
- true or falso to send On or Off.closeSocket
- flag to close the connection when done or leave it open.public String sendColourCommand(int r, int g, int b, int w)
rgbw
- are the colour levels (0-255)public String sendColourCommand(int r, int g, int b, int w, boolean waitForResponse, boolean closeSocket)
rgbw
- are the colour levels (0-255)closeSocket
- flag to close the connection when done or leave it open.public void sendCustomCommand(int r, int g, int b, int w, int r2, int g2, int b2, int w2, int speed)
rgbw
- are the colour levels (0-255)public void sendCustomCommand(int r, int g, int b, int w, int r2, int g2, int b2, int w2, int speed, boolean closeSocket)
rgbw
- are the colour levels (0-255)closeSocket
- flag to close the connection when done or leave it open.public void fun(int loopTime)
loopTime
- is how long to loop the fun OR -1 to run forever.public void fun(int loopTime, long pause)
loopTime
- is how long to loop the fun OR -1 to run forever.pause
- is the delay between colour change calls in the looppublic void christmasFun(int loopTime)
loopTime
- is how long to loop the fun OR -1 to run forever.public void christmasFun(int loopTime, long pause)
loopTime
- is how long to loop the fun OR -1 to run forever.pause
- is the delay between colour change calls in the looppublic void christmasFade()
loopTime
- is how long to loop the fun OR -1 to run forever.public void christmasFade(int loopTime)
loopTime
- is how long to loop the fun OR -1 to run forever.public void christmasFade(int toLevel, int loopTime, long pause)
loopTime
- is how long to loop the fun OR -1 to run forever.pause
- is the delay between colour change calls in the looppublic void slowBurn(int toLevel, int loopTime, long pause)
public void stepBetween(int r, int g, int b, int w, int r2, int g2, int b2, int w2)
r
- starting red valuer2
- ending red valuepublic void fadeBetweenCommand(int r, int g, int b, int w, int r2, int g2, int b2, int w2, LedNetProxy.FadeSpeed speed)
nonLinear
- boolean flag to choose between linear or default non-linear level lookup.public void fadeBetweenCommand(int r, int g, int b, int w, int r2, int g2, int b2, int w2, LedNetProxy.FadeSpeed speed, boolean nonLinear)
nonLinear
- boolean flag to choose between linear or default non-linear level lookup.private int dToi(double d)
private int daToi(DoubleAdder d)
public double secondsBetween(String t1, String t2)
private int ledLevel(int v)
initLevelsMap
.v
- is the (0-255) level to lookup the non-linear level lookup.private int ledLevel(int v, boolean nonLinear)
initLevelsMap
.v
- is the (0-255) level to lookup the non-linear level lookup.nonLinear
- boolean flag to choose between linear or default non-linear level lookup from levels_
map.private int expLedLevel(int v)
v
- is the (0-255) level to lookup the non-linear level lookup.private int levelsDiff(int l1, int l2)
initLevelsMap
.l1
- is the (0-255) level to lookup the non-linear level lookup.l2
- is the (0-255) level to lookup the non-linear level lookup.private int levelsDiff(int l1, int l2, boolean nonLinear)
initLevelsMap
.l1
- is the (0-255) level to lookup the non-linear level lookup.l2
- is the (0-255) level to lookup the non-linear level lookup.nonLinear
- boolean flag to choose between linear or default non-linear level lookup.public void setLevelCount(int levelCount)
levelCount
- is the value to set this class field to.public int getLevelCount()
private int reverseLedLevel(int v)
initLevelsMap
.v
- is the non-level value to lookup the linear level .public String sendQueryOnOffCommand(boolean on, boolean closeSocket)
command
- must be one of the Command Class Constants from the eiscp.Eiscp.Command class.closeSocket
- flag to close the connection when done or leave it open.returnAll
- flags if all response packetMessages are returned, if no then ONLY the ones related to the command requestedpublic Vector<String> readQueryResponses()
public boolean sleep(long waitTime)
waitTime
- the sleep time in milli seconds (ms).private static String getHelpMsgStr()
private static StringBuffer getHelpMsg()
public void dumpExpLevels()
public void dumpLevels()
public void dumpReverseLevels()
private void initLevelsMap()
WebARTS Library Licensed Under the GNU - General Public License. Other Libraries licensed under their respective Open Source Licenses