diff --git a/etc/websocket-demo.conf b/etc/websocket-demo.conf new file mode 100644 index 000000000..00ce038fe --- /dev/null +++ b/etc/websocket-demo.conf @@ -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 + * @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 . + *********************************************************************************/ + +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" } + ) + } +); diff --git a/src/node.c b/src/node.c index acffd9f4a..21157a6a2 100644 --- a/src/node.c +++ b/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; }