FEDRA emulsion software from the OPERA Collaboration
EdbScanClientSysal Class Reference

#include <EdbScanClientSysal.h>

Inheritance diagram for EdbScanClientSysal:
Collaboration diagram for EdbScanClientSysal:

Public Member Functions

virtual void AsyncScanAreaS (int id1, int id2, int id3, int id4, float x1, float x2, float y1, float y2, const char *fname)
 
virtual void AsyncScanPreloadAreaS (int id1, int id2, int id3, int id4, float x1, float x2, float y1, float y2, const char *fname, float x1n, float x2n, float y1n, float y2n)
 
virtual int AsyncWaitForScanResult ()
 
 EdbScanClientSysal ()
 
virtual int LoadPlate (int BRICK, int PLATE, const char *mapext, int nAttempts=1)
 
virtual void Print ()
 
int RcvLine (TSocket *sock, char *line, int size)
 
virtual int ScanAreas (ScanType st, int id[4], EdbPattern &areas, EdbRun *run, const char *options="")
 
virtual bool ServerCreatesTarget ()
 
virtual void SetClusterThresholds (int TOP, int BOT)
 
virtual int SetFragmentSize (int X, int Y)
 
virtual void SetOdysseyThresholds (int itop, int ibottom, int size, int TOP, int BOT)
 
virtual void SetParameter (const char *Object, const char *Parameter, const char *Value)
 
virtual int UnloadPlate ()
 
virtual ~EdbScanClientSysal ()
 
- Public Member Functions inherited from EdbScanClientCommon
virtual int AddRWC_ (EdbRun *run, char *rwcname, int bAddRWD=true, const char *options="")
 
void CloseSocket ()
 
virtual int ConvertAreas (int id[4], EdbPattern &areas, EdbRun &run, const char *options="")
 
 EdbScanClientCommon ()
 
const char * GetCmd ()
 
int GetMaxAttempts ()
 
int GetMaxFails ()
 
const char * GetMess ()
 
const char * GetMess1 ()
 
float GetNXView ()
 
float GetNYView ()
 
int GetPort ()
 
const char * GetProcPthServer ()
 
const char * GetProcTgtServer ()
 
const char * GetRawDirClient ()
 
const char * GetRawDirServer ()
 
const char * GetServer ()
 
const char * GetServerCreatedRunName ()
 
float GetXstep ()
 
float GetYstep ()
 
virtual int InitializeSocket ()
 
virtual int ScanPreloadAreaS (int id1, int id2, int id3, int id4, float x1, float x2, float y1, float y2, const char *fname, float x1n, float x2n, float y1n, float y2n)
 
void SetCmd (const char *cmd_)
 
void SetMaxAttempts (int attempts_)
 
void SetMaxFails (int fails_)
 
void SetMess (const char *mess_)
 
void SetMess1 (const char *mess_)
 
void SetNXview (float nxview_)
 
void SetNYview (float nyview_)
 
void SetPort (int port_)
 
void SetProcPthServer (const char *prcpthserver_)
 
void SetProcTgtServer (const char *prctgtserver_)
 
void SetRawDirClient (const char *rawdirclient_)
 
void SetRawDirServer (const char *rawdirserver_)
 
void SetServer (const char *server_)
 
void SetXstep (float xstep_)
 
void SetYstep (float ystep_)
 
virtual Short_t ShortBrick (Int_t brick)
 
virtual ~EdbScanClientCommon ()
 
- Public Member Functions inherited from EdbScanClientBase
 EdbScanClientBase ()
 
virtual ~EdbScanClientBase ()
 

Additional Inherited Members

- Public Types inherited from EdbScanClientBase
enum  ScanType { stPred , stVolume }
 
- Protected Attributes inherited from EdbScanClientCommon
char eCMD [CMD_LEN]
 
int eMAXFAILS
 
int eMAXSCANATTEMPTS
 
char eMess [CMD_LEN]
 
char eMess1 [CMD_LEN]
 
float eNXview
 
float eNYview
 
int ePORT
 
TString eProcPthServer
 
TString eProcTgtServer
 
TString eRawDirClient
 
TString eRawDirServer
 
TString eServer
 
TString eServerCreatedRunName
 
TSocket * eSock
 
float eXstep
 
float eYstep
 

Constructor & Destructor Documentation

◆ EdbScanClientSysal()

EdbScanClientSysal::EdbScanClientSysal ( )
inline
16 {};

◆ ~EdbScanClientSysal()

virtual EdbScanClientSysal::~EdbScanClientSysal ( )
inlinevirtual
17 {};

Member Function Documentation

◆ AsyncScanAreaS()

void EdbScanClientSysal::AsyncScanAreaS ( int  id1,
int  id2,
int  id3,
int  id4,
float  x1,
float  x2,
float  y1,
float  y2,
const char *  fname 
)
virtual

Implements EdbScanClientCommon.

218 {
219  if(!eSock)
221  if(!eSock)
222  return;
223  // send the instruction for area scan and do not wait for the result
224  memset(eCMD,0,256);
225  sprintf(eCMD,"101 %d %d %d %d %f %f %f %f %s\n", ShortBrick(id1),id2,id3,id4,x1,x2,y1,y2,fname);
226  printf("%s",eCMD);
227  eSock->SendRaw(eCMD,strlen(eCMD));
228  return;
229 }
virtual int InitializeSocket()
Definition: EdbScanClientBase.cxx:48
virtual Short_t ShortBrick(Int_t brick)
Definition: EdbScanClientBase.h:93
char eCMD[CMD_LEN]
Definition: EdbScanClientBase.h:58
TSocket * eSock
Definition: EdbScanClientBase.h:57
const char * fname
Definition: mc2raw.cxx:41

◆ AsyncScanPreloadAreaS()

void EdbScanClientSysal::AsyncScanPreloadAreaS ( int  id1,
int  id2,
int  id3,
int  id4,
float  x1,
float  x2,
float  y1,
float  y2,
const char *  fname,
float  x1n,
float  x2n,
float  y1n,
float  y2n 
)
virtual

Implements EdbScanClientCommon.

235 {
236  if(!eSock)
238  if(!eSock)
239  return;
240  memset(eCMD,0,256);
241  sprintf(eCMD,"102 %d %d %d %d %f %f %f %f %s %f %f %f %f\n",
242  ShortBrick(id1),id2,id3,id4,x1,x2,y1,y2,fname,x1n,x2n,y1n,y2n);
243  printf("%s",eCMD);
244  eSock->SendRaw(eCMD,strlen(eCMD));
245  return;
246 }

◆ AsyncWaitForScanResult()

int EdbScanClientSysal::AsyncWaitForScanResult ( )
virtual

Implements EdbScanClientCommon.

250 {
251  memset(eMess,0,256);
252  memset(eMess1,0,256);
253  RcvLine(eSock,eMess,sizeof(eMess));
254  RcvLine(eSock,eMess,sizeof(eMess));
255  RcvLine(eSock,eMess1,sizeof(eMess1));
256  if(eMess1[0]!='O') {printf("Error scanning the plate! return 0\n"); return 0;}
257  printf("Area scan complete\n");
258  return 1;
259 }
char eMess[CMD_LEN]
Definition: EdbScanClientBase.h:59
char eMess1[CMD_LEN]
Definition: EdbScanClientBase.h:60
int RcvLine(TSocket *sock, char *line, int size)
Definition: EdbScanClientSysal.cxx:29

◆ LoadPlate()

int EdbScanClientSysal::LoadPlate ( int  BRICK,
int  PLATE,
const char *  mapext,
int  nAttempts = 1 
)
virtual

Implements EdbScanClientCommon.

60 {
61  if(!eSock)
63  if(!eSock)
64  return 0;
65  Int_t attempt=1;
66  eMess1[0]=0;
67 
68  while( (attempt<nAttempts+1) && (eMess1[0]!='O') )
69  {
70  printf("Plate %d brick %d : load attempt %d (of %d)\n",PLATE,BRICK,attempt,nAttempts);
71  sprintf(eCMD,"201 %d %d 0 0 gg %s\n",ShortBrick(BRICK),PLATE,mapext);
72  printf("%s",eCMD);
73  eSock->SendRaw(eCMD,strlen(eCMD));
74  RcvLine(eSock,eMess,sizeof(eMess));
75  RcvLine(eSock,eMess1,sizeof(eMess1));
76  attempt++;
77  }
78  if(eMess1[0]!='O') {printf("Error loading the plate. \n"); return -1;}
79  printf("Plate loaded\n");
80  return 1;
81 }
int PLATE
Definition: shower_btr.C:18
Definition: RecDispMC.C:95

◆ Print()

virtual void EdbScanClientSysal::Print ( )
virtual

Implements EdbScanClientCommon.

◆ RcvLine()

int EdbScanClientSysal::RcvLine ( TSocket *  sock,
char *  line,
int  size 
)
30 {
31  if(!eSock)
33  if(!eSock)
34  return 0;
35  // Receave the line from socket; return the number of bytes receaved
36  char chr=0;
37  int i=0;
38  if(!(sock->IsValid())) return -1;
39  while( chr!=10 ) { sock->RecvRaw(&chr,1); if(i<size-1) { line[i]=chr; i++;} }
40  line[i]=0;
41  return i;
42 }

◆ ScanAreas()

int EdbScanClientSysal::ScanAreas ( ScanType  st,
int  id[4],
EdbPattern areas,
EdbRun run,
const char *  options = "" 
)
virtual

Implements EdbScanClientCommon.

161 {
162  // this function scan the list of areas and save into EdbRun
163  // the run should be already correctly opened
164  // prediction id will be used for the temporary file name construction and so should be unique
165  // return number of correctly scanned and converted areas
166 
167  int n = areas.N();
168  printf("ScanAreas: %d \n",n);
169  int scanned=0, failed=0;
170  EdbSegP *s = 0;
171  EdbSegP *sn = 0;
172  char str[256];
173  for(int i=0; i<n; i++) {
174  s = areas.GetSegment(i);
175 
176  if( (s->SX() < 0.5*eNXview*eXstep) || (s->SY() < 0.5*eNYview*eYstep) ) // set the fragments size for sysal
177  s->SetErrors(0.5*eNXview*eXstep, 0.5*eNYview*eYstep, 0., .1, .1);
178 
179  if(i<n-1) sn = areas.GetSegment(i+1);
180  else sn = areas.GetSegment(i);
181 
182 #ifdef WIN32
183  sprintf(str,"del %s/raw.%d.%d.%d.%d.*",eRawDirClient.Data(),ShortBrick(id[0]), id[1], id[2], s->ID()); // s->ID() must be unique!
184 #else
185  sprintf(str,"rm -f %s/raw.%d.%d.%d.%d.*",eRawDirClient.Data(),ShortBrick(id[0]), id[1], id[2], s->ID()); // s->ID() must be unique!
186 #endif
187 
188  gSystem->Exec(str);
189  printf("ScanAreas: scan progress: %d out of %d (%4.1f%%)\n",i,n,100.*i/n);
190  sprintf(str,"%s/raw.%d.%d.%d.%d",eRawDirServer.Data(),ShortBrick(id[0]), id[1], id[2], s->ID());
191 
192  if( !ScanPreloadAreaS( id[0], id[1], id[2], s->ID(),
193  s->X()-s->SX(), s->X()+s->SX(), s->Y()-s->SY(), s->Y()+s->SY(),
194  str,sn->X()-sn->SX(), sn->X()+sn->SX(), sn->Y()-sn->SY(), sn->Y()+sn->SY() ) ) {
195  // i--; //? Igor added this line?
196  printf("EdbScanClient::ScanAreas: WARNING!!! scanning failed for area %d (%d.%d.%d.%d)!\n",
197  i, id[0], id[1], id[2], s->ID());
198  if(++failed > eMAXFAILS) {
199  printf("EdbScanClient::ScanAreas: ERROR!!! too many failures - stop scanning!\n");
200  break;
201  }
202  continue; // still try to scan other predictions
203  }
204  sprintf(str,"%s/raw.%d.%d.%d.%d.rwc",eRawDirClient.Data(),ShortBrick(id[0]), id[1], id[2], s->ID());
205  run->GetHeader()->SetFlag(9, s->ID());
206  run->GetHeader()->SetFlag(8, s->MCEvt());
207  AddRWC(run,str,true,options);
208  scanned++;
209  }
210 
211  return scanned;
212 }
void SetFlag(int i, int value)
Definition: EdbRunHeader.h:130
EdbRunHeader * GetHeader() const
Definition: EdbRun.h:137
float eNXview
Definition: EdbScanClientBase.h:62
virtual int ScanPreloadAreaS(int id1, int id2, int id3, int id4, float x1, float x2, float y1, float y2, const char *fname, float x1n, float x2n, float y1n, float y2n)
Definition: EdbScanClientBase.cxx:61
TString eRawDirClient
Definition: EdbScanClientBase.h:71
float eYstep
Definition: EdbScanClientBase.h:63
float eXstep
Definition: EdbScanClientBase.h:63
int eMAXFAILS
Definition: EdbScanClientBase.h:66
float eNYview
Definition: EdbScanClientBase.h:62
TString eRawDirServer
Definition: EdbScanClientBase.h:70
Definition: EdbSegP.h:18
void SetErrors()
Definition: EdbSegP.h:89
Int_t ID() const
Definition: EdbSegP.h:144
Float_t SY() const
Definition: EdbSegP.h:160
Float_t X() const
Definition: EdbSegP.h:170
Float_t Y() const
Definition: EdbSegP.h:171
Int_t MCEvt() const
Definition: EdbSegP.h:142
Float_t SX() const
Definition: EdbSegP.h:159
Int_t N() const
Definition: EdbPattern.h:89
EdbSegP * GetSegment(int i) const
Definition: EdbPattern.h:66
int AddRWC(EdbRun *run, char *rwcname, int bAddRWD, const char *options)
Definition: libDataConversion.cpp:64
EdbRun * run
Definition: check_raw.C:38
EdbSegP * s
Definition: tlg2pattern.C:32

◆ ServerCreatesTarget()

virtual bool EdbScanClientSysal::ServerCreatesTarget ( )
inlinevirtual

Implements EdbScanClientCommon.

36 {return false;};

◆ SetClusterThresholds()

void EdbScanClientSysal::SetClusterThresholds ( int  TOP,
int  BOT 
)
virtual

Implements EdbScanClientCommon.

100 {
101  if(!eSock)
103  if(!eSock)
104  return;
105  sprintf(eCMD,"203 VertigoScanner TopClusterThreshold %d\n",TOP);
106  printf("%s",eCMD);
107  eSock->SendRaw(eCMD,strlen(eCMD));
108  RcvLine(eSock,eMess,sizeof(eMess));
109  printf("%s",eMess);
110  sprintf(eCMD,"203 VertigoScanner BottomClusterThreshold %d\n",BOT);
111  printf("%s",eCMD);
112  eSock->SendRaw(eCMD,strlen(eCMD));
113  RcvLine(eSock,eMess,sizeof(eMess));
114  printf("%s",eMess);
115 }
@ TOP
Definition: tlg2pattern.C:37
@ BOT
Definition: tlg2pattern.C:37

◆ SetFragmentSize()

int EdbScanClientSysal::SetFragmentSize ( int  X,
int  Y 
)
virtual

Implements EdbScanClientCommon.

138 {
139  if(!eSock)
141  if(!eSock)
142  return 0;
143  eNXview = X;
144  eNYview = Y;
145  eCMD[0]=0;
146  sprintf(eCMD,"203 VertigoScanner XFields %d\n",X);
147  printf("%s",eCMD);
148  eSock->SendRaw(eCMD,strlen(eCMD));
149  RcvLine(eSock,eMess,sizeof(eMess));
150  printf("%s",eMess);
151  sprintf(eCMD,"203 VertigoScanner YFields %d\n",Y);
152  printf("%s",eCMD);
153  eSock->SendRaw(eCMD,strlen(eCMD));
154  RcvLine(eSock,eMess,sizeof(eMess));
155  printf("%s",eMess);
156  return 1; //todo!!!
157 }
Double_t X
Definition: tlg2pattern.C:77
Double_t Y
Definition: tlg2pattern.C:77

◆ SetOdysseyThresholds()

void EdbScanClientSysal::SetOdysseyThresholds ( int  itop,
int  ibottom,
int  size,
int  TOP,
int  BOT 
)
virtual

Implements EdbScanClientCommon.

119 {
120  if(!eSock)
122  if(!eSock)
123  return;
124  sprintf(eCMD,"203 Frame_Grabber VPProgram%d 0008000804F003F0%4.4X%02d%02d\n",itop,TOP,size,size);
125  printf("%s",eCMD);
126  eSock->SendRaw(eCMD,strlen(eCMD));
127  RcvLine(eSock,eMess,sizeof(eMess));
128  printf("%s",eMess);
129  sprintf(eCMD,"203 Frame_Grabber VPProgram%d 0008000804F003F0%4.4X%02d%02d\n",ibottom,BOT,size,size);
130  printf("%s",eCMD);
131  eSock->SendRaw(eCMD,strlen(eCMD));
132  RcvLine(eSock,eMess,sizeof(eMess));
133  printf("%s",eMess);
134 }

◆ SetParameter()

void EdbScanClientSysal::SetParameter ( const char *  Object,
const char *  Parameter,
const char *  Value 
)
virtual

Implements EdbScanClientCommon.

85 {
86  if(!eSock)
88  if(!eSock)
89  return;
90  memset(eCMD,0,256);
91  sprintf(eCMD,"203 %s %s %s\n",Object,Parameter,Value);
92  printf("%s",eCMD);
93  eSock->SendRaw(eCMD,strlen(eCMD));
94  RcvLine(eSock,eMess,sizeof(eMess));
95  printf("%s",eMess);
96 }

◆ UnloadPlate()

int EdbScanClientSysal::UnloadPlate ( )
virtual

!! todo

Implements EdbScanClientCommon.

46 {
47  if(!eSock)
49  if(!eSock)
50  return 0;
51  sprintf(eCMD,"202\n");
52  printf("%s: UnloadPlate\n",eCMD);
53  eSock->SendRaw(eCMD,strlen(eCMD));
54  RcvLine(eSock,eMess,sizeof(eMess));
55  return 1;
56 }

The documentation for this class was generated from the following files: