klokka 15:07

Fork of AlarmsystemDel1 by Programmeringsgruppe 1

Revision:
9:e9c4715e06ca
Parent:
8:bdb8bd12d4f4
diff -r bdb8bd12d4f4 -r e9c4715e06ca main.cpp
--- a/main.cpp	Thu Feb 01 21:47:19 2018 +0000
+++ b/main.cpp	Fri Feb 02 14:11:24 2018 +0000
@@ -7,28 +7,28 @@
 #define Tilstand3 3.3
 #define Normaldrift 1.8<2.0
 
-vector<DigitalOut> navn; navn.push_back( *(new DigitalOut( p17 )) );
+//vector<DigitalOut> navn; navn.push_back( *(new DigitalOut( p17 )) );
 DigitalOut myled2(LED2);
 Serial pc(USBTX, USBRX);
 DigitalOut Driftslys(LED1);
 BusOut AlarmUtganger1(p21, p22, p23, p24);
 BusOut AlarmUtganger2(p25, p26, p27, p28);
 DigitalIn Servicebryter(p20);
-AnalogIn _Sone1(p15); float Sone1 = _Sone1 * 3.3;
-AnalogIn _Sone2(p16); float Sone2 = _Sone2 * 3.3;
-AnalogIn _Sone3(p17); float Sone3 = _Sone3 * 3.3;
-AnalogIn _Sone4(p19); float Sone4 = _Sone4 * 3.3;
+AnalogIn _Sone1(p15); float Sone1 = _Sone1;
+AnalogIn _Sone2(p16); float Sone2 = _Sone2;
+AnalogIn _Sone3(p17); float Sone3 = _Sone3;
+AnalogIn _Sone4(p19); float Sone4 = _Sone4;
 
 Ticker AlarmBlink; //10Hz blinking for alarmfunksjon på lys og telling
 int Tid = 0;
 volatile int sysclock = 0;
 int Door1_1, Door1_2, Door2_1, Door2_2, Door3_1, Door3_2, Door4_1, Door4_2;
-void fill_arrSone (float Sone1,float Sone2,float Sone3,float Sone4);
-float filled_arrSone[4];
-void fill_arrDoorOne(int Door1_1,int Door2_1,int Door3_1,int Door4_1);
-int filled_arrDoorOne[4];
-void fill_arrDoorTwo(int Door1_2,int Door2_2,int Door3_2,int Door4_2);
-int filled_arrDoorTwo[4];
+//void fill_arrSone (float Sone1,float Sone2,float Sone3,float Sone4);
+//void fill_arrDoorOne(int Door1_1,int Door2_1,int Door3_1,int Door4_1);
+//void fill_arrDoorTwo(int Door1_2,int Door2_2,int Door3_2,int Door4_2);
+float Sone[];
+int DoorOne[];
+int DoorTwo[];
 int Tilstandssjekk();
 void AlarmBlink_Start(void);
 // ubrukelig nå // int Bryter = Servicebryter;
@@ -42,8 +42,11 @@
             AlarmUtganger1 = 0;
             AlarmUtganger2 = 0;
         }
+        Sone[4] = {float Sone1,float Sone2,float Sone3,float Sone4};
+        DoorOne[4] = {int Door1_1, int Door2_1, int Door3_1, int Door4_1};
+        DoorTwo[4] = {int Door1_2, int Door2_2, int Door3_2, int Door4_2};
         Tilstandssjekk();
-        float volt = Sone1*3.3;
+        float volt = Sone1;
         pc.printf("%f\n", volt);
         wait(1.0);
         //while(sysclock == 1);
@@ -54,39 +57,36 @@
 
 int Tilstandssjekk()
 {
-    int i = 0;
-    for(i = 0; i < 3; i++) {
-        if(filled_arrSone[i] == Tilstand1) {
+    for(int i = 0; i < 4; i++) {
+        if(Sone[i] * 3.3 == Tilstand1) {
             pc.printf("I tilstand 1\n");
-            filled_arrDoorOne[i] = AlarmUtganger1;
+            AlarmUtganger1 = DoorOne[i];
             AlarmBlink_Start();
         }
-        if(Tilstand2 == filled_arrSone[i]) {
+        if(Sone[i] * 3.3 == Tilstand2) {
             pc.printf("I tilstand 2\n");
-            filled_arrDoorTwo[i] = AlarmUtganger2;
+            AlarmUtganger2 = DoorTwo[i];
             AlarmBlink_Start();
         }
-        if(Tilstand3 == filled_arrSone[i]) {
+        if(Sone[i] * 3.3 == Tilstand3) {
             pc.printf("I tilstand 3\n");
-            filled_arrDoorOne[i] = AlarmUtganger1;
-            filled_arrDoorTwo[i] = AlarmUtganger2;
+            DoorOne[i] = i;
+            DoorTwo[i] = i;
+            AlarmUtganger1 == DoorOne[i];
+            AlarmUtganger2 == DoorTwo[i];
             AlarmBlink_Start();
         }
-        if(Feil == filled_arrSone[i]) {
+        if(Sone[i] * 3.3 == Feil) {
             pc.printf("I tilstand feil\n");
             AlarmBlink_Start();
         }
-        if(Normaldrift == filled_arrSone[i]) {
+        if(Sone[i] * 3.3 == Normaldrift) {
+            pc.printf("I tilstand normaldrift\n");
             Driftslys = 1;
-            filled_arrDoorOne[i] = AlarmUtganger1 - filled_arrDoorOne[i];
-            pc.printf("I tilstand normaldrift\n");
+            DoorOne[i] = NULL; DoorTwo[i] = NULL;
         }
         if(i < 0 ) {
-            filled_arrDoorOne[i] = AlarmUtganger1 + filled_arrDoorOne[i];
-            filled_arrDoorTwo[i] = AlarmUtganger2 - filled_arrDoorTwo[i];
-        }
-        if(i < 0 ) {
-            filled_arrDoorOne[i] = AlarmUtganger2 + filled_arrDoorTwo[i];
+            Sone[i] * 3.3 == Feil;
         }
     }
     return 0;
@@ -97,19 +97,19 @@
     sysclock = !sysclock;
     Driftslys = 1;
 }
-void fill_arrSone (float Sone1, float Sone2, float Sone3, float Sone4){
-        filled_arrSone[4] = {Sone1, Sone2, Sone3, Sone4};
-        
-}
-void fill_arrDoorOne(int Door1_1,int Door2_1,int Door3_1,int Door4_1) {
-        filled_arrDoorOne[0] = Door1_1;
-        filled_arrDoorOne[1] = Door2_1;
-        filled_arrDoorOne[2] = Door3_1;
-        filled_arrDoorOne[3] = Door4_1;
-}
-void fill_arrDoorTwo(int Door1_2,int Door2_2,int Door3_2,int Door4_2) {
-        filled_arrDoorOne[0] = Door1_2;
-        filled_arrDoorOne[1] = Door2_2;
-        filled_arrDoorOne[2] = Door3_2;
-        filled_arrDoorOne[3] = Door4_2;
-}
\ No newline at end of file
+//*void fill_arrSone (float Sone1, float Sone2, float Sone3, float Sone4){
+ //       filled_arrSone[4] = {Sone1, Sone2, Sone3, Sone4};
+   //     
+//}
+//void fill_arrDoorOne(int Door1_1,int Door2_1,int Door3_1,int Door4_1) {
+  //      filled_arrDoorOne[0] = Door1_1;
+    //    filled_arrDoorOne[1] = Door2_1;
+//        filled_arrDoorOne[2] = Door3_1;
+ //       filled_arrDoorOne[3] = Door4_1;
+//}
+//void fill_arrDoorTwo(int Door1_2,int Door2_2,int Door3_2,int Door4_2) {
+//        filled_arrDoorOne[0] = Door1_2;
+ //       filled_arrDoorOne[1] = Door2_2;
+ //       filled_arrDoorOne[2] = Door3_2;
+  //      filled_arrDoorOne[3] = Door4_2;
+//}
\ No newline at end of file