diff -urN tridas.orig/daq/pt/frb/include/FRBAddr.h tridas/daq/pt/frb/include/FRBAddr.h --- tridas.orig/daq/pt/frb/include/FRBAddr.h Wed Dec 31 18:00:00 1969 +++ tridas/daq/pt/frb/include/FRBAddr.h Wed Nov 20 17:09:39 2002 @@ -0,0 +1,13 @@ +#ifndef __FRBAddr_h__ +#define __FRBAddr_h__ + +#include "pt.h" // typedef Address + +struct FRBAddr : public Address { + U32 network_type; + U32 interface_name; + U32 is_sender; +}; + +#endif // ifndef __FRBAddr_h__ + diff -urN tridas.orig/daq/pt/frb/include/FRBReceiveEntry.h tridas/daq/pt/frb/include/FRBReceiveEntry.h --- tridas.orig/daq/pt/frb/include/FRBReceiveEntry.h Wed Dec 31 18:00:00 1969 +++ tridas/daq/pt/frb/include/FRBReceiveEntry.h Wed Nov 20 17:09:39 2002 @@ -0,0 +1,32 @@ +#ifndef __FRBReceiveEntry_h__ +#define __FRBReceiveEntry_h__ + +#include "SAP.h" // SAP, Buffer +#include "pt.h" // Address +#include "BufRef.h" +#include "i2oProtocolIn.h" + +#include "xdaqIOException.h" + +#include "node.h" + +class FRBReceiveEntry: public SAP +{ +public: + FRBReceiveEntry(Address *address, i2oProtocolIn *pin); + ~FRBReceiveEntry(); + + void put(Buffer* buffer, int len) throw (xdaqException); + void put(BufRef *ref, int len) throw (xdaqException); + void put(Buffer* buffer, int len, BufRef *freeRef) throw (xdaqException); + + bool pollRecv(); + void waitRecvLoop(); + +protected: + LeafNode *node_; + + i2oProtocolIn *pin_; +}; + +#endif // ifndef __FRBReceiveEntry_h__ diff -urN tridas.orig/daq/pt/frb/include/FRBSendEntry.h tridas/daq/pt/frb/include/FRBSendEntry.h --- tridas.orig/daq/pt/frb/include/FRBSendEntry.h Wed Dec 31 18:00:00 1969 +++ tridas/daq/pt/frb/include/FRBSendEntry.h Wed Nov 20 17:09:39 2002 @@ -0,0 +1,29 @@ +#ifndef __FRBSendEntry_h__ +#define __FRBSendEntry_h__ + +#include "SAP.h" // SAP, Buffer +#include "pt.h" // Address +#include "BufRef.h" + +#include "xdaqIOException.h" + +#include "proxy.h" + +class FRBSendEntry : public SAP +{ +public: + FRBSendEntry(Address *address); + ~FRBSendEntry(); + + void put(Buffer *buffer, int len) throw (xdaqException); + void put(BufRef *ref, int len) throw (xdaqException); + void put(Buffer *buffer, int len, BufRef *freeRef) throw (xdaqException); + + bool pollRecv(); + void waitRecvLoop(); + +protected: + Proxy *proxy_; +}; + +#endif // ifndef __FRBSendEntry_h__ diff -urN tridas.orig/daq/pt/frb/include/ptFRB.h tridas/daq/pt/frb/include/ptFRB.h --- tridas.orig/daq/pt/frb/include/ptFRB.h Wed Dec 31 18:00:00 1969 +++ tridas/daq/pt/frb/include/ptFRB.h Wed Nov 20 17:09:39 2002 @@ -0,0 +1,34 @@ +#ifndef __ptFRB_h__ +#define __ptFRB_h__ + +#include "pt.h" +#include "pta.h" +#include "Task.h" +#include "i2oProtocolOut.h" +#include "i2oProtocolIn.h" + +#include "FRBSendEntry.h" +#include "FRBReceiveEntry.h" + +class ptFRB: public pt, public Task +{ +public: + ptFRB(pta *ptap); + ~ptFRB(); + + Address *createAddress(DOM_Node addressNode); + SendObj *createSendObj(Address * local, Address * remote); + RecvObj *createRecvObj(Address * address); + + int svc(); + bool hasMulticast() { return true; }; + +protected: + FRBSendEntry *send_entry_; + FRBReceiveEntry *recv_entry_; + + i2oProtocolOut *pout_; + i2oProtocolIn *pin_; +}; + +#endif // ifndef __ptFRB_h__ diff -urN tridas.orig/daq/pt/frb/include/ptFRBSO.h tridas/daq/pt/frb/include/ptFRBSO.h --- tridas.orig/daq/pt/frb/include/ptFRBSO.h Wed Dec 31 18:00:00 1969 +++ tridas/daq/pt/frb/include/ptFRBSO.h Wed Nov 20 17:09:39 2002 @@ -0,0 +1,17 @@ +#ifndef __ptFRBSO_h__ +#define __ptFRBSO_h__ + +#include "xdaqSO.h" +#include "ptFRB.h" + +class ptFRBSO : public xdaqSO +{ +public: + void init(); + void shutdown(); + +protected: + ptFRB *pt_; +}; + +#endif // ifndef __ptFRBSO_h__ diff -urN tridas.orig/daq/pt/frb/src/common/FRBReceiveEntry.cc tridas/daq/pt/frb/src/common/FRBReceiveEntry.cc --- tridas.orig/daq/pt/frb/src/common/FRBReceiveEntry.cc Wed Dec 31 18:00:00 1969 +++ tridas/daq/pt/frb/src/common/FRBReceiveEntry.cc Wed Nov 20 17:09:39 2002 @@ -0,0 +1,77 @@ +// +// FRBReceiveEntry.cc + +#include "FRBReceiveEntry.h" +#include "FRBAddr.h" + +#include "proxy.h" + +FRBReceiveEntry::FRBReceiveEntry(Address *address, i2oProtocolIn *pin) : + pin_(pin) +{ + XDAQ_DEBUG (("Calling FRBReceiveEntry CTOR")); + + FRBAddr *addr = static_cast(address); + + if (addr->is_sender == 0) { + char interface_name[100]; + sprintf(interface_name, "eth%d", addr->interface_name); + + node_ = new LeafNode("UDP", interface_name, false); + node_->set(Proxy::OPTION_REPAIR_TIMEOUT, 200); + } else { + node_ = (LeafNode *)0; + } +} + +FRBReceiveEntry::~FRBReceiveEntry() +{ + XDAQ_DEBUG (("Calling FRBReceiveEntry DTOR")); + + if (node_ != NULL) delete node_; +} + +void FRBReceiveEntry::waitRecvLoop() +{ + XDAQ_DEBUG (("FRBReceiveEntry::waitRecvLoop()")); + + while (1) { + pollRecv(); + } +} + +bool FRBReceiveEntry::pollRecv() +{ + XDAQ_DEBUG (("FRBReceiveEntry::pollRecv()")); + + int len; + int *buf; + + len = node_->receive(&buf); + + BufRef *ref = executive->frameAlloc(len * sizeof(int)); + + memcpy(ref->buf_, buf, len * sizeof(int)); + pin_->in(ref, 1); // fake originator: 1 + + delete buf; + + return true; +} + +void FRBReceiveEntry::put(Buffer *buffer, int len) throw (xdaqException) +{ + XDAQ_RAISE(xdaqException, "not implemented"); +} + +void FRBReceiveEntry::put(BufRef *ref, int len) throw (xdaqException) +{ + XDAQ_RAISE(xdaqException, "not implemented"); +} + +void FRBReceiveEntry::put(Buffer *buffer, int len, BufRef *freeRef) throw (xdaqException) +{ + XDAQ_RAISE(xdaqException, "not implemented"); +} + +// End of file diff -urN tridas.orig/daq/pt/frb/src/common/FRBSendEntry.cc tridas/daq/pt/frb/src/common/FRBSendEntry.cc --- tridas.orig/daq/pt/frb/src/common/FRBSendEntry.cc Wed Dec 31 18:00:00 1969 +++ tridas/daq/pt/frb/src/common/FRBSendEntry.cc Wed Nov 20 17:09:39 2002 @@ -0,0 +1,68 @@ +// +// FRBSendEntry.cc + +#include "FRBSendEntry.h" +#include "FRBAddr.h" + +#include // sprintf +#include "xdaqExecutive.h" // extern xdaqExecutive *executive + +#include "proxy.h" + +FRBSendEntry::FRBSendEntry(Address *address) +{ + XDAQ_DEBUG (("Calling FRBSendEntry CTOR")); + + FRBAddr *addr = static_cast(address); + + if (addr->is_sender > 0) { + char interface_name[100]; + sprintf(interface_name, "eth%d", addr->interface_name); + + proxy_ = Proxy::instance("UDP", interface_name, false); + proxy_->set(Proxy::OPTION_FEC, "SIMPLE"); + } else { + proxy_ = (Proxy *)0; + } +} + +FRBSendEntry::~FRBSendEntry() +{ + XDAQ_DEBUG (("Calling FRBSendEntry DTOR")); + + if (proxy_ != NULL) delete proxy_; +} + +void FRBSendEntry::put(Buffer *buffer, int len) throw (xdaqException) +{ + proxy_->send((int *)buffer->userAddr(), len / sizeof(int), NULL); + + return; +} + +void FRBSendEntry::put(BufRef *ref, int len) throw (xdaqException) +{ + XDAQ_RAISE(xdaqException, "put(BufRef *, int) - not implemented"); +} + +void FRBSendEntry::put(Buffer *buffer, int len, BufRef *freeRef) throw (xdaqException) +{ + proxy_->send((int *)buffer->userAddr(), len / sizeof(int), NULL); + executive->frameFree(freeRef); + + return; +} + +bool FRBSendEntry::pollRecv() +{ + XDAQ_ERROR (("*** Cannot call receive on SendEntry !")); + + return false; +} + +void FRBSendEntry::waitRecvLoop() +{ + XDAQ_ERROR (("*** Cannot call receive on SendEntry!")); +} + +// End of file diff -urN tridas.orig/daq/pt/frb/src/common/ptFRB.cc tridas/daq/pt/frb/src/common/ptFRB.cc --- tridas.orig/daq/pt/frb/src/common/ptFRB.cc Wed Dec 31 18:00:00 1969 +++ tridas/daq/pt/frb/src/common/ptFRB.cc Wed Nov 20 17:09:39 2002 @@ -0,0 +1,104 @@ +// +// ptFRB.cc + +#include "ptFRB.h" +#include "FRBAddr.h" +#include "FRBSendEntry.h" +#include "FRBReceiveEntry.h" + +#include "TaskAttributes.h" + +ptFRB::ptFRB(pta *ptap): pt(ptap) +{ + pout_ = new i2oProtocolOut(ptap); + pin_ = new i2oProtocolIn(ptap); +} + +ptFRB::~ptFRB() +{ + if (pout_ != NULL) delete pout_; + if (pin_ != NULL) delete pin_; + + if (recv_entry_ != NULL) delete recv_entry_; + if (send_entry_ != NULL) delete send_entry_; +} + +Address *ptFRB::createAddress(DOM_Node addressNode) +{ + FRBAddr *addr = new FRBAddr(); + + string network_type = getNodeAttribute(addressNode, "network"); + string interface_name = getNodeAttribute(addressNode, "interface"); + string is_sender = getNodeAttribute(addressNode, "sender"); + + // Temporary solution. + // network_type: not used, always UDP on Ethernet + // interface_name: 0 or 1 selecting eth + // is_sender: 0 for a leaf nodes (RUs), 1 for a root (EVM) + addr->network_type = 0; + addr->interface_name = 0; + addr->is_sender = 0; + if (interface_name.size() > 0) { + addr->interface_name = interface_name[3] - '0'; + } + if (is_sender.size() > 0) { + addr->is_sender = atoi(is_sender.c_str()); + } + addr->multicast(true); + + XDAQ_DEBUG (("ptFRB::createAddr: type %d, i/f %d, sender %d", + addr->network_type, addr->interface_name, addr->is_sender)); + + return addr; +} + +SendObj *ptFRB::createSendObj(Address *local, Address *remote) +{ + FRBAddr *addr = (FRBAddr *)local; + XDAQ_DEBUG (("ptFRB::createSendObj: local %x", local)); + XDAQ_DEBUG (("ptFRB::createSendObj: type %d, i/f %d, sender %d", + addr->network_type, addr->interface_name, addr->is_sender)); + + if (addr->is_sender == 1) { + send_entry_ = new FRBSendEntry(local); + + return new SendObj(send_entry_, pout_, this); + + } else { + return new SendObj((FRBSendEntry *)0, pout_, this); + } +} + +RecvObj *ptFRB::createRecvObj(Address *address) +{ + FRBAddr *addr = (FRBAddr *)address; + XDAQ_DEBUG (("ptFRB::createRecvObj: address %x", address)); + XDAQ_DEBUG (("ptFRB::createRecvObj: type %d, i/f %d, sender %d", + addr->network_type, addr->interface_name, addr->is_sender)); + + if (addr->is_sender == 0) { + recv_entry_ = new FRBReceiveEntry(address, pin_); + + RecvObj *recv_obj = new RecvObj(recv_entry_, pout_); + + TaskAttributes att; + att.name("ptFrb"); + recv_obj->set(&att); + + if (! pollingMode_ ) { + recv_obj->activate(); + } + + return recv_obj; + + } else { + return new RecvObj((FRBReceiveEntry *)0, pout_); + } +} + +int ptFRB::svc() +{ + return 0; +} + +// End of file diff -urN tridas.orig/daq/pt/frb/src/common/ptFRBSO.cc tridas/daq/pt/frb/src/common/ptFRBSO.cc --- tridas.orig/daq/pt/frb/src/common/ptFRBSO.cc Wed Dec 31 18:00:00 1969 +++ tridas/daq/pt/frb/src/common/ptFRBSO.cc Wed Nov 20 17:09:39 2002 @@ -0,0 +1,24 @@ +// +// ptFRBSO.cc + +#include "ptFRBSO.h" + +#include "xdaqExecutive.h" // extern xdaqExecutive *executive + +void ptFRBSO::init() +{ + pt_ = new ptFRB(executive->peerTransportAgent()); + executive->install(pt_); +} + +void ptFRBSO::shutdown() +{ + delete pt_; +} + +extern "C" void *init_ptFRB() +{ + return ((void *)new ptFRBSO()); +} + +// End of file diff -urN tridas.orig/daq/pt/frb/src/linux/x86/Makefile tridas/daq/pt/frb/src/linux/x86/Makefile --- tridas.orig/daq/pt/frb/src/linux/x86/Makefile Wed Dec 31 18:00:00 1969 +++ tridas/daq/pt/frb/src/linux/x86/Makefile Wed Nov 20 17:12:47 2002 @@ -0,0 +1,177 @@ +# Makefile - makefile skeleton for C++ vxWorks PPC +# +ARCHITECTURE=linux +BSP=x86 + +################################################################## +DOMAINDIR=daq +PACKAGEDIR=pt/frb +include ${PROJECTDIR}/config/mfHeader.$(ARCHITECTURE) +################################################################## +# Default Parametrization +# It can be overwritten by using gmake option +################################################################## +# +# yes or no (default yes) +# +DO_SOAP=yes +# +# yes or no for FRB support (default no) +# +DO_FRB=yes +# +# stub or dimprobe (default stub) +# +DNS=dimprobe +DO_DNS=no +# +# yes or no(default yes) +# +DEBUG=yes +# +# big or little (no default is mandatory) +# +ENDIANESS=little +# +# gnu or native (default gnu) +# + +################################################################## +# DNS support +# +ifeq ($(DO_DNS), yes) +ifeq ($(DNS), stub) + DNS_C++FLAGS = -DDNS__ + DNS_INCLUDE = -I${PROJECTDIR}/Auxiliary/dns/include/ + DNS_LDDFLAGS = -L${PROJECTDIR}/Auxiliary/dns/lib/${ARCHITECTURE}/${BSP} + DNS_LIB = -ldnsstub +endif +ifeq ($(DNS), dimprobe) + DNS_C++FLAGS = -DDNS__ + DNS_INCLUDE = -I${PROJECTDIR}/Auxiliary/dim${ARCHITECTURE}${BSP} -I${PROJECTDIR}/Auxiliary/dns/include/ + DNS_LDDFLAGS = -L${PROJECTDIR}/Auxiliary/dns/lib/${ARCHITECTURE}/${BSP} -L${PROJECTDIR}/Auxiliary/dim${ARCHITECTURE}${BSP}/${ARCHITECTURE} + DNS_LIB = -ldnsprobe -ldim +endif +endif + +ifeq ($(DO_DNS), no) + DNS_C++FLAGS = + DNS_INCLUDE = + DNS_LDDFLAGS = + DNS_LIB = +endif +################################################################## +# SOAP Support +# +ifeq ($(DO_SOAP), yes) + SOAP_C++FLAGS = -DSOAP__ + SOAP_DIR = ${PROJECTDIR}/Auxiliary/xerces${ARCHITECTURE}${BSP} + SOAP_INCLUDE = -I${SOAP_DIR}/include + XOAP_INCLUDE = -I${PROJECTDIR}/daq/xoap/include +else + SOAP_C++FLAGS = + SOAP_INCLUDE = + XOAP_INCLUDE = +endif +################################################################## +# FRB Support +# +ifeq ($(DO_FRB),yes) + FRB_C++FLAGS = -DFRB__ -DNO_IEEE1394 + FRB_DIR = ${PROJECTDIR}/Auxiliary/frb${ARCHITECTURE}${BSP} + FRB_INCLUDE = -I${FRB_DIR}/include + FRB_LDDFLAGS = -L${FRB_DIR}/lib + FRB_LIB = -lfrb +else + FRB_C++FLAGS = + FRB_INCLUDE = + FRB_LDDFLAGS = + FRB_LIB = +endif +################################################################## +# DEBUG +# +ifeq ($(DEBUG), yes) + DEBUG_C++FLAGS = -g + DEBUG_LDDFLAGS = -g +else + DEBUG_C++FLAGS = + DEBUG_LDDFLAGS = +endif +################################################################## +# ENDIANESS +# +ifeq ($(ENDIANESS), little) + ENDIANESS_C++FLAGS = -DLITTLE_ENDIAN__ +endif +ifeq ($(ENDIANESS), big) + ENDIANESS_C++FLAGS = -DBIG_ENDIAN__ +endif +################################################################## +# Final Definitions +################################################################## + +################################################################## +# Local Definitions +################################################################## + +ADDED_CFLAGS = -fno-inline -g +ADDED_C++FLAGS = \ + ${COMPILER_C++FLAGS} \ + ${DEBUG_C++FLAGS} \ + $(ENDIANESS_C++FLAGS) \ + $(SOAP_C++FLAGS) \ + ${FRB_C++FLAGS} \ + $(DNS_C++FLAGS) \ + -Dtoolbox + +ADDED_LDXXFLAGS= ${COMPILER_LDDFLAGS} $(DEBUG_LDDFLAGS) \ +-L./ -L${PROJECTDIR}/lib/${ARCHITECTURE}/${BSP} \ +${DNS_LDDFLAGS} \ +${FRB_LDDFLAGS} \ +${DEBUG_LDDFLAGS} + +C++SOURCES= ptFRBSO.cc ptFRB.cc FRBSendEntry.cc FRBReceiveEntry.cc + +EXTERNAL_OBJECTS += ${FRB_LIB} +SHARED_LDFLAGS += ${FRB_LDDFLAGS} + +CSOURCES= +SOURCEPATH=./:../common/:../../common/ + +DLIBRARY= libptFRB.so +LIBRARIES= + +EXECUTABLES= + +APPDIR= +APPINCLUDE = -DINLINE -I./ -I${PROJECTDIR}/${DOMAINDIR}/${PACKAGEDIR}/include/ \ +-I${PROJECTDIR}/${DOMAINDIR}/${PACKAGEDIR}/include/${ARCHITECTURE} \ +-I${PROJECTDIR}/${DOMAINDIR}/toolbox/include \ +-I${PROJECTDIR}/${DOMAINDIR}/toolbox/include/${ARCHITECTURE} \ +-I${PROJECTDIR}/${DOMAINDIR}/toolbox/include/solaris \ +-I${PROJECTDIR}/${DOMAINDIR}/xdaq/include \ +-I${PROJECTDIR}/${DOMAINDIR}/xdaq/include/${ARCHITECTURE} \ +-I${PROJECTDIR}/${DOMAINDIR}/xdaq/include/solaris \ +-I${PROJECTDIR}/Auxiliary/i2o/include \ +-I${PROJECTDIR}/Auxiliary/i2o/include/i2o/ \ +-I${PROJECTDIR}/Auxiliary/i2o/include/i2o/shared \ +${DNS_INCLUDE} \ +${FRB_INCLUDE} \ +${SOAP_INCLUDE} \ +${XOAP_INCLUDE} \ + + +################################################################## +# Standard Rules +################################################################## +include ${PROJECTDIR}/config/mfRules.$(ARCHITECTURE) +help: + @echo "The following variables should cane be set" + @echo "DO_SOAP={yes|no} (default yes)" + @echo "DO_FRB={yes|no} (default yes)" + @echo "DO_DNS={yes|no} (default no)" +# @echo "DNS={stub|dimprobe} (default stub)" +# +################################################################## +#EOF