From eba7684839248763c0cc421fbfdfc509a5dd70c0 Mon Sep 17 00:00:00 2001 From: jgrosseo Date: Mon, 6 Nov 2006 14:23:04 +0000 Subject: [PATCH] major update (Alberto) o) reading of run parameters from the logbook o) online offline naming conversion o) standalone DCSclient package --- SHUTTLE/AliShuttle.cxx | 247 ++++---- SHUTTLE/AliShuttle.h | 13 +- SHUTTLE/AliShuttleConfig.cxx | 21 +- SHUTTLE/AliShuttleLogbookEntry.cxx | 334 ++++------- SHUTTLE/AliShuttleLogbookEntry.h | 38 +- SHUTTLE/{ => DCSClient}/AliDCSClient.cxx | 13 +- SHUTTLE/{ => DCSClient}/AliDCSClient.h | 17 +- SHUTTLE/{ => DCSClient}/AliDCSMessage.cxx | 22 +- SHUTTLE/{ => DCSClient}/AliDCSMessage.h | 0 SHUTTLE/DCSClient/DCSClientLinkDef.h | 17 + SHUTTLE/DCSClient/Makefile | 61 ++ SHUTTLE/DCSClient/Makefile.arch | 552 ++++++++++++++++++ SHUTTLE/DCSClient/macros/LinkDef.h | 13 + SHUTTLE/DCSClient/macros/Makefile | 59 ++ .../macros}/TestAliSimpleValue.C | 0 .../{test => DCSClient/macros}/TestClient.C | 0 .../macros}/TestClientAlias.C | 19 +- .../{test => DCSClient/macros}/TestClientDP.C | 28 +- .../{test => DCSClient/macros}/TestServer.C | 0 .../{test => DCSClient/macros}/TestServer.cxx | 0 .../{test => DCSClient/macros}/TestServer.h | 0 SHUTTLE/SHUTTLELinkDef.h | 4 +- SHUTTLE/Shuttle.C | 7 +- SHUTTLE/TestShuttle/AliTestPreprocessor.cxx | 13 + SHUTTLE/TestShuttle/AliTestShuttle.cxx | 51 +- SHUTTLE/TestShuttle/AliTestShuttle.h | 14 +- SHUTTLE/TestShuttle/Makefile | 2 +- SHUTTLE/TestShuttle/TestPreprocessor.C | 27 +- SHUTTLE/libSHUTTLE.pkg | 8 +- SHUTTLE/test/LinkDef.h | 4 +- SHUTTLE/test/Makefile | 3 +- SHUTTLE/test/README | 40 -- SHUTTLE/test/TestClientAlbe.C | 117 ---- ...ocessor.cxx => TestITSPreprocessorSPD.cxx} | 18 +- SHUTTLE/test/TestITSPreprocessorSPD.h | 25 + SHUTTLE/test/TestMessage.C | 318 ---------- SHUTTLE/test/TestRICHPreprocessor.cxx | 2 +- SHUTTLE/test/TestShuttleLogbook.C | 293 ++++++++++ SHUTTLE/test/TestTPCPreprocessor.cxx | 4 +- SHUTTLE/test/TestTPCPreprocessor.h | 2 +- SHUTTLE/test/TestZDCPreprocessor.cxx | 81 +++ ...TSPreprocessor.h => TestZDCPreprocessor.h} | 12 +- 42 files changed, 1545 insertions(+), 954 deletions(-) rename SHUTTLE/{ => DCSClient}/AliDCSClient.cxx (98%) rename SHUTTLE/{ => DCSClient}/AliDCSClient.h (88%) rename SHUTTLE/{ => DCSClient}/AliDCSMessage.cxx (98%) rename SHUTTLE/{ => DCSClient}/AliDCSMessage.h (100%) create mode 100644 SHUTTLE/DCSClient/DCSClientLinkDef.h create mode 100644 SHUTTLE/DCSClient/Makefile create mode 100644 SHUTTLE/DCSClient/Makefile.arch create mode 100644 SHUTTLE/DCSClient/macros/LinkDef.h create mode 100644 SHUTTLE/DCSClient/macros/Makefile rename SHUTTLE/{test => DCSClient/macros}/TestAliSimpleValue.C (100%) rename SHUTTLE/{test => DCSClient/macros}/TestClient.C (100%) rename SHUTTLE/{test => DCSClient/macros}/TestClientAlias.C (86%) rename SHUTTLE/{test => DCSClient/macros}/TestClientDP.C (85%) rename SHUTTLE/{test => DCSClient/macros}/TestServer.C (100%) rename SHUTTLE/{test => DCSClient/macros}/TestServer.cxx (100%) rename SHUTTLE/{test => DCSClient/macros}/TestServer.h (100%) delete mode 100644 SHUTTLE/test/README delete mode 100644 SHUTTLE/test/TestClientAlbe.C rename SHUTTLE/test/{TestITSPreprocessor.cxx => TestITSPreprocessorSPD.cxx} (82%) create mode 100644 SHUTTLE/test/TestITSPreprocessorSPD.h delete mode 100644 SHUTTLE/test/TestMessage.C create mode 100644 SHUTTLE/test/TestShuttleLogbook.C create mode 100644 SHUTTLE/test/TestZDCPreprocessor.cxx rename SHUTTLE/test/{TestITSPreprocessor.h => TestZDCPreprocessor.h} (52%) diff --git a/SHUTTLE/AliShuttle.cxx b/SHUTTLE/AliShuttle.cxx index 68396bfa293..abc17f0acf6 100644 --- a/SHUTTLE/AliShuttle.cxx +++ b/SHUTTLE/AliShuttle.cxx @@ -15,6 +15,11 @@ /* $Log$ +Revision 1.18 2006/10/20 15:22:59 jgrosseo +o) Adding time out to the execution of the preprocessors: The Shuttle forks and the parent process monitors the child +o) Merging Collect, CollectAll, CollectNew function +o) Removing implementation of empty copy constructors (declaration still there!) + Revision 1.17 2006/10/05 16:20:55 jgrosseo adapting to new CDB classes @@ -125,7 +130,7 @@ some docs added #include "AliCDBPath.h" #include "AliCDBEntry.h" #include "AliShuttleConfig.h" -#include "AliDCSClient.h" +#include "DCSClient/AliDCSClient.h" #include "AliLog.h" #include "AliPreprocessor.h" #include "AliShuttleStatus.h" @@ -155,16 +160,9 @@ TString AliShuttle::fgkLocalRefStorage("local://LocalReferenceStorage"); Bool_t AliShuttle::fgkProcessDCS(kTRUE); - const char* AliShuttle::fgkShuttleTempDir = gSystem->ExpandPathName("$ALICE_ROOT/SHUTTLE/temp"); const char* AliShuttle::fgkShuttleLogDir = gSystem->ExpandPathName("$ALICE_ROOT/SHUTTLE/log"); -const char* AliShuttle::fgkDetectorName[AliShuttle::kNDetectors] = {"SPD", "SDD", "SSD", "TPC", "TRD", "TOF", - "PHOS", "CPV", "RICH", "EMCAL", "MUON_TRK", "MUON_TRG", "FMD", "ZDC", "PMD", "START", "VZERO"}; - -const char* AliShuttle::fgkDetectorCode[AliShuttle::kNDetectors] = {"SPD", "SDD", "SSD", "TPC", "TRD", "TOF", - "PHS", "CPV", "HMP", "EMC", "MCH", "MTR", "FMD", "ZDC", "PMD", "T00", "V00"}; - //______________________________________________________________________________________________ AliShuttle::AliShuttle(const AliShuttleConfig* config, UInt_t timeout, Int_t retries): @@ -172,11 +170,12 @@ fConfig(config), fTimeout(timeout), fRetries(retries), fPreprocessorMap(), fLogbookEntry(0), -fCurrentDetector(""), +fCurrentDetector(), fStatusEntry(0), fGridError(kFALSE), fMonitoringMutex(0), -fLastActionTime(0) +fLastActionTime(0), +fLastAction() { // // config: AliShuttleConfig used @@ -204,7 +203,7 @@ AliShuttle::~AliShuttle() if(fServer[iSys]) { fServer[iSys]->Close(); delete fServer[iSys]; - fServer[iSys] = 0; + fServer[iSys] = 0; } if (fStatusEntry){ @@ -229,13 +228,16 @@ void AliShuttle::RegisterPreprocessor(AliPreprocessor* preprocessor) // with the same identificator (GetName()). // - if (fPreprocessorMap.GetValue(preprocessor->GetName())) { - AliWarning(Form("AliPreprocessor %s is already registered!", - preprocessor->GetName())); + const char* detName = preprocessor->GetName(); + if(GetDetPos(detName) < 0) + AliFatal(Form("********** !!!!! Invalid detector name: %s !!!!! **********", detName)); + + if (fPreprocessorMap.GetValue(detName)) { + AliWarning(Form("AliPreprocessor %s is already registered!", detName)); return; } - fPreprocessorMap.Add(new TObjString(preprocessor->GetName()), preprocessor); + fPreprocessorMap.Add(new TObjString(detName), preprocessor); } //______________________________________________________________________________________________ UInt_t AliShuttle::Store(const AliCDBPath& path, TObject* object, @@ -407,9 +409,10 @@ void AliShuttle::UpdateShuttleStatus(AliShuttleStatus::Status newStatus, Bool_t return; } - TString actionStr; - actionStr.Form("UpdateShuttleStatus - %s: Changing state from %s to %s", fCurrentDetector.Data(), - status->GetStatusName(), status->GetStatusName(newStatus)); + TString actionStr = Form("UpdateShuttleStatus - %s: Changing state from %s to %s", + fCurrentDetector.Data(), + status->GetStatusName(), + status->GetStatusName(newStatus)); Log("SHUTTLE", actionStr); SetLastAction(actionStr); @@ -425,17 +428,11 @@ Bool_t AliShuttle::ContinueProcessing() // checks if the processing should be continued // if yes it returns kTRUE and updates the AliShuttleStatus with nextStatus - if(!GetDetCode(fCurrentDetector)) { - Log("SHUTTLE", Form("ContinueProcessing - %s: unknown detector", - fCurrentDetector.Data())); - return kFALSE; - } - AliShuttleLogbookEntry::Status entryStatus = - fLogbookEntry->GetDetectorStatus(GetDetCode(fCurrentDetector)); + fLogbookEntry->GetDetectorStatus(fCurrentDetector); if(entryStatus != AliShuttleLogbookEntry::kUnprocessed) { - Log("SHUTTLE", Form("ContinueProcessing - %s is already %s", + Log("SHUTTLE", Form("ContinueProcessing - %s is %s", fCurrentDetector.Data(), fLogbookEntry->GetDetectorStatusName(entryStatus))); return kFALSE; @@ -482,7 +479,6 @@ Bool_t AliShuttle::ContinueProcessing() // if we get here, there is a restart // abort conditions - // TODO we should add two counters, one for PP and one for DCS! if (status->GetCount() >= fConfig->GetMaxRetries()) { Log("SHUTTLE", Form("ContinueProcessing - %s failed %d times in status %s - Updating Shuttle Logbook", @@ -492,7 +488,7 @@ Bool_t AliShuttle::ContinueProcessing() return kFALSE; } - Log("SHUTTLE", Form("ContinueProcessing - %s: restarting. Got stuck before in %s. Retry number %d.", + Log("SHUTTLE", Form("ContinueProcessing - %s: restarting. Aborted before with %s. Retry number %d.", fCurrentDetector.Data(), status->GetStatusName(), status->GetCount())); @@ -526,7 +522,7 @@ Bool_t AliShuttle::Process(AliShuttleLogbookEntry* entry) AliInfo(Form("\n\n \t\t\t^*^*^*^*^*^*^*^*^*^*^*^* run %d: START ^*^*^*^*^*^*^*^*^*^*^*^* \n", GetCurrentRun())); - fLogbookEntry->Print(""); + fLogbookEntry->Print("all"); // Initialization Bool_t hasError = kFALSE; @@ -549,7 +545,8 @@ Bool_t AliShuttle::Process(AliShuttleLogbookEntry* entry) AliPreprocessor* aPreprocessor = dynamic_cast (fPreprocessorMap.GetValue(fCurrentDetector)); if(!aPreprocessor){ - Log("SHUTTLE",Form("Process: no preprocessor registered. Skipping %s", fCurrentDetector.Data())); + Log("SHUTTLE",Form("Process - %s: no preprocessor registered. Skipping", + fCurrentDetector.Data())); continue; } @@ -802,30 +799,15 @@ Bool_t AliShuttle::QueryShuttleLogbook(const char* whereClause, TString runString(aRow->GetField(0), aRow->GetFieldLength(0)); Int_t run = runString.Atoi(); - UInt_t startTime, endTime; - if(!QueryRunParameters(run, startTime, endTime)) continue; - - const UInt_t nDet = AliShuttle::kNDetectors; - AliShuttleLogbookEntry::Status detStatus[nDet]; + AliShuttleLogbookEntry *entry = QueryRunParameters(run); + if (!entry) + continue; // loop on detectors - for(UInt_t ii = 0; ii < nCols; ii++){ - TString detCode(aResult->GetFieldName(ii)); - Int_t detPos = AliShuttle::GetDetPos(detCode.Data()); - if(detPos < 0) continue; - TString statusString(aRow->GetField(ii), aRow->GetFieldLength(ii)); - if(statusString == "UNPROCESSED"){ - detStatus[detPos] = AliShuttleLogbookEntry::kUnprocessed; - } else if (statusString == "INACTIVE") { - detStatus[detPos] = AliShuttleLogbookEntry::kInactive; - } else if (statusString == "FAILED") { - detStatus[detPos] = AliShuttleLogbookEntry::kFailed; - } else if (statusString == "DONE") { - detStatus[detPos] = AliShuttleLogbookEntry::kDone; - } - } + for(UInt_t ii = 0; ii < nCols; ii++) + entry->SetDetectorStatus(aResult->GetFieldName(ii), aRow->GetField(ii)); - entries.AddLast(new AliShuttleLogbookEntry(run, startTime, endTime, detStatus)); + entries.AddLast(entry); delete aRow; } @@ -837,58 +819,67 @@ Bool_t AliShuttle::QueryShuttleLogbook(const char* whereClause, } //______________________________________________________________________________________________ -Bool_t AliShuttle::QueryRunParameters(Int_t& run, UInt_t& startTime, UInt_t& endTime) +AliShuttleLogbookEntry* AliShuttle::QueryRunParameters(Int_t run) { -// Retrieve start time and end time for run in the DAQ logbook + // + // Retrieve run parameters written in the DAQ logbook and sets them into AliShuttleLogbookEntry object + // // check connection, in case connect - if(!Connect(kDAQ)) return kFALSE; + if (!Connect(kDAQ)) + return 0; TString sqlQuery; - sqlQuery = Form("select time_start, time_end from logbook where run=%d", run); + sqlQuery.Form("select * from logbook where run=%d", run); TSQLResult* aResult = fServer[kDAQ]->Query(sqlQuery); if (!aResult) { AliError(Form("Can't execute query <%s>!", sqlQuery.Data())); - return kFALSE; + return 0; } - if(aResult->GetRowCount() == 0) { + if (aResult->GetRowCount() == 0) { Log("SHUTTLE", Form("QueryRunParameters - No entry in DAQ Logbook for run %d. Skipping", run)); delete aResult; - return kFALSE; + return 0; } - if(aResult->GetRowCount() > 1) { + if (aResult->GetRowCount() > 1) { AliError(Form("More than one entry in DAQ Logbook for run %d. Skipping", run)); delete aResult; - return kFALSE; + return 0; } - TSQLRow* aRow; - while ((aRow = aResult->Next())) { + TSQLRow* aRow = aResult->Next(); + if (!aRow) + { + AliError(Form("Could not retrieve row for run %d. Skipping", run)); + delete aResult; + return 0; + } - TString startTimeString(aRow->GetField(0), - aRow->GetFieldLength(0)); - startTime = startTimeString.Atoi(); - TString endTimeString(aRow->GetField(1), - aRow->GetFieldLength(1)); - endTime = endTimeString.Atoi(); + AliShuttleLogbookEntry* entry = new AliShuttleLogbookEntry(run); - if (!startTime || !endTime || startTime > endTime) { - Log("SHUTTLE", - Form("QueryRunParameters - Invalid parameters for Run %d: startTime = %d, endTime = %d", - run, startTime, endTime)); - delete aRow; - delete aResult; - return kFALSE; - } + for (Int_t ii = 0; ii < aResult->GetFieldCount(); ii++) + entry->SetRunParameter(aResult->GetFieldName(ii), aRow->GetField(ii)); + UInt_t startTime = entry->GetStartTime(); + UInt_t endTime = entry->GetEndTime(); + + if (!startTime || !endTime || startTime > endTime) { + Log("SHUTTLE", + Form("QueryRunParameters - Invalid parameters for Run %d: startTime = %d, endTime = %d", + run, startTime, endTime)); + delete entry; delete aRow; + delete aResult; + return 0; } + delete aRow; delete aResult; - return kTRUE; + + return entry; } //______________________________________________________________________________________________ @@ -942,7 +933,7 @@ Bool_t AliShuttle::TryToStoreAgain(TString& gridURI) // get objects previously stored in local CDB AliCDBStorage *backupSto = man->GetStorage(backupURI); - AliCDBPath aPath(fCurrentDetector,"*","*"); + AliCDBPath aPath(GetOfflineDetName(fCurrentDetector.Data()),"*","*"); // Local objects were stored with current run as Grid version! TList* localEntries = backupSto->GetAll(aPath.GetPath(), GetCurrentRun(), GetCurrentRun()); localEntries->SetOwner(1); @@ -1107,7 +1098,8 @@ Bool_t AliShuttle::Connect(Int_t system) fConfig->GetFESlbUser(system), fConfig->GetFESlbPass(system)); if (!fServer[system] || !fServer[system]->IsConnected()) { - AliError(Form("Can't establish connection to FES logbook for %s",fkSystemNames[system])); + AliError(Form("Can't establish connection to FES logbook for %s", + AliShuttleInterface::GetSystemName(system))); if(fServer[system]) delete fServer[system]; return kFALSE; } @@ -1140,12 +1132,13 @@ const char* AliShuttle::GetDAQFileName(const char* detector, const char* id, con // First queris the DAQ logbook_fs for the DAQ file name, using the run, detector, id and source info // then calls RetrieveDAQFile(DAQfilename) for actual copy to local disk // run: current run being processed (given by Logbook entry fLogbookEntry) -// detector: comes from the Preprocessor name (must be converted into detector code with GetDetCode) +// detector: the Preprocessor name // id: provided as a parameter by the Preprocessor // source: provided by the Preprocessor through GetFileSources function // check connection, in case connect - if(!Connect(kDAQ)){ + if (!Connect(kDAQ)) + { Log(detector, "GetDAQFileName - Couldn't connect to DAQ Logbook"); return 0; } @@ -1153,7 +1146,7 @@ const char* AliShuttle::GetDAQFileName(const char* detector, const char* id, con // Query preparation TString sqlQueryStart = "select filePath from logbook_fs where"; TString whereClause = Form("run=%d and detector=\"%s\" and fileId=\"%s\" and DAQsource=\"%s\"", - GetCurrentRun(), GetDetCode(detector), id, source); + GetCurrentRun(), detector, id, source); TString sqlQuery = Form("%s %s", sqlQueryStart.Data(), whereClause.Data()); AliDebug(2, Form("SQL query: \n%s",sqlQuery.Data())); @@ -1167,7 +1160,8 @@ const char* AliShuttle::GetDAQFileName(const char* detector, const char* id, con return 0; } - if (aResult->GetRowCount() == 0) { + if(aResult->GetRowCount() == 0) + { Log(detector, Form("GetDAQFileName - No entry in FES table for: id = %s, source = %s", id, source)); @@ -1175,7 +1169,7 @@ const char* AliShuttle::GetDAQFileName(const char* detector, const char* id, con return 0; } - if (aResult->GetRowCount() >1) { + if (aResult->GetRowCount() > 1) { Log(detector, Form("GetDAQFileName - More than one entry in FES table for: id = %s, source = %s", id, source)); @@ -1185,7 +1179,7 @@ const char* AliShuttle::GetDAQFileName(const char* detector, const char* id, con TSQLRow* aRow = dynamic_cast (aResult->Next()); - if(!aRow){ + if (!aRow){ Log(detector, Form("GetDAQFileName - Empty set result from query: id = %s, source = %s", id, source)); delete aResult; @@ -1279,7 +1273,7 @@ TList* AliShuttle::GetDAQFileSources(const char* detector, const char* id) // Query preparation TString sqlQueryStart = "select DAQsource from logbook_fs where"; TString whereClause = Form("run=%d and detector=\"%s\" and fileId=\"%s\"", - GetCurrentRun(), GetDetCode(detector), id); + GetCurrentRun(), detector, id); TString sqlQuery = Form("%s %s", sqlQueryStart.Data(), whereClause.Data()); AliDebug(2, Form("SQL query: \n%s",sqlQuery.Data())); @@ -1376,7 +1370,7 @@ Bool_t AliShuttle::UpdateDAQTable() const char* fileId = ((TObjString*) aFESarray->At(0))->GetName(); const char* daqSource = ((TObjString*) aFESarray->At(1))->GetName(); TString whereClause = Form("where run=%d and detector=\"%s\" and fileId=\"%s\" and DAQsource=\"%s\";", - GetCurrentRun(), GetDetCode(fCurrentDetector), fileId, daqSource); + GetCurrentRun(), fCurrentDetector.Data(), fileId, daqSource); delete aFESarray; @@ -1415,15 +1409,10 @@ Bool_t AliShuttle::UpdateShuttleLogbook(const char* detector, const char* status if(detName == "shuttle_done") { setClause = "set shuttle_done=1"; } else { - TString detCode = GetDetCode(detector); - if(detCode.IsNull()) { - Log("SHUTTLE", Form("UpdateShuttleLogbook - Unknown detector %s", detector)); - return kFALSE; - } TString statusStr(status); if(statusStr.Contains("done", TString::kIgnoreCase) || statusStr.Contains("failed", TString::kIgnoreCase)){ - setClause = Form("set %s=\"%s\"", detCode.Data(), status); + setClause = Form("set %s=\"%s\"", detector, status); } else { Log("SHUTTLE", Form("UpdateShuttleLogbook - Invalid status <%s> for detector %s", @@ -1475,39 +1464,6 @@ UInt_t AliShuttle::GetCurrentEndTime() const return fLogbookEntry ? fLogbookEntry->GetEndTime() : 0; } -//______________________________________________________________________________________________ -const char* AliShuttle::GetDetCode(const char* detector){ -// Return detector code - - for(UInt_t iDet=0; iDet < kNDetectors; iDet++){ - if(!strcmp(fgkDetectorName[iDet], detector)) return fgkDetectorCode[iDet]; - } - - AliErrorClass(Form("Unknown detector: %s",detector)); - return 0; -} - -//______________________________________________________________________________________________ -const char* AliShuttle::GetDetCode(UInt_t detPos){ -// Return detector code - - if( detPos >= kNDetectors) { - AliErrorClass(Form("Invalid parameter: %d", detPos)); - return 0; - } - return fgkDetectorCode[detPos]; -} - -//______________________________________________________________________________________________ -const Int_t AliShuttle::GetDetPos(const char* detCode){ -// Return detector position in the detector code array - - for(UInt_t iDet=0; iDet < kNDetectors; iDet++){ - if(!strcmp(fgkDetectorCode[iDet], detCode)) return iDet; - } - return -1; -} - //______________________________________________________________________________________________ void AliShuttle::Log(const char* detector, const char* message) { @@ -1550,23 +1506,23 @@ void AliShuttle::Log(const char* detector, const char* message) //______________________________________________________________________________________________ Bool_t AliShuttle::Collect(Int_t run) { - // - // Collects conditions data for all UNPROCESSED run written to DAQ LogBook in case of run = -1 (default) - // If a dedicated run is given this run is processed - // - // In operational mode, this is the Shuttle function triggered by the EOR signal. - // +// +// Collects conditions data for all UNPROCESSED run written to DAQ LogBook in case of run = -1 (default) +// If a dedicated run is given this run is processed +// +// In operational mode, this is the Shuttle function triggered by the EOR signal. +// - if (run == -1) - Log("SHUTTLE","Collect - Shuttle called. Collecting conditions data for unprocessed runs"); - else - Log("SHUTTLE", Form("Collect - Shuttle called. Collecting conditions data for run %d", run)); + if (run == -1) + Log("SHUTTLE","Collect - Shuttle called. Collecting conditions data for unprocessed runs"); + else + Log("SHUTTLE", Form("Collect - Shuttle called. Collecting conditions data for run %d", run)); SetLastAction("Starting"); TString whereClause("where shuttle_done=0"); - if (run != -1) - whereClause += Form(" and run=%d", run); + if (run != -1) + whereClause += Form(" and run=%d", run); TObjArray shuttleLogbookEntries; if (!QueryShuttleLogbook(whereClause, shuttleLogbookEntries)) { @@ -1579,7 +1535,7 @@ Bool_t AliShuttle::Collect(Int_t run) return kFALSE; } - return kTRUE; + return kTRUE; } //______________________________________________________________________________________________ @@ -1643,3 +1599,16 @@ void AliShuttle::SetLastAction(const char* action) fMonitoringMutex->UnLock(); } + +//______________________________________________________________________________________________ +const char* AliShuttle::GetRunParameter(const char* param) +{ +// returns run parameter read from DAQ logbook + + if(!fLogbookEntry) { + AliError("No logbook entry!"); + return 0; + } + + return fLogbookEntry->GetRunParameter(param); +} diff --git a/SHUTTLE/AliShuttle.h b/SHUTTLE/AliShuttle.h index 9e0ba6c98c9..7eeb10ca740 100644 --- a/SHUTTLE/AliShuttle.h +++ b/SHUTTLE/AliShuttle.h @@ -33,8 +33,6 @@ class TMutex; class AliShuttle: public AliShuttleInterface { public: - enum { kNDetectors=17 }; // number of subdetectors in ALICE - AliShuttle(const AliShuttleConfig* config, UInt_t timeout = 5000, Int_t retries = 5); virtual ~AliShuttle(); @@ -58,6 +56,7 @@ public: virtual const char* GetFile(Int_t system, const char* detector, const char* id, const char* source); virtual TList* GetFileSources(Int_t system, const char* detector, const char* id); + virtual const char* GetRunParameter(const char* lbEntry); virtual void Log(const char* detector, const char* message); static TString GetMainCDB () {return fgkMainCDB;} @@ -72,11 +71,8 @@ public: //TODO Test only, remove later ! void SetProcessDCS(Bool_t process) {fgkProcessDCS = process;} + void SetLogbookEntry(AliShuttleLogbookEntry* entry) {fLogbookEntry=entry;} - static const char* GetDetCode(const char* detector); - static const char* GetDetCode(UInt_t detPos); - static const Int_t GetDetPos(const char* detCode); - static const UInt_t NDetectors() {return kNDetectors;} static const char* GetShuttleTempDir() {return fgkShuttleTempDir;} Bool_t Connect(Int_t system); @@ -87,7 +83,7 @@ private: UInt_t ProcessCurrentDetector(); - Bool_t QueryRunParameters(Int_t& run, UInt_t& startTime, UInt_t& endTime); + AliShuttleLogbookEntry* QueryRunParameters(Int_t run); Bool_t QueryShuttleLogbook(const char* whereClause, TObjArray& entries); Bool_t RetrieveConditionsData(const TObjArray& shuttleLogbookEntries); @@ -123,9 +119,6 @@ private: const AliShuttleConfig* fConfig; // pointer to configuration object -// static const UInt_t fgkNDetectors = 17; //! number of detectors - static const char* fgkDetectorName[kNDetectors]; //! names of detectors - static const char* fgkDetectorCode[kNDetectors]; //! codes of detectors static TString fgkMainCDB; // URI of the main (Grid) CDB storage static TString fgkLocalCDB; //! URI of the local backup CDB storage static TString fgkMainRefStorage; // URI of the main (Grid) REFERENCE storage diff --git a/SHUTTLE/AliShuttleConfig.cxx b/SHUTTLE/AliShuttleConfig.cxx index 3cb77d91dec..38132a69dc7 100644 --- a/SHUTTLE/AliShuttleConfig.cxx +++ b/SHUTTLE/AliShuttleConfig.cxx @@ -15,6 +15,11 @@ /* $Log$ +Revision 1.10 2006/10/20 15:22:59 jgrosseo +o) Adding time out to the execution of the preprocessors: The Shuttle forks and the parent process monitors the child +o) Merging Collect, CollectAll, CollectNew function +o) Removing implementation of empty copy constructors (declaration still there!) + Revision 1.9 2006/10/02 16:38:39 jgrosseo update (alberto): fixed memory leaks @@ -326,11 +331,11 @@ AliShuttleConfig::AliShuttleConfig(const char* host, Int_t port, // FES configuration (FES logbook and hosts) for(int iSys=0;iSys<3;iSys++){ - queryFilter = Form("(system=%s)", AliShuttleInterface::fkSystemNames[iSys]); + queryFilter = Form("(system=%s)", AliShuttleInterface::GetSystemName(iSys)); aResult = aServer.Search(basedn, LDAP_SCOPE_ONELEVEL, queryFilter.Data()); if (!aResult) { AliError(Form("Can't find configuration for system: %s", - AliShuttleInterface::fkSystemNames[iSys])); + AliShuttleInterface::GetSystemName(iSys))); return; } @@ -345,7 +350,7 @@ AliShuttleConfig::AliShuttleConfig(const char* host, Int_t port, anAttribute = anEntry->GetAttribute("LogbookHost"); if (!anAttribute) { AliError(Form ("Can't find LogbookHost attribute for %s!!", - AliShuttleInterface::fkSystemNames[iSys])); + AliShuttleInterface::GetSystemName(iSys))); delete aResult; delete anEntry; return; } @@ -354,7 +359,7 @@ AliShuttleConfig::AliShuttleConfig(const char* host, Int_t port, anAttribute = anEntry->GetAttribute("LogbookUser"); if (!anAttribute) { AliError(Form ("Can't find LogbookUser attribute for %s!!", - AliShuttleInterface::fkSystemNames[iSys])); + AliShuttleInterface::GetSystemName(iSys))); delete aResult; delete anEntry; return; } @@ -363,7 +368,7 @@ AliShuttleConfig::AliShuttleConfig(const char* host, Int_t port, anAttribute = anEntry->GetAttribute("LogbookPassword"); if (!anAttribute) { AliError(Form ("Can't find LogbookPassword attribute for %s!!", - AliShuttleInterface::fkSystemNames[iSys])); + AliShuttleInterface::GetSystemName(iSys))); delete aResult; delete anEntry; return; } @@ -372,7 +377,7 @@ AliShuttleConfig::AliShuttleConfig(const char* host, Int_t port, anAttribute = anEntry->GetAttribute("FSHost"); if (!anAttribute) { AliError(Form ("Can't find FSHost attribute for %s!!", - AliShuttleInterface::fkSystemNames[iSys])); + AliShuttleInterface::GetSystemName(iSys))); delete aResult; delete anEntry; return; } @@ -381,7 +386,7 @@ AliShuttleConfig::AliShuttleConfig(const char* host, Int_t port, anAttribute = anEntry->GetAttribute("FSUser"); if (!anAttribute) { AliError(Form ("Can't find FSUser attribute for %s!!", - AliShuttleInterface::fkSystemNames[iSys])); + AliShuttleInterface::GetSystemName(iSys))); delete aResult; delete anEntry; return; } @@ -525,7 +530,7 @@ void AliShuttleConfig::Print(Option_t* /*option*/) const result += "\n\n"; for(int iSys=0;iSys<3;iSys++){ - result += Form("FES Configuration for %s system\n", AliShuttleInterface::fkSystemNames[iSys]); + result += Form("FES Configuration for %s system\n", AliShuttleInterface::GetSystemName(iSys)); result += Form("\tLogbook host: \t%s - \tUser: %s\n", fFESlbHost[iSys].Data(), fFESlbUser[iSys].Data()); // result += Form("Logbook Password:",fFESlbPass[iSys].Data()); diff --git a/SHUTTLE/AliShuttleLogbookEntry.cxx b/SHUTTLE/AliShuttleLogbookEntry.cxx index 55cf09ccf13..a5b049c19ee 100644 --- a/SHUTTLE/AliShuttleLogbookEntry.cxx +++ b/SHUTTLE/AliShuttleLogbookEntry.cxx @@ -21,12 +21,9 @@ #include "AliShuttleLogbookEntry.h" #include "AliLog.h" #include "TTimeStamp.h" - -// TODO test only! -#include -#include -#include -#include +#include +#include +#include ClassImp(AliShuttleLogbookEntry) @@ -34,57 +31,53 @@ ClassImp(AliShuttleLogbookEntry) AliShuttleLogbookEntry::AliShuttleLogbookEntry() : TObject(), fRun(-1), -fStartTime(0), -fEndTime(0), -//fDetectorStatus(0), -fServer(0) +fRunParameters(0) { // default constructor - const UInt_t nDet = AliShuttle::NDetectors(); -// fDetectorStatus = new Status[nDet]; + const UInt_t nDet = AliShuttleInterface::NDetectors(); memset(fDetectorStatus, kUnprocessed, nDet*sizeof(Status)); + fRunParameters.SetOwner(1); } //______________________________________________________________________________________________ -AliShuttleLogbookEntry::AliShuttleLogbookEntry(Int_t run, UInt_t startTime, UInt_t endTime, Status* status) : +AliShuttleLogbookEntry::AliShuttleLogbookEntry(Int_t run, Status* status) : TObject(), fRun(run), -fStartTime(startTime), -fEndTime(endTime), -//fDetectorStatus(0), -fServer(0) +fRunParameters(0) { - // default constructor +// default constructor - const UInt_t nDet = AliShuttle::NDetectors(); -// fDetectorStatus = new Status[nDet]; + const UInt_t nDet = AliShuttleInterface::NDetectors(); memset(fDetectorStatus, kUnprocessed, nDet*sizeof(Status)); if(status) SetDetectorStatus(status); + fRunParameters.SetOwner(1); } //______________________________________________________________________________________________ AliShuttleLogbookEntry::~AliShuttleLogbookEntry() { // destructor - if(fServer){ - if(fServer->IsConnected()) fServer->Close(); - delete fServer; - } -// if(fDetectorStatus) delete[] fDetectorStatus; fDetectorStatus=0; } //______________________________________________________________________________________________ AliShuttleLogbookEntry::AliShuttleLogbookEntry(const AliShuttleLogbookEntry &c) : TObject(), fRun(c.fRun), -fStartTime(c.fStartTime), -fEndTime(c.fEndTime), -fServer(0) +fRunParameters(0) { // copy constructor - SetDetectorStatus(c.GetDetectorStatus()); + SetDetectorStatus(c.GetDetectorStatus()); + fRunParameters.SetOwner(1); + TIter iter(c.fRunParameters.GetTable()); + TPair* aPair = 0; + while((aPair = dynamic_cast(iter.Next()))){ + TObjString* aKey= dynamic_cast(aPair->Key()); + TObjString* aValue= dynamic_cast(aPair->Value()); + fRunParameters.Add(aKey->Clone(), aValue->Clone()); + } + } //______________________________________________________________________________________________ @@ -105,18 +98,24 @@ void AliShuttleLogbookEntry::Copy(TObject& c) const AliShuttleLogbookEntry& target = (AliShuttleLogbookEntry &) c; target.fRun = fRun; - target.fStartTime = fStartTime; - target.fEndTime = fEndTime; + target.fRunParameters.SetOwner(1); + TIter iter(fRunParameters.GetTable()); + TPair* aPair = 0; + while((aPair = dynamic_cast(iter.Next()))){ + TObjString* aKey= dynamic_cast(aPair->Key()); + TObjString* aValue= dynamic_cast(aPair->Value()); + target.fRunParameters.Add(aKey->Clone(), aValue->Clone()); + } target.SetDetectorStatus(GetDetectorStatus()); } //______________________________________________________________________________________________ -AliShuttleLogbookEntry::Status AliShuttleLogbookEntry::GetDetectorStatus(const char* detCode) const +AliShuttleLogbookEntry::Status AliShuttleLogbookEntry::GetDetectorStatus(const char* detName) const { // get detector status from detector code - return GetDetectorStatus(AliShuttle::GetDetPos(detCode)); + return GetDetectorStatus(AliShuttleInterface::GetDetPos(detName)); } //______________________________________________________________________________________________ @@ -124,7 +123,7 @@ AliShuttleLogbookEntry::Status AliShuttleLogbookEntry::GetDetectorStatus(Int_t d { // get detector status from detector code - if(detPos < 0 || detPos >= (Int_t) AliShuttle::NDetectors()) { + if(detPos < 0 || detPos >= (Int_t) AliShuttleInterface::NDetectors()) { AliError(Form("Invalid parameter: %d", detPos)); return kUnprocessed; } @@ -132,21 +131,31 @@ AliShuttleLogbookEntry::Status AliShuttleLogbookEntry::GetDetectorStatus(Int_t d } //______________________________________________________________________________________________ -void AliShuttleLogbookEntry::SetDetectorStatus(const char* detCode, Status status) +void AliShuttleLogbookEntry::SetDetectorStatus(const char* detName, Status status) { // set detector status from detector code - Int_t detPos = AliShuttle::GetDetPos(detCode); + Int_t detPos = AliShuttleInterface::GetDetPos(detName); if(detPos<0) return; SetDetectorStatus(detPos, status); } +//______________________________________________________________________________________________ +void AliShuttleLogbookEntry::SetDetectorStatus(const char* detName, const char* statusName) +{ +// set detector status from detector code + + Int_t detPos = AliShuttleInterface::GetDetPos(detName); + if(detPos<0) return; + SetDetectorStatus(detPos, statusName); +} + //______________________________________________________________________________________________ void AliShuttleLogbookEntry::SetDetectorStatus(Status* status) { // set detector status from detector code - for(UInt_t i=0; i < AliShuttle::NDetectors(); i++){ + for(UInt_t i=0; i < AliShuttleInterface::NDetectors(); i++){ fDetectorStatus[i] = status[i]; } } @@ -156,18 +165,41 @@ void AliShuttleLogbookEntry::SetDetectorStatus(UInt_t detPos, Status status) { // set detector status from detector code - if(detPos >= AliShuttle::NDetectors()) { - AliError(Form("Shuttle has only %d subdetectors!", AliShuttle::NDetectors())); + if(detPos >= AliShuttleInterface::NDetectors()) { + AliError(Form("Shuttle has only %d subdetectors!", AliShuttleInterface::NDetectors())); return; } fDetectorStatus[detPos] = status; } +//______________________________________________________________________________________________ +void AliShuttleLogbookEntry::SetDetectorStatus(UInt_t detPos, const char* statusName) +{ +// set detector status from detector code + + if(detPos >= AliShuttleInterface::NDetectors()) { + AliError(Form("Shuttle has only %d subdetectors!", AliShuttleInterface::NDetectors())); + return; + } + TString statusString(statusName); + if(statusString.Contains("UNPROCESSED", TString::kIgnoreCase)){ + SetDetectorStatus(detPos, kUnprocessed); + } else if (statusString.Contains("INACTIVE", TString::kIgnoreCase)) { + SetDetectorStatus(detPos, kInactive); + } else if (statusString.Contains("FAILED", TString::kIgnoreCase)) { + SetDetectorStatus(detPos, kFailed); + } else if (statusString.Contains("DONE", TString::kIgnoreCase)) { + SetDetectorStatus(detPos, kDone); + } else { + AliError(Form("Invalid status name: %s", statusName)); + } +} + //______________________________________________________________________________________________ Bool_t AliShuttleLogbookEntry::IsDone() const{ // return TRUE if all subdetectors are in status DONE, FAILED or INACTIVE - for(UInt_t i=0; i < AliShuttle::NDetectors(); i++){ + for(UInt_t i=0; i < AliShuttleInterface::NDetectors(); i++){ if(fDetectorStatus[i] == kUnprocessed) return kFALSE; } return kTRUE; @@ -178,207 +210,77 @@ const char* AliShuttleLogbookEntry::GetDetectorStatusName(Status status) { // returns a name (string) of the detector status - switch (status){ - case kUnprocessed: return "UNPROCESSED"; - case kInactive: return "INACTIVE"; - case kFailed: return "FAILED"; - case kDone: return "DONE"; - } - return 0; + switch (status){ + case kUnprocessed: return "UNPROCESSED"; + case kInactive: return "INACTIVE"; + case kFailed: return "FAILED"; + case kDone: return "DONE"; + } + return 0; + } //______________________________________________________________________________________________ -void AliShuttleLogbookEntry::Print(Option_t* /*option*/) const +void AliShuttleLogbookEntry::Print(Option_t* option) const { // print current shuttle logbook entry TString message = "\n*** Run parameters ***\n"; - TTimeStamp startTimeStamp(fStartTime); - TTimeStamp endTimeStamp(fEndTime); + TTimeStamp startTimeStamp(GetStartTime()); + TTimeStamp endTimeStamp(GetEndTime()); message += Form("\tRun \t\t%d\n", fRun); message += Form("\tStarted \t%s\n", startTimeStamp.AsString("s")); message += Form("\tFinished \t%s\n", endTimeStamp.AsString("s")); message += "\n*** Detector status ***\n"; - for(UInt_t i=0; i < AliShuttle::NDetectors(); i++) - message += Form("\t%2d - %s: %s\n", i, AliShuttle::GetDetCode(i), + for(UInt_t i=0; i < AliShuttleInterface::NDetectors(); i++) + message += Form("\t%2d - %s: %s\n", i, AliShuttleInterface::GetDetName(i), GetDetectorStatusName(fDetectorStatus[i])); - AliInfo(Form("%s",message.Data())); -} - -//______________________________________________________________________________________________ -Bool_t AliShuttleLogbookEntry::Connect(){ -// Connect to MySQL Server of the DAQ logbook - - // check connection: if already connected return - if(fServer && fServer->IsConnected()) return kTRUE; - - fServer = TSQLServer::Connect("mysql://pcald30.cern.ch","offline","alice"); - - if (!fServer || !fServer->IsConnected()) { - AliError("Can't establish connection to DAQ log book DB!"); - if(fServer) delete fServer; - return kFALSE; - } - - // Get table - TSQLResult* aResult=0; - aResult = fServer->GetTables("REFSYSLOG"); - delete aResult; - return kTRUE; -} - -//______________________________________________________________________________________________ -Bool_t AliShuttleLogbookEntry::QueryShuttleLogbook(Int_t runNumber) -{ -// Query DAQ's Shuttle logbook and fills detector status array - - Int_t run; - if(runNumber < 0) { - run = GetRun(); - } else{ - run = runNumber; - } - - // check connection, in case connect - if(!Connect()) return kFALSE; - - TString sqlQuery; - sqlQuery = Form("select * from logbook_shuttle where run = %d", run); - - TSQLResult* aResult = fServer->Query(sqlQuery); - if (!aResult) { - AliError(Form("Can't execute query <%s>!", sqlQuery.Data())); - return kFALSE; - } - - // TODO Check field count! - if (aResult->GetFieldCount() != 24) { - AliError("Invalid SQL result field number!"); - delete aResult; - return kFALSE; - } - - TSQLRow* aRow; - while ((aRow = aResult->Next())) { - TString runString(aRow->GetField(0), aRow->GetFieldLength(0)); - Int_t run = runString.Atoi(); - - Status detStatus[24]; - - // loop on detectors - for(UInt_t ii = 0; ii < 24; ii++){ - TString detCode(aResult->GetFieldName(ii)); - Int_t detPos = AliShuttle::GetDetPos(detCode.Data()); - if(detPos < 0) continue; - TString statusString(aRow->GetField(ii), aRow->GetFieldLength(ii)); - if(statusString == "UNPROCESSED"){ - detStatus[detPos] = AliShuttleLogbookEntry::kUnprocessed; - } else if (statusString == "INACTIVE") { - detStatus[detPos] = AliShuttleLogbookEntry::kInactive; - } else if (statusString == "FAILED") { - detStatus[detPos] = AliShuttleLogbookEntry::kFailed; - } else if (statusString == "DONE") { - detStatus[detPos] = AliShuttleLogbookEntry::kDone; + AliInfo(Form("option: %s",option)); + TString optionStr(option); + if(optionStr=="all"){ + message += "\nPrinting full list of run parameters\n"; + message += "\tParameter Value\n"; + TIter iter(fRunParameters.GetTable()); + TPair* aPair = 0; + while((aPair = dynamic_cast(iter.Next()))){ + TObjString* aKey= dynamic_cast(aPair->Key()); + TObjString* aValue= dynamic_cast(aPair->Value()); + TString keyStr=aKey->GetName(); + if(keyStr != "log"){ + message += Form("\t%s ", aKey->GetName()); + if(keyStr.Length()<30) message.Append(' ', 30-keyStr.Length()); + message += Form("%s\n", aValue->GetName()); + } else { + message += "\tlog ...\n"; } } - - SetRun(run); - SetDetectorStatus(detStatus); - delete aRow; - } - - Print(""); - - delete aResult; - return kTRUE; -} -//______________________________________________________________________________________________ -Bool_t AliShuttleLogbookEntry::UpdateShuttleLogbook() -{ - // Update Shuttle logbook table - TEST ONLY, USE WITH CARE! - - - if(!Connect()) return kFALSE; - - TString sqlQuery("update logbook_shuttle set "); - - for(UInt_t i=0; i < AliShuttle::NDetectors(); i++){ - sqlQuery += Form("%s=\"%s\"", AliShuttle::GetDetCode(i), GetDetectorStatusName(fDetectorStatus[i])); - if(i < AliShuttle::NDetectors()-1) sqlQuery += ", "; } - sqlQuery += Form(" where run=%d;",GetRun()); - - AliInfo(Form("sqlQuery: %s", sqlQuery.Data())); - - TSQLResult* aResult; - aResult = fServer->Query(sqlQuery); - if (!aResult) { - AliError(Form("Can't execute query <%s>!", sqlQuery.Data())); - return kFALSE; - } - - delete aResult; - - return kTRUE; + AliInfo(Form("%s",message.Data())); } - //______________________________________________________________________________________________ -Bool_t AliShuttleLogbookEntry::UpdateShuttleLogbook(const char* detCode, Status status) -{ - // Update Shuttle logbook table - TEST ONLY, USE WITH CARE! - - - if(AliShuttle::GetDetPos(detCode) < 0) return kFALSE; - SetDetectorStatus(detCode, status); - if(!Connect()) return kFALSE; - - TString sqlQuery("update logbook_shuttle set "); +void AliShuttleLogbookEntry::SetRunParameter(const char* key, const char* value){ +// set a run parameter (read from the DAQ logbook) + TObjString* keyObj = new TObjString(key); + if (fRunParameters.Contains(key)) { + AliWarning(Form("Parameter %s already existing and it will be replaced.", key)); + delete fRunParameters.Remove(keyObj); - sqlQuery += Form("%s=\"%s\" ", detCode, GetDetectorStatusName(status)); - - sqlQuery += Form("where run=%d;",GetRun()); - - AliInfo(Form("sqlQuery: %s", sqlQuery.Data())); - - TSQLResult* aResult; - aResult = fServer->Query(sqlQuery); - if (!aResult) { - AliError(Form("Can't execute query <%s>!", sqlQuery.Data())); - return kFALSE; } - - delete aResult; - - return kTRUE; + fRunParameters.Add(keyObj, new TObjString(value)); + AliDebug(2, Form("Number of parameters: %d", fRunParameters.GetEntries())); } - //______________________________________________________________________________________________ -Bool_t AliShuttleLogbookEntry::InsertNewRun(Int_t runNumber) -{ - // Update Shuttle logbook table - TEST ONLY, USE WITH CARE! - - if(runNumber<=0 && GetRun()<=0) return kFALSE; - if(runNumber>0) SetRun(runNumber); - if(!Connect()) return kFALSE; - - TString sqlQuery = Form("insert into logbook_shuttle (run) values (%d);", GetRun()); +const char* AliShuttleLogbookEntry::GetRunParameter(const char* key) const{ +// get a run parameter - AliInfo(Form("sqlQuery: %s", sqlQuery.Data())); - - TSQLResult* aResult; - aResult = fServer->Query(sqlQuery); - if (!aResult) { - AliError(Form("Can't execute query <%s>!", sqlQuery.Data())); - return kFALSE; + TObjString* value = dynamic_cast (fRunParameters.GetValue(key)); + if(!value) { + AliError(Form("No such parameter: %s", key)); + return 0; } - - delete aResult; - - UpdateShuttleLogbook(); - - return kTRUE; + return value->GetName(); } diff --git a/SHUTTLE/AliShuttleLogbookEntry.h b/SHUTTLE/AliShuttleLogbookEntry.h index d7bac65f7e0..8db47fd5e31 100644 --- a/SHUTTLE/AliShuttleLogbookEntry.h +++ b/SHUTTLE/AliShuttleLogbookEntry.h @@ -12,11 +12,12 @@ // #include -#include "AliShuttle.h" +#include +#include -class TSQLServer; +#include "AliShuttleInterface.h" -class AliShuttleLogbookEntry: public TObject { +class AliShuttleLogbookEntry : public TObject { public: enum Status { @@ -27,7 +28,7 @@ public: }; AliShuttleLogbookEntry(); - AliShuttleLogbookEntry(Int_t run, UInt_t startTime, UInt_t endTime, Status* status=0); + AliShuttleLogbookEntry(Int_t run, Status* status=0); ~AliShuttleLogbookEntry(); AliShuttleLogbookEntry& operator=(const AliShuttleLogbookEntry& c); @@ -35,12 +36,13 @@ public: virtual void Copy(TObject& c) const; Int_t GetRun() const {return fRun;} - UInt_t GetStartTime() const {return fStartTime;} - UInt_t GetEndTime() const {return fEndTime;} + UInt_t GetStartTime() const {TString tmp(GetRunParameter("time_start")); return tmp.Atoi();} + UInt_t GetEndTime() const {TString tmp(GetRunParameter("time_end")); return tmp.Atoi();} - void SetRun(Int_t run) {fRun=run;} - void SetStartTime(UInt_t startTime) {fStartTime=startTime;} - void SetEndTime(UInt_t endTime) {fEndTime=endTime;} +// void SetRun(Int_t run) {fRun=run;} + + void SetRunParameter(const char* key, const char* value); + const char* GetRunParameter(const char* key) const; Status GetDetectorStatus(const char* detCode) const; Status GetDetectorStatus(Int_t detPos) const; @@ -49,29 +51,19 @@ public: void SetDetectorStatus(const char* detCode, Status status); void SetDetectorStatus(Status* status); void SetDetectorStatus(UInt_t detPos, Status status); + void SetDetectorStatus(const char* detCode, const char* statusName); + void SetDetectorStatus(UInt_t detPos, const char* statusName); Bool_t IsDone() const; static const char* GetDetectorStatusName(Status status); void Print(Option_t *option) const; - // TODO Test only, remove later! - Bool_t Connect(); - Bool_t QueryShuttleLogbook(Int_t runNumber=-1); - Bool_t UpdateShuttleLogbook(); - Bool_t UpdateShuttleLogbook(const char* detCode, Status status); - Bool_t InsertNewRun(Int_t runNumber=-1); - - private: Int_t fRun; // Run number - UInt_t fStartTime; // Run start time - UInt_t fEndTime; // Run end time - Status fDetectorStatus[AliShuttle::kNDetectors]; // Detector status array - - // TODO Test only, remove later! - TSQLServer* fServer; // pointer to the MySQLServer which handles the DAQ logbook + TMap fRunParameters; // run parameters written in DAQ logbook + Status fDetectorStatus[AliShuttleInterface::kNDetectors]; // Detector status array ClassDef(AliShuttleLogbookEntry, 0) }; diff --git a/SHUTTLE/AliDCSClient.cxx b/SHUTTLE/DCSClient/AliDCSClient.cxx similarity index 98% rename from SHUTTLE/AliDCSClient.cxx rename to SHUTTLE/DCSClient/AliDCSClient.cxx index 3f7710f4af7..4327b9b760a 100644 --- a/SHUTTLE/AliDCSClient.cxx +++ b/SHUTTLE/DCSClient/AliDCSClient.cxx @@ -15,6 +15,12 @@ /* $Log$ +Revision 1.6 2006/10/02 16:38:39 jgrosseo +update (alberto): +fixed memory leaks +storing of objects that failed to be stored to the grid before +interfacing of shuttle status table in daq system + Revision 1.5 2006/08/15 10:50:00 jgrosseo effc++ corrections (alberto) @@ -72,13 +78,6 @@ some more descriptions added ClassImp(AliDCSClient) -const Int_t AliDCSClient::fgkBadState; -const Int_t AliDCSClient::fgkInvalidParameter; -const Int_t AliDCSClient::fgkTimeout; -const Int_t AliDCSClient::fgkBadMessage; -const Int_t AliDCSClient::fgkCommError; -const Int_t AliDCSClient::fgkServerError; - const char* AliDCSClient::fgkBadStateString = "BadState"; const char* AliDCSClient::fgkInvalidParameterString = "InvalidParameter"; const char* AliDCSClient::fgkTimeoutString = "Timeout"; diff --git a/SHUTTLE/AliDCSClient.h b/SHUTTLE/DCSClient/AliDCSClient.h similarity index 88% rename from SHUTTLE/AliDCSClient.h rename to SHUTTLE/DCSClient/AliDCSClient.h index d7c1a9fc253..a0191714d95 100644 --- a/SHUTTLE/AliDCSClient.h +++ b/SHUTTLE/DCSClient/AliDCSClient.h @@ -21,6 +21,15 @@ class TMap; class AliDCSClient: public TObject { public: + enum { + fgkBadState=-1, // Bad state + fgkInvalidParameter = -2, // Invalid parameter + fgkTimeout = -3, // Timeout + fgkBadMessage = -4, // Bad message + fgkCommError = -5, // Communication error + fgkServerError = -6 // Server error + }; + friend class AliShuttle; AliDCSClient(const char* host, Int_t port, UInt_t timeout = 5000, @@ -53,14 +62,6 @@ public: static const char* GetErrorString(Int_t code); private: - - static const Int_t fgkBadState = -1; // Bad state - static const Int_t fgkInvalidParameter = -2; // Invalid parameter - static const Int_t fgkTimeout = -3; // Timeout - static const Int_t fgkBadMessage = -4; // Bad message - static const Int_t fgkCommError = -5; // Communication error - static const Int_t fgkServerError = -6; // Server error - static const char* fgkBadStateString; // Bad state string static const char* fgkInvalidParameterString; // Invalid parameter string static const char* fgkTimeoutString; // Timeout string diff --git a/SHUTTLE/AliDCSMessage.cxx b/SHUTTLE/DCSClient/AliDCSMessage.cxx similarity index 98% rename from SHUTTLE/AliDCSMessage.cxx rename to SHUTTLE/DCSClient/AliDCSMessage.cxx index bfa6fecd4c1..6a46c4844d7 100644 --- a/SHUTTLE/AliDCSMessage.cxx +++ b/SHUTTLE/DCSClient/AliDCSMessage.cxx @@ -15,6 +15,12 @@ /* $Log$ +Revision 1.7 2006/10/02 16:38:39 jgrosseo +update (alberto): +fixed memory leaks +storing of objects that failed to be stored to the grid before +interfacing of shuttle status table in daq system + Revision 1.6 2006/08/15 10:50:00 jgrosseo effc++ corrections (alberto) @@ -93,10 +99,10 @@ ClassImp(AliDCSMessage) //______________________________________________________________________ AliDCSMessage::AliDCSMessage(): - fMessage(NULL), fMessageSize(0), fType(kInvalid), - fStartTime(0), fEndTime(0), + TObject(), fMessage(NULL), fMessageSize(0), fType(kInvalid), + fRequestType(kNoneType), fStartTime(0), fEndTime(0), fRequestString(""), fCount(0), - fValueType(AliDCSValue::kInvalid), + fValueType(AliDCSValue::kInvalid), fValues(), fErrorCode(kNoneError), fErrorString(""), fRequestStrings() { @@ -108,10 +114,10 @@ AliDCSMessage::AliDCSMessage(): //______________________________________________________________________ AliDCSMessage::AliDCSMessage(const char* message, UInt_t size): - fMessageSize(size), fType(kInvalid), - fStartTime(0), fEndTime(0), + TObject(), fMessage(NULL), fMessageSize(size), fType(kInvalid), + fRequestType(kNoneType), fStartTime(0), fEndTime(0), fRequestString(""), fCount(0), - fValueType(AliDCSValue::kInvalid), + fValueType(AliDCSValue::kInvalid), fValues(), fErrorCode(kNoneError), fErrorString(""), fRequestStrings() { @@ -127,9 +133,9 @@ AliDCSMessage::AliDCSMessage(const char* message, UInt_t size): //______________________________________________________________________ AliDCSMessage::AliDCSMessage(const AliDCSMessage& /*other*/): TObject(), fMessage(NULL), fMessageSize(0), fType(kInvalid), - fStartTime(0), fEndTime(0), + fRequestType(kNoneType), fStartTime(0), fEndTime(0), fRequestString(""), fCount(0), - fValueType(AliDCSValue::kInvalid), + fValueType(AliDCSValue::kInvalid), fValues(), fErrorCode(kNoneError), fErrorString(""), fRequestStrings() { diff --git a/SHUTTLE/AliDCSMessage.h b/SHUTTLE/DCSClient/AliDCSMessage.h similarity index 100% rename from SHUTTLE/AliDCSMessage.h rename to SHUTTLE/DCSClient/AliDCSMessage.h diff --git a/SHUTTLE/DCSClient/DCSClientLinkDef.h b/SHUTTLE/DCSClient/DCSClientLinkDef.h new file mode 100644 index 00000000000..df5709b2efd --- /dev/null +++ b/SHUTTLE/DCSClient/DCSClientLinkDef.h @@ -0,0 +1,17 @@ +#ifdef __CINT__ +/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * + * See cxx source for full Copyright notice */ + +/* $Id$ */ + +#pragma link off all globals; +#pragma link off all classes; +#pragma link off all functions; + +#pragma link C++ global gAlice; +#pragma link C++ global gMC; + +#pragma link C++ class AliDCSMessage; +#pragma link C++ class AliDCSClient; + +#endif diff --git a/SHUTTLE/DCSClient/Makefile b/SHUTTLE/DCSClient/Makefile new file mode 100644 index 00000000000..22b851084a4 --- /dev/null +++ b/SHUTTLE/DCSClient/Makefile @@ -0,0 +1,61 @@ + +include Makefile.arch + + +CLASSES = AliDCSMessage.cxx AliDCSClient.cxx + +DICT = Dict.cxx + +HEADERS := $(patsubst %.$(SrcSuf),%.h,$(CLASSES)) + +SRCS = $(CLASSES) $(DICT) + +INCLUDES := $(ALICE_ROOT)/include +LIBDIR := $(shell root-config --libdir) +SHARED = -shared + +CXXFLAGS += -I$(INCLUDES) + +OBJS := $(patsubst %.$(SrcSuf),.obj/%.$(ObjSuf),$(SRCS)) +DEPS := $(patsubst .obj/%.$(ObjSuf),.dep/%.d,$(OBJS)) + + +.PHONY: all clean distclean dep + +all: $(DEP) AliDCSClient.so + +$(DICT): $(HEADERS) DCSClientLinkDef.h + rootcint -f $@ -c -I$(INCLUDES) $^ + + + +AliDCSClient.so: $(OBJS) + $(LD) $(SHARED) $(LDFLAGS) $^ -L$(LIBDIR) $(LIBS) -o $@ + +dep: $(DICT) $(DEPS) + +clean: + rm -rf Dict.h + rm -rf Dict.cxx + rm -rf AliDCSClient.so + rm -rf .dep + rm -rf .obj + + +distclean: clean ; + +ifeq ($(filter %clean,$(MAKECMDGOALS)),) +DEPS_MAGIC := $(shell mkdir .dep > /dev/null 2>&1 || :) +endif +ifeq ($(strip $(filter %clean,$(MAKECMDGOALS)) $(filter dep,$(MAKECMDGOALS))),) +OBJS_MAGIC := $(shell mkdir .obj > /dev/null 2>&1 || :) +-include $(DEPS) +endif + +.dep/%.d: %.$(SrcSuf) + set -e; $(CXX) -MM $(CXXFLAGS) $< | \ + awk '/\.o/ {print ".dep/$(*F).d .obj/"$$0} ! /\.o/ {print $$0}' > .dep/$(*F).d + +.obj/%.$(ObjSuf): %.$(SrcSuf) + $(CXX) $(CXXFLAGS) -c $< -o .obj/$(*F).o + diff --git a/SHUTTLE/DCSClient/Makefile.arch b/SHUTTLE/DCSClient/Makefile.arch new file mode 100644 index 00000000000..3e233eba0e2 --- /dev/null +++ b/SHUTTLE/DCSClient/Makefile.arch @@ -0,0 +1,552 @@ +# -*- mode: makefile -*- +# +# Makefile containing platform dependencies for ROOT based projects. +# +# Copyright (c) 2000 Rene Brun and Fons Rademakers +# +# Author: Fons Rademakers, 29/2/2000 + +ARCH := $(shell root-config --arch) +PLATFORM := $(shell root-config --platform) + +CXX = +ObjSuf = o +SrcSuf = cxx +ExeSuf = +DllSuf = so +OutPutOpt = -o # keep whitespace after "-o" + +ROOTCFLAGS := $(shell root-config --cflags) +ROOTLDFLAGS := $(shell root-config --ldflags) +ROOTLIBS := $(shell root-config --libs) +ROOTGLIBS := $(shell root-config --glibs) +HASTHREAD := $(shell root-config --has-thread) + +ifeq ($(ARCH),hpuxacc) +# HP-UX 10.x with aCC +CXX = aCC +CXXFLAGS = -O +Z +LD = aCC +LDFLAGS = -O -z +SOFLAGS = -b +endif + +ifeq ($(ARCH),hpuxia64acc) +# HP-UX 11i 1.5 (IA-64) with aCC +CXX = aCC +CXXFLAGS = +DD64 -O +Z +LD = aCC +LDFLAGS = +DD64 -O -z +SOFLAGS = -b +endif + +ifeq ($(ARCH),hpuxegcs) +# HP-UX 10.x with g++ +CXXFLAGS = -O -fPIC +CXX = g++ +LD = g++ +LDFLAGS = -O +SOFLAGS = -fPIC -shared +endif + +ifeq ($(ARCH),hurddeb) +# GNU/Hurd +CXX = g++ +CXXFLAGS = -O2 -Wall -fPIC +LD = g++ +LDFLAGS = -O2 +SOFLAGS = -shared +endif + +ifeq ($(ARCH),aix) +# IBM AIX xlC 4.x +CXX = xlC +CXXFLAGS = -O +LD = xlC +LDFLAGS = -O +SOFLAGS = +ROOTLIBS := $(shell root-config --nonew --libs) +ROOTGLIBS := $(shell root-config --nonew --glibs) +endif + +ifeq ($(ARCH),aix5) +# IBM AIX xlC 5.x +CXX = xlC +CXXFLAGS = -O +LD = xlC +LDFLAGS = -O +SOFLAGS = +ROOTLIBS := $(shell root-config --nonew --libs) +ROOTGLIBS := $(shell root-config --nonew --glibs) +endif + +ifeq ($(ARCH),aixegcs) +# IBM AIX with GCC +CXX = g++ +CXXFLAGS = -O +LD = g++ +LDFLAGS = -O +SOFLAGS = -shared +endif + +ifeq ($(ARCH),solaris) +# Solaris CC +CXX = /opt/SUNWspro/bin/CC +CXXFLAGS = -O -KPIC +LD = /opt/SUNWspro/bin/CC +LDFLAGS = -O +SOFLAGS = -G +endif + +ifeq ($(ARCH),solarisCC5) +# Solaris CC 5.0 +CXX = CC +CXXFLAGS = -O -KPIC +LD = CC +LDFLAGS = -O +SOFLAGS = -G +endif + +ifeq ($(ARCH),solarisgcc) +# Solaris gcc +CXX = g++ +CXXFLAGS = -O -fPIC +LD = g++ +LDFLAGS = -O +SOFLAGS = -shared +endif + +ifeq ($(ARCH),solariskcc) +# Solaris kcc +CXX = KCC --one_instantiation_per_object +CXXFLAGS = -O4 -KPIC +LD = KCC +LDFLAGS = -O4 +SOFLAGS = +endif + +ifeq ($(ARCH),solarisx86) +# Solaris CC on Intel +CXX = CC +CXXFLAGS = -O -KPIC +LD = CC +LDFLAGS = -O +SOFLAGS = -G +endif + +ifeq ($(ARCH),sgicc) +# SGI +CXX = CC -n32 -I/usr/include/CC.sgi +CXXFLAGS = -O +LD = CC -n32 -LANG:std -I/usr/include/CC.sgi +LDFLAGS = -O +SOFLAGS = -shared +endif + +ifeq ($(ARCH),sgicc64) +# SGI +CXX = CC -64 -I/usr/include/CC.sgi +CXXFLAGS = -O +LD = CC -64 -LANG:std -I/usr/include/CC.sgi +LDFLAGS = -O +SOFLAGS = -shared +endif + +ifeq ($(ARCH),sgiegcs) +# SGI 6.x with EGCS +CXX = g++ +CXXFLAGS = -O -Wall -fPIC +LD = g++ +LDFLAGS = -O -Wl,-u,__builtin_new -Wl,-u,__builtin_delete -Wl,-u,__nw__FUiPv +SOFLAGS = -shared +endif + +ifeq ($(ARCH),sgin32egcs) +# SGI 6.x with EGCS for n32 ABI +CXX = g++ +CXXFLAGS = -O -Wall -fPIC +LD = g++ +LDFLAGS = -O -L/usr/lib32 -Wl,-woff,134 +SOFLAGS = -shared +endif + +ifeq ($(ARCH),sgikcc) +# SGI with KCC +CXX = KCC -n32 --one_instantiation_per_object +CXXFLAGS = -O +LD = KCC -n32 +LDFLAGS = -O +SOFLAGS = +endif + +ifeq ($(ARCH),alphaegcs) +# Alpha/OSF with egcs +CXX = g++ +CXXFLAGS = -O2 -Wall -fPIC +LD = g++ +LDFLAGS = -O2 +SOFLAGS = -Wl,-expect_unresolved,* -shared +endif + +ifeq ($(ARCH),alphakcc) +# Alpha/OSF with kai compiler (not yet valid) +CXX = KCC --one_instantiation_per_object +CXXFLAGS = -O -fPIC +LD = KCC +LDFLAGS = -O +SOFLAGS = -Wl,-expect_unresolved,* -shared +endif + +ifeq ($(ARCH),alphacxx6) +# Alpha/OSF with cxx6 +CXX = cxx +CXXFLAGS = -O +LD = cxx +LDFLAGS = -O +SOFLAGS = -shared -nocxxstd -Wl,-expect_unresolved,*,-msym +endif + +ifeq ($(ARCH),linuxrh51) +# Linux with gcc 2.7.2.x +CXX = g++ +CXXFLAGS = -O2 -Wall -fPIC +LD = g++ +LDFLAGS = -O2 +SOFLAGS = -shared +endif + +ifeq ($(ARCH),linuxrh42) +# Linux with gcc 2.7.2.x (RedHat 4.2) +CXX = g++ +CXXFLAGS = -O2 -Wall -fPIC +LD = g++ +LDFLAGS = -O2 +SOFLAGS = -shared +endif + +ifeq ($(ARCH),linuxdeb) +# Linux with gcc 2.7.2.x +CXX = g++ +CXXFLAGS = -O1 -Wall -fPIC +LD = g++ +LDFLAGS = -O1 +SOFLAGS = -shared +endif + +ifeq ($(ARCH),linuxdeb2) +# Linux with gcc 2.7.2.x +CXX = g++ +CXXFLAGS = -O2 -Wall -fPIC +LD = g++ +LDFLAGS = -O2 +SOFLAGS = -shared +endif + +ifeq ($(ARCH),linuxdeb2ppc) +# Debian/Linux on the PowerPC +CXX = g++ +CXXFLAGS = -O2 -Wall -fPIC +LD = g++ +LDFLAGS = -O2 +SOFLAGS = -shared +endif + +ifeq ($(ARCH),linuxsuse6) +# Linux with gcc 2.7.2.x +CXX = g++ +CXXFLAGS = -O2 -Wall -fPIC +LD = g++ +LDFLAGS = -O2 +SOFLAGS = -shared +endif + +ifeq ($(ARCH),linux) +# Linux with egcs, gcc 2.9x, gcc 3.x (>= RedHat 5.2) +CXX = g++ +CXXFLAGS = -O -Wall -fPIC +LD = g++ +LDFLAGS = -O +SOFLAGS = -shared +endif + +ifeq ($(ARCH),linuxkcc) +# Linux with the KAI compiler +CXX = KCC --one_instantiation_per_object +CXXFLAGS = -O -fPIC +K0 +LD = KCC +LDFLAGS = -O $(shell root-config --cflags) +SOFLAGS = +endif + +ifeq ($(ARCH),linuxicc) +# Linux with Intel icc compiler +ICC_MAJOR := $(shell icc -v 2>&1 | awk '{ if (NR==1) print $$2 }' | \ + cut -d'.' -f1) +ICC_MINOR := $(shell icc -v 2>&1 | awk '{ if (NR==1) print $$2 }' | \ + cut -d'.' -f2) +CXX = icc +CXXFLAGS = -O -fPIC -wd1476 +LD = icpc +LDFLAGS = -O +SOFLAGS = -shared +ifeq ($(ICC_MAJOR),8) +ifneq ($(ICC_MINOR),0) +CXXFLAGS += -wd1572 +endif +endif +endif + +ifeq ($(ARCH),linuxppcegcs) +# MkLinux with egcs/glibc +CXX = g++ +CXXFLAGS = -O2 -Wall -fPIC +LD = g++ +LDFLAGS = -O2 +SOFLAGS = -shared +endif + +ifeq ($(ARCH),linuxia64gcc) +# Itanium Linux with gcc 2.9x +CXX = g++ +CXXFLAGS = -O2 -Wall -fPIC +LD = g++ +LDFLAGS = -O2 +SOFLAGS = -shared +endif + +ifeq ($(ARCH),linuxia64sgi) +# Itanium Linux with sgiCC +CXX = sgiCC +CXXFLAGS = -O -Wall -fPIC +LD = gsgiCC +LDFLAGS = -O +SOFLAGS = -shared +endif + +ifeq ($(ARCH),linuxia64ecc) +# Itanium Linux with Intel icc (was ecc) +ICC_MAJOR := $(shell icc -v 2>&1 | awk '{ if (NR==1) print $$2 }' | \ + cut -d'.' -f1) +ICC_MINOR := $(shell icc -v 2>&1 | awk '{ if (NR==1) print $$2 }' | \ + cut -d'.' -f2) +CXX = icc +CXXFLAGS = -O -fPIC -wd1476 +LD = icpc +LDFLAGS = -O +SOFLAGS = -shared +ifeq ($(ICC_MAJOR),8) +ifneq ($(ICC_MINOR),0) +CXXFLAGS += -wd1572 +endif +endif +endif + +ifeq ($(ARCH),linuxx8664gcc) +# AMD Opteron and Intel EM64T (64 bit mode) Linux with gcc 3.x +CXX = g++ +CXXFLAGS = -O2 -Wall -fPIC +LD = g++ +LDFLAGS = -O2 +SOFLAGS = -shared +endif + +ifeq ($(ARCH),linuxppc64gcc) +# PPC64 Linux with gcc 3.x +CXX = g++ +CXXFLAGS = -O -Wall -fPIC +LD = g++ +LDFLAGS = -O +SOFLAGS = -shared +endif + +ifeq ($(ARCH),linuxx8664icc) +# AMD Opteron and Intel EM64T (64 bit mode) Linux with Intel icc compiler +CXX = icc +CXXFLAGS = -O -fPIC -wd1476 -wd1572 +LD = icpc +LDFLAGS = -O +SOFLAGS = -shared +endif + +ifeq ($(ARCH),linuxalphaegcs) +# Alpha Linux with egcs +CXX = g++ +CXXFLAGS = -O2 -Wall -fPIC +LD = g++ +LDFLAGS = -O2 +SOFLAGS = -shared +endif + +ifeq ($(ARCH),linuxarm) +# ARM Linux with egcs +CXX = g++ +CXXFLAGS = -O -Wall -fPIC +LD = g++ +LDFLAGS = -O +SOFLAGS = -shared +endif + +ifeq ($(ARCH),mklinux) +# MkLinux with libc5 +CXX = g++ +CXXFLAGS = -O2 -Wall -fPIC +LD = g++ +LDFLAGS = -O2 +SOFLAGS = -shared +endif + +ifeq ($(ARCH),freebsd) +# FreeBSD with libc5 +CXX = g++ +CXXFLAGS = -O -pipe -W -Wall -fPIC +LD = g++ +LDFLAGS = -O +SOFLAGS = -shared -Wl,-x +endif + +ifeq ($(ARCH),freebsd4) +# FreeBSD with glibc +CXX = g++ +CXXFLAGS = -O -pipe -W -Wall -fPIC +LD = g++ +LDFLAGS = -O +SOFLAGS = -shared -Wl,-x +endif + +ifeq ($(ARCH),openbsd) +# OpenBSD with libc +CXX = g++ +CXXFLAGS = -O -pipe -W -Wall -fPIC +LD = g++ +LDFLAGS = -O +SOFLAGS = -shared -Wl,-x +endif + +ifeq ($(ARCH),macosx) +# MacOS X with cc (GNU cc 2.95.2 and gcc 3.3) +MACOSX_MINOR := $(shell sw_vers | sed -n 's/ProductVersion://p' | cut -d . -f 2) +CXX = c++ +CXXFLAGS = -O2 -pipe -Wall -W -Woverloaded-virtual +LDFLAGS = -O2 -bind_at_load +# The SOFLAGS will be used to create the .dylib, +# the .so will be created separately +DllSuf = dylib +ifeq ($(MACOSX_MINOR),4) +UNDEFOPT = dynamic_lookup +LD = MACOSX_DEPLOYMENT_TARGET=10.4 c++ +else +ifeq ($(MACOSX_MINOR),3) +UNDEFOPT = dynamic_lookup +LD = MACOSX_DEPLOYMENT_TARGET=10.3 c++ +else +UNDEFOPT = suppress +LD = c++ +endif +endif +SOFLAGS = -dynamiclib -single_module -undefined $(UNDEFOPT) +endif + +ifeq ($(ARCH),macosx64) +# MacOS X >= 10.4 with gcc 64 bit mode (GNU gcc 4.*) +MACOSX_MINOR := $(shell sw_vers | sed -n 's/ProductVersion://p' | cut -d . -f 2) +CXX = c++ +CXXFLAGS = -m64 -O2 -pipe -Wall -W -Woverloaded-virtual +LDFLAGS = -m64 -O2 -bind_at_load +# The SOFLAGS will be used to create the .dylib, +# the .so will be created separately +DllSuf = dylib +LD = MACOSX_DEPLOYMENT_TARGET=10.4 c++ +SOFLAGS = -m64 -dynamiclib -single_module -undefined dynamic_lookup +endif + +ifeq ($(ARCH),macosxxlc) +# MacOS X with IBM xlC compiler +MACOSX_MINOR := $(shell sw_vers | sed -n 's/ProductVersion://p' | cut -d . -f 2) +CXX = xlC +CXXFLAGS = -O +LDFLAGS = -O -Wl,-bind_at_load +# The SOFLAGS will be used to create the .dylib, +# the .so will be created separately +DllSuf = dylib +ifeq ($(MACOSX_MINOR),4) +UNDEFOPT = dynamic_lookup +LD = MACOSX_DEPLOYMENT_TARGET=10.4 xlC +else +ifeq ($(MACOSX_MINOR),3) +UNDEFOPT = dynamic_lookup +LD = MACOSX_DEPLOYMENT_TARGET=10.3 xlC +else +UNDEFOPT = suppress +LD = xlC +endif +endif +SOFLAGS = -qmkshrobj -single_module -undefined $(UNDEFOPT) +endif + +ifeq ($(ARCH),win32) +# Windows with the VC++ compiler +ObjSuf = obj +SrcSuf = cxx +ExeSuf = .exe +DllSuf = dll +OutPutOpt = -out: +CXX = cl +CXXOPT = -O2 +#CXXOPT = -Z7 +CXXFLAGS = $(CXXOPT) -G5 -GR -GX -MD -DWIN32 -D_WINDOWS -nologo \ + -DVISUAL_CPLUSPLUS -D_X86_=1 -D_DLL +LD = link +LDOPT = -opt:ref +#LDOPT = -debug +LDFLAGS = $(LDOPT) -pdb:none -nologo +SOFLAGS = -DLL + +ROOTLIBS := $(shell root-config --nonew --libs) +ROOTGLIBS := $(shell root-config --nonew --glibs) +EXPLLINKLIBS = $(ROOTLIBS) $(ROOTGLIBS) +endif + +ifeq ($(ARCH),win32old) +# Windows with the VC++ compiler +ObjSuf = obj +SrcSuf = cxx +ExeSuf = .exe +DllSuf = dll +OutPutOpt = -out: +CXX = cl +CXXOPT = -O2 +#CXXOPT = -Z7 +CXXFLAGS = $(CXXOPT) -G5 -GR -GX -MD -DWIN32 -D_WINDOWS -nologo \ + -DVISUAL_CPLUSPLUS -D_X86_=1 -D_DLL +LD = link +LDOPT = -opt:ref +#LDOPT = -debug +LDFLAGS = $(LDOPT) -pdb:none -nologo +SOFLAGS = -DLL + +ROOTLIBS := $(shell root-config --nonew --libs) +ROOTGLIBS := $(shell root-config --nonew --glibs) +EXPLLINKLIBS = $(ROOTLIBS) $(ROOTGLIBS) +endif + +ifeq ($(ARCH),win32gcc) +# Windows with gcc +DllSuf = dll +ExeSuf = .exe +CXX = g++ +CXXFLAGS = -O -pipe -Wall -Woverloaded-virtual -I/usr/X11R6/include +LD = g++ +LDFLAGS = -O -Wl,--enable-auto-import -Wl,--enable-runtime-pseudo-reloc \ + -L/usr/X11R6/lib +SOFLAGS = -shared -D_DLL -Wl,--export-all-symbols +EXPLLINKLIBS = $(ROOTLIBS) $(ROOTGLIBS) +endif + +ifeq ($(CXX),) +$(error $(ARCH) invalid architecture) +endif + +CXXFLAGS += $(ROOTCFLAGS) +LDFLAGS += $(ROOTLDFLAGS) +LIBS = $(ROOTLIBS) $(SYSLIBS) +GLIBS = $(ROOTGLIBS) $(SYSLIBS) diff --git a/SHUTTLE/DCSClient/macros/LinkDef.h b/SHUTTLE/DCSClient/macros/LinkDef.h new file mode 100644 index 00000000000..17995aefc30 --- /dev/null +++ b/SHUTTLE/DCSClient/macros/LinkDef.h @@ -0,0 +1,13 @@ +#ifdef __CINT__ +/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * + * See cxx source for full Copyright notice */ + +/* $Id$ */ + +#pragma link off all globals; +#pragma link off all classes; +#pragma link off all functions; + +#pragma link C++ class TestServer; + +#endif diff --git a/SHUTTLE/DCSClient/macros/Makefile b/SHUTTLE/DCSClient/macros/Makefile new file mode 100644 index 00000000000..c3e4c511586 --- /dev/null +++ b/SHUTTLE/DCSClient/macros/Makefile @@ -0,0 +1,59 @@ + +include ../../../build/Makefile.$(ALICE_TARGET) + + +CLASSES = TestServer.cxx +DICT = DictTest.cxx + +HEADERS := $(patsubst %.cxx,%.h,$(CLASSES)) + +SRCS = $(CLASSES) $(DICT) + +OBJS := $(patsubst %.cxx,.obj/%.o,$(SRCS)) +DEPS := $(patsubst .obj/%.o,.dep/%.d,$(OBJS)) + +INCDIR = -I$(shell root-config --incdir) -I../ -I../../../include +CXXFLAGS += $(INCDIR) +LIBDIR = $(shell root-config --libdir) + + +SHARED = -shared + +.PHONY: all clean distclean dep + +all: $(DEP) libTest.so + +$(DICT): $(HEADERS) LinkDef.h + rootcint -f $@ -c $(INCDIR) $(HEADERS) LinkDef.h + + +libTest.so: $(OBJS) + $(LD) $(SHARED) $(LDFLAGS) $^ -L$(LIBDIR) $(LIBS) -o $@ + + +dep: $(DICT) $(DEPS) + +clean: + rm -rf DictTest.h + rm -rf DictTest.cxx + rm -rf .dep + rm -rf .obj + rm -rf libTest.so + +distclean: clean + +ifeq ($(filter %clean,$(MAKECMDGOALS)),) +DEPS_MAGIC := $(shell mkdir .dep > /dev/null 2>&1 || :) +endif +ifeq ($(strip $(filter %clean,$(MAKECMDGOALS)) $(filter dep,$(MAKECMDGOALS))),) +OBJS_MAGIC := $(shell mkdir .obj > /dev/null 2>&1 || :) +-include $(DEPS) +endif + +.dep/%.d: %.cxx + set -e; $(CXX) -MM $(CXXFLAGS) $< | \ + awk '/\.o/ {print ".dep/$(*F).d .obj/"$$0} ! /\.o/ {print $$0}' > .dep/$(*F).d + +.obj/%.o: %.cxx + $(CXX) $(CXXFLAGS) -c $< -o .obj/$(*F).o + diff --git a/SHUTTLE/test/TestAliSimpleValue.C b/SHUTTLE/DCSClient/macros/TestAliSimpleValue.C similarity index 100% rename from SHUTTLE/test/TestAliSimpleValue.C rename to SHUTTLE/DCSClient/macros/TestAliSimpleValue.C diff --git a/SHUTTLE/test/TestClient.C b/SHUTTLE/DCSClient/macros/TestClient.C similarity index 100% rename from SHUTTLE/test/TestClient.C rename to SHUTTLE/DCSClient/macros/TestClient.C diff --git a/SHUTTLE/test/TestClientAlias.C b/SHUTTLE/DCSClient/macros/TestClientAlias.C similarity index 86% rename from SHUTTLE/test/TestClientAlias.C rename to SHUTTLE/DCSClient/macros/TestClientAlias.C index bb79c56a46b..727aa11836e 100644 --- a/SHUTTLE/test/TestClientAlias.C +++ b/SHUTTLE/DCSClient/macros/TestClientAlias.C @@ -19,14 +19,19 @@ void GetValues(const char* host, Int_t port, const char* request, sw.Start(); if (requests->GetEntries() > 1) { - + TIter iter(requests); TObjString* aString; + TObjArray* valueSet; while ((aString = (TObjString*) iter.Next())) { - values.Add(new TObjString(aString->String()), NULL); - } - - result = client.GetAliasValues(startTime, endTime, values); + cout<<" Querying: "<GetName()<SetOwner(1); + + result = client.GetDPValues(aString->GetName(), startTime, + endTime, valueSet); + values.Add(aString->Clone(), valueSet); + } } else { TObjArray* valueSet = new TObjArray(); @@ -75,7 +80,7 @@ void GetValues(const char* host, Int_t port, const char* request, /* TFile file("dump.root", "UPDATE"); file.cd(); - valueSet->Write(); + values.Write("DCSAliasMap", TObject::kSingleKey); file.Close(); */ @@ -90,7 +95,7 @@ void GetValues(const char* host, Int_t port, const char* request, void TestClientAlias(const char* host, Int_t port, const char* request, UInt_t startShift, UInt_t endShift) { - gSystem->Load("libSHUTTLE"); + gSystem->Load("AliDCSClient"); // AliLog::EnableDebug(kFALSE); // AliLog::SetGlobalDebugLevel(3); diff --git a/SHUTTLE/test/TestClientDP.C b/SHUTTLE/DCSClient/macros/TestClientDP.C similarity index 85% rename from SHUTTLE/test/TestClientDP.C rename to SHUTTLE/DCSClient/macros/TestClientDP.C index f04e3669b83..4ff54d38ec4 100644 --- a/SHUTTLE/test/TestClientDP.C +++ b/SHUTTLE/DCSClient/macros/TestClientDP.C @@ -8,6 +8,7 @@ void GetValues(const char* host, Int_t port, const char* request, TTimeStamp currentTime; TMap values; + values.SetOwner(1); TString rString(request); @@ -23,19 +24,23 @@ void GetValues(const char* host, Int_t port, const char* request, TIter iter(requests); TObjString* aString; while ((aString = (TObjString*) iter.Next())) { - values.Add(new TObjString(aString->String()), NULL); - } - - result = client.GetDPValues(startTime, endTime, values); + TObjArray* valueSet = new TObjArray(); + valueSet->SetOwner(1); + + result = client.GetDPValues(request, startTime, + endTime, valueSet); + values.Add(new TObjString(request), valueSet); + } + } else { TObjArray* valueSet = new TObjArray(); valueSet->SetOwner(1); - values.Add(new TObjString(request), valueSet); result = client.GetDPValues(request, startTime, - endTime, *valueSet); + endTime, valueSet); + values.Add(new TObjString(request), valueSet); } if (result < 0) { @@ -72,12 +77,13 @@ void GetValues(const char* host, Int_t port, const char* request, } } -/* - TFile file("dump.root", "UPDATE"); + + + TFile file("DCSMap.root", "UPDATE"); file.cd(); - valueSet->Write(); + values.Write("DCSMap",TObject::kSingleKey); file.Close(); -*/ + values.DeleteAll(); delete requests; @@ -90,7 +96,7 @@ void GetValues(const char* host, Int_t port, const char* request, void TestClientDP(const char* host, Int_t port, const char* request, UInt_t startShift, UInt_t endShift) { - gSystem->Load("libSHUTTLE"); + gSystem->Load("AliDCSClient"); // AliLog::EnableDebug(kFALSE); // AliLog::SetGlobalDebugLevel(3); diff --git a/SHUTTLE/test/TestServer.C b/SHUTTLE/DCSClient/macros/TestServer.C similarity index 100% rename from SHUTTLE/test/TestServer.C rename to SHUTTLE/DCSClient/macros/TestServer.C diff --git a/SHUTTLE/test/TestServer.cxx b/SHUTTLE/DCSClient/macros/TestServer.cxx similarity index 100% rename from SHUTTLE/test/TestServer.cxx rename to SHUTTLE/DCSClient/macros/TestServer.cxx diff --git a/SHUTTLE/test/TestServer.h b/SHUTTLE/DCSClient/macros/TestServer.h similarity index 100% rename from SHUTTLE/test/TestServer.h rename to SHUTTLE/DCSClient/macros/TestServer.h diff --git a/SHUTTLE/SHUTTLELinkDef.h b/SHUTTLE/SHUTTLELinkDef.h index f82c0bdbf24..6b1ea86238a 100644 --- a/SHUTTLE/SHUTTLELinkDef.h +++ b/SHUTTLE/SHUTTLELinkDef.h @@ -12,8 +12,8 @@ #pragma link C++ global gMC; // AliDCSClient classes ... -#pragma link C++ class AliDCSMessage; -#pragma link C++ class AliDCSClient; +#pragma link C++ class AliDCSClient+; +#pragma link C++ class AliDCSMessage+; // Shuttle classes ... #pragma link C++ class AliShuttleConfig; diff --git a/SHUTTLE/Shuttle.C b/SHUTTLE/Shuttle.C index 2694db9ee2e..a9717e7c44d 100644 --- a/SHUTTLE/Shuttle.C +++ b/SHUTTLE/Shuttle.C @@ -38,9 +38,10 @@ Bool_t Shuttle(const char* param = "listen") { AliShuttle* shuttle = trigger.GetShuttle(); // Add here detectors preprocessor ... - TestTPCPreprocessor *tpcPrep = new TestTPCPreprocessor("TPC",shuttle); - TestITSPreprocessor *itsPrep = new TestITSPreprocessor("ITS",shuttle); - TestRICHPreprocessor *richPrep = new TestRICHPreprocessor("RICH",shuttle); + TestTPCPreprocessor *tpcPrep = new TestTPCPreprocessor(shuttle); + TestITSPreprocessorSPD *spdPrep = new TestITSPreprocessorSPD("SPD",shuttle); + TestRICHPreprocessor *richPrep = new TestRICHPreprocessor("HMP",shuttle); + TestZDCPreprocessor *zdcPrep = new TestZDCPreprocessor("ZDC",shuttle); TString paramStr(param); diff --git a/SHUTTLE/TestShuttle/AliTestPreprocessor.cxx b/SHUTTLE/TestShuttle/AliTestPreprocessor.cxx index bfa1ba37109..d9f20a3e1ce 100644 --- a/SHUTTLE/TestShuttle/AliTestPreprocessor.cxx +++ b/SHUTTLE/TestShuttle/AliTestPreprocessor.cxx @@ -69,6 +69,19 @@ UInt_t AliTestPreprocessor::Process(TMap* dcsAliasMap) } //TODO here the files could be opened, some values extracted and written to e.g. fData + // Example of how to retrieve a run parameter using GetRunParameter function + // TODO Here the parameter must be set manually with SetInputRunParameter function, + // in reality it will be read from the run logbook! + + // note that the parameters are returned as character strings! + const char* nEvents = GetRunParameter("totalEvents"); + if (nEvents) { + Log(Form("Number of events for run %d: %s",fRun, nEvents)); + } else { + Log(Form("Number of events not put in logbook!")); + } + + //Now we have to store the final CDB file AliCDBMetaData metaData; metaData.SetBeamPeriod(0); diff --git a/SHUTTLE/TestShuttle/AliTestShuttle.cxx b/SHUTTLE/TestShuttle/AliTestShuttle.cxx index 486bbbedc17..0cdf96c72d0 100644 --- a/SHUTTLE/TestShuttle/AliTestShuttle.cxx +++ b/SHUTTLE/TestShuttle/AliTestShuttle.cxx @@ -15,6 +15,9 @@ /* $Log$ +Revision 1.5 2006/10/02 12:58:52 jgrosseo +Small interface change in StoreReferenceData + Revision 1.4 2006/08/08 14:19:07 jgrosseo Update to shuttle classes (Alberto) @@ -73,23 +76,27 @@ some docs added #include #include -#include #include ClassImp(AliTestShuttle) +TString AliTestShuttle::fgkOCDBUri("local://$ALICE_ROOT/SHUTTLE/TestShuttle/TestCDB"); +TString AliTestShuttle::fgkRefUri("local://$ALICE_ROOT/SHUTTLE/TestShuttle/TestReference"); + //______________________________________________________________________________________________ AliTestShuttle::AliTestShuttle(Int_t run, UInt_t startTime, UInt_t endTime) : fRun(run), fStartTime(startTime), fEndTime(endTime), fInputFiles(0), + fRunParameters(0), fPreprocessors(0), fDcsAliasMap(0) { // constructor fInputFiles = new TMap; + fRunParameters = new TMap; fPreprocessors = new TObjArray; } @@ -101,6 +108,9 @@ AliTestShuttle::~AliTestShuttle() delete fInputFiles; fInputFiles = 0; + delete fRunParameters; + fRunParameters = 0; + delete fPreprocessors; fPreprocessors = 0; @@ -133,7 +143,7 @@ UInt_t AliTestShuttle::Store(const AliCDBPath& path, TObject* object, AliCDBMeta AliCDBId id(path, startRun, endRun); - return AliCDBManager::Instance()->Put(object, id, metaData); + return AliCDBManager::Instance()->GetStorage(fgkOCDBUri)->Put(object, id, metaData); } //______________________________________________________________________________________________ @@ -147,7 +157,7 @@ UInt_t AliTestShuttle::StoreReferenceData(const AliCDBPath& path, TObject* objec AliCDBId id(path, fRun, fRun); - return AliCDBManager::Instance()->GetStorage("local://ReferenceStorage")->Put(object, id, metaData); + return AliCDBManager::Instance()->GetStorage(fgkRefUri)->Put(object, id, metaData); } //______________________________________________________________________________________________ @@ -270,5 +280,38 @@ void AliTestShuttle::RegisterPreprocessor(AliPreprocessor* preprocessor) { // registers a preprocessor - fPreprocessors->Add(preprocessor); + const char* detName = preprocessor->GetName(); + if(strcmp("DET", detName) != 0) { + if(GetDetPos(detName) < 0) + AliFatal(Form("********** !!!!! Invalid detector name: %s !!!!! **********", detName)); + } + + fPreprocessors->Add(preprocessor); +} + +//______________________________________________________________________________________________ +void AliTestShuttle::AddInputRunParameter(const char* key, const char* value){ +// set a run parameter (in reality it will be read from the DAQ logbook) + + TObjString* keyObj = new TObjString(key); + if (fRunParameters->Contains(key)) { + AliWarning(Form("Parameter %s already existing and it will be replaced.", key)); + delete fRunParameters->Remove(keyObj); + + } + fRunParameters->Add(keyObj, new TObjString(value)); + AliDebug(2, Form("Number of parameters: %d", fRunParameters-> + GetEntries())); +} + +//______________________________________________________________________________________________ +const char* AliTestShuttle::GetRunParameter(const char* key){ +// get a run parameter + + TObjString* value = dynamic_cast (fRunParameters->GetValue(key)); + if(!value) { + AliError(Form("No such parameter: %s", key)); + return 0; + } + return value->GetName(); } diff --git a/SHUTTLE/TestShuttle/AliTestShuttle.h b/SHUTTLE/TestShuttle/AliTestShuttle.h index e6208e86bab..2e7d5fe43f5 100644 --- a/SHUTTLE/TestShuttle/AliTestShuttle.h +++ b/SHUTTLE/TestShuttle/AliTestShuttle.h @@ -11,6 +11,7 @@ // #include +#include class TMap; class TList; @@ -23,8 +24,14 @@ class AliTestShuttle : public AliShuttleInterface AliTestShuttle(Int_t run, UInt_t startTime, UInt_t endTime); virtual ~AliTestShuttle(); + static TString GetOCDBStorage () {return fgkOCDBUri;} + static void SetOCDBStorage (TString ocdbUri) {fgkOCDBUri = ocdbUri;} + static TString GetReferenceStorage () {return fgkRefUri;} + static void SetReferenceStorage (TString refUri) {fgkRefUri = refUri;} + void AddInputFile(Int_t system, const char* detector, const char* id, const char* source, const char* fileName); void SetDCSInput(TMap* dcsAliasMap) { fDcsAliasMap = dcsAliasMap; } + void AddInputRunParameter(const char* key, const char* value); void Process(); @@ -34,16 +41,21 @@ class AliTestShuttle : public AliShuttleInterface virtual UInt_t StoreReferenceData(const AliCDBPath& path, TObject* object, AliCDBMetaData* metaData); virtual const char* GetFile(Int_t system, const char* detector, const char* id, const char* source); virtual TList* GetFileSources(Int_t system, const char* detector, const char* id); + virtual const char* GetRunParameter(const char* key); virtual void Log(const char* detector, const char* message); virtual void RegisterPreprocessor(AliPreprocessor* preprocessor); protected: + static TString fgkOCDBUri; // URI of the test OCDB storage + static TString fgkRefUri; // URI of the test Reference storage + Int_t fRun; // run that is simulated with the AliTestShuttle UInt_t fStartTime; // starttime that is simulated with the AliTestShuttle UInt_t fEndTime; // endtime that is simulated with the AliTestShuttle - TMap* fInputFiles; // files for GetFile, GetFileSources + TMap* fInputFiles; // files for GetFile, GetFileSources + TMap* fRunParameters; // run parameters TObjArray* fPreprocessors; // list of preprocessors that are to be tested TMap* fDcsAliasMap; // DCS data for testing diff --git a/SHUTTLE/TestShuttle/Makefile b/SHUTTLE/TestShuttle/Makefile index f50cc9d3105..e90b58d84df 100644 --- a/SHUTTLE/TestShuttle/Makefile +++ b/SHUTTLE/TestShuttle/Makefile @@ -8,7 +8,7 @@ include $(PACKAGE).pkg ALICEINC = -I. ifneq ($(ALICE_ROOT),) - ALICEINC += -I$(ALICE_ROOT)/include + ALICEINC += -I$(ALICE_ROOT)/include endif CXXFLAGS += $(ALICEINC) diff --git a/SHUTTLE/TestShuttle/TestPreprocessor.C b/SHUTTLE/TestShuttle/TestPreprocessor.C index 07811532985..53dcf03116c 100644 --- a/SHUTTLE/TestShuttle/TestPreprocessor.C +++ b/SHUTTLE/TestShuttle/TestPreprocessor.C @@ -13,8 +13,13 @@ void TestPreprocessor() // load library gSystem->Load("libTestShuttle.so"); - // initialize location of CDB - AliCDBManager::Instance()->SetDefaultStorage("local://$ALICE_ROOT/SHUTTLE/TestShuttle/TestCDB"); + // TODO if needed, change location of OCDB and Reference test folders + // by default they are set to $ALICE_ROOT/SHUTTLE/TestShuttle/TestCDB and TestReference + // AliTestShuttle::SetOCDBStorage("local://$ALICE_ROOT/SHUTTLE/TestShuttle/TestCDB"); + // AliTestShuttle::SetReferenceStorage("local://$ALICE_ROOT/SHUTTLE/TestShuttle/TestCDB"); + + printf("Test OCDB storage Uri: %s\n", AliTestShuttle::GetOCDBStorage().Data()); + printf("Test Reference storage Uri: %s\n", AliTestShuttle::GetReferenceStorage().Data()); // create AliTestShuttle instance // The parameters are run, startTime, endTime @@ -58,19 +63,31 @@ void TestPreprocessor() shuttle->AddInputFile(AliTestShuttle::kDAQ, "DET", "DRIFTVELOCITY", "LDC2", "file2b.root"); // TODO(3) + // + // The shuttle can read run parameters stored in the DAQ run logbook. + // To test it, we must provide the run parameters manually. They will be retrieved in the preprocessor + // using GetRunParameter function. + // In real life the parameters will be retrieved automatically from the run logbook; + shuttle->AddInputRunParameter("totalEvents", "30000"); + shuttle->AddInputRunParameter("NumberOfGDCs", "15"); + + // TODO(4) // Create the preprocessor that should be tested, it registers itself automatically to the shuttle - AliPreprocessor* pp = new AliTestPreprocessor("DET", shuttle); +// AliPreprocessor* pp = new AliTestPreprocessor("DET", shuttle); +// AliPreprocessor* start = new AliSTARTPreprocessor("T00", shuttle); + AliPreprocessor* test = new AliTestPreprocessor("DET", shuttle); // Test the preprocessor shuttle->Process(); - // TODO(4) + // TODO(5) // In the preprocessor AliShuttleInterface::Store should be called to put the final // data to the CDB. To check if all went fine have a look at the files produced in // $ALICE_ROOT/SHUTTLE/TestShuttle/TestCDB//SHUTTLE/Data // // Check the file which should have been created - AliCDBEntry* entry = AliCDBManager::Instance()->Get("DET/SHUTTLE/Data", 7); + AliCDBEntry* entry = AliCDBManager::Instance()->GetStorage(AliTestShuttle::GetOCDBStorage()) + ->Get("DET/SHUTTLE/Data", 7); if (!entry) { printf("The file is not there. Something went wrong.\n"); diff --git a/SHUTTLE/libSHUTTLE.pkg b/SHUTTLE/libSHUTTLE.pkg index 83d5b3d2e19..6e6f76441ac 100644 --- a/SHUTTLE/libSHUTTLE.pkg +++ b/SHUTTLE/libSHUTTLE.pkg @@ -1,6 +1,6 @@ -SRCS = AliDCSMessage.cxx\ - AliDCSClient.cxx AliShuttle.cxx AliShuttleConfig.cxx\ - AliShuttleTrigger.cxx AliShuttleStatus.cxx AliShuttleLogbookEntry.cxx +SRCS = DCSClient/AliDCSClient.cxx DCSClient/AliDCSMessage.cxx \ + AliShuttle.cxx AliShuttleConfig.cxx \ + AliShuttleTrigger.cxx AliShuttleStatus.cxx AliShuttleLogbookEntry.cxx CINTHDRS:= $(patsubst %,$(MODDIR)/%,$(SRCS:.cxx=.h)) @@ -11,6 +11,6 @@ EINCLUDE := $(DIMDIR)/dim ELIBS := dim ELIBSDIR := $(DIMDIR)/$(ODIR) -DHDR= SHUTTLELinkDef.h +DHDR= SHUTTLELinkDef.h EXPORT:= diff --git a/SHUTTLE/test/LinkDef.h b/SHUTTLE/test/LinkDef.h index cfff8c3a8bf..85e1b74e924 100644 --- a/SHUTTLE/test/LinkDef.h +++ b/SHUTTLE/test/LinkDef.h @@ -8,10 +8,10 @@ #pragma link off all classes; #pragma link off all functions; -#pragma link C++ class TestServer; -#pragma link C++ class TestITSPreprocessor; +#pragma link C++ class TestITSPreprocessorSPD; #pragma link C++ class TestTPCPreprocessor; #pragma link C++ class TestRICHPreprocessor; +#pragma link C++ class TestZDCPreprocessor; #pragma link C++ class AliTPCDataDCS; #endif diff --git a/SHUTTLE/test/Makefile b/SHUTTLE/test/Makefile index a5eed0467f1..352fc41cb95 100644 --- a/SHUTTLE/test/Makefile +++ b/SHUTTLE/test/Makefile @@ -2,7 +2,8 @@ include ../../build/Makefile.$(ALICE_TARGET) -CLASSES = TestServer.cxx TestITSPreprocessor.cxx TestTPCPreprocessor.cxx TestRICHPreprocessor.cxx AliTPCDataDCS.cxx +CLASSES = TestITSPreprocessorSPD.cxx TestTPCPreprocessor.cxx TestRICHPreprocessor.cxx AliTPCDataDCS.cxx \ + TestZDCPreprocessor.cxx DICT = DictTest.cxx HEADERS := $(patsubst %.cxx,%.h,$(CLASSES)) diff --git a/SHUTTLE/test/README b/SHUTTLE/test/README deleted file mode 100644 index 5b55fe128f8..00000000000 --- a/SHUTTLE/test/README +++ /dev/null @@ -1,40 +0,0 @@ -This directory contains several tests devided in two groups: -(for all tests SHUTTLE package must be built) - -1) Unit tests: TestAliSimpleValue.C TestMessage.C - usage: aliroot TestAliSimpleValue.C - -2) General tests and examples: TestClient.C TestServer.C TestShuttle.C - TestShuttleConfig.C - -For TestServer.C and TestShuttle.C test directory must be built. - -TestShuttleConfig.C and TestShuttle.C require ldap server (see SHUTTLE/schema). - - -usage: (in aliroot) - TestClient.C - Simple client macros using AliDCSClient. - .x TestClient.C("", , "", , - ) - - - Amanda server host. - - Amanda server port. - - - coma separated list of aliases - (e.g. "HighVol01,HighVol02"). - - StartTime offset from the current moment. - - EndTime offset from the current moment. - - - TestServer.C - Test server. Could be connected with TestClient.C - .x TestServer.C("") - - Port which the server will listen to. - - - TestShuttle.C - .x TestShuttle.C - - TestShuttleConfig.C - .x TestShuttleConfig.C - - diff --git a/SHUTTLE/test/TestClientAlbe.C b/SHUTTLE/test/TestClientAlbe.C deleted file mode 100644 index 9d709b8f088..00000000000 --- a/SHUTTLE/test/TestClientAlbe.C +++ /dev/null @@ -1,117 +0,0 @@ -Int_t GetValues(const char* host, Int_t port, const char* request, - Long_t startTime, Long_t endTime) -{ - - AliDCSClient client(host, port, 1000, 5); - - Int_t result; - - TTimeStamp currentTime; - TMap values; - - TString rString(request); - - TObjArray* requests = rString.Tokenize(","); - - cout<<"Requests: "<GetEntries()<GetEntries() > 1) { - - TIter iter(requests); - TObjString* aString; - while ((aString = (TObjString*) iter.Next())) { - values.Add(new TObjString(aString->String()), NULL); - } - - result = client.GetDPValues(startTime, endTime, values); - - } else { - TObjArray* valueSet = new TObjArray(); - valueSet->SetOwner(1); - - values.Add(new TObjString(request), valueSet); - - result = client.GetAliasValues(request, startTime, - endTime, *valueSet); - } - - if (result < 0) { - cout<<"Communication failure: "<< - AliDCSClient::GetErrorString(result)< 0) { - cout<<"Time per value: "<String()<<"' values: " - <GetEntriesFast()<ToString()<Load("libSHUTTLE"); - -// AliLog::EnableDebug(kFALSE); -// AliLog::SetGlobalDebugLevel(3); - - TH1F *histo=new TH1F("h","h",36,-6,25); - Int_t result=-1; - for(int i=0;i<100;i++){ - - TTimeStamp currentTime; - - result=GetValues(host, port, request, - currentTime.GetSec() - startShift, - currentTime.GetSec() - endShift); - if(result != 22) printf("\n\n\n NO 22!!!!!!!! %d\n\n",result); - histo->Fill((Float_t)result); - if(i != 99)gSystem->Sleep(10000); - } - - cout<<"Client done"<Draw(); -} - diff --git a/SHUTTLE/test/TestITSPreprocessor.cxx b/SHUTTLE/test/TestITSPreprocessorSPD.cxx similarity index 82% rename from SHUTTLE/test/TestITSPreprocessor.cxx rename to SHUTTLE/test/TestITSPreprocessorSPD.cxx index 112ac880153..e7e3eacc333 100644 --- a/SHUTTLE/test/TestITSPreprocessor.cxx +++ b/SHUTTLE/test/TestITSPreprocessorSPD.cxx @@ -17,7 +17,7 @@ // Example of a Shuttle Preprocessor // -#include "TestITSPreprocessor.h" +#include "TestITSPreprocessorSPD.h" #include "AliCDBMetaData.h" #include "AliDCSValue.h" @@ -25,18 +25,18 @@ #include -ClassImp(TestITSPreprocessor) +ClassImp(TestITSPreprocessorSPD) //________________________________________________________________________________________ -TestITSPreprocessor::TestITSPreprocessor(): - AliPreprocessor("ITS",0) +TestITSPreprocessorSPD::TestITSPreprocessorSPD(): + AliPreprocessor("SPD",0) { // default constructor - Don't use this! } //________________________________________________________________________________________ -TestITSPreprocessor::TestITSPreprocessor(const char* detector, AliShuttleInterface* shuttle): +TestITSPreprocessorSPD::TestITSPreprocessorSPD(const char* detector, AliShuttleInterface* shuttle): AliPreprocessor(detector,shuttle) { // constructor - shuttle must be instantiated! @@ -44,8 +44,8 @@ TestITSPreprocessor::TestITSPreprocessor(const char* detector, AliShuttleInterfa } //________________________________________________________________________________________ -void TestITSPreprocessor::Initialize(Int_t run, UInt_t startTime, - UInt_t endTime) +void TestITSPreprocessorSPD::Initialize(Int_t run, UInt_t startTime, + UInt_t endTime) { // Initialize preprocessor @@ -55,7 +55,7 @@ void TestITSPreprocessor::Initialize(Int_t run, UInt_t startTime, } //________________________________________________________________________________________ -UInt_t TestITSPreprocessor::Process(TMap* valueMap) +UInt_t TestITSPreprocessorSPD::Process(TMap* valueMap) { // process data retrieved by the Shuttle @@ -69,6 +69,6 @@ UInt_t TestITSPreprocessor::Process(TMap* valueMap) AliCDBMetaData metaData; metaData.SetComment("This is a test!"); - return Store("Calib", "ITSData", valueMap, &metaData); + return Store("Calib", "ITSDataSPD", valueMap, &metaData); } diff --git a/SHUTTLE/test/TestITSPreprocessorSPD.h b/SHUTTLE/test/TestITSPreprocessorSPD.h new file mode 100644 index 00000000000..75ecd2c1bda --- /dev/null +++ b/SHUTTLE/test/TestITSPreprocessorSPD.h @@ -0,0 +1,25 @@ +#ifndef TEST_ITS_PRE_PROCESSOR_SPD_H +#define TEST_ITS_PRE_PRECESSOR_SPD_H + +#include "AliPreprocessor.h" + +// +// Example of a Shuttle Preprocessor +// + +class TestITSPreprocessorSPD: public AliPreprocessor { +public: + TestITSPreprocessorSPD(); + TestITSPreprocessorSPD(const char* detector, AliShuttleInterface* shuttle); + +protected: + + virtual void Initialize(Int_t run, UInt_t startTime, + UInt_t endTime); + + virtual UInt_t Process(TMap* valueSet); + + ClassDef(TestITSPreprocessorSPD, 0); +}; + +#endif diff --git a/SHUTTLE/test/TestMessage.C b/SHUTTLE/test/TestMessage.C deleted file mode 100644 index 676bb16063c..00000000000 --- a/SHUTTLE/test/TestMessage.C +++ /dev/null @@ -1,318 +0,0 @@ -void Compare(TObjArray& a, TObjArray& b) { - - Assert(a.GetSize() == b.GetSize()); - - TIter iterA(&a); - TIter iterB(&b); - - AliDCSValue* valA; - AliDCSValue* valB; - - while ((valA = (AliDCSValue*) iterA.Next())) { - valB = (AliDCSValue*) iterB.Next(); - - cout<ToString()<ToString()<GetSimpleValue() == valB->GetSimpleValue()); - Assert(valA->GetTimeStamp() == valB->GetTimeStamp()); - } - -} - -void CompareStr(TObjArray& a, TObjArray& b) { - - cout<<"A size: "<String()<String()<String() == valB->String()); - } -} - -void PrintBuffer(const char* buffer, UInt_t size) { - - cout<<"BUFFER START"<Load("libSHUTTLE"); - - TTimeStamp currentTime; - TString requestString("value.int.something"); - - // Request Message - AliDCSMessage requestMsg; - requestMsg.CreateRequestMessage(AliDCSMessage::kAlias, - currentTime.GetSec(), currentTime.GetSec() + 10, - requestString.Data()); - Assert(requestMsg.GetType() == AliDCSMessage::kRequest); - Assert(requestMsg.GetRequestType() == AliDCSMessage::kAlias); - Assert(requestMsg.GetStartTime() == currentTime.GetSec()); - Assert(requestMsg.GetEndTime() == currentTime.GetSec() + 10); - Assert(requestMsg.GetRequestString() == requestString); - requestMsg.StoreToBuffer(); - - AliDCSMessage newRequestMsg(requestMsg.GetMessage(), - requestMsg.GetMessageSize()); - newRequestMsg.LoadFromBuffer(); - - Assert(newRequestMsg.GetType() == AliDCSMessage::kRequest); - Assert(newRequestMsg.GetRequestType() == AliDCSMessage::kAlias); - Assert(newRequestMsg.GetStartTime() == currentTime.GetSec()); - Assert(newRequestMsg.GetEndTime() == currentTime.GetSec() + 10); - Assert(newRequestMsg.GetRequestString() == requestString); - - - // Count Message - AliDCSMessage countMsg; - countMsg.CreateCountMessage(200); - - Assert(countMsg.GetType() == AliDCSMessage::kCount); - Assert(countMsg.GetCount() == 200); - countMsg.StoreToBuffer(); - - AliDCSMessage newCountMsg(countMsg.GetMessage(), - countMsg.GetMessageSize()); - newCountMsg.LoadFromBuffer(); - - Assert(newCountMsg.GetType() == AliDCSMessage::kCount); - Assert(newCountMsg.GetCount() == 200); - - // ResultSet Message - - Int_t maxCount = 3; - - // Bool - AliDCSMessage rsMsg; - rsMsg.CreateResultSetMessage(AliSimpleValue::kBool); - - Assert(rsMsg.GetType() == AliDCSMessage::kResultSet); - - TObjArray values; - values.SetOwner(1); - values.AddLast(new AliDCSValue(kFALSE, currentTime.GetSec())); - values.AddLast(new AliDCSValue(kTRUE, currentTime.GetSec() + 1)); - values.AddLast(new AliDCSValue(kFALSE, currentTime.GetSec()+ 200)); - - rsMsg.AddValue(*(AliDCSValue*) values.At(0)); - rsMsg.AddValue(*(AliDCSValue*) values.At(1)); - rsMsg.AddValue(*(AliDCSValue*) values.At(2)); - rsMsg.StoreToBuffer(); - - PrintBuffer(rsMsg.GetMessage(), rsMsg.GetMessageSize()); - - AliDCSMessage nrsMsg(rsMsg.GetMessage(), rsMsg.GetMessageSize()); - nrsMsg.LoadFromBuffer(); - - Assert(nrsMsg.GetType() == AliDCSMessage::kResultSet); - Assert(nrsMsg.GetSimpleValueType() == AliSimpleValue::kBool); - - TObjArray nvalues; - nvalues.SetOwner(1); - Assert(nrsMsg.GetValues(nvalues) == maxCount); - - Compare(values, nvalues); - - // Byte - AliDCSMessage rsMsg; - rsMsg.CreateResultSetMessage(AliSimpleValue::kByte); - - Assert(rsMsg.GetType() == AliDCSMessage::kResultSet); - - TObjArray values; - values.SetOwner(1); - values.AddLast(new AliDCSValue((Char_t) 25, currentTime.GetSec())); - values.AddLast(new AliDCSValue((Char_t) 0, currentTime.GetSec() + 1)); - values.AddLast(new AliDCSValue((Char_t) 255, currentTime.GetSec()+ 200)); - - rsMsg.AddValue(*(AliDCSValue*) values.At(0)); - rsMsg.AddValue(*(AliDCSValue*) values.At(1)); - rsMsg.AddValue(*(AliDCSValue*) values.At(2)); - rsMsg.StoreToBuffer(); - - AliDCSMessage nrsMsg(rsMsg.GetMessage(), rsMsg.GetMessageSize()); - nrsMsg.LoadFromBuffer(); - - Assert(nrsMsg.GetType() == AliDCSMessage::kResultSet); - Assert(nrsMsg.GetSimpleValueType() == AliSimpleValue::kByte); - - TObjArray nvalues; - nvalues.SetOwner(1); - Assert(nrsMsg.GetValues(nvalues) == maxCount); - - Compare(values, nvalues); - - - // Int - AliDCSMessage rsMsg; - rsMsg.CreateResultSetMessage(AliSimpleValue::kInt); - - Assert(rsMsg.GetType() == AliDCSMessage::kResultSet); - - TObjArray values; - values.SetOwner(1); - values.AddLast(new AliDCSValue(100, currentTime.GetSec())); - values.AddLast(new AliDCSValue(10, currentTime.GetSec() + 1)); - values.AddLast(new AliDCSValue(666, currentTime.GetSec()+ 200)); - - rsMsg.AddValue(*(AliDCSValue*) values.At(0)); - rsMsg.AddValue(*(AliDCSValue*) values.At(1)); - rsMsg.AddValue(*(AliDCSValue*) values.At(2)); - rsMsg.StoreToBuffer(); - - AliDCSMessage nrsMsg(rsMsg.GetMessage(), rsMsg.GetMessageSize()); - nrsMsg.LoadFromBuffer(); - - Assert(nrsMsg.GetType() == AliDCSMessage::kResultSet); - Assert(nrsMsg.GetSimpleValueType() == AliSimpleValue::kInt); - - TObjArray nvalues; - nvalues.SetOwner(1); - Assert(nrsMsg.GetValues(nvalues) == maxCount); - - Compare(values, nvalues); - - // UInt - AliDCSMessage rsMsg; - rsMsg.CreateResultSetMessage(AliSimpleValue::kUInt); - - Assert(rsMsg.GetType() == AliDCSMessage::kResultSet); - - TObjArray values; - values.SetOwner(1); - values.AddLast(new AliDCSValue((UInt_t) 1000, currentTime.GetSec())); - values.AddLast(new AliDCSValue((UInt_t) 104, currentTime.GetSec() + 1)); - values.AddLast(new AliDCSValue((UInt_t) 6665, currentTime.GetSec()+ 200)); - - rsMsg.AddValue(*(AliDCSValue*) values.At(0)); - rsMsg.AddValue(*(AliDCSValue*) values.At(1)); - rsMsg.AddValue(*(AliDCSValue*) values.At(2)); - rsMsg.StoreToBuffer(); - - AliDCSMessage nrsMsg(rsMsg.GetMessage(), rsMsg.GetMessageSize()); - nrsMsg.LoadFromBuffer(); - - Assert(nrsMsg.GetType() == AliDCSMessage::kResultSet); - Assert(nrsMsg.GetSimpleValueType() == AliSimpleValue::kUInt); - - TObjArray nvalues; - nvalues.SetOwner(1); - Assert(nrsMsg.GetValues(nvalues) == maxCount); - - Compare(values, nvalues); - - // Float - AliDCSMessage rsMsg; - rsMsg.CreateResultSetMessage(AliSimpleValue::kFloat); - - Assert(rsMsg.GetType() == AliDCSMessage::kResultSet); - - TObjArray values; - values.SetOwner(1); - values.AddLast(new AliDCSValue((Float_t) 1000.55, currentTime.GetSec())); - values.AddLast(new AliDCSValue((Float_t) 10.4, currentTime.GetSec() + 1)); - values.AddLast(new AliDCSValue((Float_t) 6665.1, currentTime.GetSec()+ 200)); - - rsMsg.AddValue(*(AliDCSValue*) values.At(0)); - rsMsg.AddValue(*(AliDCSValue*) values.At(1)); - rsMsg.AddValue(*(AliDCSValue*) values.At(2)); - rsMsg.StoreToBuffer(); - - AliDCSMessage nrsMsg(rsMsg.GetMessage(), rsMsg.GetMessageSize()); - nrsMsg.LoadFromBuffer(); - - Assert(nrsMsg.GetType() == AliDCSMessage::kResultSet); - Assert(nrsMsg.GetSimpleValueType() == AliSimpleValue::kFloat); - - TObjArray nvalues; - nvalues.SetOwner(1); - Assert(nrsMsg.GetValues(nvalues) == maxCount); - - Compare(values, nvalues); - - - // Error Message - TString errorString("This is an error string"); - - AliDCSMessage errorMsg; - errorMsg.CreateErrorMessage(AliDCSMessage::kUnknownAliasDPName, - errorString); - Assert(errorMsg.GetType() == AliDCSMessage::kError); - Assert(errorMsg.GetErrorCode() == AliDCSMessage::kUnknownAliasDPName); - Assert(errorMsg.GetErrorString() == errorString); - errorMsg.StoreToBuffer(); - - AliDCSMessage newErrorMsg(errorMsg.GetMessage(), - errorMsg.GetMessageSize()); - newErrorMsg.LoadFromBuffer(); - - Assert(newErrorMsg.GetType() == AliDCSMessage::kError); - Assert(newErrorMsg.GetErrorCode() - == AliDCSMessage::kUnknownAliasDPName); - Assert(newErrorMsg.GetErrorString() == errorString); - - // MultiRequest Message - TObjArray requests; - requests.SetOwner(1); - requests.AddLast(new TObjString("alias1.test")); - requests.AddLast(new TObjString("alias2.test")); - requests.AddLast(new TObjString("alias3.test")); - - AliDCSMessage multiMsg; - multiMsg.CreateMultiRequestMessage(AliDCSMessage::kAlias, - currentTime.GetSec(), - currentTime.GetSec() + 10); - multiMsg.AddRequestString("alias1.test"); - multiMsg.AddRequestString("alias2.test"); - multiMsg.AddRequestString("alias3.test"); - - Assert(multiMsg.GetType() == AliDCSMessage::kMultiRequest); - Assert(multiMsg.GetRequestType() == AliDCSMessage::kAlias); - Assert(multiMsg.GetStartTime() == currentTime.GetSec()); - Assert(multiMsg.GetEndTime() == currentTime.GetSec() + 10); - multiMsg.StoreToBuffer(); - - PrintBuffer(multiMsg.GetMessage(), multiMsg.GetMessageSize()); - - AliDCSMessage nmultiMsg(multiMsg.GetMessage(), - multiMsg.GetMessageSize()); - nmultiMsg.LoadFromBuffer(); - - Assert(nmultiMsg.GetType() == AliDCSMessage::kMultiRequest); - Assert(nmultiMsg.GetRequestType() == AliDCSMessage::kAlias); - Assert(nmultiMsg.GetStartTime() == currentTime.GetSec()); - Assert(nmultiMsg.GetEndTime() == currentTime.GetSec() + 10); - - PrintBuffer(nmultiMsg.GetMessage(), nmultiMsg.GetMessageSize()); - - TObjArray nrequests; - nrequests.SetOwner(1); - nmultiMsg.GetRequestStrings(nrequests); - - CompareStr(requests, nrequests); -} - diff --git a/SHUTTLE/test/TestRICHPreprocessor.cxx b/SHUTTLE/test/TestRICHPreprocessor.cxx index 90e5cc715f2..f4a761d54a8 100644 --- a/SHUTTLE/test/TestRICHPreprocessor.cxx +++ b/SHUTTLE/test/TestRICHPreprocessor.cxx @@ -32,7 +32,7 @@ ClassImp(TestRICHPreprocessor) //________________________________________________________________________________________ TestRICHPreprocessor::TestRICHPreprocessor(): - AliPreprocessor("RICH",0) + AliPreprocessor("HMP",0) { // default constructor - Don't use this! diff --git a/SHUTTLE/test/TestShuttleLogbook.C b/SHUTTLE/test/TestShuttleLogbook.C new file mode 100644 index 00000000000..af32254925a --- /dev/null +++ b/SHUTTLE/test/TestShuttleLogbook.C @@ -0,0 +1,293 @@ + +TSQLServer *fServer=0; + +//______________________________________________________________________________________________ +Bool_t Connect(){ +// Connect to MySQL Server of the DAQ logbook + + // check connection: if already connected return + if(fServer && fServer->IsConnected()) return kTRUE; + + fServer = TSQLServer::Connect("mysql://pcald30.cern.ch","offline","alice"); + + if (!fServer || !fServer->IsConnected()) { + printf("Can't establish connection to DAQ log book DB!\n"); + if(fServer) delete fServer; + return kFALSE; + } + + // Get table + TSQLResult* aResult=0; + aResult = fServer->GetTables("REFSYSLOG"); + delete aResult; + return kTRUE; +} + +//______________________________________________________________________________________________ +Bool_t QueryShuttleLogbook(AliShuttleLogbookEntry& entry, Int_t runNumber=-1) +{ +// Query DAQ's Shuttle logbook and fills detector status array + + if(runNumber<=0 && entry.GetRun()<=0) { + printf("Use a valid Run number!\n"); + return kFALSE; + } + if(!Connect()) return kFALSE; + if(runNumber<=0) runNumber= entry.GetRun(); + entry.SetRun(runNumber); + + // check connection, in case connect + if(!Connect()) return kFALSE; + + TString sqlQuery; + sqlQuery = Form("select * from logbook_shuttle where run = %d", runNumber); + + TSQLResult* aResult = fServer->Query(sqlQuery); + if (!aResult) { + printf("Can't execute query <%s>!\n", sqlQuery.Data()); + return kFALSE; + } + + // TODO Check field count! + if (aResult->GetFieldCount() != 24) { + printf("Invalid SQL result field number!\n"); + delete aResult; + return kFALSE; + } + + TSQLRow* aRow; + while ((aRow = aResult->Next())) { + TString runString(aRow->GetField(0), aRow->GetFieldLength(0)); + Int_t run = runString.Atoi(); + + // loop on detectors + for(UInt_t ii = 0; ii < 24; ii++){ + entry.SetDetectorStatus(aResult->GetFieldName(ii), aRow->GetField(ii)); + } + + delete aRow; + } + + delete aResult; aResult=0; + + // Query run parameters from logbook! + + sqlQuery = Form("select * from logbook where run=%d", runNumber); + + aResult = fServer->Query(sqlQuery); + if (!aResult) { + printf("Can't execute query <%s>!", sqlQuery.Data()); + return kFALSE; + } + + if(aResult->GetRowCount() == 0) { + printf("QueryRunParameters - No entry in DAQ Logbook for run %d!", runNumber); + delete aResult; + return kFALSE; + } + + if(aResult->GetRowCount() > 1) { + printf("More than one entry in DAQ Logbook for run %d!", runNumber); + delete aResult; + return kFALSE; + } + + while ((aRow = aResult->Next())) { + + for(UInt_t ii = 0; ii < aResult->GetFieldCount(); ii++) + entry.SetRunParameter(aResult->GetFieldName(ii), aRow->GetField(ii)); + + UInt_t startTime, endTime; + TString startTimeString = entry.GetRunParameter("time_start"); + UInt_t startTime = startTimeString.Atoi(); + TString endTimeString = entry.GetRunParameter("time_end"); + UInt_t endTime = endTimeString.Atoi(); + + if (!startTime || !endTime || startTime > endTime) { + printf("QueryRunParameters - Invalid parameters for Run %d: startTime = %d, endTime = %d", + runNumber, startTime, endTime); + delete aRow; + delete aResult; + return kFALSE; + } + + entry.SetStartTime(startTime); + entry.SetEndTime(endTime); + + delete aRow; + } + + entry.Print("all"); + + delete aResult; + return kTRUE; +} +//______________________________________________________________________________________________ +Bool_t UpdateShuttleLogbook(AliShuttleLogbookEntry& entry, Int_t runNumber=-1) +{ + // Update Shuttle logbook table - TEST ONLY, USE WITH CARE! + + + if(runNumber<=0 && entry.GetRun()<=0) { + printf("Use a valid Run number!\n"); + return kFALSE; + } + if(!Connect()) return kFALSE; + if(runNumber<=0) runNumber= entry.GetRun(); + entry.SetRun(runNumber); + + TString sqlQuery("update logbook_shuttle set "); + + for(UInt_t i=0; i < AliShuttleInterface::NDetectors(); i++){ + sqlQuery += Form("%s=\"%s\"", AliShuttleInterface::GetDetName(i), entry.GetDetectorStatusName(entry.GetDetectorStatus(i))); + if(i < AliShuttleInterface::NDetectors()-1) sqlQuery += ", "; + } + + sqlQuery += Form(" where run=%d;",entry.GetRun()); + + printf("sqlQuery: %s\n", sqlQuery.Data()); + + TSQLResult* aResult; + aResult = fServer->Query(sqlQuery); + if (!aResult) { + printf("Can't execute query <%s>!\n", sqlQuery.Data()); + return kFALSE; + } + + delete aResult; + + return kTRUE; +} + +//______________________________________________________________________________________________ +Bool_t UpdateShuttleLogbook(Int_t runNumber, const char* detCode, AliShuttleLogbookEntry::Status status) +{ + // Update Shuttle logbook table - TEST ONLY, USE WITH CARE! + + + if(AliShuttleInterface::GetDetPos(detCode) < 0) return kFALSE; + if(!Connect()) return kFALSE; + + TString sqlQuery("update logbook_shuttle set "); + + + sqlQuery += Form("%s=\"%s\" ", detCode, AliShuttleLogbookEntry::GetDetectorStatusName(status)); + + sqlQuery += Form("where run=%d;",runNumber); + + printf("sqlQuery: %s\n", sqlQuery.Data()); + + TSQLResult* aResult; + aResult = fServer->Query(sqlQuery); + if (!aResult) { + printf("Can't execute query <%s>!\n", sqlQuery.Data()); + return kFALSE; + } + + delete aResult; + + return kTRUE; +} + +//______________________________________________________________________________________________ +Bool_t UpdateShuttleLogbook(Int_t runNumber, const char* detCode, const char* status) +{ + // Update Shuttle logbook table - TEST ONLY, USE WITH CARE! + + + if(AliShuttleInterface::GetDetPos(detCode) < 0) return kFALSE; + if(!Connect()) return kFALSE; + + TString sqlQuery("update logbook_shuttle set "); + + + sqlQuery += Form("%s=\"%s\" ", detCode, status); + + sqlQuery += Form("where run=%d;",runNumber); + + printf("sqlQuery: %s\n", sqlQuery.Data()); + + TSQLResult* aResult; + aResult = fServer->Query(sqlQuery); + if (!aResult) { + printf("Can't execute query <%s>!\n", sqlQuery.Data()); + return kFALSE; + } + + delete aResult; + + return kTRUE; +} + +//______________________________________________________________________________________________ +Bool_t InsertNewRun(AliShuttleLogbookEntry& entry, Int_t runNumber=-1) +{ + // Update Shuttle logbook table - TEST ONLY, USE WITH CARE! + + if(runNumber<=0 && entry.GetRun()<=0) { + printf("Use a valid Run number!\n"); + return kFALSE; + } + if(!Connect()) return kFALSE; + if(runNumber<=0) runNumber= entry.GetRun(); + entry.SetRun(runNumber); + + TString sqlQuery = Form("insert into logbook_shuttle (run) values (%d);", runNumber); + + printf("sqlQuery: %s\n", sqlQuery.Data()); + + TSQLResult* aResult; + aResult = fServer->Query(sqlQuery); + if (!aResult) { + printf("Can't execute query <%s>!\n", sqlQuery.Data()); + return kFALSE; + } + + delete aResult; + + UpdateShuttleLogbook(entry); + + return kTRUE; +} + +//______________________________________________________________________________________________ +Bool_t DeleteEntries(Int_t runNumber=-1) +{ + // Update Shuttle logbook table - TEST ONLY, USE WITH CARE! + + if(!Connect()) return kFALSE; + + TString runStr; + if(runNumber>0) runStr=Form("where run=%d",runNumber); + TString sqlQuery = Form("delete from logbook_shuttle %s;", runStr.Data()); + + printf("sqlQuery: %s\n", sqlQuery.Data()); + + TSQLResult* aResult; + aResult = fServer->Query(sqlQuery); + if (!aResult) { + printf("Can't execute query <%s>!\n", sqlQuery.Data()); + return kFALSE; + } + + delete aResult; + + return kTRUE; +} + +//______________________________________________________________________________________________ +void TestShuttleLogbook(){ + + gSystem->Load("libSHUTTLE.so"); + + AliShuttleLogbookEntry::Status y[17]={1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1}; + AliShuttleLogbookEntry lb(21242,0,0,y); + lb.SetDetectorStatus("HMP","Unprocessed"); // RICH + lb.SetDetectorStatus("ZDC","Done"); // ZDC + lb.SetDetectorStatus("TPC","Unprocessed"); // TPC + lb.Print(); + + InsertNewRun(lb); + InsertNewRun(lb,21244); + +} diff --git a/SHUTTLE/test/TestTPCPreprocessor.cxx b/SHUTTLE/test/TestTPCPreprocessor.cxx index 8f9f687b40d..fabeaf68b5e 100644 --- a/SHUTTLE/test/TestTPCPreprocessor.cxx +++ b/SHUTTLE/test/TestTPCPreprocessor.cxx @@ -39,8 +39,8 @@ TestTPCPreprocessor::TestTPCPreprocessor(): } //________________________________________________________________________________________ -TestTPCPreprocessor::TestTPCPreprocessor(const char* detector, AliShuttleInterface* shuttle): - AliPreprocessor(detector,shuttle) +TestTPCPreprocessor::TestTPCPreprocessor(AliShuttleInterface* shuttle): + AliPreprocessor("TPC", shuttle) { // constructor - shuttle must be instantiated! diff --git a/SHUTTLE/test/TestTPCPreprocessor.h b/SHUTTLE/test/TestTPCPreprocessor.h index 609fd74508d..9c0b8e0dcef 100644 --- a/SHUTTLE/test/TestTPCPreprocessor.h +++ b/SHUTTLE/test/TestTPCPreprocessor.h @@ -12,7 +12,7 @@ class TestTPCPreprocessor: public AliPreprocessor { public: TestTPCPreprocessor(); - TestTPCPreprocessor(const char* detector, AliShuttleInterface* shuttle); + TestTPCPreprocessor(AliShuttleInterface* shuttle); ~TestTPCPreprocessor(); protected: diff --git a/SHUTTLE/test/TestZDCPreprocessor.cxx b/SHUTTLE/test/TestZDCPreprocessor.cxx new file mode 100644 index 00000000000..54cd2843ef8 --- /dev/null +++ b/SHUTTLE/test/TestZDCPreprocessor.cxx @@ -0,0 +1,81 @@ +/************************************************************************** + * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * + * * + * Author: The ALICE Off-line Project. * + * Contributors are mentioned in the code where appropriate. * + * * + * Permission to use, copy, modify and distribute this software and its * + * documentation strictly for non-commercial purposes is hereby granted * + * without fee, provided that the above copyright notice appears in all * + * copies and that both the copyright notice and this permission notice * + * appear in the supporting documentation. The authors make no claims * + * about the suitability of this software for any purpose. It is * + * provided "as is" without express or implied warranty. * + **************************************************************************/ + +// +// Prototype of ZDC Preprocessor +// + +#include "TestZDCPreprocessor.h" + +#include "AliCDBMetaData.h" +#include "AliDCSValue.h" +#include "AliLog.h" +#include "AliShuttleInterface.h" + +#include +#include +#include + +ClassImp(TestZDCPreprocessor) + +//________________________________________________________________________________________ +TestZDCPreprocessor::TestZDCPreprocessor(): + AliPreprocessor("ZDC",0) +{ +// default constructor - Don't use this! + +} + +//________________________________________________________________________________________ +TestZDCPreprocessor::TestZDCPreprocessor(const char* detector, AliShuttleInterface* shuttle): + AliPreprocessor(detector,shuttle) +{ +// constructor - shuttle must be instantiated! + +} + +//________________________________________________________________________________________ +void TestZDCPreprocessor::Initialize(Int_t run, UInt_t startTime, + UInt_t endTime) +{ +// Initialize preprocessor + + AliInfo(Form("\n\tRun %d \n\tStartTime %s \n\tEndTime %s", run, + TTimeStamp(startTime).AsString(), + TTimeStamp(endTime).AsString())); + + fRun = run; + fStartTime = startTime; + fEndTime = endTime; + AliInfo("This preprocessor is to test the GetRunParameter function."); +} + +//________________________________________________________________________________________ +UInt_t TestZDCPreprocessor::Process(TMap* /*valueMap*/) +{ +// process data retrieved by the Shuttle + + Int_t result=0; + + const char* dataRate = GetRunParameter("averageDataRate"); + if (dataRate) { + Log(Form("Average data rate for run %d: %s",fRun, dataRate)); + } else { + Log(Form("Average data rate not put in logbook!")); + } + + return dataRate !=0; +} + diff --git a/SHUTTLE/test/TestITSPreprocessor.h b/SHUTTLE/test/TestZDCPreprocessor.h similarity index 52% rename from SHUTTLE/test/TestITSPreprocessor.h rename to SHUTTLE/test/TestZDCPreprocessor.h index 456b1be60aa..911704ebc2d 100644 --- a/SHUTTLE/test/TestITSPreprocessor.h +++ b/SHUTTLE/test/TestZDCPreprocessor.h @@ -1,5 +1,5 @@ -#ifndef TEST_ITS_PRE_PROCESSOR_H -#define TEST_ITS_PRE_PRECESSOR_H +#ifndef TEST_ZDC_PRE_PROCESSOR_SPD_H +#define TEST_ZDC_PRE_PRECESSOR_SPD_H #include "AliPreprocessor.h" @@ -7,10 +7,10 @@ // Example of a Shuttle Preprocessor // -class TestITSPreprocessor: public AliPreprocessor { +class TestZDCPreprocessor: public AliPreprocessor { public: - TestITSPreprocessor(); - TestITSPreprocessor(const char* detector, AliShuttleInterface* shuttle); + TestZDCPreprocessor(); + TestZDCPreprocessor(const char* detector, AliShuttleInterface* shuttle); protected: @@ -19,7 +19,7 @@ protected: virtual UInt_t Process(TMap* valueSet); - ClassDef(TestITSPreprocessor, 0); + ClassDef(TestZDCPreprocessor, 0); }; #endif -- 2.39.3