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
TouchPanelPageSelector.cpp
00001 #include "TouchPanelPageSelector.h" 00002 00003 #include "EasyGUITouchAreaIndices.h" 00004 #include "ServiceInterval.h" 00005 #include "ColumnDHAutoCalibrationPageHandler.h" 00006 #include "DetectorIgnitionHandler.h" 00007 00008 00009 //#define FORCE_DIRECTLY_HEATED_COLUMN // For testing/debugging - pretend we have a directly heated column 00010 // (regardless of what we actually have) 00011 00012 #define USE_DH_COLUMN_AUTO_CALIBRATION_PAGE // Otherwise (i.e. if commented out) use manual calibration page 00013 00014 /* 00015 TouchPanelPageSelector class 00016 */ 00017 00018 /* 00019 static members 00020 */ 00021 bool TouchPanelPageSelector::pageChangeEnabled = true; 00022 00023 00024 // The default constructor exists purely to satisfy the compiler - it is not intended to be used 00025 TouchPanelPageSelector::TouchPanelPageSelector() 00026 { 00027 panelIndex = -1; 00028 00029 pageNumber = -1; 00030 } 00031 00032 TouchPanelPageSelector::TouchPanelPageSelector(int index, int page) 00033 { 00034 panelIndex = index; 00035 00036 pageNumber = page; 00037 } 00038 00039 00040 /* 00041 TouchPanelDetectorPageSelector class 00042 */ 00043 00044 // The default constructor exists purely to satisfy the compiler - it is not intended to be used 00045 TouchPanelDetectorPageSelector::TouchPanelDetectorPageSelector() : TouchPanelPageSelector() 00046 { 00047 } 00048 00049 // We do not use the base class' page number in this class - we calculate it 'on the fly' - see below 00050 TouchPanelDetectorPageSelector::TouchPanelDetectorPageSelector(int index) : TouchPanelPageSelector(index, -1) 00051 { 00052 } 00053 00054 /* 00055 For the detector, the page number varies according to the detector type. 00056 This function calculates the correct page number, and returns it. 00057 00058 Params: USBDeviceConnected and USBHostGC corresponding to the GC 00059 */ 00060 int TouchPanelDetectorPageSelector::GetPageNumber(USBDeviceConnected* usbDevice, USBHostGC* usbHostGC) 00061 { 00062 switch(GetDetectorType(usbDevice, usbHostGC)) { 00063 case FID_DETECTOR: 00064 return GuiStruct_DetectorFIDPage_4; 00065 case TCD_DETECTOR: 00066 return GuiStruct_DetectorTCDPage_11; 00067 case ECD_DETECTOR: 00068 return GuiStruct_DetectorECDPage_12; 00069 case TXL_DETECTOR: 00070 return GuiStruct_DetectorTXLPage_27; 00071 // case 4 is "None" - leave for default 00072 case NPD_DETECTOR: 00073 return GuiStruct_DetectorNPDPage_28; 00074 case PID_DETECTOR: 00075 return GuiStruct_DetectorPIDPage_29; 00076 case FPD_DETECTOR: 00077 return GuiStruct_DetectorFPDPage_14; 00078 case SPDID_DETECTOR: 00079 return GuiStruct_DetectorSPDIDPage_30; 00080 default: // i.e. all other types (including "None") 00081 break; // Return default (see below) 00082 } 00083 00084 // Default return code 00085 return GuiStruct_DetectorNonePage_31; 00086 } 00087 00088 /* 00089 Gets the detector type from the GC, and returns it as a DetectorType enumeration. 00090 00091 Params: USBDeviceConnected and USBHostGC corresponding to the GC 00092 */ 00093 DetectorType TouchPanelDetectorPageSelector::GetDetectorType(USBDeviceConnected* usbDevice, USBHostGC* usbHostGC) 00094 { 00095 char response[50]; 00096 while(usbHostGC->ExecutingSetDeviceReport()) {} 00097 00098 usbHostGC->SetDeviceReport(usbDevice, "GDTY", response); 00099 00100 // We expect a response like this: "DDTY0000" for FID, "DDTY0001" for TCD, 00101 // "DDTY0002" for ECD, "DDTY0003" for TXL, "DDTY0004" for "None", "DDTY0005" for NPD, 00102 // "DDTY0006" for PID, "DDTY0007" for FPD, "DDTY0008" for SPDID. 00103 // We assume any other "DDTY00nn" value means "None". 00104 00105 // We convert the final two digits to an integer 00106 int type; 00107 sscanf(&response[6], "%d", &type); 00108 00109 // Now we convert the integer value to a DetectorType 00110 DetectorType detectorType; 00111 if((type < MIN_DETECTOR_TYPE) || (type > MAX_DETECTOR_TYPE)) { 00112 detectorType = NO_DETECTOR; 00113 } else { 00114 detectorType = (DetectorType) type; 00115 } 00116 00117 return detectorType; 00118 } 00119 00120 00121 /* 00122 TouchPanelAbortRunPageSelector class 00123 */ 00124 00125 // The default constructor exists purely to satisfy the compiler - it is not intended to be used 00126 TouchPanelAbortRunPageSelector::TouchPanelAbortRunPageSelector() : TouchPanelPageSelector() 00127 { 00128 } 00129 00130 // We do not use the base class' page number in this class - we calculate it 'on the fly' - see below 00131 TouchPanelAbortRunPageSelector::TouchPanelAbortRunPageSelector(int index) : TouchPanelPageSelector(index, -1) 00132 { 00133 } 00134 00135 /* 00136 When the user aborts the run, we will normally display the Home page. But if any components 00137 now require servicing (since even an aborted run counts as one 'cycle', and some components 00138 require servicing after a particular number of cycles), we want to display 00139 the 'Servicing Required' page instead. This function decides which page to display, 00140 and returns its number. 00141 00142 Params: USBDeviceConnected and USBHostGC corresponding to the GC 00143 (these are not used in this class) 00144 */ 00145 int TouchPanelAbortRunPageSelector::GetPageNumber(USBDeviceConnected* usbDevice, USBHostGC* usbHostGC) 00146 { 00147 if(ServiceInterval::AtLeastOneServiceIntervalHasExpired()) { 00148 return GuiStruct_ServicingRequired_Def; 00149 } 00150 00151 // 'else'... 00152 return GuiStruct_HomePage_1; 00153 } 00154 00155 00156 00157 00158 00159 00160 /* 00161 TouchPanelReturnPageSelector class 00162 */ 00163 00164 // The default constructor exists purely to satisfy the compiler - it is not intended to be used 00165 TouchPanelReturnPageSelector::TouchPanelReturnPageSelector() : TouchPanelPageSelector() 00166 { 00167 thisIsTheReturnInstance = false; 00168 } 00169 00170 /* 00171 In this constructor, 'index' is the number of the easyGUI touch area to which this instance corresponds, 'pageToDisplayNow' is the easyGUI page("structure") number to which this instance corresponds, 00172 and 'thisWillBeTheReturnInstance' is a boolean that, if false, says that this instance's 'GetPageNumber' function records 'pageToReturnTo' as the page to be returned to, 00173 then tells the caller 'go to pageToDisplayNow' - or, if true, says that this instance's 'GetPageNumber' function returns the number of the page to be returned to. 00174 */ 00175 TouchPanelReturnPageSelector::TouchPanelReturnPageSelector(int index, int pageToReturnTo, int pageToDisplayNow, bool thisWillBeTheReturnInstance) : TouchPanelPageSelector(index, pageToDisplayNow) 00176 { 00177 thisReturnPage = pageToReturnTo; 00178 00179 thisIsTheReturnInstance = thisWillBeTheReturnInstance; 00180 } 00181 00182 int TouchPanelReturnPageSelector::GetPageNumber(USBDeviceConnected* usbDevice, USBHostGC* usbHostGC) 00183 { 00184 if(thisIsTheReturnInstance) { 00185 if(theReturnPage == -1) { 00186 // Return page not yet set - as a default, return the page number we were given when we were constructed 00187 return thisReturnPage; 00188 } 00189 // 'else' we have a return page number 00190 return theReturnPage; 00191 } 00192 00193 // 'else' this is a 'calling' instance - record our return page 00194 // as the one to return to, then return (to the caller) the page to display now 00195 00196 theReturnPage = thisReturnPage; 00197 00198 return GetBasePageNumber(); 00199 } 00200 00201 // Static variable - all instances of TouchPanelReturnPageSelector share the same return page. 00202 // (Note that this is only one variable, not a stack - if we want 'overlapping' return pages 00203 // at some point, this will have to be changed.) 00204 int TouchPanelReturnPageSelector::theReturnPage = -1; 00205 00206 00207 /* 00208 TouchPanelPageSelectors class 00209 */ 00210 00211 // TouchPanelPageSelectors constructor - set up the array of page selectors 00212 TouchPanelPageSelectors::TouchPanelPageSelectors() 00213 { 00214 // Note that the touch area indexes, etc, below 00215 // are hardcoded to match those set up in easyGUI. 00216 // There seems to be no way to get these values from easyGUI at runtime. 00217 // See EasyGUITouchAreaIndices.h for the actual numerical values. 00218 00219 // Note also that we have two touch areas each for the Column, Injector, 00220 // Detector and Gas (which overlap in each case - see the easyGUI project). 00221 // This is so that we can (nearly) fill the relevant rectangle on the Home Page 00222 // with touch areas, without overlapping the Run button at the centre. 00223 00224 // The TouchCallback function (main.cpp) is the main user of this. As well as getting, from this class, 00225 // the page to be displayed in response to the user touching a particular touch area, it also performs 00226 // any other actions (e.g. telling the GC to abort the run, etc) that may be required before we can display the new page. 00227 00228 // Another note - there are multiple Abort Run pages, which are all identical apart from the touch index of the No button (this is of course invisible to the user). 00229 // Each one is invoked from the Abort Run button on a different 'Running xxx' page, where 'xxx' is one of the components (Column, Injector, etc). 00230 // This is so that we know which page to return to if the user presses 'No' - the index of the 'No' button tells us which Abort Run page the user is on, 00231 // therefore which page he pressed the 'Abort Run' button on - and that is the page we need to return to. Otherwise (i.e. if we had a single Abort Run page), 00232 // the code here would be much more complicated. 00233 00234 // And another... The Detector pages are different for the different detector types. This is why, for these pages, we use 00235 // the TouchPanelDetectorPageSelector class, derived from TouchPanelPageSelector, 00236 // which find out the detector type at runtime, and return the corresponding page numbers. 00237 00238 tppsArray[0] = new TouchPanelPageSelector(HOME_BUTTON, GuiStruct_HomePage_1); 00239 tppsArray[1] = new TouchPanelPageSelector(SETTINGS_BUTTON, GuiStruct_SettingsPage_5); 00240 tppsArray[2] = new TouchPanelPageSelector(COLUMN_TOUCH_AREA_1, GuiStruct_ColumnPage2_9); 00241 tppsArray[3] = new TouchPanelPageSelector(INJECTOR_TOUCH_AREA_1, GuiStruct_InjectorPage1_3); 00242 // tppsArray[4] = new TouchPanelPageSelector(5, GuiStruct_DefaultDetectorPage1_4); 00243 tppsArray[4] = new TouchPanelDetectorPageSelector(DETECTOR_TOUCH_AREA_1); 00244 tppsArray[5] = new TouchPanelPageSelector(GAS_TOUCH_AREA_1, GuiStruct_GasInformationPage_6); 00245 tppsArray[6] = new TouchPanelPageSelector(COLUMN_TOUCH_AREA_2, GuiStruct_ColumnPage2_9); 00246 tppsArray[7] = new TouchPanelPageSelector(INJECTOR_TOUCH_AREA_2, GuiStruct_InjectorPage1_3); // Second (overlapping) 'Injector' touch area on Home page 00247 // tppsArray[8] = new TouchPanelPageSelector(9, GuiStruct_DefaultDetectorPage1_4); 00248 tppsArray[8] = new TouchPanelDetectorPageSelector(DETECTOR_TOUCH_AREA_2); // Second (overlapping) 'Detector' touch area on Home page 00249 tppsArray[9] = new TouchPanelPageSelector(GAS_TOUCH_AREA_2, GuiStruct_GasInformationPage_6); // Second (overlapping) 'Gas' touch area on Home page 00250 00251 tppsArray[10] = new TouchPanelReturnPageSelector(RUNNING_PAGE1_ABORT_RUN, GuiStruct_RunningPage1_7, GuiStruct_AbortRunPage_19, false); 00252 tppsArray[11] = new TouchPanelReturnPageSelector(RUNNING_COLUMN_ABORT_RUN, GuiStruct_RunningColumnPage_25, GuiStruct_AbortRunPage_19, false); 00253 tppsArray[12] = new TouchPanelReturnPageSelector(RUNNING_INJECTOR_ABORT_RUN, GuiStruct_RunningInjectorPage_26, GuiStruct_AbortRunPage_19, false); 00254 tppsArray[13] = new TouchPanelReturnPageSelector(RUNNING_DETECTOR_ABORT_RUN, GuiStruct_RunningDetectorPage_27, GuiStruct_AbortRunPage_19, false); 00255 tppsArray[14] = new TouchPanelReturnPageSelector(RUNNING_GAS_ABORT_RUN, GuiStruct_RunningGasPage_28, GuiStruct_AbortRunPage_19, false); 00256 tppsArray[15] = new TouchPanelReturnPageSelector(RUNNING_INJECTOR_PROFILE_ABORT_RUN, GuiStruct_RunningInjectorProfilePage_Def, GuiStruct_AbortRunPage_19, false); 00257 tppsArray[16] = new TouchPanelAbortRunPageSelector(ABORT_RUN_YES); 00258 tppsArray[17] = new TouchPanelReturnPageSelector(ABORT_RUN_NO, GuiStruct_AbortRunPage_19, GuiStruct_RunningPage1_7, true); 00259 00260 tppsArray[18] = new TouchPanelPageSelector(GAS_INFO_LEFT_ARROW, GuiStruct_GasProfilePage_15); 00261 tppsArray[19] = new TouchPanelPageSelector(GAS_INFO_RIGHT_ARROW, GuiStruct_GasMethodPage_Def); 00262 tppsArray[20] = new TouchPanelPageSelector(GAS_METHOD_LEFT_ARROW, GuiStruct_GasInformationPage_6); 00263 tppsArray[21] = new TouchPanelPageSelector(GAS_METHOD_RIGHT_ARROW, GuiStruct_GasProfilePage_15); 00264 tppsArray[22] = new TouchPanelPageSelector(GAS_PROFILE_LEFT_ARROW, GuiStruct_GasMethodPage_Def); 00265 tppsArray[23] = new TouchPanelPageSelector(GAS_PROFILE_RIGHT_ARROW, GuiStruct_GasInformationPage_6); 00266 00267 tppsArray[24] = new TouchPanelPageSelector(GAS_SAVER_RETURN_TO_READY, GuiStruct_HomePage_1); // 'Return to ready state' touch area on Gas Saver page (covers entire page) 00268 00269 // Note - we now use the same pages for the conventional and directly heated columns 00270 tppsArray[25] = new TouchPanelPageSelector(COLUMN_PAGE2_LEFT_ARROW, GuiStruct_ColumnTempProfilePage_60); 00271 tppsArray[26] = new TouchPanelPageSelector(COLUMN_PAGE2_RIGHT_ARROW, GuiStruct_ColumnMethodPage_Def); 00272 tppsArray[27] = new TouchPanelPageSelector(COLUMN_METHOD_LEFT_ARROW, GuiStruct_ColumnPage2_9); 00273 tppsArray[28] = new TouchPanelPageSelector(COLUMN_METHOD_RIGHT_ARROW, GuiStruct_ColumnTempProfilePage_60); 00274 tppsArray[29] = new TouchPanelPageSelector(COLUMN_PROFILE_LEFT_ARROW, GuiStruct_ColumnMethodPage_Def); 00275 tppsArray[30] = new TouchPanelPageSelector(COLUMN_PROFILE_RIGHT_ARROW, GuiStruct_ColumnPage2_9); 00276 00277 tppsArray[31] = new TouchPanelPageSelector(CLEAR_ERRORS_BUTTON, GuiStruct_HomePage_1); // 'Clear Errors' button on 'GC in fault state' page 00278 00279 tppsArray[32] = new TouchPanelPageSelector(INJECTOR_PAGE1_LEFT_ARROW, GuiStruct_InjectorTempProfilePage_25); 00280 tppsArray[33] = new TouchPanelPageSelector(INJECTOR_PAGE1_RIGHT_ARROW, GuiStruct_InjectorMethodPage_Def); 00281 tppsArray[34] = new TouchPanelPageSelector(INJECTOR_METHOD_LEFT_ARROW, GuiStruct_InjectorPage1_3); 00282 tppsArray[35] = new TouchPanelPageSelector(INJECTOR_METHOD_RIGHT_ARROW, GuiStruct_InjectorTempProfilePage_25); 00283 tppsArray[36] = new TouchPanelPageSelector(INJECTOR_PROFILE_LEFT_ARROW, GuiStruct_InjectorMethodPage_Def); 00284 tppsArray[37] = new TouchPanelPageSelector(INJECTOR_PROFILE_RIGHT_ARROW, GuiStruct_InjectorPage1_3); 00285 00286 tppsArray[38] = new TouchPanelPageSelector(RUNNING_PAGE1_RIGHT_ARROW, GuiStruct_RunningColumnPage_25); 00287 tppsArray[39] = new TouchPanelPageSelector(RUNNING_PAGE1_LEFT_ARROW, GuiStruct_RunningGasPage_28); 00288 tppsArray[40] = new TouchPanelPageSelector(RUNNING_COLUMN_RIGHT_ARROW, GuiStruct_RunningInjectorPage_26); 00289 tppsArray[41] = new TouchPanelPageSelector(RUNNING_COLUMN_LEFT_ARROW, GuiStruct_RunningPage1_7); 00290 tppsArray[42] = new TouchPanelPageSelector(RUNNING_INJECTOR_RIGHT_ARROW, GuiStruct_RunningInjectorProfilePage_Def); 00291 tppsArray[43] = new TouchPanelPageSelector(RUNNING_INJECTOR_LEFT_ARROW, GuiStruct_RunningColumnPage_25); 00292 tppsArray[44] = new TouchPanelPageSelector(RUNNING_INJECTOR_PROFILE_RIGHT_ARROW, GuiStruct_RunningDetectorPage_27); 00293 tppsArray[45] = new TouchPanelPageSelector(RUNNING_INJECTOR_PROFILE_LEFT_ARROW, GuiStruct_RunningInjectorPage_26); 00294 tppsArray[46] = new TouchPanelPageSelector(RUNNING_DETECTOR_RIGHT_ARROW, GuiStruct_RunningGasPage_28); 00295 tppsArray[47] = new TouchPanelPageSelector(RUNNING_DETECTOR_LEFT_ARROW, GuiStruct_RunningInjectorProfilePage_Def); 00296 tppsArray[48] = new TouchPanelPageSelector(RUNNING_GAS_RIGHT_ARROW, GuiStruct_RunningPage1_7); 00297 tppsArray[49] = new TouchPanelPageSelector(RUNNING_GAS_LEFT_ARROW, GuiStruct_RunningDetectorPage_27); 00298 00299 tppsArray[50] = new TouchPanelPageSelector(SETTINGS_TO_NETWORK_PARAMS_BUTTON, GuiStruct_EthernetParametersPage_50); 00300 tppsArray[51] = new TouchPanelPageSelector(NETWORK_PARAMS_RETURN_BUTTON, GuiStruct_SettingsPage_5); 00301 00302 tppsArray[52] = new TouchPanelPageSelector(SETTINGS_TO_SERVICING_PAGE_BUTTON, GuiStruct_EngineersLockPage_Def); 00303 tppsArray[53] = new TouchPanelPageSelector(SERVICING_PAGE_RETURN_BUTTON, GuiStruct_SettingsPage_5); 00304 00305 tppsArray[54] = new TouchPanelPageSelector(SERVICING_REQUIRED_PAGE_HOME_BUTTON, GuiStruct_HomePage_1); 00306 00307 tppsArray[55] = new TouchPanelPageSelector(COLUMN_SERVICING_AREA, GuiStruct_ColumnDHAutoCalibrationPage_Def); 00308 tppsArray[56] = new TouchPanelPageSelector(DETECTOR_SERVICING_AREA, GuiStruct_DetectorNudgeAndDampPage_0); 00309 tppsArray[57] = new TouchPanelPageSelector(INJECTOR_SERVICING_AREA, GuiStruct_InjectorNudgeAndDampPage_0); 00310 tppsArray[58] = new TouchPanelPageSelector(GAS_SERVICING_AREA, GuiStruct_GasCalibrationPage_Def); 00311 tppsArray[59] = new TouchPanelPageSelector(SERVICING_HOME, GuiStruct_ServicingHomePage_Def); 00312 00313 tppsArray[60] = new TouchPanelPageSelector(COLUMN_DH_AUTO_CALIB_LEFT_ARROW, GuiStruct_FanPowerPage_0); 00314 tppsArray[61] = new TouchPanelPageSelector(COLUMN_DH_AUTO_CALIB_RIGHT_ARROW, GuiStruct_ColumnDHManualCalibrationPage_Def); 00315 tppsArray[62] = new TouchPanelPageSelector(COLUMN_DH_MANUAL_CALIB_LEFT_ARROW, GuiStruct_ColumnDHAutoCalibrationPage_Def); 00316 tppsArray[63] = new TouchPanelPageSelector(COLUMN_DH_MANUAL_CALIB_RIGHT_ARROW, GuiStruct_ColumnDHSensorCalibration_Def); 00317 tppsArray[64] = new TouchPanelPageSelector(COLUMN_DH_SENSOR_CALIB_LEFT_ARROW, GuiStruct_ColumnDHManualCalibrationPage_Def); 00318 tppsArray[65] = new TouchPanelPageSelector(COLUMN_DH_SENSOR_CALIB_RIGHT_ARROW, GuiStruct_PSU_DAC_Page_Def); 00319 tppsArray[66] = new TouchPanelPageSelector(COLUMN_DH_PSU_DAC_LEFT_ARROW, GuiStruct_ColumnDHSensorCalibration_Def); 00320 tppsArray[67] = new TouchPanelPageSelector(COLUMN_DH_PSU_DAC_RIGHT_ARROW, GuiStruct_ColumnDHOvenFanPage_Def); 00321 tppsArray[68] = new TouchPanelPageSelector(COLUMN_OVEN_FAN_LEFT_ARROW, GuiStruct_PSU_DAC_Page_Def); 00322 tppsArray[69] = new TouchPanelPageSelector(COLUMN_OVEN_FAN_RIGHT_ARROW, GuiStruct_ColumnOvenNudgeAndDampPage_0); 00323 tppsArray[70] = new TouchPanelPageSelector(COLUMN_OVEN_NUDGE_AND_DAMP_LEFT_ARROW, GuiStruct_ColumnDHOvenFanPage_Def); 00324 tppsArray[71] = new TouchPanelPageSelector(COLUMN_OVEN_NUDGE_AND_DAMP_RIGHT_ARROW, GuiStruct_ColumnDHNudgeAndDampPage_0); 00325 tppsArray[72] = new TouchPanelPageSelector(COLUMN_DH_NUDGE_AND_DAMP_LEFT_ARROW, GuiStruct_ColumnOvenNudgeAndDampPage_0); 00326 tppsArray[73] = new TouchPanelPageSelector(COLUMN_DH_NUDGE_AND_DAMP_RIGHT_ARROW, GuiStruct_FanPowerPage_0); 00327 tppsArray[74] = new TouchPanelPageSelector(FAN_POWER_LEFT_ARROW, GuiStruct_ColumnDHNudgeAndDampPage_0); 00328 tppsArray[75] = new TouchPanelPageSelector(FAN_POWER_RIGHT_ARROW, GuiStruct_ColumnDHAutoCalibrationPage_Def); 00329 00330 tppsArray[76] = new TouchPanelPageSelector(DETECTOR_NUDGE_AND_DAMP_LEFT_ARROW, GuiStruct_AuxiliaryNudgeAndDampPage_0); 00331 tppsArray[77] = new TouchPanelPageSelector(DETECTOR_NUDGE_AND_DAMP_RIGHT_ARROW, GuiStruct_AuxiliaryNudgeAndDampPage_0); 00332 tppsArray[78] = new TouchPanelPageSelector(AUXILIARY_NUDGE_AND_DAMP_LEFT_ARROW, GuiStruct_DetectorNudgeAndDampPage_0); 00333 tppsArray[79] = new TouchPanelPageSelector(AUXILIARY_NUDGE_AND_DAMP_RIGHT_ARROW, GuiStruct_DetectorNudgeAndDampPage_0); 00334 00335 tppsArray[80] = new TouchPanelPageSelector(GAS_CALIB_LEFT_ARROW, GuiStruct_GasChannelDACAndADCPage_Def); 00336 tppsArray[81] = new TouchPanelPageSelector(GAS_CALIB_RIGHT_ARROW, GuiStruct_GasBackPressureDACPage_Def); 00337 tppsArray[82] = new TouchPanelPageSelector(GAS_BACKPRESSURE_DAC_LEFT_ARROW, GuiStruct_GasCalibrationPage_Def); 00338 tppsArray[83] = new TouchPanelPageSelector(GAS_BACKPRESSURE_DAC_RIGHT_ARROW, GuiStruct_GasChannelDACAndADCPage_Def); 00339 tppsArray[84] = new TouchPanelPageSelector(GAS_CHANNEL_DAC_AND_ADC_LEFT_ARROW, GuiStruct_GasBackPressureDACPage_Def); 00340 tppsArray[85] = new TouchPanelPageSelector(GAS_CHANNEL_DAC_AND_ADC_RIGHT_ARROW, GuiStruct_GasCalibrationPage_Def); 00341 00342 tppsArray[86] = new TouchPanelPageSelector(SERVICING_PAGE_GC_CMDS_BUTTON, GuiStruct_DebugCommandsPage_Def); 00343 } 00344 00345 TouchPanelPageSelectors::~TouchPanelPageSelectors() 00346 { 00347 for (int i = 0; i < SELECTOR_COUNT; ++i) { 00348 if(tppsArray[i] != NULL) { // We may occasionally set some to NULL while testing new changes 00349 delete tppsArray[i]; 00350 } 00351 } 00352 } 00353 00354 /* 00355 Given a touch area index, returns a pointer to the corresponding page selector, 00356 or NULL if that index has no page selector. If the pointer is not NULL, caller 00357 can then call 'GetPageNumber' on that page selector, to find out which page to display 00358 in response to the user touching that touch area. (If the pointer is NULL, that touch area 00359 does not select a new page.) 00360 */ 00361 TouchPanelPageSelector* TouchPanelPageSelectors::GetTouchPanelPageSelector(int touchAreaIndex) 00362 { 00363 for (int i = 0; i < SELECTOR_COUNT; ++i) { 00364 if(tppsArray[i] != NULL) { // We may occasionally set some to NULL while testing new changes 00365 if( tppsArray[i]->GetIndex() == touchAreaIndex) { 00366 return tppsArray[i]; 00367 } 00368 } 00369 } 00370 00371 // 'else' - not found 00372 return NULL; 00373 } 00374 00375 00376 /* 00377 Tells the caller which TouchPanelPageSelector they have - i.e. returns its index 00378 in our array, or -1 if we cannot find it. (This should be useful for debugging.) 00379 00380 Arguments: pointer to the TouchPanelPageSelector instance in question 00381 00382 Return code: its index in our array, or -1 if not found 00383 */ 00384 int TouchPanelPageSelectors::GetTouchPanelPageSelectorIndex(TouchPanelPageSelector *tppsptr) 00385 { 00386 for (int i = 0; i < SELECTOR_COUNT; ++i) { 00387 if(tppsArray[i] == tppsptr) { 00388 return i; 00389 } 00390 } 00391 00392 // 'else' - not found 00393 return -1; 00394 } 00395
Generated on Tue Jul 19 2022 00:31:07 by
1.7.2