| 1 | #ifndef FACT_FactGui
|
|---|
| 2 | #define FACT_FactGui
|
|---|
| 3 |
|
|---|
| 4 | #include "MainWindow.h"
|
|---|
| 5 |
|
|---|
| 6 | #include <iomanip>
|
|---|
| 7 | #include <valarray>
|
|---|
| 8 |
|
|---|
| 9 | #include <boost/bind.hpp>
|
|---|
| 10 |
|
|---|
| 11 | #include <QTimer>
|
|---|
| 12 | #include <QStandardItemModel>
|
|---|
| 13 |
|
|---|
| 14 | #include "CheckBoxDelegate.h"
|
|---|
| 15 |
|
|---|
| 16 | #include "src/Dim.h"
|
|---|
| 17 | #include "src/Converter.h"
|
|---|
| 18 | #include "src/HeadersFTM.h"
|
|---|
| 19 | #include "src/HeadersFAD.h"
|
|---|
| 20 | #include "src/DimNetwork.h"
|
|---|
| 21 | #include "src/tools.h"
|
|---|
| 22 |
|
|---|
| 23 | #include "TROOT.h"
|
|---|
| 24 | #include "TSystem.h"
|
|---|
| 25 | #include "TGraph.h"
|
|---|
| 26 | #include "TH1.h"
|
|---|
| 27 | #include "TStyle.h"
|
|---|
| 28 | #include "TMarker.h"
|
|---|
| 29 | #include "TColor.h"
|
|---|
| 30 |
|
|---|
| 31 | using namespace std;
|
|---|
| 32 |
|
|---|
| 33 | // #########################################################################
|
|---|
| 34 |
|
|---|
| 35 | class Camera : public TObject
|
|---|
| 36 | {
|
|---|
| 37 | typedef pair<double,double> Position;
|
|---|
| 38 | typedef vector<Position> Positions;
|
|---|
| 39 |
|
|---|
| 40 | Positions fGeom;
|
|---|
| 41 |
|
|---|
| 42 | void CreatePalette()
|
|---|
| 43 | {
|
|---|
| 44 | /*
|
|---|
| 45 | double ss[5] = {0., 0.10, 0.45, 0.75, 1.00};
|
|---|
| 46 | double rr[5] = {0., 0.35, 0.85, 1.00, 1.00};
|
|---|
| 47 | double gg[5] = {0., 0.10, 0.20, 0.73, 1.00};
|
|---|
| 48 | double bb[5] = {0., 0.03, 0.06, 0.00, 1.00};
|
|---|
| 49 | */
|
|---|
| 50 | double ss[5] = {0.00, 0.25, 0.50, 0.75, 1.00};
|
|---|
| 51 | double rr[5] = {0.15, 0.00, 0.00, 1.00, 0.85};
|
|---|
| 52 | double gg[5] = {0.15, 0.00, 1.00, 0.00, 0.85};
|
|---|
| 53 | double bb[5] = {0.15, 1.00, 0.00, 0.00, 0.85};
|
|---|
| 54 |
|
|---|
| 55 | const Int_t nn = 1440;
|
|---|
| 56 |
|
|---|
| 57 | Int_t idx = TColor::CreateGradientColorTable(5, ss, rr, gg, bb, nn);
|
|---|
| 58 | for (int i=0; i<nn; i++)
|
|---|
| 59 | fPalette.push_back(idx++);
|
|---|
| 60 | }
|
|---|
| 61 |
|
|---|
| 62 | void CreateGeometry()
|
|---|
| 63 | {
|
|---|
| 64 | const double gsSin60 = sqrt(3.)/2;
|
|---|
| 65 |
|
|---|
| 66 | const int rings = 23;
|
|---|
| 67 |
|
|---|
| 68 | // add the first pixel to the list
|
|---|
| 69 |
|
|---|
| 70 | fGeom.push_back(make_pair(0, -0.5));
|
|---|
| 71 |
|
|---|
| 72 | for (int ring=1; ring<=rings; ring++)
|
|---|
| 73 | {
|
|---|
| 74 | for (int s=0; s<6; s++)
|
|---|
| 75 | {
|
|---|
| 76 | for (int i=1; i<=ring; i++)
|
|---|
| 77 | {
|
|---|
| 78 | double xx, yy;
|
|---|
| 79 | switch (s)
|
|---|
| 80 | {
|
|---|
| 81 | case 0: // Direction South East
|
|---|
| 82 | xx = (ring+i)*0.5;
|
|---|
| 83 | yy = (-ring+i)*gsSin60;
|
|---|
| 84 | break;
|
|---|
| 85 |
|
|---|
| 86 | case 1: // Direction North East
|
|---|
| 87 | xx = ring-i*0.5;
|
|---|
| 88 | yy = i*gsSin60;
|
|---|
| 89 | break;
|
|---|
| 90 |
|
|---|
| 91 | case 2: // Direction North
|
|---|
| 92 | xx = ring*0.5-i;
|
|---|
| 93 | yy = ring*gsSin60;
|
|---|
| 94 | break;
|
|---|
| 95 |
|
|---|
| 96 | case 3: // Direction North West
|
|---|
| 97 | xx = -(ring+i)*0.5;
|
|---|
| 98 | yy = (ring-i)*gsSin60;
|
|---|
| 99 | break;
|
|---|
| 100 |
|
|---|
| 101 | case 4: // Direction South West
|
|---|
| 102 | xx = 0.5*i-ring;
|
|---|
| 103 | yy = -i*gsSin60;
|
|---|
| 104 | break;
|
|---|
| 105 |
|
|---|
| 106 | case 5: // Direction South
|
|---|
| 107 | xx = i-ring*0.5;
|
|---|
| 108 | yy = -ring*gsSin60;
|
|---|
| 109 | break;
|
|---|
| 110 | }
|
|---|
| 111 |
|
|---|
| 112 | if (xx*xx + yy*yy - xx > 395.75)
|
|---|
| 113 | continue;
|
|---|
| 114 |
|
|---|
| 115 | fGeom.push_back(make_pair(yy, xx-0.5));
|
|---|
| 116 | }
|
|---|
| 117 | }
|
|---|
| 118 | }
|
|---|
| 119 | }
|
|---|
| 120 |
|
|---|
| 121 | valarray<double> fData;
|
|---|
| 122 | vector<bool> fBold;
|
|---|
| 123 | vector<bool> fEnable;
|
|---|
| 124 |
|
|---|
| 125 | int fWhite;
|
|---|
| 126 |
|
|---|
| 127 | public:
|
|---|
| 128 | Camera() : fData(1440), fBold(1440), fEnable(1440), fWhite(-1)
|
|---|
| 129 | {
|
|---|
| 130 | CreatePalette();
|
|---|
| 131 | CreateGeometry();
|
|---|
| 132 |
|
|---|
| 133 | for (int i=0; i<1440; i++)
|
|---|
| 134 | {
|
|---|
| 135 | fData[i] = i;
|
|---|
| 136 | fBold[i]=false;
|
|---|
| 137 | fEnable[i]=true;
|
|---|
| 138 | }
|
|---|
| 139 | }
|
|---|
| 140 |
|
|---|
| 141 | void Reset() { fBold.assign(1440, false); }
|
|---|
| 142 |
|
|---|
| 143 | void SetBold(int idx) { fBold[idx]=true; }
|
|---|
| 144 | void SetWhite(int idx) { fWhite=idx; }
|
|---|
| 145 | void SetEnable(int idx, bool b) { fEnable[idx]=b; }
|
|---|
| 146 | void Toggle(int idx) { fEnable[idx]=!fEnable[idx]; }
|
|---|
| 147 | double GetData(int idx) const { return fData[idx]; }
|
|---|
| 148 |
|
|---|
| 149 | const char *GetName() const { return "Camera"; }
|
|---|
| 150 |
|
|---|
| 151 | vector<Int_t> fPalette;
|
|---|
| 152 |
|
|---|
| 153 | void Paint(const Position &p)
|
|---|
| 154 | {
|
|---|
| 155 | static const Double_t fgCos60 = 0.5; // TMath::Cos(60/TMath::RadToDeg());
|
|---|
| 156 | static const Double_t fgSin60 = sqrt(3.)/2; // TMath::Sin(60/TMath::RadToDeg());
|
|---|
| 157 |
|
|---|
| 158 | static const Double_t fgDy[6] = { fgCos60, 0., -fgCos60, -fgCos60, 0., fgCos60 };
|
|---|
| 159 | static const Double_t fgDx[6] = { fgSin60/3, fgSin60*2/3, fgSin60/3, -fgSin60/3, -fgSin60*2/3, -fgSin60/3 };
|
|---|
| 160 |
|
|---|
| 161 | //
|
|---|
| 162 | // calculate the positions of the pixel corners
|
|---|
| 163 | //
|
|---|
| 164 | Double_t x[7], y[7];
|
|---|
| 165 | for (Int_t i=0; i<7; i++)
|
|---|
| 166 | {
|
|---|
| 167 | x[i] = p.first + fgDx[i%6];
|
|---|
| 168 | y[i] = p.second + fgDy[i%6];
|
|---|
| 169 | }
|
|---|
| 170 |
|
|---|
| 171 | gPad->PaintFillArea(6, x, y);
|
|---|
| 172 | gPad->PaintPolyLine(7, x, y);
|
|---|
| 173 |
|
|---|
| 174 | }
|
|---|
| 175 |
|
|---|
| 176 | double align(double min, double val, double max) const
|
|---|
| 177 | {
|
|---|
| 178 | if (val<min)
|
|---|
| 179 | return min;
|
|---|
| 180 | if (val>max)
|
|---|
| 181 | return max;
|
|---|
| 182 | return val;
|
|---|
| 183 | }
|
|---|
| 184 |
|
|---|
| 185 | void Paint(Option_t *)
|
|---|
| 186 | {
|
|---|
| 187 | gStyle->SetPalette(fPalette.size(), fPalette.data());
|
|---|
| 188 |
|
|---|
| 189 | const double r = double(gPad->GetWw())/gPad->GetWh();
|
|---|
| 190 | const double max = 20.5; // 20.5 rings in x and y
|
|---|
| 191 |
|
|---|
| 192 | if (r>1)
|
|---|
| 193 | gPad->Range(-r*max, -max, r*max, max);
|
|---|
| 194 | else
|
|---|
| 195 | gPad->Range(-max, -max/r, max, max/r);
|
|---|
| 196 |
|
|---|
| 197 | Double_t x1, x2, y1, y2;
|
|---|
| 198 | gPad->GetRange(x1, x2, y1, y2);
|
|---|
| 199 |
|
|---|
| 200 | double dmin = fData[0];
|
|---|
| 201 | double dmax = fData[0];
|
|---|
| 202 |
|
|---|
| 203 | for (unsigned int i=0; i<fData.size(); i++)
|
|---|
| 204 | {
|
|---|
| 205 | if (!fEnable[i])
|
|---|
| 206 | continue;
|
|---|
| 207 |
|
|---|
| 208 | if (fData[i]>dmax)
|
|---|
| 209 | dmax = fData[i];
|
|---|
| 210 | if (fData[i]<dmin)
|
|---|
| 211 | dmin = fData[i];
|
|---|
| 212 | }
|
|---|
| 213 |
|
|---|
| 214 | const double min = dmin;
|
|---|
| 215 | const double scale = dmax==dmin ? 1 : dmax-dmin;
|
|---|
| 216 |
|
|---|
| 217 | TAttFill fill(0, 1001);
|
|---|
| 218 | TAttLine line;
|
|---|
| 219 |
|
|---|
| 220 | int cnt=0;
|
|---|
| 221 | for (Positions::iterator p=fGeom.begin(); p!=fGeom.end(); p++, cnt++)
|
|---|
| 222 | {
|
|---|
| 223 | if (fBold[cnt])
|
|---|
| 224 | continue;
|
|---|
| 225 |
|
|---|
| 226 | const double val = align(dmin, fData[cnt], dmax);
|
|---|
| 227 |
|
|---|
| 228 | const int col = (val-min)/scale*(fPalette.size()-1);
|
|---|
| 229 |
|
|---|
| 230 | if (fEnable[cnt])
|
|---|
| 231 | fill.SetFillColor(gStyle->GetColorPalette(col));
|
|---|
| 232 | else
|
|---|
| 233 | fill.SetFillColor(kWhite);
|
|---|
| 234 |
|
|---|
| 235 | fill.Modify();
|
|---|
| 236 |
|
|---|
| 237 | Paint(*p);
|
|---|
| 238 | }
|
|---|
| 239 |
|
|---|
| 240 | line.SetLineWidth(2);
|
|---|
| 241 | line.Modify();
|
|---|
| 242 |
|
|---|
| 243 | cnt = 0;
|
|---|
| 244 | for (Positions::iterator p=fGeom.begin(); p!=fGeom.end(); p++, cnt++)
|
|---|
| 245 | {
|
|---|
| 246 | if (!fBold[cnt])
|
|---|
| 247 | continue;
|
|---|
| 248 |
|
|---|
| 249 | const double val = align(dmin, fData[cnt], dmax);
|
|---|
| 250 |
|
|---|
| 251 | const int col = (val-min)/scale*(fPalette.size()-1);
|
|---|
| 252 |
|
|---|
| 253 | if (fEnable[cnt])
|
|---|
| 254 | fill.SetFillColor(gStyle->GetColorPalette(col));
|
|---|
| 255 | else
|
|---|
| 256 | fill.SetFillColor(kWhite);
|
|---|
| 257 | fill.Modify();
|
|---|
| 258 |
|
|---|
| 259 | Paint(*p);
|
|---|
| 260 | }
|
|---|
| 261 |
|
|---|
| 262 | TMarker m(0,0,kStar);
|
|---|
| 263 | m.DrawMarker(0, 0);
|
|---|
| 264 |
|
|---|
| 265 | if (fWhite<0)
|
|---|
| 266 | return;
|
|---|
| 267 |
|
|---|
| 268 | const Position &p = fGeom[fWhite];
|
|---|
| 269 |
|
|---|
| 270 | line.SetLineColor(kWhite);
|
|---|
| 271 | line.Modify();
|
|---|
| 272 |
|
|---|
| 273 | const double val = align(dmin, fData[fWhite], dmax);
|
|---|
| 274 |
|
|---|
| 275 | const int col = (val-min)/scale*(fPalette.size()-1);
|
|---|
| 276 |
|
|---|
| 277 | if (fEnable[fWhite])
|
|---|
| 278 | fill.SetFillColor(gStyle->GetColorPalette(col));
|
|---|
| 279 | else
|
|---|
| 280 | fill.SetFillColor(kWhite);
|
|---|
| 281 | fill.Modify();
|
|---|
| 282 |
|
|---|
| 283 | Paint(p);
|
|---|
| 284 | }
|
|---|
| 285 |
|
|---|
| 286 | int GetIdx(float px, float py) const
|
|---|
| 287 | {
|
|---|
| 288 | static const double sqrt3 = sqrt(3);
|
|---|
| 289 |
|
|---|
| 290 | int idx = 0;
|
|---|
| 291 | for (Positions::const_iterator p=fGeom.begin(); p!=fGeom.end(); p++, idx++)
|
|---|
| 292 | {
|
|---|
| 293 | const Double_t dy = py - p->second;
|
|---|
| 294 | if (fabs(dy)>0.5)
|
|---|
| 295 | continue;
|
|---|
| 296 |
|
|---|
| 297 | const Double_t dx = px - p->first;
|
|---|
| 298 |
|
|---|
| 299 | if (TMath::Abs(dy + dx*sqrt3) > 1)
|
|---|
| 300 | continue;
|
|---|
| 301 |
|
|---|
| 302 | if (TMath::Abs(dy - dx*sqrt3) > 1)
|
|---|
| 303 | continue;
|
|---|
| 304 |
|
|---|
| 305 | return idx;
|
|---|
| 306 | }
|
|---|
| 307 | return -1;
|
|---|
| 308 | }
|
|---|
| 309 |
|
|---|
| 310 | char *GetObjectInfo(Int_t px, Int_t py) const
|
|---|
| 311 | {
|
|---|
| 312 | static stringstream stream;
|
|---|
| 313 | static string str;
|
|---|
| 314 |
|
|---|
| 315 | const float x = gPad->AbsPixeltoX(px);
|
|---|
| 316 | const float y = gPad->AbsPixeltoY(py);
|
|---|
| 317 |
|
|---|
| 318 | const int idx = GetIdx(x, y);
|
|---|
| 319 |
|
|---|
| 320 | stream.seekp(0);
|
|---|
| 321 | if (idx>=0)
|
|---|
| 322 | {
|
|---|
| 323 | stream << "Pixel=" << idx << " Data=" << fData[idx] << '\0';
|
|---|
| 324 | }
|
|---|
| 325 |
|
|---|
| 326 | str = stream.str();
|
|---|
| 327 | return const_cast<char*>(str.c_str());
|
|---|
| 328 | }
|
|---|
| 329 |
|
|---|
| 330 | Int_t DistancetoPrimitive(Int_t px, Int_t py)
|
|---|
| 331 | {
|
|---|
| 332 | const float x = gPad->AbsPixeltoX(px);
|
|---|
| 333 | const float y = gPad->AbsPixeltoY(py);
|
|---|
| 334 |
|
|---|
| 335 | return GetIdx(x, y)>=0 ? 0 : 99999;
|
|---|
| 336 | }
|
|---|
| 337 |
|
|---|
| 338 | void SetData(const valarray<double> &data)
|
|---|
| 339 | {
|
|---|
| 340 | fData = data;
|
|---|
| 341 | }
|
|---|
| 342 | };
|
|---|
| 343 |
|
|---|
| 344 | // #########################################################################
|
|---|
| 345 |
|
|---|
| 346 |
|
|---|
| 347 | class FactGui : public MainWindow, public DimNetwork
|
|---|
| 348 | {
|
|---|
| 349 | private:
|
|---|
| 350 | class FunctionEvent : public QEvent
|
|---|
| 351 | {
|
|---|
| 352 | public:
|
|---|
| 353 | boost::function<void(const QEvent &)> fFunction;
|
|---|
| 354 |
|
|---|
| 355 | FunctionEvent(const boost::function<void(const QEvent &)> &f)
|
|---|
| 356 | : QEvent((QEvent::Type)QEvent::registerEventType()),
|
|---|
| 357 | fFunction(f) { }
|
|---|
| 358 |
|
|---|
| 359 | bool Exec() { fFunction(*this); return true; }
|
|---|
| 360 | };
|
|---|
| 361 |
|
|---|
| 362 | valarray<int8_t> fFtuStatus;
|
|---|
| 363 |
|
|---|
| 364 | vector<int> fPixelMapHW; // Software -> Hardware
|
|---|
| 365 | vector<int> fPatchMapHW; // Software -> Hardware
|
|---|
| 366 | vector<int> fPatchHW; // Maps the software(!) pixel id to the hardware(!) patch id
|
|---|
| 367 |
|
|---|
| 368 | bool fInChoosePatch; // FIXME. Find a better solution
|
|---|
| 369 |
|
|---|
| 370 | DimStampedInfo fDimDNS;
|
|---|
| 371 |
|
|---|
| 372 | DimStampedInfo fDimLoggerStats;
|
|---|
| 373 | DimStampedInfo fDimLoggerFilenameNight;
|
|---|
| 374 | DimStampedInfo fDimLoggerFilenameRun;
|
|---|
| 375 | DimStampedInfo fDimLoggerNumSubs;
|
|---|
| 376 |
|
|---|
| 377 | DimStampedInfo fDimFtmPassport;
|
|---|
| 378 | DimStampedInfo fDimFtmTriggerCounter;
|
|---|
| 379 | DimStampedInfo fDimFtmError;
|
|---|
| 380 | DimStampedInfo fDimFtmFtuList;
|
|---|
| 381 | DimStampedInfo fDimFtmStaticData;
|
|---|
| 382 | DimStampedInfo fDimFtmDynamicData;
|
|---|
| 383 | DimStampedInfo fDimFtmCounter;
|
|---|
| 384 |
|
|---|
| 385 | DimStampedInfo fDimFadFiles;
|
|---|
| 386 | DimStampedInfo fDimFadRuns;
|
|---|
| 387 | DimStampedInfo fDimFadEvents;
|
|---|
| 388 | DimStampedInfo fDimFadCurrentEvent;
|
|---|
| 389 | DimStampedInfo fDimFadEventData;
|
|---|
| 390 | DimStampedInfo fDimFadConnections;
|
|---|
| 391 | DimStampedInfo fDimFadFwVersion;
|
|---|
| 392 | DimStampedInfo fDimFadStatistics;
|
|---|
| 393 |
|
|---|
| 394 | map<string, DimInfo*> fServices;
|
|---|
| 395 |
|
|---|
| 396 | // ========================== LED Colors ================================
|
|---|
| 397 |
|
|---|
| 398 | enum LedColor_t
|
|---|
| 399 | {
|
|---|
| 400 | kLedRed,
|
|---|
| 401 | kLedGreen,
|
|---|
| 402 | kLedYellow,
|
|---|
| 403 | kLedOrange,
|
|---|
| 404 | kLedGray
|
|---|
| 405 | };
|
|---|
| 406 |
|
|---|
| 407 | void SetLedColor(QPushButton *button, LedColor_t col, const Time &t)
|
|---|
| 408 | {
|
|---|
| 409 | switch (col)
|
|---|
| 410 | {
|
|---|
| 411 | case kLedRed:
|
|---|
| 412 | button->setIcon(QIcon(":/Resources/icons/red circle 1.png"));
|
|---|
| 413 | break;
|
|---|
| 414 |
|
|---|
| 415 | case kLedGreen:
|
|---|
| 416 | button->setIcon(QIcon(":/Resources/icons/green circle 1.png"));
|
|---|
| 417 | break;
|
|---|
| 418 |
|
|---|
| 419 | case kLedYellow:
|
|---|
| 420 | button->setIcon(QIcon(":/Resources/icons/yellow circle 1.png"));
|
|---|
| 421 | break;
|
|---|
| 422 |
|
|---|
| 423 | case kLedOrange:
|
|---|
| 424 | button->setIcon(QIcon(":/Resources/icons/orange circle 1.png"));
|
|---|
| 425 | break;
|
|---|
| 426 |
|
|---|
| 427 | case kLedGray:
|
|---|
| 428 | button->setIcon(QIcon(":/Resources/icons/gray circle 1.png"));
|
|---|
| 429 | break;
|
|---|
| 430 | }
|
|---|
| 431 |
|
|---|
| 432 | //button->setToolTip("Last change: "+QDateTime::currentDateTimeUtc().toString()+" UTC");
|
|---|
| 433 | button->setToolTip(("Last change: "+t.GetAsStr()+" UTC").c_str());
|
|---|
| 434 | }
|
|---|
| 435 |
|
|---|
| 436 | // ===================== Services and Commands ==========================
|
|---|
| 437 |
|
|---|
| 438 | QStandardItem *AddServiceItem(const std::string &server, const std::string &service, bool iscmd)
|
|---|
| 439 | {
|
|---|
| 440 | QListView *servers = iscmd ? fDimCmdServers : fDimSvcServers;
|
|---|
| 441 | QListView *services = iscmd ? fDimCmdCommands : fDimSvcServices;
|
|---|
| 442 | QListView *description = iscmd ? fDimCmdDescription : fDimSvcDescription;
|
|---|
| 443 |
|
|---|
| 444 | QStandardItemModel *m = dynamic_cast<QStandardItemModel*>(servers->model());
|
|---|
| 445 | if (!m)
|
|---|
| 446 | {
|
|---|
| 447 | m = new QStandardItemModel(this);
|
|---|
| 448 | servers->setModel(m);
|
|---|
| 449 | services->setModel(m);
|
|---|
| 450 | description->setModel(m);
|
|---|
| 451 | }
|
|---|
| 452 |
|
|---|
| 453 | QList<QStandardItem*> l = m->findItems(server.c_str());
|
|---|
| 454 |
|
|---|
| 455 | if (l.size()>1)
|
|---|
| 456 | {
|
|---|
| 457 | cout << "hae" << endl;
|
|---|
| 458 | return 0;
|
|---|
| 459 | }
|
|---|
| 460 |
|
|---|
| 461 | QStandardItem *col = l.size()==0 ? NULL : l[0];
|
|---|
| 462 |
|
|---|
| 463 | if (!col)
|
|---|
| 464 | {
|
|---|
| 465 | col = new QStandardItem(server.c_str());
|
|---|
| 466 | m->appendRow(col);
|
|---|
| 467 |
|
|---|
| 468 | if (!services->rootIndex().isValid())
|
|---|
| 469 | {
|
|---|
| 470 | services->setRootIndex(col->index());
|
|---|
| 471 | servers->setCurrentIndex(col->index());
|
|---|
| 472 | }
|
|---|
| 473 | }
|
|---|
| 474 |
|
|---|
| 475 | QStandardItem *item = 0;
|
|---|
| 476 | for (int i=0; i<col->rowCount(); i++)
|
|---|
| 477 | {
|
|---|
| 478 | QStandardItem *coli = col->child(i);
|
|---|
| 479 | if (coli->text().toStdString()==service)
|
|---|
| 480 | return coli;
|
|---|
| 481 | }
|
|---|
| 482 |
|
|---|
| 483 | item = new QStandardItem(service.c_str());
|
|---|
| 484 | col->appendRow(item);
|
|---|
| 485 | col->sortChildren(0);
|
|---|
| 486 |
|
|---|
| 487 | if (!description->rootIndex().isValid())
|
|---|
| 488 | {
|
|---|
| 489 | description->setRootIndex(item->index());
|
|---|
| 490 | services->setCurrentIndex(item->index());
|
|---|
| 491 | }
|
|---|
| 492 |
|
|---|
| 493 | if (!iscmd)
|
|---|
| 494 | item->setCheckable(true);
|
|---|
| 495 |
|
|---|
| 496 | return item;
|
|---|
| 497 | }
|
|---|
| 498 |
|
|---|
| 499 | void AddDescription(QStandardItem *item, const vector<Description> &vec)
|
|---|
| 500 | {
|
|---|
| 501 | if (!item)
|
|---|
| 502 | return;
|
|---|
| 503 | if (vec.size()==0)
|
|---|
| 504 | return;
|
|---|
| 505 |
|
|---|
| 506 | item->setToolTip(vec[0].comment.c_str());
|
|---|
| 507 |
|
|---|
| 508 | const string str = Description::GetHtmlDescription(vec);
|
|---|
| 509 |
|
|---|
| 510 | QStandardItem *desc = new QStandardItem(str.c_str());
|
|---|
| 511 | desc->setSelectable(false);
|
|---|
| 512 | item->setChild(0, 0, desc);
|
|---|
| 513 | }
|
|---|
| 514 |
|
|---|
| 515 | void AddServer(const std::string &s)
|
|---|
| 516 | {
|
|---|
| 517 | DimNetwork::AddServer(s);
|
|---|
| 518 |
|
|---|
| 519 | QApplication::postEvent(this,
|
|---|
| 520 | new FunctionEvent(boost::bind(&FactGui::handleAddServer, this, s)));
|
|---|
| 521 | }
|
|---|
| 522 |
|
|---|
| 523 | void RemoveServer(const std::string &s)
|
|---|
| 524 | {
|
|---|
| 525 | UnsubscribeServer(s);
|
|---|
| 526 |
|
|---|
| 527 | DimNetwork::RemoveServer(s);
|
|---|
| 528 |
|
|---|
| 529 | QApplication::postEvent(this,
|
|---|
| 530 | new FunctionEvent(boost::bind(&FactGui::handleRemoveServer, this, s)));
|
|---|
| 531 | }
|
|---|
| 532 |
|
|---|
| 533 | void RemoveAllServers()
|
|---|
| 534 | {
|
|---|
| 535 | UnsubscribeAllServers();
|
|---|
| 536 |
|
|---|
| 537 | vector<string> v = GetServerList();
|
|---|
| 538 | for (vector<string>::iterator i=v.begin(); i<v.end(); i++)
|
|---|
| 539 | QApplication::postEvent(this,
|
|---|
| 540 | new FunctionEvent(boost::bind(&FactGui::handleStateOffline, this, *i)));
|
|---|
| 541 |
|
|---|
| 542 | DimNetwork::RemoveAllServers();
|
|---|
| 543 |
|
|---|
| 544 | QApplication::postEvent(this,
|
|---|
| 545 | new FunctionEvent(boost::bind(&FactGui::handleRemoveAllServers, this)));
|
|---|
| 546 | }
|
|---|
| 547 |
|
|---|
| 548 | void AddService(const std::string &server, const std::string &service, const std::string &fmt, bool iscmd)
|
|---|
| 549 | {
|
|---|
| 550 | QApplication::postEvent(this,
|
|---|
| 551 | new FunctionEvent(boost::bind(&FactGui::handleAddService, this, server, service, fmt, iscmd)));
|
|---|
| 552 | }
|
|---|
| 553 |
|
|---|
| 554 | void RemoveService(const std::string &server, const std::string &service, bool iscmd)
|
|---|
| 555 | {
|
|---|
| 556 | if (fServices.find(server+'/'+service)!=fServices.end())
|
|---|
| 557 | UnsubscribeService(server+'/'+service);
|
|---|
| 558 |
|
|---|
| 559 | QApplication::postEvent(this,
|
|---|
| 560 | new FunctionEvent(boost::bind(&FactGui::handleRemoveService, this, server, service, iscmd)));
|
|---|
| 561 | }
|
|---|
| 562 |
|
|---|
| 563 | void RemoveAllServices(const std::string &server)
|
|---|
| 564 | {
|
|---|
| 565 | UnsubscribeServer(server);
|
|---|
| 566 |
|
|---|
| 567 | QApplication::postEvent(this,
|
|---|
| 568 | new FunctionEvent(boost::bind(&FactGui::handleRemoveAllServices, this, server)));
|
|---|
| 569 | }
|
|---|
| 570 |
|
|---|
| 571 | void AddDescription(const std::string &server, const std::string &service, const vector<Description> &vec)
|
|---|
| 572 | {
|
|---|
| 573 | QApplication::postEvent(this,
|
|---|
| 574 | new FunctionEvent(boost::bind(&FactGui::handleAddDescription, this, server, service, vec)));
|
|---|
| 575 | }
|
|---|
| 576 |
|
|---|
| 577 | // ======================================================================
|
|---|
| 578 |
|
|---|
| 579 | void handleAddServer(const std::string &server)
|
|---|
| 580 | {
|
|---|
| 581 | const State s = GetState(server, GetCurrentState(server));
|
|---|
| 582 | handleStateChanged(Time(), server, s);
|
|---|
| 583 | }
|
|---|
| 584 |
|
|---|
| 585 | void handleRemoveServer(const string &server)
|
|---|
| 586 | {
|
|---|
| 587 | handleStateOffline(server);
|
|---|
| 588 | handleRemoveAllServices(server);
|
|---|
| 589 | }
|
|---|
| 590 |
|
|---|
| 591 | void handleRemoveAllServers()
|
|---|
| 592 | {
|
|---|
| 593 | QStandardItemModel *m = 0;
|
|---|
| 594 | if ((m=dynamic_cast<QStandardItemModel*>(fDimCmdServers->model())))
|
|---|
| 595 | m->removeRows(0, m->rowCount());
|
|---|
| 596 |
|
|---|
| 597 | if ((m = dynamic_cast<QStandardItemModel*>(fDimSvcServers->model())))
|
|---|
| 598 | m->removeRows(0, m->rowCount());
|
|---|
| 599 | }
|
|---|
| 600 |
|
|---|
| 601 | void handleAddService(const std::string &server, const std::string &service, const std::string &/*fmt*/, bool iscmd)
|
|---|
| 602 | {
|
|---|
| 603 | QStandardItem *item = AddServiceItem(server, service, iscmd);
|
|---|
| 604 | const vector<Description> v = GetDescription(server, service);
|
|---|
| 605 | AddDescription(item, v);
|
|---|
| 606 | }
|
|---|
| 607 |
|
|---|
| 608 | void handleRemoveService(const std::string &server, const std::string &service, bool iscmd)
|
|---|
| 609 | {
|
|---|
| 610 | QListView *servers = iscmd ? fDimCmdServers : fDimSvcServers;
|
|---|
| 611 |
|
|---|
| 612 | QStandardItemModel *m = dynamic_cast<QStandardItemModel*>(servers->model());
|
|---|
| 613 | if (!m)
|
|---|
| 614 | return;
|
|---|
| 615 |
|
|---|
| 616 | QList<QStandardItem*> l = m->findItems(server.c_str());
|
|---|
| 617 | if (l.size()!=1)
|
|---|
| 618 | return;
|
|---|
| 619 |
|
|---|
| 620 | for (int i=0; i<l[0]->rowCount(); i++)
|
|---|
| 621 | {
|
|---|
| 622 | QStandardItem *row = l[0]->child(i);
|
|---|
| 623 | if (row->text().toStdString()==service)
|
|---|
| 624 | {
|
|---|
| 625 | l[0]->removeRow(row->index().row());
|
|---|
| 626 | return;
|
|---|
| 627 | }
|
|---|
| 628 | }
|
|---|
| 629 | }
|
|---|
| 630 |
|
|---|
| 631 | void handleRemoveAllServices(const std::string &server)
|
|---|
| 632 | {
|
|---|
| 633 | QStandardItemModel *m = 0;
|
|---|
| 634 | if ((m=dynamic_cast<QStandardItemModel*>(fDimCmdServers->model())))
|
|---|
| 635 | {
|
|---|
| 636 | QList<QStandardItem*> l = m->findItems(server.c_str());
|
|---|
| 637 | if (l.size()==1)
|
|---|
| 638 | m->removeRow(l[0]->index().row());
|
|---|
| 639 | }
|
|---|
| 640 |
|
|---|
| 641 | if ((m = dynamic_cast<QStandardItemModel*>(fDimSvcServers->model())))
|
|---|
| 642 | {
|
|---|
| 643 | QList<QStandardItem*> l = m->findItems(server.c_str());
|
|---|
| 644 | if (l.size()==1)
|
|---|
| 645 | m->removeRow(l[0]->index().row());
|
|---|
| 646 | }
|
|---|
| 647 | }
|
|---|
| 648 |
|
|---|
| 649 | void handleAddDescription(const std::string &server, const std::string &service, const vector<Description> &vec)
|
|---|
| 650 | {
|
|---|
| 651 | const bool iscmd = IsCommand(server, service)==true;
|
|---|
| 652 |
|
|---|
| 653 | QStandardItem *item = AddServiceItem(server, service, iscmd);
|
|---|
| 654 | AddDescription(item, vec);
|
|---|
| 655 | }
|
|---|
| 656 |
|
|---|
| 657 | // ======================================================================
|
|---|
| 658 |
|
|---|
| 659 | void SubscribeService(const string &service)
|
|---|
| 660 | {
|
|---|
| 661 | if (fServices.find(service)!=fServices.end())
|
|---|
| 662 | {
|
|---|
| 663 | cout << "ERROR - We are already subscribed to " << service << endl;
|
|---|
| 664 | return;
|
|---|
| 665 | }
|
|---|
| 666 |
|
|---|
| 667 | fServices[service] = new DimStampedInfo(service.c_str(), (void*)NULL, 0, this);
|
|---|
| 668 | }
|
|---|
| 669 |
|
|---|
| 670 | void UnsubscribeService(const string &service)
|
|---|
| 671 | {
|
|---|
| 672 | const map<string,DimInfo*>::iterator i=fServices.find(service);
|
|---|
| 673 |
|
|---|
| 674 | if (i==fServices.end())
|
|---|
| 675 | {
|
|---|
| 676 | cout << "ERROR - We are not subscribed to " << service << endl;
|
|---|
| 677 | return;
|
|---|
| 678 | }
|
|---|
| 679 |
|
|---|
| 680 | delete i->second;
|
|---|
| 681 |
|
|---|
| 682 | fServices.erase(i);
|
|---|
| 683 | }
|
|---|
| 684 |
|
|---|
| 685 | void UnsubscribeServer(const string &server)
|
|---|
| 686 | {
|
|---|
| 687 | for (map<string,DimInfo*>::iterator i=fServices.begin();
|
|---|
| 688 | i!=fServices.end(); i++)
|
|---|
| 689 | if (i->first.substr(0, server.length()+1)==server+'/')
|
|---|
| 690 | {
|
|---|
| 691 | delete i->second;
|
|---|
| 692 | fServices.erase(i);
|
|---|
| 693 | }
|
|---|
| 694 | }
|
|---|
| 695 |
|
|---|
| 696 | void UnsubscribeAllServers()
|
|---|
| 697 | {
|
|---|
| 698 | for (map<string,DimInfo*>::iterator i=fServices.begin();
|
|---|
| 699 | i!=fServices.end(); i++)
|
|---|
| 700 | delete i->second;
|
|---|
| 701 |
|
|---|
| 702 | fServices.clear();
|
|---|
| 703 | }
|
|---|
| 704 |
|
|---|
| 705 | // ======================================================================
|
|---|
| 706 |
|
|---|
| 707 | struct DimData
|
|---|
| 708 | {
|
|---|
| 709 | const int qos;
|
|---|
| 710 | const string name;
|
|---|
| 711 | const string format;
|
|---|
| 712 | const vector<char> data;
|
|---|
| 713 | const Time time;
|
|---|
| 714 |
|
|---|
| 715 | Time extract(DimInfo *inf) const
|
|---|
| 716 | {
|
|---|
| 717 | // Must be called in exactly this order!
|
|---|
| 718 | const int tsec = inf->getTimestamp();
|
|---|
| 719 | const int tms = inf->getTimestampMillisecs();
|
|---|
| 720 |
|
|---|
| 721 | return Time(tsec, tms*1000);
|
|---|
| 722 | }
|
|---|
| 723 |
|
|---|
| 724 | // DimInfo *info; // this is ONLY for a fast check of the type of the DimData!!
|
|---|
| 725 |
|
|---|
| 726 | DimData(DimInfo *inf) :
|
|---|
| 727 | qos(inf->getQuality()),
|
|---|
| 728 | name(inf->getName()),
|
|---|
| 729 | format(inf->getFormat()),
|
|---|
| 730 | data(inf->getString(), inf->getString()+inf->getSize()),
|
|---|
| 731 | time(extract(inf))/*,
|
|---|
| 732 | info(inf)*/
|
|---|
| 733 | {
|
|---|
| 734 | }
|
|---|
| 735 |
|
|---|
| 736 | template<typename T>
|
|---|
| 737 | T get(uint32_t offset=0) const { return *reinterpret_cast<const T*>(data.data()+offset); }
|
|---|
| 738 |
|
|---|
| 739 | template<typename T>
|
|---|
| 740 | const T *ptr(uint32_t offset=0) const { return reinterpret_cast<const T*>(data.data()+offset); }
|
|---|
| 741 |
|
|---|
| 742 | template<typename T>
|
|---|
| 743 | const T &ref(uint32_t offset=0) const { return *reinterpret_cast<const T*>(data.data()+offset); }
|
|---|
| 744 |
|
|---|
| 745 | // vector<char> vec(int b) const { return vector<char>(data.begin()+b, data.end()); }
|
|---|
| 746 | // string str(unsigned int b) const { return b>=data.size()?string():string(data.data()+b, data.size()-b); }
|
|---|
| 747 | const char *c_str() const { return (char*)data.data(); }
|
|---|
| 748 | /*
|
|---|
| 749 | vector<boost::any> any() const
|
|---|
| 750 | {
|
|---|
| 751 | const Converter conv(format);
|
|---|
| 752 | conv.Print();
|
|---|
| 753 | return conv.GetAny(data.data(), data.size());
|
|---|
| 754 | }*/
|
|---|
| 755 | size_t size() const { return data.size(); }
|
|---|
| 756 | };
|
|---|
| 757 |
|
|---|
| 758 | // ======================= DNS ==========================================
|
|---|
| 759 |
|
|---|
| 760 | void handleDimDNS(const DimData &d)
|
|---|
| 761 | {
|
|---|
| 762 | const int version = d.size()!=4 ? 0 : d.get<uint32_t>();
|
|---|
| 763 |
|
|---|
| 764 | ostringstream str;
|
|---|
| 765 | str << "V" << version/100 << 'r' << version%100;
|
|---|
| 766 |
|
|---|
| 767 | SetLedColor(fStatusDNSLed, version==0 ? kLedRed : kLedGreen, Time());
|
|---|
| 768 |
|
|---|
| 769 | fStatusDNSLabel->setText(version==0?"Offline":str.str().c_str());
|
|---|
| 770 | fStatusDNSLabel->setToolTip(version==0?"No connection to DIM DNS.":"Connection to DIM DNS established.");
|
|---|
| 771 | }
|
|---|
| 772 |
|
|---|
| 773 |
|
|---|
| 774 | // ======================= Logger =======================================
|
|---|
| 775 |
|
|---|
| 776 | void handleLoggerStats(const DimData &d)
|
|---|
| 777 | {
|
|---|
| 778 | const bool connected = d.size()!=0;
|
|---|
| 779 |
|
|---|
| 780 | fLoggerET->setEnabled(connected);
|
|---|
| 781 | fLoggerRate->setEnabled(connected);
|
|---|
| 782 | fLoggerWritten->setEnabled(connected);
|
|---|
| 783 | fLoggerFreeSpace->setEnabled(connected);
|
|---|
| 784 | fLoggerSpaceLeft->setEnabled(connected);
|
|---|
| 785 |
|
|---|
| 786 | if (!connected)
|
|---|
| 787 | return;
|
|---|
| 788 |
|
|---|
| 789 | const uint64_t *vals = d.ptr<uint64_t>();
|
|---|
| 790 |
|
|---|
| 791 | const size_t written = vals[0];
|
|---|
| 792 | const size_t space = vals[1];
|
|---|
| 793 | const size_t rate = vals[2];
|
|---|
| 794 |
|
|---|
| 795 | fLoggerFreeSpace->setSuffix(" MB");
|
|---|
| 796 | fLoggerFreeSpace->setDecimals(0);
|
|---|
| 797 | fLoggerFreeSpace->setValue(space*1e-6);
|
|---|
| 798 |
|
|---|
| 799 | if (space> 1000000) // > 1GB
|
|---|
| 800 | {
|
|---|
| 801 | fLoggerFreeSpace->setSuffix(" GB");
|
|---|
| 802 | fLoggerFreeSpace->setDecimals(2);
|
|---|
| 803 | fLoggerFreeSpace->setValue(space*1e-9);
|
|---|
| 804 | }
|
|---|
| 805 | if (space>= 3000000) // >= 3GB
|
|---|
| 806 | {
|
|---|
| 807 | fLoggerFreeSpace->setSuffix(" GB");
|
|---|
| 808 | fLoggerFreeSpace->setDecimals(1);
|
|---|
| 809 | fLoggerFreeSpace->setValue(space*1e-9);
|
|---|
| 810 | }
|
|---|
| 811 | if (space>=100000000) // >= 100GB
|
|---|
| 812 | {
|
|---|
| 813 | fLoggerFreeSpace->setSuffix(" GB");
|
|---|
| 814 | fLoggerFreeSpace->setDecimals(0);
|
|---|
| 815 | fLoggerFreeSpace->setValue(space*1e-9);
|
|---|
| 816 | }
|
|---|
| 817 |
|
|---|
| 818 | fLoggerET->setTime(QTime().addSecs(rate>0?space/rate:0));
|
|---|
| 819 | fLoggerRate->setValue(rate*1e-3); // kB/s
|
|---|
| 820 | fLoggerWritten->setValue(written*1e-6);
|
|---|
| 821 |
|
|---|
| 822 | fLoggerRate->setSuffix(" kB/s");
|
|---|
| 823 | fLoggerRate->setDecimals(2);
|
|---|
| 824 | fLoggerRate->setValue(rate*1e-3);
|
|---|
| 825 | if (rate> 2000) // > 2kB/s
|
|---|
| 826 | {
|
|---|
| 827 | fLoggerRate->setSuffix(" kB/s");
|
|---|
| 828 | fLoggerRate->setDecimals(1);
|
|---|
| 829 | fLoggerRate->setValue(rate*1e-3);
|
|---|
| 830 | }
|
|---|
| 831 | if (rate>=100000) // >100kB/s
|
|---|
| 832 | {
|
|---|
| 833 | fLoggerRate->setSuffix(" kB/s");
|
|---|
| 834 | fLoggerRate->setDecimals(0);
|
|---|
| 835 | fLoggerRate->setValue(rate*1e-3);
|
|---|
| 836 | }
|
|---|
| 837 | if (rate>=1000000) // >100kB/s
|
|---|
| 838 | {
|
|---|
| 839 | fLoggerRate->setSuffix(" MB/s");
|
|---|
| 840 | fLoggerRate->setDecimals(2);
|
|---|
| 841 | fLoggerRate->setValue(rate*1e-6);
|
|---|
| 842 | }
|
|---|
| 843 | if (rate>=10000000) // >1MB/s
|
|---|
| 844 | {
|
|---|
| 845 | fLoggerRate->setSuffix(" MB/s");
|
|---|
| 846 | fLoggerRate->setDecimals(1);
|
|---|
| 847 | fLoggerRate->setValue(rate*1e-6);
|
|---|
| 848 | }
|
|---|
| 849 | if (rate>=100000000) // >10MB/s
|
|---|
| 850 | {
|
|---|
| 851 | fLoggerRate->setSuffix(" MB/s");
|
|---|
| 852 | fLoggerRate->setDecimals(0);
|
|---|
| 853 | fLoggerRate->setValue(rate*1e-6);
|
|---|
| 854 | }
|
|---|
| 855 |
|
|---|
| 856 | if (space/1000000>static_cast<size_t>(fLoggerSpaceLeft->maximum()))
|
|---|
| 857 | fLoggerSpaceLeft->setValue(fLoggerSpaceLeft->maximum()); // GB
|
|---|
| 858 | else
|
|---|
| 859 | fLoggerSpaceLeft->setValue(space/1000000); // MB
|
|---|
| 860 | }
|
|---|
| 861 |
|
|---|
| 862 | void handleLoggerFilenameNight(const DimData &d)
|
|---|
| 863 | {
|
|---|
| 864 | const bool connected = d.size()!=0;
|
|---|
| 865 |
|
|---|
| 866 | fLoggerFilenameNight->setEnabled(connected);
|
|---|
| 867 | if (!connected)
|
|---|
| 868 | return;
|
|---|
| 869 |
|
|---|
| 870 | fLoggerFilenameNight->setText(d.c_str()+4);
|
|---|
| 871 |
|
|---|
| 872 | const uint32_t files = d.get<uint32_t>();
|
|---|
| 873 |
|
|---|
| 874 | SetLedColor(fLoggerLedLog, files&1 ? kLedGreen : kLedGray, d.time);
|
|---|
| 875 | SetLedColor(fLoggerLedRep, files&2 ? kLedGreen : kLedGray, d.time);
|
|---|
| 876 | SetLedColor(fLoggerLedFits, files&4 ? kLedGreen : kLedGray, d.time);
|
|---|
| 877 | }
|
|---|
| 878 |
|
|---|
| 879 | void handleLoggerFilenameRun(const DimData &d)
|
|---|
| 880 | {
|
|---|
| 881 | const bool connected = d.size()!=0;
|
|---|
| 882 |
|
|---|
| 883 | fLoggerFilenameRun->setEnabled(connected);
|
|---|
| 884 | if (!connected)
|
|---|
| 885 | return;
|
|---|
| 886 |
|
|---|
| 887 | fLoggerFilenameRun->setText(d.c_str()+4);
|
|---|
| 888 |
|
|---|
| 889 | const uint32_t files = d.get<uint32_t>();
|
|---|
| 890 |
|
|---|
| 891 | SetLedColor(fLoggerLedLog, files&1 ? kLedGreen : kLedGray, d.time);
|
|---|
| 892 | SetLedColor(fLoggerLedRep, files&2 ? kLedGreen : kLedGray, d.time);
|
|---|
| 893 | SetLedColor(fLoggerLedFits, files&4 ? kLedGreen : kLedGray, d.time);
|
|---|
| 894 | }
|
|---|
| 895 |
|
|---|
| 896 | void handleLoggerNumSubs(const DimData &d)
|
|---|
| 897 | {
|
|---|
| 898 | const bool connected = d.size()!=0;
|
|---|
| 899 |
|
|---|
| 900 | fLoggerSubscriptions->setEnabled(connected);
|
|---|
| 901 | fLoggerOpenFiles->setEnabled(connected);
|
|---|
| 902 | if (!connected)
|
|---|
| 903 | return;
|
|---|
| 904 |
|
|---|
| 905 | const uint32_t *vals = d.ptr<uint32_t>();
|
|---|
| 906 |
|
|---|
| 907 | fLoggerSubscriptions->setValue(vals[0]);
|
|---|
| 908 | fLoggerOpenFiles->setValue(vals[1]);
|
|---|
| 909 | }
|
|---|
| 910 |
|
|---|
| 911 |
|
|---|
| 912 | // ===================== All ============================================
|
|---|
| 913 |
|
|---|
| 914 | bool CheckSize(const DimData &d, size_t sz) const
|
|---|
| 915 | {
|
|---|
| 916 | if (d.size()==0)
|
|---|
| 917 | return false;
|
|---|
| 918 |
|
|---|
| 919 | if (d.size()!=sz)
|
|---|
| 920 | {
|
|---|
| 921 | cout << "Size mismatch in " << d.name << ": Found=" << d.size() << " Expected=" << sz << endl;
|
|---|
| 922 | return false;
|
|---|
| 923 | }
|
|---|
| 924 |
|
|---|
| 925 | return true;
|
|---|
| 926 | }
|
|---|
| 927 |
|
|---|
| 928 | // ===================== FAD ============================================
|
|---|
| 929 |
|
|---|
| 930 | void handleFadFiles(const DimData &d)
|
|---|
| 931 | {
|
|---|
| 932 | if (!CheckSize(d, 8))
|
|---|
| 933 | return;
|
|---|
| 934 |
|
|---|
| 935 | fEvtBuilderOpenFiles->setValue(d.get<uint64_t>());
|
|---|
| 936 | }
|
|---|
| 937 |
|
|---|
| 938 | void handleFadRuns(const DimData &d)
|
|---|
| 939 | {
|
|---|
| 940 | if (!CheckSize(d, 4))
|
|---|
| 941 | return;
|
|---|
| 942 |
|
|---|
| 943 | fEvtsRunMax->setValue(d.get<uint32_t>());
|
|---|
| 944 | }
|
|---|
| 945 |
|
|---|
| 946 | void handleFadEvents(const DimData &d)
|
|---|
| 947 | {
|
|---|
| 948 | if (!CheckSize(d, 8))
|
|---|
| 949 | return;
|
|---|
| 950 |
|
|---|
| 951 | const uint32_t *ptr = d.ptr<uint32_t>();
|
|---|
| 952 |
|
|---|
| 953 | fEvtsSuccessCurRun->setValue(ptr[0]);
|
|---|
| 954 | fEvtsSuccessTotal->setValue(ptr[1]);
|
|---|
| 955 | }
|
|---|
| 956 |
|
|---|
| 957 | void handleFadCurrentEvent(const DimData &d)
|
|---|
| 958 | {
|
|---|
| 959 | if (!CheckSize(d, 4))
|
|---|
| 960 | return;
|
|---|
| 961 |
|
|---|
| 962 | fEvtsTriggerId->setValue(d.get<uint32_t>());
|
|---|
| 963 | }
|
|---|
| 964 |
|
|---|
| 965 | struct DimEventData
|
|---|
| 966 | {
|
|---|
| 967 | uint16_t Roi ; // #slices per pixel (same for all pixels and tmarks)
|
|---|
| 968 | uint32_t EventNum ; // EventNumber as from FTM
|
|---|
| 969 | uint16_t TriggerType ; // Trigger Type from FTM
|
|---|
| 970 |
|
|---|
| 971 | uint32_t PCTime ; // when did event start to arrive at PC
|
|---|
| 972 | uint32_t BoardTime; //
|
|---|
| 973 |
|
|---|
| 974 | int16_t StartPix; // First Channel per Pixel (Pixels sorted according Software ID) ; -1 if not filled
|
|---|
| 975 | int16_t StartTM; // First Channel for TimeMark (sorted Hardware ID) ; -1 if not filled
|
|---|
| 976 |
|
|---|
| 977 | uint16_t Adc_Data[]; // final length defined by malloc ....
|
|---|
| 978 |
|
|---|
| 979 | } __attribute__((__packed__));;
|
|---|
| 980 |
|
|---|
| 981 | void handleFadEventData(const DimData &d)
|
|---|
| 982 | {
|
|---|
| 983 | if (d.size()==0)
|
|---|
| 984 | return;
|
|---|
| 985 |
|
|---|
| 986 | #ifdef HAVE_ROOT
|
|---|
| 987 | const DimEventData &dat = d.ref<DimEventData>();
|
|---|
| 988 |
|
|---|
| 989 | if (d.size()<sizeof(DimEventData))
|
|---|
| 990 | {
|
|---|
| 991 | cout << "Size mismatch in " << d.name << ": Found=" << d.size() << " Expected=" << sizeof(DimEventData) << endl;
|
|---|
| 992 | return;
|
|---|
| 993 | }
|
|---|
| 994 |
|
|---|
| 995 | if (d.size()!=dat.Roi*2+sizeof(DimEventData))
|
|---|
| 996 | {
|
|---|
| 997 | cout << "Size mismatch in " << d.name << ": Found=" << d.size() << " Expected=" << dat.Roi*2+sizeof(DimEventData) << endl;
|
|---|
| 998 | return;
|
|---|
| 999 | }
|
|---|
| 1000 |
|
|---|
| 1001 | TCanvas *c = fAdcDataCanv->GetCanvas();
|
|---|
| 1002 |
|
|---|
| 1003 | TH1 *h = dynamic_cast<TH1*>(c->FindObject("EventData"));
|
|---|
| 1004 | if (h && h->GetNbinsX()!=dat.Roi)
|
|---|
| 1005 | {
|
|---|
| 1006 | delete h;
|
|---|
| 1007 | h = 0;
|
|---|
| 1008 | }
|
|---|
| 1009 |
|
|---|
| 1010 | if (!h)
|
|---|
| 1011 | {
|
|---|
| 1012 | c->cd();
|
|---|
| 1013 |
|
|---|
| 1014 | TH1D hist("EventData", "", dat.Roi, -0.5, dat.Roi-0.5);
|
|---|
| 1015 | hist.SetStats(kFALSE);
|
|---|
| 1016 | //hist->SetBit(TH1::kNoTitle);
|
|---|
| 1017 | hist.SetMarkerStyle(kFullDotMedium);
|
|---|
| 1018 | hist.SetYTitle("Voltage [mV]");
|
|---|
| 1019 | hist.GetXaxis()->CenterTitle();
|
|---|
| 1020 | hist.GetYaxis()->CenterTitle();
|
|---|
| 1021 | hist.SetMinimum(-1025);
|
|---|
| 1022 | hist.SetMaximum(1025);
|
|---|
| 1023 | h = hist.DrawCopy("P");
|
|---|
| 1024 | h->SetDirectory(0);
|
|---|
| 1025 |
|
|---|
| 1026 | }
|
|---|
| 1027 |
|
|---|
| 1028 | ostringstream str;
|
|---|
| 1029 | str << "ADC Pipeline (start=" << dat.StartTM << ")";
|
|---|
| 1030 | h->SetXTitle(str.str().c_str());
|
|---|
| 1031 |
|
|---|
| 1032 | //str.str("");
|
|---|
| 1033 | //str << "Crate=" << crate << " Board=" << board << " Channel=" << channel << " [" << d.time() << "]" << endl;
|
|---|
| 1034 | //hist->SetTitle(str.str().c_str());
|
|---|
| 1035 |
|
|---|
| 1036 | for (int i=0; i<dat.Roi; i++)
|
|---|
| 1037 | h->SetBinContent(i+1, dat.Adc_Data[i]-1024);
|
|---|
| 1038 |
|
|---|
| 1039 | c->Modified();
|
|---|
| 1040 | c->Update();
|
|---|
| 1041 | #endif
|
|---|
| 1042 | }
|
|---|
| 1043 |
|
|---|
| 1044 | vector<uint8_t> fFadConnections;
|
|---|
| 1045 |
|
|---|
| 1046 | void handleFadConnections(const DimData &d)
|
|---|
| 1047 | {
|
|---|
| 1048 | if (!CheckSize(d, 41))
|
|---|
| 1049 | return;
|
|---|
| 1050 |
|
|---|
| 1051 | const uint8_t *ptr = d.ptr<uint8_t>();
|
|---|
| 1052 |
|
|---|
| 1053 | for (int i=0; i<40; i++)
|
|---|
| 1054 | {
|
|---|
| 1055 | switch (ptr[i])
|
|---|
| 1056 | {
|
|---|
| 1057 | case 0: SetLedColor(fFadLED[i], kLedGray, d.time); break;
|
|---|
| 1058 | case 9: SetLedColor(fFadLED[i], kLedGreen, d.time); break;
|
|---|
| 1059 | default: SetLedColor(fFadLED[i], kLedOrange, d.time);
|
|---|
| 1060 | }
|
|---|
| 1061 | }
|
|---|
| 1062 |
|
|---|
| 1063 | SetLedColor(fFadLEDEventBuilder, ptr[40]==0?kLedRed:kLedGreen, d.time);
|
|---|
| 1064 |
|
|---|
| 1065 | fFadConnections.assign(ptr, ptr+40);
|
|---|
| 1066 | }
|
|---|
| 1067 |
|
|---|
| 1068 | template<typename T>
|
|---|
| 1069 | bool CheckConsistency(const T *v)
|
|---|
| 1070 | {
|
|---|
| 1071 | for (int i=1; i<40; i++)
|
|---|
| 1072 | if (fFadConnections[i]==9 && v[i]!=v[0])
|
|---|
| 1073 | return false;
|
|---|
| 1074 |
|
|---|
| 1075 | return true;
|
|---|
| 1076 | }
|
|---|
| 1077 |
|
|---|
| 1078 | template<typename T>
|
|---|
| 1079 | T GetFirst(const T *v)
|
|---|
| 1080 | {
|
|---|
| 1081 | for (int i=0; i<40; i++)
|
|---|
| 1082 | if (fFadConnections[i]==9)
|
|---|
| 1083 | return v[i];
|
|---|
| 1084 |
|
|---|
| 1085 | return T();
|
|---|
| 1086 | }
|
|---|
| 1087 |
|
|---|
| 1088 | void handleFadFwVersion(const DimData &d)
|
|---|
| 1089 | {
|
|---|
| 1090 | if (!CheckSize(d, 40*sizeof(float)))
|
|---|
| 1091 | return;
|
|---|
| 1092 |
|
|---|
| 1093 | const float *ptr = d.ptr<float>();
|
|---|
| 1094 | fFadFwVersion->setValue(GetFirst(ptr));
|
|---|
| 1095 |
|
|---|
| 1096 | ostringstream tip;
|
|---|
| 1097 | tip << "<table border='1'><tr><th colspan='11'>" << Time().GetAsStr() << "</th></tr><tr><th></th>";
|
|---|
| 1098 | for (int b=0; b<10; b++)
|
|---|
| 1099 | tip << "<th>" << b << "</th>";
|
|---|
| 1100 | tip << "</tr>";
|
|---|
| 1101 |
|
|---|
| 1102 | for (int c=0; c<4; c++)
|
|---|
| 1103 | {
|
|---|
| 1104 | tip << "<tr><th>" << c << "</th>";
|
|---|
| 1105 | for (int b=0; b<10; b++)
|
|---|
| 1106 | tip << "<td>" << ptr[c*10+b] << "</td>";
|
|---|
| 1107 | tip << "</tr>";
|
|---|
| 1108 | }
|
|---|
| 1109 | tip << "</table>";
|
|---|
| 1110 |
|
|---|
| 1111 | fFadFwVersion->setToolTip(tip.str().c_str());
|
|---|
| 1112 | }
|
|---|
| 1113 |
|
|---|
| 1114 | void handleFadStatistics(const DimData &d)
|
|---|
| 1115 | {
|
|---|
| 1116 | if (!CheckSize(d, 8*sizeof(int64_t)))
|
|---|
| 1117 | return;
|
|---|
| 1118 |
|
|---|
| 1119 | const int64_t *stat = d.ptr<int64_t>();
|
|---|
| 1120 |
|
|---|
| 1121 | cout << stat[0] << " " << stat[0]/1000000 << endl;
|
|---|
| 1122 |
|
|---|
| 1123 | fFadBufferMax->setValue(stat[0]/1000000);
|
|---|
| 1124 | fFadBuffer->setMaximum(stat[0]);
|
|---|
| 1125 | fFadBuffer->setValue(stat[5]);
|
|---|
| 1126 |
|
|---|
| 1127 | fFadEvtWait->setValue(stat[1]);
|
|---|
| 1128 | fFadEvtSkip->setValue(stat[2]);
|
|---|
| 1129 | fFadEvtDel->setValue(stat[3]);
|
|---|
| 1130 | fFadEvtTot->setValue(stat[4]);
|
|---|
| 1131 | fFadEvtRead->setValue(stat[6]);
|
|---|
| 1132 | fFadEvtConn->setValue(stat[7]);
|
|---|
| 1133 | }
|
|---|
| 1134 |
|
|---|
| 1135 |
|
|---|
| 1136 | // ===================== FTM ============================================
|
|---|
| 1137 |
|
|---|
| 1138 | double fTimeStamp1;
|
|---|
| 1139 |
|
|---|
| 1140 | void handleFtmTriggerCounter(const DimData &d)
|
|---|
| 1141 | {
|
|---|
| 1142 | if (!CheckSize(d, sizeof(FTM::DimTriggerCounter)))
|
|---|
| 1143 | return;
|
|---|
| 1144 |
|
|---|
| 1145 | const FTM::DimTriggerCounter &sdata = d.ref<FTM::DimTriggerCounter>();
|
|---|
| 1146 |
|
|---|
| 1147 | fFtmTime->setText(QString::number(sdata.fTimeStamp/1000000., 'f', 6)+ " s");
|
|---|
| 1148 | fTriggerCounter->setText(QString::number(sdata.fTriggerCounter));
|
|---|
| 1149 |
|
|---|
| 1150 | if (sdata.fTimeStamp>0)
|
|---|
| 1151 | fTriggerCounterRate->setValue(1000000.*sdata.fTriggerCounter/sdata.fTimeStamp);
|
|---|
| 1152 | else
|
|---|
| 1153 | fTriggerCounterRate->setValue(0);
|
|---|
| 1154 |
|
|---|
| 1155 |
|
|---|
| 1156 | // ----------------------------------------------
|
|---|
| 1157 | #ifdef HAVE_ROOT
|
|---|
| 1158 |
|
|---|
| 1159 | if (fTriggerCounter0<0)
|
|---|
| 1160 | {
|
|---|
| 1161 | fTriggerCounter0 = sdata.fTriggerCounter;
|
|---|
| 1162 | fTimeStamp1 = sdata.fTimeStamp;
|
|---|
| 1163 | return;
|
|---|
| 1164 | }
|
|---|
| 1165 |
|
|---|
| 1166 | TCanvas *c = fFtmRateCanv->GetCanvas();
|
|---|
| 1167 |
|
|---|
| 1168 | TH1 *h = (TH1*)c->FindObject("TimeFrame");
|
|---|
| 1169 |
|
|---|
| 1170 | const double rate = sdata.fTriggerCounter-fTriggerCounter0;
|
|---|
| 1171 | const double tdiff = sdata.fTimeStamp -fTimeStamp1;
|
|---|
| 1172 |
|
|---|
| 1173 | fTriggerCounter0 = sdata.fTriggerCounter;
|
|---|
| 1174 | fTimeStamp1 = sdata.fTimeStamp;
|
|---|
| 1175 |
|
|---|
| 1176 | if (rate<0 && tdiff<=0)
|
|---|
| 1177 | {
|
|---|
| 1178 | fGraphFtmRate.Set(0);
|
|---|
| 1179 |
|
|---|
| 1180 | const double tm = Time().RootTime();
|
|---|
| 1181 |
|
|---|
| 1182 | h->SetBins(1, tm, tm+60);
|
|---|
| 1183 | h->GetXaxis()->SetTimeFormat("%M'%S\"");
|
|---|
| 1184 | h->GetXaxis()->SetTitle("Time");
|
|---|
| 1185 |
|
|---|
| 1186 | c->Modified();
|
|---|
| 1187 | c->Update();
|
|---|
| 1188 | return;
|
|---|
| 1189 | }
|
|---|
| 1190 |
|
|---|
| 1191 | if (rate<0)
|
|---|
| 1192 | return;
|
|---|
| 1193 |
|
|---|
| 1194 | // const double avgrate = sdata.fTimeStamp>0 ? double(sdata.fTriggerCounter)/sdata.fTimeStamp*1000000 : 1;
|
|---|
| 1195 |
|
|---|
| 1196 | const double t1 = h->GetXaxis()->GetXmax();
|
|---|
| 1197 | const double t0 = h->GetXaxis()->GetXmin();
|
|---|
| 1198 |
|
|---|
| 1199 | h->SetBins(h->GetNbinsX()+1, t0, t0+sdata.fTimeStamp/1000000.+1);
|
|---|
| 1200 | fGraphFtmRate.SetPoint(fGraphFtmRate.GetN(),
|
|---|
| 1201 | t0+sdata.fTimeStamp/1000000., 1000000*rate/tdiff);
|
|---|
| 1202 |
|
|---|
| 1203 | if (t1-t0>60)
|
|---|
| 1204 | {
|
|---|
| 1205 | h->GetXaxis()->SetTimeFormat("%Hh%M'");
|
|---|
| 1206 | h->GetXaxis()->SetTitle("Time");
|
|---|
| 1207 | }
|
|---|
| 1208 |
|
|---|
| 1209 | h->SetMinimum(0);
|
|---|
| 1210 | // h->SetMaximum(2*avgrate);
|
|---|
| 1211 |
|
|---|
| 1212 | c->Modified();
|
|---|
| 1213 | c->Update();
|
|---|
| 1214 | #endif
|
|---|
| 1215 | // ----------------------------------------------
|
|---|
| 1216 | }
|
|---|
| 1217 |
|
|---|
| 1218 | void handleFtmCounter(const DimData &d)
|
|---|
| 1219 | {
|
|---|
| 1220 | if (!CheckSize(d, sizeof(uint32_t)*6))
|
|---|
| 1221 | return;
|
|---|
| 1222 |
|
|---|
| 1223 | const uint32_t *sdata = d.ptr<uint32_t>();
|
|---|
| 1224 |
|
|---|
| 1225 | fFtmCounterH->setValue(sdata[0]);
|
|---|
| 1226 | fFtmCounterS->setValue(sdata[1]);
|
|---|
| 1227 | fFtmCounterD->setValue(sdata[2]);
|
|---|
| 1228 | fFtmCounterF->setValue(sdata[3]);
|
|---|
| 1229 | fFtmCounterE->setValue(sdata[4]);
|
|---|
| 1230 | fFtmCounterR->setValue(sdata[5]);
|
|---|
| 1231 | }
|
|---|
| 1232 |
|
|---|
| 1233 | int64_t fTriggerCounter0;
|
|---|
| 1234 | int64_t fTimeStamp0;
|
|---|
| 1235 |
|
|---|
| 1236 | void handleFtmDynamicData(const DimData &d)
|
|---|
| 1237 | {
|
|---|
| 1238 | if (!CheckSize(d, sizeof(FTM::DimDynamicData)))
|
|---|
| 1239 | return;
|
|---|
| 1240 |
|
|---|
| 1241 | const FTM::DimDynamicData &sdata = d.ref<FTM::DimDynamicData>();
|
|---|
| 1242 |
|
|---|
| 1243 | fOnTime->setText(QString::number(sdata.fOnTimeCounter/1000000., 'f', 6)+" s");
|
|---|
| 1244 |
|
|---|
| 1245 | if (sdata.fTimeStamp>0)
|
|---|
| 1246 | fOnTimeRel->setValue(100.*sdata.fOnTimeCounter/sdata.fTimeStamp);
|
|---|
| 1247 | else
|
|---|
| 1248 | fOnTimeRel->setValue(0);
|
|---|
| 1249 |
|
|---|
| 1250 | fFtmTemp0->setValue(sdata.fTempSensor[0]*0.1);
|
|---|
| 1251 | fFtmTemp1->setValue(sdata.fTempSensor[1]*0.1);
|
|---|
| 1252 | fFtmTemp2->setValue(sdata.fTempSensor[2]*0.1);
|
|---|
| 1253 | fFtmTemp3->setValue(sdata.fTempSensor[3]*0.1);
|
|---|
| 1254 |
|
|---|
| 1255 |
|
|---|
| 1256 | #ifdef HAVE_ROOT
|
|---|
| 1257 |
|
|---|
| 1258 | // ----------------------------------------------
|
|---|
| 1259 |
|
|---|
| 1260 | if (fTimeStamp0<0)
|
|---|
| 1261 | {
|
|---|
| 1262 | fTimeStamp0 = sdata.fTimeStamp;
|
|---|
| 1263 | return;
|
|---|
| 1264 | }
|
|---|
| 1265 |
|
|---|
| 1266 | TCanvas *c = fFtmRateCanv->GetCanvas();
|
|---|
| 1267 |
|
|---|
| 1268 | TH1 *h = (TH1*)c->FindObject("TimeFrame");
|
|---|
| 1269 |
|
|---|
| 1270 | const double tdiff = sdata.fTimeStamp-fTimeStamp0;
|
|---|
| 1271 | fTimeStamp0 = sdata.fTimeStamp;
|
|---|
| 1272 |
|
|---|
| 1273 | if (tdiff<0)
|
|---|
| 1274 | {
|
|---|
| 1275 | for (int i=0; i<160; i++)
|
|---|
| 1276 | fGraphPatchRate[i].Set(0);
|
|---|
| 1277 | for (int i=0; i<40; i++)
|
|---|
| 1278 | fGraphBoardRate[i].Set(0);
|
|---|
| 1279 |
|
|---|
| 1280 | return;
|
|---|
| 1281 | }
|
|---|
| 1282 |
|
|---|
| 1283 | //const double t1 = h->GetXaxis()->GetXmax();
|
|---|
| 1284 | const double t0 = h->GetXaxis()->GetXmin();
|
|---|
| 1285 |
|
|---|
| 1286 | for (int i=0; i<160; i++)
|
|---|
| 1287 | fGraphPatchRate[i].SetPoint(fGraphPatchRate[i].GetN(),
|
|---|
| 1288 | t0+sdata.fTimeStamp/1000000., float(sdata.fRatePatch[i])*2/fFtmStaticData.fPrescaling[i]);
|
|---|
| 1289 | for (int i=0; i<40; i++)
|
|---|
| 1290 | fGraphBoardRate[i].SetPoint(fGraphBoardRate[i].GetN(),
|
|---|
| 1291 | t0+sdata.fTimeStamp/1000000., float(sdata.fRateBoard[i])*2/fFtmStaticData.fPrescaling[i]);
|
|---|
| 1292 |
|
|---|
| 1293 | c->Modified();
|
|---|
| 1294 | c->Update();
|
|---|
| 1295 |
|
|---|
| 1296 | //fGraphFtmRate.ComputeRange(x[0], x[1], x[2], x[3]);
|
|---|
| 1297 |
|
|---|
| 1298 | // ----------------------------------------------
|
|---|
| 1299 |
|
|---|
| 1300 | if (fThresholdIdx->value()>=0)
|
|---|
| 1301 | {
|
|---|
| 1302 | const int isw = fThresholdIdx->value();
|
|---|
| 1303 | const int ihw = fPatchMapHW[isw];
|
|---|
| 1304 | fPatchRate->setValue(sdata.fRatePatch[ihw]);
|
|---|
| 1305 | }
|
|---|
| 1306 |
|
|---|
| 1307 | valarray<double> dat(0., 1440);
|
|---|
| 1308 |
|
|---|
| 1309 | // fPatch converts from software id to software patch id
|
|---|
| 1310 | for (int i=0; i<1440; i++)
|
|---|
| 1311 | {
|
|---|
| 1312 | const int ihw = fPatchHW[i];
|
|---|
| 1313 | // const int isw = fPatch[i];
|
|---|
| 1314 | // const int ihw = fPatchMapHW[isw];
|
|---|
| 1315 | dat[i] = sdata.fRatePatch[ihw];
|
|---|
| 1316 | }
|
|---|
| 1317 |
|
|---|
| 1318 | c = fRatesCanv->GetCanvas();
|
|---|
| 1319 | Camera *cam = (Camera*)c->FindObject("Camera");
|
|---|
| 1320 |
|
|---|
| 1321 | cam->SetData(dat);
|
|---|
| 1322 |
|
|---|
| 1323 | c->Modified();
|
|---|
| 1324 | c->Update();
|
|---|
| 1325 |
|
|---|
| 1326 | // ----------------------------------------------
|
|---|
| 1327 | #endif
|
|---|
| 1328 | }
|
|---|
| 1329 |
|
|---|
| 1330 | void DisplayRates()
|
|---|
| 1331 | {
|
|---|
| 1332 | #ifdef HAVE_ROOT
|
|---|
| 1333 | TCanvas *c = fFtmRateCanv->GetCanvas();
|
|---|
| 1334 |
|
|---|
| 1335 | while (c->FindObject("PatchRate"))
|
|---|
| 1336 | c->GetListOfPrimitives()->Remove(c->FindObject("PatchRate"));
|
|---|
| 1337 |
|
|---|
| 1338 | while (c->FindObject("BoardRate"))
|
|---|
| 1339 | c->GetListOfPrimitives()->Remove(c->FindObject("BoardRate"));
|
|---|
| 1340 |
|
|---|
| 1341 | c->cd();
|
|---|
| 1342 |
|
|---|
| 1343 | if (fRatePatch1->value()>=0)
|
|---|
| 1344 | {
|
|---|
| 1345 | fGraphPatchRate[fRatePatch1->value()].SetLineColor(kRed);
|
|---|
| 1346 | fGraphPatchRate[fRatePatch1->value()].SetMarkerColor(kRed);
|
|---|
| 1347 | fGraphPatchRate[fRatePatch1->value()].Draw("PL");
|
|---|
| 1348 | }
|
|---|
| 1349 | if (fRatePatch2->value()>=0)
|
|---|
| 1350 | {
|
|---|
| 1351 | fGraphPatchRate[fRatePatch2->value()].SetLineColor(kGreen);
|
|---|
| 1352 | fGraphPatchRate[fRatePatch2->value()].SetMarkerColor(kGreen);
|
|---|
| 1353 | fGraphPatchRate[fRatePatch2->value()].Draw("PL");
|
|---|
| 1354 | }
|
|---|
| 1355 | if (fRateBoard1->value()>=0)
|
|---|
| 1356 | {
|
|---|
| 1357 | fGraphBoardRate[fRateBoard1->value()].SetLineColor(kMagenta);
|
|---|
| 1358 | fGraphBoardRate[fRateBoard1->value()].SetMarkerColor(kMagenta);
|
|---|
| 1359 | fGraphBoardRate[fRateBoard1->value()].Draw("PL");
|
|---|
| 1360 | }
|
|---|
| 1361 | if (fRateBoard2->value()>=0)
|
|---|
| 1362 | {
|
|---|
| 1363 | fGraphBoardRate[fRateBoard2->value()].SetLineColor(kCyan);
|
|---|
| 1364 | fGraphBoardRate[fRateBoard2->value()].SetMarkerColor(kCyan);
|
|---|
| 1365 | fGraphBoardRate[fRateBoard2->value()].Draw("PL");
|
|---|
| 1366 | }
|
|---|
| 1367 | #endif
|
|---|
| 1368 | }
|
|---|
| 1369 |
|
|---|
| 1370 | void on_fRatePatch1_valueChanged(int)
|
|---|
| 1371 | {
|
|---|
| 1372 | DisplayRates();
|
|---|
| 1373 | }
|
|---|
| 1374 |
|
|---|
| 1375 | void on_fRatePatch2_valueChanged(int)
|
|---|
| 1376 | {
|
|---|
| 1377 | DisplayRates();
|
|---|
| 1378 | }
|
|---|
| 1379 |
|
|---|
| 1380 | void on_fRateBoard1_valueChanged(int)
|
|---|
| 1381 | {
|
|---|
| 1382 | DisplayRates();
|
|---|
| 1383 | }
|
|---|
| 1384 |
|
|---|
| 1385 | void on_fRateBoard2_valueChanged(int)
|
|---|
| 1386 | {
|
|---|
| 1387 | DisplayRates();
|
|---|
| 1388 | }
|
|---|
| 1389 |
|
|---|
| 1390 | FTM::DimStaticData fFtmStaticData;
|
|---|
| 1391 |
|
|---|
| 1392 | void SetFtuLed(int idx, int counter, const Time &t)
|
|---|
| 1393 | {
|
|---|
| 1394 | if (counter==0 || counter>3)
|
|---|
| 1395 | counter = 3;
|
|---|
| 1396 |
|
|---|
| 1397 | if (counter<0)
|
|---|
| 1398 | counter = 0;
|
|---|
| 1399 |
|
|---|
| 1400 | const LedColor_t col[4] = { kLedGray, kLedGreen, kLedOrange, kLedRed };
|
|---|
| 1401 |
|
|---|
| 1402 | SetLedColor(fFtuLED[idx], col[counter], t);
|
|---|
| 1403 |
|
|---|
| 1404 | fFtuStatus[idx] = counter;
|
|---|
| 1405 | }
|
|---|
| 1406 |
|
|---|
| 1407 | void SetFtuStatusLed(const Time &t)
|
|---|
| 1408 | {
|
|---|
| 1409 | const int max = fFtuStatus.max();
|
|---|
| 1410 |
|
|---|
| 1411 | switch (max)
|
|---|
| 1412 | {
|
|---|
| 1413 | case 0:
|
|---|
| 1414 | SetLedColor(fStatusFTULed, kLedGray, t);
|
|---|
| 1415 | fStatusFTULabel->setText("All disabled");
|
|---|
| 1416 | fStatusFTULabel->setToolTip("All FTUs are disabled");
|
|---|
| 1417 | break;
|
|---|
| 1418 |
|
|---|
| 1419 | case 1:
|
|---|
| 1420 | SetLedColor(fStatusFTULed, kLedGreen, t);
|
|---|
| 1421 | fStatusFTULabel->setToolTip("Communication with FTU is smooth.");
|
|---|
| 1422 | fStatusFTULabel->setText("ok");
|
|---|
| 1423 | break;
|
|---|
| 1424 |
|
|---|
| 1425 | case 2:
|
|---|
| 1426 | SetLedColor(fStatusFTULed, kLedOrange, t);
|
|---|
| 1427 | fStatusFTULabel->setText("Warning");
|
|---|
| 1428 | fStatusFTULabel->setToolTip("At least one FTU didn't answer immediately");
|
|---|
| 1429 | break;
|
|---|
| 1430 |
|
|---|
| 1431 | case 3:
|
|---|
| 1432 | SetLedColor(fStatusFTULed, kLedRed, t);
|
|---|
| 1433 | fStatusFTULabel->setToolTip("At least one FTU didn't answer!");
|
|---|
| 1434 | fStatusFTULabel->setText("ERROR");
|
|---|
| 1435 | break;
|
|---|
| 1436 | }
|
|---|
| 1437 |
|
|---|
| 1438 | const int cnt = count(&fFtuStatus[0], &fFtuStatus[40], 0);
|
|---|
| 1439 | fFtuAllOn->setEnabled(cnt!=0);
|
|---|
| 1440 | fFtuAllOff->setEnabled(cnt!=40);
|
|---|
| 1441 | }
|
|---|
| 1442 |
|
|---|
| 1443 | void handleFtmStaticData(const DimData &d)
|
|---|
| 1444 | {
|
|---|
| 1445 | if (!CheckSize(d, sizeof(FTM::DimStaticData)))
|
|---|
| 1446 | return;
|
|---|
| 1447 |
|
|---|
| 1448 | const FTM::DimStaticData &sdata = d.ref<FTM::DimStaticData>();
|
|---|
| 1449 |
|
|---|
| 1450 | fTriggerInterval->setValue(sdata.fTriggerInterval);
|
|---|
| 1451 | fPhysicsCoincidence->setValue(sdata.fMultiplicityPhysics);
|
|---|
| 1452 | fCalibCoincidence->setValue(sdata.fMultiplicityCalib);
|
|---|
| 1453 | fPhysicsWindow->setValue(sdata.fWindowPhysics);
|
|---|
| 1454 | fCalibWindow->setValue(sdata.fWindowCalib);
|
|---|
| 1455 |
|
|---|
| 1456 | fTriggerDelay->setValue(sdata.fDelayTrigger);
|
|---|
| 1457 | fTimeMarkerDelay->setValue(sdata.fDelayTimeMarker);
|
|---|
| 1458 | fDeadTime->setValue(sdata.fDeadTime);
|
|---|
| 1459 |
|
|---|
| 1460 | fClockCondR0->setValue(sdata.fClockConditioner[0]);
|
|---|
| 1461 | fClockCondR1->setValue(sdata.fClockConditioner[1]);
|
|---|
| 1462 | fClockCondR8->setValue(sdata.fClockConditioner[2]);
|
|---|
| 1463 | fClockCondR9->setValue(sdata.fClockConditioner[3]);
|
|---|
| 1464 | fClockCondR11->setValue(sdata.fClockConditioner[4]);
|
|---|
| 1465 | fClockCondR13->setValue(sdata.fClockConditioner[5]);
|
|---|
| 1466 | fClockCondR14->setValue(sdata.fClockConditioner[6]);
|
|---|
| 1467 | fClockCondR15->setValue(sdata.fClockConditioner[7]);
|
|---|
| 1468 |
|
|---|
| 1469 | //fClockCondFreq->setEditText("");
|
|---|
| 1470 | fClockCondFreq->setCurrentIndex(0);
|
|---|
| 1471 |
|
|---|
| 1472 | fTriggerSeqPed->setValue(sdata.fTriggerSeqPed);
|
|---|
| 1473 | fTriggerSeqLPint->setValue(sdata.fTriggerSeqLPint);
|
|---|
| 1474 | fTriggerSeqLPext->setValue(sdata.fTriggerSeqLPext);
|
|---|
| 1475 |
|
|---|
| 1476 | fEnableTrigger->setChecked(sdata.HasTrigger());
|
|---|
| 1477 | fEnableVeto->setChecked(sdata.HasVeto());
|
|---|
| 1478 | fEnableExt1->setChecked(sdata.HasExt1());
|
|---|
| 1479 | fEnableExt2->setChecked(sdata.HasExt2());
|
|---|
| 1480 | fEnableClockCond->setChecked(sdata.HasClockConditioner());
|
|---|
| 1481 |
|
|---|
| 1482 | for (int i=0; i<40; i++)
|
|---|
| 1483 | {
|
|---|
| 1484 | if (!sdata.IsActive(i))
|
|---|
| 1485 | SetFtuLed(i, -1, d.time);
|
|---|
| 1486 | else
|
|---|
| 1487 | {
|
|---|
| 1488 | if (fFtuStatus[i]==0)
|
|---|
| 1489 | SetFtuLed(i, 1, d.time);
|
|---|
| 1490 | }
|
|---|
| 1491 | fFtuLED[i]->setChecked(false);
|
|---|
| 1492 | }
|
|---|
| 1493 | SetFtuStatusLed(d.time);
|
|---|
| 1494 |
|
|---|
| 1495 | #ifdef HAVE_ROOT
|
|---|
| 1496 | Camera *cam = (Camera*)fRatesCanv->GetCanvas()->FindObject("Camera");
|
|---|
| 1497 | for (int isw=0; isw<1440; isw++)
|
|---|
| 1498 | {
|
|---|
| 1499 | const int ihw = fPixelMapHW[isw];
|
|---|
| 1500 | cam->SetEnable(isw, sdata.IsEnabled(ihw));
|
|---|
| 1501 | }
|
|---|
| 1502 |
|
|---|
| 1503 | fRatesCanv->GetCanvas()->Modified();
|
|---|
| 1504 | fRatesCanv->GetCanvas()->Update();
|
|---|
| 1505 | #endif
|
|---|
| 1506 |
|
|---|
| 1507 | {
|
|---|
| 1508 | const int isw = fPixelIdx->value();
|
|---|
| 1509 | const int ihw = fPixelMapHW[isw];
|
|---|
| 1510 | const bool on = sdata.IsEnabled(ihw);
|
|---|
| 1511 | fPixelEnable->setChecked(on);
|
|---|
| 1512 | }
|
|---|
| 1513 |
|
|---|
| 1514 | if (fThresholdIdx->value()>=0)
|
|---|
| 1515 | {
|
|---|
| 1516 | const int isw = fThresholdIdx->value();
|
|---|
| 1517 | const int ihw = fPatchMapHW[isw];
|
|---|
| 1518 | fThresholdVal->setValue(sdata.fThreshold[ihw]);
|
|---|
| 1519 | }
|
|---|
| 1520 |
|
|---|
| 1521 | fPrescalingVal->setValue(sdata.fPrescaling[0]);
|
|---|
| 1522 |
|
|---|
| 1523 | fFtmStaticData = sdata;
|
|---|
| 1524 | }
|
|---|
| 1525 |
|
|---|
| 1526 | void handleFtmPassport(const DimData &d)
|
|---|
| 1527 | {
|
|---|
| 1528 | if (!CheckSize(d, sizeof(FTM::DimPassport)))
|
|---|
| 1529 | return;
|
|---|
| 1530 |
|
|---|
| 1531 | const FTM::DimPassport &sdata = d.ref<FTM::DimPassport>();
|
|---|
| 1532 |
|
|---|
| 1533 | stringstream str1, str2;
|
|---|
| 1534 | str1 << hex << "0x" << setfill('0') << setw(16) << sdata.fBoardId;
|
|---|
| 1535 | str2 << sdata.fFirmwareId;
|
|---|
| 1536 |
|
|---|
| 1537 | fFtmBoardId->setText(str1.str().c_str());
|
|---|
| 1538 | fFtmFirmwareId->setText(str2.str().c_str());
|
|---|
| 1539 | }
|
|---|
| 1540 |
|
|---|
| 1541 | void handleFtmFtuList(const DimData &d)
|
|---|
| 1542 | {
|
|---|
| 1543 | if (!CheckSize(d, sizeof(FTM::DimFtuList)))
|
|---|
| 1544 | return;
|
|---|
| 1545 |
|
|---|
| 1546 | fFtuPing->setChecked(false);
|
|---|
| 1547 |
|
|---|
| 1548 | const FTM::DimFtuList &sdata = d.ref<FTM::DimFtuList>();
|
|---|
| 1549 |
|
|---|
| 1550 | stringstream str;
|
|---|
| 1551 | str << "<table width='100%'>" << setfill('0');
|
|---|
| 1552 | str << "<tr><th>Num</th><th></th><th>Addr</th><th></th><th>DNA</th></tr>";
|
|---|
| 1553 | for (int i=0; i<40; i++)
|
|---|
| 1554 | {
|
|---|
| 1555 | str << "<tr>";
|
|---|
| 1556 | str << "<td align='center'>" << dec << i << hex << "</td>";
|
|---|
| 1557 | str << "<td align='center'>:</td>";
|
|---|
| 1558 | str << "<td align='center'>0x" << setw(2) << (int)sdata.fAddr[i] << "</td>";
|
|---|
| 1559 | str << "<td align='center'>:</td>";
|
|---|
| 1560 | str << "<td align='center'>0x" << setw(16) << sdata.fDNA[i] << "</td>";
|
|---|
| 1561 | str << "</tr>";
|
|---|
| 1562 | }
|
|---|
| 1563 | str << "</table>";
|
|---|
| 1564 |
|
|---|
| 1565 | fFtuDNA->setText(str.str().c_str());
|
|---|
| 1566 |
|
|---|
| 1567 | fFtuAnswersTotal->setValue(sdata.fNumBoards);
|
|---|
| 1568 | fFtuAnswersCrate0->setValue(sdata.fNumBoardsCrate[0]);
|
|---|
| 1569 | fFtuAnswersCrate1->setValue(sdata.fNumBoardsCrate[1]);
|
|---|
| 1570 | fFtuAnswersCrate2->setValue(sdata.fNumBoardsCrate[2]);
|
|---|
| 1571 | fFtuAnswersCrate3->setValue(sdata.fNumBoardsCrate[3]);
|
|---|
| 1572 |
|
|---|
| 1573 | for (int i=0; i<40; i++)
|
|---|
| 1574 | SetFtuLed(i, sdata.IsActive(i) ? sdata.fPing[i] : -1, d.time);
|
|---|
| 1575 |
|
|---|
| 1576 | SetFtuStatusLed(d.time);
|
|---|
| 1577 | }
|
|---|
| 1578 |
|
|---|
| 1579 | void handleFtmError(const DimData &d)
|
|---|
| 1580 | {
|
|---|
| 1581 | if (!CheckSize(d, sizeof(FTM::DimError)))
|
|---|
| 1582 | return;
|
|---|
| 1583 |
|
|---|
| 1584 | const FTM::DimError &sdata = d.ref<FTM::DimError>();
|
|---|
| 1585 |
|
|---|
| 1586 | SetFtuLed(sdata.fError.fDestAddress , sdata.fError.fNumCalls, d.time);
|
|---|
| 1587 | SetFtuStatusLed(d.time);
|
|---|
| 1588 |
|
|---|
| 1589 | // FIXME: Write to special window!
|
|---|
| 1590 | //Out() << "Error:" << endl;
|
|---|
| 1591 | //Out() << sdata.fError << endl;
|
|---|
| 1592 | }
|
|---|
| 1593 |
|
|---|
| 1594 | // ====================== MessageImp ====================================
|
|---|
| 1595 |
|
|---|
| 1596 | bool fChatOnline;
|
|---|
| 1597 |
|
|---|
| 1598 | void handleStateChanged(const Time &time, const std::string &server,
|
|---|
| 1599 | const State &s)
|
|---|
| 1600 | {
|
|---|
| 1601 | // FIXME: Prefix tooltip with time
|
|---|
| 1602 | if (server=="FTM_CONTROL")
|
|---|
| 1603 | {
|
|---|
| 1604 | // FIXME: Enable FTU page!!!
|
|---|
| 1605 | fStatusFTMLabel->setText(s.name.c_str());
|
|---|
| 1606 | fStatusFTMLabel->setToolTip(s.comment.c_str());
|
|---|
| 1607 |
|
|---|
| 1608 | bool enable = false;
|
|---|
| 1609 |
|
|---|
| 1610 | if (s.index<FTM::kDisconnected) // No Dim connection
|
|---|
| 1611 | SetLedColor(fStatusFTMLed, kLedGray, time);
|
|---|
| 1612 | if (s.index==FTM::kDisconnected) // Dim connection / FTM disconnected
|
|---|
| 1613 | SetLedColor(fStatusFTMLed, kLedYellow, time);
|
|---|
| 1614 | if (s.index==FTM::kConnected || s.index==FTM::kIdle || s.index==FTM::kTakingData) // Dim connection / FTM connected
|
|---|
| 1615 | SetLedColor(fStatusFTMLed, kLedGreen, time);
|
|---|
| 1616 |
|
|---|
| 1617 | if (s.index==FTM::kConnected || s.index==FTM::kIdle) // Dim connection / FTM connected
|
|---|
| 1618 | enable = true;
|
|---|
| 1619 |
|
|---|
| 1620 | fTriggerWidget->setEnabled(enable);
|
|---|
| 1621 | fFtuWidget->setEnabled(enable);
|
|---|
| 1622 | fRatesWidget->setEnabled(enable);
|
|---|
| 1623 |
|
|---|
| 1624 | if (!enable)
|
|---|
| 1625 | {
|
|---|
| 1626 | SetLedColor(fStatusFTULed, kLedGray, time);
|
|---|
| 1627 | fStatusFTULabel->setText("Offline");
|
|---|
| 1628 | fStatusFTULabel->setToolTip("FTM is not online.");
|
|---|
| 1629 | }
|
|---|
| 1630 | }
|
|---|
| 1631 |
|
|---|
| 1632 | if (server=="FAD_CONTROL")
|
|---|
| 1633 | {
|
|---|
| 1634 | fStatusFADLabel->setText(s.name.c_str());
|
|---|
| 1635 | fStatusFADLabel->setToolTip(s.comment.c_str());
|
|---|
| 1636 |
|
|---|
| 1637 | bool enable = false;
|
|---|
| 1638 |
|
|---|
| 1639 | if (s.index<FAD::kDisconnected) // No Dim connection
|
|---|
| 1640 | SetLedColor(fStatusFADLed, kLedGray, time);
|
|---|
| 1641 | if (s.index==FAD::kOffline) // Dim connection / FTM disconnected
|
|---|
| 1642 | SetLedColor(fStatusFADLed, kLedRed, time);
|
|---|
| 1643 | if (s.index==FAD::kDisconnected) // Dim connection / FTM disconnected
|
|---|
| 1644 | SetLedColor(fStatusFADLed, kLedOrange, time);
|
|---|
| 1645 | if (s.index==FAD::kConnecting) // Dim connection / FTM disconnected
|
|---|
| 1646 | {
|
|---|
| 1647 | SetLedColor(fStatusFADLed, kLedYellow, time);
|
|---|
| 1648 | // FIXME FIXME FIXME: The LEDs are not displayed when disabled!
|
|---|
| 1649 | enable = true;
|
|---|
| 1650 | }
|
|---|
| 1651 | if (s.index>=FAD::kConnected) // Dim connection / FTM connected
|
|---|
| 1652 | {
|
|---|
| 1653 | SetLedColor(fStatusFADLed, kLedGreen, time);
|
|---|
| 1654 | enable = true;
|
|---|
| 1655 | }
|
|---|
| 1656 |
|
|---|
| 1657 | fFadWidget->setEnabled(enable);
|
|---|
| 1658 | }
|
|---|
| 1659 |
|
|---|
| 1660 | if (server=="FSC_CONTROL")
|
|---|
| 1661 | {
|
|---|
| 1662 | fStatusFSCLabel->setText(s.name.c_str());
|
|---|
| 1663 | fStatusFSCLabel->setToolTip(s.comment.c_str());
|
|---|
| 1664 |
|
|---|
| 1665 | bool enable = false;
|
|---|
| 1666 |
|
|---|
| 1667 | if (s.index<1) // No Dim connection
|
|---|
| 1668 | SetLedColor(fStatusFSCLed, kLedGray, time);
|
|---|
| 1669 | if (s.index==1) // Dim connection / FTM disconnected
|
|---|
| 1670 | SetLedColor(fStatusFSCLed, kLedRed, time);
|
|---|
| 1671 | if (s.index>=2) // Dim connection / FTM disconnected
|
|---|
| 1672 | {
|
|---|
| 1673 | SetLedColor(fStatusFSCLed, kLedGreen, time);
|
|---|
| 1674 | enable = true;
|
|---|
| 1675 | }
|
|---|
| 1676 |
|
|---|
| 1677 | //fFscWidget->setEnabled(enable);
|
|---|
| 1678 | }
|
|---|
| 1679 |
|
|---|
| 1680 | if (server=="DATA_LOGGER")
|
|---|
| 1681 | {
|
|---|
| 1682 | fStatusLoggerLabel->setText(s.name.c_str());
|
|---|
| 1683 | fStatusLoggerLabel->setToolTip(s.comment.c_str());
|
|---|
| 1684 |
|
|---|
| 1685 | bool enable = true;
|
|---|
| 1686 |
|
|---|
| 1687 | if (s.index<=30) // Ready/Waiting
|
|---|
| 1688 | SetLedColor(fStatusLoggerLed, kLedYellow, time);
|
|---|
| 1689 | if (s.index<-1) // Offline
|
|---|
| 1690 | {
|
|---|
| 1691 | SetLedColor(fStatusLoggerLed, kLedGray, time);
|
|---|
| 1692 | enable = false;
|
|---|
| 1693 | }
|
|---|
| 1694 | if (s.index>=0x100) // Error
|
|---|
| 1695 | SetLedColor(fStatusLoggerLed, kLedRed, time);
|
|---|
| 1696 | if (s.index==40) // Logging
|
|---|
| 1697 | SetLedColor(fStatusLoggerLed, kLedGreen, time);
|
|---|
| 1698 |
|
|---|
| 1699 | fLoggerWidget->setEnabled(enable);
|
|---|
| 1700 | }
|
|---|
| 1701 |
|
|---|
| 1702 | if (server=="CHAT")
|
|---|
| 1703 | {
|
|---|
| 1704 | fStatusChatLabel->setText(s.name.c_str());
|
|---|
| 1705 |
|
|---|
| 1706 | fChatOnline = s.index==0;
|
|---|
| 1707 |
|
|---|
| 1708 | SetLedColor(fStatusChatLed, fChatOnline ? kLedGreen : kLedGray, time);
|
|---|
| 1709 |
|
|---|
| 1710 | fChatSend->setEnabled(fChatOnline);
|
|---|
| 1711 | fChatMessage->setEnabled(fChatOnline);
|
|---|
| 1712 | }
|
|---|
| 1713 |
|
|---|
| 1714 | if (server=="SCHEDULER")
|
|---|
| 1715 | {
|
|---|
| 1716 | fStatusSchedulerLabel->setText(s.name.c_str());
|
|---|
| 1717 |
|
|---|
| 1718 | SetLedColor(fStatusSchedulerLed, s.index>=0 ? kLedGreen : kLedRed, time);
|
|---|
| 1719 | }
|
|---|
| 1720 | }
|
|---|
| 1721 |
|
|---|
| 1722 | void handleStateOffline(const string &server)
|
|---|
| 1723 | {
|
|---|
| 1724 | handleStateChanged(Time(), server, State(-2, "Offline", "No connection via DIM."));
|
|---|
| 1725 | }
|
|---|
| 1726 |
|
|---|
| 1727 | void on_fTabWidget_currentChanged(int which)
|
|---|
| 1728 | {
|
|---|
| 1729 | if (fTabWidget->tabText(which)=="Chat")
|
|---|
| 1730 | fTabWidget->setTabIcon(which, QIcon());
|
|---|
| 1731 | }
|
|---|
| 1732 |
|
|---|
| 1733 | void handleWrite(const Time &time, const string &text, int qos)
|
|---|
| 1734 | {
|
|---|
| 1735 | stringstream out;
|
|---|
| 1736 |
|
|---|
| 1737 | if (text.substr(0, 6)=="CHAT: ")
|
|---|
| 1738 | {
|
|---|
| 1739 | if (qos==MessageImp::kDebug)
|
|---|
| 1740 | return;
|
|---|
| 1741 |
|
|---|
| 1742 | out << "<font size='-1' color='navy'>[<B>";
|
|---|
| 1743 | out << Time::fmt("%H:%M:%S") << time << "</B>]</FONT> ";
|
|---|
| 1744 | out << text.substr(6);
|
|---|
| 1745 | fChatText->append(out.str().c_str());
|
|---|
| 1746 |
|
|---|
| 1747 | if (fTabWidget->tabText(fTabWidget->currentIndex())=="Chat")
|
|---|
| 1748 | return;
|
|---|
| 1749 |
|
|---|
| 1750 | static int num = 0;
|
|---|
| 1751 | if (num++<2)
|
|---|
| 1752 | return;
|
|---|
| 1753 |
|
|---|
| 1754 | for (int i=0; i<fTabWidget->count(); i++)
|
|---|
| 1755 | if (fTabWidget->tabText(i)=="Chat")
|
|---|
| 1756 | {
|
|---|
| 1757 | fTabWidget->setTabIcon(i, QIcon(":/Resources/icons/warning 3.png"));
|
|---|
| 1758 | break;
|
|---|
| 1759 | }
|
|---|
| 1760 |
|
|---|
| 1761 | return;
|
|---|
| 1762 | }
|
|---|
| 1763 |
|
|---|
| 1764 |
|
|---|
| 1765 | out << "<font style='font-family:monospace' color='";
|
|---|
| 1766 |
|
|---|
| 1767 | switch (qos)
|
|---|
| 1768 | {
|
|---|
| 1769 | case kMessage: out << "black"; break;
|
|---|
| 1770 | case kInfo: out << "green"; break;
|
|---|
| 1771 | case kWarn: out << "#FF6600"; break;
|
|---|
| 1772 | case kError: out << "maroon"; break;
|
|---|
| 1773 | case kFatal: out << "maroon"; break;
|
|---|
| 1774 | case kDebug: out << "navy"; break;
|
|---|
| 1775 | default: out << "navy"; break;
|
|---|
| 1776 | }
|
|---|
| 1777 | out << "'>" << time.GetAsStr() << " - " << text << "</font>";
|
|---|
| 1778 |
|
|---|
| 1779 | fLogText->append(out.str().c_str());
|
|---|
| 1780 |
|
|---|
| 1781 | if (qos>=kWarn)
|
|---|
| 1782 | fTextEdit->append(out.str().c_str());
|
|---|
| 1783 | }
|
|---|
| 1784 |
|
|---|
| 1785 | void IndicateStateChange(const Time &time, const std::string &server)
|
|---|
| 1786 | {
|
|---|
| 1787 | const State s = GetState(server, GetCurrentState(server));
|
|---|
| 1788 |
|
|---|
| 1789 | QApplication::postEvent(this,
|
|---|
| 1790 | new FunctionEvent(boost::bind(&FactGui::handleStateChanged, this, time, server, s)));
|
|---|
| 1791 | }
|
|---|
| 1792 |
|
|---|
| 1793 | int Write(const Time &time, const string &txt, int qos)
|
|---|
| 1794 | {
|
|---|
| 1795 | QApplication::postEvent(this,
|
|---|
| 1796 | new FunctionEvent(boost::bind(&FactGui::handleWrite, this, time, txt, qos)));
|
|---|
| 1797 |
|
|---|
| 1798 | return 0;
|
|---|
| 1799 | }
|
|---|
| 1800 |
|
|---|
| 1801 | // ====================== Dim infoHandler================================
|
|---|
| 1802 |
|
|---|
| 1803 | void handleDimService(const string &txt)
|
|---|
| 1804 | {
|
|---|
| 1805 | fDimSvcText->append(txt.c_str());
|
|---|
| 1806 | }
|
|---|
| 1807 |
|
|---|
| 1808 | void infoHandlerService(DimInfo &info)
|
|---|
| 1809 | {
|
|---|
| 1810 | const string fmt = string(info.getFormat()).empty() ? "C" : info.getFormat();
|
|---|
| 1811 |
|
|---|
| 1812 | stringstream dummy;
|
|---|
| 1813 | const Converter conv(dummy, fmt, false);
|
|---|
| 1814 |
|
|---|
| 1815 | const Time tm(info.getTimestamp(), info.getTimestampMillisecs()*1000);
|
|---|
| 1816 |
|
|---|
| 1817 | stringstream out;
|
|---|
| 1818 | out << "<font size'-1' color='navy'>[" << Time::fmt("%H:%M:%S.%f") << tm << "]</font> <B>" << info.getName() << "</B> - ";
|
|---|
| 1819 |
|
|---|
| 1820 | bool iserr = true;
|
|---|
| 1821 | if (!conv)
|
|---|
| 1822 | {
|
|---|
| 1823 | out << "Compilation of format string '" << fmt << "' failed!";
|
|---|
| 1824 | }
|
|---|
| 1825 | else
|
|---|
| 1826 | {
|
|---|
| 1827 | try
|
|---|
| 1828 | {
|
|---|
| 1829 | const string dat = conv.GetString(info.getData(), info.getSize());
|
|---|
| 1830 | out << dat;
|
|---|
| 1831 | iserr = false;
|
|---|
| 1832 | }
|
|---|
| 1833 | catch (const runtime_error &e)
|
|---|
| 1834 | {
|
|---|
| 1835 | out << "Conversion to string failed!<pre>" << e.what() << "</pre>";
|
|---|
| 1836 | }
|
|---|
| 1837 | }
|
|---|
| 1838 |
|
|---|
| 1839 | // srand(hash<string>()(string(info.getName())));
|
|---|
| 1840 | // int bg = rand()&0xffffff;
|
|---|
| 1841 |
|
|---|
| 1842 | int bg = hash<string>()(string(info.getName()));
|
|---|
| 1843 |
|
|---|
| 1844 | // allow only light colors
|
|---|
| 1845 | bg = ~(bg&0x1f1f1f)&0xffffff;
|
|---|
| 1846 |
|
|---|
| 1847 | if (iserr)
|
|---|
| 1848 | bg = 0xffffff;
|
|---|
| 1849 |
|
|---|
| 1850 | stringstream bgcol;
|
|---|
| 1851 | bgcol << hex << setfill('0') << setw(6) << bg;
|
|---|
| 1852 |
|
|---|
| 1853 | const string col = iserr ? "red" : "black";
|
|---|
| 1854 | const string str = "<table width='100%' bgcolor=#"+bgcol.str()+"><tr><td><font color='"+col+"'>"+out.str()+"</font></td></tr></table>";
|
|---|
| 1855 |
|
|---|
| 1856 | QApplication::postEvent(this,
|
|---|
| 1857 | new FunctionEvent(boost::bind(&FactGui::handleDimService, this, str)));
|
|---|
| 1858 | }
|
|---|
| 1859 |
|
|---|
| 1860 | void CallInfoHandler(void (FactGui::*handler)(const DimData&), const DimData &d)
|
|---|
| 1861 | {
|
|---|
| 1862 | fInHandler = true;
|
|---|
| 1863 | (this->*handler)(d);
|
|---|
| 1864 | fInHandler = false;
|
|---|
| 1865 | }
|
|---|
| 1866 |
|
|---|
| 1867 | /*
|
|---|
| 1868 | void CallInfoHandler(const boost::function<void()> &func)
|
|---|
| 1869 | {
|
|---|
| 1870 | // This ensures that newly received values are not sent back to the emitter
|
|---|
| 1871 | // because changing the value emits the valueChanged signal (or similar)
|
|---|
| 1872 | fInHandler = true;
|
|---|
| 1873 | func();
|
|---|
| 1874 | fInHandler = false;
|
|---|
| 1875 | }*/
|
|---|
| 1876 |
|
|---|
| 1877 | void PostInfoHandler(void (FactGui::*handler)(const DimData&))
|
|---|
| 1878 | {
|
|---|
| 1879 | //const boost::function<void()> f = boost::bind(handler, this, DimData(getInfo()));
|
|---|
| 1880 |
|
|---|
| 1881 | FunctionEvent *evt = new FunctionEvent(boost::bind(&FactGui::CallInfoHandler, this, handler, DimData(getInfo())));
|
|---|
| 1882 | // FunctionEvent *evt = new FunctionEvent(boost::bind(&FactGui::CallInfoHandler, this, f));
|
|---|
| 1883 | // FunctionEvent *evt = new FunctionEvent(boost::bind(handler, this, DimData(getInfo()))));
|
|---|
| 1884 |
|
|---|
| 1885 | QApplication::postEvent(this, evt);
|
|---|
| 1886 | }
|
|---|
| 1887 |
|
|---|
| 1888 | void infoHandler()
|
|---|
| 1889 | {
|
|---|
| 1890 | // Initialize the time-stamp (what a weird workaround...)
|
|---|
| 1891 | if (getInfo())
|
|---|
| 1892 | getInfo()->getTimestamp();
|
|---|
| 1893 |
|
|---|
| 1894 | if (getInfo()==&fDimDNS)
|
|---|
| 1895 | return PostInfoHandler(&FactGui::handleDimDNS);
|
|---|
| 1896 | #ifdef DEBUG_DIM
|
|---|
| 1897 | cout << "HandleDimInfo " << getInfo()->getName() << endl;
|
|---|
| 1898 | #endif
|
|---|
| 1899 | if (getInfo()==&fDimLoggerStats)
|
|---|
| 1900 | return PostInfoHandler(&FactGui::handleLoggerStats);
|
|---|
| 1901 |
|
|---|
| 1902 | if (getInfo()==&fDimFadFiles)
|
|---|
| 1903 | return PostInfoHandler(&FactGui::handleFadFiles);
|
|---|
| 1904 |
|
|---|
| 1905 | if (getInfo()==&fDimFadConnections)
|
|---|
| 1906 | return PostInfoHandler(&FactGui::handleFadConnections);
|
|---|
| 1907 |
|
|---|
| 1908 | if (getInfo()==&fDimFadFwVersion)
|
|---|
| 1909 | return PostInfoHandler(&FactGui::handleFadFwVersion);
|
|---|
| 1910 |
|
|---|
| 1911 | if (getInfo()==&fDimFadStatistics)
|
|---|
| 1912 | return PostInfoHandler(&FactGui::handleFadStatistics);
|
|---|
| 1913 |
|
|---|
| 1914 | if (getInfo()==&fDimFadEvents)
|
|---|
| 1915 | return PostInfoHandler(&FactGui::handleFadEvents);
|
|---|
| 1916 |
|
|---|
| 1917 | if (getInfo()==&fDimFadRuns)
|
|---|
| 1918 | return PostInfoHandler(&FactGui::handleFadRuns);
|
|---|
| 1919 |
|
|---|
| 1920 | if (getInfo()==&fDimFadCurrentEvent)
|
|---|
| 1921 | return PostInfoHandler(&FactGui::handleFadCurrentEvent);
|
|---|
| 1922 |
|
|---|
| 1923 | if (getInfo()==&fDimFadEventData)
|
|---|
| 1924 | return PostInfoHandler(&FactGui::handleFadEventData);
|
|---|
| 1925 |
|
|---|
| 1926 | /*
|
|---|
| 1927 | if (getInfo()==&fDimFadSetup)
|
|---|
| 1928 | return PostInfoHandler(&FactGui::handleFadSetup);
|
|---|
| 1929 | */
|
|---|
| 1930 | if (getInfo()==&fDimLoggerFilenameNight)
|
|---|
| 1931 | return PostInfoHandler(&FactGui::handleLoggerFilenameNight);
|
|---|
| 1932 |
|
|---|
| 1933 | if (getInfo()==&fDimLoggerNumSubs)
|
|---|
| 1934 | return PostInfoHandler(&FactGui::handleLoggerNumSubs);
|
|---|
| 1935 |
|
|---|
| 1936 | if (getInfo()==&fDimLoggerFilenameRun)
|
|---|
| 1937 | return PostInfoHandler(&FactGui::handleLoggerFilenameRun);
|
|---|
| 1938 |
|
|---|
| 1939 | if (getInfo()==&fDimFtmTriggerCounter)
|
|---|
| 1940 | return PostInfoHandler(&FactGui::handleFtmTriggerCounter);
|
|---|
| 1941 |
|
|---|
| 1942 | if (getInfo()==&fDimFtmCounter)
|
|---|
| 1943 | return PostInfoHandler(&FactGui::handleFtmCounter);
|
|---|
| 1944 |
|
|---|
| 1945 | if (getInfo()==&fDimFtmDynamicData)
|
|---|
| 1946 | return PostInfoHandler(&FactGui::handleFtmDynamicData);
|
|---|
| 1947 |
|
|---|
| 1948 | if (getInfo()==&fDimFtmPassport)
|
|---|
| 1949 | return PostInfoHandler(&FactGui::handleFtmPassport);
|
|---|
| 1950 |
|
|---|
| 1951 | if (getInfo()==&fDimFtmFtuList)
|
|---|
| 1952 | return PostInfoHandler(&FactGui::handleFtmFtuList);
|
|---|
| 1953 |
|
|---|
| 1954 | if (getInfo()==&fDimFtmStaticData)
|
|---|
| 1955 | return PostInfoHandler(&FactGui::handleFtmStaticData);
|
|---|
| 1956 |
|
|---|
| 1957 | if (getInfo()==&fDimFtmError)
|
|---|
| 1958 | return PostInfoHandler(&FactGui::handleFtmError);
|
|---|
| 1959 |
|
|---|
| 1960 | if (getInfo()==&fDimFadFiles)
|
|---|
| 1961 | return PostInfoHandler(&FactGui::handleFadFiles);
|
|---|
| 1962 |
|
|---|
| 1963 | for (map<string,DimInfo*>::iterator i=fServices.begin(); i!=fServices.end(); i++)
|
|---|
| 1964 | if (i->second==getInfo())
|
|---|
| 1965 | {
|
|---|
| 1966 | infoHandlerService(*i->second);
|
|---|
| 1967 | return;
|
|---|
| 1968 | }
|
|---|
| 1969 |
|
|---|
| 1970 | DimNetwork::infoHandler();
|
|---|
| 1971 | }
|
|---|
| 1972 |
|
|---|
| 1973 |
|
|---|
| 1974 | // ======================================================================
|
|---|
| 1975 |
|
|---|
| 1976 | bool event(QEvent *evt)
|
|---|
| 1977 | {
|
|---|
| 1978 | if (dynamic_cast<FunctionEvent*>(evt))
|
|---|
| 1979 | return static_cast<FunctionEvent*>(evt)->Exec();
|
|---|
| 1980 |
|
|---|
| 1981 | if (dynamic_cast<CheckBoxEvent*>(evt))
|
|---|
| 1982 | {
|
|---|
| 1983 | const QStandardItem &item = static_cast<CheckBoxEvent*>(evt)->item;
|
|---|
| 1984 | const QStandardItem *par = item.parent();
|
|---|
| 1985 | if (par)
|
|---|
| 1986 | {
|
|---|
| 1987 | const QString server = par->text();
|
|---|
| 1988 | const QString service = item.text();
|
|---|
| 1989 |
|
|---|
| 1990 | const string s = (server+'/'+service).toStdString();
|
|---|
| 1991 |
|
|---|
| 1992 | if (item.checkState()==Qt::Checked)
|
|---|
| 1993 | SubscribeService(s);
|
|---|
| 1994 | else
|
|---|
| 1995 | UnsubscribeService(s);
|
|---|
| 1996 | }
|
|---|
| 1997 | }
|
|---|
| 1998 |
|
|---|
| 1999 | return MainWindow::event(evt); // unrecognized
|
|---|
| 2000 | }
|
|---|
| 2001 |
|
|---|
| 2002 | void on_fDimCmdSend_clicked()
|
|---|
| 2003 | {
|
|---|
| 2004 | const QString server = fDimCmdServers->currentIndex().data().toString();
|
|---|
| 2005 | const QString command = fDimCmdCommands->currentIndex().data().toString();
|
|---|
| 2006 | const QString arguments = fDimCmdLineEdit->displayText();
|
|---|
| 2007 |
|
|---|
| 2008 | // FIXME: Sending a command exactly when the info Handler changes
|
|---|
| 2009 | // the list it might lead to confusion.
|
|---|
| 2010 | try
|
|---|
| 2011 | {
|
|---|
| 2012 | SendDimCommand(server.toStdString(), command.toStdString()+" "+arguments.toStdString());
|
|---|
| 2013 | fTextEdit->append("<font color='green'>Command '"+server+'/'+command+"' successfully emitted.</font>");
|
|---|
| 2014 | fDimCmdLineEdit->clear();
|
|---|
| 2015 | }
|
|---|
| 2016 | catch (const runtime_error &e)
|
|---|
| 2017 | {
|
|---|
| 2018 | stringstream txt;
|
|---|
| 2019 | txt << e.what();
|
|---|
| 2020 |
|
|---|
| 2021 | string buffer;
|
|---|
| 2022 | while (getline(txt, buffer, '\n'))
|
|---|
| 2023 | fTextEdit->append(("<font color='red'><pre>"+buffer+"</pre></font>").c_str());
|
|---|
| 2024 | }
|
|---|
| 2025 | }
|
|---|
| 2026 |
|
|---|
| 2027 | #ifdef HAVE_ROOT
|
|---|
| 2028 | void slot_RootEventProcessed(TObject *obj, unsigned int evt, TCanvas *canv)
|
|---|
| 2029 | {
|
|---|
| 2030 | // kMousePressEvent // TCanvas processed QEvent mousePressEvent
|
|---|
| 2031 | // kMouseMoveEvent // TCanvas processed QEvent mouseMoveEvent
|
|---|
| 2032 | // kMouseReleaseEvent // TCanvas processed QEvent mouseReleaseEvent
|
|---|
| 2033 | // kMouseDoubleClickEvent // TCanvas processed QEvent mouseDoubleClickEvent
|
|---|
| 2034 | // kKeyPressEvent // TCanvas processed QEvent keyPressEvent
|
|---|
| 2035 | // kEnterEvent // TCanvas processed QEvent enterEvent
|
|---|
| 2036 | // kLeaveEvent // TCanvas processed QEvent leaveEvent
|
|---|
| 2037 | if (dynamic_cast<TCanvas*>(obj))
|
|---|
| 2038 | return;
|
|---|
| 2039 |
|
|---|
| 2040 | TQtWidget *tipped = static_cast<TQtWidget*>(sender());
|
|---|
| 2041 |
|
|---|
| 2042 | if (evt==11/*kMouseReleaseEvent*/)
|
|---|
| 2043 | {
|
|---|
| 2044 | if (dynamic_cast<Camera*>(obj))
|
|---|
| 2045 | {
|
|---|
| 2046 | const float xx = canv->AbsPixeltoX(tipped->GetEventX());
|
|---|
| 2047 | const float yy = canv->AbsPixeltoY(tipped->GetEventY());
|
|---|
| 2048 |
|
|---|
| 2049 | Camera *cam = static_cast<Camera*>(obj);
|
|---|
| 2050 | const int isw = cam->GetIdx(xx, yy);
|
|---|
| 2051 |
|
|---|
| 2052 | fPixelIdx->setValue(isw);
|
|---|
| 2053 | ChoosePixel(*cam, isw);
|
|---|
| 2054 | }
|
|---|
| 2055 | return;
|
|---|
| 2056 | }
|
|---|
| 2057 |
|
|---|
| 2058 | if (evt==61/*kMouseDoubleClickEvent*/)
|
|---|
| 2059 | {
|
|---|
| 2060 | if (dynamic_cast<Camera*>(obj))
|
|---|
| 2061 | {
|
|---|
| 2062 | const float xx = canv->AbsPixeltoX(tipped->GetEventX());
|
|---|
| 2063 | const float yy = canv->AbsPixeltoY(tipped->GetEventY());
|
|---|
| 2064 |
|
|---|
| 2065 | Camera *cam = static_cast<Camera*>(obj);
|
|---|
| 2066 | const int isw = cam->GetIdx(xx, yy);
|
|---|
| 2067 |
|
|---|
| 2068 | ChoosePixel(*cam, isw);
|
|---|
| 2069 |
|
|---|
| 2070 | fPixelIdx->setValue(isw);
|
|---|
| 2071 |
|
|---|
| 2072 | const uint16_t ihw = fPixelMapHW[isw];
|
|---|
| 2073 |
|
|---|
| 2074 | Dim::SendCommand("FTM_CONTROL/TOGGLE_PIXEL", ihw);
|
|---|
| 2075 | }
|
|---|
| 2076 |
|
|---|
| 2077 | if (dynamic_cast<TAxis*>(obj))
|
|---|
| 2078 | static_cast<TAxis*>(obj)->UnZoom();
|
|---|
| 2079 |
|
|---|
| 2080 | return;
|
|---|
| 2081 | }
|
|---|
| 2082 |
|
|---|
| 2083 | // Find the object which will get picked by the GetObjectInfo
|
|---|
| 2084 | // due to buffer overflows in many root-versions
|
|---|
| 2085 | // in TH1 and TProfile we have to work around and implement
|
|---|
| 2086 | // our own GetObjectInfo which make everything a bit more
|
|---|
| 2087 | // complicated.
|
|---|
| 2088 | canv->cd();
|
|---|
| 2089 | #if ROOT_VERSION_CODE > ROOT_VERSION(5,22,00)
|
|---|
| 2090 | const char *objectInfo =
|
|---|
| 2091 | obj->GetObjectInfo(tipped->GetEventX(),tipped->GetEventY());
|
|---|
| 2092 | #else
|
|---|
| 2093 | const char *objectInfo = dynamic_cast<TH1*>(obj) ?
|
|---|
| 2094 | "" : obj->GetObjectInfo(tipped->GetEventX(),tipped->GetEventY());
|
|---|
| 2095 | #endif
|
|---|
| 2096 |
|
|---|
| 2097 | QString tipText;
|
|---|
| 2098 | tipText += obj->GetName();
|
|---|
| 2099 | tipText += " [";
|
|---|
| 2100 | tipText += obj->ClassName();
|
|---|
| 2101 | tipText += "]: ";
|
|---|
| 2102 | tipText += objectInfo;
|
|---|
| 2103 |
|
|---|
| 2104 | if (dynamic_cast<Camera*>(obj))
|
|---|
| 2105 | {
|
|---|
| 2106 | const float xx = canv->AbsPixeltoX(tipped->GetEventX());
|
|---|
| 2107 | const float yy = canv->AbsPixeltoY(tipped->GetEventY());
|
|---|
| 2108 |
|
|---|
| 2109 | Camera *cam = static_cast<Camera*>(obj);
|
|---|
| 2110 |
|
|---|
| 2111 | const int isw = cam->GetIdx(xx, yy);
|
|---|
| 2112 | const int ihw = fPixelMapHW[isw];
|
|---|
| 2113 |
|
|---|
| 2114 | const int idx = fPatchHW[isw];
|
|---|
| 2115 |
|
|---|
| 2116 | int ii = 0;
|
|---|
| 2117 | for (; ii<160; ii++)
|
|---|
| 2118 | if (idx==fPatchMapHW[ii])
|
|---|
| 2119 | break;
|
|---|
| 2120 |
|
|---|
| 2121 |
|
|---|
| 2122 | const int patch = ihw%4;
|
|---|
| 2123 | const int board = (ihw/4)%10;
|
|---|
| 2124 | const int crate = (ihw/4)/10;
|
|---|
| 2125 |
|
|---|
| 2126 | ostringstream str;
|
|---|
| 2127 | str << " (hw=" << ihw << ") Patch=" << ii << " (hw=" << fPatchMapHW[idx] << "; Crate=" << crate << " Board=" << board << " Patch=" << patch << ")";
|
|---|
| 2128 |
|
|---|
| 2129 | tipText += str.str().c_str();
|
|---|
| 2130 | }
|
|---|
| 2131 |
|
|---|
| 2132 |
|
|---|
| 2133 | fStatusBar->showMessage(tipText, 3000);
|
|---|
| 2134 |
|
|---|
| 2135 | gSystem->ProcessEvents();
|
|---|
| 2136 | //QWhatsThis::display(tipText)
|
|---|
| 2137 | }
|
|---|
| 2138 |
|
|---|
| 2139 | void slot_RootUpdate()
|
|---|
| 2140 | {
|
|---|
| 2141 | gSystem->ProcessEvents();
|
|---|
| 2142 | QTimer::singleShot(0, this, SLOT(slot_RootUpdate()));
|
|---|
| 2143 | }
|
|---|
| 2144 |
|
|---|
| 2145 | void ChoosePatch(Camera &cam, int isw)
|
|---|
| 2146 | {
|
|---|
| 2147 | cam.Reset();
|
|---|
| 2148 |
|
|---|
| 2149 | fThresholdIdx->setValue(isw);
|
|---|
| 2150 |
|
|---|
| 2151 | const int ihw = isw<0 ? 0 : fPatchMapHW[isw];
|
|---|
| 2152 |
|
|---|
| 2153 | fPatchRate->setEnabled(isw>=0);
|
|---|
| 2154 | fThresholdCrate->setEnabled(isw>=0);
|
|---|
| 2155 | fThresholdBoard->setEnabled(isw>=0);
|
|---|
| 2156 | fThresholdPatch->setEnabled(isw>=0);
|
|---|
| 2157 |
|
|---|
| 2158 | if (isw<0)
|
|---|
| 2159 | return;
|
|---|
| 2160 |
|
|---|
| 2161 | const int patch = ihw%4;
|
|---|
| 2162 | const int board = (ihw/4)%10;
|
|---|
| 2163 | const int crate = (ihw/4)/10;
|
|---|
| 2164 |
|
|---|
| 2165 | fInChoosePatch = true;
|
|---|
| 2166 |
|
|---|
| 2167 | fThresholdCrate->setValue(crate);
|
|---|
| 2168 | fThresholdBoard->setValue(board);
|
|---|
| 2169 | fThresholdPatch->setValue(patch);
|
|---|
| 2170 |
|
|---|
| 2171 | fInChoosePatch = false;
|
|---|
| 2172 |
|
|---|
| 2173 | fThresholdVal->setValue(fFtmStaticData.fThreshold[ihw]);
|
|---|
| 2174 | fPatchRate->setValue(cam.GetData(isw));
|
|---|
| 2175 |
|
|---|
| 2176 | // Loop over the software idx of all pixels
|
|---|
| 2177 | for (unsigned int i=0; i<1440; i++)
|
|---|
| 2178 | if (fPatchHW[i]==ihw)
|
|---|
| 2179 | cam.SetBold(i);
|
|---|
| 2180 | }
|
|---|
| 2181 |
|
|---|
| 2182 | void ChoosePixel(Camera &cam, int isw)
|
|---|
| 2183 | {
|
|---|
| 2184 | const int ihw = fPixelMapHW[isw];
|
|---|
| 2185 |
|
|---|
| 2186 | int ii = 0;
|
|---|
| 2187 | for (; ii<160; ii++)
|
|---|
| 2188 | if (fPatchHW[isw]==fPatchMapHW[ii])
|
|---|
| 2189 | break;
|
|---|
| 2190 |
|
|---|
| 2191 | cam.SetWhite(isw);
|
|---|
| 2192 | ChoosePatch(cam, ii);
|
|---|
| 2193 |
|
|---|
| 2194 | const bool on = fFtmStaticData.IsEnabled(ihw);
|
|---|
| 2195 | fPixelEnable->setChecked(on);
|
|---|
| 2196 | }
|
|---|
| 2197 |
|
|---|
| 2198 | void UpdatePatch(int isw)
|
|---|
| 2199 | {
|
|---|
| 2200 | Camera *cam = (Camera*)fRatesCanv->GetCanvas()->FindObject("Camera");
|
|---|
| 2201 | ChoosePatch(*cam, isw);
|
|---|
| 2202 | }
|
|---|
| 2203 |
|
|---|
| 2204 | void on_fThresholdIdx_valueChanged(int isw)
|
|---|
| 2205 | {
|
|---|
| 2206 | UpdatePatch(isw);
|
|---|
| 2207 |
|
|---|
| 2208 | fRatesCanv->GetCanvas()->Modified();
|
|---|
| 2209 | fRatesCanv->GetCanvas()->Update();
|
|---|
| 2210 | }
|
|---|
| 2211 |
|
|---|
| 2212 | void UpdateThresholdIdx()
|
|---|
| 2213 | {
|
|---|
| 2214 | if (fInChoosePatch)
|
|---|
| 2215 | return;
|
|---|
| 2216 |
|
|---|
| 2217 | const int crate = fThresholdCrate->value();
|
|---|
| 2218 | const int board = fThresholdBoard->value();
|
|---|
| 2219 | const int patch = fThresholdPatch->value();
|
|---|
| 2220 |
|
|---|
| 2221 | const int ihw = patch + board*4 + crate*40;
|
|---|
| 2222 |
|
|---|
| 2223 | int isw = 0;
|
|---|
| 2224 | for (; isw<160; isw++)
|
|---|
| 2225 | if (ihw==fPatchMapHW[isw])
|
|---|
| 2226 | break;
|
|---|
| 2227 |
|
|---|
| 2228 | UpdatePatch(isw);
|
|---|
| 2229 | }
|
|---|
| 2230 |
|
|---|
| 2231 | void on_fThresholdPatch_valueChanged(int)
|
|---|
| 2232 | {
|
|---|
| 2233 | UpdateThresholdIdx();
|
|---|
| 2234 | }
|
|---|
| 2235 | void on_fThresholdBoard_valueChanged(int)
|
|---|
| 2236 | {
|
|---|
| 2237 | UpdateThresholdIdx();
|
|---|
| 2238 | }
|
|---|
| 2239 | void on_fThresholdCrate_valueChanged(int)
|
|---|
| 2240 | {
|
|---|
| 2241 | UpdateThresholdIdx();
|
|---|
| 2242 | }
|
|---|
| 2243 |
|
|---|
| 2244 | void on_fPixelIdx_valueChanged(int isw)
|
|---|
| 2245 | {
|
|---|
| 2246 | Camera *cam = (Camera*)fRatesCanv->GetCanvas()->FindObject("Camera");
|
|---|
| 2247 | ChoosePixel(*cam, isw);
|
|---|
| 2248 |
|
|---|
| 2249 | fRatesCanv->GetCanvas()->Modified();
|
|---|
| 2250 | fRatesCanv->GetCanvas()->Update();
|
|---|
| 2251 | }
|
|---|
| 2252 | #endif
|
|---|
| 2253 |
|
|---|
| 2254 | void on_fPixelEnable_stateChanged(int b)
|
|---|
| 2255 | {
|
|---|
| 2256 | if (fInHandler)
|
|---|
| 2257 | return;
|
|---|
| 2258 |
|
|---|
| 2259 | const uint16_t isw = fPixelIdx->value();
|
|---|
| 2260 | const uint16_t ihw = fPixelMapHW[isw];
|
|---|
| 2261 |
|
|---|
| 2262 | Dim::SendCommand(b==Qt::Unchecked ?
|
|---|
| 2263 | "FTM_CONTROL/DISABLE_PIXEL" : "FTM_CONTROL/ENABLE_PIXEL",
|
|---|
| 2264 | ihw);
|
|---|
| 2265 | }
|
|---|
| 2266 |
|
|---|
| 2267 | void on_fPixelDisableOthers_clicked()
|
|---|
| 2268 | {
|
|---|
| 2269 | const uint16_t isw = fPixelIdx->value();
|
|---|
| 2270 | const uint16_t ihw = fPixelMapHW[isw];
|
|---|
| 2271 |
|
|---|
| 2272 | Dim::SendCommand("FTM_CONTROL/DISABLE_ALL_PIXELS_EXCEPT", ihw);
|
|---|
| 2273 | }
|
|---|
| 2274 |
|
|---|
| 2275 | void on_fThresholdDisableOthers_clicked()
|
|---|
| 2276 | {
|
|---|
| 2277 | const uint16_t isw = fThresholdIdx->value();
|
|---|
| 2278 | const uint16_t ihw = fPatchMapHW[isw];
|
|---|
| 2279 |
|
|---|
| 2280 | Dim::SendCommand("FTM_CONTROL/DISABLE_ALL_PATCHES_EXCEPT", ihw);
|
|---|
| 2281 | }
|
|---|
| 2282 |
|
|---|
| 2283 | void on_fThresholdVal_valueChanged(int v)
|
|---|
| 2284 | {
|
|---|
| 2285 | fThresholdVolt->setValue(2500./4095*v);
|
|---|
| 2286 |
|
|---|
| 2287 | const int32_t isw = fThresholdIdx->value();
|
|---|
| 2288 | const int32_t ihw = fPatchMapHW[isw];
|
|---|
| 2289 |
|
|---|
| 2290 | const int32_t d[2] = { ihw, v };
|
|---|
| 2291 |
|
|---|
| 2292 | if (!fInHandler)
|
|---|
| 2293 | Dim::SendCommand("FTM_CONTROL/SET_THRESHOLD", d);
|
|---|
| 2294 | }
|
|---|
| 2295 |
|
|---|
| 2296 | TGraph fGraphFtmTemp[4];
|
|---|
| 2297 | TGraph fGraphFtmRate;
|
|---|
| 2298 | TGraph fGraphPatchRate[160];
|
|---|
| 2299 | TGraph fGraphBoardRate[40];
|
|---|
| 2300 |
|
|---|
| 2301 | #ifdef HAVE_ROOT
|
|---|
| 2302 | void DrawTimeFrame(const char *ytitle)
|
|---|
| 2303 | {
|
|---|
| 2304 | const double tm = Time().RootTime();
|
|---|
| 2305 |
|
|---|
| 2306 | TH1F h("TimeFrame", "", 1, tm, tm+60);//Time().RootTime()-1./24/60/60, Time().RootTime());
|
|---|
| 2307 | h.SetDirectory(0);
|
|---|
| 2308 | // h.SetBit(TH1::kCanRebin);
|
|---|
| 2309 | h.SetStats(kFALSE);
|
|---|
| 2310 | // h.SetMinimum(0);
|
|---|
| 2311 | // h.SetMaximum(1);
|
|---|
| 2312 | h.SetXTitle("Time");
|
|---|
| 2313 | h.SetYTitle(ytitle);
|
|---|
| 2314 | h.GetXaxis()->CenterTitle();
|
|---|
| 2315 | h.GetYaxis()->CenterTitle();
|
|---|
| 2316 | h.GetXaxis()->SetTimeDisplay(true);
|
|---|
| 2317 | h.GetXaxis()->SetTimeFormat("%Mh%S'");
|
|---|
| 2318 | h.GetXaxis()->SetLabelSize(0.025);
|
|---|
| 2319 | h.GetYaxis()->SetLabelSize(0.025);
|
|---|
| 2320 | h.GetYaxis()->SetTitleOffset(1.2);
|
|---|
| 2321 | // h.GetYaxis()->SetTitleSize(1.2);
|
|---|
| 2322 | h.DrawCopy()->SetDirectory(0);
|
|---|
| 2323 | }
|
|---|
| 2324 | #endif
|
|---|
| 2325 |
|
|---|
| 2326 | public:
|
|---|
| 2327 | FactGui() :
|
|---|
| 2328 | fFtuStatus(40),
|
|---|
| 2329 | fPixelMapHW(1440), fPatchMapHW(160), fPatchHW(1440),
|
|---|
| 2330 | fInChoosePatch(false),
|
|---|
| 2331 | fDimDNS("DIS_DNS/VERSION_NUMBER", 1, int(0), this),
|
|---|
| 2332 |
|
|---|
| 2333 | fDimLoggerStats ("DATA_LOGGER/STATS", (void*)NULL, 0, this),
|
|---|
| 2334 | fDimLoggerFilenameNight("DATA_LOGGER/FILENAME_NIGHTLY", const_cast<char*>(""), 0, this),
|
|---|
| 2335 | fDimLoggerFilenameRun ("DATA_LOGGER/FILENAME_RUN", const_cast<char*>(""), 0, this),
|
|---|
| 2336 | fDimLoggerNumSubs ("DATA_LOGGER/NUM_SUBS", const_cast<char*>(""), 0, this),
|
|---|
| 2337 |
|
|---|
| 2338 | fDimFtmPassport ("FTM_CONTROL/PASSPORT", (void*)NULL, 0, this),
|
|---|
| 2339 | fDimFtmTriggerCounter("FTM_CONTROL/TRIGGER_COUNTER", (void*)NULL, 0, this),
|
|---|
| 2340 | fDimFtmError ("FTM_CONTROL/ERROR", (void*)NULL, 0, this),
|
|---|
| 2341 | fDimFtmFtuList ("FTM_CONTROL/FTU_LIST", (void*)NULL, 0, this),
|
|---|
| 2342 | fDimFtmStaticData ("FTM_CONTROL/STATIC_DATA", (void*)NULL, 0, this),
|
|---|
| 2343 | fDimFtmDynamicData ("FTM_CONTROL/DYNAMIC_DATA", (void*)NULL, 0, this),
|
|---|
| 2344 | fDimFtmCounter ("FTM_CONTROL/COUNTER", (void*)NULL, 0, this),
|
|---|
| 2345 | fDimFadFiles ("FAD_CONTROL/FILES", (void*)NULL, 0, this),
|
|---|
| 2346 | fDimFadRuns ("FAD_CONTROL/RUNS", (void*)NULL, 0, this),
|
|---|
| 2347 | fDimFadEvents ("FAD_CONTROL/EVENTS", (void*)NULL, 0, this),
|
|---|
| 2348 | fDimFadCurrentEvent ("FAD_CONTROL/CURRENT_EVENT", (void*)NULL, 0, this),
|
|---|
| 2349 | fDimFadEventData ("FAD_CONTROL/EVENT_DATA", (void*)NULL, 0, this),
|
|---|
| 2350 | fDimFadConnections ("FAD_CONTROL/CONNECTIONS", (void*)NULL, 0, this),
|
|---|
| 2351 | fDimFadStatistics ("FAD_CONTROL/STATISTICS", (void*)NULL, 0, this)
|
|---|
| 2352 | {
|
|---|
| 2353 | fClockCondFreq->addItem("--- Hz", QVariant(-1));
|
|---|
| 2354 | fClockCondFreq->addItem("800 MHz", QVariant(800));
|
|---|
| 2355 | fClockCondFreq->addItem("1 GHz", QVariant(1000));
|
|---|
| 2356 | fClockCondFreq->addItem("2 GHz", QVariant(2000));
|
|---|
| 2357 | fClockCondFreq->addItem("3 GHz", QVariant(3000));
|
|---|
| 2358 | fClockCondFreq->addItem("4 GHz", QVariant(4000));
|
|---|
| 2359 | fClockCondFreq->addItem("5 GHz", QVariant(5000));
|
|---|
| 2360 |
|
|---|
| 2361 | fTriggerWidget->setEnabled(false);
|
|---|
| 2362 | fFtuWidget->setEnabled(false);
|
|---|
| 2363 | fRatesWidget->setEnabled(false);
|
|---|
| 2364 | // fFadWidget->setEnabled(false);
|
|---|
| 2365 | fLoggerWidget->setEnabled(false);
|
|---|
| 2366 |
|
|---|
| 2367 | fChatSend->setEnabled(false);
|
|---|
| 2368 | fChatMessage->setEnabled(false);
|
|---|
| 2369 |
|
|---|
| 2370 | DimClient::sendCommand("CHAT/MSG", "GUI online.");
|
|---|
| 2371 | // + MessageDimRX
|
|---|
| 2372 |
|
|---|
| 2373 | // --------------------------------------------------------------------------
|
|---|
| 2374 |
|
|---|
| 2375 | ifstream fin1("Trigger-Patches.txt");
|
|---|
| 2376 |
|
|---|
| 2377 | int l = 0;
|
|---|
| 2378 |
|
|---|
| 2379 | string buf;
|
|---|
| 2380 | while (getline(fin1, buf, '\n'))
|
|---|
| 2381 | {
|
|---|
| 2382 | buf = Tools::Trim(buf);
|
|---|
| 2383 | if (buf[0]=='#')
|
|---|
| 2384 | continue;
|
|---|
| 2385 |
|
|---|
| 2386 | stringstream str(buf);
|
|---|
| 2387 | for (int i=0; i<9; i++)
|
|---|
| 2388 | {
|
|---|
| 2389 | unsigned int n;
|
|---|
| 2390 | str >> n;
|
|---|
| 2391 |
|
|---|
| 2392 | if (n>=fPatchHW.size())
|
|---|
| 2393 | continue;
|
|---|
| 2394 |
|
|---|
| 2395 | fPatchHW[n] = l;
|
|---|
| 2396 | }
|
|---|
| 2397 | l++;
|
|---|
| 2398 | }
|
|---|
| 2399 |
|
|---|
| 2400 | if (l!=160)
|
|---|
| 2401 | cerr << "WARNING - Problems reading Trigger-Patches.txt" << endl;
|
|---|
| 2402 |
|
|---|
| 2403 | // --------------------------------------------------------------------------
|
|---|
| 2404 |
|
|---|
| 2405 | ifstream fin2("MasterList-v3.txt");
|
|---|
| 2406 |
|
|---|
| 2407 | l = 0;
|
|---|
| 2408 |
|
|---|
| 2409 | while (getline(fin2, buf, '\n'))
|
|---|
| 2410 | {
|
|---|
| 2411 | buf = Tools::Trim(buf);
|
|---|
| 2412 | if (buf[0]=='#')
|
|---|
| 2413 | continue;
|
|---|
| 2414 |
|
|---|
| 2415 | unsigned int softid, hardid, dummy;
|
|---|
| 2416 |
|
|---|
| 2417 | stringstream str(buf);
|
|---|
| 2418 |
|
|---|
| 2419 | str >> softid;
|
|---|
| 2420 | str >> dummy;
|
|---|
| 2421 | str >> hardid;
|
|---|
| 2422 |
|
|---|
| 2423 | if (softid>=fPixelMapHW.size())
|
|---|
| 2424 | continue;
|
|---|
| 2425 |
|
|---|
| 2426 | fPixelMapHW[softid] = hardid;
|
|---|
| 2427 |
|
|---|
| 2428 | l++;
|
|---|
| 2429 | }
|
|---|
| 2430 |
|
|---|
| 2431 | if (l!=1440)
|
|---|
| 2432 | cerr << "WARNING - Problems reading MasterList-v3.txt" << endl;
|
|---|
| 2433 |
|
|---|
| 2434 | // --------------------------------------------------------------------------
|
|---|
| 2435 |
|
|---|
| 2436 | ifstream fin3("PatchList.txt");
|
|---|
| 2437 |
|
|---|
| 2438 | l = 0;
|
|---|
| 2439 |
|
|---|
| 2440 | while (getline(fin3, buf, '\n'))
|
|---|
| 2441 | {
|
|---|
| 2442 | buf = Tools::Trim(buf);
|
|---|
| 2443 | if (buf[0]=='#')
|
|---|
| 2444 | continue;
|
|---|
| 2445 |
|
|---|
| 2446 | unsigned int softid, hardid;
|
|---|
| 2447 |
|
|---|
| 2448 | stringstream str(buf);
|
|---|
| 2449 |
|
|---|
| 2450 | str >> softid;
|
|---|
| 2451 | str >> hardid;
|
|---|
| 2452 |
|
|---|
| 2453 | if (softid>=fPatchMapHW.size())
|
|---|
| 2454 | continue;
|
|---|
| 2455 |
|
|---|
| 2456 | fPatchMapHW[softid] = hardid-1;
|
|---|
| 2457 |
|
|---|
| 2458 | l++;
|
|---|
| 2459 | }
|
|---|
| 2460 |
|
|---|
| 2461 | if (l!=160)
|
|---|
| 2462 | cerr << "WARNING - Problems reading PatchList.txt" << endl;
|
|---|
| 2463 |
|
|---|
| 2464 | // --------------------------------------------------------------------------
|
|---|
| 2465 | #ifdef HAVE_ROOT
|
|---|
| 2466 |
|
|---|
| 2467 | fGraphFtmRate.SetLineColor(kBlue);
|
|---|
| 2468 | fGraphFtmRate.SetMarkerColor(kBlue);
|
|---|
| 2469 | fGraphFtmRate.SetMarkerStyle(kFullDotMedium);
|
|---|
| 2470 |
|
|---|
| 2471 | for (int i=0; i<160; i++)
|
|---|
| 2472 | {
|
|---|
| 2473 | fGraphPatchRate[i].SetName("PatchRate");
|
|---|
| 2474 | //fGraphPatchRate[i].SetLineColor(kBlue);
|
|---|
| 2475 | //fGraphPatchRate[i].SetMarkerColor(kBlue);
|
|---|
| 2476 | fGraphPatchRate[i].SetMarkerStyle(kFullDotMedium);
|
|---|
| 2477 | }
|
|---|
| 2478 | for (int i=0; i<40; i++)
|
|---|
| 2479 | {
|
|---|
| 2480 | fGraphBoardRate[i].SetName("BoardRate");
|
|---|
| 2481 | //fGraphBoardRate[i].SetLineColor(kBlue);
|
|---|
| 2482 | //fGraphBoardRate[i].SetMarkerColor(kBlue);
|
|---|
| 2483 | fGraphBoardRate[i].SetMarkerStyle(kFullDotMedium);
|
|---|
| 2484 | }
|
|---|
| 2485 | /*
|
|---|
| 2486 | TCanvas *c = fFtmTempCanv->GetCanvas();
|
|---|
| 2487 | c->SetBit(TCanvas::kNoContextMenu);
|
|---|
| 2488 | c->SetBorderMode(0);
|
|---|
| 2489 | c->SetFrameBorderMode(0);
|
|---|
| 2490 | c->SetFillColor(kWhite);
|
|---|
| 2491 | c->SetRightMargin(0.03);
|
|---|
| 2492 | c->SetTopMargin(0.03);
|
|---|
| 2493 | c->cd();
|
|---|
| 2494 | */
|
|---|
| 2495 | //CreateTimeFrame("Temperature / °C");
|
|---|
| 2496 |
|
|---|
| 2497 | fGraphFtmTemp[0].SetMarkerStyle(kFullDotSmall);
|
|---|
| 2498 | fGraphFtmTemp[1].SetMarkerStyle(kFullDotSmall);
|
|---|
| 2499 | fGraphFtmTemp[2].SetMarkerStyle(kFullDotSmall);
|
|---|
| 2500 | fGraphFtmTemp[3].SetMarkerStyle(kFullDotSmall);
|
|---|
| 2501 |
|
|---|
| 2502 | fGraphFtmTemp[1].SetLineColor(kBlue);
|
|---|
| 2503 | fGraphFtmTemp[2].SetLineColor(kRed);
|
|---|
| 2504 | fGraphFtmTemp[3].SetLineColor(kGreen);
|
|---|
| 2505 |
|
|---|
| 2506 | fGraphFtmTemp[1].SetMarkerColor(kBlue);
|
|---|
| 2507 | fGraphFtmTemp[2].SetMarkerColor(kRed);
|
|---|
| 2508 | fGraphFtmTemp[3].SetMarkerColor(kGreen);
|
|---|
| 2509 |
|
|---|
| 2510 | //fGraphFtmTemp[0].Draw("LP");
|
|---|
| 2511 | //fGraphFtmTemp[1].Draw("LP");
|
|---|
| 2512 | //fGraphFtmTemp[2].Draw("LP");
|
|---|
| 2513 | //fGraphFtmTemp[3].Draw("LP");
|
|---|
| 2514 |
|
|---|
| 2515 | // --------------------------------------------------------------------------
|
|---|
| 2516 |
|
|---|
| 2517 | TCanvas *c = fFtmRateCanv->GetCanvas();
|
|---|
| 2518 | //c->SetBit(TCanvas::kNoContextMenu);
|
|---|
| 2519 | c->SetBorderMode(0);
|
|---|
| 2520 | c->SetFrameBorderMode(0);
|
|---|
| 2521 | c->SetFillColor(kWhite);
|
|---|
| 2522 | c->SetRightMargin(0.03);
|
|---|
| 2523 | c->SetTopMargin(0.03);
|
|---|
| 2524 | c->SetGrid();
|
|---|
| 2525 | c->cd();
|
|---|
| 2526 |
|
|---|
| 2527 | DrawTimeFrame("Trigger rate [Hz]");
|
|---|
| 2528 |
|
|---|
| 2529 | fTriggerCounter0 = -1;
|
|---|
| 2530 |
|
|---|
| 2531 | fGraphFtmRate.SetMarkerStyle(kFullDotSmall);
|
|---|
| 2532 | fGraphFtmRate.Draw("LP");
|
|---|
| 2533 |
|
|---|
| 2534 | // --------------------------------------------------------------------------
|
|---|
| 2535 |
|
|---|
| 2536 | c = fRatesCanv->GetCanvas();
|
|---|
| 2537 | //c->SetBit(TCanvas::kNoContextMenu);
|
|---|
| 2538 | c->SetBorderMode(0);
|
|---|
| 2539 | c->SetFrameBorderMode(0);
|
|---|
| 2540 | c->SetFillColor(kWhite);
|
|---|
| 2541 | c->cd();
|
|---|
| 2542 |
|
|---|
| 2543 | Camera *cam = new Camera;
|
|---|
| 2544 | cam->SetBit(kCanDelete);
|
|---|
| 2545 | cam->Draw();
|
|---|
| 2546 |
|
|---|
| 2547 | ChoosePixel(*cam, 0);
|
|---|
| 2548 |
|
|---|
| 2549 | // --------------------------------------------------------------------------
|
|---|
| 2550 |
|
|---|
| 2551 | c = fAdcDataCanv->GetCanvas();
|
|---|
| 2552 | c->SetBit(TCanvas::kNoContextMenu);
|
|---|
| 2553 | c->SetBorderMode(0);
|
|---|
| 2554 | c->SetFrameBorderMode(0);
|
|---|
| 2555 | c->SetFillColor(kWhite);
|
|---|
| 2556 | c->SetGrid();
|
|---|
| 2557 | c->cd();
|
|---|
| 2558 |
|
|---|
| 2559 | // Create histogram?
|
|---|
| 2560 |
|
|---|
| 2561 | // --------------------------------------------------------------------------
|
|---|
| 2562 |
|
|---|
| 2563 | // QTimer::singleShot(0, this, SLOT(slot_RootUpdate()));
|
|---|
| 2564 |
|
|---|
| 2565 | //widget->setMouseTracking(true);
|
|---|
| 2566 | //widget->EnableSignalEvents(kMouseMoveEvent);
|
|---|
| 2567 |
|
|---|
| 2568 | fFtmRateCanv->setMouseTracking(true);
|
|---|
| 2569 | fFtmRateCanv->EnableSignalEvents(kMouseMoveEvent);
|
|---|
| 2570 |
|
|---|
| 2571 | fAdcDataCanv->setMouseTracking(true);
|
|---|
| 2572 | fAdcDataCanv->EnableSignalEvents(kMouseMoveEvent);
|
|---|
| 2573 |
|
|---|
| 2574 | fRatesCanv->setMouseTracking(true);
|
|---|
| 2575 | fRatesCanv->EnableSignalEvents(kMouseMoveEvent|kMouseReleaseEvent|kMouseDoubleClickEvent);
|
|---|
| 2576 |
|
|---|
| 2577 | connect(fRatesCanv, SIGNAL( RootEventProcessed(TObject*, unsigned int, TCanvas*)),
|
|---|
| 2578 | this, SLOT (slot_RootEventProcessed(TObject*, unsigned int, TCanvas*)));
|
|---|
| 2579 | connect(fFtmRateCanv, SIGNAL( RootEventProcessed(TObject*, unsigned int, TCanvas*)),
|
|---|
| 2580 | this, SLOT (slot_RootEventProcessed(TObject*, unsigned int, TCanvas*)));
|
|---|
| 2581 | connect(fAdcDataCanv, SIGNAL( RootEventProcessed(TObject*, unsigned int, TCanvas*)),
|
|---|
| 2582 | this, SLOT (slot_RootEventProcessed(TObject*, unsigned int, TCanvas*)));
|
|---|
| 2583 | #endif
|
|---|
| 2584 | }
|
|---|
| 2585 |
|
|---|
| 2586 | ~FactGui()
|
|---|
| 2587 | {
|
|---|
| 2588 | UnsubscribeAllServers();
|
|---|
| 2589 | }
|
|---|
| 2590 | };
|
|---|
| 2591 |
|
|---|
| 2592 | #endif
|
|---|