void uptime(UInt_t minutes=120, Bool_t alarm=kFALSE, Bool_t accum=kFALSE) { Bool_t done; ofstream outfile, outfile2, outfile3, outfile4; UInt_t reg; TDatime date; Int_t time, hour, min, startDate, startBin; Int_t startY, startM, startD, stopY, stopM, stopD, days; TStopwatch timer,globalTimer; outfile.open("uptime.log"); outfile2.open("all_uptime.log",ios::app); outfile3.open("all_accum.log",ios::app); outfile4.open("all_accum.times",ios::app); outfile2 << "starting new session..." << endl; date = new TDatime; date.Set(); if (accum) { startDate = date.GetDate(); startD = startDate % 100; startDate /= 100; startM = startDate % 100; startY = startDate / 100; time = date.GetTime(); time /= 100; min = time % 100; hour = (time - min) / 100; outfile4 << startM << " " << startD << " " << hour << " "; } globalTimer.Start(kTRUE); while(globalTimer.RealTime() < 60*minutes) { globalTimer.Continue(); done = kFALSE; timer.Start(kTRUE); wrcntrl(defControl,0); while (!done) { gSystem -> Sleep(1000); reg = readcr(0); cout << "reg =" << (void*) reg << endl; if ((reg != (defControl | 0x80000000)) && reg != 0) { timer.Stop(); date.Set(); cout << "Reset after " << timer.RealTime() << " sec" << endl; if (alarm) cout << (char)7 << endl; outfile << timer.RealTime() << endl; outfile2 << timer.RealTime() << "\t" << date.AsString() << endl; if (accum) outfile3 << timer.RealTime() << "\t" << date.AsString() << endl; time = date.GetTime(); time /= 100; min = time % 100; hour = (time - min) / 100; done = kTRUE; } } } if (accum) { date.Set(); startDate = date.GetDate(); startD = startDate % 100; startDate /= 100; startM = startDate % 100; startY = startDate / 100; time = date.GetTime(); time /= 100; min = time % 100; hour = (time - min) / 100; outfile4 << startM << " " << startD << " " << hour << endl; } delete date; } void plotUptime() { gROOT -> Reset(); FILE *fp = fopen("uptime.log","r"); Float_t x; Int_t n,nRead; TH1F *h1=new TH1F("h1","uptime distribution",100,0,200); while (1) { nRead = fscanf(fp,"%f",&x); if (nRead < 0) break; cout << x << endl; h1 -> Fill(x); } fclose(fp); h1 -> Draw("e1p"); } StsDumpCallback call(cout,StsDumpCallback::synch); StsDumpCallback* callbackP = &call; UInt_t readcr(int chip=0, int read=rLeft) { UInt_t ret; StsGeoAddress gAddr; cout << endl << "entered readcr okay" << endl; cout << "defRom = " << defRom << endl; gAddr.ROM (defRom); cout << "defChannel = " << defChannel << endl; gAddr.Channel (defChannel); cout << "chip = " << chip << endl; gAddr.Chip (chip); cout << "read = " << read << endl; gAddr.ReadDir (read); cout << "creating read cmd" << endl; StsCommand* cmdP = new StsChipCommand(gAddr, StsChipCommand::kReadRegisters, NULL, callbackP); cmdP -> CanDelete(kFALSE); call.SetWait(cmdP); cout << "read cmd prepared" << endl; cmdP -> Send(); call.Wait(cmdP); cout << "sent..." << endl; //while (cmdP->GetReply()==NULL) //gSystem -> Sleep(1); if (!cmdP -> GetReply() -> InheritsFrom(StsChipReply::Class())) { cout << "received a messed up reply" << endl; delete cmdP; cout << "deleted" << endl; return 0x80000000; } cout << "rec'd a reply" << endl; StsChipReply* repP = cmdP->GetReply(); cout << "repP = " << (void*) repP << endl; if (!repP) return 0x80000000; StsChipData* dataP = repP -> GetData(); cout << "dataP = " << (void*) dataP << endl; if (!dataP) return 0x80000000; StsChipDataElemReadRegs* rdP = (StsChipDataElemReadRegs*) dataP -> First(); cout << "rdP = " << (void*) rdP << endl; if (!rdP) return 0x80000000; cout << "fcr = " << (void*) (rdP->fControlRegister) << endl; ret = rdP -> fControlRegister; cout << "cmdP = " << (void*)cmdP << endl; delete cmdP; cout << "returning..." << endl; return ret; } void readmr(int chip=0, int read=rLeft, StsAtomMask *calMask, StsAtomMask *chaMask) { UInt_t ret; StsGeoAddress gAddr; calMask -> SetAllBits(0); chaMask -> SetAllBits(0); gAddr.ROM (defRom); gAddr.Channel (defChannel); gAddr.Chip (chip); gAddr.ReadDir (read); StsCommand* cmdP = new StsChipCommand(gAddr, StsChipCommand::kReadRegisters, NULL, callbackP); cmdP -> CanDelete(kFALSE); cmdP -> Send(); while (cmdP->GetReply()==NULL) gSystem -> Sleep(1); cout << "rec'd a reply" << endl; StsChipReply* repP = cmdP->GetReply(); if (!repP) return; StsChipData* dataP = repP -> GetData(); if (!dataP) return; StsChipDataElemReadRegs* rdP = (StsChipDataElemReadRegs*) dataP -> First(); if (!rdP) return; rdP -> GetCalMask(*calMask); rdP -> GetChaMask(*chaMask); delete cmdP; }