Fabien Lepoutre
/
Prog_Projet
Projet3i4
AnalogTest.cpp@0:f0c9c47e4edd, 2012-04-23 (annotated)
- Committer:
- fabienlepoutre
- Date:
- Mon Apr 23 14:40:40 2012 +0000
- Revision:
- 0:f0c9c47e4edd
- Child:
- 1:bb98d7d1e25f
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
fabienlepoutre | 0:f0c9c47e4edd | 1 | #include "AnalogTest.h" |
fabienlepoutre | 0:f0c9c47e4edd | 2 | |
fabienlepoutre | 0:f0c9c47e4edd | 3 | AnalogIn In15(p15); |
fabienlepoutre | 0:f0c9c47e4edd | 4 | AnalogIn In16(p16); |
fabienlepoutre | 0:f0c9c47e4edd | 5 | AnalogIn In17(p17); |
fabienlepoutre | 0:f0c9c47e4edd | 6 | AnalogOut Out18(p18); |
fabienlepoutre | 0:f0c9c47e4edd | 7 | AnalogIn In19(p19); |
fabienlepoutre | 0:f0c9c47e4edd | 8 | AnalogIn In20(p20); |
fabienlepoutre | 0:f0c9c47e4edd | 9 | |
fabienlepoutre | 0:f0c9c47e4edd | 10 | void v_TestCAN_CNA(){ |
fabienlepoutre | 0:f0c9c47e4edd | 11 | char char1 = 0; |
fabienlepoutre | 0:f0c9c47e4edd | 12 | float val=1; |
fabienlepoutre | 0:f0c9c47e4edd | 13 | int aff = 0; |
fabienlepoutre | 0:f0c9c47e4edd | 14 | cout<<"\033[2J"; |
fabienlepoutre | 0:f0c9c47e4edd | 15 | cout<<"\033[H"; |
fabienlepoutre | 0:f0c9c47e4edd | 16 | |
fabienlepoutre | 0:f0c9c47e4edd | 17 | while(char1 != 'q'){ |
fabienlepoutre | 0:f0c9c47e4edd | 18 | |
fabienlepoutre | 0:f0c9c47e4edd | 19 | |
fabienlepoutre | 0:f0c9c47e4edd | 20 | cout<<"valeur testee = "<<val<<" \n\r"; |
fabienlepoutre | 0:f0c9c47e4edd | 21 | |
fabienlepoutre | 0:f0c9c47e4edd | 22 | int result = i_TestPorts(val, aff); |
fabienlepoutre | 0:f0c9c47e4edd | 23 | aff =0; |
fabienlepoutre | 0:f0c9c47e4edd | 24 | if((result == 6)&&val<3.3){ |
fabienlepoutre | 0:f0c9c47e4edd | 25 | cout<<"Il y a "<<result<<"ports defaillants et V < 3,3V => Probleme sur Port Analog Out \r\n"; |
fabienlepoutre | 0:f0c9c47e4edd | 26 | } |
fabienlepoutre | 0:f0c9c47e4edd | 27 | |
fabienlepoutre | 0:f0c9c47e4edd | 28 | cout<<"Continuer? y / q voir valeur des ports : v \r\n"; |
fabienlepoutre | 0:f0c9c47e4edd | 29 | cin>>char1; |
fabienlepoutre | 0:f0c9c47e4edd | 30 | if(char1 == 'v'){ |
fabienlepoutre | 0:f0c9c47e4edd | 31 | aff = 1; |
fabienlepoutre | 0:f0c9c47e4edd | 32 | } |
fabienlepoutre | 0:f0c9c47e4edd | 33 | |
fabienlepoutre | 0:f0c9c47e4edd | 34 | val = val + 0.2; |
fabienlepoutre | 0:f0c9c47e4edd | 35 | if(val >= 3.3){ |
fabienlepoutre | 0:f0c9c47e4edd | 36 | val = 0; |
fabienlepoutre | 0:f0c9c47e4edd | 37 | } |
fabienlepoutre | 0:f0c9c47e4edd | 38 | |
fabienlepoutre | 0:f0c9c47e4edd | 39 | cout<<"\033[2J \n\r"; |
fabienlepoutre | 0:f0c9c47e4edd | 40 | cout<<"\033[H \n\r"; |
fabienlepoutre | 0:f0c9c47e4edd | 41 | |
fabienlepoutre | 0:f0c9c47e4edd | 42 | } |
fabienlepoutre | 0:f0c9c47e4edd | 43 | } |
fabienlepoutre | 0:f0c9c47e4edd | 44 | |
fabienlepoutre | 0:f0c9c47e4edd | 45 | |
fabienlepoutre | 0:f0c9c47e4edd | 46 | int i_TestPorts(float val, int aff){ |
fabienlepoutre | 0:f0c9c47e4edd | 47 | int ret = 0; |
fabienlepoutre | 0:f0c9c47e4edd | 48 | val = val/3.3; |
fabienlepoutre | 0:f0c9c47e4edd | 49 | Out18 = val; |
fabienlepoutre | 0:f0c9c47e4edd | 50 | |
fabienlepoutre | 0:f0c9c47e4edd | 51 | cout<<"Compte rendu du test : \r\n"; |
fabienlepoutre | 0:f0c9c47e4edd | 52 | if((In15.read() < (val-0.01))||(In15 > val + 0.01)){ |
fabienlepoutre | 0:f0c9c47e4edd | 53 | cout<<"Port p15 inexact \n\r"; |
fabienlepoutre | 0:f0c9c47e4edd | 54 | ret ++; |
fabienlepoutre | 0:f0c9c47e4edd | 55 | } |
fabienlepoutre | 0:f0c9c47e4edd | 56 | if((In16.read() < (val-0.01))||(In16 > val + 0.01)){ |
fabienlepoutre | 0:f0c9c47e4edd | 57 | cout<<"Port p16 inexact \n\r"; |
fabienlepoutre | 0:f0c9c47e4edd | 58 | ret ++; |
fabienlepoutre | 0:f0c9c47e4edd | 59 | } |
fabienlepoutre | 0:f0c9c47e4edd | 60 | |
fabienlepoutre | 0:f0c9c47e4edd | 61 | if((In17.read() < (val-0.01))||(In17 > val + 0.01)){ |
fabienlepoutre | 0:f0c9c47e4edd | 62 | cout<<"Port p17 inexact \n\r"; |
fabienlepoutre | 0:f0c9c47e4edd | 63 | ret ++; |
fabienlepoutre | 0:f0c9c47e4edd | 64 | } |
fabienlepoutre | 0:f0c9c47e4edd | 65 | |
fabienlepoutre | 0:f0c9c47e4edd | 66 | if((Out18.read() < (val-0.01))||(Out18.read() > val + 0.01)){ |
fabienlepoutre | 0:f0c9c47e4edd | 67 | cout<<"Port p18 inexact \n\r"; |
fabienlepoutre | 0:f0c9c47e4edd | 68 | ret ++; |
fabienlepoutre | 0:f0c9c47e4edd | 69 | } |
fabienlepoutre | 0:f0c9c47e4edd | 70 | |
fabienlepoutre | 0:f0c9c47e4edd | 71 | if((In19.read() < (val-0.01))||(In19 > val + 0.01)){ |
fabienlepoutre | 0:f0c9c47e4edd | 72 | cout<<"Port p19 inexact \n\r"; |
fabienlepoutre | 0:f0c9c47e4edd | 73 | ret ++; |
fabienlepoutre | 0:f0c9c47e4edd | 74 | } |
fabienlepoutre | 0:f0c9c47e4edd | 75 | |
fabienlepoutre | 0:f0c9c47e4edd | 76 | if((In20.read() < (val-0.01))||(In20 > val + 0.01)){ |
fabienlepoutre | 0:f0c9c47e4edd | 77 | cout<<"Port p20 inexact \n\r"; |
fabienlepoutre | 0:f0c9c47e4edd | 78 | ret ++; |
fabienlepoutre | 0:f0c9c47e4edd | 79 | } |
fabienlepoutre | 0:f0c9c47e4edd | 80 | if(aff ==1){ |
fabienlepoutre | 0:f0c9c47e4edd | 81 | cout<<"p15 ="<<In15.read()*3.3<<" \r\n"; |
fabienlepoutre | 0:f0c9c47e4edd | 82 | cout<<"p16 ="<<In16.read()*3.3<<" \r\n"; |
fabienlepoutre | 0:f0c9c47e4edd | 83 | cout<<"p17 ="<<In17.read()*3.3<<" \r\n"; |
fabienlepoutre | 0:f0c9c47e4edd | 84 | cout<<"p18 ="<<Out18.read()*3.3<<" \r\n"; |
fabienlepoutre | 0:f0c9c47e4edd | 85 | cout<<"p19 ="<<In19.read()*3.3<<" \r\n"; |
fabienlepoutre | 0:f0c9c47e4edd | 86 | cout<<"p20 ="<<In20.read()*3.3<<" \r\n"; |
fabienlepoutre | 0:f0c9c47e4edd | 87 | |
fabienlepoutre | 0:f0c9c47e4edd | 88 | } |
fabienlepoutre | 0:f0c9c47e4edd | 89 | |
fabienlepoutre | 0:f0c9c47e4edd | 90 | return ret; |
fabienlepoutre | 0:f0c9c47e4edd | 91 | |
fabienlepoutre | 0:f0c9c47e4edd | 92 | } |