YARP
Yet Another Robot Platform
 
Loading...
Searching...
No Matches
ThrottleDown.cpp
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2025-2025 Istituto Italiano di Tecnologia (IIT)
3 * SPDX-License-Identifier: BSD-3-Clause
4 */
5
6#include "ThrottleDown.h"
7
8#include <algorithm>
9#include <cmath>
10
12#include <yarp/os/LogStream.h>
13#include <yarp/os/Time.h>
14
15using namespace yarp::os;
16
17namespace {
19 "yarp.carrier.portmonitor.ThrottleDown",
23 nullptr)
24
25}//anonymous namespace
26
27
29{
30 // parse the user parameters
31 // get the value of the parameters
32 /* if (m_user_params.check("period")) {
33 //Float64 have issues related to the '.' character.
34 //Even replacing the separator character in getParamsFromCommandLine() from ` ` to `=`
35 //0.02 becomes 0.2, probabibly located in protocol .cpp
36 m_period = m_user_params.find("period").asFloat64();
37 yCDebug(PM_THRD) << "period set:" << m_period;
38 }*/
39 if (options.check("period_ms")) {
40 m_period = options.find("period_ms").asInt32();
41 m_period /= 1000.0;
42 yCDebug(PM_THRD) << "period set:" << m_period;
43 }
44
45 m_last_time= yarp::os::Time::now();
46
47 return true;
48}
49
51{
52}
53
55{
56 return false;
57}
58
60{
61 return false;
62}
63
65{
67 if (cur_time - m_last_time > m_period)
68 {
69 m_last_time = cur_time;
70 return true;
71 }
72 return false;
73}
74
76{
77 return thing;
78}
bool accept(yarp::os::Things &thing) override
This will be called when the data reach the portmonitor object.
yarp::os::Things & update(yarp::os::Things &thing) override
After data get accpeted in the accept() callback, an instance of that is given to the update function...
bool setparam(const yarp::os::Property &params) override
This will be called when the portmonitor carrier parameters are set via YARP admin port.
void destroy() override
This will be called when the portmonitor object destroyes.
bool create(const yarp::os::Property &options) override
This will be called when the dll is properly loaded by the portmonitor carrier.
bool getparam(yarp::os::Property &params) override
This will be called when the portmonitor carrier parameters are requested via YARP admin port.
A mini-server for performing network communication in the background.
static LogCallback printCallback()
Get current print callback.
Definition Log.cpp:892
static LogType minimumPrintLevel()
Get current minimum print level.
Definition Log.cpp:852
@ LogTypeReserved
Definition Log.h:98
A class for storing options and configuration information.
Definition Property.h:33
Value & find(const std::string &key) const override
Gets a value corresponding to a given keyword.
bool check(const std::string &key) const override
Check if there exists a property of the given name.
Base class for generic things.
Definition Things.h:18
virtual std::int32_t asInt32() const
Get 32-bit integer value.
Definition Value.cpp:210
#define yCDebug(component,...)
#define YARP_LOG_COMPONENT(name,...)
double now()
Return the current time in seconds, relative to an arbitrary starting point.
Definition Time.cpp:121
An interface to the operating system, including Port based communication.
Definition OSTestMsg.cpp:13