mirror of
https://git.rwth-aachen.de/acs/public/villas/node/
synced 2025-03-09 00:00:00 +01:00
hooks: add functions to set rate/ratio in limit_rate/decimate hooks
This commit is contained in:
parent
667a62c874
commit
6b68bc0f00
4 changed files with 90 additions and 0 deletions
36
include/villas/hooks/decimate.h
Normal file
36
include/villas/hooks/decimate.h
Normal file
|
@ -0,0 +1,36 @@
|
|||
/** Decimate hook.
|
||||
*
|
||||
* @author Steffen Vogel <stvogel@eonerc.rwth-aachen.de>
|
||||
* @copyright 2014-2019, Institute for Automation of Complex Power Systems, EONERC
|
||||
* @license GNU General Public License (version 3)
|
||||
*
|
||||
* VILLASnode
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*********************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
/** @addtogroup hooks Hook functions
|
||||
* @{
|
||||
*/
|
||||
|
||||
/* Forward declarations */
|
||||
struct hook;
|
||||
|
||||
int decimate_set_ratio(struct hook *h, int ratio);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
36
include/villas/hooks/limit_rate.h
Normal file
36
include/villas/hooks/limit_rate.h
Normal file
|
@ -0,0 +1,36 @@
|
|||
/** Rate-limiting hook.
|
||||
*
|
||||
* @author Steffen Vogel <stvogel@eonerc.rwth-aachen.de>
|
||||
* @copyright 2014-2019, Institute for Automation of Complex Power Systems, EONERC
|
||||
* @license GNU General Public License (version 3)
|
||||
*
|
||||
* VILLASnode
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*********************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
/** @addtogroup hooks Hook functions
|
||||
* @{
|
||||
*/
|
||||
|
||||
/* Forward declarations */
|
||||
struct hook;
|
||||
|
||||
int limit_rate_set_rate(struct hook *h, double rate);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
|
@ -32,6 +32,15 @@ struct decimate {
|
|||
unsigned counter;
|
||||
};
|
||||
|
||||
int decimate_set_ratio(struct hook *h, int ratio)
|
||||
{
|
||||
struct decimate *p = (struct decimate *) h->_vd;
|
||||
|
||||
p->ratio = ratio;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int decimate_init(struct hook *h)
|
||||
{
|
||||
struct decimate *p = (struct decimate *) h->_vd;
|
||||
|
|
|
@ -42,6 +42,15 @@ struct limit_rate {
|
|||
struct timespec last;
|
||||
};
|
||||
|
||||
int limit_rate_set_rate(struct hook *h, double rate)
|
||||
{
|
||||
struct limit_rate *p = (struct limit_rate *) h->_vd;
|
||||
|
||||
p->deadtime = 1.0 / rate;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int limit_rate_init(struct hook *h)
|
||||
{
|
||||
struct limit_rate *p = (struct limit_rate *) h->_vd;
|
||||
|
|
Loading…
Add table
Reference in a new issue