parent
2fee496a54
commit
6e81052e38
|
@ -14,6 +14,8 @@
|
|||
<element id="extracted-dir" path="$PROJECT_DIR$/libs/httpmime-4.1.3.jar" path-in-jar="/" />
|
||||
<element id="extracted-dir" path="$PROJECT_DIR$/libs/javampd-4.0.jar" path-in-jar="/" />
|
||||
<element id="extracted-dir" path="$PROJECT_DIR$/libs/jerklib.jar" path-in-jar="/" />
|
||||
<element id="extracted-dir" path="$PROJECT_DIR$/libs/rxtx-2.1-7-bins-r2/RXTXcomm.jar" path-in-jar="/" />
|
||||
<element id="file-copy" path="$PROJECT_DIR$/librxtxSerial.so" />
|
||||
</root>
|
||||
</artifact>
|
||||
</component>
|
Binary file not shown.
|
@ -1,3 +1,3 @@
|
|||
Manifest-Version: 1.0
|
||||
Main-Class: de.ctdo.crashtest.SteuerungFrame
|
||||
Main-Class: de.ctdo.crashtest.Steuerung
|
||||
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package de.ctdo.crashtest;
|
||||
|
||||
import de.ctdo.crashtest.domotics.IRelaisboard;
|
||||
import de.ctdo.crashtest.domotics.Relaisboard;
|
||||
import de.ctdo.crashtest.mpd.IMPDController;
|
||||
import de.ctdo.crashtest.mpd.MPDController;
|
||||
|
||||
|
@ -11,8 +13,29 @@ public class TestClass {
|
|||
|
||||
public static void main(String args[]) throws InterruptedException {
|
||||
|
||||
IRelaisboard board = new Relaisboard("/dev/ttyUSB0");
|
||||
board.open();
|
||||
|
||||
/*
|
||||
board.setRelais(1,false);
|
||||
//board.setRelais(1, true);
|
||||
|
||||
board.toggleRelais(1, 500);
|
||||
Thread.sleep(1000);
|
||||
board.toggleRelais(1, 500);
|
||||
Thread.sleep(1000);
|
||||
board.toggleRelais(1, 500);
|
||||
|
||||
//board.setRelais(1, false);
|
||||
|
||||
Thread.sleep(4000); */
|
||||
|
||||
board.blinkRelais(2, 500, 6); // hint Button
|
||||
|
||||
Thread.sleep(6000);
|
||||
|
||||
|
||||
board.close();
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ public interface IRelaisboard {
|
|||
|
||||
void setRelais(final int relais, final boolean state);
|
||||
void toggleRelais(final int relais, final int milliseconds);
|
||||
|
||||
void blinkRelais(final int relais, final int pause, final int count);
|
||||
boolean open();
|
||||
void close();
|
||||
|
||||
|
|
|
@ -11,38 +11,34 @@ public class Relaisboard implements IRelaisboard {
|
|||
private OutputStream outputStream;
|
||||
private Boolean serialPortGeoeffnet = false;
|
||||
private String portName = "/dev/ttyUSB0";
|
||||
private Object mLock = new Object();
|
||||
|
||||
public Relaisboard(final String port) {
|
||||
this.portName = port;
|
||||
}
|
||||
|
||||
private synchronized void send(final char ch) {
|
||||
if (!serialPortGeoeffnet) return;
|
||||
|
||||
try {
|
||||
outputStream.write(ch);
|
||||
} catch (IOException e) {
|
||||
Logger.sLog("Fehler beim Senden");
|
||||
}
|
||||
}
|
||||
|
||||
private void sendData(final int relais, final boolean state) {
|
||||
if(relais >= 0 && relais < 8) {
|
||||
if(relais >= 0 && relais < 8 && outputStream != null) {
|
||||
char charsOff[] = { 'a','b','c','d','e','f','g','h' };
|
||||
char charsOn[] = { 'A','B','C','D','E','F','G','H' };
|
||||
|
||||
if(state) {
|
||||
send(charsOn[relais]);
|
||||
} else {
|
||||
send(charsOff[relais]);
|
||||
try {
|
||||
if(state) {
|
||||
outputStream.write(charsOn[relais]);
|
||||
} else {
|
||||
outputStream.write(charsOff[relais]);
|
||||
}
|
||||
|
||||
outputStream.flush();
|
||||
} catch (IOException e) {
|
||||
Logger.sLog("Fehler beim Senden");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean open()
|
||||
{
|
||||
public boolean open() {
|
||||
serialPortGeoeffnet = false;
|
||||
Boolean foundPort = false;
|
||||
|
||||
|
@ -100,33 +96,73 @@ public class Relaisboard implements IRelaisboard {
|
|||
public void setRelais(final int relais, final boolean state) {
|
||||
if(!serialPortGeoeffnet) return;
|
||||
|
||||
Runnable r = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
sendData(relais, state);
|
||||
}
|
||||
};
|
||||
synchronized (mLock) {
|
||||
Runnable r = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
sendData(relais, state);
|
||||
}
|
||||
};
|
||||
|
||||
new Thread(r).start();
|
||||
new Thread(r).start();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void toggleRelais(final int relais, final int milliseconds) {
|
||||
if(!serialPortGeoeffnet) return;
|
||||
|
||||
Runnable r = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
sendData(relais, true);
|
||||
synchronized (mLock) {
|
||||
Runnable r = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
sendData(relais, true);
|
||||
|
||||
try {
|
||||
Thread.sleep(milliseconds);
|
||||
} catch (InterruptedException e) { }
|
||||
try {
|
||||
Thread.sleep(milliseconds);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
sendData(relais, false);
|
||||
}
|
||||
};
|
||||
sendData(relais, false);
|
||||
}
|
||||
};
|
||||
|
||||
new Thread(r).start();
|
||||
new Thread(r).start();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void blinkRelais(final int relais, final int pause, final int count) {
|
||||
if(!serialPortGeoeffnet) return;
|
||||
|
||||
synchronized (mLock) {
|
||||
Runnable r = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
int i;
|
||||
|
||||
for(i = 0; i< count; i++) {
|
||||
sendData(relais, true);
|
||||
|
||||
try {
|
||||
Thread.sleep(pause);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
sendData(relais, false);
|
||||
|
||||
try {
|
||||
Thread.sleep(pause);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
new Thread(r).start();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,6 +12,7 @@ public class TheGame implements StatemachineListener, GuiEventListener, IRCEvent
|
|||
private IStatemachine machine;
|
||||
private IBuntiClient bunti;
|
||||
private IMPDController mpdController;
|
||||
private IRelaisboard relaisboard;
|
||||
|
||||
public TheGame(IGuiControl guiControl) {
|
||||
this.guiControl = guiControl;
|
||||
|
@ -19,7 +20,8 @@ public class TheGame implements StatemachineListener, GuiEventListener, IRCEvent
|
|||
this.ircClient = new IrcClient("crashtest", "#crashtest","irc.hackint.eu");
|
||||
this.bunti = new BuntiClient("bunti.ctdo.de", 8080);
|
||||
this.mpdController = new MPDController("dampfradio.raum.ctdo.de");
|
||||
this.machine = new Statemachine();
|
||||
this.relaisboard = new Relaisboard("/dev/ttyUSB0");
|
||||
this.machine = new Statemachine();
|
||||
|
||||
initGame();
|
||||
}
|
||||
|
@ -30,6 +32,8 @@ public class TheGame implements StatemachineListener, GuiEventListener, IRCEvent
|
|||
machine.addListener(this);
|
||||
|
||||
machine.reset();
|
||||
relaisboard.open();
|
||||
relaisboard.toggleRelais(2, 2000);
|
||||
}
|
||||
|
||||
|
||||
|
@ -45,11 +49,12 @@ public class TheGame implements StatemachineListener, GuiEventListener, IRCEvent
|
|||
switch (newState) {
|
||||
case IDLE:
|
||||
machine.stopTimer();
|
||||
guiControl.setExtra("");
|
||||
guiControl.setWall("");
|
||||
|
||||
mpdController.setVolume(45);
|
||||
mpdController.playSong("start", "mix");
|
||||
|
||||
|
||||
bunti.setPar56(0,0,0);
|
||||
bunti.setLampel(false,false,false);
|
||||
|
||||
|
@ -68,6 +73,8 @@ public class TheGame implements StatemachineListener, GuiEventListener, IRCEvent
|
|||
machine.startTimer(60*8);
|
||||
break;
|
||||
case TABLE_GAME_ONE:
|
||||
guiControl.setWall("64K RAM SYSTEM 38911 BASIC BYTES FREE. **** COMMODORE 64 BASIC V2 ****");
|
||||
|
||||
mpdController.setVolume(70);
|
||||
mpdController.playSong("K2", "Der Berg Ruft");
|
||||
|
||||
|
@ -120,6 +127,9 @@ public class TheGame implements StatemachineListener, GuiEventListener, IRCEvent
|
|||
guiControl.showCountDown(true);
|
||||
machine.pauseTimer(true);
|
||||
sayScore();
|
||||
|
||||
relaisboard.blinkRelais(2, 500, 6); // hint Button
|
||||
|
||||
break;
|
||||
case ROKET_STARTED:
|
||||
mpdController.setVolume(50);
|
||||
|
@ -131,6 +141,8 @@ public class TheGame implements StatemachineListener, GuiEventListener, IRCEvent
|
|||
|
||||
ircClient.say("table game complete, r0kets now");
|
||||
|
||||
relaisboard.toggleRelais(0, 300);
|
||||
|
||||
guiControl.showCountDown(true);
|
||||
machine.startTimer(7*60);
|
||||
break;
|
||||
|
@ -163,7 +175,7 @@ public class TheGame implements StatemachineListener, GuiEventListener, IRCEvent
|
|||
@Override
|
||||
public void keyPress(char key) {
|
||||
machine.handleInput(key);
|
||||
guiControl.setExtra("btn: " + key);
|
||||
//guiControl.setExtra("btn: " + key);
|
||||
|
||||
}
|
||||
|
||||
|
@ -175,6 +187,7 @@ public class TheGame implements StatemachineListener, GuiEventListener, IRCEvent
|
|||
machine.reset();
|
||||
bunti.setPar56(0xff,0xff,0xff);
|
||||
ircClient.say("bye");
|
||||
relaisboard.close();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue