Repository for import to local machine

Dependencies:   DMBasicGUI DMSupport

Committer:
jmitc91516
Date:
Mon Jul 31 15:37:57 2017 +0000
Revision:
8:26e49e6955bd
Parent:
1:a5258871b33d
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 "ColumnDHManualCalibrationPageHandler.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 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 9 (we do not want multiple values for the same calibration parameters, etc, and nor will we show
jmitc91516 1:a5258871b33d 10 more than one easyGUI 'ColumnDHManualCalibrationPage' to the user at the same time).
jmitc91516 1:a5258871b33d 11 */
jmitc91516 1:a5258871b33d 12 ColumnDHManualCalibrationPageHandler * ColumnDHManualCalibrationPageHandler::theColumnDHManualCalibrationPageHandlerInstance = NULL;
jmitc91516 1:a5258871b33d 13
jmitc91516 1:a5258871b33d 14
jmitc91516 1:a5258871b33d 15 /*
jmitc91516 1:a5258871b33d 16 Singleton class - return the one and only instance, first creating it if necessary.
jmitc91516 1:a5258871b33d 17 */
jmitc91516 1:a5258871b33d 18 ColumnDHManualCalibrationPageHandler * ColumnDHManualCalibrationPageHandler::GetInstance(USBDeviceConnected* newUsbDevice, USBHostGC* newUsbHostGC)
jmitc91516 1:a5258871b33d 19 {
jmitc91516 1:a5258871b33d 20 if (theColumnDHManualCalibrationPageHandlerInstance == NULL) {
jmitc91516 1:a5258871b33d 21 theColumnDHManualCalibrationPageHandlerInstance = new ColumnDHManualCalibrationPageHandler(newUsbDevice, newUsbHostGC);
jmitc91516 1:a5258871b33d 22 }
jmitc91516 1:a5258871b33d 23
jmitc91516 1:a5258871b33d 24 return theColumnDHManualCalibrationPageHandlerInstance;
jmitc91516 1:a5258871b33d 25 }
jmitc91516 1:a5258871b33d 26
jmitc91516 1:a5258871b33d 27 /*
jmitc91516 1:a5258871b33d 28 Overriden version of the above, that does not take any arguments and does not create the instance
jmitc91516 1:a5258871b33d 29 if it does not already exist.
jmitc91516 1:a5258871b33d 30
jmitc91516 1:a5258871b33d 31 Provided for callers that do not have the 'usbDevice' and'usbHostGC' pointers, and just want access
jmitc91516 1:a5258871b33d 32 to the instance if it exists
jmitc91516 1:a5258871b33d 33 */
jmitc91516 1:a5258871b33d 34 ColumnDHManualCalibrationPageHandler * ColumnDHManualCalibrationPageHandler::GetInstance(void)
jmitc91516 1:a5258871b33d 35 {
jmitc91516 1:a5258871b33d 36 return theColumnDHManualCalibrationPageHandlerInstance;
jmitc91516 1:a5258871b33d 37 }
jmitc91516 1:a5258871b33d 38
jmitc91516 1:a5258871b33d 39
jmitc91516 1:a5258871b33d 40 // Singleton class - private constructor
jmitc91516 1:a5258871b33d 41 ColumnDHManualCalibrationPageHandler::ColumnDHManualCalibrationPageHandler(USBDeviceConnected* newUsbDevice, USBHostGC* newUsbHostGC)
jmitc91516 1:a5258871b33d 42 {
jmitc91516 1:a5258871b33d 43 usbDevice = newUsbDevice;
jmitc91516 1:a5258871b33d 44 usbHostGC = newUsbHostGC;
jmitc91516 1:a5258871b33d 45
jmitc91516 1:a5258871b33d 46
jmitc91516 1:a5258871b33d 47 variablesForTouchArea[0].touchAreaIndex = COLUMN_DH_MANUAL_CALIB_EDIT_TEMP1;
jmitc91516 1:a5258871b33d 48 variablesForTouchArea[0].easyGUIVariablePtr = GuiVar_columnDHManualCalibTemp1;
jmitc91516 1:a5258871b33d 49 variablesForTouchArea[0].maxValue = 999;
jmitc91516 1:a5258871b33d 50 variablesForTouchArea[0].placesOfDecimals = 1;
jmitc91516 1:a5258871b33d 51 strcpy(variablesForTouchArea[0].variableTitle, "Temp Point 1");
jmitc91516 1:a5258871b33d 52
jmitc91516 1:a5258871b33d 53 variablesForTouchArea[1].touchAreaIndex = COLUMN_DH_MANUAL_CALIB_EDIT_TEMP2;
jmitc91516 1:a5258871b33d 54 variablesForTouchArea[1].easyGUIVariablePtr = GuiVar_columnDHManualCalibTemp2;
jmitc91516 1:a5258871b33d 55 variablesForTouchArea[1].maxValue = 999;
jmitc91516 1:a5258871b33d 56 variablesForTouchArea[1].placesOfDecimals = 1;
jmitc91516 1:a5258871b33d 57 strcpy(variablesForTouchArea[1].variableTitle, "Temp Point 2");
jmitc91516 1:a5258871b33d 58
jmitc91516 1:a5258871b33d 59 variablesForTouchArea[2].touchAreaIndex = COLUMN_DH_MANUAL_CALIB_EDIT_TEMP3;
jmitc91516 1:a5258871b33d 60 variablesForTouchArea[2].easyGUIVariablePtr = GuiVar_columnDHManualCalibTemp3;
jmitc91516 1:a5258871b33d 61 variablesForTouchArea[2].maxValue = 999;
jmitc91516 1:a5258871b33d 62 variablesForTouchArea[2].placesOfDecimals = 1;
jmitc91516 1:a5258871b33d 63 strcpy(variablesForTouchArea[2].variableTitle, "Temp Point 3");
jmitc91516 1:a5258871b33d 64
jmitc91516 1:a5258871b33d 65 variablesForTouchArea[3].touchAreaIndex = COLUMN_DH_MANUAL_CALIB_EDIT_RES1;
jmitc91516 1:a5258871b33d 66 variablesForTouchArea[3].easyGUIVariablePtr = GuiVar_columnDHManualCalibRes1;
jmitc91516 1:a5258871b33d 67 variablesForTouchArea[3].maxValue = 99;
jmitc91516 1:a5258871b33d 68 variablesForTouchArea[3].placesOfDecimals = 2;
jmitc91516 1:a5258871b33d 69 strcpy(variablesForTouchArea[3].variableTitle, "Res Point 1");
jmitc91516 1:a5258871b33d 70
jmitc91516 1:a5258871b33d 71 variablesForTouchArea[4].touchAreaIndex = COLUMN_DH_MANUAL_CALIB_EDIT_RES2;
jmitc91516 1:a5258871b33d 72 variablesForTouchArea[4].easyGUIVariablePtr = GuiVar_columnDHManualCalibRes2;
jmitc91516 1:a5258871b33d 73 variablesForTouchArea[4].maxValue = 99;
jmitc91516 1:a5258871b33d 74 variablesForTouchArea[4].placesOfDecimals = 2;
jmitc91516 1:a5258871b33d 75 strcpy(variablesForTouchArea[4].variableTitle, "Res Point 2");
jmitc91516 1:a5258871b33d 76
jmitc91516 1:a5258871b33d 77 variablesForTouchArea[5].touchAreaIndex = COLUMN_DH_MANUAL_CALIB_EDIT_RES3;
jmitc91516 1:a5258871b33d 78 variablesForTouchArea[5].easyGUIVariablePtr = GuiVar_columnDHManualCalibRes3;
jmitc91516 1:a5258871b33d 79 variablesForTouchArea[5].maxValue = 99;
jmitc91516 1:a5258871b33d 80 variablesForTouchArea[5].placesOfDecimals = 2;
jmitc91516 1:a5258871b33d 81 strcpy(variablesForTouchArea[5].variableTitle, "Res Point 3");
jmitc91516 1:a5258871b33d 82 }
jmitc91516 1:a5258871b33d 83
jmitc91516 1:a5258871b33d 84 // Private destructor also
jmitc91516 1:a5258871b33d 85 ColumnDHManualCalibrationPageHandler::~ColumnDHManualCalibrationPageHandler()
jmitc91516 1:a5258871b33d 86 {
jmitc91516 1:a5258871b33d 87 }
jmitc91516 1:a5258871b33d 88
jmitc91516 1:a5258871b33d 89
jmitc91516 1:a5258871b33d 90 /*
jmitc91516 1:a5258871b33d 91 Tells the caller whether or not the specified touch index is on the easyGUI 'ColumnDHAutoCalibrationPage',
jmitc91516 1:a5258871b33d 92 and therefore needs to be handled by this class.
jmitc91516 1:a5258871b33d 93
jmitc91516 1:a5258871b33d 94 Args: the touch area index in question
jmitc91516 1:a5258871b33d 95
jmitc91516 1:a5258871b33d 96 Return code: true if the touch area is 'one of ours', false if not
jmitc91516 1:a5258871b33d 97 */
jmitc91516 1:a5258871b33d 98 bool ColumnDHManualCalibrationPageHandler::TouchAreaIsOnCalibrationPage(int touchAreaIndex)
jmitc91516 1:a5258871b33d 99 {
jmitc91516 1:a5258871b33d 100 if((touchAreaIndex >= MIN_COLUMN_DH_MANUAL_CALIB_TOUCHINDEX) && (touchAreaIndex <= MAX_COLUMN_DH_MANUAL_CALIB_TOUCHINDEX)) {
jmitc91516 1:a5258871b33d 101 return true;
jmitc91516 1:a5258871b33d 102 }
jmitc91516 1:a5258871b33d 103
jmitc91516 1:a5258871b33d 104 // 'else'
jmitc91516 1:a5258871b33d 105 return false;
jmitc91516 1:a5258871b33d 106 }
jmitc91516 1:a5258871b33d 107
jmitc91516 1:a5258871b33d 108
jmitc91516 1:a5258871b33d 109 /*
jmitc91516 1:a5258871b33d 110 If the specified touch area represents a key or field on the easyGUI 'ColumnDHManualCalibrationPage',
jmitc91516 1:a5258871b33d 111 this function performs whatever action is appropriate for it. Provided so that the caller
jmitc91516 1:a5258871b33d 112 can (in effect) say "if this is one of yours, deal with it", without needing to know
jmitc91516 1:a5258871b33d 113 anything about what this class does, or how it handles the touch areas on that easyGUI page.
jmitc91516 1:a5258871b33d 114
jmitc91516 1:a5258871b33d 115 Args: the touch area index in question
jmitc91516 1:a5258871b33d 116
jmitc91516 1:a5258871b33d 117 Returns true if it dealt with the touch area (so the caller need not do anything else
jmitc91516 1:a5258871b33d 118 with the value), or false if it did not deal with the touch area (implying that it
jmitc91516 1:a5258871b33d 119 was not a touch area on the easyGUI 'Directly Heated Column Manual CalibrationPage', and so the caller
jmitc91516 1:a5258871b33d 120 must deal with it some other way).
jmitc91516 1:a5258871b33d 121 */
jmitc91516 1:a5258871b33d 122 bool ColumnDHManualCalibrationPageHandler::DealWithTouch(int touchAreaIndex)
jmitc91516 1:a5258871b33d 123 {
jmitc91516 1:a5258871b33d 124 bool dealtWithTouch = false; // so far...
jmitc91516 1:a5258871b33d 125
jmitc91516 1:a5258871b33d 126 // Has the user selected a field to edit -
jmitc91516 1:a5258871b33d 127 // if so, we will have an entry in our 'variablesForTouchArea' array that corresponds with this touch area
jmitc91516 1:a5258871b33d 128 int indexOfValueToEdit = GetIndexOfValueToEditForTouchArea(touchAreaIndex);
jmitc91516 1:a5258871b33d 129 if(indexOfValueToEdit != -1) {
jmitc91516 1:a5258871b33d 130 // User has selected a field to edit
jmitc91516 1:a5258871b33d 131 NumericKeypadPageHandler* numericKeypadPageHandler = NumericKeypadPageHandler::GetInstance(usbDevice, usbHostGC);
jmitc91516 1:a5258871b33d 132 if(numericKeypadPageHandler != NULL) {
jmitc91516 1:a5258871b33d 133 numericKeypadPageHandler->StartEditing(variablesForTouchArea[indexOfValueToEdit].easyGUIVariablePtr,
jmitc91516 1:a5258871b33d 134 variablesForTouchArea[indexOfValueToEdit].placesOfDecimals);
jmitc91516 1:a5258871b33d 135 numericKeypadPageHandler->SetEasyGUIVariableToEdit(variablesForTouchArea[indexOfValueToEdit].easyGUIVariablePtr);
jmitc91516 1:a5258871b33d 136 numericKeypadPageHandler->SetEasyGUICallingPage(GuiStruct_ColumnDHManualCalibrationPage_Def);
jmitc91516 1:a5258871b33d 137 numericKeypadPageHandler->SetEditVariableRange(0, variablesForTouchArea[indexOfValueToEdit].maxValue);
jmitc91516 1:a5258871b33d 138 numericKeypadPageHandler->SetEditVariableName(variablesForTouchArea[indexOfValueToEdit].variableTitle);
jmitc91516 1:a5258871b33d 139 numericKeypadPageHandler->DisplayEasyGUIPage();
jmitc91516 1:a5258871b33d 140 }
jmitc91516 1:a5258871b33d 141
jmitc91516 1:a5258871b33d 142 dealtWithTouch = true;
jmitc91516 1:a5258871b33d 143 }
jmitc91516 1:a5258871b33d 144
jmitc91516 1:a5258871b33d 145 if(!dealtWithTouch) {
jmitc91516 1:a5258871b33d 146 switch(touchAreaIndex) {
jmitc91516 1:a5258871b33d 147 case COLUMN_DH_MANUAL_CALIB_SET:
jmitc91516 1:a5258871b33d 148 SetCurrentCalibrationInGC();
jmitc91516 1:a5258871b33d 149 dealtWithTouch = true;
jmitc91516 1:a5258871b33d 150 break;
jmitc91516 1:a5258871b33d 151
jmitc91516 1:a5258871b33d 152 case COLUMN_DH_MANUAL_CALIB_GET:
jmitc91516 1:a5258871b33d 153 GetCurrentCalibrationFromGC();
jmitc91516 1:a5258871b33d 154 dealtWithTouch = true;
jmitc91516 1:a5258871b33d 155 break;
jmitc91516 1:a5258871b33d 156
jmitc91516 1:a5258871b33d 157 default: // Not recognised - do nothing
jmitc91516 1:a5258871b33d 158 break;
jmitc91516 1:a5258871b33d 159 }
jmitc91516 1:a5258871b33d 160 }
jmitc91516 1:a5258871b33d 161
jmitc91516 1:a5258871b33d 162 return dealtWithTouch;
jmitc91516 1:a5258871b33d 163 }
jmitc91516 1:a5258871b33d 164
jmitc91516 1:a5258871b33d 165
jmitc91516 1:a5258871b33d 166 /*
jmitc91516 1:a5258871b33d 167 Caller is telling us it is about to display the easyGUI 'ColumnDHManualCalibrationPage',
jmitc91516 1:a5258871b33d 168 and that we should do whatever we have to do to get it ready,
jmitc91516 1:a5258871b33d 169 before the caller displays it.
jmitc91516 1:a5258871b33d 170
jmitc91516 1:a5258871b33d 171 No arguments, no return code
jmitc91516 1:a5258871b33d 172 */
jmitc91516 1:a5258871b33d 173 void ColumnDHManualCalibrationPageHandler::DisplayingEasyGUIPage(bool updateEasyGUIVariables)
jmitc91516 1:a5258871b33d 174 {
jmitc91516 1:a5258871b33d 175 if(updateEasyGUIVariables) {
jmitc91516 1:a5258871b33d 176 GetCurrentCalibrationFromGC();
jmitc91516 1:a5258871b33d 177 }
jmitc91516 1:a5258871b33d 178 }
jmitc91516 1:a5258871b33d 179
jmitc91516 1:a5258871b33d 180
jmitc91516 1:a5258871b33d 181 /*
jmitc91516 1:a5258871b33d 182 Gets the current calibration temperature and resistance values from the GC,
jmitc91516 1:a5258871b33d 183 and copies them into the relevant easyGUI variables for display to the user.
jmitc91516 1:a5258871b33d 184
jmitc91516 1:a5258871b33d 185 No arguments, no return code
jmitc91516 1:a5258871b33d 186 */
jmitc91516 1:a5258871b33d 187 void ColumnDHManualCalibrationPageHandler::GetCurrentCalibrationFromGC(void)
jmitc91516 1:a5258871b33d 188 {
jmitc91516 1:a5258871b33d 189 GetColumnTemperaturePointFromGC(1, GuiVar_columnDHManualCalibTemp1);
jmitc91516 1:a5258871b33d 190 GetColumnResistancePointFromGC(1, GuiVar_columnDHManualCalibRes1);
jmitc91516 1:a5258871b33d 191
jmitc91516 1:a5258871b33d 192 GetColumnTemperaturePointFromGC(2, GuiVar_columnDHManualCalibTemp2);
jmitc91516 1:a5258871b33d 193 GetColumnResistancePointFromGC(2, GuiVar_columnDHManualCalibRes2);
jmitc91516 1:a5258871b33d 194
jmitc91516 1:a5258871b33d 195 GetColumnTemperaturePointFromGC(3, GuiVar_columnDHManualCalibTemp3);
jmitc91516 1:a5258871b33d 196 GetColumnResistancePointFromGC(3, GuiVar_columnDHManualCalibRes3);
jmitc91516 1:a5258871b33d 197 }
jmitc91516 1:a5258871b33d 198
jmitc91516 1:a5258871b33d 199
jmitc91516 1:a5258871b33d 200 /*
jmitc91516 1:a5258871b33d 201 Sets the calibration temperature and resistance values in the GC,
jmitc91516 1:a5258871b33d 202 to match the values we are currently displayin to the user.
jmitc91516 1:a5258871b33d 203
jmitc91516 1:a5258871b33d 204 No arguments, no return code
jmitc91516 1:a5258871b33d 205 */
jmitc91516 1:a5258871b33d 206 void ColumnDHManualCalibrationPageHandler::SetCurrentCalibrationInGC(void)
jmitc91516 1:a5258871b33d 207 {
jmitc91516 1:a5258871b33d 208 SetColumnTemperaturePointInGC(1, GuiVar_columnDHManualCalibTemp1);
jmitc91516 1:a5258871b33d 209 SetColumnResistancePointInGC(1, GuiVar_columnDHManualCalibRes1);
jmitc91516 1:a5258871b33d 210
jmitc91516 1:a5258871b33d 211 SetColumnTemperaturePointInGC(2, GuiVar_columnDHManualCalibTemp2);
jmitc91516 1:a5258871b33d 212 SetColumnResistancePointInGC(2, GuiVar_columnDHManualCalibRes2);
jmitc91516 1:a5258871b33d 213
jmitc91516 1:a5258871b33d 214 SetColumnTemperaturePointInGC(3, GuiVar_columnDHManualCalibTemp3);
jmitc91516 1:a5258871b33d 215 SetColumnResistancePointInGC(3, GuiVar_columnDHManualCalibRes3);
jmitc91516 1:a5258871b33d 216 }
jmitc91516 1:a5258871b33d 217
jmitc91516 1:a5258871b33d 218
jmitc91516 1:a5258871b33d 219 /*
jmitc91516 1:a5258871b33d 220 As the name implies, sends a command to the GC and returns the response.
jmitc91516 1:a5258871b33d 221
jmitc91516 1:a5258871b33d 222 Args: pointer to a buffer containing the command, as a null-terminated string
jmitc91516 1:a5258871b33d 223 pointer to a buffer to contain the response, as a null-terminated string
jmitc91516 1:a5258871b33d 224
jmitc91516 1:a5258871b33d 225 No return code (it is up to the caller to examine the response to see whether
jmitc91516 1:a5258871b33d 226 the command succeeded or failed)
jmitc91516 1:a5258871b33d 227 */
jmitc91516 1:a5258871b33d 228 void ColumnDHManualCalibrationPageHandler::SendCommandToGCAndGetResponse(char* command, char* response)
jmitc91516 1:a5258871b33d 229 {
jmitc91516 1:a5258871b33d 230 #define USE_GC_UTILS // Testing new class
jmitc91516 1:a5258871b33d 231 #ifdef USE_GC_UTILS
jmitc91516 1:a5258871b33d 232 USBHostGCUtilities::SendCommandToGCAndGetResponse(usbDevice, usbHostGC, command, response);
jmitc91516 1:a5258871b33d 233 #else
jmitc91516 1:a5258871b33d 234 while(usbHostGC->ExecutingSetDeviceReport()) {}
jmitc91516 1:a5258871b33d 235
jmitc91516 1:a5258871b33d 236 usbHostGC->SetDeviceReport(usbDevice, command, response);
jmitc91516 1:a5258871b33d 237 //#define DEBUG_PRINT_HERE
jmitc91516 1:a5258871b33d 238 #ifdef DEBUG_PRINT_HERE
jmitc91516 1:a5258871b33d 239 char dbg[100];
jmitc91516 1:a5258871b33d 240 sprintf(dbg, "SCTGC cmd \"%s\", response \"%s\"", command, response);
jmitc91516 1:a5258871b33d 241 SpecialDebugPrint(dbg, 10, 275);
jmitc91516 1:a5258871b33d 242 #endif // DEBUG_PRINT_HERE
jmitc91516 1:a5258871b33d 243 #endif // USE_GC_UTILS
jmitc91516 1:a5258871b33d 244 }
jmitc91516 1:a5258871b33d 245
jmitc91516 1:a5258871b33d 246
jmitc91516 1:a5258871b33d 247 /*
jmitc91516 1:a5258871b33d 248 Sends a command to the GC for which we expect a response of "DACK" if successful,
jmitc91516 1:a5258871b33d 249 "DNAK" or "EPKT" if failure.
jmitc91516 1:a5258871b33d 250
jmitc91516 1:a5258871b33d 251 Args: a pointer to the command in question, as a null terminated string
jmitc91516 1:a5258871b33d 252
jmitc91516 1:a5258871b33d 253 Returns true if the GC responded with "DACK", false for anything else
jmitc91516 1:a5258871b33d 254 */
jmitc91516 1:a5258871b33d 255 bool ColumnDHManualCalibrationPageHandler::SendCommandToGCWithDACKResponse(char *cmd)
jmitc91516 1:a5258871b33d 256 {
jmitc91516 1:a5258871b33d 257 #define USE_GC_UTILS // Testing new class
jmitc91516 1:a5258871b33d 258 #ifdef USE_GC_UTILS
jmitc91516 1:a5258871b33d 259 return USBHostGCUtilities::SendCommandToGCWithDACKResponse(usbDevice, usbHostGC, cmd);
jmitc91516 1:a5258871b33d 260 #else
jmitc91516 1:a5258871b33d 261 char response[50];
jmitc91516 1:a5258871b33d 262 SendCommandToGCAndGetResponse(cmd, response);
jmitc91516 1:a5258871b33d 263 // We expect a response like this: "DACK" for success, "DNAK" for failure, "EPKT" for error
jmitc91516 1:a5258871b33d 264
jmitc91516 1:a5258871b33d 265 return (response[1] == 'A');
jmitc91516 1:a5258871b33d 266 #endif // USE_GC_UTILS
jmitc91516 1:a5258871b33d 267 }
jmitc91516 1:a5258871b33d 268
jmitc91516 1:a5258871b33d 269
jmitc91516 1:a5258871b33d 270 /*
jmitc91516 1:a5258871b33d 271 There are three temperature points included in the manual calibration of the DH column.
jmitc91516 1:a5258871b33d 272 This function gets the value for the specified point, and copies it
jmitc91516 1:a5258871b33d 273 into the specified easyGUI variable (to be displayed on the easyGUI ColumnDHManualCalibration page).
jmitc91516 1:a5258871b33d 274
jmitc91516 1:a5258871b33d 275 Args: the number of the point to be displayed (1, 2 or 3)
jmitc91516 1:a5258871b33d 276 a pointer to the corresponding easyGUI variable
jmitc91516 1:a5258871b33d 277
jmitc91516 1:a5258871b33d 278 Returns true if successful, false if not.
jmitc91516 1:a5258871b33d 279 */
jmitc91516 1:a5258871b33d 280 bool ColumnDHManualCalibrationPageHandler::GetColumnTemperaturePointFromGC(int pointNumber, GuiConst_TEXT* easyGUIVariable)
jmitc91516 1:a5258871b33d 281 {
jmitc91516 1:a5258871b33d 282 char cmd[50];
jmitc91516 1:a5258871b33d 283 char response[50];
jmitc91516 1:a5258871b33d 284
jmitc91516 1:a5258871b33d 285 if((pointNumber < 1) || (pointNumber > 3)) {
jmitc91516 1:a5258871b33d 286 return false;
jmitc91516 1:a5258871b33d 287 }
jmitc91516 1:a5258871b33d 288
jmitc91516 1:a5258871b33d 289 sprintf(cmd, "GCT%d", pointNumber);
jmitc91516 1:a5258871b33d 290
jmitc91516 1:a5258871b33d 291 SendCommandToGCAndGetResponse(cmd, response);
jmitc91516 1:a5258871b33d 292
jmitc91516 1:a5258871b33d 293 if(response[0] != 'D') return false;
jmitc91516 1:a5258871b33d 294 if(response[1] != 'C') return false;
jmitc91516 1:a5258871b33d 295 if(response[2] != 'T') return false;
jmitc91516 1:a5258871b33d 296 if(response[3] != cmd[3]) return false;
jmitc91516 1:a5258871b33d 297
jmitc91516 1:a5258871b33d 298 // Response is in units of 1/10 degree C -
jmitc91516 1:a5258871b33d 299 // and we don't want leading zeroes
jmitc91516 1:a5258871b33d 300 int index = 0;
jmitc91516 1:a5258871b33d 301 bool wantZeroes = false;
jmitc91516 1:a5258871b33d 302 if(response[4] != '0') {
jmitc91516 1:a5258871b33d 303 easyGUIVariable[index++] = response[4];
jmitc91516 1:a5258871b33d 304 wantZeroes = true;
jmitc91516 1:a5258871b33d 305 }
jmitc91516 1:a5258871b33d 306 if((response[5] != '0') || wantZeroes) {
jmitc91516 1:a5258871b33d 307 easyGUIVariable[index++] = response[5];
jmitc91516 1:a5258871b33d 308 }
jmitc91516 1:a5258871b33d 309 easyGUIVariable[index++] = response[6];
jmitc91516 1:a5258871b33d 310 easyGUIVariable[index++] = '.';
jmitc91516 1:a5258871b33d 311 easyGUIVariable[index++] = response[7];
jmitc91516 1:a5258871b33d 312 easyGUIVariable[index] = '\0';
jmitc91516 1:a5258871b33d 313
jmitc91516 1:a5258871b33d 314 return true;
jmitc91516 1:a5258871b33d 315 }
jmitc91516 1:a5258871b33d 316
jmitc91516 1:a5258871b33d 317
jmitc91516 1:a5258871b33d 318 /*
jmitc91516 1:a5258871b33d 319 There are three temperature points included in the manual calibration of the DH column.
jmitc91516 1:a5258871b33d 320 This function sets the value for the specified point in the GC from our internal variable,
jmitc91516 1:a5258871b33d 321 whose value matches the one displayed to the user in the relevant easyGUI variable.
jmitc91516 1:a5258871b33d 322
jmitc91516 1:a5258871b33d 323 Args: the number of the point to be displayed (1, 2 or 3)
jmitc91516 1:a5258871b33d 324
jmitc91516 1:a5258871b33d 325 Returns true if successful, false if not.
jmitc91516 1:a5258871b33d 326 */
jmitc91516 1:a5258871b33d 327 bool ColumnDHManualCalibrationPageHandler::SetColumnTemperaturePointInGC(int pointNumber, GuiConst_TEXT* easyGUIVariable)
jmitc91516 1:a5258871b33d 328 {
jmitc91516 1:a5258871b33d 329 char cmd[50];
jmitc91516 1:a5258871b33d 330
jmitc91516 1:a5258871b33d 331 if((pointNumber < 1) || (pointNumber > 3)) {
jmitc91516 1:a5258871b33d 332 return false;
jmitc91516 1:a5258871b33d 333 }
jmitc91516 1:a5258871b33d 334
jmitc91516 1:a5258871b33d 335 // temperature is passed to the GC in units of 0.1 degree C
jmitc91516 1:a5258871b33d 336 float temp;
jmitc91516 1:a5258871b33d 337 sscanf(easyGUIVariable, "%f", &temp);
jmitc91516 1:a5258871b33d 338 int gcTemp = (int)(temp * 10.0f);
jmitc91516 1:a5258871b33d 339
jmitc91516 1:a5258871b33d 340 // In the command, the temperature value must have 4 digits, padded if necessary with leading zeroes
jmitc91516 1:a5258871b33d 341 sprintf(cmd, "SCT%d%.4d", pointNumber, gcTemp);
jmitc91516 1:a5258871b33d 342
jmitc91516 1:a5258871b33d 343 return SendCommandToGCWithDACKResponse(cmd);
jmitc91516 1:a5258871b33d 344 }
jmitc91516 1:a5258871b33d 345
jmitc91516 1:a5258871b33d 346
jmitc91516 1:a5258871b33d 347 /*
jmitc91516 1:a5258871b33d 348 There are three resistance points included in the manual calibration of the DH column.
jmitc91516 1:a5258871b33d 349 This function gets the value for the specified point, and copies it
jmitc91516 1:a5258871b33d 350 into the specified easyGUI variable (to be displayed on the easyGUI ColumnDHManualCalibration page).
jmitc91516 1:a5258871b33d 351
jmitc91516 1:a5258871b33d 352 Args: the number of the point to be displayed (1, 2 or 3)
jmitc91516 1:a5258871b33d 353 a pointer to the corresponding easyGUI variable
jmitc91516 1:a5258871b33d 354
jmitc91516 1:a5258871b33d 355 Returns true if successful, false if not.
jmitc91516 1:a5258871b33d 356 */
jmitc91516 1:a5258871b33d 357 bool ColumnDHManualCalibrationPageHandler::GetColumnResistancePointFromGC(int pointNumber, GuiConst_TEXT* easyGUIVariable)
jmitc91516 1:a5258871b33d 358 {
jmitc91516 1:a5258871b33d 359 char cmd[50];
jmitc91516 1:a5258871b33d 360 char response[50];
jmitc91516 1:a5258871b33d 361
jmitc91516 1:a5258871b33d 362 if((pointNumber < 1) || (pointNumber > 3)) {
jmitc91516 1:a5258871b33d 363 return false;
jmitc91516 1:a5258871b33d 364 }
jmitc91516 1:a5258871b33d 365
jmitc91516 1:a5258871b33d 366 sprintf(cmd, "GCR%d", pointNumber);
jmitc91516 1:a5258871b33d 367
jmitc91516 1:a5258871b33d 368 SendCommandToGCAndGetResponse(cmd, response);
jmitc91516 1:a5258871b33d 369
jmitc91516 1:a5258871b33d 370 if(response[0] != 'D') return false;
jmitc91516 1:a5258871b33d 371 if(response[1] != 'C') return false;
jmitc91516 1:a5258871b33d 372 if(response[2] != 'R') return false;
jmitc91516 1:a5258871b33d 373 if(response[3] != cmd[3]) return false;
jmitc91516 1:a5258871b33d 374
jmitc91516 1:a5258871b33d 375 // Response is in units of 1/100 ohm -
jmitc91516 1:a5258871b33d 376 // and we don't want leading zeroes
jmitc91516 1:a5258871b33d 377 int index = 0;
jmitc91516 1:a5258871b33d 378 if(response[4] != '0') easyGUIVariable[index++] = response[4];
jmitc91516 1:a5258871b33d 379 easyGUIVariable[index++] = response[5];
jmitc91516 1:a5258871b33d 380 easyGUIVariable[index++] = '.';
jmitc91516 1:a5258871b33d 381 easyGUIVariable[index++] = response[6];
jmitc91516 1:a5258871b33d 382 easyGUIVariable[index++] = response[7];
jmitc91516 1:a5258871b33d 383 easyGUIVariable[index] = '\0';
jmitc91516 1:a5258871b33d 384
jmitc91516 1:a5258871b33d 385 return true;
jmitc91516 1:a5258871b33d 386 }
jmitc91516 1:a5258871b33d 387
jmitc91516 1:a5258871b33d 388
jmitc91516 1:a5258871b33d 389 /*
jmitc91516 1:a5258871b33d 390 There are three resistance points included in the manual calibration of the DH column.
jmitc91516 1:a5258871b33d 391 This function sets the value for the specified point in the GC from our internal variable,
jmitc91516 1:a5258871b33d 392 whose value matches the one displayed to the user in the relevant easyGUI variable.
jmitc91516 1:a5258871b33d 393
jmitc91516 1:a5258871b33d 394 Args: the number of the point to be displayed (1, 2 or 3)
jmitc91516 1:a5258871b33d 395
jmitc91516 1:a5258871b33d 396 Returns true if successful, false if not.
jmitc91516 1:a5258871b33d 397 */
jmitc91516 1:a5258871b33d 398 bool ColumnDHManualCalibrationPageHandler::SetColumnResistancePointInGC(int pointNumber, GuiConst_TEXT* easyGUIVariable)
jmitc91516 1:a5258871b33d 399 {
jmitc91516 1:a5258871b33d 400 char cmd[50];
jmitc91516 1:a5258871b33d 401
jmitc91516 1:a5258871b33d 402 if((pointNumber < 1) || (pointNumber > 3)) {
jmitc91516 1:a5258871b33d 403 return false;
jmitc91516 1:a5258871b33d 404 }
jmitc91516 1:a5258871b33d 405
jmitc91516 1:a5258871b33d 406 // Resistance is passed to the GC in units of 0.01 ohm
jmitc91516 1:a5258871b33d 407 float res;
jmitc91516 1:a5258871b33d 408 sscanf(easyGUIVariable, "%f", &res);
jmitc91516 1:a5258871b33d 409 int gcRes = (int)(res * 100.0f);
jmitc91516 1:a5258871b33d 410
jmitc91516 1:a5258871b33d 411 // In the command, the resistance value must have 4 digits, padded if necessary with leading zeroes
jmitc91516 1:a5258871b33d 412 sprintf(cmd, "SCR%d%.4d", pointNumber, gcRes);
jmitc91516 1:a5258871b33d 413
jmitc91516 1:a5258871b33d 414 return SendCommandToGCWithDACKResponse(cmd);
jmitc91516 1:a5258871b33d 415 }
jmitc91516 1:a5258871b33d 416
jmitc91516 1:a5258871b33d 417
jmitc91516 1:a5258871b33d 418 /*
jmitc91516 1:a5258871b33d 419 (Re)display the easyGUI 'ColumnDHManualCalibrationPage' -
jmitc91516 1:a5258871b33d 420 e.g. after the caller has updated one or more of the easyGUI variables
jmitc91516 1:a5258871b33d 421 included in the page, and wants to display the new value to the user.
jmitc91516 1:a5258871b33d 422
jmitc91516 1:a5258871b33d 423 No arguments, no return code
jmitc91516 1:a5258871b33d 424 */
jmitc91516 1:a5258871b33d 425 void ColumnDHManualCalibrationPageHandler::UpdateEasyGUIPage(void)
jmitc91516 1:a5258871b33d 426 {
jmitc91516 1:a5258871b33d 427 GetGCStatusLoop *getGCStatusLoop = GetGCStatusLoop::GetInstance();
jmitc91516 1:a5258871b33d 428
jmitc91516 1:a5258871b33d 429 if(getGCStatusLoop != NULL) {
jmitc91516 1:a5258871b33d 430 // The Gas Calibration page has a status rectangle for the gas -
jmitc91516 1:a5258871b33d 431 // GetGCStatusLoop can display this, we cannot
jmitc91516 1:a5258871b33d 432 getGCStatusLoop->ForceUpdateOfColumnDHManualCalibrationPage();
jmitc91516 1:a5258871b33d 433 }
jmitc91516 1:a5258871b33d 434 }
jmitc91516 1:a5258871b33d 435
jmitc91516 1:a5258871b33d 436
jmitc91516 1:a5258871b33d 437 /*
jmitc91516 1:a5258871b33d 438 Tells the caller if the specified touch area corresponds to a value the user can edit
jmitc91516 1:a5258871b33d 439 on the easyGUI 'ColumnDHManualCalibrationPage', and if so, which one.
jmitc91516 1:a5258871b33d 440
jmitc91516 1:a5258871b33d 441 Args: the touch area index in question
jmitc91516 1:a5258871b33d 442
jmitc91516 1:a5258871b33d 443 Returns the index of the corresponding entry in our 'variablesForTouchArea' array,
jmitc91516 1:a5258871b33d 444 or -1 if there is no such entry. It is up to the caller to check for -1
jmitc91516 1:a5258871b33d 445 **************************************
jmitc91516 1:a5258871b33d 446 */
jmitc91516 1:a5258871b33d 447 int ColumnDHManualCalibrationPageHandler::GetIndexOfValueToEditForTouchArea(int touchAreaIndex)
jmitc91516 1:a5258871b33d 448 {
jmitc91516 1:a5258871b33d 449 for (int index = 0; index < COUNT_OF_VARIABLES_FOR_TOUCH_AREAS; ++index) {
jmitc91516 1:a5258871b33d 450 if(variablesForTouchArea[index].touchAreaIndex == touchAreaIndex) {
jmitc91516 1:a5258871b33d 451 return index;
jmitc91516 1:a5258871b33d 452 }
jmitc91516 1:a5258871b33d 453 }
jmitc91516 1:a5258871b33d 454
jmitc91516 1:a5258871b33d 455 // 'else' no Column DH Manual Calibration value corresponds to the specified touch area
jmitc91516 1:a5258871b33d 456 return -1;
jmitc91516 1:a5258871b33d 457 }