Changeset 11013 for trunk/FACT++/src
- Timestamp:
- 06/13/11 17:05:45 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/FACT++/src/EventBuilderWrapper.h
r10995 r11013 79 79 return result.str(); 80 80 } 81 82 81 }; 83 82 83 class DataFileNone : public DataFileImp 84 { 85 public: 86 DataFileNone(uint32_t id) : DataFileImp(id) { } 87 88 bool OpenFile(RUN_HEAD* h) 89 { 90 cout << "OPEN_FILE #" << GetRunId() << " (" << this << ")" << endl; 91 cout << " Ver= " << h->Version << endl; 92 cout << " Typ= " << h->RunType << endl; 93 cout << " Nb = " << h->NBoard << endl; 94 cout << " Np = " << h->NPix << endl; 95 cout << " NTm= " << h->NTm << endl; 96 cout << " roi= " << h->Nroi << endl; 97 98 return true; 99 } 100 bool Write(EVENT *) 101 { 102 return true; 103 } 104 bool Close(RUN_TAIL * = 0) 105 { 106 cout << "CLOSE FILE #" << GetRunId() << " (" << this << ")" << endl; 107 return true; 108 } 109 }; 110 111 class DataFileDebug : public DataFileNone 112 { 113 public: 114 DataFileDebug(uint32_t id) : DataFileNone(id) { } 115 116 bool Write(EVENT *e) 117 { 118 cout << "WRITE_EVENT #" << GetRunId() << " (" << e->EventNum << ")" << endl; 119 cout << " Typ=" << e->TriggerType << endl; 120 cout << " roi=" << e->Roi << endl; 121 cout << " trg=" << e->SoftTrig << endl; 122 cout << " tim=" << e->PCTime << endl; 123 124 return true; 125 } 126 }; 84 127 85 128 #include "FAD.h" … … 265 308 }; 266 309 267 310 #ifdef HAS_FITS 268 311 class DataFileFits : public DataFileImp 269 312 { … … 624 667 625 668 }; 669 #else 670 #define DataFileFits DataFileRaw 671 #endif 626 672 627 673 class EventBuilderWrapper … … 630 676 // FIXME 631 677 static EventBuilderWrapper *This; 678 679 MessageImp &fMsg; 632 680 633 681 private: … … 647 695 }; 648 696 649 MessageImp &fMsg;650 651 697 enum 652 698 { … … 655 701 }; 656 702 657 bool fFitsFormat; 703 enum FileFormat_t 704 { 705 kNone, 706 kDebug, 707 kFits, 708 kRaw 709 }; 710 711 FileFormat_t fFileFormat; 712 658 713 659 714 uint32_t fMaxRun; … … 665 720 DimDescribedService fDimCurrentEvent; 666 721 722 int Write(const Time &time, const std::string &txt, int qos) 723 { 724 return fMsg.Write(time, txt, qos); 725 } 726 667 727 public: 668 EventBuilderWrapper(MessageImp & msg) : fMsg(msg),669 fFi tsFormat(false), fMaxRun(0),728 EventBuilderWrapper(MessageImp &imp) : fMsg(imp), 729 fFileFormat(kRaw), fMaxRun(0), 670 730 fDimFiles ("FAD_CONTROL/FILES", "X:1", ""), 671 731 fDimRuns ("FAD_CONTROL/RUNS", "I:1", ""), … … 687 747 { 688 748 Abort(); 749 689 750 // FIXME: Used timed_join and abort afterwards 690 751 // What's the maximum time the eb need to abort? 691 752 fThread.join(); 692 //f Msg.Info("EventBuilder stopped.");753 //ffMsg.Info("EventBuilder stopped."); 693 754 694 755 for (vector<DataFileImp*>::iterator it=fFiles.begin(); it!=fFiles.end(); it++) … … 696 757 } 697 758 698 void Update(ostringstream &msg, int severity)699 {700 fMsg.Update(msg, severity);701 }702 703 759 bool IsThreadRunning() 704 760 { … … 710 766 if (mb*1000000<GetUsedMemory()) 711 767 { 712 // f Msg.Warn("...");768 // ffMsg.Warn("..."); 713 769 return; 714 770 } … … 771 827 { 772 828 fThread.join(); 773 f Msg.Message("EventBuilder stopped.");829 ffMsg.Message("EventBuilder stopped."); 774 830 }*/ 775 831 … … 828 884 { 829 885 // Check if file already exists... 830 DataFileImp *file = fFitsFormat ? 831 static_cast<DataFileImp*>(new DataFileFits(runid)) : 832 static_cast<DataFileImp*>(new DataFileRaw(runid)); 886 DataFileImp *file = 0; 887 switch (fFileFormat) 888 { 889 case kNone: file = new DataFileNone(runid); break; 890 case kDebug: file = new DataFileDebug(runid); break; 891 case kFits: file = new DataFileFits(runid); break; 892 case kRaw: file = new DataFileRaw(runid); break; 893 } 833 894 834 895 try … … 841 902 return 0; 842 903 } 843 844 cout << "OPEN_FILE #" << runid << " (" << file << ")" << endl;845 cout << " Ver= " << h->Version << endl;846 cout << " Typ= " << h->RunType << endl;847 cout << " Nb = " << h->NBoard << endl;848 cout << " Np = " << h->NPix << endl;849 cout << " NTm= " << h->NTm << endl;850 cout << " roi= " << h->Nroi << endl;851 904 852 905 fFiles.push_back(file); … … 864 917 Update(fDimFiles, fFiles.size()); 865 918 866 // fDimFiles.setData(fFiles.size());867 // fDimFiles.update();868 869 919 return reinterpret_cast<FileHandle_t>(file); 870 920 } … … 873 923 { 874 924 DataFileImp *file = reinterpret_cast<DataFileImp*>(handler); 875 876 cout << "WRITE_EVENT " << file->GetRunId() << endl;877 878 cout << " Evt=" << e->EventNum << endl;879 cout << " Typ=" << e->TriggerType << endl;880 cout << " roi=" << e->Roi << endl;881 cout << " trg=" << e->SoftTrig << endl;882 cout << " tim=" << e->PCTime << endl;883 925 884 926 if (!file->Write(e)) … … 908 950 DataFileImp *file = reinterpret_cast<DataFileImp*>(handler); 909 951 910 952 const vector<DataFileImp*>::iterator it = find(fFiles.begin(), fFiles.end(), file); 911 953 if (it==fFiles.end()) 912 954 { … … 918 960 919 961 ostringstream str; 920 str << "C LOSE_RUN requested for " << file->GetRunId() << " (" << file << ")" <<endl;921 fMsg. Debug(str);962 str << "Closing file for run " << file->GetRunId() << " (" << file << ")" << endl; 963 fMsg.Info(str); 922 964 923 965 fFiles.erase(it); 924 966 925 967 Update(fDimFiles, fFiles.size()); 926 927 //fDimFiles.setData(fFiles.size());928 //fDimFiles.update();929 968 930 969 const bool rc = file->Close(tail); … … 974 1013 str << err; 975 1014 str << "): " << message; 976 EventBuilderWrapper::This-> Update(str, severity);1015 EventBuilderWrapper::This->fMsg.Update(str, severity); 977 1016 } 978 1017 … … 994 1033 str << message; 995 1034 996 EventBuilderWrapper::This-> Update(str, severity);1035 EventBuilderWrapper::This->fMsg.Update(str, severity); 997 1036 } 998 1037
Note:
See TracChangeset
for help on using the changeset viewer.