mirror of
https://github.com/michaelrausch/Party-Parrots-At-Sea.git
synced 2026-05-09 06:18:44 +00:00
Got the live ac35 data working in paralell with the parse and the app.
#story[820]
This commit is contained in:
@@ -5,16 +5,26 @@ import javafx.fxml.FXMLLoader;
|
||||
import javafx.scene.Parent;
|
||||
import javafx.scene.Scene;
|
||||
import javafx.stage.Stage;
|
||||
import seng302.models.parsers.StreamParser;
|
||||
import seng302.models.parsers.StreamReceiver;
|
||||
|
||||
public class App extends Application
|
||||
{
|
||||
@Override
|
||||
public void start(Stage primaryStage) throws Exception {
|
||||
|
||||
Parent root = FXMLLoader.load(getClass().getResource("/views/MainView.fxml"));
|
||||
primaryStage.setTitle("RaceVision");
|
||||
primaryStage.setScene(new Scene(root));
|
||||
|
||||
primaryStage.show();
|
||||
StreamReceiver sr = new StreamReceiver("csse-s302staff.canterbury.ac.nz", 4941,"TestThread1");
|
||||
// StreamReceiver sr = new StreamReceiver("livedata.americascup.com", 4941, "TestThread1");
|
||||
sr.start();
|
||||
StreamParser streamParser = new StreamParser("TestThread2");
|
||||
|
||||
streamParser.start();
|
||||
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
@@ -135,9 +135,7 @@ public class CanvasController {
|
||||
// e.printStackTrace();
|
||||
//}
|
||||
|
||||
StreamReceiver sr = new StreamReceiver("csse-s302staff.canterbury.ac.nz", 4941,"TestThread1");
|
||||
// StreamReceiver sr = new StreamReceiver("livedata.americascup.com", 4941, "TestThread1");
|
||||
sr.start();
|
||||
|
||||
|
||||
timer = new AnimationTimer() {
|
||||
private int countdown = 60;
|
||||
|
||||
@@ -19,11 +19,11 @@ public class StreamPacket {
|
||||
this.payload = payload;
|
||||
//System.out.println("type = " + this.type.toString());
|
||||
//switch the packet type to deal with what ever specific packet you want to deal with
|
||||
if (this.type == PacketType.XML_MESSAGE){
|
||||
//System.out.println("--------");
|
||||
System.out.println(new String(payload));
|
||||
StreamParser.parsePacket(this);
|
||||
}
|
||||
// if (this.type == PacketType.XML_MESSAGE){
|
||||
// //System.out.println("--------");
|
||||
// System.out.println(new String(payload));
|
||||
// StreamParser.parsePacket(this);
|
||||
// }
|
||||
}
|
||||
|
||||
PacketType getType() {
|
||||
|
||||
@@ -29,21 +29,25 @@ public class StreamParser extends Thread{
|
||||
private String threadName;
|
||||
private Thread t;
|
||||
|
||||
StreamParser(String threadName){
|
||||
public StreamParser(String threadName){
|
||||
this.threadName = threadName;
|
||||
}
|
||||
|
||||
public void run(){
|
||||
try {
|
||||
while (StreamReceiver.packetBuffer.size() <= 1) {
|
||||
System.out.println("START OF STREAM");
|
||||
while (StreamReceiver.packetBuffer == null || StreamReceiver.packetBuffer.size() < 1) {
|
||||
Thread.sleep(1);
|
||||
}
|
||||
while (StreamReceiver.packetBuffer.peek() != null){
|
||||
StreamPacket packet = StreamReceiver.packetBuffer.take();
|
||||
while (packet != null){
|
||||
parsePacket(packet);
|
||||
Thread.sleep(10);
|
||||
packet = StreamReceiver.packetBuffer.take();
|
||||
while (StreamReceiver.packetBuffer.peek() == null) {
|
||||
Thread.sleep(1);
|
||||
}
|
||||
}
|
||||
System.out.println("END OF STREAM");
|
||||
} catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
@@ -39,9 +39,7 @@ public class StreamReceiver extends Thread {
|
||||
});
|
||||
packetBuffer = pq;
|
||||
connect();
|
||||
StreamParser streamParser = new StreamParser("TestThread2");
|
||||
|
||||
streamParser.start();
|
||||
}
|
||||
|
||||
public void start () {
|
||||
|
||||
Reference in New Issue
Block a user