00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #ifndef LIST_H
00029 #define LIST_H
00030
00031 #include "packet.h"
00032
00033 #include <iostream.h>
00034 #include <assert.h>
00035 #include <string.h>
00036 #include <stdio.h>
00037 #include <string.h>
00038 #include <stdlib.h>
00039
00040
00041 #include <string>
00042
00043 #include <qstring.h>
00044 #include <qlist.h>
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054 class PlotProps {
00055 public :
00056 friend class Plot;
00057 PlotProps (char *dev = "no_name",char *var="no_name",
00058 int in =0,int prio=0,bool p=FALSE,bool s=FALSE) {
00059 dev_name = new char[strlen(dev)+1];
00060 assert( dev_name != 0);
00061 strcpy(dev_name,dev);
00062 var_name = new char[strlen(var)+1];
00063 assert( var_name !=0);
00064 strcpy(var_name,var);
00065 priority = prio;
00066 indx = in;
00067 plotflag = p;
00068 storeflag = s;
00069 InitPlotOptions();
00070 marker = FALSE;
00071 }
00072 ~PlotProps() {
00073 if (dev_name)
00074 delete dev_name;
00075 if (var_name)
00076 delete var_name;
00077 }
00078
00079
00080
00081 int indx;
00082
00083
00084
00085 int priority;
00086 char * dev_name;
00087 char * var_name;
00088 bool plotflag;
00089 bool storeflag;
00090 PlotSettings Ps;
00091 bool marker;
00092 private:
00093
00094 void InitPlotOptions(void) {
00095 Ps.pminx = P_MIN_SIZE_X;
00096 Ps.pminy = P_MIN_SIZE_Y;
00097 Ps.pleftborder = P_LEFT_BORDER;
00098 Ps.pupperborder = P_UPPER_BORDER;
00099 Ps.pdefsizex = P_DEF_SIZE_X;
00100 Ps.pdefsizey = P_DEF_SIZE_Y;
00101 Ps.xticks = X_TICKS;
00102 Ps.yticks = Y_TICKS;
00103 Ps.ticksize = TICKSIZE;
00104 Ps.tickpos = TICKPOS;
00105 Ps.tickposx = TICKPOS_X;
00106 Ps.as_interval = AS_INTERVAL;
00107 Ps.yupper = Y_UPPER_LIMIT;
00108 Ps.ylower = Y_LOWER_LIMIT;
00109 Ps.autoscale = AUTOSCALE;
00110 Ps.hgridlines = HGRIDLINES;
00111 Ps.vgridlines = VGRIDLINES;
00112 }
00113 };
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127 class Element {
00128 friend class List;
00129 public:
00130
00131 private:
00132
00133 Element(int W, const char *device, const char *var,int flag,int data_type,
00134 int x=0,int y=0, Element *E = 0) {
00135 i_var = W;
00136 next = E;
00137 enabled = flag;
00138 plotflag = y;
00139 type = data_type;
00140 storeflag = x;
00141 device_name = device;
00142 var_name = var;
00143
00144
00145
00146
00147
00148
00149 }
00150
00151 Element(double W, const char *device,const char *var,int flag, int data_type,
00152 int x=0,int y=0, Element *E = 0) {
00153 d_var = W;
00154 next = E;
00155 enabled = flag;
00156 plotflag = y;
00157 type = data_type;
00158 storeflag = x;
00159 device_name = device;
00160 var_name = var;
00161
00162
00163
00164
00165
00166
00167
00168
00169 }
00170 ~Element() {
00171 device_name.~string();
00172 var_name.~string();
00173
00174
00175
00176
00177 }
00178 string device_name;
00179 string var_name;
00180 int enabled;
00181
00182
00183 int i_var;
00184 double d_var;
00185 char c_var;
00186 char *s_var;
00187 Element *next;
00188 int type;
00189 int storeflag;
00190 int plotflag;
00191 };
00192
00193
00194
00195 class List
00196 {
00197 public:
00198 List()
00199 {
00200 L=0; Buffer_pointer=L;
00201 PlotPropList = new QList<PlotProps>;
00202 PlotPropList -> setAutoDelete(TRUE);
00203 assert(PlotPropList !=0);
00204 ParameterStr = new char[10000];
00205 assert(ParameterStr !=0);
00206 }
00207 ~List() {
00208 remove();
00209 delete PlotPropList;
00210 }
00211 void initialize();
00212 void insert (int , char *,char *,int,int );
00213 void insert (double, char *,char *,int,int );
00214 void append (int, char *,char *,int,int,int,int );
00215 void append (double ,char *,char *,int,int,int,int );
00216 Element * exist(char *,char *);
00217 void SortPlotProperties(void);
00218 void remove ();
00219 int is_active(char *);
00220
00221 int remove (int );
00222 int remove (double );
00223 int getvar (int * ,char *,char *);
00224 int getvar (double *,char *,char *);
00225 int putvar (int ,char *,char *);
00226 int putvar (double ,char *,char *);
00227 int varcomp(Element *,char *,char *);
00228 void putvar(int, int);
00229 void putvar(double, int);
00230 void putvar( char *,int);
00231 int enabled(char *,char *);
00232 int plotstatus(int );
00233 int getint (int );
00234 double getdouble(int );
00235 char getchr (int );
00236 char* getstr (int );
00237 char* get_data_type(char *);
00238
00239
00240
00241
00242
00243 devDataPacket * GetPacketElement(char *);
00244 devDataPacket * GetNextPacket(void );
00245 void ResetHelpPointer(void);
00246 int AdvanceHelpPointer(void);
00247
00248 char* getAllDeviceParameters(char * );
00249 void reset_data_buffer();
00250 void printlist();
00251 int initlist(char *);
00252 int initPlotOptions(FILE *fp,PlotProps *);
00253 Element* End_Of_List();
00254 char * getstring(int);
00255 int get_type(int );
00256 char * get_name(int );
00257 char * get_var_name(int );
00258 int get_store_flag(int );
00259 int get_plot_flag(int);
00260 int get_enabled_flag(int);
00261 void set_enabled_flag(int,bool);
00262 void set_plot_flag(int,bool);
00263 int get_number_plotvars(char *);
00264 string get_plotvar_namelist(char *);
00265
00266 QList <PlotProps> *PlotPropList;
00267 private:
00268 char *ParameterStr;
00269 int index;
00270 int x,i,y;
00271 Element *L;
00272 Element *BufferPointer,*Buffer_pointer;
00273 };
00274
00275 #endif
00276
00277
00278