Re: share software
Posted: Sun Mar 13, 2011 2:18 pm
where was it ment for?
Domotica - Home Automation Forum
https://www.domoticaforum.eu/
Storing RFXMeter counter values in a MS SQL database.Edwin2008 wrote:where was it ment for?
Code: Select all
void run(String ipAddress) {
try {
// creating a socket to connect to the server
requestSocket = new Socket(ipAddress, 10001);
System.out.println("Connected to rfxcom");
in = requestSocket.getInputStream();
int count;
byte[] previous = null;
byte[] buffer = new byte[16384];
while ((count = in.read(buffer)) > 0) {
if (ByteUtil.equalBuffer(buffer, previous, count)) {
// skip this record. It's the same as previous
} else {
previous = ByteUtil.copyByteBuffer(buffer, count);
RfxSignal thisSignal = RfxParser.getRfxSignal(buffer,count);
if (thisSignal!=null){
try {
RfxDAO.getInstance().store(thisSignal);
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
}
} catch (UnknownHostException unknownHost) {
System.err.println("You are trying to connect to an unknown host: "+ipAddress);
} catch (IOException ioException) {
ioException.printStackTrace();
} finally {
// Closing connection
try {
in.close();
requestSocket.close();
} catch (IOException ioException) {
ioException.printStackTrace();
}
}
}