major update (Alberto)
authorjgrosseo <jgrosseo@f7af4fe6-9843-0410-8265-dc069ae4e863>
Mon, 6 Nov 2006 14:23:04 +0000 (14:23 +0000)
committerjgrosseo <jgrosseo@f7af4fe6-9843-0410-8265-dc069ae4e863>
Mon, 6 Nov 2006 14:23:04 +0000 (14:23 +0000)
o) reading of run parameters from the logbook
o) online offline naming conversion
o) standalone DCSclient package

42 files changed:
SHUTTLE/AliShuttle.cxx
SHUTTLE/AliShuttle.h
SHUTTLE/AliShuttleConfig.cxx
SHUTTLE/AliShuttleLogbookEntry.cxx
SHUTTLE/AliShuttleLogbookEntry.h
SHUTTLE/DCSClient/AliDCSClient.cxx [moved from SHUTTLE/AliDCSClient.cxx with 98% similarity]
SHUTTLE/DCSClient/AliDCSClient.h [moved from SHUTTLE/AliDCSClient.h with 88% similarity]
SHUTTLE/DCSClient/AliDCSMessage.cxx [moved from SHUTTLE/AliDCSMessage.cxx with 98% similarity]
SHUTTLE/DCSClient/AliDCSMessage.h [moved from SHUTTLE/AliDCSMessage.h with 100% similarity]
SHUTTLE/DCSClient/DCSClientLinkDef.h [new file with mode: 0644]
SHUTTLE/DCSClient/Makefile [new file with mode: 0644]
SHUTTLE/DCSClient/Makefile.arch [new file with mode: 0644]
SHUTTLE/DCSClient/macros/LinkDef.h [new file with mode: 0644]
SHUTTLE/DCSClient/macros/Makefile [new file with mode: 0644]
SHUTTLE/DCSClient/macros/TestAliSimpleValue.C [moved from SHUTTLE/test/TestAliSimpleValue.C with 100% similarity]
SHUTTLE/DCSClient/macros/TestClient.C [moved from SHUTTLE/test/TestClient.C with 100% similarity]
SHUTTLE/DCSClient/macros/TestClientAlias.C [moved from SHUTTLE/test/TestClientAlias.C with 86% similarity]
SHUTTLE/DCSClient/macros/TestClientDP.C [moved from SHUTTLE/test/TestClientDP.C with 85% similarity]
SHUTTLE/DCSClient/macros/TestServer.C [moved from SHUTTLE/test/TestServer.C with 100% similarity]
SHUTTLE/DCSClient/macros/TestServer.cxx [moved from SHUTTLE/test/TestServer.cxx with 100% similarity]
SHUTTLE/DCSClient/macros/TestServer.h [moved from SHUTTLE/test/TestServer.h with 100% similarity]
SHUTTLE/SHUTTLELinkDef.h
SHUTTLE/Shuttle.C
SHUTTLE/TestShuttle/AliTestPreprocessor.cxx
SHUTTLE/TestShuttle/AliTestShuttle.cxx
SHUTTLE/TestShuttle/AliTestShuttle.h
SHUTTLE/TestShuttle/Makefile
SHUTTLE/TestShuttle/TestPreprocessor.C
SHUTTLE/libSHUTTLE.pkg
SHUTTLE/test/LinkDef.h
SHUTTLE/test/Makefile
SHUTTLE/test/README [deleted file]
SHUTTLE/test/TestClientAlbe.C [deleted file]
SHUTTLE/test/TestITSPreprocessorSPD.cxx [copied from SHUTTLE/test/TestITSPreprocessor.cxx with 82% similarity]
SHUTTLE/test/TestITSPreprocessorSPD.h [new file with mode: 0644]
SHUTTLE/test/TestMessage.C [deleted file]
SHUTTLE/test/TestRICHPreprocessor.cxx
SHUTTLE/test/TestShuttleLogbook.C [new file with mode: 0644]
SHUTTLE/test/TestTPCPreprocessor.cxx
SHUTTLE/test/TestTPCPreprocessor.h
SHUTTLE/test/TestZDCPreprocessor.cxx [moved from SHUTTLE/test/TestITSPreprocessor.cxx with 70% similarity]
SHUTTLE/test/TestZDCPreprocessor.h [moved from SHUTTLE/test/TestITSPreprocessor.h with 52% similarity]

index 68396bf..abc17f0 100644 (file)
 
 /*
 $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<AliPreprocessor*> (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<TSQLRow*> (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",
@@ -1476,39 +1465,6 @@ UInt_t AliShuttle::GetCurrentEndTime() const
 }
 
 //______________________________________________________________________________________________
-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)
 {
 // Fill log string with a 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);
+}
index 9e0ba6c..7eeb10c 100644 (file)
@@ -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
index 3cb77d9..38132a6 100644 (file)
 
 /*
 $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());
index 55cf09c..a5b049c 100644 (file)
 #include "AliShuttleLogbookEntry.h"
 #include "AliLog.h"
 #include "TTimeStamp.h"
-
-// TODO test only!
-#include <TSQLServer.h>
-#include <TSQLResult.h>
-#include <TSQLRow.h>
-#include <TObjArray.h>
+#include <TString.h>
+#include <TObjString.h>
+#include <TMap.h>
 
 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<TPair*>(iter.Next()))){
+               TObjString* aKey= dynamic_cast<TObjString*>(aPair->Key());
+               TObjString* aValue= dynamic_cast<TObjString*>(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<TPair*>(iter.Next()))){
+               TObjString* aKey= dynamic_cast<TObjString*>(aPair->Key());
+               TObjString* aValue= dynamic_cast<TObjString*>(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<TPair*>(iter.Next()))){
+                       TObjString* aKey= dynamic_cast<TObjString*>(aPair->Key());
+                       TObjString* aValue= dynamic_cast<TObjString*>(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<TObjString*> (fRunParameters.GetValue(key));
+       if(!value) {
+               AliError(Form("No such parameter: %s", key));
+               return 0;
        }
-
-       delete aResult;
-
-       UpdateShuttleLogbook();
-
-       return kTRUE;
+       return value->GetName();
 }
index d7bac65..8db47fd 100644 (file)
 //
 
 #include <TObject.h>
-#include "AliShuttle.h"
+#include <TString.h>
+#include <TMap.h>
 
-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)
 };
similarity index 98%
rename from SHUTTLE/AliDCSClient.cxx
rename to SHUTTLE/DCSClient/AliDCSClient.cxx
index 3f7710f..4327b9b 100644 (file)
 
 /*
 $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";
similarity index 88%
rename from SHUTTLE/AliDCSClient.h
rename to SHUTTLE/DCSClient/AliDCSClient.h
index d7c1a9f..a019171 100644 (file)
@@ -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
similarity index 98%
rename from SHUTTLE/AliDCSMessage.cxx
rename to SHUTTLE/DCSClient/AliDCSMessage.cxx
index bfa6fec..6a46c48 100644 (file)
 
 /*
 $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/DCSClient/DCSClientLinkDef.h b/SHUTTLE/DCSClient/DCSClientLinkDef.h
new file mode 100644 (file)
index 0000000..df5709b
--- /dev/null
@@ -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 (file)
index 0000000..22b8510
--- /dev/null
@@ -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 (file)
index 0000000..3e233eb
--- /dev/null
@@ -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 (file)
index 0000000..17995ae
--- /dev/null
@@ -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 (file)
index 0000000..c3e4c51
--- /dev/null
@@ -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 
+
similarity index 86%
rename from SHUTTLE/test/TestClientAlias.C
rename to SHUTTLE/DCSClient/macros/TestClientAlias.C
index bb79c56..727aa11 100644 (file)
@@ -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: "<<aString->GetName()<<endl;
+                       valueSet = new TObjArray();
+                       valueSet->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);
similarity index 85%
rename from SHUTTLE/test/TestClientDP.C
rename to SHUTTLE/DCSClient/macros/TestClientDP.C
index f04e366..4ff54d3 100644 (file)
@@ -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);
index f82c0bd..6b1ea86 100644 (file)
@@ -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;
index 2694db9..a9717e7 100644 (file)
@@ -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);
        
index bfa1ba3..d9f20a3 100644 (file)
@@ -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);
index 486bbbe..0cdf96c 100644 (file)
@@ -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 <TMap.h>
 #include <TList.h>
-#include <TString.h>
 #include <TObjString.h>
 
 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<TObjString*> (fRunParameters->GetValue(key));
+       if(!value) {
+               AliError(Form("No such parameter: %s", key));
+               return 0;
+       }
+       return value->GetName();
 }
index e6208e8..2e7d5fe 100644 (file)
@@ -11,6 +11,7 @@
 //
 
 #include <AliShuttleInterface.h>
+#include <TString.h>
 
 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
 
index f50cc9d..e90b58d 100644 (file)
@@ -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)
index 0781153..53dcf03 100644 (file)
@@ -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/<detector>/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");
index 83d5b3d..6e6f764 100644 (file)
@@ -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:=
index cfff8c3..85e1b74 100644 (file)
@@ -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
index a5eed04..352fc41 100644 (file)
@@ -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 (file)
index 5b55fe1..0000000
+++ /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("<host>", <port>, "<alias_list>", <startTime_offset>,
-               <endTime_offset>)
-
-       <host> - Amanda server host.
-       <port> - Amanda server port.
-       
-       <alias_list> - coma separated list of aliases 
-               (e.g. "HighVol01,HighVol02").
-       <startTime_offset> - StartTime offset from the current moment.
-       <endTime_offset> - EndTime offset from the current moment.
-
-       
-       TestServer.C - Test server. Could be connected with TestClient.C
-       .x TestServer.C("<port>")
-       <port> - 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 (file)
index 9d709b8..0000000
+++ /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: "<<requests->GetEntries()<<endl;
-
-       TStopwatch sw;
-       sw.Start();
-
-       if (requests->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)<<endl;
-
-               if (result == AliDCSClient::fgkServerError) {
-                       cout<<"Server error code: "<<
-                               client.GetServerErrorCode()<<endl;
-                       cout<<client.GetServerError()<<endl;
-               }
-       }
-       
-       sw.Stop();
-       cout<<"Elapsed time: "<<sw.RealTime()<<endl;
-       if (result > 0) {
-               cout<<"Time per value: "<<sw.RealTime()/result<<endl;
-       }
-       cout<<"Received values: "<<result<<endl;
-
-
-/* 
-       TIter iter(&values);
-       TObjString* aRequest;
-       while ((aRequest = (TObjString*) iter.Next())) {
-
-               TObjArray* valueSet = (TObjArray*) values.GetValue(aRequest);
-               
-               cout<<" '"<<aRequest->String()<<"' values: " 
-                       <<valueSet->GetEntriesFast()<<endl;
-
-               TIter valIter(valueSet);
-               AliDCSValue* aValue;
-               while ((aValue = (AliDCSValue*) valIter.Next())) {
-                       cout<<aValue->ToString()<<endl;
-               } 
-       }
-
- */
-/*     TFile file("dump.root", "UPDATE");
-       file.WriteTObject(values, "values");
-       file.Close(); */
-
-       values.DeleteAll();
-       delete requests;
-
-       cout<<"All values returned in runrange:  "<<endl;
-       cout<<"StartTime: "<<TTimeStamp(startTime).AsString()<<endl;
-       cout<<"EndTime: "<<TTimeStamp(endTime).AsString()<<endl;
-       
-       return result;
-}
-
-void TestClientAlbe(const char* host, Int_t port, const char* request,
-       UInt_t startShift, UInt_t endShift) {
-
-       gSystem->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"<<endl;
-       histo->Draw();
-}
-
similarity index 82%
copy from SHUTTLE/test/TestITSPreprocessor.cxx
copy to SHUTTLE/test/TestITSPreprocessorSPD.cxx
index 112ac88..e7e3eac 100644 (file)
@@ -17,7 +17,7 @@
 // Example of a Shuttle Preprocessor
 //
 
-#include "TestITSPreprocessor.h"
+#include "TestITSPreprocessorSPD.h"
 
 #include "AliCDBMetaData.h"
 #include "AliDCSValue.h"
 
 #include <TTimeStamp.h>
 
-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 (file)
index 0000000..75ecd2c
--- /dev/null
@@ -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 (file)
index 676bb16..0000000
+++ /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<<valA->ToString()<<endl;
-               cout<<valB->ToString()<<endl;
-
-               Assert(valA->GetSimpleValue() == valB->GetSimpleValue());
-               Assert(valA->GetTimeStamp() == valB->GetTimeStamp());
-       }
-       
-}
-
-void CompareStr(TObjArray& a, TObjArray& b) {
-
-       cout<<"A size: "<<a.GetSize()<<endl;
-       cout<<"B size: "<<b.GetSize()<<endl;
-
-        Assert(a.GetSize() == b.GetSize());
-
-        TIter iterA(&a);
-        TIter iterB(&b);
-
-        TObjString* valA;
-        TObjString* valB;
-
-        while ((valA = (TObjString*) iterA.Next())) {
-                valB = (TObjString*) iterB.Next();
-         
-                cout<<valA->String()<<endl;
-                cout<<valB->String()<<endl;
-
-               Assert(valA->String() == valB->String());
-        }
-}
-
-void PrintBuffer(const char* buffer, UInt_t size) {
-       
-       cout<<"BUFFER START"<<endl;
-
-       for (UInt_t k = 0; k < size; k ++) {
-               cout<<" "<<(UInt_t) (UChar_t) buffer[k]<<" ";
-               if (!(k + 1 % 50)) {
-                       cout<<endl;
-               }
-       }
-       
-       cout<<endl<<"BUFFER END"<<endl;
-}
-
-void TestMessage() {
-
-       gSystem->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);
-}
-
index 90e5cc7..f4a761d 100644 (file)
@@ -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 (file)
index 0000000..af32254
--- /dev/null
@@ -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);
+
+}
index 8f9f687..fabeaf6 100644 (file)
@@ -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!
 
index 609fd74..9c0b8e0 100644 (file)
@@ -12,7 +12,7 @@ class TestTPCPreprocessor: public AliPreprocessor {
 public:
 
        TestTPCPreprocessor();
-       TestTPCPreprocessor(const char* detector, AliShuttleInterface* shuttle);
+       TestTPCPreprocessor(AliShuttleInterface* shuttle);
        ~TestTPCPreprocessor();
 
 protected:
similarity index 70%
rename from SHUTTLE/test/TestITSPreprocessor.cxx
rename to SHUTTLE/test/TestZDCPreprocessor.cxx
index 112ac88..54cd284 100644 (file)
  **************************************************************************/
 
 //
-// Example of a Shuttle Preprocessor
+// Prototype of ZDC Preprocessor
 //
 
-#include "TestITSPreprocessor.h"
+#include "TestZDCPreprocessor.h"
 
 #include "AliCDBMetaData.h"
 #include "AliDCSValue.h"
 #include "AliLog.h"
+#include "AliShuttleInterface.h"
 
 #include <TTimeStamp.h>
+#include <TObjString.h>
+#include <TSystem.h>
 
-ClassImp(TestITSPreprocessor)
+ClassImp(TestZDCPreprocessor)
 
 //________________________________________________________________________________________
-TestITSPreprocessor::TestITSPreprocessor():
-       AliPreprocessor("ITS",0)
+TestZDCPreprocessor::TestZDCPreprocessor():
+       AliPreprocessor("ZDC",0)
 {
 // default constructor - Don't use this!
 
 }
 
 //________________________________________________________________________________________
-TestITSPreprocessor::TestITSPreprocessor(const char* detector, AliShuttleInterface* shuttle):
+TestZDCPreprocessor::TestZDCPreprocessor(const char* detector, AliShuttleInterface* shuttle):
        AliPreprocessor(detector,shuttle)
 {
 // constructor - shuttle must be instantiated!
@@ -44,31 +47,35 @@ TestITSPreprocessor::TestITSPreprocessor(const char* detector, AliShuttleInterfa
 }
 
 //________________________________________________________________________________________
-void TestITSPreprocessor::Initialize(Int_t run, UInt_t startTime,
-       UInt_t endTime) 
+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, 
+       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 TestITSPreprocessor::Process(TMap* valueMap)
+UInt_t TestZDCPreprocessor::Process(TMap* /*valueMap*/)
 {
 // process data retrieved by the Shuttle
 
-       AliInfo(Form("You're in AliITSPreprocessor::Process!"));
+       Int_t result=0;
 
-       TIter iter(valueMap);
-       TPair* aPair;
-       while ((aPair = (TPair*) iter.Next())) {
-               aPair->Print();
+       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!"));
        }
-       AliCDBMetaData metaData;
-       metaData.SetComment("This is a test!");
 
-       return Store("Calib", "ITSData", valueMap, &metaData);
+       return dataRate !=0;
 }
 
similarity index 52%
rename from SHUTTLE/test/TestITSPreprocessor.h
rename to SHUTTLE/test/TestZDCPreprocessor.h
index 456b1be..911704e 100644 (file)
@@ -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