Repository for import to local machine

Dependencies:   DMBasicGUI DMSupport

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

Who changed what in which revision?

UserRevisionLine numberNew contents of line
jmitc91516 0:47c880c1463d 1 #include "mbed.h"
jmitc91516 0:47c880c1463d 2 #include "DMBoard.h"
jmitc91516 1:a5258871b33d 3 #include "EthernetInterface.h"
jmitc91516 1:a5258871b33d 4 #include "NetworkParameters.h"
jmitc91516 1:a5258871b33d 5
jmitc91516 0:47c880c1463d 6 #include <string.h>
jmitc91516 1:a5258871b33d 7 #include <float.h>
jmitc91516 0:47c880c1463d 8
jmitc91516 0:47c880c1463d 9 #include "GetGCStatusLoop.h"
jmitc91516 1:a5258871b33d 10 #include "SettingsHandler.h"
jmitc91516 1:a5258871b33d 11 #include "ServiceInterval.h"
jmitc91516 1:a5258871b33d 12 #include "GCRealTimeClock.h"
jmitc91516 1:a5258871b33d 13 #include "ColumnDHAutoCalibrationPageHandler.h"
jmitc91516 1:a5258871b33d 14 #include "ColumnDHPSUDACPageHandler.h"
jmitc91516 1:a5258871b33d 15 #include "SwimDraw.h"
jmitc91516 1:a5258871b33d 16 #include "USBHostGCUtilities.h"
jmitc91516 0:47c880c1463d 17
jmitc91516 0:47c880c1463d 18 #include "GuiLib.h"
jmitc91516 0:47c880c1463d 19
jmitc91516 1:a5258871b33d 20
jmitc91516 1:a5258871b33d 21 #define USE_LED_FOR_DEBUGGING
jmitc91516 1:a5258871b33d 22
jmitc91516 1:a5258871b33d 23 #ifdef USE_LED_FOR_DEBUGGING
jmitc91516 1:a5258871b33d 24
jmitc91516 1:a5258871b33d 25 #include "gpio_api.h"
jmitc91516 1:a5258871b33d 26 #include "wait_api.h"
jmitc91516 1:a5258871b33d 27 #include "toolchain.h"
jmitc91516 1:a5258871b33d 28 #include "mbed_interface.h"
jmitc91516 1:a5258871b33d 29
jmitc91516 1:a5258871b33d 30 // We turn on LED 2 during Send Method
jmitc91516 1:a5258871b33d 31 static void SetLed2(bool turnLedOn)
jmitc91516 1:a5258871b33d 32 {
jmitc91516 1:a5258871b33d 33 gpio_t led_2; gpio_init_out(&led_2, LED2);
jmitc91516 1:a5258871b33d 34
jmitc91516 1:a5258871b33d 35 if(turnLedOn) {
jmitc91516 1:a5258871b33d 36 gpio_write(&led_2, 0); // zero appears to mean "turn LED 2 on"
jmitc91516 1:a5258871b33d 37 } else {
jmitc91516 1:a5258871b33d 38 gpio_write(&led_2, 1); // one appears to turn it off
jmitc91516 1:a5258871b33d 39 }
jmitc91516 1:a5258871b33d 40 }
jmitc91516 1:a5258871b33d 41
jmitc91516 1:a5258871b33d 42 // We turn on LED 3 when we have sent a message to the GC (received from the Ethernet thread)
jmitc91516 1:a5258871b33d 43 // and we are waiting for its response
jmitc91516 1:a5258871b33d 44 static void SetLed3(bool turnLedOn)
jmitc91516 1:a5258871b33d 45 {
jmitc91516 1:a5258871b33d 46 gpio_t led_3; gpio_init_out(&led_3, LED3);
jmitc91516 1:a5258871b33d 47
jmitc91516 1:a5258871b33d 48 if(turnLedOn) {
jmitc91516 1:a5258871b33d 49 gpio_write(&led_3, 1); // one appears to mean "turn LED 3 on"
jmitc91516 1:a5258871b33d 50 } else {
jmitc91516 1:a5258871b33d 51 gpio_write(&led_3, 0); // zero appears to turn it off
jmitc91516 1:a5258871b33d 52 }
jmitc91516 1:a5258871b33d 53 }
jmitc91516 1:a5258871b33d 54
jmitc91516 1:a5258871b33d 55 #endif // USE_LED_FOR_DEBUGGING
jmitc91516 1:a5258871b33d 56
jmitc91516 1:a5258871b33d 57
jmitc91516 1:a5258871b33d 58 /*
jmitc91516 1:a5258871b33d 59 Displays the specified text string at the specified location in the currently-displayed easyGUI page.
jmitc91516 1:a5258871b33d 60
jmitc91516 1:a5258871b33d 61 Defined in main.cpp
jmitc91516 1:a5258871b33d 62 */
jmitc91516 0:47c880c1463d 63 extern void EasyGUIDebugPrint(char *stuffToPrint, short X, short Y);
jmitc91516 1:a5258871b33d 64
jmitc91516 1:a5258871b33d 65 /*
jmitc91516 1:a5258871b33d 66 Displays the specified text string at the specified location in the currently-displayed easyGUI page.
jmitc91516 1:a5258871b33d 67
jmitc91516 1:a5258871b33d 68 Defined in main.cpp - and omits the 'ALLOW_DEBUG_PRINTS' #define
jmitc91516 1:a5258871b33d 69 */
jmitc91516 1:a5258871b33d 70 extern void SpecialDebugPrint(char *stuffToPrint, GuiConst_INT16S X, GuiConst_INT16S Y);
jmitc91516 1:a5258871b33d 71
jmitc91516 1:a5258871b33d 72
jmitc91516 1:a5258871b33d 73 // Version of the above that increments, and displays, a counter each time it is called
jmitc91516 1:a5258871b33d 74 extern void EasyGUIDebugPrintWithCounter(char *stuffToPrint, short X, short Y);
jmitc91516 1:a5258871b33d 75
jmitc91516 1:a5258871b33d 76 /*
jmitc91516 1:a5258871b33d 77 Passed three 8-bit colour components - red, green and blue.
jmitc91516 1:a5258871b33d 78 Returns the corresponding 16-bit colour value (5 bits for red, 6 bits for green, 5 bits for blue).
jmitc91516 1:a5258871b33d 79
jmitc91516 1:a5258871b33d 80 Defined in main.cpp
jmitc91516 1:a5258871b33d 81 */
jmitc91516 0:47c880c1463d 82 extern GuiConst_INTCOLOR SixteenBitColorValue(GuiConst_INT8U red, GuiConst_INT8U green, GuiConst_INT8U blue);
jmitc91516 1:a5258871b33d 83
jmitc91516 1:a5258871b33d 84 /*
jmitc91516 1:a5258871b33d 85 Draws the Run button in the correct place, in the correct enabled/disabled state.
jmitc91516 1:a5258871b33d 86 Arg is: true to display the button in an enabled state, false to display it disabled.
jmitc91516 1:a5258871b33d 87 No return code.
jmitc91516 1:a5258871b33d 88
jmitc91516 1:a5258871b33d 89 Defined in main.cpp
jmitc91516 1:a5258871b33d 90 */
jmitc91516 0:47c880c1463d 91 extern void DrawRunButton(bool enabled);
jmitc91516 0:47c880c1463d 92
jmitc91516 1:a5258871b33d 93 /*
jmitc91516 1:a5258871b33d 94 Draws the Heat On/Off button in the correct place, in the correct state (i.e. saying "Heat On"
jmitc91516 1:a5258871b33d 95 if it is off, and vice versa - i.e. the text states what the button will do if pressed).
jmitc91516 1:a5258871b33d 96 No arguments (finds out the current heat on/off state for itself)
jmitc91516 1:a5258871b33d 97 No return code.
jmitc91516 1:a5258871b33d 98
jmitc91516 1:a5258871b33d 99 Defined in main.cpp
jmitc91516 1:a5258871b33d 100 */
jmitc91516 1:a5258871b33d 101 extern void DrawHeatOnOffButton(void);
jmitc91516 1:a5258871b33d 102
jmitc91516 1:a5258871b33d 103
jmitc91516 1:a5258871b33d 104 /*
jmitc91516 1:a5258871b33d 105 Draws the background bitmap - without the Ellutia logo. It fills the screen, so you do not need to call GuiLib_Clear.
jmitc91516 1:a5258871b33d 106 Defined in main.cpp
jmitc91516 1:a5258871b33d 107 */
jmitc91516 1:a5258871b33d 108 extern void DrawBackgroundBitmap(void);
jmitc91516 1:a5258871b33d 109 #define USING_BACKGROUND_BITMAP
jmitc91516 1:a5258871b33d 110
jmitc91516 1:a5258871b33d 111 /*
jmitc91516 1:a5258871b33d 112 Same as the above, but draws the background bitmap *with* the Ellutia logo.
jmitc91516 1:a5258871b33d 113 Defined in main.cpp
jmitc91516 1:a5258871b33d 114 */
jmitc91516 1:a5258871b33d 115 void DrawBackgroundBitmapWithLogo(void);
jmitc91516 1:a5258871b33d 116
jmitc91516 1:a5258871b33d 117
jmitc91516 1:a5258871b33d 118 /*
jmitc91516 1:a5258871b33d 119 The colour of the main part of the (fake) bitmap - also from main.cpp
jmitc91516 1:a5258871b33d 120 */
jmitc91516 1:a5258871b33d 121 extern GuiConst_INTCOLOR GetFakeBackgroundBitmapMainColour(void);
jmitc91516 1:a5258871b33d 122
jmitc91516 1:a5258871b33d 123 /*
jmitc91516 1:a5258871b33d 124 Depending on the argument passed to it,this function either draws the word "Stabilising"
jmitc91516 1:a5258871b33d 125 at the bottom of the display, in the centre, in green, or erases it.
jmitc91516 1:a5258871b33d 126
jmitc91516 1:a5258871b33d 127 Arg is: true to display the text, false to erase it
jmitc91516 1:a5258871b33d 128
jmitc91516 1:a5258871b33d 129 No return code.
jmitc91516 1:a5258871b33d 130
jmitc91516 1:a5258871b33d 131 Defined in main.cpp
jmitc91516 1:a5258871b33d 132 */
jmitc91516 1:a5258871b33d 133 extern void DrawStabilisingMessage(bool stabilising);
jmitc91516 1:a5258871b33d 134
jmitc91516 1:a5258871b33d 135 /*
jmitc91516 1:a5258871b33d 136 Depending on the argument passed to it,this function either draws the word "Equilibrating"
jmitc91516 1:a5258871b33d 137 at the bottom of the display, in the centre, in amber, or erases it.
jmitc91516 1:a5258871b33d 138
jmitc91516 1:a5258871b33d 139 Arg is: true to display the text, false to erase it
jmitc91516 1:a5258871b33d 140
jmitc91516 1:a5258871b33d 141 No return code.
jmitc91516 1:a5258871b33d 142
jmitc91516 1:a5258871b33d 143 Defined in main.cpp
jmitc91516 1:a5258871b33d 144 */
jmitc91516 1:a5258871b33d 145 extern void DrawEquilibratingMessage(bool equilibrating);
jmitc91516 1:a5258871b33d 146
jmitc91516 1:a5258871b33d 147 /*
jmitc91516 1:a5258871b33d 148 Depending on the argument passed to it,this function either draws the word "Cooling"
jmitc91516 1:a5258871b33d 149 at the bottom of the display, in the centre, in light blue, or erases it.
jmitc91516 1:a5258871b33d 150
jmitc91516 1:a5258871b33d 151 Arg is: true to display the text, false to erase it
jmitc91516 1:a5258871b33d 152
jmitc91516 1:a5258871b33d 153 No return code.
jmitc91516 1:a5258871b33d 154 */
jmitc91516 1:a5258871b33d 155 extern void DrawCoolingMessage(bool cooling);
jmitc91516 1:a5258871b33d 156
jmitc91516 1:a5258871b33d 157 /*
jmitc91516 1:a5258871b33d 158 Depending on the argument passed to it,this function either draws the word "Ready"
jmitc91516 1:a5258871b33d 159 at the bottom of the display, in the centre, in green, or erases it.
jmitc91516 1:a5258871b33d 160
jmitc91516 1:a5258871b33d 161 Arg is: true to display the text, false to erase it
jmitc91516 1:a5258871b33d 162
jmitc91516 1:a5258871b33d 163 No return code.
jmitc91516 1:a5258871b33d 164 */
jmitc91516 1:a5258871b33d 165 extern void DrawReadyMessage(bool ready);
jmitc91516 1:a5258871b33d 166
jmitc91516 1:a5258871b33d 167
jmitc91516 1:a5258871b33d 168 /*
jmitc91516 1:a5258871b33d 169 Tells the caller whether or not a specified GC command represents the start of a method,
jmitc91516 1:a5258871b33d 170 and that therefore a new method is now being sent to the GC.
jmitc91516 1:a5258871b33d 171
jmitc91516 1:a5258871b33d 172 Params: pointer to a null-terminated string containing the command in question
jmitc91516 1:a5258871b33d 173
jmitc91516 1:a5258871b33d 174 Returns true if the command is one that occurs at the start of a method (and nowhere else),
jmitc91516 1:a5258871b33d 175 false if not.
jmitc91516 1:a5258871b33d 176
jmitc91516 1:a5258871b33d 177 Defined in main.cpp
jmitc91516 1:a5258871b33d 178 */
jmitc91516 1:a5258871b33d 179 bool IsStartOfMethodCommand(char *gcCommand);
jmitc91516 1:a5258871b33d 180
jmitc91516 1:a5258871b33d 181 /*
jmitc91516 1:a5258871b33d 182 Tells the caller whether or not a specified GC command represents the end of a method,
jmitc91516 1:a5258871b33d 183 and that therefore a new method has just been sent to the GC.
jmitc91516 1:a5258871b33d 184
jmitc91516 1:a5258871b33d 185 Params: pointer to a null-terminated string containing the command in question
jmitc91516 1:a5258871b33d 186
jmitc91516 1:a5258871b33d 187 Returns true if the command is one that occurs at the end of a method (and nowhere else),
jmitc91516 1:a5258871b33d 188 false if not.
jmitc91516 1:a5258871b33d 189
jmitc91516 1:a5258871b33d 190 Defined in main.cpp
jmitc91516 1:a5258871b33d 191 */
jmitc91516 1:a5258871b33d 192 bool IsEndOfMethodCommand(char *gcCommand);
jmitc91516 1:a5258871b33d 193
jmitc91516 1:a5258871b33d 194
jmitc91516 1:a5258871b33d 195
jmitc91516 1:a5258871b33d 196 /*
jmitc91516 1:a5258871b33d 197 The original TouchCallback function, called directly by ListenerFunction in the original TouchListener class.
jmitc91516 1:a5258871b33d 198
jmitc91516 1:a5258871b33d 199 Defined in main.cpp.
jmitc91516 1:a5258871b33d 200
jmitc91516 1:a5258871b33d 201 TODO: Move into this class? Rationalise, at least...
jmitc91516 1:a5258871b33d 202 */
jmitc91516 1:a5258871b33d 203 extern void TouchCallback(touch_coordinate_t touchCoords, USBDeviceConnected* usbDevice, USBHostGC* usbHostGC, int tickCount, bool newTouch);
jmitc91516 1:a5258871b33d 204
jmitc91516 1:a5258871b33d 205
jmitc91516 1:a5258871b33d 206 /*
jmitc91516 1:a5258871b33d 207 A function to deal with the 'admin' required when the GC starts running -
jmitc91516 1:a5258871b33d 208 i.e. setting up the relevant easyGUI variables, displaying the correct page, etc.
jmitc91516 1:a5258871b33d 209
jmitc91516 1:a5258871b33d 210 Defined in main.cpp
jmitc91516 1:a5258871b33d 211 */
jmitc91516 1:a5258871b33d 212 extern void SetupForStartOfRun(USBDeviceConnected* usbDevice, USBHostGC* usbHostGC);
jmitc91516 1:a5258871b33d 213
jmitc91516 1:a5258871b33d 214
jmitc91516 1:a5258871b33d 215 /*
jmitc91516 1:a5258871b33d 216 Reads the current state of the door actuators, and sets up the buttons
jmitc91516 1:a5258871b33d 217 at the bottom of the page appropriately.
jmitc91516 1:a5258871b33d 218
jmitc91516 1:a5258871b33d 219 Defined in main.cpp
jmitc91516 1:a5258871b33d 220 */
jmitc91516 1:a5258871b33d 221 extern void SetupDoorActuatorCommandUserInterface(USBDeviceConnected* usbDevice, USBHostGC* usbHostGC, bool beforePageDisplay);
jmitc91516 1:a5258871b33d 222
jmitc91516 1:a5258871b33d 223 /*
jmitc91516 1:a5258871b33d 224 Tells the caller whether or not the door actuator buttons have changed,
jmitc91516 1:a5258871b33d 225 from the single "Close"/"Unlock" button to the two "Lock" and "Release" buttons,
jmitc91516 1:a5258871b33d 226 or vice versa
jmitc91516 1:a5258871b33d 227
jmitc91516 1:a5258871b33d 228 Defined in main.cpp
jmitc91516 1:a5258871b33d 229 */
jmitc91516 1:a5258871b33d 230 extern bool DoorActuatorButtonsHaveChanged(USBDeviceConnected* usbDevice, USBHostGC* usbHostGC);
jmitc91516 1:a5258871b33d 231
jmitc91516 1:a5258871b33d 232
jmitc91516 1:a5258871b33d 233 /*
jmitc91516 1:a5258871b33d 234 Sets up the easyGUI variable that controls the colour of the door lock/unlock command.
jmitc91516 1:a5258871b33d 235
jmitc91516 1:a5258871b33d 236 Defined in main.cpp
jmitc91516 1:a5258871b33d 237 */
jmitc91516 1:a5258871b33d 238 extern void SetupDoorActuatorCommandColour(USBDeviceConnected* usbDevice, USBHostGC* usbHostGC, bool actuatorsAreMoving);
jmitc91516 1:a5258871b33d 239
jmitc91516 1:a5258871b33d 240
jmitc91516 1:a5258871b33d 241 /*
jmitc91516 1:a5258871b33d 242 Draw a part of a profile - which will be a quadrilateral, vertical at left and right, horizontal at the bottom, but a sloping straight line at the top -
jmitc91516 1:a5258871b33d 243 by calling the EasyGUI GuiLib_VLine function multiple times.
jmitc91516 1:a5258871b33d 244
jmitc91516 1:a5258871b33d 245 Args: colour of the profile
jmitc91516 1:a5258871b33d 246 X coords of the left and right edges of the section
jmitc91516 1:a5258871b33d 247 Y coord of the bottom
jmitc91516 1:a5258871b33d 248 Y coords of the top left and top right
jmitc91516 1:a5258871b33d 249
jmitc91516 1:a5258871b33d 250 Returns true if OK, false if it failed (e.g. the coords were invalid).
jmitc91516 1:a5258871b33d 251
jmitc91516 1:a5258871b33d 252 Defined in main.cpp
jmitc91516 1:a5258871b33d 253 */
jmitc91516 1:a5258871b33d 254 extern bool DrawProfileSectionUsingGuiLibVLine(GuiConst_INTCOLOR colour, GuiConst_INT16S xLeft, GuiConst_INT16S xRight, GuiConst_INT16S yBottom, GuiConst_INT16S yTopLeft, GuiConst_INT16S yTopRight);
jmitc91516 1:a5258871b33d 255
jmitc91516 1:a5258871b33d 256
jmitc91516 1:a5258871b33d 257 /*
jmitc91516 1:a5258871b33d 258 Function to cause the LPC4088 to reboot.
jmitc91516 1:a5258871b33d 259
jmitc91516 1:a5258871b33d 260 Defined in main.cpp.
jmitc91516 1:a5258871b33d 261 */
jmitc91516 1:a5258871b33d 262 extern void reboot();
jmitc91516 1:a5258871b33d 263
jmitc91516 1:a5258871b33d 264
jmitc91516 0:47c880c1463d 265 // Note that GetGCStatusLoop is a singleton - we do not need or want there to be more than one instance of it
jmitc91516 1:a5258871b33d 266 // (there is only one GC, and only one LPC4088).
jmitc91516 1:a5258871b33d 267 // This is the one and only GetGCStatusLoop instance
jmitc91516 0:47c880c1463d 268 GetGCStatusLoop * GetGCStatusLoop::theGetGCStatusLoop = NULL;
jmitc91516 0:47c880c1463d 269
jmitc91516 1:a5258871b33d 270 //const int GetGCStatusLoop::waitTimeMs = 1000;
jmitc91516 1:a5258871b33d 271 const int GetGCStatusLoop::waitTimeMs = 500;
jmitc91516 1:a5258871b33d 272 //const int GetGCStatusLoop::waitTimeMs = 200;
jmitc91516 1:a5258871b33d 273 const int GetGCStatusLoop::shortWaitTimeMs = 50; // For use by the thread_wait calls that look for Ethernet transactions
jmitc91516 1:a5258871b33d 274 // and touch events at multiple points in the 'main loop'
jmitc91516 1:a5258871b33d 275
jmitc91516 1:a5258871b33d 276 #define USE_THREAD_WAIT // Thread::wait lets other threads run while this one is paused
jmitc91516 1:a5258871b33d 277 // wait_ms (the other option) blocks all other threads while waiting - not a good idea.
jmitc91516 1:a5258871b33d 278 // Actually now using Thread::signal_wait, as part of restructuring touch event code
jmitc91516 1:a5258871b33d 279 // (see also the SimplifiedTouchListener class) - and Ethernet code (see EthernetHandler).
jmitc91516 1:a5258871b33d 280
jmitc91516 1:a5258871b33d 281 const float GetGCStatusLoop::graphBarIntervalMinutes = 1.0f; // Units are minutes...
jmitc91516 1:a5258871b33d 282 const float GetGCStatusLoop::graphBarIntervalSeconds = 0.1f; // ...in both cases
jmitc91516 1:a5258871b33d 283
jmitc91516 1:a5258871b33d 284 const float GetGCStatusLoop::methodTimeUnitsThreshold = 5.0f; // If the method takes less than this number of minutes to run,
jmitc91516 1:a5258871b33d 285 // use seconds as the time units we display on the profile graphs,
jmitc91516 1:a5258871b33d 286 // otherwise use minutes
jmitc91516 1:a5258871b33d 287
jmitc91516 1:a5258871b33d 288 // Timer stuff - trying to avoid responding to the same touch event more than once
jmitc91516 1:a5258871b33d 289 const uint32_t GetGCStatusLoop::timerIntervalMilliSec = 600; // i.e. 0.6 second
jmitc91516 1:a5258871b33d 290 const uint32_t GetGCStatusLoop::minTimerTicksBetweenTouchEvents = 5; // i.e. 1 second
jmitc91516 1:a5258871b33d 291 // Increase timer tick interval - does this make Ethernet comms more responsive?
jmitc91516 1:a5258871b33d 292 //const uint32_t GetGCStatusLoop::timerIntervalMilliSec = 500; // i.e. 0.5 second
jmitc91516 1:a5258871b33d 293 //const uint32_t GetGCStatusLoop::minTimerTicksBetweenTouchEvents = 2; // i.e. 1 second
jmitc91516 1:a5258871b33d 294 // Answer - no - possibly worse, in fact
jmitc91516 1:a5258871b33d 295 int GetGCStatusLoop::timerTickCount = 0;
jmitc91516 1:a5258871b33d 296
jmitc91516 1:a5258871b33d 297 // Trying different ways of preventing the same touch event being processed more than once
jmitc91516 1:a5258871b33d 298 //#define MULTI_TOUCH_TECHNIQUE_1 // Enforce a minimum time interval (i.e. number of ticks) between the touch events we respond to
jmitc91516 1:a5258871b33d 299 //#define MULTI_TOUCH_TECHNIQUE_2 // Look for successive touch events with different X and/or Y coordinates
jmitc91516 1:a5258871b33d 300 //#define MULTI_TOUCH_TECHNIQUE_3 // Have at least one timeout or timer tick (and now, Ethernet message) between touch events
jmitc91516 1:a5258871b33d 301 //#define MULTI_TOUCH_TECHNIQUE_4 // Use a Timer object (not an RTosTimer, like MULTI_TOUCH_TECHNIQUE_1) to enforce a minimum time interval between touches
jmitc91516 1:a5258871b33d 302 // The above are mutually exclusive - do not un-comment more than one at the same time
jmitc91516 1:a5258871b33d 303 // (you can comment them all out if you wish to see the original problem)
jmitc91516 1:a5258871b33d 304 // At present (07 Oct 2016), MULTI_TOUCH_TECHNIQUE_4 seems to be the clear winner - far more effective than the others
jmitc91516 1:a5258871b33d 305 // Although now (04 Nov 2016) itself superseded by MULTI_TOUCH_TECHNIQUE_5, in SimplifiedTouchListener
jmitc91516 1:a5258871b33d 306
jmitc91516 1:a5258871b33d 307 #ifdef MULTI_TOUCH_TECHNIQUE_1
jmitc91516 1:a5258871b33d 308 osThreadId GetGCStatusLoop::timerCallbackThreadToSignal;
jmitc91516 1:a5258871b33d 309 #endif // MULTI_TOUCH_TECHNIQUE_1
jmitc91516 1:a5258871b33d 310
jmitc91516 1:a5258871b33d 311 /*
jmitc91516 1:a5258871b33d 312 Convenient default values for Ethernet parameters
jmitc91516 1:a5258871b33d 313 */
jmitc91516 1:a5258871b33d 314 //#define FOR_GRAHAM_SEWELL
jmitc91516 1:a5258871b33d 315 #ifdef FOR_GRAHAM_SEWELL
jmitc91516 1:a5258871b33d 316 const int GetGCStatusLoop::defaultEthernetPort = 3456;
jmitc91516 1:a5258871b33d 317 const char* GetGCStatusLoop::defaultEthernetIP = "192.168.111.100";
jmitc91516 1:a5258871b33d 318 const char* GetGCStatusLoop::defaultEthernetMask = "255.255.255.0";
jmitc91516 1:a5258871b33d 319 const char* GetGCStatusLoop::defaultEthernetGateway = "192.168.111.254";
jmitc91516 1:a5258871b33d 320 #else // Mine
jmitc91516 1:a5258871b33d 321 const int GetGCStatusLoop::defaultEthernetPort = 3456;
jmitc91516 1:a5258871b33d 322 const char* GetGCStatusLoop::defaultEthernetIP = "192.168.1.100";
jmitc91516 1:a5258871b33d 323 const char* GetGCStatusLoop::defaultEthernetMask = "255.255.255.0";
jmitc91516 1:a5258871b33d 324 const char* GetGCStatusLoop::defaultEthernetGateway = "192.168.1.254";
jmitc91516 1:a5258871b33d 325 #endif
jmitc91516 1:a5258871b33d 326
jmitc91516 1:a5258871b33d 327 // Text for the "Start/Exit Calibration" button on the DH Column Calibration page
jmitc91516 1:a5258871b33d 328 const char* GetGCStatusLoop::startDHColumnCalibration = "Start Calibration";
jmitc91516 1:a5258871b33d 329 const char* GetGCStatusLoop::exitDHColumnCalibration = "Exit Calibration";
jmitc91516 1:a5258871b33d 330
jmitc91516 6:dba3fbdfd5da 331 // On the easyGUI pages/structures, character code 161 appears as the degree symbol (the little circle at the top left of the character position). See the "Font Editing" page (accessed with the F4 key).
jmitc91516 6:dba3fbdfd5da 332 // To type it into NotePad, enable Num Lock on the keyboard, hold down the Alt key, type 0161 on the numeric keypad, then release the Alt key.
jmitc91516 6:dba3fbdfd5da 333 // Note that a different character ("¡") then appears in NotePad. If you copy and paste that character into a string in easyGUI, it appears as "¡",
jmitc91516 6:dba3fbdfd5da 334 // but in an easyGUI "structure", it appears as the degree symbol. (I don't understand it either.)
jmitc91516 6:dba3fbdfd5da 335 // The following is the only way I could find to use the 161 character in code that (a) works, and (b) the compiler does not complain about.
jmitc91516 6:dba3fbdfd5da 336 const char GetGCStatusLoop::degSymbol = 161;
jmitc91516 6:dba3fbdfd5da 337 const char GetGCStatusLoop::stringFormatdegCUnits[6] = { '%', 's', ' ', 161, 'C', '\0' };
jmitc91516 6:dba3fbdfd5da 338 // Functions to make the above available to the rest of the world, in a controlled manner
jmitc91516 6:dba3fbdfd5da 339 const char *GetGCStatusLoop::GetDegCUnitsWithSpace(void)
jmitc91516 6:dba3fbdfd5da 340 {
jmitc91516 6:dba3fbdfd5da 341 return &stringFormatdegCUnits[2];
jmitc91516 6:dba3fbdfd5da 342 }
jmitc91516 6:dba3fbdfd5da 343 const char *GetGCStatusLoop::GetDegCUnitsWithoutSpace(void)
jmitc91516 6:dba3fbdfd5da 344 {
jmitc91516 6:dba3fbdfd5da 345 return &stringFormatdegCUnits[3];
jmitc91516 6:dba3fbdfd5da 346 }
jmitc91516 6:dba3fbdfd5da 347 #define TRY_DEG_SYMBOL
jmitc91516 6:dba3fbdfd5da 348
jmitc91516 1:a5258871b33d 349
jmitc91516 1:a5258871b33d 350 //#define USING_DATASET_4 // This is the 'dot at current time' dataset, used in the profile graphs we display while the GC is running.
jmitc91516 1:a5258871b33d 351 // Applies to the 'running column' and 'running gas' graphs. Omit when we make the 'before now' bars thicker
jmitc91516 1:a5258871b33d 352 // than the 'after now' bars. Without the 'dot at current time', we do not have to clear the graph
jmitc91516 1:a5258871b33d 353 // when we redraw it - reduces flickering (since the bars are now overwriting themselves)
jmitc91516 1:a5258871b33d 354
jmitc91516 1:a5258871b33d 355 //#define USING_DATASET_4_ON_NON_RUNNING_GRAPHS // Since these graphs do not show a 'current time',
jmitc91516 1:a5258871b33d 356 // dataset 4 serves little purpose on these graphs either
jmitc91516 1:a5258871b33d 357
jmitc91516 1:a5258871b33d 358 #define PTV_RAMPS_AVAILABLE // #define this if the GC software includes the commands to set up the PTV ramps - i.e. it is at least version 3.90.
jmitc91516 1:a5258871b33d 359 // If not, comment it out.
jmitc91516 1:a5258871b33d 360
jmitc91516 1:a5258871b33d 361 #define UPDATE_PAGES_CONTINUOUSLY // #define this to cause pages that display data to be updated/redisplayed whether or not the GC status has changed
jmitc91516 1:a5258871b33d 362 // (otherwise they will be redisplayed only if the status has changed, and the displayed temperatures may get out of date)
jmitc91516 1:a5258871b33d 363
jmitc91516 1:a5258871b33d 364 #define DO_NOTHING_ELSE_WHILE_SENDING_METHOD // #define this to disable all other 'events' while downloading a method from Ellution to the GC.
jmitc91516 1:a5258871b33d 365 // (we need this to be as fast as possible)
jmitc91516 1:a5258871b33d 366
jmitc91516 1:a5258871b33d 367 #define TEST_GUILIB_VLINE_PROFILES // #define this to use the experimental functions that draw a solid profile direct to the display,
jmitc91516 1:a5258871b33d 368 // without using the easyGUI graph functions
jmitc91516 1:a5258871b33d 369
jmitc91516 1:a5258871b33d 370 //#define WANT_STATUS_RECTANGLE_ON_COLUMN_AUTO_CALIB_PAGE // Now moved to Servicing pages - surely don't want status rectangles there?
jmitc91516 1:a5258871b33d 371 //#define WANT_STATUS_RECTANGLE_ON_GAS_CALIB_PAGES // ....
jmitc91516 3:010aeeacd7d7 372 //#define WANT_COLUMN_STATUS_RECTANGLE
jmitc91516 3:010aeeacd7d7 373 //#define WANT_DETECTOR_STATUS_RECTANGLE
jmitc91516 3:010aeeacd7d7 374 //#define WANT_INJECTOR_STATUS_RECTANGLE
jmitc91516 3:010aeeacd7d7 375 //#define WANT_GAS_STATUS_RECTANGLE
jmitc91516 7:f0e645cf73a2 376 //#define WANT_DOOR_ACTUATOR_BUTTONS_ON_COLUMN_PAGES
jmitc91516 7:f0e645cf73a2 377 //#define WANT_COMPONENT_ICON_ON_PROFILE_PAGES
jmitc91516 1:a5258871b33d 378
jmitc91516 1:a5258871b33d 379 /*
jmitc91516 1:a5258871b33d 380 Singleton class - return the one and only instance, first creating it if necessary.
jmitc91516 1:a5258871b33d 381
jmitc91516 1:a5258871b33d 382 The instance is passed pointers to the USBHostGC instance and the USB device corresponding with the GC.
jmitc91516 1:a5258871b33d 383 */
jmitc91516 0:47c880c1463d 384 GetGCStatusLoop *GetGCStatusLoop::GetInstance(USBDeviceConnected* newUsbDevice, USBHostGC* newUsbHostGC)
jmitc91516 0:47c880c1463d 385 {
jmitc91516 0:47c880c1463d 386 if (theGetGCStatusLoop == NULL) {
jmitc91516 0:47c880c1463d 387 theGetGCStatusLoop = new GetGCStatusLoop(newUsbDevice, newUsbHostGC);
jmitc91516 0:47c880c1463d 388 }
jmitc91516 0:47c880c1463d 389 return theGetGCStatusLoop;
jmitc91516 0:47c880c1463d 390 }
jmitc91516 0:47c880c1463d 391
jmitc91516 1:a5258871b33d 392 /*
jmitc91516 1:a5258871b33d 393 Static method to return the one and only GetGCStatusLoop instance, if it exists.
jmitc91516 1:a5258871b33d 394 If not, this function will return NULL - it will *not* create a new instance.
jmitc91516 1:a5258871b33d 395
jmitc91516 1:a5258871b33d 396 Caller must check for NULL
jmitc91516 1:a5258871b33d 397 **************************
jmitc91516 1:a5258871b33d 398 */
jmitc91516 1:a5258871b33d 399 GetGCStatusLoop *GetGCStatusLoop::GetInstance(void)
jmitc91516 1:a5258871b33d 400 {
jmitc91516 1:a5258871b33d 401 return theGetGCStatusLoop;
jmitc91516 1:a5258871b33d 402 }
jmitc91516 1:a5258871b33d 403
jmitc91516 0:47c880c1463d 404 // Singleton class - private constructor
jmitc91516 0:47c880c1463d 405 GetGCStatusLoop::GetGCStatusLoop(USBDeviceConnected* newUsbDevice, USBHostGC* newUsbHostGC)
jmitc91516 0:47c880c1463d 406 {
jmitc91516 0:47c880c1463d 407 usbDevice = newUsbDevice;
jmitc91516 0:47c880c1463d 408 usbHostGC = newUsbHostGC;
jmitc91516 0:47c880c1463d 409
jmitc91516 0:47c880c1463d 410 currentPage = 9999; // Impossible value
jmitc91516 0:47c880c1463d 411
jmitc91516 0:47c880c1463d 412 pageJustChanged = false;
jmitc91516 0:47c880c1463d 413 displayingData = false;
jmitc91516 1:a5258871b33d 414 needToUpdateProfileGraphs = false;
jmitc91516 1:a5258871b33d 415
jmitc91516 1:a5258871b33d 416 ethernetPort = defaultEthernetPort;
jmitc91516 1:a5258871b33d 417 strcpy(ethernetIP, defaultEthernetIP);
jmitc91516 1:a5258871b33d 418 strcpy(ethernetMask, defaultEthernetMask);
jmitc91516 1:a5258871b33d 419 strcpy(ethernetGateway, defaultEthernetGateway);
jmitc91516 1:a5258871b33d 420 useDHCPForEthernet = false;
jmitc91516 0:47c880c1463d 421
jmitc91516 0:47c880c1463d 422 gcInStandbyMode = false;
jmitc91516 1:a5258871b33d 423
jmitc91516 1:a5258871b33d 424 realGCIsRunning = false;
jmitc91516 1:a5258871b33d 425
jmitc91516 1:a5258871b33d 426 sendingMethod = false;
jmitc91516 1:a5258871b33d 427
jmitc91516 0:47c880c1463d 428 homePageGCComponentStatusColorAreas = NULL;
jmitc91516 0:47c880c1463d 429 singleGCComponentPageStatusColorAreas = NULL;
jmitc91516 1:a5258871b33d 430
jmitc91516 1:a5258871b33d 431 runningPage1ProgressBar = new ProgressBar(100, 250, 600, 50, horizontal, 100.0, // We will change the calibrated range at the start of every run
jmitc91516 1:a5258871b33d 432 SixteenBitColorValue(0xFF, 0, 0), // bar colour - red
jmitc91516 1:a5258871b33d 433 GetFakeBackgroundBitmapMainColour(), // background colour - as used in the fake background bitmap, drawn in main.cpp
jmitc91516 1:a5258871b33d 434 0 // border colour - black
jmitc91516 1:a5258871b33d 435 );
jmitc91516 1:a5258871b33d 436
jmitc91516 1:a5258871b33d 437 CreateGuiLibGraphsAndDataSets();
jmitc91516 1:a5258871b33d 438
jmitc91516 1:a5258871b33d 439 SetupColumnAndInjectorAndGasProfileData();
jmitc91516 1:a5258871b33d 440
jmitc91516 1:a5258871b33d 441 previousColumnMethodRunTime = -99.0f;
jmitc91516 1:a5258871b33d 442 columnMethodFinished = false;
jmitc91516 1:a5258871b33d 443
jmitc91516 1:a5258871b33d 444 previousGasMethodRunTime = -99.0f;
jmitc91516 1:a5258871b33d 445 gasMethodFinished = false;
jmitc91516 1:a5258871b33d 446
jmitc91516 1:a5258871b33d 447 gotAtLeastOneTimeout = false;
jmitc91516 1:a5258871b33d 448
jmitc91516 1:a5258871b33d 449 lastColumnStatusDisplayedOnHomePage = NONE;
jmitc91516 1:a5258871b33d 450 lastInjectorStatusDisplayedOnHomePage = NONE;
jmitc91516 1:a5258871b33d 451 lastDetectorStatusDisplayedOnHomePage = NONE;
jmitc91516 1:a5258871b33d 452 lastGasStatusDisplayedOnHomePage = NONE;
jmitc91516 1:a5258871b33d 453
jmitc91516 1:a5258871b33d 454 lastColumnStatusDisplayedOnColumnPage = NONE;
jmitc91516 1:a5258871b33d 455 lastInjectorStatusDisplayedOnInjectorPage = NONE;
jmitc91516 1:a5258871b33d 456 lastDetectorStatusDisplayedOnDetectorPage = NONE;
jmitc91516 1:a5258871b33d 457 lastGasStatusDisplayedOnGasInformationPage = NONE;
jmitc91516 1:a5258871b33d 458
jmitc91516 1:a5258871b33d 459 lastSimplifiedGCState = GC_IDLE;
jmitc91516 1:a5258871b33d 460
jmitc91516 1:a5258871b33d 461 runWasAborted = false;
jmitc91516 1:a5258871b33d 462
jmitc91516 1:a5258871b33d 463 handlingEthernetMessage = false;
jmitc91516 1:a5258871b33d 464 handlingTouchEvent = false;
jmitc91516 1:a5258871b33d 465
jmitc91516 1:a5258871b33d 466 #ifdef MULTI_TOUCH_TECHNIQUE_1
jmitc91516 1:a5258871b33d 467 // rtosTimer stuff
jmitc91516 1:a5258871b33d 468 rtosTimer = new RtosTimer(GetGCStatusLoop::TimerCallback);
jmitc91516 1:a5258871b33d 469 rtosTimer->start(timerIntervalMilliSec);
jmitc91516 1:a5258871b33d 470 lastTouchEventTickCount = 0;
jmitc91516 1:a5258871b33d 471 timerCallbackThreadToSignal = osThreadGetId();
jmitc91516 1:a5258871b33d 472 #endif // MULTI_TOUCH_TECHNIQUE_1
jmitc91516 1:a5258871b33d 473
jmitc91516 1:a5258871b33d 474 #ifdef MULTI_TOUCH_TECHNIQUE_2
jmitc91516 1:a5258871b33d 475 lastTouchEventX = 9999;
jmitc91516 1:a5258871b33d 476 lastTouchEventY = 9999;
jmitc91516 1:a5258871b33d 477 #endif // MULTI_TOUCH_TECHNIQUE_2
jmitc91516 1:a5258871b33d 478
jmitc91516 1:a5258871b33d 479 #ifdef MULTI_TOUCH_TECHNIQUE_4
jmitc91516 1:a5258871b33d 480 touchTimer.stop();
jmitc91516 1:a5258871b33d 481 touchTimer.reset();
jmitc91516 1:a5258871b33d 482 touchTimer.start();
jmitc91516 1:a5258871b33d 483 #endif // MULTI_TOUCH_TECHNIQUE_4
jmitc91516 1:a5258871b33d 484
jmitc91516 1:a5258871b33d 485 qspiBitmaps = NULL;
jmitc91516 5:aceac1035d71 486
jmitc91516 5:aceac1035d71 487 columnMethodRampData = NULL; // Create this only when we need it
jmitc91516 6:dba3fbdfd5da 488 columnMethodPageScrollIndex = 0;
jmitc91516 6:dba3fbdfd5da 489 previousColumnMethodPageScrollIndex = columnMethodPageScrollIndex;
jmitc91516 6:dba3fbdfd5da 490
jmitc91516 6:dba3fbdfd5da 491 injectorMethodRampData = NULL; // Create this only when we need it
jmitc91516 6:dba3fbdfd5da 492 injectorMethodPageScrollIndex = 0;
jmitc91516 6:dba3fbdfd5da 493 previousInjectorMethodPageScrollIndex = injectorMethodPageScrollIndex;
jmitc91516 6:dba3fbdfd5da 494
jmitc91516 6:dba3fbdfd5da 495 gasMethodRampData = NULL; // Create this only when we need it
jmitc91516 6:dba3fbdfd5da 496 gasMethodPageScrollIndex = 0;
jmitc91516 6:dba3fbdfd5da 497 previousGasMethodPageScrollIndex = gasMethodPageScrollIndex;
jmitc91516 1:a5258871b33d 498 }
jmitc91516 1:a5258871b33d 499
jmitc91516 1:a5258871b33d 500 // Private destructor also
jmitc91516 0:47c880c1463d 501 GetGCStatusLoop::~GetGCStatusLoop()
jmitc91516 0:47c880c1463d 502 {
jmitc91516 1:a5258871b33d 503 if(runningPage1ProgressBar != NULL) {
jmitc91516 1:a5258871b33d 504 delete runningPage1ProgressBar;
jmitc91516 1:a5258871b33d 505 }
jmitc91516 1:a5258871b33d 506
jmitc91516 1:a5258871b33d 507 delete runningColumnPageGraph;
jmitc91516 1:a5258871b33d 508
jmitc91516 1:a5258871b33d 509 delete runningColumnPageGraphCompleteProfileDataSet;
jmitc91516 1:a5258871b33d 510 delete runningColumnPageGraphDataSet0;
jmitc91516 1:a5258871b33d 511 delete runningColumnPageGraphDataSet1;
jmitc91516 1:a5258871b33d 512 delete runningColumnPageGraphDataSet2;
jmitc91516 1:a5258871b33d 513 delete runningColumnPageGraphDataSet3;
jmitc91516 1:a5258871b33d 514 delete runningColumnPageGraphDataSet4;
jmitc91516 1:a5258871b33d 515
jmitc91516 1:a5258871b33d 516
jmitc91516 1:a5258871b33d 517 delete runningGasPageGraph;
jmitc91516 1:a5258871b33d 518
jmitc91516 1:a5258871b33d 519 delete runningGasPageGraphCompleteProfileDataSet;
jmitc91516 1:a5258871b33d 520 delete runningGasPageGraphDataSet0;
jmitc91516 1:a5258871b33d 521 delete runningGasPageGraphDataSet1;
jmitc91516 1:a5258871b33d 522 delete runningGasPageGraphDataSet2;
jmitc91516 1:a5258871b33d 523 delete runningGasPageGraphDataSet3;
jmitc91516 1:a5258871b33d 524 delete runningGasPageGraphDataSet4;
jmitc91516 1:a5258871b33d 525
jmitc91516 1:a5258871b33d 526
jmitc91516 1:a5258871b33d 527 delete injectorTempProfilePageGraph;
jmitc91516 1:a5258871b33d 528
jmitc91516 1:a5258871b33d 529 delete injectorTempProfilePageGraphCompleteProfileDataSet;
jmitc91516 1:a5258871b33d 530 delete injectorTempProfilePageGraphDataSet0;
jmitc91516 1:a5258871b33d 531 delete injectorTempProfilePageGraphDataSet1;
jmitc91516 1:a5258871b33d 532 delete injectorTempProfilePageGraphDataSet2;
jmitc91516 1:a5258871b33d 533 delete injectorTempProfilePageGraphDataSet3;
jmitc91516 1:a5258871b33d 534 delete injectorTempProfilePageGraphDataSet4;
jmitc91516 1:a5258871b33d 535
jmitc91516 1:a5258871b33d 536
jmitc91516 1:a5258871b33d 537 delete gasFlowProfilePageGraph;
jmitc91516 1:a5258871b33d 538
jmitc91516 1:a5258871b33d 539 delete gasFlowProfilePageGraphCompleteProfileDataSet;
jmitc91516 1:a5258871b33d 540 delete gasFlowProfilePageGraphDataSet0;
jmitc91516 1:a5258871b33d 541 delete gasFlowProfilePageGraphDataSet1;
jmitc91516 1:a5258871b33d 542 delete gasFlowProfilePageGraphDataSet2;
jmitc91516 1:a5258871b33d 543 delete gasFlowProfilePageGraphDataSet3;
jmitc91516 1:a5258871b33d 544 delete gasFlowProfilePageGraphDataSet4;
jmitc91516 1:a5258871b33d 545
jmitc91516 1:a5258871b33d 546
jmitc91516 1:a5258871b33d 547 delete columnTempProfilePageGraph;
jmitc91516 1:a5258871b33d 548
jmitc91516 1:a5258871b33d 549 delete columnTempProfilePageGraphCompleteProfileDataSet;
jmitc91516 1:a5258871b33d 550 delete columnTempProfilePageGraphDataSet0;
jmitc91516 1:a5258871b33d 551 delete columnTempProfilePageGraphDataSet1;
jmitc91516 1:a5258871b33d 552 delete columnTempProfilePageGraphDataSet2;
jmitc91516 1:a5258871b33d 553 delete columnTempProfilePageGraphDataSet3;
jmitc91516 1:a5258871b33d 554 delete columnTempProfilePageGraphDataSet4;
jmitc91516 1:a5258871b33d 555
jmitc91516 1:a5258871b33d 556
jmitc91516 1:a5258871b33d 557 delete runningInjectorPageGraph;
jmitc91516 1:a5258871b33d 558
jmitc91516 1:a5258871b33d 559 delete runningInjectorPageGraphCompleteProfileDataSet;
jmitc91516 1:a5258871b33d 560 delete runningInjectorPageGraphDataSet0;
jmitc91516 1:a5258871b33d 561 delete runningInjectorPageGraphDataSet1;
jmitc91516 1:a5258871b33d 562 delete runningInjectorPageGraphDataSet2;
jmitc91516 1:a5258871b33d 563 delete runningInjectorPageGraphDataSet3;
jmitc91516 1:a5258871b33d 564 delete runningInjectorPageGraphDataSet4;
jmitc91516 5:aceac1035d71 565
jmitc91516 5:aceac1035d71 566 if(columnMethodRampData != NULL) {
jmitc91516 5:aceac1035d71 567 delete columnMethodRampData;
jmitc91516 5:aceac1035d71 568 }
jmitc91516 6:dba3fbdfd5da 569
jmitc91516 6:dba3fbdfd5da 570 if(injectorMethodRampData != NULL) {
jmitc91516 6:dba3fbdfd5da 571 delete injectorMethodRampData;
jmitc91516 6:dba3fbdfd5da 572 }
jmitc91516 6:dba3fbdfd5da 573
jmitc91516 6:dba3fbdfd5da 574 if(gasMethodRampData != NULL) {
jmitc91516 6:dba3fbdfd5da 575 delete gasMethodRampData;
jmitc91516 6:dba3fbdfd5da 576 }
jmitc91516 1:a5258871b33d 577
jmitc91516 1:a5258871b33d 578 #ifdef MULTI_TOUCH_TECHNIQUE_1
jmitc91516 1:a5258871b33d 579 rtosTimer->stop();
jmitc91516 1:a5258871b33d 580 delete rtosTimer;
jmitc91516 1:a5258871b33d 581 #endif // MULTI_TOUCH_TECHNIQUE_1
jmitc91516 1:a5258871b33d 582 }
jmitc91516 1:a5258871b33d 583
jmitc91516 1:a5258871b33d 584 void GetGCStatusLoop::SetQSPIBitmaps(QSPIBitmaps* ptrToQSPIBitmaps)
jmitc91516 1:a5258871b33d 585 {
jmitc91516 1:a5258871b33d 586 qspiBitmaps = ptrToQSPIBitmaps;
jmitc91516 1:a5258871b33d 587 }
jmitc91516 1:a5258871b33d 588
jmitc91516 1:a5258871b33d 589
jmitc91516 1:a5258871b33d 590 /*
jmitc91516 1:a5258871b33d 591 Displays the column lock and release buttons "on top of" the Lock/Unlock (originally Open Door) button
jmitc91516 1:a5258871b33d 592 defined in easyGUI, and displayed on each of the column pages. This allows us to give the user
jmitc91516 1:a5258871b33d 593 two options (Lock or Release) when we complete the Close operation - the rest of the time
jmitc91516 1:a5258871b33d 594 we display only one option, and this is how the easyGUI pages for the column are set up.
jmitc91516 1:a5258871b33d 595 Since it appears to be impossible to show or hide individual easyGUI controls at run time
jmitc91516 1:a5258871b33d 596 (i.e. each easyGUI page is fixed at design time) this seems to be the only way
jmitc91516 1:a5258871b33d 597 to make a change to the user interface at run time.
jmitc91516 1:a5258871b33d 598
jmitc91516 1:a5258871b33d 599 No arguments, no return code.
jmitc91516 1:a5258871b33d 600 */
jmitc91516 1:a5258871b33d 601 void GetGCStatusLoop::DisplayColumnLockAndReleaseButtons(void)
jmitc91516 1:a5258871b33d 602 {
jmitc91516 1:a5258871b33d 603 // Two adjoining rectangles on top of the current Lock/Unlock button
jmitc91516 1:a5258871b33d 604 GuiLib_BorderBox(248, 404, 400, 480, 0, SixteenBitColorValue(128, 128, 128)); // Black border, grey fill
jmitc91516 1:a5258871b33d 605 DisplayText("Lock", 324, 450, GuiLib_ALIGN_CENTER, GuiFont_Helv20Bold, GuiVar_doorActuatorCommandFGColour);
jmitc91516 1:a5258871b33d 606 GuiLib_BorderBox(400, 404, 552, 480, 0, SixteenBitColorValue(128, 128, 128)); // Black border, grey fill
jmitc91516 1:a5258871b33d 607 DisplayText("Release", 476, 450, GuiLib_ALIGN_CENTER, GuiFont_Helv20Bold, GuiVar_doorActuatorCommandFGColour);
jmitc91516 1:a5258871b33d 608 }
jmitc91516 1:a5258871b33d 609
jmitc91516 1:a5258871b33d 610
jmitc91516 1:a5258871b33d 611 void GetGCStatusLoop::SetupColumnAndInjectorAndGasProfileData(void)
jmitc91516 1:a5258871b33d 612 {
jmitc91516 1:a5258871b33d 613 // Do this *** before *** setting up the injector and gas profiles
jmitc91516 1:a5258871b33d 614 SetupColumnTempProfilePageGraphDataFromGC();
jmitc91516 1:a5258871b33d 615
jmitc91516 1:a5258871b33d 616 // Do this *** after *** setting up the column method
jmitc91516 1:a5258871b33d 617 SetupInjectorTempProfilePageGraphDataFromGC();
jmitc91516 1:a5258871b33d 618
jmitc91516 1:a5258871b33d 619 // Do this *** after *** setting up the column method
jmitc91516 1:a5258871b33d 620 SetupGasFlowProfilePageGraphDataFromGC();
jmitc91516 1:a5258871b33d 621
jmitc91516 1:a5258871b33d 622 // These easyGUI variables are intended to warn the user if we have
jmitc91516 1:a5258871b33d 623 // no methods set up for these components - but we do now have methods for them
jmitc91516 1:a5258871b33d 624 GuiVar_columnTempProfilePageNoMethod[0] = '\0';
jmitc91516 1:a5258871b33d 625 GuiVar_injectorTempProfilePageNoMethod[0]= '\0';
jmitc91516 1:a5258871b33d 626 GuiVar_gasFlowProfilePageNoMethod[0]= '\0';
jmitc91516 1:a5258871b33d 627 }
jmitc91516 1:a5258871b33d 628
jmitc91516 1:a5258871b33d 629 /*
jmitc91516 1:a5258871b33d 630 Called by the system in response to timer ticks.
jmitc91516 1:a5258871b33d 631
jmitc91516 1:a5258871b33d 632 *** Needs to be kept as short as possible ***
jmitc91516 1:a5258871b33d 633 */
jmitc91516 1:a5258871b33d 634 void GetGCStatusLoop::TimerCallback(void const * argument)
jmitc91516 1:a5258871b33d 635 {
jmitc91516 1:a5258871b33d 636 #ifdef MULTI_TOUCH_TECHNIQUE_1
jmitc91516 1:a5258871b33d 637 ++timerTickCount;
jmitc91516 1:a5258871b33d 638
jmitc91516 1:a5258871b33d 639 osSignalSet(timerCallbackThreadToSignal, TIMER_TICK);
jmitc91516 1:a5258871b33d 640 #endif // MULTI_TOUCH_TECHNIQUE_1
jmitc91516 1:a5258871b33d 641 }
jmitc91516 1:a5258871b33d 642
jmitc91516 1:a5258871b33d 643 /*
jmitc91516 1:a5258871b33d 644 Creates (but does not assign any data to) the objects that deal with the easyGUI graphs
jmitc91516 1:a5258871b33d 645 and their datasets. We should only need to create these once,
jmitc91516 1:a5258871b33d 646 but we may need to setup or change their data any number of times.
jmitc91516 1:a5258871b33d 647 */
jmitc91516 1:a5258871b33d 648 void GetGCStatusLoop::CreateGuiLibGraphsAndDataSets(void)
jmitc91516 1:a5258871b33d 649 {
jmitc91516 1:a5258871b33d 650 // The values passed to the GuiLibGraph constructor in creating each instance below
jmitc91516 1:a5258871b33d 651 // *must* *match* the graph indices assigned in the corresponding easyGUI 'structures' -
jmitc91516 1:a5258871b33d 652 // there seems to be no way of getting these values from easyGUI at runtime,
jmitc91516 1:a5258871b33d 653 // so we must hard code them here
jmitc91516 1:a5258871b33d 654 runningColumnPageGraph = new GuiLibGraph(0);
jmitc91516 1:a5258871b33d 655 runningGasPageGraph = new GuiLibGraph(1);
jmitc91516 1:a5258871b33d 656 injectorTempProfilePageGraph = new GuiLibGraph(2);
jmitc91516 1:a5258871b33d 657 gasFlowProfilePageGraph = new GuiLibGraph(3);
jmitc91516 1:a5258871b33d 658 columnTempProfilePageGraph = new GuiLibGraph(4);
jmitc91516 1:a5258871b33d 659 runningInjectorPageGraph = new GuiLibGraph(6);
jmitc91516 1:a5258871b33d 660
jmitc91516 1:a5258871b33d 661
jmitc91516 1:a5258871b33d 662 // Now create the datasets for each graph.
jmitc91516 1:a5258871b33d 663 //
jmitc91516 1:a5258871b33d 664 // In each case, the 'xxxGraphCompleteProfileDataSet' object contains the complete profile, but we do not display it (as such)
jmitc91516 1:a5258871b33d 665 // on the relevant graph. Instead, we make partial copies of it to each of the 'xxxGraphDataSetn' objects,
jmitc91516 1:a5258871b33d 666 // separating the points between the start and 'now' from the points between 'now' and the end of the method.
jmitc91516 1:a5258871b33d 667 // This allows us to assign these to different datasets in the relevant easyGUI graph, so that we can display
jmitc91516 1:a5258871b33d 668 // them in different colours and in different styles.
jmitc91516 1:a5258871b33d 669 //
jmitc91516 1:a5258871b33d 670 // Having the complete profile in one dataset, then copying the relevant parts of it to the others, makes the code simpler,
jmitc91516 1:a5258871b33d 671 // and easier to understand, than if we kept getting partial copies of the profile from the GC.
jmitc91516 1:a5258871b33d 672 //
jmitc91516 1:a5258871b33d 673 runningColumnPageGraphCompleteProfileDataSet = new GuiLibGraphDataSet;
jmitc91516 1:a5258871b33d 674 runningColumnPageGraphDataSet0 = new GuiLibGraphDataSet;
jmitc91516 1:a5258871b33d 675 runningColumnPageGraphDataSet1 = new GuiLibGraphDataSet;
jmitc91516 1:a5258871b33d 676 runningColumnPageGraphDataSet2 = new GuiLibGraphDataSet;
jmitc91516 1:a5258871b33d 677 runningColumnPageGraphDataSet3 = new GuiLibGraphDataSet;
jmitc91516 1:a5258871b33d 678 runningColumnPageGraphDataSet4 = new GuiLibGraphDataSet;
jmitc91516 1:a5258871b33d 679
jmitc91516 1:a5258871b33d 680 runningGasPageGraphCompleteProfileDataSet = new GuiLibGraphDataSet;
jmitc91516 1:a5258871b33d 681 runningGasPageGraphDataSet0 = new GuiLibGraphDataSet;
jmitc91516 1:a5258871b33d 682 runningGasPageGraphDataSet1 = new GuiLibGraphDataSet;
jmitc91516 1:a5258871b33d 683 runningGasPageGraphDataSet2 = new GuiLibGraphDataSet;
jmitc91516 1:a5258871b33d 684 runningGasPageGraphDataSet3 = new GuiLibGraphDataSet;
jmitc91516 1:a5258871b33d 685 runningGasPageGraphDataSet4 = new GuiLibGraphDataSet;
jmitc91516 1:a5258871b33d 686
jmitc91516 1:a5258871b33d 687 injectorTempProfilePageGraphCompleteProfileDataSet = new GuiLibGraphDataSet;
jmitc91516 1:a5258871b33d 688 injectorTempProfilePageGraphDataSet0 = new GuiLibGraphDataSet;
jmitc91516 1:a5258871b33d 689 injectorTempProfilePageGraphDataSet1 = new GuiLibGraphDataSet;
jmitc91516 1:a5258871b33d 690 injectorTempProfilePageGraphDataSet2 = new GuiLibGraphDataSet;
jmitc91516 1:a5258871b33d 691 injectorTempProfilePageGraphDataSet3 = new GuiLibGraphDataSet;
jmitc91516 1:a5258871b33d 692 injectorTempProfilePageGraphDataSet4 = new GuiLibGraphDataSet;
jmitc91516 1:a5258871b33d 693
jmitc91516 1:a5258871b33d 694 gasFlowProfilePageGraphCompleteProfileDataSet = new GuiLibGraphDataSet;
jmitc91516 1:a5258871b33d 695 gasFlowProfilePageGraphDataSet0 = new GuiLibGraphDataSet;
jmitc91516 1:a5258871b33d 696 gasFlowProfilePageGraphDataSet1 = new GuiLibGraphDataSet;
jmitc91516 1:a5258871b33d 697 gasFlowProfilePageGraphDataSet2 = new GuiLibGraphDataSet;
jmitc91516 1:a5258871b33d 698 gasFlowProfilePageGraphDataSet3 = new GuiLibGraphDataSet;
jmitc91516 1:a5258871b33d 699 gasFlowProfilePageGraphDataSet4 = new GuiLibGraphDataSet;
jmitc91516 1:a5258871b33d 700
jmitc91516 1:a5258871b33d 701 // These are used in both column page graphs (conventional and DH)
jmitc91516 1:a5258871b33d 702 columnTempProfilePageGraphCompleteProfileDataSet = new GuiLibGraphDataSet;
jmitc91516 1:a5258871b33d 703 columnTempProfilePageGraphDataSet0 = new GuiLibGraphDataSet;
jmitc91516 1:a5258871b33d 704 columnTempProfilePageGraphDataSet1 = new GuiLibGraphDataSet;
jmitc91516 1:a5258871b33d 705 columnTempProfilePageGraphDataSet2 = new GuiLibGraphDataSet;
jmitc91516 1:a5258871b33d 706 columnTempProfilePageGraphDataSet3 = new GuiLibGraphDataSet;
jmitc91516 1:a5258871b33d 707 columnTempProfilePageGraphDataSet4 = new GuiLibGraphDataSet;
jmitc91516 1:a5258871b33d 708
jmitc91516 1:a5258871b33d 709 runningInjectorPageGraphCompleteProfileDataSet = new GuiLibGraphDataSet;
jmitc91516 1:a5258871b33d 710 runningInjectorPageGraphDataSet0 = new GuiLibGraphDataSet;
jmitc91516 1:a5258871b33d 711 runningInjectorPageGraphDataSet1 = new GuiLibGraphDataSet;
jmitc91516 1:a5258871b33d 712 runningInjectorPageGraphDataSet2 = new GuiLibGraphDataSet;
jmitc91516 1:a5258871b33d 713 runningInjectorPageGraphDataSet3 = new GuiLibGraphDataSet;
jmitc91516 1:a5258871b33d 714 runningInjectorPageGraphDataSet4 = new GuiLibGraphDataSet;
jmitc91516 1:a5258871b33d 715 }
jmitc91516 1:a5258871b33d 716
jmitc91516 1:a5258871b33d 717
jmitc91516 1:a5258871b33d 718 /*
jmitc91516 1:a5258871b33d 719 Set up the graph on the Column temperature profile page from the method currently set up in the GC.
jmitc91516 1:a5258871b33d 720
jmitc91516 1:a5258871b33d 721 Note that we always display this data as if the 'current time' were at the start of the method.
jmitc91516 1:a5258871b33d 722 */
jmitc91516 1:a5258871b33d 723 void GetGCStatusLoop::SetupColumnTempProfilePageGraphDataFromGC(void)
jmitc91516 1:a5258871b33d 724 {
jmitc91516 1:a5258871b33d 725 // We do not display 'columnTempProfilePageGraphCompleteProfileDataSet' in the graph -
jmitc91516 1:a5258871b33d 726 // we use it to generate the datasets that we will display.
jmitc91516 1:a5258871b33d 727 // Use seconds as the dataset time units if the method duration is less than five minutes,
jmitc91516 1:a5258871b33d 728 // otherwise use minutes.
jmitc91516 1:a5258871b33d 729 columnTempProfilePageGraphCompleteProfileDataSet->SetupFromColumnTemperatureRampValues(usbDevice, usbHostGC);
jmitc91516 1:a5258871b33d 730
jmitc91516 1:a5258871b33d 731 float totalColumnMethodTime = columnTempProfilePageGraphCompleteProfileDataSet->GetTotalMethodTime();
jmitc91516 1:a5258871b33d 732
jmitc91516 1:a5258871b33d 733 TimeUnit timeUnit = MINUTES;
jmitc91516 1:a5258871b33d 734 float barInterval = graphBarIntervalMinutes;
jmitc91516 1:a5258871b33d 735 if(totalColumnMethodTime < methodTimeUnitsThreshold) {
jmitc91516 1:a5258871b33d 736 timeUnit = SECONDS;
jmitc91516 1:a5258871b33d 737 barInterval = graphBarIntervalSeconds;
jmitc91516 1:a5258871b33d 738 }
jmitc91516 1:a5258871b33d 739
jmitc91516 1:a5258871b33d 740 // We do not display this graph while the method is running - so for the purposes of displaying the datasets in the graph,
jmitc91516 1:a5258871b33d 741 // we say that 'now' is at the start of the method.
jmitc91516 1:a5258871b33d 742
jmitc91516 1:a5258871b33d 743 // Dataset 0 is a line representing the temperature profile of the run from 'now' to the finish
jmitc91516 1:a5258871b33d 744 columnTempProfilePageGraphCompleteProfileDataSet->MakePartialCopy(0, totalColumnMethodTime, columnTempProfilePageGraphDataSet0);
jmitc91516 1:a5258871b33d 745
jmitc91516 1:a5258871b33d 746 // Dataset 1 is a bar chart representing the temperature profile of the run from 'now' to the finish -
jmitc91516 1:a5258871b33d 747 // make sure that we have a bar at the exact end of the profile
jmitc91516 1:a5258871b33d 748 columnTempProfilePageGraphCompleteProfileDataSet->MakeInterpolatedPartialCopyWithFinalPoint(0, totalColumnMethodTime, barInterval, columnTempProfilePageGraphDataSet1);
jmitc91516 1:a5258871b33d 749
jmitc91516 1:a5258871b33d 750 // Data set 2 is a line representing the temperature profile from the start to 'now'
jmitc91516 1:a5258871b33d 751 columnTempProfilePageGraphDataSet2->ClearData();
jmitc91516 1:a5258871b33d 752
jmitc91516 1:a5258871b33d 753 // Data set 3 is a bar chart representing the temperature profile of the run from the start to 'now'
jmitc91516 1:a5258871b33d 754 columnTempProfilePageGraphDataSet3->ClearData();
jmitc91516 1:a5258871b33d 755
jmitc91516 1:a5258871b33d 756 // Data set 4 is a single dot at the current time and temperature
jmitc91516 1:a5258871b33d 757 columnTempProfilePageGraphDataSet4->ClearData();
jmitc91516 1:a5258871b33d 758 #ifdef USING_DATASET_4_ON_NON_RUNNING_GRAPHS
jmitc91516 1:a5258871b33d 759 GuiConst_INT32S startTemp = columnTempProfilePageGraphCompleteProfileDataSet->GetYCoordAtXCoord(0);
jmitc91516 1:a5258871b33d 760 columnTempProfilePageGraphDataSet4->AddDataPoint(0, startTemp);
jmitc91516 1:a5258871b33d 761 #endif // USING_DATASET_4_ON_NON_RUNNING_GRAPHS
jmitc91516 1:a5258871b33d 762
jmitc91516 1:a5258871b33d 763 SetupColumnTempProfilePageXAxisLabel(timeUnit);
jmitc91516 1:a5258871b33d 764 }
jmitc91516 1:a5258871b33d 765
jmitc91516 1:a5258871b33d 766
jmitc91516 1:a5258871b33d 767 /*
jmitc91516 1:a5258871b33d 768 Set up the graph on the Injector temperature profile page from the method currently set up in the GC.
jmitc91516 1:a5258871b33d 769
jmitc91516 1:a5258871b33d 770 Note that we always display this data as if the 'current time' were at the start of the method.
jmitc91516 1:a5258871b33d 771
jmitc91516 1:a5258871b33d 772 Note also that the column method dataset must be setup before this function is called - i.e.
jmitc91516 1:a5258871b33d 773 SetupColumnTempProfilePageGraphDataFromGC must be called before this function
jmitc91516 1:a5258871b33d 774 *****************************************************************************
jmitc91516 1:a5258871b33d 775
jmitc91516 1:a5258871b33d 776 If not, this function will do nothing.
jmitc91516 1:a5258871b33d 777
jmitc91516 1:a5258871b33d 778 */
jmitc91516 1:a5258871b33d 779 void GetGCStatusLoop::SetupInjectorTempProfilePageGraphDataFromGC(void)
jmitc91516 1:a5258871b33d 780 {
jmitc91516 1:a5258871b33d 781 // We do not display 'injectorTempProfilePageGraphCompleteProfileDataSet' in the graph -
jmitc91516 1:a5258871b33d 782 // we use it to generate the datasets that we will display.
jmitc91516 1:a5258871b33d 783
jmitc91516 1:a5258871b33d 784 #ifdef PTV_RAMPS_AVAILABLE
jmitc91516 1:a5258871b33d 785 float totalMethodTime;
jmitc91516 1:a5258871b33d 786 #else
jmitc91516 1:a5258871b33d 787 // Before setting up the injector temperature profile, we need a column method to base it on
jmitc91516 1:a5258871b33d 788 float totalMethodTime = columnTempProfilePageGraphCompleteProfileDataSet->GetTotalMethodTime();
jmitc91516 1:a5258871b33d 789 if(totalMethodTime <= 0.0f) {
jmitc91516 1:a5258871b33d 790 // Method not set up
jmitc91516 1:a5258871b33d 791 return;
jmitc91516 1:a5258871b33d 792 }
jmitc91516 1:a5258871b33d 793 #endif // PTV_RAMPS_AVAILABLE
jmitc91516 1:a5258871b33d 794
jmitc91516 1:a5258871b33d 795
jmitc91516 1:a5258871b33d 796 #ifdef PTV_RAMPS_AVAILABLE
jmitc91516 1:a5258871b33d 797 injectorTempProfilePageGraphCompleteProfileDataSet->SetupFromPTVTemperatureRampValues(usbDevice, usbHostGC);
jmitc91516 1:a5258871b33d 798 totalMethodTime = injectorTempProfilePageGraphCompleteProfileDataSet->GetTotalMethodTime();
jmitc91516 1:a5258871b33d 799 #else
jmitc91516 1:a5258871b33d 800 injectorTempProfilePageGraphCompleteProfileDataSet->SetupInjectorTemperatureProfileToMatchColumnMethod(usbDevice, usbHostGC, columnTempProfilePageGraphCompleteProfileDataSet);
jmitc91516 1:a5258871b33d 801 #endif // PTV_RAMPS_AVAILABLE
jmitc91516 1:a5258871b33d 802
jmitc91516 1:a5258871b33d 803 TimeUnit timeUnit = MINUTES;
jmitc91516 1:a5258871b33d 804 float barInterval = graphBarIntervalMinutes;
jmitc91516 1:a5258871b33d 805 if(totalMethodTime < methodTimeUnitsThreshold) {
jmitc91516 1:a5258871b33d 806 timeUnit = SECONDS;
jmitc91516 1:a5258871b33d 807 barInterval = graphBarIntervalSeconds;
jmitc91516 1:a5258871b33d 808 }
jmitc91516 1:a5258871b33d 809
jmitc91516 1:a5258871b33d 810
jmitc91516 1:a5258871b33d 811 // We do not display this graph while the method is running - so for the purposes of displaying the datasets in the graph,
jmitc91516 1:a5258871b33d 812 // we say that 'now' is at the start of the method.
jmitc91516 1:a5258871b33d 813
jmitc91516 1:a5258871b33d 814 // Dataset 0 is a line representing the temperature profile of the run from 'now' to the finish
jmitc91516 1:a5258871b33d 815 injectorTempProfilePageGraphCompleteProfileDataSet->MakePartialCopy(0, totalMethodTime, injectorTempProfilePageGraphDataSet0);
jmitc91516 1:a5258871b33d 816
jmitc91516 1:a5258871b33d 817 // Dataset 1 is a bar chart representing the temperature profile of the run from 'now' to the finish
jmitc91516 1:a5258871b33d 818 injectorTempProfilePageGraphCompleteProfileDataSet->MakeInterpolatedPartialCopyWithFinalPoint(0, totalMethodTime, barInterval, injectorTempProfilePageGraphDataSet1);
jmitc91516 1:a5258871b33d 819
jmitc91516 1:a5258871b33d 820 // Data set 2 is a line representing the temperature profile from the start to 'now'
jmitc91516 1:a5258871b33d 821 injectorTempProfilePageGraphDataSet2->ClearData();
jmitc91516 1:a5258871b33d 822
jmitc91516 1:a5258871b33d 823 // Data set 3 is a bar chart representing the temperature profile of the run from the start to 'now'
jmitc91516 1:a5258871b33d 824 injectorTempProfilePageGraphDataSet3->ClearData();
jmitc91516 1:a5258871b33d 825
jmitc91516 1:a5258871b33d 826 // Data set 4 is a single dot at the current time and temperature
jmitc91516 1:a5258871b33d 827 injectorTempProfilePageGraphDataSet4->ClearData();
jmitc91516 1:a5258871b33d 828 #ifdef USING_DATASET_4_ON_NON_RUNNING_GRAPHS
jmitc91516 1:a5258871b33d 829 float startTemp = injectorTempProfilePageGraphCompleteProfileDataSet->GetYCoordAtXCoord(0);
jmitc91516 1:a5258871b33d 830 injectorTempProfilePageGraphDataSet4->AddDataPoint(0, startTemp);
jmitc91516 1:a5258871b33d 831 #endif // USING_DATASET_4_ON_NON_RUNNING_GRAPHS
jmitc91516 1:a5258871b33d 832
jmitc91516 1:a5258871b33d 833 SetupInjectorTempProfilePageXAxisLabel(timeUnit);
jmitc91516 1:a5258871b33d 834 }
jmitc91516 1:a5258871b33d 835
jmitc91516 1:a5258871b33d 836
jmitc91516 1:a5258871b33d 837 /*
jmitc91516 1:a5258871b33d 838 Set up the graph on the Gas flow profile page from the method currently set up in the GC.
jmitc91516 1:a5258871b33d 839
jmitc91516 1:a5258871b33d 840 Note that we always display this data as if the 'current time' were at the start of the method.
jmitc91516 1:a5258871b33d 841
jmitc91516 1:a5258871b33d 842 Note also that the column method must be set up before calling this function.
jmitc91516 1:a5258871b33d 843 */
jmitc91516 1:a5258871b33d 844 void GetGCStatusLoop::SetupGasFlowProfilePageGraphDataFromGC(void)
jmitc91516 1:a5258871b33d 845 {
jmitc91516 1:a5258871b33d 846 // Before setting up the gas pressure profile, we need a column method to base it on
jmitc91516 1:a5258871b33d 847 float totalColumnMethodTime = columnTempProfilePageGraphCompleteProfileDataSet->GetTotalMethodTime();
jmitc91516 1:a5258871b33d 848 if(totalColumnMethodTime <= 0.0f) {
jmitc91516 1:a5258871b33d 849 // Column method not set up
jmitc91516 1:a5258871b33d 850 return;
jmitc91516 1:a5258871b33d 851 }
jmitc91516 1:a5258871b33d 852
jmitc91516 1:a5258871b33d 853 // We do not display 'gasFlowProfilePageGraphCompleteProfileDataSet' in the graph -
jmitc91516 1:a5258871b33d 854 // we use it to generate the datasets that we will display.
jmitc91516 1:a5258871b33d 855 gasFlowProfilePageGraphCompleteProfileDataSet->SetupGasPressureProfileWithTimingsFromColumnMethod(usbDevice, usbHostGC, columnTempProfilePageGraphCompleteProfileDataSet);
jmitc91516 1:a5258871b33d 856
jmitc91516 1:a5258871b33d 857 float totalGasFlowMethodTime = gasFlowProfilePageGraphCompleteProfileDataSet->GetTotalMethodTime();
jmitc91516 1:a5258871b33d 858
jmitc91516 1:a5258871b33d 859 TimeUnit timeUnit = MINUTES;
jmitc91516 1:a5258871b33d 860 float barInterval = graphBarIntervalMinutes;
jmitc91516 1:a5258871b33d 861 if(totalGasFlowMethodTime < methodTimeUnitsThreshold) {
jmitc91516 1:a5258871b33d 862 timeUnit = SECONDS;
jmitc91516 1:a5258871b33d 863 barInterval = graphBarIntervalSeconds;
jmitc91516 1:a5258871b33d 864 }
jmitc91516 1:a5258871b33d 865
jmitc91516 1:a5258871b33d 866
jmitc91516 1:a5258871b33d 867 // We do not display this graph while the method is running - so for the purposes of displaying the datasets in the graph,
jmitc91516 1:a5258871b33d 868 // we say that 'now' is at the start of the method.
jmitc91516 1:a5258871b33d 869
jmitc91516 1:a5258871b33d 870 // Dataset 0 is a line representing the pressure profile of the run from 'now' to the finish
jmitc91516 1:a5258871b33d 871 gasFlowProfilePageGraphCompleteProfileDataSet->MakePartialCopy(0, totalGasFlowMethodTime, gasFlowProfilePageGraphDataSet0);
jmitc91516 1:a5258871b33d 872
jmitc91516 1:a5258871b33d 873 // Dataset 1 is a bar chart representing the pressure profile of the run from 'now' to the finish
jmitc91516 1:a5258871b33d 874 gasFlowProfilePageGraphCompleteProfileDataSet->MakeInterpolatedPartialCopyWithFinalPoint(0, totalGasFlowMethodTime, barInterval, gasFlowProfilePageGraphDataSet1);
jmitc91516 1:a5258871b33d 875
jmitc91516 1:a5258871b33d 876 // Data set 2 is a line representing the pressure profile from the start to 'now'
jmitc91516 1:a5258871b33d 877 gasFlowProfilePageGraphDataSet2->ClearData();
jmitc91516 1:a5258871b33d 878
jmitc91516 1:a5258871b33d 879 // Data set 3 is a bar chart representing the pressure profile of the run from the start to 'now'
jmitc91516 1:a5258871b33d 880 gasFlowProfilePageGraphDataSet3->ClearData();
jmitc91516 1:a5258871b33d 881
jmitc91516 1:a5258871b33d 882 // Data set 4 is a single dot at the current time and pressure
jmitc91516 1:a5258871b33d 883 gasFlowProfilePageGraphDataSet4->ClearData();
jmitc91516 1:a5258871b33d 884 #ifdef USING_DATASET_4_ON_NON_RUNNING_GRAPHS
jmitc91516 1:a5258871b33d 885 GuiConst_INT32S startTemp = gasFlowProfilePageGraphCompleteProfileDataSet->GetYCoordAtXCoord(0);
jmitc91516 1:a5258871b33d 886 gasFlowProfilePageGraphDataSet4->AddDataPoint(0, startTemp);
jmitc91516 1:a5258871b33d 887 #endif // USING_DATASET_4_ON_NON_RUNNING_GRAPHS
jmitc91516 1:a5258871b33d 888
jmitc91516 1:a5258871b33d 889 SetupGasFlowProfilePageXAxisLabel(timeUnit);
jmitc91516 1:a5258871b33d 890 }
jmitc91516 1:a5258871b33d 891
jmitc91516 1:a5258871b33d 892
jmitc91516 1:a5258871b33d 893 /*
jmitc91516 1:a5258871b33d 894 Set up the complete temperature profile dataset for the graph on the 'running column' page
jmitc91516 1:a5258871b33d 895 to match the method data currently set up in the GC.
jmitc91516 1:a5258871b33d 896
jmitc91516 1:a5258871b33d 897 We assume that we will not have to do this again while the current method is running.
jmitc91516 1:a5258871b33d 898 */
jmitc91516 1:a5258871b33d 899 void GetGCStatusLoop::SetupRunningColumnPageGraphCompleteProfileDataSetFromGC(void)
jmitc91516 1:a5258871b33d 900 {
jmitc91516 1:a5258871b33d 901 // Use seconds as the dataset time units if the method duration is less than five minutes,
jmitc91516 1:a5258871b33d 902 // otherwise use minutes
jmitc91516 1:a5258871b33d 903 runningColumnPageGraphCompleteProfileDataSet->SetupFromColumnTemperatureRampValues(usbDevice, usbHostGC);
jmitc91516 1:a5258871b33d 904
jmitc91516 1:a5258871b33d 905 runningColumnPageGraph->SetXAxisRange(0, (GuiConst_INT32S) runningColumnPageGraphCompleteProfileDataSet->GetTotalMethodTime());
jmitc91516 1:a5258871b33d 906
jmitc91516 1:a5258871b33d 907 if(runningColumnPageGraphCompleteProfileDataSet->GetTotalMethodTime() < methodTimeUnitsThreshold) {
jmitc91516 1:a5258871b33d 908 strcpy(GuiVar_runningColumnPageXAxisLabel, "Time (seconds)");
jmitc91516 1:a5258871b33d 909 } else {
jmitc91516 1:a5258871b33d 910 strcpy(GuiVar_runningColumnPageXAxisLabel, "Time (minutes)");
jmitc91516 1:a5258871b33d 911 }
jmitc91516 1:a5258871b33d 912 }
jmitc91516 1:a5258871b33d 913
jmitc91516 1:a5258871b33d 914 /*
jmitc91516 1:a5258871b33d 915 Update the partial datasets for the temperature profile graph on the 'running column' page
jmitc91516 1:a5258871b33d 916 (i.e. the datasets that split up the profile into the section from the start to 'now'
jmitc91516 1:a5258871b33d 917 and the section from 'now' to the end) to match (a) the complete profile obtained from the GC,
jmitc91516 1:a5258871b33d 918 and (b) the current time.
jmitc91516 1:a5258871b33d 919
jmitc91516 1:a5258871b33d 920 Caller *must* have previously called the 'SetupRunningColumnPageGraphCompleteProfileDataSetFromGC' function.
jmitc91516 1:a5258871b33d 921
jmitc91516 1:a5258871b33d 922 Returns true if the datasets have changed, false if not
jmitc91516 1:a5258871b33d 923 */
jmitc91516 1:a5258871b33d 924 bool GetGCStatusLoop::SetupRunningColumnPageGraphPartialDataSetsToMatchCurrentRunTime(bool runHasCompleted)
jmitc91516 1:a5258871b33d 925 {
jmitc91516 1:a5258871b33d 926 if(columnMethodFinished) {
jmitc91516 1:a5258871b33d 927 return false; // Our work here is done...
jmitc91516 1:a5258871b33d 928 }
jmitc91516 1:a5258871b33d 929
jmitc91516 1:a5258871b33d 930 float currentColumnMethodRunTime;
jmitc91516 1:a5258871b33d 931 GetRunTime(&currentColumnMethodRunTime);
jmitc91516 1:a5258871b33d 932
jmitc91516 1:a5258871b33d 933
jmitc91516 1:a5258871b33d 934 float totalColumnMethodMethodTime = runningColumnPageGraphCompleteProfileDataSet->GetTotalMethodTime();
jmitc91516 1:a5258871b33d 935
jmitc91516 1:a5258871b33d 936 float barInterval = graphBarIntervalMinutes;
jmitc91516 1:a5258871b33d 937 if(totalColumnMethodMethodTime < methodTimeUnitsThreshold) {
jmitc91516 1:a5258871b33d 938 barInterval = graphBarIntervalSeconds;
jmitc91516 1:a5258871b33d 939 } else {
jmitc91516 1:a5258871b33d 940 // We are using minutes - work in whole minutes, and show the number we have completed
jmitc91516 1:a5258871b33d 941 // (i.e. do not round the number up)
jmitc91516 1:a5258871b33d 942 currentColumnMethodRunTime = (float)floor((double)currentColumnMethodRunTime);
jmitc91516 1:a5258871b33d 943 }
jmitc91516 1:a5258871b33d 944
jmitc91516 1:a5258871b33d 945 if(runHasCompleted) {
jmitc91516 1:a5258871b33d 946 // Make sure we show this
jmitc91516 1:a5258871b33d 947 currentColumnMethodRunTime = totalColumnMethodMethodTime;
jmitc91516 1:a5258871b33d 948 }
jmitc91516 1:a5258871b33d 949
jmitc91516 1:a5258871b33d 950 #ifdef USING_DATASET_4
jmitc91516 1:a5258871b33d 951 if((currentColumnMethodRunTime < (previousColumnMethodRunTime + barInterval)) && (!runHasCompleted)) { // Must show the run has completed
jmitc91516 1:a5258871b33d 952 // No need to update data sets (there will be no changes)
jmitc91516 1:a5258871b33d 953 return false;
jmitc91516 1:a5258871b33d 954 }
jmitc91516 1:a5258871b33d 955 #endif // USING_DATASET_4 - else update the graph continuously
jmitc91516 1:a5258871b33d 956 // 'else'...
jmitc91516 1:a5258871b33d 957 previousColumnMethodRunTime = currentColumnMethodRunTime;
jmitc91516 1:a5258871b33d 958
jmitc91516 1:a5258871b33d 959 // Stop adding points when the current method has 'expired'
jmitc91516 1:a5258871b33d 960 if(currentColumnMethodRunTime < totalColumnMethodMethodTime) {
jmitc91516 1:a5258871b33d 961 // Dataset 0 is a line representing the temperature profile of the run from 'now' to the finish
jmitc91516 1:a5258871b33d 962 runningColumnPageGraphCompleteProfileDataSet->MakePartialCopy(currentColumnMethodRunTime, totalColumnMethodMethodTime, runningColumnPageGraphDataSet0);
jmitc91516 1:a5258871b33d 963
jmitc91516 1:a5258871b33d 964 // Dataset 1 is a bar chart representing the temperature profile of the run from 'now' to the finish -
jmitc91516 1:a5258871b33d 965 // make sure that we have a bar at the exact end of the profile
jmitc91516 1:a5258871b33d 966 runningColumnPageGraphCompleteProfileDataSet->MakeInterpolatedPartialCopyWithFinalPoint(currentColumnMethodRunTime + barInterval, totalColumnMethodMethodTime, barInterval, runningColumnPageGraphDataSet1);
jmitc91516 1:a5258871b33d 967 // 'currentTime + barInterval' to prevent overlap with dataset 3
jmitc91516 1:a5258871b33d 968
jmitc91516 1:a5258871b33d 969 // Data set 2 is a line representing the temperature profile from the start to 'now'
jmitc91516 1:a5258871b33d 970 runningColumnPageGraphCompleteProfileDataSet->MakePartialCopy(0, currentColumnMethodRunTime, runningColumnPageGraphDataSet2);
jmitc91516 1:a5258871b33d 971
jmitc91516 1:a5258871b33d 972 // Data set 3 is a bar chart representing the temperature profile of the run from the start to 'now'
jmitc91516 1:a5258871b33d 973 runningColumnPageGraphCompleteProfileDataSet->MakeInterpolatedPartialCopy(0, currentColumnMethodRunTime, barInterval, runningColumnPageGraphDataSet3);
jmitc91516 1:a5258871b33d 974
jmitc91516 1:a5258871b33d 975 #ifdef USING_DATASET_4
jmitc91516 1:a5258871b33d 976 // Data set 4 is a single dot at the current time and temperature
jmitc91516 1:a5258871b33d 977 runningColumnPageGraphDataSet4->ClearData();
jmitc91516 1:a5258871b33d 978 GuiConst_INT32S currentTemp = runningColumnPageGraphCompleteProfileDataSet->GetYCoordAtXCoord(currentColumnMethodRunTime);
jmitc91516 1:a5258871b33d 979 runningColumnPageGraphDataSet4->AddDataPoint(currentColumnMethodRunTime, currentTemp);
jmitc91516 1:a5258871b33d 980 #endif // USING_DATASET_4
jmitc91516 1:a5258871b33d 981 } else {
jmitc91516 1:a5258871b33d 982
jmitc91516 1:a5258871b33d 983 columnMethodFinished = true;
jmitc91516 1:a5258871b33d 984
jmitc91516 1:a5258871b33d 985 // Do not leave data 'lying around' in the 'now' to the finish datasets
jmitc91516 1:a5258871b33d 986 // after we have completed the method
jmitc91516 1:a5258871b33d 987 runningColumnPageGraphDataSet0->ClearData();
jmitc91516 1:a5258871b33d 988 runningColumnPageGraphDataSet1->ClearData();
jmitc91516 1:a5258871b33d 989
jmitc91516 1:a5258871b33d 990 // Data set 2 is a line representing the temperature profile from the start to 'now'
jmitc91516 1:a5258871b33d 991 runningColumnPageGraphCompleteProfileDataSet->MakePartialCopy(0, totalColumnMethodMethodTime, runningColumnPageGraphDataSet2);
jmitc91516 1:a5258871b33d 992
jmitc91516 1:a5258871b33d 993 // Data set 3 is a bar chart representing the temperature profile of the run from the start to 'now' -
jmitc91516 1:a5258871b33d 994 // make sure that we have a bar at the exact end of the profile
jmitc91516 1:a5258871b33d 995 runningColumnPageGraphCompleteProfileDataSet->MakeInterpolatedPartialCopyWithFinalPoint(0, totalColumnMethodMethodTime, barInterval, runningColumnPageGraphDataSet3);
jmitc91516 1:a5258871b33d 996
jmitc91516 1:a5258871b33d 997 #ifdef USING_DATASET_4
jmitc91516 1:a5258871b33d 998 // Data set 4 is a single dot at the current time and temperature
jmitc91516 1:a5258871b33d 999 runningColumnPageGraphDataSet4->ClearData();
jmitc91516 1:a5258871b33d 1000 GuiConst_INT32S currentTemp = runningColumnPageGraphCompleteProfileDataSet->GetYCoordAtXCoord(totalColumnMethodMethodTime);
jmitc91516 1:a5258871b33d 1001 runningColumnPageGraphDataSet4->AddDataPoint(totalColumnMethodMethodTime, currentTemp);
jmitc91516 1:a5258871b33d 1002 #endif // USING_DATASET_4
jmitc91516 1:a5258871b33d 1003 }
jmitc91516 1:a5258871b33d 1004
jmitc91516 1:a5258871b33d 1005 return true;
jmitc91516 1:a5258871b33d 1006 }
jmitc91516 1:a5258871b33d 1007
jmitc91516 1:a5258871b33d 1008 /*
jmitc91516 1:a5258871b33d 1009 Set up the complete gas flow profile dataset for the graph on the 'running gas' page
jmitc91516 1:a5258871b33d 1010 to match the method data currently set up in the GC.
jmitc91516 1:a5258871b33d 1011
jmitc91516 1:a5258871b33d 1012 We assume that we will not have to do this again while the current method is running.
jmitc91516 1:a5258871b33d 1013 */
jmitc91516 1:a5258871b33d 1014 void GetGCStatusLoop::SetupRunningGasPageGraphCompleteProfileDataSetFromGC(void)
jmitc91516 1:a5258871b33d 1015 {
jmitc91516 1:a5258871b33d 1016 // Before setting up the gas pressure profile, we need a column method to base it on
jmitc91516 1:a5258871b33d 1017 float totalColumnMethodTime = runningColumnPageGraphCompleteProfileDataSet->GetTotalMethodTime();
jmitc91516 1:a5258871b33d 1018 if(totalColumnMethodTime <= 0.0f) {
jmitc91516 1:a5258871b33d 1019 // Column method not set up
jmitc91516 1:a5258871b33d 1020 return;
jmitc91516 1:a5258871b33d 1021 }
jmitc91516 1:a5258871b33d 1022
jmitc91516 1:a5258871b33d 1023 runningGasPageGraphCompleteProfileDataSet->SetupGasPressureProfileWithTimingsFromColumnMethod(usbDevice, usbHostGC, runningColumnPageGraphCompleteProfileDataSet);
jmitc91516 1:a5258871b33d 1024
jmitc91516 1:a5258871b33d 1025 runningGasPageGraph->SetXAxisRange(0, (GuiConst_INT32S) runningGasPageGraphCompleteProfileDataSet->GetTotalMethodTime());
jmitc91516 1:a5258871b33d 1026
jmitc91516 1:a5258871b33d 1027 if(runningGasPageGraphCompleteProfileDataSet->GetTotalMethodTime() < methodTimeUnitsThreshold) {
jmitc91516 1:a5258871b33d 1028 strcpy(GuiVar_runningGasPageXAxisLabel, "Time (seconds)");
jmitc91516 1:a5258871b33d 1029 } else {
jmitc91516 1:a5258871b33d 1030 strcpy(GuiVar_runningGasPageXAxisLabel, "Time (minutes)");
jmitc91516 1:a5258871b33d 1031 }
jmitc91516 1:a5258871b33d 1032 }
jmitc91516 1:a5258871b33d 1033
jmitc91516 1:a5258871b33d 1034 /*
jmitc91516 1:a5258871b33d 1035 Update the partial datasets for the gas flow profile graph on the 'running gas' page
jmitc91516 1:a5258871b33d 1036 (i.e. the datasets that split up the profile into the section from the start to 'now'
jmitc91516 1:a5258871b33d 1037 and the section from 'now' to the end) to match (a) the complete profile obtained from the GC,
jmitc91516 1:a5258871b33d 1038 and (b) the current time.
jmitc91516 1:a5258871b33d 1039
jmitc91516 1:a5258871b33d 1040 Caller *must* have previously called the 'SetupRunningGasPageGraphCompleteProfileDataSetFromGC' function.
jmitc91516 1:a5258871b33d 1041
jmitc91516 1:a5258871b33d 1042 Returns true if the datasets have changed, false if not
jmitc91516 1:a5258871b33d 1043 */
jmitc91516 1:a5258871b33d 1044 bool GetGCStatusLoop::SetupRunningGasPageGraphPartialDataSetsToMatchCurrentRunTime(bool runHasCompleted)
jmitc91516 1:a5258871b33d 1045 {
jmitc91516 1:a5258871b33d 1046 if(gasMethodFinished) {
jmitc91516 1:a5258871b33d 1047 return false; // Our work here is done...
jmitc91516 1:a5258871b33d 1048 }
jmitc91516 1:a5258871b33d 1049
jmitc91516 1:a5258871b33d 1050 float currentGasMethodRunTime;
jmitc91516 1:a5258871b33d 1051 GetRunTime(&currentGasMethodRunTime);
jmitc91516 1:a5258871b33d 1052
jmitc91516 1:a5258871b33d 1053 float totalGasMethodTime = runningGasPageGraphCompleteProfileDataSet->GetTotalMethodTime();
jmitc91516 1:a5258871b33d 1054
jmitc91516 1:a5258871b33d 1055 float barInterval = graphBarIntervalMinutes;
jmitc91516 1:a5258871b33d 1056 if(totalGasMethodTime < methodTimeUnitsThreshold) {
jmitc91516 1:a5258871b33d 1057 barInterval = graphBarIntervalSeconds;
jmitc91516 1:a5258871b33d 1058 } else {
jmitc91516 1:a5258871b33d 1059 // We are using minutes - work in whole minutes, and show the number we have completed
jmitc91516 1:a5258871b33d 1060 // (i.e. do not round the number up)
jmitc91516 1:a5258871b33d 1061 currentGasMethodRunTime = (float)floor((double)currentGasMethodRunTime);
jmitc91516 1:a5258871b33d 1062 }
jmitc91516 1:a5258871b33d 1063
jmitc91516 1:a5258871b33d 1064 if(runHasCompleted) {
jmitc91516 1:a5258871b33d 1065 // Make sure we show this
jmitc91516 1:a5258871b33d 1066 currentGasMethodRunTime = totalGasMethodTime;
jmitc91516 1:a5258871b33d 1067 }
jmitc91516 1:a5258871b33d 1068
jmitc91516 1:a5258871b33d 1069 #ifdef USING_DATASET_4
jmitc91516 1:a5258871b33d 1070 if((currentGasMethodRunTime < (previousGasMethodRunTime + barInterval)) && (!runHasCompleted)) { // Must show the run has completed
jmitc91516 1:a5258871b33d 1071 // No need to update data sets (there will be no changes)
jmitc91516 1:a5258871b33d 1072 return false;
jmitc91516 1:a5258871b33d 1073 }
jmitc91516 1:a5258871b33d 1074 #endif // USING_DATASET_4 - else update the graph continuously
jmitc91516 1:a5258871b33d 1075 // 'else'...
jmitc91516 1:a5258871b33d 1076 previousGasMethodRunTime = currentGasMethodRunTime;
jmitc91516 1:a5258871b33d 1077
jmitc91516 1:a5258871b33d 1078 // Stop adding points when the current method has 'expired'
jmitc91516 1:a5258871b33d 1079 if(currentGasMethodRunTime < totalGasMethodTime) {
jmitc91516 1:a5258871b33d 1080 // Dataset 0 is a line representing the flow profile of the run from 'now' to the finish
jmitc91516 1:a5258871b33d 1081 runningGasPageGraphCompleteProfileDataSet->MakePartialCopy(currentGasMethodRunTime, totalGasMethodTime, runningGasPageGraphDataSet0);
jmitc91516 1:a5258871b33d 1082
jmitc91516 1:a5258871b33d 1083 // Dataset 1 is a bar chart representing the flow profile of the run from 'now' to the finish -
jmitc91516 1:a5258871b33d 1084 // make sure that we have a bar at the exact end of the profile
jmitc91516 1:a5258871b33d 1085 runningGasPageGraphCompleteProfileDataSet->MakeInterpolatedPartialCopyWithFinalPoint(currentGasMethodRunTime + barInterval, totalGasMethodTime, barInterval, runningGasPageGraphDataSet1);
jmitc91516 1:a5258871b33d 1086 // 'currentTime + barInterval' to prevent overlap with dataset 3
jmitc91516 1:a5258871b33d 1087
jmitc91516 1:a5258871b33d 1088 // Data set 2 is a line representing the flow profile from the start to 'now'
jmitc91516 1:a5258871b33d 1089 runningGasPageGraphCompleteProfileDataSet->MakePartialCopy(0, currentGasMethodRunTime, runningGasPageGraphDataSet2);
jmitc91516 1:a5258871b33d 1090
jmitc91516 1:a5258871b33d 1091 // Data set 3 is a bar chart representing the flow profile from the start to 'now'
jmitc91516 1:a5258871b33d 1092 runningGasPageGraphCompleteProfileDataSet->MakeInterpolatedPartialCopy(0, currentGasMethodRunTime, barInterval, runningGasPageGraphDataSet3);
jmitc91516 1:a5258871b33d 1093
jmitc91516 1:a5258871b33d 1094 #ifdef USING_DATASET_4
jmitc91516 1:a5258871b33d 1095 // Data set 4 is a single dot at the current time and flow rate
jmitc91516 1:a5258871b33d 1096 runningGasPageGraphDataSet4->ClearData();
jmitc91516 1:a5258871b33d 1097 GuiConst_INT32S currentFlowRate = runningGasPageGraphCompleteProfileDataSet->GetYCoordAtXCoord(currentGasMethodRunTime);
jmitc91516 1:a5258871b33d 1098 runningGasPageGraphDataSet4->AddDataPoint(currentGasMethodRunTime, currentFlowRate);
jmitc91516 1:a5258871b33d 1099 #endif // USING_DATASET_4
jmitc91516 1:a5258871b33d 1100 } else {
jmitc91516 1:a5258871b33d 1101
jmitc91516 1:a5258871b33d 1102 gasMethodFinished = true;
jmitc91516 1:a5258871b33d 1103
jmitc91516 1:a5258871b33d 1104 // Do not leave data 'lying around' in the 'now' to the finish datasets
jmitc91516 1:a5258871b33d 1105 // after we have completed the method
jmitc91516 1:a5258871b33d 1106 runningGasPageGraphDataSet0->ClearData();
jmitc91516 1:a5258871b33d 1107 runningGasPageGraphDataSet1->ClearData();
jmitc91516 1:a5258871b33d 1108
jmitc91516 1:a5258871b33d 1109 // Data set 2 is a line representing the flow profile from the start to 'now'
jmitc91516 1:a5258871b33d 1110 runningGasPageGraphCompleteProfileDataSet->MakePartialCopy(0, currentGasMethodRunTime, runningGasPageGraphDataSet2);
jmitc91516 1:a5258871b33d 1111
jmitc91516 1:a5258871b33d 1112 // Data set 3 is a bar chart representing the flow profile from the start to 'now'-
jmitc91516 1:a5258871b33d 1113 // make sure that we have a bar at the exact end of the profile
jmitc91516 1:a5258871b33d 1114 runningGasPageGraphCompleteProfileDataSet->MakeInterpolatedPartialCopyWithFinalPoint(0, currentGasMethodRunTime, barInterval, runningGasPageGraphDataSet3);
jmitc91516 1:a5258871b33d 1115
jmitc91516 1:a5258871b33d 1116 #ifdef USING_DATASET_4
jmitc91516 1:a5258871b33d 1117 // Data set 4 is a single dot at the current time and flow rate
jmitc91516 1:a5258871b33d 1118 runningGasPageGraphDataSet4->ClearData();
jmitc91516 1:a5258871b33d 1119 GuiConst_INT32S currentFlowRate = runningGasPageGraphCompleteProfileDataSet->GetYCoordAtXCoord(currentGasMethodRunTime);
jmitc91516 1:a5258871b33d 1120 runningGasPageGraphDataSet4->AddDataPoint(currentGasMethodRunTime, currentFlowRate);
jmitc91516 1:a5258871b33d 1121 #endif // USING_DATASET_4
jmitc91516 1:a5258871b33d 1122 }
jmitc91516 1:a5258871b33d 1123
jmitc91516 1:a5258871b33d 1124 return true;
jmitc91516 1:a5258871b33d 1125 }
jmitc91516 1:a5258871b33d 1126
jmitc91516 1:a5258871b33d 1127 /*
jmitc91516 1:a5258871b33d 1128 Set up the complete injector temperature profile dataset for the graph on the second injector status
jmitc91516 1:a5258871b33d 1129 (while running the method) page, to match the method data currently set up in the GC.
jmitc91516 1:a5258871b33d 1130
jmitc91516 1:a5258871b33d 1131 We assume that we will not have to do this again while the current method is running.
jmitc91516 1:a5258871b33d 1132 */
jmitc91516 1:a5258871b33d 1133 void GetGCStatusLoop::SetupRunningInjectorPageGraphCompleteProfileDataSetFromGC(void)
jmitc91516 1:a5258871b33d 1134 {
jmitc91516 1:a5258871b33d 1135 #ifndef PTV_RAMPS_AVAILABLE
jmitc91516 1:a5258871b33d 1136 // If we do not have PTV ramps, then before we can set up the injector profile, we need a column method to base it on
jmitc91516 1:a5258871b33d 1137 if(runningColumnPageGraphCompleteProfileDataSet->GetTotalMethodTime() <= 0.0f) {
jmitc91516 1:a5258871b33d 1138 // Column method not set up
jmitc91516 1:a5258871b33d 1139 return;
jmitc91516 1:a5258871b33d 1140 }
jmitc91516 1:a5258871b33d 1141 #endif // PTV_RAMPS_AVAILABLE
jmitc91516 1:a5258871b33d 1142
jmitc91516 1:a5258871b33d 1143 #ifdef PTV_RAMPS_AVAILABLE
jmitc91516 1:a5258871b33d 1144 runningInjectorPageGraphCompleteProfileDataSet->SetupFromPTVTemperatureRampValues(usbDevice, usbHostGC);
jmitc91516 1:a5258871b33d 1145 #else
jmitc91516 1:a5258871b33d 1146 runningInjectorPageGraphCompleteProfileDataSet->SetupInjectorTemperatureProfileToMatchColumnMethod(usbDevice, usbHostGC, runningColumnPageGraphCompleteProfileDataSet);
jmitc91516 1:a5258871b33d 1147 #endif // PTV_RAMPS_AVAILABLE
jmitc91516 1:a5258871b33d 1148
jmitc91516 1:a5258871b33d 1149 runningInjectorPageGraph->SetXAxisRange(0, (GuiConst_INT32S) runningInjectorPageGraphCompleteProfileDataSet->GetTotalMethodTime());
jmitc91516 1:a5258871b33d 1150
jmitc91516 1:a5258871b33d 1151 if(runningInjectorPageGraphCompleteProfileDataSet->GetTotalMethodTime() < methodTimeUnitsThreshold) {
jmitc91516 1:a5258871b33d 1152 strcpy(GuiVar_runningInjectorPageXAxisLabel, "Time (seconds)");
jmitc91516 1:a5258871b33d 1153 } else {
jmitc91516 1:a5258871b33d 1154 strcpy(GuiVar_runningInjectorPageXAxisLabel, "Time (minutes)");
jmitc91516 1:a5258871b33d 1155 }
jmitc91516 1:a5258871b33d 1156 }
jmitc91516 1:a5258871b33d 1157
jmitc91516 1:a5258871b33d 1158 /*
jmitc91516 1:a5258871b33d 1159 Update the partial datasets for the injector temperature profile graph on the 'running injector' page
jmitc91516 1:a5258871b33d 1160 (i.e. the datasets that split up the profile into the section from the start to 'now'
jmitc91516 1:a5258871b33d 1161 and the section from 'now' to the end) to match (a) the complete profile obtained from the GC,
jmitc91516 1:a5258871b33d 1162 and (b) the current time.
jmitc91516 1:a5258871b33d 1163
jmitc91516 1:a5258871b33d 1164 Caller *must* have previously called the 'SetupRunningInjectorPageGraphCompleteProfileDataSetFromGC' function.
jmitc91516 1:a5258871b33d 1165
jmitc91516 1:a5258871b33d 1166 Returns true if the datasets have changed, false if not
jmitc91516 1:a5258871b33d 1167 */
jmitc91516 1:a5258871b33d 1168 bool GetGCStatusLoop::SetupRunningInjectorPageGraphPartialDataSetsToMatchCurrentRunTime(bool runHasCompleted)
jmitc91516 1:a5258871b33d 1169 {
jmitc91516 1:a5258871b33d 1170 if(injectorMethodFinished) {
jmitc91516 1:a5258871b33d 1171 return false; // Our work here is done...
jmitc91516 1:a5258871b33d 1172 }
jmitc91516 1:a5258871b33d 1173
jmitc91516 1:a5258871b33d 1174 float currentInjectorMethodRunTime;
jmitc91516 1:a5258871b33d 1175 GetRunTime(&currentInjectorMethodRunTime);
jmitc91516 1:a5258871b33d 1176
jmitc91516 1:a5258871b33d 1177 float totalInjectorMethodTime = runningInjectorPageGraphCompleteProfileDataSet->GetTotalMethodTime();
jmitc91516 1:a5258871b33d 1178
jmitc91516 1:a5258871b33d 1179 float barInterval = graphBarIntervalMinutes;
jmitc91516 1:a5258871b33d 1180 if(totalInjectorMethodTime < methodTimeUnitsThreshold) {
jmitc91516 1:a5258871b33d 1181 barInterval = graphBarIntervalSeconds;
jmitc91516 1:a5258871b33d 1182 } else {
jmitc91516 1:a5258871b33d 1183 // We are using minutes - work in whole minutes, and show the number we have completed
jmitc91516 1:a5258871b33d 1184 // (i.e. do not round the number up) - but leave the value unchanged if the injector method has completed -
jmitc91516 1:a5258871b33d 1185 // otherwise we will omit the final point/bar if the total time is not a whole number of minutes
jmitc91516 1:a5258871b33d 1186 if(currentInjectorMethodRunTime < totalInjectorMethodTime) {
jmitc91516 1:a5258871b33d 1187 currentInjectorMethodRunTime = (float)floor((double)currentInjectorMethodRunTime);
jmitc91516 1:a5258871b33d 1188 }
jmitc91516 1:a5258871b33d 1189 }
jmitc91516 1:a5258871b33d 1190
jmitc91516 1:a5258871b33d 1191 if(runHasCompleted) {
jmitc91516 1:a5258871b33d 1192 // Make sure we show this - but be careful of the fact that the injector method time
jmitc91516 1:a5258871b33d 1193 // is not necessarily equal to the column method time - and currently the run completes
jmitc91516 1:a5258871b33d 1194 // at the end of the column method time
jmitc91516 1:a5258871b33d 1195 if(totalInjectorMethodTime == runningColumnPageGraphCompleteProfileDataSet->GetTotalMethodTime()) {
jmitc91516 1:a5258871b33d 1196 currentInjectorMethodRunTime = totalInjectorMethodTime;
jmitc91516 1:a5258871b33d 1197 }
jmitc91516 1:a5258871b33d 1198 // If the time (i.e. duration) of the injector method is less than the column method,
jmitc91516 1:a5258871b33d 1199 // we should already have shown it as completed before the column method (and therefore
jmitc91516 1:a5258871b33d 1200 // the run as a whole) completes. If it is greater, then it will not have completed
jmitc91516 1:a5258871b33d 1201 // by the time the column method completes - and therefore we should not show it
jmitc91516 1:a5258871b33d 1202 // as complete at that point (and without the 'if' around the assignment above,
jmitc91516 1:a5258871b33d 1203 // that is what we will do)
jmitc91516 1:a5258871b33d 1204 }
jmitc91516 1:a5258871b33d 1205
jmitc91516 1:a5258871b33d 1206 #ifdef USING_DATASET_4
jmitc91516 1:a5258871b33d 1207 if((currentInjectorMethodRunTime < (previousInjectorMethodRunTime + barInterval)) && (!runHasCompleted)) { // Must show the run has completed
jmitc91516 1:a5258871b33d 1208 // No need to update data sets (there will be no changes)
jmitc91516 1:a5258871b33d 1209 return false;
jmitc91516 1:a5258871b33d 1210 }
jmitc91516 1:a5258871b33d 1211 #endif // USING_DATASET_4 - else update the graph continuously
jmitc91516 1:a5258871b33d 1212 // 'else'...
jmitc91516 1:a5258871b33d 1213 previousInjectorMethodRunTime = currentInjectorMethodRunTime;
jmitc91516 1:a5258871b33d 1214
jmitc91516 1:a5258871b33d 1215 // Stop adding points when the current method has 'expired'
jmitc91516 1:a5258871b33d 1216 if(currentInjectorMethodRunTime < totalInjectorMethodTime) {
jmitc91516 1:a5258871b33d 1217 // Dataset 0 is a line representing the flow profile of the run from 'now' to the finish
jmitc91516 1:a5258871b33d 1218 runningInjectorPageGraphCompleteProfileDataSet->MakePartialCopy(currentInjectorMethodRunTime, totalInjectorMethodTime, runningInjectorPageGraphDataSet0);
jmitc91516 1:a5258871b33d 1219
jmitc91516 1:a5258871b33d 1220 // Dataset 1 is a bar chart representing the flow profile of the run from 'now' to the finish -
jmitc91516 1:a5258871b33d 1221 // make sure that we have a bar at the exact end of the profile
jmitc91516 1:a5258871b33d 1222 runningInjectorPageGraphCompleteProfileDataSet->MakeInterpolatedPartialCopyWithFinalPoint(currentInjectorMethodRunTime + barInterval, totalInjectorMethodTime, barInterval, runningInjectorPageGraphDataSet1);
jmitc91516 1:a5258871b33d 1223 // 'currentTime + barInterval' to prevent overlap with dataset 3
jmitc91516 1:a5258871b33d 1224
jmitc91516 1:a5258871b33d 1225 // Data set 2 is a line representing the flow profile from the start to 'now'
jmitc91516 1:a5258871b33d 1226 runningInjectorPageGraphCompleteProfileDataSet->MakePartialCopy(0, currentInjectorMethodRunTime, runningInjectorPageGraphDataSet2);
jmitc91516 1:a5258871b33d 1227
jmitc91516 1:a5258871b33d 1228 // Data set 3 is a bar chart representing the flow profile from the start to 'now'
jmitc91516 1:a5258871b33d 1229 runningInjectorPageGraphCompleteProfileDataSet->MakeInterpolatedPartialCopy(0, currentInjectorMethodRunTime, barInterval, runningInjectorPageGraphDataSet3);
jmitc91516 1:a5258871b33d 1230
jmitc91516 1:a5258871b33d 1231 #ifdef USING_DATASET_4
jmitc91516 1:a5258871b33d 1232 // Data set 4 is a single dot at the current time and flow rate
jmitc91516 1:a5258871b33d 1233 runningInjectorPageGraphDataSet4->ClearData();
jmitc91516 1:a5258871b33d 1234 GuiConst_INT32S currentFlowRate = runningInjectorPageGraphCompleteProfileDataSet->GetYCoordAtXCoord(currentGasMethodRunTime);
jmitc91516 1:a5258871b33d 1235 runningGasPageGraphDataSet4->AddDataPoint(currentGasMethodRunTime, currentFlowRate);
jmitc91516 1:a5258871b33d 1236 #endif // USING_DATASET_4
jmitc91516 1:a5258871b33d 1237 } else {
jmitc91516 1:a5258871b33d 1238
jmitc91516 1:a5258871b33d 1239 injectorMethodFinished = true;
jmitc91516 1:a5258871b33d 1240
jmitc91516 1:a5258871b33d 1241 // Remember that it is the *column* method that controls how long the GC runs, *not* the injector method -
jmitc91516 1:a5258871b33d 1242 // and they do not have to have the same length (i.e. duration). Therefore, the GC may still be running
jmitc91516 1:a5258871b33d 1243 // after the injector method has finished - and we do not want to display spurious bars off the right hand end of our graph
jmitc91516 1:a5258871b33d 1244 if(currentInjectorMethodRunTime > totalInjectorMethodTime) {
jmitc91516 1:a5258871b33d 1245 currentInjectorMethodRunTime = totalInjectorMethodTime;
jmitc91516 1:a5258871b33d 1246 }
jmitc91516 1:a5258871b33d 1247
jmitc91516 1:a5258871b33d 1248 // Do not leave data 'lying around' in the 'now' to the finish datasets
jmitc91516 1:a5258871b33d 1249 // after we have completed the method
jmitc91516 1:a5258871b33d 1250 runningInjectorPageGraphDataSet0->ClearData();
jmitc91516 1:a5258871b33d 1251 runningInjectorPageGraphDataSet1->ClearData();
jmitc91516 1:a5258871b33d 1252
jmitc91516 1:a5258871b33d 1253 // Data set 2 is a line representing the flow profile from the start to 'now'
jmitc91516 1:a5258871b33d 1254 runningInjectorPageGraphCompleteProfileDataSet->MakePartialCopy(0, currentInjectorMethodRunTime, runningInjectorPageGraphDataSet2);
jmitc91516 1:a5258871b33d 1255
jmitc91516 1:a5258871b33d 1256 // Data set 3 is a bar chart representing the flow profile from the start to 'now'-
jmitc91516 1:a5258871b33d 1257 // make sure that we have a bar at the exact end of the profile
jmitc91516 1:a5258871b33d 1258 runningInjectorPageGraphCompleteProfileDataSet->MakeInterpolatedPartialCopyWithFinalPoint(0, currentInjectorMethodRunTime, barInterval, runningInjectorPageGraphDataSet3);
jmitc91516 1:a5258871b33d 1259
jmitc91516 1:a5258871b33d 1260 #ifdef USING_DATASET_4
jmitc91516 1:a5258871b33d 1261 // Data set 4 is a single dot at the current time and flow rate
jmitc91516 1:a5258871b33d 1262 runningInjectorPageGraphDataSet4->ClearData();
jmitc91516 1:a5258871b33d 1263 GuiConst_INT32S currentFlowRate = runningInjectorPageGraphCompleteProfileDataSet->GetYCoordAtXCoord(currentInjectorMethodRunTime);
jmitc91516 1:a5258871b33d 1264 runningInjectorPageGraphDataSet4->AddDataPoint(currentInjectorMethodRunTime, currentFlowRate);
jmitc91516 1:a5258871b33d 1265 #endif // USING_DATASET_4
jmitc91516 1:a5258871b33d 1266 }
jmitc91516 1:a5258871b33d 1267
jmitc91516 1:a5258871b33d 1268 return true;
jmitc91516 1:a5258871b33d 1269 }
jmitc91516 1:a5258871b33d 1270
jmitc91516 1:a5258871b33d 1271 /*
jmitc91516 1:a5258871b33d 1272 Update all the 'complete running profile' datasets from the GC.
jmitc91516 1:a5258871b33d 1273
jmitc91516 1:a5258871b33d 1274 We will want to do this, for example, when we start the GC running.
jmitc91516 1:a5258871b33d 1275 */
jmitc91516 1:a5258871b33d 1276 void GetGCStatusLoop::UpdateGCMethodRunningProfiles(void)
jmitc91516 1:a5258871b33d 1277 {
jmitc91516 1:a5258871b33d 1278 SetupRunningColumnPageGraphCompleteProfileDataSetFromGC();
jmitc91516 1:a5258871b33d 1279 SetupRunningGasPageGraphCompleteProfileDataSetFromGC();
jmitc91516 1:a5258871b33d 1280 SetupRunningInjectorPageGraphCompleteProfileDataSetFromGC();
jmitc91516 1:a5258871b33d 1281 }
jmitc91516 1:a5258871b33d 1282
jmitc91516 1:a5258871b33d 1283
jmitc91516 1:a5258871b33d 1284 /*
jmitc91516 1:a5258871b33d 1285 Caller is telling us "the GC has started running".
jmitc91516 1:a5258871b33d 1286 */
jmitc91516 1:a5258871b33d 1287 void GetGCStatusLoop::SetGCIsRunning(void)
jmitc91516 1:a5258871b33d 1288 {
jmitc91516 1:a5258871b33d 1289 previousColumnMethodRunTime = -99.0f;
jmitc91516 1:a5258871b33d 1290 columnMethodFinished = false;
jmitc91516 1:a5258871b33d 1291
jmitc91516 1:a5258871b33d 1292 previousGasMethodRunTime = -99.0f;
jmitc91516 1:a5258871b33d 1293 gasMethodFinished = false;
jmitc91516 1:a5258871b33d 1294
jmitc91516 1:a5258871b33d 1295 previousInjectorMethodRunTime = -99.0f;
jmitc91516 1:a5258871b33d 1296 injectorMethodFinished = false;
jmitc91516 1:a5258871b33d 1297
jmitc91516 1:a5258871b33d 1298 realGCIsRunning = true;
jmitc91516 1:a5258871b33d 1299
jmitc91516 1:a5258871b33d 1300 runWasAborted = false;
jmitc91516 1:a5258871b33d 1301 }
jmitc91516 1:a5258871b33d 1302
jmitc91516 1:a5258871b33d 1303 /*
jmitc91516 1:a5258871b33d 1304 Caller is telling us "the GC has stopped running".
jmitc91516 1:a5258871b33d 1305 */
jmitc91516 1:a5258871b33d 1306 void GetGCStatusLoop::ClearGCIsRunning(void)
jmitc91516 1:a5258871b33d 1307 {
jmitc91516 1:a5258871b33d 1308 realGCIsRunning = false;
jmitc91516 1:a5258871b33d 1309 }
jmitc91516 1:a5258871b33d 1310
jmitc91516 1:a5258871b33d 1311
jmitc91516 1:a5258871b33d 1312 /*
jmitc91516 1:a5258871b33d 1313 Tell the caller whether or not we 'think' the GC is running
jmitc91516 1:a5258871b33d 1314 */
jmitc91516 1:a5258871b33d 1315 bool GetGCStatusLoop::GetGCIsRunningFlag(void)
jmitc91516 1:a5258871b33d 1316 {
jmitc91516 1:a5258871b33d 1317 return realGCIsRunning;
jmitc91516 1:a5258871b33d 1318 }
jmitc91516 1:a5258871b33d 1319
jmitc91516 1:a5258871b33d 1320
jmitc91516 1:a5258871b33d 1321 /*
jmitc91516 1:a5258871b33d 1322 Returns the current page selection to the caller.
jmitc91516 1:a5258871b33d 1323 */
jmitc91516 0:47c880c1463d 1324 GuiConst_INT16U GetGCStatusLoop::GetCurrentPage(void)
jmitc91516 0:47c880c1463d 1325 {
jmitc91516 0:47c880c1463d 1326 return currentPage;
jmitc91516 0:47c880c1463d 1327 }
jmitc91516 0:47c880c1463d 1328
jmitc91516 1:a5258871b33d 1329 /*
jmitc91516 1:a5258871b33d 1330 Allows the caller to set the current page. As well as setting the page number,
jmitc91516 1:a5258871b33d 1331 we may need to take other action - e.g. displaying the data for that page.
jmitc91516 1:a5258871b33d 1332
jmitc91516 1:a5258871b33d 1333 Args: new page (easyGUI "structure") number
jmitc91516 1:a5258871b33d 1334
jmitc91516 1:a5258871b33d 1335 No return code.
jmitc91516 1:a5258871b33d 1336 */
jmitc91516 0:47c880c1463d 1337 void GetGCStatusLoop::SetCurrentPage(GuiConst_INT16U newCurrentPage)
jmitc91516 0:47c880c1463d 1338 {
jmitc91516 0:47c880c1463d 1339 if(currentPage != newCurrentPage) {
jmitc91516 0:47c880c1463d 1340 currentPage = newCurrentPage;
jmitc91516 0:47c880c1463d 1341
jmitc91516 0:47c880c1463d 1342 pageJustChanged = true; // Try this - can it prevent crashes on updating?
jmitc91516 0:47c880c1463d 1343
jmitc91516 1:a5258871b33d 1344 needToUpdateProfileGraphs = true;
jmitc91516 1:a5258871b33d 1345
jmitc91516 1:a5258871b33d 1346 //#define IS_THIS_NECESSARY_NOW
jmitc91516 1:a5258871b33d 1347 #ifdef IS_THIS_NECESSARY_NOW
jmitc91516 0:47c880c1463d 1348 // Stop the status rectangles flashing when we display these pages/structures
jmitc91516 0:47c880c1463d 1349 if((currentPage != GuiStruct_HomePage_1) &&
jmitc91516 0:47c880c1463d 1350 (currentPage != GuiStruct_ColumnPage1_2) &&
jmitc91516 1:a5258871b33d 1351 (currentPage != GuiStruct_ColumnPage2_9) &&
jmitc91516 5:aceac1035d71 1352 (currentPage != GuiStruct_ColumnMethodPage_Def) &&
jmitc91516 1:a5258871b33d 1353 (currentPage != GuiStruct_ColumnTempProfilePage_60) &&
jmitc91516 0:47c880c1463d 1354 (currentPage != GuiStruct_InjectorPage1_3) &&
jmitc91516 1:a5258871b33d 1355 (currentPage != GuiStruct_InjectorTempProfilePage_25) &&
jmitc91516 1:a5258871b33d 1356 (currentPage != GuiStruct_InjectorGasStatusPage_30) &&
jmitc91516 1:a5258871b33d 1357 (currentPage != GuiStruct_InjectorConsumablesPage_20) &&
jmitc91516 1:a5258871b33d 1358 (currentPage != GuiStruct_DetectorFIDPage_4) &&
jmitc91516 1:a5258871b33d 1359 (currentPage != GuiStruct_DetectorECDPage_12) &&
jmitc91516 1:a5258871b33d 1360 (currentPage != GuiStruct_DetectorFPDPage_14) &&
jmitc91516 1:a5258871b33d 1361 (currentPage != GuiStruct_DetectorTCDPage_11) &&
jmitc91516 1:a5258871b33d 1362 (currentPage != GuiStruct_DetectorNPDPage_28) &&
jmitc91516 1:a5258871b33d 1363 (currentPage != GuiStruct_DetectorNonePage_31) &&
jmitc91516 1:a5258871b33d 1364 (currentPage != GuiStruct_DetectorPIDPage_29) &&
jmitc91516 1:a5258871b33d 1365 (currentPage != GuiStruct_DetectorSPDIDPage_30) &&
jmitc91516 1:a5258871b33d 1366 (currentPage != GuiStruct_DetectorTXLPage_27) &&
jmitc91516 1:a5258871b33d 1367 (currentPage != GuiStruct_GasProfilePage_15) &&
jmitc91516 1:a5258871b33d 1368 (currentPage != GuiStruct_GasInformationPage_6) &&
jmitc91516 1:a5258871b33d 1369 (currentPage != GuiStruct_GasCalibrationPage_Def) &&
jmitc91516 1:a5258871b33d 1370 (currentPage != GuiStruct_GasBackPressureDACPage_Def) &&
jmitc91516 1:a5258871b33d 1371 (currentPage != GuiStruct_GasChannelDACAndADCPage_Def) &&
jmitc91516 1:a5258871b33d 1372 (currentPage != GuiStruct_RunningDetectorPage_27)) { // It also causes flickering if we display the 'Running Detector' page here
jmitc91516 0:47c880c1463d 1373
jmitc91516 0:47c880c1463d 1374 DisplayCurrentPageData(true);
jmitc91516 0:47c880c1463d 1375 }
jmitc91516 1:a5258871b33d 1376 #undef IS_THIS_NECESSARY_NOW
jmitc91516 1:a5258871b33d 1377 #endif // IS_THIS_NECESSARY_NOW
jmitc91516 1:a5258871b33d 1378 // Instead of the above, this is all that is necessary -
jmitc91516 1:a5258871b33d 1379 // without these calls, the graphs on these pages are not displayed
jmitc91516 1:a5258871b33d 1380 // when the page first appears
jmitc91516 1:a5258871b33d 1381 if(currentPage == GuiStruct_RunningColumnPage_25) {
jmitc91516 1:a5258871b33d 1382 DisplayRunningColumnPageData(true, false);
jmitc91516 1:a5258871b33d 1383 } else if (currentPage == GuiStruct_RunningGasPage_28) {
jmitc91516 1:a5258871b33d 1384 DisplayRunningGasPageData(true, false);
jmitc91516 1:a5258871b33d 1385 } else if (currentPage == GuiStruct_RunningInjectorProfilePage_Def) {
jmitc91516 1:a5258871b33d 1386 DisplayRunningInjectorProfilePageData(true, false);
jmitc91516 1:a5258871b33d 1387 }
jmitc91516 1:a5258871b33d 1388 }
jmitc91516 1:a5258871b33d 1389 }
jmitc91516 1:a5258871b33d 1390
jmitc91516 1:a5258871b33d 1391 /*
jmitc91516 1:a5258871b33d 1392 Allows the caller to tell us which component status colour areas to use for the home page.
jmitc91516 1:a5258871b33d 1393
jmitc91516 1:a5258871b33d 1394 Args: pointer to the new component status colour areas for the home page
jmitc91516 1:a5258871b33d 1395
jmitc91516 1:a5258871b33d 1396 No return code.
jmitc91516 1:a5258871b33d 1397 */
jmitc91516 0:47c880c1463d 1398 void GetGCStatusLoop::SetHomePageGCComponentStatusColorAreas(HomePageGCComponentStatusColorAreas* newColorAreas)
jmitc91516 0:47c880c1463d 1399 {
jmitc91516 0:47c880c1463d 1400 homePageGCComponentStatusColorAreas = newColorAreas;
jmitc91516 0:47c880c1463d 1401
jmitc91516 0:47c880c1463d 1402 UpdateHomePageGCComponentStatusColorAreas();
jmitc91516 0:47c880c1463d 1403 }
jmitc91516 0:47c880c1463d 1404
jmitc91516 1:a5258871b33d 1405 /*
jmitc91516 1:a5258871b33d 1406 Allows the caller to tell us which component status colour areas to use for the single component pages
jmitc91516 1:a5258871b33d 1407 (e.g. column, detector, etc).
jmitc91516 1:a5258871b33d 1408
jmitc91516 1:a5258871b33d 1409 Args: pointer to the new component status colour areas for the single component pages
jmitc91516 1:a5258871b33d 1410
jmitc91516 1:a5258871b33d 1411 No return code.
jmitc91516 1:a5258871b33d 1412 */
jmitc91516 0:47c880c1463d 1413 void GetGCStatusLoop::SetSingleGCComponentPageStatusColorAreas(SingleGCComponentPageStatusColorAreas* newColorAreas)
jmitc91516 0:47c880c1463d 1414 {
jmitc91516 0:47c880c1463d 1415 singleGCComponentPageStatusColorAreas = newColorAreas;
jmitc91516 0:47c880c1463d 1416
jmitc91516 0:47c880c1463d 1417 UpdateSingleGCComponentPageStatusColorArea(COLUMN);
jmitc91516 0:47c880c1463d 1418 UpdateSingleGCComponentPageStatusColorArea(INJECTOR);
jmitc91516 0:47c880c1463d 1419 UpdateSingleGCComponentPageStatusColorArea(DETECTOR);
jmitc91516 0:47c880c1463d 1420 UpdateSingleGCComponentPageStatusColorArea(GAS);
jmitc91516 0:47c880c1463d 1421
jmitc91516 0:47c880c1463d 1422 }
jmitc91516 0:47c880c1463d 1423
jmitc91516 0:47c880c1463d 1424
jmitc91516 1:a5258871b33d 1425 /*
jmitc91516 1:a5258871b33d 1426 Displays the specified text at the specified location, with black text on a white background.
jmitc91516 1:a5258871b33d 1427
jmitc91516 1:a5258871b33d 1428 Args: pointer to the null-terminated string to display
jmitc91516 1:a5258871b33d 1429 x coordinate
jmitc91516 1:a5258871b33d 1430 y coordinate
jmitc91516 1:a5258871b33d 1431
jmitc91516 1:a5258871b33d 1432 No return code.
jmitc91516 1:a5258871b33d 1433 */
jmitc91516 1:a5258871b33d 1434 void GetGCStatusLoop::DisplayText(char *text, short X, short Y, GuiConst_INT8U alignment, GuiConst_INT16U fontNo, GuiConst_INTCOLOR foreColor)
jmitc91516 1:a5258871b33d 1435 {
jmitc91516 0:47c880c1463d 1436 GuiLib_DrawStr(
jmitc91516 0:47c880c1463d 1437 X, //GuiConst_INT16S X,
jmitc91516 0:47c880c1463d 1438 Y, //GuiConst_INT16S Y,
jmitc91516 0:47c880c1463d 1439 fontNo, //GuiConst_INT16U FontNo,
jmitc91516 0:47c880c1463d 1440 text, //GuiConst_TEXT PrefixLocate *String,
jmitc91516 1:a5258871b33d 1441 alignment, //GuiConst_INT8U Alignment,
jmitc91516 0:47c880c1463d 1442 GuiLib_PS_ON, //GuiConst_INT8U PsWriting,
jmitc91516 1:a5258871b33d 1443 GuiLib_TRANSPARENT_ON, //GuiConst_INT8U Transparent,
jmitc91516 0:47c880c1463d 1444 GuiLib_UNDERLINE_OFF, //GuiConst_INT8U Underlining,
jmitc91516 0:47c880c1463d 1445 0, //GuiConst_INT16S BackBoxSizeX,
jmitc91516 0:47c880c1463d 1446 0, //GuiConst_INT16S BackBoxSizeY1,
jmitc91516 0:47c880c1463d 1447 0, //GuiConst_INT16S BackBoxSizeY2,
jmitc91516 0:47c880c1463d 1448 GuiLib_BBP_NONE, //GuiConst_INT8U BackBorderPixels,
jmitc91516 1:a5258871b33d 1449 foreColor, //GuiConst_INTCOLOR ForeColor,
jmitc91516 0:47c880c1463d 1450 0xFFFF //GuiConst_INTCOLOR BackColor
jmitc91516 0:47c880c1463d 1451 );
jmitc91516 0:47c880c1463d 1452 }
jmitc91516 0:47c880c1463d 1453
jmitc91516 1:a5258871b33d 1454 /*
jmitc91516 1:a5258871b33d 1455 Sends a command (known as a 'report') to the GC, and returns the response.
jmitc91516 1:a5258871b33d 1456
jmitc91516 1:a5258871b33d 1457 Args: pointer to (null-terminated) command to use
jmitc91516 1:a5258871b33d 1458 pointer to buffer to contain the (also null-terminated) response
jmitc91516 1:a5258871b33d 1459
jmitc91516 1:a5258871b33d 1460 No return code.
jmitc91516 1:a5258871b33d 1461 */
jmitc91516 0:47c880c1463d 1462 void GetGCStatusLoop::SetGCDeviceReport(char *cmd, char *response)
jmitc91516 0:47c880c1463d 1463 {
jmitc91516 1:a5258871b33d 1464 #define USE_GC_UTILS // Testing new class
jmitc91516 1:a5258871b33d 1465 #ifdef USE_GC_UTILS
jmitc91516 1:a5258871b33d 1466 USBHostGCUtilities::SendCommandToGCAndGetResponse(usbDevice, usbHostGC, cmd, response);
jmitc91516 1:a5258871b33d 1467 #else
jmitc91516 0:47c880c1463d 1468 // Guard against simultaneous calls to usbHostGC->SetDeviceReport -
jmitc91516 0:47c880c1463d 1469 // it is not re-entrant (and nor is the GC)
jmitc91516 0:47c880c1463d 1470 while(usbHostGC->ExecutingSetDeviceReport()) {}
jmitc91516 0:47c880c1463d 1471
jmitc91516 0:47c880c1463d 1472 usbHostGC->SetDeviceReport(usbDevice, cmd, response);
jmitc91516 1:a5258871b33d 1473 #endif // USE_GC_UTILS
jmitc91516 1:a5258871b33d 1474 }
jmitc91516 1:a5258871b33d 1475
jmitc91516 1:a5258871b33d 1476 /*
jmitc91516 1:a5258871b33d 1477 Executes a GC command that returns simply "DACK" if successful,
jmitc91516 1:a5258871b33d 1478 "DNAK" or "EPKT" if failure.
jmitc91516 1:a5258871b33d 1479
jmitc91516 1:a5258871b33d 1480 Args: a pointer to the command in question, as a null terminated string
jmitc91516 1:a5258871b33d 1481
jmitc91516 1:a5258871b33d 1482 Returns true if the GC returned "DACK", false for anything else
jmitc91516 1:a5258871b33d 1483 */
jmitc91516 1:a5258871b33d 1484 bool GetGCStatusLoop::ExecuteCommandWithDACKResponse(char *cmd)
jmitc91516 1:a5258871b33d 1485 {
jmitc91516 1:a5258871b33d 1486 #define USE_GC_UTILS // Testing new class
jmitc91516 1:a5258871b33d 1487 #ifdef USE_GC_UTILS
jmitc91516 1:a5258871b33d 1488 return USBHostGCUtilities::SendCommandToGCWithDACKResponse(usbDevice, usbHostGC, cmd);
jmitc91516 1:a5258871b33d 1489 #else
jmitc91516 1:a5258871b33d 1490 while(usbHostGC->ExecutingSetDeviceReport()) {}
jmitc91516 1:a5258871b33d 1491
jmitc91516 1:a5258871b33d 1492 char response[50];
jmitc91516 1:a5258871b33d 1493 usbHostGC->SetDeviceReport(usbDevice, cmd, response);
jmitc91516 1:a5258871b33d 1494 // We expect a response like this: "DACK" for success, "DNAK" for failure, "EPKT" for error
jmitc91516 1:a5258871b33d 1495
jmitc91516 1:a5258871b33d 1496 #define DEBUG_HERE
jmitc91516 1:a5258871b33d 1497 #ifdef DEBUG_HERE
jmitc91516 1:a5258871b33d 1498 char dbg[100];
jmitc91516 1:a5258871b33d 1499 sprintf(dbg, "ECWDKR - %s returned %s", cmd, response);
jmitc91516 1:a5258871b33d 1500 EasyGUIDebugPrint(dbg, 0, 15);
jmitc91516 1:a5258871b33d 1501 #undef DEBUG_HERE
jmitc91516 1:a5258871b33d 1502 #endif
jmitc91516 1:a5258871b33d 1503
jmitc91516 1:a5258871b33d 1504 return (response[1] == 'A');
jmitc91516 1:a5258871b33d 1505 #endif // USE_GC_UTILS
jmitc91516 1:a5258871b33d 1506 }
jmitc91516 1:a5258871b33d 1507
jmitc91516 1:a5258871b33d 1508 /*
jmitc91516 1:a5258871b33d 1509 The commands to get the GC status ("QSTA") and its fault state ("QFLT") are very similar,
jmitc91516 1:a5258871b33d 1510 in that they both return a response of the same form, with the (integer) status/fault value
jmitc91516 1:a5258871b33d 1511 as the final two digits. This function handles both commands, returning the status/fault code
jmitc91516 1:a5258871b33d 1512 as an integer.
jmitc91516 1:a5258871b33d 1513
jmitc91516 1:a5258871b33d 1514 Args: a pointer to the null-terminated command string to be passed to the GC
jmitc91516 1:a5258871b33d 1515 (note that this function does not check that this is either "QSTA" or "QFLT" -
jmitc91516 1:a5258871b33d 1516 this is up to the caller)
jmitc91516 1:a5258871b33d 1517
jmitc91516 1:a5258871b33d 1518 Obtains the status/fault code from the GC, and returns it as an integer.
jmitc91516 1:a5258871b33d 1519 NOTE: returns -1 if there is an error. This is *not* a valid GC status/fault code,
jmitc91516 1:a5258871b33d 1520 and the caller must check for it.
jmitc91516 1:a5258871b33d 1521 */
jmitc91516 0:47c880c1463d 1522 int GetGCStatusLoop::GetGCStatusOrFaultCode(char *cmd)
jmitc91516 0:47c880c1463d 1523 {
jmitc91516 0:47c880c1463d 1524 char response[GC_MESSAGE_LENGTH+2];
jmitc91516 0:47c880c1463d 1525
jmitc91516 0:47c880c1463d 1526 SetGCDeviceReport(cmd, response);
jmitc91516 0:47c880c1463d 1527
jmitc91516 0:47c880c1463d 1528 int gcStatusCode;
jmitc91516 0:47c880c1463d 1529
jmitc91516 0:47c880c1463d 1530 // We expect a response of the form "Dxxx00nn", where the two digits 'nn' are the status code
jmitc91516 0:47c880c1463d 1531
jmitc91516 0:47c880c1463d 1532 // But check for "EPKT" first...
jmitc91516 0:47c880c1463d 1533 if(response[0] == 'E') {
jmitc91516 0:47c880c1463d 1534 gcStatusCode = -1; // *** Caller must check for this ***
jmitc91516 0:47c880c1463d 1535 } else {
jmitc91516 0:47c880c1463d 1536 sscanf(&response[6], "%d", &gcStatusCode);
jmitc91516 0:47c880c1463d 1537 }
jmitc91516 0:47c880c1463d 1538
jmitc91516 0:47c880c1463d 1539 return gcStatusCode;
jmitc91516 0:47c880c1463d 1540 }
jmitc91516 0:47c880c1463d 1541
jmitc91516 1:a5258871b33d 1542 /*
jmitc91516 1:a5258871b33d 1543 Obtains the GC status, using the "QSTA" command.
jmitc91516 1:a5258871b33d 1544
jmitc91516 1:a5258871b33d 1545 Returns the status to the caller.
jmitc91516 1:a5258871b33d 1546 Note that this may be -1 if there was an error. Caller *must* check for this.
jmitc91516 1:a5258871b33d 1547 Otherwise see the GC_STATE enumeration (GCStateAndFaultCodes.h)
jmitc91516 1:a5258871b33d 1548 for the meaning of these codes.
jmitc91516 1:a5258871b33d 1549 */
jmitc91516 0:47c880c1463d 1550 int GetGCStatusLoop::GetGCStatus(void)
jmitc91516 0:47c880c1463d 1551 {
jmitc91516 0:47c880c1463d 1552 return GetGCStatusOrFaultCode("QSTA");
jmitc91516 0:47c880c1463d 1553 }
jmitc91516 0:47c880c1463d 1554
jmitc91516 1:a5258871b33d 1555 /*
jmitc91516 1:a5258871b33d 1556 Obtains the GC fault state, using the "QFLT" command.
jmitc91516 1:a5258871b33d 1557
jmitc91516 1:a5258871b33d 1558 Returns the fault state to the caller.
jmitc91516 1:a5258871b33d 1559 Note that this may be -1 if there was an error - caller *must* check for this.
jmitc91516 1:a5258871b33d 1560 Otherwise see the GC_FAULT enumeration (GCStateAndFaultCodes.h)
jmitc91516 1:a5258871b33d 1561 for the meaning of these codes.
jmitc91516 1:a5258871b33d 1562 */
jmitc91516 0:47c880c1463d 1563 int GetGCStatusLoop::GetGCFaultCode(void)
jmitc91516 0:47c880c1463d 1564 {
jmitc91516 0:47c880c1463d 1565 return GetGCStatusOrFaultCode("QFLT");
jmitc91516 0:47c880c1463d 1566 }
jmitc91516 0:47c880c1463d 1567
jmitc91516 1:a5258871b33d 1568 /*
jmitc91516 1:a5258871b33d 1569 Given GC status and fault codes, returns the corresponding descriptive text
jmitc91516 1:a5258871b33d 1570 as a null-terminated string, obtained from the GCStateAndFaultCodes class.
jmitc91516 1:a5258871b33d 1571
jmitc91516 1:a5258871b33d 1572 Args are: the state code
jmitc91516 1:a5258871b33d 1573 the fault code
jmitc91516 1:a5258871b33d 1574 a pointer to the buffer to contain the null-terminated string
jmitc91516 1:a5258871b33d 1575 describing the GC state
jmitc91516 1:a5258871b33d 1576
jmitc91516 1:a5258871b33d 1577 No return code.
jmitc91516 1:a5258871b33d 1578 */
jmitc91516 0:47c880c1463d 1579 void GetGCStatusLoop::GetGCStateAsInfoString(int gcStateCode, int gcFaultCode, char *statusString)
jmitc91516 0:47c880c1463d 1580 {
jmitc91516 0:47c880c1463d 1581 char buff[100];
jmitc91516 0:47c880c1463d 1582
jmitc91516 1:a5258871b33d 1583 #ifdef USE_VERSION_102 // See GCStateAndFaultCodes.h
jmitc91516 1:a5258871b33d 1584 if(gcStateCode == GC_STATE_102_METHOD_FAULTED) {
jmitc91516 1:a5258871b33d 1585 #else
jmitc91516 1:a5258871b33d 1586 if(gcStateCode == GC_STATE_FAULTED) {
jmitc91516 1:a5258871b33d 1587 #endif
jmitc91516 0:47c880c1463d 1588 if(gcStateAndFaultCodes.GetFaultCodeString(gcFaultCode, buff)) {
jmitc91516 0:47c880c1463d 1589 sprintf(statusString, "GC faulted: %s", buff);
jmitc91516 0:47c880c1463d 1590 } else {
jmitc91516 0:47c880c1463d 1591 sprintf(statusString, "GC faulted: unknown fault code %d", gcFaultCode);
jmitc91516 0:47c880c1463d 1592 }
jmitc91516 0:47c880c1463d 1593
jmitc91516 0:47c880c1463d 1594 } else {
jmitc91516 0:47c880c1463d 1595
jmitc91516 0:47c880c1463d 1596 if(gcStateAndFaultCodes.GetStateCodeString(gcStateCode, buff)) {
jmitc91516 0:47c880c1463d 1597 sprintf(statusString, "GC state: %s", buff);
jmitc91516 0:47c880c1463d 1598 } else {
jmitc91516 0:47c880c1463d 1599 sprintf(statusString, "GC state: unknown state code %d", gcStateCode);
jmitc91516 0:47c880c1463d 1600 }
jmitc91516 0:47c880c1463d 1601 }
jmitc91516 0:47c880c1463d 1602 }
jmitc91516 0:47c880c1463d 1603
jmitc91516 1:a5258871b33d 1604 /*
jmitc91516 1:a5258871b33d 1605 Sets the easyGUI variable on the GCNotReadyToRun page
jmitc91516 1:a5258871b33d 1606 to a string that tells the user why it is not ready to run
jmitc91516 1:a5258871b33d 1607 */
jmitc91516 1:a5258871b33d 1608 void GetGCStatusLoop::SetupGCNotReadyStateEasyGUIVariable(void)
jmitc91516 1:a5258871b33d 1609 {
jmitc91516 1:a5258871b33d 1610 int gcStatus = GetGCStatus();
jmitc91516 1:a5258871b33d 1611 GCStateSimplified simplifiedGCState = GCStateOrFaultCode::GetSimplifiedGCState(gcStatus);
jmitc91516 1:a5258871b33d 1612 gcStateAndFaultCodes.GetSimplifiedStateCodeString(simplifiedGCState, GuiVar_gcNotReadyState);
jmitc91516 1:a5258871b33d 1613
jmitc91516 1:a5258871b33d 1614 }
jmitc91516 1:a5258871b33d 1615
jmitc91516 1:a5258871b33d 1616
jmitc91516 1:a5258871b33d 1617 /*
jmitc91516 1:a5258871b33d 1618 Tells the caller whether or not the GC is in a fault state.
jmitc91516 1:a5258871b33d 1619 If so, returns true, and copies a string describing the status to the specified buffer.
jmitc91516 1:a5258871b33d 1620 If not, returns false (and copies nothing to the buffer).
jmitc91516 1:a5258871b33d 1621
jmitc91516 1:a5258871b33d 1622 Args: the current GC status
jmitc91516 1:a5258871b33d 1623 pointer to a buffer to contain the null-terminated string describing the status.
jmitc91516 1:a5258871b33d 1624
jmitc91516 1:a5258871b33d 1625 Return code: true if the GC is in a fault state, false if not.
jmitc91516 1:a5258871b33d 1626 */
jmitc91516 1:a5258871b33d 1627 bool GetGCStatusLoop::GCHasFaulted(int gcStatus, char* statusString)
jmitc91516 0:47c880c1463d 1628 {
jmitc91516 0:47c880c1463d 1629 bool gcHasFaulted = false;
jmitc91516 0:47c880c1463d 1630 statusString[0] = '\0';
jmitc91516 0:47c880c1463d 1631
jmitc91516 0:47c880c1463d 1632 if(gcStatus == -1) { // Got "EPKT" as response from GC
jmitc91516 0:47c880c1463d 1633 strcpy(statusString, "Failed to get status");
jmitc91516 0:47c880c1463d 1634 gcHasFaulted = true;
jmitc91516 0:47c880c1463d 1635 } else {
jmitc91516 1:a5258871b33d 1636 #ifdef USE_VERSION_102 // See GCStateAndFaultCodes.h
jmitc91516 1:a5258871b33d 1637 int gcFaultCode = GC_FAULT_102_NO_ERROR;
jmitc91516 1:a5258871b33d 1638 if(gcStatus == GC_STATE_102_METHOD_FAULTED) {
jmitc91516 0:47c880c1463d 1639 gcFaultCode = GetGCFaultCode();
jmitc91516 0:47c880c1463d 1640
jmitc91516 1:a5258871b33d 1641 if(gcFaultCode != GC_FAULT_102_NO_ERROR) {
jmitc91516 0:47c880c1463d 1642 gcHasFaulted = true;
jmitc91516 0:47c880c1463d 1643 }
jmitc91516 0:47c880c1463d 1644 }
jmitc91516 1:a5258871b33d 1645 #else
jmitc91516 1:a5258871b33d 1646 int gcFaultCode = GC_FAULT_NO_ERROR;
jmitc91516 1:a5258871b33d 1647 if(gcStatus == GC_STATE_FAULTED) {
jmitc91516 1:a5258871b33d 1648 gcFaultCode = GetGCFaultCode();
jmitc91516 1:a5258871b33d 1649
jmitc91516 1:a5258871b33d 1650 if(gcFaultCode != GC_FAULT_NO_ERROR) {
jmitc91516 1:a5258871b33d 1651 gcHasFaulted = true;
jmitc91516 1:a5258871b33d 1652 }
jmitc91516 1:a5258871b33d 1653 }
jmitc91516 1:a5258871b33d 1654 #endif
jmitc91516 0:47c880c1463d 1655 GetGCStateAsInfoString(gcStatus, gcFaultCode, statusString);
jmitc91516 0:47c880c1463d 1656 }
jmitc91516 0:47c880c1463d 1657
jmitc91516 0:47c880c1463d 1658 return gcHasFaulted;
jmitc91516 0:47c880c1463d 1659 }
jmitc91516 0:47c880c1463d 1660
jmitc91516 1:a5258871b33d 1661 /*
jmitc91516 1:a5258871b33d 1662 Version of the above that does not require any arguments.
jmitc91516 1:a5258871b33d 1663
jmitc91516 1:a5258871b33d 1664 Tells the caller whether or not the GC is in a fault state.
jmitc91516 1:a5258871b33d 1665
jmitc91516 1:a5258871b33d 1666 No arguments.
jmitc91516 1:a5258871b33d 1667
jmitc91516 1:a5258871b33d 1668 Return code: true if the GC is in a fault state, false if not.
jmitc91516 1:a5258871b33d 1669 */
jmitc91516 1:a5258871b33d 1670 bool GetGCStatusLoop::GCHasFaulted(void)
jmitc91516 1:a5258871b33d 1671 {
jmitc91516 1:a5258871b33d 1672 char statusString[100];
jmitc91516 1:a5258871b33d 1673
jmitc91516 1:a5258871b33d 1674 return GCHasFaulted(GetGCStatus(), statusString);
jmitc91516 1:a5258871b33d 1675 }
jmitc91516 1:a5258871b33d 1676
jmitc91516 1:a5258871b33d 1677
jmitc91516 1:a5258871b33d 1678 /*
jmitc91516 1:a5258871b33d 1679 Get the temperature of a GC component (column, detector, etc), and returns it as a null-terminated string, with a descriptive prefix.
jmitc91516 1:a5258871b33d 1680 The GC commands for all of the component temperatures give a similar response.
jmitc91516 1:a5258871b33d 1681
jmitc91516 1:a5258871b33d 1682 Note also that this code is intended to be as efficient as possible.
jmitc91516 1:a5258871b33d 1683
jmitc91516 1:a5258871b33d 1684 Args: pointer to the null-terminated string specifying the command to get the temperature
jmitc91516 1:a5258871b33d 1685 pointer to the buffer to contain the temperature, also as a null-terminated string
jmitc91516 1:a5258871b33d 1686 optional bool set true if the value is in units of one-tenth of a degree,
jmitc91516 1:a5258871b33d 1687 false if whole degrees (default is true)
jmitc91516 1:a5258871b33d 1688
jmitc91516 1:a5258871b33d 1689 No return code.
jmitc91516 1:a5258871b33d 1690 */
jmitc91516 1:a5258871b33d 1691 void GetGCStatusLoop::GetComponentTemperature(char *cmd, char *temp, bool wantPrefix, bool wantDegSuffix, bool oneTenthDegree)
jmitc91516 0:47c880c1463d 1692 {
jmitc91516 0:47c880c1463d 1693 char response[50];
jmitc91516 0:47c880c1463d 1694 SetGCDeviceReport(cmd, response);
jmitc91516 0:47c880c1463d 1695 // We expect a response like this: "Dxxx1234" - temp in units of 0.1 deg
jmitc91516 1:a5258871b33d 1696
jmitc91516 1:a5258871b33d 1697 int index = 0;
jmitc91516 1:a5258871b33d 1698
jmitc91516 1:a5258871b33d 1699 if(wantPrefix) {
jmitc91516 1:a5258871b33d 1700 temp[index++] = 'T';
jmitc91516 1:a5258871b33d 1701 temp[index++] = 'e';
jmitc91516 1:a5258871b33d 1702 temp[index++] = 'm';
jmitc91516 1:a5258871b33d 1703 temp[index++] = 'p';
jmitc91516 1:a5258871b33d 1704 temp[index++] = ':';
jmitc91516 1:a5258871b33d 1705 temp[index++] = ' ';
jmitc91516 1:a5258871b33d 1706 }
jmitc91516 1:a5258871b33d 1707
jmitc91516 1:a5258871b33d 1708 // But check for "EPKT" first
jmitc91516 1:a5258871b33d 1709 if(response[0] == 'E') {
jmitc91516 1:a5258871b33d 1710 temp[index++] = '*';
jmitc91516 1:a5258871b33d 1711 temp[index++] = '*';
jmitc91516 1:a5258871b33d 1712 temp[index++] = ' ';
jmitc91516 1:a5258871b33d 1713 temp[index++] = 'E';
jmitc91516 1:a5258871b33d 1714 temp[index++] = 'r';
jmitc91516 1:a5258871b33d 1715 temp[index++] = 'r';
jmitc91516 1:a5258871b33d 1716 temp[index++] = 'o';
jmitc91516 1:a5258871b33d 1717 temp[index++] = 'r';
jmitc91516 1:a5258871b33d 1718 temp[index++] = ' ';
jmitc91516 1:a5258871b33d 1719 temp[index++] = '*';
jmitc91516 1:a5258871b33d 1720 temp[index++] = '*';
jmitc91516 1:a5258871b33d 1721 } else {
jmitc91516 1:a5258871b33d 1722 // Ignore leading zeroes
jmitc91516 1:a5258871b33d 1723 bool wantNextChars = false;
jmitc91516 1:a5258871b33d 1724 if(response[4] != '0') {
jmitc91516 1:a5258871b33d 1725 temp[index++] = response[4];
jmitc91516 1:a5258871b33d 1726 wantNextChars = true;
jmitc91516 1:a5258871b33d 1727 }
jmitc91516 1:a5258871b33d 1728 if(wantNextChars || (response[5] != '0')) {
jmitc91516 1:a5258871b33d 1729 temp[index++] = response[5];
jmitc91516 1:a5258871b33d 1730 wantNextChars = true;
jmitc91516 1:a5258871b33d 1731 }
jmitc91516 1:a5258871b33d 1732 // If the value is zero, make sure we return "0.0" -
jmitc91516 1:a5258871b33d 1733 // we just don't want any zeroes before that
jmitc91516 1:a5258871b33d 1734 if(oneTenthDegree) {
jmitc91516 1:a5258871b33d 1735 temp[index++] = response[6];
jmitc91516 1:a5258871b33d 1736 temp[index++] = '.';
jmitc91516 1:a5258871b33d 1737 temp[index++] = response[7];
jmitc91516 1:a5258871b33d 1738 } else {
jmitc91516 1:a5258871b33d 1739 if(wantNextChars || (response[6] != '0')) {
jmitc91516 1:a5258871b33d 1740 temp[index++] = response[6];
jmitc91516 1:a5258871b33d 1741 }
jmitc91516 1:a5258871b33d 1742 temp[index++] = response[7];
jmitc91516 1:a5258871b33d 1743 }
jmitc91516 1:a5258871b33d 1744 if(wantDegSuffix) {
jmitc91516 6:dba3fbdfd5da 1745 #define TRY_DEG_SYMBOL
jmitc91516 6:dba3fbdfd5da 1746 #ifdef TRY_DEG_SYMBOL
jmitc91516 6:dba3fbdfd5da 1747 temp[index++] = ' ';
jmitc91516 6:dba3fbdfd5da 1748 temp[index++] = degSymbol;
jmitc91516 6:dba3fbdfd5da 1749 temp[index++] = 'C';
jmitc91516 6:dba3fbdfd5da 1750 #else
jmitc91516 1:a5258871b33d 1751 temp[index++] = ' ';
jmitc91516 1:a5258871b33d 1752 temp[index++] = 'd';
jmitc91516 1:a5258871b33d 1753 temp[index++] = 'e';
jmitc91516 1:a5258871b33d 1754 temp[index++] = 'g';
jmitc91516 1:a5258871b33d 1755 temp[index++] = ' ';
jmitc91516 1:a5258871b33d 1756 temp[index++] = 'C';
jmitc91516 6:dba3fbdfd5da 1757 #endif // TRY_DEG_SYMBOL
jmitc91516 1:a5258871b33d 1758 }
jmitc91516 1:a5258871b33d 1759 }
jmitc91516 1:a5258871b33d 1760
jmitc91516 1:a5258871b33d 1761 temp[index++] = '\0';
jmitc91516 1:a5258871b33d 1762 }
jmitc91516 1:a5258871b33d 1763
jmitc91516 1:a5258871b33d 1764 /*
jmitc91516 1:a5258871b33d 1765 Get the temperature of a GC component (column, detector, etc), and returns it as a floating-point value.
jmitc91516 1:a5258871b33d 1766 The GC commands for all of the component temperatures give a similar response.
jmitc91516 1:a5258871b33d 1767
jmitc91516 1:a5258871b33d 1768 Note also that this code is intended to be as efficient as possible.
jmitc91516 1:a5258871b33d 1769
jmitc91516 1:a5258871b33d 1770 Args: pointer to the null-terminated string specifying the command to get the temperature
jmitc91516 1:a5258871b33d 1771 pointer to the floating-point variable to contain the temperature
jmitc91516 1:a5258871b33d 1772 optional bool set true if the value is in units of one-tenth of a degree,
jmitc91516 1:a5258871b33d 1773 false if whole degrees (default is true)
jmitc91516 1:a5258871b33d 1774
jmitc91516 1:a5258871b33d 1775 No return code.
jmitc91516 1:a5258871b33d 1776 */
jmitc91516 1:a5258871b33d 1777 void GetGCStatusLoop::GetComponentTemperature(char *cmd, float *temp, bool oneTenthDegree)
jmitc91516 1:a5258871b33d 1778 {
jmitc91516 1:a5258871b33d 1779 char buff[10];
jmitc91516 1:a5258871b33d 1780 char response[50];
jmitc91516 1:a5258871b33d 1781 SetGCDeviceReport(cmd, response);
jmitc91516 1:a5258871b33d 1782 // We expect a response like this: "Dxxx1234" - temp in units of 0.1 deg
jmitc91516 0:47c880c1463d 1783
jmitc91516 0:47c880c1463d 1784 // But check for "EPKT" first
jmitc91516 0:47c880c1463d 1785 if(response[0] == 'E') {
jmitc91516 0:47c880c1463d 1786 *temp = -1.0f; // ** Caller must check for this **
jmitc91516 0:47c880c1463d 1787 } else {
jmitc91516 1:a5258871b33d 1788 buff[0] = response[4];
jmitc91516 1:a5258871b33d 1789 buff[1] = response[5];
jmitc91516 1:a5258871b33d 1790 buff[2] = response[6];
jmitc91516 1:a5258871b33d 1791 if(oneTenthDegree) {
jmitc91516 1:a5258871b33d 1792 buff[3] = '.';
jmitc91516 1:a5258871b33d 1793 buff[4] = response[7];
jmitc91516 1:a5258871b33d 1794 } else {
jmitc91516 1:a5258871b33d 1795 buff[3] = response[7];
jmitc91516 1:a5258871b33d 1796 }
jmitc91516 1:a5258871b33d 1797
jmitc91516 1:a5258871b33d 1798 sscanf(buff, "%f", temp);
jmitc91516 0:47c880c1463d 1799 }
jmitc91516 0:47c880c1463d 1800 //#define DEBUG_HERE
jmitc91516 0:47c880c1463d 1801 #ifdef DEBUG_HERE
jmitc91516 0:47c880c1463d 1802 char dbg[100];
jmitc91516 0:47c880c1463d 1803 sprintf(dbg, "GGCSL::GCT - returning : %f", *temp);
jmitc91516 1:a5258871b33d 1804 EasyGUIDebugPrint(dbg, 0, 20);
jmitc91516 1:a5258871b33d 1805 #undef DEBUG_HERE
jmitc91516 1:a5258871b33d 1806 #endif
jmitc91516 1:a5258871b33d 1807 }
jmitc91516 1:a5258871b33d 1808
jmitc91516 1:a5258871b33d 1809 /*
jmitc91516 1:a5258871b33d 1810 Gets the column temperature, returning it as a null-terminated string, with a descriptive prefix.
jmitc91516 1:a5258871b33d 1811
jmitc91516 1:a5258871b33d 1812 Args: pointer to a buffer to contain the null-terminated string specifying the temperature.
jmitc91516 1:a5258871b33d 1813 boolean true if the caller wants an identifying prefix, false if not
jmitc91516 1:a5258871b33d 1814
jmitc91516 1:a5258871b33d 1815 No return code.
jmitc91516 1:a5258871b33d 1816 */
jmitc91516 1:a5258871b33d 1817 void GetGCStatusLoop::GetColumnTemperature(char *temp, bool wantPrefix)
jmitc91516 1:a5258871b33d 1818 {
jmitc91516 1:a5258871b33d 1819 GetComponentTemperature("QCOL", temp, wantPrefix, true);
jmitc91516 1:a5258871b33d 1820 }
jmitc91516 1:a5258871b33d 1821
jmitc91516 1:a5258871b33d 1822 /*
jmitc91516 1:a5258871b33d 1823 Gets the column temperature, returning it as a null-terminated string.
jmitc91516 1:a5258871b33d 1824
jmitc91516 1:a5258871b33d 1825 Args: pointer to a buffer to contain the null-terminated string specifying the temperature.
jmitc91516 1:a5258871b33d 1826 boolean true if the caller wants an identifying prefix, false if not
jmitc91516 1:a5258871b33d 1827 boolean true if the caller wants a suffix specifyng the units, false if not
jmitc91516 1:a5258871b33d 1828
jmitc91516 1:a5258871b33d 1829 No return code.
jmitc91516 1:a5258871b33d 1830 */
jmitc91516 1:a5258871b33d 1831 void GetGCStatusLoop::GetColumnTemperature(char *temp, bool wantPrefix, bool wantSuffix)
jmitc91516 1:a5258871b33d 1832 {
jmitc91516 1:a5258871b33d 1833 GetComponentTemperature("QCOL", temp, wantPrefix, wantSuffix);
jmitc91516 1:a5258871b33d 1834 }
jmitc91516 1:a5258871b33d 1835
jmitc91516 1:a5258871b33d 1836 /*
jmitc91516 1:a5258871b33d 1837 Gets the column temperature, returning it as a floating-point value.
jmitc91516 1:a5258871b33d 1838
jmitc91516 1:a5258871b33d 1839 Args: pointer to a floating point variable to contain the temperature
jmitc91516 1:a5258871b33d 1840
jmitc91516 1:a5258871b33d 1841 No return code.
jmitc91516 1:a5258871b33d 1842 */
jmitc91516 0:47c880c1463d 1843 void GetGCStatusLoop::GetColumnTemperature(float *temp)
jmitc91516 0:47c880c1463d 1844 {
jmitc91516 0:47c880c1463d 1845 GetComponentTemperature("QCOL", temp);
jmitc91516 0:47c880c1463d 1846 }
jmitc91516 0:47c880c1463d 1847
jmitc91516 1:a5258871b33d 1848 /*
jmitc91516 1:a5258871b33d 1849 Gets the target column temperature, returning it as a null-terminated string
jmitc91516 1:a5258871b33d 1850
jmitc91516 1:a5258871b33d 1851 Args: pointer to a buffer to contain the null-terminated string specifying the temperature.
jmitc91516 1:a5258871b33d 1852 pointer to a string specifying the sprintf format to use
jmitc91516 1:a5258871b33d 1853 No return code.
jmitc91516 1:a5258871b33d 1854 */
jmitc91516 6:dba3fbdfd5da 1855 void GetGCStatusLoop::GetColumnTargetTemperature(char *temp, const char *format)
jmitc91516 1:a5258871b33d 1856 {
jmitc91516 1:a5258871b33d 1857 char buff[40];
jmitc91516 1:a5258871b33d 1858 GetComponentTemperature("GCOL", buff, false, false, false); // Target temperature is in whole degrees, not one-tenth
jmitc91516 1:a5258871b33d 1859
jmitc91516 1:a5258871b33d 1860 sprintf(temp, format, buff);
jmitc91516 1:a5258871b33d 1861 }
jmitc91516 1:a5258871b33d 1862
jmitc91516 1:a5258871b33d 1863 /*
jmitc91516 1:a5258871b33d 1864 Gets the column temperature, returning it as a null-terminated string, with a descriptive prefix.
jmitc91516 1:a5258871b33d 1865
jmitc91516 1:a5258871b33d 1866 Args: pointer to a buffer to contain the null-terminated string specifying the temperature.
jmitc91516 1:a5258871b33d 1867 boolean true if the caller wants an identifying prefix, false if not
jmitc91516 1:a5258871b33d 1868
jmitc91516 1:a5258871b33d 1869 No return code.
jmitc91516 1:a5258871b33d 1870 */
jmitc91516 1:a5258871b33d 1871 void GetGCStatusLoop::GetDirectlyHeatedColumnTemperature(char *temp, bool wantPrefix)
jmitc91516 1:a5258871b33d 1872 {
jmitc91516 1:a5258871b33d 1873 GetComponentTemperature("QDCT", temp, wantPrefix, true);
jmitc91516 1:a5258871b33d 1874 }
jmitc91516 1:a5258871b33d 1875
jmitc91516 1:a5258871b33d 1876 /*
jmitc91516 1:a5258871b33d 1877 Gets the column temperature, returning it as a floating-point value.
jmitc91516 1:a5258871b33d 1878
jmitc91516 1:a5258871b33d 1879 Args: pointer to a floating point variable to contain the temperature
jmitc91516 1:a5258871b33d 1880
jmitc91516 1:a5258871b33d 1881 No return code.
jmitc91516 1:a5258871b33d 1882 */
jmitc91516 1:a5258871b33d 1883 void GetGCStatusLoop::GetDirectlyHeatedColumnTemperature(float *temp)
jmitc91516 1:a5258871b33d 1884 {
jmitc91516 1:a5258871b33d 1885 GetComponentTemperature("QDCT", temp);
jmitc91516 1:a5258871b33d 1886 }
jmitc91516 1:a5258871b33d 1887
jmitc91516 1:a5258871b33d 1888 /*
jmitc91516 1:a5258871b33d 1889 Gets the detector temperature, returning it as a null-terminated string, with 'deg C' as suffix.
jmitc91516 1:a5258871b33d 1890
jmitc91516 1:a5258871b33d 1891 Args: pointer to a buffer to contain the null-terminated string specifying the temperature.
jmitc91516 1:a5258871b33d 1892
jmitc91516 1:a5258871b33d 1893 No return code.
jmitc91516 1:a5258871b33d 1894 */
jmitc91516 0:47c880c1463d 1895 void GetGCStatusLoop::GetDetectorTemperature(char *temp)
jmitc91516 0:47c880c1463d 1896 {
jmitc91516 1:a5258871b33d 1897 char buff[40];
jmitc91516 1:a5258871b33d 1898 GetComponentTemperature("QDET", buff, true, true);
jmitc91516 1:a5258871b33d 1899
jmitc91516 1:a5258871b33d 1900 // Temporary - omit "Temp: " prefix
jmitc91516 1:a5258871b33d 1901 strcpy(temp, &buff[6]);
jmitc91516 1:a5258871b33d 1902 }
jmitc91516 1:a5258871b33d 1903
jmitc91516 1:a5258871b33d 1904 /*
jmitc91516 1:a5258871b33d 1905 Gets the detector temperature, returning it as a floating-point value.
jmitc91516 1:a5258871b33d 1906
jmitc91516 1:a5258871b33d 1907 Args: pointer to a floating point variable to contain the temperature
jmitc91516 1:a5258871b33d 1908
jmitc91516 1:a5258871b33d 1909 No return code.
jmitc91516 1:a5258871b33d 1910 */
jmitc91516 0:47c880c1463d 1911 void GetGCStatusLoop::GetDetectorTemperature(float *temp)
jmitc91516 0:47c880c1463d 1912 {
jmitc91516 0:47c880c1463d 1913 GetComponentTemperature("QDET", temp);
jmitc91516 0:47c880c1463d 1914 }
jmitc91516 0:47c880c1463d 1915
jmitc91516 1:a5258871b33d 1916 /*
jmitc91516 1:a5258871b33d 1917 Gets the target detector temperature, returning it as a null-terminated string
jmitc91516 1:a5258871b33d 1918
jmitc91516 1:a5258871b33d 1919 Args: pointer to a buffer to contain the null-terminated string specifying the temperature.
jmitc91516 1:a5258871b33d 1920 string specifying the sprintf format to use
jmitc91516 1:a5258871b33d 1921
jmitc91516 1:a5258871b33d 1922 No return code.
jmitc91516 1:a5258871b33d 1923 */
jmitc91516 6:dba3fbdfd5da 1924 void GetGCStatusLoop::GetDetectorTargetTemperature(char *temp, const char *format)
jmitc91516 1:a5258871b33d 1925 {
jmitc91516 1:a5258871b33d 1926 char buff[40];
jmitc91516 1:a5258871b33d 1927 GetComponentTemperature("GDET", buff, false, false, false); // Target temperature is in whole degrees, not one-tenth
jmitc91516 1:a5258871b33d 1928
jmitc91516 1:a5258871b33d 1929 sprintf(temp, format, buff);
jmitc91516 1:a5258871b33d 1930 }
jmitc91516 1:a5258871b33d 1931
jmitc91516 1:a5258871b33d 1932
jmitc91516 1:a5258871b33d 1933 /*
jmitc91516 1:a5258871b33d 1934 Gets the filament polarity for a TCD detector, and returns it as a null-terminated string.
jmitc91516 1:a5258871b33d 1935
jmitc91516 1:a5258871b33d 1936 Note also that this code is intended to be as efficient as possible.
jmitc91516 1:a5258871b33d 1937
jmitc91516 1:a5258871b33d 1938 Args: pointer to the buffer to contain the polarity, as a null-terminated string
jmitc91516 1:a5258871b33d 1939
jmitc91516 1:a5258871b33d 1940 No return code.
jmitc91516 1:a5258871b33d 1941 */
jmitc91516 1:a5258871b33d 1942 void GetGCStatusLoop::GetTCDDetectorFilamentPolarity(char *polarity)
jmitc91516 1:a5258871b33d 1943 {
jmitc91516 1:a5258871b33d 1944 char response[50];
jmitc91516 1:a5258871b33d 1945 SetGCDeviceReport("GPOL", response);
jmitc91516 1:a5258871b33d 1946
jmitc91516 1:a5258871b33d 1947 // We expect a response like this: "DPOL0001" for positive, "DPOL0002" for negative
jmitc91516 1:a5258871b33d 1948 int index = 0;
jmitc91516 1:a5258871b33d 1949 // But check for "EPKT" first
jmitc91516 1:a5258871b33d 1950 if(response[0] == 'E') {
jmitc91516 1:a5258871b33d 1951 polarity[index++] = '*';
jmitc91516 1:a5258871b33d 1952 polarity[index++] = '*';
jmitc91516 1:a5258871b33d 1953 polarity[index++] = ' ';
jmitc91516 1:a5258871b33d 1954 polarity[index++] = 'E';
jmitc91516 1:a5258871b33d 1955 polarity[index++] = 'r';
jmitc91516 1:a5258871b33d 1956 polarity[index++] = 'r';
jmitc91516 1:a5258871b33d 1957 polarity[index++] = 'o';
jmitc91516 1:a5258871b33d 1958 polarity[index++] = 'r';
jmitc91516 1:a5258871b33d 1959 polarity[index++] = ' ';
jmitc91516 1:a5258871b33d 1960 polarity[index++] = '*';
jmitc91516 1:a5258871b33d 1961 polarity[index++] = '*';
jmitc91516 1:a5258871b33d 1962 } else {
jmitc91516 1:a5258871b33d 1963 switch(response[7]) {
jmitc91516 1:a5258871b33d 1964 case '1':
jmitc91516 1:a5258871b33d 1965 polarity[index++] = 'p';
jmitc91516 1:a5258871b33d 1966 polarity[index++] = 'o';
jmitc91516 1:a5258871b33d 1967 polarity[index++] = 's';
jmitc91516 1:a5258871b33d 1968 polarity[index++] = 'i';
jmitc91516 1:a5258871b33d 1969 polarity[index++] = 't';
jmitc91516 1:a5258871b33d 1970 polarity[index++] = 'i';
jmitc91516 1:a5258871b33d 1971 polarity[index++] = 'v';
jmitc91516 1:a5258871b33d 1972 polarity[index++] = 'e';
jmitc91516 1:a5258871b33d 1973 break;
jmitc91516 1:a5258871b33d 1974 case '2':
jmitc91516 1:a5258871b33d 1975 polarity[index++] = 'n';
jmitc91516 1:a5258871b33d 1976 polarity[index++] = 'e';
jmitc91516 1:a5258871b33d 1977 polarity[index++] = 'g';
jmitc91516 1:a5258871b33d 1978 polarity[index++] = 'a';
jmitc91516 1:a5258871b33d 1979 polarity[index++] = 't';
jmitc91516 1:a5258871b33d 1980 polarity[index++] = 'i';
jmitc91516 1:a5258871b33d 1981 polarity[index++] = 'v';
jmitc91516 1:a5258871b33d 1982 polarity[index++] = 'e';
jmitc91516 1:a5258871b33d 1983 break;
jmitc91516 1:a5258871b33d 1984 default:
jmitc91516 1:a5258871b33d 1985 polarity[index++] = 'i';
jmitc91516 1:a5258871b33d 1986 polarity[index++] = 'n';
jmitc91516 1:a5258871b33d 1987 polarity[index++] = 'v';
jmitc91516 1:a5258871b33d 1988 polarity[index++] = 'a';
jmitc91516 1:a5258871b33d 1989 polarity[index++] = 'l';
jmitc91516 1:a5258871b33d 1990 polarity[index++] = 'd';
jmitc91516 1:a5258871b33d 1991 polarity[index++] = 'd';
jmitc91516 1:a5258871b33d 1992 break;
jmitc91516 1:a5258871b33d 1993 }
jmitc91516 1:a5258871b33d 1994 }
jmitc91516 1:a5258871b33d 1995 polarity[index] = '\0';
jmitc91516 1:a5258871b33d 1996 }
jmitc91516 1:a5258871b33d 1997
jmitc91516 1:a5258871b33d 1998 /*
jmitc91516 1:a5258871b33d 1999 Gets the filament temperature for a TCD detector, and returns it as a null-terminated string.
jmitc91516 1:a5258871b33d 2000
jmitc91516 1:a5258871b33d 2001 Note also that this code is intended to be as efficient as possible.
jmitc91516 1:a5258871b33d 2002
jmitc91516 1:a5258871b33d 2003 Args: pointer to the buffer to contain the temperature, as a null-terminated string
jmitc91516 1:a5258871b33d 2004
jmitc91516 1:a5258871b33d 2005 No return code.
jmitc91516 1:a5258871b33d 2006 */
jmitc91516 1:a5258871b33d 2007 void GetGCStatusLoop::GetTCDDetectorFilamentTemperature(char *temp)
jmitc91516 1:a5258871b33d 2008 {
jmitc91516 1:a5258871b33d 2009 char buff[40];
jmitc91516 1:a5258871b33d 2010 GetComponentTemperature("GFIL", buff, true, true);
jmitc91516 1:a5258871b33d 2011
jmitc91516 1:a5258871b33d 2012 // Temporary - omit "Temp: " prefix
jmitc91516 1:a5258871b33d 2013 strcpy(temp, &buff[6]);
jmitc91516 1:a5258871b33d 2014 }
jmitc91516 1:a5258871b33d 2015
jmitc91516 1:a5258871b33d 2016 /*
jmitc91516 1:a5258871b33d 2017 Gets the amplifier range (gain) for a TCD detector, and returns it as a null-terminated string.
jmitc91516 1:a5258871b33d 2018
jmitc91516 1:a5258871b33d 2019 Note also that this code is intended to be as efficient as possible.
jmitc91516 1:a5258871b33d 2020
jmitc91516 1:a5258871b33d 2021 Args: pointer to the buffer to contain the range, as a null-terminated string
jmitc91516 1:a5258871b33d 2022
jmitc91516 1:a5258871b33d 2023 No return code.
jmitc91516 1:a5258871b33d 2024 */
jmitc91516 1:a5258871b33d 2025 void GetGCStatusLoop::GetTCDDetectorRange(char *range)
jmitc91516 1:a5258871b33d 2026 {
jmitc91516 1:a5258871b33d 2027 char response[50];
jmitc91516 1:a5258871b33d 2028 SetGCDeviceReport("GRNG", response);
jmitc91516 1:a5258871b33d 2029
jmitc91516 1:a5258871b33d 2030 // We expect a response like this: "DRNG0001" for x1, "DRNG0002" for x10
jmitc91516 1:a5258871b33d 2031 int index = 0;
jmitc91516 1:a5258871b33d 2032 // But check for "EPKT" first
jmitc91516 1:a5258871b33d 2033 if(response[0] == 'E') {
jmitc91516 1:a5258871b33d 2034 range[index++] = '*';
jmitc91516 1:a5258871b33d 2035 range[index++] = '*';
jmitc91516 1:a5258871b33d 2036 range[index++] = ' ';
jmitc91516 1:a5258871b33d 2037 range[index++] = 'E';
jmitc91516 1:a5258871b33d 2038 range[index++] = 'r';
jmitc91516 1:a5258871b33d 2039 range[index++] = 'r';
jmitc91516 1:a5258871b33d 2040 range[index++] = 'o';
jmitc91516 1:a5258871b33d 2041 range[index++] = 'r';
jmitc91516 1:a5258871b33d 2042 range[index++] = ' ';
jmitc91516 1:a5258871b33d 2043 range[index++] = '*';
jmitc91516 1:a5258871b33d 2044 range[index++] = '*';
jmitc91516 1:a5258871b33d 2045 } else {
jmitc91516 1:a5258871b33d 2046 switch(response[7]) {
jmitc91516 1:a5258871b33d 2047 case '1':
jmitc91516 1:a5258871b33d 2048 range[index++] = 'x';
jmitc91516 1:a5258871b33d 2049 range[index++] = '1';
jmitc91516 1:a5258871b33d 2050 break;
jmitc91516 1:a5258871b33d 2051 case '2':
jmitc91516 1:a5258871b33d 2052 range[index++] = 'x';
jmitc91516 1:a5258871b33d 2053 range[index++] = '1';
jmitc91516 1:a5258871b33d 2054 range[index++] = '0';
jmitc91516 1:a5258871b33d 2055 break;
jmitc91516 1:a5258871b33d 2056 default:
jmitc91516 1:a5258871b33d 2057 range[index++] = 'i';
jmitc91516 1:a5258871b33d 2058 range[index++] = 'n';
jmitc91516 1:a5258871b33d 2059 range[index++] = 'v';
jmitc91516 1:a5258871b33d 2060 range[index++] = 'a';
jmitc91516 1:a5258871b33d 2061 range[index++] = 'l';
jmitc91516 1:a5258871b33d 2062 range[index++] = 'd';
jmitc91516 1:a5258871b33d 2063 range[index++] = 'd';
jmitc91516 1:a5258871b33d 2064 break;
jmitc91516 1:a5258871b33d 2065 }
jmitc91516 1:a5258871b33d 2066 }
jmitc91516 1:a5258871b33d 2067 range[index] = '\0';
jmitc91516 1:a5258871b33d 2068 }
jmitc91516 1:a5258871b33d 2069
jmitc91516 1:a5258871b33d 2070 /*
jmitc91516 1:a5258871b33d 2071 Gets the current for an ECD detector, and returns it as a null-terminated string.
jmitc91516 1:a5258871b33d 2072
jmitc91516 1:a5258871b33d 2073 Note also that this code is intended to be as efficient as possible.
jmitc91516 1:a5258871b33d 2074
jmitc91516 1:a5258871b33d 2075 Args: pointer to the buffer to contain the current, as a null-terminated string
jmitc91516 1:a5258871b33d 2076
jmitc91516 1:a5258871b33d 2077 No return code.
jmitc91516 1:a5258871b33d 2078 */
jmitc91516 1:a5258871b33d 2079 void GetGCStatusLoop::GetECDDetectorCurrent(char *current)
jmitc91516 1:a5258871b33d 2080 {
jmitc91516 1:a5258871b33d 2081 char response[50];
jmitc91516 1:a5258871b33d 2082 SetGCDeviceReport("GCUR", response);
jmitc91516 1:a5258871b33d 2083
jmitc91516 1:a5258871b33d 2084 // We expect a response like this: "DCURnnnn", where 'nnnn' is the sensitivity.
jmitc91516 1:a5258871b33d 2085 // TODO: perform appropriate interpretation on the value 'nnnn'.
jmitc91516 1:a5258871b33d 2086 // Currently, we just return it unchanged
jmitc91516 1:a5258871b33d 2087
jmitc91516 1:a5258871b33d 2088 int index = 0;
jmitc91516 1:a5258871b33d 2089 // Check for "EPKT" first
jmitc91516 1:a5258871b33d 2090 if(response[0] == 'E') {
jmitc91516 1:a5258871b33d 2091 current[index++] = '*';
jmitc91516 1:a5258871b33d 2092 current[index++] = '*';
jmitc91516 1:a5258871b33d 2093 current[index++] = ' ';
jmitc91516 1:a5258871b33d 2094 current[index++] = 'E';
jmitc91516 1:a5258871b33d 2095 current[index++] = 'r';
jmitc91516 1:a5258871b33d 2096 current[index++] = 'r';
jmitc91516 1:a5258871b33d 2097 current[index++] = 'o';
jmitc91516 1:a5258871b33d 2098 current[index++] = 'r';
jmitc91516 1:a5258871b33d 2099 current[index++] = ' ';
jmitc91516 1:a5258871b33d 2100 current[index++] = '*';
jmitc91516 1:a5258871b33d 2101 current[index++] = '*';
jmitc91516 1:a5258871b33d 2102 } else {
jmitc91516 1:a5258871b33d 2103 // Ignore leading zeroes
jmitc91516 1:a5258871b33d 2104 bool wantNextChars = false;
jmitc91516 1:a5258871b33d 2105 if(response[4] != '0') {
jmitc91516 1:a5258871b33d 2106 current[index++] = response[4];
jmitc91516 1:a5258871b33d 2107 wantNextChars = true;
jmitc91516 1:a5258871b33d 2108 }
jmitc91516 1:a5258871b33d 2109 if(wantNextChars || (response[5] != '0')) {
jmitc91516 1:a5258871b33d 2110 current[index++] = response[5];
jmitc91516 1:a5258871b33d 2111 wantNextChars = true;
jmitc91516 1:a5258871b33d 2112 }
jmitc91516 1:a5258871b33d 2113 if(wantNextChars || (response[6] != '0')) {
jmitc91516 1:a5258871b33d 2114 current[index++] = response[6];
jmitc91516 1:a5258871b33d 2115 }
jmitc91516 1:a5258871b33d 2116 // If the value is zero, make sure we return "0" -
jmitc91516 1:a5258871b33d 2117 // we just don't want any zeroes before that
jmitc91516 1:a5258871b33d 2118 current[index++] = response[7];
jmitc91516 1:a5258871b33d 2119 }
jmitc91516 1:a5258871b33d 2120 current[index] = '\0';
jmitc91516 1:a5258871b33d 2121 }
jmitc91516 1:a5258871b33d 2122
jmitc91516 1:a5258871b33d 2123 /*
jmitc91516 1:a5258871b33d 2124 Gets the range for an FPD detector, and returns it as a null-terminated string.
jmitc91516 1:a5258871b33d 2125
jmitc91516 1:a5258871b33d 2126 Note also that this code is intended to be as efficient as possible.
jmitc91516 1:a5258871b33d 2127
jmitc91516 1:a5258871b33d 2128 Args: pointer to the buffer to contain the current, as a null-terminated string
jmitc91516 1:a5258871b33d 2129
jmitc91516 1:a5258871b33d 2130 No return code.
jmitc91516 1:a5258871b33d 2131
jmitc91516 1:a5258871b33d 2132 *** This detector type now seems to have the same "Get Range" command as all other types ***
jmitc91516 1:a5258871b33d 2133 *** i.e. "GRNG" - so this function is not currently used ***
jmitc91516 1:a5258871b33d 2134 */
jmitc91516 1:a5258871b33d 2135 void GetGCStatusLoop::GetFPDDetectorRange(char *range)
jmitc91516 1:a5258871b33d 2136 {
jmitc91516 1:a5258871b33d 2137 char response[50];
jmitc91516 1:a5258871b33d 2138 SetGCDeviceReport("GRN2", response);
jmitc91516 1:a5258871b33d 2139
jmitc91516 1:a5258871b33d 2140 // We expect a response like this: "DRNG0001" for x1, "DRNG0002" for x10, "DRNG0003" for x100
jmitc91516 1:a5258871b33d 2141 int index = 0;
jmitc91516 1:a5258871b33d 2142 // But check for "EPKT" first
jmitc91516 1:a5258871b33d 2143 if(response[0] == 'E') {
jmitc91516 1:a5258871b33d 2144 range[index++] = '*';
jmitc91516 1:a5258871b33d 2145 range[index++] = '*';
jmitc91516 1:a5258871b33d 2146 range[index++] = ' ';
jmitc91516 1:a5258871b33d 2147 range[index++] = 'E';
jmitc91516 1:a5258871b33d 2148 range[index++] = 'r';
jmitc91516 1:a5258871b33d 2149 range[index++] = 'r';
jmitc91516 1:a5258871b33d 2150 range[index++] = 'o';
jmitc91516 1:a5258871b33d 2151 range[index++] = 'r';
jmitc91516 1:a5258871b33d 2152 range[index++] = ' ';
jmitc91516 1:a5258871b33d 2153 range[index++] = '*';
jmitc91516 1:a5258871b33d 2154 range[index++] = '*';
jmitc91516 1:a5258871b33d 2155 } else {
jmitc91516 1:a5258871b33d 2156 switch(response[7]) {
jmitc91516 1:a5258871b33d 2157 case '1':
jmitc91516 1:a5258871b33d 2158 range[index++] = 'x';
jmitc91516 1:a5258871b33d 2159 range[index++] = '1';
jmitc91516 1:a5258871b33d 2160 break;
jmitc91516 1:a5258871b33d 2161 case '2':
jmitc91516 1:a5258871b33d 2162 range[index++] = 'x';
jmitc91516 1:a5258871b33d 2163 range[index++] = '1';
jmitc91516 1:a5258871b33d 2164 range[index++] = '0';
jmitc91516 1:a5258871b33d 2165 break;
jmitc91516 1:a5258871b33d 2166 case '3':
jmitc91516 1:a5258871b33d 2167 range[index++] = 'x';
jmitc91516 1:a5258871b33d 2168 range[index++] = '1';
jmitc91516 1:a5258871b33d 2169 range[index++] = '0';
jmitc91516 1:a5258871b33d 2170 range[index++] = '0';
jmitc91516 1:a5258871b33d 2171 break;
jmitc91516 1:a5258871b33d 2172 default:
jmitc91516 1:a5258871b33d 2173 range[index++] = 'i';
jmitc91516 1:a5258871b33d 2174 range[index++] = 'n';
jmitc91516 1:a5258871b33d 2175 range[index++] = 'v';
jmitc91516 1:a5258871b33d 2176 range[index++] = 'a';
jmitc91516 1:a5258871b33d 2177 range[index++] = 'l';
jmitc91516 1:a5258871b33d 2178 range[index++] = 'd';
jmitc91516 1:a5258871b33d 2179 range[index++] = 'd';
jmitc91516 1:a5258871b33d 2180 break;
jmitc91516 1:a5258871b33d 2181 }
jmitc91516 1:a5258871b33d 2182 }
jmitc91516 1:a5258871b33d 2183 range[index] = '\0';
jmitc91516 1:a5258871b33d 2184 }
jmitc91516 1:a5258871b33d 2185
jmitc91516 1:a5258871b33d 2186 /*
jmitc91516 1:a5258871b33d 2187 Gets the current for an ECD detector, and returns it as a null-terminated string.
jmitc91516 1:a5258871b33d 2188
jmitc91516 1:a5258871b33d 2189 Note also that this code is intended to be as efficient as possible.
jmitc91516 1:a5258871b33d 2190
jmitc91516 1:a5258871b33d 2191 Args: pointer to the buffer to contain the current, as a null-terminated string
jmitc91516 1:a5258871b33d 2192
jmitc91516 1:a5258871b33d 2193 No return code.
jmitc91516 1:a5258871b33d 2194 */
jmitc91516 1:a5258871b33d 2195 void GetGCStatusLoop::GetFPDDetectorSensitivity(char *sensitivity)
jmitc91516 1:a5258871b33d 2196 {
jmitc91516 1:a5258871b33d 2197 char response[50];
jmitc91516 1:a5258871b33d 2198 SetGCDeviceReport("GSEN", response);
jmitc91516 1:a5258871b33d 2199
jmitc91516 1:a5258871b33d 2200 // We expect a response like this: "DSENnnnn", where 'nnnn' is the sensitivity.
jmitc91516 1:a5258871b33d 2201 // TODO: perform appropriate interpretation on the value 'nnnn'.
jmitc91516 1:a5258871b33d 2202 // Currently, we just return it unchanged
jmitc91516 1:a5258871b33d 2203
jmitc91516 1:a5258871b33d 2204 int index = 0;
jmitc91516 1:a5258871b33d 2205 // Check for "EPKT" first
jmitc91516 1:a5258871b33d 2206 if(response[0] == 'E') {
jmitc91516 1:a5258871b33d 2207 sensitivity[index++] = '*';
jmitc91516 1:a5258871b33d 2208 sensitivity[index++] = '*';
jmitc91516 1:a5258871b33d 2209 sensitivity[index++] = ' ';
jmitc91516 1:a5258871b33d 2210 sensitivity[index++] = 'E';
jmitc91516 1:a5258871b33d 2211 sensitivity[index++] = 'r';
jmitc91516 1:a5258871b33d 2212 sensitivity[index++] = 'r';
jmitc91516 1:a5258871b33d 2213 sensitivity[index++] = 'o';
jmitc91516 1:a5258871b33d 2214 sensitivity[index++] = 'r';
jmitc91516 1:a5258871b33d 2215 sensitivity[index++] = ' ';
jmitc91516 1:a5258871b33d 2216 sensitivity[index++] = '*';
jmitc91516 1:a5258871b33d 2217 sensitivity[index++] = '*';
jmitc91516 1:a5258871b33d 2218 } else {
jmitc91516 1:a5258871b33d 2219 // Ignore leading zeroes
jmitc91516 1:a5258871b33d 2220 bool wantNextChars = false;
jmitc91516 1:a5258871b33d 2221 if(response[4] != '0') {
jmitc91516 1:a5258871b33d 2222 sensitivity[index++] = response[4];
jmitc91516 1:a5258871b33d 2223 wantNextChars = true;
jmitc91516 1:a5258871b33d 2224 }
jmitc91516 1:a5258871b33d 2225 if(wantNextChars || (response[5] != '0')) {
jmitc91516 1:a5258871b33d 2226 sensitivity[index++] = response[5];
jmitc91516 1:a5258871b33d 2227 wantNextChars = true;
jmitc91516 1:a5258871b33d 2228 }
jmitc91516 1:a5258871b33d 2229 if(wantNextChars || (response[6] != '0')) {
jmitc91516 1:a5258871b33d 2230 sensitivity[index++] = response[6];
jmitc91516 1:a5258871b33d 2231 }
jmitc91516 1:a5258871b33d 2232 // If the value is zero, make sure we return "0" -
jmitc91516 1:a5258871b33d 2233 // we just don't want any zeroes before that
jmitc91516 1:a5258871b33d 2234 sensitivity[index++] = response[7];
jmitc91516 1:a5258871b33d 2235 }
jmitc91516 1:a5258871b33d 2236 sensitivity[index] = '\0';
jmitc91516 1:a5258871b33d 2237 }
jmitc91516 1:a5258871b33d 2238
jmitc91516 1:a5258871b33d 2239 /*
jmitc91516 1:a5258871b33d 2240 Gets the injector temperature, returning it as a null-terminated string, with a descriptive prefix.
jmitc91516 1:a5258871b33d 2241
jmitc91516 1:a5258871b33d 2242 Args: pointer to a buffer to contain the null-terminated string specifying the temperature.
jmitc91516 1:a5258871b33d 2243
jmitc91516 1:a5258871b33d 2244 No return code.
jmitc91516 1:a5258871b33d 2245 */
jmitc91516 1:a5258871b33d 2246 void GetGCStatusLoop::GetInjectorTemperature(char *temp, bool wantPrefix)
jmitc91516 1:a5258871b33d 2247 {
jmitc91516 1:a5258871b33d 2248 GetComponentTemperature("QINJ", temp, wantPrefix, true);
jmitc91516 1:a5258871b33d 2249 }
jmitc91516 1:a5258871b33d 2250
jmitc91516 1:a5258871b33d 2251 /*
jmitc91516 1:a5258871b33d 2252 Gets the injector temperature, returning it as a floating-point value.
jmitc91516 1:a5258871b33d 2253
jmitc91516 1:a5258871b33d 2254 Args: pointer to a floating point variable to contain the temperature
jmitc91516 1:a5258871b33d 2255
jmitc91516 1:a5258871b33d 2256 No return code.
jmitc91516 1:a5258871b33d 2257 */
jmitc91516 0:47c880c1463d 2258 void GetGCStatusLoop::GetInjectorTemperature(float *temp)
jmitc91516 0:47c880c1463d 2259 {
jmitc91516 0:47c880c1463d 2260 GetComponentTemperature("QINJ", temp);
jmitc91516 0:47c880c1463d 2261 }
jmitc91516 0:47c880c1463d 2262
jmitc91516 1:a5258871b33d 2263 /*
jmitc91516 1:a5258871b33d 2264 Gets the target injector temperature, returning it as a null-terminated string
jmitc91516 1:a5258871b33d 2265
jmitc91516 1:a5258871b33d 2266 Args: pointer to a buffer to contain the null-terminated string specifying the temperature.
jmitc91516 1:a5258871b33d 2267 pointer to a string specifying the sprintf format string to use
jmitc91516 1:a5258871b33d 2268
jmitc91516 1:a5258871b33d 2269 No return code.
jmitc91516 1:a5258871b33d 2270 */
jmitc91516 6:dba3fbdfd5da 2271 void GetGCStatusLoop::GetInjectorTargetTemperature(char *temp, const char *format)
jmitc91516 1:a5258871b33d 2272 {
jmitc91516 1:a5258871b33d 2273 char buff[40];
jmitc91516 1:a5258871b33d 2274 GetComponentTemperature("GINJ", buff, false, false, false); // Target temperature is in whole degrees, not one-tenth
jmitc91516 1:a5258871b33d 2275
jmitc91516 1:a5258871b33d 2276 sprintf(temp, format, buff);
jmitc91516 1:a5258871b33d 2277 }
jmitc91516 1:a5258871b33d 2278
jmitc91516 1:a5258871b33d 2279 /*
jmitc91516 1:a5258871b33d 2280 Gets a pressure value using the specified command, and returns it as a null-terminated string, with a descriptive prefix.
jmitc91516 1:a5258871b33d 2281
jmitc91516 1:a5258871b33d 2282 Note also that this code is intended to be as efficient as possible.
jmitc91516 1:a5258871b33d 2283
jmitc91516 1:a5258871b33d 2284 Args: pointer to the buffer to contain the pressure, as a null-terminated string
jmitc91516 1:a5258871b33d 2285
jmitc91516 1:a5258871b33d 2286 No return code.
jmitc91516 1:a5258871b33d 2287 */
jmitc91516 1:a5258871b33d 2288 void GetGCStatusLoop::GetPressure(char *cmd, char *press, bool wantPrefix, bool wantUnits)
jmitc91516 0:47c880c1463d 2289 {
jmitc91516 0:47c880c1463d 2290 char response[50];
jmitc91516 1:a5258871b33d 2291 SetGCDeviceReport(cmd, response);
jmitc91516 0:47c880c1463d 2292 // We expect a response like this: "DPRS1234" - pressure in units of 0.1 psi
jmitc91516 1:a5258871b33d 2293
jmitc91516 1:a5258871b33d 2294 int index = 0;
jmitc91516 1:a5258871b33d 2295
jmitc91516 1:a5258871b33d 2296 if(wantPrefix) {
jmitc91516 1:a5258871b33d 2297 press[index++] = 'P';
jmitc91516 1:a5258871b33d 2298 press[index++] = 'r';
jmitc91516 1:a5258871b33d 2299 press[index++] = 'e';
jmitc91516 1:a5258871b33d 2300 press[index++] = 's';
jmitc91516 1:a5258871b33d 2301 press[index++] = 's';
jmitc91516 1:a5258871b33d 2302 press[index++] = 'u';
jmitc91516 1:a5258871b33d 2303 press[index++] = 'r';
jmitc91516 1:a5258871b33d 2304 press[index++] = 'e';
jmitc91516 1:a5258871b33d 2305 press[index++] = ':';
jmitc91516 1:a5258871b33d 2306 press[index++] = ' ';
jmitc91516 1:a5258871b33d 2307 }
jmitc91516 1:a5258871b33d 2308
jmitc91516 0:47c880c1463d 2309 // But check for "EPKT" first
jmitc91516 0:47c880c1463d 2310 if(response[0] == 'E') {
jmitc91516 1:a5258871b33d 2311 press[index++] = '*';
jmitc91516 1:a5258871b33d 2312 press[index++] = '*';
jmitc91516 1:a5258871b33d 2313 press[index++] = ' ';
jmitc91516 1:a5258871b33d 2314 press[index++] = 'E';
jmitc91516 1:a5258871b33d 2315 press[index++] = 'r';
jmitc91516 1:a5258871b33d 2316 press[index++] = 'r';
jmitc91516 1:a5258871b33d 2317 press[index++] = 'o';
jmitc91516 1:a5258871b33d 2318 press[index++] = 'r';
jmitc91516 1:a5258871b33d 2319 press[index++] = ' ';
jmitc91516 1:a5258871b33d 2320 press[index++] = '*';
jmitc91516 1:a5258871b33d 2321 press[index++] = '*';
jmitc91516 0:47c880c1463d 2322 } else {
jmitc91516 1:a5258871b33d 2323 bool wantNextChars = false;
jmitc91516 1:a5258871b33d 2324 if(response[4] != '0') {
jmitc91516 1:a5258871b33d 2325 press[index++] = response[4];
jmitc91516 1:a5258871b33d 2326 wantNextChars = true;
jmitc91516 1:a5258871b33d 2327 }
jmitc91516 1:a5258871b33d 2328 if(wantNextChars || (response[5] != '0')) {
jmitc91516 1:a5258871b33d 2329 press[index++] = response[5];
jmitc91516 1:a5258871b33d 2330 }
jmitc91516 1:a5258871b33d 2331 // If the value is zero, make sure we return "0.0" -
jmitc91516 1:a5258871b33d 2332 // we just don't want any zeroes before that
jmitc91516 1:a5258871b33d 2333 press[index++] = response[6];
jmitc91516 1:a5258871b33d 2334 press[index++] = '.';
jmitc91516 1:a5258871b33d 2335 press[index++] = response[7];
jmitc91516 1:a5258871b33d 2336
jmitc91516 1:a5258871b33d 2337 if(wantUnits) {
jmitc91516 1:a5258871b33d 2338 press[index++] = ' ';
jmitc91516 1:a5258871b33d 2339 press[index++] = 'p';
jmitc91516 1:a5258871b33d 2340 press[index++] = 's';
jmitc91516 1:a5258871b33d 2341 press[index++] = 'i';
jmitc91516 1:a5258871b33d 2342 }
jmitc91516 1:a5258871b33d 2343 }
jmitc91516 1:a5258871b33d 2344
jmitc91516 1:a5258871b33d 2345 press[index++] = '\0';
jmitc91516 1:a5258871b33d 2346 }
jmitc91516 1:a5258871b33d 2347
jmitc91516 1:a5258871b33d 2348 /*
jmitc91516 1:a5258871b33d 2349 Gets the gas pressure, and returns it as a null-terminated string, with a descriptive prefix.
jmitc91516 1:a5258871b33d 2350
jmitc91516 1:a5258871b33d 2351 Args: pointer to the buffer to contain the gas pressure, as a null-terminated string
jmitc91516 1:a5258871b33d 2352
jmitc91516 1:a5258871b33d 2353 No return code.
jmitc91516 1:a5258871b33d 2354 */
jmitc91516 1:a5258871b33d 2355 void GetGCStatusLoop::GetGasPressure(char *press, bool wantPrefix, bool wantUnits)
jmitc91516 1:a5258871b33d 2356 {
jmitc91516 1:a5258871b33d 2357 // GetPressure("QPRS", press, wantPrefix, wantUnits);
jmitc91516 1:a5258871b33d 2358 // Use GPRS command, not QPRS - it gets the initial pressure specified as part of the current method, which is what we want
jmitc91516 1:a5258871b33d 2359 GetPressure("GPRS", press, wantPrefix, wantUnits);
jmitc91516 1:a5258871b33d 2360 }
jmitc91516 1:a5258871b33d 2361
jmitc91516 1:a5258871b33d 2362 /*
jmitc91516 1:a5258871b33d 2363 Gets the actual, current, gas pressure (as opposed to the initial pressure specified in the current method),
jmitc91516 1:a5258871b33d 2364 and returns it as a null-terminated string, with a descriptive prefix if required.
jmitc91516 1:a5258871b33d 2365
jmitc91516 1:a5258871b33d 2366 Args: pointer to the buffer to contain the current gas pressure, as a null-terminated string
jmitc91516 1:a5258871b33d 2367
jmitc91516 1:a5258871b33d 2368 No return code.
jmitc91516 1:a5258871b33d 2369 */
jmitc91516 1:a5258871b33d 2370 void GetGCStatusLoop::GetCurrentGasPressure(char *press, bool wantPrefix, bool wantUnits)
jmitc91516 1:a5258871b33d 2371 {
jmitc91516 1:a5258871b33d 2372 GetPressure("QPRS", press, wantPrefix, wantUnits); // QPRS - get current pressure - not GPRS
jmitc91516 1:a5258871b33d 2373 }
jmitc91516 1:a5258871b33d 2374
jmitc91516 1:a5258871b33d 2375 /*
jmitc91516 1:a5258871b33d 2376 Gets the pulsed pressure, and returns it as a null-terminated string, with a descriptive prefix.
jmitc91516 1:a5258871b33d 2377
jmitc91516 1:a5258871b33d 2378 Args: pointer to the buffer to contain the pulsed pressure, as a null-terminated string
jmitc91516 1:a5258871b33d 2379
jmitc91516 1:a5258871b33d 2380 No return code.
jmitc91516 1:a5258871b33d 2381 */
jmitc91516 1:a5258871b33d 2382 void GetGCStatusLoop::GetGasPulsedPressure(char *pulsedPress)
jmitc91516 1:a5258871b33d 2383 {
jmitc91516 1:a5258871b33d 2384 GetPressure("GPPS", pulsedPress, false, true);
jmitc91516 1:a5258871b33d 2385 }
jmitc91516 1:a5258871b33d 2386
jmitc91516 1:a5258871b33d 2387 /*
jmitc91516 1:a5258871b33d 2388 Gets the gas pressure, returning it as a floating-point value.
jmitc91516 1:a5258871b33d 2389
jmitc91516 1:a5258871b33d 2390 Args: pointer to a floating point variable to be set to the pressure
jmitc91516 1:a5258871b33d 2391
jmitc91516 1:a5258871b33d 2392 No return code.
jmitc91516 1:a5258871b33d 2393 */
jmitc91516 0:47c880c1463d 2394 void GetGCStatusLoop::GetGasPressure(float *press)
jmitc91516 0:47c880c1463d 2395 {
jmitc91516 0:47c880c1463d 2396 char buff[100];
jmitc91516 1:a5258871b33d 2397 char response[50];
jmitc91516 1:a5258871b33d 2398 // SetGCDeviceReport("QPRS", response);
jmitc91516 1:a5258871b33d 2399 // Use GPRS command, not QPRS - it gets the initial pressure specified as part of the current method, which is what we want
jmitc91516 1:a5258871b33d 2400 SetGCDeviceReport("GPRS", response);
jmitc91516 1:a5258871b33d 2401 // We expect a response like this: "DPRS1234" - pressure in units of 0.1 psi
jmitc91516 1:a5258871b33d 2402
jmitc91516 1:a5258871b33d 2403 // Allow for "EPKT" being returned from GC
jmitc91516 1:a5258871b33d 2404 if(response[0] == 'E') {
jmitc91516 0:47c880c1463d 2405 *press = -1.0f; // ** Caller must check for this **
jmitc91516 0:47c880c1463d 2406 } else {
jmitc91516 1:a5258871b33d 2407 buff[0] = response[4];
jmitc91516 1:a5258871b33d 2408 buff[1] = response[5];
jmitc91516 1:a5258871b33d 2409 buff[2] = response[6];
jmitc91516 1:a5258871b33d 2410 buff[3] = '.';
jmitc91516 1:a5258871b33d 2411 buff[4] = response[7];
jmitc91516 1:a5258871b33d 2412
jmitc91516 1:a5258871b33d 2413 sscanf(buff, "%f", press);
jmitc91516 0:47c880c1463d 2414 }
jmitc91516 0:47c880c1463d 2415 //#define DEBUG_HERE
jmitc91516 0:47c880c1463d 2416 #ifdef DEBUG_HERE
jmitc91516 0:47c880c1463d 2417 char dbg[100];
jmitc91516 0:47c880c1463d 2418 sprintf(dbg, "GGCSL::GGP - returning : %f", *press);
jmitc91516 1:a5258871b33d 2419 EasyGUIDebugPrint(dbg, 0, 20);
jmitc91516 0:47c880c1463d 2420 #endif
jmitc91516 0:47c880c1463d 2421 //#undef DEBUG_HERE
jmitc91516 0:47c880c1463d 2422 }
jmitc91516 0:47c880c1463d 2423
jmitc91516 1:a5258871b33d 2424 /*
jmitc91516 1:a5258871b33d 2425 Redraw one easyGUI variable on its component page.
jmitc91516 1:a5258871b33d 2426
jmitc91516 1:a5258871b33d 2427 (Trying to reduce "display flickering" by not redrawing the entire page unnecessarily).
jmitc91516 1:a5258871b33d 2428
jmitc91516 1:a5258871b33d 2429 Note that the font must match the one specified in the easyGUI project for this variable -
jmitc91516 1:a5258871b33d 2430 we cannot obtain this at runtime.
jmitc91516 1:a5258871b33d 2431 */
jmitc91516 1:a5258871b33d 2432 void GetGCStatusLoop::RedrawSingleEasyGUIVariableOnComponentPage(GuiConst_INT16S X, GuiConst_INT16S Y, void *varPtr, GuiConst_INT8U alignment, GCComponent gcComponent)
jmitc91516 1:a5258871b33d 2433 {
jmitc91516 1:a5258871b33d 2434 GuiLib_DrawVar(
jmitc91516 1:a5258871b33d 2435 X, // GuiConst_INT16S X,
jmitc91516 1:a5258871b33d 2436 Y, // GuiConst_INT16S Y,
jmitc91516 1:a5258871b33d 2437 GuiFont_Helv20Bold, // GuiConst_INT16U FontNo,
jmitc91516 1:a5258871b33d 2438 varPtr, // void PrefixLocate *VarPtr,
jmitc91516 1:a5258871b33d 2439 GuiLib_VAR_STRING, // GuiConst_INT8U VarType,
jmitc91516 1:a5258871b33d 2440 GuiLib_FORMAT_DEC, // GuiConst_INT8U FormatterFormat,
jmitc91516 1:a5258871b33d 2441 10, // GuiConst_INT8U FormatterFieldWidth,
jmitc91516 1:a5258871b33d 2442 GuiLib_FORMAT_ALIGNMENT_RIGHT, // GuiConst_INT8U FormatterAlignment,
jmitc91516 1:a5258871b33d 2443 0, // GuiConst_INT8U FormatterDecimals,
jmitc91516 1:a5258871b33d 2444 0, // GuiConst_INT8U FormatterShowSign,
jmitc91516 1:a5258871b33d 2445 0, // GuiConst_INT8U FormatterZeroPadding,
jmitc91516 1:a5258871b33d 2446 0, // GuiConst_INT8U FormatterTrailingZeros,
jmitc91516 1:a5258871b33d 2447 0, // GuiConst_INT8U FormatterThousandsSeparator,
jmitc91516 1:a5258871b33d 2448 alignment, // GuiConst_INT8U Alignment,
jmitc91516 1:a5258871b33d 2449 GuiLib_PS_ON, // GuiConst_INT8U PsWriting,
jmitc91516 1:a5258871b33d 2450 GuiLib_TRANSPARENT_OFF, // GuiConst_INT8U Transparent,
jmitc91516 1:a5258871b33d 2451 GuiLib_UNDERLINE_OFF, // GuiConst_INT8U Underlining,
jmitc91516 1:a5258871b33d 2452 200, // GuiConst_INT16S BackBoxSizeX,
jmitc91516 1:a5258871b33d 2453 0, // GuiConst_INT16S BackBoxSizeY1,
jmitc91516 1:a5258871b33d 2454 0, // GuiConst_INT16S BackBoxSizeY2,
jmitc91516 1:a5258871b33d 2455 GuiLib_BBP_NONE, // GuiConst_INT8U BackBorderPixels,
jmitc91516 1:a5258871b33d 2456 0, // GuiConst_INTCOLOR ForeColor, [Black]
jmitc91516 1:a5258871b33d 2457 homePageGCComponentStatusColorAreas->GetComponentCurrentColor(gcComponent) // GuiConst_INTCOLOR BackColor [same as status rectangle]
jmitc91516 1:a5258871b33d 2458 );
jmitc91516 1:a5258871b33d 2459 }
jmitc91516 1:a5258871b33d 2460
jmitc91516 1:a5258871b33d 2461 /*
jmitc91516 1:a5258871b33d 2462 Redraw one easyGUI variable on the home page. Unlike the single component pages (as of 13 Mar 2017),
jmitc91516 1:a5258871b33d 2463 we no longer have component status rectangles on the Home page.
jmitc91516 1:a5258871b33d 2464
jmitc91516 1:a5258871b33d 2465 (Trying to reduce "display flickering" by not redrawing the entire page unnecessarily).
jmitc91516 1:a5258871b33d 2466
jmitc91516 1:a5258871b33d 2467 Note that the font must match the one specified in the easyGUI project for this variable -
jmitc91516 1:a5258871b33d 2468 we cannot obtain this at runtime.
jmitc91516 1:a5258871b33d 2469 */
jmitc91516 1:a5258871b33d 2470 void GetGCStatusLoop::RedrawSingleEasyGUIVariableOnHomePage(GuiConst_INT16S X, GuiConst_INT16S Y, void *varPtr, GuiConst_INT8U alignment)
jmitc91516 1:a5258871b33d 2471 {
jmitc91516 1:a5258871b33d 2472 GuiLib_DrawVar(
jmitc91516 1:a5258871b33d 2473 X, // GuiConst_INT16S X,
jmitc91516 1:a5258871b33d 2474 Y, // GuiConst_INT16S Y,
jmitc91516 1:a5258871b33d 2475 GuiFont_Helv20Bold, // GuiConst_INT16U FontNo,
jmitc91516 1:a5258871b33d 2476 varPtr, // void PrefixLocate *VarPtr,
jmitc91516 1:a5258871b33d 2477 GuiLib_VAR_STRING, // GuiConst_INT8U VarType,
jmitc91516 1:a5258871b33d 2478 GuiLib_FORMAT_DEC, // GuiConst_INT8U FormatterFormat,
jmitc91516 1:a5258871b33d 2479 10, // GuiConst_INT8U FormatterFieldWidth,
jmitc91516 1:a5258871b33d 2480 GuiLib_FORMAT_ALIGNMENT_RIGHT, // GuiConst_INT8U FormatterAlignment,
jmitc91516 1:a5258871b33d 2481 0, // GuiConst_INT8U FormatterDecimals,
jmitc91516 1:a5258871b33d 2482 0, // GuiConst_INT8U FormatterShowSign,
jmitc91516 1:a5258871b33d 2483 0, // GuiConst_INT8U FormatterZeroPadding,
jmitc91516 1:a5258871b33d 2484 0, // GuiConst_INT8U FormatterTrailingZeros,
jmitc91516 1:a5258871b33d 2485 0, // GuiConst_INT8U FormatterThousandsSeparator,
jmitc91516 1:a5258871b33d 2486 alignment, // GuiConst_INT8U Alignment,
jmitc91516 1:a5258871b33d 2487 GuiLib_PS_ON, // GuiConst_INT8U PsWriting,
jmitc91516 1:a5258871b33d 2488 GuiLib_TRANSPARENT_ON, // GuiConst_INT8U Transparent,
jmitc91516 1:a5258871b33d 2489 GuiLib_UNDERLINE_OFF, // GuiConst_INT8U Underlining,
jmitc91516 1:a5258871b33d 2490 200, // GuiConst_INT16S BackBoxSizeX,
jmitc91516 1:a5258871b33d 2491 0, // GuiConst_INT16S BackBoxSizeY1,
jmitc91516 1:a5258871b33d 2492 0, // GuiConst_INT16S BackBoxSizeY2,
jmitc91516 1:a5258871b33d 2493 GuiLib_BBP_NONE, // GuiConst_INT8U BackBorderPixels,
jmitc91516 1:a5258871b33d 2494 0, // GuiConst_INTCOLOR ForeColor, [Black]
jmitc91516 1:a5258871b33d 2495 0xFFFF // GuiConst_INTCOLOR BackColor [White]
jmitc91516 1:a5258871b33d 2496 );
jmitc91516 1:a5258871b33d 2497 }
jmitc91516 1:a5258871b33d 2498
jmitc91516 1:a5258871b33d 2499 /*
jmitc91516 1:a5258871b33d 2500 If the column temperature has changed on the home page,
jmitc91516 1:a5258871b33d 2501 redraw it manually - do not redisplay the entire page just for this
jmitc91516 1:a5258871b33d 2502 (trying to reduce "flashing and banging")
jmitc91516 1:a5258871b33d 2503 */
jmitc91516 1:a5258871b33d 2504 void GetGCStatusLoop::DrawColumnTemperatureVariableOnHomePage(void)
jmitc91516 1:a5258871b33d 2505 {
jmitc91516 1:a5258871b33d 2506 // Hard coded values taken from easyGUI
jmitc91516 1:a5258871b33d 2507 // RedrawSingleEasyGUIVariableOnComponentPage(180, 140, &GuiVar_columnTemperature2, GuiLib_ALIGN_CENTER, COLUMN);
jmitc91516 1:a5258871b33d 2508 RedrawSingleEasyGUIVariableOnHomePage(260, 100, &GuiVar_columnTemperature2, GuiLib_ALIGN_CENTER);
jmitc91516 1:a5258871b33d 2509 }
jmitc91516 1:a5258871b33d 2510
jmitc91516 1:a5258871b33d 2511 /*
jmitc91516 1:a5258871b33d 2512 If the column target temperature has changed on the home page,
jmitc91516 1:a5258871b33d 2513 redraw it manually - do not redisplay the entire page just for this
jmitc91516 1:a5258871b33d 2514 (trying to reduce "flashing and banging")
jmitc91516 1:a5258871b33d 2515 */
jmitc91516 1:a5258871b33d 2516 void GetGCStatusLoop::DrawColumnTargetTemperatureVariableOnHomePage(void)
jmitc91516 1:a5258871b33d 2517 {
jmitc91516 1:a5258871b33d 2518 // Hard coded values taken from easyGUI
jmitc91516 1:a5258871b33d 2519 RedrawSingleEasyGUIVariableOnHomePage(260, 140, &GuiVar_columnTargetTemperature, GuiLib_ALIGN_CENTER);
jmitc91516 1:a5258871b33d 2520 }
jmitc91516 1:a5258871b33d 2521
jmitc91516 1:a5258871b33d 2522 /*
jmitc91516 1:a5258871b33d 2523 If the injector temperature has changed on the home page,
jmitc91516 1:a5258871b33d 2524 redraw it manually - do not redisplay the entire page just for this
jmitc91516 1:a5258871b33d 2525 (trying to reduce "flashing and banging")
jmitc91516 1:a5258871b33d 2526 */
jmitc91516 1:a5258871b33d 2527 void GetGCStatusLoop::DrawInjectorTemperatureVariableOnHomePage(void)
jmitc91516 1:a5258871b33d 2528 {
jmitc91516 1:a5258871b33d 2529 // Hard coded values taken from easyGUI
jmitc91516 1:a5258871b33d 2530 // RedrawSingleEasyGUIVariableOnComponentPage(590, 140, &GuiVar_injectorTemperature2, GuiLib_ALIGN_CENTER, INJECTOR);
jmitc91516 1:a5258871b33d 2531 RedrawSingleEasyGUIVariableOnHomePage(260, 300, &GuiVar_injectorTemperature2, GuiLib_ALIGN_CENTER);
jmitc91516 1:a5258871b33d 2532 }
jmitc91516 1:a5258871b33d 2533
jmitc91516 1:a5258871b33d 2534 /*
jmitc91516 1:a5258871b33d 2535 If the injector target temperature has changed on the home page,
jmitc91516 1:a5258871b33d 2536 redraw it manually - do not redisplay the entire page just for this
jmitc91516 1:a5258871b33d 2537 (trying to reduce "flashing and banging")
jmitc91516 1:a5258871b33d 2538 */
jmitc91516 1:a5258871b33d 2539 void GetGCStatusLoop::DrawInjectorTargetTemperatureVariableOnHomePage(void)
jmitc91516 1:a5258871b33d 2540 {
jmitc91516 1:a5258871b33d 2541 // Hard coded values taken from easyGUI
jmitc91516 1:a5258871b33d 2542 RedrawSingleEasyGUIVariableOnHomePage(260, 340, &GuiVar_injectorTargetTemperature, GuiLib_ALIGN_CENTER);
jmitc91516 1:a5258871b33d 2543 }
jmitc91516 1:a5258871b33d 2544
jmitc91516 1:a5258871b33d 2545 /*
jmitc91516 1:a5258871b33d 2546 If the detector temperature has changed on the home page,
jmitc91516 1:a5258871b33d 2547 redraw it manually - do not redisplay the entire page just for this
jmitc91516 1:a5258871b33d 2548 (trying to reduce "flashing and banging")
jmitc91516 1:a5258871b33d 2549 */
jmitc91516 1:a5258871b33d 2550 void GetGCStatusLoop::DrawDetectorTemperatureVariableOnHomePage(void)
jmitc91516 1:a5258871b33d 2551 {
jmitc91516 1:a5258871b33d 2552 // Hard coded values taken from easyGUI
jmitc91516 1:a5258871b33d 2553 // RedrawSingleEasyGUIVariableOnComponentPage(190, 340, &GuiVar_detectorTemperature2, GuiLib_ALIGN_LEFT, DETECTOR);
jmitc91516 1:a5258871b33d 2554 RedrawSingleEasyGUIVariableOnHomePage(520, 100, &GuiVar_detectorTemperature2, GuiLib_ALIGN_LEFT);
jmitc91516 1:a5258871b33d 2555 }
jmitc91516 1:a5258871b33d 2556
jmitc91516 1:a5258871b33d 2557 /*
jmitc91516 1:a5258871b33d 2558 If the detector target temperature has changed on the home page,
jmitc91516 1:a5258871b33d 2559 redraw it manually - do not redisplay the entire page just for this
jmitc91516 1:a5258871b33d 2560 (trying to reduce "flashing and banging")
jmitc91516 1:a5258871b33d 2561 */
jmitc91516 1:a5258871b33d 2562 void GetGCStatusLoop::DrawDetectorTargetTemperatureVariableOnHomePage(void)
jmitc91516 1:a5258871b33d 2563 {
jmitc91516 1:a5258871b33d 2564 // Hard coded values taken from easyGUI
jmitc91516 1:a5258871b33d 2565 RedrawSingleEasyGUIVariableOnHomePage(520, 140, &GuiVar_detectorTargetTemperature, GuiLib_ALIGN_LEFT);
jmitc91516 1:a5258871b33d 2566 }
jmitc91516 1:a5258871b33d 2567
jmitc91516 1:a5258871b33d 2568 /*
jmitc91516 1:a5258871b33d 2569 If the gas pressure has changed on the home page,
jmitc91516 1:a5258871b33d 2570 redraw it manually - do not redisplay the entire page just for this
jmitc91516 1:a5258871b33d 2571 (trying to reduce "flashing and banging")
jmitc91516 1:a5258871b33d 2572 */
jmitc91516 1:a5258871b33d 2573 void GetGCStatusLoop::DrawGasPressureVariableOnHomePage(void)
jmitc91516 1:a5258871b33d 2574 {
jmitc91516 1:a5258871b33d 2575 // Hard coded values taken from easyGUI
jmitc91516 1:a5258871b33d 2576 // RedrawSingleEasyGUIVariableOnComponentPage(590, 340, &GuiVar_gasPressure2, GuiLib_ALIGN_CENTER, GAS);
jmitc91516 1:a5258871b33d 2577 RedrawSingleEasyGUIVariableOnHomePage(520, 300, &GuiVar_gasPressure2, GuiLib_ALIGN_CENTER);
jmitc91516 1:a5258871b33d 2578 }
jmitc91516 1:a5258871b33d 2579
jmitc91516 1:a5258871b33d 2580 /*
jmitc91516 1:a5258871b33d 2581 If the gas target pressures have changed on the home page,
jmitc91516 1:a5258871b33d 2582 redraw it manually - do not redisplay the entire page just for this
jmitc91516 1:a5258871b33d 2583 (trying to reduce "flashing and banging")
jmitc91516 1:a5258871b33d 2584 */
jmitc91516 1:a5258871b33d 2585 void GetGCStatusLoop::DrawGasTargetPressureVariableOnHomePage(void)
jmitc91516 1:a5258871b33d 2586 {
jmitc91516 1:a5258871b33d 2587 // Hard coded values taken from easyGUI
jmitc91516 1:a5258871b33d 2588 RedrawSingleEasyGUIVariableOnHomePage(520, 340, &GuiVar_gasTargetPressure2, GuiLib_ALIGN_CENTER);
jmitc91516 1:a5258871b33d 2589 }
jmitc91516 1:a5258871b33d 2590
jmitc91516 1:a5258871b33d 2591 /*
jmitc91516 1:a5258871b33d 2592 If the gas target pressures have changed on the home page,
jmitc91516 1:a5258871b33d 2593 redraw it manually - do not redisplay the entire page just for this
jmitc91516 1:a5258871b33d 2594 (trying to reduce "flashing and banging")
jmitc91516 1:a5258871b33d 2595 */
jmitc91516 1:a5258871b33d 2596 void GetGCStatusLoop::DrawGCRealTimeClockVariableOnHomePage(void)
jmitc91516 1:a5258871b33d 2597 {
jmitc91516 1:a5258871b33d 2598 // Hard coded values taken from easyGUI
jmitc91516 1:a5258871b33d 2599
jmitc91516 1:a5258871b33d 2600 // Need to redraw background, to erase previous value of variable.
jmitc91516 1:a5258871b33d 2601 // I do not understand why the first coordinate pair in the call to GuiLib_ShowBitmapArea
jmitc91516 1:a5258871b33d 2602 // needs to be 0, 0 to display the correct part of the bitmap. I expected them to be the same
jmitc91516 1:a5258871b33d 2603 // as the second coordinate pair - but that caused the top left portion of the bitmap to be displayed,
jmitc91516 1:a5258871b33d 2604 // not the part where the variable actually is.
jmitc91516 1:a5258871b33d 2605 //(See also DrawBackgroundBitmapOverDoorLockAndReleaseButtons() in main.cpp)
jmitc91516 1:a5258871b33d 2606 GuiLib_ShowBitmapArea(GuiStruct_Bitmap_BlankBackground, 0, 0, 230, 428, 580, 460, -1); // -1 means 'no transparent colour'
jmitc91516 1:a5258871b33d 2607
jmitc91516 1:a5258871b33d 2608 RedrawSingleEasyGUIVariableOnHomePage(404, 450, &GuiVar_gcTimeOnHomePage, GuiLib_ALIGN_CENTER);
jmitc91516 1:a5258871b33d 2609 }
jmitc91516 1:a5258871b33d 2610
jmitc91516 1:a5258871b33d 2611 /*
jmitc91516 1:a5258871b33d 2612 We display both the gas initial pressure and pulsed pressure on the Home page,
jmitc91516 1:a5258871b33d 2613 in the same string. This function generates that string, in a consistent format.
jmitc91516 1:a5258871b33d 2614
jmitc91516 1:a5258871b33d 2615 Args: a pointer to the string to be updated
jmitc91516 1:a5258871b33d 2616
jmitc91516 1:a5258871b33d 2617 No return code
jmitc91516 1:a5258871b33d 2618 */
jmitc91516 1:a5258871b33d 2619 void GetGCStatusLoop::UpdateGasTargetPressuresOnHomePage(char *buffer)
jmitc91516 1:a5258871b33d 2620 {
jmitc91516 1:a5258871b33d 2621 char initialPressure[20];
jmitc91516 1:a5258871b33d 2622 char pulsedPressure[20];
jmitc91516 1:a5258871b33d 2623
jmitc91516 1:a5258871b33d 2624 GetPressure("GPRS", initialPressure, false, false);
jmitc91516 1:a5258871b33d 2625 GetPressure("GPPS", pulsedPressure, false, false);
jmitc91516 1:a5258871b33d 2626
jmitc91516 1:a5258871b33d 2627 sprintf(buffer, "(Target: %s/%s)", initialPressure, pulsedPressure);
jmitc91516 1:a5258871b33d 2628 }
jmitc91516 1:a5258871b33d 2629
jmitc91516 1:a5258871b33d 2630 /*
jmitc91516 1:a5258871b33d 2631 Displays the data on the home page, by copying it to the relevant easyGUI variables,
jmitc91516 1:a5258871b33d 2632 and calling the relevant functions to actually display it.
jmitc91516 1:a5258871b33d 2633
jmitc91516 1:a5258871b33d 2634 Args: a boolean specifying whether or not the display is actually to be updated.
jmitc91516 1:a5258871b33d 2635 Even if it is false when we are called, we may set it true if we discover
jmitc91516 1:a5258871b33d 2636 one or more data items has changed - but note that we will not set it false
jmitc91516 1:a5258871b33d 2637 if it is already true. If it is true after we have looked at all
jmitc91516 1:a5258871b33d 2638 the home page data, we will then update the display. (If we are called
jmitc91516 1:a5258871b33d 2639 with this value set to false, the caller is effectively saying
jmitc91516 1:a5258871b33d 2640 'display the home page data only if it has changed'.)
jmitc91516 1:a5258871b33d 2641
jmitc91516 1:a5258871b33d 2642 No return code.
jmitc91516 1:a5258871b33d 2643 */
jmitc91516 0:47c880c1463d 2644 void GetGCStatusLoop::DisplayHomePageData(bool mustUpdateDisplay)
jmitc91516 0:47c880c1463d 2645 {
jmitc91516 0:47c880c1463d 2646 // EasyGUIDebugPrint("Home Page", 100, 100);
jmitc91516 0:47c880c1463d 2647
jmitc91516 1:a5258871b33d 2648 #define DRAW_VARIABLES_INDIVIDUALLY
jmitc91516 0:47c880c1463d 2649 char buff[40];
jmitc91516 0:47c880c1463d 2650
jmitc91516 1:a5258871b33d 2651 if(GetColumnType() == DIRECTLY_HEATED_COLUMN) {
jmitc91516 1:a5258871b33d 2652 GetDirectlyHeatedColumnTemperature(buff, false);
jmitc91516 1:a5258871b33d 2653 } else {
jmitc91516 1:a5258871b33d 2654 GetColumnTemperature(buff, false);
jmitc91516 1:a5258871b33d 2655 }
jmitc91516 0:47c880c1463d 2656 if(strcmp(buff, GuiVar_columnTemperature2) != 0) {
jmitc91516 1:a5258871b33d 2657 strcpy(GuiVar_columnTemperature2, buff);
jmitc91516 1:a5258871b33d 2658 #ifdef DRAW_VARIABLES_INDIVIDUALLY
jmitc91516 1:a5258871b33d 2659 DrawColumnTemperatureVariableOnHomePage();
jmitc91516 1:a5258871b33d 2660 #else
jmitc91516 0:47c880c1463d 2661 mustUpdateDisplay = true;
jmitc91516 1:a5258871b33d 2662 #endif
jmitc91516 1:a5258871b33d 2663 }
jmitc91516 1:a5258871b33d 2664
jmitc91516 1:a5258871b33d 2665 GetColumnTargetTemperature(buff, "(Target: %s)");
jmitc91516 1:a5258871b33d 2666 if(strcmp(buff, GuiVar_columnTargetTemperature) != 0) {
jmitc91516 1:a5258871b33d 2667 strcpy(GuiVar_columnTargetTemperature, buff);
jmitc91516 1:a5258871b33d 2668 #ifdef DRAW_VARIABLES_INDIVIDUALLY
jmitc91516 1:a5258871b33d 2669 DrawColumnTargetTemperatureVariableOnHomePage();
jmitc91516 1:a5258871b33d 2670 #else
jmitc91516 1:a5258871b33d 2671 mustUpdateDisplay = true;
jmitc91516 1:a5258871b33d 2672 #endif
jmitc91516 1:a5258871b33d 2673 }
jmitc91516 1:a5258871b33d 2674
jmitc91516 1:a5258871b33d 2675 GetInjectorTemperature(buff, false);
jmitc91516 1:a5258871b33d 2676 if(strcmp(buff, GuiVar_injectorTemperature2) != 0) {
jmitc91516 1:a5258871b33d 2677 strcpy(GuiVar_injectorTemperature2, buff);
jmitc91516 1:a5258871b33d 2678 #ifdef DRAW_VARIABLES_INDIVIDUALLY
jmitc91516 1:a5258871b33d 2679 DrawInjectorTemperatureVariableOnHomePage();
jmitc91516 1:a5258871b33d 2680 #else
jmitc91516 1:a5258871b33d 2681 mustUpdateDisplay = true;
jmitc91516 1:a5258871b33d 2682 #endif
jmitc91516 1:a5258871b33d 2683 }
jmitc91516 1:a5258871b33d 2684
jmitc91516 1:a5258871b33d 2685 GetInjectorTargetTemperature(buff, "(Target: %s)");
jmitc91516 1:a5258871b33d 2686 if(strcmp(buff, GuiVar_injectorTargetTemperature) != 0) {
jmitc91516 1:a5258871b33d 2687 strcpy(GuiVar_injectorTargetTemperature, buff);
jmitc91516 1:a5258871b33d 2688 #ifdef DRAW_VARIABLES_INDIVIDUALLY
jmitc91516 1:a5258871b33d 2689 DrawInjectorTargetTemperatureVariableOnHomePage();
jmitc91516 1:a5258871b33d 2690 #else
jmitc91516 1:a5258871b33d 2691 mustUpdateDisplay = true;
jmitc91516 1:a5258871b33d 2692 #endif
jmitc91516 0:47c880c1463d 2693 }
jmitc91516 0:47c880c1463d 2694
jmitc91516 0:47c880c1463d 2695 GetDetectorTemperature(buff);
jmitc91516 0:47c880c1463d 2696 if(strcmp(buff, GuiVar_detectorTemperature2) != 0) {
jmitc91516 1:a5258871b33d 2697 strcpy(GuiVar_detectorTemperature2, buff);
jmitc91516 1:a5258871b33d 2698 #ifdef DRAW_VARIABLES_INDIVIDUALLY
jmitc91516 1:a5258871b33d 2699 DrawDetectorTemperatureVariableOnHomePage();
jmitc91516 1:a5258871b33d 2700 #else
jmitc91516 0:47c880c1463d 2701 mustUpdateDisplay = true;
jmitc91516 1:a5258871b33d 2702 #endif
jmitc91516 1:a5258871b33d 2703 }
jmitc91516 1:a5258871b33d 2704
jmitc91516 1:a5258871b33d 2705 GetDetectorTargetTemperature(buff, "(Target: %s)");
jmitc91516 1:a5258871b33d 2706 if(strcmp(buff, GuiVar_detectorTargetTemperature) != 0) {
jmitc91516 1:a5258871b33d 2707 strcpy(GuiVar_detectorTargetTemperature, buff);
jmitc91516 1:a5258871b33d 2708 #ifdef DRAW_VARIABLES_INDIVIDUALLY
jmitc91516 1:a5258871b33d 2709 DrawDetectorTargetTemperatureVariableOnHomePage();
jmitc91516 1:a5258871b33d 2710 #else
jmitc91516 1:a5258871b33d 2711 mustUpdateDisplay = true;
jmitc91516 1:a5258871b33d 2712 #endif
jmitc91516 1:a5258871b33d 2713 }
jmitc91516 1:a5258871b33d 2714
jmitc91516 1:a5258871b33d 2715 GetCurrentGasPressure(buff, false, true);
jmitc91516 1:a5258871b33d 2716 if(strcmp(buff, GuiVar_gasPressure2) != 0) {
jmitc91516 1:a5258871b33d 2717 strcpy(GuiVar_gasPressure2, buff);
jmitc91516 1:a5258871b33d 2718 #ifdef DRAW_VARIABLES_INDIVIDUALLY
jmitc91516 1:a5258871b33d 2719 DrawGasPressureVariableOnHomePage();
jmitc91516 1:a5258871b33d 2720 #else
jmitc91516 0:47c880c1463d 2721 mustUpdateDisplay = true;
jmitc91516 1:a5258871b33d 2722 #endif
jmitc91516 1:a5258871b33d 2723 }
jmitc91516 1:a5258871b33d 2724
jmitc91516 1:a5258871b33d 2725 UpdateGasTargetPressuresOnHomePage(buff);
jmitc91516 1:a5258871b33d 2726 if(strcmp(buff, GuiVar_gasTargetPressure2) != 0) {
jmitc91516 1:a5258871b33d 2727 strcpy(GuiVar_gasTargetPressure2, buff);
jmitc91516 1:a5258871b33d 2728 #ifdef DRAW_VARIABLES_INDIVIDUALLY
jmitc91516 1:a5258871b33d 2729 DrawGasTargetPressureVariableOnHomePage();
jmitc91516 1:a5258871b33d 2730 #else
jmitc91516 0:47c880c1463d 2731 mustUpdateDisplay = true;
jmitc91516 1:a5258871b33d 2732 #endif
jmitc91516 1:a5258871b33d 2733 }
jmitc91516 1:a5258871b33d 2734
jmitc91516 1:a5258871b33d 2735 GetGCRealTimeClockTime(buff);
jmitc91516 1:a5258871b33d 2736 if(strcmp(buff, GuiVar_gcTimeOnHomePage) != 0) {
jmitc91516 1:a5258871b33d 2737 strcpy(GuiVar_gcTimeOnHomePage, buff);
jmitc91516 1:a5258871b33d 2738 #ifdef DRAW_VARIABLES_INDIVIDUALLY
jmitc91516 1:a5258871b33d 2739 DrawGCRealTimeClockVariableOnHomePage();
jmitc91516 1:a5258871b33d 2740 #else
jmitc91516 1:a5258871b33d 2741 mustUpdateDisplay = true;
jmitc91516 1:a5258871b33d 2742 #endif
jmitc91516 1:a5258871b33d 2743 }
jmitc91516 1:a5258871b33d 2744
jmitc91516 1:a5258871b33d 2745 if(HomePageGCComponentStatusesHaveChanged()) {
jmitc91516 1:a5258871b33d 2746 mustUpdateDisplay = true;
jmitc91516 1:a5258871b33d 2747 }
jmitc91516 1:a5258871b33d 2748
jmitc91516 0:47c880c1463d 2749 if(mustUpdateDisplay) {
jmitc91516 0:47c880c1463d 2750
jmitc91516 1:a5258871b33d 2751 //#define WANT_STATUS_RECTANGLES_ON_HOME_PAGE // else use QSPIBitmaps
jmitc91516 1:a5258871b33d 2752 #ifdef WANT_STATUS_RECTANGLES_ON_HOME_PAGE
jmitc91516 0:47c880c1463d 2753 // Updating the color areas involves getting the component statuses from the GC -
jmitc91516 0:47c880c1463d 2754 // do this before GuiLib_Clear, otherwise the display stays blank for an annoyingly long time
jmitc91516 0:47c880c1463d 2755 if(homePageGCComponentStatusColorAreas != NULL) {
jmitc91516 0:47c880c1463d 2756 UpdateHomePageGCComponentStatusColorAreas();
jmitc91516 0:47c880c1463d 2757 }
jmitc91516 1:a5258871b33d 2758 #endif // WANT_STATUS_RECTANGLES_ON_HOME_PAGE
jmitc91516 1:a5258871b33d 2759
jmitc91516 1:a5258871b33d 2760 // Also get the GC state before GuiLib_Clear, for the same reason
jmitc91516 1:a5258871b33d 2761 int gcStatus = GetGCStatus();
jmitc91516 1:a5258871b33d 2762 GCStateSimplified simplifiedGCState = GCStateOrFaultCode::GetSimplifiedGCState(gcStatus);
jmitc91516 1:a5258871b33d 2763
jmitc91516 0:47c880c1463d 2764 // Makes the display flicker - but omitting it means old text is not cleared from the display
jmitc91516 2:6e94a7fd1e37 2765 #define WANT_GUILIB_CLEAR
jmitc91516 0:47c880c1463d 2766 #ifdef WANT_GUILIB_CLEAR
jmitc91516 1:a5258871b33d 2767 #ifdef USING_BACKGROUND_BITMAP
jmitc91516 1:a5258871b33d 2768 DrawBackgroundBitmap(); // We want the status rectangles to be 'on top' of this -
jmitc91516 1:a5258871b33d 2769 // if we include it in the easyGUI page itself, it gets drawn by GuiLib_ShowScreen,
jmitc91516 1:a5258871b33d 2770 // and overwrites the rectangles
jmitc91516 1:a5258871b33d 2771 #else
jmitc91516 0:47c880c1463d 2772 GuiLib_Clear();
jmitc91516 1:a5258871b33d 2773 #endif
jmitc91516 0:47c880c1463d 2774 #undef WANT_GUILIB_CLEAR
jmitc91516 0:47c880c1463d 2775 #endif
jmitc91516 0:47c880c1463d 2776 //...except that redrawing the status rectangles effectively clears the text on top of the rectangles -
jmitc91516 1:a5258871b33d 2777 // so we do not need GuiLib_Clear here, since all the 'home page data' appears on top of the rectangles.
jmitc91516 1:a5258871b33d 2778 // Without it, only the text flickers, not the rectangles
jmitc91516 1:a5258871b33d 2779
jmitc91516 1:a5258871b33d 2780
jmitc91516 1:a5258871b33d 2781 #ifdef WANT_STATUS_RECTANGLES_ON_HOME_PAGE
jmitc91516 0:47c880c1463d 2782 // Note - we draw the status rectangles after GuiLib_Clear - otherwise we wouldn't see the rectangles at all -
jmitc91516 0:47c880c1463d 2783 // and before GuiLib_ShowScreen - so text, etc, is drawn on top of the rectangles.
jmitc91516 0:47c880c1463d 2784 // (But note that we get the component statuses before GuiLib_Clear above.)
jmitc91516 0:47c880c1463d 2785 if(homePageGCComponentStatusColorAreas != NULL) {
jmitc91516 0:47c880c1463d 2786 homePageGCComponentStatusColorAreas->DisplayAll();
jmitc91516 1:a5258871b33d 2787
jmitc91516 1:a5258871b33d 2788 lastColumnStatusDisplayedOnHomePage = homePageGCComponentStatusColorAreas->GetGCComponentStatus(COLUMN);
jmitc91516 1:a5258871b33d 2789 lastInjectorStatusDisplayedOnHomePage = homePageGCComponentStatusColorAreas->GetGCComponentStatus(INJECTOR);
jmitc91516 1:a5258871b33d 2790 lastDetectorStatusDisplayedOnHomePage = homePageGCComponentStatusColorAreas->GetGCComponentStatus(DETECTOR);
jmitc91516 1:a5258871b33d 2791 lastGasStatusDisplayedOnHomePage = homePageGCComponentStatusColorAreas->GetGCComponentStatus(GAS);
jmitc91516 1:a5258871b33d 2792 }
jmitc91516 1:a5258871b33d 2793 #else
jmitc91516 1:a5258871b33d 2794 if(qspiBitmaps != NULL) {
jmitc91516 1:a5258871b33d 2795 qspiBitmaps->DisplayAllHomePageBitmaps();
jmitc91516 1:a5258871b33d 2796 }
jmitc91516 1:a5258871b33d 2797 #endif // WANT_STATUS_RECTANGLES_ON_HOME_PAGE
jmitc91516 0:47c880c1463d 2798
jmitc91516 0:47c880c1463d 2799 GuiLib_ShowScreen(GuiStruct_HomePage_1, GuiLib_NO_CURSOR, GuiLib_RESET_AUTO_REDRAW);
jmitc91516 0:47c880c1463d 2800
jmitc91516 1:a5258871b33d 2801 // ...but we draw the Run button and the Heat On/Off button on top of the structure
jmitc91516 2:6e94a7fd1e37 2802 //#define ALWAYS_WANT_RUN_BUTTON
jmitc91516 2:6e94a7fd1e37 2803 #ifdef ALWAYS_WANT_RUN_BUTTON
jmitc91516 1:a5258871b33d 2804 DrawRunButton((simplifiedGCState == GC_READY_TO_RUN) || (simplifiedGCState == GC_RUNNING));
jmitc91516 2:6e94a7fd1e37 2805 #else
jmitc91516 2:6e94a7fd1e37 2806 if((simplifiedGCState == GC_READY_TO_RUN) || (simplifiedGCState == GC_RUNNING)) {
jmitc91516 2:6e94a7fd1e37 2807 DrawRunButton(true);
jmitc91516 2:6e94a7fd1e37 2808 }
jmitc91516 2:6e94a7fd1e37 2809 #endif // ALWAYS_WANT_RUN_BUTTON
jmitc91516 1:a5258871b33d 2810 DrawHeatOnOffButton();
jmitc91516 1:a5258871b33d 2811
jmitc91516 2:6e94a7fd1e37 2812 GCStateOrFaultCode::DrawSimplifiedStateMessageOnHomePageRunButton(simplifiedGCState); // *After* drawing the Run button
jmitc91516 1:a5258871b33d 2813
jmitc91516 1:a5258871b33d 2814 // This variable (which sets the colour for the door actuator lock/unlock button text)
jmitc91516 1:a5258871b33d 2815 // is not used on this page, only on the column pages - but this is the page
jmitc91516 1:a5258871b33d 2816 // on which we turn the heat on and off. Try and make sure this variable is up to date
jmitc91516 1:a5258871b33d 2817 // before we display the column pages, by updating it here
jmitc91516 1:a5258871b33d 2818 SetupDoorActuatorCommandColour(usbDevice, usbHostGC, false);
jmitc91516 1:a5258871b33d 2819
jmitc91516 1:a5258871b33d 2820
jmitc91516 0:47c880c1463d 2821 GuiLib_Refresh();
jmitc91516 0:47c880c1463d 2822
jmitc91516 0:47c880c1463d 2823 #define DEBUG_HERE
jmitc91516 0:47c880c1463d 2824 #ifdef DEBUG_HERE
jmitc91516 1:a5258871b33d 2825 static int counter = 0;
jmitc91516 1:a5258871b33d 2826 char dbg[100];
jmitc91516 1:a5258871b33d 2827 sprintf(dbg, "After GuiLib_Clear 1 [%d]", ++counter);
jmitc91516 1:a5258871b33d 2828 EasyGUIDebugPrint(dbg, 0, 20);
jmitc91516 0:47c880c1463d 2829 #undef DEBUG_HERE
jmitc91516 0:47c880c1463d 2830 #endif
jmitc91516 0:47c880c1463d 2831 }
jmitc91516 0:47c880c1463d 2832 }
jmitc91516 0:47c880c1463d 2833
jmitc91516 1:a5258871b33d 2834 /*
jmitc91516 1:a5258871b33d 2835 Gets the maximum column temperature, and returns it as a null-terminated string, with a descriptive prefix.
jmitc91516 1:a5258871b33d 2836
jmitc91516 1:a5258871b33d 2837 Note also that this code is intended to be as efficient as possible.
jmitc91516 1:a5258871b33d 2838
jmitc91516 1:a5258871b33d 2839 Args: pointer to the buffer to contain the maximum temperature, as a null-terminated string
jmitc91516 1:a5258871b33d 2840 boolean set true if the caller wants a full prefix ("Column max temp: "),
jmitc91516 1:a5258871b33d 2841 or false for a short prefix ("Max temp: ")
jmitc91516 1:a5258871b33d 2842 boolean set false if the caller wants no prefix whatsoever
jmitc91516 1:a5258871b33d 2843
jmitc91516 1:a5258871b33d 2844 No return code.
jmitc91516 1:a5258871b33d 2845 */
jmitc91516 1:a5258871b33d 2846 void GetGCStatusLoop::GetColumnMaxTemperature(char *maxTemp, bool wantFullPrefix, bool wantAnyPrefix, bool wantUnits)
jmitc91516 0:47c880c1463d 2847 {
jmitc91516 0:47c880c1463d 2848 char response[50];
jmitc91516 1:a5258871b33d 2849 // SetGCDeviceReport("QCMX", response);
jmitc91516 1:a5258871b33d 2850 // Correct command for this is now:
jmitc91516 1:a5258871b33d 2851 SetGCDeviceReport("GCMX", response);
jmitc91516 1:a5258871b33d 2852 // This returns a value in whole degrees, not 0.1 degree units
jmitc91516 1:a5258871b33d 2853 // We expect a response like this: "DCMX1234" - where "1234" is the max temp
jmitc91516 0:47c880c1463d 2854 int index = 0;
jmitc91516 1:a5258871b33d 2855 if(wantAnyPrefix) {
jmitc91516 1:a5258871b33d 2856 if(wantFullPrefix) {
jmitc91516 1:a5258871b33d 2857 maxTemp[index++] = 'C';
jmitc91516 1:a5258871b33d 2858 maxTemp[index++] = 'o';
jmitc91516 1:a5258871b33d 2859 maxTemp[index++] = 'l';
jmitc91516 1:a5258871b33d 2860 maxTemp[index++] = 'u';
jmitc91516 1:a5258871b33d 2861 maxTemp[index++] = 'm';
jmitc91516 1:a5258871b33d 2862 maxTemp[index++] = 'n';
jmitc91516 1:a5258871b33d 2863 maxTemp[index++] = ' ';
jmitc91516 1:a5258871b33d 2864 maxTemp[index++] = 'm';
jmitc91516 1:a5258871b33d 2865 } else {
jmitc91516 1:a5258871b33d 2866 maxTemp[index++] = 'M';
jmitc91516 1:a5258871b33d 2867 }
jmitc91516 1:a5258871b33d 2868 maxTemp[index++] = 'a';
jmitc91516 1:a5258871b33d 2869 maxTemp[index++] = 'x';
jmitc91516 0:47c880c1463d 2870 maxTemp[index++] = ' ';
jmitc91516 1:a5258871b33d 2871 maxTemp[index++] = 't';
jmitc91516 1:a5258871b33d 2872 maxTemp[index++] = 'e';
jmitc91516 0:47c880c1463d 2873 maxTemp[index++] = 'm';
jmitc91516 1:a5258871b33d 2874 maxTemp[index++] = 'p';
jmitc91516 1:a5258871b33d 2875 maxTemp[index++] = ':';
jmitc91516 1:a5258871b33d 2876 maxTemp[index++] = ' ';
jmitc91516 1:a5258871b33d 2877 }
jmitc91516 1:a5258871b33d 2878
jmitc91516 0:47c880c1463d 2879 // But check for "EPKT" first
jmitc91516 0:47c880c1463d 2880 if(response[0] == 'E') {
jmitc91516 0:47c880c1463d 2881 maxTemp[index++] = '*';
jmitc91516 0:47c880c1463d 2882 maxTemp[index++] = '*';
jmitc91516 0:47c880c1463d 2883 maxTemp[index++] = ' ';
jmitc91516 0:47c880c1463d 2884 maxTemp[index++] = 'E';
jmitc91516 0:47c880c1463d 2885 maxTemp[index++] = 'r';
jmitc91516 0:47c880c1463d 2886 maxTemp[index++] = 'r';
jmitc91516 0:47c880c1463d 2887 maxTemp[index++] = 'o';
jmitc91516 0:47c880c1463d 2888 maxTemp[index++] = 'r';
jmitc91516 0:47c880c1463d 2889 maxTemp[index++] = ' ';
jmitc91516 0:47c880c1463d 2890 maxTemp[index++] = '*';
jmitc91516 0:47c880c1463d 2891 maxTemp[index++] = '*';
jmitc91516 0:47c880c1463d 2892 } else {
jmitc91516 1:a5258871b33d 2893 bool wantNextChars = false;
jmitc91516 1:a5258871b33d 2894 if(response[4] != '0') {
jmitc91516 1:a5258871b33d 2895 maxTemp[index++] = response[4];
jmitc91516 1:a5258871b33d 2896 wantNextChars = true;
jmitc91516 1:a5258871b33d 2897 }
jmitc91516 1:a5258871b33d 2898 if(wantNextChars || (response[5] != '0')) {
jmitc91516 1:a5258871b33d 2899 maxTemp[index++] = response[5];
jmitc91516 1:a5258871b33d 2900 wantNextChars = true;
jmitc91516 1:a5258871b33d 2901 }
jmitc91516 1:a5258871b33d 2902 if(wantNextChars || (response[6] != '0')) {
jmitc91516 1:a5258871b33d 2903 maxTemp[index++] = response[6];
jmitc91516 1:a5258871b33d 2904 }
jmitc91516 1:a5258871b33d 2905 // If the value is zero, make sure we return "0" -
jmitc91516 1:a5258871b33d 2906 // we just don't want any zeroes before that
jmitc91516 0:47c880c1463d 2907 maxTemp[index++] = response[7];
jmitc91516 1:a5258871b33d 2908
jmitc91516 1:a5258871b33d 2909 if(wantUnits) {
jmitc91516 6:dba3fbdfd5da 2910 #ifdef TRY_DEG_SYMBOL
jmitc91516 6:dba3fbdfd5da 2911 maxTemp[index++] = ' ';
jmitc91516 6:dba3fbdfd5da 2912 maxTemp[index++] = degSymbol;
jmitc91516 6:dba3fbdfd5da 2913 maxTemp[index++] = 'C';
jmitc91516 6:dba3fbdfd5da 2914 #else
jmitc91516 1:a5258871b33d 2915 maxTemp[index++] = ' ';
jmitc91516 1:a5258871b33d 2916 maxTemp[index++] = 'd';
jmitc91516 1:a5258871b33d 2917 maxTemp[index++] = 'e';
jmitc91516 1:a5258871b33d 2918 maxTemp[index++] = 'g';
jmitc91516 1:a5258871b33d 2919 maxTemp[index++] = ' ';
jmitc91516 1:a5258871b33d 2920 maxTemp[index++] = 'C';
jmitc91516 6:dba3fbdfd5da 2921 #endif // TRY_DEG_SYMBOL
jmitc91516 1:a5258871b33d 2922 }
jmitc91516 1:a5258871b33d 2923 }
jmitc91516 1:a5258871b33d 2924
jmitc91516 1:a5258871b33d 2925 maxTemp[index] = '\0';
jmitc91516 1:a5258871b33d 2926 }
jmitc91516 1:a5258871b33d 2927
jmitc91516 1:a5258871b33d 2928 /*
jmitc91516 1:a5258871b33d 2929 Gets the maximum column temperature, returning it as a floating-point value.
jmitc91516 1:a5258871b33d 2930
jmitc91516 1:a5258871b33d 2931 Args: pointer to a floating point variable to be set to the maximum temperature
jmitc91516 1:a5258871b33d 2932
jmitc91516 1:a5258871b33d 2933 No return code.
jmitc91516 1:a5258871b33d 2934 */
jmitc91516 0:47c880c1463d 2935 void GetGCStatusLoop::GetColumnMaxTemperature(float *maxTemp)
jmitc91516 0:47c880c1463d 2936 {
jmitc91516 0:47c880c1463d 2937 char response[50];
jmitc91516 1:a5258871b33d 2938 SetGCDeviceReport("GCMX", response);
jmitc91516 0:47c880c1463d 2939
jmitc91516 0:47c880c1463d 2940 // Check for "EPKT" first
jmitc91516 0:47c880c1463d 2941 if(response[0] == 'E') {
jmitc91516 0:47c880c1463d 2942 *maxTemp = 0.0;
jmitc91516 0:47c880c1463d 2943 } else {
jmitc91516 1:a5258871b33d 2944 sscanf(&response[4], "%f", maxTemp);
jmitc91516 0:47c880c1463d 2945 }
jmitc91516 0:47c880c1463d 2946
jmitc91516 0:47c880c1463d 2947 //#define DEBUG_HERE
jmitc91516 0:47c880c1463d 2948 #ifdef DEBUG_HERE
jmitc91516 0:47c880c1463d 2949 char dbg[100];
jmitc91516 0:47c880c1463d 2950 sprintf(dbg, "GGCSL::GCMTT - returning : %f", *maxTemp);
jmitc91516 1:a5258871b33d 2951 EasyGUIDebugPrint(dbg, 0, 20);
jmitc91516 1:a5258871b33d 2952 #undef DEBUG_HERE
jmitc91516 1:a5258871b33d 2953 #endif
jmitc91516 1:a5258871b33d 2954 }
jmitc91516 1:a5258871b33d 2955
jmitc91516 1:a5258871b33d 2956 /*
jmitc91516 1:a5258871b33d 2957 Gets the column type, and returns it as a null-terminated string, with a descriptive prefix.
jmitc91516 1:a5258871b33d 2958
jmitc91516 1:a5258871b33d 2959 Note also that this code is intended to be as efficient as possible.
jmitc91516 1:a5258871b33d 2960
jmitc91516 1:a5258871b33d 2961 Args: pointer to a buffer to contain the column type, as a null-terminated string
jmitc91516 1:a5258871b33d 2962
jmitc91516 1:a5258871b33d 2963 No return code.
jmitc91516 1:a5258871b33d 2964 */
jmitc91516 1:a5258871b33d 2965 void GetGCStatusLoop::GetColumnType(char *type)
jmitc91516 1:a5258871b33d 2966 {
jmitc91516 1:a5258871b33d 2967 char response[50];
jmitc91516 1:a5258871b33d 2968 SetGCDeviceReport("GCTY", response);
jmitc91516 1:a5258871b33d 2969
jmitc91516 1:a5258871b33d 2970 // We expect a response like this: "DCTY0000" for None, "DCTY0001" for Conventional,
jmitc91516 1:a5258871b33d 2971 // "DCTY0002" for Directly heated
jmitc91516 1:a5258871b33d 2972 int index = 0;
jmitc91516 1:a5258871b33d 2973 // Check for "EPKT" first
jmitc91516 1:a5258871b33d 2974 if(response[0] == 'E') {
jmitc91516 1:a5258871b33d 2975 type[index++] = '*';
jmitc91516 1:a5258871b33d 2976 type[index++] = '*';
jmitc91516 1:a5258871b33d 2977 type[index++] = ' ';
jmitc91516 1:a5258871b33d 2978 type[index++] = 'E';
jmitc91516 1:a5258871b33d 2979 type[index++] = 'r';
jmitc91516 1:a5258871b33d 2980 type[index++] = 'r';
jmitc91516 1:a5258871b33d 2981 type[index++] = 'o';
jmitc91516 1:a5258871b33d 2982 type[index++] = 'r';
jmitc91516 1:a5258871b33d 2983 type[index++] = ' ';
jmitc91516 1:a5258871b33d 2984 type[index++] = '*';
jmitc91516 1:a5258871b33d 2985 type[index++] = '*';
jmitc91516 1:a5258871b33d 2986 } else {
jmitc91516 1:a5258871b33d 2987 switch(response[7]) {
jmitc91516 1:a5258871b33d 2988 case '1':
jmitc91516 1:a5258871b33d 2989 type[index++] = 'C';
jmitc91516 1:a5258871b33d 2990 type[index++] = 'o';
jmitc91516 1:a5258871b33d 2991 type[index++] = 'n';
jmitc91516 1:a5258871b33d 2992 type[index++] = 'v';
jmitc91516 1:a5258871b33d 2993 type[index++] = 'e';
jmitc91516 1:a5258871b33d 2994 type[index++] = 'n';
jmitc91516 1:a5258871b33d 2995 type[index++] = 't';
jmitc91516 1:a5258871b33d 2996 type[index++] = 'i';
jmitc91516 1:a5258871b33d 2997 type[index++] = 'o';
jmitc91516 1:a5258871b33d 2998 type[index++] = 'n';
jmitc91516 1:a5258871b33d 2999 type[index++] = 'a';
jmitc91516 1:a5258871b33d 3000 type[index++] = 'l';
jmitc91516 1:a5258871b33d 3001 break;
jmitc91516 1:a5258871b33d 3002 case '2':
jmitc91516 1:a5258871b33d 3003 type[index++] = 'D';
jmitc91516 1:a5258871b33d 3004 type[index++] = 'i';
jmitc91516 1:a5258871b33d 3005 type[index++] = 'r';
jmitc91516 1:a5258871b33d 3006 type[index++] = 'e';
jmitc91516 1:a5258871b33d 3007 type[index++] = 'c';
jmitc91516 1:a5258871b33d 3008 type[index++] = 't';
jmitc91516 1:a5258871b33d 3009 type[index++] = 'l';
jmitc91516 1:a5258871b33d 3010 type[index++] = 'y';
jmitc91516 1:a5258871b33d 3011 type[index++] = ' ';
jmitc91516 1:a5258871b33d 3012 type[index++] = 'h';
jmitc91516 1:a5258871b33d 3013 type[index++] = 'e';
jmitc91516 1:a5258871b33d 3014 type[index++] = 'a';
jmitc91516 1:a5258871b33d 3015 type[index++] = 't';
jmitc91516 1:a5258871b33d 3016 type[index++] = 'e';
jmitc91516 1:a5258871b33d 3017 type[index++] = 'd';
jmitc91516 1:a5258871b33d 3018 break;
jmitc91516 1:a5258871b33d 3019 default:
jmitc91516 1:a5258871b33d 3020 type[index++] = 'N';
jmitc91516 1:a5258871b33d 3021 type[index++] = 'o';
jmitc91516 1:a5258871b33d 3022 type[index++] = 'n';
jmitc91516 1:a5258871b33d 3023 type[index++] = 'e';
jmitc91516 1:a5258871b33d 3024 break;
jmitc91516 1:a5258871b33d 3025 }
jmitc91516 1:a5258871b33d 3026 }
jmitc91516 1:a5258871b33d 3027
jmitc91516 1:a5258871b33d 3028 type[index++] = '\0';
jmitc91516 1:a5258871b33d 3029 }
jmitc91516 1:a5258871b33d 3030
jmitc91516 1:a5258871b33d 3031 /*
jmitc91516 1:a5258871b33d 3032 Gets the column type, and returns it as a value in the 'ColumnType' enumeration
jmitc91516 1:a5258871b33d 3033
jmitc91516 1:a5258871b33d 3034 No arguments.
jmitc91516 1:a5258871b33d 3035
jmitc91516 1:a5258871b33d 3036 Return value: the column type
jmitc91516 1:a5258871b33d 3037 */
jmitc91516 1:a5258871b33d 3038 ColumnType GetGCStatusLoop::GetColumnType(void)
jmitc91516 1:a5258871b33d 3039 {
jmitc91516 1:a5258871b33d 3040 char response[50];
jmitc91516 1:a5258871b33d 3041 SetGCDeviceReport("GCTY", response);
jmitc91516 1:a5258871b33d 3042
jmitc91516 1:a5258871b33d 3043 // We expect a response like this: "DCTY0000" for None, "DCTY0001" for Conventional,
jmitc91516 1:a5258871b33d 3044 // "DCTY0002" for Directly heated
jmitc91516 1:a5258871b33d 3045 // Check for "EPKT" first
jmitc91516 1:a5258871b33d 3046 if(response[0] == 'E') {
jmitc91516 1:a5258871b33d 3047 return NO_COLUMN;
jmitc91516 1:a5258871b33d 3048 }
jmitc91516 1:a5258871b33d 3049
jmitc91516 1:a5258871b33d 3050 // 'else'...
jmitc91516 1:a5258871b33d 3051 switch(response[7]) {
jmitc91516 1:a5258871b33d 3052 case '1':
jmitc91516 1:a5258871b33d 3053 return CONVENTIONAL_COLUMN;
jmitc91516 1:a5258871b33d 3054 case '2':
jmitc91516 1:a5258871b33d 3055 return DIRECTLY_HEATED_COLUMN;
jmitc91516 1:a5258871b33d 3056 default:
jmitc91516 1:a5258871b33d 3057 return NO_COLUMN;
jmitc91516 1:a5258871b33d 3058 }
jmitc91516 1:a5258871b33d 3059 }
jmitc91516 1:a5258871b33d 3060
jmitc91516 1:a5258871b33d 3061
jmitc91516 1:a5258871b33d 3062 /*
jmitc91516 1:a5258871b33d 3063 Displays the data on the column page, by copying it to the relevant easyGUI variables,
jmitc91516 1:a5258871b33d 3064 and calling the relevant functions to actually display it.
jmitc91516 1:a5258871b33d 3065
jmitc91516 1:a5258871b33d 3066 Args: a boolean specifying whether or not the display is actually to be updated.
jmitc91516 1:a5258871b33d 3067 Even if it is false when we are called, we may set it true if we discover
jmitc91516 1:a5258871b33d 3068 one or more data items has changed - but note that we will not set it false
jmitc91516 1:a5258871b33d 3069 if it is already true. If it is true after we have looked at all
jmitc91516 1:a5258871b33d 3070 the home page data, we will then update the display. (If we are called
jmitc91516 1:a5258871b33d 3071 with this value set to false, the caller is effectively saying
jmitc91516 1:a5258871b33d 3072 'display the column page data only if it has changed').
jmitc91516 1:a5258871b33d 3073
jmitc91516 1:a5258871b33d 3074 The column type.
jmitc91516 1:a5258871b33d 3075
jmitc91516 1:a5258871b33d 3076 The page number (this varies according to the column type - if the caller knows the column type,
jmitc91516 1:a5258871b33d 3077 it must also (in effect) know the page number, so it seems ridiculous for this function
jmitc91516 1:a5258871b33d 3078 to work it out again from the column type)
jmitc91516 1:a5258871b33d 3079
jmitc91516 1:a5258871b33d 3080 No return code.
jmitc91516 1:a5258871b33d 3081 */
jmitc91516 1:a5258871b33d 3082 void GetGCStatusLoop::DisplayColumnPageData(bool mustUpdateDisplay, ColumnType columnType, int pageNumber)
jmitc91516 0:47c880c1463d 3083 {
jmitc91516 0:47c880c1463d 3084 // EasyGUIDebugPrint("Column Page", 100, 100);
jmitc91516 0:47c880c1463d 3085 // Column temperature and maximum temperature
jmitc91516 0:47c880c1463d 3086 char buff[40];
jmitc91516 0:47c880c1463d 3087
jmitc91516 7:f0e645cf73a2 3088 #ifdef WANT_DOOR_ACTUATOR_BUTTONS_ON_COLUMN_PAGES
jmitc91516 1:a5258871b33d 3089 if(DoorActuatorButtonsHaveChanged(usbDevice, usbHostGC)) {
jmitc91516 1:a5258871b33d 3090 mustUpdateDisplay = true;
jmitc91516 1:a5258871b33d 3091 }
jmitc91516 1:a5258871b33d 3092
jmitc91516 1:a5258871b33d 3093 SetupDoorActuatorCommandUserInterface(usbDevice, usbHostGC, true);
jmitc91516 7:f0e645cf73a2 3094 #endif // WANT_DOOR_ACTUATOR_BUTTONS_ON_COLUMN_PAGES
jmitc91516 7:f0e645cf73a2 3095
jmitc91516 1:a5258871b33d 3096 GetColumnTemperature(buff, false, true);
jmitc91516 0:47c880c1463d 3097 if(strcmp(buff, GuiVar_columnTemperature) != 0) {
jmitc91516 0:47c880c1463d 3098 strcpy(GuiVar_columnTemperature, buff);
jmitc91516 1:a5258871b33d 3099
jmitc91516 1:a5258871b33d 3100 //mustUpdateDisplay = true;
jmitc91516 1:a5258871b33d 3101 // No - just do this (don't force entire rectangle to redisplay)
jmitc91516 1:a5258871b33d 3102 // Hard coded values taken from easyGUI
jmitc91516 5:aceac1035d71 3103 RedrawSingleEasyGUIVariableOnComponentPage(400, 110, &GuiVar_columnTemperature, GuiLib_ALIGN_LEFT, COLUMN);
jmitc91516 1:a5258871b33d 3104 }
jmitc91516 1:a5258871b33d 3105
jmitc91516 6:dba3fbdfd5da 3106 GetColumnTargetTemperature(buff, stringFormatdegCUnits);
jmitc91516 1:a5258871b33d 3107 if(strcmp(buff, GuiVar_columnTargetTemperature2) != 0) {
jmitc91516 1:a5258871b33d 3108 strcpy(GuiVar_columnTargetTemperature2, buff);
jmitc91516 1:a5258871b33d 3109
jmitc91516 1:a5258871b33d 3110 //mustUpdateDisplay = true;
jmitc91516 1:a5258871b33d 3111 // No - just do this (don't force entire rectangle to redisplay)
jmitc91516 1:a5258871b33d 3112 // Hard coded values taken from easyGUI
jmitc91516 5:aceac1035d71 3113 RedrawSingleEasyGUIVariableOnComponentPage(400, 160, &GuiVar_columnTargetTemperature2, GuiLib_ALIGN_LEFT, COLUMN);
jmitc91516 1:a5258871b33d 3114 }
jmitc91516 1:a5258871b33d 3115
jmitc91516 1:a5258871b33d 3116 GetColumnMaxTemperature(buff, false, false, true);
jmitc91516 0:47c880c1463d 3117 if(strcmp(buff, GuiVar_columnMaxTemp2) != 0) {
jmitc91516 1:a5258871b33d 3118 strcpy(GuiVar_columnMaxTemp2, buff);
jmitc91516 1:a5258871b33d 3119
jmitc91516 1:a5258871b33d 3120 //mustUpdateDisplay = true;
jmitc91516 1:a5258871b33d 3121 // No - just do this (don't force entire rectangle to redisplay)
jmitc91516 1:a5258871b33d 3122 // Hard coded values taken from easyGUI
jmitc91516 5:aceac1035d71 3123 RedrawSingleEasyGUIVariableOnComponentPage(400, 230, &GuiVar_columnMaxTemp2, GuiLib_ALIGN_LEFT, COLUMN);
jmitc91516 1:a5258871b33d 3124 }
jmitc91516 1:a5258871b33d 3125
jmitc91516 1:a5258871b33d 3126 GetComponentStatusString(COLUMN, buff);
jmitc91516 1:a5258871b33d 3127 if(strcmp(buff, GuiVar_columnStatus) != 0) {
jmitc91516 1:a5258871b33d 3128 strcpy(GuiVar_columnStatus, buff);
jmitc91516 1:a5258871b33d 3129
jmitc91516 1:a5258871b33d 3130 //mustUpdateDisplay = true;
jmitc91516 1:a5258871b33d 3131 // No - just do this (don't force entire rectangle to redisplay)
jmitc91516 1:a5258871b33d 3132 // Hard coded values taken from easyGUI
jmitc91516 5:aceac1035d71 3133 RedrawSingleEasyGUIVariableOnComponentPage(400, 290, &GuiVar_columnStatus, GuiLib_ALIGN_LEFT, COLUMN);
jmitc91516 1:a5258871b33d 3134 }
jmitc91516 1:a5258871b33d 3135
jmitc91516 1:a5258871b33d 3136 if(SinglePageGCComponentStatusHasChanged(COLUMN, lastColumnStatusDisplayedOnColumnPage)) {
jmitc91516 0:47c880c1463d 3137 mustUpdateDisplay = true;
jmitc91516 1:a5258871b33d 3138 }
jmitc91516 1:a5258871b33d 3139
jmitc91516 1:a5258871b33d 3140 if(mustUpdateDisplay) {
jmitc91516 1:a5258871b33d 3141
jmitc91516 3:010aeeacd7d7 3142 #ifdef WANT_COLUMN_STATUS_RECTANGLE
jmitc91516 1:a5258871b33d 3143 // Reduce display flickering - get the component status from the GC
jmitc91516 1:a5258871b33d 3144 // *before* we call GuiLib_Clear()
jmitc91516 1:a5258871b33d 3145 if(singleGCComponentPageStatusColorAreas != NULL) {
jmitc91516 1:a5258871b33d 3146 UpdateSingleGCComponentPageStatusColorArea(COLUMN);
jmitc91516 1:a5258871b33d 3147 }
jmitc91516 3:010aeeacd7d7 3148 #endif
jmitc91516 3:010aeeacd7d7 3149
jmitc91516 3:010aeeacd7d7 3150 #ifndef WANT_COLUMN_STATUS_RECTANGLE
jmitc91516 3:010aeeacd7d7 3151 #define WANT_GUILIB_CLEAR // Want this, if no status rectangle
jmitc91516 3:010aeeacd7d7 3152 #endif
jmitc91516 3:010aeeacd7d7 3153
jmitc91516 1:a5258871b33d 3154 #ifdef WANT_GUILIB_CLEAR
jmitc91516 1:a5258871b33d 3155 #ifdef USING_BACKGROUND_BITMAP
jmitc91516 1:a5258871b33d 3156 DrawBackgroundBitmap(); // We want the status rectangles to be 'on top' of this -
jmitc91516 1:a5258871b33d 3157 // if we include it in the easyGUI page itself, it gets drawn by GuiLib_ShowScreen,
jmitc91516 1:a5258871b33d 3158 // and overwrites the rectangles
jmitc91516 1:a5258871b33d 3159 #else
jmitc91516 1:a5258871b33d 3160 GuiLib_Clear();
jmitc91516 1:a5258871b33d 3161 #endif
jmitc91516 1:a5258871b33d 3162 #undef WANT_GUILIB_CLEAR
jmitc91516 1:a5258871b33d 3163 #endif
jmitc91516 1:a5258871b33d 3164 //...except that redrawing the status rectangle effectively clears the text on top of the rectangle -
jmitc91516 1:a5258871b33d 3165 // so we do not need GuiLib_Clear here, since all the column page data appears on top of the rectangle.
jmitc91516 1:a5258871b33d 3166 // Without it, only the text flickers, not the rectangle
jmitc91516 1:a5258871b33d 3167
jmitc91516 3:010aeeacd7d7 3168 #ifdef WANT_COLUMN_STATUS_RECTANGLE
jmitc91516 1:a5258871b33d 3169 // Note - we draw the status rectangle after GuiLib_Clear - otherwise we wouldn't see the rectangles at all -
jmitc91516 1:a5258871b33d 3170 // and before GuiLib_ShowScreen - so text, etc, is drawn on top of the rectangles
jmitc91516 1:a5258871b33d 3171 if(singleGCComponentPageStatusColorAreas != NULL) {
jmitc91516 1:a5258871b33d 3172 singleGCComponentPageStatusColorAreas->DisplayGCComponentStatus(COLUMN);
jmitc91516 1:a5258871b33d 3173
jmitc91516 1:a5258871b33d 3174 lastColumnStatusDisplayedOnColumnPage = singleGCComponentPageStatusColorAreas->GetGCComponentStatus(COLUMN);
jmitc91516 1:a5258871b33d 3175 }
jmitc91516 3:010aeeacd7d7 3176 #endif
jmitc91516 1:a5258871b33d 3177 // And (currently) we draw the component bitmap on top of the rectangle
jmitc91516 1:a5258871b33d 3178 if(qspiBitmaps != NULL) {
jmitc91516 1:a5258871b33d 3179 qspiBitmaps->DisplayColumnComponentBitmap();
jmitc91516 1:a5258871b33d 3180 }
jmitc91516 1:a5258871b33d 3181
jmitc91516 1:a5258871b33d 3182 GuiLib_ShowScreen(pageNumber, GuiLib_NO_CURSOR, GuiLib_RESET_AUTO_REDRAW);
jmitc91516 1:a5258871b33d 3183
jmitc91516 7:f0e645cf73a2 3184 #ifdef WANT_DOOR_ACTUATOR_BUTTONS_ON_COLUMN_PAGES
jmitc91516 1:a5258871b33d 3185 SetupDoorActuatorCommandUserInterface(usbDevice, usbHostGC, false);
jmitc91516 7:f0e645cf73a2 3186 #endif // WANT_DOOR_ACTUATOR_BUTTONS_ON_COLUMN_PAGES
jmitc91516 1:a5258871b33d 3187
jmitc91516 1:a5258871b33d 3188 GuiLib_Refresh();
jmitc91516 1:a5258871b33d 3189
jmitc91516 1:a5258871b33d 3190 #define DEBUG_HERE
jmitc91516 1:a5258871b33d 3191 #ifdef DEBUG_HERE
jmitc91516 1:a5258871b33d 3192 char dbg[100];
jmitc91516 1:a5258871b33d 3193 sprintf(dbg, "After GuiLib_Clear 2");
jmitc91516 1:a5258871b33d 3194 EasyGUIDebugPrint(dbg, 0, 20);
jmitc91516 1:a5258871b33d 3195 #undef DEBUG_HERE
jmitc91516 1:a5258871b33d 3196 #endif
jmitc91516 1:a5258871b33d 3197 }
jmitc91516 1:a5258871b33d 3198 }
jmitc91516 1:a5258871b33d 3199
jmitc91516 1:a5258871b33d 3200 /*
jmitc91516 1:a5258871b33d 3201 Gets the column length and returns it as a null-terminated string.
jmitc91516 1:a5258871b33d 3202
jmitc91516 1:a5258871b33d 3203 This involves getting the value from the settings stored in QSPI memory.
jmitc91516 1:a5258871b33d 3204
jmitc91516 1:a5258871b33d 3205 Args: pointer to a buffer to contain the column length, as a null-terminated string.
jmitc91516 1:a5258871b33d 3206 This buffer must be at least 10 chars long.
jmitc91516 1:a5258871b33d 3207
jmitc91516 1:a5258871b33d 3208 No return code.
jmitc91516 1:a5258871b33d 3209 */
jmitc91516 1:a5258871b33d 3210 void GetGCStatusLoop::GetColumnLength(char *columnLengthBuffer)
jmitc91516 1:a5258871b33d 3211 {
jmitc91516 1:a5258871b33d 3212 if(SettingsHandler::GetSettingValueFromQSPI("ColumnLength", columnLengthBuffer, 10) == 0) {
jmitc91516 1:a5258871b33d 3213 // Failed to read the setting - supply a default
jmitc91516 1:a5258871b33d 3214 columnLengthBuffer[0] = '0';
jmitc91516 1:a5258871b33d 3215 columnLengthBuffer[1] = '\0';
jmitc91516 1:a5258871b33d 3216 }
jmitc91516 1:a5258871b33d 3217 }
jmitc91516 1:a5258871b33d 3218
jmitc91516 1:a5258871b33d 3219 /*
jmitc91516 1:a5258871b33d 3220 Gets the column inner diameter and returns it as a null-terminated string.
jmitc91516 1:a5258871b33d 3221
jmitc91516 1:a5258871b33d 3222 This involves getting the value from the settings stored in QSPI memory.
jmitc91516 1:a5258871b33d 3223
jmitc91516 1:a5258871b33d 3224 Args: pointer to a buffer to contain the column inner diameter, as a null-terminated string.
jmitc91516 1:a5258871b33d 3225 This buffer must be at least 10 chars long.
jmitc91516 1:a5258871b33d 3226
jmitc91516 1:a5258871b33d 3227 No return code.
jmitc91516 1:a5258871b33d 3228 */
jmitc91516 1:a5258871b33d 3229 void GetGCStatusLoop::GetColumnInnerDiameter(char *columnIDBuffer)
jmitc91516 1:a5258871b33d 3230 {
jmitc91516 1:a5258871b33d 3231 if(SettingsHandler::GetSettingValueFromQSPI("ColumnInnerDiameter", columnIDBuffer, 10) == 0) {
jmitc91516 1:a5258871b33d 3232 // Failed to read the setting - supply a default
jmitc91516 1:a5258871b33d 3233 columnIDBuffer[0] = '0';
jmitc91516 1:a5258871b33d 3234 columnIDBuffer[1] = '\0';
jmitc91516 1:a5258871b33d 3235 }
jmitc91516 1:a5258871b33d 3236 }
jmitc91516 1:a5258871b33d 3237
jmitc91516 1:a5258871b33d 3238 /*
jmitc91516 1:a5258871b33d 3239 Gets the column inner diameter and returns it as a null-terminated string.
jmitc91516 1:a5258871b33d 3240
jmitc91516 1:a5258871b33d 3241 This involves getting the value from the settings stored in QSPI memory.
jmitc91516 1:a5258871b33d 3242
jmitc91516 1:a5258871b33d 3243 Args: pointer to a buffer to contain the column outer diameter, as a null-terminated string.
jmitc91516 1:a5258871b33d 3244 This buffer must be at least 10 chars long.
jmitc91516 1:a5258871b33d 3245
jmitc91516 1:a5258871b33d 3246 No return code.
jmitc91516 1:a5258871b33d 3247 */
jmitc91516 1:a5258871b33d 3248 void GetGCStatusLoop::GetColumnOuterDiameter(char *columnODBuffer)
jmitc91516 1:a5258871b33d 3249 {
jmitc91516 1:a5258871b33d 3250 if(SettingsHandler::GetSettingValueFromQSPI("ColumnOuterDiameter", columnODBuffer, 10) == 0) {
jmitc91516 1:a5258871b33d 3251 // Failed to read the setting - supply a default
jmitc91516 1:a5258871b33d 3252 columnODBuffer[0] = '0';
jmitc91516 1:a5258871b33d 3253 columnODBuffer[1] = '\0';
jmitc91516 1:a5258871b33d 3254 }
jmitc91516 1:a5258871b33d 3255 }
jmitc91516 1:a5258871b33d 3256
jmitc91516 1:a5258871b33d 3257 /*
jmitc91516 1:a5258871b33d 3258 Gets the number of injections (i.e. runs) since the column was installed
jmitc91516 1:a5258871b33d 3259 and returns it as a null-terminated string.
jmitc91516 1:a5258871b33d 3260
jmitc91516 1:a5258871b33d 3261 This involves getting both values from the settings stored in QSPI memory.
jmitc91516 1:a5258871b33d 3262
jmitc91516 1:a5258871b33d 3263 Args: pointer to a buffer to contain the injection count, as a null-terminated string
jmitc91516 1:a5258871b33d 3264
jmitc91516 1:a5258871b33d 3265 No return code.
jmitc91516 1:a5258871b33d 3266 */
jmitc91516 1:a5258871b33d 3267 void GetGCStatusLoop::GetInjectionCountSinceColumnInstalled(char *injCount)
jmitc91516 1:a5258871b33d 3268 {
jmitc91516 1:a5258871b33d 3269 int runCount = SettingsHandler::GetIntegerValueFromQSPISettings("RunCount", 0);
jmitc91516 1:a5258871b33d 3270 int columnInstalledRunCount = SettingsHandler::GetIntegerValueFromQSPISettings("RunCountWhenColumnInstalled", 0);
jmitc91516 1:a5258871b33d 3271
jmitc91516 1:a5258871b33d 3272 sprintf(injCount, "%d", (runCount - columnInstalledRunCount));
jmitc91516 1:a5258871b33d 3273 }
jmitc91516 1:a5258871b33d 3274
jmitc91516 1:a5258871b33d 3275 /*
jmitc91516 1:a5258871b33d 3276 Displays the data on the column information page, by copying it to the relevant easyGUI variables,
jmitc91516 1:a5258871b33d 3277 and calling the relevant functions to actually display it.
jmitc91516 1:a5258871b33d 3278
jmitc91516 1:a5258871b33d 3279 Args: a boolean specifying whether or not the display is actually to be updated.
jmitc91516 1:a5258871b33d 3280 Even if it is false when we are called, we may set it true if we discover
jmitc91516 1:a5258871b33d 3281 one or more data items has changed - but note that we will not set it false
jmitc91516 1:a5258871b33d 3282 if it is already true. If it is true after we have looked at all
jmitc91516 1:a5258871b33d 3283 the home page data, we will then update the display. (If we are called
jmitc91516 1:a5258871b33d 3284 with this value set to false, the caller is effectively saying
jmitc91516 1:a5258871b33d 3285 'display the column page data only if it has changed').
jmitc91516 1:a5258871b33d 3286
jmitc91516 1:a5258871b33d 3287 The column type.
jmitc91516 1:a5258871b33d 3288
jmitc91516 1:a5258871b33d 3289 The page number (this varies according to the column type - if the caller knows the column type,
jmitc91516 1:a5258871b33d 3290 it must also (in effect) know the page number, so it seems ridiculous for this function
jmitc91516 1:a5258871b33d 3291 to work it out again from the column type)
jmitc91516 1:a5258871b33d 3292
jmitc91516 5:aceac1035d71 3293 TODO: We no longer have separate pages for the conventional and directly heated columns -
jmitc91516 5:aceac1035d71 3294 *** update this function ***
jmitc91516 5:aceac1035d71 3295
jmitc91516 1:a5258871b33d 3296 No return code.
jmitc91516 1:a5258871b33d 3297 */
jmitc91516 1:a5258871b33d 3298 void GetGCStatusLoop::DisplayColumnInformationPageData(bool mustUpdateDisplay, ColumnType columnType, int pageNumber)
jmitc91516 1:a5258871b33d 3299 {
jmitc91516 1:a5258871b33d 3300 // EasyGUIDebugPrint("Column Information Page", 100, 100);
jmitc91516 1:a5258871b33d 3301 // Column temperature and maximum temperature
jmitc91516 1:a5258871b33d 3302 char buff[40];
jmitc91516 1:a5258871b33d 3303
jmitc91516 7:f0e645cf73a2 3304 #ifdef WANT_DOOR_ACTUATOR_BUTTONS_ON_COLUMN_PAGES
jmitc91516 1:a5258871b33d 3305 if(DoorActuatorButtonsHaveChanged(usbDevice, usbHostGC)) {
jmitc91516 1:a5258871b33d 3306 mustUpdateDisplay = true;
jmitc91516 1:a5258871b33d 3307 }
jmitc91516 1:a5258871b33d 3308
jmitc91516 1:a5258871b33d 3309 SetupDoorActuatorCommandUserInterface(usbDevice, usbHostGC, true);
jmitc91516 7:f0e645cf73a2 3310 #endif // WANT_DOOR_ACTUATOR_BUTTONS_ON_COLUMN_PAGES
jmitc91516 7:f0e645cf73a2 3311
jmitc91516 1:a5258871b33d 3312 GetColumnType(buff);
jmitc91516 1:a5258871b33d 3313 if(strcmp(buff, GuiVar_columnType) != 0) {
jmitc91516 1:a5258871b33d 3314 mustUpdateDisplay = true;
jmitc91516 1:a5258871b33d 3315
jmitc91516 1:a5258871b33d 3316 strcpy(GuiVar_columnType, buff);
jmitc91516 1:a5258871b33d 3317 }
jmitc91516 1:a5258871b33d 3318
jmitc91516 4:6840cf2b153a 3319 GetColumnMaxTemperature(buff, false, false, true);
jmitc91516 4:6840cf2b153a 3320 if(strcmp(buff, GuiVar_columnMaxTemp2) != 0) {
jmitc91516 4:6840cf2b153a 3321 strcpy(GuiVar_columnMaxTemp2, buff);
jmitc91516 4:6840cf2b153a 3322
jmitc91516 4:6840cf2b153a 3323 //mustUpdateDisplay = true;
jmitc91516 4:6840cf2b153a 3324 // No - just do this (don't force entire page to redisplay)
jmitc91516 4:6840cf2b153a 3325 // Hard coded values taken from easyGUI
jmitc91516 4:6840cf2b153a 3326 RedrawSingleEasyGUIVariableOnComponentPage(400, 150, &GuiVar_columnMaxTemp2, GuiLib_ALIGN_LEFT, COLUMN);
jmitc91516 4:6840cf2b153a 3327 }
jmitc91516 4:6840cf2b153a 3328
jmitc91516 4:6840cf2b153a 3329
jmitc91516 1:a5258871b33d 3330 GetColumnLength(buff);
jmitc91516 1:a5258871b33d 3331 if(strcmp(buff, GuiVar_columnLength) != 0) {
jmitc91516 1:a5258871b33d 3332 mustUpdateDisplay = true;
jmitc91516 1:a5258871b33d 3333
jmitc91516 1:a5258871b33d 3334 strcpy(GuiVar_columnLength, buff);
jmitc91516 1:a5258871b33d 3335 }
jmitc91516 1:a5258871b33d 3336
jmitc91516 1:a5258871b33d 3337 GetColumnInnerDiameter(buff);
jmitc91516 1:a5258871b33d 3338 if(strcmp(buff, GuiVar_columnInnerDiameter) != 0) {
jmitc91516 1:a5258871b33d 3339 mustUpdateDisplay = true;
jmitc91516 1:a5258871b33d 3340
jmitc91516 1:a5258871b33d 3341 strcpy(GuiVar_columnInnerDiameter, buff);
jmitc91516 1:a5258871b33d 3342 }
jmitc91516 1:a5258871b33d 3343
jmitc91516 1:a5258871b33d 3344 GetColumnOuterDiameter(buff);
jmitc91516 1:a5258871b33d 3345 if(strcmp(buff, GuiVar_columnOuterDiameter) != 0) {
jmitc91516 1:a5258871b33d 3346 mustUpdateDisplay = true;
jmitc91516 1:a5258871b33d 3347
jmitc91516 1:a5258871b33d 3348 strcpy(GuiVar_columnOuterDiameter, buff);
jmitc91516 1:a5258871b33d 3349 }
jmitc91516 1:a5258871b33d 3350
jmitc91516 1:a5258871b33d 3351 if(SinglePageGCComponentStatusHasChanged(COLUMN)) {
jmitc91516 1:a5258871b33d 3352 mustUpdateDisplay = true;
jmitc91516 0:47c880c1463d 3353 }
jmitc91516 0:47c880c1463d 3354
jmitc91516 0:47c880c1463d 3355 if(mustUpdateDisplay) {
jmitc91516 3:010aeeacd7d7 3356
jmitc91516 3:010aeeacd7d7 3357 #ifdef WANT_COLUMN_STATUS_RECTANGLE
jmitc91516 0:47c880c1463d 3358 // Reduce display flickering - get the component status from the GC
jmitc91516 0:47c880c1463d 3359 // *before* we call GuiLib_Clear()
jmitc91516 0:47c880c1463d 3360 if(singleGCComponentPageStatusColorAreas != NULL) {
jmitc91516 0:47c880c1463d 3361 UpdateSingleGCComponentPageStatusColorArea(COLUMN);
jmitc91516 0:47c880c1463d 3362 }
jmitc91516 3:010aeeacd7d7 3363 #endif
jmitc91516 3:010aeeacd7d7 3364
jmitc91516 3:010aeeacd7d7 3365 #ifndef WANT_COLUMN_STATUS_RECTANGLE
jmitc91516 3:010aeeacd7d7 3366 #define WANT_GUILIB_CLEAR
jmitc91516 3:010aeeacd7d7 3367 #endif
jmitc91516 3:010aeeacd7d7 3368
jmitc91516 1:a5258871b33d 3369 #ifdef WANT_GUILIB_CLEAR
jmitc91516 1:a5258871b33d 3370 #ifdef USING_BACKGROUND_BITMAP
jmitc91516 1:a5258871b33d 3371 DrawBackgroundBitmap(); // We want the status rectangles to be 'on top' of this -
jmitc91516 1:a5258871b33d 3372 // if we include it in the easyGUI page itself, it gets drawn by GuiLib_ShowScreen,
jmitc91516 1:a5258871b33d 3373 // and overwrites the rectangles
jmitc91516 1:a5258871b33d 3374 #else
jmitc91516 1:a5258871b33d 3375 GuiLib_Clear();
jmitc91516 1:a5258871b33d 3376 #endif
jmitc91516 1:a5258871b33d 3377 #undef WANT_GUILIB_CLEAR
jmitc91516 1:a5258871b33d 3378 #endif
jmitc91516 1:a5258871b33d 3379 //...except that redrawing the status rectangle effectively clears the text on top of the rectangle -
jmitc91516 1:a5258871b33d 3380 // so we do not need GuiLib_Clear here, since all the column page data appears on top of the rectangle.
jmitc91516 1:a5258871b33d 3381 // Without it, only the text flickers, not the rectangle
jmitc91516 0:47c880c1463d 3382
jmitc91516 3:010aeeacd7d7 3383 #ifdef WANT_COLUMN_STATUS_RECTANGLE
jmitc91516 0:47c880c1463d 3384 // Note - we draw the status rectangle after GuiLib_Clear - otherwise we wouldn't see the rectangles at all -
jmitc91516 0:47c880c1463d 3385 // and before GuiLib_ShowScreen - so text, etc, is drawn on top of the rectangles
jmitc91516 0:47c880c1463d 3386 if(singleGCComponentPageStatusColorAreas != NULL) {
jmitc91516 0:47c880c1463d 3387 singleGCComponentPageStatusColorAreas->DisplayGCComponentStatus(COLUMN);
jmitc91516 0:47c880c1463d 3388 }
jmitc91516 3:010aeeacd7d7 3389 #endif
jmitc91516 3:010aeeacd7d7 3390
jmitc91516 1:a5258871b33d 3391 // And (currently) we draw the component bitmap on top of the rectangle
jmitc91516 1:a5258871b33d 3392 if(qspiBitmaps != NULL) {
jmitc91516 1:a5258871b33d 3393 qspiBitmaps->DisplayColumnComponentBitmap();
jmitc91516 1:a5258871b33d 3394 }
jmitc91516 1:a5258871b33d 3395
jmitc91516 1:a5258871b33d 3396 GuiLib_ShowScreen(pageNumber, GuiLib_NO_CURSOR, GuiLib_RESET_AUTO_REDRAW);
jmitc91516 1:a5258871b33d 3397
jmitc91516 7:f0e645cf73a2 3398 #ifdef WANT_DOOR_ACTUATOR_BUTTONS_ON_COLUMN_PAGES
jmitc91516 1:a5258871b33d 3399 SetupDoorActuatorCommandUserInterface(usbDevice, usbHostGC, false);
jmitc91516 7:f0e645cf73a2 3400 #endif // WANT_DOOR_ACTUATOR_BUTTONS_ON_COLUMN_PAGES
jmitc91516 1:a5258871b33d 3401
jmitc91516 0:47c880c1463d 3402 GuiLib_Refresh();
jmitc91516 0:47c880c1463d 3403
jmitc91516 0:47c880c1463d 3404 #define DEBUG_HERE
jmitc91516 0:47c880c1463d 3405 #ifdef DEBUG_HERE
jmitc91516 0:47c880c1463d 3406 char dbg[100];
jmitc91516 1:a5258871b33d 3407 sprintf(dbg, "After GuiLib_Clear 9");
jmitc91516 1:a5258871b33d 3408 EasyGUIDebugPrint(dbg, 0, 20);
jmitc91516 0:47c880c1463d 3409 #undef DEBUG_HERE
jmitc91516 0:47c880c1463d 3410 #endif
jmitc91516 0:47c880c1463d 3411 }
jmitc91516 0:47c880c1463d 3412 }
jmitc91516 0:47c880c1463d 3413
jmitc91516 5:aceac1035d71 3414
jmitc91516 5:aceac1035d71 3415 /*
jmitc91516 5:aceac1035d71 3416 Gets the initial hold time, and returns it as a null-terminated string.
jmitc91516 5:aceac1035d71 3417
jmitc91516 5:aceac1035d71 3418 This code is intended to be as efficient as possible.
jmitc91516 5:aceac1035d71 3419
jmitc91516 5:aceac1035d71 3420 Args: pointer to a buffer to contain the run time, as a null-terminated string
jmitc91516 5:aceac1035d71 3421
jmitc91516 5:aceac1035d71 3422 No return code.
jmitc91516 5:aceac1035d71 3423 */
jmitc91516 5:aceac1035d71 3424 void GetGCStatusLoop::GetInitialHoldTime(char *time)
jmitc91516 5:aceac1035d71 3425 {
jmitc91516 5:aceac1035d71 3426 char response[50];
jmitc91516 5:aceac1035d71 3427 SetGCDeviceReport("GTIM", response);
jmitc91516 5:aceac1035d71 3428
jmitc91516 5:aceac1035d71 3429 // We expect a response like this: "DTIM1234", with run time in units of 0.1 min
jmitc91516 5:aceac1035d71 3430 int index = 0;
jmitc91516 5:aceac1035d71 3431
jmitc91516 5:aceac1035d71 3432 bool wantNextChars = false;
jmitc91516 5:aceac1035d71 3433 if(response[4] != '0') {
jmitc91516 5:aceac1035d71 3434 time[index++] = response[4];
jmitc91516 5:aceac1035d71 3435 wantNextChars = true;
jmitc91516 5:aceac1035d71 3436 }
jmitc91516 5:aceac1035d71 3437 if(wantNextChars || (response[5] != '0')) {
jmitc91516 5:aceac1035d71 3438 time[index++] = response[5];
jmitc91516 5:aceac1035d71 3439 }
jmitc91516 5:aceac1035d71 3440 // If the value is zero, make sure we return "0.0" -
jmitc91516 5:aceac1035d71 3441 // we just don't want any zeroes before that
jmitc91516 5:aceac1035d71 3442 time[index++] = response[6];
jmitc91516 5:aceac1035d71 3443 time[index++] = '.';
jmitc91516 5:aceac1035d71 3444 time[index++] = response[7];
jmitc91516 5:aceac1035d71 3445 }
jmitc91516 5:aceac1035d71 3446
jmitc91516 5:aceac1035d71 3447 /*
jmitc91516 6:dba3fbdfd5da 3448 Shows or hides, as required, the scroll up and down buttons
jmitc91516 6:dba3fbdfd5da 3449 on whichever "XXX Method" page is being displayed.
jmitc91516 6:dba3fbdfd5da 3450 Currently, we display the scroll buttons at the same coordinates
jmitc91516 6:dba3fbdfd5da 3451 on all three method pages, i.e. column, injector and gas.
jmitc91516 6:dba3fbdfd5da 3452 If these buttons are ever moved from these positions,
jmitc91516 6:dba3fbdfd5da 3453 this function will need to be changed.
jmitc91516 6:dba3fbdfd5da 3454 *************************************
jmitc91516 6:dba3fbdfd5da 3455
jmitc91516 6:dba3fbdfd5da 3456 Args: a boolean saying whether or not to display the scroll buttons
jmitc91516 6:dba3fbdfd5da 3457
jmitc91516 6:dba3fbdfd5da 3458 No return code.
jmitc91516 6:dba3fbdfd5da 3459
jmitc91516 6:dba3fbdfd5da 3460 It is up to the caller (1) to decide whether the ramps need to be scrolled or not,
jmitc91516 6:dba3fbdfd5da 3461 and (2) to verify that an XXX Method page actually *is* the page currently being displayed
jmitc91516 6:dba3fbdfd5da 3462 */
jmitc91516 6:dba3fbdfd5da 3463 void GetGCStatusLoop::ShowMethodPageScrollButtons(bool needToScrollRampData)
jmitc91516 6:dba3fbdfd5da 3464 {
jmitc91516 8:26e49e6955bd 3465 #define USE_QSPI_ARROW_BITMAPS
jmitc91516 6:dba3fbdfd5da 3466 if(needToScrollRampData){
jmitc91516 6:dba3fbdfd5da 3467 // Hard coded coords obtained - these will need to be changed
jmitc91516 6:dba3fbdfd5da 3468 // if we change the layout of the Column Method page in easyGUI
jmitc91516 8:26e49e6955bd 3469 #ifdef USE_QSPI_ARROW_BITMAPS
jmitc91516 8:26e49e6955bd 3470 if(qspiBitmaps != NULL) {
jmitc91516 8:26e49e6955bd 3471 qspiBitmaps->DisplayUpArrowBitmap(620, 250);
jmitc91516 8:26e49e6955bd 3472 qspiBitmaps->DisplayDownArrowBitmap(620, 350);
jmitc91516 8:26e49e6955bd 3473 }
jmitc91516 8:26e49e6955bd 3474 #else
jmitc91516 6:dba3fbdfd5da 3475 GuiLib_ShowBitmap(GuiStruct_Bitmap_UpArrow, 630, 260, -1); // No transparency
jmitc91516 6:dba3fbdfd5da 3476 GuiLib_ShowBitmap(GuiStruct_Bitmap_DownArrow, 630, 345, -1);
jmitc91516 8:26e49e6955bd 3477 #endif
jmitc91516 6:dba3fbdfd5da 3478 } else {
jmitc91516 6:dba3fbdfd5da 3479 // Blank out the whole area where the scroll buttons appear.
jmitc91516 8:26e49e6955bd 3480 // Note that, as always, the first coordinate pair in the call to 'GuiLib_ShowBitmapArea' has to be (0, 0)
jmitc91516 8:26e49e6955bd 3481 // to display the correct part of the bitmap - not, as one might expect, the same as the second coordinate pair
jmitc91516 8:26e49e6955bd 3482 #ifdef USE_QSPI_ARROW_BITMAPS
jmitc91516 8:26e49e6955bd 3483 GuiLib_ShowBitmapArea(GuiStruct_Bitmap_BlankBackground, 0, 0, 620, 250, 670, 390, -1); // -1 means 'no transparent colour'
jmitc91516 8:26e49e6955bd 3484 #undef USE_QSPI_ARROW_BITMAPS
jmitc91516 8:26e49e6955bd 3485 #else
jmitc91516 6:dba3fbdfd5da 3486 GuiLib_ShowBitmapArea(GuiStruct_Bitmap_BlankBackground, 0, 0, 630, 250, 670, 390, -1); // -1 means 'no transparent colour'
jmitc91516 8:26e49e6955bd 3487 #endif
jmitc91516 6:dba3fbdfd5da 3488 }
jmitc91516 6:dba3fbdfd5da 3489 }
jmitc91516 6:dba3fbdfd5da 3490
jmitc91516 6:dba3fbdfd5da 3491 /*
jmitc91516 6:dba3fbdfd5da 3492 General function to show or hide the scroll buttons on one of the XXX Method pages.
jmitc91516 6:dba3fbdfd5da 3493
jmitc91516 6:dba3fbdfd5da 3494 Args: pointer to the "MethodRampData" instance that is controlling this.
jmitc91516 6:dba3fbdfd5da 3495 */
jmitc91516 6:dba3fbdfd5da 3496 void GetGCStatusLoop::ShowMethodPageScrollButtonsIfNecessary(MethodRampData *methodRampData)
jmitc91516 6:dba3fbdfd5da 3497 {
jmitc91516 6:dba3fbdfd5da 3498 bool needToScrollRampData = false;
jmitc91516 6:dba3fbdfd5da 3499
jmitc91516 6:dba3fbdfd5da 3500 if(methodRampData != NULL) {
jmitc91516 6:dba3fbdfd5da 3501 needToScrollRampData = (methodRampData->GetScrollRange() > 0);
jmitc91516 6:dba3fbdfd5da 3502 }
jmitc91516 6:dba3fbdfd5da 3503
jmitc91516 6:dba3fbdfd5da 3504 ShowMethodPageScrollButtons(needToScrollRampData);
jmitc91516 6:dba3fbdfd5da 3505 }
jmitc91516 6:dba3fbdfd5da 3506
jmitc91516 6:dba3fbdfd5da 3507 /*
jmitc91516 6:dba3fbdfd5da 3508 Public function, allowing an external caller to tell us
jmitc91516 6:dba3fbdfd5da 3509 to display, or not, the ramp scroll buttons on the Column Method page.
jmitc91516 6:dba3fbdfd5da 3510
jmitc91516 6:dba3fbdfd5da 3511 Assume that the caller knows the Column Method page *is*
jmitc91516 6:dba3fbdfd5da 3512 currently being displayed.
jmitc91516 6:dba3fbdfd5da 3513 */
jmitc91516 6:dba3fbdfd5da 3514 void GetGCStatusLoop::ShowColumnMethodPageScrollButtonsIfNecessary(void)
jmitc91516 6:dba3fbdfd5da 3515 {
jmitc91516 6:dba3fbdfd5da 3516 ShowMethodPageScrollButtonsIfNecessary(columnMethodRampData);
jmitc91516 6:dba3fbdfd5da 3517 }
jmitc91516 6:dba3fbdfd5da 3518
jmitc91516 6:dba3fbdfd5da 3519 void GetGCStatusLoop::ScrollColumnMethodRampsUpIfPossible(void)
jmitc91516 6:dba3fbdfd5da 3520 {
jmitc91516 6:dba3fbdfd5da 3521 if(currentPage == GuiStruct_ColumnMethodPage_Def) {
jmitc91516 6:dba3fbdfd5da 3522 if(columnMethodPageScrollIndex > 0) {
jmitc91516 6:dba3fbdfd5da 3523 --columnMethodPageScrollIndex;
jmitc91516 6:dba3fbdfd5da 3524
jmitc91516 6:dba3fbdfd5da 3525 DisplayColumnMethodPageData(false);
jmitc91516 6:dba3fbdfd5da 3526 }
jmitc91516 6:dba3fbdfd5da 3527 }
jmitc91516 6:dba3fbdfd5da 3528 }
jmitc91516 6:dba3fbdfd5da 3529
jmitc91516 6:dba3fbdfd5da 3530 void GetGCStatusLoop::ScrollColumnMethodRampsDownIfPossible(void)
jmitc91516 6:dba3fbdfd5da 3531 {
jmitc91516 6:dba3fbdfd5da 3532 if(currentPage == GuiStruct_ColumnMethodPage_Def) {
jmitc91516 6:dba3fbdfd5da 3533 if(columnMethodRampData != NULL) {
jmitc91516 6:dba3fbdfd5da 3534 if(columnMethodPageScrollIndex < columnMethodRampData->GetScrollRange()) {
jmitc91516 6:dba3fbdfd5da 3535 ++columnMethodPageScrollIndex;
jmitc91516 6:dba3fbdfd5da 3536
jmitc91516 6:dba3fbdfd5da 3537 DisplayColumnMethodPageData(false);
jmitc91516 6:dba3fbdfd5da 3538 }
jmitc91516 6:dba3fbdfd5da 3539 }
jmitc91516 6:dba3fbdfd5da 3540 }
jmitc91516 6:dba3fbdfd5da 3541 }
jmitc91516 6:dba3fbdfd5da 3542
jmitc91516 6:dba3fbdfd5da 3543 /*
jmitc91516 5:aceac1035d71 3544 Displays the data on the column method page, by copying it to the relevant easyGUI variables,
jmitc91516 5:aceac1035d71 3545 and calling the relevant functions to actually display it.
jmitc91516 5:aceac1035d71 3546
jmitc91516 5:aceac1035d71 3547 Args: a boolean specifying whether or not the display is actually to be updated.
jmitc91516 5:aceac1035d71 3548 Even if it is false when we are called, we may set it true if we discover
jmitc91516 5:aceac1035d71 3549 one or more data items has changed - but note that we will not set it false
jmitc91516 5:aceac1035d71 3550 if it is already true. If it is true after we have looked at all
jmitc91516 5:aceac1035d71 3551 the home page data, we will then update the display. (If we are called
jmitc91516 5:aceac1035d71 3552 with this value set to false, the caller is effectively saying
jmitc91516 5:aceac1035d71 3553 'display the column page data only if it has changed').
jmitc91516 5:aceac1035d71 3554
jmitc91516 5:aceac1035d71 3555 No return code.
jmitc91516 5:aceac1035d71 3556 */
jmitc91516 5:aceac1035d71 3557 void GetGCStatusLoop::DisplayColumnMethodPageData(bool mustUpdateDisplay)
jmitc91516 5:aceac1035d71 3558 {
jmitc91516 5:aceac1035d71 3559 // EasyGUIDebugPrint("Column Method Page", 100, 100);
jmitc91516 5:aceac1035d71 3560 // Column temperature and maximum temperature
jmitc91516 5:aceac1035d71 3561 char buff[40];
jmitc91516 5:aceac1035d71 3562
jmitc91516 7:f0e645cf73a2 3563 #ifdef WANT_DOOR_ACTUATOR_BUTTONS_ON_COLUMN_PAGES
jmitc91516 5:aceac1035d71 3564 if(DoorActuatorButtonsHaveChanged(usbDevice, usbHostGC)) {
jmitc91516 5:aceac1035d71 3565 mustUpdateDisplay = true;
jmitc91516 5:aceac1035d71 3566 }
jmitc91516 5:aceac1035d71 3567
jmitc91516 5:aceac1035d71 3568 SetupDoorActuatorCommandUserInterface(usbDevice, usbHostGC, true);
jmitc91516 7:f0e645cf73a2 3569 #endif // WANT_DOOR_ACTUATOR_BUTTONS_ON_COLUMN_PAGES
jmitc91516 7:f0e645cf73a2 3570
jmitc91516 5:aceac1035d71 3571 GetColumnTargetTemperature(buff, "%s");
jmitc91516 5:aceac1035d71 3572 if(strcmp(buff, GuiVar_columnMethodInitialTemp) != 0) {
jmitc91516 5:aceac1035d71 3573 strcpy(GuiVar_columnMethodInitialTemp, buff);
jmitc91516 5:aceac1035d71 3574
jmitc91516 5:aceac1035d71 3575 //mustUpdateDisplay = true;
jmitc91516 5:aceac1035d71 3576 // No - just do this (don't force entire page to redisplay)
jmitc91516 5:aceac1035d71 3577 // Hard coded values taken from easyGUI
jmitc91516 6:dba3fbdfd5da 3578 RedrawSingleEasyGUIVariableOnComponentPage(520, 85, &GuiVar_columnMethodInitialTemp, GuiLib_ALIGN_RIGHT, COLUMN);
jmitc91516 5:aceac1035d71 3579 }
jmitc91516 5:aceac1035d71 3580
jmitc91516 5:aceac1035d71 3581 GetInitialHoldTime(buff);
jmitc91516 5:aceac1035d71 3582 if(strcmp(buff, GuiVar_columnMethodInitialHold) != 0) {
jmitc91516 5:aceac1035d71 3583 strcpy(GuiVar_columnMethodInitialHold, buff);
jmitc91516 5:aceac1035d71 3584
jmitc91516 5:aceac1035d71 3585 //mustUpdateDisplay = true;
jmitc91516 5:aceac1035d71 3586 // No - just do this (don't force entire page to redisplay)
jmitc91516 5:aceac1035d71 3587 // Hard coded values taken from easyGUI
jmitc91516 6:dba3fbdfd5da 3588 RedrawSingleEasyGUIVariableOnComponentPage(520, 120, &GuiVar_columnMethodInitialHold, GuiLib_ALIGN_RIGHT, COLUMN);
jmitc91516 5:aceac1035d71 3589 }
jmitc91516 5:aceac1035d71 3590
jmitc91516 5:aceac1035d71 3591 if(columnMethodRampData == NULL) {
jmitc91516 5:aceac1035d71 3592 columnMethodRampData = new ColumnMethodRampData(usbDevice, usbHostGC);
jmitc91516 5:aceac1035d71 3593 }
jmitc91516 5:aceac1035d71 3594
jmitc91516 5:aceac1035d71 3595 if(columnMethodRampData != NULL) {
jmitc91516 5:aceac1035d71 3596 if(!columnMethodRampData->GotRampData()) {
jmitc91516 5:aceac1035d71 3597 columnMethodRampData->GetRampDataFromGC();
jmitc91516 5:aceac1035d71 3598 }
jmitc91516 5:aceac1035d71 3599
jmitc91516 5:aceac1035d71 3600 sprintf(buff, "%u", columnMethodRampData->GetRampCount());
jmitc91516 5:aceac1035d71 3601 if(strcmp(buff, GuiVar_columnMethodRampCount) != 0) {
jmitc91516 5:aceac1035d71 3602 strcpy(GuiVar_columnMethodRampCount, buff);
jmitc91516 5:aceac1035d71 3603
jmitc91516 5:aceac1035d71 3604 //mustUpdateDisplay = true;
jmitc91516 5:aceac1035d71 3605 // No - just do this (don't force entire page to redisplay)
jmitc91516 5:aceac1035d71 3606 // Hard coded values taken from easyGUI
jmitc91516 6:dba3fbdfd5da 3607 RedrawSingleEasyGUIVariableOnComponentPage(520, 155, &GuiVar_columnMethodRampCount, GuiLib_ALIGN_RIGHT, COLUMN);
jmitc91516 6:dba3fbdfd5da 3608 }
jmitc91516 6:dba3fbdfd5da 3609
jmitc91516 6:dba3fbdfd5da 3610 if(columnMethodRampData->NeedToUpdateEasyGUIMethodPageRampVariables()) {
jmitc91516 6:dba3fbdfd5da 3611
jmitc91516 6:dba3fbdfd5da 3612 columnMethodPageScrollIndex = 0;
jmitc91516 6:dba3fbdfd5da 3613
jmitc91516 6:dba3fbdfd5da 3614 columnMethodRampData->UpdateEasyGUIMethodPageVariables(columnMethodPageScrollIndex);
jmitc91516 6:dba3fbdfd5da 3615
jmitc91516 6:dba3fbdfd5da 3616 previousColumnMethodPageScrollIndex = columnMethodPageScrollIndex;
jmitc91516 6:dba3fbdfd5da 3617
jmitc91516 6:dba3fbdfd5da 3618 mustUpdateDisplay = true; // Not practical to write all these variables individually
jmitc91516 6:dba3fbdfd5da 3619
jmitc91516 6:dba3fbdfd5da 3620 } else if (previousColumnMethodPageScrollIndex != columnMethodPageScrollIndex) {
jmitc91516 6:dba3fbdfd5da 3621
jmitc91516 6:dba3fbdfd5da 3622 columnMethodRampData->UpdateEasyGUIMethodPageVariables(columnMethodPageScrollIndex);
jmitc91516 6:dba3fbdfd5da 3623
jmitc91516 6:dba3fbdfd5da 3624 previousColumnMethodPageScrollIndex = columnMethodPageScrollIndex;
jmitc91516 6:dba3fbdfd5da 3625
jmitc91516 6:dba3fbdfd5da 3626 mustUpdateDisplay = true; // Not practical to write all these variables individually
jmitc91516 5:aceac1035d71 3627 }
jmitc91516 5:aceac1035d71 3628 }
jmitc91516 5:aceac1035d71 3629
jmitc91516 5:aceac1035d71 3630 if(SinglePageGCComponentStatusHasChanged(COLUMN)) {
jmitc91516 5:aceac1035d71 3631 mustUpdateDisplay = true;
jmitc91516 5:aceac1035d71 3632 }
jmitc91516 5:aceac1035d71 3633
jmitc91516 5:aceac1035d71 3634 if(mustUpdateDisplay) {
jmitc91516 5:aceac1035d71 3635
jmitc91516 5:aceac1035d71 3636 #ifdef WANT_COLUMN_STATUS_RECTANGLE
jmitc91516 5:aceac1035d71 3637 // Reduce display flickering - get the component status from the GC
jmitc91516 5:aceac1035d71 3638 // *before* we call GuiLib_Clear()
jmitc91516 5:aceac1035d71 3639 if(singleGCComponentPageStatusColorAreas != NULL) {
jmitc91516 5:aceac1035d71 3640 UpdateSingleGCComponentPageStatusColorArea(COLUMN);
jmitc91516 5:aceac1035d71 3641 }
jmitc91516 5:aceac1035d71 3642 #endif
jmitc91516 5:aceac1035d71 3643
jmitc91516 5:aceac1035d71 3644 #ifndef WANT_COLUMN_STATUS_RECTANGLE
jmitc91516 5:aceac1035d71 3645 #define WANT_GUILIB_CLEAR
jmitc91516 5:aceac1035d71 3646 #endif
jmitc91516 5:aceac1035d71 3647
jmitc91516 5:aceac1035d71 3648 #ifdef WANT_GUILIB_CLEAR
jmitc91516 5:aceac1035d71 3649 #ifdef USING_BACKGROUND_BITMAP
jmitc91516 5:aceac1035d71 3650 DrawBackgroundBitmap(); // We want the status rectangles to be 'on top' of this -
jmitc91516 5:aceac1035d71 3651 // if we include it in the easyGUI page itself, it gets drawn by GuiLib_ShowScreen,
jmitc91516 5:aceac1035d71 3652 // and overwrites the rectangles
jmitc91516 5:aceac1035d71 3653 #else
jmitc91516 5:aceac1035d71 3654 GuiLib_Clear();
jmitc91516 5:aceac1035d71 3655 #endif
jmitc91516 5:aceac1035d71 3656 #undef WANT_GUILIB_CLEAR
jmitc91516 5:aceac1035d71 3657 #endif
jmitc91516 5:aceac1035d71 3658 //...except that redrawing the status rectangle effectively clears the text on top of the rectangle -
jmitc91516 5:aceac1035d71 3659 // so we do not need GuiLib_Clear here, since all the column page data appears on top of the rectangle.
jmitc91516 5:aceac1035d71 3660 // Without it, only the text flickers, not the rectangle
jmitc91516 5:aceac1035d71 3661
jmitc91516 5:aceac1035d71 3662 #ifdef WANT_COLUMN_STATUS_RECTANGLE
jmitc91516 5:aceac1035d71 3663 // Note - we draw the status rectangle after GuiLib_Clear - otherwise we wouldn't see the rectangles at all -
jmitc91516 5:aceac1035d71 3664 // and before GuiLib_ShowScreen - so text, etc, is drawn on top of the rectangles
jmitc91516 5:aceac1035d71 3665 if(singleGCComponentPageStatusColorAreas != NULL) {
jmitc91516 5:aceac1035d71 3666 singleGCComponentPageStatusColorAreas->DisplayGCComponentStatus(COLUMN);
jmitc91516 5:aceac1035d71 3667 }
jmitc91516 5:aceac1035d71 3668 #endif
jmitc91516 5:aceac1035d71 3669
jmitc91516 5:aceac1035d71 3670 // And (currently) we draw the component bitmap on top of the rectangle
jmitc91516 5:aceac1035d71 3671 if(qspiBitmaps != NULL) {
jmitc91516 5:aceac1035d71 3672 qspiBitmaps->DisplayColumnComponentBitmap();
jmitc91516 5:aceac1035d71 3673 }
jmitc91516 5:aceac1035d71 3674
jmitc91516 5:aceac1035d71 3675 GuiLib_ShowScreen(GuiStruct_ColumnMethodPage_Def, GuiLib_NO_CURSOR, GuiLib_RESET_AUTO_REDRAW);
jmitc91516 5:aceac1035d71 3676
jmitc91516 7:f0e645cf73a2 3677 #ifdef WANT_DOOR_ACTUATOR_BUTTONS_ON_COLUMN_PAGES
jmitc91516 5:aceac1035d71 3678 SetupDoorActuatorCommandUserInterface(usbDevice, usbHostGC, false);
jmitc91516 7:f0e645cf73a2 3679 #endif // WANT_DOOR_ACTUATOR_BUTTONS_ON_COLUMN_PAGES
jmitc91516 7:f0e645cf73a2 3680
jmitc91516 7:f0e645cf73a2 3681 ShowMethodPageScrollButtonsIfNecessary(columnMethodRampData);
jmitc91516 5:aceac1035d71 3682
jmitc91516 5:aceac1035d71 3683 GuiLib_Refresh();
jmitc91516 5:aceac1035d71 3684 }
jmitc91516 5:aceac1035d71 3685 }
jmitc91516 5:aceac1035d71 3686
jmitc91516 5:aceac1035d71 3687
jmitc91516 5:aceac1035d71 3688
jmitc91516 1:a5258871b33d 3689 /*
jmitc91516 1:a5258871b33d 3690 Column temperature profile X axis units may be minutes or seconds.
jmitc91516 1:a5258871b33d 3691 Sets up the label easyGUI variable appropriately.
jmitc91516 1:a5258871b33d 3692 */
jmitc91516 1:a5258871b33d 3693 void GetGCStatusLoop::SetupColumnTempProfilePageXAxisLabel(TimeUnit timeUnit)
jmitc91516 1:a5258871b33d 3694 {
jmitc91516 1:a5258871b33d 3695 if(timeUnit == SECONDS) {
jmitc91516 1:a5258871b33d 3696 strcpy(GuiVar_columnTempProfilePageXAxisLabel, "Time (seconds)");
jmitc91516 1:a5258871b33d 3697 } else {
jmitc91516 1:a5258871b33d 3698 strcpy(GuiVar_columnTempProfilePageXAxisLabel, "Time (minutes)");
jmitc91516 1:a5258871b33d 3699 }
jmitc91516 1:a5258871b33d 3700 }
jmitc91516 1:a5258871b33d 3701
jmitc91516 1:a5258871b33d 3702 /*
jmitc91516 1:a5258871b33d 3703 Injector temperature profile X axis units may be minutes or seconds.
jmitc91516 1:a5258871b33d 3704 Sets up the label easyGUI variable appropriately.
jmitc91516 1:a5258871b33d 3705 */
jmitc91516 1:a5258871b33d 3706 void GetGCStatusLoop::SetupInjectorTempProfilePageXAxisLabel(TimeUnit timeUnit)
jmitc91516 1:a5258871b33d 3707 {
jmitc91516 1:a5258871b33d 3708 if(timeUnit == SECONDS) {
jmitc91516 1:a5258871b33d 3709 strcpy(GuiVar_injectorTempProfilePageXAxisLabel, "Time (seconds)");
jmitc91516 1:a5258871b33d 3710 } else {
jmitc91516 1:a5258871b33d 3711 strcpy(GuiVar_injectorTempProfilePageXAxisLabel, "Time (minutes)");
jmitc91516 1:a5258871b33d 3712 }
jmitc91516 1:a5258871b33d 3713 }
jmitc91516 1:a5258871b33d 3714
jmitc91516 1:a5258871b33d 3715
jmitc91516 1:a5258871b33d 3716 /*
jmitc91516 1:a5258871b33d 3717 Sets up the data for the graph on either the Column Temperature Profile page,
jmitc91516 1:a5258871b33d 3718 or the Column (directly heated) Temperature Profile page,
jmitc91516 1:a5258871b33d 3719 and causes it to be displayed
jmitc91516 1:a5258871b33d 3720 */
jmitc91516 1:a5258871b33d 3721 void GetGCStatusLoop::DisplayColumnTempProfilePageGraph(ColumnType columnType)
jmitc91516 1:a5258871b33d 3722 {
jmitc91516 5:aceac1035d71 3723 GuiLibGraph* graphToUse = columnTempProfilePageGraph;
jmitc91516 1:a5258871b33d 3724
jmitc91516 1:a5258871b33d 3725 if(graphToUse == NULL) {
jmitc91516 1:a5258871b33d 3726 return; // Nothing to do
jmitc91516 1:a5258871b33d 3727 }
jmitc91516 1:a5258871b33d 3728
jmitc91516 1:a5258871b33d 3729 // - dataset 0 is a line representing the temperature profile of the run from 'now' to the finish
jmitc91516 1:a5258871b33d 3730 // - dataset 1 is a bar chart representing the temperature profile of the run from 'now' to the finish
jmitc91516 1:a5258871b33d 3731 // - dataset 2 is a line representing the temperature profile from the start to 'now'
jmitc91516 1:a5258871b33d 3732 // - dataset 3 is a bar chart representing the temperature profile of the run from the start to 'now'
jmitc91516 1:a5258871b33d 3733 // - dataset 4 is a single dot at the current time and temperature
jmitc91516 1:a5258871b33d 3734
jmitc91516 1:a5258871b33d 3735 TimeUnit timeUnit = MINUTES;
jmitc91516 1:a5258871b33d 3736 if(columnTempProfilePageGraphCompleteProfileDataSet->GetTotalMethodTime() < methodTimeUnitsThreshold) {
jmitc91516 1:a5258871b33d 3737 timeUnit = SECONDS;
jmitc91516 1:a5258871b33d 3738 }
jmitc91516 1:a5258871b33d 3739
jmitc91516 1:a5258871b33d 3740 const float yAxisScaleFactor = 10.0f;
jmitc91516 1:a5258871b33d 3741
jmitc91516 1:a5258871b33d 3742 // Dataset 0
jmitc91516 1:a5258871b33d 3743 graphToUse->SetDataForGraphDataSetInTenthsOfMinutes(0, yAxisScaleFactor, columnTempProfilePageGraphDataSet0);
jmitc91516 1:a5258871b33d 3744
jmitc91516 1:a5258871b33d 3745 // Dataset 1
jmitc91516 1:a5258871b33d 3746 graphToUse->SetDataForGraphDataSetInTenthsOfMinutes(1, yAxisScaleFactor, columnTempProfilePageGraphDataSet1);
jmitc91516 1:a5258871b33d 3747
jmitc91516 1:a5258871b33d 3748 // Dataset 2
jmitc91516 1:a5258871b33d 3749 graphToUse->SetDataForGraphDataSetInTenthsOfMinutes(2, yAxisScaleFactor, columnTempProfilePageGraphDataSet2);
jmitc91516 1:a5258871b33d 3750
jmitc91516 1:a5258871b33d 3751 // Dataset 3
jmitc91516 1:a5258871b33d 3752 graphToUse->SetDataForGraphDataSetInTenthsOfMinutes(3, yAxisScaleFactor, columnTempProfilePageGraphDataSet3);
jmitc91516 1:a5258871b33d 3753
jmitc91516 1:a5258871b33d 3754 // Dataset 4
jmitc91516 1:a5258871b33d 3755 graphToUse->SetDataForGraphDataSetInTenthsOfMinutes(4, yAxisScaleFactor, columnTempProfilePageGraphDataSet4);
jmitc91516 1:a5258871b33d 3756
jmitc91516 1:a5258871b33d 3757 graphToUse->SetXAxisUnits(timeUnit);
jmitc91516 1:a5258871b33d 3758
jmitc91516 1:a5258871b33d 3759 // The tick sizes must match those set in easyGUI - we do not seem
jmitc91516 1:a5258871b33d 3760 // to be able to get them at runtime
jmitc91516 1:a5258871b33d 3761 GuiConst_INT32S minX, maxX;
jmitc91516 1:a5258871b33d 3762 //GuiConst_INT32S tickSize = (timeUnit == SECONDS) ? 300 : 100;
jmitc91516 1:a5258871b33d 3763 // Always in 1/10 minutes
jmitc91516 1:a5258871b33d 3764 GuiConst_INT32S xAxisTickSize = (timeUnit == SECONDS) ? 5 : 100; // 5 == 0.5 minutes (i.e. 30 seconds), 100 == 10 minutes
jmitc91516 1:a5258871b33d 3765 columnTempProfilePageGraphCompleteProfileDataSet->GetXAxisRangeInTenthsOfMinutes(&minX, &maxX, xAxisTickSize );
jmitc91516 1:a5258871b33d 3766 graphToUse->SetXAxisRange(0, maxX); // Always start X axis at zero
jmitc91516 1:a5258871b33d 3767
jmitc91516 1:a5258871b33d 3768 GuiConst_INT32S minY, maxY;
jmitc91516 1:a5258871b33d 3769 GuiConst_INT32S yAxisTickSize = 50;
jmitc91516 1:a5258871b33d 3770 columnTempProfilePageGraphCompleteProfileDataSet->GetYAxisRange(&minY, &maxY, yAxisTickSize);
jmitc91516 1:a5258871b33d 3771 graphToUse->SetYAxisRange(0, (maxY * yAxisScaleFactor)); // Always start Y axis at zero
jmitc91516 1:a5258871b33d 3772
jmitc91516 1:a5258871b33d 3773
jmitc91516 1:a5258871b33d 3774 graphToUse->DrawAxes();
jmitc91516 1:a5258871b33d 3775
jmitc91516 1:a5258871b33d 3776 // Graph coordinates copied from easyGUI - I cannot find a way of obtaining them at runtime.
jmitc91516 1:a5258871b33d 3777 // We need to draw the X axis labels ourselves, since our time values are in units of 0.1 minute,
jmitc91516 1:a5258871b33d 3778 // but easyGUI graphs work only in integers - we therefore have to multiply the time values by 10
jmitc91516 1:a5258871b33d 3779 // before passing them to easyGUI, and if we let easyGUI draw its own values on the X axis,
jmitc91516 1:a5258871b33d 3780 // they would be 10 times the correct values.
jmitc91516 1:a5258871b33d 3781 if(timeUnit == SECONDS) {
jmitc91516 1:a5258871b33d 3782 graphToUse->DrawXAxisLabels(0, (maxX * 6), (xAxisTickSize * 6), 130, 340, 500);
jmitc91516 1:a5258871b33d 3783 } else {
jmitc91516 1:a5258871b33d 3784 graphToUse->DrawXAxisLabels(0, (maxX / 10), (xAxisTickSize / 10), 130, 340, 500);
jmitc91516 1:a5258871b33d 3785 }
jmitc91516 1:a5258871b33d 3786 // Note that we repeat this call by calling 'DrawXAxisLabels' without arguments
jmitc91516 1:a5258871b33d 3787 // every time we (re)display this page
jmitc91516 1:a5258871b33d 3788
jmitc91516 1:a5258871b33d 3789 // Similar to the X axis - the values we pass to the easyGUI graph are scaled to be larger
jmitc91516 1:a5258871b33d 3790 // than the real values, to get round the fact that easyGUI graphs work in integers.
jmitc91516 1:a5258871b33d 3791 // (This can cause the profile to appear to be 'stepped', which obviously we do not want.)
jmitc91516 1:a5258871b33d 3792 // We must therefore draw the Y axis values ourselves.
jmitc91516 1:a5258871b33d 3793 graphToUse->DrawYAxisLabels(0, maxY, yAxisTickSize, 130, 340, 250);
jmitc91516 1:a5258871b33d 3794 // Note that we repeat this call by calling 'DrawYAxisLabels' without arguments
jmitc91516 1:a5258871b33d 3795 // every time we (re)display this page
jmitc91516 1:a5258871b33d 3796
jmitc91516 1:a5258871b33d 3797 graphToUse->DrawDataSet(0);
jmitc91516 1:a5258871b33d 3798 graphToUse->ShowDataSet(0);
jmitc91516 1:a5258871b33d 3799
jmitc91516 1:a5258871b33d 3800 graphToUse->DrawDataSet(1);
jmitc91516 1:a5258871b33d 3801 graphToUse->ShowDataSet(1);
jmitc91516 1:a5258871b33d 3802
jmitc91516 1:a5258871b33d 3803 graphToUse->DrawDataSet(2);
jmitc91516 1:a5258871b33d 3804 graphToUse->ShowDataSet(2);
jmitc91516 1:a5258871b33d 3805
jmitc91516 1:a5258871b33d 3806 graphToUse->DrawDataSet(3);
jmitc91516 1:a5258871b33d 3807 graphToUse->ShowDataSet(3);
jmitc91516 1:a5258871b33d 3808
jmitc91516 1:a5258871b33d 3809 graphToUse->DrawDataSet(4);
jmitc91516 1:a5258871b33d 3810 graphToUse->ShowDataSet(4);
jmitc91516 1:a5258871b33d 3811
jmitc91516 1:a5258871b33d 3812 graphToUse->Redraw();
jmitc91516 1:a5258871b33d 3813
jmitc91516 1:a5258871b33d 3814 #ifdef TEST_GUILIB_VLINE_PROFILES
jmitc91516 1:a5258871b33d 3815 // *** TESTING *** Draw the profile as a solid colour, direct to the display
jmitc91516 1:a5258871b33d 3816 // Coords manually copied from easyGUI application.
jmitc91516 1:a5258871b33d 3817 // Boundary between colours is arbitrary for now
jmitc91516 1:a5258871b33d 3818 GuiConst_INTCOLOR graphColour1 = SixteenBitColorValue(100, 100, 100);
jmitc91516 1:a5258871b33d 3819 GuiConst_INTCOLOR graphColour2 = SixteenBitColorValue(200, 200, 200);
jmitc91516 6:dba3fbdfd5da 3820 // double colourBoundaryX = (double) columnTempProfilePageGraphCompleteProfileDataSet->GetTotalMethodTime() / 5.0; // Should be one-fifth across the profile
jmitc91516 6:dba3fbdfd5da 3821 double colourBoundaryX = -1.0; // No - use one colour only
jmitc91516 1:a5258871b33d 3822 if(timeUnit == SECONDS) {
jmitc91516 1:a5258871b33d 3823 columnTempProfilePageGraphCompleteProfileDataSet->DrawUsingGuiLibVLine(140, 330, ((double) 500 / (double) (maxX * 6)), ((double) -250 / (double) maxY), graphColour1, graphColour2, colourBoundaryX);
jmitc91516 1:a5258871b33d 3824 } else {
jmitc91516 1:a5258871b33d 3825 columnTempProfilePageGraphCompleteProfileDataSet->DrawUsingGuiLibVLine(140, 330, ((double) 500 / (double) (maxX / 10)), ((double) -250 / (double) maxY), graphColour1, graphColour2, colourBoundaryX);
jmitc91516 1:a5258871b33d 3826 }
jmitc91516 1:a5258871b33d 3827 #endif // TEST_GUILIB_VLINE_PROFILES
jmitc91516 1:a5258871b33d 3828 }
jmitc91516 1:a5258871b33d 3829
jmitc91516 1:a5258871b33d 3830 /*
jmitc91516 1:a5258871b33d 3831 Displays the data on the column temperature profile page,
jmitc91516 1:a5258871b33d 3832 by copying it to the relevant easyGUI variables,
jmitc91516 1:a5258871b33d 3833 and calling the relevant functions to actually display it.
jmitc91516 1:a5258871b33d 3834
jmitc91516 1:a5258871b33d 3835 Args: a boolean specifying whether or not the display is actually to be updated.
jmitc91516 1:a5258871b33d 3836 Even if it is false when we are called, we may set it true if we discover
jmitc91516 1:a5258871b33d 3837 one or more data items has changed - but note that we will not set it false
jmitc91516 1:a5258871b33d 3838 if it is already true. If it is true after we have looked at all
jmitc91516 1:a5258871b33d 3839 the home page data, we will then update the display. (If we are called
jmitc91516 1:a5258871b33d 3840 with this value set to false, the caller is effectively saying
jmitc91516 1:a5258871b33d 3841 'display the column temperature page data only if it has changed').
jmitc91516 1:a5258871b33d 3842
jmitc91516 1:a5258871b33d 3843 No return code.
jmitc91516 1:a5258871b33d 3844 */
jmitc91516 1:a5258871b33d 3845 void GetGCStatusLoop::DisplayColumnTempProfilePageData(bool mustUpdateDisplay, ColumnType columnType, int pageNumber)
jmitc91516 1:a5258871b33d 3846 {
jmitc91516 1:a5258871b33d 3847 // Ensure this is always up to date
jmitc91516 1:a5258871b33d 3848 if(needToUpdateProfileGraphs) {
jmitc91516 1:a5258871b33d 3849 SetupColumnAndInjectorAndGasProfileData();
jmitc91516 1:a5258871b33d 3850 mustUpdateDisplay = true;
jmitc91516 1:a5258871b33d 3851
jmitc91516 1:a5258871b33d 3852 needToUpdateProfileGraphs = false;
jmitc91516 1:a5258871b33d 3853 }
jmitc91516 1:a5258871b33d 3854
jmitc91516 1:a5258871b33d 3855 DisplayColumnTempProfilePageGraph(columnType);
jmitc91516 1:a5258871b33d 3856
jmitc91516 7:f0e645cf73a2 3857 #ifdef WANT_DOOR_ACTUATOR_BUTTONS_ON_COLUMN_PAGES
jmitc91516 1:a5258871b33d 3858 if(DoorActuatorButtonsHaveChanged(usbDevice, usbHostGC)) {
jmitc91516 1:a5258871b33d 3859 mustUpdateDisplay = true;
jmitc91516 1:a5258871b33d 3860 }
jmitc91516 1:a5258871b33d 3861
jmitc91516 1:a5258871b33d 3862 SetupDoorActuatorCommandUserInterface(usbDevice, usbHostGC, true);
jmitc91516 7:f0e645cf73a2 3863 #endif // WANT_DOOR_ACTUATOR_BUTTONS_ON_COLUMN_PAGES
jmitc91516 1:a5258871b33d 3864
jmitc91516 1:a5258871b33d 3865 if(SinglePageGCComponentStatusHasChanged(COLUMN)) {
jmitc91516 1:a5258871b33d 3866 mustUpdateDisplay = true;
jmitc91516 1:a5258871b33d 3867 }
jmitc91516 1:a5258871b33d 3868
jmitc91516 1:a5258871b33d 3869 if(mustUpdateDisplay) {
jmitc91516 1:a5258871b33d 3870
jmitc91516 3:010aeeacd7d7 3871 #ifdef WANT_COLUMN_STATUS_RECTANGLE
jmitc91516 1:a5258871b33d 3872 // Reduce display flickering - get the component status from the GC
jmitc91516 1:a5258871b33d 3873 // *before* we call GuiLib_Clear()
jmitc91516 1:a5258871b33d 3874 if(singleGCComponentPageStatusColorAreas != NULL) {
jmitc91516 1:a5258871b33d 3875 UpdateSingleGCComponentPageStatusColorArea(COLUMN);
jmitc91516 1:a5258871b33d 3876 }
jmitc91516 3:010aeeacd7d7 3877 #endif
jmitc91516 3:010aeeacd7d7 3878
jmitc91516 3:010aeeacd7d7 3879 #ifndef WANT_COLUMN_STATUS_RECTANGLE
jmitc91516 1:a5258871b33d 3880 // Makes the display flicker - but omitting it means old text is not cleared from the display
jmitc91516 3:010aeeacd7d7 3881 #define WANT_GUILIB_CLEAR
jmitc91516 3:010aeeacd7d7 3882 #endif
jmitc91516 3:010aeeacd7d7 3883
jmitc91516 1:a5258871b33d 3884 #ifdef WANT_GUILIB_CLEAR
jmitc91516 1:a5258871b33d 3885 #ifdef USING_BACKGROUND_BITMAP
jmitc91516 1:a5258871b33d 3886 DrawBackgroundBitmap(); // We want the status rectangles to be 'on top' of this -
jmitc91516 1:a5258871b33d 3887 // if we include it in the easyGUI page itself, it gets drawn by GuiLib_ShowScreen,
jmitc91516 1:a5258871b33d 3888 // and overwrites the rectangles
jmitc91516 1:a5258871b33d 3889 #else
jmitc91516 1:a5258871b33d 3890 GuiLib_Clear();
jmitc91516 1:a5258871b33d 3891 #endif
jmitc91516 1:a5258871b33d 3892 #undef WANT_GUILIB_CLEAR
jmitc91516 1:a5258871b33d 3893 #endif
jmitc91516 1:a5258871b33d 3894 //...except that redrawing the status rectangle effectively clears the text on top of the rectangle -
jmitc91516 1:a5258871b33d 3895 // so we do not need GuiLib_Clear here, since all the injector page data appears on top of the rectangle.
jmitc91516 1:a5258871b33d 3896 // Without it, only the text flickers, not the rectangle
jmitc91516 1:a5258871b33d 3897
jmitc91516 1:a5258871b33d 3898 // Note - we draw the status rectangle after GuiLib_Clear - otherwise we wouldn't see the rectangles at all -
jmitc91516 1:a5258871b33d 3899 // and before GuiLib_ShowScreen - so text, etc, is drawn on top of the rectangles
jmitc91516 3:010aeeacd7d7 3900 #ifdef WANT_COLUMN_STATUS_RECTANGLE
jmitc91516 1:a5258871b33d 3901 if(singleGCComponentPageStatusColorAreas != NULL) {
jmitc91516 1:a5258871b33d 3902 singleGCComponentPageStatusColorAreas->DisplayGCComponentStatus(COLUMN);
jmitc91516 1:a5258871b33d 3903 }
jmitc91516 3:010aeeacd7d7 3904 #endif
jmitc91516 3:010aeeacd7d7 3905
jmitc91516 7:f0e645cf73a2 3906 #ifdef WANT_COMPONENT_ICON_ON_PROFILE_PAGES
jmitc91516 4:6840cf2b153a 3907 // And (currently) we draw the component bitmap on top of the rectangle
jmitc91516 4:6840cf2b153a 3908 if(qspiBitmaps != NULL) {
jmitc91516 4:6840cf2b153a 3909 qspiBitmaps->DisplayColumnComponentBitmap();
jmitc91516 4:6840cf2b153a 3910 }
jmitc91516 7:f0e645cf73a2 3911 #endif // WANT_COMPONENT_ICON_ON_PROFILE_PAGES
jmitc91516 1:a5258871b33d 3912
jmitc91516 5:aceac1035d71 3913 GuiLibGraph* graphToUse = columnTempProfilePageGraph;
jmitc91516 1:a5258871b33d 3914
jmitc91516 1:a5258871b33d 3915 if(graphToUse != NULL) {
jmitc91516 1:a5258871b33d 3916 graphToUse->Redraw();
jmitc91516 1:a5258871b33d 3917 }
jmitc91516 1:a5258871b33d 3918
jmitc91516 1:a5258871b33d 3919 // Also in DisplayEasyGUIStructure, main.cpp
jmitc91516 1:a5258871b33d 3920 //#define SWIM_TEST
jmitc91516 1:a5258871b33d 3921 #ifdef SWIM_TEST
jmitc91516 1:a5258871b33d 3922 SwimDraw* swimDrawInstance = SwimDraw::GetInstance();
jmitc91516 1:a5258871b33d 3923 if(swimDrawInstance != NULL) {
jmitc91516 1:a5258871b33d 3924 // two horizontal boxes
jmitc91516 1:a5258871b33d 3925 swimDrawInstance->DrawRectangle(SixteenBitColorValue(0xFF, 0, 0), 50, 200, 650, 250);
jmitc91516 1:a5258871b33d 3926 swimDrawInstance->DrawRectangle(SixteenBitColorValue(0, 0, 0xFF), 50, 350, 650, 400);
jmitc91516 1:a5258871b33d 3927
jmitc91516 1:a5258871b33d 3928 // two vertical boxes
jmitc91516 1:a5258871b33d 3929 swimDrawInstance->DrawRectangle(SixteenBitColorValue(0xFF, 0, 0), 100, 50, 150, 350);
jmitc91516 1:a5258871b33d 3930 swimDrawInstance->DrawRectangle(SixteenBitColorValue(0, 0, 0xFF), 500, 50, 550, 350);
jmitc91516 1:a5258871b33d 3931 }
jmitc91516 1:a5258871b33d 3932 #else // Draw the same boxes with easyGUI
jmitc91516 1:a5258871b33d 3933 // GuiLib_FillBox(50, 200, 650, 250, SixteenBitColorValue(0xFF, 0, 0));
jmitc91516 1:a5258871b33d 3934 // GuiLib_FillBox(50, 350, 650, 400, SixteenBitColorValue(0, 0, 0xFF));
jmitc91516 1:a5258871b33d 3935
jmitc91516 1:a5258871b33d 3936 // GuiLib_FillBox(100, 50, 150, 350, SixteenBitColorValue(0xFF, 0, 0));
jmitc91516 1:a5258871b33d 3937 // GuiLib_FillBox(500, 50, 550, 350, SixteenBitColorValue(0, 0, 0xFF));
jmitc91516 1:a5258871b33d 3938
jmitc91516 1:a5258871b33d 3939 // No - draw a dummy profile section
jmitc91516 1:a5258871b33d 3940 // DrawProfileSectionUsingGuiLibVLine(SixteenBitColorValue(0xFF, 0, 0), 300, 500, 350, 200, 125);
jmitc91516 1:a5258871b33d 3941
jmitc91516 8:26e49e6955bd 3942 #ifdef TEST_GUILIB_VLINE_PROFILES
jmitc91516 1:a5258871b33d 3943 // Now draw the profile as a solid colour, direct to the display.
jmitc91516 1:a5258871b33d 3944 // Use the same parameters as the previous call, in DisplayColumnTempProfilePageGraph
jmitc91516 1:a5258871b33d 3945 columnTempProfilePageGraphCompleteProfileDataSet->DrawUsingGuiLibVLine();
jmitc91516 8:26e49e6955bd 3946 #endif // TEST_GUILIB_VLINE_PROFILES
jmitc91516 1:a5258871b33d 3947 #endif // SWIM_TEST
jmitc91516 1:a5258871b33d 3948
jmitc91516 1:a5258871b33d 3949 GuiLib_ShowScreen(pageNumber, GuiLib_NO_CURSOR, GuiLib_RESET_AUTO_REDRAW);
jmitc91516 1:a5258871b33d 3950
jmitc91516 1:a5258871b33d 3951 // Repeat the previous call to the version of this function with parameters,
jmitc91516 1:a5258871b33d 3952 // made from 'DisplayColumnTempProfilePageGraph()' above (it is more convenient
jmitc91516 1:a5258871b33d 3953 // to calculate the parameter values in 'DisplayColumnTempProfilePageGraph()' than here)
jmitc91516 1:a5258871b33d 3954 if(graphToUse != NULL) {
jmitc91516 1:a5258871b33d 3955 graphToUse->DrawXAxisLabels();
jmitc91516 1:a5258871b33d 3956 graphToUse->DrawYAxisLabels();
jmitc91516 1:a5258871b33d 3957 }
jmitc91516 1:a5258871b33d 3958
jmitc91516 7:f0e645cf73a2 3959 #ifdef WANT_DOOR_ACTUATOR_BUTTONS_ON_COLUMN_PAGES
jmitc91516 1:a5258871b33d 3960 SetupDoorActuatorCommandUserInterface(usbDevice, usbHostGC, false);
jmitc91516 7:f0e645cf73a2 3961 #endif // WANT_DOOR_ACTUATOR_BUTTONS_ON_COLUMN_PAGES
jmitc91516 1:a5258871b33d 3962
jmitc91516 1:a5258871b33d 3963 GuiLib_Refresh();
jmitc91516 1:a5258871b33d 3964
jmitc91516 1:a5258871b33d 3965 #define DEBUG_HERE
jmitc91516 1:a5258871b33d 3966 #ifdef DEBUG_HERE
jmitc91516 1:a5258871b33d 3967 char dbg[100];
jmitc91516 1:a5258871b33d 3968 sprintf(dbg, "After GuiLib_Clear 3");
jmitc91516 1:a5258871b33d 3969 EasyGUIDebugPrint(dbg, 0, 20);
jmitc91516 1:a5258871b33d 3970 #undef DEBUG_HERE
jmitc91516 1:a5258871b33d 3971 #endif
jmitc91516 1:a5258871b33d 3972 }
jmitc91516 1:a5258871b33d 3973 }
jmitc91516 1:a5258871b33d 3974
jmitc91516 1:a5258871b33d 3975
jmitc91516 1:a5258871b33d 3976 /*
jmitc91516 1:a5258871b33d 3977 Public function that calls DisplayColumnPageData -
jmitc91516 1:a5258871b33d 3978 provided so that 'TouchCallback' (main.cpp) can cause
jmitc91516 1:a5258871b33d 3979 the column page to be redisplayed in response to the user
jmitc91516 1:a5258871b33d 3980 touching one of the up or down buttons on the relevant easyGUI page
jmitc91516 1:a5258871b33d 3981 */
jmitc91516 1:a5258871b33d 3982 void GetGCStatusLoop::RedisplayColumnPage(void)
jmitc91516 1:a5258871b33d 3983 {
jmitc91516 1:a5258871b33d 3984 if(currentPage == GuiStruct_ColumnPage1_2) {
jmitc91516 1:a5258871b33d 3985 DisplayColumnPageData(true, CONVENTIONAL_COLUMN, GuiStruct_ColumnPage1_2);
jmitc91516 1:a5258871b33d 3986 }
jmitc91516 1:a5258871b33d 3987 // else we are displaying a different page - disastrous to call DisplayColumnPageData()
jmitc91516 1:a5258871b33d 3988 }
jmitc91516 1:a5258871b33d 3989
jmitc91516 1:a5258871b33d 3990
jmitc91516 1:a5258871b33d 3991 void GetGCStatusLoop::DisplayColumnDHAutoCalibrationPageData(bool mustUpdateDisplay)
jmitc91516 1:a5258871b33d 3992 {
jmitc91516 1:a5258871b33d 3993 ColumnDHAutoCalibrationPageHandler *columnDHAutoCalibrationPageHandler = ColumnDHAutoCalibrationPageHandler::GetInstance(usbDevice, usbHostGC);
jmitc91516 1:a5258871b33d 3994
jmitc91516 1:a5258871b33d 3995 if(columnDHAutoCalibrationPageHandler != NULL) {
jmitc91516 1:a5258871b33d 3996 columnDHAutoCalibrationPageHandler->UpdateVolatileEasyGUIVariables();
jmitc91516 1:a5258871b33d 3997 }
jmitc91516 1:a5258871b33d 3998
jmitc91516 1:a5258871b33d 3999 if(DoorActuatorButtonsHaveChanged(usbDevice, usbHostGC)) {
jmitc91516 1:a5258871b33d 4000 mustUpdateDisplay = true;
jmitc91516 1:a5258871b33d 4001 }
jmitc91516 1:a5258871b33d 4002
jmitc91516 1:a5258871b33d 4003 SetupDoorActuatorCommandUserInterface(usbDevice, usbHostGC, true);
jmitc91516 1:a5258871b33d 4004
jmitc91516 1:a5258871b33d 4005 if(SinglePageGCComponentStatusHasChanged(COLUMN)) {
jmitc91516 1:a5258871b33d 4006 mustUpdateDisplay = true;
jmitc91516 1:a5258871b33d 4007 }
jmitc91516 1:a5258871b33d 4008
jmitc91516 1:a5258871b33d 4009 if(mustUpdateDisplay) {
jmitc91516 1:a5258871b33d 4010
jmitc91516 1:a5258871b33d 4011 // Reduce display flickering - get the component status from the GC
jmitc91516 1:a5258871b33d 4012 // *before* we call GuiLib_Clear()
jmitc91516 1:a5258871b33d 4013 if(singleGCComponentPageStatusColorAreas != NULL) {
jmitc91516 1:a5258871b33d 4014 UpdateSingleGCComponentPageStatusColorArea(COLUMN);
jmitc91516 1:a5258871b33d 4015 }
jmitc91516 1:a5258871b33d 4016
jmitc91516 1:a5258871b33d 4017 // Makes the display flicker - but omitting it means old text is not cleared from the display
jmitc91516 1:a5258871b33d 4018 //#define WANT_GUILIB_CLEAR
jmitc91516 1:a5258871b33d 4019 #ifdef WANT_GUILIB_CLEAR
jmitc91516 1:a5258871b33d 4020 #ifdef USING_BACKGROUND_BITMAP
jmitc91516 1:a5258871b33d 4021 DrawBackgroundBitmap(); // We want the status rectangles to be 'on top' of this -
jmitc91516 1:a5258871b33d 4022 // if we include it in the easyGUI page itself, it gets drawn by GuiLib_ShowScreen,
jmitc91516 1:a5258871b33d 4023 // and overwrites the rectangles
jmitc91516 1:a5258871b33d 4024 #else
jmitc91516 1:a5258871b33d 4025 GuiLib_Clear();
jmitc91516 1:a5258871b33d 4026 #endif
jmitc91516 1:a5258871b33d 4027 #undef WANT_GUILIB_CLEAR
jmitc91516 1:a5258871b33d 4028 #endif
jmitc91516 1:a5258871b33d 4029 //...except that redrawing the status rectangle effectively clears the text on top of the rectangle -
jmitc91516 1:a5258871b33d 4030 // so we do not need GuiLib_Clear here, since all the injector page data appears on top of the rectangle.
jmitc91516 1:a5258871b33d 4031 // Without it, only the text flickers, not the rectangle
jmitc91516 1:a5258871b33d 4032
jmitc91516 1:a5258871b33d 4033 // Note - we draw the status rectangle after GuiLib_Clear - otherwise we wouldn't see the rectangles at all -
jmitc91516 1:a5258871b33d 4034 // and before GuiLib_ShowScreen - so text, etc, is drawn on top of the rectangles
jmitc91516 1:a5258871b33d 4035 #ifdef WANT_STATUS_RECTANGLE_ON_COLUMN_AUTO_CALIB_PAGE
jmitc91516 1:a5258871b33d 4036 if(singleGCComponentPageStatusColorAreas != NULL) {
jmitc91516 1:a5258871b33d 4037 singleGCComponentPageStatusColorAreas->DisplayGCComponentStatus(COLUMN);
jmitc91516 1:a5258871b33d 4038 }
jmitc91516 1:a5258871b33d 4039 #else // Need to clear old text some other way...
jmitc91516 1:a5258871b33d 4040 #ifdef USING_BACKGROUND_BITMAP
jmitc91516 1:a5258871b33d 4041 DrawBackgroundBitmap();
jmitc91516 1:a5258871b33d 4042 #else
jmitc91516 1:a5258871b33d 4043 GuiLib_Clear();
jmitc91516 1:a5258871b33d 4044 #endif // USING_BACKGROUND_BITMAP
jmitc91516 1:a5258871b33d 4045 #endif // WANT_STATUS_RECTANGLE_ON_COLUMN_AUTO_CALIB_PAGE
jmitc91516 1:a5258871b33d 4046 GuiLib_ShowScreen(GuiStruct_ColumnDHAutoCalibrationPage_Def, GuiLib_NO_CURSOR, GuiLib_RESET_AUTO_REDRAW);
jmitc91516 1:a5258871b33d 4047
jmitc91516 1:a5258871b33d 4048 SetupDoorActuatorCommandUserInterface(usbDevice, usbHostGC, false);
jmitc91516 1:a5258871b33d 4049
jmitc91516 1:a5258871b33d 4050 GuiLib_Refresh();
jmitc91516 1:a5258871b33d 4051
jmitc91516 1:a5258871b33d 4052 #define DEBUG_HERE
jmitc91516 1:a5258871b33d 4053 #ifdef DEBUG_HERE
jmitc91516 1:a5258871b33d 4054 char dbg[100];
jmitc91516 1:a5258871b33d 4055 sprintf(dbg, "After GuiLib_Clear 94");
jmitc91516 1:a5258871b33d 4056 EasyGUIDebugPrint(dbg, 0, 20);
jmitc91516 1:a5258871b33d 4057 #undef DEBUG_HERE
jmitc91516 1:a5258871b33d 4058 #endif
jmitc91516 1:a5258871b33d 4059 }
jmitc91516 1:a5258871b33d 4060 }
jmitc91516 1:a5258871b33d 4061
jmitc91516 1:a5258871b33d 4062
jmitc91516 1:a5258871b33d 4063 /*
jmitc91516 1:a5258871b33d 4064 A "simple page" is one that only has fixed text, rectangles, etc, and easyGUI variables.
jmitc91516 1:a5258871b33d 4065 No status rectangles, etc.
jmitc91516 1:a5258871b33d 4066
jmitc91516 1:a5258871b33d 4067 All these can be displayed using the same sequence of function calls.
jmitc91516 1:a5258871b33d 4068 */
jmitc91516 1:a5258871b33d 4069 void GetGCStatusLoop::DisplaySimplePageData(int pageNumber, bool mustUpdateDisplay)
jmitc91516 1:a5258871b33d 4070 {
jmitc91516 1:a5258871b33d 4071 // There are no status rectangles on a "simple page"
jmitc91516 1:a5258871b33d 4072
jmitc91516 1:a5258871b33d 4073 // Makes the display flicker - but omitting it means old text is not cleared from the display
jmitc91516 1:a5258871b33d 4074 #define WANT_GUILIB_CLEAR
jmitc91516 1:a5258871b33d 4075 #ifdef WANT_GUILIB_CLEAR
jmitc91516 1:a5258871b33d 4076 #ifdef USING_BACKGROUND_BITMAP
jmitc91516 1:a5258871b33d 4077 DrawBackgroundBitmap();
jmitc91516 1:a5258871b33d 4078 #else
jmitc91516 1:a5258871b33d 4079 GuiLib_Clear();
jmitc91516 1:a5258871b33d 4080 #endif
jmitc91516 1:a5258871b33d 4081 #undef WANT_GUILIB_CLEAR
jmitc91516 1:a5258871b33d 4082 #endif
jmitc91516 1:a5258871b33d 4083 GuiLib_ShowScreen(pageNumber, GuiLib_NO_CURSOR, GuiLib_RESET_AUTO_REDRAW);
jmitc91516 1:a5258871b33d 4084
jmitc91516 1:a5258871b33d 4085 GuiLib_Refresh();
jmitc91516 1:a5258871b33d 4086
jmitc91516 1:a5258871b33d 4087 //#define DEBUG_HERE
jmitc91516 1:a5258871b33d 4088 #ifdef DEBUG_HERE
jmitc91516 1:a5258871b33d 4089 char dbg[100];
jmitc91516 1:a5258871b33d 4090 sprintf(dbg, "After GuiLib_Clear 95");
jmitc91516 1:a5258871b33d 4091 EasyGUIDebugPrint(dbg, 0, 20);
jmitc91516 1:a5258871b33d 4092 #undef DEBUG_HERE
jmitc91516 1:a5258871b33d 4093 #endif
jmitc91516 1:a5258871b33d 4094 }
jmitc91516 1:a5258871b33d 4095
jmitc91516 1:a5258871b33d 4096 void GetGCStatusLoop::DisplayColumnDHManualCalibrationPageData(bool mustUpdateDisplay)
jmitc91516 1:a5258871b33d 4097 {
jmitc91516 1:a5258871b33d 4098 DisplaySimplePageData(GuiStruct_ColumnDHManualCalibrationPage_Def, mustUpdateDisplay);
jmitc91516 1:a5258871b33d 4099 }
jmitc91516 1:a5258871b33d 4100
jmitc91516 1:a5258871b33d 4101 void GetGCStatusLoop::DisplayColumnDHSensorCalibrationPageData(bool mustUpdateDisplay)
jmitc91516 1:a5258871b33d 4102 {
jmitc91516 1:a5258871b33d 4103 DisplaySimplePageData(GuiStruct_ColumnDHSensorCalibration_Def, mustUpdateDisplay);
jmitc91516 1:a5258871b33d 4104 }
jmitc91516 1:a5258871b33d 4105
jmitc91516 1:a5258871b33d 4106 void GetGCStatusLoop::DisplayColumnDHPSUDACPageData(bool mustUpdateDisplay)
jmitc91516 1:a5258871b33d 4107 {
jmitc91516 1:a5258871b33d 4108 if(mustUpdateDisplay) {
jmitc91516 1:a5258871b33d 4109 ColumnDHPSUDACPageHandler *columnDHPSUDACPageHandler = ColumnDHPSUDACPageHandler::GetInstance(usbDevice, usbHostGC);
jmitc91516 1:a5258871b33d 4110
jmitc91516 1:a5258871b33d 4111 if(columnDHPSUDACPageHandler != NULL) {
jmitc91516 1:a5258871b33d 4112 columnDHPSUDACPageHandler->DisplayingEasyGUIPage(true);
jmitc91516 1:a5258871b33d 4113 }
jmitc91516 1:a5258871b33d 4114 }
jmitc91516 1:a5258871b33d 4115
jmitc91516 1:a5258871b33d 4116 DisplaySimplePageData(GuiStruct_PSU_DAC_Page_Def, mustUpdateDisplay);
jmitc91516 1:a5258871b33d 4117 }
jmitc91516 1:a5258871b33d 4118
jmitc91516 1:a5258871b33d 4119 void GetGCStatusLoop::DisplayColumnOvenNudgeAndDampPageData(bool mustUpdateDisplay)
jmitc91516 1:a5258871b33d 4120 {
jmitc91516 1:a5258871b33d 4121 DisplaySimplePageData(GuiStruct_ColumnOvenNudgeAndDampPage_0, mustUpdateDisplay);
jmitc91516 1:a5258871b33d 4122 }
jmitc91516 1:a5258871b33d 4123
jmitc91516 1:a5258871b33d 4124 void GetGCStatusLoop::DisplayColumnDHNudgeAndDampPageData(bool mustUpdateDisplay)
jmitc91516 1:a5258871b33d 4125 {
jmitc91516 1:a5258871b33d 4126 DisplaySimplePageData(GuiStruct_ColumnDHNudgeAndDampPage_0, mustUpdateDisplay);
jmitc91516 1:a5258871b33d 4127 }
jmitc91516 1:a5258871b33d 4128
jmitc91516 1:a5258871b33d 4129 void GetGCStatusLoop::DisplayInjectorNudgeAndDampPageData(bool mustUpdateDisplay)
jmitc91516 1:a5258871b33d 4130 {
jmitc91516 1:a5258871b33d 4131 DisplaySimplePageData(GuiStruct_InjectorNudgeAndDampPage_0, mustUpdateDisplay);
jmitc91516 1:a5258871b33d 4132 }
jmitc91516 1:a5258871b33d 4133
jmitc91516 1:a5258871b33d 4134 void GetGCStatusLoop::DisplayDetectorNudgeAndDampPageData(bool mustUpdateDisplay)
jmitc91516 1:a5258871b33d 4135 {
jmitc91516 1:a5258871b33d 4136 DisplaySimplePageData(GuiStruct_DetectorNudgeAndDampPage_0, mustUpdateDisplay);
jmitc91516 1:a5258871b33d 4137 }
jmitc91516 1:a5258871b33d 4138
jmitc91516 1:a5258871b33d 4139 void GetGCStatusLoop::DisplayAuxiliaryNudgeAndDampPageData(bool mustUpdateDisplay)
jmitc91516 1:a5258871b33d 4140 {
jmitc91516 1:a5258871b33d 4141 DisplaySimplePageData(GuiStruct_AuxiliaryNudgeAndDampPage_0, mustUpdateDisplay);
jmitc91516 1:a5258871b33d 4142 }
jmitc91516 1:a5258871b33d 4143
jmitc91516 1:a5258871b33d 4144 void GetGCStatusLoop::DisplayFanPowerPageData(bool mustUpdateDisplay)
jmitc91516 1:a5258871b33d 4145 {
jmitc91516 1:a5258871b33d 4146 DisplaySimplePageData(GuiStruct_FanPowerPage_0, mustUpdateDisplay);
jmitc91516 1:a5258871b33d 4147 }
jmitc91516 1:a5258871b33d 4148
jmitc91516 1:a5258871b33d 4149 void GetGCStatusLoop::DisplayDebugCommandsPageData(bool mustUpdateDisplay)
jmitc91516 1:a5258871b33d 4150 {
jmitc91516 1:a5258871b33d 4151 DisplaySimplePageData(GuiStruct_DebugCommandsPage_Def, mustUpdateDisplay);
jmitc91516 1:a5258871b33d 4152 }
jmitc91516 1:a5258871b33d 4153
jmitc91516 1:a5258871b33d 4154
jmitc91516 1:a5258871b33d 4155 /*
jmitc91516 1:a5258871b33d 4156 Gets the injection mode, and returns it as a null-terminated string, with a descriptive prefix.
jmitc91516 1:a5258871b33d 4157
jmitc91516 1:a5258871b33d 4158 Note also that this code is intended to be as efficient as possible.
jmitc91516 1:a5258871b33d 4159
jmitc91516 1:a5258871b33d 4160 Args: pointer to a buffer to contain the injection mode, as a null-terminated string
jmitc91516 1:a5258871b33d 4161
jmitc91516 1:a5258871b33d 4162 Does not put a hard-coded prefix on the string it returns.
jmitc91516 1:a5258871b33d 4163
jmitc91516 1:a5258871b33d 4164 No return code.
jmitc91516 1:a5258871b33d 4165 */
jmitc91516 1:a5258871b33d 4166 void GetGCStatusLoop::GetInjectionMode(char *mode)
jmitc91516 0:47c880c1463d 4167 {
jmitc91516 0:47c880c1463d 4168 char response[50];
jmitc91516 1:a5258871b33d 4169 SetGCDeviceReport("GIMD", response);
jmitc91516 1:a5258871b33d 4170 // We expect a response like this: "DIMD0000" for Split, "DIMD0001" for Splitless,
jmitc91516 1:a5258871b33d 4171 // "DIMD0002" for On Column, "DIMD0003" for Gas Sampling
jmitc91516 1:a5258871b33d 4172
jmitc91516 0:47c880c1463d 4173 int index = 0;
jmitc91516 1:a5258871b33d 4174 // Check for "EPKT" first
jmitc91516 1:a5258871b33d 4175 if(response[0] == 'E') {
jmitc91516 1:a5258871b33d 4176 mode[index++] = '*';
jmitc91516 1:a5258871b33d 4177 mode[index++] = '*';
jmitc91516 1:a5258871b33d 4178 mode[index++] = ' ';
jmitc91516 1:a5258871b33d 4179 mode[index++] = 'E';
jmitc91516 1:a5258871b33d 4180 mode[index++] = 'r';
jmitc91516 1:a5258871b33d 4181 mode[index++] = 'r';
jmitc91516 1:a5258871b33d 4182 mode[index++] = 'o';
jmitc91516 1:a5258871b33d 4183 mode[index++] = 'r';
jmitc91516 1:a5258871b33d 4184 mode[index++] = ' ';
jmitc91516 1:a5258871b33d 4185 mode[index++] = '*';
jmitc91516 1:a5258871b33d 4186 mode[index++] = '*';
jmitc91516 1:a5258871b33d 4187 } else {
jmitc91516 1:a5258871b33d 4188 switch(response[7]) {
jmitc91516 1:a5258871b33d 4189 case 1:
jmitc91516 1:a5258871b33d 4190 mode[index++] = 'S';
jmitc91516 1:a5258871b33d 4191 mode[index++] = 'p';
jmitc91516 1:a5258871b33d 4192 mode[index++] = 'l';
jmitc91516 1:a5258871b33d 4193 mode[index++] = 'i';
jmitc91516 1:a5258871b33d 4194 mode[index++] = 't';
jmitc91516 1:a5258871b33d 4195 mode[index++] = 'l';
jmitc91516 1:a5258871b33d 4196 mode[index++] = 'e';
jmitc91516 1:a5258871b33d 4197 mode[index++] = 's';
jmitc91516 1:a5258871b33d 4198 mode[index++] = 's';
jmitc91516 1:a5258871b33d 4199 break;
jmitc91516 1:a5258871b33d 4200 case 2:
jmitc91516 1:a5258871b33d 4201 mode[index++] = 'O';
jmitc91516 1:a5258871b33d 4202 mode[index++] = 'n';
jmitc91516 1:a5258871b33d 4203 mode[index++] = ' ';
jmitc91516 1:a5258871b33d 4204 mode[index++] = 'C';
jmitc91516 1:a5258871b33d 4205 mode[index++] = 'o';
jmitc91516 1:a5258871b33d 4206 mode[index++] = 'l';
jmitc91516 1:a5258871b33d 4207 mode[index++] = 'u';
jmitc91516 1:a5258871b33d 4208 mode[index++] = 'm';
jmitc91516 1:a5258871b33d 4209 mode[index++] = 'n';
jmitc91516 1:a5258871b33d 4210 break;
jmitc91516 1:a5258871b33d 4211 case 3:
jmitc91516 1:a5258871b33d 4212 mode[index++] = 'G';
jmitc91516 1:a5258871b33d 4213 mode[index++] = 'a';
jmitc91516 1:a5258871b33d 4214 mode[index++] = 's';
jmitc91516 1:a5258871b33d 4215 mode[index++] = ' ';
jmitc91516 1:a5258871b33d 4216 mode[index++] = 's';
jmitc91516 1:a5258871b33d 4217 mode[index++] = 'a';
jmitc91516 1:a5258871b33d 4218 mode[index++] = 'm';
jmitc91516 1:a5258871b33d 4219 mode[index++] = 'p';
jmitc91516 1:a5258871b33d 4220 mode[index++] = 'l';
jmitc91516 1:a5258871b33d 4221 mode[index++] = 'i';
jmitc91516 1:a5258871b33d 4222 mode[index++] = 'n';
jmitc91516 1:a5258871b33d 4223 mode[index++] = 'g';
jmitc91516 1:a5258871b33d 4224 break;
jmitc91516 1:a5258871b33d 4225 default:
jmitc91516 1:a5258871b33d 4226 mode[index++] = 'S';
jmitc91516 1:a5258871b33d 4227 mode[index++] = 'p';
jmitc91516 1:a5258871b33d 4228 mode[index++] = 'l';
jmitc91516 1:a5258871b33d 4229 mode[index++] = 'i';
jmitc91516 1:a5258871b33d 4230 mode[index++] = 't';
jmitc91516 1:a5258871b33d 4231 break;
jmitc91516 1:a5258871b33d 4232 }
jmitc91516 1:a5258871b33d 4233 }
jmitc91516 1:a5258871b33d 4234
jmitc91516 1:a5258871b33d 4235 mode[index++] = '\0';
jmitc91516 1:a5258871b33d 4236 }
jmitc91516 1:a5258871b33d 4237
jmitc91516 1:a5258871b33d 4238 /*
jmitc91516 1:a5258871b33d 4239 Gets the injector type, and returns it as a null-terminated string, with a descriptive prefix.
jmitc91516 1:a5258871b33d 4240
jmitc91516 1:a5258871b33d 4241 Note also that this code is intended to be as efficient as possible.
jmitc91516 1:a5258871b33d 4242
jmitc91516 1:a5258871b33d 4243 Args: pointer to a buffer to contain the injection mode, as a null-terminated string
jmitc91516 1:a5258871b33d 4244 boolean set true if the caller wants a full prefix ("Injector type: "),
jmitc91516 1:a5258871b33d 4245 or false for a short prefix ("Type: ")
jmitc91516 1:a5258871b33d 4246
jmitc91516 1:a5258871b33d 4247 No return code.
jmitc91516 1:a5258871b33d 4248 */
jmitc91516 1:a5258871b33d 4249 void GetGCStatusLoop::GetInjectorType(char *mode, bool wantPrefix)
jmitc91516 1:a5258871b33d 4250 {
jmitc91516 1:a5258871b33d 4251 char response[50];
jmitc91516 1:a5258871b33d 4252 SetGCDeviceReport("GITY", response);
jmitc91516 1:a5258871b33d 4253
jmitc91516 1:a5258871b33d 4254 // We expect a response like this: "DITY0000" for None,
jmitc91516 1:a5258871b33d 4255 // "DITY0001" for standard (split/splitless), "DITY0002" for PTV
jmitc91516 1:a5258871b33d 4256 int index = 0;
jmitc91516 1:a5258871b33d 4257 if(wantPrefix) {
jmitc91516 0:47c880c1463d 4258 mode[index++] = 'I';
jmitc91516 0:47c880c1463d 4259 mode[index++] = 'n';
jmitc91516 0:47c880c1463d 4260 mode[index++] = 'j';
jmitc91516 0:47c880c1463d 4261 mode[index++] = 'e';
jmitc91516 0:47c880c1463d 4262 mode[index++] = 'c';
jmitc91516 0:47c880c1463d 4263 mode[index++] = 't';
jmitc91516 0:47c880c1463d 4264 mode[index++] = 'o';
jmitc91516 1:a5258871b33d 4265 mode[index++] = 'r';
jmitc91516 0:47c880c1463d 4266 mode[index++] = ' ';
jmitc91516 1:a5258871b33d 4267 mode[index++] = 't';
jmitc91516 1:a5258871b33d 4268 mode[index++] = 'y';
jmitc91516 1:a5258871b33d 4269 mode[index++] = 'p';
jmitc91516 1:a5258871b33d 4270 mode[index++] = 'e';
jmitc91516 1:a5258871b33d 4271 mode[index++] = ':';
jmitc91516 1:a5258871b33d 4272 mode[index++] = ' ';
jmitc91516 1:a5258871b33d 4273 }
jmitc91516 1:a5258871b33d 4274
jmitc91516 0:47c880c1463d 4275 // Check for "EPKT" first
jmitc91516 0:47c880c1463d 4276 if(response[0] == 'E') {
jmitc91516 0:47c880c1463d 4277 mode[index++] = '*';
jmitc91516 0:47c880c1463d 4278 mode[index++] = '*';
jmitc91516 0:47c880c1463d 4279 mode[index++] = ' ';
jmitc91516 0:47c880c1463d 4280 mode[index++] = 'E';
jmitc91516 0:47c880c1463d 4281 mode[index++] = 'r';
jmitc91516 0:47c880c1463d 4282 mode[index++] = 'r';
jmitc91516 0:47c880c1463d 4283 mode[index++] = 'o';
jmitc91516 0:47c880c1463d 4284 mode[index++] = 'r';
jmitc91516 0:47c880c1463d 4285 mode[index++] = ' ';
jmitc91516 0:47c880c1463d 4286 mode[index++] = '*';
jmitc91516 0:47c880c1463d 4287 mode[index++] = '*';
jmitc91516 0:47c880c1463d 4288 mode[index++] = '\0';
jmitc91516 0:47c880c1463d 4289 } else {
jmitc91516 1:a5258871b33d 4290 switch(response[7]) {
jmitc91516 1:a5258871b33d 4291 case '1':
jmitc91516 1:a5258871b33d 4292 mode[index++] = 'S';
jmitc91516 1:a5258871b33d 4293 mode[index++] = 't';
jmitc91516 1:a5258871b33d 4294 mode[index++] = 'a';
jmitc91516 1:a5258871b33d 4295 mode[index++] = 'n';
jmitc91516 1:a5258871b33d 4296 mode[index++] = 'd';
jmitc91516 1:a5258871b33d 4297 mode[index++] = 'a';
jmitc91516 1:a5258871b33d 4298 mode[index++] = 'r';
jmitc91516 1:a5258871b33d 4299 mode[index++] = 'd';
jmitc91516 1:a5258871b33d 4300 break;
jmitc91516 1:a5258871b33d 4301 case '2':
jmitc91516 1:a5258871b33d 4302 mode[index++] = 'P';
jmitc91516 1:a5258871b33d 4303 mode[index++] = 'T';
jmitc91516 1:a5258871b33d 4304 mode[index++] = 'V';
jmitc91516 1:a5258871b33d 4305 break;
jmitc91516 1:a5258871b33d 4306 default:
jmitc91516 1:a5258871b33d 4307 mode[index++] = 'N';
jmitc91516 1:a5258871b33d 4308 mode[index++] = 'o';
jmitc91516 1:a5258871b33d 4309 mode[index++] = 'n';
jmitc91516 1:a5258871b33d 4310 mode[index++] = 'e';
jmitc91516 1:a5258871b33d 4311 break;
jmitc91516 1:a5258871b33d 4312 }
jmitc91516 1:a5258871b33d 4313 mode[index++] = '\0';
jmitc91516 1:a5258871b33d 4314 }
jmitc91516 1:a5258871b33d 4315 }
jmitc91516 1:a5258871b33d 4316
jmitc91516 1:a5258871b33d 4317 /*
jmitc91516 1:a5258871b33d 4318 Gets the injection split time, and returns it as a null-terminated string.
jmitc91516 1:a5258871b33d 4319
jmitc91516 1:a5258871b33d 4320 Note also that this code is intended to be as efficient as possible.
jmitc91516 1:a5258871b33d 4321
jmitc91516 1:a5258871b33d 4322 Args: pointer to a buffer to contain the split time, as a null-terminated string
jmitc91516 1:a5258871b33d 4323
jmitc91516 1:a5258871b33d 4324 Does not put a hard-coded prefix on the string it returns,
jmitc91516 1:a5258871b33d 4325 but does put " min" as a suffix
jmitc91516 1:a5258871b33d 4326
jmitc91516 1:a5258871b33d 4327 No return code.
jmitc91516 1:a5258871b33d 4328 */
jmitc91516 1:a5258871b33d 4329 void GetGCStatusLoop::GetInjectorSplitTime(char *splitTime)
jmitc91516 1:a5258871b33d 4330 {
jmitc91516 1:a5258871b33d 4331 char response[50];
jmitc91516 1:a5258871b33d 4332 SetGCDeviceReport("GSPT", response);
jmitc91516 1:a5258871b33d 4333 // We expect a response like this: "DSPTnnnn", where "nnnn" is the split time,
jmitc91516 1:a5258871b33d 4334 // in units of 0.1 min.
jmitc91516 1:a5258871b33d 4335
jmitc91516 1:a5258871b33d 4336 int index = 0;
jmitc91516 1:a5258871b33d 4337 // Check for "EPKT" first
jmitc91516 1:a5258871b33d 4338 if(response[0] == 'E') {
jmitc91516 1:a5258871b33d 4339 splitTime[index++] = '*';
jmitc91516 1:a5258871b33d 4340 splitTime[index++] = '*';
jmitc91516 1:a5258871b33d 4341 splitTime[index++] = ' ';
jmitc91516 1:a5258871b33d 4342 splitTime[index++] = 'E';
jmitc91516 1:a5258871b33d 4343 splitTime[index++] = 'r';
jmitc91516 1:a5258871b33d 4344 splitTime[index++] = 'r';
jmitc91516 1:a5258871b33d 4345 splitTime[index++] = 'o';
jmitc91516 1:a5258871b33d 4346 splitTime[index++] = 'r';
jmitc91516 1:a5258871b33d 4347 splitTime[index++] = ' ';
jmitc91516 1:a5258871b33d 4348 splitTime[index++] = '*';
jmitc91516 1:a5258871b33d 4349 splitTime[index++] = '*';
jmitc91516 1:a5258871b33d 4350 } else {
jmitc91516 1:a5258871b33d 4351 bool wantNextChars = false;
jmitc91516 1:a5258871b33d 4352 if(response[4] != '0') {
jmitc91516 1:a5258871b33d 4353 splitTime[index++] = response[4];
jmitc91516 1:a5258871b33d 4354 wantNextChars = true;
jmitc91516 1:a5258871b33d 4355 }
jmitc91516 1:a5258871b33d 4356 if(wantNextChars || (response[5] != '0')) {
jmitc91516 1:a5258871b33d 4357 splitTime[index++] = response[5];
jmitc91516 1:a5258871b33d 4358 }
jmitc91516 1:a5258871b33d 4359 // If the value is zero, make sure we return "0.0" -
jmitc91516 1:a5258871b33d 4360 // we just don't want any zeroes before that
jmitc91516 1:a5258871b33d 4361 splitTime[index++] = response[6];
jmitc91516 1:a5258871b33d 4362 splitTime[index++] = '.';
jmitc91516 1:a5258871b33d 4363 splitTime[index++] = response[7];
jmitc91516 1:a5258871b33d 4364 splitTime[index++] = ' ';
jmitc91516 1:a5258871b33d 4365 splitTime[index++] = 'm';
jmitc91516 1:a5258871b33d 4366 splitTime[index++] = 'i';
jmitc91516 1:a5258871b33d 4367 splitTime[index++] = 'n';
jmitc91516 1:a5258871b33d 4368 }
jmitc91516 1:a5258871b33d 4369
jmitc91516 1:a5258871b33d 4370 splitTime[index] = '\0';
jmitc91516 1:a5258871b33d 4371 }
jmitc91516 1:a5258871b33d 4372
jmitc91516 1:a5258871b33d 4373
jmitc91516 1:a5258871b33d 4374 /*
jmitc91516 1:a5258871b33d 4375 Displays the data on the injector page, by copying it to the relevant easyGUI variables,
jmitc91516 1:a5258871b33d 4376 and calling the relevant functions to actually display it.
jmitc91516 1:a5258871b33d 4377
jmitc91516 1:a5258871b33d 4378 Args: a boolean specifying whether or not the display is actually to be updated.
jmitc91516 1:a5258871b33d 4379 Even if it is false when we are called, we may set it true if we discover
jmitc91516 1:a5258871b33d 4380 one or more data items has changed - but note that we will not set it false
jmitc91516 1:a5258871b33d 4381 if it is already true. If it is true after we have looked at all
jmitc91516 1:a5258871b33d 4382 the home page data, we will then update the display. (If we are called
jmitc91516 1:a5258871b33d 4383 with this value set to false, the caller is effectively saying
jmitc91516 1:a5258871b33d 4384 'display the injector page data only if it has changed').
jmitc91516 1:a5258871b33d 4385
jmitc91516 1:a5258871b33d 4386 No return code.
jmitc91516 1:a5258871b33d 4387 */
jmitc91516 0:47c880c1463d 4388 void GetGCStatusLoop::DisplayInjectorPageData(bool mustUpdateDisplay)
jmitc91516 0:47c880c1463d 4389 {
jmitc91516 0:47c880c1463d 4390 // EasyGUIDebugPrint("Injector Page", 100, 100);
jmitc91516 0:47c880c1463d 4391 // Injector temperature and mode
jmitc91516 0:47c880c1463d 4392 char buff[40];
jmitc91516 0:47c880c1463d 4393
jmitc91516 1:a5258871b33d 4394 GetInjectorTemperature(buff, false);
jmitc91516 0:47c880c1463d 4395 if(strcmp(buff, GuiVar_injectorTemperature) != 0) {
jmitc91516 0:47c880c1463d 4396 strcpy(GuiVar_injectorTemperature, buff);
jmitc91516 1:a5258871b33d 4397
jmitc91516 1:a5258871b33d 4398 //mustUpdateDisplay = true;
jmitc91516 1:a5258871b33d 4399 // No - just do this (don't force entire rectangle to redisplay)
jmitc91516 1:a5258871b33d 4400 // Hard coded values taken from easyGUI
jmitc91516 1:a5258871b33d 4401 RedrawSingleEasyGUIVariableOnComponentPage(410, 90, &GuiVar_injectorTemperature, GuiLib_ALIGN_LEFT, INJECTOR);
jmitc91516 1:a5258871b33d 4402 }
jmitc91516 1:a5258871b33d 4403
jmitc91516 6:dba3fbdfd5da 4404 GetInjectorTargetTemperature(buff, stringFormatdegCUnits);
jmitc91516 1:a5258871b33d 4405 if(strcmp(buff, GuiVar_injectorTargetTemperature2) != 0) {
jmitc91516 1:a5258871b33d 4406 strcpy(GuiVar_injectorTargetTemperature2, buff);
jmitc91516 1:a5258871b33d 4407
jmitc91516 1:a5258871b33d 4408 //mustUpdateDisplay = true;
jmitc91516 1:a5258871b33d 4409 // No - just do this (don't force entire rectangle to redisplay)
jmitc91516 1:a5258871b33d 4410 // Hard coded values taken from easyGUI
jmitc91516 1:a5258871b33d 4411 RedrawSingleEasyGUIVariableOnComponentPage(410, 130, &GuiVar_injectorTargetTemperature2, GuiLib_ALIGN_LEFT, INJECTOR);
jmitc91516 1:a5258871b33d 4412 }
jmitc91516 1:a5258871b33d 4413
jmitc91516 1:a5258871b33d 4414 GetInjectionMode(buff);
jmitc91516 0:47c880c1463d 4415 if(strcmp(buff, GuiVar_injectionMode2) != 0) {
jmitc91516 1:a5258871b33d 4416 strcpy(GuiVar_injectionMode2, buff);
jmitc91516 1:a5258871b33d 4417
jmitc91516 1:a5258871b33d 4418 //mustUpdateDisplay = true;
jmitc91516 1:a5258871b33d 4419 // No - just do this (don't force entire rectangle to redisplay)
jmitc91516 1:a5258871b33d 4420 // Hard coded values taken from easyGUI
jmitc91516 1:a5258871b33d 4421 RedrawSingleEasyGUIVariableOnComponentPage(410, 170, &GuiVar_injectionMode2, GuiLib_ALIGN_LEFT, INJECTOR);
jmitc91516 1:a5258871b33d 4422 }
jmitc91516 1:a5258871b33d 4423
jmitc91516 1:a5258871b33d 4424 GetInjectorType(buff, false);
jmitc91516 1:a5258871b33d 4425 if(strcmp(buff, GuiVar_injectorType) != 0) {
jmitc91516 1:a5258871b33d 4426 strcpy(GuiVar_injectorType, buff);
jmitc91516 1:a5258871b33d 4427
jmitc91516 1:a5258871b33d 4428 //mustUpdateDisplay = true;
jmitc91516 1:a5258871b33d 4429 // No - just do this (don't force entire rectangle to redisplay)
jmitc91516 1:a5258871b33d 4430 // Hard coded values taken from easyGUI
jmitc91516 1:a5258871b33d 4431 RedrawSingleEasyGUIVariableOnComponentPage(410, 210, &GuiVar_injectorType, GuiLib_ALIGN_LEFT, INJECTOR);
jmitc91516 1:a5258871b33d 4432 }
jmitc91516 1:a5258871b33d 4433
jmitc91516 1:a5258871b33d 4434 GetComponentStatusString(INJECTOR, buff);
jmitc91516 1:a5258871b33d 4435 if(strcmp(buff, GuiVar_injectorStatus) != 0) {
jmitc91516 1:a5258871b33d 4436 strcpy(GuiVar_injectorStatus, buff);
jmitc91516 1:a5258871b33d 4437
jmitc91516 1:a5258871b33d 4438 //mustUpdateDisplay = true;
jmitc91516 1:a5258871b33d 4439 // No - just do this (don't force entire rectangle to redisplay)
jmitc91516 1:a5258871b33d 4440 // Hard coded values taken from easyGUI
jmitc91516 1:a5258871b33d 4441 RedrawSingleEasyGUIVariableOnComponentPage(410, 250, &GuiVar_injectorStatus, GuiLib_ALIGN_LEFT, INJECTOR);
jmitc91516 1:a5258871b33d 4442 }
jmitc91516 1:a5258871b33d 4443
jmitc91516 1:a5258871b33d 4444 if(SinglePageGCComponentStatusHasChanged(INJECTOR, lastInjectorStatusDisplayedOnInjectorPage)) {
jmitc91516 0:47c880c1463d 4445 mustUpdateDisplay = true;
jmitc91516 1:a5258871b33d 4446 }
jmitc91516 1:a5258871b33d 4447
jmitc91516 1:a5258871b33d 4448 if(mustUpdateDisplay) {
jmitc91516 1:a5258871b33d 4449
jmitc91516 3:010aeeacd7d7 4450 #ifdef WANT_INJECTOR_STATUS_RECTANGLE
jmitc91516 1:a5258871b33d 4451 // Reduce display flickering - get the component status from the GC
jmitc91516 1:a5258871b33d 4452 // *before* we call GuiLib_Clear()
jmitc91516 1:a5258871b33d 4453 if(singleGCComponentPageStatusColorAreas != NULL) {
jmitc91516 1:a5258871b33d 4454 UpdateSingleGCComponentPageStatusColorArea(INJECTOR);
jmitc91516 1:a5258871b33d 4455 }
jmitc91516 3:010aeeacd7d7 4456 #endif
jmitc91516 3:010aeeacd7d7 4457
jmitc91516 3:010aeeacd7d7 4458 #ifndef WANT_INJECTOR_STATUS_RECTANGLE
jmitc91516 1:a5258871b33d 4459 // Makes the display flicker - but omitting it means old text is not cleared from the display
jmitc91516 3:010aeeacd7d7 4460 #define WANT_GUILIB_CLEAR
jmitc91516 3:010aeeacd7d7 4461 #endif
jmitc91516 3:010aeeacd7d7 4462
jmitc91516 1:a5258871b33d 4463 #ifdef WANT_GUILIB_CLEAR
jmitc91516 1:a5258871b33d 4464 #ifdef USING_BACKGROUND_BITMAP
jmitc91516 1:a5258871b33d 4465 DrawBackgroundBitmap(); // We want the status rectangles to be 'on top' of this -
jmitc91516 1:a5258871b33d 4466 // if we include it in the easyGUI page itself, it gets drawn by GuiLib_ShowScreen,
jmitc91516 1:a5258871b33d 4467 // and overwrites the rectangles
jmitc91516 1:a5258871b33d 4468 #else
jmitc91516 1:a5258871b33d 4469 GuiLib_Clear();
jmitc91516 1:a5258871b33d 4470 #endif
jmitc91516 1:a5258871b33d 4471 #undef WANT_GUILIB_CLEAR
jmitc91516 1:a5258871b33d 4472 #endif
jmitc91516 1:a5258871b33d 4473 //...except that redrawing the status rectangle effectively clears the text on top of the rectangle -
jmitc91516 1:a5258871b33d 4474 // so we do not need GuiLib_Clear here, since all the injector page data appears on top of the rectangle.
jmitc91516 1:a5258871b33d 4475 // Without it, only the text flickers, not the rectangle
jmitc91516 1:a5258871b33d 4476
jmitc91516 3:010aeeacd7d7 4477 #ifdef WANT_INJECTOR_STATUS_RECTANGLE
jmitc91516 1:a5258871b33d 4478 // Note - we draw the status rectangle after GuiLib_Clear - otherwise we wouldn't see the rectangles at all -
jmitc91516 1:a5258871b33d 4479 // and before GuiLib_ShowScreen - so text, etc, is drawn on top of the rectangles
jmitc91516 1:a5258871b33d 4480 if(singleGCComponentPageStatusColorAreas != NULL) {
jmitc91516 1:a5258871b33d 4481 singleGCComponentPageStatusColorAreas->DisplayGCComponentStatus(INJECTOR);
jmitc91516 1:a5258871b33d 4482
jmitc91516 1:a5258871b33d 4483 lastInjectorStatusDisplayedOnInjectorPage = singleGCComponentPageStatusColorAreas->GetGCComponentStatus(INJECTOR);
jmitc91516 1:a5258871b33d 4484 }
jmitc91516 3:010aeeacd7d7 4485 #endif
jmitc91516 1:a5258871b33d 4486
jmitc91516 1:a5258871b33d 4487 // And (currently) we draw the component bitmap on top of the rectangle
jmitc91516 1:a5258871b33d 4488 if(qspiBitmaps != NULL) {
jmitc91516 1:a5258871b33d 4489 qspiBitmaps->DisplayInjectorComponentBitmap();
jmitc91516 1:a5258871b33d 4490 }
jmitc91516 1:a5258871b33d 4491
jmitc91516 1:a5258871b33d 4492 GuiLib_ShowScreen(GuiStruct_InjectorPage1_3, GuiLib_NO_CURSOR, GuiLib_RESET_AUTO_REDRAW);
jmitc91516 1:a5258871b33d 4493
jmitc91516 1:a5258871b33d 4494 GuiLib_Refresh();
jmitc91516 1:a5258871b33d 4495
jmitc91516 1:a5258871b33d 4496 #define DEBUG_HERE
jmitc91516 1:a5258871b33d 4497 #ifdef DEBUG_HERE
jmitc91516 1:a5258871b33d 4498 char dbg[100];
jmitc91516 1:a5258871b33d 4499 sprintf(dbg, "After GuiLib_Clear 3");
jmitc91516 1:a5258871b33d 4500 EasyGUIDebugPrint(dbg, 0, 20);
jmitc91516 1:a5258871b33d 4501 #undef DEBUG_HERE
jmitc91516 1:a5258871b33d 4502 #endif
jmitc91516 1:a5258871b33d 4503 }
jmitc91516 1:a5258871b33d 4504 }
jmitc91516 1:a5258871b33d 4505
jmitc91516 1:a5258871b33d 4506 /*
jmitc91516 6:dba3fbdfd5da 4507 Public function, allowing an external caller to tell us
jmitc91516 6:dba3fbdfd5da 4508 to display, or not, the ramp scroll buttons on the Injector Method page.
jmitc91516 6:dba3fbdfd5da 4509
jmitc91516 6:dba3fbdfd5da 4510 Assume that the caller knows the Injector Method page *is*
jmitc91516 6:dba3fbdfd5da 4511 currently being displayed.
jmitc91516 6:dba3fbdfd5da 4512 */
jmitc91516 6:dba3fbdfd5da 4513 void GetGCStatusLoop::ShowInjectorMethodPageScrollButtonsIfNecessary(void)
jmitc91516 6:dba3fbdfd5da 4514 {
jmitc91516 6:dba3fbdfd5da 4515 ShowMethodPageScrollButtonsIfNecessary(injectorMethodRampData);
jmitc91516 6:dba3fbdfd5da 4516 }
jmitc91516 6:dba3fbdfd5da 4517
jmitc91516 6:dba3fbdfd5da 4518 void GetGCStatusLoop::ScrollInjectorMethodRampsUpIfPossible(void)
jmitc91516 6:dba3fbdfd5da 4519 {
jmitc91516 6:dba3fbdfd5da 4520 if(currentPage == GuiStruct_InjectorMethodPage_Def) {
jmitc91516 6:dba3fbdfd5da 4521 if(injectorMethodPageScrollIndex > 0) {
jmitc91516 6:dba3fbdfd5da 4522 --injectorMethodPageScrollIndex;
jmitc91516 6:dba3fbdfd5da 4523
jmitc91516 6:dba3fbdfd5da 4524 DisplayInjectorMethodPageData(false);
jmitc91516 6:dba3fbdfd5da 4525 }
jmitc91516 6:dba3fbdfd5da 4526 }
jmitc91516 6:dba3fbdfd5da 4527 }
jmitc91516 6:dba3fbdfd5da 4528
jmitc91516 6:dba3fbdfd5da 4529 void GetGCStatusLoop::ScrollInjectorMethodRampsDownIfPossible(void)
jmitc91516 6:dba3fbdfd5da 4530 {
jmitc91516 6:dba3fbdfd5da 4531 if(currentPage == GuiStruct_InjectorMethodPage_Def) {
jmitc91516 6:dba3fbdfd5da 4532 if(injectorMethodRampData != NULL) {
jmitc91516 6:dba3fbdfd5da 4533 if(injectorMethodPageScrollIndex < injectorMethodRampData->GetScrollRange()) {
jmitc91516 6:dba3fbdfd5da 4534 ++injectorMethodPageScrollIndex;
jmitc91516 6:dba3fbdfd5da 4535
jmitc91516 6:dba3fbdfd5da 4536 DisplayInjectorMethodPageData(false);
jmitc91516 6:dba3fbdfd5da 4537 }
jmitc91516 6:dba3fbdfd5da 4538 }
jmitc91516 6:dba3fbdfd5da 4539 }
jmitc91516 6:dba3fbdfd5da 4540 }
jmitc91516 6:dba3fbdfd5da 4541
jmitc91516 6:dba3fbdfd5da 4542 /*
jmitc91516 6:dba3fbdfd5da 4543 Displays the data on the injector method page, by copying it to the relevant easyGUI variables,
jmitc91516 6:dba3fbdfd5da 4544 and calling the relevant functions to actually display it.
jmitc91516 6:dba3fbdfd5da 4545
jmitc91516 6:dba3fbdfd5da 4546 Args: a boolean specifying whether or not the display is actually to be updated.
jmitc91516 6:dba3fbdfd5da 4547 Even if it is false when we are called, we may set it true if we discover
jmitc91516 6:dba3fbdfd5da 4548 one or more data items has changed - but note that we will not set it false
jmitc91516 6:dba3fbdfd5da 4549 if it is already true. If it is true after we have looked at all
jmitc91516 6:dba3fbdfd5da 4550 the home page data, we will then update the display. (If we are called
jmitc91516 6:dba3fbdfd5da 4551 with this value set to false, the caller is effectively saying
jmitc91516 6:dba3fbdfd5da 4552 'display the column page data only if it has changed').
jmitc91516 6:dba3fbdfd5da 4553
jmitc91516 6:dba3fbdfd5da 4554 No return code.
jmitc91516 6:dba3fbdfd5da 4555 */
jmitc91516 6:dba3fbdfd5da 4556 void GetGCStatusLoop::DisplayInjectorMethodPageData(bool mustUpdateDisplay)
jmitc91516 6:dba3fbdfd5da 4557 {
jmitc91516 6:dba3fbdfd5da 4558 char buff[40];
jmitc91516 6:dba3fbdfd5da 4559
jmitc91516 6:dba3fbdfd5da 4560 GetInjectorTargetTemperature(buff, "%s");
jmitc91516 6:dba3fbdfd5da 4561 if(strcmp(buff, GuiVar_injectorMethodInitialTemp) != 0) {
jmitc91516 6:dba3fbdfd5da 4562 strcpy(GuiVar_injectorMethodInitialTemp, buff);
jmitc91516 6:dba3fbdfd5da 4563
jmitc91516 6:dba3fbdfd5da 4564 //mustUpdateDisplay = true;
jmitc91516 6:dba3fbdfd5da 4565 // No - just do this (don't force entire page to redisplay)
jmitc91516 6:dba3fbdfd5da 4566 // Hard coded values taken from easyGUI
jmitc91516 6:dba3fbdfd5da 4567 RedrawSingleEasyGUIVariableOnComponentPage(520, 85, &GuiVar_injectorMethodInitialTemp, GuiLib_ALIGN_RIGHT, COLUMN);
jmitc91516 6:dba3fbdfd5da 4568 }
jmitc91516 6:dba3fbdfd5da 4569
jmitc91516 6:dba3fbdfd5da 4570 GetInitialHoldTime(buff);
jmitc91516 6:dba3fbdfd5da 4571 if(strcmp(buff, GuiVar_injectorMethodInitialHold) != 0) {
jmitc91516 6:dba3fbdfd5da 4572 strcpy(GuiVar_injectorMethodInitialHold, buff);
jmitc91516 6:dba3fbdfd5da 4573
jmitc91516 6:dba3fbdfd5da 4574 //mustUpdateDisplay = true;
jmitc91516 6:dba3fbdfd5da 4575 // No - just do this (don't force entire page to redisplay)
jmitc91516 6:dba3fbdfd5da 4576 // Hard coded values taken from easyGUI
jmitc91516 6:dba3fbdfd5da 4577 RedrawSingleEasyGUIVariableOnComponentPage(520, 120, &GuiVar_injectorMethodInitialHold, GuiLib_ALIGN_RIGHT, COLUMN);
jmitc91516 6:dba3fbdfd5da 4578 }
jmitc91516 6:dba3fbdfd5da 4579
jmitc91516 6:dba3fbdfd5da 4580 if(injectorMethodRampData == NULL) {
jmitc91516 6:dba3fbdfd5da 4581 injectorMethodRampData = new InjectorMethodRampData(usbDevice, usbHostGC);
jmitc91516 6:dba3fbdfd5da 4582 }
jmitc91516 6:dba3fbdfd5da 4583
jmitc91516 6:dba3fbdfd5da 4584 if(injectorMethodRampData != NULL) {
jmitc91516 6:dba3fbdfd5da 4585 if(!injectorMethodRampData->GotRampData()) {
jmitc91516 6:dba3fbdfd5da 4586 injectorMethodRampData->GetRampDataFromGC();
jmitc91516 6:dba3fbdfd5da 4587 }
jmitc91516 6:dba3fbdfd5da 4588
jmitc91516 6:dba3fbdfd5da 4589 sprintf(buff, "%u", injectorMethodRampData->GetRampCount());
jmitc91516 6:dba3fbdfd5da 4590 if(strcmp(buff, GuiVar_injectorMethodRampCount) != 0) {
jmitc91516 6:dba3fbdfd5da 4591 strcpy(GuiVar_injectorMethodRampCount, buff);
jmitc91516 6:dba3fbdfd5da 4592
jmitc91516 6:dba3fbdfd5da 4593 //mustUpdateDisplay = true;
jmitc91516 6:dba3fbdfd5da 4594 // No - just do this (don't force entire page to redisplay)
jmitc91516 6:dba3fbdfd5da 4595 // Hard coded values taken from easyGUI
jmitc91516 6:dba3fbdfd5da 4596 RedrawSingleEasyGUIVariableOnComponentPage(520, 155, &GuiVar_injectorMethodRampCount, GuiLib_ALIGN_RIGHT, COLUMN);
jmitc91516 6:dba3fbdfd5da 4597 }
jmitc91516 6:dba3fbdfd5da 4598
jmitc91516 6:dba3fbdfd5da 4599 if(injectorMethodRampData->NeedToUpdateEasyGUIMethodPageRampVariables()) {
jmitc91516 6:dba3fbdfd5da 4600
jmitc91516 6:dba3fbdfd5da 4601 injectorMethodPageScrollIndex = 0;
jmitc91516 6:dba3fbdfd5da 4602
jmitc91516 6:dba3fbdfd5da 4603 injectorMethodRampData->UpdateEasyGUIMethodPageVariables(injectorMethodPageScrollIndex);
jmitc91516 6:dba3fbdfd5da 4604
jmitc91516 6:dba3fbdfd5da 4605 previousInjectorMethodPageScrollIndex = injectorMethodPageScrollIndex;
jmitc91516 6:dba3fbdfd5da 4606
jmitc91516 6:dba3fbdfd5da 4607 mustUpdateDisplay = true; // Not practical to write all these variables individually
jmitc91516 6:dba3fbdfd5da 4608
jmitc91516 6:dba3fbdfd5da 4609 } else if (previousInjectorMethodPageScrollIndex != injectorMethodPageScrollIndex) {
jmitc91516 6:dba3fbdfd5da 4610
jmitc91516 6:dba3fbdfd5da 4611 injectorMethodRampData->UpdateEasyGUIMethodPageVariables(injectorMethodPageScrollIndex);
jmitc91516 6:dba3fbdfd5da 4612
jmitc91516 6:dba3fbdfd5da 4613 previousInjectorMethodPageScrollIndex = injectorMethodPageScrollIndex;
jmitc91516 6:dba3fbdfd5da 4614
jmitc91516 6:dba3fbdfd5da 4615 mustUpdateDisplay = true; // Not practical to write all these variables individually
jmitc91516 6:dba3fbdfd5da 4616 }
jmitc91516 6:dba3fbdfd5da 4617 }
jmitc91516 6:dba3fbdfd5da 4618
jmitc91516 6:dba3fbdfd5da 4619 if(SinglePageGCComponentStatusHasChanged(INJECTOR)) {
jmitc91516 6:dba3fbdfd5da 4620 mustUpdateDisplay = true;
jmitc91516 6:dba3fbdfd5da 4621 }
jmitc91516 6:dba3fbdfd5da 4622
jmitc91516 6:dba3fbdfd5da 4623 if(mustUpdateDisplay) {
jmitc91516 6:dba3fbdfd5da 4624
jmitc91516 6:dba3fbdfd5da 4625 #ifdef WANT_INJECTOR_STATUS_RECTANGLE
jmitc91516 6:dba3fbdfd5da 4626 // Reduce display flickering - get the component status from the GC
jmitc91516 6:dba3fbdfd5da 4627 // *before* we call GuiLib_Clear()
jmitc91516 6:dba3fbdfd5da 4628 if(singleGCComponentPageStatusColorAreas != NULL) {
jmitc91516 6:dba3fbdfd5da 4629 UpdateSingleGCComponentPageStatusColorArea(INJECTOR);
jmitc91516 6:dba3fbdfd5da 4630 }
jmitc91516 6:dba3fbdfd5da 4631 #endif
jmitc91516 6:dba3fbdfd5da 4632
jmitc91516 6:dba3fbdfd5da 4633 #ifndef WANT_INJECTOR_STATUS_RECTANGLE
jmitc91516 6:dba3fbdfd5da 4634 #define WANT_GUILIB_CLEAR
jmitc91516 6:dba3fbdfd5da 4635 #endif
jmitc91516 6:dba3fbdfd5da 4636
jmitc91516 6:dba3fbdfd5da 4637 #ifdef WANT_GUILIB_CLEAR
jmitc91516 6:dba3fbdfd5da 4638 #ifdef USING_BACKGROUND_BITMAP
jmitc91516 6:dba3fbdfd5da 4639 DrawBackgroundBitmap(); // We want the status rectangles to be 'on top' of this -
jmitc91516 6:dba3fbdfd5da 4640 // if we include it in the easyGUI page itself, it gets drawn by GuiLib_ShowScreen,
jmitc91516 6:dba3fbdfd5da 4641 // and overwrites the rectangles
jmitc91516 6:dba3fbdfd5da 4642 #else
jmitc91516 6:dba3fbdfd5da 4643 GuiLib_Clear();
jmitc91516 6:dba3fbdfd5da 4644 #endif
jmitc91516 6:dba3fbdfd5da 4645 #undef WANT_GUILIB_CLEAR
jmitc91516 6:dba3fbdfd5da 4646 #endif
jmitc91516 6:dba3fbdfd5da 4647 //...except that redrawing the status rectangle effectively clears the text on top of the rectangle -
jmitc91516 6:dba3fbdfd5da 4648 // so we do not need GuiLib_Clear here, since all the column page data appears on top of the rectangle.
jmitc91516 6:dba3fbdfd5da 4649 // Without it, only the text flickers, not the rectangle
jmitc91516 6:dba3fbdfd5da 4650
jmitc91516 6:dba3fbdfd5da 4651 #ifdef WANT_INJECTOR_STATUS_RECTANGLE
jmitc91516 6:dba3fbdfd5da 4652 // Note - we draw the status rectangle after GuiLib_Clear - otherwise we wouldn't see the rectangles at all -
jmitc91516 6:dba3fbdfd5da 4653 // and before GuiLib_ShowScreen - so text, etc, is drawn on top of the rectangles
jmitc91516 6:dba3fbdfd5da 4654 if(singleGCComponentPageStatusColorAreas != NULL) {
jmitc91516 6:dba3fbdfd5da 4655 singleGCComponentPageStatusColorAreas->DisplayGCComponentStatus(INJECTOR);
jmitc91516 6:dba3fbdfd5da 4656 }
jmitc91516 6:dba3fbdfd5da 4657 #endif
jmitc91516 6:dba3fbdfd5da 4658
jmitc91516 6:dba3fbdfd5da 4659 // And (currently) we draw the component bitmap on top of the rectangle
jmitc91516 6:dba3fbdfd5da 4660 if(qspiBitmaps != NULL) {
jmitc91516 6:dba3fbdfd5da 4661 qspiBitmaps->DisplayInjectorComponentBitmap();
jmitc91516 6:dba3fbdfd5da 4662 }
jmitc91516 6:dba3fbdfd5da 4663
jmitc91516 6:dba3fbdfd5da 4664 GuiLib_ShowScreen(GuiStruct_InjectorMethodPage_Def, GuiLib_NO_CURSOR, GuiLib_RESET_AUTO_REDRAW);
jmitc91516 6:dba3fbdfd5da 4665
jmitc91516 7:f0e645cf73a2 4666 ShowMethodPageScrollButtonsIfNecessary(injectorMethodRampData);
jmitc91516 6:dba3fbdfd5da 4667
jmitc91516 6:dba3fbdfd5da 4668 GuiLib_Refresh();
jmitc91516 6:dba3fbdfd5da 4669 }
jmitc91516 6:dba3fbdfd5da 4670 }
jmitc91516 6:dba3fbdfd5da 4671
jmitc91516 6:dba3fbdfd5da 4672
jmitc91516 6:dba3fbdfd5da 4673 /*
jmitc91516 1:a5258871b33d 4674 Sets up the data for the graph on the Injector Temperature Profile page,
jmitc91516 1:a5258871b33d 4675 and causes it to be displayed
jmitc91516 1:a5258871b33d 4676 */
jmitc91516 1:a5258871b33d 4677 void GetGCStatusLoop::DisplayInjectorTempProfilePageGraph(void)
jmitc91516 1:a5258871b33d 4678 {
jmitc91516 1:a5258871b33d 4679 // - dataset 0 is a line representing the temperature profile of the run from 'now' to the finish
jmitc91516 1:a5258871b33d 4680 // - dataset 1 is a bar chart representing the temperature profile of the run from 'now' to the finish
jmitc91516 1:a5258871b33d 4681 // - dataset 2 is a line representing the temperature profile from the start to 'now'
jmitc91516 1:a5258871b33d 4682 // - dataset 3 is a bar chart representing the temperature profile of the run from the start to 'now'
jmitc91516 1:a5258871b33d 4683 // - dataset 4 is a single dot at the current time and temperature
jmitc91516 1:a5258871b33d 4684
jmitc91516 1:a5258871b33d 4685 TimeUnit timeUnit = MINUTES;
jmitc91516 1:a5258871b33d 4686 if(injectorTempProfilePageGraphCompleteProfileDataSet->GetTotalMethodTime() < methodTimeUnitsThreshold) {
jmitc91516 1:a5258871b33d 4687 timeUnit = SECONDS;
jmitc91516 1:a5258871b33d 4688 }
jmitc91516 1:a5258871b33d 4689
jmitc91516 1:a5258871b33d 4690 const float yAxisScaleFactor = 10.0f;
jmitc91516 1:a5258871b33d 4691
jmitc91516 1:a5258871b33d 4692 // Dataset 0
jmitc91516 1:a5258871b33d 4693 injectorTempProfilePageGraph->SetDataForGraphDataSetInTenthsOfMinutes(0, yAxisScaleFactor, injectorTempProfilePageGraphDataSet0);
jmitc91516 1:a5258871b33d 4694
jmitc91516 1:a5258871b33d 4695 // Dataset 1
jmitc91516 1:a5258871b33d 4696 injectorTempProfilePageGraph->SetDataForGraphDataSetInTenthsOfMinutes(1, yAxisScaleFactor, injectorTempProfilePageGraphDataSet1);
jmitc91516 1:a5258871b33d 4697
jmitc91516 1:a5258871b33d 4698 // Dataset 2
jmitc91516 1:a5258871b33d 4699 injectorTempProfilePageGraph->SetDataForGraphDataSetInTenthsOfMinutes(2, yAxisScaleFactor, injectorTempProfilePageGraphDataSet2);
jmitc91516 1:a5258871b33d 4700
jmitc91516 1:a5258871b33d 4701 // Dataset 3
jmitc91516 1:a5258871b33d 4702 injectorTempProfilePageGraph->SetDataForGraphDataSetInTenthsOfMinutes(3, yAxisScaleFactor, injectorTempProfilePageGraphDataSet3);
jmitc91516 1:a5258871b33d 4703
jmitc91516 1:a5258871b33d 4704 // Dataset 4
jmitc91516 1:a5258871b33d 4705 injectorTempProfilePageGraph->SetDataForGraphDataSetInTenthsOfMinutes(4, yAxisScaleFactor, injectorTempProfilePageGraphDataSet4);
jmitc91516 1:a5258871b33d 4706
jmitc91516 1:a5258871b33d 4707 injectorTempProfilePageGraph->SetXAxisUnits(timeUnit);
jmitc91516 1:a5258871b33d 4708
jmitc91516 1:a5258871b33d 4709 if(timeUnit == SECONDS) {
jmitc91516 1:a5258871b33d 4710 strcpy(GuiVar_injectorTempProfilePageXAxisLabel, "Time (seconds)");
jmitc91516 1:a5258871b33d 4711 } else {
jmitc91516 1:a5258871b33d 4712 strcpy(GuiVar_injectorTempProfilePageXAxisLabel, "Time (minutes)");
jmitc91516 1:a5258871b33d 4713 }
jmitc91516 1:a5258871b33d 4714
jmitc91516 1:a5258871b33d 4715 if(injectorTempProfilePageGraphCompleteProfileDataSet->GetPointCount() == 0) {
jmitc91516 1:a5258871b33d 4716 strcpy(GuiVar_injectorTempProfilePageNoMethod, "No method set up");
jmitc91516 1:a5258871b33d 4717 } else {
jmitc91516 1:a5258871b33d 4718 GuiVar_injectorTempProfilePageNoMethod[0] = '\0';
jmitc91516 1:a5258871b33d 4719 }
jmitc91516 1:a5258871b33d 4720
jmitc91516 1:a5258871b33d 4721 // The tick sizes must match those set in easyGUI - we do not seem
jmitc91516 1:a5258871b33d 4722 // to be able to get them at runtime
jmitc91516 1:a5258871b33d 4723 GuiConst_INT32S minX, maxX;
jmitc91516 1:a5258871b33d 4724 //GuiConst_INT32S tickSize = (timeUnit == SECONDS) ? 300 : 100;
jmitc91516 1:a5258871b33d 4725 // Always in 1/10 minutes
jmitc91516 1:a5258871b33d 4726 GuiConst_INT32S xAxisTickSize = (timeUnit == SECONDS) ? 5 : 100; // 5 == 0.5 minutes (i.e. 30 seconds), 100 == 10 minutes
jmitc91516 1:a5258871b33d 4727 injectorTempProfilePageGraphCompleteProfileDataSet->GetXAxisRangeInTenthsOfMinutes(&minX, &maxX, xAxisTickSize);
jmitc91516 1:a5258871b33d 4728 injectorTempProfilePageGraph->SetXAxisRange(0, maxX); // Always start X axis at zero
jmitc91516 1:a5258871b33d 4729
jmitc91516 1:a5258871b33d 4730 GuiConst_INT32S minY, maxY;
jmitc91516 1:a5258871b33d 4731 GuiConst_INT32S yAxisTickSize = 50;
jmitc91516 1:a5258871b33d 4732 injectorTempProfilePageGraphCompleteProfileDataSet->GetYAxisRange(&minY, &maxY, yAxisTickSize);
jmitc91516 1:a5258871b33d 4733 injectorTempProfilePageGraph->SetYAxisRange(0, (maxY * yAxisScaleFactor)); // Always start Y axis at zero
jmitc91516 1:a5258871b33d 4734
jmitc91516 1:a5258871b33d 4735
jmitc91516 1:a5258871b33d 4736 injectorTempProfilePageGraph->DrawAxes();
jmitc91516 1:a5258871b33d 4737
jmitc91516 1:a5258871b33d 4738 // We need to draw the X axis labels ourselves, since our time values are in units of 0.1 minute,
jmitc91516 1:a5258871b33d 4739 // but easyGUI graphs work only in integers - we therefore have to multiply the time values by 10
jmitc91516 1:a5258871b33d 4740 // before passing them to easyGUI, and if we let easyGUI draw its own values on the X axis,
jmitc91516 1:a5258871b33d 4741 // they would be 10 times the correct values.
jmitc91516 1:a5258871b33d 4742 // Graph coordinates copied from easyGUI - I cannot find a way of obtaining them at runtime.
jmitc91516 1:a5258871b33d 4743 if(timeUnit == SECONDS) {
jmitc91516 1:a5258871b33d 4744 injectorTempProfilePageGraph->DrawXAxisLabels(0, (maxX * 6), (xAxisTickSize * 6), 130, 340, 500);
jmitc91516 1:a5258871b33d 4745 } else {
jmitc91516 1:a5258871b33d 4746 injectorTempProfilePageGraph->DrawXAxisLabels(0, (maxX / 10), (xAxisTickSize / 10), 130, 340, 500);
jmitc91516 1:a5258871b33d 4747 }
jmitc91516 1:a5258871b33d 4748 // Note that we repeat this call by calling 'DrawXAxisLabels' without arguments
jmitc91516 1:a5258871b33d 4749 // every time we (re)display this page
jmitc91516 1:a5258871b33d 4750
jmitc91516 1:a5258871b33d 4751 // Similar to the X axis - the values we pass to the easyGUI graph are scaled to be larger
jmitc91516 1:a5258871b33d 4752 // than the real values, to get round the fact that easyGUI graphs work in integers.
jmitc91516 1:a5258871b33d 4753 // (This can cause the profile to appear to be 'stepped', which obviously we do not want.)
jmitc91516 1:a5258871b33d 4754 // We must therefore draw the Y axis values ourselves.
jmitc91516 1:a5258871b33d 4755 injectorTempProfilePageGraph->DrawYAxisLabels(0, maxY, yAxisTickSize, 130, 340, 250);
jmitc91516 1:a5258871b33d 4756 // Note that we repeat this call by calling 'DrawYAxisLabels' without arguments
jmitc91516 1:a5258871b33d 4757 // every time we (re)display this page
jmitc91516 1:a5258871b33d 4758
jmitc91516 1:a5258871b33d 4759 injectorTempProfilePageGraph->DrawDataSet(0);
jmitc91516 1:a5258871b33d 4760 injectorTempProfilePageGraph->ShowDataSet(0);
jmitc91516 1:a5258871b33d 4761
jmitc91516 1:a5258871b33d 4762 injectorTempProfilePageGraph->DrawDataSet(1);
jmitc91516 1:a5258871b33d 4763 injectorTempProfilePageGraph->ShowDataSet(1);
jmitc91516 1:a5258871b33d 4764
jmitc91516 1:a5258871b33d 4765 injectorTempProfilePageGraph->DrawDataSet(2);
jmitc91516 1:a5258871b33d 4766 injectorTempProfilePageGraph->ShowDataSet(2);
jmitc91516 1:a5258871b33d 4767
jmitc91516 1:a5258871b33d 4768 injectorTempProfilePageGraph->DrawDataSet(3);
jmitc91516 1:a5258871b33d 4769 injectorTempProfilePageGraph->ShowDataSet(3);
jmitc91516 1:a5258871b33d 4770
jmitc91516 1:a5258871b33d 4771 injectorTempProfilePageGraph->DrawDataSet(4);
jmitc91516 1:a5258871b33d 4772 injectorTempProfilePageGraph->ShowDataSet(4);
jmitc91516 1:a5258871b33d 4773
jmitc91516 1:a5258871b33d 4774 injectorTempProfilePageGraph->Redraw();
jmitc91516 6:dba3fbdfd5da 4775
jmitc91516 6:dba3fbdfd5da 4776 #ifdef TEST_GUILIB_VLINE_PROFILES
jmitc91516 6:dba3fbdfd5da 4777 // *** TESTING *** Draw the profile as a solid colour, direct to the display
jmitc91516 6:dba3fbdfd5da 4778 // Coords manually copied from easyGUI application.
jmitc91516 6:dba3fbdfd5da 4779 // Boundary between colours is arbitrary for now
jmitc91516 6:dba3fbdfd5da 4780 GuiConst_INTCOLOR graphColour1 = SixteenBitColorValue(100, 100, 100);
jmitc91516 6:dba3fbdfd5da 4781 GuiConst_INTCOLOR graphColour2 = SixteenBitColorValue(200, 200, 200);
jmitc91516 6:dba3fbdfd5da 4782 // double colourBoundaryX = (double) injectorTempProfilePageGraphCompleteProfileDataSet->GetTotalMethodTime() / 5.0; // Should be one-fifth across the profile
jmitc91516 6:dba3fbdfd5da 4783 double colourBoundaryX = -1.0; // No - use one colour only
jmitc91516 6:dba3fbdfd5da 4784 if(timeUnit == SECONDS) {
jmitc91516 6:dba3fbdfd5da 4785 injectorTempProfilePageGraphCompleteProfileDataSet->DrawUsingGuiLibVLine(140, 330, ((double) 500 / (double) (maxX * 6)), ((double) -250 / (double) maxY), graphColour1, graphColour2, colourBoundaryX);
jmitc91516 6:dba3fbdfd5da 4786 } else {
jmitc91516 6:dba3fbdfd5da 4787 injectorTempProfilePageGraphCompleteProfileDataSet->DrawUsingGuiLibVLine(140, 330, ((double) 500 / (double) (maxX / 10)), ((double) -250 / (double) maxY), graphColour1, graphColour2, colourBoundaryX);
jmitc91516 6:dba3fbdfd5da 4788 }
jmitc91516 6:dba3fbdfd5da 4789 #endif // TEST_GUILIB_VLINE_PROFILES
jmitc91516 1:a5258871b33d 4790 }
jmitc91516 1:a5258871b33d 4791
jmitc91516 1:a5258871b33d 4792 /*
jmitc91516 1:a5258871b33d 4793 Displays the data on the injector temperature profile page,
jmitc91516 1:a5258871b33d 4794 by copying it to the relevant easyGUI variables,
jmitc91516 1:a5258871b33d 4795 and calling the relevant functions to actually display it.
jmitc91516 1:a5258871b33d 4796
jmitc91516 1:a5258871b33d 4797 Args: a boolean specifying whether or not the display is actually to be updated.
jmitc91516 1:a5258871b33d 4798 Even if it is false when we are called, we may set it true if we discover
jmitc91516 1:a5258871b33d 4799 one or more data items has changed - but note that we will not set it false
jmitc91516 1:a5258871b33d 4800 if it is already true. If it is true after we have looked at all
jmitc91516 1:a5258871b33d 4801 the home page data, we will then update the display. (If we are called
jmitc91516 1:a5258871b33d 4802 with this value set to false, the caller is effectively saying
jmitc91516 1:a5258871b33d 4803 'display the injector page data only if it has changed').
jmitc91516 1:a5258871b33d 4804
jmitc91516 1:a5258871b33d 4805 No return code.
jmitc91516 1:a5258871b33d 4806 */
jmitc91516 1:a5258871b33d 4807 void GetGCStatusLoop::DisplayInjectorTempProfilePageData(bool mustUpdateDisplay)
jmitc91516 1:a5258871b33d 4808 {
jmitc91516 1:a5258871b33d 4809 // Ensure this is always up to date
jmitc91516 1:a5258871b33d 4810 if(needToUpdateProfileGraphs) {
jmitc91516 1:a5258871b33d 4811 SetupColumnAndInjectorAndGasProfileData();
jmitc91516 1:a5258871b33d 4812 mustUpdateDisplay = true;
jmitc91516 1:a5258871b33d 4813
jmitc91516 1:a5258871b33d 4814 needToUpdateProfileGraphs = false;
jmitc91516 1:a5258871b33d 4815 }
jmitc91516 1:a5258871b33d 4816
jmitc91516 1:a5258871b33d 4817 DisplayInjectorTempProfilePageGraph();
jmitc91516 1:a5258871b33d 4818
jmitc91516 1:a5258871b33d 4819 if(SinglePageGCComponentStatusHasChanged(INJECTOR)) {
jmitc91516 1:a5258871b33d 4820 mustUpdateDisplay = true;
jmitc91516 0:47c880c1463d 4821 }
jmitc91516 0:47c880c1463d 4822
jmitc91516 0:47c880c1463d 4823 if(mustUpdateDisplay) {
jmitc91516 0:47c880c1463d 4824
jmitc91516 3:010aeeacd7d7 4825 #ifdef WANT_INJECTOR_STATUS_RECTANGLE
jmitc91516 0:47c880c1463d 4826 // Reduce display flickering - get the component status from the GC
jmitc91516 0:47c880c1463d 4827 // *before* we call GuiLib_Clear()
jmitc91516 0:47c880c1463d 4828 if(singleGCComponentPageStatusColorAreas != NULL) {
jmitc91516 0:47c880c1463d 4829 UpdateSingleGCComponentPageStatusColorArea(INJECTOR);
jmitc91516 0:47c880c1463d 4830 }
jmitc91516 3:010aeeacd7d7 4831 #endif
jmitc91516 3:010aeeacd7d7 4832
jmitc91516 3:010aeeacd7d7 4833 #ifndef WANT_INJECTOR_STATUS_RECTANGLE
jmitc91516 0:47c880c1463d 4834 // Makes the display flicker - but omitting it means old text is not cleared from the display
jmitc91516 3:010aeeacd7d7 4835 #define WANT_GUILIB_CLEAR
jmitc91516 3:010aeeacd7d7 4836 #endif
jmitc91516 3:010aeeacd7d7 4837
jmitc91516 1:a5258871b33d 4838 #ifdef WANT_GUILIB_CLEAR
jmitc91516 1:a5258871b33d 4839 #ifdef USING_BACKGROUND_BITMAP
jmitc91516 1:a5258871b33d 4840 DrawBackgroundBitmap(); // We want the status rectangles to be 'on top' of this -
jmitc91516 1:a5258871b33d 4841 // if we include it in the easyGUI page itself, it gets drawn by GuiLib_ShowScreen,
jmitc91516 1:a5258871b33d 4842 // and overwrites the rectangles
jmitc91516 1:a5258871b33d 4843 #else
jmitc91516 0:47c880c1463d 4844 GuiLib_Clear();
jmitc91516 1:a5258871b33d 4845 #endif
jmitc91516 1:a5258871b33d 4846 #undef WANT_GUILIB_CLEAR
jmitc91516 1:a5258871b33d 4847 #endif
jmitc91516 1:a5258871b33d 4848 //...except that redrawing the status rectangle effectively clears the text on top of the rectangle -
jmitc91516 1:a5258871b33d 4849 // so we do not need GuiLib_Clear here, since all the injector page data appears on top of the rectangle.
jmitc91516 1:a5258871b33d 4850 // Without it, only the text flickers, not the rectangle
jmitc91516 0:47c880c1463d 4851
jmitc91516 3:010aeeacd7d7 4852 #ifdef WANT_INJECTOR_STATUS_RECTANGLE
jmitc91516 0:47c880c1463d 4853 // Note - we draw the status rectangle after GuiLib_Clear - otherwise we wouldn't see the rectangles at all -
jmitc91516 0:47c880c1463d 4854 // and before GuiLib_ShowScreen - so text, etc, is drawn on top of the rectangles
jmitc91516 0:47c880c1463d 4855 if(singleGCComponentPageStatusColorAreas != NULL) {
jmitc91516 0:47c880c1463d 4856 singleGCComponentPageStatusColorAreas->DisplayGCComponentStatus(INJECTOR);
jmitc91516 0:47c880c1463d 4857 }
jmitc91516 3:010aeeacd7d7 4858 #endif
jmitc91516 0:47c880c1463d 4859
jmitc91516 7:f0e645cf73a2 4860 #ifdef WANT_COMPONENT_ICON_ON_PROFILE_PAGES
jmitc91516 1:a5258871b33d 4861 // And (currently) we draw the component bitmap on top of the rectangle
jmitc91516 1:a5258871b33d 4862 if(qspiBitmaps != NULL) {
jmitc91516 1:a5258871b33d 4863 qspiBitmaps->DisplayInjectorComponentBitmap();
jmitc91516 1:a5258871b33d 4864 }
jmitc91516 7:f0e645cf73a2 4865 #endif // WANT_COMPONENT_ICON_ON_PROFILE_PAGES
jmitc91516 1:a5258871b33d 4866
jmitc91516 1:a5258871b33d 4867 injectorTempProfilePageGraph->Redraw();
jmitc91516 1:a5258871b33d 4868
jmitc91516 8:26e49e6955bd 4869 #ifdef TEST_GUILIB_VLINE_PROFILES
jmitc91516 6:dba3fbdfd5da 4870 // Now draw the profile as a solid colour, direct to the display.
jmitc91516 6:dba3fbdfd5da 4871 // Use the same parameters as the previous call, in DisplayInjectorTempProfilePageGraph
jmitc91516 6:dba3fbdfd5da 4872 injectorTempProfilePageGraphCompleteProfileDataSet->DrawUsingGuiLibVLine();
jmitc91516 8:26e49e6955bd 4873 #endif // TEST_GUILIB_VLINE_PROFILES
jmitc91516 6:dba3fbdfd5da 4874
jmitc91516 1:a5258871b33d 4875 GuiLib_ShowScreen(GuiStruct_InjectorTempProfilePage_25, GuiLib_NO_CURSOR, GuiLib_RESET_AUTO_REDRAW);
jmitc91516 1:a5258871b33d 4876
jmitc91516 1:a5258871b33d 4877 // Repeat the previous call to the version of this function with parameters,
jmitc91516 1:a5258871b33d 4878 // made from 'DisplayInjectorTempProfilePageGraph()' above (it is more convenient
jmitc91516 1:a5258871b33d 4879 // to calculate the parameter values in 'DisplayInjectorTempProfilePageGraph()' than here)
jmitc91516 1:a5258871b33d 4880 injectorTempProfilePageGraph->DrawXAxisLabels();
jmitc91516 1:a5258871b33d 4881 injectorTempProfilePageGraph->DrawYAxisLabels();
jmitc91516 0:47c880c1463d 4882
jmitc91516 0:47c880c1463d 4883 GuiLib_Refresh();
jmitc91516 0:47c880c1463d 4884
jmitc91516 0:47c880c1463d 4885 #define DEBUG_HERE
jmitc91516 0:47c880c1463d 4886 #ifdef DEBUG_HERE
jmitc91516 0:47c880c1463d 4887 char dbg[100];
jmitc91516 0:47c880c1463d 4888 sprintf(dbg, "After GuiLib_Clear 3");
jmitc91516 1:a5258871b33d 4889 EasyGUIDebugPrint(dbg, 0, 20);
jmitc91516 0:47c880c1463d 4890 #undef DEBUG_HERE
jmitc91516 0:47c880c1463d 4891 #endif
jmitc91516 0:47c880c1463d 4892 }
jmitc91516 0:47c880c1463d 4893 }
jmitc91516 0:47c880c1463d 4894
jmitc91516 1:a5258871b33d 4895
jmitc91516 1:a5258871b33d 4896 /*
jmitc91516 1:a5258871b33d 4897 Gets the total flow rate, and returns it as a null-terminated string, with a suffix for the units.
jmitc91516 1:a5258871b33d 4898
jmitc91516 1:a5258871b33d 4899 Note also that this code is intended to be as efficient as possible.
jmitc91516 1:a5258871b33d 4900
jmitc91516 1:a5258871b33d 4901 Args: pointer to a buffer to contain the total flow rate, as a null-terminated string
jmitc91516 1:a5258871b33d 4902
jmitc91516 1:a5258871b33d 4903 No return code.
jmitc91516 1:a5258871b33d 4904 */
jmitc91516 1:a5258871b33d 4905 void GetGCStatusLoop::GetTotalFlow(char *totalFlow)
jmitc91516 1:a5258871b33d 4906 {
jmitc91516 1:a5258871b33d 4907 GetFlowRate("GTFL", totalFlow);
jmitc91516 1:a5258871b33d 4908 }
jmitc91516 1:a5258871b33d 4909
jmitc91516 1:a5258871b33d 4910 /*
jmitc91516 1:a5258871b33d 4911 Gets the total flow rate, and returns it as a floating point value
jmitc91516 1:a5258871b33d 4912
jmitc91516 1:a5258871b33d 4913 Args: pointer to a variable to contain the total flow rate, as a floating point value
jmitc91516 1:a5258871b33d 4914
jmitc91516 1:a5258871b33d 4915 No return code.
jmitc91516 1:a5258871b33d 4916 */
jmitc91516 1:a5258871b33d 4917 void GetGCStatusLoop::GetTotalFlow(float *totalFlow)
jmitc91516 1:a5258871b33d 4918 {
jmitc91516 1:a5258871b33d 4919 char buff[40];
jmitc91516 1:a5258871b33d 4920 GetTotalFlow(buff);
jmitc91516 1:a5258871b33d 4921 if(buff[0] == '*') {
jmitc91516 1:a5258871b33d 4922 // Assume "EPKT" returned from GC
jmitc91516 1:a5258871b33d 4923 *totalFlow = 0.0;
jmitc91516 1:a5258871b33d 4924 return;
jmitc91516 1:a5258871b33d 4925 }
jmitc91516 1:a5258871b33d 4926
jmitc91516 1:a5258871b33d 4927 // 'else' we received a valid value
jmitc91516 1:a5258871b33d 4928 buff[4] = '\0'; // Remove the units suffix
jmitc91516 1:a5258871b33d 4929 sscanf(buff, "%f", totalFlow);
jmitc91516 1:a5258871b33d 4930 }
jmitc91516 1:a5258871b33d 4931
jmitc91516 1:a5258871b33d 4932 /*
jmitc91516 1:a5258871b33d 4933 Gets the column flow rate, and returns it as a null-terminated string, with a suffix for the units.
jmitc91516 1:a5258871b33d 4934
jmitc91516 1:a5258871b33d 4935 Args: pointer to a buffer to contain the total flow rate, as a null-terminated string
jmitc91516 1:a5258871b33d 4936
jmitc91516 1:a5258871b33d 4937 No return code.
jmitc91516 1:a5258871b33d 4938 */
jmitc91516 1:a5258871b33d 4939 void GetGCStatusLoop::GetColumnFlow(char *columnFlow)
jmitc91516 1:a5258871b33d 4940 {
jmitc91516 1:a5258871b33d 4941 GetFlowRate("GCFL", columnFlow);
jmitc91516 1:a5258871b33d 4942 }
jmitc91516 1:a5258871b33d 4943
jmitc91516 1:a5258871b33d 4944 /*
jmitc91516 1:a5258871b33d 4945 Gets the column flow rate, and returns it as a floating point value
jmitc91516 1:a5258871b33d 4946
jmitc91516 1:a5258871b33d 4947 Args: pointer to a variable to contain the column flow rate, as a floating point value
jmitc91516 1:a5258871b33d 4948
jmitc91516 1:a5258871b33d 4949 No return code.
jmitc91516 1:a5258871b33d 4950 */
jmitc91516 1:a5258871b33d 4951 void GetGCStatusLoop::GetColumnFlow(float *columnFlow)
jmitc91516 1:a5258871b33d 4952 {
jmitc91516 1:a5258871b33d 4953 char buff[40];
jmitc91516 1:a5258871b33d 4954 GetColumnFlow(buff);
jmitc91516 1:a5258871b33d 4955 if(buff[0] == '*') {
jmitc91516 1:a5258871b33d 4956 // Assume "EPKT" returned from GC
jmitc91516 1:a5258871b33d 4957 *columnFlow = 0.0;
jmitc91516 1:a5258871b33d 4958 return;
jmitc91516 1:a5258871b33d 4959 }
jmitc91516 1:a5258871b33d 4960
jmitc91516 1:a5258871b33d 4961 // 'else' we received a valid value
jmitc91516 1:a5258871b33d 4962 buff[4] = '\0'; // Remove the units suffix
jmitc91516 1:a5258871b33d 4963 sscanf(buff, "%f", columnFlow);
jmitc91516 1:a5258871b33d 4964 }
jmitc91516 1:a5258871b33d 4965
jmitc91516 1:a5258871b33d 4966 /*
jmitc91516 1:a5258871b33d 4967 Gets the split flow rate, and returns it as a floating point value
jmitc91516 1:a5258871b33d 4968
jmitc91516 1:a5258871b33d 4969 Args: pointer to a variable to contain the split flow rate, as a floating point value
jmitc91516 1:a5258871b33d 4970
jmitc91516 1:a5258871b33d 4971 No return code.
jmitc91516 1:a5258871b33d 4972 */
jmitc91516 1:a5258871b33d 4973 void GetGCStatusLoop::GetSplitFlow(float *splitFlow)
jmitc91516 1:a5258871b33d 4974 {
jmitc91516 1:a5258871b33d 4975 float totalFlow;
jmitc91516 1:a5258871b33d 4976 float columnFlow;
jmitc91516 1:a5258871b33d 4977
jmitc91516 1:a5258871b33d 4978 GetTotalFlow(&totalFlow);
jmitc91516 1:a5258871b33d 4979 GetColumnFlow(&columnFlow);
jmitc91516 1:a5258871b33d 4980
jmitc91516 1:a5258871b33d 4981 *splitFlow = totalFlow - columnFlow;
jmitc91516 1:a5258871b33d 4982 }
jmitc91516 1:a5258871b33d 4983
jmitc91516 1:a5258871b33d 4984 /*
jmitc91516 1:a5258871b33d 4985 Gets the split flow rate, and returns it (to a precision of one decimal place,
jmitc91516 1:a5258871b33d 4986 like most floating point values returned by the GC - and with a suffix
jmitc91516 1:a5258871b33d 4987 representing the units) as a null terminated string.
jmitc91516 1:a5258871b33d 4988
jmitc91516 1:a5258871b33d 4989 Args: pointer to a buffer to contain the split flow rate, as a null terminated string
jmitc91516 1:a5258871b33d 4990
jmitc91516 1:a5258871b33d 4991 No return code.
jmitc91516 1:a5258871b33d 4992 */
jmitc91516 1:a5258871b33d 4993 void GetGCStatusLoop::GetSplitFlow(char *splitFlow)
jmitc91516 1:a5258871b33d 4994 {
jmitc91516 1:a5258871b33d 4995 float flt;
jmitc91516 1:a5258871b33d 4996 GetSplitFlow(&flt);
jmitc91516 1:a5258871b33d 4997 sprintf(splitFlow, "%.1f ml/min", flt);
jmitc91516 1:a5258871b33d 4998 }
jmitc91516 1:a5258871b33d 4999
jmitc91516 1:a5258871b33d 5000 /*
jmitc91516 1:a5258871b33d 5001 Gets the split ratio, and returns it as a floating point value
jmitc91516 1:a5258871b33d 5002
jmitc91516 1:a5258871b33d 5003 Args: pointer to a variable to contain the split ratio, as a floating point value
jmitc91516 1:a5258871b33d 5004
jmitc91516 1:a5258871b33d 5005 No return code.
jmitc91516 1:a5258871b33d 5006 */
jmitc91516 1:a5258871b33d 5007 void GetGCStatusLoop::GetSplitRatio(float *splitRatio)
jmitc91516 1:a5258871b33d 5008 {
jmitc91516 1:a5258871b33d 5009 float splitFlow;
jmitc91516 1:a5258871b33d 5010 float columnFlow;
jmitc91516 1:a5258871b33d 5011
jmitc91516 1:a5258871b33d 5012 GetSplitFlow(&splitFlow);
jmitc91516 1:a5258871b33d 5013 GetColumnFlow(&columnFlow);
jmitc91516 1:a5258871b33d 5014
jmitc91516 1:a5258871b33d 5015 // Avoid divide by zero (and avoid floating point rounding errors)
jmitc91516 1:a5258871b33d 5016 if(columnFlow > FLT_MIN) {
jmitc91516 1:a5258871b33d 5017 *splitRatio = splitFlow / columnFlow;
jmitc91516 1:a5258871b33d 5018 } else {
jmitc91516 1:a5258871b33d 5019 *splitRatio = 1.0F; // Default (we have to assign *something*)
jmitc91516 1:a5258871b33d 5020 }
jmitc91516 1:a5258871b33d 5021 }
jmitc91516 1:a5258871b33d 5022
jmitc91516 1:a5258871b33d 5023 /*
jmitc91516 1:a5258871b33d 5024 Gets the split ratio, and returns it (to a precision of one decimal place,
jmitc91516 1:a5258871b33d 5025 like most floating point values returned by the GC) as a null terminated string.
jmitc91516 1:a5258871b33d 5026
jmitc91516 1:a5258871b33d 5027 Args: pointer to a buffer to contain the split flow rate, as a null terminated string
jmitc91516 1:a5258871b33d 5028
jmitc91516 1:a5258871b33d 5029 No return code.
jmitc91516 1:a5258871b33d 5030 */
jmitc91516 1:a5258871b33d 5031 void GetGCStatusLoop::GetSplitRatio(char *splitRatio)
jmitc91516 1:a5258871b33d 5032 {
jmitc91516 1:a5258871b33d 5033 float flt;
jmitc91516 1:a5258871b33d 5034 GetSplitRatio(&flt);
jmitc91516 1:a5258871b33d 5035 sprintf(splitRatio, "%.1f", flt);
jmitc91516 1:a5258871b33d 5036 }
jmitc91516 1:a5258871b33d 5037
jmitc91516 1:a5258871b33d 5038 /*
jmitc91516 1:a5258871b33d 5039 Gets the number of injections (i.e. runs) since the liner was changed,
jmitc91516 1:a5258871b33d 5040 and returns it as a null-terminated string.
jmitc91516 1:a5258871b33d 5041
jmitc91516 1:a5258871b33d 5042 This involves getting both values from the settings stored in QSPI memory.
jmitc91516 1:a5258871b33d 5043
jmitc91516 1:a5258871b33d 5044 Args: pointer to a buffer to contain the injection count, as a null-terminated string
jmitc91516 1:a5258871b33d 5045
jmitc91516 1:a5258871b33d 5046 No return code.
jmitc91516 1:a5258871b33d 5047 */
jmitc91516 1:a5258871b33d 5048 void GetGCStatusLoop::GetInjectionCountSinceLinerChanged(char *injCount)
jmitc91516 1:a5258871b33d 5049 {
jmitc91516 1:a5258871b33d 5050 int runCount = SettingsHandler::GetIntegerValueFromQSPISettings("RunCount", 0);
jmitc91516 1:a5258871b33d 5051 int linerChangedRunCount = SettingsHandler::GetIntegerValueFromQSPISettings("RunCountWhenLinerChanged", 0);
jmitc91516 1:a5258871b33d 5052
jmitc91516 1:a5258871b33d 5053 sprintf(injCount, "%d", (runCount - linerChangedRunCount));
jmitc91516 1:a5258871b33d 5054 }
jmitc91516 1:a5258871b33d 5055
jmitc91516 1:a5258871b33d 5056 /*
jmitc91516 1:a5258871b33d 5057 Gets the number of injections (i.e. runs) since the septa was changed,
jmitc91516 1:a5258871b33d 5058 and returns it as a null-terminated string.
jmitc91516 1:a5258871b33d 5059
jmitc91516 1:a5258871b33d 5060 This involves getting both values from the settings stored in QSPI memory.
jmitc91516 1:a5258871b33d 5061
jmitc91516 1:a5258871b33d 5062 Args: pointer to a buffer to contain the injection count, as a null-terminated string
jmitc91516 1:a5258871b33d 5063
jmitc91516 1:a5258871b33d 5064 No return code.
jmitc91516 1:a5258871b33d 5065 */
jmitc91516 1:a5258871b33d 5066 void GetGCStatusLoop::GetInjectionCountSinceSeptaChanged(char *injCount)
jmitc91516 1:a5258871b33d 5067 {
jmitc91516 1:a5258871b33d 5068 int runCount = SettingsHandler::GetIntegerValueFromQSPISettings("RunCount", 0);
jmitc91516 1:a5258871b33d 5069 int septaChangedRunCount = SettingsHandler::GetIntegerValueFromQSPISettings("RunCountWhenSeptaChanged", 0);
jmitc91516 1:a5258871b33d 5070
jmitc91516 1:a5258871b33d 5071 sprintf(injCount, "%d", (runCount - septaChangedRunCount));
jmitc91516 1:a5258871b33d 5072 }
jmitc91516 1:a5258871b33d 5073
jmitc91516 1:a5258871b33d 5074 /*
jmitc91516 1:a5258871b33d 5075 Gets the number of injections (i.e. runs) since the O-ring was changed,
jmitc91516 1:a5258871b33d 5076 and returns it as a null-terminated string.
jmitc91516 1:a5258871b33d 5077
jmitc91516 1:a5258871b33d 5078 This involves getting both values from the settings stored in QSPI memory.
jmitc91516 1:a5258871b33d 5079
jmitc91516 1:a5258871b33d 5080 Args: pointer to a buffer to contain the injection count, as a null-terminated string
jmitc91516 1:a5258871b33d 5081
jmitc91516 1:a5258871b33d 5082 No return code.
jmitc91516 1:a5258871b33d 5083 */
jmitc91516 1:a5258871b33d 5084 void GetGCStatusLoop::GetInjectionCountSinceOringChanged(char *injCount)
jmitc91516 1:a5258871b33d 5085 {
jmitc91516 1:a5258871b33d 5086 int runCount = SettingsHandler::GetIntegerValueFromQSPISettings("RunCount", 0);
jmitc91516 1:a5258871b33d 5087 int oRingChangedRunCount = SettingsHandler::GetIntegerValueFromQSPISettings("RunCountWhenOringChanged", 0);
jmitc91516 1:a5258871b33d 5088
jmitc91516 1:a5258871b33d 5089 sprintf(injCount, "%d", (runCount - oRingChangedRunCount));
jmitc91516 1:a5258871b33d 5090 }
jmitc91516 1:a5258871b33d 5091
jmitc91516 1:a5258871b33d 5092
jmitc91516 1:a5258871b33d 5093 /*
jmitc91516 1:a5258871b33d 5094 Gets the detector type, and returns it as a null-terminated string, with a descriptive prefix.
jmitc91516 1:a5258871b33d 5095 (This is the first version of this function, using the "QDTY" command.)
jmitc91516 1:a5258871b33d 5096
jmitc91516 1:a5258871b33d 5097 Note also that this code is intended to be as efficient as possible.
jmitc91516 1:a5258871b33d 5098
jmitc91516 1:a5258871b33d 5099 Args: pointer to a buffer to contain the detector type, as a null-terminated string
jmitc91516 1:a5258871b33d 5100 boolean set true if the caller wants a full prefix ("Detector type: "),
jmitc91516 1:a5258871b33d 5101 or false for a short prefix ("Type: ")
jmitc91516 1:a5258871b33d 5102
jmitc91516 1:a5258871b33d 5103 No return code.
jmitc91516 1:a5258871b33d 5104 */
jmitc91516 1:a5258871b33d 5105 void GetGCStatusLoop::GetDetectorTypeOld(char *type, bool wantFullPrefix)
jmitc91516 0:47c880c1463d 5106 {
jmitc91516 0:47c880c1463d 5107 char response[50];
jmitc91516 0:47c880c1463d 5108 SetGCDeviceReport("QDTY", response);
jmitc91516 0:47c880c1463d 5109
jmitc91516 1:a5258871b33d 5110 // We expect a response like this: "DDTY0000" for FID, "DDTY0001" for TCD,
jmitc91516 1:a5258871b33d 5111 // "DDTY0002" for ECD, "DDTY0003" for PID, "DDTY0004" for PDID, "DDTY0099" for None
jmitc91516 0:47c880c1463d 5112 int index = 0;
jmitc91516 0:47c880c1463d 5113 if(wantFullPrefix) {
jmitc91516 0:47c880c1463d 5114 type[index++] = 'D';
jmitc91516 0:47c880c1463d 5115 type[index++] = 'e';
jmitc91516 0:47c880c1463d 5116 type[index++] = 't';
jmitc91516 0:47c880c1463d 5117 type[index++] = 'e';
jmitc91516 0:47c880c1463d 5118 type[index++] = 'c';
jmitc91516 0:47c880c1463d 5119 type[index++] = 't';
jmitc91516 0:47c880c1463d 5120 type[index++] = 'o';
jmitc91516 0:47c880c1463d 5121 type[index++] = 'r';
jmitc91516 0:47c880c1463d 5122 type[index++] = ' ';
jmitc91516 0:47c880c1463d 5123 type[index++] = 't';
jmitc91516 0:47c880c1463d 5124 } else {
jmitc91516 0:47c880c1463d 5125 type[index++] = 'T';
jmitc91516 0:47c880c1463d 5126 }
jmitc91516 0:47c880c1463d 5127
jmitc91516 0:47c880c1463d 5128 type[index++] = 'y';
jmitc91516 0:47c880c1463d 5129 type[index++] = 'p';
jmitc91516 0:47c880c1463d 5130 type[index++] = 'e';
jmitc91516 0:47c880c1463d 5131 type[index++] = ':';
jmitc91516 0:47c880c1463d 5132 type[index++] = ' ';
jmitc91516 0:47c880c1463d 5133
jmitc91516 0:47c880c1463d 5134 // Check for "EPKT" first
jmitc91516 0:47c880c1463d 5135 if(response[0] == 'E') {
jmitc91516 0:47c880c1463d 5136 type[index++] = '*';
jmitc91516 0:47c880c1463d 5137 type[index++] = '*';
jmitc91516 0:47c880c1463d 5138 type[index++] = ' ';
jmitc91516 0:47c880c1463d 5139 type[index++] = 'E';
jmitc91516 0:47c880c1463d 5140 type[index++] = 'r';
jmitc91516 0:47c880c1463d 5141 type[index++] = 'r';
jmitc91516 0:47c880c1463d 5142 type[index++] = 'o';
jmitc91516 0:47c880c1463d 5143 type[index++] = 'r';
jmitc91516 0:47c880c1463d 5144 type[index++] = ' ';
jmitc91516 0:47c880c1463d 5145 type[index++] = '*';
jmitc91516 0:47c880c1463d 5146 type[index++] = '*';
jmitc91516 0:47c880c1463d 5147 type[index++] = '\0';
jmitc91516 0:47c880c1463d 5148 } else {
jmitc91516 0:47c880c1463d 5149 switch(response[7] ) {
jmitc91516 0:47c880c1463d 5150 case '0':
jmitc91516 0:47c880c1463d 5151 type[index++] = 'F';
jmitc91516 0:47c880c1463d 5152 type[index++] = 'I';
jmitc91516 0:47c880c1463d 5153 type[index++] = 'D';
jmitc91516 0:47c880c1463d 5154 type[index++] = '\0';
jmitc91516 0:47c880c1463d 5155 break;
jmitc91516 0:47c880c1463d 5156 case '1':
jmitc91516 0:47c880c1463d 5157 type[index++] = 'T';
jmitc91516 0:47c880c1463d 5158 type[index++] = 'C';
jmitc91516 0:47c880c1463d 5159 type[index++] = 'D';
jmitc91516 0:47c880c1463d 5160 type[index++] = '\0';
jmitc91516 0:47c880c1463d 5161 break;
jmitc91516 0:47c880c1463d 5162 case '2':
jmitc91516 0:47c880c1463d 5163 type[index++] = 'E';
jmitc91516 0:47c880c1463d 5164 type[index++] = 'C';
jmitc91516 0:47c880c1463d 5165 type[index++] = 'D';
jmitc91516 0:47c880c1463d 5166 type[index++] = '\0';
jmitc91516 0:47c880c1463d 5167 break;
jmitc91516 0:47c880c1463d 5168 case '3':
jmitc91516 0:47c880c1463d 5169 type[index++] = 'P';
jmitc91516 0:47c880c1463d 5170 type[index++] = 'I';
jmitc91516 0:47c880c1463d 5171 type[index++] = 'D';
jmitc91516 0:47c880c1463d 5172 type[index++] = '\0';
jmitc91516 0:47c880c1463d 5173 break;
jmitc91516 0:47c880c1463d 5174 case '4':
jmitc91516 0:47c880c1463d 5175 type[index++] = 'P';
jmitc91516 0:47c880c1463d 5176 type[index++] = 'D';
jmitc91516 0:47c880c1463d 5177 type[index++] = 'I';
jmitc91516 0:47c880c1463d 5178 type[index++] = 'D';
jmitc91516 0:47c880c1463d 5179 type[index++] = '\0';
jmitc91516 0:47c880c1463d 5180 break;
jmitc91516 0:47c880c1463d 5181 default:
jmitc91516 0:47c880c1463d 5182 type[index++] = 'N';
jmitc91516 0:47c880c1463d 5183 type[index++] = 'o';
jmitc91516 0:47c880c1463d 5184 type[index++] = 'n';
jmitc91516 0:47c880c1463d 5185 type[index++] = 'e';
jmitc91516 0:47c880c1463d 5186 type[index++] = '\0';
jmitc91516 0:47c880c1463d 5187 break;
jmitc91516 0:47c880c1463d 5188 }
jmitc91516 0:47c880c1463d 5189 }
jmitc91516 0:47c880c1463d 5190 }
jmitc91516 0:47c880c1463d 5191
jmitc91516 1:a5258871b33d 5192 /*
jmitc91516 1:a5258871b33d 5193 Gets the detector type, and returns it as a null-terminated string, with a descriptive prefix.
jmitc91516 1:a5258871b33d 5194 (This is the second version of this function, using the new "GDTY" command.)
jmitc91516 1:a5258871b33d 5195
jmitc91516 1:a5258871b33d 5196 Note also that this code is intended to be as efficient as possible.
jmitc91516 1:a5258871b33d 5197
jmitc91516 1:a5258871b33d 5198 Args: pointer to a buffer to contain the detector type, as a null-terminated string
jmitc91516 1:a5258871b33d 5199 boolean set true if the caller wants a full prefix ("Detector type: "),
jmitc91516 1:a5258871b33d 5200 or false for a short prefix ("Type: ")
jmitc91516 1:a5258871b33d 5201 boolean set true if the caller wants any prefix, false for no prefix at all
jmitc91516 1:a5258871b33d 5202
jmitc91516 1:a5258871b33d 5203 No return code.
jmitc91516 1:a5258871b33d 5204 */
jmitc91516 1:a5258871b33d 5205 void GetGCStatusLoop::GetDetectorType(char *type, bool wantFullPrefix, bool wantPrefix)
jmitc91516 1:a5258871b33d 5206 {
jmitc91516 1:a5258871b33d 5207 char response[50];
jmitc91516 1:a5258871b33d 5208 SetGCDeviceReport("GDTY", response);
jmitc91516 1:a5258871b33d 5209
jmitc91516 1:a5258871b33d 5210 // We expect a response like this: "DDTY0000" for FID, "DDTY0001" for TCD,
jmitc91516 1:a5258871b33d 5211 // "DDTY0002" for ECD, "DDTY0003" for TXL, "DDTY0005" for NPD, "DDTY0006" for PID,
jmitc91516 1:a5258871b33d 5212 // "DDTY0007" for FPD, "DDTY0008" for SPDID.
jmitc91516 1:a5258871b33d 5213 // We assume any other "DDTY00nn" value means "None".
jmitc91516 1:a5258871b33d 5214
jmitc91516 1:a5258871b33d 5215 int index = 0;
jmitc91516 1:a5258871b33d 5216 if(wantPrefix) {
jmitc91516 1:a5258871b33d 5217 if(wantFullPrefix) {
jmitc91516 1:a5258871b33d 5218 type[index++] = 'D';
jmitc91516 1:a5258871b33d 5219 type[index++] = 'e';
jmitc91516 1:a5258871b33d 5220 type[index++] = 't';
jmitc91516 1:a5258871b33d 5221 type[index++] = 'e';
jmitc91516 1:a5258871b33d 5222 type[index++] = 'c';
jmitc91516 1:a5258871b33d 5223 type[index++] = 't';
jmitc91516 1:a5258871b33d 5224 type[index++] = 'o';
jmitc91516 1:a5258871b33d 5225 type[index++] = 'r';
jmitc91516 1:a5258871b33d 5226 type[index++] = ' ';
jmitc91516 1:a5258871b33d 5227 type[index++] = 't';
jmitc91516 1:a5258871b33d 5228 } else {
jmitc91516 1:a5258871b33d 5229 type[index++] = 'T';
jmitc91516 1:a5258871b33d 5230 }
jmitc91516 1:a5258871b33d 5231
jmitc91516 1:a5258871b33d 5232 type[index++] = 'y';
jmitc91516 1:a5258871b33d 5233 type[index++] = 'p';
jmitc91516 1:a5258871b33d 5234 type[index++] = 'e';
jmitc91516 1:a5258871b33d 5235 type[index++] = ':';
jmitc91516 1:a5258871b33d 5236 type[index++] = ' ';
jmitc91516 1:a5258871b33d 5237 }
jmitc91516 1:a5258871b33d 5238
jmitc91516 1:a5258871b33d 5239 // Check for "EPKT" first
jmitc91516 1:a5258871b33d 5240 if(response[0] == 'E') {
jmitc91516 1:a5258871b33d 5241 type[index++] = '*';
jmitc91516 1:a5258871b33d 5242 type[index++] = '*';
jmitc91516 1:a5258871b33d 5243 type[index++] = ' ';
jmitc91516 1:a5258871b33d 5244 type[index++] = 'E';
jmitc91516 1:a5258871b33d 5245 type[index++] = 'r';
jmitc91516 1:a5258871b33d 5246 type[index++] = 'r';
jmitc91516 1:a5258871b33d 5247 type[index++] = 'o';
jmitc91516 1:a5258871b33d 5248 type[index++] = 'r';
jmitc91516 1:a5258871b33d 5249 type[index++] = ' ';
jmitc91516 1:a5258871b33d 5250 type[index++] = '*';
jmitc91516 1:a5258871b33d 5251 type[index++] = '*';
jmitc91516 1:a5258871b33d 5252 type[index++] = '\0';
jmitc91516 1:a5258871b33d 5253 } else {
jmitc91516 1:a5258871b33d 5254 switch(response[7] ) {
jmitc91516 1:a5258871b33d 5255 case '0':
jmitc91516 1:a5258871b33d 5256 type[index++] = 'F';
jmitc91516 1:a5258871b33d 5257 type[index++] = 'I';
jmitc91516 1:a5258871b33d 5258 type[index++] = 'D';
jmitc91516 1:a5258871b33d 5259 type[index++] = '\0';
jmitc91516 1:a5258871b33d 5260 break;
jmitc91516 1:a5258871b33d 5261 case '1':
jmitc91516 1:a5258871b33d 5262 type[index++] = 'T';
jmitc91516 1:a5258871b33d 5263 type[index++] = 'C';
jmitc91516 1:a5258871b33d 5264 type[index++] = 'D';
jmitc91516 1:a5258871b33d 5265 type[index++] = '\0';
jmitc91516 1:a5258871b33d 5266 break;
jmitc91516 1:a5258871b33d 5267 case '2':
jmitc91516 1:a5258871b33d 5268 type[index++] = 'E';
jmitc91516 1:a5258871b33d 5269 type[index++] = 'C';
jmitc91516 1:a5258871b33d 5270 type[index++] = 'D';
jmitc91516 1:a5258871b33d 5271 type[index++] = '\0';
jmitc91516 1:a5258871b33d 5272 break;
jmitc91516 1:a5258871b33d 5273 // Omit 4, i.e. "None" - leave for default
jmitc91516 1:a5258871b33d 5274 case '3':
jmitc91516 1:a5258871b33d 5275 type[index++] = 'T';
jmitc91516 1:a5258871b33d 5276 type[index++] = 'X';
jmitc91516 1:a5258871b33d 5277 type[index++] = 'L';
jmitc91516 1:a5258871b33d 5278 type[index++] = '\0';
jmitc91516 1:a5258871b33d 5279 break;
jmitc91516 1:a5258871b33d 5280 case '5':
jmitc91516 1:a5258871b33d 5281 type[index++] = 'N';
jmitc91516 1:a5258871b33d 5282 type[index++] = 'P';
jmitc91516 1:a5258871b33d 5283 type[index++] = 'D';
jmitc91516 1:a5258871b33d 5284 type[index++] = '\0';
jmitc91516 1:a5258871b33d 5285 break;
jmitc91516 1:a5258871b33d 5286 case '6':
jmitc91516 1:a5258871b33d 5287 type[index++] = 'P';
jmitc91516 1:a5258871b33d 5288 type[index++] = 'I';
jmitc91516 1:a5258871b33d 5289 type[index++] = 'D';
jmitc91516 1:a5258871b33d 5290 type[index++] = '\0';
jmitc91516 1:a5258871b33d 5291 break;
jmitc91516 1:a5258871b33d 5292 case '7':
jmitc91516 1:a5258871b33d 5293 type[index++] = 'F';
jmitc91516 1:a5258871b33d 5294 type[index++] = 'P';
jmitc91516 1:a5258871b33d 5295 type[index++] = 'D';
jmitc91516 1:a5258871b33d 5296 type[index++] = '\0';
jmitc91516 1:a5258871b33d 5297 break;
jmitc91516 1:a5258871b33d 5298 case '8':
jmitc91516 1:a5258871b33d 5299 type[index++] = 'S';
jmitc91516 1:a5258871b33d 5300 type[index++] = 'P';
jmitc91516 1:a5258871b33d 5301 type[index++] = 'D';
jmitc91516 1:a5258871b33d 5302 type[index++] = 'I';
jmitc91516 1:a5258871b33d 5303 type[index++] = 'D';
jmitc91516 1:a5258871b33d 5304 type[index++] = '\0';
jmitc91516 1:a5258871b33d 5305 break;
jmitc91516 1:a5258871b33d 5306 default:
jmitc91516 1:a5258871b33d 5307 type[index++] = 'N';
jmitc91516 1:a5258871b33d 5308 type[index++] = 'o';
jmitc91516 1:a5258871b33d 5309 type[index++] = 'n';
jmitc91516 1:a5258871b33d 5310 type[index++] = 'e';
jmitc91516 1:a5258871b33d 5311 type[index++] = '\0';
jmitc91516 1:a5258871b33d 5312 break;
jmitc91516 1:a5258871b33d 5313 }
jmitc91516 1:a5258871b33d 5314 }
jmitc91516 1:a5258871b33d 5315 }
jmitc91516 1:a5258871b33d 5316
jmitc91516 1:a5258871b33d 5317 /*
jmitc91516 1:a5258871b33d 5318 Gets the detector range, and returns it as a null-terminated string.
jmitc91516 1:a5258871b33d 5319
jmitc91516 1:a5258871b33d 5320 Note also that this code is intended to be as efficient as possible.
jmitc91516 1:a5258871b33d 5321
jmitc91516 1:a5258871b33d 5322 Args: pointer to a buffer to contain the detector range, as a null-terminated string
jmitc91516 1:a5258871b33d 5323
jmitc91516 1:a5258871b33d 5324 No return code.
jmitc91516 1:a5258871b33d 5325 */
jmitc91516 1:a5258871b33d 5326 void GetGCStatusLoop::GetDetectorRange(char *range)
jmitc91516 1:a5258871b33d 5327 {
jmitc91516 1:a5258871b33d 5328 char response[50];
jmitc91516 1:a5258871b33d 5329 SetGCDeviceReport("GRNG", response);
jmitc91516 1:a5258871b33d 5330
jmitc91516 1:a5258871b33d 5331 // We expect a response like this: "DRNG0001" for x2,
jmitc91516 1:a5258871b33d 5332 // "DRNG0002" for x10, "DRNG0003" for x100, "DRNG0004" for x1000
jmitc91516 1:a5258871b33d 5333
jmitc91516 1:a5258871b33d 5334 int index = 0;
jmitc91516 1:a5258871b33d 5335 // Check for "EPKT" first
jmitc91516 1:a5258871b33d 5336 if(response[0] == 'E') {
jmitc91516 1:a5258871b33d 5337 range[index++] = '*';
jmitc91516 1:a5258871b33d 5338 range[index++] = '*';
jmitc91516 1:a5258871b33d 5339 range[index++] = ' ';
jmitc91516 1:a5258871b33d 5340 range[index++] = 'E';
jmitc91516 1:a5258871b33d 5341 range[index++] = 'r';
jmitc91516 1:a5258871b33d 5342 range[index++] = 'r';
jmitc91516 1:a5258871b33d 5343 range[index++] = 'o';
jmitc91516 1:a5258871b33d 5344 range[index++] = 'r';
jmitc91516 1:a5258871b33d 5345 range[index++] = ' ';
jmitc91516 1:a5258871b33d 5346 range[index++] = '*';
jmitc91516 1:a5258871b33d 5347 range[index++] = '*';
jmitc91516 1:a5258871b33d 5348 } else {
jmitc91516 1:a5258871b33d 5349 range[index++] = 'x';
jmitc91516 1:a5258871b33d 5350 switch (response[7]) {
jmitc91516 1:a5258871b33d 5351 case '2':
jmitc91516 1:a5258871b33d 5352 range[index++] = '1';
jmitc91516 1:a5258871b33d 5353 range[index++] = '0';
jmitc91516 1:a5258871b33d 5354 break;
jmitc91516 1:a5258871b33d 5355 case '3':
jmitc91516 1:a5258871b33d 5356 range[index++] = '1';
jmitc91516 1:a5258871b33d 5357 range[index++] = '0';
jmitc91516 1:a5258871b33d 5358 range[index++] = '0';
jmitc91516 1:a5258871b33d 5359 break;
jmitc91516 1:a5258871b33d 5360 case '4':
jmitc91516 1:a5258871b33d 5361 range[index++] = '1';
jmitc91516 1:a5258871b33d 5362 range[index++] = '0';
jmitc91516 1:a5258871b33d 5363 range[index++] = '0';
jmitc91516 1:a5258871b33d 5364 range[index++] = '0';
jmitc91516 1:a5258871b33d 5365 break;
jmitc91516 1:a5258871b33d 5366 default:
jmitc91516 1:a5258871b33d 5367 range[index++] = '2';
jmitc91516 1:a5258871b33d 5368 break;
jmitc91516 1:a5258871b33d 5369 }
jmitc91516 1:a5258871b33d 5370 }
jmitc91516 1:a5258871b33d 5371
jmitc91516 1:a5258871b33d 5372 range[index] = '\0';
jmitc91516 1:a5258871b33d 5373 }
jmitc91516 1:a5258871b33d 5374
jmitc91516 1:a5258871b33d 5375 /*
jmitc91516 1:a5258871b33d 5376 Gets the detector ignition state (not lit, igniting, lit), and returns it as a null-terminated string.
jmitc91516 1:a5258871b33d 5377
jmitc91516 1:a5258871b33d 5378 Note also that this code is intended to be as efficient as possible.
jmitc91516 1:a5258871b33d 5379
jmitc91516 1:a5258871b33d 5380 Args: pointer to a buffer to contain the state, as a null-terminated string
jmitc91516 1:a5258871b33d 5381
jmitc91516 1:a5258871b33d 5382 No return code.
jmitc91516 1:a5258871b33d 5383 */
jmitc91516 1:a5258871b33d 5384 void GetGCStatusLoop::GetDetectorIgnitionState(char *state)
jmitc91516 1:a5258871b33d 5385 {
jmitc91516 1:a5258871b33d 5386 char response[50];
jmitc91516 1:a5258871b33d 5387 SetGCDeviceReport("QIGN", response);
jmitc91516 1:a5258871b33d 5388
jmitc91516 1:a5258871b33d 5389 // We expect a response like this: "DIGN0001" for "not lit",
jmitc91516 1:a5258871b33d 5390 // "DIGN0002" for "igniting", "DIGN0003" for "lit"
jmitc91516 1:a5258871b33d 5391
jmitc91516 1:a5258871b33d 5392 int index = 0;
jmitc91516 1:a5258871b33d 5393 // Check for "EPKT" first
jmitc91516 1:a5258871b33d 5394 if(response[0] == 'E') {
jmitc91516 1:a5258871b33d 5395 state[index++] = '*';
jmitc91516 1:a5258871b33d 5396 state[index++] = '*';
jmitc91516 1:a5258871b33d 5397 state[index++] = ' ';
jmitc91516 1:a5258871b33d 5398 state[index++] = 'E';
jmitc91516 1:a5258871b33d 5399 state[index++] = 'r';
jmitc91516 1:a5258871b33d 5400 state[index++] = 'r';
jmitc91516 1:a5258871b33d 5401 state[index++] = 'o';
jmitc91516 1:a5258871b33d 5402 state[index++] = 'r';
jmitc91516 1:a5258871b33d 5403 state[index++] = ' ';
jmitc91516 1:a5258871b33d 5404 state[index++] = '*';
jmitc91516 1:a5258871b33d 5405 state[index++] = '*';
jmitc91516 1:a5258871b33d 5406 } else {
jmitc91516 1:a5258871b33d 5407 switch (response[7]) {
jmitc91516 1:a5258871b33d 5408 case '2':
jmitc91516 1:a5258871b33d 5409 state[index++] = 'i';
jmitc91516 1:a5258871b33d 5410 state[index++] = 'g';
jmitc91516 1:a5258871b33d 5411 state[index++] = 'n';
jmitc91516 1:a5258871b33d 5412 state[index++] = 'i';
jmitc91516 1:a5258871b33d 5413 state[index++] = 't';
jmitc91516 1:a5258871b33d 5414 state[index++] = 'i';
jmitc91516 1:a5258871b33d 5415 state[index++] = 'n';
jmitc91516 1:a5258871b33d 5416 state[index++] = 'g';
jmitc91516 1:a5258871b33d 5417 break;
jmitc91516 1:a5258871b33d 5418 case '3':
jmitc91516 1:a5258871b33d 5419 state[index++] = 'l';
jmitc91516 1:a5258871b33d 5420 state[index++] = 'i';
jmitc91516 1:a5258871b33d 5421 state[index++] = 't';
jmitc91516 1:a5258871b33d 5422 break;
jmitc91516 1:a5258871b33d 5423 default:
jmitc91516 1:a5258871b33d 5424 state[index++] = 'n';
jmitc91516 1:a5258871b33d 5425 state[index++] = 'o';
jmitc91516 1:a5258871b33d 5426 state[index++] = 't';
jmitc91516 1:a5258871b33d 5427 state[index++] = ' ';
jmitc91516 1:a5258871b33d 5428 state[index++] = 'l';
jmitc91516 1:a5258871b33d 5429 state[index++] = 'i';
jmitc91516 1:a5258871b33d 5430 state[index++] = 't';
jmitc91516 1:a5258871b33d 5431 break;
jmitc91516 1:a5258871b33d 5432 }
jmitc91516 1:a5258871b33d 5433 }
jmitc91516 1:a5258871b33d 5434
jmitc91516 1:a5258871b33d 5435 state[index] = '\0';
jmitc91516 1:a5258871b33d 5436 }
jmitc91516 1:a5258871b33d 5437
jmitc91516 1:a5258871b33d 5438 /*
jmitc91516 1:a5258871b33d 5439 Gets the specified flow rate, and returns it as a null-terminated string.
jmitc91516 1:a5258871b33d 5440
jmitc91516 1:a5258871b33d 5441 Note also that this code is intended to be as efficient as possible.
jmitc91516 1:a5258871b33d 5442
jmitc91516 1:a5258871b33d 5443 Args: pointer to the command characters, as a null-terminated string
jmitc91516 1:a5258871b33d 5444 pointer to a buffer to contain the flow rate, as a null-terminated string
jmitc91516 1:a5258871b33d 5445
jmitc91516 1:a5258871b33d 5446 No return code.
jmitc91516 1:a5258871b33d 5447 */
jmitc91516 1:a5258871b33d 5448 void GetGCStatusLoop::GetFlowRate(char* cmd, char *rate)
jmitc91516 1:a5258871b33d 5449 {
jmitc91516 1:a5258871b33d 5450 char response[50];
jmitc91516 1:a5258871b33d 5451 SetGCDeviceReport(cmd, response);
jmitc91516 1:a5258871b33d 5452
jmitc91516 1:a5258871b33d 5453 // We expect a response like this: "Dxxxnnnn", where 'nnnn' is the flow rate, in ml/min.
jmitc91516 1:a5258871b33d 5454 // Note that we do *not* want leading zeroes
jmitc91516 1:a5258871b33d 5455
jmitc91516 1:a5258871b33d 5456 int index = 0;
jmitc91516 1:a5258871b33d 5457 // Check for "EPKT" first
jmitc91516 1:a5258871b33d 5458 if(response[0] == 'E') {
jmitc91516 1:a5258871b33d 5459 rate[index++] = '*';
jmitc91516 1:a5258871b33d 5460 rate[index++] = '*';
jmitc91516 1:a5258871b33d 5461 rate[index++] = ' ';
jmitc91516 1:a5258871b33d 5462 rate[index++] = 'E';
jmitc91516 1:a5258871b33d 5463 rate[index++] = 'r';
jmitc91516 1:a5258871b33d 5464 rate[index++] = 'r';
jmitc91516 1:a5258871b33d 5465 rate[index++] = 'o';
jmitc91516 1:a5258871b33d 5466 rate[index++] = 'r';
jmitc91516 1:a5258871b33d 5467 rate[index++] = ' ';
jmitc91516 1:a5258871b33d 5468 rate[index++] = '*';
jmitc91516 1:a5258871b33d 5469 rate[index++] = '*';
jmitc91516 1:a5258871b33d 5470 } else {
jmitc91516 1:a5258871b33d 5471 bool wantNextChars = false;
jmitc91516 1:a5258871b33d 5472 if(response[4] != '0') {
jmitc91516 1:a5258871b33d 5473 rate[index++] = response[4];
jmitc91516 1:a5258871b33d 5474 wantNextChars = true;
jmitc91516 1:a5258871b33d 5475 }
jmitc91516 1:a5258871b33d 5476 if(wantNextChars || (response[5] != '0')) {
jmitc91516 1:a5258871b33d 5477 rate[index++] = response[5];
jmitc91516 1:a5258871b33d 5478 wantNextChars = true;
jmitc91516 1:a5258871b33d 5479 }
jmitc91516 1:a5258871b33d 5480 if(wantNextChars || (response[6] != '0')) {
jmitc91516 1:a5258871b33d 5481 rate[index++] = response[6];
jmitc91516 1:a5258871b33d 5482 }
jmitc91516 1:a5258871b33d 5483 // We always want the final char, even if it's zero -
jmitc91516 1:a5258871b33d 5484 // the flow rate may actually be zero
jmitc91516 1:a5258871b33d 5485 rate[index++] = response[7];
jmitc91516 1:a5258871b33d 5486
jmitc91516 1:a5258871b33d 5487 rate[index++] = ' ';
jmitc91516 1:a5258871b33d 5488 rate[index++] = 'm';
jmitc91516 1:a5258871b33d 5489 rate[index++] = 'l';
jmitc91516 1:a5258871b33d 5490 rate[index++] = '/';
jmitc91516 1:a5258871b33d 5491 rate[index++] = 'm';
jmitc91516 1:a5258871b33d 5492 rate[index++] = 'i';
jmitc91516 1:a5258871b33d 5493 rate[index++] = 'n';
jmitc91516 1:a5258871b33d 5494 }
jmitc91516 1:a5258871b33d 5495
jmitc91516 1:a5258871b33d 5496 rate[index] = '\0';
jmitc91516 1:a5258871b33d 5497 }
jmitc91516 1:a5258871b33d 5498
jmitc91516 1:a5258871b33d 5499 /*
jmitc91516 1:a5258871b33d 5500 Gets the detector fuel flow rate, and returns it as a null-terminated string.
jmitc91516 1:a5258871b33d 5501
jmitc91516 1:a5258871b33d 5502 Args: pointer to a buffer to contain the fuel flow rate, as a null-terminated string
jmitc91516 1:a5258871b33d 5503
jmitc91516 1:a5258871b33d 5504 No return code.
jmitc91516 1:a5258871b33d 5505 */
jmitc91516 1:a5258871b33d 5506 void GetGCStatusLoop::GetFuelFlowRate(char *rate)
jmitc91516 1:a5258871b33d 5507 {
jmitc91516 1:a5258871b33d 5508 GetFlowRate("GHFL", rate);
jmitc91516 1:a5258871b33d 5509 }
jmitc91516 1:a5258871b33d 5510
jmitc91516 1:a5258871b33d 5511 /*
jmitc91516 1:a5258871b33d 5512 Gets the detector air flow rate, and returns it as a null-terminated string.
jmitc91516 1:a5258871b33d 5513
jmitc91516 1:a5258871b33d 5514 Args: pointer to a buffer to contain the air flow rate, as a null-terminated string
jmitc91516 1:a5258871b33d 5515
jmitc91516 1:a5258871b33d 5516 No return code.
jmitc91516 1:a5258871b33d 5517 */
jmitc91516 1:a5258871b33d 5518 void GetGCStatusLoop::GetAirFlowRate(char *rate)
jmitc91516 1:a5258871b33d 5519 {
jmitc91516 1:a5258871b33d 5520 GetFlowRate("GAFL", rate);
jmitc91516 1:a5258871b33d 5521 }
jmitc91516 1:a5258871b33d 5522
jmitc91516 1:a5258871b33d 5523
jmitc91516 1:a5258871b33d 5524
jmitc91516 1:a5258871b33d 5525 /*
jmitc91516 1:a5258871b33d 5526 If the detector temperature has changed on the detector page,
jmitc91516 1:a5258871b33d 5527 redraw it manually - do not redisplay the entire page just for this
jmitc91516 1:a5258871b33d 5528 (trying to reduce "flashing and banging")
jmitc91516 1:a5258871b33d 5529 */
jmitc91516 1:a5258871b33d 5530 void GetGCStatusLoop::DrawDetectorTemperatureVariableOnDetectorPage(void)
jmitc91516 1:a5258871b33d 5531 {
jmitc91516 1:a5258871b33d 5532 // Hard coded values taken from easyGUI -
jmitc91516 1:a5258871b33d 5533 // Note that the temperature is at the same coordinates on all the detector pages
jmitc91516 1:a5258871b33d 5534 //(except TCD, where it does not appear)
jmitc91516 1:a5258871b33d 5535 RedrawSingleEasyGUIVariableOnComponentPage(380, 290, &GuiVar_detectorTemperature, GuiLib_ALIGN_LEFT, DETECTOR);
jmitc91516 1:a5258871b33d 5536 }
jmitc91516 1:a5258871b33d 5537
jmitc91516 1:a5258871b33d 5538 /*
jmitc91516 1:a5258871b33d 5539 If the detector target temperature has changed on the detector page,
jmitc91516 1:a5258871b33d 5540 redraw it manually - do not redisplay the entire page just for this
jmitc91516 1:a5258871b33d 5541 (trying to reduce "flashing and banging")
jmitc91516 1:a5258871b33d 5542 */
jmitc91516 1:a5258871b33d 5543 void GetGCStatusLoop::DrawDetectorTargetTemperatureVariableOnDetectorPage(void)
jmitc91516 1:a5258871b33d 5544 {
jmitc91516 1:a5258871b33d 5545 // Hard coded values taken from easyGUI -
jmitc91516 1:a5258871b33d 5546 // Note that the target temperature is at the same coordinates on all the detector pages
jmitc91516 1:a5258871b33d 5547 //(except TCD, where it does not appear)
jmitc91516 1:a5258871b33d 5548 RedrawSingleEasyGUIVariableOnComponentPage(380, 330, &GuiVar_detectorTargetTemperature2, GuiLib_ALIGN_LEFT, DETECTOR);
jmitc91516 1:a5258871b33d 5549 }
jmitc91516 1:a5258871b33d 5550
jmitc91516 1:a5258871b33d 5551 /*
jmitc91516 1:a5258871b33d 5552 Displays the data on one of the detector pages, by copying the data to the relevant easyGUI variables,
jmitc91516 1:a5258871b33d 5553 and calling the relevant functions to actually display it.
jmitc91516 1:a5258871b33d 5554
jmitc91516 1:a5258871b33d 5555 Args: a boolean specifying whether or not the display is actually to be updated.
jmitc91516 1:a5258871b33d 5556 Even if it is false when we are called, we may set it true if we discover
jmitc91516 1:a5258871b33d 5557 one or more data items has changed - but note that we will not set it false
jmitc91516 1:a5258871b33d 5558 if it is already true. If it is true after we have looked at all
jmitc91516 1:a5258871b33d 5559 the home page data, we will then update the display. (If we are called
jmitc91516 1:a5258871b33d 5560 with this value set to false, the caller is effectively saying
jmitc91516 1:a5258871b33d 5561 'display the detector page data only if it has changed').
jmitc91516 1:a5258871b33d 5562
jmitc91516 1:a5258871b33d 5563 the detector type. (It seems ridiculous to have separate functions for each type,
jmitc91516 1:a5258871b33d 5564 since the values that need to be displayed are mostly the same.)
jmitc91516 1:a5258871b33d 5565
jmitc91516 1:a5258871b33d 5566 the page number (this is derived from the detector type - if the caller knows the detector type,
jmitc91516 1:a5258871b33d 5567 it must also (in effect) know the page number, so it seems ridiculous for this function
jmitc91516 1:a5258871b33d 5568 to work it out again).
jmitc91516 1:a5258871b33d 5569
jmitc91516 1:a5258871b33d 5570 No return code.
jmitc91516 1:a5258871b33d 5571 */
jmitc91516 1:a5258871b33d 5572 void GetGCStatusLoop::DisplayDetectorPageData(bool mustUpdateDisplay, DetectorType detectorType, int pageNumber)
jmitc91516 0:47c880c1463d 5573 {
jmitc91516 0:47c880c1463d 5574 // EasyGUIDebugPrint("Detector Page", 100, 100);
jmitc91516 0:47c880c1463d 5575 // Detector temperature and type
jmitc91516 0:47c880c1463d 5576 char buff[40];
jmitc91516 0:47c880c1463d 5577
jmitc91516 1:a5258871b33d 5578 if(detectorType != NO_DETECTOR) {
jmitc91516 1:a5258871b33d 5579 GetDetectorType(buff, false, false);
jmitc91516 1:a5258871b33d 5580 if(strcmp(buff, GuiVar_detectorType2) != 0) {
jmitc91516 1:a5258871b33d 5581 strcpy(GuiVar_detectorType2, buff);
jmitc91516 1:a5258871b33d 5582 mustUpdateDisplay = true;
jmitc91516 1:a5258871b33d 5583 }
jmitc91516 1:a5258871b33d 5584
jmitc91516 1:a5258871b33d 5585 GetDetectorRange(buff);
jmitc91516 1:a5258871b33d 5586 if(strcmp(buff, GuiVar_detectorRange) != 0) {
jmitc91516 1:a5258871b33d 5587 strcpy(GuiVar_detectorRange, buff);
jmitc91516 1:a5258871b33d 5588 mustUpdateDisplay = true;
jmitc91516 1:a5258871b33d 5589 }
jmitc91516 1:a5258871b33d 5590
jmitc91516 1:a5258871b33d 5591 GetFuelFlowRate(buff);
jmitc91516 1:a5258871b33d 5592 if(strcmp(buff, GuiVar_detectorFuelFlowRate) != 0) {
jmitc91516 1:a5258871b33d 5593 strcpy(GuiVar_detectorFuelFlowRate, buff);
jmitc91516 1:a5258871b33d 5594 mustUpdateDisplay = true;
jmitc91516 1:a5258871b33d 5595 }
jmitc91516 1:a5258871b33d 5596
jmitc91516 1:a5258871b33d 5597 GetAirFlowRate(buff);
jmitc91516 1:a5258871b33d 5598 if(strcmp(buff, GuiVar_detectorAirFlowRate) != 0) {
jmitc91516 1:a5258871b33d 5599 strcpy(GuiVar_detectorAirFlowRate, buff);
jmitc91516 1:a5258871b33d 5600 mustUpdateDisplay = true;
jmitc91516 1:a5258871b33d 5601 }
jmitc91516 1:a5258871b33d 5602
jmitc91516 1:a5258871b33d 5603 GetDetectorIgnitionState(buff);
jmitc91516 1:a5258871b33d 5604 if(strcmp(buff, GuiVar_detectorStatus) != 0) {
jmitc91516 1:a5258871b33d 5605 strcpy(GuiVar_detectorStatus, buff);
jmitc91516 1:a5258871b33d 5606 mustUpdateDisplay = true;
jmitc91516 1:a5258871b33d 5607 }
jmitc91516 1:a5258871b33d 5608
jmitc91516 1:a5258871b33d 5609 // Now - variables that are different between the detector types
jmitc91516 1:a5258871b33d 5610 if(detectorType != TCD_DETECTOR) {
jmitc91516 1:a5258871b33d 5611
jmitc91516 1:a5258871b33d 5612 GetDetectorTemperature(buff);
jmitc91516 1:a5258871b33d 5613 if(strcmp(buff, GuiVar_detectorTemperature) != 0) {
jmitc91516 1:a5258871b33d 5614 strcpy(GuiVar_detectorTemperature, buff);
jmitc91516 1:a5258871b33d 5615
jmitc91516 1:a5258871b33d 5616 //mustUpdateDisplay = true;
jmitc91516 1:a5258871b33d 5617 // No - just do this (don't force entire rectangle to redisplay)
jmitc91516 1:a5258871b33d 5618 DrawDetectorTemperatureVariableOnDetectorPage();
jmitc91516 1:a5258871b33d 5619 }
jmitc91516 1:a5258871b33d 5620
jmitc91516 6:dba3fbdfd5da 5621 GetDetectorTargetTemperature(buff, stringFormatdegCUnits);
jmitc91516 1:a5258871b33d 5622 if(strcmp(buff, GuiVar_detectorTargetTemperature2) != 0) {
jmitc91516 1:a5258871b33d 5623 strcpy(GuiVar_detectorTargetTemperature2, buff);
jmitc91516 1:a5258871b33d 5624
jmitc91516 1:a5258871b33d 5625 //mustUpdateDisplay = true;
jmitc91516 1:a5258871b33d 5626 // No - just do this (don't force entire rectangle to redisplay)
jmitc91516 1:a5258871b33d 5627 DrawDetectorTemperatureVariableOnDetectorPage();
jmitc91516 1:a5258871b33d 5628 }
jmitc91516 1:a5258871b33d 5629 }
jmitc91516 1:a5258871b33d 5630
jmitc91516 1:a5258871b33d 5631 if(detectorType == TCD_DETECTOR) {
jmitc91516 1:a5258871b33d 5632
jmitc91516 1:a5258871b33d 5633 GetTCDDetectorFilamentTemperature(buff);
jmitc91516 1:a5258871b33d 5634 if(strcmp(buff, GuiVar_tcdDetectorFilamentTemperature) != 0) {
jmitc91516 1:a5258871b33d 5635 strcpy(GuiVar_tcdDetectorFilamentTemperature, buff);
jmitc91516 1:a5258871b33d 5636 mustUpdateDisplay = true;
jmitc91516 1:a5258871b33d 5637 }
jmitc91516 1:a5258871b33d 5638
jmitc91516 1:a5258871b33d 5639 GetTCDDetectorFilamentPolarity(buff);
jmitc91516 1:a5258871b33d 5640 if(strcmp(buff, GuiVar_tcdDetectorFilamentPolarity) != 0) {
jmitc91516 1:a5258871b33d 5641 strcpy(GuiVar_tcdDetectorFilamentPolarity, buff);
jmitc91516 1:a5258871b33d 5642 mustUpdateDisplay = true;
jmitc91516 1:a5258871b33d 5643 }
jmitc91516 1:a5258871b33d 5644
jmitc91516 1:a5258871b33d 5645 } else if(detectorType == ECD_DETECTOR) {
jmitc91516 1:a5258871b33d 5646
jmitc91516 1:a5258871b33d 5647 GetECDDetectorCurrent(buff);
jmitc91516 1:a5258871b33d 5648 if(strcmp(buff, GuiVar_ecdDetectorCurrent) != 0) {
jmitc91516 1:a5258871b33d 5649 strcpy(GuiVar_ecdDetectorCurrent, buff);
jmitc91516 1:a5258871b33d 5650 mustUpdateDisplay = true;
jmitc91516 1:a5258871b33d 5651 }
jmitc91516 1:a5258871b33d 5652
jmitc91516 1:a5258871b33d 5653 } else if(detectorType == FPD_DETECTOR) {
jmitc91516 1:a5258871b33d 5654
jmitc91516 1:a5258871b33d 5655 GetFPDDetectorSensitivity(buff);
jmitc91516 1:a5258871b33d 5656 if(strcmp(buff, GuiVar_fpdDetectorSensitivity) != 0) {
jmitc91516 1:a5258871b33d 5657 strcpy(GuiVar_fpdDetectorSensitivity, buff);
jmitc91516 1:a5258871b33d 5658 mustUpdateDisplay = true;
jmitc91516 1:a5258871b33d 5659 }
jmitc91516 1:a5258871b33d 5660 }
jmitc91516 1:a5258871b33d 5661 }
jmitc91516 1:a5258871b33d 5662
jmitc91516 1:a5258871b33d 5663 if(SinglePageGCComponentStatusHasChanged(DETECTOR, lastDetectorStatusDisplayedOnDetectorPage)) {
jmitc91516 0:47c880c1463d 5664 mustUpdateDisplay = true;
jmitc91516 0:47c880c1463d 5665 }
jmitc91516 0:47c880c1463d 5666
jmitc91516 0:47c880c1463d 5667 if(mustUpdateDisplay) {
jmitc91516 0:47c880c1463d 5668
jmitc91516 3:010aeeacd7d7 5669 #ifdef WANT_DETECTOR_STATUS_RECTANGLE
jmitc91516 0:47c880c1463d 5670 // Reduce display flickering - get the component status from the GC
jmitc91516 0:47c880c1463d 5671 // *before* we call GuiLib_Clear()
jmitc91516 0:47c880c1463d 5672 if(singleGCComponentPageStatusColorAreas != NULL) {
jmitc91516 0:47c880c1463d 5673 UpdateSingleGCComponentPageStatusColorArea(DETECTOR);
jmitc91516 0:47c880c1463d 5674 }
jmitc91516 3:010aeeacd7d7 5675 #endif
jmitc91516 3:010aeeacd7d7 5676
jmitc91516 3:010aeeacd7d7 5677 #ifndef WANT_DETECTOR_STATUS_RECTANGLE
jmitc91516 0:47c880c1463d 5678 // Makes the display flicker - but omitting it means old text is not cleared from the display
jmitc91516 3:010aeeacd7d7 5679 #define WANT_GUILIB_CLEAR
jmitc91516 3:010aeeacd7d7 5680 #endif
jmitc91516 3:010aeeacd7d7 5681
jmitc91516 1:a5258871b33d 5682 #ifdef WANT_GUILIB_CLEAR
jmitc91516 1:a5258871b33d 5683 #ifdef USING_BACKGROUND_BITMAP
jmitc91516 1:a5258871b33d 5684 DrawBackgroundBitmap(); // We want the status rectangles to be 'on top' of this -
jmitc91516 1:a5258871b33d 5685 // if we include it in the easyGUI page itself, it gets drawn by GuiLib_ShowScreen,
jmitc91516 1:a5258871b33d 5686 // and overwrites the rectangles
jmitc91516 1:a5258871b33d 5687 #else
jmitc91516 0:47c880c1463d 5688 GuiLib_Clear();
jmitc91516 1:a5258871b33d 5689 #endif
jmitc91516 1:a5258871b33d 5690 #undef WANT_GUILIB_CLEAR
jmitc91516 1:a5258871b33d 5691 #endif
jmitc91516 1:a5258871b33d 5692 //...except that redrawing the status rectangle effectively clears the text on top of the rectangle -
jmitc91516 1:a5258871b33d 5693 // so we do not need GuiLib_Clear here, since all the detector page data appears on top of the rectangle.
jmitc91516 1:a5258871b33d 5694 // Without it, only the text flickers, not the rectangle
jmitc91516 0:47c880c1463d 5695
jmitc91516 3:010aeeacd7d7 5696 #ifdef WANT_DETECTOR_STATUS_RECTANGLE
jmitc91516 0:47c880c1463d 5697 // Note - we draw the status rectangle after GuiLib_Clear - otherwise we wouldn't see the rectangles at all -
jmitc91516 0:47c880c1463d 5698 // and before GuiLib_ShowScreen - so text, etc, is drawn on top of the rectangles
jmitc91516 0:47c880c1463d 5699 if(singleGCComponentPageStatusColorAreas != NULL) {
jmitc91516 0:47c880c1463d 5700 singleGCComponentPageStatusColorAreas->DisplayGCComponentStatus(DETECTOR);
jmitc91516 1:a5258871b33d 5701
jmitc91516 1:a5258871b33d 5702 lastDetectorStatusDisplayedOnDetectorPage = singleGCComponentPageStatusColorAreas->GetGCComponentStatus(DETECTOR);
jmitc91516 1:a5258871b33d 5703 }
jmitc91516 3:010aeeacd7d7 5704 #endif
jmitc91516 1:a5258871b33d 5705
jmitc91516 1:a5258871b33d 5706 // And (currently) we draw the component bitmap on top of the rectangle
jmitc91516 1:a5258871b33d 5707 if(qspiBitmaps != NULL) {
jmitc91516 1:a5258871b33d 5708 qspiBitmaps->DisplayDetectorComponentBitmap();
jmitc91516 1:a5258871b33d 5709 }
jmitc91516 1:a5258871b33d 5710
jmitc91516 1:a5258871b33d 5711 GuiLib_ShowScreen(pageNumber, GuiLib_NO_CURSOR, GuiLib_RESET_AUTO_REDRAW);
jmitc91516 0:47c880c1463d 5712
jmitc91516 0:47c880c1463d 5713 GuiLib_Refresh();
jmitc91516 0:47c880c1463d 5714
jmitc91516 0:47c880c1463d 5715 #define DEBUG_HERE
jmitc91516 0:47c880c1463d 5716 #ifdef DEBUG_HERE
jmitc91516 0:47c880c1463d 5717 char dbg[100];
jmitc91516 0:47c880c1463d 5718 sprintf(dbg, "After GuiLib_Clear 4");
jmitc91516 1:a5258871b33d 5719 EasyGUIDebugPrint(dbg, 0, 20);
jmitc91516 0:47c880c1463d 5720 #undef DEBUG_HERE
jmitc91516 0:47c880c1463d 5721 #endif
jmitc91516 0:47c880c1463d 5722 }
jmitc91516 0:47c880c1463d 5723 }
jmitc91516 0:47c880c1463d 5724
jmitc91516 1:a5258871b33d 5725 /*
jmitc91516 1:a5258871b33d 5726 Gets the gas control mode, and returns it as a null-terminated string, with a descriptive prefix.
jmitc91516 1:a5258871b33d 5727
jmitc91516 1:a5258871b33d 5728 Note also that this code is intended to be as efficient as possible.
jmitc91516 1:a5258871b33d 5729
jmitc91516 1:a5258871b33d 5730 Args: pointer to a buffer to contain the mode, as a null-terminated string
jmitc91516 1:a5258871b33d 5731 boolean set true if the caller wants a full prefix ("Gas control mode: "),
jmitc91516 1:a5258871b33d 5732 or false for a short prefix ("Control mode: ")
jmitc91516 1:a5258871b33d 5733 boolean set true if the caller wants a prefix, false for no prefix whatsoever
jmitc91516 1:a5258871b33d 5734
jmitc91516 1:a5258871b33d 5735 Returns true if the mode was obtained successfully, false if there was an error.
jmitc91516 1:a5258871b33d 5736 */
jmitc91516 1:a5258871b33d 5737 bool GetGCStatusLoop::GetGasControlMode(char *mode, bool wantFullPrefix, bool wantAnyPrefix)
jmitc91516 0:47c880c1463d 5738 {
jmitc91516 0:47c880c1463d 5739 bool retval = true; // Return false only if we get "EPKT" from the GC
jmitc91516 0:47c880c1463d 5740
jmitc91516 0:47c880c1463d 5741 char response[50];
jmitc91516 1:a5258871b33d 5742 // SetGCDeviceReport("QGAS", response);
jmitc91516 1:a5258871b33d 5743 // // We expect a response like this: "DGAS0000" for Manual, "DGAS0001" for EPPC, or "EPKT" for error
jmitc91516 1:a5258871b33d 5744 // Above command has been removed - now use:
jmitc91516 1:a5258871b33d 5745 SetGCDeviceReport("GGTY", response);
jmitc91516 1:a5258871b33d 5746 // We expect a response like this: "DGTY0000" for Manual, "DGTY0001" for EPPC, or "EPKT" for error
jmitc91516 1:a5258871b33d 5747
jmitc91516 0:47c880c1463d 5748 int index = 0;
jmitc91516 1:a5258871b33d 5749 if(wantAnyPrefix) {
jmitc91516 1:a5258871b33d 5750 if(wantFullPrefix) {
jmitc91516 1:a5258871b33d 5751 mode[index++] = 'G';
jmitc91516 1:a5258871b33d 5752 mode[index++] = 'a';
jmitc91516 1:a5258871b33d 5753 mode[index++] = 's';
jmitc91516 1:a5258871b33d 5754 mode[index++] = ' ';
jmitc91516 1:a5258871b33d 5755 mode[index++] = 'c';
jmitc91516 1:a5258871b33d 5756 } else {
jmitc91516 1:a5258871b33d 5757 mode[index++] = 'C';
jmitc91516 1:a5258871b33d 5758 }
jmitc91516 1:a5258871b33d 5759
jmitc91516 1:a5258871b33d 5760 mode[index++] = 'o';
jmitc91516 1:a5258871b33d 5761 mode[index++] = 'n';
jmitc91516 1:a5258871b33d 5762 mode[index++] = 't';
jmitc91516 1:a5258871b33d 5763 mode[index++] = 'r';
jmitc91516 1:a5258871b33d 5764 mode[index++] = 'o';
jmitc91516 1:a5258871b33d 5765 mode[index++] = 'l';
jmitc91516 1:a5258871b33d 5766 mode[index++] = ' ';
jmitc91516 1:a5258871b33d 5767 mode[index++] = 'm';
jmitc91516 1:a5258871b33d 5768 mode[index++] = 'o';
jmitc91516 1:a5258871b33d 5769 mode[index++] = 'd';
jmitc91516 1:a5258871b33d 5770 mode[index++] = 'e';
jmitc91516 1:a5258871b33d 5771 mode[index++] = ':';
jmitc91516 1:a5258871b33d 5772 mode[index++] = ' ';
jmitc91516 1:a5258871b33d 5773 }
jmitc91516 1:a5258871b33d 5774
jmitc91516 0:47c880c1463d 5775 if(response[0] == 'E') {
jmitc91516 0:47c880c1463d 5776 mode[index++] = '*';
jmitc91516 0:47c880c1463d 5777 mode[index++] = '*';
jmitc91516 0:47c880c1463d 5778 mode[index++] = ' ';
jmitc91516 0:47c880c1463d 5779 mode[index++] = 'E';
jmitc91516 0:47c880c1463d 5780 mode[index++] = 'r';
jmitc91516 0:47c880c1463d 5781 mode[index++] = 'r';
jmitc91516 0:47c880c1463d 5782 mode[index++] = 'o';
jmitc91516 0:47c880c1463d 5783 mode[index++] = 'r';
jmitc91516 0:47c880c1463d 5784 mode[index++] = ' ';
jmitc91516 0:47c880c1463d 5785 mode[index++] = '*';
jmitc91516 0:47c880c1463d 5786 mode[index++] = '*';
jmitc91516 0:47c880c1463d 5787 mode[index++] = '\0';
jmitc91516 0:47c880c1463d 5788
jmitc91516 0:47c880c1463d 5789 retval = false;
jmitc91516 0:47c880c1463d 5790 } else {
jmitc91516 0:47c880c1463d 5791 if(response[7] == '0') {
jmitc91516 0:47c880c1463d 5792 mode[index++] = 'M';
jmitc91516 0:47c880c1463d 5793 mode[index++] = 'a';
jmitc91516 0:47c880c1463d 5794 mode[index++] = 'n';
jmitc91516 0:47c880c1463d 5795 mode[index++] = 'u';
jmitc91516 0:47c880c1463d 5796 mode[index++] = 'a';
jmitc91516 0:47c880c1463d 5797 mode[index++] = 'l';
jmitc91516 0:47c880c1463d 5798 mode[index++] = '\0';
jmitc91516 0:47c880c1463d 5799 } else {
jmitc91516 0:47c880c1463d 5800 mode[index++] = 'E';
jmitc91516 0:47c880c1463d 5801 mode[index++] = 'P';
jmitc91516 0:47c880c1463d 5802 mode[index++] = 'P';
jmitc91516 0:47c880c1463d 5803 mode[index++] = 'C';
jmitc91516 0:47c880c1463d 5804 mode[index++] = '\0';
jmitc91516 0:47c880c1463d 5805 }
jmitc91516 0:47c880c1463d 5806 }
jmitc91516 0:47c880c1463d 5807
jmitc91516 0:47c880c1463d 5808 return retval;
jmitc91516 0:47c880c1463d 5809 }
jmitc91516 0:47c880c1463d 5810
jmitc91516 1:a5258871b33d 5811 /*
jmitc91516 1:a5258871b33d 5812 Gets the carrier gas type, and returns it as a null-terminated string, with a descriptive prefix.
jmitc91516 1:a5258871b33d 5813
jmitc91516 1:a5258871b33d 5814 Note also that this code is intended to be as efficient as possible.
jmitc91516 1:a5258871b33d 5815
jmitc91516 1:a5258871b33d 5816 Args: pointer to the buffer to contain the carrier gas type, as a null-terminated string
jmitc91516 1:a5258871b33d 5817
jmitc91516 1:a5258871b33d 5818 No return code.
jmitc91516 1:a5258871b33d 5819 */
jmitc91516 1:a5258871b33d 5820 void GetGCStatusLoop::GetCarrierGasType(char *type)
jmitc91516 1:a5258871b33d 5821 {
jmitc91516 1:a5258871b33d 5822 char response[50];
jmitc91516 1:a5258871b33d 5823 SetGCDeviceReport("GCGS", response);
jmitc91516 1:a5258871b33d 5824 // We expect a response like this: "DCGS000n", where 'n' = 0 for nitrogen, 1 for helium, and 2 for hydrogen,
jmitc91516 1:a5258871b33d 5825 // or "EPKT" for error
jmitc91516 1:a5258871b33d 5826
jmitc91516 1:a5258871b33d 5827 int index = 0;
jmitc91516 1:a5258871b33d 5828 if(response[0] == 'E') {
jmitc91516 1:a5258871b33d 5829 type[index++] = '*';
jmitc91516 1:a5258871b33d 5830 type[index++] = '*';
jmitc91516 1:a5258871b33d 5831 type[index++] = ' ';
jmitc91516 1:a5258871b33d 5832 type[index++] = 'E';
jmitc91516 1:a5258871b33d 5833 type[index++] = 'r';
jmitc91516 1:a5258871b33d 5834 type[index++] = 'r';
jmitc91516 1:a5258871b33d 5835 type[index++] = 'o';
jmitc91516 1:a5258871b33d 5836 type[index++] = 'r';
jmitc91516 1:a5258871b33d 5837 type[index++] = ' ';
jmitc91516 1:a5258871b33d 5838 type[index++] = '*';
jmitc91516 1:a5258871b33d 5839 type[index++] = '*';
jmitc91516 1:a5258871b33d 5840 } else {
jmitc91516 1:a5258871b33d 5841 switch(response[7]) {
jmitc91516 1:a5258871b33d 5842 case '1':
jmitc91516 1:a5258871b33d 5843 type[index++] = 'H';
jmitc91516 1:a5258871b33d 5844 type[index++] = 'e';
jmitc91516 1:a5258871b33d 5845 type[index++] = 'l';
jmitc91516 1:a5258871b33d 5846 type[index++] = 'i';
jmitc91516 1:a5258871b33d 5847 type[index++] = 'u';
jmitc91516 1:a5258871b33d 5848 type[index++] = 'm';
jmitc91516 1:a5258871b33d 5849 break;
jmitc91516 1:a5258871b33d 5850 case '2':
jmitc91516 1:a5258871b33d 5851 type[index++] = 'H';
jmitc91516 1:a5258871b33d 5852 type[index++] = 'y';
jmitc91516 1:a5258871b33d 5853 type[index++] = 'd';
jmitc91516 1:a5258871b33d 5854 type[index++] = 'r';
jmitc91516 1:a5258871b33d 5855 type[index++] = 'o';
jmitc91516 1:a5258871b33d 5856 type[index++] = 'g';
jmitc91516 1:a5258871b33d 5857 type[index++] = 'e';
jmitc91516 1:a5258871b33d 5858 type[index++] = 'n';
jmitc91516 1:a5258871b33d 5859 break;
jmitc91516 1:a5258871b33d 5860 default:
jmitc91516 1:a5258871b33d 5861 type[index++] = 'N';
jmitc91516 1:a5258871b33d 5862 type[index++] = 'i';
jmitc91516 1:a5258871b33d 5863 type[index++] = 't';
jmitc91516 1:a5258871b33d 5864 type[index++] = 'r';
jmitc91516 1:a5258871b33d 5865 type[index++] = 'o';
jmitc91516 1:a5258871b33d 5866 type[index++] = 'g';
jmitc91516 1:a5258871b33d 5867 type[index++] = 'e';
jmitc91516 1:a5258871b33d 5868 type[index++] = 'n';
jmitc91516 1:a5258871b33d 5869 break;
jmitc91516 1:a5258871b33d 5870 }
jmitc91516 1:a5258871b33d 5871 }
jmitc91516 1:a5258871b33d 5872
jmitc91516 1:a5258871b33d 5873 type[index++] = '\0';
jmitc91516 1:a5258871b33d 5874 }
jmitc91516 1:a5258871b33d 5875
jmitc91516 1:a5258871b33d 5876 /*
jmitc91516 1:a5258871b33d 5877 Gets the date the filter was last changed, and returns it as a null-terminated string, with a descriptive prefix.
jmitc91516 1:a5258871b33d 5878
jmitc91516 1:a5258871b33d 5879 Note also that this code is intended to be as efficient as possible.
jmitc91516 1:a5258871b33d 5880
jmitc91516 1:a5258871b33d 5881 Args: pointer to the buffer to contain the date the filter was changed, as a null-terminated string
jmitc91516 1:a5258871b33d 5882
jmitc91516 1:a5258871b33d 5883 No return code.
jmitc91516 1:a5258871b33d 5884
jmitc91516 1:a5258871b33d 5885 ** This function is currently a placeholder until we work out how to implement this facility **
jmitc91516 1:a5258871b33d 5886 */
jmitc91516 1:a5258871b33d 5887 void GetGCStatusLoop::GetGasFilterDateChanged(char *date)
jmitc91516 1:a5258871b33d 5888 {
jmitc91516 1:a5258871b33d 5889 // TODO: Fill in, i.e. get the date from the GC somehow
jmitc91516 1:a5258871b33d 5890 int index = 0;
jmitc91516 1:a5258871b33d 5891 date[index++] = '0';
jmitc91516 1:a5258871b33d 5892 date[index++] = '1';
jmitc91516 1:a5258871b33d 5893 date[index++] = '/';
jmitc91516 1:a5258871b33d 5894 date[index++] = '0';
jmitc91516 1:a5258871b33d 5895 date[index++] = '1';
jmitc91516 1:a5258871b33d 5896 date[index++] = '/';
jmitc91516 1:a5258871b33d 5897 date[index++] = '2';
jmitc91516 1:a5258871b33d 5898 date[index++] = '0';
jmitc91516 1:a5258871b33d 5899 date[index++] = '1';
jmitc91516 1:a5258871b33d 5900 date[index++] = '6';
jmitc91516 1:a5258871b33d 5901 date[index] = '\0';
jmitc91516 1:a5258871b33d 5902 }
jmitc91516 1:a5258871b33d 5903
jmitc91516 1:a5258871b33d 5904
jmitc91516 1:a5258871b33d 5905 /*
jmitc91516 1:a5258871b33d 5906 Displays the data on the gas page, by copying it to the relevant easyGUI variables,
jmitc91516 1:a5258871b33d 5907 and calling the relevant functions to actually display it.
jmitc91516 1:a5258871b33d 5908
jmitc91516 1:a5258871b33d 5909 Args: a boolean specifying whether or not the display is actually to be updated.
jmitc91516 1:a5258871b33d 5910 Even if it is false when we are called, we may set it true if we discover
jmitc91516 1:a5258871b33d 5911 one or more data items has changed - but note that we will not set it false
jmitc91516 1:a5258871b33d 5912 if it is already true. If it is true after we have looked at all
jmitc91516 1:a5258871b33d 5913 the home page data, we will then update the display. (If we are called
jmitc91516 1:a5258871b33d 5914 with this value set to false, the caller is effectively saying
jmitc91516 1:a5258871b33d 5915 'display the gas page data only if it has changed').
jmitc91516 1:a5258871b33d 5916
jmitc91516 1:a5258871b33d 5917 No return code.
jmitc91516 1:a5258871b33d 5918 */
jmitc91516 1:a5258871b33d 5919 void GetGCStatusLoop::DisplayGasInformationPageData(bool mustUpdateDisplay)
jmitc91516 0:47c880c1463d 5920 {
jmitc91516 0:47c880c1463d 5921 //EasyGUIDebugPrint("Gas Page", 100, 100);
jmitc91516 0:47c880c1463d 5922 // Gas pressure and control mode
jmitc91516 0:47c880c1463d 5923 char buff[60];
jmitc91516 0:47c880c1463d 5924
jmitc91516 1:a5258871b33d 5925 GetGasPressure(buff, false, true);
jmitc91516 0:47c880c1463d 5926 if(strcmp(buff, GuiVar_gasPressure) != 0) {
jmitc91516 0:47c880c1463d 5927 strcpy(GuiVar_gasPressure, buff);
jmitc91516 1:a5258871b33d 5928
jmitc91516 1:a5258871b33d 5929 //mustUpdateDisplay = true;
jmitc91516 1:a5258871b33d 5930 // No - just do this (don't force entire rectangle to redisplay)
jmitc91516 1:a5258871b33d 5931 // Hard coded values taken from easyGUI
jmitc91516 1:a5258871b33d 5932 RedrawSingleEasyGUIVariableOnComponentPage(430, 90, &GuiVar_gasPressure, GuiLib_ALIGN_LEFT, GAS);
jmitc91516 1:a5258871b33d 5933 }
jmitc91516 1:a5258871b33d 5934
jmitc91516 1:a5258871b33d 5935 GetGasPulsedPressure(buff);
jmitc91516 1:a5258871b33d 5936 if(strcmp(buff, GuiVar_gasPulsedPressure) != 0) {
jmitc91516 1:a5258871b33d 5937 strcpy(GuiVar_gasPulsedPressure, buff);
jmitc91516 1:a5258871b33d 5938
jmitc91516 1:a5258871b33d 5939 //mustUpdateDisplay = true;
jmitc91516 1:a5258871b33d 5940 // No - just do this (don't force entire rectangle to redisplay)
jmitc91516 1:a5258871b33d 5941 // Hard coded values taken from easyGUI
jmitc91516 1:a5258871b33d 5942 RedrawSingleEasyGUIVariableOnComponentPage(430, 130, &GuiVar_gasPulsedPressure, GuiLib_ALIGN_LEFT, GAS);
jmitc91516 1:a5258871b33d 5943 }
jmitc91516 1:a5258871b33d 5944
jmitc91516 1:a5258871b33d 5945 GetGasControlMode(buff, true, false);
jmitc91516 0:47c880c1463d 5946 if(strcmp(buff, GuiVar_gasControlMode2) != 0) {
jmitc91516 1:a5258871b33d 5947 strcpy(GuiVar_gasControlMode2, buff);
jmitc91516 1:a5258871b33d 5948
jmitc91516 1:a5258871b33d 5949 //mustUpdateDisplay = true;
jmitc91516 1:a5258871b33d 5950 // No - just do this (don't force entire rectangle to redisplay)
jmitc91516 1:a5258871b33d 5951 // Hard coded values taken from easyGUI
jmitc91516 1:a5258871b33d 5952 RedrawSingleEasyGUIVariableOnComponentPage(430, 170, &GuiVar_gasControlMode2, GuiLib_ALIGN_LEFT, GAS);
jmitc91516 1:a5258871b33d 5953 }
jmitc91516 1:a5258871b33d 5954
jmitc91516 1:a5258871b33d 5955 GetCarrierGasType(buff);
jmitc91516 1:a5258871b33d 5956 if(strcmp(buff, GuiVar_gasCarrierType) != 0) {
jmitc91516 1:a5258871b33d 5957 strcpy(GuiVar_gasCarrierType, buff);
jmitc91516 1:a5258871b33d 5958
jmitc91516 1:a5258871b33d 5959 //mustUpdateDisplay = true;
jmitc91516 1:a5258871b33d 5960 // No - just do this (don't force entire rectangle to redisplay)
jmitc91516 1:a5258871b33d 5961 // Hard coded values taken from easyGUI
jmitc91516 1:a5258871b33d 5962 RedrawSingleEasyGUIVariableOnComponentPage(430, 210, &GuiVar_gasCarrierType, GuiLib_ALIGN_LEFT, GAS);
jmitc91516 1:a5258871b33d 5963 }
jmitc91516 1:a5258871b33d 5964
jmitc91516 1:a5258871b33d 5965 GetGasFilterDateChanged(buff);
jmitc91516 1:a5258871b33d 5966 if(strcmp(buff, GuiVar_gasFilterDateChanged) != 0) {
jmitc91516 1:a5258871b33d 5967 strcpy(GuiVar_gasFilterDateChanged, buff);
jmitc91516 1:a5258871b33d 5968
jmitc91516 1:a5258871b33d 5969 //mustUpdateDisplay = true;
jmitc91516 1:a5258871b33d 5970 // No - just do this (don't force entire rectangle to redisplay)
jmitc91516 1:a5258871b33d 5971 // Hard coded values taken from easyGUI
jmitc91516 1:a5258871b33d 5972 RedrawSingleEasyGUIVariableOnComponentPage(430, 270, &GuiVar_gasFilterDateChanged, GuiLib_ALIGN_LEFT, GAS);
jmitc91516 1:a5258871b33d 5973 }
jmitc91516 1:a5258871b33d 5974
jmitc91516 1:a5258871b33d 5975 if(SinglePageGCComponentStatusHasChanged(GAS, lastGasStatusDisplayedOnGasInformationPage)) {
jmitc91516 0:47c880c1463d 5976 mustUpdateDisplay = true;
jmitc91516 1:a5258871b33d 5977 }
jmitc91516 1:a5258871b33d 5978
jmitc91516 1:a5258871b33d 5979 if(mustUpdateDisplay) {
jmitc91516 1:a5258871b33d 5980
jmitc91516 3:010aeeacd7d7 5981 #ifdef WANT_GAS_STATUS_RECTANGLE
jmitc91516 1:a5258871b33d 5982 // Reduce display flickering - get the component status from the GC
jmitc91516 1:a5258871b33d 5983 // *before* we call GuiLib_Clear()
jmitc91516 1:a5258871b33d 5984 if(singleGCComponentPageStatusColorAreas != NULL) {
jmitc91516 1:a5258871b33d 5985 UpdateSingleGCComponentPageStatusColorArea(GAS);
jmitc91516 1:a5258871b33d 5986 }
jmitc91516 3:010aeeacd7d7 5987 #endif
jmitc91516 3:010aeeacd7d7 5988
jmitc91516 3:010aeeacd7d7 5989 #ifndef WANT_GAS_STATUS_RECTANGLE
jmitc91516 1:a5258871b33d 5990 // Makes the display flicker - but omitting it means old text is not cleared from the display
jmitc91516 3:010aeeacd7d7 5991 #define WANT_GUILIB_CLEAR
jmitc91516 3:010aeeacd7d7 5992 #endif
jmitc91516 3:010aeeacd7d7 5993
jmitc91516 1:a5258871b33d 5994 #ifdef WANT_GUILIB_CLEAR
jmitc91516 1:a5258871b33d 5995 #ifdef USING_BACKGROUND_BITMAP
jmitc91516 1:a5258871b33d 5996 DrawBackgroundBitmap(); // We want the status rectangles to be 'on top' of this -
jmitc91516 1:a5258871b33d 5997 // if we include it in the easyGUI page itself, it gets drawn by GuiLib_ShowScreen,
jmitc91516 1:a5258871b33d 5998 // and overwrites the rectangles
jmitc91516 1:a5258871b33d 5999 #else
jmitc91516 1:a5258871b33d 6000 GuiLib_Clear();
jmitc91516 1:a5258871b33d 6001 #endif
jmitc91516 1:a5258871b33d 6002 #undef WANT_GUILIB_CLEAR
jmitc91516 1:a5258871b33d 6003 #endif
jmitc91516 1:a5258871b33d 6004 //...except that redrawing the status rectangle effectively clears the text on top of the rectangle -
jmitc91516 1:a5258871b33d 6005 // so we do not need GuiLib_Clear here, since all the gas page data appears on top of the rectangle.
jmitc91516 1:a5258871b33d 6006 // Without it, only the text flickers, not the rectangle
jmitc91516 1:a5258871b33d 6007
jmitc91516 3:010aeeacd7d7 6008 #ifdef WANT_GAS_STATUS_RECTANGLE
jmitc91516 1:a5258871b33d 6009 // Note - we draw the status rectangle after GuiLib_Clear - otherwise we wouldn't see the rectangles at all -
jmitc91516 1:a5258871b33d 6010 // and before GuiLib_ShowScreen - so text, etc, is drawn on top of the rectangles
jmitc91516 1:a5258871b33d 6011 if(singleGCComponentPageStatusColorAreas != NULL) {
jmitc91516 1:a5258871b33d 6012 singleGCComponentPageStatusColorAreas->DisplayGCComponentStatus(GAS);
jmitc91516 1:a5258871b33d 6013
jmitc91516 1:a5258871b33d 6014 lastGasStatusDisplayedOnGasInformationPage = singleGCComponentPageStatusColorAreas->GetGCComponentStatus(GAS);
jmitc91516 1:a5258871b33d 6015 }
jmitc91516 3:010aeeacd7d7 6016 #endif
jmitc91516 1:a5258871b33d 6017
jmitc91516 1:a5258871b33d 6018 // And (currently) we draw the component bitmap on top of the rectangle
jmitc91516 1:a5258871b33d 6019 if(qspiBitmaps != NULL) {
jmitc91516 1:a5258871b33d 6020 qspiBitmaps->DisplayGasComponentBitmap();
jmitc91516 1:a5258871b33d 6021 }
jmitc91516 1:a5258871b33d 6022
jmitc91516 1:a5258871b33d 6023 GuiLib_ShowScreen(GuiStruct_GasInformationPage_6, GuiLib_NO_CURSOR, GuiLib_RESET_AUTO_REDRAW);
jmitc91516 1:a5258871b33d 6024
jmitc91516 1:a5258871b33d 6025 GuiLib_Refresh();
jmitc91516 1:a5258871b33d 6026
jmitc91516 1:a5258871b33d 6027 #define DEBUG_HERE
jmitc91516 1:a5258871b33d 6028 #ifdef DEBUG_HERE
jmitc91516 1:a5258871b33d 6029 char dbg[100];
jmitc91516 1:a5258871b33d 6030 sprintf(dbg, "After GuiLib_Clear 5");
jmitc91516 1:a5258871b33d 6031 EasyGUIDebugPrint(dbg, 0, 20);
jmitc91516 1:a5258871b33d 6032 #undef DEBUG_HERE
jmitc91516 1:a5258871b33d 6033 #endif
jmitc91516 1:a5258871b33d 6034 }
jmitc91516 1:a5258871b33d 6035 }
jmitc91516 1:a5258871b33d 6036
jmitc91516 6:dba3fbdfd5da 6037
jmitc91516 6:dba3fbdfd5da 6038 /*
jmitc91516 6:dba3fbdfd5da 6039 Public function, allowing an external caller to tell us
jmitc91516 6:dba3fbdfd5da 6040 to display, or not, the ramp scroll buttons on the Gas Method page.
jmitc91516 6:dba3fbdfd5da 6041
jmitc91516 6:dba3fbdfd5da 6042 Assume that the caller knows the Injector Method page *is*
jmitc91516 6:dba3fbdfd5da 6043 currently being displayed.
jmitc91516 6:dba3fbdfd5da 6044 */
jmitc91516 6:dba3fbdfd5da 6045 void GetGCStatusLoop::ShowGasMethodPageScrollButtonsIfNecessary(void)
jmitc91516 6:dba3fbdfd5da 6046 {
jmitc91516 6:dba3fbdfd5da 6047 ShowMethodPageScrollButtonsIfNecessary(gasMethodRampData);
jmitc91516 6:dba3fbdfd5da 6048 }
jmitc91516 6:dba3fbdfd5da 6049
jmitc91516 6:dba3fbdfd5da 6050 void GetGCStatusLoop::ScrollGasMethodRampsUpIfPossible(void)
jmitc91516 6:dba3fbdfd5da 6051 {
jmitc91516 6:dba3fbdfd5da 6052 if(currentPage == GuiStruct_GasMethodPage_Def) {
jmitc91516 6:dba3fbdfd5da 6053 if(gasMethodPageScrollIndex > 0) {
jmitc91516 6:dba3fbdfd5da 6054 --gasMethodPageScrollIndex;
jmitc91516 6:dba3fbdfd5da 6055
jmitc91516 6:dba3fbdfd5da 6056 DisplayGasMethodPageData(false);
jmitc91516 6:dba3fbdfd5da 6057 }
jmitc91516 6:dba3fbdfd5da 6058 }
jmitc91516 6:dba3fbdfd5da 6059 }
jmitc91516 6:dba3fbdfd5da 6060
jmitc91516 6:dba3fbdfd5da 6061 void GetGCStatusLoop::ScrollGasMethodRampsDownIfPossible(void)
jmitc91516 6:dba3fbdfd5da 6062 {
jmitc91516 6:dba3fbdfd5da 6063 if(currentPage == GuiStruct_GasMethodPage_Def) {
jmitc91516 6:dba3fbdfd5da 6064 if(gasMethodRampData != NULL) {
jmitc91516 6:dba3fbdfd5da 6065 if(gasMethodPageScrollIndex < gasMethodRampData->GetScrollRange()) {
jmitc91516 6:dba3fbdfd5da 6066 ++gasMethodPageScrollIndex;
jmitc91516 6:dba3fbdfd5da 6067
jmitc91516 6:dba3fbdfd5da 6068 DisplayGasMethodPageData(false);
jmitc91516 6:dba3fbdfd5da 6069 }
jmitc91516 6:dba3fbdfd5da 6070 }
jmitc91516 6:dba3fbdfd5da 6071 }
jmitc91516 6:dba3fbdfd5da 6072 }
jmitc91516 6:dba3fbdfd5da 6073
jmitc91516 6:dba3fbdfd5da 6074 /*
jmitc91516 6:dba3fbdfd5da 6075 Displays the data on the Gas Method page, by copying it to the relevant easyGUI variables,
jmitc91516 6:dba3fbdfd5da 6076 and calling the relevant functions to actually display it.
jmitc91516 6:dba3fbdfd5da 6077
jmitc91516 6:dba3fbdfd5da 6078 Args: a boolean specifying whether or not the display is actually to be updated.
jmitc91516 6:dba3fbdfd5da 6079 Even if it is false when we are called, we may set it true if we discover
jmitc91516 6:dba3fbdfd5da 6080 one or more data items has changed - but note that we will not set it false
jmitc91516 6:dba3fbdfd5da 6081 if it is already true. If it is true after we have looked at all
jmitc91516 6:dba3fbdfd5da 6082 the home page data, we will then update the display. (If we are called
jmitc91516 6:dba3fbdfd5da 6083 with this value set to false, the caller is effectively saying
jmitc91516 6:dba3fbdfd5da 6084 'display the column page data only if it has changed').
jmitc91516 6:dba3fbdfd5da 6085
jmitc91516 6:dba3fbdfd5da 6086 No return code.
jmitc91516 6:dba3fbdfd5da 6087 */
jmitc91516 6:dba3fbdfd5da 6088 void GetGCStatusLoop::DisplayGasMethodPageData(bool mustUpdateDisplay)
jmitc91516 6:dba3fbdfd5da 6089 {
jmitc91516 6:dba3fbdfd5da 6090 char buff[40];
jmitc91516 6:dba3fbdfd5da 6091
jmitc91516 6:dba3fbdfd5da 6092 GetGasPressure(buff, false, false);
jmitc91516 6:dba3fbdfd5da 6093 if(strcmp(buff, GuiVar_gasMethodInitialPressure) != 0) {
jmitc91516 6:dba3fbdfd5da 6094 strcpy(GuiVar_gasMethodInitialPressure, buff);
jmitc91516 6:dba3fbdfd5da 6095
jmitc91516 6:dba3fbdfd5da 6096 //mustUpdateDisplay = true;
jmitc91516 6:dba3fbdfd5da 6097 // No - just do this (don't force entire page to redisplay)
jmitc91516 6:dba3fbdfd5da 6098 // Hard coded values taken from easyGUI
jmitc91516 6:dba3fbdfd5da 6099 RedrawSingleEasyGUIVariableOnComponentPage(520, 85, &GuiVar_gasMethodInitialPressure, GuiLib_ALIGN_RIGHT, COLUMN);
jmitc91516 6:dba3fbdfd5da 6100 }
jmitc91516 6:dba3fbdfd5da 6101
jmitc91516 6:dba3fbdfd5da 6102 GetInitialHoldTime(buff);
jmitc91516 6:dba3fbdfd5da 6103 if(strcmp(buff, GuiVar_gasMethodInitialHold) != 0) {
jmitc91516 6:dba3fbdfd5da 6104 strcpy(GuiVar_gasMethodInitialHold, buff);
jmitc91516 6:dba3fbdfd5da 6105
jmitc91516 6:dba3fbdfd5da 6106 //mustUpdateDisplay = true;
jmitc91516 6:dba3fbdfd5da 6107 // No - just do this (don't force entire page to redisplay)
jmitc91516 6:dba3fbdfd5da 6108 // Hard coded values taken from easyGUI
jmitc91516 6:dba3fbdfd5da 6109 RedrawSingleEasyGUIVariableOnComponentPage(520, 120, &GuiVar_gasMethodInitialHold, GuiLib_ALIGN_RIGHT, COLUMN);
jmitc91516 6:dba3fbdfd5da 6110 }
jmitc91516 6:dba3fbdfd5da 6111
jmitc91516 6:dba3fbdfd5da 6112 if(gasMethodRampData == NULL) {
jmitc91516 6:dba3fbdfd5da 6113 gasMethodRampData = new GasMethodRampData(usbDevice, usbHostGC);
jmitc91516 6:dba3fbdfd5da 6114 }
jmitc91516 6:dba3fbdfd5da 6115
jmitc91516 6:dba3fbdfd5da 6116 if(gasMethodRampData != NULL) {
jmitc91516 6:dba3fbdfd5da 6117 if(!gasMethodRampData->GotRampData()) {
jmitc91516 6:dba3fbdfd5da 6118 gasMethodRampData->GetRampDataFromGC();
jmitc91516 6:dba3fbdfd5da 6119 }
jmitc91516 6:dba3fbdfd5da 6120
jmitc91516 6:dba3fbdfd5da 6121 sprintf(buff, "%u", gasMethodRampData->GetRampCount());
jmitc91516 6:dba3fbdfd5da 6122 if(strcmp(buff, GuiVar_gasMethodRampCount) != 0) {
jmitc91516 6:dba3fbdfd5da 6123 strcpy(GuiVar_gasMethodRampCount, buff);
jmitc91516 6:dba3fbdfd5da 6124
jmitc91516 6:dba3fbdfd5da 6125 //mustUpdateDisplay = true;
jmitc91516 6:dba3fbdfd5da 6126 // No - just do this (don't force entire page to redisplay)
jmitc91516 6:dba3fbdfd5da 6127 // Hard coded values taken from easyGUI
jmitc91516 6:dba3fbdfd5da 6128 RedrawSingleEasyGUIVariableOnComponentPage(520, 155, &GuiVar_gasMethodRampCount, GuiLib_ALIGN_RIGHT, COLUMN);
jmitc91516 6:dba3fbdfd5da 6129 }
jmitc91516 6:dba3fbdfd5da 6130
jmitc91516 6:dba3fbdfd5da 6131 if(gasMethodRampData->NeedToUpdateEasyGUIMethodPageRampVariables()) {
jmitc91516 6:dba3fbdfd5da 6132
jmitc91516 6:dba3fbdfd5da 6133 gasMethodPageScrollIndex = 0;
jmitc91516 6:dba3fbdfd5da 6134
jmitc91516 6:dba3fbdfd5da 6135 gasMethodRampData->UpdateEasyGUIMethodPageVariables(gasMethodPageScrollIndex);
jmitc91516 6:dba3fbdfd5da 6136
jmitc91516 6:dba3fbdfd5da 6137 previousGasMethodPageScrollIndex = gasMethodPageScrollIndex;
jmitc91516 6:dba3fbdfd5da 6138
jmitc91516 6:dba3fbdfd5da 6139 mustUpdateDisplay = true; // Not practical to write all these variables individually
jmitc91516 6:dba3fbdfd5da 6140
jmitc91516 6:dba3fbdfd5da 6141 } else if (previousGasMethodPageScrollIndex != gasMethodPageScrollIndex) {
jmitc91516 6:dba3fbdfd5da 6142
jmitc91516 6:dba3fbdfd5da 6143 gasMethodRampData->UpdateEasyGUIMethodPageVariables(gasMethodPageScrollIndex);
jmitc91516 6:dba3fbdfd5da 6144
jmitc91516 6:dba3fbdfd5da 6145 previousGasMethodPageScrollIndex = gasMethodPageScrollIndex;
jmitc91516 6:dba3fbdfd5da 6146
jmitc91516 6:dba3fbdfd5da 6147 mustUpdateDisplay = true; // Not practical to write all these variables individually
jmitc91516 6:dba3fbdfd5da 6148 }
jmitc91516 6:dba3fbdfd5da 6149 }
jmitc91516 6:dba3fbdfd5da 6150
jmitc91516 6:dba3fbdfd5da 6151 if(SinglePageGCComponentStatusHasChanged(GAS)) {
jmitc91516 6:dba3fbdfd5da 6152 mustUpdateDisplay = true;
jmitc91516 6:dba3fbdfd5da 6153 }
jmitc91516 6:dba3fbdfd5da 6154
jmitc91516 6:dba3fbdfd5da 6155 if(mustUpdateDisplay) {
jmitc91516 6:dba3fbdfd5da 6156
jmitc91516 6:dba3fbdfd5da 6157 #ifdef WANT_INJECTOR_STATUS_RECTANGLE
jmitc91516 6:dba3fbdfd5da 6158 // Reduce display flickering - get the component status from the GC
jmitc91516 6:dba3fbdfd5da 6159 // *before* we call GuiLib_Clear()
jmitc91516 6:dba3fbdfd5da 6160 if(singleGCComponentPageStatusColorAreas != NULL) {
jmitc91516 6:dba3fbdfd5da 6161 UpdateSingleGCComponentPageStatusColorArea(GAS);
jmitc91516 6:dba3fbdfd5da 6162 }
jmitc91516 6:dba3fbdfd5da 6163 #endif
jmitc91516 6:dba3fbdfd5da 6164
jmitc91516 6:dba3fbdfd5da 6165 #ifndef WANT_INJECTOR_STATUS_RECTANGLE
jmitc91516 6:dba3fbdfd5da 6166 #define WANT_GUILIB_CLEAR
jmitc91516 6:dba3fbdfd5da 6167 #endif
jmitc91516 6:dba3fbdfd5da 6168
jmitc91516 6:dba3fbdfd5da 6169 #ifdef WANT_GUILIB_CLEAR
jmitc91516 6:dba3fbdfd5da 6170 #ifdef USING_BACKGROUND_BITMAP
jmitc91516 6:dba3fbdfd5da 6171 DrawBackgroundBitmap(); // We want the status rectangles to be 'on top' of this -
jmitc91516 6:dba3fbdfd5da 6172 // if we include it in the easyGUI page itself, it gets drawn by GuiLib_ShowScreen,
jmitc91516 6:dba3fbdfd5da 6173 // and overwrites the rectangles
jmitc91516 6:dba3fbdfd5da 6174 #else
jmitc91516 6:dba3fbdfd5da 6175 GuiLib_Clear();
jmitc91516 6:dba3fbdfd5da 6176 #endif
jmitc91516 6:dba3fbdfd5da 6177 #undef WANT_GUILIB_CLEAR
jmitc91516 6:dba3fbdfd5da 6178 #endif
jmitc91516 6:dba3fbdfd5da 6179 //...except that redrawing the status rectangle effectively clears the text on top of the rectangle -
jmitc91516 6:dba3fbdfd5da 6180 // so we do not need GuiLib_Clear here, since all the column page data appears on top of the rectangle.
jmitc91516 6:dba3fbdfd5da 6181 // Without it, only the text flickers, not the rectangle
jmitc91516 6:dba3fbdfd5da 6182
jmitc91516 6:dba3fbdfd5da 6183 #ifdef WANT_INJECTOR_STATUS_RECTANGLE
jmitc91516 6:dba3fbdfd5da 6184 // Note - we draw the status rectangle after GuiLib_Clear - otherwise we wouldn't see the rectangles at all -
jmitc91516 6:dba3fbdfd5da 6185 // and before GuiLib_ShowScreen - so text, etc, is drawn on top of the rectangles
jmitc91516 6:dba3fbdfd5da 6186 if(singleGCComponentPageStatusColorAreas != NULL) {
jmitc91516 6:dba3fbdfd5da 6187 singleGCComponentPageStatusColorAreas->DisplayGCComponentStatus(GAS);
jmitc91516 6:dba3fbdfd5da 6188 }
jmitc91516 6:dba3fbdfd5da 6189 #endif
jmitc91516 6:dba3fbdfd5da 6190
jmitc91516 6:dba3fbdfd5da 6191 // And (currently) we draw the component bitmap on top of the rectangle
jmitc91516 6:dba3fbdfd5da 6192 if(qspiBitmaps != NULL) {
jmitc91516 6:dba3fbdfd5da 6193 qspiBitmaps->DisplayGasComponentBitmap();
jmitc91516 6:dba3fbdfd5da 6194 }
jmitc91516 6:dba3fbdfd5da 6195
jmitc91516 6:dba3fbdfd5da 6196 GuiLib_ShowScreen(GuiStruct_GasMethodPage_Def, GuiLib_NO_CURSOR, GuiLib_RESET_AUTO_REDRAW);
jmitc91516 6:dba3fbdfd5da 6197
jmitc91516 7:f0e645cf73a2 6198 ShowMethodPageScrollButtonsIfNecessary(gasMethodRampData);
jmitc91516 6:dba3fbdfd5da 6199
jmitc91516 6:dba3fbdfd5da 6200 GuiLib_Refresh();
jmitc91516 6:dba3fbdfd5da 6201 }
jmitc91516 6:dba3fbdfd5da 6202 }
jmitc91516 6:dba3fbdfd5da 6203
jmitc91516 6:dba3fbdfd5da 6204
jmitc91516 1:a5258871b33d 6205 /*
jmitc91516 1:a5258871b33d 6206 Gas pressure profile X axis units may be minutes or seconds.
jmitc91516 1:a5258871b33d 6207 Set up the label easyGUI variable appropriately.
jmitc91516 1:a5258871b33d 6208 */
jmitc91516 1:a5258871b33d 6209 void GetGCStatusLoop::SetupGasFlowProfilePageXAxisLabel(TimeUnit timeUnit)
jmitc91516 1:a5258871b33d 6210 {
jmitc91516 1:a5258871b33d 6211 if(timeUnit == SECONDS) {
jmitc91516 1:a5258871b33d 6212 strcpy(GuiVar_gasFlowProfilePageXAxisLabel, "Time (seconds)");
jmitc91516 1:a5258871b33d 6213 } else {
jmitc91516 1:a5258871b33d 6214 strcpy(GuiVar_gasFlowProfilePageXAxisLabel, "Time (minutes)");
jmitc91516 1:a5258871b33d 6215 }
jmitc91516 1:a5258871b33d 6216 }
jmitc91516 1:a5258871b33d 6217
jmitc91516 1:a5258871b33d 6218 /*
jmitc91516 1:a5258871b33d 6219 Sets up the data for the graph on the Gas Flow Profile page,
jmitc91516 1:a5258871b33d 6220 and causes it to be displayed
jmitc91516 1:a5258871b33d 6221 */
jmitc91516 1:a5258871b33d 6222 void GetGCStatusLoop::DisplayGasFlowProfilePageGraph(void)
jmitc91516 1:a5258871b33d 6223 {
jmitc91516 1:a5258871b33d 6224 // Test values only:
jmitc91516 1:a5258871b33d 6225 // - dataset 0 is a line representing the flow profile of the run from 'now' to the finish
jmitc91516 1:a5258871b33d 6226 // - dataset 1 is a bar chart representing the flow profile of the run from 'now' to the finish
jmitc91516 1:a5258871b33d 6227 // - dataset 2 is a line representing the flow profile from the start to 'now'
jmitc91516 1:a5258871b33d 6228 // - dataset 3 is a bar chart representing the flow profile of the run from the start to 'now'
jmitc91516 1:a5258871b33d 6229 // - dataset 4 is a single dot at the current time and temperature
jmitc91516 1:a5258871b33d 6230
jmitc91516 1:a5258871b33d 6231 TimeUnit timeUnit = MINUTES;
jmitc91516 1:a5258871b33d 6232 if(gasFlowProfilePageGraphCompleteProfileDataSet->GetTotalMethodTime() < methodTimeUnitsThreshold) {
jmitc91516 1:a5258871b33d 6233 timeUnit = SECONDS;
jmitc91516 1:a5258871b33d 6234 }
jmitc91516 1:a5258871b33d 6235
jmitc91516 1:a5258871b33d 6236 const float yAxisScaleFactor = 10.0f;
jmitc91516 1:a5258871b33d 6237
jmitc91516 1:a5258871b33d 6238 // Dataset 0
jmitc91516 1:a5258871b33d 6239 gasFlowProfilePageGraph->SetDataForGraphDataSetInTenthsOfMinutes(0, yAxisScaleFactor, gasFlowProfilePageGraphDataSet0);
jmitc91516 1:a5258871b33d 6240
jmitc91516 1:a5258871b33d 6241 // Dataset 1
jmitc91516 1:a5258871b33d 6242 gasFlowProfilePageGraph->SetDataForGraphDataSetInTenthsOfMinutes(1, yAxisScaleFactor, gasFlowProfilePageGraphDataSet1);
jmitc91516 1:a5258871b33d 6243
jmitc91516 1:a5258871b33d 6244 // Dataset 2
jmitc91516 1:a5258871b33d 6245 gasFlowProfilePageGraph->SetDataForGraphDataSetInTenthsOfMinutes(2, yAxisScaleFactor, gasFlowProfilePageGraphDataSet2);
jmitc91516 1:a5258871b33d 6246
jmitc91516 1:a5258871b33d 6247 // Dataset 3
jmitc91516 1:a5258871b33d 6248 gasFlowProfilePageGraph->SetDataForGraphDataSetInTenthsOfMinutes(3, yAxisScaleFactor, gasFlowProfilePageGraphDataSet3);
jmitc91516 1:a5258871b33d 6249
jmitc91516 1:a5258871b33d 6250 // Dataset 4
jmitc91516 1:a5258871b33d 6251 gasFlowProfilePageGraph->SetDataForGraphDataSetInTenthsOfMinutes(4, yAxisScaleFactor, gasFlowProfilePageGraphDataSet4);
jmitc91516 1:a5258871b33d 6252
jmitc91516 1:a5258871b33d 6253 gasFlowProfilePageGraph->SetXAxisUnits(timeUnit);
jmitc91516 1:a5258871b33d 6254
jmitc91516 1:a5258871b33d 6255 if(timeUnit == SECONDS) {
jmitc91516 1:a5258871b33d 6256 strcpy(GuiVar_gasFlowProfilePageXAxisLabel, "Time (seconds)");
jmitc91516 1:a5258871b33d 6257 } else {
jmitc91516 1:a5258871b33d 6258 strcpy(GuiVar_gasFlowProfilePageXAxisLabel, "Time (minutes)");
jmitc91516 1:a5258871b33d 6259 }
jmitc91516 1:a5258871b33d 6260
jmitc91516 1:a5258871b33d 6261
jmitc91516 1:a5258871b33d 6262 if(gasFlowProfilePageGraphCompleteProfileDataSet->GetPointCount() == 0) {
jmitc91516 1:a5258871b33d 6263 strcpy(GuiVar_gasFlowProfilePageNoMethod, "No method set up");
jmitc91516 1:a5258871b33d 6264 } else {
jmitc91516 1:a5258871b33d 6265 GuiVar_gasFlowProfilePageNoMethod[0] = '\0';
jmitc91516 1:a5258871b33d 6266 }
jmitc91516 1:a5258871b33d 6267
jmitc91516 1:a5258871b33d 6268 // The tick sizes must match those set in easyGUI - we do not seem
jmitc91516 1:a5258871b33d 6269 // to be able to get them at runtime
jmitc91516 1:a5258871b33d 6270 GuiConst_INT32S minX, maxX;
jmitc91516 1:a5258871b33d 6271 //GuiConst_INT32S tickSize = (timeUnit == SECONDS) ? 300 : 100;
jmitc91516 1:a5258871b33d 6272 // Always in 1/10 minutes
jmitc91516 1:a5258871b33d 6273 GuiConst_INT32S xAxisTickSize = (timeUnit == SECONDS) ? 5 : 100; // 5 == 0.5 minutes (i.e. 30 seconds), 100 == 10 minutes
jmitc91516 1:a5258871b33d 6274 gasFlowProfilePageGraphCompleteProfileDataSet->GetXAxisRangeInTenthsOfMinutes(&minX, &maxX, xAxisTickSize);
jmitc91516 1:a5258871b33d 6275 gasFlowProfilePageGraph->SetXAxisRange(0, maxX); // Always start X axis at zero
jmitc91516 1:a5258871b33d 6276
jmitc91516 1:a5258871b33d 6277 GuiConst_INT32S minY, maxY;
jmitc91516 1:a5258871b33d 6278 GuiConst_INT32S yAxisTickSize = 10;
jmitc91516 1:a5258871b33d 6279 gasFlowProfilePageGraphCompleteProfileDataSet->GetYAxisRange(&minY, &maxY, yAxisTickSize);
jmitc91516 1:a5258871b33d 6280 gasFlowProfilePageGraph->SetYAxisRange(0, (maxY * yAxisScaleFactor)); // Always start Y axis at zero
jmitc91516 1:a5258871b33d 6281
jmitc91516 1:a5258871b33d 6282
jmitc91516 1:a5258871b33d 6283 gasFlowProfilePageGraph->DrawAxes();
jmitc91516 1:a5258871b33d 6284
jmitc91516 1:a5258871b33d 6285 // We need to draw the X axis labels ourselves, since our time values are in units of 0.1 minute,
jmitc91516 1:a5258871b33d 6286 // but easyGUI graphs work only in integers - we therefore have to multiply the time values by 10
jmitc91516 1:a5258871b33d 6287 // before passing them to easyGUI, and if we let easyGUI draw its own values on the X axis,
jmitc91516 1:a5258871b33d 6288 // they would be 10 times the correct values.
jmitc91516 1:a5258871b33d 6289 // Graph coordinates copied from easyGUI - I cannot find a way of obtaining them at runtime.
jmitc91516 1:a5258871b33d 6290 if(timeUnit == SECONDS) {
jmitc91516 1:a5258871b33d 6291 gasFlowProfilePageGraph->DrawXAxisLabels(0, (maxX * 6), (xAxisTickSize * 6), 150, 340, 500);
jmitc91516 1:a5258871b33d 6292 } else {
jmitc91516 1:a5258871b33d 6293 gasFlowProfilePageGraph->DrawXAxisLabels(0, (maxX / 10), (xAxisTickSize / 10), 150, 340, 500);
jmitc91516 1:a5258871b33d 6294 }
jmitc91516 1:a5258871b33d 6295 // Note that we repeat this call by calling 'DrawXAxisLabels' without arguments
jmitc91516 1:a5258871b33d 6296 // every time we (re)display this page
jmitc91516 1:a5258871b33d 6297
jmitc91516 1:a5258871b33d 6298 // Similar to the X axis - the values we pass to the easyGUI graph are scaled to be larger
jmitc91516 1:a5258871b33d 6299 // than the real values, to get round the fact that easyGUI graphs work in integers.
jmitc91516 1:a5258871b33d 6300 // (This can cause the profile to appear to be 'stepped', which obviously we do not want.)
jmitc91516 1:a5258871b33d 6301 // We must therefore draw the Y axis values ourselves.
jmitc91516 1:a5258871b33d 6302 gasFlowProfilePageGraph->DrawYAxisLabels(0, maxY, yAxisTickSize, 150, 340, 250);
jmitc91516 1:a5258871b33d 6303 // Note that we repeat this call by calling 'DrawYAxisLabels' without arguments
jmitc91516 1:a5258871b33d 6304 // every time we (re)display this page
jmitc91516 1:a5258871b33d 6305
jmitc91516 1:a5258871b33d 6306 gasFlowProfilePageGraph->DrawDataSet(0);
jmitc91516 1:a5258871b33d 6307 gasFlowProfilePageGraph->ShowDataSet(0);
jmitc91516 1:a5258871b33d 6308
jmitc91516 1:a5258871b33d 6309 gasFlowProfilePageGraph->DrawDataSet(1);
jmitc91516 1:a5258871b33d 6310 gasFlowProfilePageGraph->ShowDataSet(1);
jmitc91516 1:a5258871b33d 6311
jmitc91516 1:a5258871b33d 6312 gasFlowProfilePageGraph->DrawDataSet(2);
jmitc91516 1:a5258871b33d 6313 gasFlowProfilePageGraph->ShowDataSet(2);
jmitc91516 1:a5258871b33d 6314
jmitc91516 1:a5258871b33d 6315 gasFlowProfilePageGraph->DrawDataSet(3);
jmitc91516 1:a5258871b33d 6316 gasFlowProfilePageGraph->ShowDataSet(3);
jmitc91516 1:a5258871b33d 6317
jmitc91516 1:a5258871b33d 6318 gasFlowProfilePageGraph->DrawDataSet(4);
jmitc91516 1:a5258871b33d 6319 gasFlowProfilePageGraph->ShowDataSet(4);
jmitc91516 1:a5258871b33d 6320
jmitc91516 1:a5258871b33d 6321 gasFlowProfilePageGraph->Redraw();
jmitc91516 8:26e49e6955bd 6322
jmitc91516 8:26e49e6955bd 6323 #ifdef TEST_GUILIB_VLINE_PROFILES
jmitc91516 8:26e49e6955bd 6324 // *** TESTING *** Draw the profile as a solid colour, direct to the display
jmitc91516 8:26e49e6955bd 6325 // Coords manually copied from easyGUI application.
jmitc91516 8:26e49e6955bd 6326 // Boundary between colours is arbitrary for now
jmitc91516 8:26e49e6955bd 6327 GuiConst_INTCOLOR graphColour1 = SixteenBitColorValue(100, 100, 100);
jmitc91516 8:26e49e6955bd 6328 GuiConst_INTCOLOR graphColour2 = SixteenBitColorValue(200, 200, 200);
jmitc91516 8:26e49e6955bd 6329 // double colourBoundaryX = (double) gasFlowProfilePageGraphCompleteProfileDataSet->GetTotalMethodTime() / 5.0; // Should be one-fifth across the profile
jmitc91516 8:26e49e6955bd 6330 double colourBoundaryX = -1.0; // No - use one colour only
jmitc91516 8:26e49e6955bd 6331 if(timeUnit == SECONDS) {
jmitc91516 8:26e49e6955bd 6332 gasFlowProfilePageGraphCompleteProfileDataSet->DrawUsingGuiLibVLine(160, 330, ((double) 500 / (double) (maxX * 6)), ((double) -250 / (double) maxY), graphColour1, graphColour2, colourBoundaryX);
jmitc91516 8:26e49e6955bd 6333 } else {
jmitc91516 8:26e49e6955bd 6334 gasFlowProfilePageGraphCompleteProfileDataSet->DrawUsingGuiLibVLine(160, 330, ((double) 500 / (double) (maxX / 10)), ((double) -250 / (double) maxY), graphColour1, graphColour2, colourBoundaryX);
jmitc91516 8:26e49e6955bd 6335 }
jmitc91516 8:26e49e6955bd 6336 #endif // TEST_GUILIB_VLINE_PROFILES
jmitc91516 1:a5258871b33d 6337 }
jmitc91516 1:a5258871b33d 6338
jmitc91516 1:a5258871b33d 6339 void GetGCStatusLoop::DisplayGasFlowProfilePageData(bool mustUpdateDisplay)
jmitc91516 1:a5258871b33d 6340 {
jmitc91516 1:a5258871b33d 6341 // Ensure this is always up to date
jmitc91516 1:a5258871b33d 6342 if(needToUpdateProfileGraphs) {
jmitc91516 1:a5258871b33d 6343 SetupColumnAndInjectorAndGasProfileData();
jmitc91516 1:a5258871b33d 6344 mustUpdateDisplay = true;
jmitc91516 1:a5258871b33d 6345
jmitc91516 1:a5258871b33d 6346 needToUpdateProfileGraphs = false;
jmitc91516 1:a5258871b33d 6347 }
jmitc91516 1:a5258871b33d 6348
jmitc91516 1:a5258871b33d 6349 DisplayGasFlowProfilePageGraph();
jmitc91516 1:a5258871b33d 6350
jmitc91516 1:a5258871b33d 6351 if(SinglePageGCComponentStatusHasChanged(GAS)) {
jmitc91516 1:a5258871b33d 6352 mustUpdateDisplay = true;
jmitc91516 1:a5258871b33d 6353 }
jmitc91516 1:a5258871b33d 6354
jmitc91516 1:a5258871b33d 6355 if(mustUpdateDisplay) {
jmitc91516 1:a5258871b33d 6356
jmitc91516 3:010aeeacd7d7 6357 #ifdef WANT_GAS_STATUS_RECTANGLE
jmitc91516 1:a5258871b33d 6358 // Reduce display flickering - get the component status from the GC
jmitc91516 1:a5258871b33d 6359 // *before* we call GuiLib_Clear()
jmitc91516 1:a5258871b33d 6360 if(singleGCComponentPageStatusColorAreas != NULL) {
jmitc91516 1:a5258871b33d 6361 UpdateSingleGCComponentPageStatusColorArea(GAS);
jmitc91516 1:a5258871b33d 6362 }
jmitc91516 3:010aeeacd7d7 6363 #endif
jmitc91516 3:010aeeacd7d7 6364
jmitc91516 3:010aeeacd7d7 6365 #ifndef WANT_GAS_STATUS_RECTANGLE
jmitc91516 1:a5258871b33d 6366 // Makes the display flicker - but omitting it means old text is not cleared from the display
jmitc91516 3:010aeeacd7d7 6367 #define WANT_GUILIB_CLEAR
jmitc91516 3:010aeeacd7d7 6368 #endif
jmitc91516 3:010aeeacd7d7 6369
jmitc91516 1:a5258871b33d 6370 #ifdef WANT_GUILIB_CLEAR
jmitc91516 1:a5258871b33d 6371 #ifdef USING_BACKGROUND_BITMAP
jmitc91516 1:a5258871b33d 6372 DrawBackgroundBitmap(); // We want the status rectangles to be 'on top' of this -
jmitc91516 1:a5258871b33d 6373 // if we include it in the easyGUI page itself, it gets drawn by GuiLib_ShowScreen,
jmitc91516 1:a5258871b33d 6374 // and overwrites the rectangles
jmitc91516 1:a5258871b33d 6375 #else
jmitc91516 1:a5258871b33d 6376 GuiLib_Clear();
jmitc91516 1:a5258871b33d 6377 #endif
jmitc91516 1:a5258871b33d 6378 #undef WANT_GUILIB_CLEAR
jmitc91516 1:a5258871b33d 6379 #endif
jmitc91516 1:a5258871b33d 6380 //...except that redrawing the status rectangle effectively clears the text on top of the rectangle -
jmitc91516 1:a5258871b33d 6381 // so we do not need GuiLib_Clear here, since all the injector page data appears on top of the rectangle.
jmitc91516 1:a5258871b33d 6382 // Without it, only the text flickers, not the rectangle
jmitc91516 1:a5258871b33d 6383
jmitc91516 3:010aeeacd7d7 6384 #ifdef WANT_GAS_STATUS_RECTANGLE
jmitc91516 1:a5258871b33d 6385 // Note - we draw the status rectangle after GuiLib_Clear - otherwise we wouldn't see the rectangles at all -
jmitc91516 1:a5258871b33d 6386 // and before GuiLib_ShowScreen - so text, etc, is drawn on top of the rectangles
jmitc91516 1:a5258871b33d 6387 if(singleGCComponentPageStatusColorAreas != NULL) {
jmitc91516 1:a5258871b33d 6388 singleGCComponentPageStatusColorAreas->DisplayGCComponentStatus(GAS);
jmitc91516 1:a5258871b33d 6389 }
jmitc91516 3:010aeeacd7d7 6390 #endif
jmitc91516 1:a5258871b33d 6391
jmitc91516 7:f0e645cf73a2 6392 #ifdef WANT_COMPONENT_ICON_ON_PROFILE_PAGES
jmitc91516 1:a5258871b33d 6393 // And (currently) we draw the component bitmap on top of the rectangle
jmitc91516 1:a5258871b33d 6394 if(qspiBitmaps != NULL) {
jmitc91516 1:a5258871b33d 6395 qspiBitmaps->DisplayGasComponentBitmap();
jmitc91516 1:a5258871b33d 6396 }
jmitc91516 7:f0e645cf73a2 6397 #endif // WANT_COMPONENT_ICON_ON_PROFILE_PAGES
jmitc91516 1:a5258871b33d 6398
jmitc91516 1:a5258871b33d 6399 gasFlowProfilePageGraph->Redraw();
jmitc91516 1:a5258871b33d 6400
jmitc91516 8:26e49e6955bd 6401 #ifdef TEST_GUILIB_VLINE_PROFILES
jmitc91516 8:26e49e6955bd 6402 // Now draw the profile as a solid colour, direct to the display.
jmitc91516 8:26e49e6955bd 6403 // Use the same parameters as the previous call, in DisplayInjectorTempProfilePageGraph
jmitc91516 8:26e49e6955bd 6404 gasFlowProfilePageGraphCompleteProfileDataSet->DrawUsingGuiLibVLine();
jmitc91516 8:26e49e6955bd 6405 #endif // TEST_GUILIB_VLINE_PROFILES
jmitc91516 8:26e49e6955bd 6406
jmitc91516 1:a5258871b33d 6407 GuiLib_ShowScreen(GuiStruct_GasProfilePage_15, GuiLib_NO_CURSOR, GuiLib_RESET_AUTO_REDRAW);
jmitc91516 1:a5258871b33d 6408
jmitc91516 1:a5258871b33d 6409 // Repeat the previous call to the version of this function with parameters,
jmitc91516 1:a5258871b33d 6410 // made from 'DisplayGasFlowProfilePageGraph()' above (it is more convenient
jmitc91516 1:a5258871b33d 6411 // to calculate the parameter values in 'DisplayGasFlowProfilePageGraph()' than here)
jmitc91516 1:a5258871b33d 6412 gasFlowProfilePageGraph->DrawXAxisLabels();
jmitc91516 1:a5258871b33d 6413 gasFlowProfilePageGraph->DrawYAxisLabels();
jmitc91516 1:a5258871b33d 6414
jmitc91516 1:a5258871b33d 6415 GuiLib_Refresh();
jmitc91516 1:a5258871b33d 6416
jmitc91516 1:a5258871b33d 6417 #define DEBUG_HERE
jmitc91516 1:a5258871b33d 6418 #ifdef DEBUG_HERE
jmitc91516 1:a5258871b33d 6419 char dbg[100];
jmitc91516 1:a5258871b33d 6420 sprintf(dbg, "After GuiLib_Clear 99");
jmitc91516 1:a5258871b33d 6421 EasyGUIDebugPrint(dbg, 0, 20);
jmitc91516 1:a5258871b33d 6422 #undef DEBUG_HERE
jmitc91516 1:a5258871b33d 6423 #endif
jmitc91516 1:a5258871b33d 6424 }
jmitc91516 1:a5258871b33d 6425 }
jmitc91516 1:a5258871b33d 6426
jmitc91516 1:a5258871b33d 6427 /*
jmitc91516 1:a5258871b33d 6428 Displays the data on the gas calibration page, by copying it to the relevant easyGUI variables,
jmitc91516 1:a5258871b33d 6429 and calling the relevant functions to actually display it.
jmitc91516 1:a5258871b33d 6430
jmitc91516 1:a5258871b33d 6431 Args: a boolean specifying whether or not the display is actually to be updated.
jmitc91516 1:a5258871b33d 6432 Even if it is false when we are called, we may set it true if we discover
jmitc91516 1:a5258871b33d 6433 one or more data items has changed - but note that we will not set it false
jmitc91516 1:a5258871b33d 6434 if it is already true. If it is true after we have looked at all
jmitc91516 1:a5258871b33d 6435 the home page data, we will then update the display. (If we are called
jmitc91516 1:a5258871b33d 6436 with this value set to false, the caller is effectively saying
jmitc91516 1:a5258871b33d 6437 'display the gas page data only if it has changed').
jmitc91516 1:a5258871b33d 6438
jmitc91516 1:a5258871b33d 6439 No return code.
jmitc91516 1:a5258871b33d 6440 */
jmitc91516 1:a5258871b33d 6441 void GetGCStatusLoop::DisplayGasCalibrationPageData(bool mustUpdateDisplay)
jmitc91516 1:a5258871b33d 6442 {
jmitc91516 1:a5258871b33d 6443 //EasyGUIDebugPrint("Gas Calibration Page", 100, 100);
jmitc91516 1:a5258871b33d 6444 // Gas pressure and control mode
jmitc91516 1:a5258871b33d 6445
jmitc91516 1:a5258871b33d 6446 if(SinglePageGCComponentStatusHasChanged(GAS)) {
jmitc91516 1:a5258871b33d 6447 mustUpdateDisplay = true;
jmitc91516 1:a5258871b33d 6448 }
jmitc91516 1:a5258871b33d 6449
jmitc91516 1:a5258871b33d 6450 if(mustUpdateDisplay) {
jmitc91516 1:a5258871b33d 6451
jmitc91516 1:a5258871b33d 6452 // Reduce display flickering - get the component status from the GC
jmitc91516 1:a5258871b33d 6453 // *before* we call GuiLib_Clear()
jmitc91516 1:a5258871b33d 6454 if(singleGCComponentPageStatusColorAreas != NULL) {
jmitc91516 1:a5258871b33d 6455 UpdateSingleGCComponentPageStatusColorArea(GAS);
jmitc91516 1:a5258871b33d 6456 }
jmitc91516 1:a5258871b33d 6457
jmitc91516 1:a5258871b33d 6458 // Makes the display flicker - but omitting it means old text is not cleared from the display
jmitc91516 1:a5258871b33d 6459 //#define WANT_GUILIB_CLEAR
jmitc91516 1:a5258871b33d 6460 #ifdef WANT_GUILIB_CLEAR
jmitc91516 1:a5258871b33d 6461 #ifdef USING_BACKGROUND_BITMAP
jmitc91516 1:a5258871b33d 6462 DrawBackgroundBitmap(); // We want the status rectangles to be 'on top' of this -
jmitc91516 1:a5258871b33d 6463 // if we include it in the easyGUI page itself, it gets drawn by GuiLib_ShowScreen,
jmitc91516 1:a5258871b33d 6464 // and overwrites the rectangles
jmitc91516 1:a5258871b33d 6465 #else
jmitc91516 1:a5258871b33d 6466 GuiLib_Clear();
jmitc91516 1:a5258871b33d 6467 #endif
jmitc91516 1:a5258871b33d 6468 #undef WANT_GUILIB_CLEAR
jmitc91516 1:a5258871b33d 6469 #endif
jmitc91516 1:a5258871b33d 6470 //...except that redrawing the status rectangle effectively clears the text on top of the rectangle -
jmitc91516 1:a5258871b33d 6471 // so we do not need GuiLib_Clear here, since all the gas page data appears on top of the rectangle.
jmitc91516 1:a5258871b33d 6472 // Without it, only the text flickers, not the rectangle
jmitc91516 1:a5258871b33d 6473
jmitc91516 1:a5258871b33d 6474 // Note - we draw the status rectangle after GuiLib_Clear - otherwise we wouldn't see the rectangles at all -
jmitc91516 1:a5258871b33d 6475 // and before GuiLib_ShowScreen - so text, etc, is drawn on top of the rectangles
jmitc91516 1:a5258871b33d 6476 #ifdef WANT_STATUS_RECTANGLE_ON_GAS_CALIB_PAGES
jmitc91516 1:a5258871b33d 6477 if(singleGCComponentPageStatusColorAreas != NULL) {
jmitc91516 1:a5258871b33d 6478 singleGCComponentPageStatusColorAreas->DisplayGCComponentStatus(GAS);
jmitc91516 1:a5258871b33d 6479 }
jmitc91516 1:a5258871b33d 6480 #else // Need to clear old text some other way...
jmitc91516 1:a5258871b33d 6481 #ifdef USING_BACKGROUND_BITMAP
jmitc91516 1:a5258871b33d 6482 DrawBackgroundBitmap();
jmitc91516 1:a5258871b33d 6483 #else
jmitc91516 1:a5258871b33d 6484 GuiLib_Clear();
jmitc91516 1:a5258871b33d 6485 #endif // USING_BACKGROUND_BITMAP
jmitc91516 1:a5258871b33d 6486 #endif // WANT_STATUS_RECTANGLE_ON_GAS_CALIB_PAGES
jmitc91516 1:a5258871b33d 6487
jmitc91516 1:a5258871b33d 6488 GuiLib_ShowScreen(GuiStruct_GasCalibrationPage_Def, GuiLib_NO_CURSOR, GuiLib_RESET_AUTO_REDRAW);
jmitc91516 1:a5258871b33d 6489
jmitc91516 1:a5258871b33d 6490 GuiLib_Refresh();
jmitc91516 1:a5258871b33d 6491
jmitc91516 1:a5258871b33d 6492 #define DEBUG_HERE
jmitc91516 1:a5258871b33d 6493 #ifdef DEBUG_HERE
jmitc91516 1:a5258871b33d 6494 char dbg[100];
jmitc91516 1:a5258871b33d 6495 sprintf(dbg, "After GuiLib_Clear 105");
jmitc91516 1:a5258871b33d 6496 EasyGUIDebugPrint(dbg, 0, 20);
jmitc91516 1:a5258871b33d 6497 #undef DEBUG_HERE
jmitc91516 1:a5258871b33d 6498 #endif
jmitc91516 1:a5258871b33d 6499 }
jmitc91516 1:a5258871b33d 6500 }
jmitc91516 1:a5258871b33d 6501
jmitc91516 1:a5258871b33d 6502
jmitc91516 1:a5258871b33d 6503 /*
jmitc91516 1:a5258871b33d 6504 Displays the data on the gas backpressure DAC page, by copying it to the relevant easyGUI variables,
jmitc91516 1:a5258871b33d 6505 and calling the relevant functions to actually display it.
jmitc91516 1:a5258871b33d 6506
jmitc91516 1:a5258871b33d 6507 Args: a boolean specifying whether or not the display is actually to be updated.
jmitc91516 1:a5258871b33d 6508 Even if it is false when we are called, we may set it true if we discover
jmitc91516 1:a5258871b33d 6509 one or more data items has changed - but note that we will not set it false
jmitc91516 1:a5258871b33d 6510 if it is already true. If it is true after we have looked at all
jmitc91516 1:a5258871b33d 6511 the home page data, we will then update the display. (If we are called
jmitc91516 1:a5258871b33d 6512 with this value set to false, the caller is effectively saying
jmitc91516 1:a5258871b33d 6513 'display the gas page data only if it has changed').
jmitc91516 1:a5258871b33d 6514
jmitc91516 1:a5258871b33d 6515 No return code.
jmitc91516 1:a5258871b33d 6516 */
jmitc91516 1:a5258871b33d 6517 void GetGCStatusLoop::DisplayGasBackPressureDACPageData(bool mustUpdateDisplay)
jmitc91516 1:a5258871b33d 6518 {
jmitc91516 1:a5258871b33d 6519 //EasyGUIDebugPrint("Gas Backpressure DAC Page", 100, 100);
jmitc91516 1:a5258871b33d 6520 // Gas pressure and control mode
jmitc91516 1:a5258871b33d 6521
jmitc91516 1:a5258871b33d 6522 if(SinglePageGCComponentStatusHasChanged(GAS)) {
jmitc91516 1:a5258871b33d 6523 mustUpdateDisplay = true;
jmitc91516 1:a5258871b33d 6524 }
jmitc91516 1:a5258871b33d 6525
jmitc91516 1:a5258871b33d 6526 if(mustUpdateDisplay) {
jmitc91516 1:a5258871b33d 6527
jmitc91516 1:a5258871b33d 6528 // Reduce display flickering - get the component status from the GC
jmitc91516 1:a5258871b33d 6529 // *before* we call GuiLib_Clear()
jmitc91516 1:a5258871b33d 6530 if(singleGCComponentPageStatusColorAreas != NULL) {
jmitc91516 1:a5258871b33d 6531 UpdateSingleGCComponentPageStatusColorArea(GAS);
jmitc91516 1:a5258871b33d 6532 }
jmitc91516 1:a5258871b33d 6533
jmitc91516 1:a5258871b33d 6534 // Makes the display flicker - but omitting it means old text is not cleared from the display
jmitc91516 1:a5258871b33d 6535 //#define WANT_GUILIB_CLEAR
jmitc91516 1:a5258871b33d 6536 #ifdef WANT_GUILIB_CLEAR
jmitc91516 1:a5258871b33d 6537 #ifdef USING_BACKGROUND_BITMAP
jmitc91516 1:a5258871b33d 6538 DrawBackgroundBitmap(); // We want the status rectangles to be 'on top' of this -
jmitc91516 1:a5258871b33d 6539 // if we include it in the easyGUI page itself, it gets drawn by GuiLib_ShowScreen,
jmitc91516 1:a5258871b33d 6540 // and overwrites the rectangles
jmitc91516 1:a5258871b33d 6541 #else
jmitc91516 1:a5258871b33d 6542 GuiLib_Clear();
jmitc91516 1:a5258871b33d 6543 #endif
jmitc91516 1:a5258871b33d 6544 #undef WANT_GUILIB_CLEAR
jmitc91516 1:a5258871b33d 6545 #endif
jmitc91516 1:a5258871b33d 6546 //...except that redrawing the status rectangle effectively clears the text on top of the rectangle -
jmitc91516 1:a5258871b33d 6547 // so we do not need GuiLib_Clear here, since all the gas page data appears on top of the rectangle.
jmitc91516 1:a5258871b33d 6548 // Without it, only the text flickers, not the rectangle
jmitc91516 1:a5258871b33d 6549
jmitc91516 1:a5258871b33d 6550 // Note - we draw the status rectangle after GuiLib_Clear - otherwise we wouldn't see the rectangles at all -
jmitc91516 1:a5258871b33d 6551 // and before GuiLib_ShowScreen - so text, etc, is drawn on top of the rectangles
jmitc91516 1:a5258871b33d 6552 #ifdef WANT_STATUS_RECTANGLE_ON_GAS_CALIB_PAGES
jmitc91516 1:a5258871b33d 6553 if(singleGCComponentPageStatusColorAreas != NULL) {
jmitc91516 1:a5258871b33d 6554 singleGCComponentPageStatusColorAreas->DisplayGCComponentStatus(GAS);
jmitc91516 1:a5258871b33d 6555 }
jmitc91516 1:a5258871b33d 6556 #else // Need to clear old text some other way...
jmitc91516 1:a5258871b33d 6557 #ifdef USING_BACKGROUND_BITMAP
jmitc91516 1:a5258871b33d 6558 DrawBackgroundBitmap();
jmitc91516 1:a5258871b33d 6559 #else
jmitc91516 1:a5258871b33d 6560 GuiLib_Clear();
jmitc91516 1:a5258871b33d 6561 #endif // USING_BACKGROUND_BITMAP
jmitc91516 1:a5258871b33d 6562 #endif // WANT_STATUS_RECTANGLE_ON_GAS_CALIB_PAGES
jmitc91516 1:a5258871b33d 6563
jmitc91516 1:a5258871b33d 6564 GuiLib_ShowScreen(GuiStruct_GasBackPressureDACPage_Def, GuiLib_NO_CURSOR, GuiLib_RESET_AUTO_REDRAW);
jmitc91516 1:a5258871b33d 6565
jmitc91516 1:a5258871b33d 6566 GuiLib_Refresh();
jmitc91516 1:a5258871b33d 6567
jmitc91516 1:a5258871b33d 6568 #define DEBUG_HERE
jmitc91516 1:a5258871b33d 6569 #ifdef DEBUG_HERE
jmitc91516 1:a5258871b33d 6570 char dbg[100];
jmitc91516 1:a5258871b33d 6571 sprintf(dbg, "After GuiLib_Clear 105");
jmitc91516 1:a5258871b33d 6572 EasyGUIDebugPrint(dbg, 0, 20);
jmitc91516 1:a5258871b33d 6573 #undef DEBUG_HERE
jmitc91516 1:a5258871b33d 6574 #endif
jmitc91516 1:a5258871b33d 6575 }
jmitc91516 1:a5258871b33d 6576 }
jmitc91516 1:a5258871b33d 6577
jmitc91516 1:a5258871b33d 6578
jmitc91516 1:a5258871b33d 6579 /*
jmitc91516 1:a5258871b33d 6580 Displays the data on the gas channel DAC and ADC page, by copying it to the relevant easyGUI variables,
jmitc91516 1:a5258871b33d 6581 and calling the relevant functions to actually display it.
jmitc91516 1:a5258871b33d 6582
jmitc91516 1:a5258871b33d 6583 Args: a boolean specifying whether or not the display is actually to be updated.
jmitc91516 1:a5258871b33d 6584 Even if it is false when we are called, we may set it true if we discover
jmitc91516 1:a5258871b33d 6585 one or more data items has changed - but note that we will not set it false
jmitc91516 1:a5258871b33d 6586 if it is already true. If it is true after we have looked at all
jmitc91516 1:a5258871b33d 6587 the home page data, we will then update the display. (If we are called
jmitc91516 1:a5258871b33d 6588 with this value set to false, the caller is effectively saying
jmitc91516 1:a5258871b33d 6589 'display the gas page data only if it has changed').
jmitc91516 1:a5258871b33d 6590
jmitc91516 1:a5258871b33d 6591 No return code.
jmitc91516 1:a5258871b33d 6592 */
jmitc91516 1:a5258871b33d 6593 void GetGCStatusLoop::DisplayGasChannelDACAndADCPageData(bool mustUpdateDisplay)
jmitc91516 1:a5258871b33d 6594 {
jmitc91516 1:a5258871b33d 6595 //EasyGUIDebugPrint("Gas Backpressure DAC Page", 100, 100);
jmitc91516 1:a5258871b33d 6596 // Gas pressure and control mode
jmitc91516 1:a5258871b33d 6597
jmitc91516 1:a5258871b33d 6598 if(SinglePageGCComponentStatusHasChanged(GAS)) {
jmitc91516 1:a5258871b33d 6599 mustUpdateDisplay = true;
jmitc91516 0:47c880c1463d 6600 }
jmitc91516 0:47c880c1463d 6601
jmitc91516 0:47c880c1463d 6602 if(mustUpdateDisplay) {
jmitc91516 0:47c880c1463d 6603
jmitc91516 0:47c880c1463d 6604 // Reduce display flickering - get the component status from the GC
jmitc91516 0:47c880c1463d 6605 // *before* we call GuiLib_Clear()
jmitc91516 0:47c880c1463d 6606 if(singleGCComponentPageStatusColorAreas != NULL) {
jmitc91516 0:47c880c1463d 6607 UpdateSingleGCComponentPageStatusColorArea(GAS);
jmitc91516 0:47c880c1463d 6608 }
jmitc91516 0:47c880c1463d 6609
jmitc91516 0:47c880c1463d 6610 // Makes the display flicker - but omitting it means old text is not cleared from the display
jmitc91516 1:a5258871b33d 6611 //#define WANT_GUILIB_CLEAR
jmitc91516 1:a5258871b33d 6612 #ifdef WANT_GUILIB_CLEAR
jmitc91516 1:a5258871b33d 6613 #ifdef USING_BACKGROUND_BITMAP
jmitc91516 1:a5258871b33d 6614 DrawBackgroundBitmap(); // We want the status rectangles to be 'on top' of this -
jmitc91516 1:a5258871b33d 6615 // if we include it in the easyGUI page itself, it gets drawn by GuiLib_ShowScreen,
jmitc91516 1:a5258871b33d 6616 // and overwrites the rectangles
jmitc91516 1:a5258871b33d 6617 #else
jmitc91516 0:47c880c1463d 6618 GuiLib_Clear();
jmitc91516 1:a5258871b33d 6619 #endif
jmitc91516 1:a5258871b33d 6620 #undef WANT_GUILIB_CLEAR
jmitc91516 1:a5258871b33d 6621 #endif
jmitc91516 1:a5258871b33d 6622 //...except that redrawing the status rectangle effectively clears the text on top of the rectangle -
jmitc91516 1:a5258871b33d 6623 // so we do not need GuiLib_Clear here, since all the gas page data appears on top of the rectangle.
jmitc91516 1:a5258871b33d 6624 // Without it, only the text flickers, not the rectangle
jmitc91516 0:47c880c1463d 6625
jmitc91516 0:47c880c1463d 6626 // Note - we draw the status rectangle after GuiLib_Clear - otherwise we wouldn't see the rectangles at all -
jmitc91516 0:47c880c1463d 6627 // and before GuiLib_ShowScreen - so text, etc, is drawn on top of the rectangles
jmitc91516 1:a5258871b33d 6628 #ifdef WANT_STATUS_RECTANGLE_ON_GAS_CALIB_PAGES
jmitc91516 0:47c880c1463d 6629 if(singleGCComponentPageStatusColorAreas != NULL) {
jmitc91516 0:47c880c1463d 6630 singleGCComponentPageStatusColorAreas->DisplayGCComponentStatus(GAS);
jmitc91516 0:47c880c1463d 6631 }
jmitc91516 1:a5258871b33d 6632 #else // Need to clear old text some other way...
jmitc91516 1:a5258871b33d 6633 #ifdef USING_BACKGROUND_BITMAP
jmitc91516 1:a5258871b33d 6634 DrawBackgroundBitmap();
jmitc91516 1:a5258871b33d 6635 #else
jmitc91516 1:a5258871b33d 6636 GuiLib_Clear();
jmitc91516 1:a5258871b33d 6637 #endif // USING_BACKGROUND_BITMAP
jmitc91516 1:a5258871b33d 6638 #endif // WANT_STATUS_RECTANGLE_ON_GAS_CALIB_PAGES
jmitc91516 1:a5258871b33d 6639
jmitc91516 1:a5258871b33d 6640 GuiLib_ShowScreen(GuiStruct_GasChannelDACAndADCPage_Def, GuiLib_NO_CURSOR, GuiLib_RESET_AUTO_REDRAW);
jmitc91516 0:47c880c1463d 6641
jmitc91516 0:47c880c1463d 6642 GuiLib_Refresh();
jmitc91516 0:47c880c1463d 6643
jmitc91516 0:47c880c1463d 6644 #define DEBUG_HERE
jmitc91516 0:47c880c1463d 6645 #ifdef DEBUG_HERE
jmitc91516 0:47c880c1463d 6646 char dbg[100];
jmitc91516 1:a5258871b33d 6647 sprintf(dbg, "After GuiLib_Clear 105");
jmitc91516 1:a5258871b33d 6648 EasyGUIDebugPrint(dbg, 0, 20);
jmitc91516 0:47c880c1463d 6649 #undef DEBUG_HERE
jmitc91516 0:47c880c1463d 6650 #endif
jmitc91516 0:47c880c1463d 6651 }
jmitc91516 0:47c880c1463d 6652 }
jmitc91516 0:47c880c1463d 6653
jmitc91516 1:a5258871b33d 6654
jmitc91516 1:a5258871b33d 6655 /*
jmitc91516 1:a5258871b33d 6656 A public function allowing other classes (specifically GasCalibrationPageHandler),
jmitc91516 1:a5258871b33d 6657 having changed something on the gas calibration page, to tell us to redisplay it
jmitc91516 1:a5258871b33d 6658 */
jmitc91516 1:a5258871b33d 6659 void GetGCStatusLoop::ForceUpdateOfGasCalibrationPage(void)
jmitc91516 1:a5258871b33d 6660 {
jmitc91516 1:a5258871b33d 6661 if(currentPage == GuiStruct_GasCalibrationPage_Def) {
jmitc91516 1:a5258871b33d 6662 DisplayGasCalibrationPageData(true);
jmitc91516 1:a5258871b33d 6663 }
jmitc91516 1:a5258871b33d 6664 }
jmitc91516 1:a5258871b33d 6665
jmitc91516 1:a5258871b33d 6666
jmitc91516 1:a5258871b33d 6667 /*
jmitc91516 1:a5258871b33d 6668 A public function allowing other classes (specifically ColumnDHManualCalibrationPageHandler),
jmitc91516 1:a5258871b33d 6669 having changed something on the gas calibration page, to tell us to redisplay it
jmitc91516 1:a5258871b33d 6670 */
jmitc91516 1:a5258871b33d 6671 void GetGCStatusLoop::ForceUpdateOfColumnDHManualCalibrationPage(void)
jmitc91516 1:a5258871b33d 6672 {
jmitc91516 1:a5258871b33d 6673 if(currentPage == GuiStruct_ColumnDHManualCalibrationPage_Def) {
jmitc91516 1:a5258871b33d 6674 DisplayColumnDHManualCalibrationPageData(true);
jmitc91516 1:a5258871b33d 6675 }
jmitc91516 1:a5258871b33d 6676 }
jmitc91516 1:a5258871b33d 6677
jmitc91516 1:a5258871b33d 6678
jmitc91516 1:a5258871b33d 6679 /*
jmitc91516 1:a5258871b33d 6680 A public function allowing other classes (specifically ColumnDHManualCalibrationPageHandler),
jmitc91516 1:a5258871b33d 6681 having changed something on the manual calibration page, to tell us to redisplay it
jmitc91516 1:a5258871b33d 6682 */
jmitc91516 1:a5258871b33d 6683 void GetGCStatusLoop::ForceUpdateOfColumnDHSensorCalibrationPage(void)
jmitc91516 1:a5258871b33d 6684 {
jmitc91516 1:a5258871b33d 6685 if(currentPage == GuiStruct_ColumnDHSensorCalibration_Def) {
jmitc91516 1:a5258871b33d 6686 DisplayColumnDHSensorCalibrationPageData(true);
jmitc91516 1:a5258871b33d 6687 }
jmitc91516 1:a5258871b33d 6688 }
jmitc91516 1:a5258871b33d 6689
jmitc91516 1:a5258871b33d 6690
jmitc91516 1:a5258871b33d 6691 /*
jmitc91516 1:a5258871b33d 6692 A public function allowing other classes (specifically ColumnDHPSUDACPageHandler),
jmitc91516 1:a5258871b33d 6693 having changed something on the PSU DAC page, to tell us to redisplay it
jmitc91516 1:a5258871b33d 6694 */
jmitc91516 1:a5258871b33d 6695 void GetGCStatusLoop::ForceUpdateOfColumnDHPSUDACPage(void)
jmitc91516 1:a5258871b33d 6696 {
jmitc91516 1:a5258871b33d 6697 if(currentPage == GuiStruct_PSU_DAC_Page_Def) {
jmitc91516 1:a5258871b33d 6698 DisplayColumnDHPSUDACPageData(true);
jmitc91516 1:a5258871b33d 6699 }
jmitc91516 1:a5258871b33d 6700 }
jmitc91516 1:a5258871b33d 6701
jmitc91516 1:a5258871b33d 6702
jmitc91516 1:a5258871b33d 6703 /*
jmitc91516 1:a5258871b33d 6704 A public function allowing other classes (specifically ColumnDHAutoCalibrationPageHandler),
jmitc91516 1:a5258871b33d 6705 having changed something on the auto calibration page, to tell us to redisplay it
jmitc91516 1:a5258871b33d 6706 */
jmitc91516 1:a5258871b33d 6707 void GetGCStatusLoop::ForceUpdateOfColumnDHAutoCalibrationPage(void)
jmitc91516 1:a5258871b33d 6708 {
jmitc91516 1:a5258871b33d 6709 if(currentPage == GuiStruct_ColumnDHAutoCalibrationPage_Def) {
jmitc91516 1:a5258871b33d 6710 DisplayColumnDHAutoCalibrationPageData(true);
jmitc91516 1:a5258871b33d 6711 }
jmitc91516 1:a5258871b33d 6712 }
jmitc91516 1:a5258871b33d 6713
jmitc91516 1:a5258871b33d 6714
jmitc91516 1:a5258871b33d 6715 /*
jmitc91516 1:a5258871b33d 6716 A public function allowing other classes (specifically GasBackPressureDACPageHandler),
jmitc91516 1:a5258871b33d 6717 having changed something on the gas back pressure DAC page, to tell us to redisplay it
jmitc91516 1:a5258871b33d 6718 */
jmitc91516 1:a5258871b33d 6719 void GetGCStatusLoop::ForceUpdateOfGasBackPressureDACPage(void)
jmitc91516 1:a5258871b33d 6720 {
jmitc91516 1:a5258871b33d 6721 if(currentPage == GuiStruct_GasBackPressureDACPage_Def) {
jmitc91516 1:a5258871b33d 6722 DisplayGasBackPressureDACPageData(true);
jmitc91516 1:a5258871b33d 6723 }
jmitc91516 1:a5258871b33d 6724 }
jmitc91516 1:a5258871b33d 6725
jmitc91516 1:a5258871b33d 6726
jmitc91516 1:a5258871b33d 6727 /*
jmitc91516 1:a5258871b33d 6728 A public function allowing other classes (specifically GasChannelDACAndADCPageHandler),
jmitc91516 1:a5258871b33d 6729 having changed something on the channel DAC and ADC page, to tell us to redisplay it
jmitc91516 1:a5258871b33d 6730 */
jmitc91516 1:a5258871b33d 6731 void GetGCStatusLoop::ForceUpdateOfGasChannelDACAndADCPage(void)
jmitc91516 1:a5258871b33d 6732 {
jmitc91516 1:a5258871b33d 6733 if(currentPage == GuiStruct_GasChannelDACAndADCPage_Def) {
jmitc91516 1:a5258871b33d 6734 DisplayGasChannelDACAndADCPageData(true);
jmitc91516 1:a5258871b33d 6735 }
jmitc91516 1:a5258871b33d 6736 }
jmitc91516 1:a5258871b33d 6737
jmitc91516 1:a5258871b33d 6738
jmitc91516 1:a5258871b33d 6739
jmitc91516 1:a5258871b33d 6740 /*
jmitc91516 1:a5258871b33d 6741 Returns the length of time remaining until the column method finishes.
jmitc91516 1:a5258871b33d 6742 Value is in minutes.
jmitc91516 1:a5258871b33d 6743 */
jmitc91516 1:a5258871b33d 6744 float GetGCStatusLoop::GetColumnMethodTimeRemaining(void)
jmitc91516 1:a5258871b33d 6745 {
jmitc91516 1:a5258871b33d 6746 float currentColumnMethodRunTime;
jmitc91516 1:a5258871b33d 6747 GetRunTime(&currentColumnMethodRunTime);
jmitc91516 1:a5258871b33d 6748 // float totalColumnMethodMethodTime = runningColumnPageGraphCompleteProfileDataSet->GetTotalMethodTime();
jmitc91516 1:a5258871b33d 6749 float totalColumnMethodMethodTime = runningColumnPageGraphCompleteProfileDataSet->GetNonRoundedTotalMethodTime();
jmitc91516 1:a5258871b33d 6750
jmitc91516 1:a5258871b33d 6751
jmitc91516 1:a5258871b33d 6752 char dbg[100];
jmitc91516 1:a5258871b33d 6753 sprintf(dbg, "GCMTR - %f %f", currentColumnMethodRunTime, totalColumnMethodMethodTime);
jmitc91516 1:a5258871b33d 6754 EasyGUIDebugPrintWithCounter(dbg, 125, 350);
jmitc91516 1:a5258871b33d 6755
jmitc91516 1:a5258871b33d 6756 // This value will be in minutes
jmitc91516 1:a5258871b33d 6757 return (totalColumnMethodMethodTime - currentColumnMethodRunTime);
jmitc91516 1:a5258871b33d 6758 }
jmitc91516 1:a5258871b33d 6759
jmitc91516 1:a5258871b33d 6760 /*
jmitc91516 1:a5258871b33d 6761 If the GC is running, updates the easyGUI variables
jmitc91516 1:a5258871b33d 6762 that display the run time.
jmitc91516 1:a5258871b33d 6763
jmitc91516 1:a5258871b33d 6764 Returns true if it updated [any of] the variables, false if not
jmitc91516 1:a5258871b33d 6765 */
jmitc91516 1:a5258871b33d 6766 bool GetGCStatusLoop::UpdateMethodRunTimeEasyGUIVariables(bool runHasCompleted)
jmitc91516 1:a5258871b33d 6767 {
jmitc91516 1:a5258871b33d 6768 bool variableUpdated = false;
jmitc91516 1:a5258871b33d 6769 char buff[50];
jmitc91516 1:a5258871b33d 6770
jmitc91516 1:a5258871b33d 6771 if(GCIsRunning()) {
jmitc91516 1:a5258871b33d 6772 float currentColumnMethodRunTime;
jmitc91516 1:a5258871b33d 6773 GetRunTime(&currentColumnMethodRunTime);
jmitc91516 1:a5258871b33d 6774
jmitc91516 1:a5258871b33d 6775 // Always display in units of 0.1 minute
jmitc91516 1:a5258871b33d 6776 sprintf(buff, "%.1f", currentColumnMethodRunTime);
jmitc91516 1:a5258871b33d 6777
jmitc91516 1:a5258871b33d 6778 if(strcmp(GuiVar_runTimeElapsed, buff) != 0) {
jmitc91516 1:a5258871b33d 6779 strcpy(GuiVar_runTimeElapsed, buff);
jmitc91516 1:a5258871b33d 6780 variableUpdated = true;
jmitc91516 1:a5258871b33d 6781 }
jmitc91516 1:a5258871b33d 6782
jmitc91516 1:a5258871b33d 6783
jmitc91516 1:a5258871b33d 6784 float columnMethodTimeRemaining = GetColumnMethodTimeRemaining();
jmitc91516 1:a5258871b33d 6785
jmitc91516 1:a5258871b33d 6786 if(columnMethodTimeRemaining >= 0.0f) {
jmitc91516 1:a5258871b33d 6787 // We display the value in 'units' of 0.1 minute
jmitc91516 1:a5258871b33d 6788 sprintf(buff, "(Time remaining: %.1f minutes)", columnMethodTimeRemaining);
jmitc91516 1:a5258871b33d 6789 } else {
jmitc91516 1:a5258871b33d 6790 strcpy(buff, "(Time remaining: 0.0 minutes)"); // *Never* display a negative value
jmitc91516 1:a5258871b33d 6791 }
jmitc91516 1:a5258871b33d 6792
jmitc91516 1:a5258871b33d 6793 if(strcmp(GuiVar_runTimeRemaining, buff) != 0) {
jmitc91516 1:a5258871b33d 6794 strcpy(GuiVar_runTimeRemaining, buff);
jmitc91516 1:a5258871b33d 6795 variableUpdated = true;
jmitc91516 1:a5258871b33d 6796 }
jmitc91516 1:a5258871b33d 6797
jmitc91516 1:a5258871b33d 6798 } else if (runHasCompleted) {
jmitc91516 1:a5258871b33d 6799
jmitc91516 1:a5258871b33d 6800 strcpy(buff, "0.0");
jmitc91516 1:a5258871b33d 6801
jmitc91516 1:a5258871b33d 6802 if(strcmp(GuiVar_runTimeRemaining, buff) != 0) {
jmitc91516 1:a5258871b33d 6803 strcpy(GuiVar_runTimeRemaining, buff);
jmitc91516 1:a5258871b33d 6804 variableUpdated = true;
jmitc91516 1:a5258871b33d 6805 }
jmitc91516 1:a5258871b33d 6806
jmitc91516 1:a5258871b33d 6807 // GuiVar_runTimeElapsed needs to be an empty string
jmitc91516 1:a5258871b33d 6808 if(GuiVar_runTimeElapsed[0] != '\0') {
jmitc91516 1:a5258871b33d 6809 GuiVar_runTimeElapsed[0] = '\0';
jmitc91516 1:a5258871b33d 6810 variableUpdated = true;
jmitc91516 1:a5258871b33d 6811 }
jmitc91516 1:a5258871b33d 6812 }
jmitc91516 1:a5258871b33d 6813
jmitc91516 1:a5258871b33d 6814 return variableUpdated;
jmitc91516 1:a5258871b33d 6815 }
jmitc91516 1:a5258871b33d 6816
jmitc91516 1:a5258871b33d 6817 /*
jmitc91516 1:a5258871b33d 6818 Update the easyGUI variable that displays the column status on Column page 1
jmitc91516 1:a5258871b33d 6819 and Column DH page 1
jmitc91516 1:a5258871b33d 6820 */
jmitc91516 1:a5258871b33d 6821 void GetGCStatusLoop::UpdateColumnStatusEasyGUIVariable(void)
jmitc91516 1:a5258871b33d 6822 {
jmitc91516 1:a5258871b33d 6823 GetComponentStatusString(COLUMN, GuiVar_columnStatus);
jmitc91516 1:a5258871b33d 6824 }
jmitc91516 1:a5258871b33d 6825
jmitc91516 1:a5258871b33d 6826 void GetGCStatusLoop::UpdateInjectorStatusEasyGUIVariable(void)
jmitc91516 1:a5258871b33d 6827 {
jmitc91516 1:a5258871b33d 6828 GetComponentStatusString(INJECTOR, GuiVar_injectorStatus);
jmitc91516 1:a5258871b33d 6829 }
jmitc91516 1:a5258871b33d 6830
jmitc91516 1:a5258871b33d 6831 /*
jmitc91516 1:a5258871b33d 6832 Update the calibrated range and current position of the progress bar
jmitc91516 1:a5258871b33d 6833 displayed on 'RunningPage1' - then re-display it.
jmitc91516 1:a5258871b33d 6834
jmitc91516 1:a5258871b33d 6835 No arguments, no return code
jmitc91516 1:a5258871b33d 6836 */
jmitc91516 1:a5258871b33d 6837 void GetGCStatusLoop::UpdateAndDisplayRunningPage1ProgressBar(bool runHasCompleted)
jmitc91516 1:a5258871b33d 6838 {
jmitc91516 1:a5258871b33d 6839 if(runningPage1ProgressBar != NULL) {
jmitc91516 1:a5258871b33d 6840
jmitc91516 1:a5258871b33d 6841 float totalColumnMethodMethodTime = runningColumnPageGraphCompleteProfileDataSet->GetNonRoundedTotalMethodTime();
jmitc91516 1:a5258871b33d 6842
jmitc91516 1:a5258871b33d 6843 if(GCIsRunning()) {
jmitc91516 1:a5258871b33d 6844 float currentColumnMethodRunTime;
jmitc91516 1:a5258871b33d 6845 GetRunTime(&currentColumnMethodRunTime);
jmitc91516 1:a5258871b33d 6846 //float totalColumnMethodMethodTime = runningColumnPageGraphCompleteProfileDataSet->GetTotalMethodTime();
jmitc91516 1:a5258871b33d 6847 runningPage1ProgressBar->SetCalibratedRange((double)totalColumnMethodMethodTime);
jmitc91516 1:a5258871b33d 6848
jmitc91516 1:a5258871b33d 6849 runningPage1ProgressBar->UpdateCalibratedPosition((double)currentColumnMethodRunTime, true);
jmitc91516 1:a5258871b33d 6850 } else if (runHasCompleted) {
jmitc91516 1:a5258871b33d 6851 runningPage1ProgressBar->DisplayBarComplete(true);
jmitc91516 1:a5258871b33d 6852 }
jmitc91516 1:a5258871b33d 6853 }
jmitc91516 1:a5258871b33d 6854 }
jmitc91516 1:a5258871b33d 6855
jmitc91516 1:a5258871b33d 6856
jmitc91516 1:a5258871b33d 6857 void GetGCStatusLoop::SetRunningPage1ProgressBarToZero(void)
jmitc91516 1:a5258871b33d 6858 {
jmitc91516 1:a5258871b33d 6859 if(runningPage1ProgressBar != NULL) {
jmitc91516 1:a5258871b33d 6860 runningPage1ProgressBar->UpdateCalibratedPosition(0.0, true);
jmitc91516 1:a5258871b33d 6861 }
jmitc91516 1:a5258871b33d 6862 }
jmitc91516 1:a5258871b33d 6863
jmitc91516 1:a5258871b33d 6864 /*
jmitc91516 1:a5258871b33d 6865 Displays the data on the 'GC is running' page, by copying it to the relevant easyGUI variables,
jmitc91516 1:a5258871b33d 6866 and calling the relevant functions to actually display it.
jmitc91516 1:a5258871b33d 6867
jmitc91516 1:a5258871b33d 6868 Args: a boolean specifying whether or not the display is actually to be updated.
jmitc91516 1:a5258871b33d 6869 Even if it is false when we are called, we may set it true if we discover
jmitc91516 1:a5258871b33d 6870 one or more data items has changed - but note that we will not set it false
jmitc91516 1:a5258871b33d 6871 if it is already true. If it is true after we have looked at all
jmitc91516 1:a5258871b33d 6872 the home page data, we will then update the display. (If we are called
jmitc91516 1:a5258871b33d 6873 with this value set to false, the caller is effectively saying
jmitc91516 1:a5258871b33d 6874 'display the running page data only if it has changed').
jmitc91516 1:a5258871b33d 6875
jmitc91516 1:a5258871b33d 6876 No return code.
jmitc91516 1:a5258871b33d 6877 */
jmitc91516 1:a5258871b33d 6878 void GetGCStatusLoop::DisplayRunningPageData(bool mustUpdateDisplay, bool runHasCompleted)
jmitc91516 1:a5258871b33d 6879 {
jmitc91516 1:a5258871b33d 6880 if(UpdateMethodRunTimeEasyGUIVariables(runHasCompleted)) {
jmitc91516 1:a5258871b33d 6881 mustUpdateDisplay = true;
jmitc91516 1:a5258871b33d 6882 }
jmitc91516 1:a5258871b33d 6883
jmitc91516 1:a5258871b33d 6884 if(mustUpdateDisplay) {
jmitc91516 1:a5258871b33d 6885
jmitc91516 1:a5258871b33d 6886 // Makes the display flicker - but omitting it means old text is not cleared from the display
jmitc91516 1:a5258871b33d 6887 #ifdef USING_BACKGROUND_BITMAP
jmitc91516 1:a5258871b33d 6888 DrawBackgroundBitmap();
jmitc91516 1:a5258871b33d 6889 #else
jmitc91516 1:a5258871b33d 6890 GuiLib_Clear();
jmitc91516 1:a5258871b33d 6891 #endif
jmitc91516 1:a5258871b33d 6892
jmitc91516 1:a5258871b33d 6893 GuiLib_ShowScreen(GuiStruct_RunningPage1_7, GuiLib_NO_CURSOR, GuiLib_RESET_AUTO_REDRAW);
jmitc91516 1:a5258871b33d 6894
jmitc91516 1:a5258871b33d 6895 UpdateAndDisplayRunningPage1ProgressBar(runHasCompleted);
jmitc91516 1:a5258871b33d 6896
jmitc91516 1:a5258871b33d 6897 GuiLib_Refresh();
jmitc91516 1:a5258871b33d 6898 }
jmitc91516 1:a5258871b33d 6899
jmitc91516 1:a5258871b33d 6900 }
jmitc91516 1:a5258871b33d 6901
jmitc91516 1:a5258871b33d 6902
jmitc91516 1:a5258871b33d 6903 /*
jmitc91516 1:a5258871b33d 6904 When the GC starts running a method, set up the easyGUI variables that display
jmitc91516 1:a5258871b33d 6905 the column temperature, etc, on the relevant graph/profile pages.
jmitc91516 1:a5258871b33d 6906 This is so that they are all set to valid values before they are displayed.
jmitc91516 1:a5258871b33d 6907
jmitc91516 1:a5258871b33d 6908 This *must* be called every time the GC starts running, whatever the reason
jmitc91516 1:a5258871b33d 6909
jmitc91516 1:a5258871b33d 6910 No arguments, no return value
jmitc91516 1:a5258871b33d 6911 */
jmitc91516 1:a5258871b33d 6912 void GetGCStatusLoop::SetupTemperatureWhileRunningEasyGUIVariables(void)
jmitc91516 1:a5258871b33d 6913 {
jmitc91516 1:a5258871b33d 6914 // Get the column type from the GC, put it in the 'runningColumnType' variable.
jmitc91516 1:a5258871b33d 6915 // Provided so that:
jmitc91516 1:a5258871b33d 6916 // (1) this is *always* called when we start running
jmitc91516 1:a5258871b33d 6917 // (2) we do not have to get the column type every time we read the temperature
jmitc91516 1:a5258871b33d 6918 // (the column type is hardly likely to change while we are running)
jmitc91516 1:a5258871b33d 6919 runningColumnType = GetColumnType();
jmitc91516 1:a5258871b33d 6920
jmitc91516 1:a5258871b33d 6921 if(runningColumnType == DIRECTLY_HEATED_COLUMN) {
jmitc91516 1:a5258871b33d 6922 GetDirectlyHeatedColumnTemperature(GuiVar_columnTemperatureWhileRunning, false);
jmitc91516 1:a5258871b33d 6923 } else {
jmitc91516 1:a5258871b33d 6924 GetColumnTemperature(GuiVar_columnTemperatureWhileRunning, false);
jmitc91516 1:a5258871b33d 6925 }
jmitc91516 1:a5258871b33d 6926
jmitc91516 1:a5258871b33d 6927 GetInjectorTemperature(GuiVar_injectorTemperatureWhileRunning, false);
jmitc91516 1:a5258871b33d 6928
jmitc91516 1:a5258871b33d 6929 GetCurrentGasPressure(GuiVar_gasPressureWhileRunning, false, true);
jmitc91516 1:a5258871b33d 6930 }
jmitc91516 1:a5258871b33d 6931
jmitc91516 1:a5258871b33d 6932
jmitc91516 1:a5258871b33d 6933 /*
jmitc91516 1:a5258871b33d 6934 Displays the data on the 'running column' page.
jmitc91516 1:a5258871b33d 6935
jmitc91516 1:a5258871b33d 6936 Args: a boolean specifying whether or not the display is actually to be updated.
jmitc91516 1:a5258871b33d 6937 Even if it is false when we are called, we may set it true if we discover
jmitc91516 1:a5258871b33d 6938 one or more data items has changed - but note that we will not set it false
jmitc91516 1:a5258871b33d 6939 if it is already true. If it is true after we have looked at all
jmitc91516 1:a5258871b33d 6940 the home page data, we will then update the display. (If we are called
jmitc91516 1:a5258871b33d 6941 with this value set to false, the caller is effectively saying
jmitc91516 1:a5258871b33d 6942 'display the running settings page data only if it has changed').
jmitc91516 1:a5258871b33d 6943
jmitc91516 1:a5258871b33d 6944 No return code.
jmitc91516 1:a5258871b33d 6945 */
jmitc91516 1:a5258871b33d 6946 void GetGCStatusLoop::DisplayRunningColumnPageData(bool mustUpdateDisplay, bool runHasCompleted)
jmitc91516 1:a5258871b33d 6947 {
jmitc91516 1:a5258871b33d 6948 // This page consists principally of an easyGUI graph, to which we assign several datasets:
jmitc91516 1:a5258871b33d 6949 //
jmitc91516 1:a5258871b33d 6950 // - dataset 0 is a line representing the temperature profile of the run from 'now' to the finish
jmitc91516 1:a5258871b33d 6951 // - dataset 1 is a bar chart representing the temperature profile of the run from 'now' to the finish
jmitc91516 1:a5258871b33d 6952 // - dataset 2 is a line representing the temperature profile from the start to 'now'
jmitc91516 1:a5258871b33d 6953 // - dataset 3 is a bar chart representing the temperature profile of the run from the start to 'now'
jmitc91516 1:a5258871b33d 6954 // - dataset 4 is a single dot at the current time and temperature
jmitc91516 1:a5258871b33d 6955
jmitc91516 1:a5258871b33d 6956 if(GCIsRunning() || runHasCompleted) {
jmitc91516 1:a5258871b33d 6957
jmitc91516 1:a5258871b33d 6958 // SetupRunningColumnPageGraphPartialDataSetsToMatchCurrentRunTime
jmitc91516 1:a5258871b33d 6959 // returns true if it has updated the datasets, false otherwise
jmitc91516 1:a5258871b33d 6960 if(SetupRunningColumnPageGraphPartialDataSetsToMatchCurrentRunTime(runHasCompleted)) {
jmitc91516 1:a5258871b33d 6961 mustUpdateDisplay = true;
jmitc91516 1:a5258871b33d 6962 }
jmitc91516 1:a5258871b33d 6963 }
jmitc91516 1:a5258871b33d 6964
jmitc91516 1:a5258871b33d 6965 char buff[40];
jmitc91516 1:a5258871b33d 6966 if(runningColumnType == DIRECTLY_HEATED_COLUMN) {
jmitc91516 1:a5258871b33d 6967 GetDirectlyHeatedColumnTemperature(buff, false);
jmitc91516 1:a5258871b33d 6968 } else {
jmitc91516 1:a5258871b33d 6969 GetColumnTemperature(buff, false);
jmitc91516 1:a5258871b33d 6970 }
jmitc91516 1:a5258871b33d 6971 if(strcmp(buff, GuiVar_columnTemperatureWhileRunning) != 0) {
jmitc91516 1:a5258871b33d 6972 strcpy(GuiVar_columnTemperatureWhileRunning, buff);
jmitc91516 1:a5258871b33d 6973 mustUpdateDisplay = true;
jmitc91516 1:a5258871b33d 6974 }
jmitc91516 1:a5258871b33d 6975
jmitc91516 1:a5258871b33d 6976 // Do this *before* updating the datasets, not after - otherwise we don't see the data at all
jmitc91516 1:a5258871b33d 6977 if(mustUpdateDisplay) {
jmitc91516 1:a5258871b33d 6978
jmitc91516 1:a5258871b33d 6979 #ifdef USING_DATASET_4 // If we are not using dataset4, we do not need to erase the previous 'dots' -
jmitc91516 1:a5258871b33d 6980 // all elements of the graph will get redrawn anyway, so we do not need to clear it
jmitc91516 1:a5258871b33d 6981
jmitc91516 1:a5258871b33d 6982 // Makes the display flicker - but omitting it means old text is not cleared from the display
jmitc91516 1:a5258871b33d 6983 #ifdef USING_BACKGROUND_BITMAP
jmitc91516 1:a5258871b33d 6984 DrawBackgroundBitmap();
jmitc91516 1:a5258871b33d 6985 #else
jmitc91516 1:a5258871b33d 6986 GuiLib_Clear();
jmitc91516 1:a5258871b33d 6987 #endif
jmitc91516 1:a5258871b33d 6988 // But the text does not change - so why do we need this?
jmitc91516 1:a5258871b33d 6989 // Answer - because otherwise the 'dot at current time' (dataset 4) does not get erased when we draw the next one
jmitc91516 1:a5258871b33d 6990
jmitc91516 1:a5258871b33d 6991 #else
jmitc91516 1:a5258871b33d 6992 // We are not erasing the background, to minimise flickering of the graph.
jmitc91516 1:a5258871b33d 6993 // Therefore, must manually erase background of 'column temperature while running' variable
jmitc91516 1:a5258871b33d 6994 GuiLib_FillBox(400, 45, 550, 75, 0xFFFF); // White background
jmitc91516 1:a5258871b33d 6995
jmitc91516 1:a5258871b33d 6996 #endif // USING_DATASET_4
jmitc91516 1:a5258871b33d 6997
jmitc91516 1:a5258871b33d 6998 GuiLib_ShowScreen(GuiStruct_RunningColumnPage_25, GuiLib_NO_CURSOR, GuiLib_RESET_AUTO_REDRAW);
jmitc91516 1:a5258871b33d 6999
jmitc91516 1:a5258871b33d 7000 GuiLib_Refresh();
jmitc91516 1:a5258871b33d 7001 }
jmitc91516 1:a5258871b33d 7002
jmitc91516 1:a5258871b33d 7003 TimeUnit timeUnit = MINUTES;
jmitc91516 1:a5258871b33d 7004 if(runningColumnPageGraphCompleteProfileDataSet->GetTotalMethodTime() < methodTimeUnitsThreshold) {
jmitc91516 1:a5258871b33d 7005 timeUnit = SECONDS;
jmitc91516 1:a5258871b33d 7006 }
jmitc91516 1:a5258871b33d 7007
jmitc91516 1:a5258871b33d 7008
jmitc91516 1:a5258871b33d 7009 const float yAxisScaleFactor = 10.0f;
jmitc91516 1:a5258871b33d 7010
jmitc91516 1:a5258871b33d 7011 // Dataset 0
jmitc91516 1:a5258871b33d 7012 runningColumnPageGraph->SetDataForGraphDataSetInTenthsOfMinutes(0, yAxisScaleFactor, runningColumnPageGraphDataSet0);
jmitc91516 1:a5258871b33d 7013
jmitc91516 1:a5258871b33d 7014 // Dataset 1
jmitc91516 1:a5258871b33d 7015 runningColumnPageGraph->SetDataForGraphDataSetInTenthsOfMinutes(1, yAxisScaleFactor, runningColumnPageGraphDataSet1);
jmitc91516 1:a5258871b33d 7016
jmitc91516 1:a5258871b33d 7017 // Dataset 2
jmitc91516 1:a5258871b33d 7018 runningColumnPageGraph->SetDataForGraphDataSetInTenthsOfMinutes(2, yAxisScaleFactor, runningColumnPageGraphDataSet2);
jmitc91516 1:a5258871b33d 7019
jmitc91516 1:a5258871b33d 7020 // Dataset 3
jmitc91516 1:a5258871b33d 7021 runningColumnPageGraph->SetDataForGraphDataSetInTenthsOfMinutes(3, yAxisScaleFactor, runningColumnPageGraphDataSet3);
jmitc91516 1:a5258871b33d 7022
jmitc91516 1:a5258871b33d 7023 #ifdef USING_DATASET_4
jmitc91516 1:a5258871b33d 7024 // Dataset 4
jmitc91516 1:a5258871b33d 7025 runningColumnPageGraph->SetDataForGraphDataSetInTenthsOfMinutes(4, yAxisScaleFactor, runningColumnPageGraphDataSet4);
jmitc91516 1:a5258871b33d 7026 #endif // USING_DATASET_4
jmitc91516 1:a5258871b33d 7027
jmitc91516 1:a5258871b33d 7028 runningColumnPageGraph->SetXAxisUnits(timeUnit);
jmitc91516 1:a5258871b33d 7029
jmitc91516 1:a5258871b33d 7030
jmitc91516 1:a5258871b33d 7031 // The tick sizes must match those set in easyGUI - we do not seem
jmitc91516 1:a5258871b33d 7032 // to be able to get them at runtime
jmitc91516 1:a5258871b33d 7033 GuiConst_INT32S minX, maxX;
jmitc91516 1:a5258871b33d 7034 //GuiConst_INT32S tickSize = (timeUnit == SECONDS) ? 300 : 100;
jmitc91516 1:a5258871b33d 7035 // Always in 1/10 minutes
jmitc91516 1:a5258871b33d 7036 GuiConst_INT32S xAxisTickSize = (timeUnit == SECONDS) ? 5 : 100; // 5 == 0.5 minutes (i.e. 30 seconds), 100 == 10 minutes
jmitc91516 1:a5258871b33d 7037 runningColumnPageGraphCompleteProfileDataSet->GetXAxisRangeInTenthsOfMinutes(&minX, &maxX, xAxisTickSize );
jmitc91516 1:a5258871b33d 7038 runningColumnPageGraph->SetXAxisRange(0, maxX); // Always start X axis at zero
jmitc91516 1:a5258871b33d 7039
jmitc91516 1:a5258871b33d 7040 GuiConst_INT32S minY, maxY;
jmitc91516 1:a5258871b33d 7041 GuiConst_INT32S yAxisTickSize = 50;
jmitc91516 1:a5258871b33d 7042 runningColumnPageGraphCompleteProfileDataSet->GetYAxisRange(&minY, &maxY, yAxisTickSize);
jmitc91516 1:a5258871b33d 7043 runningColumnPageGraph->SetYAxisRange(0, (maxY * yAxisScaleFactor)); // Always start Y axis at zero
jmitc91516 1:a5258871b33d 7044
jmitc91516 1:a5258871b33d 7045
jmitc91516 1:a5258871b33d 7046 runningColumnPageGraph->DrawAxes();
jmitc91516 1:a5258871b33d 7047
jmitc91516 1:a5258871b33d 7048 // We need to draw the X axis labels ourselves, since our time values are in units of 0.1 minute,
jmitc91516 1:a5258871b33d 7049 // but easyGUI graphs work only in integers - we therefore have to multiply the time values by 10
jmitc91516 1:a5258871b33d 7050 // before passing them to easyGUI, and if we let easyGUI draw its own values on the X axis,
jmitc91516 1:a5258871b33d 7051 // they would be 10 times the correct values.
jmitc91516 1:a5258871b33d 7052 // Graph coordinates copied from easyGUI - I cannot find a way of obtaining them at runtime.
jmitc91516 1:a5258871b33d 7053 if(timeUnit == SECONDS) {
jmitc91516 1:a5258871b33d 7054 runningColumnPageGraph->DrawXAxisLabels(0, (maxX * 6), (xAxisTickSize * 6), 170, 335, 500);
jmitc91516 1:a5258871b33d 7055 } else {
jmitc91516 1:a5258871b33d 7056 runningColumnPageGraph->DrawXAxisLabels(0, (maxX / 10), (xAxisTickSize / 10), 170, 335, 500);
jmitc91516 1:a5258871b33d 7057 }
jmitc91516 1:a5258871b33d 7058
jmitc91516 1:a5258871b33d 7059 // Similar to the X axis - the values we pass to the easyGUI graph are scaled to be larger
jmitc91516 1:a5258871b33d 7060 // than the real values, to get round the fact that easyGUI graphs work in integers.
jmitc91516 1:a5258871b33d 7061 // (This can cause the profile to appear to be 'stepped', which obviously we do not want.)
jmitc91516 1:a5258871b33d 7062 // We must therefore draw the Y axis values ourselves.
jmitc91516 1:a5258871b33d 7063 runningColumnPageGraph->DrawYAxisLabels(0, maxY, yAxisTickSize, 170, 335, 250);
jmitc91516 1:a5258871b33d 7064
jmitc91516 1:a5258871b33d 7065 runningColumnPageGraph->DrawDataSet(0);
jmitc91516 1:a5258871b33d 7066 runningColumnPageGraph->ShowDataSet(0);
jmitc91516 1:a5258871b33d 7067
jmitc91516 1:a5258871b33d 7068 runningColumnPageGraph->DrawDataSet(1);
jmitc91516 1:a5258871b33d 7069 runningColumnPageGraph->ShowDataSet(1);
jmitc91516 1:a5258871b33d 7070
jmitc91516 1:a5258871b33d 7071 runningColumnPageGraph->DrawDataSet(2);
jmitc91516 1:a5258871b33d 7072 runningColumnPageGraph->ShowDataSet(2);
jmitc91516 1:a5258871b33d 7073
jmitc91516 1:a5258871b33d 7074 runningColumnPageGraph->DrawDataSet(3);
jmitc91516 1:a5258871b33d 7075 runningColumnPageGraph->ShowDataSet(3);
jmitc91516 1:a5258871b33d 7076
jmitc91516 1:a5258871b33d 7077 #ifdef USING_DATASET_4
jmitc91516 1:a5258871b33d 7078 runningColumnPageGraph->DrawDataSet(4);
jmitc91516 1:a5258871b33d 7079 runningColumnPageGraph->ShowDataSet(4);
jmitc91516 1:a5258871b33d 7080 #endif // USING_DATASET_4
jmitc91516 1:a5258871b33d 7081
jmitc91516 1:a5258871b33d 7082 runningColumnPageGraph->Redraw(); // This only redraws the graph axes, etc - not the data
jmitc91516 1:a5258871b33d 7083
jmitc91516 1:a5258871b33d 7084 #ifdef TEST_GUILIB_VLINE_PROFILES
jmitc91516 1:a5258871b33d 7085 GuiConst_INTCOLOR graphColour1 = SixteenBitColorValue(100, 100, 100);
jmitc91516 1:a5258871b33d 7086 GuiConst_INTCOLOR graphColour2 = SixteenBitColorValue(200, 200, 200);
jmitc91516 1:a5258871b33d 7087 float runTime;
jmitc91516 1:a5258871b33d 7088 GetRunTime(&runTime);
jmitc91516 1:a5258871b33d 7089 double colourBoundaryX = (double) runTime;
jmitc91516 1:a5258871b33d 7090 // columnTempProfilePageGraphCompleteProfileDataSet->DrawUsingGuiLibVLine(170, 335, ((double) 500 / (double) (maxX / 10)), ((double) -250 / (double) maxY), graphColour1, graphColour2, colourBoundaryX);
jmitc91516 1:a5258871b33d 7091 // Surely...
jmitc91516 1:a5258871b33d 7092 runningColumnPageGraphCompleteProfileDataSet->DrawUsingGuiLibVLine(170, 335, ((double) 500 / (double) (maxX / 10)), ((double) -250 / (double) maxY), graphColour1, graphColour2, colourBoundaryX);
jmitc91516 1:a5258871b33d 7093 // &&&&
jmitc91516 1:a5258871b33d 7094 #endif // TEST_GUILIB_VLINE_PROFILES
jmitc91516 1:a5258871b33d 7095
jmitc91516 1:a5258871b33d 7096 // Does this solve 'pause before graph displayed' problem with double buffering?
jmitc91516 1:a5258871b33d 7097 if(mustUpdateDisplay) {
jmitc91516 1:a5258871b33d 7098 GuiLib_Refresh();
jmitc91516 1:a5258871b33d 7099 }
jmitc91516 1:a5258871b33d 7100 // Answer - yes it does - although there is still a (just noticeable) pause
jmitc91516 1:a5258871b33d 7101 // (without double buffering, we do not need the above 'if' -
jmitc91516 1:a5258871b33d 7102 // the graph gets redisplayed without it)
jmitc91516 1:a5258871b33d 7103 }
jmitc91516 1:a5258871b33d 7104
jmitc91516 1:a5258871b33d 7105 /*
jmitc91516 1:a5258871b33d 7106 Displays the data on the 'running detector' page.
jmitc91516 1:a5258871b33d 7107
jmitc91516 1:a5258871b33d 7108 Args: a boolean specifying whether or not the display is actually to be updated.
jmitc91516 1:a5258871b33d 7109 Even if it is false when we are called, we may set it true if we discover
jmitc91516 1:a5258871b33d 7110 one or more data items has changed - but note that we will not set it false
jmitc91516 1:a5258871b33d 7111 if it is already true. If it is true after we have looked at all
jmitc91516 1:a5258871b33d 7112 the data to be displayed, we will then update the display. (If we are called
jmitc91516 1:a5258871b33d 7113 with this value set to false, the caller is effectively saying
jmitc91516 1:a5258871b33d 7114 'display the running settings page data only if it has changed').
jmitc91516 1:a5258871b33d 7115
jmitc91516 1:a5258871b33d 7116 No return code.
jmitc91516 1:a5258871b33d 7117 */
jmitc91516 1:a5258871b33d 7118 void GetGCStatusLoop::DisplayRunningDetectorPageData(bool mustUpdateDisplay)
jmitc91516 1:a5258871b33d 7119 {
jmitc91516 1:a5258871b33d 7120 char buff[40];
jmitc91516 1:a5258871b33d 7121
jmitc91516 1:a5258871b33d 7122 GetDetectorType(buff, false, false);
jmitc91516 1:a5258871b33d 7123 if(strcmp(buff, GuiVar_detectorType2) != 0) {
jmitc91516 1:a5258871b33d 7124 mustUpdateDisplay = true;
jmitc91516 1:a5258871b33d 7125
jmitc91516 1:a5258871b33d 7126 strcpy(GuiVar_detectorType2, buff);
jmitc91516 1:a5258871b33d 7127 }
jmitc91516 1:a5258871b33d 7128
jmitc91516 1:a5258871b33d 7129 // if(detectorType != FPD_DETECTOR) {
jmitc91516 1:a5258871b33d 7130 GetDetectorRange(buff);
jmitc91516 1:a5258871b33d 7131 if(strcmp(buff, GuiVar_detectorRange) != 0) {
jmitc91516 1:a5258871b33d 7132 mustUpdateDisplay = true;
jmitc91516 1:a5258871b33d 7133
jmitc91516 1:a5258871b33d 7134 strcpy(GuiVar_detectorRange, buff);
jmitc91516 1:a5258871b33d 7135 }
jmitc91516 1:a5258871b33d 7136 // FPD detector has a different GC command for range - see below
jmitc91516 1:a5258871b33d 7137 // }
jmitc91516 1:a5258871b33d 7138
jmitc91516 1:a5258871b33d 7139 GetFuelFlowRate(buff);
jmitc91516 1:a5258871b33d 7140 if(strcmp(buff, GuiVar_detectorFuelFlowRate) != 0) {
jmitc91516 1:a5258871b33d 7141 mustUpdateDisplay = true;
jmitc91516 1:a5258871b33d 7142
jmitc91516 1:a5258871b33d 7143 strcpy(GuiVar_detectorFuelFlowRate, buff);
jmitc91516 1:a5258871b33d 7144 }
jmitc91516 1:a5258871b33d 7145
jmitc91516 1:a5258871b33d 7146 GetDetectorTemperature(buff);
jmitc91516 1:a5258871b33d 7147 if(strcmp(buff, GuiVar_detectorTemperature) != 0) {
jmitc91516 1:a5258871b33d 7148 strcpy(GuiVar_detectorTemperature, buff);
jmitc91516 1:a5258871b33d 7149
jmitc91516 1:a5258871b33d 7150 mustUpdateDisplay = true;
jmitc91516 1:a5258871b33d 7151 }
jmitc91516 1:a5258871b33d 7152
jmitc91516 6:dba3fbdfd5da 7153 GetDetectorTargetTemperature(buff, stringFormatdegCUnits);
jmitc91516 1:a5258871b33d 7154 if(strcmp(buff, GuiVar_detectorTargetTemperature2) != 0) {
jmitc91516 1:a5258871b33d 7155 strcpy(GuiVar_detectorTargetTemperature2, buff);
jmitc91516 1:a5258871b33d 7156
jmitc91516 1:a5258871b33d 7157 mustUpdateDisplay = true;
jmitc91516 1:a5258871b33d 7158 }
jmitc91516 1:a5258871b33d 7159
jmitc91516 1:a5258871b33d 7160 // *** 14 MarWhy is this code commented out?? ***
jmitc91516 1:a5258871b33d 7161 /*
jmitc91516 1:a5258871b33d 7162 if(detectorType == TCD_DETECTOR) {
jmitc91516 1:a5258871b33d 7163
jmitc91516 1:a5258871b33d 7164 GetTCDDetectorFilamentTemperature(buff);
jmitc91516 1:a5258871b33d 7165 if(strcmp(buff, GuiVar_tcdDetectorFilamentTemperature) != 0) {
jmitc91516 1:a5258871b33d 7166 mustUpdateDisplay = true;
jmitc91516 1:a5258871b33d 7167
jmitc91516 1:a5258871b33d 7168 strcpy(GuiVar_tcdDetectorFilamentTemperature, buff);
jmitc91516 1:a5258871b33d 7169 }
jmitc91516 1:a5258871b33d 7170
jmitc91516 1:a5258871b33d 7171 GetTCDDetectorFilamentPolarity(buff);
jmitc91516 1:a5258871b33d 7172 if(strcmp(buff, GuiVar_tcdDetectorFilamentPolarity) != 0) {
jmitc91516 1:a5258871b33d 7173 mustUpdateDisplay = true;
jmitc91516 1:a5258871b33d 7174
jmitc91516 1:a5258871b33d 7175 strcpy(GuiVar_tcdDetectorFilamentPolarity, buff);
jmitc91516 1:a5258871b33d 7176 }
jmitc91516 1:a5258871b33d 7177
jmitc91516 1:a5258871b33d 7178 } else if(detectorType == ECD_DETECTOR) {
jmitc91516 1:a5258871b33d 7179
jmitc91516 1:a5258871b33d 7180 GetECDDetectorCurrent(buff);
jmitc91516 1:a5258871b33d 7181 if(strcmp(buff, GuiVar_ecdDetectorCurrent) != 0) {
jmitc91516 1:a5258871b33d 7182 mustUpdateDisplay = true;
jmitc91516 1:a5258871b33d 7183
jmitc91516 1:a5258871b33d 7184 strcpy(GuiVar_ecdDetectorCurrent, buff);
jmitc91516 1:a5258871b33d 7185 }
jmitc91516 1:a5258871b33d 7186
jmitc91516 1:a5258871b33d 7187 } else if(detectorType == FPD_DETECTOR) {
jmitc91516 1:a5258871b33d 7188
jmitc91516 1:a5258871b33d 7189 GetFPDDetectorRange(buff);
jmitc91516 1:a5258871b33d 7190 if(strcmp(buff, GuiVar_fpdDetectorRange) != 0) {
jmitc91516 1:a5258871b33d 7191 mustUpdateDisplay = true;
jmitc91516 1:a5258871b33d 7192
jmitc91516 1:a5258871b33d 7193 strcpy(GuiVar_fpdDetectorRange, buff);
jmitc91516 1:a5258871b33d 7194 }
jmitc91516 1:a5258871b33d 7195
jmitc91516 1:a5258871b33d 7196 GetFPDDetectorSensitivity(buff);
jmitc91516 1:a5258871b33d 7197 if(strcmp(buff, GuiVar_fpdDetectorSensitivity) != 0) {
jmitc91516 1:a5258871b33d 7198 mustUpdateDisplay = true;
jmitc91516 1:a5258871b33d 7199
jmitc91516 1:a5258871b33d 7200 strcpy(GuiVar_fpdDetectorSensitivity, buff);
jmitc91516 1:a5258871b33d 7201 }
jmitc91516 1:a5258871b33d 7202
jmitc91516 1:a5258871b33d 7203 } else {
jmitc91516 1:a5258871b33d 7204
jmitc91516 1:a5258871b33d 7205 GetDetectorTemperature(buff);
jmitc91516 1:a5258871b33d 7206 if(strcmp(buff, GuiVar_detectorTemperature) != 0) {
jmitc91516 1:a5258871b33d 7207 mustUpdateDisplay = true;
jmitc91516 1:a5258871b33d 7208
jmitc91516 1:a5258871b33d 7209 strcpy(GuiVar_detectorTemperature, buff);
jmitc91516 1:a5258871b33d 7210 }
jmitc91516 1:a5258871b33d 7211 }
jmitc91516 1:a5258871b33d 7212 */
jmitc91516 1:a5258871b33d 7213
jmitc91516 1:a5258871b33d 7214 if(mustUpdateDisplay) {
jmitc91516 1:a5258871b33d 7215
jmitc91516 1:a5258871b33d 7216 // Makes the display flicker - but omitting it means old text is not cleared from the display
jmitc91516 1:a5258871b33d 7217 #ifdef USING_BACKGROUND_BITMAP
jmitc91516 1:a5258871b33d 7218 DrawBackgroundBitmap();
jmitc91516 1:a5258871b33d 7219 #else
jmitc91516 1:a5258871b33d 7220 GuiLib_Clear();
jmitc91516 1:a5258871b33d 7221 #endif
jmitc91516 1:a5258871b33d 7222
jmitc91516 1:a5258871b33d 7223 GuiLib_ShowScreen(GuiStruct_RunningDetectorPage_27, GuiLib_NO_CURSOR, GuiLib_RESET_AUTO_REDRAW);
jmitc91516 1:a5258871b33d 7224
jmitc91516 1:a5258871b33d 7225 GuiLib_Refresh();
jmitc91516 1:a5258871b33d 7226
jmitc91516 1:a5258871b33d 7227 }
jmitc91516 1:a5258871b33d 7228 }
jmitc91516 1:a5258871b33d 7229
jmitc91516 1:a5258871b33d 7230 /*
jmitc91516 1:a5258871b33d 7231 Displays the data on the 'running injector' page.
jmitc91516 1:a5258871b33d 7232
jmitc91516 1:a5258871b33d 7233 Args: a boolean specifying whether or not the display is actually to be updated.
jmitc91516 1:a5258871b33d 7234 Even if it is false when we are called, we may set it true if we discover
jmitc91516 1:a5258871b33d 7235 one or more data items has changed - but note that we will not set it false
jmitc91516 1:a5258871b33d 7236 if it is already true. If it is true after we have looked at all
jmitc91516 1:a5258871b33d 7237 the home page data, we will then update the display. (If we are called
jmitc91516 1:a5258871b33d 7238 with this value set to false, the caller is effectively saying
jmitc91516 1:a5258871b33d 7239 'display the running settings page data only if it has changed').
jmitc91516 1:a5258871b33d 7240
jmitc91516 1:a5258871b33d 7241 No return code.
jmitc91516 1:a5258871b33d 7242 */
jmitc91516 1:a5258871b33d 7243 void GetGCStatusLoop::DisplayRunningInjectorPageData(bool mustUpdateDisplay)
jmitc91516 1:a5258871b33d 7244 {
jmitc91516 1:a5258871b33d 7245 char buff[40];
jmitc91516 1:a5258871b33d 7246
jmitc91516 1:a5258871b33d 7247 GetInjectorTemperature(buff, false);
jmitc91516 1:a5258871b33d 7248 if(strcmp(buff, GuiVar_injectorTemperature) != 0) {
jmitc91516 1:a5258871b33d 7249 strcpy(GuiVar_injectorTemperature, buff);
jmitc91516 1:a5258871b33d 7250 mustUpdateDisplay = true;
jmitc91516 1:a5258871b33d 7251 }
jmitc91516 1:a5258871b33d 7252
jmitc91516 1:a5258871b33d 7253 GetInjectionMode(buff);
jmitc91516 1:a5258871b33d 7254 if(strcmp(buff, GuiVar_injectionMode2) != 0) {
jmitc91516 1:a5258871b33d 7255 strcpy(GuiVar_injectionMode2, buff);
jmitc91516 1:a5258871b33d 7256 mustUpdateDisplay = true;
jmitc91516 1:a5258871b33d 7257 }
jmitc91516 1:a5258871b33d 7258
jmitc91516 1:a5258871b33d 7259 GetInjectorType(buff, false);
jmitc91516 1:a5258871b33d 7260 if(strcmp(buff, GuiVar_injectorType) != 0) {
jmitc91516 1:a5258871b33d 7261 strcpy(GuiVar_injectorType, buff);
jmitc91516 1:a5258871b33d 7262 mustUpdateDisplay = true;
jmitc91516 1:a5258871b33d 7263 }
jmitc91516 1:a5258871b33d 7264
jmitc91516 1:a5258871b33d 7265 GetComponentStatusString(INJECTOR, buff);
jmitc91516 1:a5258871b33d 7266 if(strcmp(buff, GuiVar_injectorStatus) != 0) {
jmitc91516 1:a5258871b33d 7267 strcpy(GuiVar_injectorStatus, buff);
jmitc91516 1:a5258871b33d 7268 mustUpdateDisplay = true;
jmitc91516 1:a5258871b33d 7269 }
jmitc91516 1:a5258871b33d 7270
jmitc91516 1:a5258871b33d 7271 GetInjectorSplitTime(buff);
jmitc91516 1:a5258871b33d 7272 if(strcmp(buff, GuiVar_injectorSplitTime) != 0) {
jmitc91516 1:a5258871b33d 7273 strcpy(GuiVar_injectorSplitTime, buff);
jmitc91516 1:a5258871b33d 7274 mustUpdateDisplay = true;
jmitc91516 1:a5258871b33d 7275 }
jmitc91516 1:a5258871b33d 7276
jmitc91516 1:a5258871b33d 7277 GetSplitFlow(buff);
jmitc91516 1:a5258871b33d 7278 if(strcmp(buff, GuiVar_injectorSplitFlowRate) != 0) {
jmitc91516 1:a5258871b33d 7279 strcpy(GuiVar_injectorSplitFlowRate, buff);
jmitc91516 1:a5258871b33d 7280 mustUpdateDisplay = true;
jmitc91516 1:a5258871b33d 7281 }
jmitc91516 1:a5258871b33d 7282
jmitc91516 1:a5258871b33d 7283 GetSplitRatio(buff);
jmitc91516 1:a5258871b33d 7284 if(strcmp(buff, GuiVar_injectorSplitRatio) != 0) {
jmitc91516 1:a5258871b33d 7285 strcpy(GuiVar_injectorSplitRatio, buff);
jmitc91516 1:a5258871b33d 7286 mustUpdateDisplay = true;
jmitc91516 1:a5258871b33d 7287 }
jmitc91516 1:a5258871b33d 7288
jmitc91516 1:a5258871b33d 7289 if(mustUpdateDisplay) {
jmitc91516 1:a5258871b33d 7290
jmitc91516 1:a5258871b33d 7291 // Makes the display flicker - but omitting it means old text is not cleared from the display
jmitc91516 1:a5258871b33d 7292 #ifdef USING_BACKGROUND_BITMAP
jmitc91516 1:a5258871b33d 7293 DrawBackgroundBitmap();
jmitc91516 1:a5258871b33d 7294 #else
jmitc91516 1:a5258871b33d 7295 GuiLib_Clear();
jmitc91516 1:a5258871b33d 7296 #endif
jmitc91516 1:a5258871b33d 7297
jmitc91516 1:a5258871b33d 7298 GuiLib_ShowScreen(GuiStruct_RunningInjectorPage_26, GuiLib_NO_CURSOR, GuiLib_RESET_AUTO_REDRAW);
jmitc91516 1:a5258871b33d 7299
jmitc91516 1:a5258871b33d 7300 GuiLib_Refresh();
jmitc91516 1:a5258871b33d 7301
jmitc91516 1:a5258871b33d 7302 }
jmitc91516 1:a5258871b33d 7303 }
jmitc91516 1:a5258871b33d 7304
jmitc91516 1:a5258871b33d 7305 /*
jmitc91516 1:a5258871b33d 7306 Displays the data on the 'running gas' page.
jmitc91516 1:a5258871b33d 7307
jmitc91516 1:a5258871b33d 7308 Args: a boolean specifying whether or not the display is actually to be updated.
jmitc91516 1:a5258871b33d 7309 Even if it is false when we are called, we may set it true if we discover
jmitc91516 1:a5258871b33d 7310 one or more data items has changed - but note that we will not set it false
jmitc91516 1:a5258871b33d 7311 if it is already true. If it is true after we have looked at all
jmitc91516 1:a5258871b33d 7312 the home page data, we will then update the display. (If we are called
jmitc91516 1:a5258871b33d 7313 with this value set to false, the caller is effectively saying
jmitc91516 1:a5258871b33d 7314 'display the running settings page data only if it has changed').
jmitc91516 1:a5258871b33d 7315
jmitc91516 1:a5258871b33d 7316 No return code.
jmitc91516 1:a5258871b33d 7317 */
jmitc91516 1:a5258871b33d 7318 void GetGCStatusLoop::DisplayRunningGasPageData(bool mustUpdateDisplay, bool runHasCompleted)
jmitc91516 1:a5258871b33d 7319 {
jmitc91516 1:a5258871b33d 7320 // This page consists principally of an easyGUI graph, to which we assign several datasets:
jmitc91516 1:a5258871b33d 7321 //
jmitc91516 1:a5258871b33d 7322 // - dataset 0 is a line representing the flow profile of the run from 'now' to the finish
jmitc91516 1:a5258871b33d 7323 // - dataset 1 is a bar chart representing the flow profile of the run from 'now' to the finish
jmitc91516 1:a5258871b33d 7324 // - dataset 2 is a line representing the flow profile from the start to 'now'
jmitc91516 1:a5258871b33d 7325 // - dataset 3 is a bar chart representing the flow profile from the start to 'now'
jmitc91516 1:a5258871b33d 7326 // - dataset 4 is a single dot at the current time and flow rate
jmitc91516 1:a5258871b33d 7327
jmitc91516 1:a5258871b33d 7328 if(GCIsRunning() || runHasCompleted) {
jmitc91516 1:a5258871b33d 7329
jmitc91516 1:a5258871b33d 7330 // SetupRunningGasPageGraphPartialDataSetsToMatchCurrentRunTime
jmitc91516 1:a5258871b33d 7331 // returns true if it has updated the datasets, false otherwise
jmitc91516 1:a5258871b33d 7332 if(SetupRunningGasPageGraphPartialDataSetsToMatchCurrentRunTime(runHasCompleted)) {
jmitc91516 1:a5258871b33d 7333 mustUpdateDisplay = true;
jmitc91516 1:a5258871b33d 7334 }
jmitc91516 1:a5258871b33d 7335 }
jmitc91516 1:a5258871b33d 7336
jmitc91516 1:a5258871b33d 7337 char buff[40];
jmitc91516 1:a5258871b33d 7338 GetCurrentGasPressure(buff, false, true);
jmitc91516 1:a5258871b33d 7339 if(strcmp(buff, GuiVar_gasPressureWhileRunning) != 0) {
jmitc91516 1:a5258871b33d 7340 strcpy(GuiVar_gasPressureWhileRunning, buff);
jmitc91516 1:a5258871b33d 7341 mustUpdateDisplay = true;
jmitc91516 1:a5258871b33d 7342 }
jmitc91516 1:a5258871b33d 7343
jmitc91516 1:a5258871b33d 7344 // Do this *before* updating the datasets, not after - otherwise we don't see the data at all
jmitc91516 1:a5258871b33d 7345 if(mustUpdateDisplay) {
jmitc91516 1:a5258871b33d 7346
jmitc91516 1:a5258871b33d 7347 #ifdef USING_DATASET_4
jmitc91516 1:a5258871b33d 7348 // Makes the display flicker - but omitting it means old text is not cleared from the display
jmitc91516 1:a5258871b33d 7349 #ifdef USING_BACKGROUND_BITMAP
jmitc91516 1:a5258871b33d 7350 DrawBackgroundBitmap();
jmitc91516 1:a5258871b33d 7351 #else
jmitc91516 1:a5258871b33d 7352 GuiLib_Clear();
jmitc91516 1:a5258871b33d 7353 #endif
jmitc91516 1:a5258871b33d 7354 // But the text does not change - so why do we need this?
jmitc91516 1:a5258871b33d 7355 // Answer - because otherwise the 'dot at current time' (dataset 4) does not get erased when we draw the next one
jmitc91516 1:a5258871b33d 7356 #else
jmitc91516 1:a5258871b33d 7357 // We are not erasing the background, to minimise flickering of the graph.
jmitc91516 1:a5258871b33d 7358 // Therefore, must manually erase background of 'gas pressure while running' variable
jmitc91516 1:a5258871b33d 7359 GuiLib_FillBox(400, 45, 550, 75, 0xFFFF); // White background
jmitc91516 1:a5258871b33d 7360 #endif // USING_DATASET_4 - if we are not displaying dataset 4, we do not need to erase the graph - all its other datapoints will get overwritten anyway
jmitc91516 1:a5258871b33d 7361
jmitc91516 1:a5258871b33d 7362 GuiLib_ShowScreen(GuiStruct_RunningGasPage_28, GuiLib_NO_CURSOR, GuiLib_RESET_AUTO_REDRAW);
jmitc91516 1:a5258871b33d 7363
jmitc91516 1:a5258871b33d 7364 GuiLib_Refresh();
jmitc91516 1:a5258871b33d 7365 }
jmitc91516 1:a5258871b33d 7366
jmitc91516 1:a5258871b33d 7367 TimeUnit timeUnit = MINUTES;
jmitc91516 1:a5258871b33d 7368 if(runningGasPageGraphCompleteProfileDataSet->GetTotalMethodTime() < methodTimeUnitsThreshold) {
jmitc91516 1:a5258871b33d 7369 timeUnit = SECONDS;
jmitc91516 1:a5258871b33d 7370 }
jmitc91516 1:a5258871b33d 7371
jmitc91516 1:a5258871b33d 7372
jmitc91516 1:a5258871b33d 7373 const float yAxisScaleFactor = 10.0f;
jmitc91516 1:a5258871b33d 7374
jmitc91516 1:a5258871b33d 7375 // Dataset 0
jmitc91516 1:a5258871b33d 7376 runningGasPageGraph->SetDataForGraphDataSetInTenthsOfMinutes(0, yAxisScaleFactor, runningGasPageGraphDataSet0);
jmitc91516 1:a5258871b33d 7377
jmitc91516 1:a5258871b33d 7378 // Dataset 1
jmitc91516 1:a5258871b33d 7379 runningGasPageGraph->SetDataForGraphDataSetInTenthsOfMinutes(1, yAxisScaleFactor, runningGasPageGraphDataSet1);
jmitc91516 1:a5258871b33d 7380
jmitc91516 1:a5258871b33d 7381 // Dataset 2
jmitc91516 1:a5258871b33d 7382 runningGasPageGraph->SetDataForGraphDataSetInTenthsOfMinutes(2, yAxisScaleFactor, runningGasPageGraphDataSet2);
jmitc91516 1:a5258871b33d 7383
jmitc91516 1:a5258871b33d 7384 // Dataset 3
jmitc91516 1:a5258871b33d 7385 runningGasPageGraph->SetDataForGraphDataSetInTenthsOfMinutes(3, yAxisScaleFactor, runningGasPageGraphDataSet3);
jmitc91516 1:a5258871b33d 7386
jmitc91516 1:a5258871b33d 7387 #ifdef USING_DATASET_4
jmitc91516 1:a5258871b33d 7388 // Dataset 4
jmitc91516 1:a5258871b33d 7389 runningGasPageGraph->SetDataForGraphDataSetInTenthsOfMinutes(4, yAxisScaleFactor, runningGasPageGraphDataSet4);
jmitc91516 1:a5258871b33d 7390 #endif // USING_DATASET_4
jmitc91516 1:a5258871b33d 7391
jmitc91516 1:a5258871b33d 7392 runningGasPageGraph->SetXAxisUnits(timeUnit);
jmitc91516 1:a5258871b33d 7393
jmitc91516 1:a5258871b33d 7394
jmitc91516 1:a5258871b33d 7395 // The tick sizes must match those set in easyGUI - we do not seem
jmitc91516 1:a5258871b33d 7396 // to be able to get them at runtime
jmitc91516 1:a5258871b33d 7397 GuiConst_INT32S minX, maxX;
jmitc91516 1:a5258871b33d 7398 //GuiConst_INT32S tickSize = (timeUnit == SECONDS) ? 300 : 100;
jmitc91516 1:a5258871b33d 7399 // Always in 1/10 minutes
jmitc91516 1:a5258871b33d 7400 GuiConst_INT32S xAxisTickSize = (timeUnit == SECONDS) ? 5 : 100; // 5 == 0.5 minutes (i.e. 30 seconds), 100 == 10 minutes
jmitc91516 1:a5258871b33d 7401 runningGasPageGraphCompleteProfileDataSet->GetXAxisRangeInTenthsOfMinutes(&minX, &maxX, xAxisTickSize );
jmitc91516 1:a5258871b33d 7402 runningGasPageGraph->SetXAxisRange(0, maxX); // Always start X axis at zero
jmitc91516 1:a5258871b33d 7403
jmitc91516 1:a5258871b33d 7404 GuiConst_INT32S minY, maxY;
jmitc91516 1:a5258871b33d 7405 GuiConst_INT32S yAxisTickSize = 10;
jmitc91516 1:a5258871b33d 7406 runningGasPageGraphCompleteProfileDataSet->GetYAxisRange(&minY, &maxY, yAxisTickSize);
jmitc91516 1:a5258871b33d 7407 runningGasPageGraph->SetYAxisRange(0, (maxY * yAxisScaleFactor)); // Always start Y axis at zero
jmitc91516 1:a5258871b33d 7408
jmitc91516 1:a5258871b33d 7409
jmitc91516 1:a5258871b33d 7410 runningGasPageGraph->DrawAxes();
jmitc91516 1:a5258871b33d 7411
jmitc91516 1:a5258871b33d 7412 // We need to draw the X axis labels ourselves, since our time values are in units of 0.1 minute,
jmitc91516 1:a5258871b33d 7413 // but easyGUI graphs work only in integers - we therefore have to multiply the time values by 10
jmitc91516 1:a5258871b33d 7414 // before passing them to easyGUI, and if we let easyGUI draw its own values on the X axis,
jmitc91516 1:a5258871b33d 7415 // they would be 10 times the correct values.
jmitc91516 1:a5258871b33d 7416 // Graph coordinates copied from easyGUI - I cannot find a way of obtaining them at runtime.
jmitc91516 1:a5258871b33d 7417 if(timeUnit == SECONDS) {
jmitc91516 1:a5258871b33d 7418 runningGasPageGraph->DrawXAxisLabels(0, (maxX * 6), (xAxisTickSize * 6), 160, 335, 500);
jmitc91516 1:a5258871b33d 7419 } else {
jmitc91516 1:a5258871b33d 7420 runningGasPageGraph->DrawXAxisLabels(0, (maxX / 10), (xAxisTickSize / 10), 160, 335, 500);
jmitc91516 1:a5258871b33d 7421 }
jmitc91516 1:a5258871b33d 7422
jmitc91516 1:a5258871b33d 7423 // Similar to the X axis - the values we pass to the easyGUI graph are scaled to be larger
jmitc91516 1:a5258871b33d 7424 // than the real values, to get round the fact that easyGUI graphs work in integers.
jmitc91516 1:a5258871b33d 7425 // (This can cause the profile to appear to be 'stepped', which obviously we do not want.)
jmitc91516 1:a5258871b33d 7426 // We must therefore draw the Y axis values ourselves.
jmitc91516 1:a5258871b33d 7427 runningGasPageGraph->DrawYAxisLabels(0, maxY, yAxisTickSize, 160, 335, 250);
jmitc91516 1:a5258871b33d 7428
jmitc91516 1:a5258871b33d 7429 runningGasPageGraph->DrawDataSet(0);
jmitc91516 1:a5258871b33d 7430 runningGasPageGraph->ShowDataSet(0);
jmitc91516 1:a5258871b33d 7431
jmitc91516 1:a5258871b33d 7432 runningGasPageGraph->DrawDataSet(1);
jmitc91516 1:a5258871b33d 7433 runningGasPageGraph->ShowDataSet(1);
jmitc91516 1:a5258871b33d 7434
jmitc91516 1:a5258871b33d 7435 runningGasPageGraph->DrawDataSet(2);
jmitc91516 1:a5258871b33d 7436 runningGasPageGraph->ShowDataSet(2);
jmitc91516 1:a5258871b33d 7437
jmitc91516 1:a5258871b33d 7438 runningGasPageGraph->DrawDataSet(3);
jmitc91516 1:a5258871b33d 7439 runningGasPageGraph->ShowDataSet(3);
jmitc91516 1:a5258871b33d 7440
jmitc91516 1:a5258871b33d 7441 #ifdef USING_DATASET_4
jmitc91516 1:a5258871b33d 7442 runningGasPageGraph->DrawDataSet(4);
jmitc91516 1:a5258871b33d 7443 runningGasPageGraph->ShowDataSet(4);
jmitc91516 1:a5258871b33d 7444 #endif // USING_DATASET_4
jmitc91516 1:a5258871b33d 7445
jmitc91516 1:a5258871b33d 7446 runningGasPageGraph->Redraw(); // this only redraws the axes,etc - not the graph data
jmitc91516 1:a5258871b33d 7447
jmitc91516 1:a5258871b33d 7448 // Does this solve 'pause before graph displayed' problem with double buffering?
jmitc91516 1:a5258871b33d 7449 if(mustUpdateDisplay) {
jmitc91516 1:a5258871b33d 7450 GuiLib_Refresh();
jmitc91516 1:a5258871b33d 7451 }
jmitc91516 1:a5258871b33d 7452 // Answer - yes it does - although there is still a (just noticeable) pause
jmitc91516 1:a5258871b33d 7453 // (without double buffering, we do not need the above 'if' -
jmitc91516 1:a5258871b33d 7454 // the graph gets redisplayed without it)
jmitc91516 1:a5258871b33d 7455 }
jmitc91516 1:a5258871b33d 7456
jmitc91516 1:a5258871b33d 7457 /*
jmitc91516 1:a5258871b33d 7458 Displays the data on the 'running gas' page.
jmitc91516 1:a5258871b33d 7459
jmitc91516 1:a5258871b33d 7460 Args: a boolean specifying whether or not the display is actually to be updated.
jmitc91516 1:a5258871b33d 7461 Even if it is false when we are called, we may set it true if we discover
jmitc91516 1:a5258871b33d 7462 one or more data items has changed - but note that we will not set it false
jmitc91516 1:a5258871b33d 7463 if it is already true. If it is true after we have looked at all
jmitc91516 1:a5258871b33d 7464 the home page data, we will then update the display. (If we are called
jmitc91516 1:a5258871b33d 7465 with this value set to false, the caller is effectively saying
jmitc91516 1:a5258871b33d 7466 'display the running settings page data only if it has changed').
jmitc91516 1:a5258871b33d 7467
jmitc91516 1:a5258871b33d 7468 No return code.
jmitc91516 1:a5258871b33d 7469 */
jmitc91516 1:a5258871b33d 7470 void GetGCStatusLoop::DisplayRunningInjectorProfilePageData(bool mustUpdateDisplay, bool runHasCompleted)
jmitc91516 1:a5258871b33d 7471 {
jmitc91516 1:a5258871b33d 7472 // This page consists principally of an easyGUI graph, to which we assign several datasets:
jmitc91516 1:a5258871b33d 7473 //
jmitc91516 1:a5258871b33d 7474 // - dataset 0 is a line representing the injector temperature profile of the run from 'now' to the finish
jmitc91516 1:a5258871b33d 7475 // - dataset 1 is a bar chart representing the injector temperature profile of the run from 'now' to the finish
jmitc91516 1:a5258871b33d 7476 // - dataset 2 is a line representing the injector temperature profile from the start to 'now'
jmitc91516 1:a5258871b33d 7477 // - dataset 3 is a bar chart representing the injector temperature profile from the start to 'now'
jmitc91516 1:a5258871b33d 7478 // - dataset 4 is a single dot at the current time and injector temperature
jmitc91516 1:a5258871b33d 7479
jmitc91516 1:a5258871b33d 7480 if(GCIsRunning() || runHasCompleted) {
jmitc91516 1:a5258871b33d 7481
jmitc91516 1:a5258871b33d 7482 // SetupRunningInjectorPageGraphPartialDataSetsToMatchCurrentRunTime
jmitc91516 1:a5258871b33d 7483 // returns true if it has updated the datasets, false otherwise
jmitc91516 1:a5258871b33d 7484 if(SetupRunningInjectorPageGraphPartialDataSetsToMatchCurrentRunTime(runHasCompleted)) {
jmitc91516 1:a5258871b33d 7485 mustUpdateDisplay = true;
jmitc91516 1:a5258871b33d 7486 }
jmitc91516 1:a5258871b33d 7487 }
jmitc91516 1:a5258871b33d 7488
jmitc91516 1:a5258871b33d 7489 char buff[40];
jmitc91516 1:a5258871b33d 7490 GetInjectorTemperature(buff, false);
jmitc91516 1:a5258871b33d 7491 if(strcmp(buff, GuiVar_injectorTemperatureWhileRunning) != 0) {
jmitc91516 1:a5258871b33d 7492 strcpy(GuiVar_injectorTemperatureWhileRunning, buff);
jmitc91516 1:a5258871b33d 7493 mustUpdateDisplay = true;
jmitc91516 1:a5258871b33d 7494 }
jmitc91516 1:a5258871b33d 7495
jmitc91516 1:a5258871b33d 7496 // Do this *before* updating the datasets, not after - otherwise we don't see the data at all
jmitc91516 1:a5258871b33d 7497 if(mustUpdateDisplay) {
jmitc91516 1:a5258871b33d 7498
jmitc91516 1:a5258871b33d 7499 #ifdef USING_DATASET_4
jmitc91516 1:a5258871b33d 7500 // Makes the display flicker - but omitting it means old text is not cleared from the display
jmitc91516 1:a5258871b33d 7501 #ifdef USING_BACKGROUND_BITMAP
jmitc91516 1:a5258871b33d 7502 DrawBackgroundBitmap();
jmitc91516 1:a5258871b33d 7503 #else
jmitc91516 1:a5258871b33d 7504 GuiLib_Clear();
jmitc91516 1:a5258871b33d 7505 #endif
jmitc91516 1:a5258871b33d 7506 // But the text does not change - so why do we need this?
jmitc91516 1:a5258871b33d 7507 // Answer - because otherwise the 'dot at current time' (dataset 4) does not get erased when we draw the next one
jmitc91516 1:a5258871b33d 7508 #else
jmitc91516 1:a5258871b33d 7509 // We are not erasing the background, to minimise flickering of the graph.
jmitc91516 1:a5258871b33d 7510 // Therefore, must manually erase background of 'injector temperature while running' variable
jmitc91516 1:a5258871b33d 7511 GuiLib_FillBox(400, 45, 550, 75, 0xFFFF); // White background
jmitc91516 1:a5258871b33d 7512 #endif // USING_DATASET_4 - if we are not displaying dataset 4, we do not need to erase the graph - all its other datapoints will get overwritten anyway
jmitc91516 1:a5258871b33d 7513
jmitc91516 1:a5258871b33d 7514 GuiLib_ShowScreen(GuiStruct_RunningInjectorProfilePage_Def, GuiLib_NO_CURSOR, GuiLib_RESET_AUTO_REDRAW);
jmitc91516 1:a5258871b33d 7515
jmitc91516 1:a5258871b33d 7516 GuiLib_Refresh();
jmitc91516 1:a5258871b33d 7517 }
jmitc91516 1:a5258871b33d 7518
jmitc91516 1:a5258871b33d 7519 TimeUnit timeUnit = MINUTES;
jmitc91516 1:a5258871b33d 7520 if(runningInjectorPageGraphCompleteProfileDataSet->GetTotalMethodTime() < methodTimeUnitsThreshold) {
jmitc91516 1:a5258871b33d 7521 timeUnit = SECONDS;
jmitc91516 1:a5258871b33d 7522 }
jmitc91516 1:a5258871b33d 7523
jmitc91516 1:a5258871b33d 7524
jmitc91516 1:a5258871b33d 7525 const float yAxisScaleFactor = 10.0f;
jmitc91516 1:a5258871b33d 7526
jmitc91516 1:a5258871b33d 7527 // Dataset 0
jmitc91516 1:a5258871b33d 7528 runningInjectorPageGraph->SetDataForGraphDataSetInTenthsOfMinutes(0, yAxisScaleFactor, runningInjectorPageGraphDataSet0);
jmitc91516 1:a5258871b33d 7529
jmitc91516 1:a5258871b33d 7530 // Dataset 1
jmitc91516 1:a5258871b33d 7531 runningInjectorPageGraph->SetDataForGraphDataSetInTenthsOfMinutes(1, yAxisScaleFactor, runningInjectorPageGraphDataSet1);
jmitc91516 1:a5258871b33d 7532
jmitc91516 1:a5258871b33d 7533 // Dataset 2
jmitc91516 1:a5258871b33d 7534 runningInjectorPageGraph->SetDataForGraphDataSetInTenthsOfMinutes(2, yAxisScaleFactor, runningInjectorPageGraphDataSet2);
jmitc91516 1:a5258871b33d 7535
jmitc91516 1:a5258871b33d 7536 // Dataset 3
jmitc91516 1:a5258871b33d 7537 runningInjectorPageGraph->SetDataForGraphDataSetInTenthsOfMinutes(3, yAxisScaleFactor, runningInjectorPageGraphDataSet3);
jmitc91516 1:a5258871b33d 7538
jmitc91516 1:a5258871b33d 7539 #ifdef USING_DATASET_4
jmitc91516 1:a5258871b33d 7540 // Dataset 4
jmitc91516 1:a5258871b33d 7541 runningInjectorPageGraph->SetDataForGraphDataSetInTenthsOfMinutes(4, yAxisScaleFactor, runningInjectorPageGraphDataSet4);
jmitc91516 1:a5258871b33d 7542 #endif // USING_DATASET_4
jmitc91516 1:a5258871b33d 7543
jmitc91516 1:a5258871b33d 7544 runningInjectorPageGraph->SetXAxisUnits(timeUnit);
jmitc91516 1:a5258871b33d 7545
jmitc91516 1:a5258871b33d 7546
jmitc91516 1:a5258871b33d 7547 // The tick sizes must match those set in easyGUI - we do not seem
jmitc91516 1:a5258871b33d 7548 // to be able to get them at runtime
jmitc91516 1:a5258871b33d 7549 GuiConst_INT32S minX, maxX;
jmitc91516 1:a5258871b33d 7550 //GuiConst_INT32S tickSize = (timeUnit == SECONDS) ? 300 : 100;
jmitc91516 1:a5258871b33d 7551 // Always in 1/10 minutes
jmitc91516 1:a5258871b33d 7552 GuiConst_INT32S xAxisTickSize = (timeUnit == SECONDS) ? 5 : 100; // 5 == 0.5 minutes (i.e. 30 seconds), 100 == 10 minutes
jmitc91516 1:a5258871b33d 7553 runningInjectorPageGraphCompleteProfileDataSet->GetXAxisRangeInTenthsOfMinutes(&minX, &maxX, xAxisTickSize );
jmitc91516 1:a5258871b33d 7554 runningInjectorPageGraph->SetXAxisRange(0, maxX); // Always start X axis at zero
jmitc91516 1:a5258871b33d 7555
jmitc91516 1:a5258871b33d 7556 GuiConst_INT32S minY, maxY;
jmitc91516 1:a5258871b33d 7557 GuiConst_INT32S yAxisTickSize = 50;
jmitc91516 1:a5258871b33d 7558 runningInjectorPageGraphCompleteProfileDataSet->GetYAxisRange(&minY, &maxY, yAxisTickSize);
jmitc91516 1:a5258871b33d 7559 runningInjectorPageGraph->SetYAxisRange(0, (maxY * yAxisScaleFactor)); // Always start Y axis at zero
jmitc91516 1:a5258871b33d 7560
jmitc91516 1:a5258871b33d 7561
jmitc91516 1:a5258871b33d 7562 runningInjectorPageGraph->DrawAxes();
jmitc91516 1:a5258871b33d 7563
jmitc91516 1:a5258871b33d 7564 // We need to draw the X axis labels ourselves, since our time values are in units of 0.1 minute,
jmitc91516 1:a5258871b33d 7565 // but easyGUI graphs work only in integers - we therefore have to multiply the time values by 10
jmitc91516 1:a5258871b33d 7566 // before passing them to easyGUI, and if we let easyGUI draw its own values on the X axis,
jmitc91516 1:a5258871b33d 7567 // they would be 10 times the correct values.
jmitc91516 1:a5258871b33d 7568 // Graph coordinates copied from easyGUI - I cannot find a way of obtaining them at runtime.
jmitc91516 1:a5258871b33d 7569 if(timeUnit == SECONDS) {
jmitc91516 1:a5258871b33d 7570 runningInjectorPageGraph->DrawXAxisLabels(0, (maxX * 6), (xAxisTickSize * 6), 160, 335, 500);
jmitc91516 1:a5258871b33d 7571 } else {
jmitc91516 1:a5258871b33d 7572 runningInjectorPageGraph->DrawXAxisLabels(0, (maxX / 10), (xAxisTickSize / 10), 160, 335, 500);
jmitc91516 1:a5258871b33d 7573 }
jmitc91516 1:a5258871b33d 7574
jmitc91516 1:a5258871b33d 7575 // Similar to the X axis - the values we pass to the easyGUI graph are scaled to be larger
jmitc91516 1:a5258871b33d 7576 // than the real values, to get round the fact that easyGUI graphs work in integers.
jmitc91516 1:a5258871b33d 7577 // (This can cause the profile to appear to be 'stepped', which obviously we do not want.)
jmitc91516 1:a5258871b33d 7578 // We must therefore draw the Y axis values ourselves.
jmitc91516 1:a5258871b33d 7579 runningInjectorPageGraph->DrawYAxisLabels(0, maxY, yAxisTickSize, 160, 335, 250);
jmitc91516 1:a5258871b33d 7580
jmitc91516 1:a5258871b33d 7581 runningInjectorPageGraph->DrawDataSet(0);
jmitc91516 1:a5258871b33d 7582 runningInjectorPageGraph->ShowDataSet(0);
jmitc91516 1:a5258871b33d 7583
jmitc91516 1:a5258871b33d 7584 runningInjectorPageGraph->DrawDataSet(1);
jmitc91516 1:a5258871b33d 7585 runningInjectorPageGraph->ShowDataSet(1);
jmitc91516 1:a5258871b33d 7586
jmitc91516 1:a5258871b33d 7587 runningInjectorPageGraph->DrawDataSet(2);
jmitc91516 1:a5258871b33d 7588 runningInjectorPageGraph->ShowDataSet(2);
jmitc91516 1:a5258871b33d 7589
jmitc91516 1:a5258871b33d 7590 runningInjectorPageGraph->DrawDataSet(3);
jmitc91516 1:a5258871b33d 7591 runningInjectorPageGraph->ShowDataSet(3);
jmitc91516 1:a5258871b33d 7592
jmitc91516 1:a5258871b33d 7593 #ifdef USING_DATASET_4
jmitc91516 1:a5258871b33d 7594 runningInjectorPageGraph->DrawDataSet(4);
jmitc91516 1:a5258871b33d 7595 runningInjectorPageGraph->ShowDataSet(4);
jmitc91516 1:a5258871b33d 7596 #endif // USING_DATASET_4
jmitc91516 1:a5258871b33d 7597
jmitc91516 1:a5258871b33d 7598 runningInjectorPageGraph->Redraw(); // this only redraws the axes,etc - not the graph data
jmitc91516 1:a5258871b33d 7599
jmitc91516 6:dba3fbdfd5da 7600 #ifdef TEST_GUILIB_VLINE_PROFILES
jmitc91516 6:dba3fbdfd5da 7601 GuiConst_INTCOLOR graphColour1 = SixteenBitColorValue(100, 100, 100);
jmitc91516 6:dba3fbdfd5da 7602 GuiConst_INTCOLOR graphColour2 = SixteenBitColorValue(200, 200, 200);
jmitc91516 6:dba3fbdfd5da 7603 float runTime;
jmitc91516 6:dba3fbdfd5da 7604 GetRunTime(&runTime);
jmitc91516 6:dba3fbdfd5da 7605 double colourBoundaryX = (double) runTime;
jmitc91516 6:dba3fbdfd5da 7606 runningInjectorPageGraphCompleteProfileDataSet->DrawUsingGuiLibVLine(170, 335, ((double) 500 / (double) (maxX / 10)), ((double) -250 / (double) maxY), graphColour1, graphColour2, colourBoundaryX);
jmitc91516 6:dba3fbdfd5da 7607 // &&&&
jmitc91516 6:dba3fbdfd5da 7608 #endif // TEST_GUILIB_VLINE_PROFILES
jmitc91516 6:dba3fbdfd5da 7609
jmitc91516 1:a5258871b33d 7610 // Does this solve 'pause before graph displayed' problem with double buffering?
jmitc91516 1:a5258871b33d 7611 if(mustUpdateDisplay) {
jmitc91516 1:a5258871b33d 7612 GuiLib_Refresh();
jmitc91516 1:a5258871b33d 7613 }
jmitc91516 1:a5258871b33d 7614 // Answer - yes it does - although there is still a (just noticeable) pause
jmitc91516 1:a5258871b33d 7615 // (without double buffering, we do not need the above 'if' -
jmitc91516 1:a5258871b33d 7616 // the graph gets redisplayed without it)
jmitc91516 1:a5258871b33d 7617 }
jmitc91516 1:a5258871b33d 7618
jmitc91516 1:a5258871b33d 7619
jmitc91516 1:a5258871b33d 7620 /*
jmitc91516 1:a5258871b33d 7621 Gets the GC embedded software version, and returns it as a null-terminated string, with a descriptive prefix.
jmitc91516 1:a5258871b33d 7622
jmitc91516 1:a5258871b33d 7623 Note also that this code is intended to be as efficient as possible.
jmitc91516 1:a5258871b33d 7624
jmitc91516 1:a5258871b33d 7625 Args: pointer to a buffer to contain the version, as a null-terminated string
jmitc91516 1:a5258871b33d 7626
jmitc91516 1:a5258871b33d 7627 No return code.
jmitc91516 1:a5258871b33d 7628 */
jmitc91516 1:a5258871b33d 7629 void GetGCStatusLoop::GetGCSoftwareVersion(char *version)
jmitc91516 0:47c880c1463d 7630 {
jmitc91516 0:47c880c1463d 7631 char response[50];
jmitc91516 0:47c880c1463d 7632 SetGCDeviceReport("QWHO", response);
jmitc91516 0:47c880c1463d 7633
jmitc91516 0:47c880c1463d 7634 // We expect a response like this: "DWHO0320" -> version 3.20
jmitc91516 1:a5258871b33d 7635 version[0] = 'G';
jmitc91516 1:a5258871b33d 7636 version[1] = 'C';
jmitc91516 1:a5258871b33d 7637 version[2] = ' ';
jmitc91516 0:47c880c1463d 7638 version[3] = 's';
jmitc91516 1:a5258871b33d 7639 version[4] = '/';
jmitc91516 1:a5258871b33d 7640 version[5] = 'w';
jmitc91516 1:a5258871b33d 7641 version[6] = ' ';
jmitc91516 1:a5258871b33d 7642 version[7] = 'v';
jmitc91516 1:a5258871b33d 7643 version[8] = 'e';
jmitc91516 1:a5258871b33d 7644 version[9] = 'r';
jmitc91516 1:a5258871b33d 7645 version[10] = 's';
jmitc91516 1:a5258871b33d 7646 version[11] = 'i';
jmitc91516 1:a5258871b33d 7647 version[12] = 'o';
jmitc91516 1:a5258871b33d 7648 version[13] = 'n';
jmitc91516 1:a5258871b33d 7649 version[14] = ':';
jmitc91516 1:a5258871b33d 7650 version[15] = ' ';
jmitc91516 1:a5258871b33d 7651 version[16] = response[4];
jmitc91516 1:a5258871b33d 7652 version[17] = response[5];
jmitc91516 1:a5258871b33d 7653 version[18] = '.';
jmitc91516 1:a5258871b33d 7654 version[19] = response[6];
jmitc91516 1:a5258871b33d 7655 version[20] = response[7];
jmitc91516 1:a5258871b33d 7656 version[21] = '\0';
jmitc91516 1:a5258871b33d 7657 }
jmitc91516 1:a5258871b33d 7658
jmitc91516 1:a5258871b33d 7659 /*
jmitc91516 1:a5258871b33d 7660 Gets the actuator software version, and returns it as a null-terminated string, with a descriptive prefix.
jmitc91516 1:a5258871b33d 7661
jmitc91516 1:a5258871b33d 7662 Args: pointer to a buffer to contain the version, as a null-terminated string
jmitc91516 1:a5258871b33d 7663
jmitc91516 1:a5258871b33d 7664 No return code.
jmitc91516 1:a5258871b33d 7665 */
jmitc91516 1:a5258871b33d 7666 void GetGCStatusLoop::GetActuatorSoftwareVersion(char *version)
jmitc91516 1:a5258871b33d 7667 {
jmitc91516 1:a5258871b33d 7668 char response[50];
jmitc91516 1:a5258871b33d 7669 SetGCDeviceReport("QACT0004", response);
jmitc91516 1:a5258871b33d 7670
jmitc91516 1:a5258871b33d 7671 // We expect a response like this: "DACnnnnn" (note 5 digits).
jmitc91516 1:a5258871b33d 7672 // The value contains 14 bits, and the least significant byte is the software version
jmitc91516 1:a5258871b33d 7673 int value;
jmitc91516 1:a5258871b33d 7674 sscanf(&response[3], "%d", &value);
jmitc91516 1:a5258871b33d 7675
jmitc91516 1:a5258871b33d 7676 sprintf(version, "Actuator s/w version: %d", (value & 0xFF));
jmitc91516 1:a5258871b33d 7677 }
jmitc91516 1:a5258871b33d 7678
jmitc91516 1:a5258871b33d 7679
jmitc91516 1:a5258871b33d 7680 /*
jmitc91516 1:a5258871b33d 7681 Gets the GC run time, and returns it as a floating point value.
jmitc91516 1:a5258871b33d 7682 Note that the GC returns the run time as a four digit value,
jmitc91516 1:a5258871b33d 7683 scaled in units of 0.1 min. This function applies that scaling
jmitc91516 1:a5258871b33d 7684 to the value it returns - i.e. if the GC returns "1234",
jmitc91516 1:a5258871b33d 7685 this function returns 123.4 as the float value.
jmitc91516 1:a5258871b33d 7686
jmitc91516 1:a5258871b33d 7687 Remember that the GC sets its runtime to zero at the start of every run.
jmitc91516 1:a5258871b33d 7688
jmitc91516 1:a5258871b33d 7689 Args: pointer to a 'float' variable to contain the run time
jmitc91516 1:a5258871b33d 7690
jmitc91516 1:a5258871b33d 7691 No return code.
jmitc91516 1:a5258871b33d 7692 */
jmitc91516 1:a5258871b33d 7693 void GetGCStatusLoop::GetRunTime(float *time)
jmitc91516 1:a5258871b33d 7694 {
jmitc91516 1:a5258871b33d 7695 char response[50];
jmitc91516 1:a5258871b33d 7696 SetGCDeviceReport("QTIM", response);
jmitc91516 1:a5258871b33d 7697
jmitc91516 1:a5258871b33d 7698 if(response[0] == 'E') {
jmitc91516 1:a5258871b33d 7699 // Got "EPKT" response
jmitc91516 1:a5258871b33d 7700 *time = -1.0f;
jmitc91516 1:a5258871b33d 7701
jmitc91516 1:a5258871b33d 7702 return;
jmitc91516 1:a5258871b33d 7703 }
jmitc91516 1:a5258871b33d 7704
jmitc91516 1:a5258871b33d 7705 // Must have received a valid response from the GC. We expect a response like this:
jmitc91516 1:a5258871b33d 7706 // "DTIM1234", with run time in units of 0.1 min
jmitc91516 1:a5258871b33d 7707 char buff[50];
jmitc91516 1:a5258871b33d 7708 buff[0] = response[4];
jmitc91516 1:a5258871b33d 7709 buff[1] = response[5];
jmitc91516 1:a5258871b33d 7710 buff[2] = response[6];
jmitc91516 1:a5258871b33d 7711 buff[3] = '.';
jmitc91516 1:a5258871b33d 7712 buff[4] = response[7];
jmitc91516 1:a5258871b33d 7713 buff[5] = '\0';
jmitc91516 1:a5258871b33d 7714
jmitc91516 1:a5258871b33d 7715 sscanf(buff, "%f", time);
jmitc91516 1:a5258871b33d 7716 }
jmitc91516 1:a5258871b33d 7717
jmitc91516 1:a5258871b33d 7718
jmitc91516 1:a5258871b33d 7719 /*
jmitc91516 1:a5258871b33d 7720 Gets the GC run time, and returns it as a null-terminated string, with a descriptive prefix.
jmitc91516 1:a5258871b33d 7721 (The GC sets this to zero at the start of every run.)
jmitc91516 1:a5258871b33d 7722
jmitc91516 1:a5258871b33d 7723 Note also that this code is intended to be as efficient as possible.
jmitc91516 1:a5258871b33d 7724
jmitc91516 1:a5258871b33d 7725 Args: pointer to a buffer to contain the run time, as a null-terminated string
jmitc91516 1:a5258871b33d 7726
jmitc91516 1:a5258871b33d 7727 No return code.
jmitc91516 1:a5258871b33d 7728 */
jmitc91516 0:47c880c1463d 7729 void GetGCStatusLoop::GetRunTime(char *time)
jmitc91516 0:47c880c1463d 7730 {
jmitc91516 0:47c880c1463d 7731 char response[50];
jmitc91516 0:47c880c1463d 7732 SetGCDeviceReport("QTIM", response);
jmitc91516 0:47c880c1463d 7733
jmitc91516 0:47c880c1463d 7734 // We expect a response like this: "DTIM1234", with run time in units of 0.1 min
jmitc91516 1:a5258871b33d 7735 int index = 0;
jmitc91516 1:a5258871b33d 7736 time[index++] = 'R';
jmitc91516 1:a5258871b33d 7737 time[index++] = 'u';
jmitc91516 1:a5258871b33d 7738 time[index++] = 'n';
jmitc91516 1:a5258871b33d 7739 time[index++] = ' ';
jmitc91516 1:a5258871b33d 7740 time[index++] = 't';
jmitc91516 1:a5258871b33d 7741 time[index++] = 'i';
jmitc91516 1:a5258871b33d 7742 time[index++] = 'm';
jmitc91516 1:a5258871b33d 7743 time[index++] = 'e';
jmitc91516 1:a5258871b33d 7744 time[index++] = ':';
jmitc91516 1:a5258871b33d 7745 time[index++] = ' ';
jmitc91516 1:a5258871b33d 7746
jmitc91516 1:a5258871b33d 7747 bool wantNextChars = false;
jmitc91516 1:a5258871b33d 7748 if(response[4] != '0') {
jmitc91516 1:a5258871b33d 7749 time[index++] = response[4];
jmitc91516 1:a5258871b33d 7750 wantNextChars = true;
jmitc91516 1:a5258871b33d 7751 }
jmitc91516 1:a5258871b33d 7752 if(wantNextChars || (response[5] != '0')) {
jmitc91516 1:a5258871b33d 7753 time[index++] = response[5];
jmitc91516 1:a5258871b33d 7754 }
jmitc91516 1:a5258871b33d 7755 // If the value is zero, make sure we return "0.0" -
jmitc91516 1:a5258871b33d 7756 // we just don't want any zeroes before that
jmitc91516 1:a5258871b33d 7757 time[index++] = response[6];
jmitc91516 1:a5258871b33d 7758 time[index++] = '.';
jmitc91516 1:a5258871b33d 7759 time[index++] = response[7];
jmitc91516 1:a5258871b33d 7760
jmitc91516 1:a5258871b33d 7761 time[index++] = ' ';
jmitc91516 1:a5258871b33d 7762 time[index++] = 'm';
jmitc91516 1:a5258871b33d 7763 time[index++] = 'i';
jmitc91516 1:a5258871b33d 7764 time[index++] = 'n';
jmitc91516 1:a5258871b33d 7765 time[index++] = '\0';
jmitc91516 1:a5258871b33d 7766 }
jmitc91516 1:a5258871b33d 7767
jmitc91516 1:a5258871b33d 7768 /*
jmitc91516 1:a5258871b33d 7769 Gets the GC serial number (which consists of eight digits), and returns it as a null-terminated string.
jmitc91516 1:a5258871b33d 7770
jmitc91516 1:a5258871b33d 7771 Note also that this code is intended to be as efficient as possible.
jmitc91516 1:a5258871b33d 7772
jmitc91516 1:a5258871b33d 7773 Args: pointer to a buffer to contain the run time, as a null-terminated string.
jmitc91516 1:a5258871b33d 7774 This must be at least twelve bytes long, to allow for a possible error message.
jmitc91516 1:a5258871b33d 7775
jmitc91516 1:a5258871b33d 7776 No return code.
jmitc91516 1:a5258871b33d 7777 */
jmitc91516 1:a5258871b33d 7778 void GetGCStatusLoop::GetSerialNumber(char *serialNumber)
jmitc91516 1:a5258871b33d 7779 {
jmitc91516 1:a5258871b33d 7780 char response1[50];
jmitc91516 1:a5258871b33d 7781 SetGCDeviceReport("GSN1", response1);
jmitc91516 1:a5258871b33d 7782 // We expect a response like this: "DSN1nnnn", where 'nnnn' is the first four digits of the serial number
jmitc91516 1:a5258871b33d 7783
jmitc91516 1:a5258871b33d 7784 char response2[50];
jmitc91516 1:a5258871b33d 7785 SetGCDeviceReport("GSN2", response2);
jmitc91516 1:a5258871b33d 7786 // We expect a response like this: "DSN2nnnn", where 'nnnn' is the second four digits of the serial number
jmitc91516 1:a5258871b33d 7787
jmitc91516 1:a5258871b33d 7788 int index = 0;
jmitc91516 1:a5258871b33d 7789 // But check for "EPKT" first
jmitc91516 1:a5258871b33d 7790 if((response1[0] == 'E') || (response2[0] == 'E')) {
jmitc91516 1:a5258871b33d 7791 serialNumber[index++] = '*';
jmitc91516 1:a5258871b33d 7792 serialNumber[index++] = '*';
jmitc91516 1:a5258871b33d 7793 serialNumber[index++] = ' ';
jmitc91516 1:a5258871b33d 7794 serialNumber[index++] = 'E';
jmitc91516 1:a5258871b33d 7795 serialNumber[index++] = 'r';
jmitc91516 1:a5258871b33d 7796 serialNumber[index++] = 'r';
jmitc91516 1:a5258871b33d 7797 serialNumber[index++] = 'o';
jmitc91516 1:a5258871b33d 7798 serialNumber[index++] = 'r';
jmitc91516 1:a5258871b33d 7799 serialNumber[index++] = ' ';
jmitc91516 1:a5258871b33d 7800 serialNumber[index++] = '*';
jmitc91516 1:a5258871b33d 7801 serialNumber[index++] = '*';
jmitc91516 1:a5258871b33d 7802 } else {
jmitc91516 1:a5258871b33d 7803 serialNumber[index++] = response1[4];
jmitc91516 1:a5258871b33d 7804 serialNumber[index++] = response1[5];
jmitc91516 1:a5258871b33d 7805 serialNumber[index++] = response1[6];
jmitc91516 1:a5258871b33d 7806 serialNumber[index++] = response1[7];
jmitc91516 1:a5258871b33d 7807 serialNumber[index++] = response2[4];
jmitc91516 1:a5258871b33d 7808 serialNumber[index++] = response2[5];
jmitc91516 1:a5258871b33d 7809 serialNumber[index++] = response2[6];
jmitc91516 1:a5258871b33d 7810 serialNumber[index++] = response2[7];
jmitc91516 1:a5258871b33d 7811 }
jmitc91516 1:a5258871b33d 7812
jmitc91516 1:a5258871b33d 7813 serialNumber[index] = '\0';
jmitc91516 1:a5258871b33d 7814 }
jmitc91516 1:a5258871b33d 7815
jmitc91516 1:a5258871b33d 7816
jmitc91516 1:a5258871b33d 7817 /*
jmitc91516 1:a5258871b33d 7818 Gets the time represented by the GC's real time clock [RTC], and returns it as a null-terminated string.
jmitc91516 1:a5258871b33d 7819
jmitc91516 1:a5258871b33d 7820 Args: pointer to a buffer to contain the time, as a null-terminated string.
jmitc91516 1:a5258871b33d 7821 This must be at least twenty-five bytes long, to accomodate the string
jmitc91516 1:a5258871b33d 7822 returned by the 'ctime' function
jmitc91516 1:a5258871b33d 7823
jmitc91516 1:a5258871b33d 7824 No return code.
jmitc91516 1:a5258871b33d 7825 */
jmitc91516 1:a5258871b33d 7826 void GetGCStatusLoop::GetGCRealTimeClockTime(char *clockTime)
jmitc91516 1:a5258871b33d 7827 {
jmitc91516 1:a5258871b33d 7828 time_t gcRtcValue;
jmitc91516 1:a5258871b33d 7829
jmitc91516 1:a5258871b33d 7830 GCRealTimeClock::GetGCClockTime(usbDevice, usbHostGC, &gcRtcValue);
jmitc91516 1:a5258871b33d 7831
jmitc91516 1:a5258871b33d 7832 strcpy(clockTime, ctime(&gcRtcValue));
jmitc91516 1:a5258871b33d 7833
jmitc91516 1:a5258871b33d 7834 // Remove the newline character from the string returned by 'ctime'
jmitc91516 1:a5258871b33d 7835 // (easyGUI displays it as a black rectangle)
jmitc91516 1:a5258871b33d 7836 char *cp = clockTime;
jmitc91516 1:a5258871b33d 7837 while(*cp) {
jmitc91516 1:a5258871b33d 7838 if(*cp == '\n') {
jmitc91516 1:a5258871b33d 7839 *cp = '\0';
jmitc91516 1:a5258871b33d 7840 break;
jmitc91516 1:a5258871b33d 7841 }
jmitc91516 1:a5258871b33d 7842 ++cp;
jmitc91516 1:a5258871b33d 7843 }
jmitc91516 1:a5258871b33d 7844 }
jmitc91516 1:a5258871b33d 7845
jmitc91516 1:a5258871b33d 7846 /*
jmitc91516 1:a5258871b33d 7847 Displays the data on the settings page, by copying it to the relevant easyGUI variables,
jmitc91516 1:a5258871b33d 7848 and calling the relevant functions to actually display it.
jmitc91516 1:a5258871b33d 7849
jmitc91516 1:a5258871b33d 7850 Args: a boolean specifying whether or not the display is actually to be updated.
jmitc91516 1:a5258871b33d 7851 Even if it is false when we are called, we may set it true if we discover
jmitc91516 1:a5258871b33d 7852 one or more data items has changed - but note that we will not set it false
jmitc91516 1:a5258871b33d 7853 if it is already true. If it is true after we have looked at all
jmitc91516 1:a5258871b33d 7854 the home page data, we will then update the display. (If we are called
jmitc91516 1:a5258871b33d 7855 with this value set to false, the caller is effectively saying
jmitc91516 1:a5258871b33d 7856 'display the settings page data only if it has changed').
jmitc91516 1:a5258871b33d 7857
jmitc91516 1:a5258871b33d 7858 No return code.
jmitc91516 1:a5258871b33d 7859 */
jmitc91516 0:47c880c1463d 7860 void GetGCStatusLoop::DisplaySettingsPageData(bool mustUpdateDisplay)
jmitc91516 0:47c880c1463d 7861 {
jmitc91516 0:47c880c1463d 7862 //EasyGUIDebugPrint("Settings Page", 100, 100);
jmitc91516 0:47c880c1463d 7863 // Various settings
jmitc91516 0:47c880c1463d 7864 char buff[60];
jmitc91516 0:47c880c1463d 7865
jmitc91516 1:a5258871b33d 7866 GetGCSoftwareVersion(GuiVar_gcSoftwareVersion);
jmitc91516 0:47c880c1463d 7867 // Assume software version cannot change while we are running
jmitc91516 0:47c880c1463d 7868
jmitc91516 1:a5258871b33d 7869 GetActuatorSoftwareVersion(GuiVar_actuatorSoftwareVersion);
jmitc91516 1:a5258871b33d 7870
jmitc91516 1:a5258871b33d 7871 GetGasControlMode(buff, true, true);
jmitc91516 0:47c880c1463d 7872 if(strcmp(buff, GuiVar_gasControlMode) != 0) {
jmitc91516 0:47c880c1463d 7873 mustUpdateDisplay = true;
jmitc91516 0:47c880c1463d 7874
jmitc91516 0:47c880c1463d 7875 strcpy(GuiVar_gasControlMode, buff);
jmitc91516 0:47c880c1463d 7876 }
jmitc91516 0:47c880c1463d 7877
jmitc91516 1:a5258871b33d 7878 GetDetectorType(buff, true, true);
jmitc91516 0:47c880c1463d 7879 if(strcmp(buff, GuiVar_detectorType) != 0) {
jmitc91516 0:47c880c1463d 7880 mustUpdateDisplay = true;
jmitc91516 0:47c880c1463d 7881
jmitc91516 0:47c880c1463d 7882 strcpy(GuiVar_detectorType, buff);
jmitc91516 0:47c880c1463d 7883 }
jmitc91516 0:47c880c1463d 7884
jmitc91516 1:a5258871b33d 7885 GetColumnMaxTemperature(buff, true, true);
jmitc91516 0:47c880c1463d 7886 if(strcmp(buff, GuiVar_columnMaxTemp) != 0) {
jmitc91516 0:47c880c1463d 7887 mustUpdateDisplay = true;
jmitc91516 0:47c880c1463d 7888
jmitc91516 0:47c880c1463d 7889 strcpy(GuiVar_columnMaxTemp, buff);
jmitc91516 0:47c880c1463d 7890 }
jmitc91516 0:47c880c1463d 7891
jmitc91516 1:a5258871b33d 7892 // GetInjectionMode(buff, true);
jmitc91516 1:a5258871b33d 7893 GetInjectorType(buff, true);
jmitc91516 0:47c880c1463d 7894 if(strcmp(buff, GuiVar_injectionMode) != 0) {
jmitc91516 0:47c880c1463d 7895 mustUpdateDisplay = true;
jmitc91516 0:47c880c1463d 7896
jmitc91516 0:47c880c1463d 7897 strcpy(GuiVar_injectionMode, buff);
jmitc91516 0:47c880c1463d 7898 }
jmitc91516 0:47c880c1463d 7899
jmitc91516 0:47c880c1463d 7900 GetRunTime(buff);
jmitc91516 0:47c880c1463d 7901 if(strcmp(buff, GuiVar_runTime) != 0) {
jmitc91516 0:47c880c1463d 7902 mustUpdateDisplay = true;
jmitc91516 0:47c880c1463d 7903
jmitc91516 0:47c880c1463d 7904 strcpy(GuiVar_runTime, buff);
jmitc91516 0:47c880c1463d 7905 }
jmitc91516 0:47c880c1463d 7906
jmitc91516 1:a5258871b33d 7907 GetSerialNumber(buff);
jmitc91516 1:a5258871b33d 7908 if(strcmp(buff, GuiVar_gcSerialNumber) != 0) {
jmitc91516 1:a5258871b33d 7909 mustUpdateDisplay = true;
jmitc91516 1:a5258871b33d 7910
jmitc91516 1:a5258871b33d 7911 strcpy(GuiVar_gcSerialNumber, buff);
jmitc91516 1:a5258871b33d 7912 }
jmitc91516 1:a5258871b33d 7913
jmitc91516 1:a5258871b33d 7914 GetGCRealTimeClockTime(buff);
jmitc91516 1:a5258871b33d 7915 if(strcmp(buff, GuiVar_gcTime) != 0) {
jmitc91516 1:a5258871b33d 7916 mustUpdateDisplay = true;
jmitc91516 1:a5258871b33d 7917
jmitc91516 1:a5258871b33d 7918 strcpy(GuiVar_gcTime, buff);
jmitc91516 1:a5258871b33d 7919 }
jmitc91516 1:a5258871b33d 7920
jmitc91516 0:47c880c1463d 7921 if(mustUpdateDisplay) {
jmitc91516 0:47c880c1463d 7922
jmitc91516 0:47c880c1463d 7923 // Makes the display flicker - but omitting it means old text is not cleared from the display
jmitc91516 1:a5258871b33d 7924 #ifdef USING_BACKGROUND_BITMAP
jmitc91516 1:a5258871b33d 7925 DrawBackgroundBitmap();
jmitc91516 1:a5258871b33d 7926 #else
jmitc91516 0:47c880c1463d 7927 GuiLib_Clear();
jmitc91516 1:a5258871b33d 7928 #endif
jmitc91516 0:47c880c1463d 7929
jmitc91516 0:47c880c1463d 7930 GuiLib_ShowScreen(GuiStruct_SettingsPage_5, GuiLib_NO_CURSOR, GuiLib_RESET_AUTO_REDRAW);
jmitc91516 0:47c880c1463d 7931
jmitc91516 0:47c880c1463d 7932 GuiLib_Refresh();
jmitc91516 0:47c880c1463d 7933
jmitc91516 0:47c880c1463d 7934 #define DEBUG_HERE
jmitc91516 0:47c880c1463d 7935 #ifdef DEBUG_HERE
jmitc91516 0:47c880c1463d 7936 char dbg[100];
jmitc91516 0:47c880c1463d 7937 sprintf(dbg, "After GuiLib_Clear 6");
jmitc91516 1:a5258871b33d 7938 EasyGUIDebugPrint(dbg, 0, 20);
jmitc91516 0:47c880c1463d 7939 #undef DEBUG_HERE
jmitc91516 0:47c880c1463d 7940 #endif
jmitc91516 0:47c880c1463d 7941 }
jmitc91516 0:47c880c1463d 7942 }
jmitc91516 0:47c880c1463d 7943
jmitc91516 1:a5258871b33d 7944
jmitc91516 1:a5258871b33d 7945 /*
jmitc91516 1:a5258871b33d 7946 Displays the 'establishing ethernet connection' page -
jmitc91516 1:a5258871b33d 7947 so the user knows we are doing something, and have not locked up.
jmitc91516 1:a5258871b33d 7948
jmitc91516 1:a5258871b33d 7949 No args, no return code.
jmitc91516 1:a5258871b33d 7950 */
jmitc91516 1:a5258871b33d 7951 void GetGCStatusLoop::DisplayEthernetConnectionPage(void)
jmitc91516 1:a5258871b33d 7952 {
jmitc91516 1:a5258871b33d 7953 #ifdef USING_BACKGROUND_BITMAP
jmitc91516 1:a5258871b33d 7954 DrawBackgroundBitmapWithLogo(); // Only on this page and the "Connecting to GC" page
jmitc91516 1:a5258871b33d 7955 #else
jmitc91516 1:a5258871b33d 7956 GuiLib_Clear();
jmitc91516 1:a5258871b33d 7957 #endif
jmitc91516 1:a5258871b33d 7958
jmitc91516 1:a5258871b33d 7959 GuiLib_ShowScreen(GuiStruct_EthernetConnectionPage_Def, GuiLib_NO_CURSOR, GuiLib_RESET_AUTO_REDRAW);
jmitc91516 1:a5258871b33d 7960
jmitc91516 1:a5258871b33d 7961 GuiLib_Refresh();
jmitc91516 1:a5258871b33d 7962 }
jmitc91516 1:a5258871b33d 7963
jmitc91516 1:a5258871b33d 7964 /*
jmitc91516 1:a5258871b33d 7965 Displays the 'failed to load bitmaps' page
jmitc91516 1:a5258871b33d 7966
jmitc91516 1:a5258871b33d 7967 No args, no return code.
jmitc91516 1:a5258871b33d 7968 */
jmitc91516 1:a5258871b33d 7969 void GetGCStatusLoop::DisplayFailedToFindBitmapsPage(void)
jmitc91516 1:a5258871b33d 7970 {
jmitc91516 1:a5258871b33d 7971 #ifdef USING_BACKGROUND_BITMAP
jmitc91516 1:a5258871b33d 7972 DrawBackgroundBitmap(); // Only on this page and the "Connecting to GC" page
jmitc91516 1:a5258871b33d 7973 #else
jmitc91516 1:a5258871b33d 7974 GuiLib_Clear();
jmitc91516 1:a5258871b33d 7975 #endif
jmitc91516 1:a5258871b33d 7976
jmitc91516 1:a5258871b33d 7977 GuiLib_ShowScreen(GuiStruct_FailedToFindBitmapsPage_0, GuiLib_NO_CURSOR, GuiLib_RESET_AUTO_REDRAW);
jmitc91516 1:a5258871b33d 7978
jmitc91516 1:a5258871b33d 7979 GuiLib_Refresh();
jmitc91516 1:a5258871b33d 7980 }
jmitc91516 1:a5258871b33d 7981
jmitc91516 1:a5258871b33d 7982 /*
jmitc91516 1:a5258871b33d 7983 Display the 'Servicing Required' page, telling the user which components
jmitc91516 1:a5258871b33d 7984 now need servicing
jmitc91516 1:a5258871b33d 7985 */
jmitc91516 1:a5258871b33d 7986 void GetGCStatusLoop::DisplayServicingRequiredPage(void)
jmitc91516 1:a5258871b33d 7987 {
jmitc91516 1:a5258871b33d 7988 GetSerialNumber(GuiVar_columnSerialNumber);
jmitc91516 1:a5258871b33d 7989
jmitc91516 1:a5258871b33d 7990 char *easyGuiComponentVariables[6] = { GuiVar_componentNeedsServicing1,
jmitc91516 1:a5258871b33d 7991 GuiVar_componentNeedsServicing2,
jmitc91516 1:a5258871b33d 7992 GuiVar_componentNeedsServicing3,
jmitc91516 1:a5258871b33d 7993 GuiVar_componentNeedsServicing4,
jmitc91516 1:a5258871b33d 7994 GuiVar_componentNeedsServicing5,
jmitc91516 1:a5258871b33d 7995 GuiVar_componentNeedsServicing6
jmitc91516 1:a5258871b33d 7996 };
jmitc91516 1:a5258871b33d 7997
jmitc91516 1:a5258871b33d 7998 // Make sure we clear the 'component needs servicing' easy GUI variables
jmitc91516 1:a5258871b33d 7999 // before we start - we only want to display the components that
jmitc91516 1:a5258871b33d 8000 // *now* need servicing, not whatever needed servicing last time
jmitc91516 1:a5258871b33d 8001 int componentIndex = 0;
jmitc91516 1:a5258871b33d 8002 while(componentIndex < 6) {
jmitc91516 1:a5258871b33d 8003 easyGuiComponentVariables[componentIndex][0] = '\0';
jmitc91516 1:a5258871b33d 8004 ++componentIndex;
jmitc91516 1:a5258871b33d 8005 }
jmitc91516 1:a5258871b33d 8006
jmitc91516 1:a5258871b33d 8007 // Now find out which components need servicing, and display their names
jmitc91516 1:a5258871b33d 8008 componentIndex = 0;
jmitc91516 1:a5258871b33d 8009 ServiceInterval* expiredServiceInterval = ServiceInterval::GetNextExpiredServiceInterval(NULL);
jmitc91516 1:a5258871b33d 8010 while((expiredServiceInterval != NULL) && (componentIndex < 6)) {
jmitc91516 1:a5258871b33d 8011 if(expiredServiceInterval->GetDescriptionLength() < 40) {
jmitc91516 1:a5258871b33d 8012 expiredServiceInterval->GetDescription(easyGuiComponentVariables[componentIndex]);
jmitc91516 1:a5258871b33d 8013 }
jmitc91516 1:a5258871b33d 8014
jmitc91516 1:a5258871b33d 8015 ++componentIndex;
jmitc91516 1:a5258871b33d 8016
jmitc91516 1:a5258871b33d 8017 expiredServiceInterval = ServiceInterval::GetNextExpiredServiceInterval(expiredServiceInterval);
jmitc91516 1:a5258871b33d 8018 }
jmitc91516 1:a5258871b33d 8019
jmitc91516 1:a5258871b33d 8020 #ifdef USING_BACKGROUND_BITMAP
jmitc91516 1:a5258871b33d 8021 DrawBackgroundBitmap();
jmitc91516 1:a5258871b33d 8022 #else
jmitc91516 1:a5258871b33d 8023 GuiLib_Clear();
jmitc91516 1:a5258871b33d 8024 #endif
jmitc91516 1:a5258871b33d 8025
jmitc91516 1:a5258871b33d 8026 GuiLib_ShowScreen(GuiStruct_ServicingRequired_Def, GuiLib_NO_CURSOR, GuiLib_RESET_AUTO_REDRAW);
jmitc91516 1:a5258871b33d 8027
jmitc91516 1:a5258871b33d 8028 GuiLib_Refresh();
jmitc91516 1:a5258871b33d 8029
jmitc91516 1:a5258871b33d 8030 SetCurrentPage(GuiStruct_ServicingRequired_Def);
jmitc91516 1:a5258871b33d 8031 }
jmitc91516 1:a5258871b33d 8032
jmitc91516 1:a5258871b33d 8033
jmitc91516 1:a5258871b33d 8034 /*
jmitc91516 1:a5258871b33d 8035 This needs to be called from SetupAllEasyGUIVariables,
jmitc91516 1:a5258871b33d 8036 as well as fromDisplayServicingPage
jmitc91516 1:a5258871b33d 8037 */
jmitc91516 1:a5258871b33d 8038 void GetGCStatusLoop::SetupServicingPageEasyGUIVariables(void)
jmitc91516 1:a5258871b33d 8039 {
jmitc91516 1:a5258871b33d 8040 ServiceInterval* serviceInterval;
jmitc91516 1:a5258871b33d 8041
jmitc91516 1:a5258871b33d 8042 serviceInterval = ServiceInterval::GetServiceInterval(0);
jmitc91516 1:a5258871b33d 8043 if(serviceInterval != NULL) {
jmitc91516 1:a5258871b33d 8044 serviceInterval->GetDescription(GuiVar_componentSetupServicing1);
jmitc91516 1:a5258871b33d 8045 }
jmitc91516 1:a5258871b33d 8046
jmitc91516 1:a5258871b33d 8047 serviceInterval = ServiceInterval::GetServiceInterval(1);
jmitc91516 1:a5258871b33d 8048 if(serviceInterval != NULL) {
jmitc91516 1:a5258871b33d 8049 serviceInterval->GetDescription(GuiVar_componentSetupServicing2);
jmitc91516 1:a5258871b33d 8050 }
jmitc91516 1:a5258871b33d 8051
jmitc91516 1:a5258871b33d 8052 serviceInterval = ServiceInterval::GetServiceInterval(2);
jmitc91516 1:a5258871b33d 8053 if(serviceInterval != NULL) {
jmitc91516 1:a5258871b33d 8054 serviceInterval->GetDescription(GuiVar_componentSetupServicing3);
jmitc91516 1:a5258871b33d 8055 }
jmitc91516 1:a5258871b33d 8056
jmitc91516 1:a5258871b33d 8057 serviceInterval = ServiceInterval::GetServiceInterval(3);
jmitc91516 1:a5258871b33d 8058 if(serviceInterval != NULL) {
jmitc91516 1:a5258871b33d 8059 serviceInterval->GetDescription(GuiVar_componentSetupServicing4);
jmitc91516 1:a5258871b33d 8060 }
jmitc91516 1:a5258871b33d 8061
jmitc91516 1:a5258871b33d 8062 serviceInterval = ServiceInterval::GetServiceInterval(4);
jmitc91516 1:a5258871b33d 8063 if(serviceInterval != NULL) {
jmitc91516 1:a5258871b33d 8064 serviceInterval->GetDescription(GuiVar_componentSetupServicing5);
jmitc91516 1:a5258871b33d 8065 }
jmitc91516 1:a5258871b33d 8066
jmitc91516 1:a5258871b33d 8067 serviceInterval = ServiceInterval::GetServiceInterval(5);
jmitc91516 1:a5258871b33d 8068 if(serviceInterval != NULL) {
jmitc91516 1:a5258871b33d 8069 serviceInterval->GetDescription(GuiVar_componentSetupServicing6);
jmitc91516 1:a5258871b33d 8070 }
jmitc91516 1:a5258871b33d 8071 }
jmitc91516 1:a5258871b33d 8072
jmitc91516 1:a5258871b33d 8073 /*
jmitc91516 1:a5258871b33d 8074 Display the 'Servicing' page, allowing our engineer to setup
jmitc91516 1:a5258871b33d 8075 the service intervals for each [serviceable] component
jmitc91516 1:a5258871b33d 8076 */
jmitc91516 1:a5258871b33d 8077 void GetGCStatusLoop::DisplayServicingPage(void)
jmitc91516 1:a5258871b33d 8078 {
jmitc91516 1:a5258871b33d 8079 SetupServicingPageEasyGUIVariables();
jmitc91516 1:a5258871b33d 8080
jmitc91516 1:a5258871b33d 8081 #ifdef USING_BACKGROUND_BITMAP
jmitc91516 1:a5258871b33d 8082 DrawBackgroundBitmap();
jmitc91516 1:a5258871b33d 8083 #else
jmitc91516 1:a5258871b33d 8084 GuiLib_Clear();
jmitc91516 1:a5258871b33d 8085 #endif
jmitc91516 1:a5258871b33d 8086
jmitc91516 1:a5258871b33d 8087 GuiLib_ShowScreen(GuiStruct_ServicingPage_Def, GuiLib_NO_CURSOR, GuiLib_RESET_AUTO_REDRAW);
jmitc91516 1:a5258871b33d 8088
jmitc91516 1:a5258871b33d 8089 GuiLib_Refresh();
jmitc91516 1:a5258871b33d 8090
jmitc91516 1:a5258871b33d 8091 SetCurrentPage(GuiStruct_ServicingPage_Def);
jmitc91516 1:a5258871b33d 8092 }
jmitc91516 1:a5258871b33d 8093
jmitc91516 1:a5258871b33d 8094
jmitc91516 1:a5258871b33d 8095 /*
jmitc91516 1:a5258871b33d 8096 Displays the 'downloading method' page - to try and speed this operation up,
jmitc91516 1:a5258871b33d 8097 we do not allow the user to do anything else while we do this -
jmitc91516 1:a5258871b33d 8098 displaying this page makes that clear to the user
jmitc91516 1:a5258871b33d 8099
jmitc91516 1:a5258871b33d 8100 After completing the download, call 'UndisplayDownloadingMethodPage'
jmitc91516 1:a5258871b33d 8101 - currently, this always returns to the Running page if the GC is running,
jmitc91516 1:a5258871b33d 8102 or the Home page if it is not
jmitc91516 1:a5258871b33d 8103
jmitc91516 1:a5258871b33d 8104 No args, no return code.
jmitc91516 1:a5258871b33d 8105 */
jmitc91516 1:a5258871b33d 8106 void GetGCStatusLoop::DisplayDownloadingMethodPage(void)
jmitc91516 1:a5258871b33d 8107 {
jmitc91516 1:a5258871b33d 8108 #ifdef USING_BACKGROUND_BITMAP
jmitc91516 1:a5258871b33d 8109 DrawBackgroundBitmap();
jmitc91516 1:a5258871b33d 8110 #else
jmitc91516 1:a5258871b33d 8111 GuiLib_Clear();
jmitc91516 1:a5258871b33d 8112 #endif
jmitc91516 1:a5258871b33d 8113
jmitc91516 1:a5258871b33d 8114 GuiLib_ShowScreen(GuiStruct_DownloadingMethodPage_Def, GuiLib_NO_CURSOR, GuiLib_RESET_AUTO_REDRAW);
jmitc91516 1:a5258871b33d 8115
jmitc91516 1:a5258871b33d 8116 GuiLib_Refresh();
jmitc91516 1:a5258871b33d 8117
jmitc91516 1:a5258871b33d 8118 currentPage = GuiStruct_DownloadingMethodPage_Def;
jmitc91516 1:a5258871b33d 8119 }
jmitc91516 1:a5258871b33d 8120
jmitc91516 1:a5258871b33d 8121 /*
jmitc91516 1:a5258871b33d 8122 Restores our display after the method has downloaded -
jmitc91516 1:a5258871b33d 8123 currently, we always return to the Home page unless the GC is running,
jmitc91516 1:a5258871b33d 8124 in which case we return to the main Running page
jmitc91516 1:a5258871b33d 8125
jmitc91516 1:a5258871b33d 8126 No args, no return code
jmitc91516 1:a5258871b33d 8127 */
jmitc91516 1:a5258871b33d 8128 void GetGCStatusLoop::UndisplayDownloadingMethodPage(void)
jmitc91516 1:a5258871b33d 8129 {
jmitc91516 1:a5258871b33d 8130 #ifdef USING_BACKGROUND_BITMAP
jmitc91516 1:a5258871b33d 8131 DrawBackgroundBitmap();
jmitc91516 1:a5258871b33d 8132 #else
jmitc91516 1:a5258871b33d 8133 GuiLib_Clear();
jmitc91516 1:a5258871b33d 8134 #endif
jmitc91516 1:a5258871b33d 8135
jmitc91516 1:a5258871b33d 8136 int gcStatus = GetGCStatus();
jmitc91516 1:a5258871b33d 8137 if(GCStateOrFaultCode::GetSimplifiedGCState(gcStatus) == GC_RUNNING) {
jmitc91516 1:a5258871b33d 8138 currentPage = GuiStruct_RunningPage1_7;
jmitc91516 1:a5258871b33d 8139 } else {
jmitc91516 1:a5258871b33d 8140 currentPage = GuiStruct_HomePage_1;
jmitc91516 1:a5258871b33d 8141 }
jmitc91516 1:a5258871b33d 8142
jmitc91516 1:a5258871b33d 8143 DisplayCurrentPageData(true);
jmitc91516 1:a5258871b33d 8144 }
jmitc91516 1:a5258871b33d 8145
jmitc91516 1:a5258871b33d 8146
jmitc91516 1:a5258871b33d 8147 /*
jmitc91516 1:a5258871b33d 8148 Displays the data for the current page (easyGUI "structure"), by copying it
jmitc91516 1:a5258871b33d 8149 to the relevant easyGUI variables, and calling the relevant functions to actually display it.
jmitc91516 1:a5258871b33d 8150
jmitc91516 1:a5258871b33d 8151 Args: a boolean specifying whether or not the display is actually to be updated.
jmitc91516 1:a5258871b33d 8152 Even if it is false when we are called, we may set it true if we discover
jmitc91516 1:a5258871b33d 8153 one or more data items has changed - but note that we will not set it false
jmitc91516 1:a5258871b33d 8154 if it is already true. If it is true after we have looked at all
jmitc91516 1:a5258871b33d 8155 the home page data, we will then update the display. (If we are called
jmitc91516 1:a5258871b33d 8156 with this value set to false, the caller is effectively saying
jmitc91516 1:a5258871b33d 8157 'display the current page data only if it has changed').
jmitc91516 1:a5258871b33d 8158
jmitc91516 1:a5258871b33d 8159 No return code.
jmitc91516 1:a5258871b33d 8160 */
jmitc91516 0:47c880c1463d 8161 void GetGCStatusLoop::DisplayCurrentPageData(bool mustUpdateDisplay)
jmitc91516 0:47c880c1463d 8162 {
jmitc91516 0:47c880c1463d 8163 // We don't do re-entrancy here - can get random crashes
jmitc91516 0:47c880c1463d 8164 // if the user switches between pages too quickly
jmitc91516 0:47c880c1463d 8165 if(displayingData) {
jmitc91516 0:47c880c1463d 8166 return;
jmitc91516 0:47c880c1463d 8167 }
jmitc91516 0:47c880c1463d 8168
jmitc91516 0:47c880c1463d 8169 displayingData = true;
jmitc91516 0:47c880c1463d 8170
jmitc91516 1:a5258871b33d 8171 UpdateAllGCComponentStatusColorAreas();
jmitc91516 1:a5258871b33d 8172
jmitc91516 0:47c880c1463d 8173 switch(currentPage) {
jmitc91516 0:47c880c1463d 8174 case GuiStruct_HomePage_1:
jmitc91516 0:47c880c1463d 8175 DisplayHomePageData(mustUpdateDisplay);
jmitc91516 0:47c880c1463d 8176 break;
jmitc91516 0:47c880c1463d 8177 case GuiStruct_ColumnPage1_2:
jmitc91516 1:a5258871b33d 8178 DisplayColumnPageData(mustUpdateDisplay, CONVENTIONAL_COLUMN, GuiStruct_ColumnPage1_2);
jmitc91516 1:a5258871b33d 8179 break;
jmitc91516 1:a5258871b33d 8180 case GuiStruct_ColumnPage2_9:
jmitc91516 1:a5258871b33d 8181 DisplayColumnInformationPageData(mustUpdateDisplay, CONVENTIONAL_COLUMN, GuiStruct_ColumnPage2_9);
jmitc91516 1:a5258871b33d 8182 break;
jmitc91516 5:aceac1035d71 8183 case GuiStruct_ColumnMethodPage_Def:
jmitc91516 5:aceac1035d71 8184 DisplayColumnMethodPageData(mustUpdateDisplay);
jmitc91516 5:aceac1035d71 8185 break;
jmitc91516 1:a5258871b33d 8186 case GuiStruct_ColumnTempProfilePage_60:
jmitc91516 1:a5258871b33d 8187 DisplayColumnTempProfilePageData(mustUpdateDisplay, CONVENTIONAL_COLUMN, GuiStruct_ColumnTempProfilePage_60);
jmitc91516 1:a5258871b33d 8188 break;
jmitc91516 1:a5258871b33d 8189 case GuiStruct_ColumnDHAutoCalibrationPage_Def:
jmitc91516 1:a5258871b33d 8190 DisplayColumnDHAutoCalibrationPageData(mustUpdateDisplay);
jmitc91516 1:a5258871b33d 8191 break;
jmitc91516 1:a5258871b33d 8192 case GuiStruct_ColumnDHManualCalibrationPage_Def:
jmitc91516 1:a5258871b33d 8193 DisplayColumnDHManualCalibrationPageData(mustUpdateDisplay);
jmitc91516 1:a5258871b33d 8194 break;
jmitc91516 1:a5258871b33d 8195 case GuiStruct_ColumnDHSensorCalibration_Def:
jmitc91516 1:a5258871b33d 8196 DisplayColumnDHSensorCalibrationPageData(mustUpdateDisplay);
jmitc91516 1:a5258871b33d 8197 break;
jmitc91516 1:a5258871b33d 8198 case GuiStruct_PSU_DAC_Page_Def:
jmitc91516 1:a5258871b33d 8199 DisplayColumnDHPSUDACPageData(mustUpdateDisplay);
jmitc91516 1:a5258871b33d 8200 break;
jmitc91516 1:a5258871b33d 8201 case GuiStruct_ColumnOvenNudgeAndDampPage_0:
jmitc91516 1:a5258871b33d 8202 DisplayColumnOvenNudgeAndDampPageData(mustUpdateDisplay);
jmitc91516 1:a5258871b33d 8203 break;
jmitc91516 1:a5258871b33d 8204 case GuiStruct_ColumnDHNudgeAndDampPage_0:
jmitc91516 1:a5258871b33d 8205 DisplayColumnDHNudgeAndDampPageData(mustUpdateDisplay);
jmitc91516 1:a5258871b33d 8206 break;
jmitc91516 1:a5258871b33d 8207 case GuiStruct_InjectorNudgeAndDampPage_0:
jmitc91516 1:a5258871b33d 8208 DisplayInjectorNudgeAndDampPageData(mustUpdateDisplay);
jmitc91516 1:a5258871b33d 8209 break;
jmitc91516 1:a5258871b33d 8210 case GuiStruct_DetectorNudgeAndDampPage_0:
jmitc91516 1:a5258871b33d 8211 DisplayDetectorNudgeAndDampPageData(mustUpdateDisplay);
jmitc91516 1:a5258871b33d 8212 break;
jmitc91516 1:a5258871b33d 8213 case GuiStruct_AuxiliaryNudgeAndDampPage_0:
jmitc91516 1:a5258871b33d 8214 DisplayAuxiliaryNudgeAndDampPageData(mustUpdateDisplay);
jmitc91516 1:a5258871b33d 8215 break;
jmitc91516 1:a5258871b33d 8216 case GuiStruct_FanPowerPage_0:
jmitc91516 1:a5258871b33d 8217 DisplayFanPowerPageData(mustUpdateDisplay);
jmitc91516 1:a5258871b33d 8218 break;
jmitc91516 1:a5258871b33d 8219 case GuiStruct_DebugCommandsPage_Def:
jmitc91516 1:a5258871b33d 8220 DisplayDebugCommandsPageData(mustUpdateDisplay);
jmitc91516 0:47c880c1463d 8221 break;
jmitc91516 0:47c880c1463d 8222 case GuiStruct_InjectorPage1_3:
jmitc91516 0:47c880c1463d 8223 DisplayInjectorPageData(mustUpdateDisplay);
jmitc91516 0:47c880c1463d 8224 break;
jmitc91516 6:dba3fbdfd5da 8225 case GuiStruct_InjectorMethodPage_Def:
jmitc91516 6:dba3fbdfd5da 8226 DisplayInjectorMethodPageData(mustUpdateDisplay);
jmitc91516 6:dba3fbdfd5da 8227 break;
jmitc91516 1:a5258871b33d 8228 case GuiStruct_InjectorTempProfilePage_25:
jmitc91516 1:a5258871b33d 8229 DisplayInjectorTempProfilePageData(mustUpdateDisplay);
jmitc91516 1:a5258871b33d 8230 break;
jmitc91516 1:a5258871b33d 8231 case GuiStruct_DetectorFIDPage_4:
jmitc91516 1:a5258871b33d 8232 DisplayDetectorPageData(mustUpdateDisplay, FID_DETECTOR, GuiStruct_DetectorFIDPage_4);
jmitc91516 0:47c880c1463d 8233 break;
jmitc91516 1:a5258871b33d 8234 case GuiStruct_DetectorECDPage_12:
jmitc91516 1:a5258871b33d 8235 DisplayDetectorPageData(mustUpdateDisplay, ECD_DETECTOR, GuiStruct_DetectorECDPage_12);
jmitc91516 1:a5258871b33d 8236 break;
jmitc91516 1:a5258871b33d 8237 case GuiStruct_DetectorFPDPage_14:
jmitc91516 1:a5258871b33d 8238 DisplayDetectorPageData(mustUpdateDisplay, FPD_DETECTOR, GuiStruct_DetectorFPDPage_14);
jmitc91516 1:a5258871b33d 8239 break;
jmitc91516 1:a5258871b33d 8240 case GuiStruct_DetectorNPDPage_28:
jmitc91516 1:a5258871b33d 8241 DisplayDetectorPageData(mustUpdateDisplay, NPD_DETECTOR, GuiStruct_DetectorNPDPage_28);
jmitc91516 1:a5258871b33d 8242 break;
jmitc91516 1:a5258871b33d 8243 case GuiStruct_DetectorNonePage_31:
jmitc91516 1:a5258871b33d 8244 DisplayDetectorPageData(mustUpdateDisplay, NO_DETECTOR, GuiStruct_DetectorNonePage_31);
jmitc91516 0:47c880c1463d 8245 break;
jmitc91516 1:a5258871b33d 8246 case GuiStruct_DetectorPIDPage_29:
jmitc91516 1:a5258871b33d 8247 DisplayDetectorPageData(mustUpdateDisplay, PID_DETECTOR, GuiStruct_DetectorPIDPage_29);
jmitc91516 1:a5258871b33d 8248 break;
jmitc91516 1:a5258871b33d 8249 case GuiStruct_DetectorSPDIDPage_30:
jmitc91516 1:a5258871b33d 8250 DisplayDetectorPageData(mustUpdateDisplay, SPDID_DETECTOR, GuiStruct_DetectorSPDIDPage_30);
jmitc91516 1:a5258871b33d 8251 break;
jmitc91516 1:a5258871b33d 8252 case GuiStruct_DetectorTCDPage_11:
jmitc91516 1:a5258871b33d 8253 DisplayDetectorPageData(mustUpdateDisplay, TCD_DETECTOR, GuiStruct_DetectorTCDPage_11);
jmitc91516 1:a5258871b33d 8254 break;
jmitc91516 1:a5258871b33d 8255 case GuiStruct_GasInformationPage_6:
jmitc91516 1:a5258871b33d 8256 DisplayGasInformationPageData(mustUpdateDisplay);
jmitc91516 0:47c880c1463d 8257 break;
jmitc91516 6:dba3fbdfd5da 8258 case GuiStruct_GasMethodPage_Def:
jmitc91516 6:dba3fbdfd5da 8259 DisplayGasMethodPageData(mustUpdateDisplay);
jmitc91516 6:dba3fbdfd5da 8260 break;
jmitc91516 1:a5258871b33d 8261 case GuiStruct_GasProfilePage_15:
jmitc91516 1:a5258871b33d 8262 DisplayGasFlowProfilePageData(mustUpdateDisplay);
jmitc91516 1:a5258871b33d 8263 break;
jmitc91516 1:a5258871b33d 8264 case GuiStruct_GasCalibrationPage_Def:
jmitc91516 1:a5258871b33d 8265 DisplayGasCalibrationPageData(mustUpdateDisplay);
jmitc91516 1:a5258871b33d 8266 break;
jmitc91516 1:a5258871b33d 8267 case GuiStruct_GasBackPressureDACPage_Def:
jmitc91516 1:a5258871b33d 8268 DisplayGasBackPressureDACPageData(mustUpdateDisplay);
jmitc91516 1:a5258871b33d 8269 break;
jmitc91516 1:a5258871b33d 8270 case GuiStruct_GasChannelDACAndADCPage_Def:
jmitc91516 1:a5258871b33d 8271 DisplayGasChannelDACAndADCPageData(mustUpdateDisplay);
jmitc91516 1:a5258871b33d 8272 break;
jmitc91516 1:a5258871b33d 8273 case GuiStruct_RunningPage1_7:
jmitc91516 1:a5258871b33d 8274 DisplayRunningPageData(mustUpdateDisplay, false);
jmitc91516 0:47c880c1463d 8275 break;
jmitc91516 0:47c880c1463d 8276 case GuiStruct_SettingsPage_5:
jmitc91516 0:47c880c1463d 8277 DisplaySettingsPageData(mustUpdateDisplay);
jmitc91516 0:47c880c1463d 8278 break;
jmitc91516 1:a5258871b33d 8279 case GuiStruct_RunningColumnPage_25:
jmitc91516 1:a5258871b33d 8280 DisplayRunningColumnPageData(mustUpdateDisplay, false);
jmitc91516 1:a5258871b33d 8281 break;
jmitc91516 1:a5258871b33d 8282 case GuiStruct_RunningInjectorPage_26:
jmitc91516 1:a5258871b33d 8283 DisplayRunningInjectorPageData(mustUpdateDisplay);
jmitc91516 1:a5258871b33d 8284 break;
jmitc91516 1:a5258871b33d 8285 case GuiStruct_RunningInjectorProfilePage_Def:
jmitc91516 1:a5258871b33d 8286 DisplayRunningInjectorProfilePageData(mustUpdateDisplay, false);
jmitc91516 1:a5258871b33d 8287 break;
jmitc91516 1:a5258871b33d 8288 case GuiStruct_RunningDetectorPage_27:
jmitc91516 1:a5258871b33d 8289 DisplayRunningDetectorPageData(mustUpdateDisplay);
jmitc91516 1:a5258871b33d 8290 break;
jmitc91516 1:a5258871b33d 8291 case GuiStruct_RunningGasPage_28:
jmitc91516 1:a5258871b33d 8292 DisplayRunningGasPageData(mustUpdateDisplay, false);
jmitc91516 1:a5258871b33d 8293 break;
jmitc91516 1:a5258871b33d 8294 case GuiStruct_ServicingPage_Def:
jmitc91516 1:a5258871b33d 8295 DisplayServicingPage();
jmitc91516 1:a5258871b33d 8296 break;
jmitc91516 1:a5258871b33d 8297 case GuiStruct_ServicingRequired_Def:
jmitc91516 1:a5258871b33d 8298 DisplayServicingRequiredPage();
jmitc91516 1:a5258871b33d 8299 break;
jmitc91516 0:47c880c1463d 8300 default:
jmitc91516 0:47c880c1463d 8301 // Page with no data (e.g. Gas Saver/Standby) - ignore
jmitc91516 0:47c880c1463d 8302 break;
jmitc91516 0:47c880c1463d 8303 }
jmitc91516 0:47c880c1463d 8304
jmitc91516 0:47c880c1463d 8305 displayingData = false;
jmitc91516 0:47c880c1463d 8306 }
jmitc91516 0:47c880c1463d 8307
jmitc91516 0:47c880c1463d 8308 // This effectively duplicates the function of the same name in GCHeatControl -
jmitc91516 0:47c880c1463d 8309 // it seems less complicated than calling GCHeatControl::IsHeatOn from here -
jmitc91516 0:47c880c1463d 8310 // would need an instance of GCHeatControl in this class, etc -
jmitc91516 0:47c880c1463d 8311 // why bother, since both would just call the same GC?
jmitc91516 0:47c880c1463d 8312 bool GetGCStatusLoop::IsHeatOn(void)
jmitc91516 0:47c880c1463d 8313 {
jmitc91516 0:47c880c1463d 8314 char response[50];
jmitc91516 0:47c880c1463d 8315 SetGCDeviceReport("QHTS", response);
jmitc91516 0:47c880c1463d 8316
jmitc91516 0:47c880c1463d 8317 // Check for "EPKT" first
jmitc91516 0:47c880c1463d 8318 if(response[0] == 'E') return false;
jmitc91516 0:47c880c1463d 8319
jmitc91516 0:47c880c1463d 8320 return (response[7] != '0');
jmitc91516 0:47c880c1463d 8321 }
jmitc91516 0:47c880c1463d 8322
jmitc91516 1:a5258871b33d 8323 /*
jmitc91516 1:a5258871b33d 8324 Gets the GC status code, and returns it as an integer.
jmitc91516 1:a5258871b33d 8325
jmitc91516 1:a5258871b33d 8326 No arguments.
jmitc91516 1:a5258871b33d 8327
jmitc91516 1:a5258871b33d 8328 Returns the status as an integer - see the GC_STATE enumeration (GCStateAndFaultCodes.h)
jmitc91516 1:a5258871b33d 8329 for the meaning of each value.
jmitc91516 1:a5258871b33d 8330 */
jmitc91516 0:47c880c1463d 8331 int GetGCStatusLoop::GetInstrumentStatus(void)
jmitc91516 0:47c880c1463d 8332 {
jmitc91516 0:47c880c1463d 8333 char response[50];
jmitc91516 0:47c880c1463d 8334 SetGCDeviceReport("QSTA", response);
jmitc91516 0:47c880c1463d 8335
jmitc91516 0:47c880c1463d 8336 // We expect a response of the form "DSTA00nn", where 'nn' is a two-digit code representing the status.
jmitc91516 0:47c880c1463d 8337 // We convert those two digits to an integer, and return the result to the user
jmitc91516 0:47c880c1463d 8338
jmitc91516 0:47c880c1463d 8339 // But check for "EPKT" first
jmitc91516 1:a5258871b33d 8340 #ifdef USE_VERSION_102 // See GCStateAndFaultCodes.h
jmitc91516 1:a5258871b33d 8341 if(response[0] == 'E') return GC_STATE_102_METHOD_FAULTED;
jmitc91516 1:a5258871b33d 8342 #else
jmitc91516 1:a5258871b33d 8343 if(response[0] == 'E') return GC_STATE_FAULTED;
jmitc91516 1:a5258871b33d 8344 #endif
jmitc91516 0:47c880c1463d 8345
jmitc91516 0:47c880c1463d 8346 int retval;
jmitc91516 0:47c880c1463d 8347 sscanf(&response[6], "%d", &retval);
jmitc91516 0:47c880c1463d 8348 //#define DEBUG_HERE
jmitc91516 0:47c880c1463d 8349 #ifdef DEBUG_HERE
jmitc91516 0:47c880c1463d 8350 char dbg[100];
jmitc91516 0:47c880c1463d 8351 sprintf(dbg, "GGCSL::GIS - returning : %d", retval);
jmitc91516 1:a5258871b33d 8352 EasyGUIDebugPrint(dbg, 0, 20);
jmitc91516 1:a5258871b33d 8353 #undef DEBUG_HERE
jmitc91516 1:a5258871b33d 8354 #endif
jmitc91516 0:47c880c1463d 8355 return retval;
jmitc91516 0:47c880c1463d 8356 }
jmitc91516 0:47c880c1463d 8357
jmitc91516 1:a5258871b33d 8358 /*
jmitc91516 1:a5258871b33d 8359 Tells the caller whether or not the GC is running, based on its current state
jmitc91516 1:a5258871b33d 8360 (note that there is not one single 'GC_IS_RUNNING' state).
jmitc91516 1:a5258871b33d 8361
jmitc91516 1:a5258871b33d 8362 Returns true if the GC is running, false if not.
jmitc91516 1:a5258871b33d 8363 */
jmitc91516 1:a5258871b33d 8364 bool GetGCStatusLoop::GCIsRunning(void)
jmitc91516 1:a5258871b33d 8365 {
jmitc91516 1:a5258871b33d 8366 int currentGCState = GetInstrumentStatus();
jmitc91516 1:a5258871b33d 8367
jmitc91516 1:a5258871b33d 8368 return(GCStateOrFaultCode::GetSimplifiedGCState(currentGCState) == GC_RUNNING);
jmitc91516 1:a5258871b33d 8369 }
jmitc91516 1:a5258871b33d 8370
jmitc91516 1:a5258871b33d 8371
jmitc91516 1:a5258871b33d 8372 /*
jmitc91516 1:a5258871b33d 8373 Tells the caller whether or not the GC is in the 'stabilising' state
jmitc91516 1:a5258871b33d 8374
jmitc91516 1:a5258871b33d 8375 Returns true if the GC is ing, false if not.
jmitc91516 1:a5258871b33d 8376 */
jmitc91516 1:a5258871b33d 8377 bool GetGCStatusLoop::GCIsStabilising(void)
jmitc91516 1:a5258871b33d 8378 {
jmitc91516 1:a5258871b33d 8379 int currentGCState = GetInstrumentStatus();
jmitc91516 1:a5258871b33d 8380
jmitc91516 1:a5258871b33d 8381 return(GCStateOrFaultCode::GetSimplifiedGCState(currentGCState) == GC_STABILISING);
jmitc91516 1:a5258871b33d 8382 }
jmitc91516 1:a5258871b33d 8383
jmitc91516 1:a5258871b33d 8384
jmitc91516 1:a5258871b33d 8385 /*
jmitc91516 1:a5258871b33d 8386 Returns the status of the specified component.
jmitc91516 1:a5258871b33d 8387
jmitc91516 1:a5258871b33d 8388 Args: the component whose status is to be obtained, as a value in the GCComponent enumeration.
jmitc91516 1:a5258871b33d 8389
jmitc91516 1:a5258871b33d 8390 Return value: the status of the specified component, as a value in the GCComponentStatus enumeration.
jmitc91516 1:a5258871b33d 8391
jmitc91516 1:a5258871b33d 8392 The GCComponent and GCComponentStatus enumerations are defined in GCComponentStatusEnums.h.
jmitc91516 1:a5258871b33d 8393 */
jmitc91516 0:47c880c1463d 8394 GCComponentStatus GetGCStatusLoop::GetComponentStatus(GCComponent component)
jmitc91516 0:47c880c1463d 8395 {
jmitc91516 1:a5258871b33d 8396 int currentGCState = GetInstrumentStatus();
jmitc91516 1:a5258871b33d 8397 GCStateSimplified simplifiedGCState = GCStateOrFaultCode::GetSimplifiedGCState(currentGCState);
jmitc91516 1:a5258871b33d 8398
jmitc91516 1:a5258871b33d 8399 if(simplifiedGCState == GC_RUNNING) {
jmitc91516 1:a5258871b33d 8400 return READY; // It must be ready, if the GC is running
jmitc91516 1:a5258871b33d 8401 }
jmitc91516 1:a5258871b33d 8402 // 'else'...
jmitc91516 1:a5258871b33d 8403
jmitc91516 1:a5258871b33d 8404 switch (simplifiedGCState) {
jmitc91516 1:a5258871b33d 8405 case GC_READY_TO_RUN:
jmitc91516 0:47c880c1463d 8406 return READY;
jmitc91516 1:a5258871b33d 8407 case GC_FAULTED:
jmitc91516 0:47c880c1463d 8408 return FAULTED;
jmitc91516 0:47c880c1463d 8409 default:
jmitc91516 0:47c880c1463d 8410 break; // Fall through to code below...
jmitc91516 0:47c880c1463d 8411 }
jmitc91516 0:47c880c1463d 8412
jmitc91516 0:47c880c1463d 8413 char buff[100];
jmitc91516 0:47c880c1463d 8414 float temperature, maxTemperature;
jmitc91516 0:47c880c1463d 8415 float pressure;
jmitc91516 0:47c880c1463d 8416
jmitc91516 0:47c880c1463d 8417 switch (component) {
jmitc91516 0:47c880c1463d 8418 case COLUMN:
jmitc91516 0:47c880c1463d 8419 GetColumnTemperature(&temperature);
jmitc91516 0:47c880c1463d 8420 if(temperature < 0.0f) {// Got "EPKT" response
jmitc91516 0:47c880c1463d 8421 return FAULTED;
jmitc91516 0:47c880c1463d 8422 }
jmitc91516 0:47c880c1463d 8423 if(temperature < 0.1f) { // Allow for floating-point rounding errors
jmitc91516 0:47c880c1463d 8424 return COLD;
jmitc91516 0:47c880c1463d 8425 }
jmitc91516 0:47c880c1463d 8426 GetColumnMaxTemperature(&maxTemperature);
jmitc91516 0:47c880c1463d 8427 if(temperature < maxTemperature) {
jmitc91516 0:47c880c1463d 8428 return HEATING_UP;
jmitc91516 0:47c880c1463d 8429 } else {
jmitc91516 0:47c880c1463d 8430 return READY;
jmitc91516 0:47c880c1463d 8431 }
jmitc91516 0:47c880c1463d 8432 case INJECTOR:
jmitc91516 0:47c880c1463d 8433 GetInjectorTemperature(&temperature);
jmitc91516 0:47c880c1463d 8434 if(temperature < 0.0f) {// Got "EPKT" response
jmitc91516 0:47c880c1463d 8435 return FAULTED;
jmitc91516 0:47c880c1463d 8436 }
jmitc91516 0:47c880c1463d 8437 if(temperature < 0.1f) { // Allow for floating-point rounding errors
jmitc91516 0:47c880c1463d 8438 return COLD;
jmitc91516 0:47c880c1463d 8439 }
jmitc91516 0:47c880c1463d 8440 //TODO: Fill in...
jmitc91516 0:47c880c1463d 8441 return HEATING_UP;
jmitc91516 0:47c880c1463d 8442 case DETECTOR:
jmitc91516 0:47c880c1463d 8443 GetDetectorTemperature(&temperature);
jmitc91516 0:47c880c1463d 8444 if(temperature < 0.0f) {// Got "EPKT" response
jmitc91516 0:47c880c1463d 8445 return FAULTED;
jmitc91516 0:47c880c1463d 8446 }
jmitc91516 0:47c880c1463d 8447 if(temperature < 0.1f) { // Allow for floating-point rounding errors
jmitc91516 0:47c880c1463d 8448 return COLD;
jmitc91516 0:47c880c1463d 8449 }
jmitc91516 0:47c880c1463d 8450 //TODO: Fill in...
jmitc91516 0:47c880c1463d 8451 return HEATING_UP;
jmitc91516 0:47c880c1463d 8452 case GAS:
jmitc91516 1:a5258871b33d 8453 if(GetGasControlMode(buff, false, false) == false) {
jmitc91516 1:a5258871b33d 8454 // Got "EPKT"
jmitc91516 1:a5258871b33d 8455 return FAULTED;
jmitc91516 1:a5258871b33d 8456 }
jmitc91516 0:47c880c1463d 8457 GetGasPressure(&pressure);
jmitc91516 0:47c880c1463d 8458 if(pressure < 0.0f) {// Got "EPKT" response
jmitc91516 0:47c880c1463d 8459 return FAULTED;
jmitc91516 0:47c880c1463d 8460 }
jmitc91516 0:47c880c1463d 8461 if(pressure < 0.1f) { // Allow for floating-point rounding errors
jmitc91516 0:47c880c1463d 8462 return COLD;
jmitc91516 0:47c880c1463d 8463 }
jmitc91516 0:47c880c1463d 8464 //TODO: Fill in...
jmitc91516 0:47c880c1463d 8465 return HEATING_UP;
jmitc91516 0:47c880c1463d 8466 default:
jmitc91516 0:47c880c1463d 8467 sprintf(buff, "Unknown component: %d", component);
jmitc91516 1:a5258871b33d 8468 EasyGUIDebugPrint(buff, 0, 20);
jmitc91516 0:47c880c1463d 8469 break;
jmitc91516 0:47c880c1463d 8470 }
jmitc91516 0:47c880c1463d 8471
jmitc91516 0:47c880c1463d 8472 return FAULTED;
jmitc91516 0:47c880c1463d 8473 }
jmitc91516 0:47c880c1463d 8474
jmitc91516 1:a5258871b33d 8475 /*
jmitc91516 1:a5258871b33d 8476 Gets the status of the specified component, amd returns an appropriate null-terminated descriptive string
jmitc91516 1:a5258871b33d 8477 in the buffer provided
jmitc91516 1:a5258871b33d 8478
jmitc91516 1:a5258871b33d 8479 Note also that this code is intended to be as efficient as possible.
jmitc91516 1:a5258871b33d 8480
jmitc91516 1:a5258871b33d 8481 Args: the component whose status is to be obtained, as a value in the GCComponent enumeration.
jmitc91516 1:a5258871b33d 8482 pointer to the buffer to contain the null-terminated descriptive string
jmitc91516 1:a5258871b33d 8483
jmitc91516 1:a5258871b33d 8484 The GCComponent and GCComponentStatus enumerations are defined in GCComponentStatusEnums.h.
jmitc91516 1:a5258871b33d 8485
jmitc91516 1:a5258871b33d 8486 No return value.
jmitc91516 1:a5258871b33d 8487 */
jmitc91516 1:a5258871b33d 8488 void GetGCStatusLoop::GetComponentStatusString(GCComponent component, char *buff)
jmitc91516 1:a5258871b33d 8489 {
jmitc91516 1:a5258871b33d 8490 int index = 0;
jmitc91516 1:a5258871b33d 8491 switch (GetComponentStatus(component)) {
jmitc91516 1:a5258871b33d 8492 case COLD:
jmitc91516 1:a5258871b33d 8493 buff[index++] = 'C';
jmitc91516 1:a5258871b33d 8494 buff[index++] = 'o';
jmitc91516 1:a5258871b33d 8495 buff[index++] = 'l';
jmitc91516 1:a5258871b33d 8496 buff[index++] = 'd';
jmitc91516 1:a5258871b33d 8497 break;
jmitc91516 1:a5258871b33d 8498 case HEATING_UP:
jmitc91516 1:a5258871b33d 8499 if(IsHeatOn()) {
jmitc91516 1:a5258871b33d 8500 if(GCIsStabilising()) {
jmitc91516 1:a5258871b33d 8501 buff[index++] = 'S';
jmitc91516 1:a5258871b33d 8502 buff[index++] = 't';
jmitc91516 1:a5258871b33d 8503 buff[index++] = 'a';
jmitc91516 1:a5258871b33d 8504 buff[index++] = 'b';
jmitc91516 1:a5258871b33d 8505 buff[index++] = 'i';
jmitc91516 1:a5258871b33d 8506 buff[index++] = 'l';
jmitc91516 1:a5258871b33d 8507 buff[index++] = 'i';
jmitc91516 1:a5258871b33d 8508 buff[index++] = 's';
jmitc91516 1:a5258871b33d 8509 buff[index++] = 'i';
jmitc91516 1:a5258871b33d 8510 buff[index++] = 'n';
jmitc91516 1:a5258871b33d 8511 buff[index++] = 'g';
jmitc91516 1:a5258871b33d 8512 } else {
jmitc91516 1:a5258871b33d 8513 // Assume it is equilibrating
jmitc91516 1:a5258871b33d 8514 buff[index++] = 'E';
jmitc91516 1:a5258871b33d 8515 buff[index++] = 'q';
jmitc91516 1:a5258871b33d 8516 buff[index++] = 'u';
jmitc91516 1:a5258871b33d 8517 buff[index++] = 'i';
jmitc91516 1:a5258871b33d 8518 buff[index++] = 'l';
jmitc91516 1:a5258871b33d 8519 buff[index++] = 'i';
jmitc91516 1:a5258871b33d 8520 buff[index++] = 'b';
jmitc91516 1:a5258871b33d 8521 buff[index++] = 'r';
jmitc91516 1:a5258871b33d 8522 buff[index++] = 'a';
jmitc91516 1:a5258871b33d 8523 buff[index++] = 't';
jmitc91516 1:a5258871b33d 8524 buff[index++] = 'i';
jmitc91516 1:a5258871b33d 8525 buff[index++] = 'n';
jmitc91516 1:a5258871b33d 8526 buff[index++] = 'g';
jmitc91516 1:a5258871b33d 8527 }
jmitc91516 1:a5258871b33d 8528 } else {
jmitc91516 1:a5258871b33d 8529 buff[index++] = 'I';
jmitc91516 1:a5258871b33d 8530 buff[index++] = 'd';
jmitc91516 1:a5258871b33d 8531 buff[index++] = 'l';
jmitc91516 1:a5258871b33d 8532 buff[index++] = 'e';
jmitc91516 1:a5258871b33d 8533 }
jmitc91516 1:a5258871b33d 8534 break;
jmitc91516 1:a5258871b33d 8535 case READY:
jmitc91516 1:a5258871b33d 8536 buff[index++] = 'R';
jmitc91516 1:a5258871b33d 8537 buff[index++] = 'e';
jmitc91516 1:a5258871b33d 8538 buff[index++] = 'a';
jmitc91516 1:a5258871b33d 8539 buff[index++] = 'd';
jmitc91516 1:a5258871b33d 8540 buff[index++] = 'y';
jmitc91516 1:a5258871b33d 8541 break;
jmitc91516 1:a5258871b33d 8542 default: // Including FAULTED
jmitc91516 1:a5258871b33d 8543 buff[index++] = 'F';
jmitc91516 1:a5258871b33d 8544 buff[index++] = 'a';
jmitc91516 1:a5258871b33d 8545 buff[index++] = 'u';
jmitc91516 1:a5258871b33d 8546 buff[index++] = 'l';
jmitc91516 1:a5258871b33d 8547 buff[index++] = 't';
jmitc91516 1:a5258871b33d 8548 buff[index++] = 'e';
jmitc91516 1:a5258871b33d 8549 buff[index++] = 'd';
jmitc91516 1:a5258871b33d 8550 break;
jmitc91516 1:a5258871b33d 8551 }
jmitc91516 1:a5258871b33d 8552 buff[index++] = '\0';
jmitc91516 1:a5258871b33d 8553 }
jmitc91516 1:a5258871b33d 8554
jmitc91516 1:a5258871b33d 8555
jmitc91516 1:a5258871b33d 8556 /*
jmitc91516 1:a5258871b33d 8557 Returns true if the GC is in standby mode, false if not.
jmitc91516 1:a5258871b33d 8558 */
jmitc91516 0:47c880c1463d 8559 bool GetGCStatusLoop::GCIsInStandbyMode(void)
jmitc91516 0:47c880c1463d 8560 {
jmitc91516 0:47c880c1463d 8561 char response[50];
jmitc91516 0:47c880c1463d 8562 SetGCDeviceReport("QDIS", response);
jmitc91516 0:47c880c1463d 8563
jmitc91516 1:a5258871b33d 8564 // We expect a response of the form "DDIS000n", where 'n' == '0' means the GC is in standby mode,
jmitc91516 0:47c880c1463d 8565 // while 'n' == '1' means that it is not in standby mode
jmitc91516 0:47c880c1463d 8566
jmitc91516 0:47c880c1463d 8567 bool retval = (response[7] == '0');
jmitc91516 0:47c880c1463d 8568
jmitc91516 0:47c880c1463d 8569 // Also check for "EPKT"
jmitc91516 0:47c880c1463d 8570 if(response[0] == 'E') retval = false;
jmitc91516 0:47c880c1463d 8571
jmitc91516 0:47c880c1463d 8572 //#define DEBUG_HERE
jmitc91516 0:47c880c1463d 8573 #ifdef DEBUG_HERE
jmitc91516 0:47c880c1463d 8574 if(retval) {
jmitc91516 1:a5258871b33d 8575 EasyGUIDebugPrint("GGCSL::GCIISM - returning true", 0, 20);
jmitc91516 0:47c880c1463d 8576 } else {
jmitc91516 1:a5258871b33d 8577 EasyGUIDebugPrint("GGCSL::GCIISM - returning false", 0, 20);
jmitc91516 0:47c880c1463d 8578 }
jmitc91516 0:47c880c1463d 8579 #endif
jmitc91516 0:47c880c1463d 8580 //#undef DEBUG_HERE
jmitc91516 0:47c880c1463d 8581 return retval;
jmitc91516 0:47c880c1463d 8582 }
jmitc91516 0:47c880c1463d 8583
jmitc91516 1:a5258871b33d 8584 /*
jmitc91516 1:a5258871b33d 8585 Caller uses this to tell us that the GC has exited from standby mode
jmitc91516 1:a5258871b33d 8586 */
jmitc91516 0:47c880c1463d 8587 void GetGCStatusLoop::ExitedGCStandbyMode(void)
jmitc91516 0:47c880c1463d 8588 {
jmitc91516 0:47c880c1463d 8589 gcInStandbyMode = false;
jmitc91516 0:47c880c1463d 8590 }
jmitc91516 0:47c880c1463d 8591
jmitc91516 1:a5258871b33d 8592 /*
jmitc91516 1:a5258871b33d 8593 Takes the GC out of standby mode, by passing it the "CDIS" command.
jmitc91516 1:a5258871b33d 8594
jmitc91516 1:a5258871b33d 8595 Returns true if the GC returned "DACK" in response, false if it returned "DNAK".
jmitc91516 1:a5258871b33d 8596 */
jmitc91516 1:a5258871b33d 8597 bool GetGCStatusLoop::ExitGCStandbyMode(void)
jmitc91516 1:a5258871b33d 8598 {
jmitc91516 1:a5258871b33d 8599 if(ExecuteCommandWithDACKResponse("CDIS")) {
jmitc91516 1:a5258871b33d 8600
jmitc91516 1:a5258871b33d 8601 ExitedGCStandbyMode();
jmitc91516 1:a5258871b33d 8602
jmitc91516 1:a5258871b33d 8603 return true;
jmitc91516 1:a5258871b33d 8604 }
jmitc91516 1:a5258871b33d 8605
jmitc91516 1:a5258871b33d 8606 return false;
jmitc91516 1:a5258871b33d 8607 }
jmitc91516 1:a5258871b33d 8608
jmitc91516 1:a5258871b33d 8609 /*
jmitc91516 1:a5258871b33d 8610 Displays the standby mode page (easyGUI "structure")
jmitc91516 1:a5258871b33d 8611 */
jmitc91516 0:47c880c1463d 8612 void GetGCStatusLoop::DisplayStandbyModePage(void)
jmitc91516 0:47c880c1463d 8613 {
jmitc91516 1:a5258871b33d 8614 #ifdef USING_BACKGROUND_BITMAP
jmitc91516 1:a5258871b33d 8615 DrawBackgroundBitmap();
jmitc91516 1:a5258871b33d 8616 #else
jmitc91516 0:47c880c1463d 8617 GuiLib_Clear();
jmitc91516 1:a5258871b33d 8618 #endif
jmitc91516 0:47c880c1463d 8619
jmitc91516 0:47c880c1463d 8620 GuiLib_ShowScreen(GuiStruct_GasSaver_9, GuiLib_NO_CURSOR, GuiLib_RESET_AUTO_REDRAW);
jmitc91516 0:47c880c1463d 8621
jmitc91516 0:47c880c1463d 8622 GuiLib_Refresh();
jmitc91516 0:47c880c1463d 8623
jmitc91516 0:47c880c1463d 8624 #define DEBUG_HERE
jmitc91516 0:47c880c1463d 8625 #ifdef DEBUG_HERE
jmitc91516 0:47c880c1463d 8626 char dbg[100];
jmitc91516 0:47c880c1463d 8627 sprintf(dbg, "After GuiLib_Clear 7");
jmitc91516 1:a5258871b33d 8628 EasyGUIDebugPrint(dbg, 0, 20);
jmitc91516 0:47c880c1463d 8629 #undef DEBUG_HERE
jmitc91516 0:47c880c1463d 8630 #endif
jmitc91516 0:47c880c1463d 8631
jmitc91516 0:47c880c1463d 8632 SetCurrentPage(GuiStruct_GasSaver_9);
jmitc91516 0:47c880c1463d 8633 }
jmitc91516 0:47c880c1463d 8634
jmitc91516 1:a5258871b33d 8635 /*
jmitc91516 1:a5258871b33d 8636 Displays the easyGUI page (or "structure") that shows the user that the GC has faulted
jmitc91516 1:a5258871b33d 8637 */
jmitc91516 1:a5258871b33d 8638 void GetGCStatusLoop::DisplayGCInFaultStatePage(bool clearDisplay)
jmitc91516 1:a5258871b33d 8639 {
jmitc91516 1:a5258871b33d 8640 if(clearDisplay) {
jmitc91516 1:a5258871b33d 8641 #ifdef USING_BACKGROUND_BITMAP
jmitc91516 1:a5258871b33d 8642 DrawBackgroundBitmap();
jmitc91516 1:a5258871b33d 8643 #else
jmitc91516 1:a5258871b33d 8644 GuiLib_Clear();
jmitc91516 1:a5258871b33d 8645 #endif
jmitc91516 1:a5258871b33d 8646 }
jmitc91516 1:a5258871b33d 8647
jmitc91516 1:a5258871b33d 8648 // Display red background to the error message, same as for a single component page
jmitc91516 1:a5258871b33d 8649 GCComponentStatusColorArea::DisplayErrorRectangle();
jmitc91516 0:47c880c1463d 8650
jmitc91516 0:47c880c1463d 8651 GuiLib_ShowScreen(GuiStruct_GCInFaultStatePage_11, GuiLib_NO_CURSOR, GuiLib_RESET_AUTO_REDRAW);
jmitc91516 0:47c880c1463d 8652
jmitc91516 0:47c880c1463d 8653 GuiLib_Refresh();
jmitc91516 0:47c880c1463d 8654
jmitc91516 0:47c880c1463d 8655 #define DEBUG_HERE
jmitc91516 0:47c880c1463d 8656 #ifdef DEBUG_HERE
jmitc91516 0:47c880c1463d 8657 char dbg[100];
jmitc91516 0:47c880c1463d 8658 sprintf(dbg, "After GuiLib_Clear 8");
jmitc91516 1:a5258871b33d 8659 EasyGUIDebugPrint(dbg, 0, 20);
jmitc91516 0:47c880c1463d 8660 #undef DEBUG_HERE
jmitc91516 0:47c880c1463d 8661 #endif
jmitc91516 0:47c880c1463d 8662
jmitc91516 0:47c880c1463d 8663 SetCurrentPage(GuiStruct_GCInFaultStatePage_11);
jmitc91516 0:47c880c1463d 8664 }
jmitc91516 0:47c880c1463d 8665
jmitc91516 1:a5258871b33d 8666 void GetGCStatusLoop::DisplayRunCompletePage(void)
jmitc91516 1:a5258871b33d 8667 {
jmitc91516 1:a5258871b33d 8668 #ifdef USING_BACKGROUND_BITMAP
jmitc91516 1:a5258871b33d 8669 DrawBackgroundBitmap();
jmitc91516 1:a5258871b33d 8670 #else
jmitc91516 1:a5258871b33d 8671 GuiLib_Clear();
jmitc91516 1:a5258871b33d 8672 #endif
jmitc91516 1:a5258871b33d 8673
jmitc91516 1:a5258871b33d 8674 GuiLib_ShowScreen(GuiStruct_RunCompletePage_41, GuiLib_NO_CURSOR, GuiLib_RESET_AUTO_REDRAW);
jmitc91516 1:a5258871b33d 8675
jmitc91516 1:a5258871b33d 8676 GuiLib_Refresh();
jmitc91516 1:a5258871b33d 8677
jmitc91516 1:a5258871b33d 8678 SetCurrentPage(GuiStruct_RunCompletePage_41);
jmitc91516 1:a5258871b33d 8679 }
jmitc91516 1:a5258871b33d 8680
jmitc91516 1:a5258871b33d 8681 void GetGCStatusLoop::DisplayRunAbortedPage(void)
jmitc91516 1:a5258871b33d 8682 {
jmitc91516 1:a5258871b33d 8683 #ifdef USING_BACKGROUND_BITMAP
jmitc91516 1:a5258871b33d 8684 DrawBackgroundBitmap();
jmitc91516 1:a5258871b33d 8685 #else
jmitc91516 1:a5258871b33d 8686 GuiLib_Clear();
jmitc91516 1:a5258871b33d 8687 #endif
jmitc91516 1:a5258871b33d 8688
jmitc91516 1:a5258871b33d 8689 GuiLib_ShowScreen(GuiStruct_RunAbortedPage_Def, GuiLib_NO_CURSOR, GuiLib_RESET_AUTO_REDRAW);
jmitc91516 1:a5258871b33d 8690
jmitc91516 1:a5258871b33d 8691 GuiLib_Refresh();
jmitc91516 1:a5258871b33d 8692
jmitc91516 1:a5258871b33d 8693 SetCurrentPage(GuiStruct_RunAbortedPage_Def);
jmitc91516 1:a5258871b33d 8694 }
jmitc91516 1:a5258871b33d 8695
jmitc91516 1:a5258871b33d 8696 /*
jmitc91516 1:a5258871b33d 8697 Takes the GC out of its error state, by passing it the "CCLR" command.
jmitc91516 1:a5258871b33d 8698
jmitc91516 1:a5258871b33d 8699 Returns true if the GC returned "DACK" in response, false if it returned "DNAK".
jmitc91516 1:a5258871b33d 8700 */
jmitc91516 1:a5258871b33d 8701 bool GetGCStatusLoop::ClearGCErrors(void)
jmitc91516 1:a5258871b33d 8702 {
jmitc91516 1:a5258871b33d 8703 return ExecuteCommandWithDACKResponse("CCLR");
jmitc91516 1:a5258871b33d 8704 }
jmitc91516 1:a5258871b33d 8705
jmitc91516 1:a5258871b33d 8706 /*
jmitc91516 1:a5258871b33d 8707 Aborts the current GC run, by passing it the "CABT" command.
jmitc91516 1:a5258871b33d 8708
jmitc91516 1:a5258871b33d 8709 Returns true if the GC returned "DACK" in response, false if it returned "DNAK".
jmitc91516 1:a5258871b33d 8710 */
jmitc91516 1:a5258871b33d 8711 bool GetGCStatusLoop::AbortGCRun(void)
jmitc91516 1:a5258871b33d 8712 {
jmitc91516 1:a5258871b33d 8713 return ExecuteCommandWithDACKResponse("CABT");
jmitc91516 1:a5258871b33d 8714 }
jmitc91516 1:a5258871b33d 8715
jmitc91516 1:a5258871b33d 8716
jmitc91516 1:a5258871b33d 8717 /*
jmitc91516 1:a5258871b33d 8718 Make sure that the component statuses, recorded in each of the colour areas for the home page,
jmitc91516 1:a5258871b33d 8719 are up to date.
jmitc91516 1:a5258871b33d 8720 */
jmitc91516 0:47c880c1463d 8721 void GetGCStatusLoop::UpdateHomePageGCComponentStatusColorAreas(void)
jmitc91516 0:47c880c1463d 8722 {
jmitc91516 1:a5258871b33d 8723 GCComponentStatus columnStatus = GetComponentStatus(COLUMN);
jmitc91516 1:a5258871b33d 8724 GCComponentStatus injectorStatus = GetComponentStatus(INJECTOR);
jmitc91516 1:a5258871b33d 8725 GCComponentStatus detectorStatus = GetComponentStatus(DETECTOR);
jmitc91516 1:a5258871b33d 8726 GCComponentStatus gasStatus = GetComponentStatus(GAS);
jmitc91516 1:a5258871b33d 8727
jmitc91516 1:a5258871b33d 8728 if(homePageGCComponentStatusColorAreas != NULL) {
jmitc91516 1:a5258871b33d 8729 homePageGCComponentStatusColorAreas->SetGCComponentStatus(COLUMN, columnStatus);
jmitc91516 1:a5258871b33d 8730 homePageGCComponentStatusColorAreas->SetGCComponentStatus(INJECTOR, injectorStatus);
jmitc91516 1:a5258871b33d 8731 homePageGCComponentStatusColorAreas->SetGCComponentStatus(DETECTOR, detectorStatus);
jmitc91516 1:a5258871b33d 8732 homePageGCComponentStatusColorAreas->SetGCComponentStatus(GAS, gasStatus);
jmitc91516 1:a5258871b33d 8733 }
jmitc91516 1:a5258871b33d 8734 }
jmitc91516 1:a5258871b33d 8735
jmitc91516 1:a5258871b33d 8736 /*
jmitc91516 1:a5258871b33d 8737 Returns true if the current status of any of the components on the home page
jmitc91516 1:a5258871b33d 8738 is now different to that displayed in the relevant status rectangle
jmitc91516 1:a5258871b33d 8739 *** when we last displayed it ***
jmitc91516 1:a5258871b33d 8740 */
jmitc91516 1:a5258871b33d 8741 bool GetGCStatusLoop::HomePageGCComponentStatusesHaveChanged(void)
jmitc91516 1:a5258871b33d 8742 {
jmitc91516 0:47c880c1463d 8743 if(homePageGCComponentStatusColorAreas != NULL) {
jmitc91516 1:a5258871b33d 8744 if(GetComponentStatus(COLUMN) != lastColumnStatusDisplayedOnHomePage) {
jmitc91516 1:a5258871b33d 8745 return true;
jmitc91516 1:a5258871b33d 8746 }
jmitc91516 1:a5258871b33d 8747
jmitc91516 1:a5258871b33d 8748 if(GetComponentStatus(INJECTOR) != lastInjectorStatusDisplayedOnHomePage) {
jmitc91516 1:a5258871b33d 8749 return true;
jmitc91516 1:a5258871b33d 8750 }
jmitc91516 1:a5258871b33d 8751
jmitc91516 1:a5258871b33d 8752 if(GetComponentStatus(DETECTOR) != lastDetectorStatusDisplayedOnHomePage) {
jmitc91516 1:a5258871b33d 8753 return true;
jmitc91516 1:a5258871b33d 8754 }
jmitc91516 1:a5258871b33d 8755
jmitc91516 1:a5258871b33d 8756 if(GetComponentStatus(GAS) != lastGasStatusDisplayedOnHomePage) {
jmitc91516 1:a5258871b33d 8757 return true;
jmitc91516 1:a5258871b33d 8758 }
jmitc91516 1:a5258871b33d 8759 }
jmitc91516 1:a5258871b33d 8760
jmitc91516 1:a5258871b33d 8761 return false;
jmitc91516 1:a5258871b33d 8762 }
jmitc91516 1:a5258871b33d 8763
jmitc91516 1:a5258871b33d 8764 /*
jmitc91516 1:a5258871b33d 8765 Make sure that the component status, recorded in the colour area for a single component page,
jmitc91516 1:a5258871b33d 8766 is up to date.
jmitc91516 1:a5258871b33d 8767
jmitc91516 1:a5258871b33d 8768 Args: the component whose colour area is to be updated, as a value in the GCComponent enumeration.
jmitc91516 1:a5258871b33d 8769
jmitc91516 1:a5258871b33d 8770 The GCComponent enumeration is defined in GCComponentStatusEnums.h.
jmitc91516 1:a5258871b33d 8771 */
jmitc91516 0:47c880c1463d 8772 void GetGCStatusLoop::UpdateSingleGCComponentPageStatusColorArea(GCComponent component)
jmitc91516 0:47c880c1463d 8773 {
jmitc91516 1:a5258871b33d 8774 GCComponentStatus componentStatus = GetComponentStatus(component);
jmitc91516 1:a5258871b33d 8775
jmitc91516 1:a5258871b33d 8776 if(singleGCComponentPageStatusColorAreas != NULL) {
jmitc91516 1:a5258871b33d 8777 singleGCComponentPageStatusColorAreas->SetGCComponentStatus(component, componentStatus);
jmitc91516 1:a5258871b33d 8778 }
jmitc91516 1:a5258871b33d 8779 }
jmitc91516 1:a5258871b33d 8780
jmitc91516 1:a5258871b33d 8781 /*
jmitc91516 1:a5258871b33d 8782 Update all the component status colour areas (i.e. the home page colour areas
jmitc91516 1:a5258871b33d 8783 and the single component page colour areas), so they all match
jmitc91516 1:a5258871b33d 8784 */
jmitc91516 1:a5258871b33d 8785 void GetGCStatusLoop::UpdateAllGCComponentStatusColorAreas(void)
jmitc91516 1:a5258871b33d 8786 {
jmitc91516 1:a5258871b33d 8787 GCComponentStatus columnStatus = GetComponentStatus(COLUMN);
jmitc91516 1:a5258871b33d 8788 GCComponentStatus injectorStatus = GetComponentStatus(INJECTOR);
jmitc91516 1:a5258871b33d 8789 GCComponentStatus detectorStatus = GetComponentStatus(DETECTOR);
jmitc91516 1:a5258871b33d 8790 GCComponentStatus gasStatus = GetComponentStatus(GAS);
jmitc91516 1:a5258871b33d 8791
jmitc91516 1:a5258871b33d 8792 if(homePageGCComponentStatusColorAreas != NULL) {
jmitc91516 1:a5258871b33d 8793 homePageGCComponentStatusColorAreas->SetGCComponentStatus(COLUMN, columnStatus);
jmitc91516 1:a5258871b33d 8794 homePageGCComponentStatusColorAreas->SetGCComponentStatus(INJECTOR, injectorStatus);
jmitc91516 1:a5258871b33d 8795 homePageGCComponentStatusColorAreas->SetGCComponentStatus(DETECTOR, detectorStatus);
jmitc91516 1:a5258871b33d 8796 homePageGCComponentStatusColorAreas->SetGCComponentStatus(GAS, gasStatus);
jmitc91516 1:a5258871b33d 8797 }
jmitc91516 1:a5258871b33d 8798
jmitc91516 1:a5258871b33d 8799 if(singleGCComponentPageStatusColorAreas != NULL) {
jmitc91516 1:a5258871b33d 8800 singleGCComponentPageStatusColorAreas->SetGCComponentStatus(COLUMN, columnStatus);
jmitc91516 1:a5258871b33d 8801 singleGCComponentPageStatusColorAreas->SetGCComponentStatus(INJECTOR, injectorStatus);
jmitc91516 1:a5258871b33d 8802 singleGCComponentPageStatusColorAreas->SetGCComponentStatus(DETECTOR, detectorStatus);
jmitc91516 1:a5258871b33d 8803 singleGCComponentPageStatusColorAreas->SetGCComponentStatus(GAS, gasStatus);
jmitc91516 1:a5258871b33d 8804 }
jmitc91516 1:a5258871b33d 8805 }
jmitc91516 1:a5258871b33d 8806
jmitc91516 1:a5258871b33d 8807 /*
jmitc91516 1:a5258871b33d 8808 Returns true if the status of the specified component is now different
jmitc91516 1:a5258871b33d 8809 to that recorded in the status rectangle for the relevant single component page
jmitc91516 1:a5258871b33d 8810 */
jmitc91516 1:a5258871b33d 8811 bool GetGCStatusLoop::SinglePageGCComponentStatusHasChanged(GCComponent component)
jmitc91516 1:a5258871b33d 8812 {
jmitc91516 0:47c880c1463d 8813 if(singleGCComponentPageStatusColorAreas != NULL) {
jmitc91516 1:a5258871b33d 8814 if(GetComponentStatus(component) != singleGCComponentPageStatusColorAreas->GetGCComponentStatus(component)) {
jmitc91516 1:a5258871b33d 8815 return true;
jmitc91516 1:a5258871b33d 8816 }
jmitc91516 1:a5258871b33d 8817 }
jmitc91516 1:a5258871b33d 8818
jmitc91516 1:a5258871b33d 8819 return false;
jmitc91516 1:a5258871b33d 8820 }
jmitc91516 1:a5258871b33d 8821
jmitc91516 1:a5258871b33d 8822 /*
jmitc91516 1:a5258871b33d 8823 Returns true if the status of the specified component is now different
jmitc91516 1:a5258871b33d 8824 to the last status displayed in the relevant status rectangle
jmitc91516 1:a5258871b33d 8825 */
jmitc91516 1:a5258871b33d 8826 bool GetGCStatusLoop::SinglePageGCComponentStatusHasChanged(GCComponent component, GCComponentStatus lastStatusDisplayed)
jmitc91516 1:a5258871b33d 8827 {
jmitc91516 1:a5258871b33d 8828 if(GetComponentStatus(component) != lastStatusDisplayed) {
jmitc91516 1:a5258871b33d 8829 return true;
jmitc91516 1:a5258871b33d 8830 }
jmitc91516 1:a5258871b33d 8831
jmitc91516 1:a5258871b33d 8832 return false;
jmitc91516 1:a5258871b33d 8833 }
jmitc91516 1:a5258871b33d 8834
jmitc91516 1:a5258871b33d 8835 /*
jmitc91516 1:a5258871b33d 8836 Set up (i.e. get from the GC) the values for all the EasyGUI variables used by the various pages/structures we display.
jmitc91516 1:a5258871b33d 8837 Caller should do this before entering our main loop - this ensures these variables are set up and ready
jmitc91516 1:a5258871b33d 8838 before each of the pages is displayed
jmitc91516 1:a5258871b33d 8839
jmitc91516 1:a5258871b33d 8840 No arguments.
jmitc91516 1:a5258871b33d 8841
jmitc91516 1:a5258871b33d 8842 No return code.
jmitc91516 1:a5258871b33d 8843 */
jmitc91516 0:47c880c1463d 8844 void GetGCStatusLoop::SetupAllEasyGUIVariables(void)
jmitc91516 0:47c880c1463d 8845 {
jmitc91516 0:47c880c1463d 8846 // Set up (i.e. get from the GC) the values for all the EasyGUI variables used by the various pages/structures we display.
jmitc91516 0:47c880c1463d 8847 // Caller should do this before entering our main loop - this ensures these variables are set up and ready
jmitc91516 0:47c880c1463d 8848 // before each of the pages is displayed
jmitc91516 0:47c880c1463d 8849
jmitc91516 0:47c880c1463d 8850 // Home page
jmitc91516 0:47c880c1463d 8851 #define SETUP_HOME_PAGE
jmitc91516 0:47c880c1463d 8852 #ifdef SETUP_HOME_PAGE
jmitc91516 1:a5258871b33d 8853 if(GetColumnType() == DIRECTLY_HEATED_COLUMN) {
jmitc91516 1:a5258871b33d 8854 GetDirectlyHeatedColumnTemperature(GuiVar_columnTemperature2, false);
jmitc91516 1:a5258871b33d 8855 } else {
jmitc91516 1:a5258871b33d 8856 GetColumnTemperature(GuiVar_columnTemperature2, false);
jmitc91516 1:a5258871b33d 8857 }
jmitc91516 1:a5258871b33d 8858 GetColumnTargetTemperature(GuiVar_columnTargetTemperature, "(Target: %s)");
jmitc91516 0:47c880c1463d 8859 GetDetectorTemperature(GuiVar_detectorTemperature2);
jmitc91516 1:a5258871b33d 8860 GetDetectorTargetTemperature(GuiVar_detectorTargetTemperature, "(Target: %s)");
jmitc91516 1:a5258871b33d 8861 GetInjectorTemperature(GuiVar_injectorTemperature2, false);
jmitc91516 1:a5258871b33d 8862 GetInjectorTargetTemperature(GuiVar_injectorTargetTemperature, "(Target: %s)");
jmitc91516 1:a5258871b33d 8863 GetCurrentGasPressure(GuiVar_gasPressure2, false, true);
jmitc91516 1:a5258871b33d 8864 GetGCRealTimeClockTime(GuiVar_gcTimeOnHomePage);
jmitc91516 0:47c880c1463d 8865 #undef SETUP_HOME_PAGE
jmitc91516 0:47c880c1463d 8866 #endif
jmitc91516 0:47c880c1463d 8867 // We were omitting the home page variables here, on the theory that the home page is the first one displayed,
jmitc91516 0:47c880c1463d 8868 // so its variables will get updated anyway, and if we set them here, the page does not get updated when first displayed.
jmitc91516 0:47c880c1463d 8869 // However, this no longer appears to be true (and I cannot now remember why I thought it was).
jmitc91516 0:47c880c1463d 8870 // If we do *not* update these variables here, then we see the component status rectangles in their correct colours at startup,
jmitc91516 0:47c880c1463d 8871 // but the text does not appear for several seconds. If we *do* update these variables, the text is displayed at startup
jmitc91516 1:a5258871b33d 8872 // at the same time as the rectangles, i.e. we get the behaviour we want.
jmitc91516 0:47c880c1463d 8873
jmitc91516 0:47c880c1463d 8874 // Column page
jmitc91516 1:a5258871b33d 8875 GetColumnTemperature(GuiVar_columnTemperature, false, true);
jmitc91516 6:dba3fbdfd5da 8876 GetColumnTargetTemperature(GuiVar_columnTargetTemperature2, stringFormatdegCUnits);
jmitc91516 1:a5258871b33d 8877 GetColumnMaxTemperature(GuiVar_columnMaxTemp2, false, false, true);
jmitc91516 1:a5258871b33d 8878 GetComponentStatusString(COLUMN, GuiVar_columnStatus);
jmitc91516 1:a5258871b33d 8879
jmitc91516 1:a5258871b33d 8880 // Column Information page
jmitc91516 1:a5258871b33d 8881 GetColumnType(GuiVar_columnType);
jmitc91516 1:a5258871b33d 8882 GetColumnLength(GuiVar_columnLength);
jmitc91516 1:a5258871b33d 8883 GetColumnInnerDiameter(GuiVar_columnInnerDiameter);
jmitc91516 1:a5258871b33d 8884 GetColumnOuterDiameter(GuiVar_columnOuterDiameter);
jmitc91516 1:a5258871b33d 8885 GetSerialNumber(GuiVar_columnSerialNumber);
jmitc91516 1:a5258871b33d 8886
jmitc91516 5:aceac1035d71 8887 // Column Method page
jmitc91516 5:aceac1035d71 8888 UpdateColumnMethodPageData();
jmitc91516 5:aceac1035d71 8889
jmitc91516 0:47c880c1463d 8890 // Injector page
jmitc91516 1:a5258871b33d 8891 GetInjectorTemperature(GuiVar_injectorTemperature, false);
jmitc91516 6:dba3fbdfd5da 8892 GetInjectorTargetTemperature(GuiVar_injectorTargetTemperature2, stringFormatdegCUnits);
jmitc91516 1:a5258871b33d 8893 GetInjectionMode(GuiVar_injectionMode2);
jmitc91516 1:a5258871b33d 8894 GetInjectorType(GuiVar_injectorType, false);
jmitc91516 1:a5258871b33d 8895 GetComponentStatusString(INJECTOR, GuiVar_injectorStatus);
jmitc91516 1:a5258871b33d 8896
jmitc91516 6:dba3fbdfd5da 8897 // Injector Method page
jmitc91516 6:dba3fbdfd5da 8898 UpdateInjectorMethodPageData();
jmitc91516 1:a5258871b33d 8899
jmitc91516 1:a5258871b33d 8900 // Detector page(s)
jmitc91516 1:a5258871b33d 8901 GetDetectorType(GuiVar_detectorType2, false, false);
jmitc91516 1:a5258871b33d 8902 GetDetectorRange(GuiVar_detectorRange);
jmitc91516 1:a5258871b33d 8903 GetFuelFlowRate(GuiVar_detectorFuelFlowRate);
jmitc91516 1:a5258871b33d 8904 GetAirFlowRate(GuiVar_detectorAirFlowRate);
jmitc91516 1:a5258871b33d 8905 GetDetectorIgnitionState(GuiVar_detectorStatus);
jmitc91516 0:47c880c1463d 8906 GetDetectorTemperature(GuiVar_detectorTemperature);
jmitc91516 6:dba3fbdfd5da 8907 GetDetectorTargetTemperature(GuiVar_detectorTargetTemperature2, stringFormatdegCUnits);
jmitc91516 1:a5258871b33d 8908 GetTCDDetectorFilamentPolarity(GuiVar_tcdDetectorFilamentPolarity);
jmitc91516 1:a5258871b33d 8909 GetTCDDetectorFilamentTemperature(GuiVar_tcdDetectorFilamentTemperature);
jmitc91516 1:a5258871b33d 8910 GetTCDDetectorRange(GuiVar_tcdDetectorRange);
jmitc91516 1:a5258871b33d 8911 GetECDDetectorCurrent(GuiVar_ecdDetectorCurrent);
jmitc91516 1:a5258871b33d 8912 //GetFPDDetectorRange(GuiVar_fpdDetectorRange);
jmitc91516 1:a5258871b33d 8913 // No - now same command as all other detector types
jmitc91516 1:a5258871b33d 8914 GetDetectorRange(GuiVar_fpdDetectorRange);
jmitc91516 1:a5258871b33d 8915 GetFPDDetectorSensitivity(GuiVar_fpdDetectorSensitivity);
jmitc91516 0:47c880c1463d 8916
jmitc91516 0:47c880c1463d 8917 // Gas page
jmitc91516 1:a5258871b33d 8918 GetGasPressure(GuiVar_gasPressure, false, true);
jmitc91516 1:a5258871b33d 8919 GetGasPulsedPressure(GuiVar_gasPulsedPressure);
jmitc91516 1:a5258871b33d 8920 GetGasControlMode(GuiVar_gasControlMode2, true, false);
jmitc91516 1:a5258871b33d 8921 GetCarrierGasType(GuiVar_gasCarrierType);
jmitc91516 1:a5258871b33d 8922 GetGasFilterDateChanged(GuiVar_gasFilterDateChanged);
jmitc91516 0:47c880c1463d 8923
jmitc91516 6:dba3fbdfd5da 8924 // Gas Method page
jmitc91516 6:dba3fbdfd5da 8925 UpdateGasMethodPageData();
jmitc91516 6:dba3fbdfd5da 8926
jmitc91516 0:47c880c1463d 8927 // Settings page
jmitc91516 1:a5258871b33d 8928 GetGCSoftwareVersion(GuiVar_gcSoftwareVersion);
jmitc91516 1:a5258871b33d 8929 GetActuatorSoftwareVersion(GuiVar_actuatorSoftwareVersion);
jmitc91516 0:47c880c1463d 8930 GetRunTime(GuiVar_runTime);
jmitc91516 1:a5258871b33d 8931 // GetInjectionMode(GuiVar_injectionMode, true);
jmitc91516 1:a5258871b33d 8932 GetInjectorType(GuiVar_injectionMode, true);
jmitc91516 1:a5258871b33d 8933 GetColumnMaxTemperature(GuiVar_columnMaxTemp, true, true);
jmitc91516 1:a5258871b33d 8934 GetDetectorType(GuiVar_detectorType, true, true);
jmitc91516 1:a5258871b33d 8935 GetGasControlMode(GuiVar_gasControlMode, true, true);
jmitc91516 1:a5258871b33d 8936 GetSerialNumber(GuiVar_gcSerialNumber);
jmitc91516 1:a5258871b33d 8937 GetGCRealTimeClockTime(GuiVar_gcTime);
jmitc91516 1:a5258871b33d 8938
jmitc91516 1:a5258871b33d 8939 // Servicing page
jmitc91516 1:a5258871b33d 8940 SetupServicingPageEasyGUIVariables();
jmitc91516 1:a5258871b33d 8941 }
jmitc91516 1:a5258871b33d 8942
jmitc91516 1:a5258871b33d 8943
jmitc91516 1:a5258871b33d 8944 /*
jmitc91516 1:a5258871b33d 8945 Tells the caller whether or not a specified GC command is (potentially)
jmitc91516 1:a5258871b33d 8946 part of a SendMethod sequence.
jmitc91516 1:a5258871b33d 8947
jmitc91516 1:a5258871b33d 8948 Params: pointer to a null-terminated string containing the command in question
jmitc91516 1:a5258871b33d 8949
jmitc91516 1:a5258871b33d 8950 Returns true if the command is one that is commonly part of a method specification,
jmitc91516 1:a5258871b33d 8951 false if not.
jmitc91516 1:a5258871b33d 8952
jmitc91516 1:a5258871b33d 8953 This code is intended to be as efficient as possible.
jmitc91516 1:a5258871b33d 8954 */
jmitc91516 1:a5258871b33d 8955 bool GetGCStatusLoop::IsSendMethodCommand(char *gcCommand)
jmitc91516 1:a5258871b33d 8956 {
jmitc91516 1:a5258871b33d 8957 // First of all - must be an "Sxxx" (i.e. set) command
jmitc91516 1:a5258871b33d 8958 if(gcCommand[0] != 'S') {
jmitc91516 1:a5258871b33d 8959 // Cannot be a 'set' command
jmitc91516 1:a5258871b33d 8960 return false;
jmitc91516 1:a5258871b33d 8961 }
jmitc91516 1:a5258871b33d 8962
jmitc91516 1:a5258871b33d 8963 if((gcCommand[1] == 'C') && (gcCommand[2] == 'O') && (gcCommand[3] == 'L')) {
jmitc91516 1:a5258871b33d 8964 // "SCOL" command
jmitc91516 1:a5258871b33d 8965 return true;
jmitc91516 1:a5258871b33d 8966 }
jmitc91516 1:a5258871b33d 8967
jmitc91516 1:a5258871b33d 8968 if((gcCommand[1] == 'I') && (gcCommand[2] == 'N') && (gcCommand[3] == 'J')) {
jmitc91516 1:a5258871b33d 8969 // "SINJ" command
jmitc91516 1:a5258871b33d 8970 return true;
jmitc91516 1:a5258871b33d 8971 }
jmitc91516 1:a5258871b33d 8972
jmitc91516 1:a5258871b33d 8973 if((gcCommand[1] == 'D') && (gcCommand[2] == 'E') && (gcCommand[3] == 'T')) {
jmitc91516 1:a5258871b33d 8974 // "SDET" command
jmitc91516 1:a5258871b33d 8975 return true;
jmitc91516 1:a5258871b33d 8976 }
jmitc91516 1:a5258871b33d 8977
jmitc91516 1:a5258871b33d 8978 if((gcCommand[1] == 'A') && (gcCommand[2] == 'U') && (gcCommand[3] == 'X')) {
jmitc91516 1:a5258871b33d 8979 // "SAUX" command
jmitc91516 1:a5258871b33d 8980 return true;
jmitc91516 1:a5258871b33d 8981 }
jmitc91516 1:a5258871b33d 8982
jmitc91516 1:a5258871b33d 8983 if((gcCommand[1] == 'S') && (gcCommand[2] == 'T') && (gcCommand[3] == 'B')) {
jmitc91516 1:a5258871b33d 8984 // "SSTB" command
jmitc91516 1:a5258871b33d 8985 return true;
jmitc91516 1:a5258871b33d 8986 }
jmitc91516 1:a5258871b33d 8987
jmitc91516 1:a5258871b33d 8988 if((gcCommand[1] == 'T') && (gcCommand[2] == 'I') && (gcCommand[3] == 'M')) {
jmitc91516 1:a5258871b33d 8989 // "STIM" command
jmitc91516 1:a5258871b33d 8990 return true;
jmitc91516 1:a5258871b33d 8991 }
jmitc91516 1:a5258871b33d 8992
jmitc91516 1:a5258871b33d 8993 if((gcCommand[1] == 'R') && (gcCommand[2] == 'P')) {
jmitc91516 1:a5258871b33d 8994 // "SRPn" command
jmitc91516 1:a5258871b33d 8995 return true;
jmitc91516 1:a5258871b33d 8996 }
jmitc91516 1:a5258871b33d 8997
jmitc91516 1:a5258871b33d 8998 if((gcCommand[1] == 'R') && (gcCommand[2] == 'C')) {
jmitc91516 1:a5258871b33d 8999 // "SRCn" command
jmitc91516 1:a5258871b33d 9000 return true;
jmitc91516 1:a5258871b33d 9001 }
jmitc91516 1:a5258871b33d 9002
jmitc91516 1:a5258871b33d 9003 if((gcCommand[1] == 'R') && (gcCommand[2] == 'S')) {
jmitc91516 1:a5258871b33d 9004 // "SRSn" command
jmitc91516 1:a5258871b33d 9005 return true;
jmitc91516 1:a5258871b33d 9006 }
jmitc91516 1:a5258871b33d 9007
jmitc91516 1:a5258871b33d 9008 if((gcCommand[1] == 'P') && (gcCommand[2] == 'R')) {
jmitc91516 1:a5258871b33d 9009 // "SPRS" or "SPRn" command
jmitc91516 1:a5258871b33d 9010 return true;
jmitc91516 1:a5258871b33d 9011 }
jmitc91516 1:a5258871b33d 9012
jmitc91516 1:a5258871b33d 9013 if((gcCommand[1] == 'P') && (gcCommand[2] == 'P') && (gcCommand[3] == 'S')) {
jmitc91516 1:a5258871b33d 9014 // "SPPS" command
jmitc91516 1:a5258871b33d 9015 return true;
jmitc91516 1:a5258871b33d 9016 }
jmitc91516 1:a5258871b33d 9017
jmitc91516 1:a5258871b33d 9018 if((gcCommand[1] == 'P') && (gcCommand[2] == 'U')) {
jmitc91516 1:a5258871b33d 9019 // "SPUn" command
jmitc91516 1:a5258871b33d 9020 return true;
jmitc91516 1:a5258871b33d 9021 }
jmitc91516 1:a5258871b33d 9022
jmitc91516 1:a5258871b33d 9023 if((gcCommand[1] == 'I') && (gcCommand[2] == 'M') && (gcCommand[3] == 'D')) {
jmitc91516 1:a5258871b33d 9024 // "SIMD" command
jmitc91516 1:a5258871b33d 9025 return true;
jmitc91516 1:a5258871b33d 9026 }
jmitc91516 1:a5258871b33d 9027
jmitc91516 1:a5258871b33d 9028 if((gcCommand[1] == 'S') && (gcCommand[2] == 'P') && (gcCommand[3] == 'T')) {
jmitc91516 1:a5258871b33d 9029 // "SSPT" command
jmitc91516 1:a5258871b33d 9030 return true;
jmitc91516 1:a5258871b33d 9031 }
jmitc91516 1:a5258871b33d 9032
jmitc91516 1:a5258871b33d 9033 if((gcCommand[1] == 'C') && (gcCommand[2] == 'F') && (gcCommand[3] == 'L')) {
jmitc91516 1:a5258871b33d 9034 // "SCFL" command
jmitc91516 1:a5258871b33d 9035 return true;
jmitc91516 1:a5258871b33d 9036 }
jmitc91516 1:a5258871b33d 9037
jmitc91516 1:a5258871b33d 9038 if((gcCommand[1] == 'T') && (gcCommand[2] == 'F') && (gcCommand[3] == 'L')) {
jmitc91516 1:a5258871b33d 9039 // "STFL" command
jmitc91516 1:a5258871b33d 9040 return true;
jmitc91516 1:a5258871b33d 9041 }
jmitc91516 1:a5258871b33d 9042
jmitc91516 1:a5258871b33d 9043 if((gcCommand[1] == 'M') && (gcCommand[2] == 'A') && (gcCommand[3] == 'K')) {
jmitc91516 1:a5258871b33d 9044 // "SMAK" command
jmitc91516 1:a5258871b33d 9045 return true;
jmitc91516 1:a5258871b33d 9046 }
jmitc91516 1:a5258871b33d 9047
jmitc91516 1:a5258871b33d 9048 if((gcCommand[1] == 'C') && (gcCommand[2] == 'L') && (gcCommand[3] == 'B')) {
jmitc91516 1:a5258871b33d 9049 // "SCLB" command
jmitc91516 1:a5258871b33d 9050 return true;
jmitc91516 1:a5258871b33d 9051 }
jmitc91516 1:a5258871b33d 9052
jmitc91516 1:a5258871b33d 9053 return false; // None of the above
jmitc91516 1:a5258871b33d 9054 }
jmitc91516 1:a5258871b33d 9055
jmitc91516 1:a5258871b33d 9056
jmitc91516 1:a5258871b33d 9057 /*
jmitc91516 1:a5258871b33d 9058 Forces the MainLoopWithEthernet function to exit its while loop
jmitc91516 1:a5258871b33d 9059 and reboot the whole application
jmitc91516 1:a5258871b33d 9060 */
jmitc91516 1:a5258871b33d 9061 void GetGCStatusLoop::ForceRestart(void)
jmitc91516 1:a5258871b33d 9062 {
jmitc91516 1:a5258871b33d 9063 restartRequired = true;
jmitc91516 1:a5258871b33d 9064 }
jmitc91516 1:a5258871b33d 9065
jmitc91516 1:a5258871b33d 9066
jmitc91516 1:a5258871b33d 9067 /*
jmitc91516 1:a5258871b33d 9068 Deals with the user touching the screen. Works out if the user touched an area
jmitc91516 1:a5258871b33d 9069 we are interested in, and if so, handles it appropriately.
jmitc91516 1:a5258871b33d 9070
jmitc91516 1:a5258871b33d 9071 Args: the X, Y and Z cordinates where the user touched (the touch panel gives us
jmitc91516 1:a5258871b33d 9072 all three coordinates, although currently we do not use the Z coordinate).
jmitc91516 1:a5258871b33d 9073
jmitc91516 1:a5258871b33d 9074 No return code.
jmitc91516 1:a5258871b33d 9075
jmitc91516 1:a5258871b33d 9076 The intention is that this function will, in effect, supersede the 'TouchCallback' function in main.cpp.
jmitc91516 1:a5258871b33d 9077 For now, we are calling that function from here.
jmitc91516 1:a5258871b33d 9078
jmitc91516 1:a5258871b33d 9079 Also note that this function sets 'handlingTouchEvent' true while it is dealing with the touch event.
jmitc91516 1:a5258871b33d 9080 Caller should not call this function if this flag is true.
jmitc91516 1:a5258871b33d 9081 */
jmitc91516 1:a5258871b33d 9082 void GetGCStatusLoop::HandleTouchEvent(short touchX, short touchY, short touchZ, int debugValue)
jmitc91516 1:a5258871b33d 9083 {
jmitc91516 1:a5258871b33d 9084 handlingTouchEvent = true;
jmitc91516 1:a5258871b33d 9085
jmitc91516 1:a5258871b33d 9086 #if defined MULTI_TOUCH_TECHNIQUE_1
jmitc91516 1:a5258871b33d 9087 // Enforce a minimum time interval between the touch events we respond to
jmitc91516 1:a5258871b33d 9088 if((timerTickCount - lastTouchEventTickCount) > minTimerTicksBetweenTouchEvents) {
jmitc91516 1:a5258871b33d 9089 #endif
jmitc91516 1:a5258871b33d 9090 #if defined MULTI_TOUCH_TECHNIQUE_2
jmitc91516 1:a5258871b33d 9091 // Assume we are unlikely to get separate 'touches' in succession at exactly the same coordinates
jmitc91516 1:a5258871b33d 9092 //if((x != lastTouchEventX) && (y != lastTouchEventY)) { // was '||', i.e. OR, not AND - we still got 'multiple touches'
jmitc91516 1:a5258871b33d 9093 //Try and apply a minimum 'movement'...
jmitc91516 1:a5258871b33d 9094 if((abs(touchX - lastTouchEventX) > 2) || (abs(touchY - lastTouchEventY) > 2)) { // Note the '||' - we miss too many 'touches' if we use '&&'
jmitc91516 1:a5258871b33d 9095 #endif
jmitc91516 1:a5258871b33d 9096 #if defined MULTI_TOUCH_TECHNIQUE_3
jmitc91516 1:a5258871b33d 9097 if(gotAtLeastOneTimeout) {
jmitc91516 1:a5258871b33d 9098 #endif
jmitc91516 1:a5258871b33d 9099 #if defined MULTI_TOUCH_TECHNIQUE_4
jmitc91516 1:a5258871b33d 9100 if(touchTimer.read_ms() > timerIntervalMilliSec) {
jmitc91516 1:a5258871b33d 9101 #endif
jmitc91516 1:a5258871b33d 9102 char dbg[200];
jmitc91516 1:a5258871b33d 9103 sprintf(dbg, "*** Got touch event at %d, %d, %d, %d ***", touchX, touchY, touchZ, timerTickCount);
jmitc91516 1:a5258871b33d 9104 EasyGUIDebugPrintWithCounter(dbg, 430, 450);
jmitc91516 0:47c880c1463d 9105
jmitc91516 1:a5258871b33d 9106 touch_coordinate_t touchCoords;
jmitc91516 1:a5258871b33d 9107 touchCoords.x = touchX;
jmitc91516 1:a5258871b33d 9108 touchCoords.y = touchY;
jmitc91516 1:a5258871b33d 9109 touchCoords.z = touchZ;
jmitc91516 1:a5258871b33d 9110
jmitc91516 1:a5258871b33d 9111 TouchCallback(touchCoords, usbDevice, usbHostGC, 1, true);
jmitc91516 1:a5258871b33d 9112
jmitc91516 1:a5258871b33d 9113 #if defined MULTI_TOUCH_TECHNIQUE_1
jmitc91516 1:a5258871b33d 9114 lastTouchEventTickCount = timerTickCount;
jmitc91516 1:a5258871b33d 9115 }
jmitc91516 1:a5258871b33d 9116 #endif
jmitc91516 1:a5258871b33d 9117 #if defined MULTI_TOUCH_TECHNIQUE_2
jmitc91516 1:a5258871b33d 9118 lastTouchEventX = touchX;
jmitc91516 1:a5258871b33d 9119 lastTouchEventY = touchY;
jmitc91516 1:a5258871b33d 9120 }
jmitc91516 1:a5258871b33d 9121 #endif
jmitc91516 1:a5258871b33d 9122 #if defined MULTI_TOUCH_TECHNIQUE_3
jmitc91516 1:a5258871b33d 9123 gotAtLeastOneTimeout = false;
jmitc91516 1:a5258871b33d 9124 }
jmitc91516 1:a5258871b33d 9125 #endif
jmitc91516 1:a5258871b33d 9126 #if defined MULTI_TOUCH_TECHNIQUE_4
jmitc91516 1:a5258871b33d 9127 touchTimer.stop();
jmitc91516 1:a5258871b33d 9128 touchTimer.reset();
jmitc91516 1:a5258871b33d 9129 touchTimer.start();
jmitc91516 1:a5258871b33d 9130 }
jmitc91516 1:a5258871b33d 9131 #endif
jmitc91516 1:a5258871b33d 9132
jmitc91516 1:a5258871b33d 9133 handlingTouchEvent = false;
jmitc91516 1:a5258871b33d 9134 }
jmitc91516 1:a5258871b33d 9135
jmitc91516 1:a5258871b33d 9136 /*
jmitc91516 1:a5258871b33d 9137 Tells the caller if the specified command was a Run command,
jmitc91516 1:a5258871b33d 9138 and if it succeeded - i.e. the command was "CRUN", and
jmitc91516 1:a5258871b33d 9139 the GC responded with "DACK".
jmitc91516 1:a5258871b33d 9140
jmitc91516 1:a5258871b33d 9141 Args: pointers to null-terminated strings containing the command in question,
jmitc91516 1:a5258871b33d 9142 and the GC response
jmitc91516 1:a5258871b33d 9143
jmitc91516 1:a5258871b33d 9144 True if it was a "CRUN" command, and the response was "DACK", false otherwise
jmitc91516 1:a5258871b33d 9145 */
jmitc91516 1:a5258871b33d 9146 bool GetGCStatusLoop::SuccessfulRunCommand(char* gcCommand, char* gcResponse)
jmitc91516 1:a5258871b33d 9147 {
jmitc91516 1:a5258871b33d 9148 if(gcCommand[0] != 'C') {
jmitc91516 1:a5258871b33d 9149 return false;
jmitc91516 1:a5258871b33d 9150 }
jmitc91516 1:a5258871b33d 9151
jmitc91516 1:a5258871b33d 9152 if(gcCommand[1] != 'R') {
jmitc91516 1:a5258871b33d 9153 return false;
jmitc91516 1:a5258871b33d 9154 }
jmitc91516 1:a5258871b33d 9155
jmitc91516 1:a5258871b33d 9156 if(gcCommand[2] != 'U') {
jmitc91516 1:a5258871b33d 9157 return false;
jmitc91516 1:a5258871b33d 9158 }
jmitc91516 1:a5258871b33d 9159
jmitc91516 1:a5258871b33d 9160 if(gcCommand[3] != 'N') {
jmitc91516 1:a5258871b33d 9161 return false;
jmitc91516 1:a5258871b33d 9162 }
jmitc91516 1:a5258871b33d 9163
jmitc91516 1:a5258871b33d 9164
jmitc91516 1:a5258871b33d 9165 if(gcResponse[0] != 'D') {
jmitc91516 1:a5258871b33d 9166 return false;
jmitc91516 1:a5258871b33d 9167 }
jmitc91516 1:a5258871b33d 9168
jmitc91516 1:a5258871b33d 9169 if(gcResponse[1] != 'A') {
jmitc91516 1:a5258871b33d 9170 return false;
jmitc91516 1:a5258871b33d 9171 }
jmitc91516 1:a5258871b33d 9172
jmitc91516 1:a5258871b33d 9173 if(gcResponse[2] != 'C') {
jmitc91516 1:a5258871b33d 9174 return false;
jmitc91516 1:a5258871b33d 9175 }
jmitc91516 1:a5258871b33d 9176
jmitc91516 1:a5258871b33d 9177 if(gcResponse[3] != 'K') {
jmitc91516 1:a5258871b33d 9178 return false;
jmitc91516 1:a5258871b33d 9179 }
jmitc91516 1:a5258871b33d 9180
jmitc91516 1:a5258871b33d 9181 // All the above were true
jmitc91516 1:a5258871b33d 9182 return true;
jmitc91516 1:a5258871b33d 9183 }
jmitc91516 1:a5258871b33d 9184
jmitc91516 1:a5258871b33d 9185
jmitc91516 1:a5258871b33d 9186 /*
jmitc91516 1:a5258871b33d 9187 Tells the caller if the specified command was an Abort command,
jmitc91516 1:a5258871b33d 9188 and if it succeeded - i.e. the command was "CABT" or "CSTP"
jmitc91516 1:a5258871b33d 9189 (currently these two GC commands are equivalent),
jmitc91516 1:a5258871b33d 9190 and the GC responded with "DACK".
jmitc91516 1:a5258871b33d 9191
jmitc91516 1:a5258871b33d 9192 Args: pointers to null-terminated strings containing the command in question,
jmitc91516 1:a5258871b33d 9193 and the GC response
jmitc91516 1:a5258871b33d 9194
jmitc91516 1:a5258871b33d 9195 True if it was a "CRUN" command, and the response was "DACK", false otherwise
jmitc91516 1:a5258871b33d 9196 */
jmitc91516 1:a5258871b33d 9197 bool GetGCStatusLoop::SuccessfulAbortCommand(char* gcCommand, char* gcResponse)
jmitc91516 1:a5258871b33d 9198 {
jmitc91516 1:a5258871b33d 9199 if(gcCommand[0] != 'C') {
jmitc91516 1:a5258871b33d 9200 // Not a command at all - give up
jmitc91516 1:a5258871b33d 9201 return false;
jmitc91516 1:a5258871b33d 9202 }
jmitc91516 1:a5258871b33d 9203
jmitc91516 1:a5258871b33d 9204 bool wasAbortCommand = false;
jmitc91516 1:a5258871b33d 9205
jmitc91516 1:a5258871b33d 9206 if((gcCommand[1]== 'A') && (gcCommand[2]== 'B') && (gcCommand[3]== 'T')) {
jmitc91516 1:a5258871b33d 9207 wasAbortCommand = true;
jmitc91516 1:a5258871b33d 9208 } else if ((gcCommand[1]== 'S') && (gcCommand[2]== 'T') && (gcCommand[3]== 'P')) {
jmitc91516 1:a5258871b33d 9209 wasAbortCommand = true;
jmitc91516 1:a5258871b33d 9210 }
jmitc91516 1:a5258871b33d 9211
jmitc91516 1:a5258871b33d 9212 if(!wasAbortCommand) {
jmitc91516 1:a5258871b33d 9213 return false;
jmitc91516 1:a5258871b33d 9214 }
jmitc91516 1:a5258871b33d 9215
jmitc91516 1:a5258871b33d 9216
jmitc91516 1:a5258871b33d 9217 // Now the response...
jmitc91516 1:a5258871b33d 9218
jmitc91516 1:a5258871b33d 9219 if(gcResponse[0] != 'D') {
jmitc91516 1:a5258871b33d 9220 return false;
jmitc91516 1:a5258871b33d 9221 }
jmitc91516 1:a5258871b33d 9222
jmitc91516 1:a5258871b33d 9223 if(gcResponse[1] != 'A') {
jmitc91516 1:a5258871b33d 9224 return false;
jmitc91516 1:a5258871b33d 9225 }
jmitc91516 1:a5258871b33d 9226
jmitc91516 1:a5258871b33d 9227 if(gcResponse[2] != 'C') {
jmitc91516 1:a5258871b33d 9228 return false;
jmitc91516 1:a5258871b33d 9229 }
jmitc91516 1:a5258871b33d 9230
jmitc91516 1:a5258871b33d 9231 if(gcResponse[3] != 'K') {
jmitc91516 1:a5258871b33d 9232 return false;
jmitc91516 1:a5258871b33d 9233 }
jmitc91516 1:a5258871b33d 9234
jmitc91516 1:a5258871b33d 9235 // Must have been an abort command, acknowledged with "DACK"
jmitc91516 1:a5258871b33d 9236 return true;
jmitc91516 1:a5258871b33d 9237 }
jmitc91516 1:a5258871b33d 9238
jmitc91516 1:a5258871b33d 9239 /*
jmitc91516 1:a5258871b33d 9240 Tells the caller if the specified page includes one or more component status rectangles,
jmitc91516 1:a5258871b33d 9241 or a component status displayed as text, and will therefore need to be redisplayed
jmitc91516 1:a5258871b33d 9242 if the component status changes
jmitc91516 1:a5258871b33d 9243
jmitc91516 1:a5258871b33d 9244 Args: the number of the page in question
jmitc91516 1:a5258871b33d 9245
jmitc91516 1:a5258871b33d 9246 Returns: true if the page contains the status of one or more components, false if not
jmitc91516 1:a5258871b33d 9247 */
jmitc91516 1:a5258871b33d 9248 bool GetGCStatusLoop::PageIncludesComponentStatus(int pageNumber)
jmitc91516 1:a5258871b33d 9249 {
jmitc91516 1:a5258871b33d 9250 // Quicker to decide which pages do *not* include a component status...
jmitc91516 1:a5258871b33d 9251
jmitc91516 1:a5258871b33d 9252 if(pageNumber == GuiStruct_AbortRunPage_19) {
jmitc91516 1:a5258871b33d 9253 return false;
jmitc91516 1:a5258871b33d 9254 }
jmitc91516 1:a5258871b33d 9255
jmitc91516 1:a5258871b33d 9256 //#define USING_REAL_BACKGROUND_BITMAP
jmitc91516 1:a5258871b33d 9257 #ifdef USING_REAL_BACKGROUND_BITMAP
jmitc91516 1:a5258871b33d 9258 if(pageNumber == GuiStruct_BackgroundBitmapPage_Def) {
jmitc91516 1:a5258871b33d 9259 return false;
jmitc91516 1:a5258871b33d 9260 }
jmitc91516 1:a5258871b33d 9261 #endif // USING_REAL_BACKGROUND_BITMAP
jmitc91516 1:a5258871b33d 9262
jmitc91516 1:a5258871b33d 9263 if(pageNumber == GuiStruct_DownloadingMethodPage_Def) {
jmitc91516 1:a5258871b33d 9264 return false;
jmitc91516 1:a5258871b33d 9265 }
jmitc91516 1:a5258871b33d 9266
jmitc91516 1:a5258871b33d 9267 if(pageNumber == GuiStruct_EthernetConnectionPage_Def) {
jmitc91516 1:a5258871b33d 9268 return false;
jmitc91516 1:a5258871b33d 9269 }
jmitc91516 1:a5258871b33d 9270
jmitc91516 1:a5258871b33d 9271 if(pageNumber == GuiStruct_EthernetParametersPage_50) {
jmitc91516 1:a5258871b33d 9272 return false;
jmitc91516 1:a5258871b33d 9273 }
jmitc91516 1:a5258871b33d 9274
jmitc91516 1:a5258871b33d 9275 if(pageNumber == GuiStruct_GCConnectionPage_Def) {
jmitc91516 1:a5258871b33d 9276 return false;
jmitc91516 1:a5258871b33d 9277 }
jmitc91516 1:a5258871b33d 9278
jmitc91516 1:a5258871b33d 9279 if(pageNumber == GuiStruct_GasSaver_9) {
jmitc91516 1:a5258871b33d 9280 return false;
jmitc91516 1:a5258871b33d 9281 }
jmitc91516 1:a5258871b33d 9282
jmitc91516 1:a5258871b33d 9283 if(pageNumber == GuiStruct_RunAbortedPage_Def) {
jmitc91516 1:a5258871b33d 9284 return false;
jmitc91516 1:a5258871b33d 9285 }
jmitc91516 1:a5258871b33d 9286
jmitc91516 1:a5258871b33d 9287 if(pageNumber == GuiStruct_RunCompletePage_41) {
jmitc91516 1:a5258871b33d 9288 return false;
jmitc91516 1:a5258871b33d 9289 }
jmitc91516 1:a5258871b33d 9290
jmitc91516 1:a5258871b33d 9291 if(pageNumber == GuiStruct_RunningColumnPage_25) {
jmitc91516 1:a5258871b33d 9292 return false;
jmitc91516 1:a5258871b33d 9293 }
jmitc91516 1:a5258871b33d 9294
jmitc91516 1:a5258871b33d 9295 if(pageNumber == GuiStruct_RunningDetectorPage_27) {
jmitc91516 1:a5258871b33d 9296 return false;
jmitc91516 1:a5258871b33d 9297 }
jmitc91516 1:a5258871b33d 9298
jmitc91516 1:a5258871b33d 9299 if(pageNumber == GuiStruct_RunningGasPage_28) {
jmitc91516 1:a5258871b33d 9300 return false;
jmitc91516 1:a5258871b33d 9301 }
jmitc91516 1:a5258871b33d 9302
jmitc91516 1:a5258871b33d 9303 if(pageNumber == GuiStruct_RunningInjectorPage_26) {
jmitc91516 1:a5258871b33d 9304 return false;
jmitc91516 1:a5258871b33d 9305 }
jmitc91516 1:a5258871b33d 9306
jmitc91516 1:a5258871b33d 9307 if(pageNumber == GuiStruct_RunningPage1_7) {
jmitc91516 1:a5258871b33d 9308 return false;
jmitc91516 1:a5258871b33d 9309 }
jmitc91516 1:a5258871b33d 9310
jmitc91516 1:a5258871b33d 9311 if(pageNumber == GuiStruct_ServicingPage_Def) {
jmitc91516 1:a5258871b33d 9312 return false;
jmitc91516 1:a5258871b33d 9313 }
jmitc91516 1:a5258871b33d 9314
jmitc91516 1:a5258871b33d 9315 if(pageNumber == GuiStruct_ServicingRequired_Def) {
jmitc91516 1:a5258871b33d 9316 return false;
jmitc91516 1:a5258871b33d 9317 }
jmitc91516 1:a5258871b33d 9318
jmitc91516 1:a5258871b33d 9319 if(pageNumber == GuiStruct_SettingsPage_5) {
jmitc91516 1:a5258871b33d 9320 return false;
jmitc91516 1:a5258871b33d 9321 }
jmitc91516 1:a5258871b33d 9322
jmitc91516 1:a5258871b33d 9323 if(pageNumber == GuiStruct_NumericKeypadPage_Def) {
jmitc91516 1:a5258871b33d 9324 return false;
jmitc91516 1:a5258871b33d 9325 }
jmitc91516 1:a5258871b33d 9326
jmitc91516 1:a5258871b33d 9327 // 'else' - none of the above
jmitc91516 1:a5258871b33d 9328 return true;
jmitc91516 1:a5258871b33d 9329 }
jmitc91516 1:a5258871b33d 9330
jmitc91516 5:aceac1035d71 9331
jmitc91516 5:aceac1035d71 9332 /*
jmitc91516 5:aceac1035d71 9333 Should be done at startup, and after a new method has been downloaded
jmitc91516 5:aceac1035d71 9334 */
jmitc91516 5:aceac1035d71 9335 void GetGCStatusLoop::UpdateColumnMethodPageData(void)
jmitc91516 5:aceac1035d71 9336 {
jmitc91516 5:aceac1035d71 9337 GetColumnTargetTemperature(GuiVar_columnMethodInitialTemp, "%s");
jmitc91516 5:aceac1035d71 9338 GetInitialHoldTime(GuiVar_columnMethodInitialHold);
jmitc91516 5:aceac1035d71 9339 if(columnMethodRampData == NULL) {
jmitc91516 5:aceac1035d71 9340 columnMethodRampData = new ColumnMethodRampData(usbDevice, usbHostGC);
jmitc91516 5:aceac1035d71 9341 }
jmitc91516 5:aceac1035d71 9342 if(columnMethodRampData != NULL) {
jmitc91516 5:aceac1035d71 9343 columnMethodRampData->GetRampDataFromGC();
jmitc91516 5:aceac1035d71 9344
jmitc91516 5:aceac1035d71 9345 sprintf(GuiVar_columnMethodRampCount, "%u", columnMethodRampData->GetRampCount());
jmitc91516 6:dba3fbdfd5da 9346
jmitc91516 6:dba3fbdfd5da 9347 if(columnMethodRampData->NeedToUpdateEasyGUIMethodPageRampVariables()) {
jmitc91516 6:dba3fbdfd5da 9348 columnMethodPageScrollIndex = 0;
jmitc91516 6:dba3fbdfd5da 9349
jmitc91516 6:dba3fbdfd5da 9350 columnMethodRampData->UpdateEasyGUIMethodPageVariables(columnMethodPageScrollIndex);
jmitc91516 6:dba3fbdfd5da 9351
jmitc91516 6:dba3fbdfd5da 9352 previousColumnMethodPageScrollIndex = columnMethodPageScrollIndex;
jmitc91516 6:dba3fbdfd5da 9353 }
jmitc91516 6:dba3fbdfd5da 9354 }
jmitc91516 6:dba3fbdfd5da 9355 }
jmitc91516 6:dba3fbdfd5da 9356
jmitc91516 6:dba3fbdfd5da 9357
jmitc91516 6:dba3fbdfd5da 9358 /*
jmitc91516 6:dba3fbdfd5da 9359 Should be done at startup, and after a new method has been downloaded
jmitc91516 6:dba3fbdfd5da 9360 */
jmitc91516 6:dba3fbdfd5da 9361 void GetGCStatusLoop::UpdateInjectorMethodPageData(void)
jmitc91516 6:dba3fbdfd5da 9362 {
jmitc91516 6:dba3fbdfd5da 9363 GetInjectorTargetTemperature(GuiVar_injectorMethodInitialTemp, "%s");
jmitc91516 6:dba3fbdfd5da 9364 GetInitialHoldTime(GuiVar_injectorMethodInitialHold);
jmitc91516 6:dba3fbdfd5da 9365 if(injectorMethodRampData == NULL) {
jmitc91516 6:dba3fbdfd5da 9366 injectorMethodRampData = new InjectorMethodRampData(usbDevice, usbHostGC);
jmitc91516 6:dba3fbdfd5da 9367 }
jmitc91516 6:dba3fbdfd5da 9368 if(injectorMethodRampData != NULL) {
jmitc91516 6:dba3fbdfd5da 9369 injectorMethodRampData->GetRampDataFromGC();
jmitc91516 6:dba3fbdfd5da 9370
jmitc91516 6:dba3fbdfd5da 9371 sprintf(GuiVar_injectorMethodRampCount, "%u", injectorMethodRampData->GetRampCount());
jmitc91516 6:dba3fbdfd5da 9372
jmitc91516 6:dba3fbdfd5da 9373 if(injectorMethodRampData->NeedToUpdateEasyGUIMethodPageRampVariables()) {
jmitc91516 6:dba3fbdfd5da 9374 injectorMethodPageScrollIndex = 0;
jmitc91516 6:dba3fbdfd5da 9375
jmitc91516 6:dba3fbdfd5da 9376 injectorMethodRampData->UpdateEasyGUIMethodPageVariables(injectorMethodPageScrollIndex);
jmitc91516 6:dba3fbdfd5da 9377
jmitc91516 6:dba3fbdfd5da 9378 previousInjectorMethodPageScrollIndex = injectorMethodPageScrollIndex;
jmitc91516 6:dba3fbdfd5da 9379 }
jmitc91516 6:dba3fbdfd5da 9380 }
jmitc91516 6:dba3fbdfd5da 9381 }
jmitc91516 6:dba3fbdfd5da 9382
jmitc91516 6:dba3fbdfd5da 9383
jmitc91516 6:dba3fbdfd5da 9384 /*
jmitc91516 6:dba3fbdfd5da 9385 Should be done at startup, and after a new method has been downloaded
jmitc91516 6:dba3fbdfd5da 9386 */
jmitc91516 6:dba3fbdfd5da 9387 void GetGCStatusLoop::UpdateGasMethodPageData(void)
jmitc91516 6:dba3fbdfd5da 9388 {
jmitc91516 6:dba3fbdfd5da 9389 GetGasPressure(GuiVar_gasMethodInitialPressure, false, false);
jmitc91516 6:dba3fbdfd5da 9390 GetInitialHoldTime(GuiVar_gasMethodInitialHold);
jmitc91516 6:dba3fbdfd5da 9391 if(gasMethodRampData == NULL) {
jmitc91516 6:dba3fbdfd5da 9392 gasMethodRampData = new GasMethodRampData(usbDevice, usbHostGC);
jmitc91516 6:dba3fbdfd5da 9393 }
jmitc91516 6:dba3fbdfd5da 9394 if(gasMethodRampData != NULL) {
jmitc91516 6:dba3fbdfd5da 9395 gasMethodRampData->GetRampDataFromGC();
jmitc91516 6:dba3fbdfd5da 9396
jmitc91516 6:dba3fbdfd5da 9397 sprintf(GuiVar_gasMethodRampCount, "%u", gasMethodRampData->GetRampCount());
jmitc91516 6:dba3fbdfd5da 9398
jmitc91516 6:dba3fbdfd5da 9399 if(gasMethodRampData->NeedToUpdateEasyGUIMethodPageRampVariables()) {
jmitc91516 6:dba3fbdfd5da 9400 gasMethodPageScrollIndex = 0;
jmitc91516 6:dba3fbdfd5da 9401
jmitc91516 6:dba3fbdfd5da 9402 gasMethodRampData->UpdateEasyGUIMethodPageVariables(gasMethodPageScrollIndex);
jmitc91516 6:dba3fbdfd5da 9403
jmitc91516 6:dba3fbdfd5da 9404 previousGasMethodPageScrollIndex = gasMethodPageScrollIndex;
jmitc91516 6:dba3fbdfd5da 9405 }
jmitc91516 5:aceac1035d71 9406 }
jmitc91516 5:aceac1035d71 9407 }
jmitc91516 5:aceac1035d71 9408
jmitc91516 5:aceac1035d71 9409
jmitc91516 1:a5258871b33d 9410 /*
jmitc91516 1:a5258871b33d 9411 This function is called when the Ethernet handler has signaled us that it has
jmitc91516 1:a5258871b33d 9412 received a message from the Ethernet client. This function gets the message
jmitc91516 1:a5258871b33d 9413 from the Ethernet handler, passes it on to the GC, then passes the response back to the handler,
jmitc91516 1:a5258871b33d 9414 to be passed back to the client.
jmitc91516 1:a5258871b33d 9415
jmitc91516 1:a5258871b33d 9416 Note that this function does no other processing on the message -
jmitc91516 1:a5258871b33d 9417 we simply assume that the message must be a GC command without looking at it.
jmitc91516 1:a5258871b33d 9418 */
jmitc91516 1:a5258871b33d 9419 void GetGCStatusLoop::HandleEthernetMessage(Thread* ethernetThread, int debugValue)
jmitc91516 1:a5258871b33d 9420 {
jmitc91516 1:a5258871b33d 9421 // TODO: What if 'handlingEthernetMessage' is already true??
jmitc91516 1:a5258871b33d 9422
jmitc91516 1:a5258871b33d 9423 char gcCommand[256];
jmitc91516 1:a5258871b33d 9424 char gcResponse[GC_MESSAGE_LENGTH + 2];
jmitc91516 1:a5258871b33d 9425 int responseReadyThreadSignalCode;
jmitc91516 1:a5258871b33d 9426
jmitc91516 1:a5258871b33d 9427 handlingEthernetMessage = true;
jmitc91516 1:a5258871b33d 9428
jmitc91516 1:a5258871b33d 9429 EthernetHandler::GetGCCommand(gcCommand, &responseReadyThreadSignalCode);
jmitc91516 1:a5258871b33d 9430
jmitc91516 1:a5258871b33d 9431 ethernetThread->signal_set(GOT_GC_COMMAND);
jmitc91516 1:a5258871b33d 9432
jmitc91516 1:a5258871b33d 9433 //#define ALLOW_DEBUG_PRINTS_HERE
jmitc91516 1:a5258871b33d 9434 #ifdef ALLOW_DEBUG_PRINTS_HERE
jmitc91516 1:a5258871b33d 9435 char buff[300];
jmitc91516 1:a5258871b33d 9436 sprintf(buff, "[%d] Command sent to GC: \"%s\"", debugValue, gcCommand);
jmitc91516 1:a5258871b33d 9437 SpecialDebugPrint(buff, 50, 50);
jmitc91516 1:a5258871b33d 9438 #endif // ALLOW_DEBUG_PRINTS_HERE
jmitc91516 1:a5258871b33d 9439
jmitc91516 1:a5258871b33d 9440 #ifdef USE_LED_FOR_DEBUGGING
jmitc91516 1:a5258871b33d 9441 SetLed3(true);
jmitc91516 1:a5258871b33d 9442 #endif
jmitc91516 1:a5258871b33d 9443
jmitc91516 1:a5258871b33d 9444 gcResponseTimer.reset();
jmitc91516 1:a5258871b33d 9445 gcResponseTimer.start();
jmitc91516 1:a5258871b33d 9446
jmitc91516 1:a5258871b33d 9447 SetGCDeviceReport(gcCommand, gcResponse);
jmitc91516 1:a5258871b33d 9448
jmitc91516 1:a5258871b33d 9449 gcResponseTimer.stop();
jmitc91516 1:a5258871b33d 9450
jmitc91516 1:a5258871b33d 9451 #ifdef USE_LED_FOR_DEBUGGING
jmitc91516 1:a5258871b33d 9452 SetLed3(false);
jmitc91516 1:a5258871b33d 9453 #endif
jmitc91516 1:a5258871b33d 9454
jmitc91516 1:a5258871b33d 9455 // Turn on LED 2 while we are sending a method to the GC
jmitc91516 1:a5258871b33d 9456
jmitc91516 1:a5258871b33d 9457 if(IsStartOfMethodCommand(gcCommand)) {
jmitc91516 1:a5258871b33d 9458 // We have just started sending a method to the GC
jmitc91516 1:a5258871b33d 9459 #ifdef USE_LED_FOR_DEBUGGING
jmitc91516 1:a5258871b33d 9460 SetLed2(true);
jmitc91516 1:a5258871b33d 9461 #endif
jmitc91516 1:a5258871b33d 9462
jmitc91516 1:a5258871b33d 9463 #ifdef DO_NOTHING_ELSE_WHILE_SENDING_METHOD
jmitc91516 1:a5258871b33d 9464 sendingMethod = true;
jmitc91516 1:a5258871b33d 9465 // This is not set true anywhere else - we only need this '#ifdef' here
jmitc91516 1:a5258871b33d 9466 #endif // DO_NOTHING_ELSE_WHILE_SENDING_METHOD
jmitc91516 1:a5258871b33d 9467
jmitc91516 1:a5258871b33d 9468 DisplayDownloadingMethodPage();
jmitc91516 1:a5258871b33d 9469 }
jmitc91516 1:a5258871b33d 9470
jmitc91516 1:a5258871b33d 9471 if(IsEndOfMethodCommand(gcCommand)) {
jmitc91516 1:a5258871b33d 9472 // We have just finished sending a method to the GC
jmitc91516 1:a5258871b33d 9473 #ifdef USE_LED_FOR_DEBUGGING
jmitc91516 1:a5258871b33d 9474 SetLed2(false);
jmitc91516 1:a5258871b33d 9475 #endif
jmitc91516 1:a5258871b33d 9476 sendingMethod = false;
jmitc91516 1:a5258871b33d 9477
jmitc91516 1:a5258871b33d 9478 UndisplayDownloadingMethodPage();
jmitc91516 1:a5258871b33d 9479
jmitc91516 1:a5258871b33d 9480 //needToUpdateProfileGraphs = true;
jmitc91516 1:a5258871b33d 9481 // Just do this here - don't wait - make sure graphs are updated
jmitc91516 1:a5258871b33d 9482 // *before* the user sees them
jmitc91516 1:a5258871b33d 9483 SetupColumnAndInjectorAndGasProfileData();
jmitc91516 5:aceac1035d71 9484
jmitc91516 5:aceac1035d71 9485 UpdateColumnMethodPageData();
jmitc91516 6:dba3fbdfd5da 9486 UpdateInjectorMethodPageData();
jmitc91516 6:dba3fbdfd5da 9487 UpdateGasMethodPageData();
jmitc91516 1:a5258871b33d 9488 }
jmitc91516 1:a5258871b33d 9489
jmitc91516 1:a5258871b33d 9490 if(SuccessfulRunCommand(gcCommand, gcResponse)) {
jmitc91516 1:a5258871b33d 9491 SetupForStartOfRun(usbDevice, usbHostGC);
jmitc91516 1:a5258871b33d 9492 }
jmitc91516 1:a5258871b33d 9493
jmitc91516 1:a5258871b33d 9494 if(SuccessfulAbortCommand(gcCommand, gcResponse)) {
jmitc91516 1:a5258871b33d 9495 runWasAborted = true;
jmitc91516 1:a5258871b33d 9496 }
jmitc91516 1:a5258871b33d 9497
jmitc91516 1:a5258871b33d 9498 #ifdef ALLOW_DEBUG_PRINTS_HERE
jmitc91516 1:a5258871b33d 9499 sprintf(buff, "[%d] Response received from GC: \"%s\"", debugValue, gcResponse);
jmitc91516 1:a5258871b33d 9500 SpecialDebugPrint(buff, 50, 100);
jmitc91516 1:a5258871b33d 9501
jmitc91516 1:a5258871b33d 9502 if((gcResponse[1] == gcCommand[1]) && (gcResponse[2] == gcCommand[2]) && (gcResponse[3] == gcCommand[3])) {
jmitc91516 1:a5258871b33d 9503 SpecialDebugPrint("Command and response match", 50, 120);
jmitc91516 1:a5258871b33d 9504 } else {
jmitc91516 1:a5258871b33d 9505 SpecialDebugPrint("Command and response *** do not match ***", 50, 120);
jmitc91516 1:a5258871b33d 9506 }
jmitc91516 1:a5258871b33d 9507
jmitc91516 1:a5258871b33d 9508 sprintf(buff, "[%d] Time taken by GC: %d ms", debugValue, gcResponseTimer.read_ms());
jmitc91516 1:a5258871b33d 9509 SpecialDebugPrint(buff, 50, 140);
jmitc91516 1:a5258871b33d 9510 #undef ALLOW_DEBUG_PRINTS_HERE
jmitc91516 1:a5258871b33d 9511 #endif // ALLOW_DEBUG_PRINTS_HERE
jmitc91516 1:a5258871b33d 9512
jmitc91516 1:a5258871b33d 9513 // TODO: do this immediately after 'SetGCDeviceReport' above?
jmitc91516 1:a5258871b33d 9514
jmitc91516 1:a5258871b33d 9515 EthernetHandler::SetGCResponse(gcResponse);
jmitc91516 1:a5258871b33d 9516
jmitc91516 1:a5258871b33d 9517 ethernetThread->signal_set(responseReadyThreadSignalCode);
jmitc91516 1:a5258871b33d 9518
jmitc91516 1:a5258871b33d 9519 handlingEthernetMessage = false;
jmitc91516 1:a5258871b33d 9520 }
jmitc91516 1:a5258871b33d 9521
jmitc91516 1:a5258871b33d 9522 /*
jmitc91516 1:a5258871b33d 9523 Attempt to speed up main thread's response to the Ethernet thread -
jmitc91516 1:a5258871b33d 9524 perform a short wait for Ethernet transactions at multiple points in the main loop.
jmitc91516 1:a5258871b33d 9525 */
jmitc91516 1:a5258871b33d 9526 void GetGCStatusLoop::ShortEthernetThreadWait(Thread* ethernetThread, int debugValue)
jmitc91516 1:a5258871b33d 9527 {
jmitc91516 1:a5258871b33d 9528 // Try and keep comms in sync
jmitc91516 1:a5258871b33d 9529 if(!handlingEthernetMessage) {
jmitc91516 1:a5258871b33d 9530
jmitc91516 1:a5258871b33d 9531 Thread::signal_wait(GC_COMMAND_READY, shortWaitTimeMs); // Wait for GC commands over Ethernet link, nothing else
jmitc91516 1:a5258871b33d 9532
jmitc91516 1:a5258871b33d 9533 if(EthernetHandler::GCCommandReceived()) {
jmitc91516 1:a5258871b33d 9534
jmitc91516 1:a5258871b33d 9535 EasyGUIDebugPrintWithCounter("*** Ethernet command received ***", 125, 405);
jmitc91516 1:a5258871b33d 9536
jmitc91516 1:a5258871b33d 9537 HandleEthernetMessage(ethernetThread, debugValue);
jmitc91516 1:a5258871b33d 9538 }
jmitc91516 1:a5258871b33d 9539 // else must have timed out - do nothing
jmitc91516 1:a5258871b33d 9540 }
jmitc91516 1:a5258871b33d 9541 }
jmitc91516 1:a5258871b33d 9542
jmitc91516 1:a5258871b33d 9543 /*
jmitc91516 1:a5258871b33d 9544 Attempt to speed up main thread's response to touch events -
jmitc91516 1:a5258871b33d 9545 perform a short wait for signals from the touch thread at multiple points in the main loop.
jmitc91516 1:a5258871b33d 9546 */
jmitc91516 1:a5258871b33d 9547 void GetGCStatusLoop::ShortTouchThreadWait(SimplifiedTouchListener* stl, int debugValue)
jmitc91516 1:a5258871b33d 9548 {
jmitc91516 1:a5258871b33d 9549 if(!handlingTouchEvent) {
jmitc91516 1:a5258871b33d 9550
jmitc91516 1:a5258871b33d 9551 Thread::signal_wait(TOUCH_EVENT, shortWaitTimeMs); // Wait for touch events (signaled by SimplifiedTouchListener
jmitc91516 1:a5258871b33d 9552 // on touch thread), nothing else
jmitc91516 1:a5258871b33d 9553 short x, y, z;
jmitc91516 1:a5258871b33d 9554 if(stl->GotTouchEvent(&x, &y, &z)) {
jmitc91516 1:a5258871b33d 9555
jmitc91516 1:a5258871b33d 9556 //#define ALLOW_DEBUG_PRINTS_HERE
jmitc91516 1:a5258871b33d 9557 #ifdef ALLOW_DEBUG_PRINTS_HERE
jmitc91516 1:a5258871b33d 9558 char buff[300];
jmitc91516 1:a5258871b33d 9559 sprintf(buff, "[%d] Got touch event", debugValue);
jmitc91516 1:a5258871b33d 9560 SpecialDebugPrint(buff, 400, 80);
jmitc91516 1:a5258871b33d 9561 #endif // ALLOW_DEBUG_PRINTS_HERE
jmitc91516 1:a5258871b33d 9562
jmitc91516 1:a5258871b33d 9563 HandleTouchEvent(x, y, z, debugValue);
jmitc91516 1:a5258871b33d 9564 }
jmitc91516 1:a5258871b33d 9565 // else must have timed out - do nothing
jmitc91516 1:a5258871b33d 9566 }
jmitc91516 1:a5258871b33d 9567 }
jmitc91516 1:a5258871b33d 9568
jmitc91516 1:a5258871b33d 9569
jmitc91516 1:a5258871b33d 9570 /*
jmitc91516 1:a5258871b33d 9571 Attempt to speed up main thread's response to the Touch and Ethernet threads -
jmitc91516 1:a5258871b33d 9572 perform a short wait for signals from any thread at multiple points in the main loop.
jmitc91516 1:a5258871b33d 9573 */
jmitc91516 1:a5258871b33d 9574 void GetGCStatusLoop::ShortThreadWait(SimplifiedTouchListener* stl, Thread* ethernetThread, int debugValue)
jmitc91516 1:a5258871b33d 9575 {
jmitc91516 1:a5258871b33d 9576 osEvent signalWaitRetcode = Thread::signal_wait(0, shortWaitTimeMs); // Wait for any signal
jmitc91516 1:a5258871b33d 9577
jmitc91516 1:a5258871b33d 9578 //#define ALLOW_DEBUG_PRINTS_HERE
jmitc91516 1:a5258871b33d 9579 #ifdef ALLOW_DEBUG_PRINTS_HERE
jmitc91516 1:a5258871b33d 9580 if(signalWaitRetcode.value.signals != 0) {
jmitc91516 1:a5258871b33d 9581 char buff[300];
jmitc91516 1:a5258871b33d 9582 sprintf(buff, "Short Thread::signal_wait returned %X", signalWaitRetcode.value.signals);
jmitc91516 1:a5258871b33d 9583 SpecialDebugPrint(buff, 400, 50);
jmitc91516 1:a5258871b33d 9584 }
jmitc91516 1:a5258871b33d 9585 #undef ALLOW_DEBUG_PRINTS_HERE
jmitc91516 1:a5258871b33d 9586 #endif // ALLOW_DEBUG_PRINTS_HERE
jmitc91516 1:a5258871b33d 9587
jmitc91516 1:a5258871b33d 9588 switch(signalWaitRetcode.value.signals) {
jmitc91516 1:a5258871b33d 9589 case TOUCH_EVENT:
jmitc91516 1:a5258871b33d 9590 if(!handlingTouchEvent) {
jmitc91516 1:a5258871b33d 9591
jmitc91516 1:a5258871b33d 9592 short x, y, z;
jmitc91516 1:a5258871b33d 9593 if(stl->GotTouchEvent(&x, &y, &z)) {
jmitc91516 1:a5258871b33d 9594
jmitc91516 1:a5258871b33d 9595 //#define ALLOW_DEBUG_PRINTS_HERE
jmitc91516 1:a5258871b33d 9596 #ifdef ALLOW_DEBUG_PRINTS_HERE
jmitc91516 1:a5258871b33d 9597 char buff[300];
jmitc91516 1:a5258871b33d 9598 sprintf(buff, "[%d] Got touch event", debugValue);
jmitc91516 1:a5258871b33d 9599 SpecialDebugPrint(buff, 400, 80);
jmitc91516 1:a5258871b33d 9600 #undef ALLOW_DEBUG_PRINTS_HERE
jmitc91516 1:a5258871b33d 9601 #endif // ALLOW_DEBUG_PRINTS_HERE
jmitc91516 1:a5258871b33d 9602
jmitc91516 1:a5258871b33d 9603 HandleTouchEvent(x, y, z, debugValue);
jmitc91516 1:a5258871b33d 9604 }
jmitc91516 0:47c880c1463d 9605 }
jmitc91516 1:a5258871b33d 9606 break;
jmitc91516 1:a5258871b33d 9607
jmitc91516 1:a5258871b33d 9608 case GC_COMMAND_READY:
jmitc91516 1:a5258871b33d 9609 // Try and keep comms in sync
jmitc91516 1:a5258871b33d 9610 if(!handlingEthernetMessage) {
jmitc91516 0:47c880c1463d 9611
jmitc91516 1:a5258871b33d 9612 if(EthernetHandler::GCCommandReceived()) {
jmitc91516 1:a5258871b33d 9613
jmitc91516 1:a5258871b33d 9614 //#define ALLOW_DEBUG_PRINTS_HERE
jmitc91516 1:a5258871b33d 9615 #ifdef ALLOW_DEBUG_PRINTS_HERE
jmitc91516 1:a5258871b33d 9616 char buff[300];
jmitc91516 1:a5258871b33d 9617 sprintf(buff, "[%d] Got Ethernet event", debugValue);
jmitc91516 1:a5258871b33d 9618 SpecialDebugPrint(buff, 400, 80);
jmitc91516 1:a5258871b33d 9619 #undef ALLOW_DEBUG_PRINTS_HERE
jmitc91516 1:a5258871b33d 9620 #endif // ALLOW_DEBUG_PRINTS_HERE
jmitc91516 1:a5258871b33d 9621
jmitc91516 1:a5258871b33d 9622 HandleEthernetMessage(ethernetThread, debugValue);
jmitc91516 1:a5258871b33d 9623 }
jmitc91516 1:a5258871b33d 9624 // else must have timed out - do nothing
jmitc91516 1:a5258871b33d 9625 }
jmitc91516 1:a5258871b33d 9626 break;
jmitc91516 1:a5258871b33d 9627
jmitc91516 1:a5258871b33d 9628 case STARTED_DOWNLOADING_METHOD:
jmitc91516 1:a5258871b33d 9629 // Ethernet thread has signalled us that we have just started sending a method to the GC
jmitc91516 1:a5258871b33d 9630 #ifdef USE_LED_FOR_DEBUGGING
jmitc91516 1:a5258871b33d 9631 // Turn on LED 2 while we are sending a method to the GC
jmitc91516 1:a5258871b33d 9632 SetLed2(true);
jmitc91516 1:a5258871b33d 9633 #endif
jmitc91516 1:a5258871b33d 9634
jmitc91516 1:a5258871b33d 9635 #ifdef DO_NOTHING_ELSE_WHILE_SENDING_METHOD
jmitc91516 1:a5258871b33d 9636 sendingMethod = true;
jmitc91516 1:a5258871b33d 9637 // This is not set true anywhere else - we only need this '#ifdef' here
jmitc91516 1:a5258871b33d 9638 #endif // DO_NOTHING_ELSE_WHILE_SENDING_METHOD
jmitc91516 1:a5258871b33d 9639
jmitc91516 1:a5258871b33d 9640 DisplayDownloadingMethodPage();
jmitc91516 1:a5258871b33d 9641 break;
jmitc91516 1:a5258871b33d 9642
jmitc91516 1:a5258871b33d 9643 case FINISHED_DOWNLOADING_METHOD:
jmitc91516 1:a5258871b33d 9644 // Ethernet thread has signalled us that we have just finished sending a method to the GC
jmitc91516 1:a5258871b33d 9645 #ifdef USE_LED_FOR_DEBUGGING
jmitc91516 1:a5258871b33d 9646 SetLed2(false);
jmitc91516 1:a5258871b33d 9647 #endif
jmitc91516 1:a5258871b33d 9648 sendingMethod = false;
jmitc91516 1:a5258871b33d 9649
jmitc91516 1:a5258871b33d 9650 UndisplayDownloadingMethodPage();
jmitc91516 1:a5258871b33d 9651
jmitc91516 1:a5258871b33d 9652 //needToUpdateProfileGraphs = true;
jmitc91516 1:a5258871b33d 9653 // Just do this here - don't wait - make sure graphs are updated
jmitc91516 1:a5258871b33d 9654 // *before* the user sees them
jmitc91516 1:a5258871b33d 9655 SetupColumnAndInjectorAndGasProfileData();
jmitc91516 5:aceac1035d71 9656
jmitc91516 5:aceac1035d71 9657 UpdateColumnMethodPageData();
jmitc91516 6:dba3fbdfd5da 9658 UpdateInjectorMethodPageData();
jmitc91516 6:dba3fbdfd5da 9659 UpdateGasMethodPageData();
jmitc91516 1:a5258871b33d 9660 break;
jmitc91516 1:a5258871b33d 9661
jmitc91516 1:a5258871b33d 9662 case CRUN_COMMAND_SENT:
jmitc91516 1:a5258871b33d 9663 SetupForStartOfRun(usbDevice, usbHostGC);
jmitc91516 1:a5258871b33d 9664 break;
jmitc91516 1:a5258871b33d 9665
jmitc91516 1:a5258871b33d 9666 case CHON_COMMAND_SENT:
jmitc91516 1:a5258871b33d 9667 DisplayCurrentPageData(true);
jmitc91516 1:a5258871b33d 9668 break;
jmitc91516 1:a5258871b33d 9669
jmitc91516 1:a5258871b33d 9670 case CHOF_COMMAND_SENT:
jmitc91516 1:a5258871b33d 9671 if(realGCIsRunning) {
jmitc91516 1:a5258871b33d 9672 runWasAborted = true;
jmitc91516 1:a5258871b33d 9673 } else {
jmitc91516 1:a5258871b33d 9674 DisplayCurrentPageData(true);
jmitc91516 1:a5258871b33d 9675 }
jmitc91516 1:a5258871b33d 9676 break;
jmitc91516 1:a5258871b33d 9677
jmitc91516 1:a5258871b33d 9678 case ABORT_RUN_COMMAND_SENT:
jmitc91516 1:a5258871b33d 9679 if(realGCIsRunning) {
jmitc91516 1:a5258871b33d 9680 runWasAborted = true;
jmitc91516 1:a5258871b33d 9681 }
jmitc91516 1:a5258871b33d 9682
jmitc91516 1:a5258871b33d 9683 default: // Unknown signal or timeout - ignore
jmitc91516 1:a5258871b33d 9684 break;
jmitc91516 1:a5258871b33d 9685 }
jmitc91516 1:a5258871b33d 9686 }
jmitc91516 1:a5258871b33d 9687
jmitc91516 1:a5258871b33d 9688
jmitc91516 1:a5258871b33d 9689 /*
jmitc91516 1:a5258871b33d 9690 Find out and display the GC's current status
jmitc91516 1:a5258871b33d 9691 */
jmitc91516 1:a5258871b33d 9692 void GetGCStatusLoop::PollGC(SimplifiedTouchListener* stl, Thread* ethernetThread)
jmitc91516 1:a5258871b33d 9693 {
jmitc91516 1:a5258871b33d 9694 char statusString[100];
jmitc91516 1:a5258871b33d 9695
jmitc91516 1:a5258871b33d 9696 if(GCIsInStandbyMode()) {
jmitc91516 1:a5258871b33d 9697 if(!gcInStandbyMode) {
jmitc91516 1:a5258871b33d 9698 gcInStandbyMode = true;
jmitc91516 1:a5258871b33d 9699
jmitc91516 1:a5258871b33d 9700 DisplayStandbyModePage();
jmitc91516 1:a5258871b33d 9701 }
jmitc91516 1:a5258871b33d 9702 }
jmitc91516 1:a5258871b33d 9703
jmitc91516 1:a5258871b33d 9704 //ShortEthernetThreadWait(ethernetThread, 2);
jmitc91516 1:a5258871b33d 9705 //ShortTouchThreadWait(stl, 2);
jmitc91516 1:a5258871b33d 9706 ShortThreadWait(stl, ethernetThread, 2);
jmitc91516 1:a5258871b33d 9707
jmitc91516 1:a5258871b33d 9708 // Deal with GC status
jmitc91516 1:a5258871b33d 9709 int gcStatus = GetGCStatus();
jmitc91516 1:a5258871b33d 9710 if(GCHasFaulted(gcStatus, statusString)) {
jmitc91516 1:a5258871b33d 9711 if(realGCIsRunning) {
jmitc91516 1:a5258871b33d 9712
jmitc91516 1:a5258871b33d 9713 // GC has faulted during a run
jmitc91516 1:a5258871b33d 9714
jmitc91516 1:a5258871b33d 9715 realGCIsRunning = false;
jmitc91516 1:a5258871b33d 9716
jmitc91516 1:a5258871b33d 9717 #ifdef SERVICE_INTERVALS_ACTIVE
jmitc91516 1:a5258871b33d 9718 ServiceInterval::TellAllServiceIntervalsInstrumentHasCycled();
jmitc91516 1:a5258871b33d 9719 // Some components need servicing based on how many cycles the instrument has performed
jmitc91516 1:a5258871b33d 9720 // (others are time-based, i.e. every twelve months)
jmitc91516 1:a5258871b33d 9721 if(ServiceInterval::AtLeastOneServiceIntervalHasExpired()) {
jmitc91516 1:a5258871b33d 9722 DisplayServicingRequiredPage();
jmitc91516 0:47c880c1463d 9723 }
jmitc91516 1:a5258871b33d 9724 #endif // SERVICE_INTERVALS_ACTIVE
jmitc91516 1:a5258871b33d 9725 }
jmitc91516 1:a5258871b33d 9726
jmitc91516 1:a5258871b33d 9727 //ShortEthernetThreadWait(ethernetThread, 3);
jmitc91516 1:a5258871b33d 9728 //ShortTouchThreadWait(stl, 3);
jmitc91516 1:a5258871b33d 9729 ShortThreadWait(stl, ethernetThread, 3);
jmitc91516 1:a5258871b33d 9730
jmitc91516 1:a5258871b33d 9731
jmitc91516 1:a5258871b33d 9732 if((currentPage != GuiStruct_GCInFaultStatePage_11)
jmitc91516 1:a5258871b33d 9733 || (strcmp(GuiVar_gcState, statusString) != 0)) {
jmitc91516 1:a5258871b33d 9734 strcpy(GuiVar_gcState, statusString);
jmitc91516 1:a5258871b33d 9735
jmitc91516 1:a5258871b33d 9736 DisplayGCInFaultStatePage(currentPage != GuiStruct_GCInFaultStatePage_11);
jmitc91516 1:a5258871b33d 9737 }
jmitc91516 1:a5258871b33d 9738
jmitc91516 1:a5258871b33d 9739 //ShortEthernetThreadWait(ethernetThread, 4);
jmitc91516 1:a5258871b33d 9740 //ShortTouchThreadWait(stl, 4);
jmitc91516 1:a5258871b33d 9741 ShortThreadWait(stl, ethernetThread, 4);
jmitc91516 1:a5258871b33d 9742
jmitc91516 1:a5258871b33d 9743
jmitc91516 1:a5258871b33d 9744 } else { // GC has not faulted
jmitc91516 1:a5258871b33d 9745
jmitc91516 1:a5258871b33d 9746 if(currentPage == GuiStruct_GCInFaultStatePage_11) {
jmitc91516 1:a5258871b33d 9747
jmitc91516 1:a5258871b33d 9748 // No longer in fault state
jmitc91516 1:a5258871b33d 9749
jmitc91516 1:a5258871b33d 9750 currentPage = GuiStruct_HomePage_1;
jmitc91516 1:a5258871b33d 9751
jmitc91516 1:a5258871b33d 9752 lastSimplifiedGCState = GC_FAULTED;
jmitc91516 1:a5258871b33d 9753
jmitc91516 1:a5258871b33d 9754 // The code below will now display the home page
jmitc91516 1:a5258871b33d 9755
jmitc91516 1:a5258871b33d 9756 // ...but first, we need to do this - without it, the red rectangle (showing the error state)
jmitc91516 1:a5258871b33d 9757 // is left in the background when we display the home page
jmitc91516 1:a5258871b33d 9758 #ifdef USING_BACKGROUND_BITMAP
jmitc91516 1:a5258871b33d 9759 DrawBackgroundBitmap();
jmitc91516 1:a5258871b33d 9760 #else
jmitc91516 1:a5258871b33d 9761 GuiLib_Clear();
jmitc91516 1:a5258871b33d 9762 #endif
jmitc91516 1:a5258871b33d 9763 }
jmitc91516 1:a5258871b33d 9764
jmitc91516 1:a5258871b33d 9765 //ShortEthernetThreadWait(ethernetThread, 5);
jmitc91516 1:a5258871b33d 9766 //ShortTouchThreadWait(stl, 5);
jmitc91516 1:a5258871b33d 9767 ShortThreadWait(stl, ethernetThread, 5);
jmitc91516 1:a5258871b33d 9768
jmitc91516 1:a5258871b33d 9769 // Bug #4 fix - make sure GC status is up to date - we may have done something
jmitc91516 1:a5258871b33d 9770 // to change it in 'ShortThreadWait'
jmitc91516 1:a5258871b33d 9771 gcStatus = GetGCStatus();
jmitc91516 1:a5258871b33d 9772
jmitc91516 1:a5258871b33d 9773 GCStateSimplified simplifiedGCState = GCStateOrFaultCode::GetSimplifiedGCState(gcStatus);
jmitc91516 1:a5258871b33d 9774
jmitc91516 1:a5258871b33d 9775 char buff[200];
jmitc91516 1:a5258871b33d 9776 sprintf(buff, "simplifiedGCState is: %d", simplifiedGCState);
jmitc91516 1:a5258871b33d 9777 EasyGUIDebugPrintWithCounter(buff, 400, 300);
jmitc91516 1:a5258871b33d 9778
jmitc91516 1:a5258871b33d 9779 #ifdef UPDATE_PAGES_CONTINUOUSLY
jmitc91516 1:a5258871b33d 9780 if(!handlingEthernetMessage) { // Try and keep comms in sync
jmitc91516 1:a5258871b33d 9781 #else
jmitc91516 1:a5258871b33d 9782 if(simplifiedGCState != lastSimplifiedGCState) {
jmitc91516 1:a5258871b33d 9783 #endif // UPDATE_PAGES_CONTINUOUSLY
jmitc91516 1:a5258871b33d 9784
jmitc91516 1:a5258871b33d 9785 // Re-display all pages that display a status (heat on/off, column ready/equilibrating, etc)
jmitc91516 1:a5258871b33d 9786 // - i.e. a coloured status rectangle, and/or descriptive status text
jmitc91516 1:a5258871b33d 9787 if(PageIncludesComponentStatus(currentPage)) {
jmitc91516 1:a5258871b33d 9788 DisplayCurrentPageData(true);
jmitc91516 1:a5258871b33d 9789 }
jmitc91516 1:a5258871b33d 9790 /*
jmitc91516 1:a5258871b33d 9791 if(currentPage == GuiStruct_HomePage_1) {
jmitc91516 1:a5258871b33d 9792 DisplayHomePageData(true);
jmitc91516 1:a5258871b33d 9793 } else if(currentPage == GuiStruct_ColumnPage1_2) {
jmitc91516 1:a5258871b33d 9794 DisplayColumnPageData(true, CONVENTIONAL_COLUMN, GuiStruct_ColumnPage1_2);
jmitc91516 1:a5258871b33d 9795 } else if(currentPage == GuiStruct_ColumnDHPage1_40) {
jmitc91516 1:a5258871b33d 9796 DisplayColumnPageData(true, DIRECTLY_HEATED_COLUMN, GuiStruct_ColumnDHPage1_40);
jmitc91516 1:a5258871b33d 9797 } else if(currentPage == GuiStruct_InjectorPage1_3) {
jmitc91516 1:a5258871b33d 9798 DisplayInjectorPageData(true);
jmitc91516 1:a5258871b33d 9799 }
jmitc91516 1:a5258871b33d 9800 */
jmitc91516 1:a5258871b33d 9801 }
jmitc91516 1:a5258871b33d 9802
jmitc91516 1:a5258871b33d 9803 if((simplifiedGCState == GC_RUNNING) && (!realGCIsRunning)) {
jmitc91516 1:a5258871b33d 9804 // GC has started running without our knowledge
jmitc91516 1:a5258871b33d 9805 // (e.g. it can be started by a hardware trigger)
jmitc91516 1:a5258871b33d 9806 SetupForStartOfRun(usbDevice, usbHostGC);
jmitc91516 1:a5258871b33d 9807 //#define BUG_4_ALLOW_DEBUG_PRINTS_HERE
jmitc91516 1:a5258871b33d 9808 #ifdef BUG_4_ALLOW_DEBUG_PRINTS_HERE
jmitc91516 1:a5258871b33d 9809 SpecialDebugPrint("WOK run started", 150, 460);
jmitc91516 1:a5258871b33d 9810 // WOK = "without our knowledge" -
jmitc91516 1:a5258871b33d 9811 // mistakenly executing this code after the run has been aborted
jmitc91516 1:a5258871b33d 9812 // causes bug #4 - but *why* is it executed?
jmitc91516 1:a5258871b33d 9813 // Ans - because we get the GC status early on in this function,
jmitc91516 1:a5258871b33d 9814 // and we call 'ShortThreadWait' several times between there and here.
jmitc91516 1:a5258871b33d 9815 // If a 'ShortThreadWait' sees a touch on ABORT_RUN_YES, we will stop
jmitc91516 1:a5258871b33d 9816 // the run *after* getting the status in this function, and
jmitc91516 1:a5258871b33d 9817 // 'simplifiedGCState' will be out of date. In this case, we will see bug #4...
jmitc91516 1:a5258871b33d 9818 #undef BUG_4_ALLOW_DEBUG_PRINTS_HERE
jmitc91516 1:a5258871b33d 9819 #endif // BUG_4_ALLOW_DEBUG_PRINTS_HERE
jmitc91516 1:a5258871b33d 9820 }
jmitc91516 1:a5258871b33d 9821
jmitc91516 1:a5258871b33d 9822 lastSimplifiedGCState = simplifiedGCState;
jmitc91516 1:a5258871b33d 9823 }
jmitc91516 1:a5258871b33d 9824 // End of dealing with GC status
jmitc91516 1:a5258871b33d 9825
jmitc91516 1:a5258871b33d 9826 //ShortEthernetThreadWait(ethernetThread, 6);
jmitc91516 1:a5258871b33d 9827 //ShortTouchThreadWait(stl, 6);
jmitc91516 1:a5258871b33d 9828 ShortThreadWait(stl, ethernetThread, 6);
jmitc91516 1:a5258871b33d 9829
jmitc91516 1:a5258871b33d 9830 if(pageJustChanged) {
jmitc91516 1:a5258871b33d 9831 // Don't display page data if it has just been done - leave till next time -
jmitc91516 1:a5258871b33d 9832 // (a) it's unnecessary, (b) it appears to cause random crashes
jmitc91516 1:a5258871b33d 9833 pageJustChanged = false;
jmitc91516 1:a5258871b33d 9834 } else {
jmitc91516 1:a5258871b33d 9835 DisplayCurrentPageData(false);
jmitc91516 1:a5258871b33d 9836 }
jmitc91516 1:a5258871b33d 9837
jmitc91516 1:a5258871b33d 9838 //ShortEthernetThreadWait(ethernetThread, 7);
jmitc91516 1:a5258871b33d 9839 //ShortTouchThreadWait(stl, 7);
jmitc91516 1:a5258871b33d 9840 ShortThreadWait(stl, ethernetThread, 7);
jmitc91516 1:a5258871b33d 9841 }
jmitc91516 1:a5258871b33d 9842
jmitc91516 1:a5258871b33d 9843
jmitc91516 1:a5258871b33d 9844 /*
jmitc91516 1:a5258871b33d 9845 Deal with the user interface and the Ethernet interface - both are signaled to us by other threads,
jmitc91516 1:a5258871b33d 9846 so we need to use the same Thread::signal_wait for both.
jmitc91516 1:a5258871b33d 9847
jmitc91516 1:a5258871b33d 9848 One of the most important functions in this application.
jmitc91516 1:a5258871b33d 9849 ********************************************************
jmitc91516 1:a5258871b33d 9850 */
jmitc91516 1:a5258871b33d 9851 void GetGCStatusLoop::HandleUserInterfaceAndEthernet(SimplifiedTouchListener* stl, Thread* ethernetThread)
jmitc91516 1:a5258871b33d 9852 {
jmitc91516 0:47c880c1463d 9853 #ifdef USE_THREAD_WAIT
jmitc91516 1:a5258871b33d 9854 // Thread::wait(waitTimeMs); // Let other things happen
jmitc91516 1:a5258871b33d 9855 // Thread::signal_wait(TOUCH_EVENT, waitTimeMs);
jmitc91516 1:a5258871b33d 9856 osEvent signalWaitRetcode;
jmitc91516 1:a5258871b33d 9857
jmitc91516 1:a5258871b33d 9858 if(sendingMethod) {
jmitc91516 1:a5258871b33d 9859 // Try and make sending a method as fast as possible - ignore other events
jmitc91516 1:a5258871b33d 9860 // signalWaitRetcode = Thread::signal_wait(GC_COMMAND_READY); // Wait for GC commands over Ethernet link, nothing else -
jmitc91516 1:a5258871b33d 9861 // // and don't timeout
jmitc91516 1:a5258871b33d 9862 // No - the Ethernet thread, not this thread, now handles the USB traffic with the GC -
jmitc91516 1:a5258871b33d 9863 // so while the download is in progress, wait only for the signal the Ethernet thread sends us
jmitc91516 1:a5258871b33d 9864 // to tell us it has finished downloading the method
jmitc91516 1:a5258871b33d 9865 signalWaitRetcode = Thread::signal_wait(FINISHED_DOWNLOADING_METHOD);
jmitc91516 1:a5258871b33d 9866 } else {
jmitc91516 1:a5258871b33d 9867 signalWaitRetcode = Thread::signal_wait(0, waitTimeMs); // Wait for any signal, not just touch events
jmitc91516 1:a5258871b33d 9868 }
jmitc91516 1:a5258871b33d 9869 //#define ALLOW_DEBUG_PRINTS_HERE
jmitc91516 1:a5258871b33d 9870 #ifdef ALLOW_DEBUG_PRINTS_HERE
jmitc91516 1:a5258871b33d 9871 if(signalWaitRetcode.value.signals != 0) {
jmitc91516 1:a5258871b33d 9872 char buff[300];
jmitc91516 1:a5258871b33d 9873 sprintf(buff, "Main Thread::signal_wait returned %X", signalWaitRetcode.value.signals);
jmitc91516 1:a5258871b33d 9874 SpecialDebugPrint(buff, 400, 50);
jmitc91516 1:a5258871b33d 9875 }
jmitc91516 1:a5258871b33d 9876 #undef ALLOW_DEBUG_PRINTS_HERE
jmitc91516 1:a5258871b33d 9877 #endif // ALLOW_DEBUG_PRINTS_HERE
jmitc91516 1:a5258871b33d 9878
jmitc91516 1:a5258871b33d 9879 if(signalWaitRetcode.value.signals == TOUCH_EVENT) {
jmitc91516 1:a5258871b33d 9880
jmitc91516 1:a5258871b33d 9881 if(!handlingTouchEvent) {
jmitc91516 1:a5258871b33d 9882 short x, y, z;
jmitc91516 1:a5258871b33d 9883 if(stl->GotTouchEvent(&x, &y, &z)) {
jmitc91516 1:a5258871b33d 9884 //#define ALLOW_DEBUG_PRINTS_HERE
jmitc91516 1:a5258871b33d 9885 #ifdef ALLOW_DEBUG_PRINTS_HERE
jmitc91516 1:a5258871b33d 9886 SpecialDebugPrint("[1] Got touch event", 400, 80);
jmitc91516 1:a5258871b33d 9887 #endif // ALLOW_DEBUG_PRINTS_HERE
jmitc91516 1:a5258871b33d 9888
jmitc91516 1:a5258871b33d 9889 HandleTouchEvent(x, y, z, 1);
jmitc91516 1:a5258871b33d 9890 }
jmitc91516 1:a5258871b33d 9891 }
jmitc91516 1:a5258871b33d 9892
jmitc91516 1:a5258871b33d 9893 } else if (signalWaitRetcode.value.signals == GC_COMMAND_READY) {
jmitc91516 1:a5258871b33d 9894 if(EthernetHandler::GCCommandReceived()) {
jmitc91516 1:a5258871b33d 9895
jmitc91516 1:a5258871b33d 9896 EasyGUIDebugPrintWithCounter("*** Ethernet command received ***", 125, 405);
jmitc91516 1:a5258871b33d 9897
jmitc91516 1:a5258871b33d 9898 // Try and keep comms in sync
jmitc91516 1:a5258871b33d 9899 if(!handlingEthernetMessage) {
jmitc91516 1:a5258871b33d 9900 HandleEthernetMessage(ethernetThread, 1);
jmitc91516 1:a5258871b33d 9901 }
jmitc91516 1:a5258871b33d 9902
jmitc91516 1:a5258871b33d 9903 #if defined MULTI_TOUCH_TECHNIQUE_3
jmitc91516 1:a5258871b33d 9904 gotAtLeastOneTimeout = true; // i.e. 'one non touch event'
jmitc91516 1:a5258871b33d 9905 #endif
jmitc91516 1:a5258871b33d 9906 }
jmitc91516 1:a5258871b33d 9907
jmitc91516 1:a5258871b33d 9908 } else if (signalWaitRetcode.value.signals == STARTED_DOWNLOADING_METHOD) {
jmitc91516 1:a5258871b33d 9909
jmitc91516 1:a5258871b33d 9910 // Ethernet thread has signaled us that we have just started sending a method to the GC
jmitc91516 1:a5258871b33d 9911 #ifdef USE_LED_FOR_DEBUGGING
jmitc91516 1:a5258871b33d 9912 // Turn on LED 2 while we are sending a method to the GC
jmitc91516 1:a5258871b33d 9913 SetLed2(true);
jmitc91516 1:a5258871b33d 9914 #endif
jmitc91516 1:a5258871b33d 9915
jmitc91516 1:a5258871b33d 9916 #ifdef DO_NOTHING_ELSE_WHILE_SENDING_METHOD
jmitc91516 1:a5258871b33d 9917 sendingMethod = true;
jmitc91516 1:a5258871b33d 9918 // This is not set true anywhere else - we only need this '#ifdef' here
jmitc91516 1:a5258871b33d 9919 #endif // DO_NOTHING_ELSE_WHILE_SENDING_METHOD
jmitc91516 1:a5258871b33d 9920
jmitc91516 1:a5258871b33d 9921 DisplayDownloadingMethodPage();
jmitc91516 1:a5258871b33d 9922
jmitc91516 1:a5258871b33d 9923 } else if (signalWaitRetcode.value.signals == FINISHED_DOWNLOADING_METHOD) {
jmitc91516 1:a5258871b33d 9924
jmitc91516 1:a5258871b33d 9925 // Ethernet thread has signaled us that we have just finished sending a method to the GC
jmitc91516 1:a5258871b33d 9926 #ifdef USE_LED_FOR_DEBUGGING
jmitc91516 1:a5258871b33d 9927 // Turn on LED 2 while we are sending a method to the GC
jmitc91516 1:a5258871b33d 9928 SetLed2(false);
jmitc91516 1:a5258871b33d 9929 #endif
jmitc91516 1:a5258871b33d 9930 sendingMethod = false;
jmitc91516 1:a5258871b33d 9931
jmitc91516 1:a5258871b33d 9932 UndisplayDownloadingMethodPage();
jmitc91516 1:a5258871b33d 9933
jmitc91516 1:a5258871b33d 9934 //needToUpdateProfileGraphs = true;
jmitc91516 1:a5258871b33d 9935 // Just do this here - don't wait - make sure graphs are updated
jmitc91516 1:a5258871b33d 9936 // *before* the user sees them
jmitc91516 1:a5258871b33d 9937 SetupColumnAndInjectorAndGasProfileData();
jmitc91516 1:a5258871b33d 9938 // ...but note that we do this *after* un-displaying the downloading method page -
jmitc91516 1:a5258871b33d 9939 // otherwise there is an annoying lag between Ellution saying it has finished sending the method
jmitc91516 1:a5258871b33d 9940 // and our showing our normal UI again (and we hope the user will not want to look
jmitc91516 1:a5258871b33d 9941 // at the profiles immediately after the download finishes)
jmitc91516 1:a5258871b33d 9942
jmitc91516 5:aceac1035d71 9943 UpdateColumnMethodPageData();
jmitc91516 6:dba3fbdfd5da 9944 UpdateInjectorMethodPageData();
jmitc91516 6:dba3fbdfd5da 9945 UpdateGasMethodPageData();
jmitc91516 5:aceac1035d71 9946
jmitc91516 1:a5258871b33d 9947 } else if (signalWaitRetcode.value.signals == CRUN_COMMAND_SENT) {
jmitc91516 1:a5258871b33d 9948 SetupForStartOfRun(usbDevice, usbHostGC);
jmitc91516 1:a5258871b33d 9949 } else if (signalWaitRetcode.value.signals == CHON_COMMAND_SENT) {
jmitc91516 1:a5258871b33d 9950 DisplayCurrentPageData(true);
jmitc91516 1:a5258871b33d 9951 } else if (signalWaitRetcode.value.signals == CHOF_COMMAND_SENT) {
jmitc91516 1:a5258871b33d 9952 if(realGCIsRunning) {
jmitc91516 1:a5258871b33d 9953 runWasAborted = true;
jmitc91516 1:a5258871b33d 9954 } else {
jmitc91516 1:a5258871b33d 9955 DisplayCurrentPageData(true);
jmitc91516 1:a5258871b33d 9956 }
jmitc91516 1:a5258871b33d 9957 } else if (signalWaitRetcode.value.signals == ABORT_RUN_COMMAND_SENT) {
jmitc91516 1:a5258871b33d 9958 if(realGCIsRunning) {
jmitc91516 1:a5258871b33d 9959 runWasAborted = true;
jmitc91516 1:a5258871b33d 9960 }
jmitc91516 1:a5258871b33d 9961 } else { // Assume Thread::signal_wait timed out
jmitc91516 1:a5258871b33d 9962
jmitc91516 1:a5258871b33d 9963 #ifdef MULTI_TOUCH_TECHNIQUE_1
jmitc91516 1:a5258871b33d 9964 EasyGUIDebugPrintWithCounter("*** Timer event or timeout ***", 125, 405);
jmitc91516 0:47c880c1463d 9965 #else
jmitc91516 1:a5258871b33d 9966 // Timer used only with MULTI_TOUCH_TECHNIQUE_1
jmitc91516 1:a5258871b33d 9967 EasyGUIDebugPrintWithCounter("*** Timeout ***", 125, 405);
jmitc91516 1:a5258871b33d 9968 #endif // MULTI_TOUCH_TECHNIQUE_1
jmitc91516 1:a5258871b33d 9969
jmitc91516 1:a5258871b33d 9970 #if defined MULTI_TOUCH_TECHNIQUE_3
jmitc91516 1:a5258871b33d 9971 gotAtLeastOneTimeout = true;
jmitc91516 1:a5258871b33d 9972 #endif
jmitc91516 1:a5258871b33d 9973
jmitc91516 1:a5258871b33d 9974 // While sending a method, do nothing else - otherwise method download is ridiculously slow
jmitc91516 1:a5258871b33d 9975 // ***************
jmitc91516 1:a5258871b33d 9976 if(!sendingMethod) {
jmitc91516 1:a5258871b33d 9977 PollGC(stl, ethernetThread);
jmitc91516 1:a5258871b33d 9978 // }
jmitc91516 1:a5258871b33d 9979 // Include everything else in this if - *really* do nothing else
jmitc91516 1:a5258871b33d 9980
jmitc91516 1:a5258871b33d 9981 if(GCIsRunning()) {
jmitc91516 1:a5258871b33d 9982
jmitc91516 1:a5258871b33d 9983 // While the GC is running, all pages below need to be continuously updated -
jmitc91516 1:a5258871b33d 9984 // but do not force them to (re)display their data if it has not changed
jmitc91516 1:a5258871b33d 9985 if(currentPage == GuiStruct_RunningColumnPage_25) {
jmitc91516 1:a5258871b33d 9986 DisplayRunningColumnPageData(false, false);
jmitc91516 1:a5258871b33d 9987 } else if (currentPage == GuiStruct_RunningGasPage_28) {
jmitc91516 1:a5258871b33d 9988 DisplayRunningGasPageData(false, false);
jmitc91516 1:a5258871b33d 9989 } else if (currentPage == GuiStruct_RunningInjectorProfilePage_Def) {
jmitc91516 1:a5258871b33d 9990 DisplayRunningInjectorProfilePageData(false, false);
jmitc91516 1:a5258871b33d 9991 } else if (currentPage == GuiStruct_RunningPage1_7) {
jmitc91516 1:a5258871b33d 9992 DisplayRunningPageData(false, false);
jmitc91516 1:a5258871b33d 9993 }
jmitc91516 1:a5258871b33d 9994
jmitc91516 1:a5258871b33d 9995 } else if(realGCIsRunning) {
jmitc91516 1:a5258871b33d 9996
jmitc91516 1:a5258871b33d 9997 // The GC has stopped running, but our "the GC is running" flag is still set -
jmitc91516 1:a5258871b33d 9998 // either the run has ended normally, it has been aborted, or the GC has faulted
jmitc91516 1:a5258871b33d 9999 // (although now we should be dealing with the latter situation above,
jmitc91516 1:a5258871b33d 10000 // when we detect that the GC has faulted)
jmitc91516 1:a5258871b33d 10001
jmitc91516 1:a5258871b33d 10002 if(!GCHasFaulted()) {
jmitc91516 1:a5258871b33d 10003
jmitc91516 1:a5258871b33d 10004 if(runWasAborted) {
jmitc91516 1:a5258871b33d 10005
jmitc91516 1:a5258871b33d 10006 DisplayRunAbortedPage();
jmitc91516 1:a5258871b33d 10007
jmitc91516 1:a5258871b33d 10008 // Prepare for next run...
jmitc91516 1:a5258871b33d 10009 runWasAborted = false;
jmitc91516 1:a5258871b33d 10010
jmitc91516 1:a5258871b33d 10011 } else {
jmitc91516 1:a5258871b33d 10012
jmitc91516 1:a5258871b33d 10013 // The run has ended normally - give the progress bar and method profiles a chance to show this to the user
jmitc91516 1:a5258871b33d 10014 if(currentPage == GuiStruct_RunningColumnPage_25) {
jmitc91516 1:a5258871b33d 10015 DisplayRunningColumnPageData(false, true);
jmitc91516 1:a5258871b33d 10016 } else if (currentPage == GuiStruct_RunningGasPage_28) {
jmitc91516 1:a5258871b33d 10017 DisplayRunningGasPageData(false, true);
jmitc91516 1:a5258871b33d 10018 } else if (currentPage == GuiStruct_RunningInjectorProfilePage_Def) {
jmitc91516 1:a5258871b33d 10019 DisplayRunningInjectorProfilePageData(false, true);
jmitc91516 1:a5258871b33d 10020 } else if (currentPage == GuiStruct_RunningPage1_7) {
jmitc91516 1:a5258871b33d 10021 DisplayRunningPageData(false, true);
jmitc91516 1:a5258871b33d 10022 }
jmitc91516 1:a5258871b33d 10023
jmitc91516 1:a5258871b33d 10024 // Let the user briefly see the above before we display "Run Completed"
jmitc91516 1:a5258871b33d 10025 Thread::wait(500); // 0.5 second
jmitc91516 1:a5258871b33d 10026
jmitc91516 1:a5258871b33d 10027 DisplayRunCompletePage();
jmitc91516 8:26e49e6955bd 10028
jmitc91516 8:26e49e6955bd 10029 // Want to display "Run Complete" for 5 seconds, then the Home page.
jmitc91516 8:26e49e6955bd 10030 // Maybe this is all that is needed...
jmitc91516 8:26e49e6955bd 10031 // Thread::wait(5000);
jmitc91516 8:26e49e6955bd 10032 // DisplayHomePageData(true);
jmitc91516 8:26e49e6955bd 10033
jmitc91516 1:a5258871b33d 10034
jmitc91516 1:a5258871b33d 10035 //#define BUG_4_ALLOW_DEBUG_PRINTS_HERE
jmitc91516 1:a5258871b33d 10036 #ifdef BUG_4_ALLOW_DEBUG_PRINTS_HERE
jmitc91516 1:a5258871b33d 10037 char bug4[100];
jmitc91516 1:a5258871b33d 10038 sprintf(bug4, "+++ realGCIsRunning %d +++", realGCIsRunning);
jmitc91516 1:a5258871b33d 10039 SpecialDebugPrint(bug4, 150, 440);
jmitc91516 1:a5258871b33d 10040 sprintf(bug4, "+++ Thread %X +++", osThreadGetId());
jmitc91516 1:a5258871b33d 10041 SpecialDebugPrint(bug4, 150, 460);
jmitc91516 1:a5258871b33d 10042 #undef BUG_4_ALLOW_DEBUG_PRINTS_HERE
jmitc91516 1:a5258871b33d 10043 #endif // BUG_4_ALLOW_DEBUG_PRINTS_HERE
jmitc91516 1:a5258871b33d 10044 }
jmitc91516 1:a5258871b33d 10045 }
jmitc91516 1:a5258871b33d 10046 // 'else' the GC has faulted while the run was in progress - we will display the 'GCInFaultStatePage' anyway
jmitc91516 1:a5258871b33d 10047 // (see the top of this function)
jmitc91516 1:a5258871b33d 10048
jmitc91516 1:a5258871b33d 10049 // Now tidy up...
jmitc91516 1:a5258871b33d 10050 ClearGCIsRunning();
jmitc91516 1:a5258871b33d 10051
jmitc91516 1:a5258871b33d 10052 #ifdef SERVICE_INTERVALS_ACTIVE
jmitc91516 1:a5258871b33d 10053 ServiceInterval::TellAllServiceIntervalsInstrumentHasCycled();
jmitc91516 1:a5258871b33d 10054 // Some components need servicing based on how many cycles the instrument has performed
jmitc91516 1:a5258871b33d 10055 // (others are time-based, i.e. every twelve months)
jmitc91516 1:a5258871b33d 10056 if(ServiceInterval::AtLeastOneServiceIntervalHasExpired()) {
jmitc91516 1:a5258871b33d 10057 DisplayServicingRequiredPage();
jmitc91516 1:a5258871b33d 10058 }
jmitc91516 1:a5258871b33d 10059 #endif // SERVICE_INTERVALS_ACTIVE
jmitc91516 1:a5258871b33d 10060 }
jmitc91516 1:a5258871b33d 10061 } // if (!sendingMethod)
jmitc91516 1:a5258871b33d 10062 }
jmitc91516 1:a5258871b33d 10063 #else // USE_THREAD_WAIT
jmitc91516 1:a5258871b33d 10064 wait_ms(waitTimeMs); // Let other things happen
jmitc91516 1:a5258871b33d 10065 #endif // USE_THREAD_WAIT
jmitc91516 1:a5258871b33d 10066
jmitc91516 1:a5258871b33d 10067 }
jmitc91516 1:a5258871b33d 10068
jmitc91516 1:a5258871b33d 10069 /*
jmitc91516 1:a5258871b33d 10070 Along with TouchCallBack (main.cpp), this is one of the most important functions in this application.
jmitc91516 1:a5258871b33d 10071 ****************************************************************************************************
jmitc91516 1:a5258871b33d 10072
jmitc91516 1:a5258871b33d 10073 Once called, this function never returns - it enters a loop in which it sets up the Ethernet interface,
jmitc91516 1:a5258871b33d 10074 which in turn enters an inner loop calling HandleUserInterfaceAndEthernet (see above) repeatedly.
jmitc91516 1:a5258871b33d 10075 This inner loop exits only if the Ethernet parameters have changed,
jmitc91516 1:a5258871b33d 10076 and we have to set up the Ethernet interface again.
jmitc91516 1:a5258871b33d 10077 */
jmitc91516 1:a5258871b33d 10078 void GetGCStatusLoop::MainLoopWithEthernet(DMBoard* board)
jmitc91516 1:a5258871b33d 10079 {
jmitc91516 1:a5258871b33d 10080 // Need to do this once only - it is nothing to do with the Ethernet interface
jmitc91516 1:a5258871b33d 10081 SimplifiedTouchListener* stl = SimplifiedTouchListener::GetInstance(osThreadGetId(), board->touchPanel());
jmitc91516 1:a5258871b33d 10082
jmitc91516 1:a5258871b33d 10083 Thread* ethernetThread;
jmitc91516 0:47c880c1463d 10084 EthernetInterface eth;
jmitc91516 1:a5258871b33d 10085 TCPSocketServer server;
jmitc91516 1:a5258871b33d 10086
jmitc91516 1:a5258871b33d 10087 DisplayEthernetConnectionPage();
jmitc91516 1:a5258871b33d 10088
jmitc91516 1:a5258871b33d 10089 EasyGUIDebugPrintWithCounter("Ethernet -2", 100, 450);
jmitc91516 1:a5258871b33d 10090 //#define ALLOW_DEBUG_PRINTS_HERE
jmitc91516 1:a5258871b33d 10091 #ifdef ALLOW_DEBUG_PRINTS_HERE
jmitc91516 1:a5258871b33d 10092 char buff[300];
jmitc91516 1:a5258871b33d 10093 sprintf(buff, "Ethernet -2 - stl %X", stl);
jmitc91516 1:a5258871b33d 10094 SpecialDebugPrint(buff, 100, 400);
jmitc91516 1:a5258871b33d 10095 #endif // ALLOW_DEBUG_PRINTS_HERE
jmitc91516 1:a5258871b33d 10096
jmitc91516 1:a5258871b33d 10097 NetworkParameters *networkParameters = NetworkParameters::GetInstance(usbDevice, usbHostGC);
jmitc91516 1:a5258871b33d 10098 if(networkParameters != NULL) {
jmitc91516 1:a5258871b33d 10099 // We are assuming here that the NetworkParameters instance will have read its values
jmitc91516 1:a5258871b33d 10100 // from QSPI memory
jmitc91516 1:a5258871b33d 10101 ethernetPort = networkParameters->GetPortNumber();
jmitc91516 1:a5258871b33d 10102 networkParameters->GetIPAddressAsString(ethernetIP);
jmitc91516 1:a5258871b33d 10103 networkParameters->GetSubnetMaskAsString(ethernetMask);
jmitc91516 1:a5258871b33d 10104 networkParameters->GetGatewayAddressAsString(ethernetGateway);
jmitc91516 1:a5258871b33d 10105 useDHCPForEthernet = networkParameters->GetUseDHCP();
jmitc91516 1:a5258871b33d 10106 //#define WANT_ETHERNET_DEBUG_2
jmitc91516 1:a5258871b33d 10107 #ifdef WANT_ETHERNET_DEBUG_2
jmitc91516 1:a5258871b33d 10108 char dbg[300];
jmitc91516 1:a5258871b33d 10109 sprintf(dbg, "networkParameters IP: \"%s\", mask: \"%s\", gateway: \"%s\"", ethernetIP, ethernetMask, ethernetGateway);
jmitc91516 1:a5258871b33d 10110 SpecialDebugPrint(dbg, 100, 20);
jmitc91516 1:a5258871b33d 10111 #endif // WANT_ETHERNET_DEBUG_2
jmitc91516 1:a5258871b33d 10112 }
jmitc91516 1:a5258871b33d 10113
jmitc91516 1:a5258871b33d 10114 EasyGUIDebugPrintWithCounter("Ethernet -1", 100, 450);
jmitc91516 1:a5258871b33d 10115
jmitc91516 1:a5258871b33d 10116 //#define WANT_ETHERNET_DEBUG
jmitc91516 1:a5258871b33d 10117 if(useDHCPForEthernet) {
jmitc91516 1:a5258871b33d 10118 eth.init(); // With no args, init function uses DHCP
jmitc91516 1:a5258871b33d 10119
jmitc91516 1:a5258871b33d 10120 #ifdef WANT_ETHERNET_DEBUG
jmitc91516 1:a5258871b33d 10121 char dbg[300];
jmitc91516 1:a5258871b33d 10122 sprintf(dbg, "DHCP Ethernet IP: \"%s\", mask: \"%s\", gateway: \"%s\"", eth.getIPAddress(), eth.getNetworkMask(), eth.getGateway());
jmitc91516 1:a5258871b33d 10123 SpecialDebugPrint(dbg, 100, 20);
jmitc91516 1:a5258871b33d 10124 #endif // WANT_ETHERNET_DEBUG
jmitc91516 1:a5258871b33d 10125
jmitc91516 1:a5258871b33d 10126 } else {
jmitc91516 1:a5258871b33d 10127
jmitc91516 1:a5258871b33d 10128 #ifdef WANT_ETHERNET_DEBUG
jmitc91516 1:a5258871b33d 10129 char dbg[300];
jmitc91516 1:a5258871b33d 10130 sprintf(dbg, "Ethernet IP: \"%s\", mask: \"%s\", gateway: \"%s\"", ethernetIP, ethernetMask, ethernetGateway);
jmitc91516 1:a5258871b33d 10131 SpecialDebugPrint(dbg, 100, 20);
jmitc91516 1:a5258871b33d 10132 #undef WANT_ETHERNET_DEBUG
jmitc91516 1:a5258871b33d 10133 #endif // WANT_ETHERNET_DEBUG
jmitc91516 1:a5258871b33d 10134
jmitc91516 1:a5258871b33d 10135 eth.init(ethernetIP, ethernetMask, ethernetGateway); // Use addresses from our member variables
jmitc91516 1:a5258871b33d 10136 }
jmitc91516 1:a5258871b33d 10137
jmitc91516 1:a5258871b33d 10138 EasyGUIDebugPrintWithCounter("Ethernet -1 A", 100, 450);
jmitc91516 1:a5258871b33d 10139
jmitc91516 0:47c880c1463d 10140 eth.connect();
jmitc91516 1:a5258871b33d 10141
jmitc91516 1:a5258871b33d 10142 EasyGUIDebugPrintWithCounter("Ethernet -1 B", 100, 450);
jmitc91516 1:a5258871b33d 10143
jmitc91516 0:47c880c1463d 10144 server.bind(ethernetPort);
jmitc91516 0:47c880c1463d 10145 server.listen();
jmitc91516 0:47c880c1463d 10146
jmitc91516 1:a5258871b33d 10147 EasyGUIDebugPrintWithCounter("Ethernet 0", 100, 450);
jmitc91516 1:a5258871b33d 10148
jmitc91516 1:a5258871b33d 10149 // Set up Ethernet Handler, and start it in its own thread
jmitc91516 1:a5258871b33d 10150 EthernetHandler::SetMainThreadId(osThreadGetId());
jmitc91516 1:a5258871b33d 10151 EthernetHandler::SetEthernetServer(&server);
jmitc91516 1:a5258871b33d 10152 EthernetHandler::SetUsbGC(usbDevice, usbHostGC);
jmitc91516 1:a5258871b33d 10153 #define ETHERNET_THREAD_RAISE_PRIORITY
jmitc91516 1:a5258871b33d 10154 #ifdef ETHERNET_THREAD_RAISE_PRIORITY
jmitc91516 1:a5258871b33d 10155 ethernetThread = new Thread(EthernetHandler::HandlerFunction, NULL, osPriorityHigh);
jmitc91516 1:a5258871b33d 10156 #undef ETHERNET_THREAD_RAISE_PRIORITY
jmitc91516 1:a5258871b33d 10157 #else // Give the Ethernet thread normal priority
jmitc91516 1:a5258871b33d 10158 ethernetThread = new Thread(EthernetHandler::HandlerFunction);
jmitc91516 1:a5258871b33d 10159 #endif
jmitc91516 1:a5258871b33d 10160
jmitc91516 1:a5258871b33d 10161 restartRequired = false;
jmitc91516 1:a5258871b33d 10162
jmitc91516 1:a5258871b33d 10163 EasyGUIDebugPrintWithCounter("Ethernet 1", 100, 450);
jmitc91516 1:a5258871b33d 10164
jmitc91516 1:a5258871b33d 10165 // We are no longer trying to establish the Ethernet connection
jmitc91516 1:a5258871b33d 10166 #ifdef USING_BACKGROUND_BITMAP
jmitc91516 1:a5258871b33d 10167 DrawBackgroundBitmap();
jmitc91516 0:47c880c1463d 10168 #else
jmitc91516 1:a5258871b33d 10169 GuiLib_Clear();
jmitc91516 1:a5258871b33d 10170 #endif
jmitc91516 1:a5258871b33d 10171
jmitc91516 1:a5258871b33d 10172 if((qspiBitmaps != NULL) && (qspiBitmaps->AllBitmapsLoaded())) {
jmitc91516 1:a5258871b33d 10173 currentPage = GuiStruct_HomePage_1;
jmitc91516 1:a5258871b33d 10174 DisplayCurrentPageData(true);
jmitc91516 1:a5258871b33d 10175 } else {
jmitc91516 1:a5258871b33d 10176 currentPage = GuiStruct_FailedToFindBitmapsPage_0;
jmitc91516 1:a5258871b33d 10177 DisplayFailedToFindBitmapsPage();
jmitc91516 1:a5258871b33d 10178 }
jmitc91516 1:a5258871b33d 10179
jmitc91516 1:a5258871b33d 10180 //#define WANT_ETHERNET_DEBUG_3
jmitc91516 1:a5258871b33d 10181 if(useDHCPForEthernet) {
jmitc91516 1:a5258871b33d 10182 #ifdef WANT_ETHERNET_DEBUG_3
jmitc91516 1:a5258871b33d 10183 char dbg[100];
jmitc91516 1:a5258871b33d 10184 sprintf(dbg, "DHCP Ethernet IP: \"%s\", mask: \"%s\", gateway: \"%s\"", eth.getIPAddress(), eth.getNetworkMask(), eth.getGateway());
jmitc91516 1:a5258871b33d 10185 SpecialDebugPrint(dbg, 100, 20);
jmitc91516 1:a5258871b33d 10186 #endif // WANT_ETHERNET_DEBUG_3
jmitc91516 1:a5258871b33d 10187
jmitc91516 1:a5258871b33d 10188 // Let the user see (in the Network Parameters page) the actual IP address, etc, we are using
jmitc91516 1:a5258871b33d 10189 if(networkParameters != NULL) {
jmitc91516 1:a5258871b33d 10190 networkParameters->SetIPAddressFromString(eth.getIPAddress());
jmitc91516 1:a5258871b33d 10191 networkParameters->SetSubnetMaskFromString(eth.getNetworkMask());
jmitc91516 1:a5258871b33d 10192 networkParameters->SetGatewayAddressFromString(eth.getGateway());
jmitc91516 1:a5258871b33d 10193 }
jmitc91516 1:a5258871b33d 10194 #ifdef WANT_ETHERNET_DEBUG_3
jmitc91516 1:a5258871b33d 10195 } else {
jmitc91516 1:a5258871b33d 10196 char dbg[600];
jmitc91516 1:a5258871b33d 10197 int dbg1;
jmitc91516 1:a5258871b33d 10198 char dbg2[100];
jmitc91516 1:a5258871b33d 10199 char dbg3[100];
jmitc91516 1:a5258871b33d 10200 char dbg4[100];
jmitc91516 1:a5258871b33d 10201 int dbg5;
jmitc91516 1:a5258871b33d 10202
jmitc91516 1:a5258871b33d 10203 dbg1 = networkParameters->GetPortNumber();
jmitc91516 1:a5258871b33d 10204 networkParameters->GetIPAddressAsString(dbg2);
jmitc91516 1:a5258871b33d 10205 networkParameters->GetSubnetMaskAsString(dbg3);
jmitc91516 1:a5258871b33d 10206 networkParameters->GetGatewayAddressAsString(dbg4);
jmitc91516 1:a5258871b33d 10207 dbg5 = networkParameters->GetUseDHCP();
jmitc91516 1:a5258871b33d 10208
jmitc91516 1:a5258871b33d 10209 sprintf(dbg, "Non-DHCP : %d, IP: \"%s\", mask: \"%s\", gateway: \"%s\"", dbg1, dbg2, dbg3, dbg4);
jmitc91516 1:a5258871b33d 10210 SpecialDebugPrint(dbg, 100, 20);
jmitc91516 1:a5258871b33d 10211 }
jmitc91516 1:a5258871b33d 10212 #else
jmitc91516 1:a5258871b33d 10213 }
jmitc91516 1:a5258871b33d 10214 #endif
jmitc91516 1:a5258871b33d 10215
jmitc91516 1:a5258871b33d 10216 if(networkParameters != NULL) {
jmitc91516 1:a5258871b33d 10217 networkParameters->SaveRealValues(&eth);
jmitc91516 1:a5258871b33d 10218 }
jmitc91516 1:a5258871b33d 10219
jmitc91516 1:a5258871b33d 10220 // We will need to restart (i.e. reboot) if the Ethernet parameters have changed -
jmitc91516 1:a5258871b33d 10221 // if you try and call the EthernetInterface init method again (which is the obvious way
jmitc91516 1:a5258871b33d 10222 // of doing this) it crashes
jmitc91516 1:a5258871b33d 10223 while (!restartRequired)
jmitc91516 1:a5258871b33d 10224 {
jmitc91516 1:a5258871b33d 10225 HandleUserInterfaceAndEthernet(stl, ethernetThread);
jmitc91516 1:a5258871b33d 10226 }
jmitc91516 1:a5258871b33d 10227
jmitc91516 1:a5258871b33d 10228 EasyGUIDebugPrintWithCounter("Ethernet 2", 100, 400);
jmitc91516 1:a5258871b33d 10229
jmitc91516 1:a5258871b33d 10230 eth.disconnect();
jmitc91516 1:a5258871b33d 10231 ethernetThread->terminate();
jmitc91516 1:a5258871b33d 10232 delete ethernetThread;
jmitc91516 1:a5258871b33d 10233
jmitc91516 1:a5258871b33d 10234 EasyGUIDebugPrintWithCounter("Ethernet 3", 100, 400);
jmitc91516 1:a5258871b33d 10235
jmitc91516 1:a5258871b33d 10236 reboot(); // In main.cpp
jmitc91516 1:a5258871b33d 10237 }
jmitc91516 1:a5258871b33d 10238