00001
00002
00003
00005
00006
00007
00009
00010 #include "TFndSlowCntSilRecode.h"
00011
00012
00013 ClassImp(TFndSlowCntSilRecode)
00014
00015
00016 TFndSlowCntSilRecode::TFndSlowCntSilRecode():
00017 fDebugLevel(),fSilRawLen()
00018 {
00019
00020 Reset();
00021 }
00022
00023
00024 TFndSlowCntSilRecode::~TFndSlowCntSilRecode(){
00025
00026 Reset();
00027 }
00028
00029
00030 void TFndSlowCntSilRecode::Reset(){
00031
00032 fSilRawLen = 0;
00033 bzero(fSilRawBuf,sizeof(fSilRawBuf));
00034 fCurChar = 0;
00035 fCurMsgInt_ID = 0;
00036 fMsgBuf = "";
00037 fMessagePart = "";
00038
00039 }
00040
00041
00042 void TFndSlowCntSilRecode::SetReceivedMessage(UInt_t *raw){
00043
00044
00045 fMessagePart = "";
00046 if(raw==0) return;
00047 fMessagePart = TString((const Char_t *)raw);
00048 fMessagePart+='\n';
00049
00050 if(fDebugLevel > 1){
00051 Printf("\n\n+------------> SetReceivedMessage <-----------------+");
00052 Printf("| |");
00053 Int_t i=0;
00054 while(i<K_SLOW_SOCK_LEN){
00055 if(fMessagePart[i] == '\n') break;
00056 cout << fMessagePart[i];
00057 i++;
00058 }
00059 Printf("\n| |");
00060 Printf("+------------> SetReceivedMessage <-----------------+\n\n");
00061 }
00062
00063 }
00064
00065
00066
00067 void TFndSlowCntSilRecode::SetReceivedString(UInt_t *raw){
00068
00069
00070 Reset();
00071
00072 TString chkstr = "";
00073 fReceivedString = TString((const Char_t *)raw);
00074 fReceivedString+='\n';
00075
00076 if(fDebugLevel > 1){
00077 Printf("\n\n+------------> SetReceivedString <-----------------+");
00078 Printf("| |");
00079 Int_t i=0;
00080 while(i<K_SLOW_SOCK_LEN){
00081 if(fReceivedString[i] == '\n') break;
00082 cout << fReceivedString[i];
00083 i++;
00084 }
00085 Printf("\n| |");
00086 Printf("+------------> SetReceivedString <-----------------+\n\n");
00087 }
00088 }
00089
00090
00091
00092 void TFndSlowCntSilRecode::FillExampleString(){
00093
00094
00095
00096 Reset();
00097
00098 fReceivedString = "13:42:12 26/09/2006\nwarning Dig IO: Watchdog switched off DAQ/Comms: New pedestals run required\n";
00099 fReceivedString+="Module 0\nBI 45.2 2.3 2 (Ok)\nPH 5.99 0.21 2 (Ok) 6.39 0.47 2 (Ok) 43.4 3 (T Normal)\nZA 5.98 0.20 2 (Ok) 6.42 0.46 2 (Ok) 45.8 3 (T Normal)\nZB 6.03 0.20 2 (Ok) 6.40 0.47 2 (Ok) 37.2 3 (T Normal)\n";
00100 fReceivedString+="Module 1\nBI 45.1 2.9 2 (Ok)\nPH 6.00 0.20 2 (Ok) 6.41 0.45 2 (Ok) 33.3 3 (T Normal)\nZA 6.03 0.20 2 (Ok) 6.43 0.45 2 (Ok) 38.1 3 (T Normal)\nZB 6.01 0.20 2 (Ok) 6.41 0.45 2 (Ok) 36.0 3 (T Normal)\n";
00101 fReceivedString+= "Module 2\nBI 50.0 3.8 2 (Ok)\nPH 5.99 0.20 2 (Ok) 6.41 0.47 2 (Ok) 36.2 3 (T Normal)\nZA 6.02 0.20 2 (Ok) 6.42 0.47 2 (Ok) 46.6 3 (T Normal)\nZB 6.01 0.20 2 (Ok) 6.42 0.46 2 (Ok) 39.6 3 (T Normal)\n";
00102 fReceivedString+="Module 3\nBI 55.1 1.8 2 (Ok)\nPH 6.00 0.20 2 (Ok) 6.40 0.47 2 (Ok) 39.3 3 (T Normal)\nZA 6.02 0.20 2 (Ok) 6.41 0.48 2 (Ok) 45.7 3 (T Normal)\nZB 6.00 0.20 2 (Ok) 6.43 0.47 2 (Ok) 30.8 3 (T Normal)\n";
00103 fReceivedString+="Module 4\nBI 65.4 1.9 2 (Ok)\nPH 5.97 0.20 2 (Ok) 6.39 0.47 2 (Ok) 43.9 3 (T Normal)\nZA 5.98 0.20 2 (Ok) 6.40 0.44 2 (Ok) 42.4 3 (T Normal)\nZB 5.99 0.20 2 (Ok) 6.38 0.45 2 (Ok) 22.3 3 (T Normal)\n";
00104 fReceivedString+="Module 5\nBI 40.1 2.0 2 (Ok)\nPH 5.98 0.20 2 (Ok) 6.38 0.46 2 (Ok) 39.5 3 (T Normal)\nZA 5.98 0.20 2 (Ok) 6.38 0.47 2 (Ok) 34.2 3 (T Normal)\nZB 5.99 0.20 2 (Ok) 6.39 0.45 2 (Ok) 45.0 3 (T Normal)\n";
00105 fReceivedString+="Module 6\nBI 50.4 1.9 2 (Ok)\nPH 5.98 0.20 2 (Ok) 6.39 0.47 2 (Ok) 37.0 3 (T Normal)\nZA 5.99 0.20 2 (Ok) 5.98 0.46 2 (Ok) 35.6 3 (T Normal)\nZB 6.00 0.20 2 (Ok) 6.41 0.45 2 (Ok) 34.0 3 (T Normal)\n";
00106 fReceivedString+="Module 7\nBI 40.3 4.1 2 (Ok)\nPH 5.99 0.20 2 (Ok) 6.40 0.48 2 (Ok) 39.5 3 (T Normal)\nZA 6.01 0.20 2 (Ok) 6.41 0.47 2 (Ok) 35.4 3 (T Normal)\nZB 6.00 0.20 2 (Ok) 6.40 0.46 2 (Ok) 38.6 3 (T Normal)\n";
00107 fReceivedString+="Module 8\nBI 54.8 1.6 2 (Ok)\nPH 6.00 0.20 2 (Ok) 6.41 0.47 2 (Ok) 46.1 3 (T Normal)\nZA 6.31 0.21 2 (Ok) 6.00 0.45 2 (Ok) 35.8 3 (T Normal)\nZB 6.02 0.20 2 (Ok) 6.42 0.46 2 (Ok) 32.9 3 (T Normal)\n";
00108 fReceivedString+="Module 9\nBI 55.0 3.4 2 (Ok)\nPH 5.99 0.20 2 (Ok) 6.40 0.46 2 (Ok) 33.8 3 (T Normal)\nZA 5.99 0.20 2 (Ok) 6.41 0.44 2 (Ok) 43.0 3 (T Normal)\nZB 5.99 0.20 2 (Ok) 6.44 0.46 2 (Ok) 35.4 3 (T Normal)\n";
00109 fReceivedString+="Module 10\nBI 45.0 3.5 2 (Ok)\nPH 6.03 0.20 2 (Ok) 6.42 0.46 2 (Ok) 36.1 3 (T Normal)\nZA 5.98 0.20 2 (Ok) 6.40 0.48 2 (Ok) 35.4 3 (T Normal)\nZB 5.98 0.19 2 (Ok) 6.38 0.43 2 (Ok) 42.8 3 (T Normal)\n";
00110 fReceivedString+="Module 11\nBI 39.8 3.7 2 (Ok)\nPH 5.99 0.19 2 (Ok) 6.36 0.44 2 (Ok) 45.5 3 (T Normal)\nZA 5.99 0.18 2 (Ok) 6.37 0.43 2 (Ok) 35.3 3 (T Normal)\nZB 6.00 0.19 2 (Ok) 6.43 0.45 2 (Ok) 35.3 3 (T Normal)\n";
00111 fReceivedString+="Module 12\nBI 40.0 1.9 2 (Ok)\nPH 5.99 0.20 2 (Ok) 6.39 0.45 2 (Ok) 44.7 3 (T Normal)\nZA 5.98 0.20 2 (Ok) 6.40 0.47 2 (Ok) 53.9 3 (T Normal)\nZB 5.99 0.20 2 (Ok) 6.39 0.45 2 (Ok) 26.5 3 (T Normal)\n";
00112 fReceivedString+="Module 13\nBI 40.1 1.6 2 (Ok)\nPH 6.02 0.20 2 (Ok) 6.41 0.45 2 (Ok) 26.2 3 (T Normal)\nZA 5.99 0.20 2 (Ok) 6.42 0.48 2 (Ok) 27.6 3 (T Normal)\nZB 6.00 0.20 2 (Ok) 6.40 0.43 2 (Ok) 26.9 3 (T Normal)\n";
00113 fReceivedString+="Module 14\nBI 45.1 1.8 2 (Ok)\nPH 6.00 0.20 2 (Ok) 6.43 0.47 2 (Ok) 35.4 3 (T Normal)\nZA 5.99 0.23 2 (Ok) 6.41 0.45 2 (Ok) 34.1 3 (T Normal)\nZB 5.97 0.21 2 (Ok) 6.41 0.50 2 (Ok) 35.5 3 (T Normal)\n";
00114 fReceivedString+="Module 15\nBI 40.0 2.5 2 (Ok)\nPH 5.99 0.20 2 (Ok) 6.43 0.44 2 (Ok) 40.8 3 (T Normal)\nZA 5.99 0.20 2 (Ok) 6.37 0.43 2 (Ok) 33.1 3 (T Normal)\nZB 6.02 0.20 2 (Ok) 6.39 0.46 2 (Ok) 35.4 3 (T Normal)\n";
00115 fReceivedString+="Module 16\nBI 40.0 2.3 2 (Ok)\nPH 6.00 0.21 2 (Ok) 6.41 0.46 2 (Ok) 35.3 3 (T Normal)\nZA 6.00 0.20 2 (Ok) 6.41 0.48 2 (Ok) 35.4 3 (T Normal)\nZB 6.00 0.21 2 (Ok) 6.41 0.48 2 (Ok) 35.3 3 (T Normal)\n";
00116 fReceivedString+="Module 17\nBI 39.9 3.3 2 (Ok)\nPH 6.00 0.20 2 (Ok) 6.40 0.48 2 (Ok) 34.4 3 (T Normal)\nZA 6.00 0.20 2 (Ok) 6.40 0.48 2 (Ok) 54.6 3 (T Normal)\nZB 6.01 0.20 2 (Ok) 6.39 0.45 2 (Ok) 34.6 3 (T Normal)\nCooling data:\n";
00117 fReceivedString+="15.0 1 (Started) \'03 REMOTE START\' 0.000\n";
00118
00119 }
00120
00121
00122 void TFndSlowCntSilRecode::ReadSilStringCompact(){
00123
00124 if(fReceivedString.IsNull()){
00125 Warning("ReadSilStringCompact","received string is empty");
00126 return;
00127 }
00128
00129 if(fDebugLevel > 0){
00130 Printf("\n\n =====> TFndSlowCntSilRecode::ReadSilStringCompact called <=====");
00131 Printf("\'fReceivedString\' content is: ");
00132 Printf("----------------------------------");
00133 Printf(fReceivedString);
00134 Printf("----------------------------------");
00135 }
00136
00137
00138 sscanf((const char*)fReceivedString, "%lf %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %d %d %d %d %d",
00139 &fDataCompact.timeStamp, &fDataCompact.biasV[0], &fDataCompact.biasI[0], &fDataCompact.biasV[1], &fDataCompact.biasI[1], &fDataCompact.biasV[2], &fDataCompact.biasI[2],
00140 &fDataCompact.biasV[3], &fDataCompact.biasI[3], &fDataCompact.biasV[4], &fDataCompact.biasI[4], &fDataCompact.biasV[5], &fDataCompact.biasI[5], &fDataCompact.biasV[6], &fDataCompact.biasI[6],
00141 &fDataCompact.biasV[7], &fDataCompact.biasI[7], &fDataCompact.biasV[8], &fDataCompact.biasI[8], &fDataCompact.biasV[9], &fDataCompact.biasI[9], &fDataCompact.biasV[10], &fDataCompact.biasI[10],
00142 &fDataCompact.biasV[11], &fDataCompact.biasI[11], &fDataCompact.biasV[12], &fDataCompact.biasI[12], &fDataCompact.biasV[13], &fDataCompact.biasI[13], &fDataCompact.biasV[14], &fDataCompact.biasI[14],
00143 &fDataCompact.biasV[15], &fDataCompact.biasI[15], &fDataCompact.biasV[16], &fDataCompact.biasI[16], &fDataCompact.biasV[17], &fDataCompact.biasI[17],
00144 &fDataCompact.crateErrorCondition, &fDataCompact.crateKill, &fDataCompact.crateStartupFailed, &fDataCompact.crateStatus, &fDataCompact.packetCounter);
00145
00146 Printf("=================> \"%f\"",fDataCompact.timeStamp);
00147 Printf("=================> \"%f\"",fDataCompact.biasV[3]);
00148
00149 if(fDebugLevel > 0) Printf("\n =====> TFndSlowCntSilRecode::ReadSilStringCompact completed <=====");
00150
00151 }
00152
00153
00154 void TFndSlowCntSilRecode::PrintDataCompact(){
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167 Printf("timestamp: %f",fDataCompact.timeStamp);
00168 for(Int_t i=0;i<18;i++) Printf("Module \"%d\" => bias_V: %f; bias_I: %f",i,fDataCompact.biasV[i],fDataCompact.biasV[i]);
00169 Printf("Crate_Errcondition: %d; CrateKill: %d; crateStartupFailed: %d; crateStatus: %d; packetCounter:%d",
00170 fDataCompact.crateErrorCondition,
00171 fDataCompact.crateKill,
00172 fDataCompact.crateStartupFailed,
00173 fDataCompact.crateStatus,
00174 fDataCompact.packetCounter
00175 );
00176
00177 }
00178
00179
00180
00181 void TFndSlowCntSilRecode::ReadSilString(){
00182
00183 if(fReceivedString.IsNull()){
00184 Warning("ReadSilString","received string is empty");
00185 return;
00186 }
00187
00188 if(fDebugLevel){
00189 Printf("\n\n =====> TFndSlowCntSilRecode::ReadSilString called <=====");
00190 Printf("\'fReceivedString\' content is: ");
00191 Printf("----------------------------------");
00192 Printf(fReceivedString);
00193 Printf("----------------------------------");
00194 }
00195
00196
00197 Char_t line_data[95][200];
00198
00199 Int_t nline=0;
00200 Int_t nchar=0;
00201 while(nline<94){
00202 nline++;
00203 Int_t nchar_line = 0;
00204 while(nchar_line < 200){
00205
00206 line_data[nline-1][nchar_line++] = fReceivedString[nchar];
00207 nchar++;
00208 if(fReceivedString[nchar-1] == '\n') break;
00209
00210 }
00211
00212
00213 line_data[nline-1][nchar_line-1] = '\0';
00214
00215 }
00216
00217 sscanf((const char*)line_data[0],
00218 "%u:%u:%u %u/%u/%u",
00219 &fData.TimeStamp_hours,
00220 &fData.TimeStamp_minutes,
00221 &fData.TimeStamp_seconds,
00222 &fData.TimeStamp_day,
00223 &fData.TimeStamp_month,
00224 &fData.TimeStamp_year
00225 );
00226
00227 fData.SCC_msg = line_data[1];
00228
00229
00230
00231
00232
00233
00234 Char_t dummy_str[4][100];
00235 Int_t mod_num = 0;
00236 for(Int_t mod=0;mod<18;mod++){
00237
00238 sscanf((const char*)line_data[(5*mod)+2],
00239 "%s %d",
00240 dummy_str[0],
00241 &mod_num
00242 );
00243
00244
00245
00246 sscanf((const char*)line_data[(5*mod)+3],
00247 "%s %f %f %d",
00248 dummy_str[0],
00249 &fData.biasV[mod],
00250 &fData.biasI[mod],
00251 &fData.biasStatus[mod]
00252 );
00253
00254
00255
00256 sscanf((const char*)line_data[(5*mod)+4],
00257 "%s %f %f %d %s %f %f %d %s %f %f %d",
00258 dummy_str[0],
00259 &fData.Phi_V[mod][0],
00260 &fData.Phi_I[mod][0],
00261 &fData.Phi_Status[mod][0],
00262 dummy_str[1],
00263 &fData.Phi_V[mod][1],
00264 &fData.Phi_I[mod][1],
00265 &fData.Phi_Status[mod][1],
00266 dummy_str[2],
00267 &fData.Phi_V[mod][2],
00268 &fData.Phi_I[mod][2],
00269 &fData.Phi_Status[mod][2]
00270 );
00271
00272
00273 sscanf((const char*)line_data[(5*mod)+5],
00274 "%s %f %f %d %s %f %f %d %s %f %f %d",
00275 dummy_str[0],
00276 &fData.ZA_V[mod][0],
00277 &fData.ZA_I[mod][0],
00278 &fData.ZA_Status[mod][0],
00279 dummy_str[1],
00280 &fData.ZA_V[mod][1],
00281 &fData.ZA_I[mod][1],
00282 &fData.ZA_Status[mod][1],
00283 dummy_str[2],
00284 &fData.ZA_V[mod][2],
00285 &fData.ZA_I[mod][2],
00286 &fData.ZA_Status[mod][2]
00287 );
00288
00289
00290
00291 sscanf((const char*)line_data[(5*mod)+6],
00292 "%s %f %f %d %s %f %f %d %s %f %f %d",
00293 dummy_str[0],
00294 &fData.ZB_V[mod][0],
00295 &fData.ZB_I[mod][0],
00296 &fData.ZB_Status[mod][0],
00297 dummy_str[1],
00298 &fData.ZB_V[mod][1],
00299 &fData.ZB_I[mod][1],
00300 &fData.ZB_Status[mod][1],
00301 dummy_str[2],
00302 &fData.ZB_V[mod][2],
00303 &fData.ZB_I[mod][2],
00304 &fData.ZB_Status[mod][2]
00305 );
00306
00307 }
00308
00309
00310 sscanf((const char*)line_data[92],
00311 "%s %s",
00312 dummy_str[0],
00313 dummy_str[1]
00314 );
00315 TString check_str_1 = "Cooling";
00316 TString check_str_2 = "data:";
00317 if(check_str_1.CompareTo(dummy_str[0]) != 0 || check_str_2.CompareTo(dummy_str[1]) != 0){
00318 Printf("--------> FORMAT eror detected!");
00319 return;
00320 }
00321
00322 sscanf((const char*)line_data[93],
00323 "%f",
00324 &fData.Temperature
00325 );
00326
00327 if(fDebugLevel > 0) Printf("\n =====> TFndSlowCntSilRecode::ReadSilStringCompact completed <=====");
00328
00329 }
00330
00331
00332 void TFndSlowCntSilRecode::PrintData(){
00333
00334 Printf("");
00335 Printf(" ---------------------------------");
00336 Printf("Printing complete data content");
00337 Printf("Timestamp (hours:minutes:seconds day/month/year): %u:%u:%u %u/%u/%u",
00338 fData.TimeStamp_hours,
00339 fData.TimeStamp_minutes,
00340 fData.TimeStamp_seconds,
00341 fData.TimeStamp_day,
00342 fData.TimeStamp_month,
00343 fData.TimeStamp_year
00344 );
00345
00346 Printf("SCC_msg: \"%s\"",(const Char_t *)fData.SCC_msg);
00347
00348 for(Int_t mod=0;mod<18;mod++){
00349 Printf("Module %d ===> BIAS info (V; I; Status): %f; %f; %d",
00350 mod,
00351 fData.biasV[mod],
00352 fData.biasI[mod],
00353 fData.biasStatus[mod]
00354 );
00355 Printf("Module %d ===> PHI info (V; I; Status): (%f; %f; %d) - (%f; %f; %d) - (%f; %f; %d)",
00356 mod,
00357 fData.Phi_V[mod][0],
00358 fData.Phi_I[mod][0],
00359 fData.Phi_Status[mod][0],
00360 fData.Phi_V[mod][1],
00361 fData.Phi_I[mod][1],
00362 fData.Phi_Status[mod][1],
00363 fData.Phi_V[mod][2],
00364 fData.Phi_I[mod][2],
00365 fData.Phi_Status[mod][2]
00366 );
00367 Printf("Module %d ===> ZA info (V; I; Status): (%f; %f; %d) - (%f; %f; %d) - (%f; %f; %d)",
00368 mod,
00369 fData.ZA_V[mod][0],
00370 fData.ZA_I[mod][0],
00371 fData.ZA_Status[mod][0],
00372 fData.ZA_V[mod][1],
00373 fData.ZA_I[mod][1],
00374 fData.ZA_Status[mod][1],
00375 fData.ZA_V[mod][2],
00376 fData.ZA_I[mod][2],
00377 fData.ZA_Status[mod][2]
00378 );
00379 Printf("Module %d ===> ZB info (V; I; Status): (%f; %f; %d) - (%f; %f; %d) - (%f; %f; %d)",
00380 mod,
00381 fData.ZB_V[mod][0],
00382 fData.ZB_I[mod][0],
00383 fData.ZB_Status[mod][0],
00384 fData.ZB_V[mod][1],
00385 fData.ZB_I[mod][1],
00386 fData.ZB_Status[mod][1],
00387 fData.ZB_V[mod][2],
00388 fData.ZB_I[mod][2],
00389 fData.ZB_Status[mod][2]
00390 );
00391
00392 }
00393 Printf("Temperature: %f",fData.Temperature);
00394 Printf(" ---------------------------------");
00395 }
00396
00397
00398 void TFndSlowCntSilRecode::BuildHeaderPart(Bool_t emptydata){
00399
00400
00401
00402
00403
00404
00405
00406
00407
00408
00409
00410
00411
00412
00413
00414
00415
00416
00417
00418
00419
00420
00421
00422 fSilRawBuf[HdrDet_evlen] = 0;
00423
00424 UInt_t name_u32 = (UInt_t)'S';
00425 name_u32 = name_u32 & 0xFF;
00426 name_u32 = name_u32 | ( ((UInt_t)'I')<<8 );
00427 name_u32 = name_u32 & 0xFFFF;
00428 name_u32 = name_u32 | ( ((UInt_t)'L')<<16 );
00429 name_u32 = name_u32 & 0xFFFFFF;
00430
00431 fSilRawBuf[HdrDet_detname] = name_u32;
00432
00433 if(!emptydata){
00434 TDatime datime;
00435 datime.Set( (Int_t) (fData.TimeStamp_year),
00436 (Int_t) (fData.TimeStamp_month),
00437 (Int_t) (fData.TimeStamp_day),
00438 (Int_t) (fData.TimeStamp_hours),
00439 (Int_t) (fData.TimeStamp_minutes),
00440 (Int_t) (fData.TimeStamp_seconds) );
00441 fSilRawBuf[HdrDet_systime] = datime.Convert();
00442 }
00443
00444 fSilRawBuf[HdrDet_nchans] = K_SLOW_N_CHANS[SIL];
00445 fSilRawBuf[HdrDet_dataoff] = K_SCC_HDR_SIZE + 1;
00446 fSilRawBuf[HdrDet_msgoff] = fSilRawBuf[HdrDet_dataoff] + (UInt_t)(fSilRawBuf[HdrDet_nchans] * 4);
00447 fSilRawBuf[HdrDet_miscoff] = fSilRawBuf[HdrDet_msgoff] + K_MSG_MAX_SIZE;
00448 fSilRawBuf[HdrDet_hdrlen] = K_SCC_HDR_SIZE;
00449 fSilRawBuf[HdrDet_magic] =K_MAGIC_NUMBER;
00450 fSilRawBuf[HdrDet_free] = 0x0;
00451
00452
00453 fSilRawLen += fSilRawBuf[HdrDet_miscoff]-1 ;
00454 }
00455
00456
00457 void TFndSlowCntSilRecode::UpdateHeaderPart(){
00458
00459
00460 if(fDebugLevel > 0) Printf("TFndSlowCntSilRecode::UpdateHeaderPart ===> %u",fSilRawLen);
00461 fSilRawBuf[HdrDet_evlen] = fSilRawLen;
00462 }
00463
00464
00465
00466
00467 void TFndSlowCntSilRecode::BuildDataPart(){
00468
00469
00470
00471
00472
00473
00474
00475
00476
00477
00478
00479
00480
00481 enum e_sil_side {
00482 e_ph = 0,
00483 e_za = 1,
00484 e_zb = 2,
00485 e_end = 3,
00486 };
00487
00488 UInt_t data_off = (UInt_t) (fSilRawBuf[HdrDet_dataoff]/4) ;
00489
00490
00491 for(UInt_t uid = 0; uid < K_SLOW_N_CHANS[SIL] ; uid+=6){
00492
00493 UInt_t mod = uid/6;
00494
00495
00496
00497 UShort_t PosSuppl_PW[e_end] = {0};
00498 UShort_t PosSuppl_TR[e_end] = {0};
00499
00500 UShort_t NegSuppl_PW[e_end] = {0};
00501 UShort_t NegSuppl_TR[e_end] = {0};
00502
00504 if(fData.Phi_Status[mod][0] == 2){
00505 PosSuppl_PW[e_ph] = 1;
00506 PosSuppl_TR[e_ph] = 0;
00507 }
00508 else if(fData.Phi_Status[mod][0] == 13){
00509 PosSuppl_PW[e_ph] = 0;
00510 PosSuppl_TR[e_ph] = 0;
00511 }
00512 else{
00513 PosSuppl_PW[e_ph] = 0;
00514 PosSuppl_TR[e_ph] = 1;
00515 }
00516
00517 if(fData.Phi_Status[mod][1] == 2){
00518 NegSuppl_PW[e_ph] = 1;
00519 NegSuppl_TR[e_ph] = 0;
00520 }
00521 else if(fData. Phi_Status[mod][1] == 13){
00522 NegSuppl_PW[e_ph] = 0;
00523 NegSuppl_TR[e_ph] = 0;
00524 }
00525 else{
00526 NegSuppl_PW[e_ph] = 0;
00527 NegSuppl_TR[e_ph] = 1;
00528 }
00530 if(fData.ZA_Status[mod][0] == 2){
00531 PosSuppl_PW[e_za] = 1;
00532 PosSuppl_TR[e_za] = 0;
00533 }
00534 else if(fData. ZA_Status[mod][0] == 13){
00535 PosSuppl_PW[e_za] = 0;
00536 PosSuppl_TR[e_za] = 0;
00537 }
00538 else{
00539 PosSuppl_PW[e_za] = 0;
00540 PosSuppl_TR[e_za] = 1;
00541 }
00542
00543 if(fData.ZA_Status[mod][1] == 2){
00544 NegSuppl_PW[e_za] = 1;
00545 NegSuppl_TR[e_za] = 0;
00546 }
00547 else if(fData.ZA_Status[mod][1] == 13){
00548 NegSuppl_PW[e_za] = 0;
00549 NegSuppl_TR[e_za] = 0;
00550 }
00551 else{
00552 NegSuppl_PW[e_za] = 0;
00553 NegSuppl_TR[e_za] = 1;
00554 }
00556 if(fData.ZB_Status[mod][0] == 2){
00557 PosSuppl_PW[e_zb] = 1;
00558 PosSuppl_TR[e_zb] = 0;
00559 }
00560 else if(fData.ZB_Status[mod][0] == 13){
00561 PosSuppl_PW[e_zb] = 0;
00562 PosSuppl_TR[e_zb]= 0;
00563 }
00564 else{
00565 PosSuppl_PW[e_zb] = 0;
00566 PosSuppl_TR[e_zb] = 1;
00567 }
00568
00569 if(fData.ZB_Status[mod][1] == 2){
00570 NegSuppl_PW[e_zb] = 1;
00571 NegSuppl_TR[e_zb] = 0;
00572 }
00573 else if(fData. ZB_Status[mod][1] == 13){
00574 NegSuppl_PW[e_zb] = 0;
00575 NegSuppl_TR[e_zb] = 0;
00576 }
00577 else{
00578 NegSuppl_PW[e_zb] = 0;
00579 NegSuppl_TR[e_zb] = 1;
00580 }
00581
00582
00583 UInt_t PosSuppl_V[e_end] = {0};
00584 UInt_t PosSuppl_I[e_end] = {0};
00585
00586 UInt_t NegSuppl_V[e_end] = {0};
00587 UInt_t NegSuppl_I[e_end] = {0};
00588
00589
00590 Float_t Multiplier = 100;
00591
00592 PosSuppl_V[e_ph] = (UInt_t) (0.5 + Multiplier * fData.Phi_V[mod][0]);
00593 PosSuppl_I[e_ph] = (UInt_t) (0.5 + Multiplier * fData.Phi_I[mod][0]);
00594
00595 PosSuppl_V[e_za] = (UInt_t) (0.5 + Multiplier * fData.ZA_V[mod][0]);
00596 PosSuppl_I[e_za] = (UInt_t) (0.5 + Multiplier * fData.ZA_I[mod][0]);
00597
00598 PosSuppl_V[e_zb] = (UInt_t) (0.5 + Multiplier * fData.ZB_V[mod][0]);
00599 PosSuppl_I[e_zb] = (UInt_t) (0.5 + Multiplier * fData.ZB_I[mod][0]);
00600
00601 NegSuppl_V[e_ph] = (UInt_t) (0.5 + Multiplier * fData.Phi_V[mod][1]);
00602 NegSuppl_I[e_ph] = (UInt_t) (0.5 + Multiplier * fData.Phi_I[mod][1]);
00603
00604 NegSuppl_V[e_za] = (UInt_t) (0.5 + Multiplier * fData.ZA_V[mod][1]);
00605 NegSuppl_I[e_za] = (UInt_t) (0.5 + Multiplier * fData.ZA_I[mod][1]);
00606
00607 NegSuppl_V[e_zb] = (UInt_t) (0.5 + Multiplier * fData.ZB_V[mod][1]);
00608 NegSuppl_I[e_zb] = (UInt_t) (0.5 + Multiplier * fData.ZB_I[mod][1]);
00609
00610
00611 for(Int_t i=0;i<3;i++){
00612 PosSuppl_V[i] = PosSuppl_V[i] & 0x7FFF;
00613 NegSuppl_V[i] = NegSuppl_V[i] & 0x7FFF;
00614 PosSuppl_I[i] = PosSuppl_I[i] & 0x7FFF;
00615 NegSuppl_I[i] = NegSuppl_I[i] & 0x7FFF;
00616 PosSuppl_PW[i] = PosSuppl_PW[i] & 0x1;
00617 PosSuppl_TR[i] = PosSuppl_TR[i] & 0x1;
00618 }
00619
00620
00621
00622
00623
00624
00625
00626
00627
00628
00629
00630
00631
00632
00633
00634
00635
00636
00637
00638
00639
00640
00641
00642 UInt_t Pos_entry_Phi = 0;
00643 Pos_entry_Phi = (PosSuppl_V[e_ph] << 16);
00644 Pos_entry_Phi = Pos_entry_Phi & 0x8FFFFFFF;
00645 Pos_entry_Phi = Pos_entry_Phi | (PosSuppl_PW[e_ph] << 31 );
00646 Pos_entry_Phi = Pos_entry_Phi & 0xFFFF0000;
00647 Pos_entry_Phi = Pos_entry_Phi | PosSuppl_I[e_ph];
00648 Pos_entry_Phi = Pos_entry_Phi & 0xFFFF8FFF;
00649 Pos_entry_Phi = Pos_entry_Phi | ( PosSuppl_TR[e_ph] << 15);
00650
00651 UInt_t Neg_entry_Phi = 0;
00652 Neg_entry_Phi = (NegSuppl_V[e_ph] << 16);
00653 Neg_entry_Phi = Neg_entry_Phi & 0x8FFFFFFF;
00654 Neg_entry_Phi = Neg_entry_Phi | (NegSuppl_PW[e_ph] << 31 );
00655 Neg_entry_Phi = Neg_entry_Phi & 0xFFFF0000;
00656 Neg_entry_Phi = Neg_entry_Phi | NegSuppl_I[e_ph];
00657 Neg_entry_Phi = Neg_entry_Phi & 0xFFFF8FFF;
00658 Neg_entry_Phi = Neg_entry_Phi | ( NegSuppl_TR[e_ph] << 15);
00659
00660 UInt_t Pos_entry_ZA = 0;
00661 Pos_entry_ZA = (PosSuppl_V[e_za] << 16);
00662 Pos_entry_ZA = Pos_entry_ZA & 0x8FFFFFFF;
00663 Pos_entry_ZA = Pos_entry_ZA | (PosSuppl_PW[e_za] << 31 );
00664 Pos_entry_ZA = Pos_entry_ZA & 0xFFFF0000;
00665 Pos_entry_ZA = Pos_entry_ZA | PosSuppl_I[e_za];
00666 Pos_entry_ZA = Pos_entry_ZA & 0xFFFF8FFF;
00667 Pos_entry_ZA = Pos_entry_ZA | ( PosSuppl_TR[e_za] << 15);
00668
00669 UInt_t Neg_entry_ZA = 0;
00670 Neg_entry_ZA = (NegSuppl_V[e_za] << 16);
00671 Neg_entry_ZA = Neg_entry_ZA & 0x8FFFFFFF;
00672 Neg_entry_ZA = Neg_entry_ZA | (NegSuppl_PW[e_za] << 31 );
00673 Neg_entry_ZA = Neg_entry_ZA & 0xFFFF0000;
00674 Neg_entry_ZA = Neg_entry_ZA | NegSuppl_I[e_za];
00675 Neg_entry_ZA = Neg_entry_ZA & 0xFFFF8FFF;
00676 Neg_entry_ZA = Neg_entry_ZA | ( NegSuppl_TR[e_za] << 15);
00677
00678 UInt_t Pos_entry_ZB = 0;
00679 Pos_entry_ZB = (PosSuppl_V[e_zb] << 16);
00680 Pos_entry_ZB = Pos_entry_ZB & 0x8FFFFFFF;
00681 Pos_entry_ZB = Pos_entry_ZB | (PosSuppl_PW[e_zb] << 31 );
00682 Pos_entry_ZB = Pos_entry_ZB & 0xFFFF0000;
00683 Pos_entry_ZB = Pos_entry_ZB | PosSuppl_I[e_zb];
00684 Pos_entry_ZB = Pos_entry_ZB & 0xFFFF8FFF;
00685 Pos_entry_ZB = Pos_entry_ZB | ( PosSuppl_TR[e_zb] << 15);
00686
00687 UInt_t Neg_entry_ZB = 0;
00688 Neg_entry_ZB = (NegSuppl_V[e_zb] << 16);
00689 Neg_entry_ZB = Neg_entry_ZB & 0x8FFFFFFF;
00690 Neg_entry_ZB = Neg_entry_ZB | (NegSuppl_PW[e_zb] << 31 );
00691 Neg_entry_ZB = Neg_entry_ZB & 0xFFFF0000;
00692 Neg_entry_ZB = Neg_entry_ZB | NegSuppl_I[e_zb];
00693 Neg_entry_ZB = Neg_entry_ZB & 0xFFFF8FFF;
00694 Neg_entry_ZB = Neg_entry_ZB | ( NegSuppl_TR[e_zb] << 15);
00695
00696
00697 fSilRawBuf[data_off + uid ] = Pos_entry_Phi;
00698 fSilRawBuf[data_off + uid + 1] = Neg_entry_Phi;
00699 fSilRawBuf[data_off + uid + 2] = Pos_entry_ZA;
00700 fSilRawBuf[data_off + uid + 3] = Neg_entry_ZA;
00701 fSilRawBuf[data_off + uid + 4] = Pos_entry_ZB;
00702 fSilRawBuf[data_off + uid + 5] = Neg_entry_ZB;
00703
00704 }
00705
00706
00707
00708
00709
00710 }
00711
00712
00713 void TFndSlowCntSilRecode::ConvertSingleU32(){
00714
00715
00716 UInt_t *conv = (UInt_t *)(fMsgBuf.Data());
00717 fSilRawBuf[(fSilRawBuf[HdrDet_msgoff]/4) + fCurMsgInt_ID] = conv[0] ;
00718 if(fDebugLevel > 1) Printf(" single fSilRawBuf: \"%s\"",(Char_t *) &fSilRawBuf[(fSilRawBuf[HdrDet_msgoff]/4) + fCurMsgInt_ID] );
00719 fCurMsgInt_ID++;
00720 fMsgBuf = "";
00721 }
00722
00723
00724 void TFndSlowCntSilRecode::BuildMessagesPart(){
00725
00726 if(fDebugLevel > 0) Printf("TFndSlowCntSilRecode::BuildMessagesPart: Entering method");
00727
00728 fCurChar = 0;
00729 fCurMsgInt_ID = 0;
00730
00731 while(fCurChar<K_MSG_MAX_SIZE){
00732
00733 if(fDebugLevel > 2){Printf("fCurChar: %d; fCurMsgInt_ID: %d ===> \"%c\"",
00734 fCurChar,
00735 fCurMsgInt_ID,
00736 (Char_t)(fData.SCC_msg)[fCurChar]
00737 );
00738 }
00739
00740 if(fCurChar!=0 && fCurChar%4==0){
00741 ConvertSingleU32();
00742 }
00743
00744 fMsgBuf+=(fData.SCC_msg)[fCurChar];
00745 if(fDebugLevel > 1) Printf( " fMsgBuf: \"%s\"",fMsgBuf.Data() );
00746 fCurChar++;
00747
00748 if((fData.SCC_msg)[fCurChar] == '\0' || (fData.SCC_msg)[fCurChar] == '\n'){
00749 if(fDebugLevel > 1) Printf("End of line reached");
00750 ConvertSingleU32();
00751 fSilRawBuf[(fSilRawBuf[HdrDet_msgoff]/4) + fCurMsgInt_ID] = (UInt_t)('\0');
00752 break;
00753 }
00754 }
00755
00756 if(fDebugLevel > 1) Printf("fSilRawBuf conv. message: \"%s\"", (Char_t *)(&fSilRawBuf[fSilRawBuf[HdrDet_msgoff]/4]) );
00757 if(fDebugLevel > 0) Printf("TFndSlowCntSilRecode::BuildMessagesPart: Exiting method");
00758
00759 }
00760
00761
00762 void TFndSlowCntSilRecode::UpdateMessagePart(){
00763
00764
00765 if(fDebugLevel > 0) Info("UpdateSilMessage","Entering method");
00766 if(fSilRawBuf[HdrDet_evlen] ==0) {
00767 if(fDebugLevel > 0) Warning("UpdateSilMessage","Sil raw data still not available: creating an empty raw buffer");
00768 ReBuildSilSlowRaw(kTRUE);
00769 }
00770
00771 if(fMessagePart.IsNull()){
00772 Warning("UpdateMessagePart","Null message received");
00773 for(Int_t i=(Int_t)(fSilRawBuf[HdrDet_msgoff]/4);i<(Int_t)(fSilRawBuf[HdrDet_miscoff]/4);i++) fSilRawBuf[i] = 0;
00774 return;
00775 }
00776
00777 fCurChar = 0;
00778 fCurMsgInt_ID = 0;
00779
00780 while(fCurChar<K_MSG_MAX_SIZE){
00781
00782 if(fDebugLevel > 2){Printf("fCurChar: %d; fCurMsgInt_ID: %d ===> \"%c\"",
00783 fCurChar,
00784 fCurMsgInt_ID,
00785 (Char_t)(fMessagePart)[fCurChar]
00786 );
00787 }
00788
00789 if(fCurChar!=0 && fCurChar%4==0){
00790 ConvertSingleU32();
00791 }
00792
00793 fMsgBuf+=(fMessagePart)[fCurChar];
00794 if(fDebugLevel > 1) Printf( " fMsgBuf: \"%s\"",fMsgBuf.Data() );
00795 fCurChar++;
00796
00797 if((fMessagePart)[fCurChar] == '\0' || (fMessagePart)[fCurChar] == '\n'){
00798 if(fDebugLevel > 1) Printf("End of line reached");
00799 ConvertSingleU32();
00800 fSilRawBuf[(fSilRawBuf[HdrDet_msgoff]/4) + fCurMsgInt_ID] = (UInt_t)('\0');
00801 break;
00802 }
00803 }
00804
00805 if(fDebugLevel > 1) Printf("fSilRawBuf conv. message: \"%s\"", (Char_t *)(&fSilRawBuf[fSilRawBuf[HdrDet_msgoff]/4]) );
00806
00807 if(fDebugLevel > 0) Info("UpdateSilMessage","Exiting method");
00808 }
00809
00810
00811
00812 void TFndSlowCntSilRecode::BuildMiscPart(){
00813
00814
00815 if(fDebugLevel > 1) Printf("TFndSlowCntSilRecode::BuildMiscPart ===> misc start at byte: %u",fSilRawBuf[HdrDet_miscoff]);
00816
00817 }
00818
00819
00820 void TFndSlowCntSilRecode::ReBuildSilSlowRaw(Bool_t empty){
00821
00822 bzero(fSilRawBuf,sizeof(fSilRawBuf));
00823 BuildHeaderPart(empty);
00824
00825 if(!empty){
00826 BuildDataPart();
00827 BuildMessagesPart();
00828 BuildMiscPart();
00829 }
00830
00831 UpdateHeaderPart();
00832
00833 }
00834
00835
00836 void TFndSlowCntSilRecode::PrintSilSlowRaw(Bool_t hdr,Bool_t data,Bool_t msg){
00837
00838 if(!hdr && !data && !msg){
00839 Printf("\n\n --- TFndSlowCntSilRecode::PrintSilSlowRaw: Nothing to print (all arguments are \"false\"): \n");
00840 return;
00841 }
00842
00843 Printf("\n\n --- printing SIL Slow-raw-data: \n");
00844
00845 if(hdr){
00846 Printf(" -> HEADER: ");
00847 for(Int_t i=0;i<10;i++) Printf("fSilRawBuf [%d] = 0x%x",i,fSilRawBuf[i]);
00848 Printf(" ---------- ");
00849 }
00850
00851 if(data){
00852 Printf(" -> DATA: ");
00853 for(Int_t i=(Int_t)(fSilRawBuf[HdrDet_dataoff]/4);i<(Int_t)(fSilRawBuf[HdrDet_msgoff]/4);i++) Printf("fSilRawBuf [%d] = 0x%x",i,fSilRawBuf[i]);
00854 Printf(" ---------- ");
00855 }
00856
00857 if(msg){
00858 Printf(" -> MESSAGE: ");
00859 for(Int_t i=(Int_t)(fSilRawBuf[HdrDet_msgoff]/4);i<(Int_t)(fSilRawBuf[HdrDet_miscoff]/4);i++) Printf("fSilRawBuf [%d] = 0x%x",i,fSilRawBuf[i]);
00860 for(Int_t i=(Int_t)(fSilRawBuf[HdrDet_msgoff]/4);i<(Int_t)(fSilRawBuf[HdrDet_miscoff]/4);i++) Printf("fSilRawBuf [%d] = \"%s\"",i,(Char_t*)&fSilRawBuf[i]);
00861 Printf(" ---------- ");
00862 }
00863
00864 }