Ignore:
Timestamp:
11/10/03 11:14:35 (21 years ago)
Author:
tbretz
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars/mraw
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/mraw/MRawSocketRead.cc

    r2466 r2490  
    3535//
    3636//  Output Containers:
    37 //   MRawRunHeader, MRawEvtHeader, MRawEvtData, MRawCrateArray, MRawEvtTime
     37//   MRawRunHeader
     38//   MRawEvtHeader
     39//   MRawEvtData
     40//   MRawCrateArray
     41//   MRawEvtTime
    3842//
    3943//////////////////////////////////////////////////////////////////////////////
     
    5862#include "MRawCrateArray.h"
    5963
    60 //#include "../mmain/MStatusDisplay.h"
     64#include "MStatusDisplay.h"
    6165
    6266ClassImp(MRawSocketRead);
     
    6973//
    7074MRawSocketRead::MRawSocketRead(const char *name, const char *title)
    71     : fIn(NULL)
     75    : fIn(NULL), fPort(-1)
    7276{
    7377    fName  = name  ? name  : "MRawSocketRead";
    7478    fTitle = title ? title : "Task to read DAQ binary data from tcp/ip socket";
    7579
    76     fIn = new MReadSocket(7000);
     80    fIn = new MReadSocket;
    7781}
    7882
     
    8488{
    8589    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//
     98Bool_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;
    86138}
    87139
     
    104156Int_t MRawSocketRead::PreProcess(MParList *pList)
    105157{
     158    if (!OpenSocket())
     159        return kFALSE;
     160
    106161    //
    107162    //  check if all necessary containers exist in the Parameter list.
     
    269324
    270325    fEvtNumber=fRawEvtHeader->GetDAQEvtNumber();
    271 /*
     326
    272327    if (fDisplay)
    273328        fDisplay->SetProgressBarPosition((Float_t)fEvtNumber/fRawRunHeader->GetNumEvents());
    274  */
     329
    275330    return kTRUE;
    276331}
    277332
    278333Int_t MRawSocketRead::PostProcess()
    279 {   /*
     334{
     335    //
     336    // Close Socket connection
     337    //
     338    fIn->Close();
     339
    280340    if (fDisplay)
    281341        fDisplay->SetProgressBarPosition(1);
    282      */
     342
    283343    return kTRUE;
    284344}
  • trunk/MagicSoft/Mars/mraw/MRawSocketRead.h

    r2466 r2490  
    44#ifndef MARS_MTask
    55#include "MTask.h"
    6 #endif
    7 
    8 #ifndef __IOSFWD__
    9 #include <iosfwd>
    106#endif
    117
     
    3329    UInt_t          fEvtNumber;     //!
    3430
    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();
    3838
    3939public:
     
    4141    ~MRawSocketRead();
    4242
     43    void SetPort(int port) { fPort = port; }
     44
    4345    ClassDef(MRawSocketRead, 0) //Task to read DAQ binary data from tcp/ip socket
    4446};
Note: See TracChangeset for help on using the changeset viewer.