From 3660598f315ca152964598717486f0539bd69290 Mon Sep 17 00:00:00 2001 From: PF Date: Fri, 26 May 2017 22:14:59 +0200 Subject: [PATCH] =?UTF-8?q?Commandes=20actionneurs=20par=20t=C3=A9l=C3=A9c?= =?UTF-8?q?ommandes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pc/src/config/ConfigInfo.java | 8 ++++++++ pc/src/remoteControl/Client.java | 10 +++++++++- pc/src/remoteControl/Commandes.java | 19 +++++++++++++------ pc/src/threads/ThreadRemoteControl.java | 18 ++++++++++++++++++ 4 files changed, 48 insertions(+), 7 deletions(-) diff --git a/pc/src/config/ConfigInfo.java b/pc/src/config/ConfigInfo.java index ebf28520..e6889abb 100644 --- a/pc/src/config/ConfigInfo.java +++ b/pc/src/config/ConfigInfo.java @@ -121,6 +121,14 @@ public enum ConfigInfo TURN_LEFT_KEY(37), TURN_RIGHT_KEY(39), RESET_WHEELS_KEY(10), + BAISSE_FILET_KEY(66), + LEVE_FILET_KEY(76), + EJECTE_DROITE_KEY(68), + EJECTE_GAUCHE_KEY(71), + REARME_DROITE_KEY(69), + REARME_GAUCHE_KEY(84), + FERME_FILET_KEY(70), + OUVRE_FILET_KEY(79), /** * Paramètres bas niveau des capteurs diff --git a/pc/src/remoteControl/Client.java b/pc/src/remoteControl/Client.java index 155a9494..2f7d70ba 100644 --- a/pc/src/remoteControl/Client.java +++ b/pc/src/remoteControl/Client.java @@ -57,7 +57,15 @@ public Client(String[] args) throws InterruptedException Commandes.SPEED_UP.setCode(config.getInt(ConfigInfo.SPEED_UP_KEY)); Commandes.TURN_LEFT.setCode(config.getInt(ConfigInfo.TURN_LEFT_KEY)); Commandes.TURN_RIGHT.setCode(config.getInt(ConfigInfo.TURN_RIGHT_KEY)); - + Commandes.BAISSE_FILET.setCode(config.getInt(ConfigInfo.BAISSE_FILET_KEY)); + Commandes.LEVE_FILET.setCode(config.getInt(ConfigInfo.LEVE_FILET_KEY)); + Commandes.EJECTE_DROITE.setCode(config.getInt(ConfigInfo.EJECTE_DROITE_KEY)); + Commandes.EJECTE_GAUCHE.setCode(config.getInt(ConfigInfo.EJECTE_GAUCHE_KEY)); + Commandes.REARME_GAUCHE.setCode(config.getInt(ConfigInfo.REARME_GAUCHE_KEY)); + Commandes.REARME_DROITE.setCode(config.getInt(ConfigInfo.REARME_DROITE_KEY)); + Commandes.FERME_FILET.setCode(config.getInt(ConfigInfo.FERME_FILET_KEY)); + Commandes.OUVRE_FILET.setCode(config.getInt(ConfigInfo.OUVRE_FILET_KEY)); + InetAddress rpiAdresse = null; boolean loop = false; log.debug("Démarrage du client de contrôle à distance"); diff --git a/pc/src/remoteControl/Commandes.java b/pc/src/remoteControl/Commandes.java index 155ba252..762e3f34 100644 --- a/pc/src/remoteControl/Commandes.java +++ b/pc/src/remoteControl/Commandes.java @@ -24,14 +24,21 @@ public enum Commandes implements Serializable { - SPEED_UP(38), SPEED_DOWN(40), TURN_RIGHT(39), TURN_LEFT(37), STOP(32), RESET_WHEELS(10), SHUTDOWN(-1), PING(-1); + SPEED_UP, SPEED_DOWN, + TURN_RIGHT, TURN_LEFT, + STOP, + RESET_WHEELS, + SHUTDOWN, + PING, + LEVE_FILET, BAISSE_FILET, + FERME_FILET, OUVRE_FILET, + EJECTE_GAUCHE, EJECTE_DROITE, + REARME_GAUCHE, REARME_DROITE; - private Commandes(int code) - { - this.code = code; - } + private Commandes() + {} - public int code; + public int code = -1; public void setCode(int code) { diff --git a/pc/src/threads/ThreadRemoteControl.java b/pc/src/threads/ThreadRemoteControl.java index 8c7ae620..d8471fe0 100644 --- a/pc/src/threads/ThreadRemoteControl.java +++ b/pc/src/threads/ThreadRemoteControl.java @@ -264,6 +264,24 @@ else if(c == Commandes.TURN_LEFT || c == Commandes.TURN_RIGHT) data.setCurvature(courbure); } } + else if(c == Commandes.BAISSE_FILET) + data.baisseFilet(); + else if(c == Commandes.LEVE_FILET) + data.leveFilet(); + else if(c == Commandes.OUVRE_FILET) + data.ouvreFilet(); + else if(c == Commandes.FERME_FILET) + data.fermeFilet(); + else if(c == Commandes.EJECTE_DROITE) + data.ejecteBalles(true); + else if(c == Commandes.EJECTE_GAUCHE) + data.ejecteBalles(false); + else if(c == Commandes.REARME_GAUCHE) + data.rearme(false); + else if(c == Commandes.REARME_DROITE) + data.rearme(true); + + else if(c == Commandes.SHUTDOWN) { Thread.sleep(1000);