diff --git a/.clang-format b/.clang-format new file mode 100644 index 000000000..112004a90 --- /dev/null +++ b/.clang-format @@ -0,0 +1,100 @@ +# BasedOnStyle: LLVM +AccessModifierOffset: -3 +AlignAfterOpenBracket: Align +AlignConsecutiveAssignments: None +# This would be nice to have but seems to also (mis)align function parameters +AlignConsecutiveDeclarations: None +AlignEscapedNewlines: Left +AlignOperands: true +AlignTrailingComments: true +AllowAllParametersOfDeclarationOnNextLine: true +AllowShortBlocksOnASingleLine: Never +AllowShortCaseLabelsOnASingleLine: true +AllowShortFunctionsOnASingleLine: Inline +AllowShortIfStatementsOnASingleLine: false +AllowShortLoopsOnASingleLine: false +# This option is "deprecated and is retained for backwards compatibility." +# AlwaysBreakAfterDefinitionReturnType: None +AlwaysBreakAfterReturnType: None +AlwaysBreakBeforeMultilineStrings: false +AlwaysBreakTemplateDeclarations: Yes +BinPackArguments: true +BinPackParameters: true +BraceWrapping: + AfterClass: false + AfterControlStatement: Never + AfterEnum: false + AfterFunction: true + AfterNamespace: false + AfterObjCDeclaration: false + AfterStruct: false + AfterUnion: false + BeforeCatch: false + BeforeElse: false + IndentBraces: false +BreakBeforeBinaryOperators: None +BreakBeforeBraces: Custom +BreakBeforeTernaryOperators: true +BreakConstructorInitializersBeforeComma: false +ColumnLimit: 120 +CommentPragmas: '^ IWYU pragma:' +ConstructorInitializerAllOnOneLineOrOnePerLine: true +ConstructorInitializerIndentWidth: 3 +ContinuationIndentWidth: 3 +Cpp11BracedListStyle: true +DerivePointerAlignment: false +DisableFormat: false +ExperimentalAutoDetectBinPacking: false +ForEachMacros: [ foreach, Q_FOREACH, BOOST_FOREACH ] +IndentCaseLabels: false +IndentWidth: 3 +IndentWrappedFunctionNames: false +KeepEmptyLinesAtTheStartOfBlocks: true +MacroBlockBegin: '' +MacroBlockEnd: '' +MaxEmptyLinesToKeep: 1 +NamespaceIndentation: None +ObjCBlockIndentWidth: 3 +ObjCSpaceAfterProperty: false +ObjCSpaceBeforeProtocolList: true +PenaltyBreakBeforeFirstCallParameter: 19 +PenaltyBreakComment: 300 +PenaltyBreakFirstLessLess: 120 +PenaltyBreakString: 1000 +PenaltyExcessCharacter: 1000000 +PenaltyReturnTypeOnItsOwnLine: 10 +PointerAlignment: Right +ReflowComments: true +SortIncludes: Never +SpaceAfterCStyleCast: false +SpaceBeforeAssignmentOperators: true +# You want this : enable it if you have https://reviews.llvm.org/D32525 +# SpaceBeforeColon: false +SpaceBeforeParens: ControlStatements +SpaceInEmptyParentheses: false +SpacesBeforeTrailingComments: 1 +SpacesInAngles: false +SpacesInContainerLiterals: true +SpacesInCStyleCastParentheses: false +SpacesInParentheses: false +SpacesInSquareBrackets: false +Standard: c++11 +TabWidth: 3 +UseTab: Never + +# Order alphabetically and by generality the included header files. +IncludeCategories: + - Regex: '^"[^/]+\"' + Priority: 10 + - Regex: '^("|<)T' + Priority: 12 + - Regex: '^"ROOT/' + Priority: 15 + - Regex: '^"cling/' + Priority: 20 + - Regex: '^"clang/' + Priority: 30 + - Regex: '^"llvm/' + Priority: 40 + - Regex: '^<' + Priority: 50 diff --git a/.clang-tidy b/.clang-tidy new file mode 100644 index 000000000..9ddfeae90 --- /dev/null +++ b/.clang-tidy @@ -0,0 +1 @@ +WarningsAsErrors: '*' diff --git a/plugins/dogma/CMakeLists.txt b/plugins/dogma/CMakeLists.txt index 59df49f18..ba1216291 100644 --- a/plugins/dogma/CMakeLists.txt +++ b/plugins/dogma/CMakeLists.txt @@ -5,11 +5,14 @@ dabc_link_library( src/defines.cxx src/UdpTransport.cxx src/TypeDefs.cxx + src/api.cxx HEADERS dogma/TerminalModule.h dogma/Factory.h + dogma/Iterator.h dogma/defines.h dogma/UdpTransport.h dogma/TypeDefs.h + dogma/api.h INCDIR dogma LIBRARIES DabcBase INCLUDES ${CMAKE_CURRENT_SOURCE_DIR}) @@ -19,6 +22,11 @@ dabc_executable( SOURCES dogmacmd.cxx LIBRARIES DabcBase) +dabc_executable( + dogmaprint + SOURCES dogmaprint.cxx + LIBRARIES DabcBase DabcMbs DabcDogma) + dabc_install_plugin_data( DabcDogma DIRECTORIES app diff --git a/plugins/dogma/Readme.md b/plugins/dogma/Readme.md index 8c7df3648..1afdc3840 100644 --- a/plugins/dogma/Readme.md +++ b/plugins/dogma/Readme.md @@ -1,4 +1,21 @@ -# Short info +## Usage of `dogmaprint` + +1. Start readout + + dabc_exe plugins/dogma/app/readout.xml + +2. Run print on any other node + + dogmaprint host:6002 -raw + + dogmaprint host:6002 -rate + + + +## Usage of `dogmacmd` + +This is demo how one use DABC command channel to submit arbitrary commands +to remote node. Any kind of protocol can be implemented on top. 1. Start on the control node diff --git a/plugins/dogma/app/dogma.xml b/plugins/dogma/app/dogma.xml index 1c9060dbe..361f97c32 100644 --- a/plugins/dogma/app/dogma.xml +++ b/plugins/dogma/app/dogma.xml @@ -2,6 +2,7 @@ + diff --git a/plugins/dogma/app/print.xml b/plugins/dogma/app/print.xml index 81aeae134..d600ab6c2 100644 --- a/plugins/dogma/app/print.xml +++ b/plugins/dogma/app/print.xml @@ -4,6 +4,7 @@ + @@ -30,7 +31,7 @@ - + diff --git a/plugins/dogma/app/readout.xml b/plugins/dogma/app/readout.xml new file mode 100644 index 000000000..e845e0b43 --- /dev/null +++ b/plugins/dogma/app/readout.xml @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/plugins/dogma/dogma/Factory.h b/plugins/dogma/dogma/Factory.h index 839a46272..23be073e9 100644 --- a/plugins/dogma/dogma/Factory.h +++ b/plugins/dogma/dogma/Factory.h @@ -30,6 +30,8 @@ namespace dogma { public: Factory(const std::string &name) : dabc::Factory(name) {} + dabc::Reference CreateObject(const std::string &classname, const std::string &objname, dabc::Command cmd) override; + dabc::Module *CreateModule(const std::string &classname, const std::string &modulename, dabc::Command cmd) override; dabc::Module *CreateTransport(const dabc::Reference& port, const std::string &typ, dabc::Command cmd) override; diff --git a/plugins/dogma/dogma/Iterator.h b/plugins/dogma/dogma/Iterator.h new file mode 100644 index 000000000..2c3e1a416 --- /dev/null +++ b/plugins/dogma/dogma/Iterator.h @@ -0,0 +1,89 @@ +// $Id$ + +/************************************************************ + * The Data Acquisition Backbone Core (DABC) * + ************************************************************ + * Copyright (C) 2009 - * + * GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Planckstr. 1, 64291 Darmstadt, Germany * + * Contact: http://dabc.gsi.de * + ************************************************************ + * This software can be used under the GPL license * + * agreements as stated in LICENSE.txt file * + * which is part of the distribution. * + ************************************************************/ + +#ifndef DOGMA_Iterator +#define DOGMA_Iterator + +#ifndef DABC_Buffer +#include "dabc/Buffer.h" +#endif + +#ifndef DABC_Pointer +#include "dabc/Pointer.h" +#endif + +#ifndef DABC_eventsapi +#include "dabc/eventsapi.h" +#endif + +#ifndef DOGMA_TypeDefs +#include "dogma/TypeDefs.h" +#endif + +#ifndef DOGMA_defines +#include "dogma/defines.h" +#endif + +namespace dogma { + + class RawIterator : public dabc::EventsIterator { + protected: + dabc::Pointer fRawPtr; + + public: + RawIterator(const std::string &name) : dabc::EventsIterator(name) {} + ~RawIterator() override {} + + bool Assign(const dabc::Buffer& buf) override + { + Close(); + if (buf.null() || (buf.GetTypeId() != mbt_DogmaTransportUnit)) + return false; + + fRawPtr = buf; + return true; + } + void Close() override { return fRawPtr.reset(); } + + bool NextEvent() override + { + auto sz = EventSize(); + if (sz >= fRawPtr.fullsize()) { + fRawPtr.reset(); + return false; + } + fRawPtr.shift(sz); + return !fRawPtr.null(); + }; + + void *Event() override + { + if (fRawPtr.fullsize() < sizeof(DogmaTu)) + fRawPtr.reset(); + + return fRawPtr(); + } + + dabc::BufferSize_t EventSize() override + { + auto tu = (DogmaTu *) Event(); + return tu ? tu->GetSize() : 0; + } + }; + + +} + +#endif diff --git a/plugins/dogma/dogma/api.h b/plugins/dogma/dogma/api.h new file mode 100644 index 000000000..b6ce4f8c2 --- /dev/null +++ b/plugins/dogma/dogma/api.h @@ -0,0 +1,69 @@ +// $Id$ + +/************************************************************ + * The Data Acquisition Backbone Core (DABC) * + ************************************************************ + * Copyright (C) 2009 - * + * GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Planckstr. 1, 64291 Darmstadt, Germany * + * Contact: http://dabc.gsi.de * + ************************************************************ + * This software can be used under the GPL license * + * agreements as stated in LICENSE.txt file * + * which is part of the distribution. * + ************************************************************/ + +#ifndef DOGMA_api +#define DOGMA_api + +#ifndef MBS_api +#include "mbs/api.h" +#endif + +#ifndef DOGMA_Iterator +#include "dogma/Iterator.h" +#endif + +namespace dogma { + + class ReadoutHandle; + + class ReadoutModule : public mbs::ReadoutModule { + protected: + + friend class ReadoutHandle; + + dogma::RawIterator fIter2; ///< iterator over DOGMA buffers + + int AcceptBuffer(dabc::Buffer &buf) override; + + public: + + ReadoutModule(const std::string &name, dabc::Command cmd); + }; + + + class ReadoutHandle : protected mbs::ReadoutHandle { + + DABC_REFERENCE(ReadoutHandle, mbs::ReadoutHandle, dogma::ReadoutModule) + + /** Connect with data source */ + static ReadoutHandle Connect(const std::string &url); + + /** Return true if handle not initialized */ + bool null() const { return mbs::ReadoutHandle::null(); } + + /** Disconnect from MBS server */ + bool Disconnect() { return mbs::ReadoutHandle::Disconnect(); } + + /** Retrieve next event from the server */ + DogmaTu *NextTu(double tm = 1.0, double maxage = -1.); + + /** Get current event pointer */ + DogmaTu *GetTu(); + }; + +} + + +#endif diff --git a/plugins/dogma/dogma/defines.h b/plugins/dogma/dogma/defines.h index 313e2382e..c3d6d2197 100644 --- a/plugins/dogma/dogma/defines.h +++ b/plugins/dogma/dogma/defines.h @@ -53,7 +53,7 @@ namespace dogma { inline uint32_t GetAddr() const { return Value(&tuAddr); } - inline uint32_t GetTrigType() const { return Value(&tuTrigTypeNumber) << 24; } + inline uint32_t GetTrigType() const { return Value(&tuTrigTypeNumber) >> 24; } inline uint32_t GetTrigNumber() const { return Value(&tuTrigTypeNumber) & 0xffffff; } @@ -61,7 +61,10 @@ namespace dogma { inline uint32_t GetPayloadLen() const { return Value(&tuLenPayload) & 0xffff; } - inline uint32_t GetMessageSize() const { return 20 + GetPayloadLen(); } + inline uint32_t GetSize() const { return 20 + GetPayloadLen(); } + + inline uint32_t GetPayload(uint32_t indx) const { return Value(&tuLenPayload + 1 + indx); } + }; } diff --git a/plugins/dogma/dogmaprint.cxx b/plugins/dogma/dogmaprint.cxx new file mode 100644 index 000000000..c23198d7d --- /dev/null +++ b/plugins/dogma/dogmaprint.cxx @@ -0,0 +1,244 @@ +// $Id$ + +/******************************************************************** + * The Data Acquisition Backbone Core (DABC) + ******************************************************************** + * Copyright (C) 2009- + * GSI Helmholtzzentrum fuer Schwerionenforschung GmbH + * Planckstr. 1 + * 64291 Darmstadt + * Germany + * Contact: http://dabc.gsi.de + ******************************************************************** + * This software can be used under the GPL license agreements as stated + * in LICENSE.txt file which is part of the distribution. + ********************************************************************/ + +#include +#include +#include +#include +#include +#include + +#include "dogma/api.h" +#include "dabc/Url.h" +#include "dabc/api.h" + +int usage(const char* errstr = nullptr) +{ + if (errstr) + printf("Error: %s\n\n", errstr); + + printf("Utility for printing DOGMA data. 15.03.2024. S.Linev\n"); + printf(" dogmaprint source [args]\n"); + printf("Following sources are supported:\n"); + printf(" file.bin - DABC binary file reading\n"); + printf(" dabcnode - DABC stream server\n"); + printf(" dabcnode:port - DABC stream server with custom port\n"); + printf("Arguments:\n"); + printf(" -tmout value - maximal time in seconds for waiting next event (default 5)\n"); + printf(" -maxage value - maximal age time for events, if expired queue are cleaned (default off)\n"); + printf(" -num number - number of events to print, 0 - all events (default 10)\n"); + printf(" -all - print all events (equivalent to -num 0)\n"); + printf(" -skip number - number of events to skip before start printing\n"); + printf(" -raw - printout of raw data (default false)\n"); + printf(" -rate - display only events and data rate\n"); + + return errstr ? 1 : 0; +} + +bool printraw = false, printsub = false, showrate = false, reconnect = false, dostat = false, dominsz = false, domaxsz = false, autoid = false; +unsigned idrange = 0xff, onlytdc = 0, onlynew = 0, onlyraw = 0, hubmask = 0, fullid = 0, adcmask = 0, onlymonitor = 0; + + +int main(int argc, char* argv[]) +{ + if ((argc < 2) || !strcmp(argv[1], "-help") || !strcmp(argv[1], "?")) + return usage(); + + long number = 10, skip = 0, nagain = 0; + double tmout = -1., maxage = -1.; + + int n = 1; + while (++n < argc) { + if ((strcmp(argv[n], "-num") == 0) && (n + 1 < argc)) { + dabc::str_to_lint(argv[++n], &number); + } else if (strcmp(argv[n], "-all") == 0) { + number = 0; + } else if (strcmp(argv[n], "-rate") == 0) { + showrate = true; + number = 0; + } else if ((strcmp(argv[n], "-skip") == 0) && (n + 1 < argc)) { + dabc::str_to_lint(argv[++n], &skip); + } else if ((strcmp(argv[n], "-tmout") == 0) && (n + 1 < argc)) { + dabc::str_to_double(argv[++n], &tmout); + } else if ((strcmp(argv[n], "-maxage") == 0) && (n + 1 < argc)) { + dabc::str_to_double(argv[++n], &maxage); + } else if (strcmp(argv[n], "-raw") == 0) { + printraw = true; + } else if (strcmp(argv[n], "-sub") == 0) { + printsub = true; + } else if (strcmp(argv[n], "-stat") == 0) { + dostat = true; + } else + return usage("Unknown option"); + } + + printf("Try to open %s\n", argv[1]); + + if (tmout < 0) tmout = 5.; + + bool isfile = false; + std::string src = argv[1]; + + if ((src.find(".bin") != std::string::npos) && (src.find("bin://") != 0)) { + src = std::string("bin://") + src; + isfile = true; + } else if ((src.find("bin://") == 0) || (src.find(".bin") != std::string::npos)) { + isfile = true; + } + + if (!isfile) { + + dabc::Url url(src); + + if (url.IsValid()) { + if (url.GetProtocol().empty()) + src = std::string("mbss://") + src; + + if (reconnect && !url.HasOption("reconnect")) { + if (url.GetOptions().empty()) + src += "?reconnect"; + else + src += "&reconnect"; + } + } + } + + dogma::DogmaTu *evnt = nullptr; + + long cnt = 0, cnt0 = 0, lastcnt = 0, printcnt = 0, mincnt = -1, maxcnt = -1; + uint32_t mintrignr = 0, maxtrignr = 0; + uint64_t lastsz = 0, currsz = 0, minsz = 10000000000, numminsz = 0, maxsz = 0, nummaxsz = 0; + dabc::TimeStamp last, first, lastevtm; + + dogma::ReadoutHandle ref; + + dabc::InstallSignalHandlers(); + + while (nagain-- >= 0) { + + ref = dogma::ReadoutHandle::Connect(src); + + if (ref.null()) return 1; + + cnt = cnt0 = lastcnt = printcnt = 0; + lastsz = currsz = 0; + last = first = lastevtm = dabc::Now(); + + while (!dabc::CtrlCPressed()) { + + evnt = ref.NextTu(maxage > 0 ? maxage/2. : 1., maxage); + + cnt0++; + + // if (debug_delay > 0) dabc::Sleep(debug_delay); + + dabc::TimeStamp curr = dabc::Now(); + + if (evnt) { + + // ignore events which are not match with specified id + if ((fullid != 0) && (evnt->GetAddr() != fullid)) continue; + + if (dominsz) { + if (evnt->GetSize() < minsz) { + minsz = evnt->GetSize(); + mintrignr = evnt->GetTrigNumber(); + mincnt = cnt; + numminsz = 1; + } else if (evnt->GetSize() == minsz) { + numminsz++; + } + } + + if (domaxsz) { + if (evnt->GetSize() > maxsz) { + maxsz = evnt->GetSize(); + maxtrignr = evnt->GetTrigNumber(); + maxcnt = cnt; + nummaxsz = 1; + } else if (evnt->GetSize() == maxsz) { + nummaxsz++; + } + } + + cnt++; + currsz += evnt->GetSize(); + lastevtm = curr; + } else if (curr - lastevtm > tmout) { + /*printf("TIMEOUT %ld\n", cnt0);*/ + break; + } + + if (showrate) { + + double tm = curr - last; + + if (tm >= 0.3) { + printf("\rTm:%6.1fs Ev:%8ld Rate:%8.2f Ev/s %6.2f MB/s", first.SpentTillNow(), cnt, (cnt-lastcnt)/tm, (currsz-lastsz)/tm/1024./1024.); + fflush(stdout); + last = curr; + lastcnt = cnt; + lastsz = currsz; + } + + // when showing rate, only with statistic one need to analyze event + if (!dostat) continue; + } + + if (!evnt) continue; + + if (skip > 0) { skip--; continue; } + + printcnt++; + + printf("Event addr: %lu type: 0x%02x trignum; %lu, time: %lu paylod: %lu\n", + (long unsigned) evnt->GetAddr(), (unsigned) evnt->GetTrigType(), (long unsigned) evnt->GetTrigNumber(), (long unsigned) evnt->GetTrigTime(), (long unsigned) evnt->GetPayloadLen()); + + if (printraw) { + unsigned len = evnt->GetPayloadLen() / 4; + for (unsigned i = 0; i < len; ++i) { + printf(" %08x", (unsigned) evnt->GetPayload(i)); + if ((i == len - 1) || ((i % 8 == 0) && (i > 0))) + printf("\n"); + } + } + + if ((number > 0) && (printcnt >= number)) break; + } + + if (showrate) { + printf("\n"); + fflush(stdout); + } + + ref.Disconnect(); + + if (dostat) { + printf("Statistic: %ld events analyzed\n", printcnt); + } + + if (dominsz && mincnt >= 0) + printf("Event #0x%08x (-skip %ld) has minimal size %lu cnt %lu\n", (unsigned) mintrignr, mincnt, (long unsigned) minsz, (long unsigned) numminsz); + + if (domaxsz && maxcnt >= 0) + printf("Event #0x%08x (-skip %ld) has maximal size %lu cnt %lu\n", (unsigned) maxtrignr, maxcnt, (long unsigned) maxsz, (long unsigned) nummaxsz); + + if (dabc::CtrlCPressed()) break; + + } // ngain-- + + return 0; +} diff --git a/plugins/dogma/src/Factory.cxx b/plugins/dogma/src/Factory.cxx index 055614ce8..3a3cefc21 100644 --- a/plugins/dogma/src/Factory.cxx +++ b/plugins/dogma/src/Factory.cxx @@ -17,15 +17,27 @@ #include "dogma/TerminalModule.h" #include "dogma/UdpTransport.h" - +#include "dogma/Iterator.h" +#include "dogma/api.h" dabc::FactoryPlugin dogmafactory(new dogma::Factory("dogma")); +dabc::Reference dogma::Factory::CreateObject(const std::string &classname, const std::string &objname, dabc::Command cmd) +{ + if (classname == "dogma_iter") + return new dogma::RawIterator(objname); + + return dabc::Factory::CreateObject(classname, objname, cmd); +} + dabc::Module* dogma::Factory::CreateModule(const std::string &classname, const std::string &modulename, dabc::Command cmd) { if (classname == "dogma::TerminalModule") return new dogma::TerminalModule(modulename, cmd); + if (classname == "dogma::ReadoutModule") + return new dogma::ReadoutModule(modulename, cmd); + return dabc::Factory::CreateModule(classname, modulename, cmd); } diff --git a/plugins/dogma/src/UdpTransport.cxx b/plugins/dogma/src/UdpTransport.cxx index 67a6664c2..e0c282557 100644 --- a/plugins/dogma/src/UdpTransport.cxx +++ b/plugins/dogma/src/UdpTransport.cxx @@ -169,7 +169,7 @@ bool dogma::UdpAddon::ReadUdp() } auto tu = (DogmaTu *) tgt; - auto msgsize = tu->GetMessageSize(); // trb sender adds a 32 byte control trailer identical to event header + auto msgsize = tu->GetSize(); // trb sender adds a 32 byte control trailer identical to event header std::string errmsg; @@ -194,8 +194,8 @@ bool dogma::UdpAddon::ReadUdp() } if (fPrint) - DOUT0("Event addr: %lu type: %lu trignum; %lu, time: %lu paylod: %lu", - (long unsigned) tu->GetAddr(), (long unsigned) tu->GetTrigType(), (long unsigned) tu->GetTrigNumber(), (long unsigned) tu->GetTrigTime(), (long unsigned) tu->GetPayloadLen()); + DOUT0("Event addr: %lu type: 0x%x trignum; %lu, time: %lu paylod: %lu", + (long unsigned) tu->GetAddr(), (unsigned) tu->GetTrigType(), (long unsigned) tu->GetTrigNumber(), (long unsigned) tu->GetTrigTime(), (long unsigned) tu->GetPayloadLen()); fTotalRecvPacket++; fTotalRecvBytes += res; diff --git a/plugins/dogma/src/api.cxx b/plugins/dogma/src/api.cxx new file mode 100644 index 000000000..322634ff6 --- /dev/null +++ b/plugins/dogma/src/api.cxx @@ -0,0 +1,92 @@ +// $Id$ + +/************************************************************ + * The Data Acquisition Backbone Core (DABC) * + ************************************************************ + * Copyright (C) 2009 - * + * GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Planckstr. 1, 64291 Darmstadt, Germany * + * Contact: http://dabc.gsi.de * + ************************************************************ + * This software can be used under the GPL license * + * agreements as stated in LICENSE.txt file * + * which is part of the distribution. * + ************************************************************/ + +#include "dogma/api.h" + +dogma::ReadoutModule::ReadoutModule(const std::string &name, dabc::Command cmd) : + mbs::ReadoutModule(name, cmd), + fIter2("dogma_iter") +{ +} + +int dogma::ReadoutModule::AcceptBuffer(dabc::Buffer& buf) +{ + if (fIter2.Assign(buf)) + return dabc::cmd_true; + + return dabc::cmd_false; +} + +// ========================================================================= + + +dogma::ReadoutHandle dogma::ReadoutHandle::Connect(const std::string &src) +{ + std::string newurl = src; + + //if (((newurl.find(".hld") != std::string::npos) || (newurl.find(".HLD") != std::string::npos)) && + // (newurl.find("hld://") == std::string::npos)) + // newurl = std::string("hld://") + src; + + return DoConnect(newurl, "dogma::ReadoutModule"); +} + + +dogma::DogmaTu *dogma::ReadoutHandle::NextTu(double tmout, double maxage) +{ + if (null()) return nullptr; + + bool intime = GetObject()->GetEventInTime(maxage); + + // check that DOGMA event can be produced + // while dogma events can be read only from file, ignore maxage parameter here + if (intime && GetObject()->fIter2.NextEvent()) + return (dogma::DogmaTu *) GetObject()->fIter2.Event(); + + // this is a case, when hadaq event packed into MBS event + if (mbs::ReadoutHandle::NextEvent(tmout, maxage)) + return dogma::ReadoutHandle::GetTu(); + + // check again that DOGMA event can be produced + if (GetObject()->fIter2.NextEvent()) + return (dogma::DogmaTu *) GetObject()->fIter2.Event(); + + return nullptr; +} + +dogma::DogmaTu *dogma::ReadoutHandle::GetTu() +{ + if (null()) + return nullptr; + + auto direct = GetObject()->fIter2.Event(); + if (direct) + return (dogma::DogmaTu *) direct; + + mbs::EventHeader *mbsev = mbs::ReadoutHandle::GetEvent(); + if (!mbsev) + return nullptr; + + auto mbssub = mbsev->NextSubEvent(nullptr); + + if (mbssub && (mbssub->FullSize() == mbsev->SubEventsSize())) { + auto tu = (dogma::DogmaTu *) mbssub->RawData(); + + if (tu && (tu->GetSize() == mbssub->RawDataSize())) + return tu; + } + + return nullptr; +} diff --git a/plugins/hadaq/hldprint.cxx b/plugins/hadaq/hldprint.cxx index 3c7454ea1..5d23c4c62 100644 --- a/plugins/hadaq/hldprint.cxx +++ b/plugins/hadaq/hldprint.cxx @@ -1175,7 +1175,7 @@ int main(int argc, char* argv[]) while (nagain-- >= 0) { - ref = hadaq::ReadoutHandle::Connect(src.c_str()); + ref = hadaq::ReadoutHandle::Connect(src); if (ref.null()) return 1; diff --git a/plugins/hadaq/test/rawdump.xml b/plugins/hadaq/test/rawdump.xml index 21601b3ec..6c87eeed8 100644 --- a/plugins/hadaq/test/rawdump.xml +++ b/plugins/hadaq/test/rawdump.xml @@ -31,7 +31,7 @@ - + diff --git a/plugins/stream/app/astransport.xml b/plugins/stream/app/astransport.xml index b0772265c..a73f254c4 100644 --- a/plugins/stream/app/astransport.xml +++ b/plugins/stream/app/astransport.xml @@ -1,29 +1,29 @@ - + - - - - - - + + + + + + - + - + - + @@ -31,7 +31,7 @@ - +