00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #include <sys/types.h>
00024
00025 #include <Alloc.hh>
00026 #include <Condition.hh>
00027 #include <Mutex.hh>
00028 #include <Semaphore.hh>
00029
00030 #include <dsp/DSPOp.hh>
00031 #include <dsp/ReBuffer.hh>
00032 #include <dsp/RecDecimator.hh>
00033
00034 #include "Config.h"
00035 #include "LocalMsg.h"
00036 #include "CfgFile.hh"
00037 #include "FreqBeamDipole.hh"
00038 #include "FreqBeamLine.hh"
00039 #include "LogFile.hh"
00040 #include "Messages.hh"
00041 #include "SockClie.hh"
00042 #include "SockOp.hh"
00043 #include "SockServ.hh"
00044
00045 #include "BeamCommon.hh"
00046
00047
00048 #ifndef BEAMSRV_HH
00049 #define BEAMSRV_HH
00050
00051 # define BS_PROCINFOV_T std::vector<stBeamProcInfo>
00052
00053
00054 typedef struct _stBeamProcInfo
00055 {
00056 pid_t pidProc;
00057 int iSockH;
00058 } stBeamProcInfo, *stpBeamProcInfo;
00059
00060
00068 class clBeamSrvMaster
00069 {
00070 int iFilterType;
00071 int iDecimate;
00072 int iDecFact;
00073 int iChOffset;
00074 int iOutDataCount;
00075 volatile int iBlockCntr;
00076 char cpLogBuf[BS_LOGBUFSIZE];
00077 stRawDataFirst sInHdr;
00078 stBeamNodeParams sNodeParams;
00079 clAlloc FiltWork;
00080 clCfgFile Cfg;
00081 clDSPOp DSP;
00082 clLogFile Log;
00083 clRecDecimator *FilterBank;
00084 clSockOp SOpIn;
00085 clSockServ SServ;
00086
00087 clReBuffer InBuf;
00088 clSemaphore SemIn;
00089 clMutex MtxIn;
00090
00091 clAlloc OutData;
00092 clCondition CndOut;
00093 clMutex MtxOut;
00094
00095 bool ReadConfig ();
00096 bool InitFilterBank ();
00097 bool InitProcessing ();
00098 void ProcessLoop ();
00099 bool SendNodeParams ();
00100 bool WaitReady ();
00101 bool SendInData (const GDT *, int);
00102 void CompactData (GDT *, const GDT *, long, long, long, long);
00103 bool FilterData (GDT *, const GDT *, long, long, long, long);
00104 public:
00105 clBeamSrvMaster ();
00106 ~clBeamSrvMaster ();
00107 int Main (int *, char ***);
00108 static void Abort ();
00109 void *InDataThread (void *);
00110 void *ServerThread (void *);
00111 void *ServeClientThread (void *);
00112 };
00113
00114
00120 class clBeamSrvSlave
00121 {
00122 int iProcess;
00123 int iSockH;
00124 stBeamNodeParams sNodeParams;
00125 clFreqBeamDipole FBDipole;
00126 clFreqBeamLine FBLine;
00127 bool RecvParams ();
00128 bool RecvInData (GDT *, int);
00129 bool SendReady ();
00130 bool SendRes (const GDT *, int);
00131 public:
00132 clBeamSrvSlave (int, int);
00133 ~clBeamSrvSlave ();
00134 int Main (int *, char ***);
00135 };
00136
00137 #endif