From 6541012e04909111f504e5a75deb3f9b3cc3070c Mon Sep 17 00:00:00 2001 From: SeekDaSky Date: Thu, 4 May 2017 12:11:42 +0200 Subject: [PATCH] ViewTerm 1.1 --- command-terminal/CommandTerminal/build.xml | 73 - command-terminal/CommandTerminal/manifest.mf | 3 - .../CommandTerminal/nbproject/build-impl.xml | 1413 ----------------- .../nbproject/genfiles.properties | 8 - .../nbproject/project.properties | 73 - .../CommandTerminal/nbproject/project.xml | 15 - .../src/commandterminal/CommandTerminal.java | 69 - .../src/commandterminal/OpCode.java | 20 - command-terminal/commandTerm.jar | Bin 0 -> 11042 bytes .../AsynchronousDatagramSocket.java | 32 +- .../DatagramSocket/SynchronizedBuffer.java | 0 .../ViewTerminal/InvalidFlagException.java | 18 + viewer-terminal/src/ViewTerminal/Plane.java | 108 ++ .../src/ViewTerminal/PlaneContainer.java | 88 + viewer-terminal/src/ViewTerminal/Printer.java | 53 + .../src/ViewTerminal/ViewTerminal.java | 102 ++ viewer-terminal/viewTerm.jar | Bin 9946 -> 9946 bytes 17 files changed, 392 insertions(+), 1683 deletions(-) delete mode 100644 command-terminal/CommandTerminal/build.xml delete mode 100644 command-terminal/CommandTerminal/manifest.mf delete mode 100644 command-terminal/CommandTerminal/nbproject/build-impl.xml delete mode 100644 command-terminal/CommandTerminal/nbproject/genfiles.properties delete mode 100644 command-terminal/CommandTerminal/nbproject/project.properties delete mode 100644 command-terminal/CommandTerminal/nbproject/project.xml delete mode 100644 command-terminal/CommandTerminal/src/commandterminal/CommandTerminal.java delete mode 100644 command-terminal/CommandTerminal/src/commandterminal/OpCode.java create mode 100644 command-terminal/commandTerm.jar rename {command-terminal/CommandTerminal => viewer-terminal}/src/DatagramSocket/AsynchronousDatagramSocket.java (63%) rename {command-terminal/CommandTerminal => viewer-terminal}/src/DatagramSocket/SynchronizedBuffer.java (100%) create mode 100644 viewer-terminal/src/ViewTerminal/InvalidFlagException.java create mode 100644 viewer-terminal/src/ViewTerminal/Plane.java create mode 100644 viewer-terminal/src/ViewTerminal/PlaneContainer.java create mode 100644 viewer-terminal/src/ViewTerminal/Printer.java create mode 100644 viewer-terminal/src/ViewTerminal/ViewTerminal.java diff --git a/command-terminal/CommandTerminal/build.xml b/command-terminal/CommandTerminal/build.xml deleted file mode 100644 index e14409b..0000000 --- a/command-terminal/CommandTerminal/build.xml +++ /dev/null @@ -1,73 +0,0 @@ - - - - - - - - - - - Builds, tests, and runs the project CommandTerminal. - - - diff --git a/command-terminal/CommandTerminal/manifest.mf b/command-terminal/CommandTerminal/manifest.mf deleted file mode 100644 index 328e8e5..0000000 --- a/command-terminal/CommandTerminal/manifest.mf +++ /dev/null @@ -1,3 +0,0 @@ -Manifest-Version: 1.0 -X-COMMENT: Main-Class will be added automatically by build - diff --git a/command-terminal/CommandTerminal/nbproject/build-impl.xml b/command-terminal/CommandTerminal/nbproject/build-impl.xml deleted file mode 100644 index c50f26c..0000000 --- a/command-terminal/CommandTerminal/nbproject/build-impl.xml +++ /dev/null @@ -1,1413 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must set src.dir - Must set test.src.dir - Must set build.dir - Must set dist.dir - Must set build.classes.dir - Must set dist.javadoc.dir - Must set build.test.classes.dir - Must set build.test.results.dir - Must set build.classes.excludes - Must set dist.jar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must set javac.includes - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - No tests executed. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must set JVM to use for profiling in profiler.info.jvm - Must set profiler agent JVM arguments in profiler.info.jvmargs.agent - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must select some files in the IDE or set javac.includes - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - To run this application from the command line without Ant, try: - - java -jar "${dist.jar.resolved}" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must select one file in the IDE or set run.class - - - - Must select one file in the IDE or set run.class - - - - - - - - - - - - - - - - - - - - - - - Must select one file in the IDE or set debug.class - - - - - Must select one file in the IDE or set debug.class - - - - - Must set fix.includes - - - - - - - - - - This target only works when run from inside the NetBeans IDE. - - - - - - - - - Must select one file in the IDE or set profile.class - This target only works when run from inside the NetBeans IDE. - - - - - - - - - This target only works when run from inside the NetBeans IDE. - - - - - - - - - - - - - This target only works when run from inside the NetBeans IDE. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must select one file in the IDE or set run.class - - - - - - Must select some files in the IDE or set test.includes - - - - - Must select one file in the IDE or set run.class - - - - - Must select one file in the IDE or set applet.url - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must select some files in the IDE or set javac.includes - - - - - - - - - - - - - - - - - - - - Some tests failed; see details above. - - - - - - - - - Must select some files in the IDE or set test.includes - - - - Some tests failed; see details above. - - - - Must select some files in the IDE or set test.class - Must select some method in the IDE or set test.method - - - - Some tests failed; see details above. - - - - - Must select one file in the IDE or set test.class - - - - Must select one file in the IDE or set test.class - Must select some method in the IDE or set test.method - - - - - - - - - - - - - - Must select one file in the IDE or set applet.url - - - - - - - - - Must select one file in the IDE or set applet.url - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/command-terminal/CommandTerminal/nbproject/genfiles.properties b/command-terminal/CommandTerminal/nbproject/genfiles.properties deleted file mode 100644 index b22b9e6..0000000 --- a/command-terminal/CommandTerminal/nbproject/genfiles.properties +++ /dev/null @@ -1,8 +0,0 @@ -build.xml.data.CRC32=fdad8e2e -build.xml.script.CRC32=1cd81838 -build.xml.stylesheet.CRC32=8064a381@1.74.1.48 -# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. -# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. -nbproject/build-impl.xml.data.CRC32=fdad8e2e -nbproject/build-impl.xml.script.CRC32=95faf5a3 -nbproject/build-impl.xml.stylesheet.CRC32=876e7a8f@1.74.1.48 diff --git a/command-terminal/CommandTerminal/nbproject/project.properties b/command-terminal/CommandTerminal/nbproject/project.properties deleted file mode 100644 index 9645bed..0000000 --- a/command-terminal/CommandTerminal/nbproject/project.properties +++ /dev/null @@ -1,73 +0,0 @@ -annotation.processing.enabled=true -annotation.processing.enabled.in.editor=false -annotation.processing.processor.options= -annotation.processing.processors.list= -annotation.processing.run.all.processors=true -annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output -build.classes.dir=${build.dir}/classes -build.classes.excludes=**/*.java,**/*.form -# This directory is removed when the project is cleaned: -build.dir=build -build.generated.dir=${build.dir}/generated -build.generated.sources.dir=${build.dir}/generated-sources -# Only compile against the classpath explicitly listed here: -build.sysclasspath=ignore -build.test.classes.dir=${build.dir}/test/classes -build.test.results.dir=${build.dir}/test/results -# Uncomment to specify the preferred debugger connection transport: -#debug.transport=dt_socket -debug.classpath=\ - ${run.classpath} -debug.test.classpath=\ - ${run.test.classpath} -# Files in build.classes.dir which should be excluded from distribution jar -dist.archive.excludes= -# This directory is removed when the project is cleaned: -dist.dir=dist -dist.jar=${dist.dir}/CommandTerminal.jar -dist.javadoc.dir=${dist.dir}/javadoc -excludes= -includes=** -jar.compress=false -javac.classpath= -# Space-separated list of extra javac options -javac.compilerargs= -javac.deprecation=false -javac.processorpath=\ - ${javac.classpath} -javac.source=1.8 -javac.target=1.8 -javac.test.classpath=\ - ${javac.classpath}:\ - ${build.classes.dir} -javac.test.processorpath=\ - ${javac.test.classpath} -javadoc.additionalparam= -javadoc.author=false -javadoc.encoding=${source.encoding} -javadoc.noindex=false -javadoc.nonavbar=false -javadoc.notree=false -javadoc.private=false -javadoc.splitindex=true -javadoc.use=true -javadoc.version=false -javadoc.windowtitle= -main.class=commandterminal.CommandTerminal -manifest.file=manifest.mf -meta.inf.dir=${src.dir}/META-INF -mkdist.disabled=false -platform.active=default_platform -run.classpath=\ - ${javac.classpath}:\ - ${build.classes.dir} -# Space-separated list of JVM arguments used when running the project. -# You may also define separate properties like run-sys-prop.name=value instead of -Dname=value. -# To set system properties for unit tests define test-sys-prop.name=value: -run.jvmargs= -run.test.classpath=\ - ${javac.test.classpath}:\ - ${build.test.classes.dir} -source.encoding=UTF-8 -src.dir=src -test.src.dir=test diff --git a/command-terminal/CommandTerminal/nbproject/project.xml b/command-terminal/CommandTerminal/nbproject/project.xml deleted file mode 100644 index 30bb371..0000000 --- a/command-terminal/CommandTerminal/nbproject/project.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - org.netbeans.modules.java.j2seproject - - - CommandTerminal - - - - - - - - - diff --git a/command-terminal/CommandTerminal/src/commandterminal/CommandTerminal.java b/command-terminal/CommandTerminal/src/commandterminal/CommandTerminal.java deleted file mode 100644 index 013377a..0000000 --- a/command-terminal/CommandTerminal/src/commandterminal/CommandTerminal.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ - -package commandterminal; - -import java.io.IOException; -import java.net.DatagramPacket; -import java.net.DatagramSocket; -import java.net.InetAddress; -import java.net.SocketException; -import java.net.UnknownHostException; -import java.nio.ByteBuffer; - -/** - * - * @author lmascaro - */ -public class CommandTerminal { - - private final static int SGCA_MULTICAST_PORT = 4446; - private final static String SCGA_MULTICAST_ADDRESS = "224.0.0.3"; - - /** - * @param args the command line arguments - */ - public static void main(String[] args){ - - /* - * Handshake - */ - - try { - DatagramSocket socket = new DatagramSocket(); - ByteBuffer buf = ByteBuffer.allocate(21); - buf.clear(); - buf.put((byte)(0x01|0x02)); - - DatagramPacket payload = new DatagramPacket(buf.array(),buf.array().length,InetAddress.getByName(SCGA_MULTICAST_ADDRESS),SGCA_MULTICAST_PORT); - socket.send(payload); - - socket.receive(payload); - - buf = ByteBuffer.wrap(payload.getData()); - - if(buf.get() == 3){ - System.out.println("--Connection request successful"); - byte address[] = new byte[15]; - buf = buf.get(address,0,15); - String addressString = new String(address); - InetAddress sgcaAddress = InetAddress.getByName(addressString); - //emulate an unsigned short - char cast = buf.getChar(); - int port = (int) cast; - System.out.println("----Address : "+sgcaAddress.getHostAddress()); - System.out.println("----Port : "+port); - } - - } catch ( IOException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - - - } - -} diff --git a/command-terminal/CommandTerminal/src/commandterminal/OpCode.java b/command-terminal/CommandTerminal/src/commandterminal/OpCode.java deleted file mode 100644 index 3183b8c..0000000 --- a/command-terminal/CommandTerminal/src/commandterminal/OpCode.java +++ /dev/null @@ -1,20 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ - -package commandterminal; - -/** - * - * @author lmascaro - */ -public enum OpCode { - ISALIVE, - CAP, - ALT, - SPEED, - SUCCESS, - ERROR -} diff --git a/command-terminal/commandTerm.jar b/command-terminal/commandTerm.jar new file mode 100644 index 0000000000000000000000000000000000000000..dc9885c93c66a3254c7124ce06a0c71fbd9d515d GIT binary patch literal 11042 zcmaia1ymi`vNjF}cXzh~!QFzpI|O%kC%6W8cMa|y+}+(B0vtlH1o)GC-&-?xX72l| z*IBE(&+h8oySl5ss;`t}A)zqA;NalE*c!RGEdRh95+M?;5;i8$Of^e70Kdu zbecMxA8=i4raN61Q1;nJLYP2)W&(`AoHc)dSqY^61X#oJnJf_nL7c(dAo9Ao!Zp2kSi*G7P8~8!om90K?sgz}@{Gtx zj7(jU4+ZmjyN4Y=gNii4z{Q-@M$iH~&_yBrPHCPS^rB^l4O$^{3j65!qYrpvS&I0O z5&6SUw5O`v^gDnod$6)Nb{SuV1i5GP;NuR_dH8H=bgcL$B^uY9QF`FA+8tA^KHhlA zu%=0>!26H(zWZPp229;?ov-pdKqkfz=NbECs5WBNqH$Ichyy~$Tf4QBn6C@H(VAeB zXa1IXsjzUCosylF0Y;ww&Jm`z&iAu9D@|Dqz|}RS-!)BxJ%A-!9j8FQ#Am#hr)#{4 zvAkFiu#eWxJ)zq|0Kpx%f;hSBrb1ELVO5Dm{TezZ4w?3Dq9c=mVLlh<6u1&XRcK7E z7r_9t-K&m0B#ndYQPvbuC}WJD4tbs3V`)yab=gS51j>bbwJ&WQIgNX$0?}KR~J+2gb^I~vW%7+qFG!9kaUC& z8`==tCDfu#9vDut9ljAKNYAj?5lJ{mArMFH%!)~U``Gbhp-3ElZ794es>aZX(WE<~ z2n~`B#MpM*w7uW%qYL~Ikv*%^oP~Q!_^rCAjO(y-(*wsOt;RnZv=Q;0-Ns99d*mse zIqr;~>Cl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b9Qh|-WWcXNI%;0%KKAyQuOKr95B1Z*?SjloutSmv8;gK+us?@=gGF1q*suuQ#AY_JniSD_lhx4e-6w4z5Nl% zRrGZVVV9fjW8#y5`tX9a5<{A7je?JC$YGFlUafk4&30;WJ!=-ITo3-?& zY=jRk8W)^l(#ai4d4>P3u6t7eI-Tg+VL@{HV6E6#34~sboE5RAriE+3!>%!&mi|}? zjtuS_E7wn#$cZ=>{&w}dpC3j>$ZLl9Giqctd3q*6uEYxuX|H(Js9weXBF|(Eg*0)U zzfRzLN30NRPaVAckp0rp8vXW(wu|t`O$E*e*c7O+Hoo^r5?;(TH@=8la!Mozyy2hk zxQ@LykF4F-zIh_3|JYnA&HBcCL&Y=Al3RPjVZqA7H&#DLUaLZi=`Z+n8qH9Q{WvT? z(faR_2y$ZS=;SYc^6FpwBsc^n*dLvMf9}is-3j=g^56Obm1Myo;KBYGb^h+*`$Inc z+WiZY_6vmmF^AuUnLl^8{O;-dLppx#{_W~NcliBP)t{-@-|aAe$oQ`X_?xOfnq&T| z=+C_2Z|3$7vHZ1)e^vC~dE7ti{mnZ5xjglob^Jr1eqs5)>ix^{zr*vNRsLSSKPLmf z>so)vckI8b{HH3{Z;k)WoWGNZKVA&-mw8 m_&1{YLw3miru6@ZZGvM+nx6S literal 0 HcmV?d00001 diff --git a/command-terminal/CommandTerminal/src/DatagramSocket/AsynchronousDatagramSocket.java b/viewer-terminal/src/DatagramSocket/AsynchronousDatagramSocket.java similarity index 63% rename from command-terminal/CommandTerminal/src/DatagramSocket/AsynchronousDatagramSocket.java rename to viewer-terminal/src/DatagramSocket/AsynchronousDatagramSocket.java index 86f45e3..c112bad 100644 --- a/command-terminal/CommandTerminal/src/DatagramSocket/AsynchronousDatagramSocket.java +++ b/viewer-terminal/src/DatagramSocket/AsynchronousDatagramSocket.java @@ -13,16 +13,20 @@ import java.net.SocketException; import java.util.logging.Level; import java.util.logging.Logger; +import ViewTerminal.InvalidFlagException; +import ViewTerminal.PlaneContainer; + /** * * @author lmascaro */ public class AsynchronousDatagramSocket implements Runnable, AutoCloseable{ - private final static int MAX_MESSAGE_SIZE = 300; + public final static int MAX_MESSAGE_SIZE = 300; private SynchronizedBuffer buf; private DatagramSocket socket; + private PlaneContainer container; public AsynchronousDatagramSocket() throws SocketException{ this.buf = new SynchronizedBuffer<>(); @@ -36,6 +40,10 @@ public class AsynchronousDatagramSocket implements Runnable, AutoCloseable{ new Thread(this).start(); } + public void bindContainer(PlaneContainer c){ + this.container = c; + } + public void send(DatagramPacket dp) throws IOException{ this.socket.send(dp); } @@ -49,8 +57,8 @@ public class AsynchronousDatagramSocket implements Runnable, AutoCloseable{ } } - public void synchronousReceive(DatagramPacket dp){ - dp = this.buf.removeElement(true); + public DatagramPacket synchronousReceive(){ + return this.buf.removeElement(true); } public boolean available(){ @@ -64,12 +72,18 @@ public class AsynchronousDatagramSocket implements Runnable, AutoCloseable{ @Override public void run() { - DatagramPacket packet = new DatagramPacket(new byte[MAX_MESSAGE_SIZE],MAX_MESSAGE_SIZE); - try { - this.socket.receive(packet); - this.buf.addElement(packet); - } catch (IOException ex) { - Logger.getLogger(AsynchronousDatagramSocket.class.getName()).log(Level.SEVERE, null, ex); + DatagramPacket packet; + while(true){ + packet = new DatagramPacket(new byte[MAX_MESSAGE_SIZE],MAX_MESSAGE_SIZE); + try { + this.socket.receive(packet); + this.buf.addElement(packet); + this.container.notifyReceive(); + } catch (IOException ex) { + Logger.getLogger(AsynchronousDatagramSocket.class.getName()).log(Level.SEVERE, null, ex); + } catch (InvalidFlagException e) { + System.out.println("\033[01;31m Unexpected flag received \033[0m"); + } } } } diff --git a/command-terminal/CommandTerminal/src/DatagramSocket/SynchronizedBuffer.java b/viewer-terminal/src/DatagramSocket/SynchronizedBuffer.java similarity index 100% rename from command-terminal/CommandTerminal/src/DatagramSocket/SynchronizedBuffer.java rename to viewer-terminal/src/DatagramSocket/SynchronizedBuffer.java diff --git a/viewer-terminal/src/ViewTerminal/InvalidFlagException.java b/viewer-terminal/src/ViewTerminal/InvalidFlagException.java new file mode 100644 index 0000000..e4fbc91 --- /dev/null +++ b/viewer-terminal/src/ViewTerminal/InvalidFlagException.java @@ -0,0 +1,18 @@ +package ViewTerminal; + +public class InvalidFlagException extends Exception { + + /** + * + */ + private static final long serialVersionUID = 1L; + + public InvalidFlagException(){ + super(); + } + + public InvalidFlagException(String message){ + super(message); + } + +} diff --git a/viewer-terminal/src/ViewTerminal/Plane.java b/viewer-terminal/src/ViewTerminal/Plane.java new file mode 100644 index 0000000..0e11ede --- /dev/null +++ b/viewer-terminal/src/ViewTerminal/Plane.java @@ -0,0 +1,108 @@ +package ViewTerminal; + +public class Plane { + + private String code; + private int x; + private int y; + private int z; + private int cap; + private int speed; + + private boolean isDead; + + public Plane(String code,int x, int y, int z, int cap, int speed){ + this.code = code; + this.x = x; + this.y = y; + this.z = z; + this.cap = cap; + this.speed = speed; + this.isDead = false; + } + + public String getCode() { + return code; + } + + public void setCode(String code) { + this.code = code; + } + + public int getX() { + return x; + } + + public void setX(int x) { + this.x = x; + } + + public int getY() { + return y; + } + + public void setY(int y) { + this.y = y; + } + + public int getZ() { + return z; + } + + public void setZ(int z) { + this.z = z; + } + + public int getCap() { + return cap; + } + + public boolean isDead(){ + return this.isDead; + } + + public void setCap(int cap) { + this.cap = cap; + } + + public int getSpeed() { + return speed; + } + + public void setSpeed(int speed) { + this.speed = speed; + } + + //Die Motherfucker + public void die(){ + this.isDead = true; + } + + public String getLine(int i){ + switch(i){ + case 0: + return "--------------------------------"; + case 1: + if(this.isDead){ + return "\033[4;37;41m Code: "+this.code+"\t\t\t|"; + }else{ + return "\033[4;37;42m Code: "+this.code+"\t\t\t|"; + } + case 2: + return "\033[0m --Coords: {"+this.x+";"+this.y+";"+this.z+"} \t|"; + case 3: + return "\033[0m --Cap: "+this.cap+"\t\t\t|"; + case 4: + if(this.isDead){ + return "\033[4;37;41m ATTENTION: avion hors ligne\t|\033[0m"; + }else if(this.speed<50){ + return "\033[5;37;41m --Speed: "+this.speed+"\t\t\t|\033[0m"; + }else{ + return "\033[0m --Speed: "+this.speed+"\t\t\t|"; + } + default: + return ""; + } + } + +} diff --git a/viewer-terminal/src/ViewTerminal/PlaneContainer.java b/viewer-terminal/src/ViewTerminal/PlaneContainer.java new file mode 100644 index 0000000..98740f5 --- /dev/null +++ b/viewer-terminal/src/ViewTerminal/PlaneContainer.java @@ -0,0 +1,88 @@ +package ViewTerminal; + +import java.net.DatagramPacket; +import java.nio.ByteBuffer; +import java.util.ArrayList; +import java.util.HashMap; + +import DatagramSocket.AsynchronousDatagramSocket; + +public class PlaneContainer { + + private HashMap map; + private AsynchronousDatagramSocket socket; + private Printer printer; + + public PlaneContainer(){ + this.map = new HashMap(); + } + + public void bindSocket(AsynchronousDatagramSocket s){ + this.socket = s; + } + + public void bindPrinter(Printer p){ + this.printer = p; + } + + public void notifyReceive() throws InvalidFlagException{ + DatagramPacket packet = this.socket.synchronousReceive(); + + ByteBuffer buf = ByteBuffer.wrap(packet.getData()); + + byte flag; + byte nbrPlane; + ArrayList codes; + + flag = buf.get(); + nbrPlane = buf.get(); + + codes = new ArrayList(nbrPlane); + + //System.out.println("Processing "+nbrPlane+" planes"); + + if(flag != 1){ + throw new InvalidFlagException("Flag is not a feedback flag :"+flag); + }else{ + String code; + byte rawCode[] = new byte[5]; + Plane plane; + for(int i = 0;i getMap(){ + return this.map; + } +} diff --git a/viewer-terminal/src/ViewTerminal/Printer.java b/viewer-terminal/src/ViewTerminal/Printer.java new file mode 100644 index 0000000..2dd779b --- /dev/null +++ b/viewer-terminal/src/ViewTerminal/Printer.java @@ -0,0 +1,53 @@ +package ViewTerminal; + +import java.util.HashMap; + +public class Printer { + + private PlaneContainer container; + + public Printer(){ + + } + + public void bindContainer(PlaneContainer c){ + this.container = c; + } + + public void notifyReceive(){ + System.out.println("\033[2J \033[H"); + HashMap map = this.container.getMap(); + int i = 0; + + String lines[] = new String[5]; + for(int k = 0;k<5;k++){ + lines[k] = ""; + } + + if(map.keySet().size() == 0){ + System.out.println("\033[37;43m Aucun avion connecté au système \033[0m"); + }else{ + for(String code : map.keySet()){ + if(i <= 1){ + for(int k = 0;k<5;k++){ + lines[k] += map.get(code).getLine(k); + } + i++; + }else{ + for(int k = 0;k<5;k++){ + System.out.println(lines[k]); + lines[k] = ""; + } + for(int k = 0;k<5;k++){ + lines[k] += map.get(code).getLine(k); + } + i=1; + } + } + for(int k = 0;k<5;k++){ + System.out.println(lines[k]); + } + } + + } +} diff --git a/viewer-terminal/src/ViewTerminal/ViewTerminal.java b/viewer-terminal/src/ViewTerminal/ViewTerminal.java new file mode 100644 index 0000000..74f1a29 --- /dev/null +++ b/viewer-terminal/src/ViewTerminal/ViewTerminal.java @@ -0,0 +1,102 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ + +package ViewTerminal; + +import java.io.IOException; +import java.net.DatagramPacket; +import java.net.DatagramSocket; +import java.net.InetAddress; +import java.net.SocketException; +import java.net.UnknownHostException; +import java.nio.ByteBuffer; + +import DatagramSocket.AsynchronousDatagramSocket; + +/** + * + * @author lmascaro + */ +public class ViewTerminal { + + private final static int SGCA_MULTICAST_PORT = 4445; + private final static String SCGA_MULTICAST_ADDRESS = "224.0.0.2"; + + /** + * @param args the command line arguments + */ + public static void main(String[] args){ + System.out.println("\033[2J"); + + /* + * Handshake + */ + int port = 0; + String addressString = "0.0.0.0"; + + try { + DatagramSocket socket = new DatagramSocket(); + ByteBuffer buf = ByteBuffer.allocate(21); + buf.clear(); + buf.put((byte)(0x01)); + + DatagramPacket payload = new DatagramPacket(buf.array(),buf.array().length,InetAddress.getByName(SCGA_MULTICAST_ADDRESS),SGCA_MULTICAST_PORT); + socket.send(payload); + + socket.receive(payload); + + buf = ByteBuffer.wrap(payload.getData()); + if(buf.get() == 1){ + System.out.println("--Connection request successful"); + byte address[] = new byte[4]; + buf = buf.get(address,0,4); + InetAddress addressObj = InetAddress.getByAddress(address); + addressString = addressObj.getHostAddress(); + //emulate an unsigned short + char cast = buf.getChar(); + port = (int) cast; + System.out.println("----Address : "+addressString); + System.out.println("----Port : "+port); + } + + } catch ( IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + return; + } + + /* + * Opening final socket + */ + try { + //create all objects + AsynchronousDatagramSocket socket = new AsynchronousDatagramSocket(); + PlaneContainer container = new PlaneContainer(); + Printer printer = new Printer(); + + //bind them + socket.bindContainer(container); + container.bindPrinter(printer); + container.bindSocket(socket); + printer.bindContainer(container); + + //send first packet + DatagramPacket p = new DatagramPacket(new byte[13],13,InetAddress.getByName(addressString),port); + socket.send(p); + + //now we let the objects do the job + while(true){ + + } + + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + } + +} diff --git a/viewer-terminal/viewTerm.jar b/viewer-terminal/viewTerm.jar index a1b6ac635bc4a7711f2229b0827905691269575e..af0702d73563ba28d506b35025ce3613d0482170 100644 GIT binary patch delta 31 lcmccRd&`$Mz?+#xgn@&DgW-Mk;*Gpll$n9_<|oSEm;j{d3$6eF delta 31 lcmccRd&`$Mz?+#xgn@&DgMoMNtc|=^l$n9_<|oSEm;jWq3S0mH