ChimeraTK-ApplicationCore 04.06.00
Loading...
Searching...
No Matches
DataLossCounter.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Deutsches Elektronen-Synchrotron DESY, MSK, ChimeraTK Project <chimeratk-support@desy.de>
2// SPDX-License-Identifier: LGPL-3.0-or-later
3#pragma once
4
5#include "Application.h"
6#include "ApplicationModule.h"
7#include "ScalarAccessor.h"
8#include "VariableGroup.h"
9
10#include <ChimeraTK/SupportedUserTypes.h>
11
12#include <map>
13
14namespace ChimeraTK {
15
21 template<typename TRIGGERTYPE = int32_t>
23 DataLossCounter(ModuleGroup* owner, const std::string& name, const std::string& description,
24 const std::string& pathToTrigger, const std::unordered_set<std::string>& tags = {})
25 : ApplicationModule(owner, name, description, tags), directTrigger(this, pathToTrigger, "", "Trigger Input"),
27
29
31
36
37 // This is for backwards compatibility!
39
40 ScalarOutput<uint64_t> lostDataInLastTrigger{this, "lostDataInLastTrigger", "",
41 "Number of data transfers during "
42 "the last trigger which resulted in data loss."};
43 ScalarOutput<uint64_t> triggersWithDataLoss{this, "triggersWithDataLoss", "",
44 "Number of trigger periods during "
45 "which at least on data transfer resulted in data loss."};
46
47 void mainLoop() override {
48 while(true) {
49 trigger.read();
50 uint64_t counter = Application::getAndResetDataLossCounter();
51 lostDataInLastTrigger = counter;
52 if(counter > 0) ++triggersWithDataLoss;
53 writeAll();
54 }
55 }
56 };
57
58} // namespace ChimeraTK
static size_t getAndResetDataLossCounter()
Return the current value of the data loss counter and (atomically) reset it to 0.
void writeAll(bool includeReturnChannels=false)
Just call write() on all writable variables in the group.
Definition Module.cc:157
Convenience class for input scalar accessors with UpdateMode::push.
VariableGroup()=default
Default constructor: Allows late initialisation of VariableGroups (e.g.
InvalidityTracer application module.
Module which gathers statistics on data loss inside the application.
ScalarPushInput< TRIGGERTYPE > directTrigger
ScalarPushInput< TRIGGERTYPE > & trigger
void mainLoop() override
To be implemented by the user: function called in a separate thread executing the main loop of the mo...
ScalarOutput< uint64_t > lostDataInLastTrigger
DataLossCounter(ModuleGroup *owner, const std::string &name, const std::string &description, const std::string &pathToTrigger, const std::unordered_set< std::string > &tags={})
ScalarOutput< uint64_t > triggersWithDataLoss
ChimeraTK::DataLossCounter::TriggerGroup_compat triggerGroup_compat
Convenience class for output scalar accessors (always UpdateMode::push)