/*
$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
#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"
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):
fTimeout(timeout), fRetries(retries),
fPreprocessorMap(),
fLogbookEntry(0),
-fCurrentDetector(""),
+fCurrentDetector(),
fStatusEntry(0),
fGridError(kFALSE),
fMonitoringMutex(0),
-fLastActionTime(0)
+fLastActionTime(0),
+fLastAction()
{
//
// config: AliShuttleConfig used
if(fServer[iSys]) {
fServer[iSys]->Close();
delete fServer[iSys];
- fServer[iSys] = 0;
+ fServer[iSys] = 0;
}
if (fStatusEntry){
// 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,
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);
// 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;
// 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",
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()));
AliInfo(Form("\n\n \t\t\t^*^*^*^*^*^*^*^*^*^*^*^* run %d: START ^*^*^*^*^*^*^*^*^*^*^*^* \n",
GetCurrentRun()));
- fLogbookEntry->Print("");
+ fLogbookEntry->Print("all");
// Initialization
Bool_t hasError = kFALSE;
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;
}
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;
}
}
//______________________________________________________________________________________________
-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;
}
//______________________________________________________________________________________________
// 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);
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;
}
// 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;
}
// 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()));
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));
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));
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;
// 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()));
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;
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",
return fLogbookEntry ? fLogbookEntry->GetEndTime() : 0;
}
-//______________________________________________________________________________________________
-const char* AliShuttle::GetDetCode(const char* detector){
-// Return detector code
-
- for(UInt_t iDet=0; iDet < kNDetectors; iDet++){
- if(!strcmp(fgkDetectorName[iDet], detector)) return fgkDetectorCode[iDet];
- }
-
- AliErrorClass(Form("Unknown detector: %s",detector));
- return 0;
-}
-
-//______________________________________________________________________________________________
-const char* AliShuttle::GetDetCode(UInt_t detPos){
-// Return detector code
-
- if( detPos >= kNDetectors) {
- AliErrorClass(Form("Invalid parameter: %d", detPos));
- return 0;
- }
- return fgkDetectorCode[detPos];
-}
-
-//______________________________________________________________________________________________
-const Int_t AliShuttle::GetDetPos(const char* detCode){
-// Return detector position in the detector code array
-
- for(UInt_t iDet=0; iDet < kNDetectors; iDet++){
- if(!strcmp(fgkDetectorCode[iDet], detCode)) return iDet;
- }
- return -1;
-}
-
//______________________________________________________________________________________________
void AliShuttle::Log(const char* detector, const char* message)
{
//______________________________________________________________________________________________
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)) {
return kFALSE;
}
- return kTRUE;
+ return kTRUE;
}
//______________________________________________________________________________________________
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);
+}
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();
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;}
//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);
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);
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
/*
$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
// 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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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());
#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)
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());
+ }
+
}
//______________________________________________________________________________________________
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));
}
//______________________________________________________________________________________________
{
// 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;
}
}
//______________________________________________________________________________________________
-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];
}
}
{
// 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;
{
// 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();
}
//
#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 {
};
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);
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;
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)
};
/*
$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)
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";
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,
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
/*
$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)
//______________________________________________________________________
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()
{
//______________________________________________________________________
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()
{
//______________________________________________________________________
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()
{
--- /dev/null
+#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
--- /dev/null
+
+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
+
--- /dev/null
+# -*- 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)
--- /dev/null
+#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
--- /dev/null
+
+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
+
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();
/*
TFile file("dump.root", "UPDATE");
file.cd();
- valueSet->Write();
+ values.Write("DCSAliasMap", TObject::kSingleKey);
file.Close();
*/
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);
TTimeStamp currentTime;
TMap values;
+ values.SetOwner(1);
TString rString(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) {
}
}
-/*
- 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;
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);
#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;
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);
}
//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);
/*
$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)
#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;
}
delete fInputFiles;
fInputFiles = 0;
+ delete fRunParameters;
+ fRunParameters = 0;
+
delete fPreprocessors;
fPreprocessors = 0;
AliCDBId id(path, startRun, endRun);
- return AliCDBManager::Instance()->Put(object, id, metaData);
+ return AliCDBManager::Instance()->GetStorage(fgkOCDBUri)->Put(object, id, metaData);
}
//______________________________________________________________________________________________
AliCDBId id(path, fRun, fRun);
- return AliCDBManager::Instance()->GetStorage("local://ReferenceStorage")->Put(object, id, metaData);
+ return AliCDBManager::Instance()->GetStorage(fgkRefUri)->Put(object, id, metaData);
}
//______________________________________________________________________________________________
{
// 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();
}
//
#include <AliShuttleInterface.h>
+#include <TString.h>
class TMap;
class TList;
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();
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
ALICEINC = -I.
ifneq ($(ALICE_ROOT),)
- ALICEINC += -I$(ALICE_ROOT)/include
+ ALICEINC += -I$(ALICE_ROOT)/include
endif
CXXFLAGS += $(ALICEINC)
// 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
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");
-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))
ELIBS := dim
ELIBSDIR := $(DIMDIR)/$(ODIR)
-DHDR= SHUTTLELinkDef.h
+DHDR= SHUTTLELinkDef.h
EXPORT:=
#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
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))
+++ /dev/null
-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
-
-
+++ /dev/null
-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();
-}
-
// 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!
}
//________________________________________________________________________________________
-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
}
//________________________________________________________________________________________
-UInt_t TestITSPreprocessor::Process(TMap* valueMap)
+UInt_t TestITSPreprocessorSPD::Process(TMap* valueMap)
{
// process data retrieved by the Shuttle
AliCDBMetaData metaData;
metaData.SetComment("This is a test!");
- return Store("Calib", "ITSData", valueMap, &metaData);
+ return Store("Calib", "ITSDataSPD", valueMap, &metaData);
}
--- /dev/null
+#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
+++ /dev/null
-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);
-}
-
//________________________________________________________________________________________
TestRICHPreprocessor::TestRICHPreprocessor():
- AliPreprocessor("RICH",0)
+ AliPreprocessor("HMP",0)
{
// default constructor - Don't use this!
--- /dev/null
+
+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);
+
+}
}
//________________________________________________________________________________________
-TestTPCPreprocessor::TestTPCPreprocessor(const char* detector, AliShuttleInterface* shuttle):
- AliPreprocessor(detector,shuttle)
+TestTPCPreprocessor::TestTPCPreprocessor(AliShuttleInterface* shuttle):
+ AliPreprocessor("TPC", shuttle)
{
// constructor - shuttle must be instantiated!
public:
TestTPCPreprocessor();
- TestTPCPreprocessor(const char* detector, AliShuttleInterface* shuttle);
+ TestTPCPreprocessor(AliShuttleInterface* shuttle);
~TestTPCPreprocessor();
protected:
--- /dev/null
+/**************************************************************************
+ * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * *
+ * Author: The ALICE Off-line Project. *
+ * Contributors are mentioned in the code where appropriate. *
+ * *
+ * Permission to use, copy, modify and distribute this software and its *
+ * documentation strictly for non-commercial purposes is hereby granted *
+ * without fee, provided that the above copyright notice appears in all *
+ * copies and that both the copyright notice and this permission notice *
+ * appear in the supporting documentation. The authors make no claims *
+ * about the suitability of this software for any purpose. It is *
+ * provided "as is" without express or implied warranty. *
+ **************************************************************************/
+
+//
+// Prototype of ZDC Preprocessor
+//
+
+#include "TestZDCPreprocessor.h"
+
+#include "AliCDBMetaData.h"
+#include "AliDCSValue.h"
+#include "AliLog.h"
+#include "AliShuttleInterface.h"
+
+#include <TTimeStamp.h>
+#include <TObjString.h>
+#include <TSystem.h>
+
+ClassImp(TestZDCPreprocessor)
+
+//________________________________________________________________________________________
+TestZDCPreprocessor::TestZDCPreprocessor():
+ AliPreprocessor("ZDC",0)
+{
+// default constructor - Don't use this!
+
+}
+
+//________________________________________________________________________________________
+TestZDCPreprocessor::TestZDCPreprocessor(const char* detector, AliShuttleInterface* shuttle):
+ AliPreprocessor(detector,shuttle)
+{
+// constructor - shuttle must be instantiated!
+
+}
+
+//________________________________________________________________________________________
+void TestZDCPreprocessor::Initialize(Int_t run, UInt_t startTime,
+ UInt_t endTime)
+{
+// Initialize preprocessor
+
+ AliInfo(Form("\n\tRun %d \n\tStartTime %s \n\tEndTime %s", run,
+ TTimeStamp(startTime).AsString(),
+ TTimeStamp(endTime).AsString()));
+
+ fRun = run;
+ fStartTime = startTime;
+ fEndTime = endTime;
+ AliInfo("This preprocessor is to test the GetRunParameter function.");
+}
+
+//________________________________________________________________________________________
+UInt_t TestZDCPreprocessor::Process(TMap* /*valueMap*/)
+{
+// process data retrieved by the Shuttle
+
+ Int_t result=0;
+
+ const char* dataRate = GetRunParameter("averageDataRate");
+ if (dataRate) {
+ Log(Form("Average data rate for run %d: %s",fRun, dataRate));
+ } else {
+ Log(Form("Average data rate not put in logbook!"));
+ }
+
+ return dataRate !=0;
+}
+
-#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"
// 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:
virtual UInt_t Process(TMap* valueSet);
- ClassDef(TestITSPreprocessor, 0);
+ ClassDef(TestZDCPreprocessor, 0);
};
#endif