Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement dogmaprint #10

Merged
merged 14 commits into from
Mar 15, 2024
100 changes: 100 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions .clang-tidy
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
WarningsAsErrors: '*'
8 changes: 8 additions & 0 deletions plugins/dogma/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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})
Expand All @@ -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
Expand Down
19 changes: 18 additions & 1 deletion plugins/dogma/Readme.md
Original file line number Diff line number Diff line change
@@ -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

Expand Down
1 change: 1 addition & 0 deletions plugins/dogma/app/dogma.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<dabc version="2">
<Context name="Main" port="12345">
<Run>
<lib value="libDabcMbs.so"/>
<lib value="libDabcDogma.so"/>
<logfile value="master.log"/>
<loglimit value="1000000"/>
Expand Down
3 changes: 2 additions & 1 deletion plugins/dogma/app/print.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<dabc version="2">
<Context name="print">
<Run>
<lib value="libDabcMbs.so"/>
<lib value="libDabcDogma.so"/>
<logfile value="Print.log"/>
<loglimit value="1000000"/>
Expand All @@ -30,7 +31,7 @@
<OutputPort name="Output2" url="bin://out2.bin"/>
<OutputPort name="Output3" url="bin://out3.bin"/>
<OutputPort name="Output4" url="bin://out4.bin"/>
<Parameter name="DataRate" width="5" prec="3" low="0" up="50" debug="0"/>
<DataRate width="5" prec="3" low="0" up="50" debug="0"/>
</Module>
</Context>
</dabc>
34 changes: 34 additions & 0 deletions plugins/dogma/app/readout.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<!-- This is example how raw data from HADAQ input can be dump in binary DABC file -->

<?xml version="1.0"?>
<dabc version="2">
<Context name="dogma">
<Run>
<lib value="libDabcMbs.so"/>
<lib value="libDabcDogma.so"/>
<logfile value="Readout.log"/>
<loglimit value="1000000"/>
</Run>

<MemoryPool name="Pool">
<BufferSize value="400000"/>
<NumBuffers value="50"/>
</MemoryPool>

<Module name="Readout" class="dabc::MultiplexerModule">
<NumInputs value="1"/>
<NumOutputs value="1"/>
<DataRateName value="DataRate"/>

<InputPort name="Input0" url="dogma://host:60678" queue="10" urlopt="udpbuf=400000&mtu=65507&flush=0.1&maxloop=50"/>

<!-- this is stream server for online monitoring, normally always on -->
<OutputPort name="Output0" url="mbs://Stream:6002?iter=dogma_iter&subid=0x1f"/>

<!-- this is DABC binary file, not necessary for the moment -->
<OutputPort name="Output1" url="bin://readout.bin"/>

<DataRate width="5" prec="3" low="0" up="50" debug="1"/>
</Module>
</Context>
</dabc>
2 changes: 2 additions & 0 deletions plugins/dogma/dogma/Factory.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
89 changes: 89 additions & 0 deletions plugins/dogma/dogma/Iterator.h
Original file line number Diff line number Diff line change
@@ -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
69 changes: 69 additions & 0 deletions plugins/dogma/dogma/api.h
Original file line number Diff line number Diff line change
@@ -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
Loading
Loading