TSP: The Transport Sample Protocol



Main Page | Modules | Alphabetical List | Data Structures | File List | Data Fields | Globals | Related Pages

gdisp_plotCanevas.c

Go to the documentation of this file.
00001 
00044 /*
00045  * System includes.
00046  */
00047 #include <stdio.h>
00048 #include <stdlib.h>
00049 #include <assert.h>
00050 #include <string.h>
00051 #include <errno.h>
00052 
00053 
00054 /*
00055  * GDISP+ includes.
00056  */
00057 #include "gdisp_kernel.h"
00058 #include "gdisp_prototypes.h"
00059 
00060 #include "gdisp_<<<-canevas->>>.h"
00061 
00062 
00063 /*
00064  --------------------------------------------------------------------
00065                              STATIC ROUTINES
00066  --------------------------------------------------------------------
00067 */
00068 
00069 
00070 
00071 /*
00072  * Create a plot by providing an opaque structure to the caller.
00073  * This opaque structure will be given as an argument to all
00074  * plot function. These functions remain generic.
00075  */
00076 static void*
00077 gdisp_create<<<-canevas->>> (Kernel_T *kernel)
00078 {
00079 
00080   <<<-canevas->>>_T *plot = (<<<-canevas->>>_T*)NULL;
00081 
00082 
00083   /*
00084    * Return the opaque structure.
00085    */
00086   return (void*)plot;
00087 
00088 }
00089 
00090 
00091 /*
00092  * Destroy a plot opaque structure.
00093  */
00094 static void
00095 gdisp_destroy<<<-canevas--->(Kernel_T *kernel,
00096                              void     *data)
00097 {
00098 
00099   <<<-canevas->>>_T *plot = (<<<-canevas->>>_T*)data;
00100 
00101   /*
00102    * Now destroy everything.
00103    */
00104 
00105 
00106   /*
00107    * Free opaque structure.
00108    */
00109   memset(plot,0,sizeof(<<<-canevas->>>_T));
00110   g_free(plot);
00111 
00112 }
00113 
00114 
00115 /*
00116  * Record parent widget.
00117  */
00118 static void
00119 gdisp_set<<<-canevas->>>ParentWidget (Kernel_T  *kernel,
00120                                       void      *data,
00121                                       GtkWidget *parent)
00122 {
00123 
00124   <<<-canevas->>>_T *plot = (<<<-canevas->>>_T*)data;
00125 
00126   /*
00127    * Store parent widget.
00128    */
00129 
00130 }
00131 
00132 
00133 /*
00134  * Record initial dimensions provided by the calling process.
00135  */
00136 static void
00137 gdisp_set<<<-canevas->>>InitialDimensions (Kernel_T *kernel,
00138                                            void     *data,
00139                                            guint     width,
00140                                            guint     height)
00141 {
00142 
00143   <<<-canevas->>>_T *plot = (<<<-canevas->>>_T*)data;
00144 
00145   /*
00146    * Remeber here initial dimensions of the viewport.
00147    */
00148 
00149 }
00150 
00151 
00152 /*
00153  * Give back to the calling process the top level widget
00154  * in order to be inserted in a possible container for further
00155  * dynamic X management.
00156  */
00157 static GtkWidget*
00158 gdisp_get<<<-canevas->>>TopLevelWidget (Kernel_T  *kernel,
00159                                         void      *data)
00160 {
00161 
00162   <<<-canevas->>>_T *plot = (<<<-canevas->>>_T*)data;
00163 
00164   return (GtkWidget*)<<<-topLevelWidget->>>;
00165 
00166 }
00167 
00168 
00169 /*
00170  * By now, the plot widgets are created, but not shown yet.
00171  * Show them here.
00172  */
00173 static void
00174 gdisp_show<<<-canevas->>> (Kernel_T  *kernel,
00175                            void      *data)
00176 {
00177 
00178   <<<-canevas->>>_T *plot = (<<<-canevas->>>_T*)data;
00179 
00180   /*
00181    * Now show everything.
00182    */
00183 
00184 }
00185 
00186 
00187 /*
00188  * Return to calling process what king of plot we are.
00189  */
00190 static PlotType_T
00191 gdisp_get<<<-canevas->>>Type (Kernel_T *kernel,
00192                               void     *data)
00193 {
00194 
00195   <<<-canevas->>>_T *plot = (<<<-canevas->>>_T*)data;
00196 
00197   /*
00198    * Return the type of the plot.
00199    */
00200   return <<<-canevas-type->>>;
00201 
00202 }
00203 
00204 
00205 /*
00206  * Record any incoming symbols.
00207  */
00208 static void
00209 gdisp_addSymbolsTo<<<-canevas->>> (Kernel_T *kernel,
00210                                    void     *data,
00211                                    GList    *symbolList,
00212                                    guchar    zoneId)
00213 {
00214 
00215   <<<-canevas->>>_T *plot = (<<<-canevas->>>_T*)data;
00216 
00217   /*
00218    * Record here all incoming symbols.
00219    */
00220 
00221 }
00222 
00223 
00224 /*
00225  * Broadcast all recorded symbols.
00226  */
00227 static GList*
00228 gdisp_getSymbolsFrom<<<-canevas->>> (Kernel_T *kernel,
00229                                      void     *data,
00230                                      gchar     axis)
00231 {
00232 
00233   <<<-canevas->>>_T *plot = (<<<-canevas->>>_T*)data;
00234 
00235   /*
00236    * Return the list of symbols.
00237    */
00238 
00239 }
00240 
00241 
00242 /*
00243  * Real time Starting Step Action.
00244  */
00245 static gboolean
00246 gdisp_startStepOn<<<-canecas->>> (Kernel_T *kernel,
00247                                   void     *data)
00248 {
00249 
00250   /*
00251    * Do anything you want before starting steps.
00252    *
00253    * BUT we must return TRUE to the calling procedure in order to allow
00254    * the general step management to proceed.
00255    *
00256    * Returning FALSE means that our plot is not enabled to perform its
00257    * step operations, because of this or that...
00258    */
00259   return TRUE;
00260 
00261 }
00262 
00263 
00264 /*
00265  * Real time Step Action.
00266  */
00267 static void
00268 gdisp_stepOn<<<-canevas->>> (Kernel_T *kernel,
00269                              void     *data)
00270 {
00271 
00272   <<<-canevas->>>_T *plot = (<<<-canevas->>>_T*)data;
00273 
00274   /*
00275    * Do anything you want to perform steps.
00276    */
00277 }
00278 
00279 
00280 /*
00281  * Real time Starting Step Action.
00282  */
00283 static void
00284 gdisp_stopStepOn<<<-canevas->>> (Kernel_T *kernel,
00285                                  void     *data)
00286 {
00287 
00288   <<<-canevas->>>_T *plot = (<<<-canevas->>>_T*)data;
00289 
00290   /*
00291    * Do anything you want when steps are stopped.
00292    */
00293 
00294 }
00295 
00296 
00297 /*
00298  * Get back to the calling procedure my information.
00299  */
00300 static void
00301 gdisp_get<<<-canevas->>>Information (Kernel_T         *kernel,
00302                                      PlotSystemInfo_T *information)
00303 {
00304 
00305   /*
00306    *   - Name,
00307    *   - Formula,
00308    *   - Descripton for tooltip purpose.
00309    */
00310   information->psName        = "Give me a name";
00311   information->psFormula     = "Y = F ( X )";
00312   information->psDescription = "A typical skeleton for plots";
00313 
00314 }
00315 
00316 
00317 /*
00318  * Get back to the calling procedure my period, expressed in milliseconds.
00319  * CAUTION : The period must be an exact multiple of 10.
00320  *           Should not be lower than 100.
00321  */
00322 static guint
00323 gdisp_get<<<-canevas->>>Period (Kernel_T         *kernel,
00324                                 void             *data)
00325 {
00326 
00327   /*
00328    * My period is 1000 milli-seconds.
00329    */
00330   return 1000;
00331 
00332 }
00333 
00334 
00335 /*
00336  * This procedure is called whenever all symbols have been time-tagged
00337  * by the corresponding provider sampling thread.
00338  * The last value of all symbols can now be retreived by the graphic plot.
00339  *
00340  * CAUTION : This procedure is called in another thread, compared to all
00341  * other procedures of the graphic plot that are called by GTK main thread.
00342  */
00343 static void
00344 gdisp_treat<<<-canevas->>>SymbolValues (Kernel_T *kernel,
00345                                         void     *data)
00346 {
00347 
00348   /*
00349    * Take into account all last values.
00350    */
00351 
00352 }
00353 
00354 
00355 /*
00356  * Get back the zones that have been defined on that plot.
00357  */
00358 static GArray*
00359 gdisp_get<<<-canevas->>>DropZones (Kernel_T *kernel)
00360 {
00361 
00362   /*
00363    * No zones on that plot.
00364    */
00365   return (GArray*)NULL;
00366 
00367 }
00368 
00369 
00370 /*
00371  --------------------------------------------------------------------
00372                              PUBLIC ROUTINES
00373  --------------------------------------------------------------------
00374 */
00375 
00376 
00377 void
00378 gdisp_init<<<-canevas->>>System (Kernel_T     *kernel,
00379                                  PlotSystem_T *plotSystem)
00380 {
00381 
00382   /*
00383    * We must here provide all plot private functions that remain
00384    * 'static' here, but accessible from everywhere via the kernel.
00385    */
00386   plotSystem->psCreate            = gdisp_create<<<-canevas->>>;
00387   plotSystem->psDestroy           = gdisp_destroy<<<-canevas->>>;
00388   plotSystem->psSetParent         = gdisp_set<<<-canevas->>>Parent;
00389   plotSystem->psGetTopLevelWidget = gdisp_get<<<-canevas->>>TopLevelWidget;
00390   plotSystem->psSetDimensions     = gdisp_set<<<-canevas->>>InitialDimensions;
00391   plotSystem->psShow              = gdisp_show<<<-canevas->>>;
00392   plotSystem->psGetType           = gdisp_get<<<-canevas->>>Type;
00393   plotSystem->psAddSymbols        = gdisp_addSymbolsTo<<<-canevas->>>;
00394   plotSystem->psGetSymbols        = gdisp_getSymbolsFrom<<<-canevas->>>;
00395   plotSystem->psStartStep         = gdisp_startStepOn<<<-canevas->>>;
00396   plotSystem->psStep              = gdisp_stepOn<<<-canevas->>>;
00397   plotSystem->psStopStep          = gdisp_stopStepOn<<<-canevas->>>;
00398   plotSystem->psGetInformation    = gdisp_get<<<-canevas->>>Information;
00399   plotSystem->psTreatSymbolValues = gdisp_treat<<<-canevas->>>SymbolValues;
00400   plotSystem->psGetPeriod         = gdisp_get<<<-canevas->>>Period;
00401   plotSystem->psGetDropZones      = gdisp_get<<<-canevas->>>DropZones;
00402 
00403 }
00404 
Framework Home Page.

Beware !! TSP wave is coming...