LU CHIN-HE / Motor

Dependencies:   DMSupport DMemWin

Fork of Motor_Embedded_3rd_emwin by Wei Chang Shen

Committer:
destinyXfate
Date:
Thu Jun 02 05:04:57 2016 +0000
Revision:
0:08606a13a816
Child:
1:c6b089f4ff2a
;

Who changed what in which revision?

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