Commit f384aa77 authored by Michael Ott's avatar Michael Ott

Add getMsgRate() functions to SensorGroupInterface and OperatorInterface

parent d5e7f10c
......@@ -226,7 +226,15 @@ public:
*/
virtual void clearUnits() = 0;
/**
/**
* @brief Returns the number of messages this operator will
* generate per second
*
* This method must be implemented in derived classes.
*/
virtual float getMsgRate() = 0;
/**
* @brief Performs an on-demand compute task
*
* Unlike the protected computeAsync and compute methods, computeOnDemand allows to interactively
......
......@@ -201,10 +201,23 @@ public:
virtual void releaseUnits() override {}
/**
* @brief Clears all the units contained in this operator
*/
* @brief Clears all the units contained in this operator
*/
virtual void clearUnits() override { _units.clear(); _baseUnits.clear(); _unitID = -1; }
/**
* @brief Returns the number of messages this operator will
* generate per second
*
* @return Messages/s
*/
virtual float getMsgRate() override {
float msgRate = 0;
for (const auto &u : _units) {
msgRate += (float)u->getBaseOutputs().size() * (1000.0f / (float)_interval) / (float)_minValue;
}
return msgRate;
}
/**
* @brief Initializes this operator
......
......@@ -315,22 +315,13 @@ void MQTTPusher::computeMsgRate() {
bool dynWarning = false;
for (auto &p : _plugins) {
for (const auto &g : p.configurator->getSensorGroups()) {
for(const auto &s : g->acquireSensors()) {
if (s->getSubsampling() > 0)
msgRate += (1000.0f / (float) g->getInterval()) / ((float) g->getMinValues() * s->getSubsampling());
}
g->releaseSensors();
msgRate += g->getMsgRate();
}
}
for (auto &p : _operatorPlugins)
for (const auto &op : p.configurator->getOperators()) {
if (op->getStreaming() && !op->getDynamic()) {
for (const auto &u : op->getUnits())
for(const auto &s : u->getBaseOutputs()) {
if (s->getSubsampling() > 0)
msgRate += (1000.0f / (float) op->getInterval()) / ((float) op->getMinValues() * s->getSubsampling());
}
op->releaseUnits();
msgRate += op->getMsgRate();
} else if (op->getDynamic())
dynWarning = true;
}
......
......@@ -192,6 +192,16 @@ class SensorGroupInterface {
virtual void releaseSensors() { /* do nothing in base implementation */
}
/**
* @brief Compute message rate of this group.
*
* @details Computes the message rate based on number of message, interval
* and minValues
*
* @return The message rate in messages/s.
*/
virtual float getMsgRate() { return (float)_baseSensors.size() * (1000.0f / (float)_interval) / (float)_minValues; }
/**
* @brief Print interface configuration.
*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment