Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: DMBasicGUI DMSupport
NudgeAndDampPageHandler.cpp
00001 #include "NudgeAndDampPageHandler.h" 00002 #include "EasyGUITouchAreaIndices.h" 00003 #include "GetGCStatusLoop.h" 00004 #include "NumericKeypadPageHandler.h" 00005 #include "USBHostGCUtilities.h" 00006 00007 /* 00008 Static function to tell the caller whether or not the specified easyGUI page is one of the "Nudge and Damp" pages, 00009 and therefore one that this class handles. (All the other "xxxPageHandler" classes handle one page only.) 00010 00011 Static so that the caller does not have to get/create the "NudgeAndDampPageHandler" instance 00012 until it knows that the page needs to be handled by this class. 00013 00014 Args: the number of the page in question 00015 00016 Returns true if it is a nudge and damp page, false otherwise 00017 */ 00018 bool NudgeAndDampPageHandler::PageIsANudgeAndDampPage(int pageNumber) 00019 { 00020 return ((pageNumber == GuiStruct_ColumnOvenNudgeAndDampPage_0) 00021 || (pageNumber == GuiStruct_ColumnDHNudgeAndDampPage_0) 00022 || (pageNumber == GuiStruct_InjectorNudgeAndDampPage_0) 00023 || (pageNumber == GuiStruct_DetectorNudgeAndDampPage_0) 00024 || (pageNumber == GuiStruct_AuxiliaryNudgeAndDampPage_0) 00025 || (pageNumber == GuiStruct_FanPowerPage_0)); 00026 } 00027 00028 00029 /* 00030 Note that this class is a singleton - we do not need or want there to be more than one instance of it 00031 (we do not want multiple values for the same nudge and damp parameters, etc, nor will we show 00032 more than one easyGUI page to the user at the same time). 00033 */ 00034 NudgeAndDampPageHandler * NudgeAndDampPageHandler::theNudgeAndDampPageHandlerInstance = NULL; 00035 00036 00037 /* 00038 Singleton class - return the one and only instance, first creating it if necessary. 00039 */ 00040 NudgeAndDampPageHandler * NudgeAndDampPageHandler::GetInstance(USBDeviceConnected* newUsbDevice, USBHostGC* newUsbHostGC) 00041 { 00042 if (theNudgeAndDampPageHandlerInstance == NULL) { 00043 theNudgeAndDampPageHandlerInstance = new NudgeAndDampPageHandler(newUsbDevice, newUsbHostGC); 00044 } 00045 00046 return theNudgeAndDampPageHandlerInstance; 00047 } 00048 00049 /* 00050 Overriden version of the above, that does not take any arguments and does not create the instance 00051 if it does not already exist. 00052 00053 Provided for callers that do not have the 'usbDevice' and 'usbHostGC' pointers, and just want access 00054 to the instance if it exists 00055 */ 00056 NudgeAndDampPageHandler * NudgeAndDampPageHandler::GetInstance(void) 00057 { 00058 return theNudgeAndDampPageHandlerInstance; 00059 } 00060 00061 00062 // Singleton class - private constructor 00063 NudgeAndDampPageHandler::NudgeAndDampPageHandler(USBDeviceConnected* newUsbDevice, USBHostGC* newUsbHostGC) 00064 { 00065 usbDevice = newUsbDevice; 00066 usbHostGC = newUsbHostGC; 00067 00068 00069 variablesForTouchArea[0].touchAreaIndex = COLUMN_OVEN_NUDGE_FACTOR_EDIT; 00070 variablesForTouchArea[0].easyGUIVariablePtr = GuiVar_columnOvenNudgeFactor; 00071 variablesForTouchArea[0].maxValue = 2550; 00072 variablesForTouchArea[0].easyGUICallingPage = GuiStruct_ColumnOvenNudgeAndDampPage_0; 00073 strcpy(variablesForTouchArea[0].variableTitle, "Nudge"); 00074 00075 variablesForTouchArea[1].touchAreaIndex = COLUMN_OVEN_DAMP_FACTOR_EDIT; 00076 variablesForTouchArea[1].easyGUIVariablePtr = GuiVar_columnOvenDampFactor; 00077 variablesForTouchArea[1].maxValue = 2550; 00078 variablesForTouchArea[1].easyGUICallingPage = GuiStruct_ColumnOvenNudgeAndDampPage_0; 00079 strcpy(variablesForTouchArea[1].variableTitle, "Damp"); 00080 00081 variablesForTouchArea[2].touchAreaIndex = COLUMN_OVEN_RAMP_NUDGE_FACTOR_EDIT; 00082 variablesForTouchArea[2].easyGUIVariablePtr = GuiVar_columnOvenRampNudgeFactor; 00083 variablesForTouchArea[2].maxValue = 2550; 00084 variablesForTouchArea[2].easyGUICallingPage = GuiStruct_ColumnOvenNudgeAndDampPage_0; 00085 strcpy(variablesForTouchArea[2].variableTitle, "Ramp Nudge"); 00086 00087 variablesForTouchArea[3].touchAreaIndex = COLUMN_OVEN_RAMP_DAMP_FACTOR_EDIT; 00088 variablesForTouchArea[3].easyGUIVariablePtr = GuiVar_columnOvenRampDampFactor; 00089 variablesForTouchArea[3].maxValue = 2550; 00090 variablesForTouchArea[3].easyGUICallingPage = GuiStruct_ColumnOvenNudgeAndDampPage_0; 00091 strcpy(variablesForTouchArea[3].variableTitle, "Ramp Damp"); 00092 00093 variablesForTouchArea[4].touchAreaIndex = COLUMN_OVEN_TEMP_OFFSET_EDIT; 00094 variablesForTouchArea[4].easyGUIVariablePtr = GuiVar_columnOvenTempOffset; 00095 variablesForTouchArea[4].maxValue = 2550; 00096 variablesForTouchArea[4].easyGUICallingPage = GuiStruct_ColumnOvenNudgeAndDampPage_0; 00097 strcpy(variablesForTouchArea[4].variableTitle, "Temp. Offset"); 00098 00099 variablesForTouchArea[5].touchAreaIndex = COLUMN_DH_NUDGE_FACTOR_EDIT; 00100 variablesForTouchArea[5].easyGUIVariablePtr = GuiVar_columnDHNudgeFactor; 00101 variablesForTouchArea[5].maxValue = 2550; 00102 variablesForTouchArea[5].easyGUICallingPage = GuiStruct_ColumnDHNudgeAndDampPage_0; 00103 strcpy(variablesForTouchArea[5].variableTitle, "DH Col. Nudge"); 00104 00105 variablesForTouchArea[6].touchAreaIndex = COLUMN_DH_DAMP_FACTOR_EDIT; 00106 variablesForTouchArea[6].easyGUIVariablePtr = GuiVar_columnDHDampFactor; 00107 variablesForTouchArea[6].maxValue = 2550; 00108 variablesForTouchArea[6].easyGUICallingPage = GuiStruct_ColumnDHNudgeAndDampPage_0; 00109 strcpy(variablesForTouchArea[6].variableTitle, "DH Col. Damp"); 00110 00111 variablesForTouchArea[7].touchAreaIndex = COLUMN_DH_RAMP_NUDGE_FACTOR_EDIT; 00112 variablesForTouchArea[7].easyGUIVariablePtr = GuiVar_columnDHRampNudgeFactor; 00113 variablesForTouchArea[7].maxValue = 2550; 00114 variablesForTouchArea[7].easyGUICallingPage = GuiStruct_ColumnDHNudgeAndDampPage_0; 00115 strcpy(variablesForTouchArea[7].variableTitle, "DH Ramp Nudge"); 00116 00117 variablesForTouchArea[8].touchAreaIndex = COLUMN_DH_RAMP_DAMP_FACTOR_EDIT; 00118 variablesForTouchArea[8].easyGUIVariablePtr = GuiVar_columnDHRampDampFactor; 00119 variablesForTouchArea[8].maxValue = 2550; 00120 variablesForTouchArea[8].easyGUICallingPage = GuiStruct_ColumnDHNudgeAndDampPage_0; 00121 strcpy(variablesForTouchArea[8].variableTitle, "DH Ramp Damp"); 00122 00123 variablesForTouchArea[9].touchAreaIndex = INJECTOR_NUDGE_FACTOR_EDIT; 00124 variablesForTouchArea[9].easyGUIVariablePtr = GuiVar_injectorNudgeFactor; 00125 variablesForTouchArea[9].maxValue = 2550; 00126 variablesForTouchArea[9].easyGUICallingPage = GuiStruct_InjectorNudgeAndDampPage_0; 00127 strcpy(variablesForTouchArea[9].variableTitle, "Inj. Nudge"); 00128 00129 variablesForTouchArea[10].touchAreaIndex = INJECTOR_DAMP_FACTOR_EDIT; 00130 variablesForTouchArea[10].easyGUIVariablePtr = GuiVar_injectorDampFactor; 00131 variablesForTouchArea[10].maxValue = 2550; 00132 variablesForTouchArea[10].easyGUICallingPage = GuiStruct_InjectorNudgeAndDampPage_0; 00133 strcpy(variablesForTouchArea[10].variableTitle, "Inj. Damp"); 00134 00135 variablesForTouchArea[11].touchAreaIndex = DETECTOR_NUDGE_FACTOR_EDIT; 00136 variablesForTouchArea[11].easyGUIVariablePtr = GuiVar_detectorNudgeFactor; 00137 variablesForTouchArea[11].maxValue = 2550; 00138 variablesForTouchArea[11].easyGUICallingPage = GuiStruct_DetectorNudgeAndDampPage_0; 00139 strcpy(variablesForTouchArea[11].variableTitle, "Det. Nudge"); 00140 00141 variablesForTouchArea[12].touchAreaIndex = DETECTOR_DAMP_FACTOR_EDIT; 00142 variablesForTouchArea[12].easyGUIVariablePtr = GuiVar_detectorDampFactor; 00143 variablesForTouchArea[12].maxValue = 2550; 00144 variablesForTouchArea[12].easyGUICallingPage = GuiStruct_DetectorNudgeAndDampPage_0; 00145 strcpy(variablesForTouchArea[12].variableTitle, "Det. Damp"); 00146 00147 variablesForTouchArea[13].touchAreaIndex = AUXILIARY_NUDGE_FACTOR_EDIT; 00148 variablesForTouchArea[13].easyGUIVariablePtr = GuiVar_auxiliaryNudgeFactor; 00149 variablesForTouchArea[13].maxValue = 2550; 00150 variablesForTouchArea[13].easyGUICallingPage = GuiStruct_AuxiliaryNudgeAndDampPage_0; 00151 strcpy(variablesForTouchArea[13].variableTitle, "Aux. Nudge"); 00152 00153 variablesForTouchArea[14].touchAreaIndex = AUXILIARY_DAMP_FACTOR_EDIT; 00154 variablesForTouchArea[14].easyGUIVariablePtr = GuiVar_auxiliaryDampFactor; 00155 variablesForTouchArea[14].maxValue = 2550; 00156 variablesForTouchArea[14].easyGUICallingPage = GuiStruct_AuxiliaryNudgeAndDampPage_0; 00157 strcpy(variablesForTouchArea[14].variableTitle, "Aux. Damp"); 00158 00159 variablesForTouchArea[15].touchAreaIndex = FAN_POWER_NORMAL_EDIT; 00160 variablesForTouchArea[15].easyGUIVariablePtr = GuiVar_fanPowerNormal; 00161 variablesForTouchArea[15].maxValue = 255; 00162 variablesForTouchArea[15].easyGUICallingPage = GuiStruct_FanPowerPage_0; 00163 strcpy(variablesForTouchArea[15].variableTitle, "Fan Normal"); 00164 00165 variablesForTouchArea[16].touchAreaIndex = FAN_POWER_COOLING_EDIT; 00166 variablesForTouchArea[16].easyGUIVariablePtr = GuiVar_fanPowerCooling; 00167 variablesForTouchArea[16].maxValue = 255; 00168 variablesForTouchArea[16].easyGUICallingPage = GuiStruct_FanPowerPage_0; 00169 strcpy(variablesForTouchArea[16].variableTitle, "Fan Cooling"); 00170 00171 variablesForTouchArea[17].touchAreaIndex = FAN_POWER_DH_CALIB_EDIT; 00172 variablesForTouchArea[17].easyGUIVariablePtr = GuiVar_fanPowerDHCalibration; 00173 variablesForTouchArea[17].maxValue = 255; 00174 variablesForTouchArea[17].easyGUICallingPage = GuiStruct_FanPowerPage_0; 00175 strcpy(variablesForTouchArea[17].variableTitle, "Fan DH Calib"); 00176 00177 variablesForTouchArea[18].touchAreaIndex = FAN_POWER_MINIMUM_EDIT; 00178 variablesForTouchArea[18].easyGUIVariablePtr = GuiVar_fanPowerMinimum; 00179 variablesForTouchArea[18].maxValue = 255; 00180 variablesForTouchArea[18].easyGUICallingPage = GuiStruct_FanPowerPage_0; 00181 strcpy(variablesForTouchArea[18].variableTitle, "Fan Minimum"); 00182 } 00183 00184 00185 // Private destructor also 00186 NudgeAndDampPageHandler::~NudgeAndDampPageHandler() 00187 { 00188 } 00189 00190 00191 /* 00192 Tells the caller whether or not the specified touch index is on one of the easyGUI Nudge and Damp pages, 00193 and therefore needs to be handled by this class. 00194 00195 Args: the touch area index in question 00196 00197 Return code: true if the touch area is 'one of ours', false if not 00198 */ 00199 bool NudgeAndDampPageHandler::TouchAreaIsOnNudgeAndDampPage(int touchAreaIndex) 00200 { 00201 if((touchAreaIndex >= MIN_COLUMN_OVEN_NUDGE_AND_DAMP_TOUCHINDEX) && (touchAreaIndex <= MAX_COLUMN_OVEN_NUDGE_AND_DAMP_TOUCHINDEX)) { 00202 return true; 00203 } 00204 00205 if((touchAreaIndex >= MIN_COLUMN_DH_NUDGE_AND_DAMP_TOUCHINDEX) && (touchAreaIndex <= MAX_COLUMN_DH_NUDGE_AND_DAMP_TOUCHINDEX)) { 00206 return true; 00207 } 00208 00209 if((touchAreaIndex >= MIN_INJECTOR_NUDGE_AND_DAMP_TOUCHINDEX) && (touchAreaIndex <= MAX_INJECTOR_NUDGE_AND_DAMP_TOUCHINDEX)) { 00210 return true; 00211 } 00212 00213 if((touchAreaIndex >= MIN_DETECTOR_NUDGE_AND_DAMP_TOUCHINDEX) && (touchAreaIndex <= MAX_DETECTOR_NUDGE_AND_DAMP_TOUCHINDEX)) { 00214 return true; 00215 } 00216 00217 if((touchAreaIndex >= MIN_AUXILIARY_NUDGE_AND_DAMP_TOUCHINDEX) && (touchAreaIndex <= MAX_AUXILIARY_NUDGE_AND_DAMP_TOUCHINDEX)) { 00218 return true; 00219 } 00220 00221 if((touchAreaIndex >= MIN_FAN_POWER_TOUCHINDEX) && (touchAreaIndex <= MAX_FAN_POWER_TOUCHINDEX)) { 00222 return true; 00223 } 00224 00225 // 'else' 00226 return false; 00227 } 00228 00229 00230 /* 00231 If the specified touch area represents a key or field on one of the easyGUI Nudge and Damp pages, 00232 this function performs whatever action is appropriate for it. Provided so that the caller 00233 can (in effect) say "if this is one of yours, deal with it", without needing to know 00234 anything about what this class does, or how it handles the touch areas on that easyGUI page. 00235 00236 Args: the touch area index in question 00237 00238 Returns true if it dealt with the touch area (so the caller need not do anything else 00239 with the value), or false if it did not deal with the touch area (implying that it 00240 was not a touch area on an easyGUI Nudge and Damp page, and so the caller 00241 must deal with it some other way). 00242 */ 00243 bool NudgeAndDampPageHandler::DealWithTouch(int touchAreaIndex) 00244 { 00245 // TODO: if 'touchAreaIndex' is one of the areas handled by this class, 00246 // deal with it 00247 00248 // Has the user selected a field to edit - 00249 // if so, we will have an entry in our 'variablesForTouchArea' array that corresponds with this touch area 00250 int indexOfValueToEdit = GetIndexOfValueToEditForTouchArea(touchAreaIndex); 00251 if(indexOfValueToEdit != -1) { 00252 // User has selected a field to edit 00253 NumericKeypadPageHandler* numericKeypadPageHandler = NumericKeypadPageHandler::GetInstance(usbDevice, usbHostGC); 00254 if(numericKeypadPageHandler != NULL) { 00255 numericKeypadPageHandler->StartEditing(variablesForTouchArea[indexOfValueToEdit].easyGUIVariablePtr); 00256 numericKeypadPageHandler->SetEasyGUIVariableToEdit(variablesForTouchArea[indexOfValueToEdit].easyGUIVariablePtr); 00257 numericKeypadPageHandler->SetEasyGUICallingPage(variablesForTouchArea[indexOfValueToEdit].easyGUICallingPage); 00258 numericKeypadPageHandler->SetEditVariableRange(0, variablesForTouchArea[indexOfValueToEdit].maxValue); 00259 numericKeypadPageHandler->SetEditVariableName(variablesForTouchArea[indexOfValueToEdit].variableTitle); 00260 numericKeypadPageHandler->DisplayEasyGUIPage(); 00261 } 00262 00263 return true; 00264 } 00265 00266 00267 if(touchAreaIndex == COLUMN_OVEN_NUDGE_AND_DAMP_GET) { 00268 GetColumnOvenNudgeAndDampFactorsFromGC(); 00269 return true; 00270 } 00271 00272 if(touchAreaIndex == COLUMN_DH_NUDGE_AND_DAMP_GET) { 00273 GetColumnDHNudgeAndDampFactorsFromGC(); 00274 return true; 00275 } 00276 00277 if(touchAreaIndex == INJECTOR_NUDGE_AND_DAMP_GET) { 00278 GetInjectorNudgeAndDampFactorsFromGC(); 00279 return true; 00280 } 00281 00282 if(touchAreaIndex == DETECTOR_NUDGE_AND_DAMP_GET) { 00283 GetDetectorNudgeAndDampFactorsFromGC(); 00284 return true; 00285 } 00286 00287 if(touchAreaIndex == AUXILIARY_NUDGE_AND_DAMP_GET) { 00288 GetAuxiliaryNudgeAndDampFactorsFromGC(); 00289 return true; 00290 } 00291 00292 if(touchAreaIndex == FAN_POWER_GET) { 00293 GetFanPowerValuesFromGC(); 00294 return true; 00295 } 00296 00297 if(touchAreaIndex == COLUMN_OVEN_NUDGE_AND_DAMP_SET) { 00298 SetColumnOvenNudgeAndDampFactorsInGC(); 00299 return true; 00300 } 00301 00302 if(touchAreaIndex == COLUMN_DH_NUDGE_AND_DAMP_SET) { 00303 SetColumnDHNudgeAndDampFactorsInGC(); 00304 return true; 00305 } 00306 00307 if(touchAreaIndex == INJECTOR_NUDGE_AND_DAMP_SET) { 00308 SetInjectorNudgeAndDampFactorsInGC(); 00309 return true; 00310 } 00311 00312 if(touchAreaIndex == DETECTOR_NUDGE_AND_DAMP_SET) { 00313 SetDetectorNudgeAndDampFactorsInGC(); 00314 return true; 00315 } 00316 00317 if(touchAreaIndex == AUXILIARY_NUDGE_AND_DAMP_SET) { 00318 SetAuxiliaryNudgeAndDampFactorsInGC(); 00319 return true; 00320 } 00321 00322 if(touchAreaIndex == FAN_POWER_SET) { 00323 SetFanPowerValuesInGC(); 00324 return true; 00325 } 00326 00327 // 'else'... 00328 00329 return false; 00330 } 00331 00332 00333 /* 00334 Caller is telling us it is about to display one of the easyGUI Nudge and Damp pages, 00335 and that we should do whatever we have to do to get it ready, before the caller displays it. 00336 00337 No arguments, no return code 00338 */ 00339 void NudgeAndDampPageHandler::DisplayingEasyGUIPage(int pageNumber, bool updateEasyGUIVariables) 00340 { 00341 // TODO: if 'updateEasyGUIVariables' is true, update the easyGUI variables for that page 00342 00343 if(updateEasyGUIVariables) { 00344 if(pageNumber == GuiStruct_ColumnOvenNudgeAndDampPage_0) { 00345 GetColumnOvenNudgeAndDampFactorsFromGC(); 00346 } 00347 else if(pageNumber == GuiStruct_ColumnDHNudgeAndDampPage_0) { 00348 GetColumnDHNudgeAndDampFactorsFromGC(); 00349 } 00350 else if(pageNumber == GuiStruct_InjectorNudgeAndDampPage_0) { 00351 GetInjectorNudgeAndDampFactorsFromGC(); 00352 } 00353 else if (pageNumber == GuiStruct_DetectorNudgeAndDampPage_0) { 00354 GetDetectorNudgeAndDampFactorsFromGC(); 00355 } 00356 else if (pageNumber == GuiStruct_AuxiliaryNudgeAndDampPage_0) { 00357 GetAuxiliaryNudgeAndDampFactorsFromGC(); 00358 } 00359 else if (pageNumber == GuiStruct_FanPowerPage_0) { 00360 GetFanPowerValuesFromGC(); 00361 } 00362 } 00363 } 00364 00365 00366 /* 00367 As the name implies, sends a command to the GC and returns the response. 00368 00369 Args: pointer to a buffer containing the command, as a null-terminated string 00370 pointer to a buffer to contain the response, as a null-terminated string 00371 00372 No return code (it is up to the caller to examine the response to see whether 00373 the command succeeded or failed) 00374 */ 00375 void NudgeAndDampPageHandler::SendCommandToGCAndGetResponse(char* command, char* response) 00376 { 00377 #define USE_GC_UTILS // Testing new class 00378 #ifdef USE_GC_UTILS 00379 USBHostGCUtilities::SendCommandToGCAndGetResponse(usbDevice, usbHostGC, command, response); 00380 #else 00381 while(usbHostGC->ExecutingSetDeviceReport()) {} 00382 00383 usbHostGC->SetDeviceReport(usbDevice, command, response); 00384 //#define DEBUG_PRINT_HERE 00385 #ifdef DEBUG_PRINT_HERE 00386 char dbg[100]; 00387 sprintf(dbg, "NDPH cmd \"%s\", response \"%s\"", command, response); 00388 SpecialDebugPrint(dbg, 10, 275); 00389 #endif // DEBUG_PRINT_HERE 00390 00391 #endif // USE_GC_UTILS 00392 } 00393 00394 00395 /* 00396 Sends a command to the GC for which we expect a response of "DACK" if successful, 00397 "DNAK" or "EPKT" if failure. 00398 00399 Args: a pointer to the command in question, as a null terminated string 00400 00401 Returns true if the GC responded with "DACK", false for anything else 00402 */ 00403 bool NudgeAndDampPageHandler::SendCommandToGCWithDACKResponse(char *cmd) 00404 { 00405 #define USE_GC_UTILS // Testing new class 00406 #ifdef USE_GC_UTILS 00407 return USBHostGCUtilities::SendCommandToGCWithDACKResponse(usbDevice, usbHostGC, cmd); 00408 #else 00409 char response[50]; 00410 SendCommandToGCAndGetResponse(cmd, response); 00411 // We expect a response like this: "DACK" for success, "DNAK" for failure, "EPKT" for error 00412 00413 return (response[1] == 'A'); 00414 #endif // USE_GC_UTILS 00415 } 00416 00417 00418 /* 00419 Gets a nudge or damp factor from the GC, and put its value into an easyGUI variable. 00420 It is up to the caller to display the updated variable to the user. 00421 00422 We use the same factor for nudge *and* damp, since the GC returns both values 00423 in the same format. 00424 00425 Args: a string, set to the command to get the value from the GC 00426 a pointer to the easyGUI variable to update 00427 00428 Returns true if successful, false if error 00429 */ 00430 bool NudgeAndDampPageHandler::GetNudgeOrDampFactorFromGC(char *cmd, GuiConst_TEXT* easyGUIVariable) 00431 { 00432 char response[50]; 00433 SendCommandToGCAndGetResponse(cmd, response); 00434 00435 if(response[0] != 'D') { 00436 return false; 00437 } 00438 00439 if(response[1] != cmd[1]) { 00440 return false; 00441 } 00442 00443 if(response[2] != cmd[2]) { 00444 return false; 00445 } 00446 00447 if(response[3] != cmd[3]) { 00448 return false; 00449 } 00450 00451 // OK so far... 00452 00453 response[8] = '\0'; // Ensure null terminator 00454 00455 // Need to remove leading zeroes, if any 00456 int factor; 00457 sscanf(&response[4], "%d", &factor); 00458 00459 sprintf(easyGUIVariable, "%d", factor); 00460 00461 return true; 00462 } 00463 00464 00465 /* 00466 Gets the current column oven nudge and damp factors from the GC, 00467 and copies them into the relevant easyGUI variables for display to the user. 00468 It is up to the caller to (re)display the Column Oven Nudge and Damp easyGUI page. 00469 00470 No arguments, no return code 00471 */ 00472 void NudgeAndDampPageHandler::GetColumnOvenNudgeAndDampFactorsFromGC(void) 00473 { 00474 GetNudgeOrDampFactorFromGC("GCNU", GuiVar_columnOvenNudgeFactor); 00475 GetNudgeOrDampFactorFromGC("GCDA", GuiVar_columnOvenDampFactor); 00476 GetNudgeOrDampFactorFromGC("GRNU", GuiVar_columnOvenRampNudgeFactor); 00477 GetNudgeOrDampFactorFromGC("GRDA", GuiVar_columnOvenRampDampFactor); 00478 GetNudgeOrDampFactorFromGC("GCTO", GuiVar_columnOvenTempOffset); 00479 } 00480 00481 00482 /* 00483 Gets the current directly heated column nudge and damp factors from the GC, 00484 and copies them into the relevant easyGUI variables for display to the user. 00485 It is up to the caller to (re)display the Column DH Nudge and Damp easyGUI page. 00486 00487 No arguments, no return code 00488 */ 00489 void NudgeAndDampPageHandler::GetColumnDHNudgeAndDampFactorsFromGC(void) 00490 { 00491 GetNudgeOrDampFactorFromGC("GHNU", GuiVar_columnDHNudgeFactor); 00492 GetNudgeOrDampFactorFromGC("GHDA", GuiVar_columnDHDampFactor); 00493 GetNudgeOrDampFactorFromGC("GHRN", GuiVar_columnDHRampNudgeFactor); 00494 GetNudgeOrDampFactorFromGC("GHRD", GuiVar_columnDHRampDampFactor); 00495 } 00496 00497 00498 /* 00499 Gets the current injector nudge and damp factors from the GC, 00500 and copies them into the relevant easyGUI variables for display to the user. 00501 It is up to the caller to (re)display the Injector Nudge and Damp easyGUI page. 00502 00503 No arguments, no return code 00504 */ 00505 void NudgeAndDampPageHandler::GetInjectorNudgeAndDampFactorsFromGC(void) 00506 { 00507 GetNudgeOrDampFactorFromGC("GINU", GuiVar_injectorNudgeFactor); 00508 GetNudgeOrDampFactorFromGC("GIDA", GuiVar_injectorDampFactor); 00509 } 00510 00511 00512 /* 00513 Gets the current detector nudge and damp factors from the GC, 00514 and copies them into the relevant easyGUI variables for display to the user. 00515 It is up to the caller to (re)display the Detector Nudge and Damp easyGUI page. 00516 00517 No arguments, no return code 00518 */ 00519 void NudgeAndDampPageHandler::GetDetectorNudgeAndDampFactorsFromGC(void) 00520 { 00521 GetNudgeOrDampFactorFromGC("GDNU", GuiVar_detectorNudgeFactor); 00522 GetNudgeOrDampFactorFromGC("GDDA", GuiVar_detectorDampFactor); 00523 } 00524 00525 00526 /* 00527 Gets the current auxiliary nudge and damp factors from the GC, 00528 and copies them into the relevant easyGUI variables for display to the user. 00529 It is up to the caller to (re)display the Auxiliary Nudge and Damp easyGUI page. 00530 00531 No arguments, no return code 00532 */ 00533 void NudgeAndDampPageHandler::GetAuxiliaryNudgeAndDampFactorsFromGC(void) 00534 { 00535 GetNudgeOrDampFactorFromGC("GANU", GuiVar_auxiliaryNudgeFactor); 00536 GetNudgeOrDampFactorFromGC("GADA", GuiVar_auxiliaryDampFactor); 00537 } 00538 00539 00540 /* 00541 Gets the current values for each fan power setting from the GC, 00542 and copies them into the relevant easyGUI variables for display to the user. 00543 It is up to the caller to (re)display the Fan Power easyGUI page. 00544 00545 No arguments, no return code 00546 */ 00547 void NudgeAndDampPageHandler::GetFanPowerValuesFromGC(void) 00548 { 00549 // The commands to get the fan power values are very similar to those for the nudge and damp factors 00550 GetNudgeOrDampFactorFromGC("GFNM", GuiVar_fanPowerNormal); 00551 GetNudgeOrDampFactorFromGC("GFCL", GuiVar_fanPowerCooling); 00552 GetNudgeOrDampFactorFromGC("GFCA", GuiVar_fanPowerDHCalibration); 00553 GetNudgeOrDampFactorFromGC("GFMI", GuiVar_fanPowerMinimum); 00554 } 00555 00556 00557 /* 00558 The commands to set the various nudge and damp factors are very similar. 00559 In particular the format of their data values is identical. This function sets the value in the GC 00560 using the specified command, using the value in the specified easyGUI variable. 00561 00562 Returns true if successful, false if not. 00563 */ 00564 bool NudgeAndDampPageHandler::SetNudgeOrDampFactorInGC(char *cmd, GuiConst_TEXT* easyGUIVariable) 00565 { 00566 char buffer[50]; 00567 00568 // In the command, the nudge/damp value must have 4 digits, padded if necessary with leading zeroes 00569 int factor; 00570 sscanf(easyGUIVariable, "%d", &factor); 00571 sprintf(buffer, "%s%.4d", cmd, factor); 00572 00573 return SendCommandToGCWithDACKResponse(buffer); 00574 } 00575 00576 00577 /* 00578 Sets the current column oven nudge and damp factors in the GC, 00579 using the values in the relevant easyGUI variables. 00580 00581 No arguments, no return code 00582 */ 00583 void NudgeAndDampPageHandler::SetColumnOvenNudgeAndDampFactorsInGC(void) 00584 { 00585 SetNudgeOrDampFactorInGC("SCNU", GuiVar_columnOvenNudgeFactor); 00586 SetNudgeOrDampFactorInGC("SCDA", GuiVar_columnOvenDampFactor); 00587 SetNudgeOrDampFactorInGC("SRNU", GuiVar_columnOvenRampNudgeFactor); 00588 SetNudgeOrDampFactorInGC("SRDA", GuiVar_columnOvenRampDampFactor); 00589 SetNudgeOrDampFactorInGC("SCTO", GuiVar_columnOvenTempOffset); 00590 } 00591 00592 00593 /* 00594 Sets the current directly heated column nudge and damp factors in the GC, 00595 using the values in the relevant easyGUI variables. 00596 00597 No arguments, no return code 00598 */ 00599 void NudgeAndDampPageHandler::SetColumnDHNudgeAndDampFactorsInGC(void) 00600 { 00601 SetNudgeOrDampFactorInGC("SHNU", GuiVar_columnDHNudgeFactor); 00602 SetNudgeOrDampFactorInGC("SHDA", GuiVar_columnDHDampFactor); 00603 SetNudgeOrDampFactorInGC("SHRN", GuiVar_columnDHRampNudgeFactor); 00604 SetNudgeOrDampFactorInGC("SHRD", GuiVar_columnDHRampDampFactor); 00605 } 00606 00607 00608 /* 00609 Sets the current injector nudge and damp factors in the GC, 00610 using the values in the relevant easyGUI variables. 00611 00612 No arguments, no return code 00613 */ 00614 void NudgeAndDampPageHandler::SetInjectorNudgeAndDampFactorsInGC(void) 00615 { 00616 SetNudgeOrDampFactorInGC("SINU", GuiVar_injectorNudgeFactor); 00617 SetNudgeOrDampFactorInGC("SIDA", GuiVar_injectorDampFactor); 00618 } 00619 00620 00621 /* 00622 Sets the current detector nudge and damp factors in the GC, 00623 using the values in the relevant easyGUI variables. 00624 00625 No arguments, no return code 00626 */ 00627 void NudgeAndDampPageHandler::SetDetectorNudgeAndDampFactorsInGC(void) 00628 { 00629 SetNudgeOrDampFactorInGC("SDNU", GuiVar_detectorNudgeFactor); 00630 SetNudgeOrDampFactorInGC("SDDA", GuiVar_detectorDampFactor); 00631 } 00632 00633 00634 /* 00635 Sets the current auxiliary nudge and damp factors in the GC, 00636 using the values in the relevant easyGUI variables. 00637 00638 No arguments, no return code 00639 */ 00640 void NudgeAndDampPageHandler::SetAuxiliaryNudgeAndDampFactorsInGC(void) 00641 { 00642 SetNudgeOrDampFactorInGC("SANU", GuiVar_auxiliaryNudgeFactor); 00643 SetNudgeOrDampFactorInGC("SADA", GuiVar_auxiliaryDampFactor); 00644 } 00645 00646 00647 /* 00648 Sets the current values for each fan power setting in the GC, 00649 using the values in the relevant easyGUI variables. 00650 00651 No arguments, no return code 00652 */ 00653 void NudgeAndDampPageHandler::SetFanPowerValuesInGC(void) 00654 { 00655 // The commands to set the fan power values are very similar to those for the nudge and damp factors 00656 SetNudgeOrDampFactorInGC("SFNM", GuiVar_fanPowerNormal); 00657 SetNudgeOrDampFactorInGC("SFCL", GuiVar_fanPowerCooling); 00658 SetNudgeOrDampFactorInGC("SFCA", GuiVar_fanPowerDHCalibration); 00659 SetNudgeOrDampFactorInGC("SFMI", GuiVar_fanPowerMinimum); 00660 } 00661 00662 00663 /* 00664 Tells the caller if the specified touch area corresponds to a value the user can edit 00665 on one of the easyGUI nudge and damp pages, and if so, which value it is. 00666 00667 Args: the touch area index in question 00668 00669 Returns the index of the corresponding entry in our 'variablesForTouchArea' array, 00670 or -1 if there is no such entry. It is up to the caller to check for -1 00671 ************************************** 00672 */ 00673 int NudgeAndDampPageHandler::GetIndexOfValueToEditForTouchArea(int touchAreaIndex) 00674 { 00675 for (int index = 0; index < COUNT_OF_VARIABLES_FOR_TOUCH_AREAS; ++index) { 00676 if(variablesForTouchArea[index].touchAreaIndex == touchAreaIndex) { 00677 return index; 00678 } 00679 } 00680 00681 // 'else' no nudge or damp factor corresponds to the specified touch area 00682 return -1; 00683 }
Generated on Tue Jul 19 2022 00:31:07 by
1.7.2