Repository for import to local machine

Dependencies:   DMBasicGUI DMSupport

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

Who changed what in which revision?

UserRevisionLine numberNew contents of line
jmitc91516 1:a5258871b33d 1 #ifndef GUILIBGRAPH_H
jmitc91516 1:a5258871b33d 2 #define GUILIBGRAPH_H
jmitc91516 1:a5258871b33d 3
jmitc91516 1:a5258871b33d 4 #include "GuiLib.h"
jmitc91516 1:a5258871b33d 5 #include "GuiDisplay.h"
jmitc91516 1:a5258871b33d 6
jmitc91516 1:a5258871b33d 7 #include "USBHostGC.h"
jmitc91516 1:a5258871b33d 8
jmitc91516 1:a5258871b33d 9 #include "GCStateAndFaultCodes.h" // This also contains the #define'd symbol USE_VERSION_102
jmitc91516 1:a5258871b33d 10
jmitc91516 1:a5258871b33d 11
jmitc91516 1:a5258871b33d 12 typedef enum enumTimeUnit { MINUTES, SECONDS } TimeUnit;
jmitc91516 1:a5258871b33d 13
jmitc91516 1:a5258871b33d 14 typedef struct structFloatingDataPoint { float X; float Y; } FloatingDataPoint;
jmitc91516 1:a5258871b33d 15
jmitc91516 1:a5258871b33d 16 /*
jmitc91516 1:a5258871b33d 17 A class to implement an array of graph coordinate values, for use with an easyGUI graph
jmitc91516 1:a5258871b33d 18 (and with the GuiLibGraph class below, each instance of which encapsulates an easyGUI graph).
jmitc91516 1:a5258871b33d 19 Note that, while an easyGUI graph requires its coordinates to be integers,
jmitc91516 1:a5258871b33d 20 we use floating point values in this class, for accuracy (the GC stores time values in 'units'
jmitc91516 1:a5258871b33d 21 of 0.1 minute). We convert these values to integers only when we pass them to an actual graph.
jmitc91516 1:a5258871b33d 22 */
jmitc91516 1:a5258871b33d 23 class GuiLibGraphDataSet
jmitc91516 1:a5258871b33d 24 {
jmitc91516 1:a5258871b33d 25 public:
jmitc91516 1:a5258871b33d 26 GuiLibGraphDataSet();
jmitc91516 1:a5258871b33d 27 ~GuiLibGraphDataSet();
jmitc91516 1:a5258871b33d 28
jmitc91516 1:a5258871b33d 29 void ClearData(void);
jmitc91516 1:a5258871b33d 30
jmitc91516 1:a5258871b33d 31 bool AddDataPoint(float X, float Y);
jmitc91516 1:a5258871b33d 32 bool GetDataPoint(int dataPointIndex, float *X, float *Y);
jmitc91516 1:a5258871b33d 33
jmitc91516 1:a5258871b33d 34 GuiLib_GraphDataPoint* GetGraphDataPointCopy(TimeUnit timeUnit, GuiConst_INT16U *countOfCopiedPoints);
jmitc91516 1:a5258871b33d 35 GuiLib_GraphDataPoint* GetGraphDataPointCopyInTenthsOfMinutes(float yAxisScaleFactor, GuiConst_INT16U *countOfCopiedPoints);
jmitc91516 1:a5258871b33d 36 GuiConst_INT16U GetDataSize(void) { return graphDataSetActualLength; }
jmitc91516 1:a5258871b33d 37
jmitc91516 1:a5258871b33d 38 float GetYCoordAtXCoord(float X);
jmitc91516 1:a5258871b33d 39
jmitc91516 1:a5258871b33d 40 void MakePartialCopy(float startXCoord, float endXCoord, GuiLibGraphDataSet* copyDestination);
jmitc91516 1:a5258871b33d 41 void MakeInterpolatedPartialCopy(float startXCoord, float endXCoord, float xInterval, GuiLibGraphDataSet* copyDestination);
jmitc91516 1:a5258871b33d 42 void MakeInterpolatedPartialCopyWithFinalPoint(float startXCoord, float endXCoord, float xInterval, GuiLibGraphDataSet* copyDestination);
jmitc91516 1:a5258871b33d 43
jmitc91516 1:a5258871b33d 44 int SetupFromColumnTemperatureRampValues(USBDeviceConnected* usbDevice, USBHostGC* usbHostGC);
jmitc91516 1:a5258871b33d 45 int SetupFromPressureRampValues(USBDeviceConnected* usbDevice, USBHostGC* usbHostGC, GuiLibGraphDataSet* columnMethodDataSet);
jmitc91516 1:a5258871b33d 46 int SetupInjectorTemperatureProfileToMatchColumnMethod(USBDeviceConnected* usbDevice, USBHostGC* usbHostGC, GuiLibGraphDataSet* columnMethodDataSet);
jmitc91516 1:a5258871b33d 47 int SetupFromPTVTemperatureRampValues(USBDeviceConnected* usbDevice, USBHostGC* usbHostGC);
jmitc91516 1:a5258871b33d 48 int SetupGasPressureProfileWithTimingsFromColumnMethod(USBDeviceConnected* usbDevice, USBHostGC* usbHostGC, GuiLibGraphDataSet* columnMethodDataSet);
jmitc91516 1:a5258871b33d 49
jmitc91516 1:a5258871b33d 50 float GetTotalMethodTime(void);
jmitc91516 1:a5258871b33d 51 int GetPointCount(void) { return graphDataSetActualLength; }
jmitc91516 1:a5258871b33d 52 float GetNonRoundedTotalMethodTime(void) { return nonRoundedTotalMethodTime; }
jmitc91516 1:a5258871b33d 53
jmitc91516 1:a5258871b33d 54 void GetXAxisRange(GuiConst_INT32S *xMin, GuiConst_INT32S *xMax, TimeUnit timeUnit);
jmitc91516 1:a5258871b33d 55 void GetXAxisRangeInTenthsOfMinutes(GuiConst_INT32S *xMin, GuiConst_INT32S *xMax);
jmitc91516 1:a5258871b33d 56 void GetYAxisRange(GuiConst_INT32S *yMin, GuiConst_INT32S *yMax);
jmitc91516 1:a5258871b33d 57
jmitc91516 1:a5258871b33d 58 void GetXAxisRange(GuiConst_INT32S *xMin, GuiConst_INT32S *xMax, GuiConst_INT32S tickSize, TimeUnit timeUnit);
jmitc91516 1:a5258871b33d 59 void GetXAxisRangeInTenthsOfMinutes(GuiConst_INT32S *xMin, GuiConst_INT32S *xMax, GuiConst_INT32S tickSize);
jmitc91516 1:a5258871b33d 60 void GetYAxisRange(GuiConst_INT32S *yMin, GuiConst_INT32S *yMax, GuiConst_INT32S tickSize);
jmitc91516 1:a5258871b33d 61
jmitc91516 1:a5258871b33d 62 void DrawUsingGuiLibVLine(GuiConst_INT16S xLeft, GuiConst_INT16S yBottom, double xScaleFactor, double yScaleFactor, GuiConst_INTCOLOR firstColour, GuiConst_INTCOLOR secondColour, double xColourBoundary);
jmitc91516 1:a5258871b33d 63 void DrawUsingGuiLibVLine(void); // Use the values previously passed to the version with parameters
jmitc91516 1:a5258871b33d 64
jmitc91516 1:a5258871b33d 65 static void ConvertFloatingDataPointToGuiLibGraphDataPoint(GuiLib_GraphDataPoint* graphDataPoint, FloatingDataPoint floatingDataPoint, TimeUnit timeUnit);
jmitc91516 1:a5258871b33d 66
jmitc91516 1:a5258871b33d 67 private:
jmitc91516 1:a5258871b33d 68 enum SizeIncrement { SIZE_INCREMENT = 10 }; // i.e. we allocate enough memory for this number of points each time we extend the array
jmitc91516 1:a5258871b33d 69
jmitc91516 1:a5258871b33d 70 FloatingDataPoint* theGraphDataSet; // pointer to the actual data
jmitc91516 1:a5258871b33d 71
jmitc91516 1:a5258871b33d 72 int graphDataSetActualLength; // The number of points to which we have actually assigned values
jmitc91516 1:a5258871b33d 73 int graphDataSetSizeInIncrements; // The number of points allowed for in the memory allocated to the array, as a count of SIZE_INCREMENT 'quanta' -
jmitc91516 1:a5258871b33d 74 // i.e. the actual number of points currently available is (graphDataSetSizeInIncrements * SIZE_INCREMENT).
jmitc91516 1:a5258871b33d 75 // This *must* always be >= graphDataSetActualLength
jmitc91516 1:a5258871b33d 76
jmitc91516 1:a5258871b33d 77 float nonRoundedTotalMethodTime; // The value returned by 'GetTotalMethodTime' is affected by the fact that X coordinates (i.e. time values)
jmitc91516 1:a5258871b33d 78 // are rounded to integer values (usually in minutes), because easyGUI graphs use integer coordinate values.
jmitc91516 1:a5258871b33d 79 // This variable contains the non-rounded, accurate, total method time (effectively in units of 0.1 minute,
jmitc91516 1:a5258871b33d 80 // as used by the GC itself).
jmitc91516 1:a5258871b33d 81 // *** This variable will be set only if the 'SetupFromColumnTemperatureRampValues', 'SetupFromPressureRampValues' ***
jmitc91516 1:a5258871b33d 82 // *** 'SetupGasPressureProfileWithTimingsFromColumnMethod', 'SetupInjectorTemperatureProfileToMatchColumnMethod' ***
jmitc91516 1:a5258871b33d 83 // *** or 'SetupFromPTVTemperatureRampValues' methods have been called on this dataset. Otherwise it will be zero. ***
jmitc91516 1:a5258871b33d 84
jmitc91516 1:a5258871b33d 85 bool ExtendDataSetArray(void);
jmitc91516 1:a5258871b33d 86
jmitc91516 1:a5258871b33d 87 float GetComponentTemperature(char *cmd, USBDeviceConnected* usbDevice, USBHostGC* usbHostGC);
jmitc91516 1:a5258871b33d 88 float GetColumnTemperature(USBDeviceConnected* usbDevice, USBHostGC* usbHostGC);
jmitc91516 1:a5258871b33d 89 float GetInjectorTemperature(USBDeviceConnected* usbDevice, USBHostGC* usbHostGC);
jmitc91516 1:a5258871b33d 90
jmitc91516 1:a5258871b33d 91 float GetTimeValue(char *cmd, USBDeviceConnected* usbDevice, USBHostGC* usbHostGC);
jmitc91516 1:a5258871b33d 92 float GetInitialHoldTime(USBDeviceConnected* usbDevice, USBHostGC* usbHostGC);
jmitc91516 1:a5258871b33d 93 float GetPTVInitialTime(USBDeviceConnected* usbDevice, USBHostGC* usbHostGC);
jmitc91516 1:a5258871b33d 94
jmitc91516 1:a5258871b33d 95 float GetInitialPressure(USBDeviceConnected* usbDevice, USBHostGC* usbHostGC);
jmitc91516 1:a5258871b33d 96
jmitc91516 1:a5258871b33d 97 float GetRampValue(char *cmd, int rampIndex, USBDeviceConnected* usbDevice, USBHostGC* usbHostGC);
jmitc91516 1:a5258871b33d 98
jmitc91516 1:a5258871b33d 99 float GetTemperatureRampRate(int rampIndex, USBDeviceConnected* usbDevice, USBHostGC* usbHostGC);
jmitc91516 1:a5258871b33d 100 float GetRampUpperTemperature(int rampIndex, USBDeviceConnected* usbDevice, USBHostGC* usbHostGC);
jmitc91516 1:a5258871b33d 101
jmitc91516 1:a5258871b33d 102 float GetRampUpperTime(int rampIndex, USBDeviceConnected* usbDevice, USBHostGC* usbHostGC);
jmitc91516 1:a5258871b33d 103
jmitc91516 1:a5258871b33d 104 float GetPressureRampRate(int rampIndex, USBDeviceConnected* usbDevice, USBHostGC* usbHostGC);
jmitc91516 1:a5258871b33d 105 float GetRampUpperPressure(int rampIndex, USBDeviceConnected* usbDevice, USBHostGC* usbHostGC);
jmitc91516 1:a5258871b33d 106
jmitc91516 1:a5258871b33d 107 float GetPTVTemperatureRampRate(int rampIndex, USBDeviceConnected* usbDevice, USBHostGC* usbHostGC);
jmitc91516 1:a5258871b33d 108 float GetPTVRampUpperTemperature(int rampIndex, USBDeviceConnected* usbDevice, USBHostGC* usbHostGC);
jmitc91516 1:a5258871b33d 109
jmitc91516 1:a5258871b33d 110 float GetPTVRampUpperTime(int rampIndex, USBDeviceConnected* usbDevice, USBHostGC* usbHostGC);
jmitc91516 1:a5258871b33d 111
jmitc91516 1:a5258871b33d 112 void RoundAxisRangeByTickSize(GuiConst_INT32S *axisMin, GuiConst_INT32S *axisMax, GuiConst_INT32S rawAxisMin, GuiConst_INT32S rawAxisMax, GuiConst_INT32S axisTickSize);
jmitc91516 1:a5258871b33d 113
jmitc91516 1:a5258871b33d 114 struct structDrawUsingGuiLibVLineParameters {
jmitc91516 1:a5258871b33d 115 bool isSet;
jmitc91516 1:a5258871b33d 116 GuiConst_INT16S xLeft;
jmitc91516 1:a5258871b33d 117 GuiConst_INT16S yBottom;
jmitc91516 1:a5258871b33d 118 double xScaleFactor;
jmitc91516 1:a5258871b33d 119 double yScaleFactor;
jmitc91516 1:a5258871b33d 120 GuiConst_INTCOLOR firstColour;
jmitc91516 1:a5258871b33d 121 GuiConst_INTCOLOR secondColour;
jmitc91516 1:a5258871b33d 122 double xColourBoundary;
jmitc91516 1:a5258871b33d 123 } DrawUsingGuiLibVLineParameters;
jmitc91516 1:a5258871b33d 124
jmitc91516 1:a5258871b33d 125 void DrawUsingGuiLibVLine(GuiConst_INT16S xLeft, GuiConst_INT16S yBottom, double xScaleFactor, double yScaleFactor,
jmitc91516 1:a5258871b33d 126 GuiConst_INTCOLOR firstColour, GuiConst_INTCOLOR secondColour, double xColourBoundary, bool recordParameters);
jmitc91516 1:a5258871b33d 127 };
jmitc91516 1:a5258871b33d 128
jmitc91516 1:a5258871b33d 129 /*
jmitc91516 1:a5258871b33d 130 A class to implement an easyGUI graph, so that the caller does not need to know (for example)
jmitc91516 1:a5258871b33d 131 which easyGUI 'GuiLib_Graph_xxx' functions to call, or how to use them. These functions
jmitc91516 1:a5258871b33d 132 will be called only from inside this class.
jmitc91516 1:a5258871b33d 133
jmitc91516 1:a5258871b33d 134 This should keep the caller's code simpler and easier to understand - all the complications
jmitc91516 1:a5258871b33d 135 will be 'encapsulated' in this class.
jmitc91516 1:a5258871b33d 136
jmitc91516 1:a5258871b33d 137 The graph index must be defined when an object of this class is instantiated.
jmitc91516 1:a5258871b33d 138 This must correspond with its index number in easyGUI.
jmitc91516 1:a5258871b33d 139 *****************************************************
jmitc91516 1:a5258871b33d 140 */
jmitc91516 1:a5258871b33d 141 class GuiLibGraph
jmitc91516 1:a5258871b33d 142 {
jmitc91516 1:a5258871b33d 143 public:
jmitc91516 1:a5258871b33d 144 GuiLibGraph(GuiConst_INT8U graphIndex);
jmitc91516 1:a5258871b33d 145 ~GuiLibGraph();
jmitc91516 1:a5258871b33d 146
jmitc91516 1:a5258871b33d 147 GuiConst_INT8U DrawAxes(void);
jmitc91516 1:a5258871b33d 148 GuiConst_INT8U DrawDataSet(GuiConst_INT8U dataSetIndex);
jmitc91516 1:a5258871b33d 149 GuiConst_INT8U DrawDataPoint(GuiConst_INT8U dataSetIndex, GuiConst_INT16U dataPointIndex);
jmitc91516 1:a5258871b33d 150 GuiConst_INT8U HideDataSet(GuiConst_INT8U dataSetIndex);
jmitc91516 1:a5258871b33d 151 GuiConst_INT8U ShowDataSet(GuiConst_INT8U dataSetIndex);
jmitc91516 1:a5258871b33d 152
jmitc91516 1:a5258871b33d 153 void DrawXAxisLabels(GuiConst_INT32S minValue, GuiConst_INT32S maxValue, GuiConst_INT32S tickSize,
jmitc91516 1:a5258871b33d 154 GuiConst_INT16S graphX, GuiConst_INT16S graphY, GuiConst_INT16S graphW);
jmitc91516 1:a5258871b33d 155 void DrawXAxisLabels(void); // Use the values previously passed to the version with parameters
jmitc91516 1:a5258871b33d 156
jmitc91516 1:a5258871b33d 157 void DrawYAxisLabels(GuiConst_INT32S minValue, GuiConst_INT32S maxValue, GuiConst_INT32S tickSize,
jmitc91516 1:a5258871b33d 158 GuiConst_INT16S graphX, GuiConst_INT16S graphY, GuiConst_INT16S graphH);
jmitc91516 1:a5258871b33d 159 void DrawYAxisLabels(void); // Use the values previously passed to the version with parameters
jmitc91516 1:a5258871b33d 160
jmitc91516 1:a5258871b33d 161 GuiConst_INT8U SetXAxisRange(GuiConst_INT32S minValue, GuiConst_INT32S maxValue);
jmitc91516 1:a5258871b33d 162 GuiConst_INT8U SetYAxisRange(GuiConst_INT32S minValue, GuiConst_INT32S maxValue);
jmitc91516 1:a5258871b33d 163
jmitc91516 1:a5258871b33d 164 GuiConst_INT8U SetDataForGraphDataSet(GuiConst_INT8U dataSetIndex, GuiLibGraphDataSet* dataSet, TimeUnit timeUnit);
jmitc91516 1:a5258871b33d 165 GuiConst_INT8U SetDataForGraphDataSetInTenthsOfMinutes(GuiConst_INT8U dataSetIndex, float yAxisScaleFactor, GuiLibGraphDataSet* dataSet);
jmitc91516 1:a5258871b33d 166 GuiConst_INT8U SetSinglePointForGraphDataSet(GuiConst_INT8U dataSetIndex, GuiConst_INT32S X, GuiConst_INT32S Y);
jmitc91516 1:a5258871b33d 167
jmitc91516 1:a5258871b33d 168 GuiConst_INT8U Redraw(void);
jmitc91516 1:a5258871b33d 169
jmitc91516 1:a5258871b33d 170 void SetXAxisUnits(TimeUnit newXAxisUnits);
jmitc91516 1:a5258871b33d 171 TimeUnit GetXAxisUnits(void);
jmitc91516 1:a5258871b33d 172
jmitc91516 1:a5258871b33d 173 private:
jmitc91516 1:a5258871b33d 174 GuiConst_INT8U GuiLib_GraphIndex;
jmitc91516 1:a5258871b33d 175
jmitc91516 1:a5258871b33d 176 TimeUnit xAxisUnits;
jmitc91516 1:a5258871b33d 177
jmitc91516 1:a5258871b33d 178 enum { MINUTES_XAXIS_INDEX = 0, SECONDS_XAXIS_INDEX = 1 }; // There are two X axes set up for each graph in easyGUI. These are their indices
jmitc91516 1:a5258871b33d 179 enum { YAXIS_INDEX = 0 }; // For completeness - we currently do not intend to have multiple Y axes
jmitc91516 1:a5258871b33d 180
jmitc91516 1:a5258871b33d 181 // We keep a pointer to the dataset data for each dataset index, up to 10.
jmitc91516 1:a5258871b33d 182 // This is the data added to the easyGUI graph object at that index.
jmitc91516 1:a5258871b33d 183 // Currently, we do not allow indices outside the range 0-9 - we just ignore them
jmitc91516 1:a5258871b33d 184 enum { DATASET_INDEX_COUNT = 10 };
jmitc91516 1:a5258871b33d 185 GuiLib_GraphDataPoint *dataSetDataPtr[DATASET_INDEX_COUNT];
jmitc91516 1:a5258871b33d 186
jmitc91516 1:a5258871b33d 187 struct structXAxisLabelData {
jmitc91516 1:a5258871b33d 188 bool isSet;
jmitc91516 1:a5258871b33d 189 GuiConst_INT32S minValue;
jmitc91516 1:a5258871b33d 190 GuiConst_INT32S maxValue;
jmitc91516 1:a5258871b33d 191 GuiConst_INT32S tickSize;
jmitc91516 1:a5258871b33d 192 GuiConst_INT16S graphX;
jmitc91516 1:a5258871b33d 193 GuiConst_INT16S graphY;
jmitc91516 1:a5258871b33d 194 GuiConst_INT16S graphW;
jmitc91516 1:a5258871b33d 195 } xAxisLabelData;
jmitc91516 1:a5258871b33d 196
jmitc91516 1:a5258871b33d 197 struct structYAxisLabelData {
jmitc91516 1:a5258871b33d 198 bool isSet;
jmitc91516 1:a5258871b33d 199 GuiConst_INT32S minValue;
jmitc91516 1:a5258871b33d 200 GuiConst_INT32S maxValue;
jmitc91516 1:a5258871b33d 201 GuiConst_INT32S tickSize;
jmitc91516 1:a5258871b33d 202 GuiConst_INT16S graphX;
jmitc91516 1:a5258871b33d 203 GuiConst_INT16S graphY;
jmitc91516 1:a5258871b33d 204 GuiConst_INT16S graphH;
jmitc91516 1:a5258871b33d 205 } yAxisLabelData;
jmitc91516 1:a5258871b33d 206
jmitc91516 1:a5258871b33d 207 void DrawXAxisLabels(GuiConst_INT32S minValue, GuiConst_INT32S maxValue, GuiConst_INT32S tickSize,
jmitc91516 1:a5258871b33d 208 GuiConst_INT16S graphX, GuiConst_INT16S graphY, GuiConst_INT16S graphW, bool recordParameters);
jmitc91516 1:a5258871b33d 209
jmitc91516 1:a5258871b33d 210 void DrawYAxisLabels(GuiConst_INT32S minValue, GuiConst_INT32S maxValue, GuiConst_INT32S tickSize,
jmitc91516 1:a5258871b33d 211 GuiConst_INT16S graphX, GuiConst_INT16S graphY, GuiConst_INT16S graphH, bool recordParameters);
jmitc91516 1:a5258871b33d 212 };
jmitc91516 1:a5258871b33d 213
jmitc91516 1:a5258871b33d 214 #endif // GUILIBGRAPH_H