diff --git a/ctrlTerm/commandTerm.jar b/ctrlTerm/commandTerm.jar index 562e7b4..a4f6a3d 100644 Binary files a/ctrlTerm/commandTerm.jar and b/ctrlTerm/commandTerm.jar differ diff --git a/ctrlTerm/src/ControlTerminal/ControlTerminal.java b/ctrlTerm/src/ControlTerminal/ControlTerminal.java index fea2a93..a9999ab 100644 --- a/ctrlTerm/src/ControlTerminal/ControlTerminal.java +++ b/ctrlTerm/src/ControlTerminal/ControlTerminal.java @@ -167,7 +167,11 @@ public class ControlTerminal { plane.setSpeed(data); flags = (byte) (flags|0x04); break; - } + default: + System.out.println("Wrong input please retry"); + s.nextLine(); + break; + } }catch(Exception e){ System.out.println("Wrong input please retry"); s.nextLine(); @@ -180,7 +184,7 @@ public class ControlTerminal { break; } } - System.out.println("flags: "+flags); + container.setExpectedFlags(flags); buf = ByteBuffer.allocate(27); buf.put(flags); buf.put(plane.toBytes()); diff --git a/ctrlTerm/src/ControlTerminal/Plane.java b/ctrlTerm/src/ControlTerminal/Plane.java index a437024..adb19cb 100644 --- a/ctrlTerm/src/ControlTerminal/Plane.java +++ b/ctrlTerm/src/ControlTerminal/Plane.java @@ -98,7 +98,7 @@ public class Plane{ case 4: if(this.isDead){ return "\033[4;37;41m ATTENTION: avion hors ligne\t|\033[0m"; - }else if(this.speed<50){ + }else if(this.speed<300){ return "\033[5;37;41m --Speed: "+this.speed+"\t\t\t|\033[0m"; }else{ return "\033[0m --Speed: "+this.speed+"\t\t\t|"; diff --git a/ctrlTerm/src/ControlTerminal/PlaneContainer.java b/ctrlTerm/src/ControlTerminal/PlaneContainer.java index fdbb4b4..ba82d67 100644 --- a/ctrlTerm/src/ControlTerminal/PlaneContainer.java +++ b/ctrlTerm/src/ControlTerminal/PlaneContainer.java @@ -12,6 +12,7 @@ public class PlaneContainer { private HashMap map; private AsynchronousDatagramSocket socket; private Printer printer; + private byte expectedFlags = 0x01; public PlaneContainer(){ this.map = new HashMap(); @@ -25,6 +26,10 @@ public class PlaneContainer { this.printer = p; } + public void setExpectedFlags(byte flags){ + this.expectedFlags = flags; + } + public void notifyReceive() throws InvalidFlagException{ DatagramPacket packet = this.socket.synchronousReceive(); @@ -41,6 +46,19 @@ public class PlaneContainer { //System.out.println("Processing "+nbrPlane+" planes"); + if(this.expectedFlags != flag){ + System.out.println("\033[5;37;41m Plane could not apply data \033[0m"); + if((flag&(byte)0x10) == 1){ + System.out.println("\033[5;37;41m Plane crashed gracefully \033[0m"); + } + try { + Thread.sleep(2000); + } catch (InterruptedException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + if(flag == 0){ //this is a ping response return; diff --git a/viewTerm/src/ViewTerminal/Plane.java b/viewTerm/src/ViewTerminal/Plane.java index 0e11ede..00579a6 100644 --- a/viewTerm/src/ViewTerminal/Plane.java +++ b/viewTerm/src/ViewTerminal/Plane.java @@ -95,7 +95,7 @@ public class Plane { case 4: if(this.isDead){ return "\033[4;37;41m ATTENTION: avion hors ligne\t|\033[0m"; - }else if(this.speed<50){ + }else if(this.speed<300){ return "\033[5;37;41m --Speed: "+this.speed+"\t\t\t|\033[0m"; }else{ return "\033[0m --Speed: "+this.speed+"\t\t\t|"; diff --git a/viewTerm/viewTerm.jar b/viewTerm/viewTerm.jar index 5dafac4..0c8f5a6 100644 Binary files a/viewTerm/viewTerm.jar and b/viewTerm/viewTerm.jar differ