6 #include "dictionaries.h"
9 #include <Windows4Root.h>
13 #include <TGTextView.h>
14 #include <TGTextEntry.h>
15 #include <TGTextBuffer.h>
32 virtual bool setParameter(std::string parName, std::string sval);
45 TGTransientFrame * tf;
46 TGTextView * transcript;
47 TGHorizontalFrame * textOutputFrame;
48 TGHorizontalFrame * cmdLineFrame;
49 TGTextEntry * commandLine;
50 std::vector<std::string> cmdHistory;
51 unsigned int historyIndex;
77 vector< pair<int,int> > ranges;
80 enum special{IMIN=-1, IMAX=-2, UNDEFINED=-3, IVAR=-4};
81 IntList():singleValue(UNDEFINED){ranges.clear();}
82 bool parse(
Token & ,
const bool append=
false );
84 int value(){
return singleValue;}
85 bool isSingleValue(){
return (!(singleValue==UNDEFINED));}
86 bool isVariable(){
return ( (singleValue==IVAR));}
87 vector<int> getVect(
const int imin=0,
const int imax=0);
94 enum argtype {UNDEF,STRING_T, IVALUE_T, IVAR_T, ILIST_T};
95 Arg(
string s):type(STRING_T),svalue(s){};
97 if( v.isSingleValue() ){
110 bool getInt(
int & value){
111 if (type==IVALUE_T){value=ivalue;
return true;}
112 if (type==IVAR_T){value=varvalue;
return true;}
116 bool getList(
IntList & value){
if(type==ILIST_T){ value=lvalue;
return true;}
return false;}
117 bool getVect(vector<int> & value,
const int imin=0,
const int imax=0){
119 value=lvalue.getVect(imin, imax);
121 }
else if(type==IVALUE_T){
122 value.push_back( ivalue);
124 }
else if(type==IVAR_T){
125 value.push_back( varvalue );
131 bool getString(
string & value){
if(type==STRING_T){ value=svalue;
return true;}
return false;}
132 bool scmp(
const char *s){
return (type==STRING_T)&&( strcmp(s, svalue.c_str())==0 );}
141 if (type==IVALUE_T){ s << ivalue;}
142 else if (type==IVAR_T){ s << varvalue;}
143 else if (type==ILIST_T) { s <<
"vector("<<
")";}
144 else if (type==STRING_T){ s <<
"'" << svalue <<
"'";}
151 if (type==IVALUE_T){ s << ivalue;}
152 else if (type==IVAR_T){ s << varvalue;}
153 else if (type==STRING_T){ s << svalue;}
162 bool kw(
const char* s){
return (strcmp(s, keyword.c_str())==0);};
166 Keyword(
string s):keyword(s){};
168 bool match(
const char * s){
return kw(s) && (narg()==0); };
169 bool match(
const char * s,
int & value,
const char * s1);
170 bool match(
const char * s1,
const char * s2);
171 bool match(
const char * s1,
const char * s2,
string &);
172 bool match(
const char * s1 ,
const char * s2,
int & );
173 bool match(
const char * s,
string & s1, vector<string> & options, ostream & err);
174 bool match(
const char *,
int &);
175 bool match(
const char *,
int &,
int &);
176 bool match(
const char *,
int &,
int &,
int &);
177 bool match(
const char *,
string &);
178 bool match(
const char * s, vector<int> & , vector<int> &);
179 bool match(
const char * s, vector<int> &,
const int,
const int , vector<int> &,
const int,
const int);
180 bool greedy_match(
const char *,
string &);
181 bool greedy_match(
const char *,
int &,
int&,
int&,
string &);
182 bool concat(
unsigned int i,
string &s){ s=
"";
for (;i<argv.size(); i++) s+=argv[i].str();
return true;}
184 unsigned int narg(){
return argv.size();};
196 map<string, deque <string> >::iterator mi;
197 vector< deque <string> > stack;
200 Token(){ macros=NULL; token.clear(); stack.clear(); }
201 Token(
const deque<string> tlist){ macros=NULL; token=tlist; stack.clear(); }
202 map<string, deque <string> > * macros;
204 string front(
bool expand=
true);
206 void push_front(
string s);
207 bool empty(){
return (token.size()==0)&&(stack.size()==0);}
208 void push_back(
string s){token.push_back(s);}
210 bool assignment(
string & name);
211 void add_macro(
string name, deque <string> t){ (*macros)[name]=t; }
224 void expand(
const int imin=0,
const int imax=0 ){
225 if (expanded)
return;
226 ivalues=lvalues.getVect(imin, imax); expanded=
true;
228 unsigned int size(){
if (!expanded){
return 0;}
else{
return ivalues.size();}}
229 vector<int> values(){
return ivalues;}
230 Target():name(
""){expanded=
false;}
231 Target(
string s):name(s){expanded=
false;}
234 int value(){
if (!expanded) {
return 0;}
else{
return ivalues.size()==1 ? ivalues[0] : -1;}; }
235 Target(
string name,
const int value):name(name){ivalues.clear();ivalues.push_back( value );expanded=
true;}
236 Target get(
unsigned int i){
Target t(name, ivalues[i]);
return t;};
238 bool parse(
Token & );
245 vector<Statement *> stmts;
247 Block(){ stmts.clear();}
257 bool has_localTarget;
263 isAssignment(
false), name(
""), has_localTarget(
false), keyword(
""), redirected(
false), out_filename(
""){block=NULL;};
264 ~
Statement(){
if (!(block==NULL))
delete block; }
265 bool parse(
Token & );
279 DRecord(uint8_t T=0xff, uint32_t D=0x00000000, uint16_t W1=0x000, uint16_t W2=0x0000){
297 int exec(
const char* p){
return exec(
string(p));}
300 bool setDefaultTarget(
Target t){ defaultTarget=t;
return true; }
308 vector<string> fD_names;
309 vector<string> fA_names;
310 static const unsigned int fnDAC_names;
311 static const char *
const fDAC_names[];
312 static int fGetBufMethod;
314 bool fPixelConfigNeeded;
315 unsigned int fTCT, fTRC, fTTK;
316 unsigned int fBufsize;
317 vector<uint16_t> fBuf;
318 unsigned int fNumberOfEvents;
319 unsigned int fHeaderCount;
320 vector<unsigned int> fHeadersWithErrors;
322 unsigned int fPeriod;
323 vector<pair<string,uint8_t> > fSigdelays;
324 vector<pair<string,uint8_t> > fSigdelaysSetup;
329 int fDeser400XOR1sum[8];
336 map<string, deque <string> > macros;
339 int tbmset(
int address,
int value);
340 int tbmset (
string name, uint8_t coreMask,
int value, uint8_t valueMask=0xff);
341 int tbmsetbit(
string name, uint8_t coreMask,
int bit,
int value);
342 int tbmget(
string name,
const uint8_t core, uint8_t & value);
344 int rawscan(
int level=0);
346 int tctscan(
unsigned int tctmin=0,
unsigned int tctmax=0);
350 int countErrors(
unsigned int ntrig=1,
int ftrigkhz=0,
int nroc_expected=-1,
bool setup=
true);
351 int countGood(
unsigned int nloop,
unsigned int ntrig,
int ftrigkhz,
int nroc);
352 int printData(vector<uint16_t> buf,
int level);
353 int readRocs(uint8_t signal=0xff,
double scale=0, std::string units=
"" );
354 int getBuffer(vector<uint16_t> & buf);
355 int setupDaq(
int ntrig,
int ftrigkhz,
int verbosity=0);
356 int restoreDaq(
int verbosity=0);
357 int runDaq(vector<uint16_t> & buf,
int ntrig,
int ftrigkhz,
int verbosity=0,
bool setup=
true);
358 int runDaq(
int ntrig,
int ftrigkhz,
int verbosity=0);
359 int burst(vector<uint16_t> & buf,
int ntrig,
int trigsep=6,
int nburst=1,
int verbosity=0);
360 int getData(vector<uint16_t> & buf, vector<DRecord > & data,
int verbosity=1,
int nroc_expected=-1);
361 int pixDecodeRaw(
int,
int level=1);
362 int setTestboardDelay(
string name=
"all", uint8_t value=0);
363 int setTestboardPower(
string name, uint16_t value);
365 int bursttest(
int ntrig,
int trigsep=6,
int nburst=1);
367 int adctest(
const string s);
368 int sequence(
int seq);
369 int pg_sequence(
int seq,
int length=0);
371 int pg_loop(
int value=0);
virtual void doTest()
function connected to "DoTest" button of PixTab
void bookHist(std::string name)
use if you want, or define the histograms in the specific member functions
virtual void setToolTips()
implement this to provide updated tool tips if the user changes test parameters
virtual bool setParameter(std::string parName, std::string sval)
set the string value of a parameter
void init()
sets all test parameters