mirror of
https://github.com/michaelrausch/Party-Parrots-At-Sea.git
synced 2026-05-09 14:28:43 +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.Parent;
|
||||||
import javafx.scene.Scene;
|
import javafx.scene.Scene;
|
||||||
import javafx.stage.Stage;
|
import javafx.stage.Stage;
|
||||||
|
import seng302.models.parsers.StreamParser;
|
||||||
|
import seng302.models.parsers.StreamReceiver;
|
||||||
|
|
||||||
public class App extends Application
|
public class App extends Application
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
public void start(Stage primaryStage) throws Exception {
|
public void start(Stage primaryStage) throws Exception {
|
||||||
|
|
||||||
Parent root = FXMLLoader.load(getClass().getResource("/views/MainView.fxml"));
|
Parent root = FXMLLoader.load(getClass().getResource("/views/MainView.fxml"));
|
||||||
primaryStage.setTitle("RaceVision");
|
primaryStage.setTitle("RaceVision");
|
||||||
primaryStage.setScene(new Scene(root));
|
primaryStage.setScene(new Scene(root));
|
||||||
|
|
||||||
primaryStage.show();
|
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) {
|
public static void main(String[] args) {
|
||||||
|
|||||||
@@ -135,9 +135,7 @@ public class CanvasController {
|
|||||||
// e.printStackTrace();
|
// 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() {
|
timer = new AnimationTimer() {
|
||||||
private int countdown = 60;
|
private int countdown = 60;
|
||||||
|
|||||||
@@ -19,11 +19,11 @@ public class StreamPacket {
|
|||||||
this.payload = payload;
|
this.payload = payload;
|
||||||
//System.out.println("type = " + this.type.toString());
|
//System.out.println("type = " + this.type.toString());
|
||||||
//switch the packet type to deal with what ever specific packet you want to deal with
|
//switch the packet type to deal with what ever specific packet you want to deal with
|
||||||
if (this.type == PacketType.XML_MESSAGE){
|
// if (this.type == PacketType.XML_MESSAGE){
|
||||||
//System.out.println("--------");
|
// //System.out.println("--------");
|
||||||
System.out.println(new String(payload));
|
// System.out.println(new String(payload));
|
||||||
StreamParser.parsePacket(this);
|
// StreamParser.parsePacket(this);
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
PacketType getType() {
|
PacketType getType() {
|
||||||
|
|||||||
@@ -29,21 +29,25 @@ public class StreamParser extends Thread{
|
|||||||
private String threadName;
|
private String threadName;
|
||||||
private Thread t;
|
private Thread t;
|
||||||
|
|
||||||
StreamParser(String threadName){
|
public StreamParser(String threadName){
|
||||||
this.threadName = threadName;
|
this.threadName = threadName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void run(){
|
public void run(){
|
||||||
try {
|
try {
|
||||||
while (StreamReceiver.packetBuffer.size() <= 1) {
|
System.out.println("START OF STREAM");
|
||||||
|
while (StreamReceiver.packetBuffer == null || StreamReceiver.packetBuffer.size() < 1) {
|
||||||
Thread.sleep(1);
|
Thread.sleep(1);
|
||||||
}
|
}
|
||||||
|
while (StreamReceiver.packetBuffer.peek() != null){
|
||||||
StreamPacket packet = StreamReceiver.packetBuffer.take();
|
StreamPacket packet = StreamReceiver.packetBuffer.take();
|
||||||
while (packet != null){
|
|
||||||
parsePacket(packet);
|
parsePacket(packet);
|
||||||
Thread.sleep(10);
|
Thread.sleep(10);
|
||||||
packet = StreamReceiver.packetBuffer.take();
|
while (StreamReceiver.packetBuffer.peek() == null) {
|
||||||
|
Thread.sleep(1);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
System.out.println("END OF STREAM");
|
||||||
} catch (Exception e){
|
} catch (Exception e){
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -39,9 +39,7 @@ public class StreamReceiver extends Thread {
|
|||||||
});
|
});
|
||||||
packetBuffer = pq;
|
packetBuffer = pq;
|
||||||
connect();
|
connect();
|
||||||
StreamParser streamParser = new StreamParser("TestThread2");
|
|
||||||
|
|
||||||
streamParser.start();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void start () {
|
public void start () {
|
||||||
|
|||||||
Reference in New Issue
Block a user