40 #include "TTimeStamp.h" 43 CWB::History::History(
char** StageNames,
int StageNumber,
char** TypeNames,
int TypeNumber,
char* FilePrefix,
bool HistoryModify) {
45 TTimeStamp CreationTT;
51 if (StageNames != NULL) {
53 for (i = 0; i < StageNumber; i++) {
54 if (StageNames[i] == NULL)
HistoryException(kBreak,
"CWB::History::History",
"StageNames[%i] is NULL", i);
55 this->StageNames.AddLast(
new TObjString(StageNames[i]));
59 if (TypeNames != NULL) {
61 for (i = 0; i < TypeNumber; i++) {
62 if (TypeNames[i] == NULL)
HistoryException(kBreak,
"CWB::History::History",
"TypeNames[%i] is NULL", i);
63 this->TypeNames.AddLast(
new TObjString(TypeNames[i]));
67 if (FilePrefix != NULL) this->FilePrefix.SetString(FilePrefix);
68 else this->FilePrefix.SetString(
"");
76 for (i = 0; i < History.
StageNames.GetSize(); i++) {
79 for (i = 0; i < History.
TypeNames.GetSize(); i++) {
80 this->
TypeNames.AddLast(
new TObjString(*static_cast<TObjString*>(History.
TypeNames.At(i))));
82 for (i = 0; i < History.
StageList.GetSize(); i++) {
101 if (strcmp(Name, static_cast<TObjString*>(
StageNames.At(
i))->GetName()) == 0)
return true;
112 if (strcmp(StrApp, Name) == 0) {
129 if (strcmp(Name, static_cast<TObjString*>(
TypeNames.At(
i))->GetName()) == 0)
return true;
140 if (StageNames == NULL)
HistoryException(kBreak,
"CWB::History::SetStageNames",
"StageNames is NULL");
142 this->StageNames.Delete();
144 for (i = 0; i < StageNumber; i++) {
145 if (StageNames[i] == NULL)
HistoryException(kBreak,
"History:SetStageNames",
"StageNames[%i] is NULL", i);
146 this->StageNames.AddLast(
new TObjString(StageNames[i]));
149 for (i =0; i <
StageList.GetSize(); i++) {
167 if (TypeNames == NULL)
HistoryException(kBreak,
"CWB::History::SetTypeNames",
"TypeNames is NULL");
168 this->TypeNames.Delete();
170 for (i = 0; i < TypeNumber; i++) {
171 if (TypeNames[i] == NULL)
HistoryException(kBreak,
"History:SetTypeNames",
"TypeNames[%i] is NULL", i);
172 this->TypeNames.AddLast(
new TObjString(TypeNames[i]));
202 tmpStage->
AddLog(Log, Time);
221 tmpStage->
AddLog(Log, Date, Time);
264 this->FilePrefix.SetString(FilePrefix);
280 for (i = 0; i <
StageList.GetSize(); i++) {
282 if (strcmp(StrApp, StageName) == 0) {
293 HistoryException(kBreak,
"CWB::History::GetHistoryDatime",
"Not implemented !!!");
333 char cfg_tmp_name[256];
334 sprintf(cfg_tmp_name,
"/dev/shm/%f.history.cfg",
fabs(random.Uniform()));
337 if (getenv(
"IGEC_HISTORY_VIEWER") != NULL) {
338 sprintf(tmpStr,
"%s %s", getenv(
"IGEC_HISTORY_VIEWER"), cfg_tmp_name);
339 ret = system(tmpStr);
341 sprintf(tmpStr,
"vim %s", cfg_tmp_name);
346 sprintf(tmpStr,
"vim %s", cfg_tmp_name);
350 sprintf(tmpStr,
"rm -f %s", cfg_tmp_name);
373 char cfg_tmp_name[256];
374 sprintf(cfg_tmp_name,
"/dev/shm/%f.history.cfg",
fabs(random.Uniform()));
377 if (getenv(
"IGEC_HISTORY_VIEWER") != NULL) {
378 sprintf(tmpStr,
"%s %s", getenv(
"IGEC_HISTORY_VIEWER"), cfg_tmp_name);
379 ret = system(tmpStr);
381 sprintf(tmpStr,
"vim %s", cfg_tmp_name);
386 sprintf(tmpStr,
"vim %s", cfg_tmp_name);
390 sprintf(tmpStr,
"rm -f %s", cfg_tmp_name);
399 if (FileName != NULL) file_name =
TString(FileName);
402 cout <<
"Dump To File " << file_name.Data() << endl;
412 if (FileName != NULL)
strcpy(fname, FileName);
416 strcpy(fname, file_name.Data());
418 cout <<
"Dump To File " << fname << endl;
420 RootFile =
new TFile(fname,
"RECREATE");
432 for(i = 0; i <
StageNames.GetEntries(); i++) {
433 TmpList->AddLast(
new TObjString(
StageNames.At(i)->GetName()));
445 for(i = 0; i <
TypeNames.GetEntries(); i++) {
446 TmpList->AddLast(
new TObjString(
TypeNames.At(i)->GetName()));
466 HistoryException(kBreak,
"CWB::History::AddStage",
"History Modify not allowed");
469 HistoryException(kBreak,
"CWB::History::AddStage",
"Stage %s already present", StageName);
471 StageNames.AddLast(
new TObjString(StageName));
481 TObjString* TempString;
484 HistoryException(kBreak,
"CWB::History::RemoveStage",
"History Modify not allowed");
487 HistoryException(kBreak,
"CWB::History::RemoveStage",
"Stage %s not present", StageName);
490 TempString =
static_cast<TObjString*
>(
StageNames.At(i));
491 if (strcmp(TempString->GetName(), StageName) == 0)
StageNames.Remove(TempString);
494 for (i = 0; i <
StageList.GetSize(); i++) {
510 HistoryException(kBreak,
"Hsitory::AddType" ,
"Type %s already present", TypeName);
512 TypeNames.AddLast(
new TObjString(TypeName));
523 TObjString* TempString;
527 HistoryException(kBreak,
"Hsitory::RemoveType",
"History modify not allowed");
530 HistoryException(kBreak,
"Hsitory::RemoveType" ,
"Type %s not present", TypeName);
532 for (i = 0; i <
TypeNames.GetSize(); i++) {
533 TempString =
static_cast<TObjString*
>(
TypeNames.At(i));
534 if (strcmp(TempString->GetName(), TypeName) == 0)
TypeNames.Remove(TempString);
537 for(i = 0; i <
StageList.GetSize(); i++) {
547 HistoryException(kBreak,
"CWB::History::SetStageComment",
"Stage %s not allowed", Stage);
550 HistoryException(kBreak,
"CWB::History::SetStageComment",
"Stage %s not present yet", Stage);
558 HistoryException(kBreak,
"CWB::History::SetTypeComment",
"Stage %s not allowed", Stage);
561 HistoryException(kBreak,
"CWB::History::SetTypeComment",
"Stage %s not present yet", Stage);
569 HistoryException(kBreak,
"CWB::History::GetStageComment",
"Stage %s not allowed", Stage);
572 HistoryException(kBreak,
"CWB::History::GetStageComment",
"Stage %s not present", Stage);
580 HistoryException(kBreak,
"CWB::History::GetTypeComment",
"Stage %s not allowed", Stage);
583 HistoryException(kBreak,
"CWB::History::GetTypeComment",
"Stage %s not present", Stage);
593 for (i = 0; i <
StageList.GetSize(); i++) {
627 for (i = 0; i <
StageList.GetSize(); i++) {
638 for (i = 0; i <
StageList.GetSize(); i++) {
659 for (i = 0; i <
StageList.GetSize(); i++) {
674 HistoryException(kBreak,
"CWB::History::GetCreationDate",
"Stage %s not allowed", Stage);
677 HistoryException(kBreak,
"CWB::History::GetCreationDate",
"Stage %s not present yet", Stage);
698 for (i = 0; i <
StageList.GetSize(); i++) {
701 if (strcmp(StrApp, Name) == 0) {
714 for (i = 0; i < NameNumber; i++) {
715 for (j = i + 1; j < NameNumber; j++) {
716 if (strcmp(NameList[i], NameList[j]) == 0)
return true;
724 char *StrApp1, *StrApp2, tmpStr[256];
728 ofstream OutFile(FileName,
ios::out);
730 if (OutFile.fail())
HistoryException(kBreak,
"CWB::History::WriteToFile",
"Error opening output file");
734 for (i = 0; i <
StageList.GetSize(); i++) {
735 TDatime tmpTime(static_cast<HistoryStage*>(
StageList.At(i))->GetDate(),
741 length = strlen(StrApp1);
749 OutFile << tmpStr << endl;
753 if (strlen(StrApp1) > 0) {
754 OutFile << StrApp1 << endl;
758 sprintf(tmpStr,
"Date: %i/%i/%i - Time: %i:%i:%i", tmpTime.GetDay(), tmpTime.GetMonth(),
759 tmpTime.GetYear(), tmpTime.GetHour(), tmpTime.GetMinute(), tmpTime.GetSecond());
760 OutFile << tmpStr << endl;
764 OutFile << tmpStr << endl;
767 if (static_cast<HistoryStage*>(
StageList.At(i))->GetHistorySize() > 0) {
768 sprintf(tmpStr,
"Stage's History:");
769 OutFile << tmpStr << endl;
771 for (j = 0; j < static_cast<HistoryStage*>(
StageList.At(i))->GetHistorySize(); j++) {
773 OutFile << StrApp2 <<
": " << endl;
776 OutFile << StrApp2 << endl;
782 sprintf(tmpStr,
"Stage's Logs:");
783 OutFile << tmpStr << endl;
788 OutFile << TimePtr->GetDay() <<
"/" << TimePtr->GetMonth() <<
"/" << TimePtr->GetYear() <<
" - ";
789 OutFile << TimePtr->GetHour() <<
":" << TimePtr->GetMinute() <<
":" << TimePtr->GetSecond() <<
" ";
792 OutFile << StrApp2 << endl;
798 OutFile << endl << endl;
809 if (strcmp(StrApp, Name) == 0) {
816 void CWB::History::Streamer(TBuffer &R__b)
819 TDatime CreationDatime;
820 TTimeStamp CreationTT;
823 if (R__b.IsReading()) {
824 Version_t R__v = R__b.ReadVersion(&R__s, &R__c);
if (R__v) { }
825 TObject::Streamer(R__b);
835 CreationDatime.Streamer(R__b);
836 CreationTT.Set(CreationDatime.GetYear(), CreationDatime.GetMonth(), CreationDatime.GetDay(), CreationDatime.GetHour(), CreationDatime.GetMinute(), CreationDatime.GetSecond(), 0,
true, 0);
843 R__b.CheckByteCount(R__s, R__c, CWB::History::IsA());
854 R__c = R__b.WriteVersion(CWB::History::IsA(), kTRUE);
855 TObject::Streamer(R__b);
865 R__b.SetByteCount(R__c, kTRUE);
871 cout << location <<
" " << msgfmt << endl;
bool IsSortOrderAlphabetical()
bool IsSortOrderInsertion()
void DumpToROOTFile(char *FileName=NULL)
char * RemoveStage(char *StageName)
bool SetDescendantSortOrder()
#define DEFAULT_SORT_ORDER
bool DuplicateNames(char **NameList, int NameNumber)
bool GetDescendantSortOrder()
bool SetDescendantSortOrder()
bool TypeAllowed(char *Name)
TDatime * GetHistoryDatime(char *StageName, char *Type)
void HistoryException(int type, const char *location, const char *msgfmt,...)
SortOrderType SetSortOrder(SortOrderType SortOrder)
char * RemoveType(char *TypeName)
void SetStageNames(char **StageNames, int StageNumber)
char * GetStageComment(char *Stage)
virtual void Browse(TBrowser *b)
char * GetLog(char *Stage, int index)
int GetLogSize(char *Stage)
void AddLog(char *LogMsg, TDatime *Time=NULL)
char * SetStageComment(char *Stage, char *Comment=NULL)
bool StageAlreadyPresent(char *Name)
bool GetAscendingSortOrder()
bool SetHistoryModify(bool Replace=true)
bool SetAscendingSortOrder()
char * SetTypeComment(char *Stage, char *Type, char *Comment=NULL)
double fabs(const Complex &x)
int GetStagePosition(char *Name)
bool StageAllowed(char *Name)
void AddHistory(char *Type, char *History, char *Comment=NULL, bool Replace=false)
void AddLog(char *Stage, char *Log, TDatime *Time=NULL)
bool NameAllowed(char *Name)
strcpy(RunLabel, RUN_LABEL)
bool SetAscendingSortOrder()
#define DEFAULT_ASCENDING
History(char **StageNames=NULL, int StageNumber=0, char **TypeNames=NULL, int TypeNumber=0, char *FilePrefix=NULL, bool HistoryModify=false)
sprintf(tfres,"(1/%g)x(%g) (sec)x(Hz)", 2 *df, df)
void SetTypeNames(char **TypeNames, int TypeNumber)
char * AddType(char *TypeName)
void DumpToTextFile(char *FileName=NULL)
char * GetLogEntry(int index)
SortOrderType GetSortOrder()
SortOrderType SetSortOrder(SortOrderType SortOrder)
char * GetTypeComment(char *Stage, char *Type)
void SetFilePrefix(char *FilePrefix)
char * GetHistory(char *StageName, char *Type)
const CWB::HistoryStage * GetStage(char *Name)
void WriteToFile(char *FileName, bool SummaryOnly=false)
TTimeStamp GetCreationTimeStamp()
void AddHistory(char *Stage, char *Type, char *History, TDatime *Time=NULL)
char * AddStage(char *StageName)