00001 00002 00003 00004 00005 00006 00007 00008 #include "EventDisplayBase/AutoAdvance.h" 00009 #include <iostream> 00010 #include <unistd.h> 00011 #include "TTimer.h" 00012 #include "IoModules/ReadWriteModule.h" 00013 #include "EventDisplayBase/IoModule.h" 00014 using namespace evdb; 00015 00016 AutoAdvance::AutoAdvance() : fTimer(0) { 00017 fTimer = new TTimer; 00018 fTimer->SetObject(this); 00019 fTimer->Start(1000); 00020 } 00021 00022 //...................................................................... 00023 00024 AutoAdvance::~AutoAdvance() 00025 { 00026 fTimer->Stop(); 00027 delete fTimer; 00028 } 00029 00030 //...................................................................... 00031 00032 Bool_t AutoAdvance::HandleTimer(TTimer *t) 00033 { 00034 t->Stop(); 00035 00036 // Advance to next event. When in auto-advance mode, quit at end of file 00037 FILE* fpp = fopen(".evd-pause-autoadvance","r"); 00038 int istat = 1; 00039 if (fpp==0) istat = IoModule::Instance()->Advance(); 00040 else fclose(fpp); 00041 00042 if (istat == 0) { 00043 // If we reach the end of the file, pause and look for a flag file 00044 // indicating that we should reopen the file and continue 00045 std::cerr << "EOF -- waiting for .evd-reopen-file flag..." << std::endl; 00046 FILE* fp = fopen(".evd-reopen-file","r"); 00047 if (fp!=0) { 00048 fclose(fp); 00049 IoModule::Instance()->IoMod().Close(); 00050 unlink(".evd-reopen-file"); 00051 IoModule::Instance()->IoMod().RewindFile(); 00052 IoModule::Instance()->Reload(); 00053 std::cerr << "Reopenning file..." << std::endl; 00054 } 00055 } 00056 t->Start(1000); 00057 return true; 00058 } 00059
1.3.9.1