Main Page   Class Hierarchy   Compound List   File List   Compound Members   File Members  

list_client.h

Go to the documentation of this file.
00001 /*
00002  * MAX : list_client.h, Sam Dez 29 19:49:59 CET 2001 -sg
00003  *
00004  * This file is part of Max data acquisition software
00005  * Copyright (C) 1998 Christian Rosen
00006  *
00007  * Max is free software; you can redistribute it and/or modify it
00008  * under the terms of the version 2 of GNU General Public License as
00009  * published by the Free Software Foundation.
00010  *
00011  * Max is distributed in the hope that it will be useful, but WITHOUT
00012  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00013  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00014  * for more details.
00015  *
00016  * You should have received a copy of the GNU General Public License
00017  * (see the file COPYING) in this directory; if not, write to the
00018  * Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00019  */
00020 
00021 //list header file contains class declaration for list class
00022 //the list class stores the device parameters which can be seen and edited
00023 //in the listbox
00024 //it also provides all functions to access it
00025 
00026 #ifndef LIST_CLIENT_H
00027 #define LIST_CLIENT_H
00028 
00029 #include "packet.h"
00030 
00031 #include <iostream.h>
00032 #include <assert.h>
00033 #include <string.h>
00034 #include <stdio.h>
00035 #include <string.h>
00036 #include <stdlib.h>
00037 
00038 //STL includes
00039 #include <string>
00040 
00041 #include <qstring.h>
00042 #include <qlist.h>
00043 /*
00044  *Plot Properties list element class PlotProps :
00045  *Max stores the properties of all plot statements in an additional list
00046  *to initialize the plotwindows with it
00047  *determine the properties of the plotwindows for all variables
00048  *to be plotted, if data is not given, set default values from
00049  *definitions.h
00050  *
00051  *set all options to default values from the file definitions.h
00052  *these are all plot properties the user can set in the initfile
00053  *the new plotwindows are then initialized with this data
00054  *see also definitions.h and plot.h
00055  */
00056 class PlotProps {
00057 public :
00058   friend class Plot;
00059   PlotProps (char *dev = "no_name",char *var="no_name",
00060              int in =0,int prio=0,bool p=FALSE,bool s=FALSE) {
00061     dev_name = dev;
00062     var_name = var;
00063     priority  = prio;
00064     indx      = in;       //number of var with plotlag == TRUE in list
00065     plotflag  = p;        //if plotflag is == FALSE -> discard the data and don't plot it
00066     storeflag = s;        //if storeflag == FALSE then  index = -1
00067     InitPlotOptions();
00068     marker = FALSE;
00069   }
00070   ~PlotProps() {                //default destruktor
00071     dev_name.~string();
00072     var_name.~string();
00073   }
00074   int    indx;         //this index is equal to the variable index received from polling deamon
00075   int priority;
00076   string dev_name;
00077   string var_name;
00078   bool   plotflag;   //really plot it or discard queued potdata ?
00079   bool   storeflag;  //is it present in the database of measured data?
00080   PlotSettings Ps;   //this structure holds all Plotoptions -> see : packet.h
00081   bool   marker;     //used for finding the right plotwindow
00082 private:             //these are priority of this device
00083   void InitPlotOptions(void) {
00084     Ps.pminx        = P_MIN_SIZE_X;
00085     Ps.pminy        = P_MIN_SIZE_Y;
00086     Ps.pleftborder  = P_LEFT_BORDER;
00087     Ps.pupperborder = P_UPPER_BORDER;
00088     Ps.pdefsizex    = P_DEF_SIZE_X;
00089     Ps.pdefsizey    = P_DEF_SIZE_Y;
00090     Ps.xticks       = X_TICKS;
00091     Ps.yticks       = Y_TICKS;
00092     Ps.ticksize     = TICKSIZE;
00093     Ps.tickpos      = TICKPOS;
00094     Ps.tickposx     = TICKPOS_X;
00095     Ps.as_interval  = AS_INTERVAL;
00096     Ps.yupper       = Y_UPPER_LIMIT;
00097     Ps.ylower       = Y_LOWER_LIMIT;
00098     Ps.autoscale    = AUTOSCALE;
00099     Ps.hgridlines   = HGRIDLINES;
00100     Ps.vgridlines   = VGRIDLINES;
00101   }
00102 };
00103 
00104 
00105 //the data_type flag contains the variable type of the save variable
00106 // -> see : Cl_List::get_data_type(char *)
00107 //this is neccessary to determine the type for saving the data
00108 //(overloading doesn't work here) -> But, I don't need this routine anymore
00109 //Scheduler::store(var) now sets up an array during first measurement cycle to store data types
00110 //look there to figure that out
00111 //IMPROVEMENT :
00112 //BUT ADD TEMPLATE LIST CLASS TO REMOVE SWITCH STATEMENTS IN GETSTRING AND
00113 // GETALLDEVICEPARAMETERS functions
00114 //
00115 //the following class contains one element of the linked list of device parameters
00116 class Element {
00117  friend class Cl_List;
00118 public:
00119 
00120 private:
00121 //private Konstructor for int var
00122   Element(int W, const char *device, const char *var,int flag,int data_type,
00123         int x=0,int y=0, Element *E = 0) {
00124     i_var       = W;
00125     next        = E;
00126     enabled   = flag; //this is the enabled flag !!!! TRUE -> device stores the data
00127     plotflag    = y;   //TRUE is var is plotted
00128     type        = data_type;
00129     storeflag   = x;   //TRUE if variable is a store variable
00130     device_name = device;
00131     var_name    = var;
00132   }
00133 //private Konstructor for double var
00134  Element(double W, const char *device,const char *var,int flag, int data_type,
00135         int x=0,int y=0, Element *E = 0) {
00136     d_var       = W;
00137     next        = E;
00138     enabled     = flag; //this is the enabled flag
00139     plotflag    = y;    //plot ot ?
00140     type        = data_type;
00141     storeflag   = x;  //indicates that thiselemet is a "store" variable
00142     device_name = device;
00143     var_name    = var;
00144  }      
00145   ~Element() {
00146     device_name.~string();
00147     var_name.~string();
00148   }
00149   string   device_name;
00150   string   var_name;     //data ist a reserved word for a variable name
00151   int      enabled;    //if that is nonzero the according variable
00152   //is saved to disk and can be plotted
00153   //1 = int,2 = double, 3 =char, 4 = string
00154   int      i_var;
00155   double   d_var;
00156   char     c_var;
00157   char *s_var;
00158   Element  *next;
00159   int       type;      //type flag 1 = int,2 = double, 3 = char, 4 = string
00160   int       storeflag; //TRUE is var is a store variable
00161   int       plotflag;  //TRUE is variable is to be plotted
00162 };
00163 //
00164 //This class represents the list of device data together with the functions to
00165 //access it
00166 class Cl_List
00167 {
00168 public:
00169   Cl_List()
00170   {
00171     L=0; Buffer_pointer=L;
00172     PlotPropList = new QList<PlotProps>;
00173     PlotPropList -> setAutoDelete(TRUE);
00174     assert(PlotPropList !=0);
00175     //   ParameterStr = new char[10000];
00176     //assert(ParameterStr !=0);
00177   }
00178   ~Cl_List() {
00179     remove();
00180     delete PlotPropList;
00181   }
00182   void initialize();
00183   void insert  (int   , char *,char *,int,int ); //insert new data-element
00184   void insert  (double, char *,char *,int,int ); //dito but with double
00185   void append  (int,    char *,char *,int,int,int,int ); //append new data-element (at the end)
00186   void append  (double ,char *,char *,int,int,int,int ); //dito but with double-variable
00187   Element * exist(char *,char *);                //check for deviceName && varName in the list
00188   void SortPlotProperties(void);          //add the actual priorites to the plot properties list
00189   void remove  ();                        //removes complete list from memory
00190   int is_active(char *);                  //returns 1 is char* device_name is an active device,
00191                                           //otherwise -1
00192   int    remove (int );                   //removes specific element from list
00193   int    remove (double );
00194   int    getvar (int *   ,char *,char *); //first  device then var-name
00195   int    getvar (double *,char *,char *); //same for double vars
00196   int    putvar (int     ,char *,char *); //set variable value (int)
00197   int    putvar (double  ,char *,char *); //set variable value (double)
00198   int    varcomp(Element *,char *,char *);
00199   void   putvar(int, int);                //set new variable for element at position i
00200   void   putvar(double, int);
00201   void   putvar( char *,int);
00202   int    enabled(char *,char *);          //return TRUE if this var is enabled
00203   int    plotstatus(int );                //return plotstaus(nostorevar,enabled,plot)
00204   int    getint   (int );                 //return variable of element at position index
00205   double getdouble(int );
00206   char   getchr   (int );
00207   char*  getstr   (int );
00208   char*  get_data_type(char *);           /* returns a string with a list of the
00209          *saved data type of device char
00210          *f.e. : the variables string,double,int
00211          *would return : sdi   *
00212          * needed for the save-routine*/
00213   /*network related functions only in ver 2.0 !!!*/
00214   devDataPacket * GetPacketElement(char *); //return struct packet for socket transfer
00215   devDataPacket * GetNextPacket(void );   //return data element pointed to by BufferPointer
00216   void   ResetHelpPointer(void);         //reset help list pointer to beginning of list
00217   int    AdvanceHelpPointer(void);       //go to next element
00218   /* end */
00219   string  getAllDeviceParameters(char * ); //returns string containing all data of dev. QString name
00220   void   reset_data_buffer();             //which is needed for parameter file save routine
00221   void   printlist();
00222   int    initlist(char *);                //setup database from initfile, return -1 on error
00223   int    initPlotOptions(FILE *fp,PlotProps *); //returns enabled flag
00224   Element* End_Of_List();
00225   char *  getstring(int);                  //returns string with dev-name par-name value
00226   int    get_type(int );                  //returns type of ith element         
00227   int    length();                        //Number of scalarelements in the list
00228   int    array_length();                  //Number of array elements in the list
00229   char * get_name(int );                  //return name of device at position i
00230   const char * get_var_name(int );              //return var name of device at position i
00231   int    get_store_flag(int );            //return the storeflag out of parameter database
00232   int    get_plot_flag(int);      //check if variable specified by position contains plotdata (ysize)
00233   int    get_enabled_flag(int);
00234   void   set_enabled_flag(int,bool);        //toggle the flags according to user input
00235   void   set_plot_flag(int,bool);         //"switch" on/off a variable
00236   int    get_number_plotvars(char *);     //return number of variables to be plotted
00237   string get_plotvar_namelist(char *);   //defined by "data" statement in initfile
00238                                           //or zero if list is empty or at the end
00239   QList <PlotProps> *PlotPropList;
00240 private:
00241   string ParameterStr;
00242   int index;    //index for plotvariable
00243   int x,i,y;
00244   Element *L;
00245   Element *BufferPointer,*Buffer_pointer;
00246 };
00247 
00248 #endif
00249 
00250 //Don't write behind the endif line !!
00251 

Generated at Mon Sep 2 18:21:03 2002 for MAX by doxygen1.2.8.1 written by Dimitri van Heesch, © 1997-2001