Changeset 8819
- Timestamp:
- 01/19/08 12:42:53 (17 years ago)
- Location:
- trunk/MagicSoft/Cosy
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Cosy/Changelog
r8816 r8819 1 1 -*-*- END -*-*- 2 3 2007/06/18 Thomas Bretz 4 5 * base/Makefile: 6 - cosmetics 7 8 * catalog/SlaStars.cc, catalog/Slalib.cc, catalog/StarCatalog.h, 9 gui/MGSkyPosition.cc: 10 - replaced kRad2Deg by TMath::RadToDeg() 11 - replaced kDeg2Rad by TMath::DegToRad() 12 - replaced kPiDiv2 by TMath::Pi()/2 13 14 * main/MCaos.cc: 15 - replaced cout by gLog and use color coding 16 - replaced coord.h by MPointing.h 17 18 2 19 3 20 2007/06/16 Thomas Bretz … … 67 84 - replaced MPointing by MSlewing 68 85 69 * main/MP pointing.[h,cc]:86 * main/MPointing.[h,cc]: 70 87 - renamed class to MSlewing 71 88 - removed -
trunk/MagicSoft/Cosy/cosy.cc
r8376 r8819 5 5 #include <TSystem.h> 6 6 #include <TApplication.h> 7 7 #include <TObjectTable.h> 8 9 #include "ethernet.h" 10 #include "vmodican.h" 11 12 #include "MArgs.h" 8 13 #include "MCosy.h" 9 14 #include "MTime.h" 15 10 16 #include "MLogManip.h" 11 17 … … 16 22 #define EXPERT 17 23 18 #define clog(txt) \ 19 { \ 20 const Bool_t is = lout.IsOutputDeviceEnabled(MLog::eStdout); \ 21 lout << edev(MLog::eStdout) << txt << endl; \ 22 if (is) \ 23 lout.EnableOutputDevice(MLog::eStdout); \ 24 } 24 static void StartUpMessage() 25 { 26 gLog << all << endl; 27 28 // 1 2 3 4 5 6 29 // 123456789012345678901234567890123456789012345678901234567890 30 gLog << "========================================================" << endl; 31 gLog << " COSY " << endl; 32 gLog << " Magic Drive Control System Software " << endl; 33 gLog << " Compiled with ROOT v" << ROOT_RELEASE << " on <" << __DATE__ << ">" << endl; 34 gLog << "========================================================" << endl; 35 gLog << endl; 36 } 37 38 static void Usage() 39 { 40 // 1 2 3 4 5 6 7 8 41 // 12345678901234567890123456789012345678901234567890123456789012345678901234567890 42 gLog << all << endl; 43 gLog << "Sorry the usage is:" << endl; 44 gLog << " cosy [options]" << endl << endl; 45 gLog << " Arguments:" << endl; 46 gLog << " n/a" << endl; 47 gLog << endl; 48 gLog << " Root Options:" << endl; 49 gLog << " -b Batch mode (no graphical output to screen)" << endl<<endl; 50 gLog << " Options:" << endl; 51 gLog.Usage(); 52 gLog << " --debug-threads Debug threads" << endl << endl; 53 gLog << " --version, -V Show startup message with version number" << endl; 54 gLog << " -?, -h, --help This help" << endl << endl; 55 } 25 56 26 57 /* ---------------------------------------------------------------------- */ 27 58 int main(int argc, char **argv) 28 59 { 29 gLog << "==================================================" << endl; 30 gLog << " Cosy V0.1 " << endl; 31 gLog << " Magic Drive Control System Software " << endl; 32 gLog << " Compiled on <" << __DATE__ << ">" << endl; 33 gLog << " Using ROOT v" << ROOTVER << endl; 34 gLog << "==================================================" << endl; 35 gLog << endl; 36 37 Int_t channel = 0; 38 for (int i=0; i<argc; i++) 39 { 40 TString arg(argv[i]); 41 if (arg=="-1") 42 channel = 1; 43 if (arg=="-0") 44 channel = 0; 45 if (arg=="-c") 46 channel = -1; 47 } 48 49 // 50 // this must move to MGCosy !!!! 51 // 52 const TString name = MCosy::GetFileName("log", "cosy", "log"); 53 cout << "Open Logfile: " << name << endl; 54 55 MLog *l = new MLog(name, kTRUE); 56 MLog &lout = *l; 57 lout.SetNoColors(); 58 59 MTime now(-1); 60 clog("Starting Cosy at " << now << " ..."); 60 if (!MARS::CheckRootVer()) 61 return 0xff; 62 63 MLog::RedirectErrorHandler(MLog::kColor); 64 65 // 66 // Evaluate arguments 67 // 68 MArgs arg(argc, argv, kTRUE); 69 gLog.Setup(arg); 70 71 StartUpMessage(); 72 73 if (arg.HasOnly("-V") || arg.HasOnly("--version")) 74 return 0; 75 76 if (arg.HasOnly("-?") || arg.HasOnly("-h") || arg.HasOnly("--help")) 77 { 78 Usage(); 79 return 2; 80 } 81 82 const Int_t channel = arg.GetIntAndRemove("--channel", 0); 83 const Bool_t kDebugMem = arg.HasOnlyAndRemove("--debug-mem"); 84 const Bool_t kDebugThreads = arg.HasOnlyAndRemove("--debug-threads"); 85 86 // 87 // check for the right usage of the program (number of arguments) 88 // 89 if (arg.GetNumArguments()>0) 90 { 91 gLog << warn << "WARNING - Wrong number of arguments..." << endl; 92 Usage(); 93 return 2; 94 } 95 /* 96 // 97 // Now we access/read the resource file. This will remove all 98 // --rc= from the list of arguments. 99 // 100 MEnv env(kConfig); 101 if (!env.IsValid()) 102 { 103 gLog << err << "ERROR - Reading resource file " << kConfig << "." << endl; 104 return 0xfe; 105 } 106 107 // And move the resource options from the command line to the MEnv 108 if (!env.TakeEnv(arg, kDebugEnv>2)) 109 return 0xfd; 110 */ 111 // 112 // check for the right usage of the program (number of options) 113 // 114 if (arg.GetNumOptions()>0) 115 { 116 gLog << warn << "WARNING - Unknown commandline options..." << endl; 117 arg.Print("options"); 118 gLog << endl; 119 return 2; 120 } 121 122 if (!gLog.IsOutputDeviceEnabled(MLog::eFile)) 123 { 124 const TString name = MCosy::GetFileName("log", "cosy", "log"); 125 gLog << inf << "Open automatic logfile: " << name << endl; 126 gLog.SetOutputFile(name); 127 } 128 129 gLog << all << "Starting Cosy at " << MTime(-1) << " in thread " << TThread::SelfId() << "..." << endl; 61 130 62 131 // 63 132 // start the main window 64 133 // 65 clog("- Initialising Root environment."); 66 67 // FIXME: Fails deleteing something in TGClient::fWlist 68 TApplication *app=new TApplication("App", &argc, argv); 69 134 gLog << all << "- Initialising Root environment." << endl; 135 136 // 137 // Initialize root 138 // 139 //MArray::Class()->IgnoreTObjectStreamer(); 140 //MParContainer::Class()->IgnoreTObjectStreamer(); 141 142 TApplication app("cosy", &argc, argv); 70 143 if (gROOT->IsBatch()) 71 144 { 72 cout<< "ERROR - Cannot run in Batch mode!" << endl;145 gLog << err << "ERROR - Cannot run in Batch mode!" << endl; 73 146 return 0; 74 147 } 148 if (!gClient) 149 { 150 gLog << err << "Bombing... maybe your DISPLAY variable is not set correctly!" << endl; 151 return 1; 152 } 153 154 if (kDebugMem) 155 TObject::SetObjectStat(kTRUE); 75 156 76 157 // 77 158 // Create the Network. Device: /dev/dpm_00, Rate: 500kbps 78 159 // 79 clog("- Constructing MCosy.");160 gLog << all <<"- Constructing MCosy." << endl; 80 161 /* 81 162 // … … 97 178 } 98 179 */ 99 MCosy *cosy = new MCosy("/dev/dpm_00", 125, lout); 100 101 clog("- Starting MCosy."); 102 #ifndef EXPERT 103 lout.DisableOutputDevice(MLog::eStdout); 104 #endif 180 MCosy *cosy = new MCosy(); 181 182 Interface *interface = new Ethernet(cosy); 183 // Interface *interface = new VmodIcan(cosy, "/dev/dpm_00", 125); 184 185 gLog << all << "- Starting MCosy." << endl; 186 105 187 cosy->Start(); 106 188 … … 108 190 if (channel>=0) 109 191 { 110 clog("- Starting Camera.");192 gLog << all << "- Starting Camera." << endl; 111 193 client=new MStarguider(MObservatory::kMagic1, channel); 112 194 cosy->SetStarguider(client); … … 114 196 } 115 197 116 clog("- Starting mainloop."); 117 #ifndef EXPERT 118 lout.DisableOutputDevice(MLog::eStdout); 119 #endif 120 app->Run(kTRUE); 198 gLog << all << "- Starting mainloop." << endl; 199 200 app.Run(kTRUE); 201 202 if (kDebugThreads) 203 TThread::Ps(); 121 204 122 205 if (channel>=0) … … 124 207 client->SetCosy(NULL); 125 208 cosy->SetStarguider(NULL); 126 clog("- Stopping starg.");209 gLog << all << "- Stopping starg." << endl; 127 210 delete client; 128 211 } 129 212 130 clog("- Stopping cosy.");213 gLog << all << "- Stopping cosy." << endl; 131 214 cosy->Stop(); 132 215 133 now.Now(); 134 clog(now << ": MCosy stopped."); 216 gLog << all << MTime(-1) << ": MCosy stopped." << endl; 217 218 delete interface; 219 220 gLog << all << "Deleting cosy at " << MTime(-1) << endl; 135 221 136 222 delete cosy; 137 223 138 now.Now(); 139 clog("Terminating cosy at " << now); 140 141 delete l; 142 143 cout << "The End." << endl; 224 if (kDebugThreads) 225 TThread::Ps(); 226 227 //delete app; 228 229 if (TObject::GetObjectStat()) 230 { 231 TObject::SetObjectStat(kFALSE); 232 gObjectTable->Print(); 233 } 234 235 gLog << all << "The End." << endl; 144 236 }
Note:
See TracChangeset
for help on using the changeset viewer.