mirror of
https://git.rwth-aachen.de/acs/public/villas/node/
synced 2025-03-09 00:00:00 +01:00
node: fix high cpu usage
This commit is contained in:
parent
cc02829def
commit
02e03a806e
2 changed files with 75 additions and 7 deletions
65
etc/websocket-demo.conf
Normal file
65
etc/websocket-demo.conf
Normal file
|
@ -0,0 +1,65 @@
|
|||
/** Example configuration file for VILLASnode.
|
||||
*
|
||||
* The syntax of this file is similar to JSON.
|
||||
* A detailed description of the format can be found here:
|
||||
* http://www.hyperrealm.com/libconfig/libconfig_manual.html#Configuration-Files
|
||||
*
|
||||
* @author Steffen Vogel <stvogel@eonerc.rwth-aachen.de>
|
||||
* @copyright 2017, 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/>.
|
||||
*********************************************************************************/
|
||||
|
||||
stats = 1;
|
||||
|
||||
nodes = {
|
||||
sig_1 = {
|
||||
type = "signal",
|
||||
|
||||
signal = "mixed",
|
||||
values = 4,
|
||||
rate = 50
|
||||
},
|
||||
ws_1 = {
|
||||
type = "websocket",
|
||||
description = "Demo Channel",
|
||||
vectorize = 50,
|
||||
source = {
|
||||
simulator = "OP5600",
|
||||
location = "ACS lab"
|
||||
},
|
||||
series = (
|
||||
{ label = "Random walk", unit = "V" },
|
||||
{ label = "Sine", unit = "A" },
|
||||
{ label = "Rect", unit = "Var"},
|
||||
{ label = "Ramp", unit = "°C" }
|
||||
)
|
||||
}
|
||||
};
|
||||
|
||||
############ List of paths ############
|
||||
|
||||
paths = (
|
||||
{
|
||||
in = "sig_1",
|
||||
out = "ws_1",
|
||||
reverse = false
|
||||
hooks = (
|
||||
{ type = "stats" }
|
||||
)
|
||||
}
|
||||
);
|
17
src/node.c
17
src/node.c
|
@ -132,12 +132,13 @@ int main(int argc, char *argv[])
|
|||
if (sn.stats > 0)
|
||||
stats_print_header(STATS_FORMAT_HUMAN);
|
||||
|
||||
struct timespec now, last = time_now();
|
||||
|
||||
/* Run! Until signal handler is invoked */
|
||||
while (1) {
|
||||
now = time_now();
|
||||
if (sn.stats > 0 && time_delta(&last, &now) > sn.stats) {
|
||||
if (sn.stats > 0) {
|
||||
int tfd = timerfd_create_rate(1.0 / sn.stats);
|
||||
|
||||
for (;;) {
|
||||
timerfd_wait(tfd);
|
||||
|
||||
for (size_t i = 0; i < list_length(&sn.paths); i++) {
|
||||
struct path *p = list_at(&sn.paths, i);
|
||||
|
||||
|
@ -150,10 +151,12 @@ int main(int argc, char *argv[])
|
|||
hook_periodic(h);
|
||||
}
|
||||
}
|
||||
|
||||
last = time_now();
|
||||
}
|
||||
}
|
||||
else {
|
||||
for (;;)
|
||||
pause();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue