Browse Source

Integrate warning system with many problem

Valentin 2 years ago
parent
commit
1ce48221d1

+ 25 - 0
Pigou/src/fr/deltastar/pigou/model/constant/WarningConstants.java

@@ -0,0 +1,25 @@
+/*
+ * 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 fr.deltastar.pigou.model.constant;
+
+/**
+ *
+ * @author Valentin
+ */
+public class WarningConstants {
+
+    public final static int WARNING_HOVERHEATED = 1;
+    public final static int WARNING_SAS_PROBLEM = 2;
+    public final static int WARNING_ENGINE_PROBLEM = 3;
+    public final static int WARNING_FUEL_LOW = 4;
+    public final static int WARNING_O2N2_LOW = 5;
+    public final static int WARNING_LIFESUPPORT = 6;
+    public final static int WARNING_POWER_LOW = 7;
+    public final static int WARNING_RADIATOR_PROBLEM = 8;
+    public final static int WARNING_GEAR_PROBLEM = 9;
+    public final static int WARNING_COMPUTER_PROBLEM = 10;
+    
+}

+ 43 - 2
Pigou/src/fr/deltastar/pigou/model/panel/module/warning/WarningModule.java

@@ -2,6 +2,7 @@ package fr.deltastar.pigou.model.panel.module.warning;
 
 import fr.deltastar.pigou.model.constant.ComponentConstants;
 import fr.deltastar.pigou.model.panel.Component;
+import fr.deltastar.pigou.model.panel.DeltaStar;
 import fr.deltastar.pigou.model.panel.ModuleInterface;
 import java.util.ArrayList;
 import java.util.List;
@@ -37,10 +38,51 @@ public class WarningModule implements ModuleInterface {
         this.ledRed10 = new Component(ComponentConstants.OUTPUT, "Led red 10");
         this.buttonReset = new Component(ComponentConstants.INPUT, "Warning reset - Button");
     }
+
+    public Component getLedRed1() {
+        return ledRed1;
+    }
+
+    public Component getLedRed2() {
+        return ledRed2;
+    }
+
+    public Component getLedRed3() {
+        return ledRed3;
+    }
+
+    public Component getLedRed4() {
+        return ledRed4;
+    }
+
+    public Component getLedRed5() {
+        return ledRed5;
+    }
+
+    public Component getLedRed6() {
+        return ledRed6;
+    }
+
+    public Component getLedRed7() {
+        return ledRed7;
+    }
+
+    public Component getLedRed8() {
+        return ledRed8;
+    }
+
+    public Component getLedRed9() {
+        return ledRed9;
+    }
+
+    public Component getLedRed10() {
+        return ledRed10;
+    }
     
     @Override
     public List<Component> getListComponents() {
         List<Component> c = new ArrayList<>();
+        c.add(this.buttonReset);
         c.add(this.ledRed1);
         c.add(this.ledRed2);
         c.add(this.ledRed3);
@@ -51,7 +93,6 @@ public class WarningModule implements ModuleInterface {
         c.add(this.ledRed8);
         c.add(this.ledRed9);
         c.add(this.ledRed10);
-        c.add(this.buttonReset);
         return c;
     }
 
@@ -61,7 +102,7 @@ public class WarningModule implements ModuleInterface {
      * Desactive tout les voyants
      */
     public void onAction(boolean activate) {
-        
+        DeltaStar.getWarningSystem().stopAlert();
     }
 
     @Override

+ 3 - 0
Pigou/src/fr/deltastar/pigou/model/panel/system/EngineSystem.java

@@ -4,6 +4,7 @@ package fr.deltastar.pigou.model.panel.system;
 import fr.deltastar.pigou.constant.CmdOrbiterConstants;
 import fr.deltastar.pigou.constant.Constants;
 import fr.deltastar.pigou.model.constant.LcdSystemEngineConstants;
+import fr.deltastar.pigou.model.constant.WarningConstants;
 import fr.deltastar.pigou.model.panel.BaseSystem;
 import fr.deltastar.pigou.model.panel.DeltaStar;
 import fr.deltastar.pigou.model.panel.ModuleInterface;
@@ -115,11 +116,13 @@ public class EngineSystem extends BaseSystem implements SystemLcdInterface {
                     try {
                         Thread.sleep(Constants.TIME_DISPLAY_ALERT_ENGINE);
                         if (qtyMainFuel <= Constants.LIMIT_MAIN_FUEL_ALERT) {
+                            DeltaStar.getWarningSystem().displayAlert(WarningConstants.WARNING_FUEL_LOW);
                             DeltaStar.getEngineSystem().getArduinoComLcd().setLcdMod(LcdSystemEngineConstants.MAIN_FUEL_LOW);
                             Thread.sleep(Constants.TIME_DISPLAY_ALERT_ENGINE);
                             DeltaStar.getEngineSystem().getArduinoComLcd().setLcdMod(LcdSystemEngineConstants.DISPLAY_FUEL);
                         }
                         if (qtyRcsFuel <= Constants.LIMIT_RCS_FUEL_ALERT) {
+                            DeltaStar.getWarningSystem().displayAlert(WarningConstants.WARNING_FUEL_LOW);
                             DeltaStar.getEngineSystem().getArduinoComLcd().setLcdMod(LcdSystemEngineConstants.RCS_FUEL_LOW);
                             Thread.sleep(Constants.TIME_DISPLAY_ALERT_ENGINE);
                             DeltaStar.getEngineSystem().getArduinoComLcd().setLcdMod(LcdSystemEngineConstants.DISPLAY_FUEL);

+ 4 - 0
Pigou/src/fr/deltastar/pigou/model/panel/system/LifePackSystem.java

@@ -2,6 +2,7 @@ package fr.deltastar.pigou.model.panel.system;
 
 import fr.deltastar.pigou.constant.Constants;
 import fr.deltastar.pigou.model.constant.LcdSystemLifePackConstants;
+import fr.deltastar.pigou.model.constant.WarningConstants;
 import fr.deltastar.pigou.model.panel.BaseSystem;
 import fr.deltastar.pigou.model.panel.DeltaStar;
 import fr.deltastar.pigou.model.panel.ModuleInterface;
@@ -73,6 +74,7 @@ public class LifePackSystem extends BaseSystem implements SystemLcdInterface {
                             //si le vaisseau est pas dépendant de l'extérieur
                             if (!ServicePigou.getOrbiterService().isPossibleToLive()) {
                                 //si pas de support de survie ou plus d'oxygen/azote
+                                DeltaStar.getWarningSystem().displayAlert(WarningConstants.WARNING_LIFESUPPORT);
                                 Thread.sleep(Constants.INTERVAL_COOLING_O2N2 + 20000);
                                 if (valueO2N2 == 0 || !DeltaStar.getLifePackSystem().getLifePackModule().isOnline()) {
                                     DeltaStar.deadGame();
@@ -170,6 +172,7 @@ public class LifePackSystem extends BaseSystem implements SystemLcdInterface {
                         //selon O2/N2 actuel on agit
                         //seuil d'alert
                         if (valueO2N2 <= Constants.LIMIT_O2N2_ALERT && DeltaStar.getLifePackSystem().isOnline()) {
+                            DeltaStar.getWarningSystem().displayAlert(WarningConstants.WARNING_O2N2_LOW);
                             DeltaStar.getLifePackSystem().getArduinoComLcd().setLcdMod(LcdSystemLifePackConstants.O2N2_LOW);
                             Thread.sleep(Constants.INTERVAL_COOLING_O2N2);
                             DeltaStar.getLifePackSystem().getArduinoComLcd().setLcdMod(LcdSystemLifePackConstants.DISPLAY_O2N2_CELSIUS);
@@ -213,6 +216,7 @@ public class LifePackSystem extends BaseSystem implements SystemLcdInterface {
                                 DeltaStar.getLifePackSystem().getHeaterModule().getLedGreenCoolerGood().switchOff();
                                 DeltaStar.getLifePackSystem().getHeaterModule().getLedRedCoolerBad().switchOn();
                             }
+                            DeltaStar.getWarningSystem().displayAlert(WarningConstants.WARNING_HOVERHEATED);
                             DeltaStar.getLifePackSystem().getArduinoComLcd().setLcdMod(LcdSystemLifePackConstants.SYSTEM_OVERHEATED);
                             Thread.sleep(Constants.INTERVAL_COOLING_O2N2);
                             DeltaStar.getLifePackSystem().getArduinoComLcd().setLcdMod(LcdSystemLifePackConstants.DISPLAY_O2N2_CELSIUS);

+ 2 - 0
Pigou/src/fr/deltastar/pigou/model/panel/system/PowerSystem.java

@@ -2,6 +2,7 @@ package fr.deltastar.pigou.model.panel.system;
 
 import fr.deltastar.pigou.constant.Constants;
 import fr.deltastar.pigou.model.constant.LcdSystemPowerConstants;
+import fr.deltastar.pigou.model.constant.WarningConstants;
 import fr.deltastar.pigou.model.panel.BaseSystem;
 import fr.deltastar.pigou.model.panel.DeltaStar;
 import fr.deltastar.pigou.model.panel.ModuleInterface;
@@ -133,6 +134,7 @@ public class PowerSystem extends BaseSystem implements SystemLcdInterface {
                         qtyPower = qtyPower - (Constants.NB_CONSOMMATION_BASE + consoSupp);
                         //on atteint le seuil on avertis
                         if (qtyPower <= Constants.LIMIT_POWER_BEFORE_ALERT) {
+                            DeltaStar.getWarningSystem().displayAlert(WarningConstants.WARNING_POWER_LOW);
                             DeltaStar.getPowerSystem().getArduinoComLcd().setLcdMod(LcdSystemPowerConstants.APU_LOW);
                             new Thread(new Runnable() {
                                 @Override

+ 22 - 0
Pigou/src/fr/deltastar/pigou/model/panel/system/WarningSystem.java

@@ -1,8 +1,11 @@
 package fr.deltastar.pigou.model.panel.system;
 
+import fr.deltastar.pigou.constant.SoundConstants;
 import fr.deltastar.pigou.model.panel.BaseSystem;
+import fr.deltastar.pigou.model.panel.Component;
 import fr.deltastar.pigou.model.panel.ModuleInterface;
 import fr.deltastar.pigou.model.panel.module.warning.WarningModule;
+import fr.deltastar.pigou.service.ServicePigou;
 import java.util.ArrayList;
 import java.util.List;
 
@@ -14,6 +17,8 @@ public class WarningSystem extends BaseSystem {
 
     private WarningModule warningModule;
     
+    private int lastErrorCode;
+    
     public WarningSystem() {
         this.warningModule = new WarningModule();
         super.isOnline = true; //ce système est toujours disponible
@@ -22,6 +27,23 @@ public class WarningSystem extends BaseSystem {
     public WarningModule getWarningModule() {
         return warningModule;
     }
+    
+    /**
+     * Affiche une alerte sur le tableau de bord
+     * errorCode doit être une constante de WarningConstants
+     * @param errorCode 
+     */
+    public void displayAlert(int errorCode) {
+        this.lastErrorCode = errorCode;
+        ServicePigou.getSoundService().play(SoundConstants.WARNING_ALERT);
+        this.warningModule.getListComponents().get(errorCode).switchBlink();
+    }
+    
+    public void stopAlert() {
+        ServicePigou.getSoundService().stop(SoundConstants.WARNING_ALERT);
+        for (Component c :this.warningModule.getListComponents())
+            c.switchOff();
+    }
 
     @Override
     public void onActivateSystem() {}

BIN
Pigou/src/fr/deltastar/pigou/resources/sound/warning.wav


+ 1 - 1
Pigou/src/fr/deltastar/pigou/view/WelcomeView.fxml

@@ -25,7 +25,7 @@
             <Button fx:id="btnSettings" layoutX="34.0" layoutY="504.0" mnemonicParsing="false" onAction="#btnSettingsClick" prefHeight="64.0" prefWidth="220.0" stylesheets="@../resources/css/baseStyle.css" text="Settings" />
             <Button fx:id="btnLaunch" layoutX="405.0" layoutY="167.0" mnemonicParsing="false" onAction="#btnLaunchClick" prefHeight="64.0" prefWidth="220.0" stylesheets="@../resources/css/baseStyle.css" text="Launch Space Simulator" />
             <Button fx:id="btnExit" layoutX="295.0" layoutY="504.0" mnemonicParsing="false" onAction="#btnExitClick" prefHeight="64.0" prefWidth="220.0" stylesheets="@../resources/css/baseStyle.css" text="Exit" />
-            <Label layoutX="734.0" layoutY="98.0" text="V 0.1" textFill="WHITE" />
+            <Label layoutX="734.0" layoutY="98.0" text="V 0.8" textFill="WHITE" />
             <Button fx:id="btnTestingPanel" layoutX="446.0" layoutY="255.0" mnemonicParsing="false" onAction="#btnTestingPanelClick" prefHeight="47.0" prefWidth="138.0" stylesheets="@../resources/css/baseStyle.css" text="Testing Panel" />
          </children>
       </Pane>

BIN
doc/doc electronique.odt


BIN
doc/doc simulateur.odt