Changeset 2490
- Timestamp:
- 11/10/03 11:14:35 (21 years ago)
- Location:
- trunk/MagicSoft/Mars
- Files:
-
- 17 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/Changelog
r2489 r2490 1 1 -*-*- END OF LINE -*-*- 2 3 2003/11/10: Nicola Galante 4 5 * macros/dohtml.C: 6 - added mreflector 7 8 * mbase/MEvtLoop.[h,cc]: 9 - removed instantiation of gListOfPrimitives 10 11 * mbase/MGGroupFrame.h: 12 - minor change 13 14 * mbase/MLog.cc: 15 - added a comment 16 17 * mbase/MParContainer.[h,cc]: 18 - removed include MEvtLoop.h 19 - added instantiation of gListOfPrimitves 20 21 * mbase/MReadSocket.[h,cc]: 22 - added more functionality 23 - added comments 24 - added Open() Close() 25 26 * mbase/MTask.cc: 27 - removed obsolete include for MGGroupFrame 28 29 * mfilter/MFRealTimePeriod.h: 30 - initialize fTime with 0 31 32 * mhist/MHCamEvent.cc, mhist/MHEvent.cc, mhist/MHTriggerLvl0.cc: 33 - removed creation of additional pad in Draw 34 35 * mhist/MHCamera.cc: 36 - added creating of additional pad in Draw 37 - added some comments 38 39 * mraw/MRawSocketRead.[h,cc]: 40 - added comments 41 - added fPort data member 42 - take MStatusDisplay status into account 43 - SetStausLine2 added 44 - SetProgressBarPosition added 45 - removed obsolete include of iosfwd 46 2 47 3 48 … … 15 60 - Added some instruction to write all the MMcTriggerLvl2 histograms into 16 61 a TFile 62 17 63 18 64 -
trunk/MagicSoft/Mars/macros/dohtml.C
r2080 r2490 51 51 sourcedir += "mmc:"; 52 52 sourcedir += "mmontecarlo:"; 53 sourcedir += "mranforest:"; 53 54 sourcedir += "mraw:"; 54 sourcedir += "mr anforest:";55 sourcedir += "mreflector:"; 55 56 sourcedir += "mtools:"; 56 57 sourcedir += ".:"; -
trunk/MagicSoft/Mars/mbase/MEvtLoop.cc
r2459 r2490 96 96 using namespace std; 97 97 98 99 //!100 //! Maybe we can add a static parameter list to MEvtLoop101 //! Also we can derive MEvtLoop from MTaskList to have a static tasklist, too102 //!103 104 TList *gListOfPrimitives; // forward declaration in MParContainer.h105 106 98 // -------------------------------------------------------------------------- 107 99 // … … 372 364 if (fProgress && fNumEvents>0) 373 365 fProgress->SetPosition((Double_t)num/fNumEvents); 374 375 366 376 367 // FIXME: This is a workaround, because TApplication::Run is not -
trunk/MagicSoft/Mars/mbase/MEvtLoop.h
r2438 r2490 85 85 }; 86 86 87 // FIXME: Move as (persistent) static data member to MParContainer88 R__EXTERN TList *gListOfPrimitives; // instantiation in MEvtLoop89 90 87 #endif -
trunk/MagicSoft/Mars/mbase/MGGroupFrame.h
r2015 r2490 14 14 class MGGroupFrame : public TGGroupFrame, public TGWidget 15 15 { 16 MGTask 16 MGTask *fTask; 17 17 MGList *fList; 18 18 -
trunk/MagicSoft/Mars/mbase/MParContainer.cc
r2470 r2490 51 51 #include "MLogManip.h" 52 52 53 #ifndef __COSY__54 #include "MEvtLoop.h" // gListOfPrimitives55 #else56 53 TList *gListOfPrimitives; // forard declaration in MParContainer.h 57 #endif58 54 59 55 #undef DEBUG -
trunk/MagicSoft/Mars/mbase/MParContainer.h
r2470 r2490 132 132 }; 133 133 134 //! 135 //! Maybe we can add a static parameter list to MEvtLoop 136 //! Also we can derive MEvtLoop from MTaskList to have a static tasklist, too 137 //! 138 139 // FIXME: Move as (persistent) static data member to MParContainer 140 R__EXTERN TList *gListOfPrimitives; // instantiation in MEvtLoop 141 134 142 /* 135 143 class MParContainer : public TNamed -
trunk/MagicSoft/Mars/mbase/MReadSocket.cc
r2438 r2490 16 16 ! 17 17 ! 18 ! Author(s): Thomas Bretz 12/2000 <mailto:tbretz@uni-sw.gwdg.de>19 ! 20 ! Copyright: MAGIC Software Development, 2000-200 118 ! Author(s): Thomas Bretz, 10/2003 <mailto:tbretz@astro.uni.wuerzburg.de> 19 ! 20 ! Copyright: MAGIC Software Development, 2000-2003 21 21 ! 22 22 ! … … 27 27 // 28 28 // MReadSocket 29 // 30 // This class acts like a standard C++ istream, but read from a socket 31 // (ifstream works similar) 32 // 33 // ios::io_state: 34 // -------------- 35 // eof() or ios::eofbit: Connection closed or not established 36 // fail() or ios::failbit: Error trying to establish connection or 37 // waiting for data in underflow() timed out 38 // good() tells you that everything is ok and we can read from the stream 39 // 40 // Example: 41 // -------- 42 // 43 // Double_t d; 44 // 45 // MReadSocket sin(1024); // open port 1024 46 // 47 // sin >> d; 48 // sin.read((char*)&d, sizeof(Double_t)); 49 // 29 50 // 30 51 ////////////////////////////////////////////////////////////////////////////// … … 44 65 using namespace std; 45 66 67 // -------------------------------------------------------------------------- 68 // 69 // You can use the constructor in two ways: 70 // 71 // MReadSocket read(7000); 72 // This opens the socket and blocks until the connection has been 73 // established. 74 // 75 // MReadSocket read; 76 // Returns immidiatly. The connection will be opend by calling 77 // read.Open(7000); 78 // 46 79 MReadSocket::MReadSocket(int port, int mtu) : istream(this), fMtu(mtu), fTimeout(2500), fServSock(NULL), fRxSocket(NULL) 47 80 { … … 50 83 setg(fBuffer, fBuffer, fBuffer+1); 51 84 52 cout << "Starting server socket on port 7000..." << endl; 53 54 while (1) 85 clear(ios::eofbit); 86 87 if (port>0) 88 Open(port); 89 } 90 91 // -------------------------------------------------------------------------- 92 // 93 // Destructor. Close an possible open connection and delete the fBuffer 94 // 95 MReadSocket::~MReadSocket() 96 { 97 Close(); 98 delete fBuffer; 99 } 100 101 void MReadSocket::OpenServerSocket(int port) 102 { 103 if (fServSock) 104 return; 105 106 cout << "Starting server socket on port #" << port << "..." << endl; 107 108 while (!fServSock) 55 109 { 56 110 fServSock=new TServerSocket(port, kTRUE); 57 111 if (fServSock->IsValid()) 58 break;112 continue; 59 113 60 114 cout << "ServerSocket not valid: "; 61 115 switch (fServSock->GetErrorCode()) 62 116 { 63 case 0: cout << "No error." << endl; break;117 case 0: cout << "No error." << endl; break; 64 118 case -1: cout << "low level socket() call failed." << endl; break; 65 119 case -2: cout << "low level bind() call failed." << endl; break; … … 68 122 } 69 123 70 delete fServSock; 71 fServSock=NULL; 72 break; 73 } 74 if (!fServSock) 75 { 76 cout << "MReadSocket: TServerSocket - Connection timed out." << endl; 77 setstate(ios::failbit); 124 Close(); 125 clear(ios::failbit); 78 126 return; 79 127 } 80 128 81 129 fServSock->SetOption(kNoBlock, 1); 82 83 while (1) 130 } 131 132 void MReadSocket::OpenConnection(Bool_t block) 133 { 134 do 84 135 { 85 136 const TTime timeout = gSystem->Now() + TTime(5000); 86 137 87 138 TDatime now; 88 cout << now.AsString() << ": Waiting for conntection on port 7000..." << endl; 89 fRxSocket = NULL; 90 while ((Long_t)fRxSocket<=0 && gSystem->Now()<timeout) 139 cout << now.AsString() << ": Waiting for connection..." << endl; 140 141 // 142 // fRxSocket<0 means: No connection,non-blocking mode 143 // fRxSocket==0 means: Error 144 // This is only done until timeout is reached 145 // 146 while (fRxSocket==0 && gSystem->Now()<timeout) 91 147 { 92 148 fRxSocket = fServSock->Accept(); 93 149 if (fRxSocket==0) 94 cout << "Error: TServerSock::Accept" << endl; 95 usleep(1); 150 { 151 cout << "MReadSocket::OpenConnection: ERROR - TServerSock::Accept()" << endl; 152 setstate(ios::failbit); 153 return; 154 } 155 if ((Long_t)fRxSocket<0) 156 fRxSocket=NULL; 157 158 usleep(10); 96 159 } 97 160 98 if ((Long_t)fRxSocket<=0) 161 // 162 // No connection has been established. Restart waiting for 163 // connection except we are in non-blocking mode. 164 // 165 if (fRxSocket==0) 99 166 continue; 100 167 168 // 169 // Check if the established connection is valid 170 // 101 171 if (fRxSocket->IsValid()) 102 break; 172 { 173 cout << "Connection established..." << endl; 174 fRxSocket->SetOption(kNoBlock, 1); 175 clear(); 176 return; 177 } 103 178 104 179 cout << "TSocket: Connection not valid..." << endl; 105 180 delete fRxSocket; 106 }107 108 if ((Long_t)fRxSocket<=0)109 {110 cout << "MReadSocket: TServerSocket::Accept - Connection timed out." << endl;111 181 fRxSocket=NULL; 112 182 setstate(ios::failbit); 113 183 return; 114 } 115 116 cout << "Connection established..." << endl; 117 118 fRxSocket->SetOption(kNoBlock, 1); 184 185 } while (block); 186 } 187 188 // -------------------------------------------------------------------------- 189 // 190 // Open the connectionj on port port. Wait until the connection has 191 // been established. If an error occures and the connection cannot 192 // be established return kFALSE. To check whether an error occured 193 // use operator!() or operator void*() or fail() 194 // 195 Bool_t MReadSocket::Open(int port, Bool_t block=kFALSE) 196 { 197 // 198 // If no port is given use the port given in the constructor 199 // 200 if (port<=0) 201 port = fPort; 202 203 // 204 // Remember port for later uses 205 // 206 if (fPort<=0) 207 fPort = port; 208 209 // 210 // Check whether a connection has already been established 211 // 212 if (fServSock) 213 { 214 // 215 // Check whether the connection has the right port 216 // 217 if (fServSock->GetLocalPort()!=port) 218 Close(); 219 } 220 221 // 222 // Check whether port is valid 223 // 224 if (port<=0) 225 { 226 cout << "Invalid port #" << port << "!" << endl; 227 clear(ios::failbit); 228 return kFALSE; 229 } 230 231 // 232 // Start server socket... 233 // 234 OpenServerSocket(port); 235 if (!fServSock) 236 return kFALSE; 237 238 OpenConnection(block); 239 if (!fRxSocket) 240 return kFALSE; 119 241 120 242 underflow(); 121 } 122 123 // -------------------------------------------------------------------------- 124 // 125 // Destructor, destroying the gui mutex. 126 // 127 MReadSocket::~MReadSocket() 243 return kTRUE; 244 } 245 246 void MReadSocket::Close() 128 247 { 129 248 if (fRxSocket) 249 { 130 250 delete fRxSocket; 251 fRxSocket=NULL; 252 } 131 253 if (fServSock) 254 { 255 const Int_t port = fServSock->GetLocalPort(); 256 132 257 delete fServSock; 133 134 delete fBuffer; 135 136 cout << "Connection on Port 7000 closed." << endl; 258 fServSock=NULL; 259 260 cout << "Connection on Port #" << port << " closed." << endl; 261 } 262 263 clear(ios::eofbit); 137 264 } 138 265 … … 149 276 int MReadSocket::underflow() 150 277 { 151 if (fail()) 278 // FIXME: vvvvv is this correct? 279 if (fail() || eof()) 152 280 { 153 281 setg(fBuffer, fBuffer, fBuffer+fMtu); … … 185 313 return 0; 186 314 } 187 -
trunk/MagicSoft/Mars/mbase/MReadSocket.h
r2386 r2490 19 19 char *fBuffer; //! 20 20 21 int fPort; 21 22 int fMtu; 22 23 TTime fTimeout; … … 25 26 TSocket *fRxSocket; 26 27 28 void OpenServerSocket(int port); 29 void OpenConnection(Bool_t block); 30 27 31 int underflow(); 28 32 int sync(); 29 33 30 34 public: 31 MReadSocket(int port , int mtu=1500);35 MReadSocket(int port=-1, int mtu=1500); 32 36 MReadSocket(MReadSocket const& log) : istream((std::streambuf*)&log) 33 37 { 34 38 } 35 39 ~MReadSocket(); 40 41 Bool_t Open(int port=-1, Bool_t block=kFALSE); 42 void Close(); 36 43 37 44 void SetTimeout(UInt_t millisec) { fTimeout = millisec; } -
trunk/MagicSoft/Mars/mbase/MTask.cc
r2473 r2490 83 83 84 84 #include "MFilter.h" 85 #include "MGGroupFrame.h"86 85 #include "MStatusDisplay.h" 87 86 -
trunk/MagicSoft/Mars/mfilter/MFRealTimePeriod.h
r2408 r2490 15 15 16 16 public: 17 MFRealTimePeriod(UInt_t millis=1000) : f MilliSec(millis)17 MFRealTimePeriod(UInt_t millis=1000) : fTime(0), fMilliSec(millis) 18 18 { 19 19 fName = "MFRealTimePeriod"; -
trunk/MagicSoft/Mars/mhist/MHCamEvent.cc
r2416 r2490 144 144 *fLog << all << underline << GetDescriptor() << ": Mean=" << mean << ", Rms=" << rms << endl; 145 145 146 for ( unsigned int i=0; i<fSum->GetNumPixels(); i++)146 for (UInt_t i=0; i<fSum->GetNumPixels(); i++) 147 147 { 148 148 if (!fSum->IsUsed(i)) … … 151 151 if ((*fSum)[i+1]>mean+s*rms) 152 152 *fLog << "Contents of Pixel-Index #" << i << ": " << (*fSum)[i+1] << " > " << s << "*rms" << endl; 153 // if ((*fSum)[i+1]==0)154 // *fLog << "Contents of Pixel-Index #" << i << ": " << (*fSum)[i+1] << " == 0" << endl;155 // if ((*fSum)[i+1]<fSum->GetMean()-s*fSum->GetRMS())156 // *fLog << "Contents of Pixel-Index #" << i << ": " << (*fSum)[i+1] << " < " << s << "*rms" << endl;157 153 } 158 154 } … … 175 171 176 172 pad->cd(1); 177 gPad->SetBorderMode(0);178 gPad->Divide(1,1);179 gPad->cd(1);180 gPad->SetBorderMode(0);181 173 fSum->Draw(); 182 174 -
trunk/MagicSoft/Mars/mhist/MHCamera.cc
r2488 r2490 359 359 // To draw a camera into its own pad do something like: 360 360 // 361 // MGeomCamMagic m; 362 // MHCamera *d=new MHCamera(m); 363 // 361 364 // TCanvas *c = new TCanvas; 362 365 // c->Divide(2,1); 363 // MGeomCamMagic m;364 // MHCamera *d=new MHCamera(&m);366 // c->cd(1); 367 // 365 368 // d->FillRandom(); 366 // c->cd(1);367 // gPad->SetBorderMode(0);368 // gPad->Divide(1,1);369 // gPad->cd(1);370 369 // d->Draw(); 371 370 // d->SetBit(kCanDelete); … … 375 374 // root 3.02: 376 375 // gPad->SetFixedAspectRatio() 377 Int_t col = 16; 378 379 if (gPad) 380 col = gPad->GetFillColor(); 381 382 TVirtualPad *pad = gPad ? gPad : MH::MakeDefCanvas("CamDisplay", "Mars Camera Display", 656, 600); 376 const Color_t col = gPad ? gPad->GetFillColor() : 16; 377 TVirtualPad *pad = gPad ? gPad : MH::MakeDefCanvas("CamDisplay", "Mars Camera Display", 656, 600); 383 378 pad->SetBorderMode(0); 384 379 pad->SetFillColor(col); 385 380 381 // 382 // Create an own pad for the MHCamera-Object which can be 383 // resized in paint to keep the correct aspect ratio 384 // 385 pad->Divide(1, 1, 0, 0, col); 386 pad->cd(1); 387 gPad->SetBorderMode(0); 388 386 389 AppendPad(option); 390 391 // 392 // Do not change gPad. The user should not see, that Draw 393 // changes gPad... 394 // 395 pad->cd(); 387 396 } 388 397 -
trunk/MagicSoft/Mars/mhist/MHEvent.cc
r2488 r2490 256 256 } 257 257 258 TVirtualPad *pad = gPad ? gPad : MakeDefCanvas(this); 259 pad->SetBorderMode(0); 260 261 pad->Divide(1,1); 262 263 pad->cd(1); 264 gPad->SetBorderMode(0); 265 gPad->Divide(1,1); 266 gPad->cd(1); 267 gPad->SetBorderMode(0); 258 if (!gPad) 259 MakeDefCanvas(this); 268 260 fHist->Draw(); 269 261 } -
trunk/MagicSoft/Mars/mhist/MHTriggerLvl0.cc
r2416 r2490 179 179 180 180 pad->cd(1); 181 gPad->SetBorderMode(0); 182 gPad->Divide(1,1); 183 gPad->cd(1); 184 gPad->SetBorderMode(0); 181 /* 182 gPad->SetBorderMode(0); 183 gPad->Divide(1,1); 184 gPad->cd(1); 185 gPad->SetBorderMode(0); 186 */ 185 187 fSum->Draw(); 186 188 -
trunk/MagicSoft/Mars/mraw/MRawSocketRead.cc
r2466 r2490 35 35 // 36 36 // Output Containers: 37 // MRawRunHeader, MRawEvtHeader, MRawEvtData, MRawCrateArray, MRawEvtTime 37 // MRawRunHeader 38 // MRawEvtHeader 39 // MRawEvtData 40 // MRawCrateArray 41 // MRawEvtTime 38 42 // 39 43 ////////////////////////////////////////////////////////////////////////////// … … 58 62 #include "MRawCrateArray.h" 59 63 60 //#include "../mmain/MStatusDisplay.h"64 #include "MStatusDisplay.h" 61 65 62 66 ClassImp(MRawSocketRead); … … 69 73 // 70 74 MRawSocketRead::MRawSocketRead(const char *name, const char *title) 71 : fIn(NULL) 75 : fIn(NULL), fPort(-1) 72 76 { 73 77 fName = name ? name : "MRawSocketRead"; 74 78 fTitle = title ? title : "Task to read DAQ binary data from tcp/ip socket"; 75 79 76 fIn = new MReadSocket (7000);80 fIn = new MReadSocket; 77 81 } 78 82 … … 84 88 { 85 89 delete fIn; 90 } 91 92 // -------------------------------------------------------------------------- 93 // 94 // Open the socket. This blocks until the connection has been established, 95 // an error occured opening the connection or the user requested to 96 // quit the application. 97 // 98 Bool_t MRawSocketRead::OpenSocket() 99 { 100 if (fDisplay) 101 fDisplay->SetStatusLine2(Form("Waiting for connection on port #%d...", fPort)); 102 103 // 104 // Open socket connection 105 // 106 while (1) 107 { 108 // 109 // If port could be opened eveything is ok 110 // 111 if (fIn->Open(fPort)) 112 return kTRUE; 113 114 // 115 // If a MStatusDisplay is attached the user might have 116 // requested to quit the application 117 // 118 if (fDisplay) 119 switch (fDisplay->CheckStatus()) 120 { 121 case MStatusDisplay::kFileClose: 122 case MStatusDisplay::kFileExit: 123 *fLog << inf << "MRawSocketRead::PreProcess - MStatusDisplay triggered exit." << endl; 124 return kFALSE; 125 default: 126 break; 127 } 128 129 // 130 // If an error occured during opening the socket stop 131 // 132 if (fIn->fail()) 133 break; 134 } 135 136 *fLog << err << "ERROR - Cannot open port #" << fPort << endl; 137 return kFALSE; 86 138 } 87 139 … … 104 156 Int_t MRawSocketRead::PreProcess(MParList *pList) 105 157 { 158 if (!OpenSocket()) 159 return kFALSE; 160 106 161 // 107 162 // check if all necessary containers exist in the Parameter list. … … 269 324 270 325 fEvtNumber=fRawEvtHeader->GetDAQEvtNumber(); 271 /* 326 272 327 if (fDisplay) 273 328 fDisplay->SetProgressBarPosition((Float_t)fEvtNumber/fRawRunHeader->GetNumEvents()); 274 */ 329 275 330 return kTRUE; 276 331 } 277 332 278 333 Int_t MRawSocketRead::PostProcess() 279 { /* 334 { 335 // 336 // Close Socket connection 337 // 338 fIn->Close(); 339 280 340 if (fDisplay) 281 341 fDisplay->SetProgressBarPosition(1); 282 */ 342 283 343 return kTRUE; 284 344 } -
trunk/MagicSoft/Mars/mraw/MRawSocketRead.h
r2466 r2490 4 4 #ifndef MARS_MTask 5 5 #include "MTask.h" 6 #endif7 8 #ifndef __IOSFWD__9 #include <iosfwd>10 6 #endif 11 7 … … 33 29 UInt_t fEvtNumber; //! 34 30 35 Int_t PreProcess(MParList *pList); 36 Int_t Process(); 37 Int_t PostProcess(); 31 Int_t fPort; // Port on which we wait for the connection 32 33 Bool_t OpenSocket(); 34 35 Int_t PreProcess(MParList *pList); 36 Int_t Process(); 37 Int_t PostProcess(); 38 38 39 39 public: … … 41 41 ~MRawSocketRead(); 42 42 43 void SetPort(int port) { fPort = port; } 44 43 45 ClassDef(MRawSocketRead, 0) //Task to read DAQ binary data from tcp/ip socket 44 46 };
Note:
See TracChangeset
for help on using the changeset viewer.