Repository for import to local machine

Dependencies:   DMBasicGUI DMSupport

Committer:
jmitc91516
Date:
Mon Jul 31 15:37:57 2017 +0000
Revision:
8:26e49e6955bd
Parent:
6:dba3fbdfd5da
Method ramp scrolling improved, and more bitmaps moved to QSPI memory

Who changed what in which revision?

UserRevisionLine numberNew contents of line
jmitc91516 1:a5258871b33d 1 #include "NudgeAndDampPageHandler.h"
jmitc91516 1:a5258871b33d 2 #include "EasyGUITouchAreaIndices.h"
jmitc91516 1:a5258871b33d 3 #include "GetGCStatusLoop.h"
jmitc91516 1:a5258871b33d 4 #include "NumericKeypadPageHandler.h"
jmitc91516 1:a5258871b33d 5 #include "USBHostGCUtilities.h"
jmitc91516 1:a5258871b33d 6
jmitc91516 1:a5258871b33d 7 /*
jmitc91516 1:a5258871b33d 8 Static function to tell the caller whether or not the specified easyGUI page is one of the "Nudge and Damp" pages,
jmitc91516 1:a5258871b33d 9 and therefore one that this class handles. (All the other "xxxPageHandler" classes handle one page only.)
jmitc91516 1:a5258871b33d 10
jmitc91516 1:a5258871b33d 11 Static so that the caller does not have to get/create the "NudgeAndDampPageHandler" instance
jmitc91516 1:a5258871b33d 12 until it knows that the page needs to be handled by this class.
jmitc91516 1:a5258871b33d 13
jmitc91516 1:a5258871b33d 14 Args: the number of the page in question
jmitc91516 1:a5258871b33d 15
jmitc91516 1:a5258871b33d 16 Returns true if it is a nudge and damp page, false otherwise
jmitc91516 1:a5258871b33d 17 */
jmitc91516 1:a5258871b33d 18 bool NudgeAndDampPageHandler::PageIsANudgeAndDampPage(int pageNumber)
jmitc91516 1:a5258871b33d 19 {
jmitc91516 1:a5258871b33d 20 return ((pageNumber == GuiStruct_ColumnOvenNudgeAndDampPage_0)
jmitc91516 1:a5258871b33d 21 || (pageNumber == GuiStruct_ColumnDHNudgeAndDampPage_0)
jmitc91516 1:a5258871b33d 22 || (pageNumber == GuiStruct_InjectorNudgeAndDampPage_0)
jmitc91516 1:a5258871b33d 23 || (pageNumber == GuiStruct_DetectorNudgeAndDampPage_0)
jmitc91516 1:a5258871b33d 24 || (pageNumber == GuiStruct_AuxiliaryNudgeAndDampPage_0)
jmitc91516 1:a5258871b33d 25 || (pageNumber == GuiStruct_FanPowerPage_0));
jmitc91516 1:a5258871b33d 26 }
jmitc91516 1:a5258871b33d 27
jmitc91516 1:a5258871b33d 28
jmitc91516 1:a5258871b33d 29 /*
jmitc91516 1:a5258871b33d 30 Note that this class is a singleton - we do not need or want there to be more than one instance of it
jmitc91516 1:a5258871b33d 31 (we do not want multiple values for the same nudge and damp parameters, etc, nor will we show
jmitc91516 1:a5258871b33d 32 more than one easyGUI page to the user at the same time).
jmitc91516 1:a5258871b33d 33 */
jmitc91516 1:a5258871b33d 34 NudgeAndDampPageHandler * NudgeAndDampPageHandler::theNudgeAndDampPageHandlerInstance = NULL;
jmitc91516 1:a5258871b33d 35
jmitc91516 1:a5258871b33d 36
jmitc91516 1:a5258871b33d 37 /*
jmitc91516 1:a5258871b33d 38 Singleton class - return the one and only instance, first creating it if necessary.
jmitc91516 1:a5258871b33d 39 */
jmitc91516 1:a5258871b33d 40 NudgeAndDampPageHandler * NudgeAndDampPageHandler::GetInstance(USBDeviceConnected* newUsbDevice, USBHostGC* newUsbHostGC)
jmitc91516 1:a5258871b33d 41 {
jmitc91516 1:a5258871b33d 42 if (theNudgeAndDampPageHandlerInstance == NULL) {
jmitc91516 1:a5258871b33d 43 theNudgeAndDampPageHandlerInstance = new NudgeAndDampPageHandler(newUsbDevice, newUsbHostGC);
jmitc91516 1:a5258871b33d 44 }
jmitc91516 1:a5258871b33d 45
jmitc91516 1:a5258871b33d 46 return theNudgeAndDampPageHandlerInstance;
jmitc91516 1:a5258871b33d 47 }
jmitc91516 1:a5258871b33d 48
jmitc91516 1:a5258871b33d 49 /*
jmitc91516 1:a5258871b33d 50 Overriden version of the above, that does not take any arguments and does not create the instance
jmitc91516 1:a5258871b33d 51 if it does not already exist.
jmitc91516 1:a5258871b33d 52
jmitc91516 1:a5258871b33d 53 Provided for callers that do not have the 'usbDevice' and 'usbHostGC' pointers, and just want access
jmitc91516 1:a5258871b33d 54 to the instance if it exists
jmitc91516 1:a5258871b33d 55 */
jmitc91516 1:a5258871b33d 56 NudgeAndDampPageHandler * NudgeAndDampPageHandler::GetInstance(void)
jmitc91516 1:a5258871b33d 57 {
jmitc91516 1:a5258871b33d 58 return theNudgeAndDampPageHandlerInstance;
jmitc91516 1:a5258871b33d 59 }
jmitc91516 1:a5258871b33d 60
jmitc91516 1:a5258871b33d 61
jmitc91516 1:a5258871b33d 62 // Singleton class - private constructor
jmitc91516 1:a5258871b33d 63 NudgeAndDampPageHandler::NudgeAndDampPageHandler(USBDeviceConnected* newUsbDevice, USBHostGC* newUsbHostGC)
jmitc91516 1:a5258871b33d 64 {
jmitc91516 1:a5258871b33d 65 usbDevice = newUsbDevice;
jmitc91516 1:a5258871b33d 66 usbHostGC = newUsbHostGC;
jmitc91516 1:a5258871b33d 67
jmitc91516 1:a5258871b33d 68
jmitc91516 1:a5258871b33d 69 variablesForTouchArea[0].touchAreaIndex = COLUMN_OVEN_NUDGE_FACTOR_EDIT;
jmitc91516 1:a5258871b33d 70 variablesForTouchArea[0].easyGUIVariablePtr = GuiVar_columnOvenNudgeFactor;
jmitc91516 1:a5258871b33d 71 variablesForTouchArea[0].maxValue = 2550;
jmitc91516 1:a5258871b33d 72 variablesForTouchArea[0].easyGUICallingPage = GuiStruct_ColumnOvenNudgeAndDampPage_0;
jmitc91516 6:dba3fbdfd5da 73 strcpy(variablesForTouchArea[0].variableTitle, "Nudge");
jmitc91516 1:a5258871b33d 74
jmitc91516 1:a5258871b33d 75 variablesForTouchArea[1].touchAreaIndex = COLUMN_OVEN_DAMP_FACTOR_EDIT;
jmitc91516 1:a5258871b33d 76 variablesForTouchArea[1].easyGUIVariablePtr = GuiVar_columnOvenDampFactor;
jmitc91516 1:a5258871b33d 77 variablesForTouchArea[1].maxValue = 2550;
jmitc91516 1:a5258871b33d 78 variablesForTouchArea[1].easyGUICallingPage = GuiStruct_ColumnOvenNudgeAndDampPage_0;
jmitc91516 6:dba3fbdfd5da 79 strcpy(variablesForTouchArea[1].variableTitle, "Damp");
jmitc91516 1:a5258871b33d 80
jmitc91516 1:a5258871b33d 81 variablesForTouchArea[2].touchAreaIndex = COLUMN_OVEN_RAMP_NUDGE_FACTOR_EDIT;
jmitc91516 1:a5258871b33d 82 variablesForTouchArea[2].easyGUIVariablePtr = GuiVar_columnOvenRampNudgeFactor;
jmitc91516 1:a5258871b33d 83 variablesForTouchArea[2].maxValue = 2550;
jmitc91516 1:a5258871b33d 84 variablesForTouchArea[2].easyGUICallingPage = GuiStruct_ColumnOvenNudgeAndDampPage_0;
jmitc91516 6:dba3fbdfd5da 85 strcpy(variablesForTouchArea[2].variableTitle, "Ramp Nudge");
jmitc91516 1:a5258871b33d 86
jmitc91516 1:a5258871b33d 87 variablesForTouchArea[3].touchAreaIndex = COLUMN_OVEN_RAMP_DAMP_FACTOR_EDIT;
jmitc91516 1:a5258871b33d 88 variablesForTouchArea[3].easyGUIVariablePtr = GuiVar_columnOvenRampDampFactor;
jmitc91516 1:a5258871b33d 89 variablesForTouchArea[3].maxValue = 2550;
jmitc91516 1:a5258871b33d 90 variablesForTouchArea[3].easyGUICallingPage = GuiStruct_ColumnOvenNudgeAndDampPage_0;
jmitc91516 6:dba3fbdfd5da 91 strcpy(variablesForTouchArea[3].variableTitle, "Ramp Damp");
jmitc91516 1:a5258871b33d 92
jmitc91516 1:a5258871b33d 93 variablesForTouchArea[4].touchAreaIndex = COLUMN_OVEN_TEMP_OFFSET_EDIT;
jmitc91516 1:a5258871b33d 94 variablesForTouchArea[4].easyGUIVariablePtr = GuiVar_columnOvenTempOffset;
jmitc91516 1:a5258871b33d 95 variablesForTouchArea[4].maxValue = 2550;
jmitc91516 1:a5258871b33d 96 variablesForTouchArea[4].easyGUICallingPage = GuiStruct_ColumnOvenNudgeAndDampPage_0;
jmitc91516 1:a5258871b33d 97 strcpy(variablesForTouchArea[4].variableTitle, "Temp. Offset");
jmitc91516 1:a5258871b33d 98
jmitc91516 1:a5258871b33d 99 variablesForTouchArea[5].touchAreaIndex = COLUMN_DH_NUDGE_FACTOR_EDIT;
jmitc91516 1:a5258871b33d 100 variablesForTouchArea[5].easyGUIVariablePtr = GuiVar_columnDHNudgeFactor;
jmitc91516 1:a5258871b33d 101 variablesForTouchArea[5].maxValue = 2550;
jmitc91516 1:a5258871b33d 102 variablesForTouchArea[5].easyGUICallingPage = GuiStruct_ColumnDHNudgeAndDampPage_0;
jmitc91516 1:a5258871b33d 103 strcpy(variablesForTouchArea[5].variableTitle, "DH Col. Nudge");
jmitc91516 1:a5258871b33d 104
jmitc91516 1:a5258871b33d 105 variablesForTouchArea[6].touchAreaIndex = COLUMN_DH_DAMP_FACTOR_EDIT;
jmitc91516 1:a5258871b33d 106 variablesForTouchArea[6].easyGUIVariablePtr = GuiVar_columnDHDampFactor;
jmitc91516 1:a5258871b33d 107 variablesForTouchArea[6].maxValue = 2550;
jmitc91516 1:a5258871b33d 108 variablesForTouchArea[6].easyGUICallingPage = GuiStruct_ColumnDHNudgeAndDampPage_0;
jmitc91516 1:a5258871b33d 109 strcpy(variablesForTouchArea[6].variableTitle, "DH Col. Damp");
jmitc91516 1:a5258871b33d 110
jmitc91516 1:a5258871b33d 111 variablesForTouchArea[7].touchAreaIndex = COLUMN_DH_RAMP_NUDGE_FACTOR_EDIT;
jmitc91516 1:a5258871b33d 112 variablesForTouchArea[7].easyGUIVariablePtr = GuiVar_columnDHRampNudgeFactor;
jmitc91516 1:a5258871b33d 113 variablesForTouchArea[7].maxValue = 2550;
jmitc91516 1:a5258871b33d 114 variablesForTouchArea[7].easyGUICallingPage = GuiStruct_ColumnDHNudgeAndDampPage_0;
jmitc91516 1:a5258871b33d 115 strcpy(variablesForTouchArea[7].variableTitle, "DH Ramp Nudge");
jmitc91516 1:a5258871b33d 116
jmitc91516 1:a5258871b33d 117 variablesForTouchArea[8].touchAreaIndex = COLUMN_DH_RAMP_DAMP_FACTOR_EDIT;
jmitc91516 1:a5258871b33d 118 variablesForTouchArea[8].easyGUIVariablePtr = GuiVar_columnDHRampDampFactor;
jmitc91516 1:a5258871b33d 119 variablesForTouchArea[8].maxValue = 2550;
jmitc91516 1:a5258871b33d 120 variablesForTouchArea[8].easyGUICallingPage = GuiStruct_ColumnDHNudgeAndDampPage_0;
jmitc91516 1:a5258871b33d 121 strcpy(variablesForTouchArea[8].variableTitle, "DH Ramp Damp");
jmitc91516 1:a5258871b33d 122
jmitc91516 1:a5258871b33d 123 variablesForTouchArea[9].touchAreaIndex = INJECTOR_NUDGE_FACTOR_EDIT;
jmitc91516 1:a5258871b33d 124 variablesForTouchArea[9].easyGUIVariablePtr = GuiVar_injectorNudgeFactor;
jmitc91516 1:a5258871b33d 125 variablesForTouchArea[9].maxValue = 2550;
jmitc91516 1:a5258871b33d 126 variablesForTouchArea[9].easyGUICallingPage = GuiStruct_InjectorNudgeAndDampPage_0;
jmitc91516 1:a5258871b33d 127 strcpy(variablesForTouchArea[9].variableTitle, "Inj. Nudge");
jmitc91516 1:a5258871b33d 128
jmitc91516 1:a5258871b33d 129 variablesForTouchArea[10].touchAreaIndex = INJECTOR_DAMP_FACTOR_EDIT;
jmitc91516 1:a5258871b33d 130 variablesForTouchArea[10].easyGUIVariablePtr = GuiVar_injectorDampFactor;
jmitc91516 1:a5258871b33d 131 variablesForTouchArea[10].maxValue = 2550;
jmitc91516 1:a5258871b33d 132 variablesForTouchArea[10].easyGUICallingPage = GuiStruct_InjectorNudgeAndDampPage_0;
jmitc91516 1:a5258871b33d 133 strcpy(variablesForTouchArea[10].variableTitle, "Inj. Damp");
jmitc91516 1:a5258871b33d 134
jmitc91516 1:a5258871b33d 135 variablesForTouchArea[11].touchAreaIndex = DETECTOR_NUDGE_FACTOR_EDIT;
jmitc91516 1:a5258871b33d 136 variablesForTouchArea[11].easyGUIVariablePtr = GuiVar_detectorNudgeFactor;
jmitc91516 1:a5258871b33d 137 variablesForTouchArea[11].maxValue = 2550;
jmitc91516 1:a5258871b33d 138 variablesForTouchArea[11].easyGUICallingPage = GuiStruct_DetectorNudgeAndDampPage_0;
jmitc91516 1:a5258871b33d 139 strcpy(variablesForTouchArea[11].variableTitle, "Det. Nudge");
jmitc91516 1:a5258871b33d 140
jmitc91516 1:a5258871b33d 141 variablesForTouchArea[12].touchAreaIndex = DETECTOR_DAMP_FACTOR_EDIT;
jmitc91516 1:a5258871b33d 142 variablesForTouchArea[12].easyGUIVariablePtr = GuiVar_detectorDampFactor;
jmitc91516 1:a5258871b33d 143 variablesForTouchArea[12].maxValue = 2550;
jmitc91516 1:a5258871b33d 144 variablesForTouchArea[12].easyGUICallingPage = GuiStruct_DetectorNudgeAndDampPage_0;
jmitc91516 1:a5258871b33d 145 strcpy(variablesForTouchArea[12].variableTitle, "Det. Damp");
jmitc91516 1:a5258871b33d 146
jmitc91516 1:a5258871b33d 147 variablesForTouchArea[13].touchAreaIndex = AUXILIARY_NUDGE_FACTOR_EDIT;
jmitc91516 1:a5258871b33d 148 variablesForTouchArea[13].easyGUIVariablePtr = GuiVar_auxiliaryNudgeFactor;
jmitc91516 1:a5258871b33d 149 variablesForTouchArea[13].maxValue = 2550;
jmitc91516 1:a5258871b33d 150 variablesForTouchArea[13].easyGUICallingPage = GuiStruct_AuxiliaryNudgeAndDampPage_0;
jmitc91516 1:a5258871b33d 151 strcpy(variablesForTouchArea[13].variableTitle, "Aux. Nudge");
jmitc91516 1:a5258871b33d 152
jmitc91516 1:a5258871b33d 153 variablesForTouchArea[14].touchAreaIndex = AUXILIARY_DAMP_FACTOR_EDIT;
jmitc91516 1:a5258871b33d 154 variablesForTouchArea[14].easyGUIVariablePtr = GuiVar_auxiliaryDampFactor;
jmitc91516 1:a5258871b33d 155 variablesForTouchArea[14].maxValue = 2550;
jmitc91516 1:a5258871b33d 156 variablesForTouchArea[14].easyGUICallingPage = GuiStruct_AuxiliaryNudgeAndDampPage_0;
jmitc91516 1:a5258871b33d 157 strcpy(variablesForTouchArea[14].variableTitle, "Aux. Damp");
jmitc91516 1:a5258871b33d 158
jmitc91516 1:a5258871b33d 159 variablesForTouchArea[15].touchAreaIndex = FAN_POWER_NORMAL_EDIT;
jmitc91516 1:a5258871b33d 160 variablesForTouchArea[15].easyGUIVariablePtr = GuiVar_fanPowerNormal;
jmitc91516 1:a5258871b33d 161 variablesForTouchArea[15].maxValue = 255;
jmitc91516 1:a5258871b33d 162 variablesForTouchArea[15].easyGUICallingPage = GuiStruct_FanPowerPage_0;
jmitc91516 1:a5258871b33d 163 strcpy(variablesForTouchArea[15].variableTitle, "Fan Normal");
jmitc91516 1:a5258871b33d 164
jmitc91516 1:a5258871b33d 165 variablesForTouchArea[16].touchAreaIndex = FAN_POWER_COOLING_EDIT;
jmitc91516 1:a5258871b33d 166 variablesForTouchArea[16].easyGUIVariablePtr = GuiVar_fanPowerCooling;
jmitc91516 1:a5258871b33d 167 variablesForTouchArea[16].maxValue = 255;
jmitc91516 1:a5258871b33d 168 variablesForTouchArea[16].easyGUICallingPage = GuiStruct_FanPowerPage_0;
jmitc91516 1:a5258871b33d 169 strcpy(variablesForTouchArea[16].variableTitle, "Fan Cooling");
jmitc91516 1:a5258871b33d 170
jmitc91516 1:a5258871b33d 171 variablesForTouchArea[17].touchAreaIndex = FAN_POWER_DH_CALIB_EDIT;
jmitc91516 1:a5258871b33d 172 variablesForTouchArea[17].easyGUIVariablePtr = GuiVar_fanPowerDHCalibration;
jmitc91516 1:a5258871b33d 173 variablesForTouchArea[17].maxValue = 255;
jmitc91516 1:a5258871b33d 174 variablesForTouchArea[17].easyGUICallingPage = GuiStruct_FanPowerPage_0;
jmitc91516 1:a5258871b33d 175 strcpy(variablesForTouchArea[17].variableTitle, "Fan DH Calib");
jmitc91516 1:a5258871b33d 176
jmitc91516 1:a5258871b33d 177 variablesForTouchArea[18].touchAreaIndex = FAN_POWER_MINIMUM_EDIT;
jmitc91516 1:a5258871b33d 178 variablesForTouchArea[18].easyGUIVariablePtr = GuiVar_fanPowerMinimum;
jmitc91516 1:a5258871b33d 179 variablesForTouchArea[18].maxValue = 255;
jmitc91516 1:a5258871b33d 180 variablesForTouchArea[18].easyGUICallingPage = GuiStruct_FanPowerPage_0;
jmitc91516 1:a5258871b33d 181 strcpy(variablesForTouchArea[18].variableTitle, "Fan Minimum");
jmitc91516 1:a5258871b33d 182 }
jmitc91516 1:a5258871b33d 183
jmitc91516 1:a5258871b33d 184
jmitc91516 1:a5258871b33d 185 // Private destructor also
jmitc91516 1:a5258871b33d 186 NudgeAndDampPageHandler::~NudgeAndDampPageHandler()
jmitc91516 1:a5258871b33d 187 {
jmitc91516 1:a5258871b33d 188 }
jmitc91516 1:a5258871b33d 189
jmitc91516 1:a5258871b33d 190
jmitc91516 1:a5258871b33d 191 /*
jmitc91516 1:a5258871b33d 192 Tells the caller whether or not the specified touch index is on one of the easyGUI Nudge and Damp pages,
jmitc91516 1:a5258871b33d 193 and therefore needs to be handled by this class.
jmitc91516 1:a5258871b33d 194
jmitc91516 1:a5258871b33d 195 Args: the touch area index in question
jmitc91516 1:a5258871b33d 196
jmitc91516 1:a5258871b33d 197 Return code: true if the touch area is 'one of ours', false if not
jmitc91516 1:a5258871b33d 198 */
jmitc91516 1:a5258871b33d 199 bool NudgeAndDampPageHandler::TouchAreaIsOnNudgeAndDampPage(int touchAreaIndex)
jmitc91516 1:a5258871b33d 200 {
jmitc91516 1:a5258871b33d 201 if((touchAreaIndex >= MIN_COLUMN_OVEN_NUDGE_AND_DAMP_TOUCHINDEX) && (touchAreaIndex <= MAX_COLUMN_OVEN_NUDGE_AND_DAMP_TOUCHINDEX)) {
jmitc91516 1:a5258871b33d 202 return true;
jmitc91516 1:a5258871b33d 203 }
jmitc91516 1:a5258871b33d 204
jmitc91516 1:a5258871b33d 205 if((touchAreaIndex >= MIN_COLUMN_DH_NUDGE_AND_DAMP_TOUCHINDEX) && (touchAreaIndex <= MAX_COLUMN_DH_NUDGE_AND_DAMP_TOUCHINDEX)) {
jmitc91516 1:a5258871b33d 206 return true;
jmitc91516 1:a5258871b33d 207 }
jmitc91516 1:a5258871b33d 208
jmitc91516 1:a5258871b33d 209 if((touchAreaIndex >= MIN_INJECTOR_NUDGE_AND_DAMP_TOUCHINDEX) && (touchAreaIndex <= MAX_INJECTOR_NUDGE_AND_DAMP_TOUCHINDEX)) {
jmitc91516 1:a5258871b33d 210 return true;
jmitc91516 1:a5258871b33d 211 }
jmitc91516 1:a5258871b33d 212
jmitc91516 1:a5258871b33d 213 if((touchAreaIndex >= MIN_DETECTOR_NUDGE_AND_DAMP_TOUCHINDEX) && (touchAreaIndex <= MAX_DETECTOR_NUDGE_AND_DAMP_TOUCHINDEX)) {
jmitc91516 1:a5258871b33d 214 return true;
jmitc91516 1:a5258871b33d 215 }
jmitc91516 1:a5258871b33d 216
jmitc91516 1:a5258871b33d 217 if((touchAreaIndex >= MIN_AUXILIARY_NUDGE_AND_DAMP_TOUCHINDEX) && (touchAreaIndex <= MAX_AUXILIARY_NUDGE_AND_DAMP_TOUCHINDEX)) {
jmitc91516 1:a5258871b33d 218 return true;
jmitc91516 1:a5258871b33d 219 }
jmitc91516 1:a5258871b33d 220
jmitc91516 1:a5258871b33d 221 if((touchAreaIndex >= MIN_FAN_POWER_TOUCHINDEX) && (touchAreaIndex <= MAX_FAN_POWER_TOUCHINDEX)) {
jmitc91516 1:a5258871b33d 222 return true;
jmitc91516 1:a5258871b33d 223 }
jmitc91516 1:a5258871b33d 224
jmitc91516 1:a5258871b33d 225 // 'else'
jmitc91516 1:a5258871b33d 226 return false;
jmitc91516 1:a5258871b33d 227 }
jmitc91516 1:a5258871b33d 228
jmitc91516 1:a5258871b33d 229
jmitc91516 1:a5258871b33d 230 /*
jmitc91516 1:a5258871b33d 231 If the specified touch area represents a key or field on one of the easyGUI Nudge and Damp pages,
jmitc91516 1:a5258871b33d 232 this function performs whatever action is appropriate for it. Provided so that the caller
jmitc91516 1:a5258871b33d 233 can (in effect) say "if this is one of yours, deal with it", without needing to know
jmitc91516 1:a5258871b33d 234 anything about what this class does, or how it handles the touch areas on that easyGUI page.
jmitc91516 1:a5258871b33d 235
jmitc91516 1:a5258871b33d 236 Args: the touch area index in question
jmitc91516 1:a5258871b33d 237
jmitc91516 1:a5258871b33d 238 Returns true if it dealt with the touch area (so the caller need not do anything else
jmitc91516 1:a5258871b33d 239 with the value), or false if it did not deal with the touch area (implying that it
jmitc91516 1:a5258871b33d 240 was not a touch area on an easyGUI Nudge and Damp page, and so the caller
jmitc91516 1:a5258871b33d 241 must deal with it some other way).
jmitc91516 1:a5258871b33d 242 */
jmitc91516 1:a5258871b33d 243 bool NudgeAndDampPageHandler::DealWithTouch(int touchAreaIndex)
jmitc91516 1:a5258871b33d 244 {
jmitc91516 1:a5258871b33d 245 // TODO: if 'touchAreaIndex' is one of the areas handled by this class,
jmitc91516 1:a5258871b33d 246 // deal with it
jmitc91516 1:a5258871b33d 247
jmitc91516 1:a5258871b33d 248 // Has the user selected a field to edit -
jmitc91516 1:a5258871b33d 249 // if so, we will have an entry in our 'variablesForTouchArea' array that corresponds with this touch area
jmitc91516 1:a5258871b33d 250 int indexOfValueToEdit = GetIndexOfValueToEditForTouchArea(touchAreaIndex);
jmitc91516 1:a5258871b33d 251 if(indexOfValueToEdit != -1) {
jmitc91516 1:a5258871b33d 252 // User has selected a field to edit
jmitc91516 1:a5258871b33d 253 NumericKeypadPageHandler* numericKeypadPageHandler = NumericKeypadPageHandler::GetInstance(usbDevice, usbHostGC);
jmitc91516 1:a5258871b33d 254 if(numericKeypadPageHandler != NULL) {
jmitc91516 1:a5258871b33d 255 numericKeypadPageHandler->StartEditing(variablesForTouchArea[indexOfValueToEdit].easyGUIVariablePtr);
jmitc91516 1:a5258871b33d 256 numericKeypadPageHandler->SetEasyGUIVariableToEdit(variablesForTouchArea[indexOfValueToEdit].easyGUIVariablePtr);
jmitc91516 1:a5258871b33d 257 numericKeypadPageHandler->SetEasyGUICallingPage(variablesForTouchArea[indexOfValueToEdit].easyGUICallingPage);
jmitc91516 1:a5258871b33d 258 numericKeypadPageHandler->SetEditVariableRange(0, variablesForTouchArea[indexOfValueToEdit].maxValue);
jmitc91516 1:a5258871b33d 259 numericKeypadPageHandler->SetEditVariableName(variablesForTouchArea[indexOfValueToEdit].variableTitle);
jmitc91516 1:a5258871b33d 260 numericKeypadPageHandler->DisplayEasyGUIPage();
jmitc91516 1:a5258871b33d 261 }
jmitc91516 1:a5258871b33d 262
jmitc91516 1:a5258871b33d 263 return true;
jmitc91516 1:a5258871b33d 264 }
jmitc91516 1:a5258871b33d 265
jmitc91516 1:a5258871b33d 266
jmitc91516 1:a5258871b33d 267 if(touchAreaIndex == COLUMN_OVEN_NUDGE_AND_DAMP_GET) {
jmitc91516 1:a5258871b33d 268 GetColumnOvenNudgeAndDampFactorsFromGC();
jmitc91516 1:a5258871b33d 269 return true;
jmitc91516 1:a5258871b33d 270 }
jmitc91516 1:a5258871b33d 271
jmitc91516 1:a5258871b33d 272 if(touchAreaIndex == COLUMN_DH_NUDGE_AND_DAMP_GET) {
jmitc91516 1:a5258871b33d 273 GetColumnDHNudgeAndDampFactorsFromGC();
jmitc91516 1:a5258871b33d 274 return true;
jmitc91516 1:a5258871b33d 275 }
jmitc91516 1:a5258871b33d 276
jmitc91516 1:a5258871b33d 277 if(touchAreaIndex == INJECTOR_NUDGE_AND_DAMP_GET) {
jmitc91516 1:a5258871b33d 278 GetInjectorNudgeAndDampFactorsFromGC();
jmitc91516 1:a5258871b33d 279 return true;
jmitc91516 1:a5258871b33d 280 }
jmitc91516 1:a5258871b33d 281
jmitc91516 1:a5258871b33d 282 if(touchAreaIndex == DETECTOR_NUDGE_AND_DAMP_GET) {
jmitc91516 1:a5258871b33d 283 GetDetectorNudgeAndDampFactorsFromGC();
jmitc91516 1:a5258871b33d 284 return true;
jmitc91516 1:a5258871b33d 285 }
jmitc91516 1:a5258871b33d 286
jmitc91516 1:a5258871b33d 287 if(touchAreaIndex == AUXILIARY_NUDGE_AND_DAMP_GET) {
jmitc91516 1:a5258871b33d 288 GetAuxiliaryNudgeAndDampFactorsFromGC();
jmitc91516 1:a5258871b33d 289 return true;
jmitc91516 1:a5258871b33d 290 }
jmitc91516 1:a5258871b33d 291
jmitc91516 1:a5258871b33d 292 if(touchAreaIndex == FAN_POWER_GET) {
jmitc91516 1:a5258871b33d 293 GetFanPowerValuesFromGC();
jmitc91516 1:a5258871b33d 294 return true;
jmitc91516 1:a5258871b33d 295 }
jmitc91516 1:a5258871b33d 296
jmitc91516 1:a5258871b33d 297 if(touchAreaIndex == COLUMN_OVEN_NUDGE_AND_DAMP_SET) {
jmitc91516 1:a5258871b33d 298 SetColumnOvenNudgeAndDampFactorsInGC();
jmitc91516 1:a5258871b33d 299 return true;
jmitc91516 1:a5258871b33d 300 }
jmitc91516 1:a5258871b33d 301
jmitc91516 1:a5258871b33d 302 if(touchAreaIndex == COLUMN_DH_NUDGE_AND_DAMP_SET) {
jmitc91516 1:a5258871b33d 303 SetColumnDHNudgeAndDampFactorsInGC();
jmitc91516 1:a5258871b33d 304 return true;
jmitc91516 1:a5258871b33d 305 }
jmitc91516 1:a5258871b33d 306
jmitc91516 1:a5258871b33d 307 if(touchAreaIndex == INJECTOR_NUDGE_AND_DAMP_SET) {
jmitc91516 1:a5258871b33d 308 SetInjectorNudgeAndDampFactorsInGC();
jmitc91516 1:a5258871b33d 309 return true;
jmitc91516 1:a5258871b33d 310 }
jmitc91516 1:a5258871b33d 311
jmitc91516 1:a5258871b33d 312 if(touchAreaIndex == DETECTOR_NUDGE_AND_DAMP_SET) {
jmitc91516 1:a5258871b33d 313 SetDetectorNudgeAndDampFactorsInGC();
jmitc91516 1:a5258871b33d 314 return true;
jmitc91516 1:a5258871b33d 315 }
jmitc91516 1:a5258871b33d 316
jmitc91516 1:a5258871b33d 317 if(touchAreaIndex == AUXILIARY_NUDGE_AND_DAMP_SET) {
jmitc91516 1:a5258871b33d 318 SetAuxiliaryNudgeAndDampFactorsInGC();
jmitc91516 1:a5258871b33d 319 return true;
jmitc91516 1:a5258871b33d 320 }
jmitc91516 1:a5258871b33d 321
jmitc91516 1:a5258871b33d 322 if(touchAreaIndex == FAN_POWER_SET) {
jmitc91516 1:a5258871b33d 323 SetFanPowerValuesInGC();
jmitc91516 1:a5258871b33d 324 return true;
jmitc91516 1:a5258871b33d 325 }
jmitc91516 1:a5258871b33d 326
jmitc91516 1:a5258871b33d 327 // 'else'...
jmitc91516 1:a5258871b33d 328
jmitc91516 1:a5258871b33d 329 return false;
jmitc91516 1:a5258871b33d 330 }
jmitc91516 1:a5258871b33d 331
jmitc91516 1:a5258871b33d 332
jmitc91516 1:a5258871b33d 333 /*
jmitc91516 1:a5258871b33d 334 Caller is telling us it is about to display one of the easyGUI Nudge and Damp pages,
jmitc91516 1:a5258871b33d 335 and that we should do whatever we have to do to get it ready, before the caller displays it.
jmitc91516 1:a5258871b33d 336
jmitc91516 1:a5258871b33d 337 No arguments, no return code
jmitc91516 1:a5258871b33d 338 */
jmitc91516 1:a5258871b33d 339 void NudgeAndDampPageHandler::DisplayingEasyGUIPage(int pageNumber, bool updateEasyGUIVariables)
jmitc91516 1:a5258871b33d 340 {
jmitc91516 1:a5258871b33d 341 // TODO: if 'updateEasyGUIVariables' is true, update the easyGUI variables for that page
jmitc91516 1:a5258871b33d 342
jmitc91516 1:a5258871b33d 343 if(updateEasyGUIVariables) {
jmitc91516 1:a5258871b33d 344 if(pageNumber == GuiStruct_ColumnOvenNudgeAndDampPage_0) {
jmitc91516 1:a5258871b33d 345 GetColumnOvenNudgeAndDampFactorsFromGC();
jmitc91516 1:a5258871b33d 346 }
jmitc91516 1:a5258871b33d 347 else if(pageNumber == GuiStruct_ColumnDHNudgeAndDampPage_0) {
jmitc91516 1:a5258871b33d 348 GetColumnDHNudgeAndDampFactorsFromGC();
jmitc91516 1:a5258871b33d 349 }
jmitc91516 1:a5258871b33d 350 else if(pageNumber == GuiStruct_InjectorNudgeAndDampPage_0) {
jmitc91516 1:a5258871b33d 351 GetInjectorNudgeAndDampFactorsFromGC();
jmitc91516 1:a5258871b33d 352 }
jmitc91516 1:a5258871b33d 353 else if (pageNumber == GuiStruct_DetectorNudgeAndDampPage_0) {
jmitc91516 1:a5258871b33d 354 GetDetectorNudgeAndDampFactorsFromGC();
jmitc91516 1:a5258871b33d 355 }
jmitc91516 1:a5258871b33d 356 else if (pageNumber == GuiStruct_AuxiliaryNudgeAndDampPage_0) {
jmitc91516 1:a5258871b33d 357 GetAuxiliaryNudgeAndDampFactorsFromGC();
jmitc91516 1:a5258871b33d 358 }
jmitc91516 1:a5258871b33d 359 else if (pageNumber == GuiStruct_FanPowerPage_0) {
jmitc91516 1:a5258871b33d 360 GetFanPowerValuesFromGC();
jmitc91516 1:a5258871b33d 361 }
jmitc91516 1:a5258871b33d 362 }
jmitc91516 1:a5258871b33d 363 }
jmitc91516 1:a5258871b33d 364
jmitc91516 1:a5258871b33d 365
jmitc91516 1:a5258871b33d 366 /*
jmitc91516 1:a5258871b33d 367 As the name implies, sends a command to the GC and returns the response.
jmitc91516 1:a5258871b33d 368
jmitc91516 1:a5258871b33d 369 Args: pointer to a buffer containing the command, as a null-terminated string
jmitc91516 1:a5258871b33d 370 pointer to a buffer to contain the response, as a null-terminated string
jmitc91516 1:a5258871b33d 371
jmitc91516 1:a5258871b33d 372 No return code (it is up to the caller to examine the response to see whether
jmitc91516 1:a5258871b33d 373 the command succeeded or failed)
jmitc91516 1:a5258871b33d 374 */
jmitc91516 1:a5258871b33d 375 void NudgeAndDampPageHandler::SendCommandToGCAndGetResponse(char* command, char* response)
jmitc91516 1:a5258871b33d 376 {
jmitc91516 1:a5258871b33d 377 #define USE_GC_UTILS // Testing new class
jmitc91516 1:a5258871b33d 378 #ifdef USE_GC_UTILS
jmitc91516 1:a5258871b33d 379 USBHostGCUtilities::SendCommandToGCAndGetResponse(usbDevice, usbHostGC, command, response);
jmitc91516 1:a5258871b33d 380 #else
jmitc91516 1:a5258871b33d 381 while(usbHostGC->ExecutingSetDeviceReport()) {}
jmitc91516 1:a5258871b33d 382
jmitc91516 1:a5258871b33d 383 usbHostGC->SetDeviceReport(usbDevice, command, response);
jmitc91516 1:a5258871b33d 384 //#define DEBUG_PRINT_HERE
jmitc91516 1:a5258871b33d 385 #ifdef DEBUG_PRINT_HERE
jmitc91516 1:a5258871b33d 386 char dbg[100];
jmitc91516 1:a5258871b33d 387 sprintf(dbg, "NDPH cmd \"%s\", response \"%s\"", command, response);
jmitc91516 1:a5258871b33d 388 SpecialDebugPrint(dbg, 10, 275);
jmitc91516 1:a5258871b33d 389 #endif // DEBUG_PRINT_HERE
jmitc91516 1:a5258871b33d 390
jmitc91516 1:a5258871b33d 391 #endif // USE_GC_UTILS
jmitc91516 1:a5258871b33d 392 }
jmitc91516 1:a5258871b33d 393
jmitc91516 1:a5258871b33d 394
jmitc91516 1:a5258871b33d 395 /*
jmitc91516 1:a5258871b33d 396 Sends a command to the GC for which we expect a response of "DACK" if successful,
jmitc91516 1:a5258871b33d 397 "DNAK" or "EPKT" if failure.
jmitc91516 1:a5258871b33d 398
jmitc91516 1:a5258871b33d 399 Args: a pointer to the command in question, as a null terminated string
jmitc91516 1:a5258871b33d 400
jmitc91516 1:a5258871b33d 401 Returns true if the GC responded with "DACK", false for anything else
jmitc91516 1:a5258871b33d 402 */
jmitc91516 1:a5258871b33d 403 bool NudgeAndDampPageHandler::SendCommandToGCWithDACKResponse(char *cmd)
jmitc91516 1:a5258871b33d 404 {
jmitc91516 1:a5258871b33d 405 #define USE_GC_UTILS // Testing new class
jmitc91516 1:a5258871b33d 406 #ifdef USE_GC_UTILS
jmitc91516 1:a5258871b33d 407 return USBHostGCUtilities::SendCommandToGCWithDACKResponse(usbDevice, usbHostGC, cmd);
jmitc91516 1:a5258871b33d 408 #else
jmitc91516 1:a5258871b33d 409 char response[50];
jmitc91516 1:a5258871b33d 410 SendCommandToGCAndGetResponse(cmd, response);
jmitc91516 1:a5258871b33d 411 // We expect a response like this: "DACK" for success, "DNAK" for failure, "EPKT" for error
jmitc91516 1:a5258871b33d 412
jmitc91516 1:a5258871b33d 413 return (response[1] == 'A');
jmitc91516 1:a5258871b33d 414 #endif // USE_GC_UTILS
jmitc91516 1:a5258871b33d 415 }
jmitc91516 1:a5258871b33d 416
jmitc91516 1:a5258871b33d 417
jmitc91516 1:a5258871b33d 418 /*
jmitc91516 1:a5258871b33d 419 Gets a nudge or damp factor from the GC, and put its value into an easyGUI variable.
jmitc91516 1:a5258871b33d 420 It is up to the caller to display the updated variable to the user.
jmitc91516 1:a5258871b33d 421
jmitc91516 1:a5258871b33d 422 We use the same factor for nudge *and* damp, since the GC returns both values
jmitc91516 1:a5258871b33d 423 in the same format.
jmitc91516 1:a5258871b33d 424
jmitc91516 1:a5258871b33d 425 Args: a string, set to the command to get the value from the GC
jmitc91516 1:a5258871b33d 426 a pointer to the easyGUI variable to update
jmitc91516 1:a5258871b33d 427
jmitc91516 1:a5258871b33d 428 Returns true if successful, false if error
jmitc91516 1:a5258871b33d 429 */
jmitc91516 1:a5258871b33d 430 bool NudgeAndDampPageHandler::GetNudgeOrDampFactorFromGC(char *cmd, GuiConst_TEXT* easyGUIVariable)
jmitc91516 1:a5258871b33d 431 {
jmitc91516 1:a5258871b33d 432 char response[50];
jmitc91516 1:a5258871b33d 433 SendCommandToGCAndGetResponse(cmd, response);
jmitc91516 1:a5258871b33d 434
jmitc91516 1:a5258871b33d 435 if(response[0] != 'D') {
jmitc91516 1:a5258871b33d 436 return false;
jmitc91516 1:a5258871b33d 437 }
jmitc91516 1:a5258871b33d 438
jmitc91516 1:a5258871b33d 439 if(response[1] != cmd[1]) {
jmitc91516 1:a5258871b33d 440 return false;
jmitc91516 1:a5258871b33d 441 }
jmitc91516 1:a5258871b33d 442
jmitc91516 1:a5258871b33d 443 if(response[2] != cmd[2]) {
jmitc91516 1:a5258871b33d 444 return false;
jmitc91516 1:a5258871b33d 445 }
jmitc91516 1:a5258871b33d 446
jmitc91516 1:a5258871b33d 447 if(response[3] != cmd[3]) {
jmitc91516 1:a5258871b33d 448 return false;
jmitc91516 1:a5258871b33d 449 }
jmitc91516 1:a5258871b33d 450
jmitc91516 1:a5258871b33d 451 // OK so far...
jmitc91516 1:a5258871b33d 452
jmitc91516 1:a5258871b33d 453 response[8] = '\0'; // Ensure null terminator
jmitc91516 1:a5258871b33d 454
jmitc91516 1:a5258871b33d 455 // Need to remove leading zeroes, if any
jmitc91516 1:a5258871b33d 456 int factor;
jmitc91516 1:a5258871b33d 457 sscanf(&response[4], "%d", &factor);
jmitc91516 1:a5258871b33d 458
jmitc91516 1:a5258871b33d 459 sprintf(easyGUIVariable, "%d", factor);
jmitc91516 1:a5258871b33d 460
jmitc91516 1:a5258871b33d 461 return true;
jmitc91516 1:a5258871b33d 462 }
jmitc91516 1:a5258871b33d 463
jmitc91516 1:a5258871b33d 464
jmitc91516 1:a5258871b33d 465 /*
jmitc91516 1:a5258871b33d 466 Gets the current column oven nudge and damp factors from the GC,
jmitc91516 1:a5258871b33d 467 and copies them into the relevant easyGUI variables for display to the user.
jmitc91516 1:a5258871b33d 468 It is up to the caller to (re)display the Column Oven Nudge and Damp easyGUI page.
jmitc91516 1:a5258871b33d 469
jmitc91516 1:a5258871b33d 470 No arguments, no return code
jmitc91516 1:a5258871b33d 471 */
jmitc91516 1:a5258871b33d 472 void NudgeAndDampPageHandler::GetColumnOvenNudgeAndDampFactorsFromGC(void)
jmitc91516 1:a5258871b33d 473 {
jmitc91516 1:a5258871b33d 474 GetNudgeOrDampFactorFromGC("GCNU", GuiVar_columnOvenNudgeFactor);
jmitc91516 1:a5258871b33d 475 GetNudgeOrDampFactorFromGC("GCDA", GuiVar_columnOvenDampFactor);
jmitc91516 1:a5258871b33d 476 GetNudgeOrDampFactorFromGC("GRNU", GuiVar_columnOvenRampNudgeFactor);
jmitc91516 1:a5258871b33d 477 GetNudgeOrDampFactorFromGC("GRDA", GuiVar_columnOvenRampDampFactor);
jmitc91516 1:a5258871b33d 478 GetNudgeOrDampFactorFromGC("GCTO", GuiVar_columnOvenTempOffset);
jmitc91516 1:a5258871b33d 479 }
jmitc91516 1:a5258871b33d 480
jmitc91516 1:a5258871b33d 481
jmitc91516 1:a5258871b33d 482 /*
jmitc91516 1:a5258871b33d 483 Gets the current directly heated column nudge and damp factors from the GC,
jmitc91516 1:a5258871b33d 484 and copies them into the relevant easyGUI variables for display to the user.
jmitc91516 1:a5258871b33d 485 It is up to the caller to (re)display the Column DH Nudge and Damp easyGUI page.
jmitc91516 1:a5258871b33d 486
jmitc91516 1:a5258871b33d 487 No arguments, no return code
jmitc91516 1:a5258871b33d 488 */
jmitc91516 1:a5258871b33d 489 void NudgeAndDampPageHandler::GetColumnDHNudgeAndDampFactorsFromGC(void)
jmitc91516 1:a5258871b33d 490 {
jmitc91516 1:a5258871b33d 491 GetNudgeOrDampFactorFromGC("GHNU", GuiVar_columnDHNudgeFactor);
jmitc91516 1:a5258871b33d 492 GetNudgeOrDampFactorFromGC("GHDA", GuiVar_columnDHDampFactor);
jmitc91516 1:a5258871b33d 493 GetNudgeOrDampFactorFromGC("GHRN", GuiVar_columnDHRampNudgeFactor);
jmitc91516 1:a5258871b33d 494 GetNudgeOrDampFactorFromGC("GHRD", GuiVar_columnDHRampDampFactor);
jmitc91516 1:a5258871b33d 495 }
jmitc91516 1:a5258871b33d 496
jmitc91516 1:a5258871b33d 497
jmitc91516 1:a5258871b33d 498 /*
jmitc91516 1:a5258871b33d 499 Gets the current injector nudge and damp factors from the GC,
jmitc91516 1:a5258871b33d 500 and copies them into the relevant easyGUI variables for display to the user.
jmitc91516 1:a5258871b33d 501 It is up to the caller to (re)display the Injector Nudge and Damp easyGUI page.
jmitc91516 1:a5258871b33d 502
jmitc91516 1:a5258871b33d 503 No arguments, no return code
jmitc91516 1:a5258871b33d 504 */
jmitc91516 1:a5258871b33d 505 void NudgeAndDampPageHandler::GetInjectorNudgeAndDampFactorsFromGC(void)
jmitc91516 1:a5258871b33d 506 {
jmitc91516 1:a5258871b33d 507 GetNudgeOrDampFactorFromGC("GINU", GuiVar_injectorNudgeFactor);
jmitc91516 1:a5258871b33d 508 GetNudgeOrDampFactorFromGC("GIDA", GuiVar_injectorDampFactor);
jmitc91516 1:a5258871b33d 509 }
jmitc91516 1:a5258871b33d 510
jmitc91516 1:a5258871b33d 511
jmitc91516 1:a5258871b33d 512 /*
jmitc91516 1:a5258871b33d 513 Gets the current detector nudge and damp factors from the GC,
jmitc91516 1:a5258871b33d 514 and copies them into the relevant easyGUI variables for display to the user.
jmitc91516 1:a5258871b33d 515 It is up to the caller to (re)display the Detector Nudge and Damp easyGUI page.
jmitc91516 1:a5258871b33d 516
jmitc91516 1:a5258871b33d 517 No arguments, no return code
jmitc91516 1:a5258871b33d 518 */
jmitc91516 1:a5258871b33d 519 void NudgeAndDampPageHandler::GetDetectorNudgeAndDampFactorsFromGC(void)
jmitc91516 1:a5258871b33d 520 {
jmitc91516 1:a5258871b33d 521 GetNudgeOrDampFactorFromGC("GDNU", GuiVar_detectorNudgeFactor);
jmitc91516 1:a5258871b33d 522 GetNudgeOrDampFactorFromGC("GDDA", GuiVar_detectorDampFactor);
jmitc91516 1:a5258871b33d 523 }
jmitc91516 1:a5258871b33d 524
jmitc91516 1:a5258871b33d 525
jmitc91516 1:a5258871b33d 526 /*
jmitc91516 1:a5258871b33d 527 Gets the current auxiliary nudge and damp factors from the GC,
jmitc91516 1:a5258871b33d 528 and copies them into the relevant easyGUI variables for display to the user.
jmitc91516 1:a5258871b33d 529 It is up to the caller to (re)display the Auxiliary Nudge and Damp easyGUI page.
jmitc91516 1:a5258871b33d 530
jmitc91516 1:a5258871b33d 531 No arguments, no return code
jmitc91516 1:a5258871b33d 532 */
jmitc91516 1:a5258871b33d 533 void NudgeAndDampPageHandler::GetAuxiliaryNudgeAndDampFactorsFromGC(void)
jmitc91516 1:a5258871b33d 534 {
jmitc91516 1:a5258871b33d 535 GetNudgeOrDampFactorFromGC("GANU", GuiVar_auxiliaryNudgeFactor);
jmitc91516 1:a5258871b33d 536 GetNudgeOrDampFactorFromGC("GADA", GuiVar_auxiliaryDampFactor);
jmitc91516 1:a5258871b33d 537 }
jmitc91516 1:a5258871b33d 538
jmitc91516 1:a5258871b33d 539
jmitc91516 1:a5258871b33d 540 /*
jmitc91516 1:a5258871b33d 541 Gets the current values for each fan power setting from the GC,
jmitc91516 1:a5258871b33d 542 and copies them into the relevant easyGUI variables for display to the user.
jmitc91516 1:a5258871b33d 543 It is up to the caller to (re)display the Fan Power easyGUI page.
jmitc91516 1:a5258871b33d 544
jmitc91516 1:a5258871b33d 545 No arguments, no return code
jmitc91516 1:a5258871b33d 546 */
jmitc91516 1:a5258871b33d 547 void NudgeAndDampPageHandler::GetFanPowerValuesFromGC(void)
jmitc91516 1:a5258871b33d 548 {
jmitc91516 1:a5258871b33d 549 // The commands to get the fan power values are very similar to those for the nudge and damp factors
jmitc91516 1:a5258871b33d 550 GetNudgeOrDampFactorFromGC("GFNM", GuiVar_fanPowerNormal);
jmitc91516 1:a5258871b33d 551 GetNudgeOrDampFactorFromGC("GFCL", GuiVar_fanPowerCooling);
jmitc91516 1:a5258871b33d 552 GetNudgeOrDampFactorFromGC("GFCA", GuiVar_fanPowerDHCalibration);
jmitc91516 1:a5258871b33d 553 GetNudgeOrDampFactorFromGC("GFMI", GuiVar_fanPowerMinimum);
jmitc91516 1:a5258871b33d 554 }
jmitc91516 1:a5258871b33d 555
jmitc91516 1:a5258871b33d 556
jmitc91516 1:a5258871b33d 557 /*
jmitc91516 1:a5258871b33d 558 The commands to set the various nudge and damp factors are very similar.
jmitc91516 1:a5258871b33d 559 In particular the format of their data values is identical. This function sets the value in the GC
jmitc91516 1:a5258871b33d 560 using the specified command, using the value in the specified easyGUI variable.
jmitc91516 1:a5258871b33d 561
jmitc91516 1:a5258871b33d 562 Returns true if successful, false if not.
jmitc91516 1:a5258871b33d 563 */
jmitc91516 1:a5258871b33d 564 bool NudgeAndDampPageHandler::SetNudgeOrDampFactorInGC(char *cmd, GuiConst_TEXT* easyGUIVariable)
jmitc91516 1:a5258871b33d 565 {
jmitc91516 1:a5258871b33d 566 char buffer[50];
jmitc91516 1:a5258871b33d 567
jmitc91516 1:a5258871b33d 568 // In the command, the nudge/damp value must have 4 digits, padded if necessary with leading zeroes
jmitc91516 1:a5258871b33d 569 int factor;
jmitc91516 1:a5258871b33d 570 sscanf(easyGUIVariable, "%d", &factor);
jmitc91516 1:a5258871b33d 571 sprintf(buffer, "%s%.4d", cmd, factor);
jmitc91516 1:a5258871b33d 572
jmitc91516 1:a5258871b33d 573 return SendCommandToGCWithDACKResponse(buffer);
jmitc91516 1:a5258871b33d 574 }
jmitc91516 1:a5258871b33d 575
jmitc91516 1:a5258871b33d 576
jmitc91516 1:a5258871b33d 577 /*
jmitc91516 1:a5258871b33d 578 Sets the current column oven nudge and damp factors in the GC,
jmitc91516 1:a5258871b33d 579 using the values in the relevant easyGUI variables.
jmitc91516 1:a5258871b33d 580
jmitc91516 1:a5258871b33d 581 No arguments, no return code
jmitc91516 1:a5258871b33d 582 */
jmitc91516 1:a5258871b33d 583 void NudgeAndDampPageHandler::SetColumnOvenNudgeAndDampFactorsInGC(void)
jmitc91516 1:a5258871b33d 584 {
jmitc91516 1:a5258871b33d 585 SetNudgeOrDampFactorInGC("SCNU", GuiVar_columnOvenNudgeFactor);
jmitc91516 1:a5258871b33d 586 SetNudgeOrDampFactorInGC("SCDA", GuiVar_columnOvenDampFactor);
jmitc91516 1:a5258871b33d 587 SetNudgeOrDampFactorInGC("SRNU", GuiVar_columnOvenRampNudgeFactor);
jmitc91516 1:a5258871b33d 588 SetNudgeOrDampFactorInGC("SRDA", GuiVar_columnOvenRampDampFactor);
jmitc91516 1:a5258871b33d 589 SetNudgeOrDampFactorInGC("SCTO", GuiVar_columnOvenTempOffset);
jmitc91516 1:a5258871b33d 590 }
jmitc91516 1:a5258871b33d 591
jmitc91516 1:a5258871b33d 592
jmitc91516 1:a5258871b33d 593 /*
jmitc91516 1:a5258871b33d 594 Sets the current directly heated column nudge and damp factors in the GC,
jmitc91516 1:a5258871b33d 595 using the values in the relevant easyGUI variables.
jmitc91516 1:a5258871b33d 596
jmitc91516 1:a5258871b33d 597 No arguments, no return code
jmitc91516 1:a5258871b33d 598 */
jmitc91516 1:a5258871b33d 599 void NudgeAndDampPageHandler::SetColumnDHNudgeAndDampFactorsInGC(void)
jmitc91516 1:a5258871b33d 600 {
jmitc91516 1:a5258871b33d 601 SetNudgeOrDampFactorInGC("SHNU", GuiVar_columnDHNudgeFactor);
jmitc91516 1:a5258871b33d 602 SetNudgeOrDampFactorInGC("SHDA", GuiVar_columnDHDampFactor);
jmitc91516 1:a5258871b33d 603 SetNudgeOrDampFactorInGC("SHRN", GuiVar_columnDHRampNudgeFactor);
jmitc91516 1:a5258871b33d 604 SetNudgeOrDampFactorInGC("SHRD", GuiVar_columnDHRampDampFactor);
jmitc91516 1:a5258871b33d 605 }
jmitc91516 1:a5258871b33d 606
jmitc91516 1:a5258871b33d 607
jmitc91516 1:a5258871b33d 608 /*
jmitc91516 1:a5258871b33d 609 Sets the current injector nudge and damp factors in the GC,
jmitc91516 1:a5258871b33d 610 using the values in the relevant easyGUI variables.
jmitc91516 1:a5258871b33d 611
jmitc91516 1:a5258871b33d 612 No arguments, no return code
jmitc91516 1:a5258871b33d 613 */
jmitc91516 1:a5258871b33d 614 void NudgeAndDampPageHandler::SetInjectorNudgeAndDampFactorsInGC(void)
jmitc91516 1:a5258871b33d 615 {
jmitc91516 1:a5258871b33d 616 SetNudgeOrDampFactorInGC("SINU", GuiVar_injectorNudgeFactor);
jmitc91516 1:a5258871b33d 617 SetNudgeOrDampFactorInGC("SIDA", GuiVar_injectorDampFactor);
jmitc91516 1:a5258871b33d 618 }
jmitc91516 1:a5258871b33d 619
jmitc91516 1:a5258871b33d 620
jmitc91516 1:a5258871b33d 621 /*
jmitc91516 1:a5258871b33d 622 Sets the current detector nudge and damp factors in the GC,
jmitc91516 1:a5258871b33d 623 using the values in the relevant easyGUI variables.
jmitc91516 1:a5258871b33d 624
jmitc91516 1:a5258871b33d 625 No arguments, no return code
jmitc91516 1:a5258871b33d 626 */
jmitc91516 1:a5258871b33d 627 void NudgeAndDampPageHandler::SetDetectorNudgeAndDampFactorsInGC(void)
jmitc91516 1:a5258871b33d 628 {
jmitc91516 1:a5258871b33d 629 SetNudgeOrDampFactorInGC("SDNU", GuiVar_detectorNudgeFactor);
jmitc91516 1:a5258871b33d 630 SetNudgeOrDampFactorInGC("SDDA", GuiVar_detectorDampFactor);
jmitc91516 1:a5258871b33d 631 }
jmitc91516 1:a5258871b33d 632
jmitc91516 1:a5258871b33d 633
jmitc91516 1:a5258871b33d 634 /*
jmitc91516 1:a5258871b33d 635 Sets the current auxiliary nudge and damp factors in the GC,
jmitc91516 1:a5258871b33d 636 using the values in the relevant easyGUI variables.
jmitc91516 1:a5258871b33d 637
jmitc91516 1:a5258871b33d 638 No arguments, no return code
jmitc91516 1:a5258871b33d 639 */
jmitc91516 1:a5258871b33d 640 void NudgeAndDampPageHandler::SetAuxiliaryNudgeAndDampFactorsInGC(void)
jmitc91516 1:a5258871b33d 641 {
jmitc91516 1:a5258871b33d 642 SetNudgeOrDampFactorInGC("SANU", GuiVar_auxiliaryNudgeFactor);
jmitc91516 1:a5258871b33d 643 SetNudgeOrDampFactorInGC("SADA", GuiVar_auxiliaryDampFactor);
jmitc91516 1:a5258871b33d 644 }
jmitc91516 1:a5258871b33d 645
jmitc91516 1:a5258871b33d 646
jmitc91516 1:a5258871b33d 647 /*
jmitc91516 1:a5258871b33d 648 Sets the current values for each fan power setting in the GC,
jmitc91516 1:a5258871b33d 649 using the values in the relevant easyGUI variables.
jmitc91516 1:a5258871b33d 650
jmitc91516 1:a5258871b33d 651 No arguments, no return code
jmitc91516 1:a5258871b33d 652 */
jmitc91516 1:a5258871b33d 653 void NudgeAndDampPageHandler::SetFanPowerValuesInGC(void)
jmitc91516 1:a5258871b33d 654 {
jmitc91516 1:a5258871b33d 655 // The commands to set the fan power values are very similar to those for the nudge and damp factors
jmitc91516 1:a5258871b33d 656 SetNudgeOrDampFactorInGC("SFNM", GuiVar_fanPowerNormal);
jmitc91516 1:a5258871b33d 657 SetNudgeOrDampFactorInGC("SFCL", GuiVar_fanPowerCooling);
jmitc91516 1:a5258871b33d 658 SetNudgeOrDampFactorInGC("SFCA", GuiVar_fanPowerDHCalibration);
jmitc91516 1:a5258871b33d 659 SetNudgeOrDampFactorInGC("SFMI", GuiVar_fanPowerMinimum);
jmitc91516 1:a5258871b33d 660 }
jmitc91516 1:a5258871b33d 661
jmitc91516 1:a5258871b33d 662
jmitc91516 1:a5258871b33d 663 /*
jmitc91516 1:a5258871b33d 664 Tells the caller if the specified touch area corresponds to a value the user can edit
jmitc91516 1:a5258871b33d 665 on one of the easyGUI nudge and damp pages, and if so, which value it is.
jmitc91516 1:a5258871b33d 666
jmitc91516 1:a5258871b33d 667 Args: the touch area index in question
jmitc91516 1:a5258871b33d 668
jmitc91516 1:a5258871b33d 669 Returns the index of the corresponding entry in our 'variablesForTouchArea' array,
jmitc91516 1:a5258871b33d 670 or -1 if there is no such entry. It is up to the caller to check for -1
jmitc91516 1:a5258871b33d 671 **************************************
jmitc91516 1:a5258871b33d 672 */
jmitc91516 1:a5258871b33d 673 int NudgeAndDampPageHandler::GetIndexOfValueToEditForTouchArea(int touchAreaIndex)
jmitc91516 1:a5258871b33d 674 {
jmitc91516 1:a5258871b33d 675 for (int index = 0; index < COUNT_OF_VARIABLES_FOR_TOUCH_AREAS; ++index) {
jmitc91516 1:a5258871b33d 676 if(variablesForTouchArea[index].touchAreaIndex == touchAreaIndex) {
jmitc91516 1:a5258871b33d 677 return index;
jmitc91516 1:a5258871b33d 678 }
jmitc91516 1:a5258871b33d 679 }
jmitc91516 1:a5258871b33d 680
jmitc91516 1:a5258871b33d 681 // 'else' no nudge or damp factor corresponds to the specified touch area
jmitc91516 1:a5258871b33d 682 return -1;
jmitc91516 1:a5258871b33d 683 }