fort test av mbed cli

Fork of Alarmsystem_rev_innlevering by Programmeringsgruppe 1

Committer:
andreped
Date:
Wed Feb 07 10:44:44 2018 +0000
Revision:
6:a3b97bf7902b
Parent:
5:045ef3068f21
Child:
10:f0a6d74095d4
tilstander skriver ut;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
andreped 0:33bf28fd1ac6 1 #include "mbed.h"
andreped 6:a3b97bf7902b 2 #include <vector>
andreped 0:33bf28fd1ac6 3
andreped 6:a3b97bf7902b 4 #define Inn 4
andreped 6:a3b97bf7902b 5 //#define Feil 0<1
andreped 6:a3b97bf7902b 6 #define Tilstand1 (0.75 > 0.83)
andreped 6:a3b97bf7902b 7 //#define Tilstand2 2.1<2.3
andreped 6:a3b97bf7902b 8 //#define Tilstand3 3.3
andreped 6:a3b97bf7902b 9 //#define Normaldrift 1.8<2.0
andreped 6:a3b97bf7902b 10
andreped 6:a3b97bf7902b 11 //DigitalOut myled2(LED2);
andreped 4:aa2cff91ff4f 12 Serial pc(USBTX, USBRX);
andreped 0:33bf28fd1ac6 13 DigitalOut Driftslys(LED1);
andreped 6:a3b97bf7902b 14 BusOut AlarmUtganger1(p21, p22, p23, p24); //1, 2, 4, 8
andreped 6:a3b97bf7902b 15 BusOut AlarmUtganger2(p25, p26, p27, p28); //1, 2, 4, 8
andreped 0:33bf28fd1ac6 16 DigitalIn Servicebryter(p20);
andreped 6:a3b97bf7902b 17 AnalogIn _Sone1(p15); AnalogIn _Sone2(p16); AnalogIn _Sone3(p17); AnalogIn _Sone4(p19);
andreped 6:a3b97bf7902b 18 float Soner[Inn];
andreped 0:33bf28fd1ac6 19
andreped 6:a3b97bf7902b 20 //Ticker AlarmBlink; //10Hz blinking for alarmfunksjon på lys og telling
andreped 6:a3b97bf7902b 21 //nt Tid = 0;
andreped 6:a3b97bf7902b 22 //volatile int sysclock = 0;
andreped 1:6917ec4f5e6d 23
andreped 1:6917ec4f5e6d 24 int Tilstandssjekk();
andreped 6:a3b97bf7902b 25 //void AlarmBlink_Start(void);
andreped 6:a3b97bf7902b 26 //volatile int Klokke = 0;
andreped 1:6917ec4f5e6d 27
andreped 1:6917ec4f5e6d 28 int main()
andreped 1:6917ec4f5e6d 29 {
andreped 6:a3b97bf7902b 30 //AlarmBlink.attach(&AlarmBlink_Start, 0.05);
andreped 1:6917ec4f5e6d 31
andreped 1:6917ec4f5e6d 32 while(1) {
andreped 6:a3b97bf7902b 33 /*if(Servicebryter == 1) {
andreped 1:6917ec4f5e6d 34 Utganger1 = 0;
andreped 1:6917ec4f5e6d 35 Utganger2 = 0;
andreped 6:a3b97bf7902b 36 }*/
andreped 6:a3b97bf7902b 37 Soner[0] = _Sone1;
andreped 6:a3b97bf7902b 38 //Soner[1] = _Sone2;
andreped 6:a3b97bf7902b 39 //Soner[2] = _Sone3;
andreped 6:a3b97bf7902b 40 //Soner[3] = _Sone4;
andreped 6:a3b97bf7902b 41 for(int i=0; i < Inn; i++) {
andreped 6:a3b97bf7902b 42 pc.printf("%f\n", Soner[i]);
andreped 6:a3b97bf7902b 43 if((Soner[i] > 0.75 )&&( Soner[i] < 0.83)) { //Tilstand1, Dør 1 åpen
andreped 6:a3b97bf7902b 44 pc.printf("Vi er i Tilstand1\n");
andreped 6:a3b97bf7902b 45 }
andreped 6:a3b97bf7902b 46 if((Soner[i] > 0.55 )&&( Soner[i] < 0.59)) { //Normaldrift
andreped 6:a3b97bf7902b 47 pc.printf("Vi er i Normaldrift\n");
andreped 6:a3b97bf7902b 48 }
andreped 6:a3b97bf7902b 49 if((Soner[i] > 0.65 )&&( Soner[i] < 0.69)) { //Tilstand 2, Dør 2 åpen
andreped 6:a3b97bf7902b 50 pc.printf("Vi er i tilstand2\n");
andreped 6:a3b97bf7902b 51 }
andreped 6:a3b97bf7902b 52 if(Soner[i] >= 1) { //Begge dører er åpne
andreped 6:a3b97bf7902b 53 pc.printf("Vi er i tilstand 3, begge doorer er aapne");
andreped 6:a3b97bf7902b 54 }
andreped 6:a3b97bf7902b 55 wait(1.5);
andreped 1:6917ec4f5e6d 56 }
andreped 6:a3b97bf7902b 57 //pc.printf("%f\n", Sone1[]);
andreped 6:a3b97bf7902b 58 //Tilstandssjekk(Sone1[]);
andreped 6:a3b97bf7902b 59 //float volt = Sone1[];
andreped 6:a3b97bf7902b 60 //pc.printf("%f\n", volt);
Banyrud 5:045ef3068f21 61 //while(sysclock == 1);
Banyrud 5:045ef3068f21 62 //while(sysclock == 0);
andreped 6:a3b97bf7902b 63 //Tid++;
andreped 0:33bf28fd1ac6 64 }
andreped 0:33bf28fd1ac6 65 }
andreped 1:6917ec4f5e6d 66
andreped 6:a3b97bf7902b 67 /*int Tilstandssjekk()
andreped 1:6917ec4f5e6d 68 {
andreped 1:6917ec4f5e6d 69 int i = 0;
andreped 1:6917ec4f5e6d 70 for(i = 0; i < 3; i++) {
andreped 1:6917ec4f5e6d 71 if(ArrSone[i] == Tilstand1) {
andreped 1:6917ec4f5e6d 72 AlarmBlink_Start();
andreped 3:26a7b2c4bed1 73 DoorOne[i] = AlarmUtganger1;
andreped 1:6917ec4f5e6d 74 }
andreped 1:6917ec4f5e6d 75 if(Tilstand2 == ArrSone[i]) {
andreped 1:6917ec4f5e6d 76 AlarmBlink_Start();
andreped 3:26a7b2c4bed1 77 DoorTwo[i] = AlarmUtganger2;
andreped 1:6917ec4f5e6d 78 }
andreped 1:6917ec4f5e6d 79 if(Tilstand3 == ArrSone[i]) {
andreped 1:6917ec4f5e6d 80 AlarmBlink_Start();
andreped 3:26a7b2c4bed1 81 DoorOne[i] = AlarmUtganger1;
andreped 3:26a7b2c4bed1 82 DoorTwo[i] = AlarmUtganger2;
andreped 1:6917ec4f5e6d 83 }
andreped 1:6917ec4f5e6d 84 if(Feil == ArrSone[i]) {
andreped 1:6917ec4f5e6d 85 AlarmBlink_Start();
andreped 1:6917ec4f5e6d 86 }
andreped 1:6917ec4f5e6d 87 if(Normaldrift == ArrSone[i]) {
andreped 1:6917ec4f5e6d 88 Driftslys = 1;
andreped 3:26a7b2c4bed1 89 DoorOne[i] = AlarmUtganger1 - DoorOne[i];
Banyrud 5:045ef3068f21 90 myled2 = 1;
andreped 1:6917ec4f5e6d 91 }
andreped 1:6917ec4f5e6d 92 if(i < 0 ) {
andreped 3:26a7b2c4bed1 93 DoorOne[i] = AlarmUtganger1 + DoorOne[i];
andreped 3:26a7b2c4bed1 94 DoorTwo[i] = AlarmUtganger2 - DoorTwo[i];
andreped 1:6917ec4f5e6d 95 }
andreped 1:6917ec4f5e6d 96 if(i < 0 ) {
andreped 3:26a7b2c4bed1 97 DoorOne[i] = AlarmUtganger2 + DoorTwo[i];
andreped 1:6917ec4f5e6d 98 }
andreped 1:6917ec4f5e6d 99 }
Banyrud 5:045ef3068f21 100 return 0;
andreped 6:a3b97bf7902b 101 } */
andreped 1:6917ec4f5e6d 102
andreped 6:a3b97bf7902b 103 /*void AlarmBlink_Start(void)
andreped 1:6917ec4f5e6d 104 {
andreped 1:6917ec4f5e6d 105 sysclock = !sysclock;
andreped 1:6917ec4f5e6d 106 Driftslys = 1;
andreped 1:6917ec4f5e6d 107 if(Normaldrift == 1) {
andreped 1:6917ec4f5e6d 108 sysclock = 1;
andreped 1:6917ec4f5e6d 109 }
andreped 6:a3b97bf7902b 110 }*/