Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: DMBasicGUI DMSupport
GuiLibGraph.h
00001 #ifndef GUILIBGRAPH_H 00002 #define GUILIBGRAPH_H 00003 00004 #include "GuiLib.h" 00005 #include "GuiDisplay.h" 00006 00007 #include "USBHostGC.h" 00008 00009 #include "GCStateAndFaultCodes.h" // This also contains the #define'd symbol USE_VERSION_102 00010 00011 00012 typedef enum enumTimeUnit { MINUTES, SECONDS } TimeUnit; 00013 00014 typedef struct structFloatingDataPoint { float X; float Y; } FloatingDataPoint; 00015 00016 /* 00017 A class to implement an array of graph coordinate values, for use with an easyGUI graph 00018 (and with the GuiLibGraph class below, each instance of which encapsulates an easyGUI graph). 00019 Note that, while an easyGUI graph requires its coordinates to be integers, 00020 we use floating point values in this class, for accuracy (the GC stores time values in 'units' 00021 of 0.1 minute). We convert these values to integers only when we pass them to an actual graph. 00022 */ 00023 class GuiLibGraphDataSet 00024 { 00025 public: 00026 GuiLibGraphDataSet(); 00027 ~GuiLibGraphDataSet(); 00028 00029 void ClearData(void); 00030 00031 bool AddDataPoint(float X, float Y); 00032 bool GetDataPoint(int dataPointIndex, float *X, float *Y); 00033 00034 GuiLib_GraphDataPoint* GetGraphDataPointCopy(TimeUnit timeUnit, GuiConst_INT16U *countOfCopiedPoints); 00035 GuiLib_GraphDataPoint* GetGraphDataPointCopyInTenthsOfMinutes(float yAxisScaleFactor, GuiConst_INT16U *countOfCopiedPoints); 00036 GuiConst_INT16U GetDataSize(void) { return graphDataSetActualLength; } 00037 00038 float GetYCoordAtXCoord(float X); 00039 00040 void MakePartialCopy(float startXCoord, float endXCoord, GuiLibGraphDataSet* copyDestination); 00041 void MakeInterpolatedPartialCopy(float startXCoord, float endXCoord, float xInterval, GuiLibGraphDataSet* copyDestination); 00042 void MakeInterpolatedPartialCopyWithFinalPoint(float startXCoord, float endXCoord, float xInterval, GuiLibGraphDataSet* copyDestination); 00043 00044 int SetupFromColumnTemperatureRampValues(USBDeviceConnected* usbDevice, USBHostGC* usbHostGC); 00045 int SetupFromPressureRampValues(USBDeviceConnected* usbDevice, USBHostGC* usbHostGC, GuiLibGraphDataSet* columnMethodDataSet); 00046 int SetupInjectorTemperatureProfileToMatchColumnMethod(USBDeviceConnected* usbDevice, USBHostGC* usbHostGC, GuiLibGraphDataSet* columnMethodDataSet); 00047 int SetupFromPTVTemperatureRampValues(USBDeviceConnected* usbDevice, USBHostGC* usbHostGC); 00048 int SetupGasPressureProfileWithTimingsFromColumnMethod(USBDeviceConnected* usbDevice, USBHostGC* usbHostGC, GuiLibGraphDataSet* columnMethodDataSet); 00049 00050 float GetTotalMethodTime(void); 00051 int GetPointCount(void) { return graphDataSetActualLength; } 00052 float GetNonRoundedTotalMethodTime(void) { return nonRoundedTotalMethodTime; } 00053 00054 void GetXAxisRange(GuiConst_INT32S *xMin, GuiConst_INT32S *xMax, TimeUnit timeUnit); 00055 void GetXAxisRangeInTenthsOfMinutes(GuiConst_INT32S *xMin, GuiConst_INT32S *xMax); 00056 void GetYAxisRange(GuiConst_INT32S *yMin, GuiConst_INT32S *yMax); 00057 00058 void GetXAxisRange(GuiConst_INT32S *xMin, GuiConst_INT32S *xMax, GuiConst_INT32S tickSize, TimeUnit timeUnit); 00059 void GetXAxisRangeInTenthsOfMinutes(GuiConst_INT32S *xMin, GuiConst_INT32S *xMax, GuiConst_INT32S tickSize); 00060 void GetYAxisRange(GuiConst_INT32S *yMin, GuiConst_INT32S *yMax, GuiConst_INT32S tickSize); 00061 00062 void DrawUsingGuiLibVLine(GuiConst_INT16S xLeft, GuiConst_INT16S yBottom, double xScaleFactor, double yScaleFactor, GuiConst_INTCOLOR firstColour, GuiConst_INTCOLOR secondColour, double xColourBoundary); 00063 void DrawUsingGuiLibVLine(void); // Use the values previously passed to the version with parameters 00064 00065 static void ConvertFloatingDataPointToGuiLibGraphDataPoint(GuiLib_GraphDataPoint* graphDataPoint, FloatingDataPoint floatingDataPoint, TimeUnit timeUnit); 00066 00067 private: 00068 enum SizeIncrement { SIZE_INCREMENT = 10 }; // i.e. we allocate enough memory for this number of points each time we extend the array 00069 00070 FloatingDataPoint* theGraphDataSet; // pointer to the actual data 00071 00072 int graphDataSetActualLength; // The number of points to which we have actually assigned values 00073 int graphDataSetSizeInIncrements; // The number of points allowed for in the memory allocated to the array, as a count of SIZE_INCREMENT 'quanta' - 00074 // i.e. the actual number of points currently available is (graphDataSetSizeInIncrements * SIZE_INCREMENT). 00075 // This *must* always be >= graphDataSetActualLength 00076 00077 float nonRoundedTotalMethodTime; // The value returned by 'GetTotalMethodTime' is affected by the fact that X coordinates (i.e. time values) 00078 // are rounded to integer values (usually in minutes), because easyGUI graphs use integer coordinate values. 00079 // This variable contains the non-rounded, accurate, total method time (effectively in units of 0.1 minute, 00080 // as used by the GC itself). 00081 // *** This variable will be set only if the 'SetupFromColumnTemperatureRampValues', 'SetupFromPressureRampValues' *** 00082 // *** 'SetupGasPressureProfileWithTimingsFromColumnMethod', 'SetupInjectorTemperatureProfileToMatchColumnMethod' *** 00083 // *** or 'SetupFromPTVTemperatureRampValues' methods have been called on this dataset. Otherwise it will be zero. *** 00084 00085 bool ExtendDataSetArray(void); 00086 00087 float GetComponentTemperature(char *cmd, USBDeviceConnected* usbDevice, USBHostGC* usbHostGC); 00088 float GetColumnTemperature(USBDeviceConnected* usbDevice, USBHostGC* usbHostGC); 00089 float GetInjectorTemperature(USBDeviceConnected* usbDevice, USBHostGC* usbHostGC); 00090 00091 float GetTimeValue(char *cmd, USBDeviceConnected* usbDevice, USBHostGC* usbHostGC); 00092 float GetInitialHoldTime(USBDeviceConnected* usbDevice, USBHostGC* usbHostGC); 00093 float GetPTVInitialTime(USBDeviceConnected* usbDevice, USBHostGC* usbHostGC); 00094 00095 float GetInitialPressure(USBDeviceConnected* usbDevice, USBHostGC* usbHostGC); 00096 00097 float GetRampValue(char *cmd, int rampIndex, USBDeviceConnected* usbDevice, USBHostGC* usbHostGC); 00098 00099 float GetTemperatureRampRate(int rampIndex, USBDeviceConnected* usbDevice, USBHostGC* usbHostGC); 00100 float GetRampUpperTemperature(int rampIndex, USBDeviceConnected* usbDevice, USBHostGC* usbHostGC); 00101 00102 float GetRampUpperTime(int rampIndex, USBDeviceConnected* usbDevice, USBHostGC* usbHostGC); 00103 00104 float GetPressureRampRate(int rampIndex, USBDeviceConnected* usbDevice, USBHostGC* usbHostGC); 00105 float GetRampUpperPressure(int rampIndex, USBDeviceConnected* usbDevice, USBHostGC* usbHostGC); 00106 00107 float GetPTVTemperatureRampRate(int rampIndex, USBDeviceConnected* usbDevice, USBHostGC* usbHostGC); 00108 float GetPTVRampUpperTemperature(int rampIndex, USBDeviceConnected* usbDevice, USBHostGC* usbHostGC); 00109 00110 float GetPTVRampUpperTime(int rampIndex, USBDeviceConnected* usbDevice, USBHostGC* usbHostGC); 00111 00112 void RoundAxisRangeByTickSize(GuiConst_INT32S *axisMin, GuiConst_INT32S *axisMax, GuiConst_INT32S rawAxisMin, GuiConst_INT32S rawAxisMax, GuiConst_INT32S axisTickSize); 00113 00114 struct structDrawUsingGuiLibVLineParameters { 00115 bool isSet; 00116 GuiConst_INT16S xLeft; 00117 GuiConst_INT16S yBottom; 00118 double xScaleFactor; 00119 double yScaleFactor; 00120 GuiConst_INTCOLOR firstColour; 00121 GuiConst_INTCOLOR secondColour; 00122 double xColourBoundary; 00123 } DrawUsingGuiLibVLineParameters; 00124 00125 void DrawUsingGuiLibVLine(GuiConst_INT16S xLeft, GuiConst_INT16S yBottom, double xScaleFactor, double yScaleFactor, 00126 GuiConst_INTCOLOR firstColour, GuiConst_INTCOLOR secondColour, double xColourBoundary, bool recordParameters); 00127 }; 00128 00129 /* 00130 A class to implement an easyGUI graph, so that the caller does not need to know (for example) 00131 which easyGUI 'GuiLib_Graph_xxx' functions to call, or how to use them. These functions 00132 will be called only from inside this class. 00133 00134 This should keep the caller's code simpler and easier to understand - all the complications 00135 will be 'encapsulated' in this class. 00136 00137 The graph index must be defined when an object of this class is instantiated. 00138 This must correspond with its index number in easyGUI. 00139 ***************************************************** 00140 */ 00141 class GuiLibGraph 00142 { 00143 public: 00144 GuiLibGraph(GuiConst_INT8U graphIndex); 00145 ~GuiLibGraph(); 00146 00147 GuiConst_INT8U DrawAxes(void); 00148 GuiConst_INT8U DrawDataSet(GuiConst_INT8U dataSetIndex); 00149 GuiConst_INT8U DrawDataPoint(GuiConst_INT8U dataSetIndex, GuiConst_INT16U dataPointIndex); 00150 GuiConst_INT8U HideDataSet(GuiConst_INT8U dataSetIndex); 00151 GuiConst_INT8U ShowDataSet(GuiConst_INT8U dataSetIndex); 00152 00153 void DrawXAxisLabels(GuiConst_INT32S minValue, GuiConst_INT32S maxValue, GuiConst_INT32S tickSize, 00154 GuiConst_INT16S graphX, GuiConst_INT16S graphY, GuiConst_INT16S graphW); 00155 void DrawXAxisLabels(void); // Use the values previously passed to the version with parameters 00156 00157 void DrawYAxisLabels(GuiConst_INT32S minValue, GuiConst_INT32S maxValue, GuiConst_INT32S tickSize, 00158 GuiConst_INT16S graphX, GuiConst_INT16S graphY, GuiConst_INT16S graphH); 00159 void DrawYAxisLabels(void); // Use the values previously passed to the version with parameters 00160 00161 GuiConst_INT8U SetXAxisRange(GuiConst_INT32S minValue, GuiConst_INT32S maxValue); 00162 GuiConst_INT8U SetYAxisRange(GuiConst_INT32S minValue, GuiConst_INT32S maxValue); 00163 00164 GuiConst_INT8U SetDataForGraphDataSet(GuiConst_INT8U dataSetIndex, GuiLibGraphDataSet* dataSet, TimeUnit timeUnit); 00165 GuiConst_INT8U SetDataForGraphDataSetInTenthsOfMinutes(GuiConst_INT8U dataSetIndex, float yAxisScaleFactor, GuiLibGraphDataSet* dataSet); 00166 GuiConst_INT8U SetSinglePointForGraphDataSet(GuiConst_INT8U dataSetIndex, GuiConst_INT32S X, GuiConst_INT32S Y); 00167 00168 GuiConst_INT8U Redraw(void); 00169 00170 void SetXAxisUnits(TimeUnit newXAxisUnits); 00171 TimeUnit GetXAxisUnits(void); 00172 00173 private: 00174 GuiConst_INT8U GuiLib_GraphIndex; 00175 00176 TimeUnit xAxisUnits; 00177 00178 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 00179 enum { YAXIS_INDEX = 0 }; // For completeness - we currently do not intend to have multiple Y axes 00180 00181 // We keep a pointer to the dataset data for each dataset index, up to 10. 00182 // This is the data added to the easyGUI graph object at that index. 00183 // Currently, we do not allow indices outside the range 0-9 - we just ignore them 00184 enum { DATASET_INDEX_COUNT = 10 }; 00185 GuiLib_GraphDataPoint *dataSetDataPtr[DATASET_INDEX_COUNT]; 00186 00187 struct structXAxisLabelData { 00188 bool isSet; 00189 GuiConst_INT32S minValue; 00190 GuiConst_INT32S maxValue; 00191 GuiConst_INT32S tickSize; 00192 GuiConst_INT16S graphX; 00193 GuiConst_INT16S graphY; 00194 GuiConst_INT16S graphW; 00195 } xAxisLabelData; 00196 00197 struct structYAxisLabelData { 00198 bool isSet; 00199 GuiConst_INT32S minValue; 00200 GuiConst_INT32S maxValue; 00201 GuiConst_INT32S tickSize; 00202 GuiConst_INT16S graphX; 00203 GuiConst_INT16S graphY; 00204 GuiConst_INT16S graphH; 00205 } yAxisLabelData; 00206 00207 void DrawXAxisLabels(GuiConst_INT32S minValue, GuiConst_INT32S maxValue, GuiConst_INT32S tickSize, 00208 GuiConst_INT16S graphX, GuiConst_INT16S graphY, GuiConst_INT16S graphW, bool recordParameters); 00209 00210 void DrawYAxisLabels(GuiConst_INT32S minValue, GuiConst_INT32S maxValue, GuiConst_INT32S tickSize, 00211 GuiConst_INT16S graphX, GuiConst_INT16S graphY, GuiConst_INT16S graphH, bool recordParameters); 00212 }; 00213 00214 #endif // GUILIBGRAPH_H
Generated on Tue Jul 19 2022 00:31:07 by
1.7.2