fort test av mbed cli

Fork of Alarmsystem_rev_innlevering by Programmeringsgruppe 1

Committer:
andreped
Date:
Fri Feb 02 14:11:24 2018 +0000
Revision:
9:e9c4715e06ca
Parent:
8:bdb8bd12d4f4
0078

Who changed what in which revision?

UserRevisionLine numberNew contents of line
andreped 0:33bf28fd1ac6 1 #include "mbed.h"
andreped 8:bdb8bd12d4f4 2 #include <vector>
andreped 0:33bf28fd1ac6 3
andreped 3:26a7b2c4bed1 4 #define Feil 0<1
andreped 3:26a7b2c4bed1 5 #define Tilstand1 2.5<2.7
andreped 3:26a7b2c4bed1 6 #define Tilstand2 2.1<2.3
andreped 3:26a7b2c4bed1 7 #define Tilstand3 3.3
andreped 3:26a7b2c4bed1 8 #define Normaldrift 1.8<2.0
andreped 8:bdb8bd12d4f4 9
andreped 9:e9c4715e06ca 10 //vector<DigitalOut> navn; navn.push_back( *(new DigitalOut( p17 )) );
Banyrud 5:045ef3068f21 11 DigitalOut myled2(LED2);
andreped 4:aa2cff91ff4f 12 Serial pc(USBTX, USBRX);
andreped 0:33bf28fd1ac6 13 DigitalOut Driftslys(LED1);
andreped 1:6917ec4f5e6d 14 BusOut AlarmUtganger1(p21, p22, p23, p24);
andreped 1:6917ec4f5e6d 15 BusOut AlarmUtganger2(p25, p26, p27, p28);
andreped 0:33bf28fd1ac6 16 DigitalIn Servicebryter(p20);
andreped 9:e9c4715e06ca 17 AnalogIn _Sone1(p15); float Sone1 = _Sone1;
andreped 9:e9c4715e06ca 18 AnalogIn _Sone2(p16); float Sone2 = _Sone2;
andreped 9:e9c4715e06ca 19 AnalogIn _Sone3(p17); float Sone3 = _Sone3;
andreped 9:e9c4715e06ca 20 AnalogIn _Sone4(p19); float Sone4 = _Sone4;
andreped 8:bdb8bd12d4f4 21
andreped 1:6917ec4f5e6d 22 Ticker AlarmBlink; //10Hz blinking for alarmfunksjon på lys og telling
andreped 1:6917ec4f5e6d 23 int Tid = 0;
andreped 1:6917ec4f5e6d 24 volatile int sysclock = 0;
andreped 8:bdb8bd12d4f4 25 int Door1_1, Door1_2, Door2_1, Door2_2, Door3_1, Door3_2, Door4_1, Door4_2;
andreped 9:e9c4715e06ca 26 //void fill_arrSone (float Sone1,float Sone2,float Sone3,float Sone4);
andreped 9:e9c4715e06ca 27 //void fill_arrDoorOne(int Door1_1,int Door2_1,int Door3_1,int Door4_1);
andreped 9:e9c4715e06ca 28 //void fill_arrDoorTwo(int Door1_2,int Door2_2,int Door3_2,int Door4_2);
andreped 9:e9c4715e06ca 29 float Sone[];
andreped 9:e9c4715e06ca 30 int DoorOne[];
andreped 9:e9c4715e06ca 31 int DoorTwo[];
andreped 1:6917ec4f5e6d 32 int Tilstandssjekk();
andreped 1:6917ec4f5e6d 33 void AlarmBlink_Start(void);
andreped 8:bdb8bd12d4f4 34 // ubrukelig nå // int Bryter = Servicebryter;
andreped 8:bdb8bd12d4f4 35 // ubrukelig nå // volatile int Klokke = 0;
andreped 8:bdb8bd12d4f4 36 // ubrukelig nå // enum {_Feil, _Tilstand1, _Tilstand2, _Tilstand3, _NormalDrift} Tilstand; // Tilstand1 = Bryter1 i Sonen valgt, Tilstand2 = Bryter2 i sonen valgt, Tilstand3 = bryter 1 og 2 i sonen valgt, Normaldrift = alt er optimalt.
andreped 1:6917ec4f5e6d 37 int main()
andreped 1:6917ec4f5e6d 38 {
andreped 1:6917ec4f5e6d 39 AlarmBlink.attach(&AlarmBlink_Start, 0.05);
andreped 1:6917ec4f5e6d 40 while(1) {
andreped 1:6917ec4f5e6d 41 if(Servicebryter == 1) {
andreped 8:bdb8bd12d4f4 42 AlarmUtganger1 = 0;
andreped 8:bdb8bd12d4f4 43 AlarmUtganger2 = 0;
andreped 1:6917ec4f5e6d 44 }
andreped 9:e9c4715e06ca 45 Sone[4] = {float Sone1,float Sone2,float Sone3,float Sone4};
andreped 9:e9c4715e06ca 46 DoorOne[4] = {int Door1_1, int Door2_1, int Door3_1, int Door4_1};
andreped 9:e9c4715e06ca 47 DoorTwo[4] = {int Door1_2, int Door2_2, int Door3_2, int Door4_2};
andreped 1:6917ec4f5e6d 48 Tilstandssjekk();
andreped 9:e9c4715e06ca 49 float volt = Sone1;
andreped 4:aa2cff91ff4f 50 pc.printf("%f\n", volt);
Banyrud 5:045ef3068f21 51 wait(1.0);
Banyrud 5:045ef3068f21 52 //while(sysclock == 1);
Banyrud 5:045ef3068f21 53 //while(sysclock == 0);
andreped 1:6917ec4f5e6d 54 Tid++;
andreped 0:33bf28fd1ac6 55 }
andreped 0:33bf28fd1ac6 56 }
andreped 1:6917ec4f5e6d 57
andreped 1:6917ec4f5e6d 58 int Tilstandssjekk()
andreped 1:6917ec4f5e6d 59 {
andreped 9:e9c4715e06ca 60 for(int i = 0; i < 4; i++) {
andreped 9:e9c4715e06ca 61 if(Sone[i] * 3.3 == Tilstand1) {
Banyrud 7:25e0260ee887 62 pc.printf("I tilstand 1\n");
andreped 9:e9c4715e06ca 63 AlarmUtganger1 = DoorOne[i];
andreped 1:6917ec4f5e6d 64 AlarmBlink_Start();
andreped 1:6917ec4f5e6d 65 }
andreped 9:e9c4715e06ca 66 if(Sone[i] * 3.3 == Tilstand2) {
Banyrud 7:25e0260ee887 67 pc.printf("I tilstand 2\n");
andreped 9:e9c4715e06ca 68 AlarmUtganger2 = DoorTwo[i];
andreped 1:6917ec4f5e6d 69 AlarmBlink_Start();
andreped 1:6917ec4f5e6d 70 }
andreped 9:e9c4715e06ca 71 if(Sone[i] * 3.3 == Tilstand3) {
Banyrud 7:25e0260ee887 72 pc.printf("I tilstand 3\n");
andreped 9:e9c4715e06ca 73 DoorOne[i] = i;
andreped 9:e9c4715e06ca 74 DoorTwo[i] = i;
andreped 9:e9c4715e06ca 75 AlarmUtganger1 == DoorOne[i];
andreped 9:e9c4715e06ca 76 AlarmUtganger2 == DoorTwo[i];
andreped 1:6917ec4f5e6d 77 AlarmBlink_Start();
andreped 1:6917ec4f5e6d 78 }
andreped 9:e9c4715e06ca 79 if(Sone[i] * 3.3 == Feil) {
andreped 8:bdb8bd12d4f4 80 pc.printf("I tilstand feil\n");
andreped 8:bdb8bd12d4f4 81 AlarmBlink_Start();
andreped 8:bdb8bd12d4f4 82 }
andreped 9:e9c4715e06ca 83 if(Sone[i] * 3.3 == Normaldrift) {
andreped 9:e9c4715e06ca 84 pc.printf("I tilstand normaldrift\n");
andreped 1:6917ec4f5e6d 85 Driftslys = 1;
andreped 9:e9c4715e06ca 86 DoorOne[i] = NULL; DoorTwo[i] = NULL;
andreped 1:6917ec4f5e6d 87 }
andreped 1:6917ec4f5e6d 88 if(i < 0 ) {
andreped 9:e9c4715e06ca 89 Sone[i] * 3.3 == Feil;
andreped 1:6917ec4f5e6d 90 }
andreped 1:6917ec4f5e6d 91 }
Banyrud 5:045ef3068f21 92 return 0;
andreped 1:6917ec4f5e6d 93 }
andreped 1:6917ec4f5e6d 94
andreped 1:6917ec4f5e6d 95 void AlarmBlink_Start(void)
andreped 1:6917ec4f5e6d 96 {
andreped 1:6917ec4f5e6d 97 sysclock = !sysclock;
andreped 1:6917ec4f5e6d 98 Driftslys = 1;
andreped 8:bdb8bd12d4f4 99 }
andreped 9:e9c4715e06ca 100 //*void fill_arrSone (float Sone1, float Sone2, float Sone3, float Sone4){
andreped 9:e9c4715e06ca 101 // filled_arrSone[4] = {Sone1, Sone2, Sone3, Sone4};
andreped 9:e9c4715e06ca 102 //
andreped 9:e9c4715e06ca 103 //}
andreped 9:e9c4715e06ca 104 //void fill_arrDoorOne(int Door1_1,int Door2_1,int Door3_1,int Door4_1) {
andreped 9:e9c4715e06ca 105 // filled_arrDoorOne[0] = Door1_1;
andreped 9:e9c4715e06ca 106 // filled_arrDoorOne[1] = Door2_1;
andreped 9:e9c4715e06ca 107 // filled_arrDoorOne[2] = Door3_1;
andreped 9:e9c4715e06ca 108 // filled_arrDoorOne[3] = Door4_1;
andreped 9:e9c4715e06ca 109 //}
andreped 9:e9c4715e06ca 110 //void fill_arrDoorTwo(int Door1_2,int Door2_2,int Door3_2,int Door4_2) {
andreped 9:e9c4715e06ca 111 // filled_arrDoorOne[0] = Door1_2;
andreped 9:e9c4715e06ca 112 // filled_arrDoorOne[1] = Door2_2;
andreped 9:e9c4715e06ca 113 // filled_arrDoorOne[2] = Door3_2;
andreped 9:e9c4715e06ca 114 // filled_arrDoorOne[3] = Door4_2;
andreped 9:e9c4715e06ca 115 //}