made lampel controlled via udp since lampel got new hardware and firmware
This commit is contained in:
parent
c127302dc1
commit
03abf212c1
|
@ -1,28 +1,48 @@
|
|||
package de.ctdo.crashtest;
|
||||
|
||||
import de.ctdo.crashtest.domotics.BuntiClient;
|
||||
import de.ctdo.crashtest.gui.GuiEventListener;
|
||||
import de.ctdo.crashtest.gui.MainGui;
|
||||
|
||||
public class TestClass implements GuiEventListener {
|
||||
public class TestClass {
|
||||
|
||||
public TestClass() {
|
||||
MainGui mg = new MainGui();
|
||||
mg.addListener(this);
|
||||
mg.setCountDown(121411);
|
||||
|
||||
BuntiClient bunti = new BuntiClient("bunti.ctdo.de",8080);
|
||||
|
||||
int pause = 500;
|
||||
|
||||
try {
|
||||
|
||||
while(true) {
|
||||
for(int i = 0; i< 3; i++) {
|
||||
Thread.sleep(pause);
|
||||
bunti.setLampel(true, false, true);
|
||||
Thread.sleep(pause);
|
||||
bunti.setLampel(false, true, true);
|
||||
Thread.sleep(pause);
|
||||
bunti.setLampel(false, false, true);
|
||||
Thread.sleep(pause);
|
||||
bunti.setLampel(false, false, false);
|
||||
Thread.sleep(pause);
|
||||
bunti.setLampel(true, true, true);
|
||||
Thread.sleep(pause);
|
||||
bunti.setLampel(false, false, true);
|
||||
Thread.sleep(pause);
|
||||
bunti.setLampel(true, true, true);
|
||||
Thread.sleep(pause);
|
||||
bunti.setLampel(false, false, false);
|
||||
}
|
||||
|
||||
//Thread.sleep(2000);
|
||||
}
|
||||
}
|
||||
catch (InterruptedException ignored) {}
|
||||
|
||||
}
|
||||
|
||||
public static void main(String args[]) {
|
||||
new TestClass();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void keyPress(char key) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void windowClosing() {
|
||||
System.out.println("closing");
|
||||
System.exit(0);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,6 +8,9 @@ import org.apache.http.entity.StringEntity;
|
|||
import org.apache.http.impl.client.DefaultHttpClient;
|
||||
|
||||
import java.io.*;
|
||||
import java.net.DatagramPacket;
|
||||
import java.net.DatagramSocket;
|
||||
import java.net.InetAddress;
|
||||
import java.net.Socket;
|
||||
|
||||
public class BuntiClient implements IBuntiClient {
|
||||
|
@ -129,18 +132,13 @@ public class BuntiClient implements IBuntiClient {
|
|||
if( red ) value |= 0x04;
|
||||
|
||||
try {
|
||||
Socket client = new Socket("lampel.ctdo.de", 2701);
|
||||
client.setSoTimeout(800);
|
||||
byte buffer[] = ("io set port 2 " + Integer.toHexString(value) + '\n').getBytes();
|
||||
|
||||
DatagramSocket udp = new DatagramSocket();
|
||||
InetAddress ia = InetAddress.getByName("lampel.raum.ctdo.de");
|
||||
DatagramPacket packet = new DatagramPacket(buffer, buffer.length, ia, 2701);
|
||||
|
||||
DataOutputStream outToServer = new DataOutputStream(client.getOutputStream());
|
||||
BufferedReader inFromServer = new BufferedReader(new InputStreamReader(client.getInputStream()));
|
||||
|
||||
|
||||
outToServer.writeBytes("io set port 2 " + Integer.toHexString(value) + '\n');
|
||||
|
||||
inFromServer.readLine();
|
||||
|
||||
client.close();
|
||||
udp.send(packet);
|
||||
} catch (IOException e) {
|
||||
Logger.sLog("lampel error: " + e.getMessage());
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue