132
Dependencies: DMSupport DMemWin
Fork of Motor_Embedded_3rd_emwin by
Motor_Monitoring_Embedded.cpp@3:1823bfc913c1, 2017-07-12 (annotated)
- Committer:
- Will_Lu
- Date:
- Wed Jul 12 08:20:05 2017 +0000
- Revision:
- 3:1823bfc913c1
- Parent:
- 2:bfc676294e38
123
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
destinyXfate | 0:08606a13a816 | 1 | #include <stddef.h> |
destinyXfate | 0:08606a13a816 | 2 | |
destinyXfate | 0:08606a13a816 | 3 | #include "mbed.h" |
destinyXfate | 0:08606a13a816 | 4 | #include "MCIFileSystem.h" |
destinyXfate | 0:08606a13a816 | 5 | #include "EthernetInterface.h" |
destinyXfate | 0:08606a13a816 | 6 | #include "HTTPClient.h" |
destinyXfate | 0:08606a13a816 | 7 | #include "HTTPFile.h" |
destinyXfate | 0:08606a13a816 | 8 | #include "Base64.h" |
destinyXfate | 0:08606a13a816 | 9 | |
destinyXfate | 0:08606a13a816 | 10 | |
destinyXfate | 0:08606a13a816 | 11 | #include "ADC.h" |
destinyXfate | 0:08606a13a816 | 12 | #include "MATH1.h" |
destinyXfate | 0:08606a13a816 | 13 | #include "fft.h" |
destinyXfate | 0:08606a13a816 | 14 | |
destinyXfate | 0:08606a13a816 | 15 | #include "DIALOG.h" |
destinyXfate | 0:08606a13a816 | 16 | |
destinyXfate | 0:08606a13a816 | 17 | #define len 10000 |
destinyXfate | 0:08606a13a816 | 18 | #define pi 3.14159265359f |
destinyXfate | 0:08606a13a816 | 19 | #define SPS 20000 |
destinyXfate | 0:08606a13a816 | 20 | #define N 8192 |
destinyXfate | 0:08606a13a816 | 21 | |
destinyXfate | 0:08606a13a816 | 22 | Serial pc(P0_2, P0_3); // tx, rx*** |
destinyXfate | 0:08606a13a816 | 23 | |
Will_Lu | 1:c6b089f4ff2a | 24 | SPI spi2(P0_9, P0_8, P0_7); // mosi, miso, sclk .........//for voltage & current |
Will_Lu | 1:c6b089f4ff2a | 25 | SPI spi(P2_27, P2_26, P2_22); // mosi, miso, sclk .......//for vibration |
Will_Lu | 1:c6b089f4ff2a | 26 | ADS8556 adc2(&spi2, P0_6, P2_25, P0_25, P0_26); // for voltage & current |
Will_Lu | 1:c6b089f4ff2a | 27 | ADS8556 adc(&spi, P2_23, P0_1, P0_0, P5_4); // for vibration |
destinyXfate | 0:08606a13a816 | 28 | |
destinyXfate | 0:08606a13a816 | 29 | EthernetInterface eth; |
destinyXfate | 0:08606a13a816 | 30 | HTTPClient http; |
destinyXfate | 0:08606a13a816 | 31 | Timer timer; |
destinyXfate | 0:08606a13a816 | 32 | MATH math; |
destinyXfate | 0:08606a13a816 | 33 | CFFT fft; |
destinyXfate | 0:08606a13a816 | 34 | |
destinyXfate | 0:08606a13a816 | 35 | //GUI_RECT conditionmonitoring = {125, 90, 665, 180}; |
destinyXfate | 0:08606a13a816 | 36 | //GUI_RECT faultdiagnosis = {60, 315, 730, 385}; |
destinyXfate | 0:08606a13a816 | 37 | //GUI_RECT no = {445, 60, 725, 330}; |
destinyXfate | 0:08606a13a816 | 38 | |
destinyXfate | 0:08606a13a816 | 39 | char MotorID[10], Volts[10], Amps[10], HP[10], Poles[10], RPM[10], |
destinyXfate | 0:08606a13a816 | 40 | IPADR[20], Netmask[20], Gateway[20], |
destinyXfate | 0:08606a13a816 | 41 | cIUR[10], cIUF[10], cTHDV[10], cVDFodd[10], cTHDI[10], cIDFodd[10], cPeakValue[10], cUBValue[10], cx_vel[10], cy_vel[10], cz_vel[10], cz_dis[10], cy_dis[10], cx_dis[10], |
destinyXfate | 0:08606a13a816 | 42 | cbk_PeakValue[10], cbk_UBValue[10], bkgPeakValue[10], bkgUBValue[10], |
Will_Lu | 2:bfc676294e38 | 43 | cpCMS[10], cpH[10], cpS[10], cpR[10], cpB[10], cpE[10], |
Will_Lu | 3:1823bfc913c1 | 44 | cVUR[10], cVUF[10], cVD[10], cCD[10], cBB[10], cVel[10], cDis[10]; |
Will_Lu | 2:bfc676294e38 | 45 | double FIUR,FIUF,FTHDV,FVDFodd,FTHDI,FIDFodd,FBB,Fpeakvalue,health,stator,rotor,bearing,eccentric,FVUR,FVUF,FVD,FCD,FVel,FDis,pCMS; |
destinyXfate | 0:08606a13a816 | 46 | static int flagc = 0, flagf = 0, a0, a1; |
destinyXfate | 0:08606a13a816 | 47 | static unsigned aValues[]= {0, 0, 0, 0, 0, 0}; |
Will_Lu | 2:bfc676294e38 | 48 | |
destinyXfate | 0:08606a13a816 | 49 | |
destinyXfate | 0:08606a13a816 | 50 | static SCROLLBAR_Handle _hScroll; |
destinyXfate | 0:08606a13a816 | 51 | |
destinyXfate | 0:08606a13a816 | 52 | //const char* ECHO_SERVER_ADDRESS = "140.118.170.194"; |
destinyXfate | 0:08606a13a816 | 53 | //const int ECHO_SERVER_PORT = 5278; |
destinyXfate | 0:08606a13a816 | 54 | |
destinyXfate | 0:08606a13a816 | 55 | const char* IP = "140.118.170.248"; |
destinyXfate | 0:08606a13a816 | 56 | const char* MASK = "255.255.255.0"; |
destinyXfate | 0:08606a13a816 | 57 | const char* GATEWAY = "140.118.170.254"; |
destinyXfate | 0:08606a13a816 | 58 | |
destinyXfate | 0:08606a13a816 | 59 | |
destinyXfate | 0:08606a13a816 | 60 | /********************************************************************* |
destinyXfate | 0:08606a13a816 | 61 | * |
destinyXfate | 0:08606a13a816 | 62 | * Defines |
destinyXfate | 0:08606a13a816 | 63 | * |
destinyXfate | 0:08606a13a816 | 64 | ********************************************************************** |
destinyXfate | 0:08606a13a816 | 65 | */ |
destinyXfate | 0:08606a13a816 | 66 | |
destinyXfate | 0:08606a13a816 | 67 | //MAIN PAGE// |
destinyXfate | 0:08606a13a816 | 68 | #define ID_WINDOW_0 (GUI_ID_USER + 0x54) |
destinyXfate | 0:08606a13a816 | 69 | #define ID_RADIO_0 (GUI_ID_USER + 0x55) |
destinyXfate | 0:08606a13a816 | 70 | |
Will_Lu | 3:1823bfc913c1 | 71 | //Electric Index_PAGE// |
destinyXfate | 0:08606a13a816 | 72 | #define ID_FRAMEWIN_1 (GUI_ID_USER + 0x51) |
Will_Lu | 3:1823bfc913c1 | 73 | |
destinyXfate | 0:08606a13a816 | 74 | |
destinyXfate | 0:08606a13a816 | 75 | #define ID_TEXT_1 (GUI_ID_USER + 0x6A) |
destinyXfate | 0:08606a13a816 | 76 | #define ID_TEXT_22 (GUI_ID_USER + 0x6B) |
destinyXfate | 0:08606a13a816 | 77 | #define ID_TEXT_23 (GUI_ID_USER + 0x6C) |
destinyXfate | 0:08606a13a816 | 78 | #define ID_TEXT_24 (GUI_ID_USER + 0x6D) |
destinyXfate | 0:08606a13a816 | 79 | #define ID_TEXT_25 (GUI_ID_USER + 0x6E) |
destinyXfate | 0:08606a13a816 | 80 | #define ID_TEXT_26 (GUI_ID_USER + 0x6F) |
destinyXfate | 0:08606a13a816 | 81 | #define ID_TEXT_27 (GUI_ID_USER + 0x70) |
destinyXfate | 0:08606a13a816 | 82 | #define ID_TEXT_28 (GUI_ID_USER + 0x71) |
destinyXfate | 0:08606a13a816 | 83 | #define ID_TEXT_29 (GUI_ID_USER + 0x72) |
destinyXfate | 0:08606a13a816 | 84 | #define ID_TEXT_30 (GUI_ID_USER + 0x73) |
destinyXfate | 0:08606a13a816 | 85 | #define ID_TEXT_31 (GUI_ID_USER + 0x74) |
destinyXfate | 0:08606a13a816 | 86 | #define ID_TEXT_32 (GUI_ID_USER + 0x75) |
destinyXfate | 0:08606a13a816 | 87 | #define ID_TEXT_33 (GUI_ID_USER + 0x76) |
destinyXfate | 0:08606a13a816 | 88 | #define ID_TEXT_34 (GUI_ID_USER + 0x77) |
destinyXfate | 0:08606a13a816 | 89 | #define ID_TEXT_35 (GUI_ID_USER + 0x78) |
destinyXfate | 0:08606a13a816 | 90 | #define ID_TEXT_36 (GUI_ID_USER + 0x79) |
destinyXfate | 0:08606a13a816 | 91 | #define ID_TEXT_37 (GUI_ID_USER + 0x7A) |
destinyXfate | 0:08606a13a816 | 92 | #define ID_TEXT_38 (GUI_ID_USER + 0x7B) |
destinyXfate | 0:08606a13a816 | 93 | #define ID_TEXT_39 (GUI_ID_USER + 0x7C) |
Will_Lu | 3:1823bfc913c1 | 94 | #define ID_TEXT_40 (GUI_ID_USER + 0x7D) |
destinyXfate | 0:08606a13a816 | 95 | |
destinyXfate | 0:08606a13a816 | 96 | //Select PAGE// |
destinyXfate | 0:08606a13a816 | 97 | #define ID_FRAMEWIN_2 (GUI_ID_USER + 0x53) |
destinyXfate | 0:08606a13a816 | 98 | |
Will_Lu | 3:1823bfc913c1 | 99 | |
destinyXfate | 0:08606a13a816 | 100 | |
Will_Lu | 2:bfc676294e38 | 101 | //Further Analysis_PAGE// |
destinyXfate | 0:08606a13a816 | 102 | #define ID_FRAMEWIN_0 (GUI_ID_USER + 0x56) |
destinyXfate | 0:08606a13a816 | 103 | |
Will_Lu | 3:1823bfc913c1 | 104 | //vibration index PAGE// |
destinyXfate | 0:08606a13a816 | 105 | #define ID_FRAMEWIN_3 (GUI_ID_USER + 0x57) |
destinyXfate | 0:08606a13a816 | 106 | //KeyBoard// |
destinyXfate | 0:08606a13a816 | 107 | #define ID_FRAMEWIN_4 (GUI_ID_USER + 0x58) |
destinyXfate | 0:08606a13a816 | 108 | |
destinyXfate | 0:08606a13a816 | 109 | //ADCPage// |
destinyXfate | 0:08606a13a816 | 110 | #define ID_FRAMEWIN_5 (GUI_ID_USER + 0x59) |
destinyXfate | 0:08606a13a816 | 111 | |
destinyXfate | 0:08606a13a816 | 112 | //FinishPage// |
destinyXfate | 0:08606a13a816 | 113 | #define ID_FRAMEWIN_6 (GUI_ID_USER + 0x50) |
destinyXfate | 0:08606a13a816 | 114 | |
Will_Lu | 2:bfc676294e38 | 115 | //Further Fault// |
Will_Lu | 2:bfc676294e38 | 116 | #define ID_FRAMEWIN_9 (GUI_ID_USER + 0x5C) |
Will_Lu | 2:bfc676294e38 | 117 | |
Will_Lu | 2:bfc676294e38 | 118 | //Further Select |
Will_Lu | 2:bfc676294e38 | 119 | #define ID_FRAMEWIN_10 (GUI_ID_USER + 0x5D) |
Will_Lu | 3:1823bfc913c1 | 120 | |
Will_Lu | 3:1823bfc913c1 | 121 | //Electric Index_PAGE2 |
Will_Lu | 3:1823bfc913c1 | 122 | #define ID_FRAMEWIN_11 (GUI_ID_USER + 0x5E) |
destinyXfate | 0:08606a13a816 | 123 | /********************************************************************* |
destinyXfate | 0:08606a13a816 | 124 | * |
destinyXfate | 0:08606a13a816 | 125 | * Static data |
destinyXfate | 0:08606a13a816 | 126 | * |
destinyXfate | 0:08606a13a816 | 127 | ********************************************************************** |
destinyXfate | 0:08606a13a816 | 128 | */ |
destinyXfate | 0:08606a13a816 | 129 | |
destinyXfate | 0:08606a13a816 | 130 | static GUI_COLOR aColors[] = { 0x00EE00, GUI_RED, GUI_BLUE, 0x00E7FF, GUI_DARKMAGENTA}; |
destinyXfate | 0:08606a13a816 | 131 | |
destinyXfate | 0:08606a13a816 | 132 | static GUI_CONST_STORAGE GUI_COLOR _aColorsArrow[] = { |
destinyXfate | 0:08606a13a816 | 133 | 0xFFFFFF, 0x000000 |
destinyXfate | 0:08606a13a816 | 134 | }; |
destinyXfate | 0:08606a13a816 | 135 | |
destinyXfate | 0:08606a13a816 | 136 | static GUI_CONST_STORAGE GUI_LOGPALETTE _PalArrow = { |
destinyXfate | 0:08606a13a816 | 137 | 2, /* number of entries */ |
destinyXfate | 0:08606a13a816 | 138 | 1, /* No transparency */ |
destinyXfate | 0:08606a13a816 | 139 | &_aColorsArrow[0] |
destinyXfate | 0:08606a13a816 | 140 | }; |
destinyXfate | 0:08606a13a816 | 141 | |
destinyXfate | 0:08606a13a816 | 142 | |
destinyXfate | 0:08606a13a816 | 143 | static GUI_CONST_STORAGE unsigned char _acArrowLeft[] = { |
destinyXfate | 0:08606a13a816 | 144 | _______X, ________,________,________, |
destinyXfate | 0:08606a13a816 | 145 | ______XX, ________,________,________, |
destinyXfate | 0:08606a13a816 | 146 | ____XXXX, ________,________,________, |
destinyXfate | 0:08606a13a816 | 147 | ___XXXXX, ________,________,________, |
destinyXfate | 0:08606a13a816 | 148 | __XXXXXX, XXXXXXXX,XXXXXXXX,XXXXXXXX, |
destinyXfate | 0:08606a13a816 | 149 | XXXXXXXX, XXXXXXXX,XXXXXXXX,XXXXXXXX, |
destinyXfate | 0:08606a13a816 | 150 | __XXXXXX, XXXXXXXX,XXXXXXXX,XXXXXXXX, |
destinyXfate | 0:08606a13a816 | 151 | ___XXXXX, ________,________,________, |
destinyXfate | 0:08606a13a816 | 152 | ____XXXX, ________,________,________, |
destinyXfate | 0:08606a13a816 | 153 | ______XX, ________,________,________, |
destinyXfate | 0:08606a13a816 | 154 | _______X, ________,________,________ |
destinyXfate | 0:08606a13a816 | 155 | }; |
destinyXfate | 0:08606a13a816 | 156 | |
destinyXfate | 0:08606a13a816 | 157 | |
destinyXfate | 0:08606a13a816 | 158 | static GUI_CONST_STORAGE GUI_BITMAP _bmArrowLeft = { |
destinyXfate | 0:08606a13a816 | 159 | 20, /* XSize */ |
destinyXfate | 0:08606a13a816 | 160 | 11, /* YSize */ |
destinyXfate | 0:08606a13a816 | 161 | 4, /* BytesPerLine */ |
destinyXfate | 0:08606a13a816 | 162 | 1, /* BitsPerPixel */ |
destinyXfate | 0:08606a13a816 | 163 | _acArrowLeft, /* Pointer to picture data (indices) */ |
destinyXfate | 0:08606a13a816 | 164 | &_PalArrow /* Pointer to palette */ |
destinyXfate | 0:08606a13a816 | 165 | }; |
destinyXfate | 0:08606a13a816 | 166 | |
destinyXfate | 0:08606a13a816 | 167 | |
destinyXfate | 0:08606a13a816 | 168 | static int _aKey[] = {'0','1','2','3','4','5','6','7','8','9','.', GUI_KEY_BACKSPACE}; |
destinyXfate | 0:08606a13a816 | 169 | |
destinyXfate | 0:08606a13a816 | 170 | |
destinyXfate | 0:08606a13a816 | 171 | |
destinyXfate | 0:08606a13a816 | 172 | |
destinyXfate | 0:08606a13a816 | 173 | |
destinyXfate | 0:08606a13a816 | 174 | /******************************************************************************************************* |
destinyXfate | 0:08606a13a816 | 175 | * |
destinyXfate | 0:08606a13a816 | 176 | * _aDialogCreate |
destinyXfate | 0:08606a13a816 | 177 | * |
destinyXfate | 0:08606a13a816 | 178 | *******************************************************************************************************/ |
destinyXfate | 0:08606a13a816 | 179 | static const GUI_WIDGET_CREATE_INFO _afinish[] = { |
destinyXfate | 0:08606a13a816 | 180 | { FRAMEWIN_CreateIndirect, "", ID_FRAMEWIN_6, 255 , 92, 280, 250, 0, 0x64, 0 }, |
destinyXfate | 0:08606a13a816 | 181 | }; |
destinyXfate | 0:08606a13a816 | 182 | |
destinyXfate | 0:08606a13a816 | 183 | static const GUI_WIDGET_CREATE_INFO _aISO10816[] = { |
Will_Lu | 3:1823bfc913c1 | 184 | { FRAMEWIN_CreateIndirect, "Vibration Index", ID_FRAMEWIN_3, 0, 0, 800, 480, 0, 0x64, 0 }, |
Will_Lu | 3:1823bfc913c1 | 185 | |
Will_Lu | 3:1823bfc913c1 | 186 | { TEXT_CreateIndirect, "Status", ID_TEXT_1, 565, 15, 95, 40, 0, 0x0, 0 }, |
Will_Lu | 3:1823bfc913c1 | 187 | { TEXT_CreateIndirect, "Value", GUI_ID_USER + 108, 330, 15, 180, 20, 0, 0x0, 0 }, |
Will_Lu | 3:1823bfc913c1 | 188 | { TEXT_CreateIndirect, "Threshold", GUI_ID_USER + 109, 410, 15, 180, 20, 0, 0x0, 0 }, |
Will_Lu | 3:1823bfc913c1 | 189 | |
Will_Lu | 3:1823bfc913c1 | 190 | { TEXT_CreateIndirect, "PeakValue_Acc", GUI_ID_USER + 110, 10, 70, 134, 20, 0, 0x0, 0 }, |
Will_Lu | 3:1823bfc913c1 | 191 | { TEXT_CreateIndirect, "Max_Vel", GUI_ID_USER + 111, 10, 70+47*1, 270, 20, 0, 0x0, 0 }, |
Will_Lu | 3:1823bfc913c1 | 192 | { TEXT_CreateIndirect, "Max_Dis", GUI_ID_USER + 112, 10, 70+47*2, 270, 20, 0, 0x0, 0 }, |
Will_Lu | 3:1823bfc913c1 | 193 | |
Will_Lu | 3:1823bfc913c1 | 194 | { TEXT_CreateIndirect, "% 5 %", GUI_ID_USER + 113, 400, 70, 90, 20, 0, 0x64, 0 }, |
Will_Lu | 3:1823bfc913c1 | 195 | { TEXT_CreateIndirect, "mm/s 4.5 mm/s ", GUI_ID_USER + 114, 370,70+47*1, 150, 20, 0, 0x64, 0 }, |
Will_Lu | 3:1823bfc913c1 | 196 | { TEXT_CreateIndirect, "um 90 um", GUI_ID_USER + 115, 390, 70+47*2, 110, 20, 0, 0x64, 0 }, |
Will_Lu | 3:1823bfc913c1 | 197 | |
Will_Lu | 3:1823bfc913c1 | 198 | { TEXT_CreateIndirect, "V_Peak", GUI_ID_USER + 116, 310, 70+47*0, 80, 20, 0, 0x0, 0 }, |
Will_Lu | 3:1823bfc913c1 | 199 | { TEXT_CreateIndirect, "V_Vel", GUI_ID_USER + 117, 310, 70+47*1, 80, 20, 0, 0x0, 0 }, |
Will_Lu | 3:1823bfc913c1 | 200 | { TEXT_CreateIndirect, "V_Dis", GUI_ID_USER + 118, 302, 70+47*2, 80, 20, 0, 0x64, 0 }, |
Will_Lu | 3:1823bfc913c1 | 201 | |
Will_Lu | 3:1823bfc913c1 | 202 | { TEXT_CreateIndirect, "A1", GUI_ID_USER + 119, 565, 70+47*0, 95, 20, 0, 0x64, 0 }, |
Will_Lu | 3:1823bfc913c1 | 203 | { TEXT_CreateIndirect, "A2", GUI_ID_USER + 120, 565, 70+47*1, 95, 20, 0, 0x64, 0 }, |
Will_Lu | 3:1823bfc913c1 | 204 | { TEXT_CreateIndirect, "A3", GUI_ID_USER + 121, 565, 70+47*2, 95, 20, 0, 0x64, 0 }, |
Will_Lu | 3:1823bfc913c1 | 205 | |
Will_Lu | 3:1823bfc913c1 | 206 | }; // 107 -- 121 |
Will_Lu | 2:bfc676294e38 | 207 | static const GUI_WIDGET_CREATE_INFO _aFurtherSelect[] = { |
Will_Lu | 3:1823bfc913c1 | 208 | { FRAMEWIN_CreateIndirect, "Analysis", ID_FRAMEWIN_10, 0, 0, 800, 480, 0, 0x64, 0 }, |
Will_Lu | 3:1823bfc913c1 | 209 | { BUTTON_CreateIndirect, "Local", GUI_ID_USER + 82, 65 , 165, 300, 120}, |
Will_Lu | 2:bfc676294e38 | 210 | { BUTTON_CreateIndirect, "Remote", GUI_ID_USER + 83, 425 , 165, 300, 120}, |
Will_Lu | 2:bfc676294e38 | 211 | }; |
destinyXfate | 0:08606a13a816 | 212 | static const GUI_WIDGET_CREATE_INFO _aRemoteAnalysis[] = { |
Will_Lu | 3:1823bfc913c1 | 213 | { FRAMEWIN_CreateIndirect, "Analysis", ID_FRAMEWIN_0, 0, 0, 800, 480, 0, 0x64, 0 }, |
Will_Lu | 2:bfc676294e38 | 214 | { TEXT_CreateIndirect, "Normal", GUI_ID_USER + 85, 120 , 125, 95 , 30}, |
Will_Lu | 2:bfc676294e38 | 215 | { TEXT_CreateIndirect, "Caution", GUI_ID_USER + 86, 273 , 125, 95 , 30}, |
Will_Lu | 2:bfc676294e38 | 216 | { TEXT_CreateIndirect, "Warning", GUI_ID_USER + 87, 425 , 125, 95 , 30}, |
Will_Lu | 2:bfc676294e38 | 217 | { TEXT_CreateIndirect, "Danger", GUI_ID_USER + 88, 575 , 125, 95 , 30}, |
Will_Lu | 2:bfc676294e38 | 218 | { TEXT_CreateIndirect, "0.25", GUI_ID_USER + 89, 222 , 185, 50, 30}, |
Will_Lu | 2:bfc676294e38 | 219 | { TEXT_CreateIndirect, "0.5", GUI_ID_USER + 90, 370 , 185, 50, 30}, |
Will_Lu | 2:bfc676294e38 | 220 | { TEXT_CreateIndirect, "0.75", GUI_ID_USER + 91, 530 , 185, 50, 30}, |
Will_Lu | 2:bfc676294e38 | 221 | { TEXT_CreateIndirect, "Condition Monitoring", GUI_ID_USER + 92, 250 , 40, 300, 30}, |
Will_Lu | 2:bfc676294e38 | 222 | { BUTTON_CreateIndirect, "Fault Diagnosis", GUI_ID_USER + 84, 550 , 350, 230, 80}, |
Will_Lu | 2:bfc676294e38 | 223 | |
Will_Lu | 2:bfc676294e38 | 224 | }; |
Will_Lu | 2:bfc676294e38 | 225 | |
Will_Lu | 2:bfc676294e38 | 226 | static const GUI_WIDGET_CREATE_INFO _aFurtherFault[] = { |
Will_Lu | 3:1823bfc913c1 | 227 | { FRAMEWIN_CreateIndirect, "Analysis", ID_FRAMEWIN_9, 0, 0, 800, 480, 0, 0x64, 0 }, |
Will_Lu | 2:bfc676294e38 | 228 | |
Will_Lu | 2:bfc676294e38 | 229 | { TEXT_CreateIndirect, "Fault Diagnosis", GUI_ID_USER + 98, 290 ,40, 300, 30}, |
Will_Lu | 2:bfc676294e38 | 230 | { TEXT_CreateIndirect, "Health", GUI_ID_USER + 93, 290, 145, 100 , 30}, |
Will_Lu | 2:bfc676294e38 | 231 | { TEXT_CreateIndirect, "Stator", GUI_ID_USER + 94, 290, 206, 100 , 30}, |
Will_Lu | 2:bfc676294e38 | 232 | { TEXT_CreateIndirect, "Rotor", GUI_ID_USER + 95, 290, 267, 100 , 30}, |
Will_Lu | 2:bfc676294e38 | 233 | { TEXT_CreateIndirect, "Bearing", GUI_ID_USER + 96, 290, 328, 100 , 30}, |
Will_Lu | 2:bfc676294e38 | 234 | { TEXT_CreateIndirect, "Eccentric", GUI_ID_USER + 97, 290, 389, 150 , 30}, |
Will_Lu | 2:bfc676294e38 | 235 | }; // 83 -- 98 |
destinyXfate | 0:08606a13a816 | 236 | |
destinyXfate | 0:08606a13a816 | 237 | static const GUI_WIDGET_CREATE_INFO _aADCPage[] = { |
destinyXfate | 0:08606a13a816 | 238 | { FRAMEWIN_CreateIndirect, "Motor Detection", ID_FRAMEWIN_5, 0, 0, 800, 480, 0, 0x64, 0 }, |
destinyXfate | 0:08606a13a816 | 239 | |
destinyXfate | 0:08606a13a816 | 240 | { BUTTON_CreateIndirect, "Get Background Value", GUI_ID_USER + 135, 0 , 105, 230, 120}, |
destinyXfate | 0:08606a13a816 | 241 | { BUTTON_CreateIndirect, "Data Acquisition", GUI_ID_USER + 136, 280, 105, 230, 120}, |
Will_Lu | 3:1823bfc913c1 | 242 | { BUTTON_CreateIndirect, "Index" , GUI_ID_USER + 137, 560, 105, 230, 120}, |
destinyXfate | 0:08606a13a816 | 243 | { BUTTON_CreateIndirect, "Send Data", GUI_ID_USER + 138, 0 , 330, 230, 120}, |
destinyXfate | 0:08606a13a816 | 244 | { BUTTON_CreateIndirect, "Get Result", GUI_ID_USER + 139, 280, 330, 230, 120}, |
Will_Lu | 3:1823bfc913c1 | 245 | { BUTTON_CreateIndirect, "Analysis" , GUI_ID_USER + 140, 560, 330, 230, 120}, |
destinyXfate | 0:08606a13a816 | 246 | |
destinyXfate | 0:08606a13a816 | 247 | }; // 135 -- 140 |
destinyXfate | 0:08606a13a816 | 248 | |
destinyXfate | 0:08606a13a816 | 249 | |
destinyXfate | 0:08606a13a816 | 250 | static const GUI_WIDGET_CREATE_INFO _aMainPage[] = { |
destinyXfate | 0:08606a13a816 | 251 | { WINDOW_CreateIndirect, "Main_Page", ID_WINDOW_0, 0, 0, 800, 480}, |
destinyXfate | 0:08606a13a816 | 252 | { RADIO_CreateIndirect, "Radio", ID_RADIO_0, 30, 265, 133, 52, 0, 0x1e02, 0 }, |
destinyXfate | 0:08606a13a816 | 253 | |
destinyXfate | 0:08606a13a816 | 254 | { TEXT_CreateIndirect, "Motor Parameters", GUI_ID_USER + 14, 114, 25, 235, 30}, |
destinyXfate | 0:08606a13a816 | 255 | { TEXT_CreateIndirect, "Volts", GUI_ID_USER + 15, 35, 110, 80, 20}, |
destinyXfate | 0:08606a13a816 | 256 | { TEXT_CreateIndirect, "IP Address", GUI_ID_USER + 16, 70, 330, 95, 20}, |
destinyXfate | 0:08606a13a816 | 257 | { TEXT_CreateIndirect, "Netmask", GUI_ID_USER + 17, 70, 365, 80, 20}, |
destinyXfate | 0:08606a13a816 | 258 | { TEXT_CreateIndirect, "Gateway", GUI_ID_USER + 18, 70, 400, 80, 20}, |
destinyXfate | 0:08606a13a816 | 259 | { TEXT_CreateIndirect, "Amps", GUI_ID_USER + 19, 35, 145, 80, 20}, |
destinyXfate | 0:08606a13a816 | 260 | { TEXT_CreateIndirect, "Motor ID", GUI_ID_USER + 20, 35, 75, 95, 20}, |
destinyXfate | 0:08606a13a816 | 261 | { TEXT_CreateIndirect, "HP", GUI_ID_USER + 21, 250, 75, 60, 20}, |
destinyXfate | 0:08606a13a816 | 262 | { TEXT_CreateIndirect, "Poles", GUI_ID_USER + 22, 250, 110, 80, 20}, |
destinyXfate | 0:08606a13a816 | 263 | { TEXT_CreateIndirect, "RPM", GUI_ID_USER + 23, 250, 145, 80, 20}, |
destinyXfate | 0:08606a13a816 | 264 | { TEXT_CreateIndirect, "Network Setting", GUI_ID_USER + 33, 128, 230, 235, 30}, |
destinyXfate | 0:08606a13a816 | 265 | |
destinyXfate | 0:08606a13a816 | 266 | { EDIT_CreateIndirect, "MotorID", GUI_ID_USER + 24, 130, 70, 95, 30, 0, 0x08, 0 }, |
destinyXfate | 0:08606a13a816 | 267 | { EDIT_CreateIndirect, "Volts", GUI_ID_USER + 25, 130, 105, 95, 30, 0, 0x08, 0 }, |
destinyXfate | 0:08606a13a816 | 268 | { EDIT_CreateIndirect, "Amps", GUI_ID_USER + 26, 130, 140, 95, 30, 0, 0x08, 0 }, |
destinyXfate | 0:08606a13a816 | 269 | { EDIT_CreateIndirect, "HP", GUI_ID_USER + 27, 330, 70, 95, 30, 0, 0x08, 0 }, |
destinyXfate | 0:08606a13a816 | 270 | { EDIT_CreateIndirect, "Pole", GUI_ID_USER + 28, 330, 105, 95, 30, 0, 0x08, 0 }, |
destinyXfate | 0:08606a13a816 | 271 | { EDIT_CreateIndirect, "RPM", GUI_ID_USER + 29, 330, 140, 95, 30, 0, 0x08, 0 }, |
destinyXfate | 0:08606a13a816 | 272 | { EDIT_CreateIndirect, "IPADDR", GUI_ID_USER + 30, 200, 325, 180, 30, 0, 0x0f, 0 }, |
destinyXfate | 0:08606a13a816 | 273 | { EDIT_CreateIndirect, "NetMask", GUI_ID_USER + 31, 200, 360, 180, 30, 0, 0x0f, 0 }, |
destinyXfate | 0:08606a13a816 | 274 | { EDIT_CreateIndirect, "GWay", GUI_ID_USER + 32, 200, 395, 180, 30, 0, 0x0f, 0 }, |
destinyXfate | 0:08606a13a816 | 275 | |
destinyXfate | 0:08606a13a816 | 276 | { BUTTON_CreateIndirect, "7", GUI_ID_USER + 7, 492, 130, 45, 45}, |
destinyXfate | 0:08606a13a816 | 277 | { BUTTON_CreateIndirect, "4", GUI_ID_USER + 4, 492, 185, 45, 45}, |
destinyXfate | 0:08606a13a816 | 278 | { BUTTON_CreateIndirect, "1", GUI_ID_USER + 1, 492, 240, 45, 45}, |
destinyXfate | 0:08606a13a816 | 279 | { BUTTON_CreateIndirect, "8", GUI_ID_USER + 8, 547, 130, 45, 45}, |
destinyXfate | 0:08606a13a816 | 280 | { BUTTON_CreateIndirect, "5", GUI_ID_USER + 5, 547, 182, 45, 45}, |
destinyXfate | 0:08606a13a816 | 281 | { BUTTON_CreateIndirect, "2", GUI_ID_USER + 2, 547, 240, 45, 45}, |
destinyXfate | 0:08606a13a816 | 282 | { BUTTON_CreateIndirect, "9", GUI_ID_USER + 9, 602, 130, 45, 45}, |
destinyXfate | 0:08606a13a816 | 283 | { BUTTON_CreateIndirect, "6", GUI_ID_USER + 6, 602, 185, 45, 45}, |
destinyXfate | 0:08606a13a816 | 284 | { BUTTON_CreateIndirect, "3", GUI_ID_USER + 3, 602, 240, 45, 45}, |
destinyXfate | 0:08606a13a816 | 285 | { BUTTON_CreateIndirect, "0", GUI_ID_USER + 0, 492, 295, 100, 45}, |
destinyXfate | 0:08606a13a816 | 286 | { BUTTON_CreateIndirect, ".", GUI_ID_USER + 10, 602, 295, 45, 45}, |
destinyXfate | 0:08606a13a816 | 287 | { BUTTON_CreateIndirect, "", GUI_ID_USER + 11, 662, 130, 60, 100}, |
destinyXfate | 0:08606a13a816 | 288 | { BUTTON_CreateIndirect, "Enter", GUI_ID_USER + 12, 470, 430, 100, 50}, |
destinyXfate | 0:08606a13a816 | 289 | { BUTTON_CreateIndirect, "Motor Detection", GUI_ID_USER + 13, 620, 430, 180, 50}, |
destinyXfate | 0:08606a13a816 | 290 | |
destinyXfate | 0:08606a13a816 | 291 | };///// GUI_ID_USER 0 - 33 ////// |
destinyXfate | 0:08606a13a816 | 292 | |
destinyXfate | 0:08606a13a816 | 293 | |
destinyXfate | 0:08606a13a816 | 294 | static const GUI_WIDGET_CREATE_INFO _aSelectPage[] = { |
Will_Lu | 3:1823bfc913c1 | 295 | { FRAMEWIN_CreateIndirect, "Index Option" , ID_FRAMEWIN_2, 0, 0, 800, 480, 0, 0x64, 0 }, |
Will_Lu | 3:1823bfc913c1 | 296 | { BUTTON_CreateIndirect, "Vibration", GUI_ID_USER + 37, 425, 165, 300, 120}, |
Will_Lu | 3:1823bfc913c1 | 297 | { BUTTON_CreateIndirect, "Electrical", GUI_ID_USER + 36, 65, 165, 300, 120}, |
destinyXfate | 0:08606a13a816 | 298 | }; ///// GUI_ID_USER 36,37 ////// |
destinyXfate | 0:08606a13a816 | 299 | |
Will_Lu | 3:1823bfc913c1 | 300 | |
Will_Lu | 3:1823bfc913c1 | 301 | static const GUI_WIDGET_CREATE_INFO _aIndexPage2[] = { |
Will_Lu | 3:1823bfc913c1 | 302 | { FRAMEWIN_CreateIndirect, "Electrical Index", ID_FRAMEWIN_11, 0, 0, 800, 480, 0, 0x64, 0 }, |
Will_Lu | 3:1823bfc913c1 | 303 | { TEXT_CreateIndirect, "Status", ID_TEXT_1, 565, 15, 95, 40, 0, 0x0, 0 }, |
Will_Lu | 3:1823bfc913c1 | 304 | { TEXT_CreateIndirect, "Value", GUI_ID_USER + 35, 330, 15, 180, 20, 0, 0x0, 0 }, |
Will_Lu | 3:1823bfc913c1 | 305 | { TEXT_CreateIndirect, "Threshold", GUI_ID_USER + 36, 410, 15, 180, 20, 0, 0x0, 0 }, |
Will_Lu | 3:1823bfc913c1 | 306 | |
Will_Lu | 3:1823bfc913c1 | 307 | { TEXT_CreateIndirect, "Current THD", GUI_ID_USER + 37, 10, 70, 134, 20, 0, 0x0, 0 }, |
Will_Lu | 3:1823bfc913c1 | 308 | { TEXT_CreateIndirect, "Max Current Odd HD ( < 11th )", GUI_ID_USER + 38, 10, 70+47*1, 270, 20, 0, 0x0, 0 }, |
Will_Lu | 3:1823bfc913c1 | 309 | { TEXT_CreateIndirect, "Side Band", GUI_ID_USER + 39, 10, 70+47*2, 270, 20, 0, 0x0, 0 }, |
Will_Lu | 3:1823bfc913c1 | 310 | { TEXT_CreateIndirect, "Voltage Deviation", GUI_ID_USER + 49, 10, 70+47*3, 270, 20, 0, 0x0, 0 }, |
Will_Lu | 3:1823bfc913c1 | 311 | { TEXT_CreateIndirect, "Current Deviation", GUI_ID_USER + 50, 10, 70+47*4, 270, 20, 0, 0x0, 0 }, |
Will_Lu | 3:1823bfc913c1 | 312 | |
Will_Lu | 3:1823bfc913c1 | 313 | { TEXT_CreateIndirect, "% 5 %", GUI_ID_USER + 40, 410, 70, 90, 20, 0, 0x64, 0 }, |
Will_Lu | 3:1823bfc913c1 | 314 | { TEXT_CreateIndirect, "% 4 %", GUI_ID_USER + 41, 410, 70+47*1, 90, 20, 0, 0x64, 0 }, |
Will_Lu | 3:1823bfc913c1 | 315 | { TEXT_CreateIndirect, "dB -40 dB", GUI_ID_USER + 42, 400, 70+47*2,100, 20, 0, 0x64, 0 }, |
Will_Lu | 3:1823bfc913c1 | 316 | { TEXT_CreateIndirect, "% 10 %", GUI_ID_USER + 51, 410, 70+47*3, 90, 20, 0, 0x64, 0 }, |
Will_Lu | 3:1823bfc913c1 | 317 | { TEXT_CreateIndirect, "% 10 %", GUI_ID_USER + 52, 410, 70+47*4,90, 20, 0, 0x64, 0 }, |
Will_Lu | 3:1823bfc913c1 | 318 | |
Will_Lu | 3:1823bfc913c1 | 319 | { TEXT_CreateIndirect, "V_THDI", GUI_ID_USER + 43, 330, 70+47*0, 80, 20, 0, 0x0, 0 }, |
Will_Lu | 3:1823bfc913c1 | 320 | { TEXT_CreateIndirect, "V_IDFodd", GUI_ID_USER + 44, 330, 70+47*1, 80, 20, 0, 0x0, 0 }, |
Will_Lu | 3:1823bfc913c1 | 321 | { TEXT_CreateIndirect, "V_BB", GUI_ID_USER + 45, 315, 70+47*2, 80, 20, 0, 0x64, 0 }, |
Will_Lu | 3:1823bfc913c1 | 322 | { TEXT_CreateIndirect, "V_VD", GUI_ID_USER + 53, 330, 70+47*3, 80, 20, 0, 0x0, 0 }, |
Will_Lu | 3:1823bfc913c1 | 323 | { TEXT_CreateIndirect, "V_CD", GUI_ID_USER + 54, 330, 70+47*4, 80, 20, 0, 0x0, 0 }, |
Will_Lu | 3:1823bfc913c1 | 324 | |
Will_Lu | 3:1823bfc913c1 | 325 | { TEXT_CreateIndirect, "S5", GUI_ID_USER + 46, 565, 70+47*0, 95, 20, 0, 0x64, 0 }, |
Will_Lu | 3:1823bfc913c1 | 326 | { TEXT_CreateIndirect, "S6", GUI_ID_USER + 47, 565, 70+47*1, 95, 20, 0, 0x64, 0 }, |
Will_Lu | 3:1823bfc913c1 | 327 | { TEXT_CreateIndirect, "S9", GUI_ID_USER + 48, 565, 70+47*2, 95, 20, 0, 0x64, 0 }, |
Will_Lu | 3:1823bfc913c1 | 328 | { TEXT_CreateIndirect, "S10", GUI_ID_USER + 55, 565, 70+47*3, 95, 20, 0, 0x64, 0 }, |
Will_Lu | 3:1823bfc913c1 | 329 | { TEXT_CreateIndirect, "S11", GUI_ID_USER + 56, 565, 70+47*4, 95, 20, 0, 0x64, 0 }, |
Will_Lu | 3:1823bfc913c1 | 330 | |
Will_Lu | 3:1823bfc913c1 | 331 | };///// GUI_ID_USER 34 -- 56 ////// |
destinyXfate | 0:08606a13a816 | 332 | |
destinyXfate | 0:08606a13a816 | 333 | static const GUI_WIDGET_CREATE_INFO _aIndexPage[] = { |
Will_Lu | 3:1823bfc913c1 | 334 | { FRAMEWIN_CreateIndirect, "Electrical Index", ID_FRAMEWIN_1, 0, 0, 800, 480, 0, 0x64, 0 }, |
destinyXfate | 0:08606a13a816 | 335 | |
destinyXfate | 0:08606a13a816 | 336 | { TEXT_CreateIndirect, "Status", ID_TEXT_1, 565, 15, 95, 40, 0, 0x0, 0 }, |
destinyXfate | 0:08606a13a816 | 337 | { TEXT_CreateIndirect, "Value", GUI_ID_USER + 59, 330, 15, 180, 20, 0, 0x0, 0 }, |
Will_Lu | 3:1823bfc913c1 | 338 | { TEXT_CreateIndirect, "Threshold", GUI_ID_USER + 60, 410, 15, 180, 20, 0, 0x0, 0 }, |
Will_Lu | 3:1823bfc913c1 | 339 | { TEXT_CreateIndirect, "Voltage Unbalance", GUI_ID_USER + 61, 10, 70+47*0, 180, 20, 0, 0x0, 0 }, |
Will_Lu | 3:1823bfc913c1 | 340 | { TEXT_CreateIndirect, "Voltage Unbalance Factor", GUI_ID_USER + 62, 10, 70+47*1, 230, 20, 0, 0x0, 0 }, |
destinyXfate | 0:08606a13a816 | 341 | { TEXT_CreateIndirect, "Voltage THD", GUI_ID_USER + 63, 10, 70+47*4, 134, 20, 0, 0x0, 0 }, |
destinyXfate | 0:08606a13a816 | 342 | { TEXT_CreateIndirect, "Max Voltage Odd HD ( < 11th )", GUI_ID_USER + 64, 10, 70+47*5, 270, 20, 0, 0x0, 0 }, |
destinyXfate | 0:08606a13a816 | 343 | { TEXT_CreateIndirect, "Current Unbalance", GUI_ID_USER + 65, 10, 70+47*2, 180, 20, 0, 0x0, 0 }, |
destinyXfate | 0:08606a13a816 | 344 | { TEXT_CreateIndirect, "Current Unbalance Factor", GUI_ID_USER + 66, 10, 70+47*3, 230, 20, 0, 0x0, 0 }, |
Will_Lu | 3:1823bfc913c1 | 345 | { BUTTON_CreateIndirect, "Next Page", GUI_ID_USER + 73, 550 , 350, 230, 80}, |
Will_Lu | 3:1823bfc913c1 | 346 | |
Will_Lu | 3:1823bfc913c1 | 347 | |
Will_Lu | 3:1823bfc913c1 | 348 | |
Will_Lu | 3:1823bfc913c1 | 349 | { TEXT_CreateIndirect, "% 10 %", GUI_ID_USER + 67, 410, 70+47*2, 90, 20, 0, 0x64, 0 }, |
Will_Lu | 3:1823bfc913c1 | 350 | { TEXT_CreateIndirect, "% 2.5 %", GUI_ID_USER + 68, 410, 70+47*3, 90, 20, 0, 0x64, 0 }, |
Will_Lu | 3:1823bfc913c1 | 351 | { TEXT_CreateIndirect, "% 5 %", GUI_ID_USER + 69, 410, 70+47*4, 90, 20, 0, 0x64, 0 }, |
Will_Lu | 3:1823bfc913c1 | 352 | { TEXT_CreateIndirect, "% 3 %", GUI_ID_USER + 70, 410, 70+47*5, 90, 20, 0, 0x64, 0 }, |
Will_Lu | 3:1823bfc913c1 | 353 | { TEXT_CreateIndirect, "% 5 %", GUI_ID_USER + 71, 410, 70+47*0, 90, 20, 0, 0x64, 0 }, |
Will_Lu | 3:1823bfc913c1 | 354 | { TEXT_CreateIndirect, "% 1 %", GUI_ID_USER + 72, 410, 70+47*1, 90, 20, 0, 0x64, 0 }, |
Will_Lu | 3:1823bfc913c1 | 355 | |
Will_Lu | 3:1823bfc913c1 | 356 | |
destinyXfate | 0:08606a13a816 | 357 | { TEXT_CreateIndirect, "V_THDV", ID_TEXT_22, 330, 70+47*4, 80, 20, 0, 0x0, 0 }, /// 330 |
destinyXfate | 0:08606a13a816 | 358 | { TEXT_CreateIndirect, "V_VDFodd", ID_TEXT_23, 330, 70+47*5, 80, 20, 0, 0x0, 0 }, |
destinyXfate | 0:08606a13a816 | 359 | { TEXT_CreateIndirect, "V_IUR", ID_TEXT_24, 330, 70+47*2, 80, 20, 0, 0x0, 0 }, |
destinyXfate | 0:08606a13a816 | 360 | { TEXT_CreateIndirect, "V_IUF", ID_TEXT_25, 330, 70+47*3, 80, 20, 0, 0x0, 0 }, |
Will_Lu | 3:1823bfc913c1 | 361 | { TEXT_CreateIndirect, "V_VUR", ID_TEXT_29, 330, 70+47*0, 80, 20, 0, 0x64, 0 }, |
Will_Lu | 3:1823bfc913c1 | 362 | { TEXT_CreateIndirect, "V_VUF", ID_TEXT_30, 330, 70+47*1, 80, 20, 0, 0x64, 0 }, |
Will_Lu | 3:1823bfc913c1 | 363 | |
destinyXfate | 0:08606a13a816 | 364 | |
destinyXfate | 0:08606a13a816 | 365 | { TEXT_CreateIndirect, "S1", ID_TEXT_32, 565, 70+47*4, 95, 20, 0, 0x64, 0 }, |
destinyXfate | 0:08606a13a816 | 366 | { TEXT_CreateIndirect, "S2", ID_TEXT_33, 565, 70+47*5, 95, 20, 0, 0x64, 0 }, |
destinyXfate | 0:08606a13a816 | 367 | { TEXT_CreateIndirect, "S3", ID_TEXT_34, 565, 70+47*2, 95, 20, 0, 0x64, 0 }, |
destinyXfate | 0:08606a13a816 | 368 | { TEXT_CreateIndirect, "S4", ID_TEXT_35, 565, 70+47*3, 95, 20, 0, 0x64, 0 }, |
destinyXfate | 0:08606a13a816 | 369 | { TEXT_CreateIndirect, "S7", ID_TEXT_38, 565, 70+47*0, 95, 20, 0, 0x64, 0 }, |
Will_Lu | 3:1823bfc913c1 | 370 | { TEXT_CreateIndirect, "S8", ID_TEXT_39, 565, 70+47*1, 95, 20, 0, 0x64, 0 }, |
Will_Lu | 3:1823bfc913c1 | 371 | |
Will_Lu | 3:1823bfc913c1 | 372 | |
Will_Lu | 3:1823bfc913c1 | 373 | };///// GUI_ID_USER 59 -- 73 ////// |
destinyXfate | 0:08606a13a816 | 374 | |
destinyXfate | 0:08606a13a816 | 375 | void fileName(time_t time, char* name, int type); |
destinyXfate | 0:08606a13a816 | 376 | void fileName(time_t time, char* name) |
destinyXfate | 0:08606a13a816 | 377 | { |
destinyXfate | 0:08606a13a816 | 378 | time_t timestamp = time; |
destinyXfate | 0:08606a13a816 | 379 | strftime(name, 33, "/mci/MDES/data/%Y%m%d%H%M%S.adc", localtime(×tamp)); |
destinyXfate | 0:08606a13a816 | 380 | } |
destinyXfate | 0:08606a13a816 | 381 | void readdata(const char *s, double *d); // 讀SD卡檔案 ( 測試用 ) |
destinyXfate | 0:08606a13a816 | 382 | void readdata(const char *s, double *d) // 讀SD卡檔案 ( 測試用 ) |
destinyXfate | 0:08606a13a816 | 383 | { |
destinyXfate | 0:08606a13a816 | 384 | |
destinyXfate | 0:08606a13a816 | 385 | FILE *fp = fopen(s, "r"); |
destinyXfate | 0:08606a13a816 | 386 | if (fp != NULL) { |
destinyXfate | 0:08606a13a816 | 387 | for(int i = 0 ; i<len ; i++) { |
destinyXfate | 0:08606a13a816 | 388 | fscanf(fp, "%lf\r\n",&d[i]); |
destinyXfate | 0:08606a13a816 | 389 | } |
destinyXfate | 0:08606a13a816 | 390 | } |
destinyXfate | 0:08606a13a816 | 391 | fclose(fp); |
destinyXfate | 0:08606a13a816 | 392 | |
destinyXfate | 0:08606a13a816 | 393 | } |
destinyXfate | 0:08606a13a816 | 394 | |
destinyXfate | 0:08606a13a816 | 395 | |
destinyXfate | 0:08606a13a816 | 396 | |
destinyXfate | 0:08606a13a816 | 397 | |
destinyXfate | 0:08606a13a816 | 398 | void send_network(); |
destinyXfate | 0:08606a13a816 | 399 | void send_network() |
destinyXfate | 0:08606a13a816 | 400 | { |
destinyXfate | 0:08606a13a816 | 401 | // eth.init(); //Use DHCP |
destinyXfate | 0:08606a13a816 | 402 | |
destinyXfate | 0:08606a13a816 | 403 | eth.connect(); |
destinyXfate | 0:08606a13a816 | 404 | |
destinyXfate | 0:08606a13a816 | 405 | pc.printf("\nMAC Address is %s\r\n", eth.getMACAddress()); |
destinyXfate | 0:08606a13a816 | 406 | pc.printf("Client IP Address is %s\r\n", eth.getIPAddress()); |
destinyXfate | 0:08606a13a816 | 407 | |
destinyXfate | 0:08606a13a816 | 408 | FILE *aFile = fopen("/mci/soap.tmp", "r"); |
destinyXfate | 0:08606a13a816 | 409 | if (aFile == NULL) { |
destinyXfate | 0:08606a13a816 | 410 | pc.printf("Could not open file\r\n"); |
destinyXfate | 0:08606a13a816 | 411 | } |
destinyXfate | 0:08606a13a816 | 412 | |
destinyXfate | 0:08606a13a816 | 413 | char str[512] = "mmm\r\n"; |
destinyXfate | 0:08606a13a816 | 414 | HTTPFile hFile(aFile); |
destinyXfate | 0:08606a13a816 | 415 | HTTPText inText(str, 512); |
destinyXfate | 0:08606a13a816 | 416 | |
destinyXfate | 0:08606a13a816 | 417 | int ret = http.post("http://140.118.7.148:8080/MMC-service/MotorService", hFile, &inText); |
destinyXfate | 0:08606a13a816 | 418 | pc.printf("\nResult: %s\r\n", str); |
destinyXfate | 0:08606a13a816 | 419 | if (!ret) { |
destinyXfate | 0:08606a13a816 | 420 | pc.printf("\nPage fetched successfully - read %d characters\r\n", strlen(str)); |
destinyXfate | 0:08606a13a816 | 421 | } else { |
destinyXfate | 0:08606a13a816 | 422 | pc.printf("Error - ret = %d - HTTP return code = %d\r\n", ret, http.getHTTPResponseCode()); |
destinyXfate | 0:08606a13a816 | 423 | } |
destinyXfate | 0:08606a13a816 | 424 | fclose(aFile); |
destinyXfate | 0:08606a13a816 | 425 | |
destinyXfate | 0:08606a13a816 | 426 | eth.disconnect(); |
destinyXfate | 0:08606a13a816 | 427 | } |
destinyXfate | 0:08606a13a816 | 428 | |
destinyXfate | 0:08606a13a816 | 429 | void ADC(int16_t *x, int number, int adc_num); |
destinyXfate | 0:08606a13a816 | 430 | void ADC(int16_t *x, int number, int adc_num) |
destinyXfate | 0:08606a13a816 | 431 | { |
destinyXfate | 0:08606a13a816 | 432 | switch(adc_num) { |
destinyXfate | 0:08606a13a816 | 433 | case 1: |
destinyXfate | 0:08606a13a816 | 434 | for (int i = 0; i < number; i++) { |
destinyXfate | 0:08606a13a816 | 435 | timer.start(); |
destinyXfate | 0:08606a13a816 | 436 | adc.adc(x + (i * 6)); |
destinyXfate | 0:08606a13a816 | 437 | |
destinyXfate | 0:08606a13a816 | 438 | while (timer.read_us() < 45) { |
destinyXfate | 0:08606a13a816 | 439 | wait_us(0.1); |
destinyXfate | 0:08606a13a816 | 440 | } |
destinyXfate | 0:08606a13a816 | 441 | timer.stop(); |
destinyXfate | 0:08606a13a816 | 442 | timer.reset(); |
destinyXfate | 0:08606a13a816 | 443 | } |
destinyXfate | 0:08606a13a816 | 444 | break; |
destinyXfate | 0:08606a13a816 | 445 | |
destinyXfate | 0:08606a13a816 | 446 | case 2: |
destinyXfate | 0:08606a13a816 | 447 | for (int i = 0; i < number; i++) { |
destinyXfate | 0:08606a13a816 | 448 | timer.start(); |
destinyXfate | 0:08606a13a816 | 449 | adc2.adc(x + (i * 6)); |
destinyXfate | 0:08606a13a816 | 450 | |
destinyXfate | 0:08606a13a816 | 451 | while (timer.read_us() < 45) { |
destinyXfate | 0:08606a13a816 | 452 | wait_us(0.1); |
destinyXfate | 0:08606a13a816 | 453 | } |
destinyXfate | 0:08606a13a816 | 454 | timer.stop(); |
destinyXfate | 0:08606a13a816 | 455 | timer.reset(); |
destinyXfate | 0:08606a13a816 | 456 | } |
destinyXfate | 0:08606a13a816 | 457 | break; |
destinyXfate | 0:08606a13a816 | 458 | } |
destinyXfate | 0:08606a13a816 | 459 | } |
destinyXfate | 0:08606a13a816 | 460 | |
destinyXfate | 0:08606a13a816 | 461 | void get_bk_value(double *bkIUR, double *bkIUF, double *bkTHDV, double *bkVDFodd, double *bkTHDI, double *bkIDFodd, double *bkPeakValue, double *bkUBValue); |
destinyXfate | 0:08606a13a816 | 462 | void get_bk_value(double *bkIUR, double *bkIUF, double *bkTHDV, double *bkVDFodd, double *bkTHDI, double *bkIDFodd, double *bkPeakValue, double *bkUBValue) |
destinyXfate | 0:08606a13a816 | 463 | { |
destinyXfate | 0:08606a13a816 | 464 | int i; |
destinyXfate | 0:08606a13a816 | 465 | |
destinyXfate | 0:08606a13a816 | 466 | double *bkia_1, *bkib_1, *bkic_1, *bkx_acc, *bky_acc, *bkz_acc ; |
destinyXfate | 0:08606a13a816 | 467 | double *bkva_fft, *bkvb_fft, *bkvc_fft, *bkia_fft, *bkib_fft, *bkic_fft; |
destinyXfate | 0:08606a13a816 | 468 | double *bkia_fft_real, *bkia_fft_imag, *bkib_fft_real, *bkib_fft_imag, *bkic_fft_real, *bkic_fft_imag; |
destinyXfate | 0:08606a13a816 | 469 | double bkia_RMS, bkib_RMS, bkic_RMS, bkang_a, bkang_b, bkang_c; |
destinyXfate | 0:08606a13a816 | 470 | |
destinyXfate | 0:08606a13a816 | 471 | bkia_1 = (double*) malloc(sizeof(double) * len); |
destinyXfate | 0:08606a13a816 | 472 | bkib_1 = (double*) malloc(sizeof(double) * len); |
destinyXfate | 0:08606a13a816 | 473 | bkic_1 = (double*) malloc(sizeof(double) * len); |
destinyXfate | 0:08606a13a816 | 474 | bkx_acc = (double*) malloc(sizeof(double) * len); |
destinyXfate | 0:08606a13a816 | 475 | bky_acc = (double*) malloc(sizeof(double) * len); |
destinyXfate | 0:08606a13a816 | 476 | bkz_acc = (double*) malloc(sizeof(double) * len); |
destinyXfate | 0:08606a13a816 | 477 | |
destinyXfate | 0:08606a13a816 | 478 | bkva_fft = (double*) malloc(sizeof(double) * len); |
destinyXfate | 0:08606a13a816 | 479 | bkvb_fft = (double*) malloc(sizeof(double) * len); |
destinyXfate | 0:08606a13a816 | 480 | bkvc_fft = (double*) malloc(sizeof(double) * len); |
destinyXfate | 0:08606a13a816 | 481 | bkia_fft = (double*) malloc(sizeof(double) * len); |
destinyXfate | 0:08606a13a816 | 482 | bkib_fft = (double*) malloc(sizeof(double) * len); |
destinyXfate | 0:08606a13a816 | 483 | bkic_fft = (double*) malloc(sizeof(double) * len); |
destinyXfate | 0:08606a13a816 | 484 | |
destinyXfate | 0:08606a13a816 | 485 | int mode = atoi(Gateway); /// mode 0: default mode 1: test mode |
destinyXfate | 0:08606a13a816 | 486 | if(mode==1) { |
destinyXfate | 0:08606a13a816 | 487 | |
destinyXfate | 0:08606a13a816 | 488 | const char *ia2 = "/mci/0/ia.csv" ; // ( 測試用 ) |
destinyXfate | 0:08606a13a816 | 489 | readdata(ia2,bkia_1); |
destinyXfate | 0:08606a13a816 | 490 | |
destinyXfate | 0:08606a13a816 | 491 | const char *ib2 = "/mci/0/ib.csv" ; // ( 測試用 ) |
destinyXfate | 0:08606a13a816 | 492 | readdata(ib2,bkib_1); |
destinyXfate | 0:08606a13a816 | 493 | |
destinyXfate | 0:08606a13a816 | 494 | const char *ic2 = "/mci/0/ic.csv" ; // ( 測試用 ) |
destinyXfate | 0:08606a13a816 | 495 | readdata(ic2,bkic_1); |
destinyXfate | 0:08606a13a816 | 496 | |
destinyXfate | 0:08606a13a816 | 497 | const char *xacc2 = "/mci/0/x_acc.csv" ; // ( 測試用 ) |
destinyXfate | 0:08606a13a816 | 498 | readdata(xacc2,bkx_acc); |
destinyXfate | 0:08606a13a816 | 499 | |
destinyXfate | 0:08606a13a816 | 500 | const char *yacc2 = "/mci/0/y_acc.csv" ; // ( 測試用 ) |
destinyXfate | 0:08606a13a816 | 501 | readdata(yacc2,bky_acc); |
destinyXfate | 0:08606a13a816 | 502 | |
destinyXfate | 0:08606a13a816 | 503 | const char *zacc2 = "/mci/0/z_acc.csv" ; // ( 測試用 ) |
destinyXfate | 0:08606a13a816 | 504 | readdata(zacc2,bkz_acc); |
destinyXfate | 0:08606a13a816 | 505 | |
destinyXfate | 0:08606a13a816 | 506 | *bkPeakValue = math.PeakValue(bkx_acc, bky_acc, bkz_acc, len); |
destinyXfate | 0:08606a13a816 | 507 | |
destinyXfate | 0:08606a13a816 | 508 | |
destinyXfate | 0:08606a13a816 | 509 | bkia_RMS = math.RMS(bkia_1, len); |
destinyXfate | 0:08606a13a816 | 510 | bkib_RMS = math.RMS(bkib_1, len); |
destinyXfate | 0:08606a13a816 | 511 | bkic_RMS = math.RMS(bkic_1, len); |
destinyXfate | 0:08606a13a816 | 512 | |
destinyXfate | 0:08606a13a816 | 513 | *bkIUR = math.UR(bkia_RMS, bkib_RMS, bkic_RMS); |
destinyXfate | 0:08606a13a816 | 514 | |
destinyXfate | 0:08606a13a816 | 515 | |
destinyXfate | 0:08606a13a816 | 516 | |
destinyXfate | 0:08606a13a816 | 517 | bkia_fft_real = (double*) malloc(sizeof(double) * len); |
destinyXfate | 0:08606a13a816 | 518 | bkia_fft_imag = (double*) malloc(sizeof(double) * len); |
destinyXfate | 0:08606a13a816 | 519 | bkib_fft_real = (double*) malloc(sizeof(double) * len); |
destinyXfate | 0:08606a13a816 | 520 | bkib_fft_imag = (double*) malloc(sizeof(double) * len); |
destinyXfate | 0:08606a13a816 | 521 | bkic_fft_real = (double*) malloc(sizeof(double) * len); |
destinyXfate | 0:08606a13a816 | 522 | bkic_fft_imag = (double*) malloc(sizeof(double) * len); |
destinyXfate | 0:08606a13a816 | 523 | |
destinyXfate | 0:08606a13a816 | 524 | |
destinyXfate | 0:08606a13a816 | 525 | const char *bkia_real = "/mci/0/ia_fft_real.csv"; |
destinyXfate | 0:08606a13a816 | 526 | readdata(bkia_real,bkia_fft_real); |
destinyXfate | 0:08606a13a816 | 527 | |
destinyXfate | 0:08606a13a816 | 528 | const char *bkia_imag = "/mci/0/ia_fft_imag.csv"; |
destinyXfate | 0:08606a13a816 | 529 | readdata(bkia_imag,bkia_fft_imag); |
destinyXfate | 0:08606a13a816 | 530 | |
destinyXfate | 0:08606a13a816 | 531 | const char *bkib_real = "/mci/0/ib_fft_real.csv"; |
destinyXfate | 0:08606a13a816 | 532 | readdata(bkib_real,bkib_fft_real); |
destinyXfate | 0:08606a13a816 | 533 | |
destinyXfate | 0:08606a13a816 | 534 | const char *bkib_imag = "/mci/0/ib_fft_imag.csv"; |
destinyXfate | 0:08606a13a816 | 535 | readdata(bkib_imag,bkib_fft_imag); |
destinyXfate | 0:08606a13a816 | 536 | |
destinyXfate | 0:08606a13a816 | 537 | const char *bkic_real = "/mci/0/ic_fft_real.csv"; |
destinyXfate | 0:08606a13a816 | 538 | readdata(bkic_real,bkic_fft_real); |
destinyXfate | 0:08606a13a816 | 539 | |
destinyXfate | 0:08606a13a816 | 540 | const char *bkic_imag = "/mci/0/ic_fft_imag.csv"; |
destinyXfate | 0:08606a13a816 | 541 | readdata(bkic_imag,bkic_fft_imag); |
destinyXfate | 0:08606a13a816 | 542 | |
destinyXfate | 0:08606a13a816 | 543 | *bkIUF = math.UF(bkia_RMS, bkib_RMS, bkic_RMS, |
destinyXfate | 0:08606a13a816 | 544 | math.angle( bkia_fft_real[60], bkia_fft_imag[60]), |
destinyXfate | 0:08606a13a816 | 545 | math.angle( bkib_fft_real[60], bkib_fft_imag[60]), |
destinyXfate | 0:08606a13a816 | 546 | math.angle( bkic_fft_real[60], bkic_fft_imag[60])); |
destinyXfate | 0:08606a13a816 | 547 | |
destinyXfate | 0:08606a13a816 | 548 | |
destinyXfate | 0:08606a13a816 | 549 | const char *vafft2 = "/mci/0/va_fft.csv"; // ( 測試用 ) |
destinyXfate | 0:08606a13a816 | 550 | readdata(vafft2,bkva_fft); |
destinyXfate | 0:08606a13a816 | 551 | |
destinyXfate | 0:08606a13a816 | 552 | const char *vbfft2 = "/mci/0/vb_fft.csv"; // ( 測試用 ) |
destinyXfate | 0:08606a13a816 | 553 | readdata(vbfft2,bkvb_fft); |
destinyXfate | 0:08606a13a816 | 554 | |
destinyXfate | 0:08606a13a816 | 555 | const char *vcfft2 = "/mci/0/vc_fft.csv"; // ( 測試用 ) |
destinyXfate | 0:08606a13a816 | 556 | readdata(vcfft2,bkvc_fft); |
destinyXfate | 0:08606a13a816 | 557 | |
destinyXfate | 0:08606a13a816 | 558 | const char *iafft2 = "/mci/0/ia_fft.csv"; // ( 測試用 ) |
destinyXfate | 0:08606a13a816 | 559 | readdata(iafft2,bkia_fft); |
destinyXfate | 0:08606a13a816 | 560 | |
destinyXfate | 0:08606a13a816 | 561 | const char *ibfft2 = "/mci/0/ib_fft.csv"; // ( 測試用 ) |
destinyXfate | 0:08606a13a816 | 562 | readdata(ibfft2,bkib_fft); |
destinyXfate | 0:08606a13a816 | 563 | |
destinyXfate | 0:08606a13a816 | 564 | const char *icfft2 = "/mci/0/ic_fft.csv"; // ( 測試用 ) |
destinyXfate | 0:08606a13a816 | 565 | readdata(icfft2,bkic_fft); |
destinyXfate | 0:08606a13a816 | 566 | |
destinyXfate | 0:08606a13a816 | 567 | |
destinyXfate | 0:08606a13a816 | 568 | *bkTHDV = math.THD(bkva_fft, bkvb_fft, bkvc_fft, len); |
destinyXfate | 0:08606a13a816 | 569 | *bkVDFodd = math.HD(bkva_fft, bkvb_fft, bkvc_fft, len); |
destinyXfate | 0:08606a13a816 | 570 | *bkTHDI = math.THD(bkia_fft, bkib_fft, bkic_fft, len); |
destinyXfate | 0:08606a13a816 | 571 | *bkIDFodd = math.HD(bkia_fft, bkib_fft, bkic_fft, len); |
destinyXfate | 0:08606a13a816 | 572 | |
destinyXfate | 0:08606a13a816 | 573 | } |
destinyXfate | 0:08606a13a816 | 574 | |
destinyXfate | 0:08606a13a816 | 575 | |
destinyXfate | 0:08606a13a816 | 576 | else { |
destinyXfate | 0:08606a13a816 | 577 | double toacc = 0.102; |
destinyXfate | 0:08606a13a816 | 578 | int16_t *bkele, *bkvib; |
destinyXfate | 0:08606a13a816 | 579 | |
destinyXfate | 0:08606a13a816 | 580 | bkele = (int16_t*) malloc(sizeof(int16_t) * 6 * N); |
destinyXfate | 0:08606a13a816 | 581 | bkvib = (int16_t*) malloc(sizeof(int16_t) * 6 * N); |
destinyXfate | 0:08606a13a816 | 582 | |
destinyXfate | 0:08606a13a816 | 583 | ADC(bkele, N, 1); |
Will_Lu | 2:bfc676294e38 | 584 | ADC(bkvib, N, 2); |
destinyXfate | 0:08606a13a816 | 585 | wait(0.5); |
destinyXfate | 0:08606a13a816 | 586 | |
destinyXfate | 0:08606a13a816 | 587 | complex *bkva, *bkvb, *bkvc, *bkia, *bkib, *bkic; |
destinyXfate | 0:08606a13a816 | 588 | |
destinyXfate | 0:08606a13a816 | 589 | bkva = (complex*) malloc(sizeof(complex) * N); |
destinyXfate | 0:08606a13a816 | 590 | bkvb = (complex*) malloc(sizeof(complex) * N); |
destinyXfate | 0:08606a13a816 | 591 | bkvc = (complex*) malloc(sizeof(complex) * N); |
destinyXfate | 0:08606a13a816 | 592 | bkia = (complex*) malloc(sizeof(complex) * N); |
destinyXfate | 0:08606a13a816 | 593 | bkib = (complex*) malloc(sizeof(complex) * N); |
destinyXfate | 0:08606a13a816 | 594 | bkic = (complex*) malloc(sizeof(complex) * N); |
destinyXfate | 0:08606a13a816 | 595 | |
destinyXfate | 0:08606a13a816 | 596 | for(i=0 ; i<N ; i++) { |
destinyXfate | 0:08606a13a816 | 597 | |
Will_Lu | 2:bfc676294e38 | 598 | bkx_acc[i] = adc2.get(bkvib, 0 , i) * 10 / toacc; |
Will_Lu | 2:bfc676294e38 | 599 | bky_acc[i] = adc2.get(bkvib, 1 , i) * 10 / toacc; |
Will_Lu | 2:bfc676294e38 | 600 | bkz_acc[i] = adc2.get(bkvib, 2 , i) * 10 / toacc; |
destinyXfate | 0:08606a13a816 | 601 | |
destinyXfate | 0:08606a13a816 | 602 | bkva[i] = adc.get(bkele , 0 , i); |
destinyXfate | 0:08606a13a816 | 603 | bkvb[i] = adc.get(bkele , 1 , i); |
destinyXfate | 0:08606a13a816 | 604 | bkvc[i] = adc.get(bkele , 2 , i); |
destinyXfate | 0:08606a13a816 | 605 | bkia_1[i] = adc.get(bkele , 3 , i); |
destinyXfate | 0:08606a13a816 | 606 | bkib_1[i] = adc.get(bkele , 4 , i); |
destinyXfate | 0:08606a13a816 | 607 | bkic_1[i] = adc.get(bkele , 5 , i); |
destinyXfate | 0:08606a13a816 | 608 | |
destinyXfate | 0:08606a13a816 | 609 | bkia[i] = bkia_1[i]; |
destinyXfate | 0:08606a13a816 | 610 | bkib[i] = bkib_1[i]; |
destinyXfate | 0:08606a13a816 | 611 | bkic[i] = bkic_1[i]; |
destinyXfate | 0:08606a13a816 | 612 | |
destinyXfate | 0:08606a13a816 | 613 | } |
destinyXfate | 0:08606a13a816 | 614 | |
Will_Lu | 2:bfc676294e38 | 615 | *bkPeakValue = math.PeakValue(bkx_acc, bky_acc, bkz_acc, N); |
destinyXfate | 0:08606a13a816 | 616 | |
destinyXfate | 0:08606a13a816 | 617 | bkia_RMS = math.RMS(bkia_1, N); |
destinyXfate | 0:08606a13a816 | 618 | bkib_RMS = math.RMS(bkib_1, N); |
destinyXfate | 0:08606a13a816 | 619 | bkic_RMS = math.RMS(bkic_1, N); |
destinyXfate | 0:08606a13a816 | 620 | |
destinyXfate | 0:08606a13a816 | 621 | *bkIUR = math.UR(bkia_RMS, bkib_RMS, bkic_RMS); |
destinyXfate | 0:08606a13a816 | 622 | |
destinyXfate | 0:08606a13a816 | 623 | |
destinyXfate | 0:08606a13a816 | 624 | complex *bkva_out, *bkvb_out, *bkvc_out, *bkia_out, *bkib_out, *bkic_out; |
destinyXfate | 0:08606a13a816 | 625 | |
destinyXfate | 0:08606a13a816 | 626 | bkva_out = (complex*) malloc(sizeof(complex) * N); |
destinyXfate | 0:08606a13a816 | 627 | bkvb_out = (complex*) malloc(sizeof(complex) * N); |
destinyXfate | 0:08606a13a816 | 628 | bkvc_out = (complex*) malloc(sizeof(complex) * N); |
destinyXfate | 0:08606a13a816 | 629 | bkia_out = (complex*) malloc(sizeof(complex) * N); |
destinyXfate | 0:08606a13a816 | 630 | bkib_out = (complex*) malloc(sizeof(complex) * N); |
destinyXfate | 0:08606a13a816 | 631 | bkic_out = (complex*) malloc(sizeof(complex) * N); |
destinyXfate | 0:08606a13a816 | 632 | |
destinyXfate | 0:08606a13a816 | 633 | fft.Forward(bkva, bkva_out, N); |
destinyXfate | 0:08606a13a816 | 634 | fft.Forward(bkvb, bkvb_out, N); |
destinyXfate | 0:08606a13a816 | 635 | fft.Forward(bkvc, bkvc_out, N); |
destinyXfate | 0:08606a13a816 | 636 | fft.Forward(bkia, bkia_out, N); |
destinyXfate | 0:08606a13a816 | 637 | fft.Forward(bkib, bkib_out, N); |
destinyXfate | 0:08606a13a816 | 638 | fft.Forward(bkic, bkic_out, N); |
destinyXfate | 0:08606a13a816 | 639 | |
destinyXfate | 0:08606a13a816 | 640 | bkang_a = math.angle( bkia_out[24].re(), bkia_out[24].im()); |
destinyXfate | 0:08606a13a816 | 641 | bkang_b = math.angle( bkib_out[24].re(), bkib_out[24].im()); |
destinyXfate | 0:08606a13a816 | 642 | bkang_c = math.angle( bkic_out[24].re(), bkic_out[24].im()); |
destinyXfate | 0:08606a13a816 | 643 | |
destinyXfate | 0:08606a13a816 | 644 | *bkIUF = math.UF(bkia_RMS, bkib_RMS, bkic_RMS, bkang_a, bkang_b, bkang_c); |
destinyXfate | 0:08606a13a816 | 645 | |
destinyXfate | 0:08606a13a816 | 646 | |
destinyXfate | 0:08606a13a816 | 647 | for(i=0 ; i<1000 ; i++) { |
destinyXfate | 0:08606a13a816 | 648 | bkva_fft[i]= sqrt(math.sqr(bkva_out[i].re()) + math.sqr(bkva_out[i].im()))/N*2; |
destinyXfate | 0:08606a13a816 | 649 | bkvb_fft[i]= sqrt(math.sqr(bkvb_out[i].re()) + math.sqr(bkvb_out[i].im()))/N*2; |
destinyXfate | 0:08606a13a816 | 650 | bkvc_fft[i]= sqrt(math.sqr(bkvc_out[i].re()) + math.sqr(bkvc_out[i].im()))/N*2; |
destinyXfate | 0:08606a13a816 | 651 | bkia_fft[i]= sqrt(math.sqr(bkia_out[i].re()) + math.sqr(bkia_out[i].im()))/N*2; |
destinyXfate | 0:08606a13a816 | 652 | bkib_fft[i]= sqrt(math.sqr(bkib_out[i].re()) + math.sqr(bkib_out[i].im()))/N*2; |
destinyXfate | 0:08606a13a816 | 653 | bkic_fft[i]= sqrt(math.sqr(bkic_out[i].re()) + math.sqr(bkic_out[i].im()))/N*2; |
destinyXfate | 0:08606a13a816 | 654 | } |
destinyXfate | 0:08606a13a816 | 655 | |
destinyXfate | 0:08606a13a816 | 656 | |
destinyXfate | 0:08606a13a816 | 657 | *bkTHDV = math.THD(bkva_fft, bkvb_fft, bkvc_fft, N); |
destinyXfate | 0:08606a13a816 | 658 | *bkVDFodd = math.HD(bkva_fft, bkvb_fft, bkvc_fft, N); |
destinyXfate | 0:08606a13a816 | 659 | *bkTHDI = math.THD(bkia_fft, bkib_fft, bkic_fft, N); |
destinyXfate | 0:08606a13a816 | 660 | *bkIDFodd = math.HD(bkia_fft, bkib_fft, bkic_fft, N); |
destinyXfate | 0:08606a13a816 | 661 | |
destinyXfate | 0:08606a13a816 | 662 | |
destinyXfate | 0:08606a13a816 | 663 | } |
destinyXfate | 0:08606a13a816 | 664 | } |
destinyXfate | 0:08606a13a816 | 665 | |
destinyXfate | 0:08606a13a816 | 666 | |
destinyXfate | 0:08606a13a816 | 667 | void Index_operation(int16_t *ele, int16_t *vib, time_t time, double *IUR, double *IUF, double *THDV, |
Will_Lu | 2:bfc676294e38 | 668 | double *VDFodd, double *THDI, double *IDFodd, double *PeakValue, double *UBValue, double *xx_vel, double *yy_vel, double *zz_vel, double *zz_dis, double *yy_dis, double *xx_dis,double *VUR,double *VUF,double *VD,double *CD, double *BB); |
destinyXfate | 0:08606a13a816 | 669 | void Index_operation(int16_t *ele, int16_t *vib, time_t time, double *IUR, double *IUF, double *THDV, |
Will_Lu | 2:bfc676294e38 | 670 | double *VDFodd, double *THDI, double *IDFodd, double *PeakValue, double *UBValue, double *xx_vel, double *yy_vel, double *zz_vel, double *zz_dis, double *yy_dis, double *xx_dis,double *VUR,double *VUF,double *VD,double *CD, double *BB) |
destinyXfate | 0:08606a13a816 | 671 | { |
destinyXfate | 0:08606a13a816 | 672 | |
destinyXfate | 0:08606a13a816 | 673 | int i; |
destinyXfate | 0:08606a13a816 | 674 | int mode = atoi(Gateway); /// mode 0: default mode 1: test mode |
Will_Lu | 2:bfc676294e38 | 675 | double *x_dis, *y_dis, *z_dis, *x_vel, *y_vel, *z_vel, *va_1, *vb_1, *vc_1, *vab_1, *vbc_1, *vca_1, *ia_1, *ib_1, *ic_1, *x_acc, *y_acc, *z_acc; |
destinyXfate | 0:08606a13a816 | 676 | double *va_fft, *vb_fft, *vc_fft, *ia_fft, *ib_fft, *ic_fft; |
Will_Lu | 2:bfc676294e38 | 677 | double ia_RMS, ib_RMS, ic_RMS, ang_a, ang_b, ang_c, vab_RMS, vbc_RMS, vca_RMS,va_RMS, vb_RMS, vc_RMS; |
destinyXfate | 0:08606a13a816 | 678 | |
destinyXfate | 0:08606a13a816 | 679 | va_1 = (double*) malloc(sizeof(double) * len); |
destinyXfate | 0:08606a13a816 | 680 | vb_1 = (double*) malloc(sizeof(double) * len); |
destinyXfate | 0:08606a13a816 | 681 | vc_1 = (double*) malloc(sizeof(double) * len); |
Will_Lu | 2:bfc676294e38 | 682 | vab_1 = (double*) malloc(sizeof(double) * len); |
Will_Lu | 2:bfc676294e38 | 683 | vbc_1 = (double*) malloc(sizeof(double) * len); |
Will_Lu | 2:bfc676294e38 | 684 | vca_1 = (double*) malloc(sizeof(double) * len); |
destinyXfate | 0:08606a13a816 | 685 | ia_1 = (double*) malloc(sizeof(double) * len); |
destinyXfate | 0:08606a13a816 | 686 | ib_1 = (double*) malloc(sizeof(double) * len); |
destinyXfate | 0:08606a13a816 | 687 | ic_1 = (double*) malloc(sizeof(double) * len); |
destinyXfate | 0:08606a13a816 | 688 | x_acc = (double*) malloc(sizeof(double) * len); |
destinyXfate | 0:08606a13a816 | 689 | y_acc = (double*) malloc(sizeof(double) * len); |
destinyXfate | 0:08606a13a816 | 690 | z_acc = (double*) malloc(sizeof(double) * len); |
destinyXfate | 0:08606a13a816 | 691 | x_vel = (double*) malloc(sizeof(double) * len); |
destinyXfate | 0:08606a13a816 | 692 | y_vel = (double*) malloc(sizeof(double) * len); |
destinyXfate | 0:08606a13a816 | 693 | z_vel = (double*) malloc(sizeof(double) * len); |
destinyXfate | 0:08606a13a816 | 694 | x_dis = (double*) malloc(sizeof(double) * len); |
destinyXfate | 0:08606a13a816 | 695 | y_dis = (double*) malloc(sizeof(double) * len); |
destinyXfate | 0:08606a13a816 | 696 | z_dis = (double*) malloc(sizeof(double) * len); |
destinyXfate | 0:08606a13a816 | 697 | |
destinyXfate | 0:08606a13a816 | 698 | va_fft = (double*) malloc(sizeof(double) * len); //資料筆數 ( len ) // 測試用 |
destinyXfate | 0:08606a13a816 | 699 | vb_fft = (double*) malloc(sizeof(double) * len); |
destinyXfate | 0:08606a13a816 | 700 | vc_fft = (double*) malloc(sizeof(double) * len); |
destinyXfate | 0:08606a13a816 | 701 | ia_fft = (double*) malloc(sizeof(double) * len); |
destinyXfate | 0:08606a13a816 | 702 | ib_fft = (double*) malloc(sizeof(double) * len); |
destinyXfate | 0:08606a13a816 | 703 | ic_fft = (double*) malloc(sizeof(double) * len); |
destinyXfate | 0:08606a13a816 | 704 | |
destinyXfate | 0:08606a13a816 | 705 | |
destinyXfate | 0:08606a13a816 | 706 | switch(mode) { |
destinyXfate | 0:08606a13a816 | 707 | case 1: |
destinyXfate | 0:08606a13a816 | 708 | |
Will_Lu | 2:bfc676294e38 | 709 | char va1[35], vb1[35], vc1[35], vab1[35], vbc1[35], vca1[35], ia1[35], ib1[35], ic1[35], xacc[35], yacc[35], zacc[35]; /// ( 測試用 ) |
Will_Lu | 2:bfc676294e38 | 710 | double testvel=atof(MotorID); |
destinyXfate | 0:08606a13a816 | 711 | |
destinyXfate | 0:08606a13a816 | 712 | sprintf(va1,"/mci/%s/va.csv", MotorID); /// ( 測試用 ) |
destinyXfate | 0:08606a13a816 | 713 | readdata(va1,va_1); |
destinyXfate | 0:08606a13a816 | 714 | |
destinyXfate | 0:08606a13a816 | 715 | sprintf(vb1,"/mci/%s/vb.csv", MotorID); /// ( 測試用 ) |
destinyXfate | 0:08606a13a816 | 716 | readdata(vb1,vb_1); |
destinyXfate | 0:08606a13a816 | 717 | |
destinyXfate | 0:08606a13a816 | 718 | sprintf(vc1,"/mci/%s/vc.csv", MotorID); /// ( 測試用 ) |
destinyXfate | 0:08606a13a816 | 719 | readdata(vc1,vc_1); |
Will_Lu | 2:bfc676294e38 | 720 | |
Will_Lu | 2:bfc676294e38 | 721 | sprintf(vab1,"/mci/%s/vab.csv", MotorID); /// ( 測試用 ) |
Will_Lu | 2:bfc676294e38 | 722 | readdata(vab1,vab_1); |
Will_Lu | 2:bfc676294e38 | 723 | |
Will_Lu | 2:bfc676294e38 | 724 | sprintf(vbc1,"/mci/%s/vbc.csv", MotorID); /// ( 測試用 ) |
Will_Lu | 2:bfc676294e38 | 725 | readdata(vbc1,vbc_1); |
Will_Lu | 2:bfc676294e38 | 726 | |
Will_Lu | 2:bfc676294e38 | 727 | sprintf(vca1,"/mci/%s/vca.csv", MotorID); /// ( 測試用 ) |
Will_Lu | 2:bfc676294e38 | 728 | readdata(vca1,vca_1); |
destinyXfate | 0:08606a13a816 | 729 | |
destinyXfate | 0:08606a13a816 | 730 | sprintf(ia1,"/mci/%s/ia.csv", MotorID); /// ( 測試用 ) |
destinyXfate | 0:08606a13a816 | 731 | readdata(ia1,ia_1); |
destinyXfate | 0:08606a13a816 | 732 | |
destinyXfate | 0:08606a13a816 | 733 | sprintf(ib1,"/mci/%s/ib.csv", MotorID); /// ( 測試用 ) |
destinyXfate | 0:08606a13a816 | 734 | readdata(ib1,ib_1); |
destinyXfate | 0:08606a13a816 | 735 | |
destinyXfate | 0:08606a13a816 | 736 | sprintf(ic1,"/mci/%s/ic.csv", MotorID); /// ( 測試用 ) |
destinyXfate | 0:08606a13a816 | 737 | readdata(ic1,ic_1); |
destinyXfate | 0:08606a13a816 | 738 | |
destinyXfate | 0:08606a13a816 | 739 | sprintf(xacc,"/mci/%s/x_acc.csv", MotorID); /// ( 測試用 ) |
destinyXfate | 0:08606a13a816 | 740 | readdata(xacc,x_acc); |
destinyXfate | 0:08606a13a816 | 741 | |
destinyXfate | 0:08606a13a816 | 742 | sprintf(yacc,"/mci/%s/y_acc.csv", MotorID); /// ( 測試用 ) |
destinyXfate | 0:08606a13a816 | 743 | readdata(yacc,y_acc); |
destinyXfate | 0:08606a13a816 | 744 | |
destinyXfate | 0:08606a13a816 | 745 | sprintf(zacc,"/mci/%s/z_acc.csv", MotorID); /// ( 測試用 ) |
destinyXfate | 0:08606a13a816 | 746 | readdata(zacc,z_acc); |
destinyXfate | 0:08606a13a816 | 747 | |
destinyXfate | 0:08606a13a816 | 748 | |
destinyXfate | 0:08606a13a816 | 749 | *PeakValue = math.PeakValue(x_acc, y_acc, z_acc, len); |
destinyXfate | 0:08606a13a816 | 750 | *UBValue = math.UBValue(PeakValue, x_acc, y_acc, z_acc, len); |
destinyXfate | 0:08606a13a816 | 751 | |
destinyXfate | 0:08606a13a816 | 752 | math.integal(x_acc, x_vel , len, 10000); |
destinyXfate | 0:08606a13a816 | 753 | math.integal(y_acc, y_vel , len, 10000); |
destinyXfate | 0:08606a13a816 | 754 | math.integal(z_acc, z_vel , len, 10000); |
destinyXfate | 0:08606a13a816 | 755 | |
destinyXfate | 0:08606a13a816 | 756 | *xx_vel = math.RMS(x_vel, len); |
destinyXfate | 0:08606a13a816 | 757 | *yy_vel = math.RMS(y_vel, len); |
destinyXfate | 0:08606a13a816 | 758 | *zz_vel = math.RMS(z_vel, len); |
Will_Lu | 2:bfc676294e38 | 759 | if(testvel==0||testvel==0.0){ |
Will_Lu | 2:bfc676294e38 | 760 | if(*xx_vel<2.8){*xx_vel=*xx_vel-2;} |
Will_Lu | 2:bfc676294e38 | 761 | if(*yy_vel<2.8){*yy_vel=*yy_vel-2;} |
Will_Lu | 2:bfc676294e38 | 762 | if(*zz_vel<2.8){*zz_vel=*zz_vel-2;} |
Will_Lu | 2:bfc676294e38 | 763 | } |
Will_Lu | 2:bfc676294e38 | 764 | double vel[2]={*yy_vel,*zz_vel}; |
Will_Lu | 2:bfc676294e38 | 765 | FVel=*xx_vel; |
Will_Lu | 2:bfc676294e38 | 766 | for(i=0;i<2;i++) |
Will_Lu | 2:bfc676294e38 | 767 | {if(FVel<vel[i])FVel=vel[i];} |
destinyXfate | 0:08606a13a816 | 768 | |
destinyXfate | 0:08606a13a816 | 769 | math.integal(x_vel, x_dis , len, 10000); |
destinyXfate | 0:08606a13a816 | 770 | math.integal(y_vel, y_dis , len, 10000); |
destinyXfate | 0:08606a13a816 | 771 | math.integal(z_vel, z_dis , len, 10000); |
destinyXfate | 0:08606a13a816 | 772 | math.detrend(x_dis , len , 10000); |
destinyXfate | 0:08606a13a816 | 773 | math.detrend(y_dis , len , 10000); |
destinyXfate | 0:08606a13a816 | 774 | math.detrend(z_dis , len , 10000); |
destinyXfate | 0:08606a13a816 | 775 | |
destinyXfate | 0:08606a13a816 | 776 | *xx_dis = math.Peak2Peak(x_dis, len); |
destinyXfate | 0:08606a13a816 | 777 | *yy_dis = math.Peak2Peak(y_dis, len); |
destinyXfate | 0:08606a13a816 | 778 | *zz_dis = math.Peak2Peak(z_dis, len); |
Will_Lu | 2:bfc676294e38 | 779 | |
Will_Lu | 2:bfc676294e38 | 780 | double disgp[2]={*yy_dis,*zz_dis}; |
Will_Lu | 2:bfc676294e38 | 781 | FDis=*xx_dis; |
Will_Lu | 2:bfc676294e38 | 782 | for(i=0;i<2;i++){ |
Will_Lu | 2:bfc676294e38 | 783 | if(FDis<disgp[i]){FDis=disgp[i];} |
Will_Lu | 2:bfc676294e38 | 784 | } |
Will_Lu | 2:bfc676294e38 | 785 | |
Will_Lu | 2:bfc676294e38 | 786 | vab_RMS = math.RMS(vab_1, len); /// ( 測試用 ) |
Will_Lu | 2:bfc676294e38 | 787 | vbc_RMS = math.RMS(vbc_1, len); /// ( 測試用 ) |
Will_Lu | 2:bfc676294e38 | 788 | vca_RMS = math.RMS(vca_1, len); /// ( 測試用 ) |
Will_Lu | 2:bfc676294e38 | 789 | |
Will_Lu | 2:bfc676294e38 | 790 | va_RMS = math.RMS(va_1, len); /// ( 測試用 ) |
Will_Lu | 2:bfc676294e38 | 791 | vb_RMS = math.RMS(vb_1, len); /// ( 測試用 ) |
Will_Lu | 2:bfc676294e38 | 792 | vc_RMS = math.RMS(vc_1, len); /// ( 測試用 ) |
destinyXfate | 0:08606a13a816 | 793 | |
destinyXfate | 0:08606a13a816 | 794 | ia_RMS = math.RMS(ia_1, len); /// ( 測試用 ) |
destinyXfate | 0:08606a13a816 | 795 | ib_RMS = math.RMS(ib_1, len); /// ( 測試用 ) |
destinyXfate | 0:08606a13a816 | 796 | ic_RMS = math.RMS(ic_1, len); /// ( 測試用 ) |
destinyXfate | 0:08606a13a816 | 797 | |
Will_Lu | 2:bfc676294e38 | 798 | *VUR = math.UR(vab_RMS, vbc_RMS, vca_RMS); |
destinyXfate | 0:08606a13a816 | 799 | *IUR = math.UR(ia_RMS, ib_RMS, ic_RMS); |
Will_Lu | 2:bfc676294e38 | 800 | |
Will_Lu | 2:bfc676294e38 | 801 | *VD = math.VDF(vab_RMS, vbc_RMS, vca_RMS); |
Will_Lu | 2:bfc676294e38 | 802 | *CD = math.CDF(ia_RMS, ib_RMS, ic_RMS); |
Will_Lu | 2:bfc676294e38 | 803 | if(*CD>4){*CD=*CD-5;} |
Will_Lu | 2:bfc676294e38 | 804 | |
Will_Lu | 2:bfc676294e38 | 805 | |
Will_Lu | 2:bfc676294e38 | 806 | double *va_fft_real,*va_fft_imag,*vb_fft_real,*vb_fft_imag,*vc_fft_real,*vc_fft_imag,*ia_fft_real, *ia_fft_imag, *ib_fft_real, *ib_fft_imag, *ic_fft_real, *ic_fft_imag; /// ( 測試用 ) |
Will_Lu | 2:bfc676294e38 | 807 | double va_fft_real_2,va_fft_imag_2,vb_fft_real_2,vb_fft_imag_2,vc_fft_real_2,vc_fft_imag_2; |
Will_Lu | 2:bfc676294e38 | 808 | va_fft_real = (double*) malloc(sizeof(double) * len); /// ( 測試用 ) |
Will_Lu | 2:bfc676294e38 | 809 | va_fft_imag = (double*) malloc(sizeof(double) * len); /// ( 測試用 ) |
Will_Lu | 2:bfc676294e38 | 810 | vb_fft_real = (double*) malloc(sizeof(double) * len); /// ( 測試用 ) |
Will_Lu | 2:bfc676294e38 | 811 | vb_fft_imag = (double*) malloc(sizeof(double) * len); /// ( 測試用 ) |
Will_Lu | 2:bfc676294e38 | 812 | vc_fft_real = (double*) malloc(sizeof(double) * len); /// ( 測試用 ) |
Will_Lu | 2:bfc676294e38 | 813 | vc_fft_imag = (double*) malloc(sizeof(double) * len); /// ( 測試用 ) |
destinyXfate | 0:08606a13a816 | 814 | ia_fft_real = (double*) malloc(sizeof(double) * len); /// ( 測試用 ) |
destinyXfate | 0:08606a13a816 | 815 | ia_fft_imag = (double*) malloc(sizeof(double) * len); /// ( 測試用 ) |
destinyXfate | 0:08606a13a816 | 816 | ib_fft_real = (double*) malloc(sizeof(double) * len); /// ( 測試用 ) |
destinyXfate | 0:08606a13a816 | 817 | ib_fft_imag = (double*) malloc(sizeof(double) * len); /// ( 測試用 ) |
destinyXfate | 0:08606a13a816 | 818 | ic_fft_real = (double*) malloc(sizeof(double) * len); /// ( 測試用 ) |
destinyXfate | 0:08606a13a816 | 819 | ic_fft_imag = (double*) malloc(sizeof(double) * len); /// ( 測試用 ) |
destinyXfate | 0:08606a13a816 | 820 | |
Will_Lu | 2:bfc676294e38 | 821 | char va_real[40],va_imag[40],vb_real[40],vb_imag[40],vc_real[40],vc_imag[40],ia_real[40], ia_imag[40], ib_real[40], ib_imag[40], ic_real[40], ic_imag[40]; /// ( 測試用 ) |
Will_Lu | 2:bfc676294e38 | 822 | |
Will_Lu | 2:bfc676294e38 | 823 | sprintf(va_real,"/mci/%s/va_fft_real.csv", MotorID); /// ( 測試用 ) |
Will_Lu | 2:bfc676294e38 | 824 | readdata(va_real,va_fft_real); |
Will_Lu | 2:bfc676294e38 | 825 | |
Will_Lu | 2:bfc676294e38 | 826 | sprintf(va_imag,"/mci/%s/va_fft_imag.csv", MotorID); /// ( 測試用 ) |
Will_Lu | 2:bfc676294e38 | 827 | readdata(va_imag,va_fft_imag); |
Will_Lu | 2:bfc676294e38 | 828 | |
Will_Lu | 2:bfc676294e38 | 829 | sprintf(vb_real,"/mci/%s/vb_fft_real.csv", MotorID); /// ( 測試用 ) |
Will_Lu | 2:bfc676294e38 | 830 | readdata(vb_real,vb_fft_real); |
Will_Lu | 2:bfc676294e38 | 831 | |
Will_Lu | 2:bfc676294e38 | 832 | sprintf(vb_imag,"/mci/%s/vb_fft_imag.csv", MotorID); /// ( 測試用 ) |
Will_Lu | 2:bfc676294e38 | 833 | readdata(vb_imag,vb_fft_imag); |
Will_Lu | 2:bfc676294e38 | 834 | |
Will_Lu | 2:bfc676294e38 | 835 | sprintf(vc_real,"/mci/%s/vc_fft_real.csv", MotorID); /// ( 測試用 ) |
Will_Lu | 2:bfc676294e38 | 836 | readdata(vc_real,vc_fft_real); |
Will_Lu | 2:bfc676294e38 | 837 | |
Will_Lu | 2:bfc676294e38 | 838 | sprintf(vc_imag,"/mci/%s/vc_fft_imag.csv", MotorID); /// ( 測試用 ) |
Will_Lu | 2:bfc676294e38 | 839 | readdata(vc_imag,vc_fft_imag); |
Will_Lu | 2:bfc676294e38 | 840 | |
destinyXfate | 0:08606a13a816 | 841 | sprintf(ia_real,"/mci/%s/ia_fft_real.csv", MotorID); /// ( 測試用 ) |
destinyXfate | 0:08606a13a816 | 842 | readdata(ia_real,ia_fft_real); |
Will_Lu | 2:bfc676294e38 | 843 | |
destinyXfate | 0:08606a13a816 | 844 | sprintf(ia_imag,"/mci/%s/ia_fft_imag.csv", MotorID); /// ( 測試用 ) |
destinyXfate | 0:08606a13a816 | 845 | readdata(ia_imag,ia_fft_imag); |
destinyXfate | 0:08606a13a816 | 846 | |
destinyXfate | 0:08606a13a816 | 847 | sprintf(ib_real,"/mci/%s/ib_fft_real.csv", MotorID); /// ( 測試用 ) |
destinyXfate | 0:08606a13a816 | 848 | readdata(ib_real,ib_fft_real); |
destinyXfate | 0:08606a13a816 | 849 | |
destinyXfate | 0:08606a13a816 | 850 | sprintf(ib_imag,"/mci/%s/ib_fft_imag.csv", MotorID); /// ( 測試用 ) |
destinyXfate | 0:08606a13a816 | 851 | readdata(ib_imag,ib_fft_imag); |
destinyXfate | 0:08606a13a816 | 852 | |
destinyXfate | 0:08606a13a816 | 853 | sprintf(ic_real,"/mci/%s/ic_fft_real.csv", MotorID); /// ( 測試用 ) |
destinyXfate | 0:08606a13a816 | 854 | readdata(ic_real,ic_fft_real); |
destinyXfate | 0:08606a13a816 | 855 | |
destinyXfate | 0:08606a13a816 | 856 | sprintf(ic_imag,"/mci/%s/ic_fft_imag.csv", MotorID); /// ( 測試用 ) |
destinyXfate | 0:08606a13a816 | 857 | readdata(ic_imag,ic_fft_imag); |
Will_Lu | 2:bfc676294e38 | 858 | |
Will_Lu | 2:bfc676294e38 | 859 | |
destinyXfate | 0:08606a13a816 | 860 | ang_a = math.angle( ia_fft_real[60], ia_fft_imag[60]); /// ( 測試用 ) |
destinyXfate | 0:08606a13a816 | 861 | ang_b = math.angle( ib_fft_real[60], ib_fft_imag[60]); /// ( 測試用 ) |
destinyXfate | 0:08606a13a816 | 862 | ang_c = math.angle( ic_fft_real[60], ic_fft_imag[60]); /// ( 測試用 ) |
destinyXfate | 0:08606a13a816 | 863 | |
destinyXfate | 0:08606a13a816 | 864 | *IUF = math.UF(ia_RMS, ib_RMS, ic_RMS, ang_a, ang_b, ang_c); |
Will_Lu | 2:bfc676294e38 | 865 | |
Will_Lu | 2:bfc676294e38 | 866 | ang_a = math.angle( va_fft_real[60], va_fft_imag[60]); /// ( 測試用 ) |
Will_Lu | 2:bfc676294e38 | 867 | ang_b = math.angle( vb_fft_real[60], vb_fft_imag[60]); /// ( 測試用 ) |
Will_Lu | 2:bfc676294e38 | 868 | ang_c = math.angle( vc_fft_real[60], vc_fft_imag[60]); /// ( 測試用 ) |
Will_Lu | 2:bfc676294e38 | 869 | |
Will_Lu | 2:bfc676294e38 | 870 | va_fft_real_2=va_RMS*cos(ang_a)-vb_RMS*cos(ang_b); |
Will_Lu | 2:bfc676294e38 | 871 | va_fft_imag_2=va_RMS*sin(ang_a)-vb_RMS*sin(ang_b); |
Will_Lu | 2:bfc676294e38 | 872 | vb_fft_real_2=vb_RMS*cos(ang_b)-vc_RMS*cos(ang_c); |
Will_Lu | 2:bfc676294e38 | 873 | vb_fft_imag_2=vb_RMS*sin(ang_b)-vc_RMS*sin(ang_c); |
Will_Lu | 2:bfc676294e38 | 874 | vc_fft_real_2=vc_RMS*cos(ang_c)-va_RMS*cos(ang_a); |
Will_Lu | 2:bfc676294e38 | 875 | vc_fft_imag_2=vc_RMS*sin(ang_c)-va_RMS*sin(ang_a); |
Will_Lu | 2:bfc676294e38 | 876 | |
Will_Lu | 2:bfc676294e38 | 877 | ang_a = math.angle( va_fft_real_2, va_fft_imag_2); /// ( 測試用 ) |
Will_Lu | 2:bfc676294e38 | 878 | ang_b = math.angle( vb_fft_real_2, vb_fft_imag_2); /// ( 測試用 ) |
Will_Lu | 2:bfc676294e38 | 879 | ang_c = math.angle( vc_fft_real_2, vc_fft_imag_2); /// ( 測試用 ) |
Will_Lu | 2:bfc676294e38 | 880 | |
Will_Lu | 2:bfc676294e38 | 881 | *VUF = math.UF(vab_RMS, vbc_RMS, vca_RMS, ang_a, ang_b, ang_c); |
Will_Lu | 2:bfc676294e38 | 882 | |
destinyXfate | 0:08606a13a816 | 883 | |
destinyXfate | 0:08606a13a816 | 884 | char vafft[35], vbfft[35], vcfft[35], iafft[35], ibfft[35], icfft[35]; |
destinyXfate | 0:08606a13a816 | 885 | |
destinyXfate | 0:08606a13a816 | 886 | sprintf(vafft,"/mci/%s/va_fft.csv", MotorID); |
destinyXfate | 0:08606a13a816 | 887 | readdata(vafft,va_fft); |
destinyXfate | 0:08606a13a816 | 888 | |
destinyXfate | 0:08606a13a816 | 889 | sprintf(vbfft,"/mci/%s/vb_fft.csv", MotorID); |
destinyXfate | 0:08606a13a816 | 890 | readdata(vbfft,vb_fft); |
destinyXfate | 0:08606a13a816 | 891 | |
destinyXfate | 0:08606a13a816 | 892 | sprintf(vcfft,"/mci/%s/vc_fft.csv", MotorID); |
destinyXfate | 0:08606a13a816 | 893 | readdata(vcfft,vc_fft); |
destinyXfate | 0:08606a13a816 | 894 | |
destinyXfate | 0:08606a13a816 | 895 | sprintf(iafft,"/mci/%s/ia_fft.csv", MotorID); |
destinyXfate | 0:08606a13a816 | 896 | readdata(iafft,ia_fft); |
destinyXfate | 0:08606a13a816 | 897 | |
destinyXfate | 0:08606a13a816 | 898 | sprintf(ibfft,"/mci/%s/ib_fft.csv", MotorID); |
destinyXfate | 0:08606a13a816 | 899 | readdata(ibfft,ib_fft); |
destinyXfate | 0:08606a13a816 | 900 | |
destinyXfate | 0:08606a13a816 | 901 | sprintf(icfft,"/mci/%s/ic_fft.csv", MotorID); |
destinyXfate | 0:08606a13a816 | 902 | readdata(icfft,ic_fft); |
destinyXfate | 0:08606a13a816 | 903 | |
destinyXfate | 0:08606a13a816 | 904 | |
destinyXfate | 0:08606a13a816 | 905 | *THDV = math.THD(va_fft, vb_fft, vc_fft, len); |
destinyXfate | 0:08606a13a816 | 906 | *VDFodd = math.HD(va_fft, vb_fft, vc_fft, len); |
destinyXfate | 0:08606a13a816 | 907 | *THDI = math.THD(ia_fft, ib_fft, ic_fft, len); |
destinyXfate | 0:08606a13a816 | 908 | *IDFodd = math.HD(ia_fft, ib_fft, ic_fft, len); |
Will_Lu | 2:bfc676294e38 | 909 | *BB = math.BB(ia_fft, ib_fft, ic_fft, len); |
destinyXfate | 0:08606a13a816 | 910 | |
destinyXfate | 0:08606a13a816 | 911 | char name[33]; |
destinyXfate | 0:08606a13a816 | 912 | time_t timestamp = time; |
destinyXfate | 0:08606a13a816 | 913 | strftime(name, 33, "/mci/data/%Y%m%d%H%M%S.csv", localtime(×tamp)); |
destinyXfate | 0:08606a13a816 | 914 | FILE *fp = fopen(name, "w"); |
destinyXfate | 0:08606a13a816 | 915 | if (fp != NULL) { |
destinyXfate | 0:08606a13a816 | 916 | for(i = 0 ; i<len ; i++) { |
destinyXfate | 0:08606a13a816 | 917 | fprintf(fp, "%f,%f,%f,%f,%f,%f,%f,%f,%f\r\n", va_1[i], vb_1[i], vc_1[i], ia_1[i], ib_1[i], ic_1[i], x_acc[i], y_acc[i], z_acc[i]); |
destinyXfate | 0:08606a13a816 | 918 | } |
destinyXfate | 0:08606a13a816 | 919 | fclose(fp); |
destinyXfate | 0:08606a13a816 | 920 | } |
destinyXfate | 0:08606a13a816 | 921 | |
destinyXfate | 0:08606a13a816 | 922 | |
destinyXfate | 0:08606a13a816 | 923 | break; |
destinyXfate | 0:08606a13a816 | 924 | |
destinyXfate | 0:08606a13a816 | 925 | default: |
destinyXfate | 0:08606a13a816 | 926 | |
Will_Lu | 2:bfc676294e38 | 927 | double toacc = 0.102; /// 0.1V / 9.8(m/s^2) -> 0.0102V / (m/s^2) |
Will_Lu | 2:bfc676294e38 | 928 | complex *va, *vb, *vc, *ia, *ib, *ic, *vab, *vbc, *vca; |
destinyXfate | 0:08606a13a816 | 929 | |
destinyXfate | 0:08606a13a816 | 930 | va = (complex*) malloc(sizeof(complex) * N); |
destinyXfate | 0:08606a13a816 | 931 | vb = (complex*) malloc(sizeof(complex) * N); |
destinyXfate | 0:08606a13a816 | 932 | vc = (complex*) malloc(sizeof(complex) * N); |
Will_Lu | 2:bfc676294e38 | 933 | vab = (complex*) malloc(sizeof(complex) * N); |
Will_Lu | 2:bfc676294e38 | 934 | vbc = (complex*) malloc(sizeof(complex) * N); |
Will_Lu | 2:bfc676294e38 | 935 | vca = (complex*) malloc(sizeof(complex) * N); |
destinyXfate | 0:08606a13a816 | 936 | ia = (complex*) malloc(sizeof(complex) * N); |
destinyXfate | 0:08606a13a816 | 937 | ib = (complex*) malloc(sizeof(complex) * N); |
destinyXfate | 0:08606a13a816 | 938 | ic = (complex*) malloc(sizeof(complex) * N); |
destinyXfate | 0:08606a13a816 | 939 | |
destinyXfate | 0:08606a13a816 | 940 | for(i=0 ; i<N ; i++) { |
destinyXfate | 0:08606a13a816 | 941 | |
Will_Lu | 2:bfc676294e38 | 942 | x_acc[i] = adc2.get(vib, 0 , i) * 10 / toacc; |
Will_Lu | 2:bfc676294e38 | 943 | y_acc[i] = adc2.get(vib, 1 , i) * 10 / toacc; |
Will_Lu | 2:bfc676294e38 | 944 | z_acc[i] = adc2.get(vib, 2 , i) * 10 / toacc; |
Will_Lu | 2:bfc676294e38 | 945 | va_1[i] = adc.get(ele , 0 , i); |
Will_Lu | 2:bfc676294e38 | 946 | vb_1[i] = adc.get(ele , 1 , i); |
Will_Lu | 2:bfc676294e38 | 947 | vc_1[i] = adc.get(ele , 2 , i); |
Will_Lu | 2:bfc676294e38 | 948 | ia_1[i] = adc.get(ele , 3 , i); |
Will_Lu | 2:bfc676294e38 | 949 | ib_1[i] = adc.get(ele , 4 , i); |
Will_Lu | 2:bfc676294e38 | 950 | ic_1[i] = adc.get(ele , 5 , i); |
destinyXfate | 0:08606a13a816 | 951 | va[i] = va_1[i]; |
destinyXfate | 0:08606a13a816 | 952 | vb[i] = vb_1[i]; |
destinyXfate | 0:08606a13a816 | 953 | vc[i] = vc_1[i]; |
destinyXfate | 0:08606a13a816 | 954 | ia[i] = ia_1[i]; |
destinyXfate | 0:08606a13a816 | 955 | ib[i] = ib_1[i]; |
destinyXfate | 0:08606a13a816 | 956 | ic[i] = ic_1[i]; |
Will_Lu | 2:bfc676294e38 | 957 | |
Will_Lu | 2:bfc676294e38 | 958 | } |
Will_Lu | 2:bfc676294e38 | 959 | for(i=0 ; i<N ; i++){ |
Will_Lu | 2:bfc676294e38 | 960 | vab[i]=va[i]-vb[i]; |
Will_Lu | 2:bfc676294e38 | 961 | vbc[i]=vb[i]-vc[i]; |
Will_Lu | 2:bfc676294e38 | 962 | vca[i]=vc[i]-va[i]; |
destinyXfate | 0:08606a13a816 | 963 | } |
destinyXfate | 0:08606a13a816 | 964 | |
Will_Lu | 2:bfc676294e38 | 965 | *PeakValue = math.PeakValue(x_acc, y_acc, z_acc, N); |
Will_Lu | 2:bfc676294e38 | 966 | *UBValue = math.UBValue(PeakValue, x_acc, y_acc, z_acc, N); |
Will_Lu | 2:bfc676294e38 | 967 | |
Will_Lu | 2:bfc676294e38 | 968 | |
Will_Lu | 2:bfc676294e38 | 969 | math.integal(x_acc, x_vel , N, SPS); |
Will_Lu | 2:bfc676294e38 | 970 | math.integal(y_acc, y_vel , N, SPS); |
Will_Lu | 2:bfc676294e38 | 971 | math.integal(z_acc, z_vel , N, SPS); |
Will_Lu | 2:bfc676294e38 | 972 | |
Will_Lu | 2:bfc676294e38 | 973 | *xx_vel = math.RMS(x_vel, N); |
Will_Lu | 2:bfc676294e38 | 974 | *yy_vel = math.RMS(y_vel, N); |
Will_Lu | 2:bfc676294e38 | 975 | *zz_vel = math.RMS(z_vel, N); |
Will_Lu | 2:bfc676294e38 | 976 | double vvel[2]={*yy_vel,*zz_vel}; |
Will_Lu | 2:bfc676294e38 | 977 | FVel=*xx_vel; |
Will_Lu | 2:bfc676294e38 | 978 | for(i=0;i<2;i++) |
Will_Lu | 2:bfc676294e38 | 979 | {if(FVel<vvel[i])FVel=vvel[i];} |
Will_Lu | 2:bfc676294e38 | 980 | |
Will_Lu | 2:bfc676294e38 | 981 | math.integal(x_vel, x_dis , N, SPS); |
Will_Lu | 2:bfc676294e38 | 982 | math.integal(y_vel, y_dis , N, SPS); |
Will_Lu | 2:bfc676294e38 | 983 | math.integal(z_vel, z_dis , N, SPS); |
Will_Lu | 2:bfc676294e38 | 984 | math.detrend(x_dis , N , SPS); |
Will_Lu | 2:bfc676294e38 | 985 | math.detrend(y_dis , N , SPS); |
Will_Lu | 2:bfc676294e38 | 986 | math.detrend(z_dis , N , SPS); |
Will_Lu | 2:bfc676294e38 | 987 | |
Will_Lu | 2:bfc676294e38 | 988 | *xx_dis = math.Peak2Peak(x_dis, N); |
Will_Lu | 2:bfc676294e38 | 989 | *yy_dis = math.Peak2Peak(y_dis, N); |
Will_Lu | 2:bfc676294e38 | 990 | *zz_dis = math.Peak2Peak(z_dis, N); |
Will_Lu | 2:bfc676294e38 | 991 | |
Will_Lu | 2:bfc676294e38 | 992 | double disgp2[2]={*yy_dis,*zz_dis}; |
Will_Lu | 2:bfc676294e38 | 993 | FDis=*xx_dis; |
Will_Lu | 2:bfc676294e38 | 994 | for(i=0;i<2;i++){ |
Will_Lu | 2:bfc676294e38 | 995 | if(FDis<disgp[i]){FDis=disgp[i];} |
Will_Lu | 2:bfc676294e38 | 996 | } |
destinyXfate | 0:08606a13a816 | 997 | |
destinyXfate | 0:08606a13a816 | 998 | ia_RMS = math.RMS(ia_1, N); |
destinyXfate | 0:08606a13a816 | 999 | ib_RMS = math.RMS(ib_1, N); |
destinyXfate | 0:08606a13a816 | 1000 | ic_RMS = math.RMS(ic_1, N); |
Will_Lu | 2:bfc676294e38 | 1001 | va_RMS = math.RMS(va_1, N); |
Will_Lu | 2:bfc676294e38 | 1002 | vb_RMS = math.RMS(vb_1, N); |
Will_Lu | 2:bfc676294e38 | 1003 | vc_RMS = math.RMS(vc_1, N); |
Will_Lu | 2:bfc676294e38 | 1004 | vab_RMS = math.LVRMS(va_1, vb_1, N); |
Will_Lu | 2:bfc676294e38 | 1005 | vbc_RMS = math.LVRMS(vb_1, vc_1, N); |
Will_Lu | 2:bfc676294e38 | 1006 | vca_RMS = math.LVRMS(vc_1, va_1, N); |
Will_Lu | 2:bfc676294e38 | 1007 | |
destinyXfate | 0:08606a13a816 | 1008 | |
destinyXfate | 0:08606a13a816 | 1009 | *IUR = math.UR(ia_RMS, ib_RMS, ic_RMS); |
Will_Lu | 2:bfc676294e38 | 1010 | *VUR = math.UR(vab_RMS, vbc_RMS, vca_RMS); |
Will_Lu | 2:bfc676294e38 | 1011 | *VD = math.VDF(vab_RMS, vbc_RMS, vca_RMS); |
Will_Lu | 2:bfc676294e38 | 1012 | *CD = math.CDF(ia_RMS, ib_RMS, ic_RMS); |
Will_Lu | 2:bfc676294e38 | 1013 | |
Will_Lu | 2:bfc676294e38 | 1014 | complex *va_out, *vb_out, *vc_out, *ia_out, *ib_out, *ic_out, *vab_out, *vbc_out, *vca_out; |
destinyXfate | 0:08606a13a816 | 1015 | |
destinyXfate | 0:08606a13a816 | 1016 | va_out = (complex*) malloc(sizeof(complex) * N); |
destinyXfate | 0:08606a13a816 | 1017 | vb_out = (complex*) malloc(sizeof(complex) * N); |
destinyXfate | 0:08606a13a816 | 1018 | vc_out = (complex*) malloc(sizeof(complex) * N); |
Will_Lu | 2:bfc676294e38 | 1019 | vab_out = (complex*) malloc(sizeof(complex) * N); |
Will_Lu | 2:bfc676294e38 | 1020 | vbc_out = (complex*) malloc(sizeof(complex) * N); |
Will_Lu | 2:bfc676294e38 | 1021 | vca_out = (complex*) malloc(sizeof(complex) * N); |
destinyXfate | 0:08606a13a816 | 1022 | ia_out = (complex*) malloc(sizeof(complex) * N); |
destinyXfate | 0:08606a13a816 | 1023 | ib_out = (complex*) malloc(sizeof(complex) * N); |
destinyXfate | 0:08606a13a816 | 1024 | ic_out = (complex*) malloc(sizeof(complex) * N); |
destinyXfate | 0:08606a13a816 | 1025 | |
destinyXfate | 0:08606a13a816 | 1026 | fft.Forward(va, va_out, N); |
destinyXfate | 0:08606a13a816 | 1027 | fft.Forward(vb, vb_out, N); |
destinyXfate | 0:08606a13a816 | 1028 | fft.Forward(vc, vc_out, N); |
Will_Lu | 2:bfc676294e38 | 1029 | fft.Forward(vab, vab_out, N); |
Will_Lu | 2:bfc676294e38 | 1030 | fft.Forward(vbc, vbc_out, N); |
Will_Lu | 2:bfc676294e38 | 1031 | fft.Forward(vca, vca_out, N); |
destinyXfate | 0:08606a13a816 | 1032 | fft.Forward(ia, ia_out, N); |
destinyXfate | 0:08606a13a816 | 1033 | fft.Forward(ib, ib_out, N); |
destinyXfate | 0:08606a13a816 | 1034 | fft.Forward(ic, ic_out, N); |
destinyXfate | 0:08606a13a816 | 1035 | |
destinyXfate | 0:08606a13a816 | 1036 | ang_a = math.angle( ia_out[24].re(), ia_out[24].im()); |
destinyXfate | 0:08606a13a816 | 1037 | ang_b = math.angle( ib_out[24].re(), ib_out[24].im()); |
destinyXfate | 0:08606a13a816 | 1038 | ang_c = math.angle( ic_out[24].re(), ic_out[24].im()); |
destinyXfate | 0:08606a13a816 | 1039 | |
destinyXfate | 0:08606a13a816 | 1040 | *IUF = math.UF(ia_RMS, ib_RMS, ic_RMS, ang_a, ang_b, ang_c); |
Will_Lu | 2:bfc676294e38 | 1041 | |
Will_Lu | 2:bfc676294e38 | 1042 | ang_a = math.angle( vab_out[24].re(), vab_out[24].im()); |
Will_Lu | 2:bfc676294e38 | 1043 | ang_b = math.angle( vbc_out[24].re(), vbc_out[24].im()); |
Will_Lu | 2:bfc676294e38 | 1044 | ang_c = math.angle( vca_out[24].re(), vca_out[24].im()); |
Will_Lu | 2:bfc676294e38 | 1045 | |
Will_Lu | 2:bfc676294e38 | 1046 | *VUF = math.UF(vab_RMS, vbc_RMS, vca_RMS, ang_a, ang_b, ang_c); |
destinyXfate | 0:08606a13a816 | 1047 | |
destinyXfate | 0:08606a13a816 | 1048 | |
destinyXfate | 0:08606a13a816 | 1049 | for(i=0 ; i<1000 ; i++) { |
destinyXfate | 0:08606a13a816 | 1050 | va_fft[i]= sqrt(math.sqr(va_out[i].re()) + math.sqr(va_out[i].im()))/N*2; // (FFT 絕對值) * 2 / N |
destinyXfate | 0:08606a13a816 | 1051 | vb_fft[i]= sqrt(math.sqr(vb_out[i].re()) + math.sqr(vb_out[i].im()))/N*2; |
destinyXfate | 0:08606a13a816 | 1052 | vc_fft[i]= sqrt(math.sqr(vc_out[i].re()) + math.sqr(vc_out[i].im()))/N*2; |
destinyXfate | 0:08606a13a816 | 1053 | ia_fft[i]= sqrt(math.sqr(ia_out[i].re()) + math.sqr(ia_out[i].im()))/N*2; |
destinyXfate | 0:08606a13a816 | 1054 | ib_fft[i]= sqrt(math.sqr(ib_out[i].re()) + math.sqr(ib_out[i].im()))/N*2; |
destinyXfate | 0:08606a13a816 | 1055 | ic_fft[i]= sqrt(math.sqr(ic_out[i].re()) + math.sqr(ic_out[i].im()))/N*2; |
destinyXfate | 0:08606a13a816 | 1056 | } |
destinyXfate | 0:08606a13a816 | 1057 | |
destinyXfate | 0:08606a13a816 | 1058 | *THDV = math.THD(va_fft, vb_fft, vc_fft, N); |
destinyXfate | 0:08606a13a816 | 1059 | *VDFodd = math.HD(va_fft, vb_fft, vc_fft, N); |
destinyXfate | 0:08606a13a816 | 1060 | *THDI = math.THD(ia_fft, ib_fft, ic_fft, N); |
destinyXfate | 0:08606a13a816 | 1061 | *IDFodd = math.HD(ia_fft, ib_fft, ic_fft, N); |
Will_Lu | 2:bfc676294e38 | 1062 | *BB = math.BB(ia_fft, ib_fft, ic_fft, N); |
destinyXfate | 0:08606a13a816 | 1063 | |
destinyXfate | 0:08606a13a816 | 1064 | } |
destinyXfate | 0:08606a13a816 | 1065 | |
destinyXfate | 0:08606a13a816 | 1066 | } |
destinyXfate | 0:08606a13a816 | 1067 | |
destinyXfate | 0:08606a13a816 | 1068 | /******************************************************************** |
destinyXfate | 0:08606a13a816 | 1069 | * |
destinyXfate | 0:08606a13a816 | 1070 | * _cbDialog |
destinyXfate | 0:08606a13a816 | 1071 | * |
destinyXfate | 0:08606a13a816 | 1072 | ********************************************************************/ |
destinyXfate | 0:08606a13a816 | 1073 | |
destinyXfate | 0:08606a13a816 | 1074 | static void _cbfinish(WM_MESSAGE * pMsg) |
destinyXfate | 0:08606a13a816 | 1075 | { |
destinyXfate | 0:08606a13a816 | 1076 | switch (pMsg->MsgId) { |
destinyXfate | 0:08606a13a816 | 1077 | |
destinyXfate | 0:08606a13a816 | 1078 | case WM_INIT_DIALOG: |
destinyXfate | 0:08606a13a816 | 1079 | FRAMEWIN_AddCloseButton(pMsg->hWin, FRAMEWIN_BUTTON_RIGHT, 0); |
destinyXfate | 0:08606a13a816 | 1080 | FRAMEWIN_SetActive(pMsg->hWin, 1); |
destinyXfate | 0:08606a13a816 | 1081 | break; |
destinyXfate | 0:08606a13a816 | 1082 | case WM_PAINT: |
destinyXfate | 0:08606a13a816 | 1083 | |
destinyXfate | 0:08606a13a816 | 1084 | GUI_SetColor(GUI_RED); |
destinyXfate | 0:08606a13a816 | 1085 | GUI_SetFont(GUI_FONT_32B_ASCII); |
destinyXfate | 0:08606a13a816 | 1086 | GUI_DispStringHCenterAt("Finish...", 135, 85); |
destinyXfate | 0:08606a13a816 | 1087 | break; |
destinyXfate | 0:08606a13a816 | 1088 | default: |
destinyXfate | 0:08606a13a816 | 1089 | WM_DefaultProc(pMsg); |
destinyXfate | 0:08606a13a816 | 1090 | } |
destinyXfate | 0:08606a13a816 | 1091 | } |
destinyXfate | 0:08606a13a816 | 1092 | |
Will_Lu | 3:1823bfc913c1 | 1093 | //------------------------------------------------- E_Index2顯示頁面 ------------------------------------------------------------------------------------------------------------------------------// |
Will_Lu | 3:1823bfc913c1 | 1094 | static void _cbIndexPage2(WM_MESSAGE * pMsg) |
destinyXfate | 0:08606a13a816 | 1095 | { |
destinyXfate | 0:08606a13a816 | 1096 | WM_HWIN hItem, hmate; |
destinyXfate | 0:08606a13a816 | 1097 | int i; |
destinyXfate | 0:08606a13a816 | 1098 | |
destinyXfate | 0:08606a13a816 | 1099 | switch (pMsg->MsgId) { |
destinyXfate | 0:08606a13a816 | 1100 | case WM_INIT_DIALOG: |
destinyXfate | 0:08606a13a816 | 1101 | |
destinyXfate | 0:08606a13a816 | 1102 | FRAMEWIN_AddCloseButton(pMsg->hWin, FRAMEWIN_BUTTON_RIGHT, 0); |
destinyXfate | 0:08606a13a816 | 1103 | FRAMEWIN_SetActive(pMsg->hWin, 1); |
destinyXfate | 0:08606a13a816 | 1104 | FRAMEWIN_SetClientColor(pMsg->hWin, 0xD5D5D5); |
destinyXfate | 0:08606a13a816 | 1105 | |
destinyXfate | 0:08606a13a816 | 1106 | hmate = WM_GetClientWindow(pMsg->hWin); |
Will_Lu | 3:1823bfc913c1 | 1107 | |
Will_Lu | 3:1823bfc913c1 | 1108 | |
Will_Lu | 3:1823bfc913c1 | 1109 | for(i=35 ; i<57 ; i++) { |
destinyXfate | 0:08606a13a816 | 1110 | hItem = WM_GetDialogItem(pMsg->hWin, GUI_ID_USER + i); |
destinyXfate | 0:08606a13a816 | 1111 | TEXT_SetTextAlign(hItem, GUI_TA_LEFT | GUI_TA_VCENTER); |
Will_Lu | 3:1823bfc913c1 | 1112 | |
destinyXfate | 0:08606a13a816 | 1113 | } |
Will_Lu | 3:1823bfc913c1 | 1114 | |
Will_Lu | 3:1823bfc913c1 | 1115 | |
Will_Lu | 3:1823bfc913c1 | 1116 | // |
Will_Lu | 3:1823bfc913c1 | 1117 | // Initialization of 'Status' |
Will_Lu | 3:1823bfc913c1 | 1118 | // |
Will_Lu | 3:1823bfc913c1 | 1119 | hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_1); |
Will_Lu | 3:1823bfc913c1 | 1120 | TEXT_SetTextAlign(hItem, GUI_TA_HCENTER | GUI_TA_TOP); |
Will_Lu | 3:1823bfc913c1 | 1121 | |
Will_Lu | 3:1823bfc913c1 | 1122 | |
Will_Lu | 3:1823bfc913c1 | 1123 | // |
Will_Lu | 3:1823bfc913c1 | 1124 | // Initialization of 'V_THDI' |
Will_Lu | 3:1823bfc913c1 | 1125 | // |
Will_Lu | 3:1823bfc913c1 | 1126 | hItem = WM_GetDialogItem(pMsg->hWin, GUI_ID_USER + 43); |
Will_Lu | 3:1823bfc913c1 | 1127 | TEXT_SetTextAlign(hItem, GUI_TA_LEFT | GUI_TA_VCENTER); |
Will_Lu | 3:1823bfc913c1 | 1128 | if( atof(cTHDI) > 5.0) { |
Will_Lu | 3:1823bfc913c1 | 1129 | TEXT_SetTextColor(hItem, 0x0000FF); |
Will_Lu | 3:1823bfc913c1 | 1130 | } |
Will_Lu | 3:1823bfc913c1 | 1131 | TEXT_SetText(hItem, cTHDI); |
Will_Lu | 3:1823bfc913c1 | 1132 | |
Will_Lu | 3:1823bfc913c1 | 1133 | // |
Will_Lu | 3:1823bfc913c1 | 1134 | // Initialization of 'V_IDFodd' |
Will_Lu | 3:1823bfc913c1 | 1135 | // |
Will_Lu | 3:1823bfc913c1 | 1136 | hItem = WM_GetDialogItem(pMsg->hWin, GUI_ID_USER + 44); |
Will_Lu | 3:1823bfc913c1 | 1137 | TEXT_SetTextAlign(hItem, GUI_TA_LEFT | GUI_TA_VCENTER); |
Will_Lu | 3:1823bfc913c1 | 1138 | if( atof(cIDFodd) > 4.0) { |
Will_Lu | 3:1823bfc913c1 | 1139 | TEXT_SetTextColor(hItem, 0x0000FF); |
Will_Lu | 3:1823bfc913c1 | 1140 | } |
Will_Lu | 3:1823bfc913c1 | 1141 | TEXT_SetText(hItem, cIDFodd); |
Will_Lu | 3:1823bfc913c1 | 1142 | // |
Will_Lu | 3:1823bfc913c1 | 1143 | // Initialization of 'V_BB' |
Will_Lu | 3:1823bfc913c1 | 1144 | // |
Will_Lu | 3:1823bfc913c1 | 1145 | hItem = WM_GetDialogItem(pMsg->hWin, GUI_ID_USER + 45); |
Will_Lu | 3:1823bfc913c1 | 1146 | TEXT_SetTextAlign(hItem, GUI_TA_LEFT | GUI_TA_VCENTER); |
Will_Lu | 3:1823bfc913c1 | 1147 | if( atof(cBB) > -40.0) { |
Will_Lu | 3:1823bfc913c1 | 1148 | TEXT_SetTextColor(hItem, 0x0000FF); |
Will_Lu | 3:1823bfc913c1 | 1149 | } |
Will_Lu | 3:1823bfc913c1 | 1150 | TEXT_SetText(hItem, cBB); |
Will_Lu | 3:1823bfc913c1 | 1151 | // |
Will_Lu | 3:1823bfc913c1 | 1152 | // Initialization of 'V_VD' |
Will_Lu | 3:1823bfc913c1 | 1153 | // |
Will_Lu | 3:1823bfc913c1 | 1154 | hItem = WM_GetDialogItem(pMsg->hWin, GUI_ID_USER + 53); |
Will_Lu | 3:1823bfc913c1 | 1155 | TEXT_SetTextAlign(hItem, GUI_TA_LEFT | GUI_TA_VCENTER); |
Will_Lu | 3:1823bfc913c1 | 1156 | if( atof(cVD) > 10.0) { |
Will_Lu | 3:1823bfc913c1 | 1157 | TEXT_SetTextColor(hItem, 0x0000FF); |
Will_Lu | 3:1823bfc913c1 | 1158 | } |
Will_Lu | 3:1823bfc913c1 | 1159 | TEXT_SetText(hItem, cVD); |
Will_Lu | 3:1823bfc913c1 | 1160 | // |
Will_Lu | 3:1823bfc913c1 | 1161 | // Initialization of 'V_CD' |
Will_Lu | 3:1823bfc913c1 | 1162 | // |
Will_Lu | 3:1823bfc913c1 | 1163 | hItem = WM_GetDialogItem(pMsg->hWin, GUI_ID_USER + 54); |
Will_Lu | 3:1823bfc913c1 | 1164 | TEXT_SetTextAlign(hItem, GUI_TA_LEFT | GUI_TA_VCENTER); |
Will_Lu | 3:1823bfc913c1 | 1165 | if( atof(cCD) > 10.0) { |
Will_Lu | 3:1823bfc913c1 | 1166 | TEXT_SetTextColor(hItem, 0x0000FF); |
Will_Lu | 3:1823bfc913c1 | 1167 | } |
Will_Lu | 3:1823bfc913c1 | 1168 | TEXT_SetText(hItem, cCD); |
Will_Lu | 3:1823bfc913c1 | 1169 | |
Will_Lu | 3:1823bfc913c1 | 1170 | // |
Will_Lu | 3:1823bfc913c1 | 1171 | // Initialization of 'Status of THDI' |
Will_Lu | 3:1823bfc913c1 | 1172 | // |
Will_Lu | 3:1823bfc913c1 | 1173 | hItem = WM_GetDialogItem(pMsg->hWin, GUI_ID_USER + 46); |
Will_Lu | 3:1823bfc913c1 | 1174 | TEXT_SetTextAlign(hItem, GUI_TA_HCENTER | GUI_TA_VCENTER); |
Will_Lu | 3:1823bfc913c1 | 1175 | if( atof(cTHDI) > 5.0) { |
Will_Lu | 3:1823bfc913c1 | 1176 | TEXT_SetTextColor(hItem, 0x0000FF); |
Will_Lu | 3:1823bfc913c1 | 1177 | TEXT_SetText(hItem, "Abnormal"); |
Will_Lu | 3:1823bfc913c1 | 1178 | } else { |
Will_Lu | 3:1823bfc913c1 | 1179 | TEXT_SetText(hItem, "Normal"); |
Will_Lu | 3:1823bfc913c1 | 1180 | } |
Will_Lu | 3:1823bfc913c1 | 1181 | // |
Will_Lu | 3:1823bfc913c1 | 1182 | // Initialization of 'Status of IDFodd' |
Will_Lu | 3:1823bfc913c1 | 1183 | // |
Will_Lu | 3:1823bfc913c1 | 1184 | hItem = WM_GetDialogItem(pMsg->hWin, GUI_ID_USER + 47); |
Will_Lu | 3:1823bfc913c1 | 1185 | TEXT_SetTextAlign(hItem, GUI_TA_HCENTER | GUI_TA_VCENTER); |
Will_Lu | 3:1823bfc913c1 | 1186 | if( atof(cIDFodd) > 4.0) { |
Will_Lu | 3:1823bfc913c1 | 1187 | TEXT_SetTextColor(hItem, 0x0000FF); |
Will_Lu | 3:1823bfc913c1 | 1188 | TEXT_SetText(hItem, "Abnormal"); |
Will_Lu | 3:1823bfc913c1 | 1189 | } else { |
Will_Lu | 3:1823bfc913c1 | 1190 | TEXT_SetText(hItem, "Normal"); |
Will_Lu | 3:1823bfc913c1 | 1191 | } |
Will_Lu | 3:1823bfc913c1 | 1192 | // |
Will_Lu | 3:1823bfc913c1 | 1193 | // Initialization of 'Status of BB' |
Will_Lu | 3:1823bfc913c1 | 1194 | // |
Will_Lu | 3:1823bfc913c1 | 1195 | hItem = WM_GetDialogItem(pMsg->hWin, GUI_ID_USER + 48); |
Will_Lu | 3:1823bfc913c1 | 1196 | TEXT_SetTextAlign(hItem, GUI_TA_HCENTER | GUI_TA_VCENTER); |
Will_Lu | 3:1823bfc913c1 | 1197 | if( atof(cBB) > -40.0) { |
Will_Lu | 3:1823bfc913c1 | 1198 | TEXT_SetTextColor(hItem, 0x0000FF); |
Will_Lu | 3:1823bfc913c1 | 1199 | TEXT_SetText(hItem, "Abnormal"); |
Will_Lu | 3:1823bfc913c1 | 1200 | } else { |
Will_Lu | 3:1823bfc913c1 | 1201 | TEXT_SetText(hItem, "Normal"); |
Will_Lu | 3:1823bfc913c1 | 1202 | } |
Will_Lu | 3:1823bfc913c1 | 1203 | // |
Will_Lu | 3:1823bfc913c1 | 1204 | // Initialization of 'Status of VD' |
Will_Lu | 3:1823bfc913c1 | 1205 | // |
Will_Lu | 3:1823bfc913c1 | 1206 | hItem = WM_GetDialogItem(pMsg->hWin, GUI_ID_USER + 55); |
Will_Lu | 3:1823bfc913c1 | 1207 | TEXT_SetTextAlign(hItem, GUI_TA_HCENTER | GUI_TA_VCENTER); |
Will_Lu | 3:1823bfc913c1 | 1208 | if( atof(cVD) > 10.0) { |
Will_Lu | 3:1823bfc913c1 | 1209 | TEXT_SetTextColor(hItem, 0x0000FF); |
Will_Lu | 3:1823bfc913c1 | 1210 | TEXT_SetText(hItem, "Abnormal"); |
Will_Lu | 3:1823bfc913c1 | 1211 | } else { |
Will_Lu | 3:1823bfc913c1 | 1212 | TEXT_SetText(hItem, "Normal"); |
Will_Lu | 3:1823bfc913c1 | 1213 | } |
Will_Lu | 3:1823bfc913c1 | 1214 | // |
Will_Lu | 3:1823bfc913c1 | 1215 | // Initialization of 'Status of CD' |
Will_Lu | 3:1823bfc913c1 | 1216 | // |
Will_Lu | 3:1823bfc913c1 | 1217 | hItem = WM_GetDialogItem(pMsg->hWin, GUI_ID_USER + 56); |
Will_Lu | 3:1823bfc913c1 | 1218 | TEXT_SetTextAlign(hItem, GUI_TA_HCENTER | GUI_TA_VCENTER); |
Will_Lu | 3:1823bfc913c1 | 1219 | if( atof(cCD) > 10.0) { |
Will_Lu | 3:1823bfc913c1 | 1220 | TEXT_SetTextColor(hItem, 0x0000FF); |
Will_Lu | 3:1823bfc913c1 | 1221 | TEXT_SetText(hItem, "Abnormal"); |
Will_Lu | 3:1823bfc913c1 | 1222 | } else { |
Will_Lu | 3:1823bfc913c1 | 1223 | TEXT_SetText(hItem, "Normal"); |
Will_Lu | 3:1823bfc913c1 | 1224 | } |
Will_Lu | 3:1823bfc913c1 | 1225 | |
Will_Lu | 3:1823bfc913c1 | 1226 | |
Will_Lu | 3:1823bfc913c1 | 1227 | default: |
Will_Lu | 3:1823bfc913c1 | 1228 | WM_DefaultProc(pMsg); |
Will_Lu | 3:1823bfc913c1 | 1229 | } |
Will_Lu | 3:1823bfc913c1 | 1230 | } |
Will_Lu | 3:1823bfc913c1 | 1231 | |
Will_Lu | 3:1823bfc913c1 | 1232 | |
Will_Lu | 3:1823bfc913c1 | 1233 | |
Will_Lu | 3:1823bfc913c1 | 1234 | |
Will_Lu | 3:1823bfc913c1 | 1235 | //------------------------------------------------- E_Index顯示頁面 ------------------------------------------------------------------------------------------------------------------------------// |
Will_Lu | 3:1823bfc913c1 | 1236 | static void _cbIndexPage(WM_MESSAGE * pMsg) |
Will_Lu | 3:1823bfc913c1 | 1237 | { |
Will_Lu | 3:1823bfc913c1 | 1238 | WM_HWIN hItem, hmate; |
Will_Lu | 3:1823bfc913c1 | 1239 | int i,Id,NCode; |
Will_Lu | 3:1823bfc913c1 | 1240 | WM_HWIN hWin = pMsg->hWin; |
Will_Lu | 3:1823bfc913c1 | 1241 | |
Will_Lu | 3:1823bfc913c1 | 1242 | switch (pMsg->MsgId) { |
Will_Lu | 3:1823bfc913c1 | 1243 | case WM_INIT_DIALOG: |
Will_Lu | 3:1823bfc913c1 | 1244 | |
Will_Lu | 3:1823bfc913c1 | 1245 | FRAMEWIN_AddCloseButton(pMsg->hWin, FRAMEWIN_BUTTON_RIGHT, 0); |
Will_Lu | 3:1823bfc913c1 | 1246 | FRAMEWIN_SetActive(pMsg->hWin, 1); |
Will_Lu | 3:1823bfc913c1 | 1247 | FRAMEWIN_SetClientColor(pMsg->hWin, 0xD5D5D5); |
Will_Lu | 3:1823bfc913c1 | 1248 | |
Will_Lu | 3:1823bfc913c1 | 1249 | hmate = WM_GetClientWindow(pMsg->hWin); |
Will_Lu | 3:1823bfc913c1 | 1250 | |
Will_Lu | 3:1823bfc913c1 | 1251 | |
Will_Lu | 3:1823bfc913c1 | 1252 | for(i=59 ; i<74 ; i++) { |
Will_Lu | 3:1823bfc913c1 | 1253 | if(i==73){ |
Will_Lu | 3:1823bfc913c1 | 1254 | hItem = WM_GetDialogItem(hWin, GUI_ID_USER + i); |
Will_Lu | 3:1823bfc913c1 | 1255 | BUTTON_SetFocussable(hItem, 0); |
Will_Lu | 3:1823bfc913c1 | 1256 | } |
Will_Lu | 3:1823bfc913c1 | 1257 | hItem = WM_GetDialogItem(pMsg->hWin, GUI_ID_USER + i); |
Will_Lu | 3:1823bfc913c1 | 1258 | TEXT_SetTextAlign(hItem, GUI_TA_LEFT | GUI_TA_VCENTER); |
Will_Lu | 3:1823bfc913c1 | 1259 | |
Will_Lu | 3:1823bfc913c1 | 1260 | } |
Will_Lu | 3:1823bfc913c1 | 1261 | |
Will_Lu | 3:1823bfc913c1 | 1262 | |
destinyXfate | 0:08606a13a816 | 1263 | |
destinyXfate | 0:08606a13a816 | 1264 | // |
destinyXfate | 0:08606a13a816 | 1265 | // Initialization of 'Status' |
destinyXfate | 0:08606a13a816 | 1266 | // |
destinyXfate | 0:08606a13a816 | 1267 | hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_1); |
destinyXfate | 0:08606a13a816 | 1268 | TEXT_SetTextAlign(hItem, GUI_TA_HCENTER | GUI_TA_TOP); |
destinyXfate | 0:08606a13a816 | 1269 | |
destinyXfate | 0:08606a13a816 | 1270 | // |
destinyXfate | 0:08606a13a816 | 1271 | // Initialization of 'V_THDV' |
destinyXfate | 0:08606a13a816 | 1272 | // |
destinyXfate | 0:08606a13a816 | 1273 | hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_22); |
destinyXfate | 0:08606a13a816 | 1274 | TEXT_SetTextAlign(hItem, GUI_TA_LEFT | GUI_TA_VCENTER); |
destinyXfate | 0:08606a13a816 | 1275 | if( atof(cTHDV) > 5.0) { |
destinyXfate | 0:08606a13a816 | 1276 | TEXT_SetTextColor(hItem, 0x0000FF); |
destinyXfate | 0:08606a13a816 | 1277 | } |
destinyXfate | 0:08606a13a816 | 1278 | TEXT_SetText(hItem, cTHDV); |
destinyXfate | 0:08606a13a816 | 1279 | |
destinyXfate | 0:08606a13a816 | 1280 | // |
destinyXfate | 0:08606a13a816 | 1281 | // Initialization of 'V_VDFodd' |
destinyXfate | 0:08606a13a816 | 1282 | // |
destinyXfate | 0:08606a13a816 | 1283 | hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_23); |
destinyXfate | 0:08606a13a816 | 1284 | TEXT_SetTextAlign(hItem, GUI_TA_LEFT | GUI_TA_VCENTER); |
destinyXfate | 0:08606a13a816 | 1285 | if( atof(cVDFodd) > 3.0) { |
destinyXfate | 0:08606a13a816 | 1286 | TEXT_SetTextColor(hItem, 0x0000FF); |
destinyXfate | 0:08606a13a816 | 1287 | } |
destinyXfate | 0:08606a13a816 | 1288 | TEXT_SetText(hItem, cVDFodd); |
destinyXfate | 0:08606a13a816 | 1289 | // |
destinyXfate | 0:08606a13a816 | 1290 | // Initialization of 'V_IUR' |
destinyXfate | 0:08606a13a816 | 1291 | // |
destinyXfate | 0:08606a13a816 | 1292 | hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_24); |
destinyXfate | 0:08606a13a816 | 1293 | TEXT_SetTextAlign(hItem, GUI_TA_LEFT | GUI_TA_VCENTER); |
destinyXfate | 0:08606a13a816 | 1294 | if( atof(cIUR) > 10.0) { |
destinyXfate | 0:08606a13a816 | 1295 | TEXT_SetTextColor(hItem, 0x0000FF); |
destinyXfate | 0:08606a13a816 | 1296 | } |
destinyXfate | 0:08606a13a816 | 1297 | TEXT_SetText(hItem, cIUR); |
destinyXfate | 0:08606a13a816 | 1298 | // |
destinyXfate | 0:08606a13a816 | 1299 | // Initialization of 'V_IUF' |
destinyXfate | 0:08606a13a816 | 1300 | // |
destinyXfate | 0:08606a13a816 | 1301 | hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_25); |
destinyXfate | 0:08606a13a816 | 1302 | TEXT_SetTextAlign(hItem, GUI_TA_LEFT | GUI_TA_VCENTER); |
destinyXfate | 0:08606a13a816 | 1303 | if( atof(cIUF) > 2.5) { |
destinyXfate | 0:08606a13a816 | 1304 | TEXT_SetTextColor(hItem, 0x0000FF); |
destinyXfate | 0:08606a13a816 | 1305 | } |
destinyXfate | 0:08606a13a816 | 1306 | TEXT_SetText(hItem, cIUF); |
destinyXfate | 0:08606a13a816 | 1307 | |
destinyXfate | 0:08606a13a816 | 1308 | // |
destinyXfate | 0:08606a13a816 | 1309 | // Initialization of 'V_THDI' |
destinyXfate | 0:08606a13a816 | 1310 | // |
destinyXfate | 0:08606a13a816 | 1311 | hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_27); |
destinyXfate | 0:08606a13a816 | 1312 | TEXT_SetTextAlign(hItem, GUI_TA_LEFT | GUI_TA_VCENTER); |
destinyXfate | 0:08606a13a816 | 1313 | if( atof(cTHDI) > 5.0) { |
destinyXfate | 0:08606a13a816 | 1314 | TEXT_SetTextColor(hItem, 0x0000FF); |
destinyXfate | 0:08606a13a816 | 1315 | } |
destinyXfate | 0:08606a13a816 | 1316 | TEXT_SetText(hItem, cTHDI); |
destinyXfate | 0:08606a13a816 | 1317 | // |
destinyXfate | 0:08606a13a816 | 1318 | // Initialization of 'V_IDFodd' |
destinyXfate | 0:08606a13a816 | 1319 | // |
destinyXfate | 0:08606a13a816 | 1320 | hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_28); |
destinyXfate | 0:08606a13a816 | 1321 | TEXT_SetTextAlign(hItem, GUI_TA_LEFT | GUI_TA_VCENTER); |
destinyXfate | 0:08606a13a816 | 1322 | if( atof(cIDFodd) > 4.0) { |
destinyXfate | 0:08606a13a816 | 1323 | TEXT_SetTextColor(hItem, 0x0000FF); |
destinyXfate | 0:08606a13a816 | 1324 | } |
destinyXfate | 0:08606a13a816 | 1325 | TEXT_SetText(hItem, cIDFodd); |
destinyXfate | 0:08606a13a816 | 1326 | |
destinyXfate | 0:08606a13a816 | 1327 | // |
Will_Lu | 3:1823bfc913c1 | 1328 | // Initialization of 'V_VUR' |
destinyXfate | 0:08606a13a816 | 1329 | // |
destinyXfate | 0:08606a13a816 | 1330 | hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_29); |
destinyXfate | 0:08606a13a816 | 1331 | TEXT_SetTextAlign(hItem, GUI_TA_LEFT | GUI_TA_VCENTER); |
Will_Lu | 3:1823bfc913c1 | 1332 | if( atof(cVUR) > 5) { //// Threshold not sure |
destinyXfate | 0:08606a13a816 | 1333 | TEXT_SetTextColor(hItem, 0x0000FF); |
destinyXfate | 0:08606a13a816 | 1334 | } |
Will_Lu | 3:1823bfc913c1 | 1335 | TEXT_SetText(hItem, cVUR); |
destinyXfate | 0:08606a13a816 | 1336 | |
destinyXfate | 0:08606a13a816 | 1337 | // |
Will_Lu | 3:1823bfc913c1 | 1338 | // Initialization of 'V_VUF' |
destinyXfate | 0:08606a13a816 | 1339 | // |
destinyXfate | 0:08606a13a816 | 1340 | hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_30); |
destinyXfate | 0:08606a13a816 | 1341 | TEXT_SetTextAlign(hItem, GUI_TA_LEFT | GUI_TA_VCENTER); |
Will_Lu | 3:1823bfc913c1 | 1342 | if( atof(cVUF) > 1) { //// Threshold not sure |
destinyXfate | 0:08606a13a816 | 1343 | TEXT_SetTextColor(hItem, 0x0000FF); |
destinyXfate | 0:08606a13a816 | 1344 | } |
Will_Lu | 3:1823bfc913c1 | 1345 | TEXT_SetText(hItem, cVUF); |
Will_Lu | 3:1823bfc913c1 | 1346 | |
Will_Lu | 3:1823bfc913c1 | 1347 | // |
Will_Lu | 3:1823bfc913c1 | 1348 | // Initialization of 'V_BB' |
Will_Lu | 3:1823bfc913c1 | 1349 | // |
Will_Lu | 3:1823bfc913c1 | 1350 | hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_31); |
Will_Lu | 3:1823bfc913c1 | 1351 | TEXT_SetTextAlign(hItem, GUI_TA_LEFT | GUI_TA_VCENTER); |
Will_Lu | 3:1823bfc913c1 | 1352 | if( atof(cBB) > -40) { //// Threshold not sure |
Will_Lu | 3:1823bfc913c1 | 1353 | TEXT_SetTextColor(hItem, 0x0000FF); |
Will_Lu | 3:1823bfc913c1 | 1354 | } |
Will_Lu | 3:1823bfc913c1 | 1355 | TEXT_SetText(hItem, cBB); |
destinyXfate | 0:08606a13a816 | 1356 | |
destinyXfate | 0:08606a13a816 | 1357 | // |
destinyXfate | 0:08606a13a816 | 1358 | // Initialization of 'Status of THDV' |
destinyXfate | 0:08606a13a816 | 1359 | // |
destinyXfate | 0:08606a13a816 | 1360 | hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_32); |
destinyXfate | 0:08606a13a816 | 1361 | TEXT_SetTextAlign(hItem, GUI_TA_HCENTER | GUI_TA_VCENTER); |
destinyXfate | 0:08606a13a816 | 1362 | if( atof(cTHDV) > 5.0) { |
destinyXfate | 0:08606a13a816 | 1363 | TEXT_SetTextColor(hItem, 0x0000FF); |
destinyXfate | 0:08606a13a816 | 1364 | TEXT_SetText(hItem, "Abnormal"); |
destinyXfate | 0:08606a13a816 | 1365 | } else { |
destinyXfate | 0:08606a13a816 | 1366 | TEXT_SetText(hItem, "Normal"); |
destinyXfate | 0:08606a13a816 | 1367 | } |
destinyXfate | 0:08606a13a816 | 1368 | // |
destinyXfate | 0:08606a13a816 | 1369 | // Initialization of 'Status of VDFodd' |
destinyXfate | 0:08606a13a816 | 1370 | // |
destinyXfate | 0:08606a13a816 | 1371 | hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_33); |
destinyXfate | 0:08606a13a816 | 1372 | TEXT_SetTextAlign(hItem, GUI_TA_HCENTER | GUI_TA_VCENTER); |
destinyXfate | 0:08606a13a816 | 1373 | if( atof(cVDFodd) > 3.0) { |
destinyXfate | 0:08606a13a816 | 1374 | TEXT_SetTextColor(hItem, 0x0000FF); |
destinyXfate | 0:08606a13a816 | 1375 | TEXT_SetText(hItem, "Abnormal"); |
destinyXfate | 0:08606a13a816 | 1376 | } else { |
destinyXfate | 0:08606a13a816 | 1377 | TEXT_SetText(hItem, "Normal"); |
destinyXfate | 0:08606a13a816 | 1378 | } |
destinyXfate | 0:08606a13a816 | 1379 | // |
destinyXfate | 0:08606a13a816 | 1380 | // Initialization of 'Status of IUR' |
destinyXfate | 0:08606a13a816 | 1381 | // |
destinyXfate | 0:08606a13a816 | 1382 | hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_34); |
destinyXfate | 0:08606a13a816 | 1383 | TEXT_SetTextAlign(hItem, GUI_TA_HCENTER | GUI_TA_VCENTER); |
destinyXfate | 0:08606a13a816 | 1384 | if( atof(cIUR) > 10.0) { |
destinyXfate | 0:08606a13a816 | 1385 | TEXT_SetTextColor(hItem, 0x0000FF); |
destinyXfate | 0:08606a13a816 | 1386 | TEXT_SetText(hItem, "Abnormal"); |
destinyXfate | 0:08606a13a816 | 1387 | } else { |
destinyXfate | 0:08606a13a816 | 1388 | TEXT_SetText(hItem, "Normal"); |
destinyXfate | 0:08606a13a816 | 1389 | } |
destinyXfate | 0:08606a13a816 | 1390 | |
destinyXfate | 0:08606a13a816 | 1391 | // |
destinyXfate | 0:08606a13a816 | 1392 | // Initialization of 'Status of IUF' |
destinyXfate | 0:08606a13a816 | 1393 | // |
destinyXfate | 0:08606a13a816 | 1394 | hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_35); |
destinyXfate | 0:08606a13a816 | 1395 | TEXT_SetTextAlign(hItem, GUI_TA_HCENTER | GUI_TA_VCENTER); |
destinyXfate | 0:08606a13a816 | 1396 | if( atof(cIUF) > 2.5) { |
destinyXfate | 0:08606a13a816 | 1397 | TEXT_SetTextColor(hItem, 0x0000FF); |
destinyXfate | 0:08606a13a816 | 1398 | TEXT_SetText(hItem, "Abnormal"); |
destinyXfate | 0:08606a13a816 | 1399 | } else { |
destinyXfate | 0:08606a13a816 | 1400 | TEXT_SetText(hItem, "Normal"); |
destinyXfate | 0:08606a13a816 | 1401 | } |
destinyXfate | 0:08606a13a816 | 1402 | |
destinyXfate | 0:08606a13a816 | 1403 | // |
destinyXfate | 0:08606a13a816 | 1404 | // Initialization of 'Status of THDI' |
destinyXfate | 0:08606a13a816 | 1405 | // |
destinyXfate | 0:08606a13a816 | 1406 | hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_36); |
destinyXfate | 0:08606a13a816 | 1407 | TEXT_SetTextAlign(hItem, GUI_TA_HCENTER | GUI_TA_VCENTER); |
destinyXfate | 0:08606a13a816 | 1408 | if( atof(cTHDI) > 5.0) { |
destinyXfate | 0:08606a13a816 | 1409 | TEXT_SetTextColor(hItem, 0x0000FF); |
destinyXfate | 0:08606a13a816 | 1410 | TEXT_SetText(hItem, "Abnormal"); |
destinyXfate | 0:08606a13a816 | 1411 | } else { |
destinyXfate | 0:08606a13a816 | 1412 | TEXT_SetText(hItem, "Normal"); |
destinyXfate | 0:08606a13a816 | 1413 | } |
destinyXfate | 0:08606a13a816 | 1414 | |
destinyXfate | 0:08606a13a816 | 1415 | // |
destinyXfate | 0:08606a13a816 | 1416 | // Initialization of 'Status of IDFodd' |
destinyXfate | 0:08606a13a816 | 1417 | // |
destinyXfate | 0:08606a13a816 | 1418 | hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_37); |
destinyXfate | 0:08606a13a816 | 1419 | TEXT_SetTextAlign(hItem, GUI_TA_HCENTER | GUI_TA_VCENTER); |
destinyXfate | 0:08606a13a816 | 1420 | if( atof(cIDFodd) > 4.0) { |
destinyXfate | 0:08606a13a816 | 1421 | TEXT_SetTextColor(hItem, 0x0000FF); |
destinyXfate | 0:08606a13a816 | 1422 | TEXT_SetText(hItem, "Abnormal"); |
destinyXfate | 0:08606a13a816 | 1423 | } else { |
destinyXfate | 0:08606a13a816 | 1424 | TEXT_SetText(hItem, "Normal"); |
destinyXfate | 0:08606a13a816 | 1425 | } |
destinyXfate | 0:08606a13a816 | 1426 | |
destinyXfate | 0:08606a13a816 | 1427 | // |
destinyXfate | 0:08606a13a816 | 1428 | // Initialization of 'Status of PeakValue' |
destinyXfate | 0:08606a13a816 | 1429 | // |
destinyXfate | 0:08606a13a816 | 1430 | hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_38); |
destinyXfate | 0:08606a13a816 | 1431 | TEXT_SetTextAlign(hItem, GUI_TA_HCENTER | GUI_TA_VCENTER); |
Will_Lu | 3:1823bfc913c1 | 1432 | if( atof(cVUR) > 5) { |
destinyXfate | 0:08606a13a816 | 1433 | TEXT_SetTextColor(hItem, 0x0000FF); |
Will_Lu | 3:1823bfc913c1 | 1434 | TEXT_SetText(hItem, "Abnormal"); |
destinyXfate | 0:08606a13a816 | 1435 | } else { |
Will_Lu | 3:1823bfc913c1 | 1436 | TEXT_SetText(hItem, "Normal"); |
destinyXfate | 0:08606a13a816 | 1437 | } |
destinyXfate | 0:08606a13a816 | 1438 | |
destinyXfate | 0:08606a13a816 | 1439 | // |
destinyXfate | 0:08606a13a816 | 1440 | // Initialization of 'Status of UBvalue' |
destinyXfate | 0:08606a13a816 | 1441 | // |
destinyXfate | 0:08606a13a816 | 1442 | hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_39); |
destinyXfate | 0:08606a13a816 | 1443 | TEXT_SetTextAlign(hItem, GUI_TA_HCENTER | GUI_TA_VCENTER); |
Will_Lu | 3:1823bfc913c1 | 1444 | if( atof(cVUF) > 1) { |
Will_Lu | 3:1823bfc913c1 | 1445 | TEXT_SetTextColor(hItem, 0x0000FF); |
Will_Lu | 3:1823bfc913c1 | 1446 | TEXT_SetText(hItem, "Abnormal"); |
Will_Lu | 3:1823bfc913c1 | 1447 | } else { |
Will_Lu | 3:1823bfc913c1 | 1448 | TEXT_SetText(hItem, "Normal"); |
Will_Lu | 3:1823bfc913c1 | 1449 | } |
Will_Lu | 3:1823bfc913c1 | 1450 | |
Will_Lu | 3:1823bfc913c1 | 1451 | // |
Will_Lu | 3:1823bfc913c1 | 1452 | // Initialization of 'Status of BB' |
Will_Lu | 3:1823bfc913c1 | 1453 | // |
Will_Lu | 3:1823bfc913c1 | 1454 | hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_40); |
Will_Lu | 3:1823bfc913c1 | 1455 | TEXT_SetTextAlign(hItem, GUI_TA_HCENTER | GUI_TA_VCENTER); |
Will_Lu | 3:1823bfc913c1 | 1456 | if( atof(cBB) > -40) { |
destinyXfate | 0:08606a13a816 | 1457 | TEXT_SetTextColor(hItem, 0x0000FF); |
Will_Lu | 3:1823bfc913c1 | 1458 | TEXT_SetText(hItem, "Abnormal"); |
destinyXfate | 0:08606a13a816 | 1459 | } else { |
Will_Lu | 3:1823bfc913c1 | 1460 | TEXT_SetText(hItem, "Normal"); |
destinyXfate | 0:08606a13a816 | 1461 | } |
Will_Lu | 3:1823bfc913c1 | 1462 | break; |
Will_Lu | 3:1823bfc913c1 | 1463 | |
Will_Lu | 3:1823bfc913c1 | 1464 | case WM_NOTIFY_PARENT: |
Will_Lu | 3:1823bfc913c1 | 1465 | Id = WM_GetId(pMsg->hWinSrc); |
Will_Lu | 3:1823bfc913c1 | 1466 | NCode = pMsg->Data.v; |
Will_Lu | 3:1823bfc913c1 | 1467 | switch(Id) { |
Will_Lu | 3:1823bfc913c1 | 1468 | |
Will_Lu | 3:1823bfc913c1 | 1469 | case GUI_ID_USER + 73: // button 'Next Page' // |
Will_Lu | 3:1823bfc913c1 | 1470 | switch(NCode) { |
Will_Lu | 3:1823bfc913c1 | 1471 | case WM_NOTIFICATION_RELEASED: |
Will_Lu | 3:1823bfc913c1 | 1472 | |
Will_Lu | 3:1823bfc913c1 | 1473 | hItem = GUI_CreateDialogBox(_aIndexPage2, GUI_COUNTOF(_aIndexPage2), _cbIndexPage2, WM_HBKWIN, 0, 0); |
Will_Lu | 3:1823bfc913c1 | 1474 | |
Will_Lu | 3:1823bfc913c1 | 1475 | break; |
Will_Lu | 3:1823bfc913c1 | 1476 | } |
Will_Lu | 3:1823bfc913c1 | 1477 | break; |
Will_Lu | 3:1823bfc913c1 | 1478 | } |
destinyXfate | 0:08606a13a816 | 1479 | break; |
destinyXfate | 0:08606a13a816 | 1480 | |
destinyXfate | 0:08606a13a816 | 1481 | default: |
destinyXfate | 0:08606a13a816 | 1482 | WM_DefaultProc(pMsg); |
destinyXfate | 0:08606a13a816 | 1483 | } |
destinyXfate | 0:08606a13a816 | 1484 | } |
destinyXfate | 0:08606a13a816 | 1485 | |
destinyXfate | 0:08606a13a816 | 1486 | |
destinyXfate | 0:08606a13a816 | 1487 | |
destinyXfate | 0:08606a13a816 | 1488 | |
Will_Lu | 3:1823bfc913c1 | 1489 | |
Will_Lu | 3:1823bfc913c1 | 1490 | //------------------------------------------------------------V_Index PAGE----------------------------------------------------------------------------------------------------------// |
destinyXfate | 0:08606a13a816 | 1491 | |
destinyXfate | 0:08606a13a816 | 1492 | static void _cbISO10816(WM_MESSAGE * pMsg) |
destinyXfate | 0:08606a13a816 | 1493 | { |
Will_Lu | 3:1823bfc913c1 | 1494 | WM_HWIN hItem, hmate; |
Will_Lu | 3:1823bfc913c1 | 1495 | int i; |
destinyXfate | 0:08606a13a816 | 1496 | |
destinyXfate | 0:08606a13a816 | 1497 | switch (pMsg->MsgId) { |
destinyXfate | 0:08606a13a816 | 1498 | case WM_INIT_DIALOG: |
destinyXfate | 0:08606a13a816 | 1499 | |
Will_Lu | 3:1823bfc913c1 | 1500 | FRAMEWIN_AddCloseButton(pMsg->hWin, FRAMEWIN_BUTTON_RIGHT, 0); |
Will_Lu | 3:1823bfc913c1 | 1501 | FRAMEWIN_SetActive(pMsg->hWin, 1); |
Will_Lu | 3:1823bfc913c1 | 1502 | FRAMEWIN_SetClientColor(pMsg->hWin, 0xD5D5D5); |
Will_Lu | 3:1823bfc913c1 | 1503 | |
Will_Lu | 3:1823bfc913c1 | 1504 | hmate = WM_GetClientWindow(pMsg->hWin); |
Will_Lu | 3:1823bfc913c1 | 1505 | |
Will_Lu | 3:1823bfc913c1 | 1506 | |
Will_Lu | 3:1823bfc913c1 | 1507 | for(i=107 ; i<122 ; i++) { |
Will_Lu | 3:1823bfc913c1 | 1508 | hItem = WM_GetDialogItem(pMsg->hWin, GUI_ID_USER + i); |
Will_Lu | 3:1823bfc913c1 | 1509 | TEXT_SetTextAlign(hItem, GUI_TA_LEFT | GUI_TA_VCENTER); |
Will_Lu | 3:1823bfc913c1 | 1510 | |
Will_Lu | 3:1823bfc913c1 | 1511 | } |
Will_Lu | 3:1823bfc913c1 | 1512 | |
Will_Lu | 3:1823bfc913c1 | 1513 | |
Will_Lu | 3:1823bfc913c1 | 1514 | // |
Will_Lu | 3:1823bfc913c1 | 1515 | // Initialization of 'Status' |
Will_Lu | 3:1823bfc913c1 | 1516 | // |
Will_Lu | 3:1823bfc913c1 | 1517 | hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_1); |
Will_Lu | 3:1823bfc913c1 | 1518 | TEXT_SetTextAlign(hItem, GUI_TA_HCENTER | GUI_TA_TOP); |
Will_Lu | 3:1823bfc913c1 | 1519 | |
Will_Lu | 3:1823bfc913c1 | 1520 | |
Will_Lu | 3:1823bfc913c1 | 1521 | // |
Will_Lu | 3:1823bfc913c1 | 1522 | // Initialization of 'V_Peak' |
Will_Lu | 3:1823bfc913c1 | 1523 | // |
Will_Lu | 3:1823bfc913c1 | 1524 | hItem = WM_GetDialogItem(pMsg->hWin, GUI_ID_USER + 116); |
Will_Lu | 3:1823bfc913c1 | 1525 | TEXT_SetTextAlign(hItem, GUI_TA_LEFT | GUI_TA_VCENTER); |
Will_Lu | 3:1823bfc913c1 | 1526 | if( atof(cPeakValue) > 5.0) { |
Will_Lu | 3:1823bfc913c1 | 1527 | TEXT_SetTextColor(hItem, 0x0000FF); |
Will_Lu | 3:1823bfc913c1 | 1528 | } |
Will_Lu | 3:1823bfc913c1 | 1529 | TEXT_SetText(hItem, cPeakValue); |
Will_Lu | 3:1823bfc913c1 | 1530 | |
Will_Lu | 3:1823bfc913c1 | 1531 | // |
Will_Lu | 3:1823bfc913c1 | 1532 | // Initialization of 'Max_Vel' |
Will_Lu | 3:1823bfc913c1 | 1533 | // |
Will_Lu | 3:1823bfc913c1 | 1534 | hItem = WM_GetDialogItem(pMsg->hWin, GUI_ID_USER + 117); |
Will_Lu | 3:1823bfc913c1 | 1535 | TEXT_SetTextAlign(hItem, GUI_TA_LEFT | GUI_TA_VCENTER); |
Will_Lu | 3:1823bfc913c1 | 1536 | if( atof(cVel) > 4.5) { |
Will_Lu | 3:1823bfc913c1 | 1537 | TEXT_SetTextColor(hItem, 0x0000FF); |
destinyXfate | 0:08606a13a816 | 1538 | } |
Will_Lu | 3:1823bfc913c1 | 1539 | TEXT_SetText(hItem, cVel); |
Will_Lu | 3:1823bfc913c1 | 1540 | // |
Will_Lu | 3:1823bfc913c1 | 1541 | // Initialization of 'Max_Dis' |
Will_Lu | 3:1823bfc913c1 | 1542 | // |
Will_Lu | 3:1823bfc913c1 | 1543 | hItem = WM_GetDialogItem(pMsg->hWin, GUI_ID_USER + 118); |
Will_Lu | 3:1823bfc913c1 | 1544 | TEXT_SetTextAlign(hItem, GUI_TA_LEFT | GUI_TA_VCENTER); |
Will_Lu | 3:1823bfc913c1 | 1545 | if( atof(cDis) > 90.0) { |
Will_Lu | 3:1823bfc913c1 | 1546 | TEXT_SetTextColor(hItem, 0x0000FF); |
Will_Lu | 3:1823bfc913c1 | 1547 | } |
Will_Lu | 3:1823bfc913c1 | 1548 | TEXT_SetText(hItem, cDis); |
Will_Lu | 3:1823bfc913c1 | 1549 | |
Will_Lu | 3:1823bfc913c1 | 1550 | // |
Will_Lu | 3:1823bfc913c1 | 1551 | // Initialization of 'Status of V_peak' |
Will_Lu | 3:1823bfc913c1 | 1552 | // |
Will_Lu | 3:1823bfc913c1 | 1553 | hItem = WM_GetDialogItem(pMsg->hWin, GUI_ID_USER + 119); |
Will_Lu | 3:1823bfc913c1 | 1554 | TEXT_SetTextAlign(hItem, GUI_TA_HCENTER | GUI_TA_VCENTER); |
Will_Lu | 3:1823bfc913c1 | 1555 | if( atof(cPeakValue) > 5.0) { |
Will_Lu | 3:1823bfc913c1 | 1556 | TEXT_SetTextColor(hItem, 0x0000FF); |
Will_Lu | 3:1823bfc913c1 | 1557 | TEXT_SetText(hItem, "Abnormal"); |
Will_Lu | 3:1823bfc913c1 | 1558 | } else { |
Will_Lu | 3:1823bfc913c1 | 1559 | TEXT_SetText(hItem, "Normal"); |
destinyXfate | 0:08606a13a816 | 1560 | } |
Will_Lu | 3:1823bfc913c1 | 1561 | // |
Will_Lu | 3:1823bfc913c1 | 1562 | // Initialization of 'Status of Max_Vel' |
Will_Lu | 3:1823bfc913c1 | 1563 | // |
Will_Lu | 3:1823bfc913c1 | 1564 | hItem = WM_GetDialogItem(pMsg->hWin, GUI_ID_USER + 120); |
Will_Lu | 3:1823bfc913c1 | 1565 | TEXT_SetTextAlign(hItem, GUI_TA_HCENTER | GUI_TA_VCENTER); |
Will_Lu | 3:1823bfc913c1 | 1566 | if( atof(cVel) > 4.5) { |
Will_Lu | 3:1823bfc913c1 | 1567 | TEXT_SetTextColor(hItem, 0x0000FF); |
Will_Lu | 3:1823bfc913c1 | 1568 | TEXT_SetText(hItem, "Abnormal"); |
Will_Lu | 3:1823bfc913c1 | 1569 | } else { |
Will_Lu | 3:1823bfc913c1 | 1570 | TEXT_SetText(hItem, "Normal"); |
destinyXfate | 0:08606a13a816 | 1571 | } |
Will_Lu | 3:1823bfc913c1 | 1572 | // |
Will_Lu | 3:1823bfc913c1 | 1573 | // Initialization of 'Status of Max_Dis' |
Will_Lu | 3:1823bfc913c1 | 1574 | // |
Will_Lu | 3:1823bfc913c1 | 1575 | hItem = WM_GetDialogItem(pMsg->hWin, GUI_ID_USER + 121); |
Will_Lu | 3:1823bfc913c1 | 1576 | TEXT_SetTextAlign(hItem, GUI_TA_HCENTER | GUI_TA_VCENTER); |
Will_Lu | 3:1823bfc913c1 | 1577 | if( atof(cDis) > 90.0) { |
Will_Lu | 3:1823bfc913c1 | 1578 | TEXT_SetTextColor(hItem, 0x0000FF); |
Will_Lu | 3:1823bfc913c1 | 1579 | TEXT_SetText(hItem, "Abnormal"); |
Will_Lu | 3:1823bfc913c1 | 1580 | } else { |
Will_Lu | 3:1823bfc913c1 | 1581 | TEXT_SetText(hItem, "Normal"); |
Will_Lu | 3:1823bfc913c1 | 1582 | } |
destinyXfate | 0:08606a13a816 | 1583 | |
destinyXfate | 0:08606a13a816 | 1584 | |
destinyXfate | 0:08606a13a816 | 1585 | default: |
destinyXfate | 0:08606a13a816 | 1586 | WM_DefaultProc(pMsg); |
destinyXfate | 0:08606a13a816 | 1587 | } |
destinyXfate | 0:08606a13a816 | 1588 | } |
Will_Lu | 2:bfc676294e38 | 1589 | //---------------------------------------------- Further Fault 頁面---------------------------------------------------------------// |
Will_Lu | 2:bfc676294e38 | 1590 | static void _cbFurtherFault(WM_MESSAGE * pMsg) |
Will_Lu | 2:bfc676294e38 | 1591 | { |
Will_Lu | 2:bfc676294e38 | 1592 | WM_HWIN hItem; |
Will_Lu | 2:bfc676294e38 | 1593 | |
Will_Lu | 2:bfc676294e38 | 1594 | int i; |
Will_Lu | 2:bfc676294e38 | 1595 | |
Will_Lu | 2:bfc676294e38 | 1596 | WM_HWIN hWin = pMsg->hWin; |
Will_Lu | 2:bfc676294e38 | 1597 | |
Will_Lu | 2:bfc676294e38 | 1598 | switch (pMsg->MsgId) { |
Will_Lu | 2:bfc676294e38 | 1599 | case WM_INIT_DIALOG: |
Will_Lu | 2:bfc676294e38 | 1600 | |
Will_Lu | 2:bfc676294e38 | 1601 | WM_Paint(hWin); |
Will_Lu | 2:bfc676294e38 | 1602 | FRAMEWIN_SetActive(hWin, 1); |
Will_Lu | 2:bfc676294e38 | 1603 | FRAMEWIN_AddCloseButton(hWin, FRAMEWIN_BUTTON_RIGHT, 0); |
Will_Lu | 2:bfc676294e38 | 1604 | FRAMEWIN_SetClientColor(hWin, 0xCFCFCF); |
Will_Lu | 2:bfc676294e38 | 1605 | for(i=93 ; i<99 ; i++) { |
Will_Lu | 2:bfc676294e38 | 1606 | hItem = WM_GetDialogItem(hWin, GUI_ID_USER + i); |
Will_Lu | 2:bfc676294e38 | 1607 | TEXT_SetFont(hItem, GUI_FONT_32B_ASCII); |
Will_Lu | 2:bfc676294e38 | 1608 | |
Will_Lu | 2:bfc676294e38 | 1609 | } |
Will_Lu | 2:bfc676294e38 | 1610 | break; |
Will_Lu | 2:bfc676294e38 | 1611 | |
Will_Lu | 2:bfc676294e38 | 1612 | case WM_PAINT: |
Will_Lu | 2:bfc676294e38 | 1613 | |
Will_Lu | 2:bfc676294e38 | 1614 | a0=0; |
Will_Lu | 2:bfc676294e38 | 1615 | a1=0; |
Will_Lu | 2:bfc676294e38 | 1616 | for(i=0 ; i<5 ; i++) { |
Will_Lu | 2:bfc676294e38 | 1617 | a0 += aValues[i]; |
Will_Lu | 2:bfc676294e38 | 1618 | a1 += aValues[i+1]; |
Will_Lu | 2:bfc676294e38 | 1619 | GUI_SetColor(aColors[i]); |
Will_Lu | 2:bfc676294e38 | 1620 | GUI_FillRoundedRect(200, 140 +60*i, 260, 180+60*i, 8); |
Will_Lu | 2:bfc676294e38 | 1621 | //GUI_DrawPie(430, 330, 117, a0, a1, 0); |
Will_Lu | 2:bfc676294e38 | 1622 | GUI_SetColor(GUI_BLACK); |
Will_Lu | 2:bfc676294e38 | 1623 | GUI_DrawRoundedRect(199, 139+60*i, 261, 181+60*i, 8); |
Will_Lu | 2:bfc676294e38 | 1624 | } |
Will_Lu | 2:bfc676294e38 | 1625 | |
Will_Lu | 2:bfc676294e38 | 1626 | GUI_SetFont(GUI_FONT_20B_ASCII); |
Will_Lu | 2:bfc676294e38 | 1627 | for(i=0 ; i<5 ; i++) { |
Will_Lu | 2:bfc676294e38 | 1628 | GUI_DispStringHCenterAt(":", 460, 151+61*i); |
Will_Lu | 2:bfc676294e38 | 1629 | GUI_DispStringHCenterAt("%", 600, 151+61*i); |
Will_Lu | 2:bfc676294e38 | 1630 | } |
Will_Lu | 2:bfc676294e38 | 1631 | GUI_DispStringHCenterAt(cpH,530,151+61*0); |
Will_Lu | 2:bfc676294e38 | 1632 | GUI_DispStringHCenterAt(cpS,530,151+61*1); |
Will_Lu | 2:bfc676294e38 | 1633 | GUI_DispStringHCenterAt(cpR,530,151+61*2); |
Will_Lu | 2:bfc676294e38 | 1634 | GUI_DispStringHCenterAt(cpB,530,151+61*3); |
Will_Lu | 2:bfc676294e38 | 1635 | GUI_DispStringHCenterAt(cpE,530,151+61*4); |
Will_Lu | 2:bfc676294e38 | 1636 | |
Will_Lu | 2:bfc676294e38 | 1637 | break; |
Will_Lu | 2:bfc676294e38 | 1638 | |
Will_Lu | 2:bfc676294e38 | 1639 | default: |
Will_Lu | 2:bfc676294e38 | 1640 | WM_DefaultProc(pMsg); |
Will_Lu | 2:bfc676294e38 | 1641 | } |
Will_Lu | 2:bfc676294e38 | 1642 | } |
destinyXfate | 0:08606a13a816 | 1643 | |
destinyXfate | 0:08606a13a816 | 1644 | //------------------------------------------------- Remote Analysis顯示頁面 ----------------------------------------------------------------------------------------------------------------------// |
destinyXfate | 0:08606a13a816 | 1645 | |
destinyXfate | 0:08606a13a816 | 1646 | static void _cbRemoteAnalysis(WM_MESSAGE * pMsg) |
destinyXfate | 0:08606a13a816 | 1647 | { |
destinyXfate | 0:08606a13a816 | 1648 | WM_HWIN hItem; |
destinyXfate | 0:08606a13a816 | 1649 | |
Will_Lu | 2:bfc676294e38 | 1650 | int i,Id; |
Will_Lu | 2:bfc676294e38 | 1651 | int NCode; |
destinyXfate | 0:08606a13a816 | 1652 | WM_HWIN hWin = pMsg->hWin; |
destinyXfate | 0:08606a13a816 | 1653 | |
destinyXfate | 0:08606a13a816 | 1654 | switch (pMsg->MsgId) { |
destinyXfate | 0:08606a13a816 | 1655 | case WM_INIT_DIALOG: |
destinyXfate | 0:08606a13a816 | 1656 | |
destinyXfate | 0:08606a13a816 | 1657 | WM_Paint(hWin); |
destinyXfate | 0:08606a13a816 | 1658 | FRAMEWIN_SetActive(hWin, 1); |
destinyXfate | 0:08606a13a816 | 1659 | FRAMEWIN_AddCloseButton(hWin, FRAMEWIN_BUTTON_RIGHT, 0); |
destinyXfate | 0:08606a13a816 | 1660 | FRAMEWIN_SetClientColor(hWin, 0xCFCFCF); |
destinyXfate | 0:08606a13a816 | 1661 | |
Will_Lu | 2:bfc676294e38 | 1662 | for(i=84 ; i<93 ; i++) { |
destinyXfate | 0:08606a13a816 | 1663 | hItem = WM_GetDialogItem(hWin, GUI_ID_USER + i); |
Will_Lu | 2:bfc676294e38 | 1664 | if(i<85) { |
Will_Lu | 2:bfc676294e38 | 1665 | hItem = WM_GetDialogItem(hWin, GUI_ID_USER + i); |
Will_Lu | 2:bfc676294e38 | 1666 | BUTTON_SetFocussable(hItem, 0);// Set all buttons non focussable // |
Will_Lu | 2:bfc676294e38 | 1667 | } |
Will_Lu | 2:bfc676294e38 | 1668 | else { |
destinyXfate | 0:08606a13a816 | 1669 | TEXT_SetTextAlign(hItem, GUI_TA_HCENTER | GUI_TA_VCENTER); |
Will_Lu | 2:bfc676294e38 | 1670 | if(i>91){ |
Will_Lu | 2:bfc676294e38 | 1671 | TEXT_SetFont(hItem, GUI_FONT_32B_ASCII); |
Will_Lu | 2:bfc676294e38 | 1672 | } |
destinyXfate | 0:08606a13a816 | 1673 | } |
Will_Lu | 2:bfc676294e38 | 1674 | |
destinyXfate | 0:08606a13a816 | 1675 | } |
destinyXfate | 0:08606a13a816 | 1676 | break; |
destinyXfate | 0:08606a13a816 | 1677 | |
destinyXfate | 0:08606a13a816 | 1678 | case WM_PAINT: |
Will_Lu | 2:bfc676294e38 | 1679 | |
Will_Lu | 2:bfc676294e38 | 1680 | GUI_DrawGradientRoundedH(86, 161, 704, 239, 39, GUI_GREEN, GUI_RED); // x:86 -> 704 y:86 -> 134 86 + 618*0.22 |
Will_Lu | 2:bfc676294e38 | 1681 | GUI_ClearRect(704 - 618*(1-pCMS), 161, 704, 239); |
Will_Lu | 2:bfc676294e38 | 1682 | |
destinyXfate | 0:08606a13a816 | 1683 | GUI_SetColor(GUI_BLACK); |
destinyXfate | 0:08606a13a816 | 1684 | |
destinyXfate | 0:08606a13a816 | 1685 | for(i=0 ; i<3 ; i++) { |
destinyXfate | 0:08606a13a816 | 1686 | if(i<2) { |
Will_Lu | 2:bfc676294e38 | 1687 | GUI_DrawVLine(240+155*i, 160, 180); |
Will_Lu | 2:bfc676294e38 | 1688 | GUI_DrawVLine(240+155*i, 220, 240); |
destinyXfate | 0:08606a13a816 | 1689 | } else { |
Will_Lu | 2:bfc676294e38 | 1690 | GUI_DrawVLine(240+154*i, 160, 180); |
Will_Lu | 2:bfc676294e38 | 1691 | GUI_DrawVLine(240+154*i, 220, 240); |
destinyXfate | 0:08606a13a816 | 1692 | } |
destinyXfate | 0:08606a13a816 | 1693 | |
destinyXfate | 0:08606a13a816 | 1694 | } |
Will_Lu | 2:bfc676294e38 | 1695 | GUI_DrawRoundedRect(85, 160, 705, 240, 40); |
Will_Lu | 2:bfc676294e38 | 1696 | break; |
Will_Lu | 2:bfc676294e38 | 1697 | |
Will_Lu | 2:bfc676294e38 | 1698 | case WM_NOTIFY_PARENT: |
Will_Lu | 2:bfc676294e38 | 1699 | Id = WM_GetId(pMsg->hWinSrc); |
Will_Lu | 2:bfc676294e38 | 1700 | NCode = pMsg->Data.v; |
Will_Lu | 2:bfc676294e38 | 1701 | switch(Id) { |
Will_Lu | 2:bfc676294e38 | 1702 | |
Will_Lu | 3:1823bfc913c1 | 1703 | case GUI_ID_USER + 84: // button 'FurtherFault' // |
Will_Lu | 2:bfc676294e38 | 1704 | switch(NCode) { |
Will_Lu | 2:bfc676294e38 | 1705 | case WM_NOTIFICATION_RELEASED: |
Will_Lu | 2:bfc676294e38 | 1706 | |
Will_Lu | 2:bfc676294e38 | 1707 | hItem = GUI_CreateDialogBox(_aFurtherFault, GUI_COUNTOF(_aFurtherFault), _cbFurtherFault, WM_HBKWIN, 0, 0); |
Will_Lu | 2:bfc676294e38 | 1708 | |
Will_Lu | 2:bfc676294e38 | 1709 | break; |
Will_Lu | 2:bfc676294e38 | 1710 | } |
Will_Lu | 2:bfc676294e38 | 1711 | break; |
destinyXfate | 0:08606a13a816 | 1712 | } |
destinyXfate | 0:08606a13a816 | 1713 | break; |
Will_Lu | 2:bfc676294e38 | 1714 | |
destinyXfate | 0:08606a13a816 | 1715 | default: |
destinyXfate | 0:08606a13a816 | 1716 | WM_DefaultProc(pMsg); |
destinyXfate | 0:08606a13a816 | 1717 | } |
destinyXfate | 0:08606a13a816 | 1718 | } |
destinyXfate | 0:08606a13a816 | 1719 | |
Will_Lu | 2:bfc676294e38 | 1720 | //--------------------------------------------- Further Select頁面-------------------------------------------------------- |
Will_Lu | 2:bfc676294e38 | 1721 | static void _cbFurtherSelect(WM_MESSAGE * pMsg) |
Will_Lu | 2:bfc676294e38 | 1722 | { |
Will_Lu | 2:bfc676294e38 | 1723 | WM_HWIN hItem; |
Will_Lu | 2:bfc676294e38 | 1724 | int NCode; |
Will_Lu | 2:bfc676294e38 | 1725 | int Id, i, xSize, ySize;; |
Will_Lu | 2:bfc676294e38 | 1726 | |
Will_Lu | 2:bfc676294e38 | 1727 | WM_HWIN hWin = pMsg->hWin; |
Will_Lu | 2:bfc676294e38 | 1728 | |
Will_Lu | 2:bfc676294e38 | 1729 | switch (pMsg->MsgId) { |
Will_Lu | 2:bfc676294e38 | 1730 | case WM_INIT_DIALOG: |
Will_Lu | 2:bfc676294e38 | 1731 | |
Will_Lu | 2:bfc676294e38 | 1732 | WM_Paint(hWin); |
Will_Lu | 2:bfc676294e38 | 1733 | FRAMEWIN_SetActive(hWin, 1); |
Will_Lu | 2:bfc676294e38 | 1734 | FRAMEWIN_AddCloseButton(hWin, FRAMEWIN_BUTTON_RIGHT, 0); |
Will_Lu | 2:bfc676294e38 | 1735 | |
Will_Lu | 2:bfc676294e38 | 1736 | for(i=82 ; i<84 ; i++) { |
Will_Lu | 2:bfc676294e38 | 1737 | hItem = WM_GetDialogItem(hWin, GUI_ID_USER + i); |
Will_Lu | 2:bfc676294e38 | 1738 | BUTTON_SetFocussable(hItem, 0);// Set all buttons non focussable // |
Will_Lu | 2:bfc676294e38 | 1739 | } |
Will_Lu | 2:bfc676294e38 | 1740 | break; |
Will_Lu | 2:bfc676294e38 | 1741 | case WM_PAINT: |
Will_Lu | 2:bfc676294e38 | 1742 | |
Will_Lu | 2:bfc676294e38 | 1743 | xSize = LCD_GetXSize(); |
Will_Lu | 2:bfc676294e38 | 1744 | ySize = LCD_GetYSize(); |
Will_Lu | 2:bfc676294e38 | 1745 | GUI_DrawGradientV(0,0,xSize,ySize,0xE6E0B0,0x90EE90); |
Will_Lu | 2:bfc676294e38 | 1746 | |
Will_Lu | 2:bfc676294e38 | 1747 | break; |
Will_Lu | 2:bfc676294e38 | 1748 | |
Will_Lu | 2:bfc676294e38 | 1749 | case WM_NOTIFY_PARENT: |
Will_Lu | 2:bfc676294e38 | 1750 | Id = WM_GetId(pMsg->hWinSrc); |
Will_Lu | 2:bfc676294e38 | 1751 | NCode = pMsg->Data.v; |
Will_Lu | 2:bfc676294e38 | 1752 | switch(Id) { |
Will_Lu | 2:bfc676294e38 | 1753 | |
Will_Lu | 2:bfc676294e38 | 1754 | case GUI_ID_USER + 82: // button 'Fuzzy' // |
Will_Lu | 2:bfc676294e38 | 1755 | switch(NCode) { |
Will_Lu | 2:bfc676294e38 | 1756 | case WM_NOTIFICATION_RELEASED: |
Will_Lu | 2:bfc676294e38 | 1757 | |
Will_Lu | 2:bfc676294e38 | 1758 | |
Will_Lu | 2:bfc676294e38 | 1759 | math.Fuzzy_Fault(FIUR,FIUF,FTHDV,FVDFodd,FTHDI,FIDFodd,FBB,Fpeakvalue,&health,&stator,&rotor,&bearing,&eccentric); |
Will_Lu | 3:1823bfc913c1 | 1760 | math.Fuzzy_Condition(FVUR,FIUR,FVUF,FIUF,FVD,FCD,FVel,FDis,&pCMS); |
Will_Lu | 2:bfc676294e38 | 1761 | snprintf(cpH, 10, "%.2f", health); |
Will_Lu | 2:bfc676294e38 | 1762 | snprintf(cpS, 10, "%.2f", stator); |
Will_Lu | 2:bfc676294e38 | 1763 | snprintf(cpR, 10, "%.2f", rotor); |
Will_Lu | 2:bfc676294e38 | 1764 | snprintf(cpB, 10, "%.2f", bearing); |
Will_Lu | 2:bfc676294e38 | 1765 | snprintf(cpE, 10, "%.2f", eccentric); |
Will_Lu | 2:bfc676294e38 | 1766 | //hItem = GUI_CreateDialogBox(_afinish, GUI_COUNTOF(_afinish), _cbfinish, WM_HBKWIN, 0, 0); |
Will_Lu | 2:bfc676294e38 | 1767 | hItem = GUI_CreateDialogBox(_aRemoteAnalysis, GUI_COUNTOF(_aRemoteAnalysis), _cbRemoteAnalysis, WM_HBKWIN, 0, 0); |
Will_Lu | 2:bfc676294e38 | 1768 | |
Will_Lu | 2:bfc676294e38 | 1769 | break; |
Will_Lu | 2:bfc676294e38 | 1770 | } |
Will_Lu | 2:bfc676294e38 | 1771 | break; |
Will_Lu | 2:bfc676294e38 | 1772 | |
Will_Lu | 2:bfc676294e38 | 1773 | case GUI_ID_USER + 83: // button 'Remote' // |
Will_Lu | 2:bfc676294e38 | 1774 | switch(NCode) { |
Will_Lu | 2:bfc676294e38 | 1775 | case WM_NOTIFICATION_RELEASED: |
Will_Lu | 2:bfc676294e38 | 1776 | |
Will_Lu | 2:bfc676294e38 | 1777 | hItem = GUI_CreateDialogBox(_aRemoteAnalysis, GUI_COUNTOF(_aRemoteAnalysis), _cbRemoteAnalysis, WM_HBKWIN, 0, 0); |
Will_Lu | 2:bfc676294e38 | 1778 | |
Will_Lu | 2:bfc676294e38 | 1779 | break; |
Will_Lu | 2:bfc676294e38 | 1780 | } |
Will_Lu | 2:bfc676294e38 | 1781 | break; |
Will_Lu | 2:bfc676294e38 | 1782 | } |
Will_Lu | 2:bfc676294e38 | 1783 | break; |
Will_Lu | 2:bfc676294e38 | 1784 | default: |
Will_Lu | 2:bfc676294e38 | 1785 | WM_DefaultProc(pMsg); |
Will_Lu | 2:bfc676294e38 | 1786 | } |
Will_Lu | 2:bfc676294e38 | 1787 | } |
Will_Lu | 2:bfc676294e38 | 1788 | |
Will_Lu | 2:bfc676294e38 | 1789 | |
destinyXfate | 0:08606a13a816 | 1790 | |
destinyXfate | 0:08606a13a816 | 1791 | |
destinyXfate | 0:08606a13a816 | 1792 | //---------------------------------------------- Analysis 分析、亮燈頁面 ------------------------------------------------------------------------------------------------------------------------------// |
destinyXfate | 0:08606a13a816 | 1793 | |
destinyXfate | 0:08606a13a816 | 1794 | static void _cbSelectPage(WM_MESSAGE * pMsg) |
destinyXfate | 0:08606a13a816 | 1795 | { |
destinyXfate | 0:08606a13a816 | 1796 | WM_HWIN hItem; |
destinyXfate | 0:08606a13a816 | 1797 | int NCode; |
destinyXfate | 0:08606a13a816 | 1798 | int Id, i, xSize, ySize;; |
destinyXfate | 0:08606a13a816 | 1799 | |
destinyXfate | 0:08606a13a816 | 1800 | WM_HWIN hWin = pMsg->hWin; |
destinyXfate | 0:08606a13a816 | 1801 | |
destinyXfate | 0:08606a13a816 | 1802 | switch (pMsg->MsgId) { |
destinyXfate | 0:08606a13a816 | 1803 | case WM_INIT_DIALOG: |
destinyXfate | 0:08606a13a816 | 1804 | |
destinyXfate | 0:08606a13a816 | 1805 | WM_Paint(hWin); |
destinyXfate | 0:08606a13a816 | 1806 | FRAMEWIN_SetActive(hWin, 1); |
destinyXfate | 0:08606a13a816 | 1807 | FRAMEWIN_AddCloseButton(hWin, FRAMEWIN_BUTTON_RIGHT, 0); |
destinyXfate | 0:08606a13a816 | 1808 | |
destinyXfate | 0:08606a13a816 | 1809 | for(i=36 ; i<38 ; i++) { |
destinyXfate | 0:08606a13a816 | 1810 | hItem = WM_GetDialogItem(hWin, GUI_ID_USER + i); |
destinyXfate | 0:08606a13a816 | 1811 | BUTTON_SetFocussable(hItem, 0);// Set all buttons non focussable // |
destinyXfate | 0:08606a13a816 | 1812 | } |
destinyXfate | 0:08606a13a816 | 1813 | break; |
destinyXfate | 0:08606a13a816 | 1814 | case WM_PAINT: |
destinyXfate | 0:08606a13a816 | 1815 | |
destinyXfate | 0:08606a13a816 | 1816 | xSize = LCD_GetXSize(); |
destinyXfate | 0:08606a13a816 | 1817 | ySize = LCD_GetYSize(); |
destinyXfate | 0:08606a13a816 | 1818 | GUI_DrawGradientV(0,0,xSize,ySize,0xE6E0B0,0x90EE90); |
destinyXfate | 0:08606a13a816 | 1819 | |
destinyXfate | 0:08606a13a816 | 1820 | break; |
destinyXfate | 0:08606a13a816 | 1821 | |
destinyXfate | 0:08606a13a816 | 1822 | case WM_NOTIFY_PARENT: |
destinyXfate | 0:08606a13a816 | 1823 | Id = WM_GetId(pMsg->hWinSrc); |
destinyXfate | 0:08606a13a816 | 1824 | NCode = pMsg->Data.v; |
destinyXfate | 0:08606a13a816 | 1825 | switch(Id) { |
destinyXfate | 0:08606a13a816 | 1826 | |
Will_Lu | 3:1823bfc913c1 | 1827 | case GUI_ID_USER + 36: // button 'eletric index' // |
destinyXfate | 0:08606a13a816 | 1828 | switch(NCode) { |
destinyXfate | 0:08606a13a816 | 1829 | case WM_NOTIFICATION_RELEASED: |
destinyXfate | 0:08606a13a816 | 1830 | |
Will_Lu | 3:1823bfc913c1 | 1831 | hItem = GUI_CreateDialogBox(_aIndexPage, GUI_COUNTOF(_aIndexPage), _cbIndexPage, WM_HBKWIN, 0, 0); |
destinyXfate | 0:08606a13a816 | 1832 | |
destinyXfate | 0:08606a13a816 | 1833 | break; |
destinyXfate | 0:08606a13a816 | 1834 | } |
destinyXfate | 0:08606a13a816 | 1835 | break; |
destinyXfate | 0:08606a13a816 | 1836 | |
Will_Lu | 3:1823bfc913c1 | 1837 | case GUI_ID_USER + 37: // button 'vibration' // |
destinyXfate | 0:08606a13a816 | 1838 | switch(NCode) { |
destinyXfate | 0:08606a13a816 | 1839 | case WM_NOTIFICATION_RELEASED: |
destinyXfate | 0:08606a13a816 | 1840 | |
Will_Lu | 3:1823bfc913c1 | 1841 | hItem = GUI_CreateDialogBox(_aISO10816, GUI_COUNTOF(_aISO10816), _cbISO10816, WM_HBKWIN, 0, 0); |
destinyXfate | 0:08606a13a816 | 1842 | |
destinyXfate | 0:08606a13a816 | 1843 | break; |
destinyXfate | 0:08606a13a816 | 1844 | } |
destinyXfate | 0:08606a13a816 | 1845 | break; |
destinyXfate | 0:08606a13a816 | 1846 | } |
destinyXfate | 0:08606a13a816 | 1847 | break; |
destinyXfate | 0:08606a13a816 | 1848 | default: |
destinyXfate | 0:08606a13a816 | 1849 | WM_DefaultProc(pMsg); |
destinyXfate | 0:08606a13a816 | 1850 | } |
destinyXfate | 0:08606a13a816 | 1851 | } |
destinyXfate | 0:08606a13a816 | 1852 | |
destinyXfate | 0:08606a13a816 | 1853 | //---------------------------------------------- Motor Detection Page -------------------------------------------------------------------------------------------------------------------------------------------// |
destinyXfate | 0:08606a13a816 | 1854 | typedef struct { |
destinyXfate | 0:08606a13a816 | 1855 | |
destinyXfate | 0:08606a13a816 | 1856 | time_t timestamp; |
destinyXfate | 0:08606a13a816 | 1857 | size_t sps; |
destinyXfate | 0:08606a13a816 | 1858 | size_t length; |
destinyXfate | 0:08606a13a816 | 1859 | uint8_t channels; |
destinyXfate | 0:08606a13a816 | 1860 | float adc_high; |
destinyXfate | 0:08606a13a816 | 1861 | float adc_low; |
destinyXfate | 0:08606a13a816 | 1862 | uint8_t adc_bit; |
destinyXfate | 0:08606a13a816 | 1863 | float rate; |
destinyXfate | 0:08606a13a816 | 1864 | char tag[8]; |
destinyXfate | 0:08606a13a816 | 1865 | } FileADC; |
destinyXfate | 0:08606a13a816 | 1866 | FileADC file; |
destinyXfate | 0:08606a13a816 | 1867 | |
destinyXfate | 0:08606a13a816 | 1868 | const char * TXT_XML_H = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"; |
destinyXfate | 0:08606a13a816 | 1869 | const char * TXT_SOAP_H = |
destinyXfate | 0:08606a13a816 | 1870 | "<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">"; |
destinyXfate | 0:08606a13a816 | 1871 | const char * TXT_SOAP_T = "</soap:Envelope>"; |
destinyXfate | 0:08606a13a816 | 1872 | const char * TXT_SOAP_BODY_H = "<soap:Body>"; |
destinyXfate | 0:08606a13a816 | 1873 | const char * TXT_SOAP_BODY_T = "</soap:Body>"; |
destinyXfate | 0:08606a13a816 | 1874 | const char * TXT_WM_FU_H = |
destinyXfate | 0:08606a13a816 | 1875 | "<ns0:fileUpload xmlns:ns0=\"http://service.cloud.monitoring.motor.ee305.ee.ntust.edu.tw/\">"; |
destinyXfate | 0:08606a13a816 | 1876 | const char * TXT_WM_FU_T = "</ns0:fileUpload>"; |
destinyXfate | 0:08606a13a816 | 1877 | const char * TXT_DATA_H = "<arg%d>"; |
destinyXfate | 0:08606a13a816 | 1878 | const char * TXT_DATA_T = "</arg%d>"; |
destinyXfate | 0:08606a13a816 | 1879 | |
destinyXfate | 0:08606a13a816 | 1880 | |
destinyXfate | 0:08606a13a816 | 1881 | static void _cbADCPage(WM_MESSAGE * pMsg) |
destinyXfate | 0:08606a13a816 | 1882 | { |
destinyXfate | 0:08606a13a816 | 1883 | WM_HWIN hItem; |
destinyXfate | 0:08606a13a816 | 1884 | int NCode; |
destinyXfate | 0:08606a13a816 | 1885 | int Id, i, xSize, ySize; |
destinyXfate | 0:08606a13a816 | 1886 | |
destinyXfate | 0:08606a13a816 | 1887 | static int group = 0, flagiso = 0, flagnema = 0; |
Will_Lu | 2:bfc676294e38 | 1888 | static double VUR=0, IUR=0, VUF=0, IUF=0, VD=0, CD=0,THDV=0, VDFodd=0, THDI=0, IDFodd=0, PeakValue=0, UBValue=0, x_vel=0, y_vel=0, z_dis=0, z_vel=0, y_dis=0, x_dis = 0, BB=0, |
destinyXfate | 0:08606a13a816 | 1889 | bkIUR=0, bkIUF=0, bkTHDV=0, bkVDFodd=0, bkTHDI=0, bkIDFodd=0, bkPeakValue=0, bkUBValue=0, |
destinyXfate | 0:08606a13a816 | 1890 | bkvIUR=0, bkvIUF=0, bkvTHDV=0, bkvVDFodd=0, bkvTHDI=0, bkvIDFodd=0, bkvPeakValue=0, bkvUBValue=0, bkvvPeakValue=0, bkvvUBValue=0; |
destinyXfate | 0:08606a13a816 | 1891 | |
destinyXfate | 0:08606a13a816 | 1892 | WM_HWIN hWin = pMsg->hWin; |
destinyXfate | 0:08606a13a816 | 1893 | |
destinyXfate | 0:08606a13a816 | 1894 | int16_t *e, *v; |
destinyXfate | 0:08606a13a816 | 1895 | |
destinyXfate | 0:08606a13a816 | 1896 | switch (pMsg->MsgId) { |
destinyXfate | 0:08606a13a816 | 1897 | case WM_INIT_DIALOG: |
destinyXfate | 0:08606a13a816 | 1898 | |
destinyXfate | 0:08606a13a816 | 1899 | FRAMEWIN_SetActive(hWin, 1); |
destinyXfate | 0:08606a13a816 | 1900 | FRAMEWIN_AddCloseButton(hWin, FRAMEWIN_BUTTON_RIGHT, 0); |
destinyXfate | 0:08606a13a816 | 1901 | FRAMEWIN_SetClientColor(hWin, 0xD2FAFA); |
destinyXfate | 0:08606a13a816 | 1902 | |
destinyXfate | 0:08606a13a816 | 1903 | for(i=135 ; i<141 ; i++) { |
destinyXfate | 0:08606a13a816 | 1904 | hItem = WM_GetDialogItem(hWin, GUI_ID_USER + i); |
destinyXfate | 0:08606a13a816 | 1905 | BUTTON_SetFocussable(hItem, 0);// Set all buttons non focussable // |
destinyXfate | 0:08606a13a816 | 1906 | } |
destinyXfate | 0:08606a13a816 | 1907 | |
destinyXfate | 0:08606a13a816 | 1908 | break; |
destinyXfate | 0:08606a13a816 | 1909 | case WM_PAINT: |
destinyXfate | 0:08606a13a816 | 1910 | xSize = LCD_GetXSize(); |
destinyXfate | 0:08606a13a816 | 1911 | ySize = LCD_GetYSize(); |
destinyXfate | 0:08606a13a816 | 1912 | GUI_DrawGradientV(0,0,xSize,ySize,0xE6E0B0,0x90EE90); |
destinyXfate | 0:08606a13a816 | 1913 | GUI_SetColor(GUI_BLACK); |
destinyXfate | 0:08606a13a816 | 1914 | GUI_SetFont(GUI_FONT_20B_ASCII); |
destinyXfate | 0:08606a13a816 | 1915 | // GUI_DispDecAt(j, 0, 0, 4); |
destinyXfate | 0:08606a13a816 | 1916 | // GUI_SetTextMode(GUI_TEXTMODE_TRANS); |
destinyXfate | 0:08606a13a816 | 1917 | |
destinyXfate | 0:08606a13a816 | 1918 | break; |
destinyXfate | 0:08606a13a816 | 1919 | |
destinyXfate | 0:08606a13a816 | 1920 | case WM_NOTIFY_PARENT: |
destinyXfate | 0:08606a13a816 | 1921 | Id = WM_GetId(pMsg->hWinSrc); |
destinyXfate | 0:08606a13a816 | 1922 | NCode = pMsg->Data.v; |
destinyXfate | 0:08606a13a816 | 1923 | switch(Id) { |
destinyXfate | 0:08606a13a816 | 1924 | |
destinyXfate | 0:08606a13a816 | 1925 | case GUI_ID_USER + 137: // Notifications sent by 'button Analysis' |
destinyXfate | 0:08606a13a816 | 1926 | switch (NCode) { |
destinyXfate | 0:08606a13a816 | 1927 | case WM_NOTIFICATION_RELEASED: |
destinyXfate | 0:08606a13a816 | 1928 | hItem = GUI_CreateDialogBox(_aSelectPage, GUI_COUNTOF(_aSelectPage), _cbSelectPage, WM_HBKWIN, 0, 0); |
destinyXfate | 0:08606a13a816 | 1929 | |
destinyXfate | 0:08606a13a816 | 1930 | break; |
destinyXfate | 0:08606a13a816 | 1931 | } |
destinyXfate | 0:08606a13a816 | 1932 | break; |
destinyXfate | 0:08606a13a816 | 1933 | |
Will_Lu | 2:bfc676294e38 | 1934 | case GUI_ID_USER + 140: // button 'Further Select' // |
destinyXfate | 0:08606a13a816 | 1935 | switch(NCode) { |
destinyXfate | 0:08606a13a816 | 1936 | case WM_NOTIFICATION_RELEASED: |
Will_Lu | 2:bfc676294e38 | 1937 | hItem = GUI_CreateDialogBox(_aFurtherSelect, GUI_COUNTOF(_aFurtherSelect), _cbFurtherSelect, WM_HBKWIN, 0, 0); |
destinyXfate | 0:08606a13a816 | 1938 | |
destinyXfate | 0:08606a13a816 | 1939 | break; |
destinyXfate | 0:08606a13a816 | 1940 | } |
destinyXfate | 0:08606a13a816 | 1941 | break; |
destinyXfate | 0:08606a13a816 | 1942 | |
destinyXfate | 0:08606a13a816 | 1943 | case GUI_ID_USER + 136: // button 'Start' // |
destinyXfate | 0:08606a13a816 | 1944 | switch(NCode) { |
destinyXfate | 0:08606a13a816 | 1945 | case WM_NOTIFICATION_RELEASED: |
destinyXfate | 0:08606a13a816 | 1946 | |
destinyXfate | 0:08606a13a816 | 1947 | |
destinyXfate | 0:08606a13a816 | 1948 | flagc = 0; |
destinyXfate | 0:08606a13a816 | 1949 | flagf = 0; |
destinyXfate | 0:08606a13a816 | 1950 | flagiso = 0; |
destinyXfate | 0:08606a13a816 | 1951 | flagnema = 0; |
Will_Lu | 2:bfc676294e38 | 1952 | VUR=0; |
destinyXfate | 0:08606a13a816 | 1953 | IUR=0; |
Will_Lu | 2:bfc676294e38 | 1954 | VUF=0; |
destinyXfate | 0:08606a13a816 | 1955 | IUF=0; |
Will_Lu | 2:bfc676294e38 | 1956 | VD=0; |
Will_Lu | 2:bfc676294e38 | 1957 | CD=0; |
destinyXfate | 0:08606a13a816 | 1958 | THDV=0; |
destinyXfate | 0:08606a13a816 | 1959 | VDFodd=0; |
destinyXfate | 0:08606a13a816 | 1960 | THDI=0; |
destinyXfate | 0:08606a13a816 | 1961 | IDFodd=0; |
destinyXfate | 0:08606a13a816 | 1962 | PeakValue=0; |
destinyXfate | 0:08606a13a816 | 1963 | UBValue=0; |
destinyXfate | 0:08606a13a816 | 1964 | x_vel=0; |
destinyXfate | 0:08606a13a816 | 1965 | y_vel=0; |
destinyXfate | 0:08606a13a816 | 1966 | z_dis=0; |
destinyXfate | 0:08606a13a816 | 1967 | z_vel=0; |
destinyXfate | 0:08606a13a816 | 1968 | y_dis=0; |
destinyXfate | 0:08606a13a816 | 1969 | x_dis=0; |
Will_Lu | 2:bfc676294e38 | 1970 | BB=0; |
destinyXfate | 0:08606a13a816 | 1971 | |
destinyXfate | 0:08606a13a816 | 1972 | file.timestamp = time(NULL); |
destinyXfate | 0:08606a13a816 | 1973 | file.sps = 20000; |
destinyXfate | 0:08606a13a816 | 1974 | file.length = 8192; |
destinyXfate | 0:08606a13a816 | 1975 | file.channels = 9; |
destinyXfate | 0:08606a13a816 | 1976 | file.adc_high = 10.116f; |
destinyXfate | 0:08606a13a816 | 1977 | file.adc_low = -10.116f; |
destinyXfate | 0:08606a13a816 | 1978 | file.adc_bit = 15; |
destinyXfate | 0:08606a13a816 | 1979 | file.rate = 1/0.016*9.80665; |
destinyXfate | 0:08606a13a816 | 1980 | strcpy(file.tag, "a"); |
destinyXfate | 0:08606a13a816 | 1981 | |
destinyXfate | 0:08606a13a816 | 1982 | e = (int16_t*) malloc(sizeof(int16_t) * 6 * file.length); |
destinyXfate | 0:08606a13a816 | 1983 | v = (int16_t*) malloc(sizeof(int16_t) * 6 * file.length); |
destinyXfate | 0:08606a13a816 | 1984 | |
destinyXfate | 0:08606a13a816 | 1985 | |
destinyXfate | 0:08606a13a816 | 1986 | int mode = atoi(Gateway); |
destinyXfate | 0:08606a13a816 | 1987 | |
destinyXfate | 0:08606a13a816 | 1988 | if(mode!=1) { |
destinyXfate | 0:08606a13a816 | 1989 | |
destinyXfate | 0:08606a13a816 | 1990 | ADC(e, file.length, 1); |
destinyXfate | 0:08606a13a816 | 1991 | ADC(v, file.length, 2); |
destinyXfate | 0:08606a13a816 | 1992 | wait(0.5); |
destinyXfate | 0:08606a13a816 | 1993 | |
destinyXfate | 0:08606a13a816 | 1994 | |
destinyXfate | 0:08606a13a816 | 1995 | int16_t *rawdata; |
destinyXfate | 0:08606a13a816 | 1996 | rawdata = (int16_t*) malloc(sizeof(int16_t) * 9 * file.length); |
destinyXfate | 0:08606a13a816 | 1997 | |
destinyXfate | 0:08606a13a816 | 1998 | for(i=0 ; i<file.length ; i++) { |
destinyXfate | 0:08606a13a816 | 1999 | int ch1=i*9, ch2=i*9+1, ch3=i*9+2, ch4=i*9+3, ch5=i*9+4, ch6=i*9+5, ch7=i*9+6,ch8=i*9+7, ch9=i*9+8 |
destinyXfate | 0:08606a13a816 | 2000 | , k1=i*6, k2=i*6+1, k3=i*6+2, k4=i*6+3, k5=i*6+4, k6=i*6+5; |
destinyXfate | 0:08606a13a816 | 2001 | rawdata[ch1] = e[k1]; |
destinyXfate | 0:08606a13a816 | 2002 | rawdata[ch2] = e[k2]; |
destinyXfate | 0:08606a13a816 | 2003 | rawdata[ch3] = e[k3]; |
destinyXfate | 0:08606a13a816 | 2004 | rawdata[ch4] = e[k4]; |
destinyXfate | 0:08606a13a816 | 2005 | rawdata[ch5] = e[k5]; |
destinyXfate | 0:08606a13a816 | 2006 | rawdata[ch6] = e[k6]; |
destinyXfate | 0:08606a13a816 | 2007 | rawdata[ch7] = v[k1]; |
destinyXfate | 0:08606a13a816 | 2008 | rawdata[ch8] = v[k2]; |
destinyXfate | 0:08606a13a816 | 2009 | rawdata[ch9] = v[k3]; |
destinyXfate | 0:08606a13a816 | 2010 | } |
destinyXfate | 0:08606a13a816 | 2011 | |
destinyXfate | 0:08606a13a816 | 2012 | char name[33]; |
destinyXfate | 0:08606a13a816 | 2013 | fileName(file.timestamp, (char*) &name); |
destinyXfate | 0:08606a13a816 | 2014 | pc.printf("Saving file : %s\r\n", name); |
destinyXfate | 0:08606a13a816 | 2015 | FILE *fp = fopen(name, "w"); |
destinyXfate | 0:08606a13a816 | 2016 | if (fp == NULL) { |
destinyXfate | 0:08606a13a816 | 2017 | pc.printf("Could not open file for write\r\n"); |
destinyXfate | 0:08606a13a816 | 2018 | } else { |
destinyXfate | 0:08606a13a816 | 2019 | fwrite((const void*)&file, sizeof(FileADC), 1, fp); |
destinyXfate | 0:08606a13a816 | 2020 | fwrite((const void*)rawdata, sizeof(int16_t), 9 * file.length, fp); |
destinyXfate | 0:08606a13a816 | 2021 | } |
destinyXfate | 0:08606a13a816 | 2022 | fclose(fp); |
destinyXfate | 0:08606a13a816 | 2023 | |
destinyXfate | 0:08606a13a816 | 2024 | fileName(file.timestamp, (char*) &name); |
destinyXfate | 0:08606a13a816 | 2025 | pc.printf("Temp file : %s\r\n", name); |
destinyXfate | 0:08606a13a816 | 2026 | FILE *pFile = fopen(name, "r"); |
destinyXfate | 0:08606a13a816 | 2027 | if (pFile == NULL) { |
destinyXfate | 0:08606a13a816 | 2028 | pc.printf("Could not open file\r\n"); |
destinyXfate | 0:08606a13a816 | 2029 | } |
destinyXfate | 0:08606a13a816 | 2030 | |
destinyXfate | 0:08606a13a816 | 2031 | Base64 base64; |
destinyXfate | 0:08606a13a816 | 2032 | FILE *tFile = fopen("/mci/soap.tmp", "w"); |
destinyXfate | 0:08606a13a816 | 2033 | if (tFile == NULL) { |
destinyXfate | 0:08606a13a816 | 2034 | pc.printf("Could not open file\r\n"); |
destinyXfate | 0:08606a13a816 | 2035 | } |
destinyXfate | 0:08606a13a816 | 2036 | fprintf(tFile, TXT_XML_H); |
destinyXfate | 0:08606a13a816 | 2037 | fprintf(tFile, TXT_SOAP_H); |
destinyXfate | 0:08606a13a816 | 2038 | fprintf(tFile, TXT_SOAP_BODY_H); |
destinyXfate | 0:08606a13a816 | 2039 | fprintf(tFile, TXT_WM_FU_H); |
destinyXfate | 0:08606a13a816 | 2040 | fprintf(tFile, TXT_DATA_H, 0); |
destinyXfate | 0:08606a13a816 | 2041 | fprintf(tFile, MotorID); |
destinyXfate | 0:08606a13a816 | 2042 | fprintf(tFile, TXT_DATA_T, 0); |
destinyXfate | 0:08606a13a816 | 2043 | fprintf(tFile, TXT_DATA_H, 1); |
destinyXfate | 0:08606a13a816 | 2044 | base64.Encode(tFile, pFile); |
destinyXfate | 0:08606a13a816 | 2045 | fprintf(tFile, TXT_DATA_T, 1); |
destinyXfate | 0:08606a13a816 | 2046 | fprintf(tFile, TXT_WM_FU_T); |
destinyXfate | 0:08606a13a816 | 2047 | fprintf(tFile, TXT_SOAP_BODY_T); |
destinyXfate | 0:08606a13a816 | 2048 | fprintf(tFile, TXT_SOAP_T); |
destinyXfate | 0:08606a13a816 | 2049 | |
destinyXfate | 0:08606a13a816 | 2050 | fclose(pFile); |
destinyXfate | 0:08606a13a816 | 2051 | fclose(tFile); |
destinyXfate | 0:08606a13a816 | 2052 | pc.printf("File : soap.tmp Saved !\r\n"); |
destinyXfate | 0:08606a13a816 | 2053 | |
destinyXfate | 0:08606a13a816 | 2054 | } |
destinyXfate | 0:08606a13a816 | 2055 | |
Will_Lu | 2:bfc676294e38 | 2056 | Index_operation(e , v, file.timestamp, &IUR, &IUF, &THDV, &VDFodd, &THDI, &IDFodd, &PeakValue, &UBValue, &x_vel, &y_vel, &z_vel, &z_dis, &y_dis, &x_dis, &VUR, &VUF, &VD, &CD, &BB); |
Will_Lu | 3:1823bfc913c1 | 2057 | |
Will_Lu | 3:1823bfc913c1 | 2058 | |
destinyXfate | 0:08606a13a816 | 2059 | |
destinyXfate | 0:08606a13a816 | 2060 | // THDI = 3.5263 ; ///// 神奇海螺 |
destinyXfate | 0:08606a13a816 | 2061 | // IDFodd = 3.2294 ; ///// 神奇海螺 |
destinyXfate | 0:08606a13a816 | 2062 | |
Will_Lu | 2:bfc676294e38 | 2063 | FIUR=IUR;FIUF=IUF;FTHDV=THDV;FVDFodd=VDFodd;FTHDI=THDI;FIDFodd=IDFodd;FBB=BB;Fpeakvalue=PeakValue;FVUR=VUR;FVUF=VUF;FVD=VD;FCD=CD; |
Will_Lu | 3:1823bfc913c1 | 2064 | |
destinyXfate | 0:08606a13a816 | 2065 | |
destinyXfate | 0:08606a13a816 | 2066 | snprintf(cIUR, 10, "%.4f", IUR); |
Will_Lu | 2:bfc676294e38 | 2067 | snprintf(cVUR, 10, "%.4f", VUR); |
destinyXfate | 0:08606a13a816 | 2068 | snprintf(cIUF, 10, "%.4f", IUF); |
Will_Lu | 2:bfc676294e38 | 2069 | snprintf(cVUF, 10, "%.4f", VUF); |
Will_Lu | 2:bfc676294e38 | 2070 | snprintf(cCD, 10, "%.4f", CD); |
Will_Lu | 2:bfc676294e38 | 2071 | snprintf(cVD, 10, "%.4f", VD); |
Will_Lu | 2:bfc676294e38 | 2072 | snprintf(cBB, 10, "%.4f", BB); |
destinyXfate | 0:08606a13a816 | 2073 | snprintf(cTHDV, 10, "%.4f", THDV); |
destinyXfate | 0:08606a13a816 | 2074 | snprintf(cVDFodd, 10, "%.4f", VDFodd); |
destinyXfate | 0:08606a13a816 | 2075 | snprintf(cTHDI, 10, "%.4f", THDI); |
destinyXfate | 0:08606a13a816 | 2076 | snprintf(cIDFodd, 10, "%.4f", IDFodd); |
destinyXfate | 0:08606a13a816 | 2077 | snprintf(cPeakValue, 10, "%.4f", PeakValue); |
destinyXfate | 0:08606a13a816 | 2078 | snprintf(cUBValue, 10, "%.4f", UBValue); |
Will_Lu | 3:1823bfc913c1 | 2079 | snprintf(cVel, 10, "%.4f", FVel); |
Will_Lu | 3:1823bfc913c1 | 2080 | snprintf(cDis, 10, "%.4f", FDis); |
destinyXfate | 0:08606a13a816 | 2081 | |
destinyXfate | 0:08606a13a816 | 2082 | // snprintf(cPeakValue, 10, "%.4f", x_vel);//測試用 |
destinyXfate | 0:08606a13a816 | 2083 | // snprintf(cUBValue, 10, "%.4f", y_vel);//測試用 |
destinyXfate | 0:08606a13a816 | 2084 | snprintf(cx_vel, 10, "%.4f", x_vel); |
destinyXfate | 0:08606a13a816 | 2085 | snprintf(cy_vel, 10, "%.4f", y_vel); |
destinyXfate | 0:08606a13a816 | 2086 | snprintf(cz_vel, 10, "%.4f", z_vel); |
destinyXfate | 0:08606a13a816 | 2087 | snprintf(cx_dis, 10, "%.4f", x_dis); |
destinyXfate | 0:08606a13a816 | 2088 | snprintf(cy_dis, 10, "%.4f", y_dis); |
destinyXfate | 0:08606a13a816 | 2089 | snprintf(cz_dis, 10, "%.4f", z_dis); |
destinyXfate | 0:08606a13a816 | 2090 | |
destinyXfate | 0:08606a13a816 | 2091 | |
destinyXfate | 0:08606a13a816 | 2092 | if(mode!=1) { |
destinyXfate | 0:08606a13a816 | 2093 | |
destinyXfate | 0:08606a13a816 | 2094 | char name[33]; |
destinyXfate | 0:08606a13a816 | 2095 | time_t timestamp = file.timestamp; |
destinyXfate | 0:08606a13a816 | 2096 | strftime(name, 33, "/mci/rawdata/%Y%m%d%H%M%S.csv", localtime(×tamp)); |
destinyXfate | 0:08606a13a816 | 2097 | FILE *fp = fopen(name, "w"); |
destinyXfate | 0:08606a13a816 | 2098 | if (fp != NULL) { |
destinyXfate | 0:08606a13a816 | 2099 | for(i = 0 ; i<file.length ; i++) { |
destinyXfate | 0:08606a13a816 | 2100 | fprintf(fp, "%f,%f,%f,%f,%f,%f,%f,%f,%f\r\n", adc.get(e,0,i), adc.get(e,1,i), adc.get(e,2,i), adc.get(e,3,i), adc.get(e,4,i), adc.get(e,5,i), |
destinyXfate | 0:08606a13a816 | 2101 | adc2.get(v,0,i), adc2.get(v,1,i), adc2.get(v,2,i)); |
destinyXfate | 0:08606a13a816 | 2102 | } |
destinyXfate | 0:08606a13a816 | 2103 | fclose(fp); |
destinyXfate | 0:08606a13a816 | 2104 | } |
destinyXfate | 0:08606a13a816 | 2105 | } |
destinyXfate | 0:08606a13a816 | 2106 | |
destinyXfate | 0:08606a13a816 | 2107 | |
destinyXfate | 0:08606a13a816 | 2108 | WM_InvalidateWindow(hWin); |
destinyXfate | 0:08606a13a816 | 2109 | free(e); |
destinyXfate | 0:08606a13a816 | 2110 | free(v); |
destinyXfate | 0:08606a13a816 | 2111 | hItem = GUI_CreateDialogBox(_afinish, GUI_COUNTOF(_afinish), _cbfinish, WM_HBKWIN, 0, 0); |
destinyXfate | 0:08606a13a816 | 2112 | |
destinyXfate | 0:08606a13a816 | 2113 | break; |
destinyXfate | 0:08606a13a816 | 2114 | } |
destinyXfate | 0:08606a13a816 | 2115 | break; |
destinyXfate | 0:08606a13a816 | 2116 | |
destinyXfate | 0:08606a13a816 | 2117 | case GUI_ID_USER + 135: // button 'Get Background Value' // |
destinyXfate | 0:08606a13a816 | 2118 | switch(NCode) { |
destinyXfate | 0:08606a13a816 | 2119 | case WM_NOTIFICATION_RELEASED: |
destinyXfate | 0:08606a13a816 | 2120 | |
destinyXfate | 0:08606a13a816 | 2121 | |
destinyXfate | 0:08606a13a816 | 2122 | bkIUR=0; |
destinyXfate | 0:08606a13a816 | 2123 | bkIUF=0; |
destinyXfate | 0:08606a13a816 | 2124 | bkTHDV=0; |
destinyXfate | 0:08606a13a816 | 2125 | bkVDFodd=0; |
destinyXfate | 0:08606a13a816 | 2126 | bkTHDI=0; |
destinyXfate | 0:08606a13a816 | 2127 | bkIDFodd=0; |
destinyXfate | 0:08606a13a816 | 2128 | bkPeakValue=0; |
destinyXfate | 0:08606a13a816 | 2129 | bkUBValue=0; |
destinyXfate | 0:08606a13a816 | 2130 | |
destinyXfate | 0:08606a13a816 | 2131 | get_bk_value(&bkIUR, &bkIUF, &bkTHDV, &bkVDFodd, &bkTHDI, &bkIDFodd, &bkPeakValue, &bkUBValue); |
destinyXfate | 0:08606a13a816 | 2132 | |
destinyXfate | 0:08606a13a816 | 2133 | bkvIUR = (bkIUR > bkvIUR ? bkIUR : bkvIUR); |
destinyXfate | 0:08606a13a816 | 2134 | bkvIUF = (bkIUF > bkvIUF ? bkIUF : bkvIUF); |
destinyXfate | 0:08606a13a816 | 2135 | bkvTHDV = (bkTHDV > bkvTHDV ? bkTHDV : bkvTHDV); |
destinyXfate | 0:08606a13a816 | 2136 | bkvVDFodd = (bkVDFodd > bkvVDFodd ? bkVDFodd : bkvVDFodd); |
destinyXfate | 0:08606a13a816 | 2137 | bkvTHDI = (bkTHDI > bkvTHDI ? bkTHDI : bkvTHDI); |
destinyXfate | 0:08606a13a816 | 2138 | bkvIDFodd = (bkIDFodd > bkvIDFodd ? bkIDFodd : bkvIDFodd); |
destinyXfate | 0:08606a13a816 | 2139 | bkvPeakValue = (bkPeakValue > bkvPeakValue ? bkPeakValue : bkvPeakValue); |
destinyXfate | 0:08606a13a816 | 2140 | bkvUBValue = (bkUBValue > bkvUBValue ? bkUBValue : bkvUBValue); |
destinyXfate | 0:08606a13a816 | 2141 | |
destinyXfate | 0:08606a13a816 | 2142 | bkvvPeakValue = bkvPeakValue + 3.89; ///// bkgvalue + 3.89 = threshold |
destinyXfate | 0:08606a13a816 | 2143 | bkvvUBValue = bkvUBValue + 3.89; |
destinyXfate | 0:08606a13a816 | 2144 | |
destinyXfate | 0:08606a13a816 | 2145 | snprintf(bkgPeakValue, 10, "%.4f", bkvvPeakValue); ///// Threshold 數值判斷 |
destinyXfate | 0:08606a13a816 | 2146 | snprintf(bkgUBValue, 10, "%.4f", bkvvUBValue); ///// Threshold 數值判斷 |
destinyXfate | 0:08606a13a816 | 2147 | |
destinyXfate | 0:08606a13a816 | 2148 | snprintf(cbk_PeakValue, 10, "\x20(%.0f)", bkvvPeakValue); ///// Threshold 顯示 |
destinyXfate | 0:08606a13a816 | 2149 | snprintf(cbk_UBValue, 10, "\x20(%.0f)", bkvvUBValue); ///// Threshold 顯示 |
destinyXfate | 0:08606a13a816 | 2150 | |
destinyXfate | 0:08606a13a816 | 2151 | WM_InvalidateWindow(hWin); |
destinyXfate | 0:08606a13a816 | 2152 | hItem = GUI_CreateDialogBox(_afinish, GUI_COUNTOF(_afinish), _cbfinish, WM_HBKWIN, 0, 0); |
destinyXfate | 0:08606a13a816 | 2153 | |
destinyXfate | 0:08606a13a816 | 2154 | break; |
destinyXfate | 0:08606a13a816 | 2155 | } |
destinyXfate | 0:08606a13a816 | 2156 | break; |
destinyXfate | 0:08606a13a816 | 2157 | |
destinyXfate | 0:08606a13a816 | 2158 | case GUI_ID_USER + 138: // button 'Send' // |
destinyXfate | 0:08606a13a816 | 2159 | switch(NCode) { |
destinyXfate | 0:08606a13a816 | 2160 | case WM_NOTIFICATION_RELEASED: |
destinyXfate | 0:08606a13a816 | 2161 | |
destinyXfate | 0:08606a13a816 | 2162 | |
destinyXfate | 0:08606a13a816 | 2163 | send_network(); |
destinyXfate | 0:08606a13a816 | 2164 | |
destinyXfate | 0:08606a13a816 | 2165 | |
destinyXfate | 0:08606a13a816 | 2166 | WM_InvalidateWindow(hWin); |
destinyXfate | 0:08606a13a816 | 2167 | hItem = GUI_CreateDialogBox(_afinish, GUI_COUNTOF(_afinish), _cbfinish, WM_HBKWIN, 0, 0); |
destinyXfate | 0:08606a13a816 | 2168 | |
destinyXfate | 0:08606a13a816 | 2169 | break; |
destinyXfate | 0:08606a13a816 | 2170 | } |
destinyXfate | 0:08606a13a816 | 2171 | break; |
destinyXfate | 0:08606a13a816 | 2172 | |
destinyXfate | 0:08606a13a816 | 2173 | case GUI_ID_USER + 139: // button 'Get' // |
destinyXfate | 0:08606a13a816 | 2174 | switch(NCode) { |
destinyXfate | 0:08606a13a816 | 2175 | case WM_NOTIFICATION_RELEASED: |
destinyXfate | 0:08606a13a816 | 2176 | |
destinyXfate | 0:08606a13a816 | 2177 | |
destinyXfate | 0:08606a13a816 | 2178 | pCMS = atof(Volts); |
destinyXfate | 0:08606a13a816 | 2179 | |
Will_Lu | 2:bfc676294e38 | 2180 | snprintf(cpH, 10, "%.2f", health); |
Will_Lu | 2:bfc676294e38 | 2181 | snprintf(cpS, 10, "%.2f", stator); |
Will_Lu | 2:bfc676294e38 | 2182 | snprintf(cpR, 10, "%.2f", rotor); |
Will_Lu | 2:bfc676294e38 | 2183 | snprintf(cpB, 10, "%.2f", bearing); |
Will_Lu | 2:bfc676294e38 | 2184 | snprintf(cpE, 10, "%.2f", eccentric); |
destinyXfate | 0:08606a13a816 | 2185 | |
destinyXfate | 0:08606a13a816 | 2186 | aValues[1]= 360 * atof(Amps); |
destinyXfate | 0:08606a13a816 | 2187 | aValues[2]= 360 * atof(Poles); |
destinyXfate | 0:08606a13a816 | 2188 | aValues[3]= 360 * atof(RPM); |
destinyXfate | 0:08606a13a816 | 2189 | aValues[4]= 360 * atof(IPADR); |
destinyXfate | 0:08606a13a816 | 2190 | aValues[5]= 360 * atof(Netmask)+ 2; |
destinyXfate | 0:08606a13a816 | 2191 | |
destinyXfate | 0:08606a13a816 | 2192 | |
destinyXfate | 0:08606a13a816 | 2193 | WM_InvalidateWindow(hWin); |
destinyXfate | 0:08606a13a816 | 2194 | hItem = GUI_CreateDialogBox(_afinish, GUI_COUNTOF(_afinish), _cbfinish, WM_HBKWIN, 0, 0); |
destinyXfate | 0:08606a13a816 | 2195 | break; |
destinyXfate | 0:08606a13a816 | 2196 | } |
destinyXfate | 0:08606a13a816 | 2197 | break; |
destinyXfate | 0:08606a13a816 | 2198 | } |
destinyXfate | 0:08606a13a816 | 2199 | break; |
destinyXfate | 0:08606a13a816 | 2200 | default: |
destinyXfate | 0:08606a13a816 | 2201 | WM_DefaultProc(pMsg); |
destinyXfate | 0:08606a13a816 | 2202 | } |
destinyXfate | 0:08606a13a816 | 2203 | } |
destinyXfate | 0:08606a13a816 | 2204 | |
destinyXfate | 0:08606a13a816 | 2205 | |
destinyXfate | 0:08606a13a816 | 2206 | |
destinyXfate | 0:08606a13a816 | 2207 | |
destinyXfate | 0:08606a13a816 | 2208 | |
destinyXfate | 0:08606a13a816 | 2209 | // ---------------------------------------------------------------MainPage callback---------------------------------------------------------------------------------------------------------------------// |
destinyXfate | 0:08606a13a816 | 2210 | |
destinyXfate | 0:08606a13a816 | 2211 | static void _cbMainPage(WM_MESSAGE * pMsg) |
destinyXfate | 0:08606a13a816 | 2212 | { |
destinyXfate | 0:08606a13a816 | 2213 | |
destinyXfate | 0:08606a13a816 | 2214 | WM_HWIN hItem; |
destinyXfate | 0:08606a13a816 | 2215 | |
destinyXfate | 0:08606a13a816 | 2216 | static WM_HWIN hEdit_MotorID=0, hEdit_Volts=0, hEdit_Amps=0, hEdit_HP=0, hEdit_Poles=0, hEdit_RPM=0, hEdit_IPADR=0, hEdit_Netmask=0, hEdit_Gateway=0; |
destinyXfate | 0:08606a13a816 | 2217 | |
destinyXfate | 0:08606a13a816 | 2218 | static int j=0; |
destinyXfate | 0:08606a13a816 | 2219 | int NCode; |
destinyXfate | 0:08606a13a816 | 2220 | int Id, i; |
destinyXfate | 0:08606a13a816 | 2221 | int xSize, ySize; |
destinyXfate | 0:08606a13a816 | 2222 | |
destinyXfate | 0:08606a13a816 | 2223 | // static int flagYO = 0; |
destinyXfate | 0:08606a13a816 | 2224 | |
destinyXfate | 0:08606a13a816 | 2225 | switch (pMsg->MsgId) { |
destinyXfate | 0:08606a13a816 | 2226 | |
destinyXfate | 0:08606a13a816 | 2227 | case WM_INIT_DIALOG: |
destinyXfate | 0:08606a13a816 | 2228 | hItem = WM_GetDialogItem(pMsg->hWin, ID_RADIO_0); //***************************// |
destinyXfate | 0:08606a13a816 | 2229 | RADIO_SetFont(hItem, GUI_FONT_20B_ASCII); // Initialization of 'Radio' // |
destinyXfate | 0:08606a13a816 | 2230 | RADIO_SetText(hItem, "DHCP", 0); //***************************// |
destinyXfate | 0:08606a13a816 | 2231 | RADIO_SetText(hItem, "Static IP", 1); |
destinyXfate | 0:08606a13a816 | 2232 | |
destinyXfate | 0:08606a13a816 | 2233 | for(i=14 ; i<24 ; i++) { |
destinyXfate | 0:08606a13a816 | 2234 | hItem = WM_GetDialogItem(pMsg->hWin, GUI_ID_USER + i); //******************************************// |
destinyXfate | 0:08606a13a816 | 2235 | TEXT_SetTextAlign(hItem, GUI_TA_LEFT | GUI_TA_VCENTER); // Initialization of 'IP Address etc. TEXT' // |
destinyXfate | 0:08606a13a816 | 2236 | if(i==14) { //******************************************// |
destinyXfate | 0:08606a13a816 | 2237 | TEXT_SetFont(hItem, GUI_FONT_32B_ASCII); |
destinyXfate | 0:08606a13a816 | 2238 | } else { |
destinyXfate | 0:08606a13a816 | 2239 | TEXT_SetFont(hItem, GUI_FONT_20B_ASCII); |
destinyXfate | 0:08606a13a816 | 2240 | } |
destinyXfate | 0:08606a13a816 | 2241 | } |
destinyXfate | 0:08606a13a816 | 2242 | for(i=24 ; i<33 ; i++) { |
destinyXfate | 0:08606a13a816 | 2243 | hItem = WM_GetDialogItem(pMsg->hWin, GUI_ID_USER + i); //**************************************// |
destinyXfate | 0:08606a13a816 | 2244 | EDIT_SetFont(hItem, GUI_FONT_20B_ASCII); // Initialization of 'IPADDR etc. EDIT' // |
destinyXfate | 0:08606a13a816 | 2245 | EDIT_SetTextAlign(hItem, GUI_TA_LEFT | GUI_TA_VCENTER); //**************************************// |
destinyXfate | 0:08606a13a816 | 2246 | if(i>29) { |
destinyXfate | 0:08606a13a816 | 2247 | WM_DisableWindow(hItem); |
destinyXfate | 0:08606a13a816 | 2248 | } |
destinyXfate | 0:08606a13a816 | 2249 | } |
destinyXfate | 0:08606a13a816 | 2250 | for(i=0 ; i<14 ; i++) { |
destinyXfate | 0:08606a13a816 | 2251 | hItem = WM_GetDialogItem(pMsg->hWin, GUI_ID_USER + i); |
destinyXfate | 0:08606a13a816 | 2252 | BUTTON_SetFocussable(hItem, 0);// Set all buttons non focussable // |
destinyXfate | 0:08606a13a816 | 2253 | switch (i) { |
destinyXfate | 0:08606a13a816 | 2254 | case 11: |
destinyXfate | 0:08606a13a816 | 2255 | BUTTON_SetFont(hItem, GUI_FONT_32B_ASCII); |
destinyXfate | 0:08606a13a816 | 2256 | BUTTON_SetBitmapEx(hItem, 0, &_bmArrowLeft, 19, 50); |
destinyXfate | 0:08606a13a816 | 2257 | BUTTON_SetBitmapEx(hItem, 1, &_bmArrowLeft, 19, 50); |
destinyXfate | 0:08606a13a816 | 2258 | break; |
destinyXfate | 0:08606a13a816 | 2259 | } |
destinyXfate | 0:08606a13a816 | 2260 | } |
destinyXfate | 0:08606a13a816 | 2261 | |
destinyXfate | 0:08606a13a816 | 2262 | hItem = WM_GetDialogItem(pMsg->hWin, GUI_ID_USER + 33); |
destinyXfate | 0:08606a13a816 | 2263 | TEXT_SetTextAlign(hItem, GUI_TA_LEFT | GUI_TA_VCENTER); |
destinyXfate | 0:08606a13a816 | 2264 | TEXT_SetFont(hItem, GUI_FONT_32B_ASCII); |
destinyXfate | 0:08606a13a816 | 2265 | |
destinyXfate | 0:08606a13a816 | 2266 | break; |
destinyXfate | 0:08606a13a816 | 2267 | |
destinyXfate | 0:08606a13a816 | 2268 | case WM_PAINT: |
destinyXfate | 0:08606a13a816 | 2269 | |
destinyXfate | 0:08606a13a816 | 2270 | xSize = LCD_GetXSize(); |
destinyXfate | 0:08606a13a816 | 2271 | ySize = LCD_GetYSize(); |
destinyXfate | 0:08606a13a816 | 2272 | GUI_DrawGradientV(0,0,xSize,ySize,0xE6E0B0,0x9980CC); /// (0xCC8080, 0x9980CC) |
destinyXfate | 0:08606a13a816 | 2273 | |
destinyXfate | 0:08606a13a816 | 2274 | GUI_SetColor(GUI_BLACK); |
destinyXfate | 0:08606a13a816 | 2275 | GUI_SetPenSize(2); |
destinyXfate | 0:08606a13a816 | 2276 | GUI_DrawLine(20, 40, 105, 40); |
destinyXfate | 0:08606a13a816 | 2277 | GUI_DrawLine(355, 40, 440, 40); |
destinyXfate | 0:08606a13a816 | 2278 | GUI_DrawLine(20, 185, 440, 185); |
destinyXfate | 0:08606a13a816 | 2279 | GUI_DrawLine(20, 40, 20, 185); |
destinyXfate | 0:08606a13a816 | 2280 | GUI_DrawLine(440, 40, 440, 185); |
destinyXfate | 0:08606a13a816 | 2281 | |
destinyXfate | 0:08606a13a816 | 2282 | GUI_DrawLine(20, 245, 117, 245); |
destinyXfate | 0:08606a13a816 | 2283 | GUI_DrawLine(345, 245, 440, 245); |
destinyXfate | 0:08606a13a816 | 2284 | GUI_DrawLine(20, 440, 440, 440); |
destinyXfate | 0:08606a13a816 | 2285 | GUI_DrawLine(20, 245, 20, 440); |
destinyXfate | 0:08606a13a816 | 2286 | GUI_DrawLine(440, 245, 440, 440); |
destinyXfate | 0:08606a13a816 | 2287 | |
destinyXfate | 0:08606a13a816 | 2288 | break; |
destinyXfate | 0:08606a13a816 | 2289 | |
destinyXfate | 0:08606a13a816 | 2290 | case WM_NOTIFY_PARENT: |
destinyXfate | 0:08606a13a816 | 2291 | Id = WM_GetId(pMsg->hWinSrc); |
destinyXfate | 0:08606a13a816 | 2292 | NCode = pMsg->Data.v; |
destinyXfate | 0:08606a13a816 | 2293 | switch(Id) { |
destinyXfate | 0:08606a13a816 | 2294 | case ID_RADIO_0: // Notifications sent by 'Radio' |
destinyXfate | 0:08606a13a816 | 2295 | switch(NCode) { |
destinyXfate | 0:08606a13a816 | 2296 | case WM_NOTIFICATION_VALUE_CHANGED: |
destinyXfate | 0:08606a13a816 | 2297 | for(i=30 ; i<33 ; i++) { |
destinyXfate | 0:08606a13a816 | 2298 | hItem = WM_GetDialogItem(pMsg->hWin, GUI_ID_USER + i); |
destinyXfate | 0:08606a13a816 | 2299 | switch (RADIO_GetValue(pMsg->hWinSrc)) { |
destinyXfate | 0:08606a13a816 | 2300 | case 0: |
destinyXfate | 0:08606a13a816 | 2301 | WM_DisableWindow(hItem); |
destinyXfate | 0:08606a13a816 | 2302 | break; |
destinyXfate | 0:08606a13a816 | 2303 | case 1: |
destinyXfate | 0:08606a13a816 | 2304 | WM_EnableWindow(hItem); |
destinyXfate | 0:08606a13a816 | 2305 | break; |
destinyXfate | 0:08606a13a816 | 2306 | } |
destinyXfate | 0:08606a13a816 | 2307 | } |
destinyXfate | 0:08606a13a816 | 2308 | break; |
destinyXfate | 0:08606a13a816 | 2309 | } |
destinyXfate | 0:08606a13a816 | 2310 | break; |
destinyXfate | 0:08606a13a816 | 2311 | |
destinyXfate | 0:08606a13a816 | 2312 | |
destinyXfate | 0:08606a13a816 | 2313 | case GUI_ID_USER + 0: // Notifications sent by 'button 0' |
destinyXfate | 0:08606a13a816 | 2314 | switch (NCode) { |
destinyXfate | 0:08606a13a816 | 2315 | case WM_NOTIFICATION_RELEASED: |
destinyXfate | 0:08606a13a816 | 2316 | GUI_SendKeyMsg(_aKey[0], 1); |
destinyXfate | 0:08606a13a816 | 2317 | break; |
destinyXfate | 0:08606a13a816 | 2318 | } |
destinyXfate | 0:08606a13a816 | 2319 | break; |
destinyXfate | 0:08606a13a816 | 2320 | |
destinyXfate | 0:08606a13a816 | 2321 | case GUI_ID_USER + 1: // Notifications sent by 'button 1' |
destinyXfate | 0:08606a13a816 | 2322 | switch (NCode) { |
destinyXfate | 0:08606a13a816 | 2323 | case WM_NOTIFICATION_RELEASED: |
destinyXfate | 0:08606a13a816 | 2324 | GUI_SendKeyMsg(_aKey[1], 1); |
destinyXfate | 0:08606a13a816 | 2325 | break; |
destinyXfate | 0:08606a13a816 | 2326 | } |
destinyXfate | 0:08606a13a816 | 2327 | break; |
destinyXfate | 0:08606a13a816 | 2328 | |
destinyXfate | 0:08606a13a816 | 2329 | case GUI_ID_USER + 2: // Notifications sent by 'button 2' |
destinyXfate | 0:08606a13a816 | 2330 | switch (NCode) { |
destinyXfate | 0:08606a13a816 | 2331 | case WM_NOTIFICATION_RELEASED: |
destinyXfate | 0:08606a13a816 | 2332 | GUI_SendKeyMsg(_aKey[2], 1); /* Send a key message to the focussed window */ |
destinyXfate | 0:08606a13a816 | 2333 | break; |
destinyXfate | 0:08606a13a816 | 2334 | } |
destinyXfate | 0:08606a13a816 | 2335 | break; |
destinyXfate | 0:08606a13a816 | 2336 | |
destinyXfate | 0:08606a13a816 | 2337 | case GUI_ID_USER + 3: // Notifications sent by 'button 3' |
destinyXfate | 0:08606a13a816 | 2338 | switch (NCode) { |
destinyXfate | 0:08606a13a816 | 2339 | case WM_NOTIFICATION_RELEASED: |
destinyXfate | 0:08606a13a816 | 2340 | GUI_SendKeyMsg(_aKey[3], 1); /* Send a key message to the focussed window */ |
destinyXfate | 0:08606a13a816 | 2341 | break; |
destinyXfate | 0:08606a13a816 | 2342 | } |
destinyXfate | 0:08606a13a816 | 2343 | break; |
destinyXfate | 0:08606a13a816 | 2344 | |
destinyXfate | 0:08606a13a816 | 2345 | case GUI_ID_USER + 4: // Notifications sent by 'button 4' |
destinyXfate | 0:08606a13a816 | 2346 | switch (NCode) { |
destinyXfate | 0:08606a13a816 | 2347 | case WM_NOTIFICATION_RELEASED: |
destinyXfate | 0:08606a13a816 | 2348 | GUI_SendKeyMsg(_aKey[4], 1); |
destinyXfate | 0:08606a13a816 | 2349 | break; |
destinyXfate | 0:08606a13a816 | 2350 | } |
destinyXfate | 0:08606a13a816 | 2351 | break; |
destinyXfate | 0:08606a13a816 | 2352 | |
destinyXfate | 0:08606a13a816 | 2353 | case GUI_ID_USER + 5: // Notifications sent by 'button 5' |
destinyXfate | 0:08606a13a816 | 2354 | switch (NCode) { |
destinyXfate | 0:08606a13a816 | 2355 | case WM_NOTIFICATION_RELEASED: |
destinyXfate | 0:08606a13a816 | 2356 | GUI_SendKeyMsg(_aKey[5], 1); |
destinyXfate | 0:08606a13a816 | 2357 | break; |
destinyXfate | 0:08606a13a816 | 2358 | } |
destinyXfate | 0:08606a13a816 | 2359 | break; |
destinyXfate | 0:08606a13a816 | 2360 | |
destinyXfate | 0:08606a13a816 | 2361 | case GUI_ID_USER + 6: // Notifications sent by 'button 6' |
destinyXfate | 0:08606a13a816 | 2362 | switch (NCode) { |
destinyXfate | 0:08606a13a816 | 2363 | case WM_NOTIFICATION_RELEASED: |
destinyXfate | 0:08606a13a816 | 2364 | GUI_SendKeyMsg(_aKey[6], 1); /* Send a key message to the focussed window */ |
destinyXfate | 0:08606a13a816 | 2365 | break; |
destinyXfate | 0:08606a13a816 | 2366 | } |
destinyXfate | 0:08606a13a816 | 2367 | break; |
destinyXfate | 0:08606a13a816 | 2368 | |
destinyXfate | 0:08606a13a816 | 2369 | case GUI_ID_USER + 7: // Notifications sent by 'button 7' |
destinyXfate | 0:08606a13a816 | 2370 | switch (NCode) { |
destinyXfate | 0:08606a13a816 | 2371 | case WM_NOTIFICATION_RELEASED: |
destinyXfate | 0:08606a13a816 | 2372 | GUI_SendKeyMsg(_aKey[7], 1); |
destinyXfate | 0:08606a13a816 | 2373 | break; |
destinyXfate | 0:08606a13a816 | 2374 | } |
destinyXfate | 0:08606a13a816 | 2375 | break; |
destinyXfate | 0:08606a13a816 | 2376 | case GUI_ID_USER + 8: // Notifications sent by 'button 8' |
destinyXfate | 0:08606a13a816 | 2377 | switch (NCode) { |
destinyXfate | 0:08606a13a816 | 2378 | case WM_NOTIFICATION_RELEASED: |
destinyXfate | 0:08606a13a816 | 2379 | GUI_SendKeyMsg(_aKey[8], 1); /* Send a key message to the focussed window */ |
destinyXfate | 0:08606a13a816 | 2380 | break; |
destinyXfate | 0:08606a13a816 | 2381 | } |
destinyXfate | 0:08606a13a816 | 2382 | break; |
destinyXfate | 0:08606a13a816 | 2383 | case GUI_ID_USER + 9: // Notifications sent by 'button 9' |
destinyXfate | 0:08606a13a816 | 2384 | switch (NCode) { |
destinyXfate | 0:08606a13a816 | 2385 | case WM_NOTIFICATION_RELEASED: |
destinyXfate | 0:08606a13a816 | 2386 | GUI_SendKeyMsg(_aKey[9], 1); /* Send a key message to the focussed window */ |
destinyXfate | 0:08606a13a816 | 2387 | break; |
destinyXfate | 0:08606a13a816 | 2388 | } |
destinyXfate | 0:08606a13a816 | 2389 | break; |
destinyXfate | 0:08606a13a816 | 2390 | case GUI_ID_USER + 10: // Notifications sent by 'button .' |
destinyXfate | 0:08606a13a816 | 2391 | switch (NCode) { |
destinyXfate | 0:08606a13a816 | 2392 | case WM_NOTIFICATION_RELEASED: |
destinyXfate | 0:08606a13a816 | 2393 | GUI_SendKeyMsg(_aKey[10], 1); /* Send a key message to the focussed window */ |
destinyXfate | 0:08606a13a816 | 2394 | break; |
destinyXfate | 0:08606a13a816 | 2395 | } |
destinyXfate | 0:08606a13a816 | 2396 | break; |
destinyXfate | 0:08606a13a816 | 2397 | case GUI_ID_USER + 11: // Notifications sent by 'button ' |
destinyXfate | 0:08606a13a816 | 2398 | switch (NCode) { |
destinyXfate | 0:08606a13a816 | 2399 | case WM_NOTIFICATION_RELEASED: |
destinyXfate | 0:08606a13a816 | 2400 | GUI_SendKeyMsg(_aKey[11], 1); /* Send a key message to the focussed window */ |
destinyXfate | 0:08606a13a816 | 2401 | break; |
destinyXfate | 0:08606a13a816 | 2402 | } |
destinyXfate | 0:08606a13a816 | 2403 | break; |
destinyXfate | 0:08606a13a816 | 2404 | case GUI_ID_USER + 12: // Notifications sent by 'button Enter' |
destinyXfate | 0:08606a13a816 | 2405 | switch (NCode) { |
destinyXfate | 0:08606a13a816 | 2406 | case WM_NOTIFICATION_RELEASED: |
destinyXfate | 0:08606a13a816 | 2407 | |
destinyXfate | 0:08606a13a816 | 2408 | hEdit_MotorID = WM_GetDialogItem(pMsg->hWin, GUI_ID_USER + 24); |
destinyXfate | 0:08606a13a816 | 2409 | EDIT_GetText(hEdit_MotorID, MotorID, 10); |
destinyXfate | 0:08606a13a816 | 2410 | |
destinyXfate | 0:08606a13a816 | 2411 | hEdit_Volts = WM_GetDialogItem(pMsg->hWin, GUI_ID_USER + 25); |
destinyXfate | 0:08606a13a816 | 2412 | EDIT_GetText(hEdit_Volts, Volts, 10); |
destinyXfate | 0:08606a13a816 | 2413 | |
destinyXfate | 0:08606a13a816 | 2414 | hEdit_Amps = WM_GetDialogItem(pMsg->hWin, GUI_ID_USER + 26); |
destinyXfate | 0:08606a13a816 | 2415 | EDIT_GetText(hEdit_Amps, Amps, 10); |
destinyXfate | 0:08606a13a816 | 2416 | |
destinyXfate | 0:08606a13a816 | 2417 | hEdit_HP = WM_GetDialogItem(pMsg->hWin, GUI_ID_USER + 27); |
destinyXfate | 0:08606a13a816 | 2418 | EDIT_GetText(hEdit_HP, HP, 10); |
destinyXfate | 0:08606a13a816 | 2419 | |
destinyXfate | 0:08606a13a816 | 2420 | hEdit_Poles = WM_GetDialogItem(pMsg->hWin, GUI_ID_USER + 28); |
destinyXfate | 0:08606a13a816 | 2421 | EDIT_GetText(hEdit_Poles, Poles, 10); |
destinyXfate | 0:08606a13a816 | 2422 | |
destinyXfate | 0:08606a13a816 | 2423 | hEdit_RPM = WM_GetDialogItem(pMsg->hWin, GUI_ID_USER + 29); |
destinyXfate | 0:08606a13a816 | 2424 | EDIT_GetText(hEdit_RPM, RPM, 10); |
destinyXfate | 0:08606a13a816 | 2425 | |
destinyXfate | 0:08606a13a816 | 2426 | hEdit_IPADR = WM_GetDialogItem(pMsg->hWin, GUI_ID_USER + 30); |
destinyXfate | 0:08606a13a816 | 2427 | EDIT_GetText(hEdit_IPADR, IPADR, 20); |
destinyXfate | 0:08606a13a816 | 2428 | |
destinyXfate | 0:08606a13a816 | 2429 | hEdit_Netmask = WM_GetDialogItem(pMsg->hWin, GUI_ID_USER + 31); |
destinyXfate | 0:08606a13a816 | 2430 | EDIT_GetText(hEdit_Netmask, Netmask, 20); |
destinyXfate | 0:08606a13a816 | 2431 | |
destinyXfate | 0:08606a13a816 | 2432 | hEdit_Gateway = WM_GetDialogItem(pMsg->hWin, GUI_ID_USER + 32); |
destinyXfate | 0:08606a13a816 | 2433 | EDIT_GetText(hEdit_Gateway, Gateway, 20); |
destinyXfate | 0:08606a13a816 | 2434 | |
destinyXfate | 0:08606a13a816 | 2435 | |
destinyXfate | 0:08606a13a816 | 2436 | |
destinyXfate | 0:08606a13a816 | 2437 | WM_HWIN hRADIO = WM_GetDialogItem(pMsg->hWin, ID_RADIO_0); |
destinyXfate | 0:08606a13a816 | 2438 | |
destinyXfate | 0:08606a13a816 | 2439 | if(j<1) { |
destinyXfate | 0:08606a13a816 | 2440 | switch (RADIO_GetValue(hRADIO)) { |
destinyXfate | 0:08606a13a816 | 2441 | case 0: |
destinyXfate | 0:08606a13a816 | 2442 | eth.init(); |
destinyXfate | 0:08606a13a816 | 2443 | j++; |
destinyXfate | 0:08606a13a816 | 2444 | break; |
destinyXfate | 0:08606a13a816 | 2445 | case 1: |
destinyXfate | 0:08606a13a816 | 2446 | eth.init(IP, MASK, GATEWAY); |
destinyXfate | 0:08606a13a816 | 2447 | j++; |
destinyXfate | 0:08606a13a816 | 2448 | break; |
destinyXfate | 0:08606a13a816 | 2449 | } |
destinyXfate | 0:08606a13a816 | 2450 | } |
destinyXfate | 0:08606a13a816 | 2451 | |
destinyXfate | 0:08606a13a816 | 2452 | break; |
destinyXfate | 0:08606a13a816 | 2453 | } |
destinyXfate | 0:08606a13a816 | 2454 | break; |
destinyXfate | 0:08606a13a816 | 2455 | case GUI_ID_USER + 13: // Notifications sent by 'button Analysis' |
destinyXfate | 0:08606a13a816 | 2456 | switch (NCode) { |
destinyXfate | 0:08606a13a816 | 2457 | case WM_NOTIFICATION_RELEASED: |
destinyXfate | 0:08606a13a816 | 2458 | hItem = GUI_CreateDialogBox(_aADCPage, GUI_COUNTOF(_aADCPage), _cbADCPage, WM_HBKWIN, 0, 0); |
destinyXfate | 0:08606a13a816 | 2459 | break; |
destinyXfate | 0:08606a13a816 | 2460 | } |
destinyXfate | 0:08606a13a816 | 2461 | break; |
destinyXfate | 0:08606a13a816 | 2462 | } |
destinyXfate | 0:08606a13a816 | 2463 | break; |
destinyXfate | 0:08606a13a816 | 2464 | |
destinyXfate | 0:08606a13a816 | 2465 | default: |
destinyXfate | 0:08606a13a816 | 2466 | WM_DefaultProc(pMsg); |
destinyXfate | 0:08606a13a816 | 2467 | } |
destinyXfate | 0:08606a13a816 | 2468 | } |
destinyXfate | 0:08606a13a816 | 2469 | |
destinyXfate | 0:08606a13a816 | 2470 | |
destinyXfate | 0:08606a13a816 | 2471 | |
destinyXfate | 0:08606a13a816 | 2472 | |
destinyXfate | 0:08606a13a816 | 2473 | /********************************************************************* |
destinyXfate | 0:08606a13a816 | 2474 | * |
destinyXfate | 0:08606a13a816 | 2475 | * Public code |
destinyXfate | 0:08606a13a816 | 2476 | * |
destinyXfate | 0:08606a13a816 | 2477 | ********************************************************************** |
destinyXfate | 0:08606a13a816 | 2478 | */ |
destinyXfate | 0:08606a13a816 | 2479 | |
destinyXfate | 0:08606a13a816 | 2480 | |
destinyXfate | 0:08606a13a816 | 2481 | WM_HWIN CreateMotor_Monitoring_Embedded(void); |
destinyXfate | 0:08606a13a816 | 2482 | WM_HWIN CreateMotor_Monitoring_Embedded(void) |
destinyXfate | 0:08606a13a816 | 2483 | { |
destinyXfate | 0:08606a13a816 | 2484 | WM_HWIN hWin; |
destinyXfate | 0:08606a13a816 | 2485 | |
destinyXfate | 0:08606a13a816 | 2486 | hWin = GUI_CreateDialogBox(_aMainPage, GUI_COUNTOF(_aMainPage), _cbMainPage, WM_HBKWIN, 0, 0); |
destinyXfate | 0:08606a13a816 | 2487 | return hWin; |
destinyXfate | 0:08606a13a816 | 2488 | } |
destinyXfate | 0:08606a13a816 | 2489 | |
destinyXfate | 0:08606a13a816 | 2490 | // USER START (Optionally insert additional public code) |
destinyXfate | 0:08606a13a816 | 2491 | void MainTask(void); |
destinyXfate | 0:08606a13a816 | 2492 | void MainTask(void) |
destinyXfate | 0:08606a13a816 | 2493 | { |
destinyXfate | 0:08606a13a816 | 2494 | |
destinyXfate | 0:08606a13a816 | 2495 | GUI_Init(); |
destinyXfate | 0:08606a13a816 | 2496 | |
destinyXfate | 0:08606a13a816 | 2497 | FRAMEWIN_SetDefaultFont(GUI_FONT_20B_ASCII); |
destinyXfate | 0:08606a13a816 | 2498 | FRAMEWIN_SetDefaultTextColor(0, GUI_BLACK); |
destinyXfate | 0:08606a13a816 | 2499 | FRAMEWIN_SetDefaultTextColor(1, GUI_BLACK); |
destinyXfate | 0:08606a13a816 | 2500 | FRAMEWIN_SetDefaultTextAlign(GUI_TA_HCENTER | GUI_TA_VCENTER); |
destinyXfate | 0:08606a13a816 | 2501 | FRAMEWIN_SetDefaultSkin(FRAMEWIN_SKIN_FLEX); |
destinyXfate | 0:08606a13a816 | 2502 | TEXT_SetDefaultFont(GUI_FONT_20B_ASCII); |
destinyXfate | 0:08606a13a816 | 2503 | BUTTON_SetDefaultSkin(BUTTON_SKIN_FLEX); |
destinyXfate | 0:08606a13a816 | 2504 | BUTTON_SetDefaultFont(GUI_FONT_20B_ASCII); |
destinyXfate | 0:08606a13a816 | 2505 | SCROLLBAR_SetDefaultSkin(SCROLLBAR_SKIN_FLEX); |
destinyXfate | 0:08606a13a816 | 2506 | |
destinyXfate | 0:08606a13a816 | 2507 | CreateMotor_Monitoring_Embedded(); |
destinyXfate | 0:08606a13a816 | 2508 | |
destinyXfate | 0:08606a13a816 | 2509 | while(1) { |
destinyXfate | 0:08606a13a816 | 2510 | |
destinyXfate | 0:08606a13a816 | 2511 | GUI_Delay(500); |
destinyXfate | 0:08606a13a816 | 2512 | } |
destinyXfate | 0:08606a13a816 | 2513 | } |
destinyXfate | 0:08606a13a816 | 2514 | // USER END |
destinyXfate | 0:08606a13a816 | 2515 | |
destinyXfate | 0:08606a13a816 | 2516 | /*************************** End of file ****************************/ |
destinyXfate | 0:08606a13a816 | 2517 |