2023-09-04 12:21:37 +02:00
|
|
|
/* Hook list functions.
|
2019-03-16 10:04:23 +01:00
|
|
|
*
|
|
|
|
* This file includes some examples.
|
|
|
|
*
|
2022-03-15 09:18:01 -04:00
|
|
|
* Author: Steffen Vogel <post@steffenvogel.de>
|
2022-03-15 09:28:57 -04:00
|
|
|
* SPDX-FileCopyrightText: 2014-2023 Institute for Automation of Complex Power Systems, RWTH Aachen University
|
2022-07-04 18:20:03 +02:00
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
|
|
*/
|
2019-03-16 10:04:23 +01:00
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <jansson.h>
|
|
|
|
|
2021-08-10 10:12:48 -04:00
|
|
|
#include <villas/hook.hpp>
|
2019-03-16 10:04:23 +01:00
|
|
|
|
2021-08-10 10:12:48 -04:00
|
|
|
namespace villas {
|
|
|
|
namespace node {
|
2019-03-16 10:04:23 +01:00
|
|
|
|
2021-08-10 10:12:48 -04:00
|
|
|
// Forward declarations
|
|
|
|
class Node;
|
|
|
|
class Path;
|
|
|
|
struct Sample;
|
2019-03-16 10:04:23 +01:00
|
|
|
|
2021-08-10 10:12:48 -04:00
|
|
|
class HookList : public std::list<Hook::Ptr> {
|
2021-07-06 18:33:33 +02:00
|
|
|
|
2021-08-10 10:12:48 -04:00
|
|
|
public:
|
2023-09-07 11:46:39 +02:00
|
|
|
HookList() {}
|
2019-03-16 10:04:23 +01:00
|
|
|
|
2023-09-07 11:46:39 +02:00
|
|
|
/* Parses an object of hooks
|
2024-02-29 21:47:13 +01:00
|
|
|
*
|
|
|
|
* Example:
|
|
|
|
*
|
|
|
|
* {
|
|
|
|
* stats = {
|
|
|
|
* output = "stdout"
|
|
|
|
* },
|
|
|
|
* skip_first = {
|
|
|
|
* seconds = 10
|
|
|
|
* },
|
|
|
|
* hooks = [ "print" ]
|
|
|
|
* }
|
|
|
|
*/
|
2023-09-07 11:46:39 +02:00
|
|
|
void parse(json_t *json, int mask, Path *p, Node *n);
|
2019-03-16 10:04:23 +01:00
|
|
|
|
2023-09-07 11:46:39 +02:00
|
|
|
void check();
|
2019-03-16 10:04:23 +01:00
|
|
|
|
2023-09-07 11:46:39 +02:00
|
|
|
void prepare(SignalList::Ptr sigs, int mask, Path *p, Node *n);
|
2019-03-16 10:04:23 +01:00
|
|
|
|
2023-09-07 11:46:39 +02:00
|
|
|
int process(struct Sample *smps[], unsigned cnt);
|
|
|
|
void periodic();
|
|
|
|
void start();
|
|
|
|
void stop();
|
2019-03-16 10:04:23 +01:00
|
|
|
|
2023-09-07 11:46:39 +02:00
|
|
|
void dump(villas::Logger logger, std::string subject) const;
|
2019-03-16 10:04:23 +01:00
|
|
|
|
2023-09-07 11:46:39 +02:00
|
|
|
SignalList::Ptr getSignals() const;
|
2019-03-16 10:04:23 +01:00
|
|
|
|
2023-09-07 11:46:39 +02:00
|
|
|
// Get the maximum number of signals which is used by any of the hooks in the list.
|
|
|
|
unsigned getSignalsMaxCount() const;
|
2020-08-25 20:24:18 +02:00
|
|
|
|
2023-09-07 11:46:39 +02:00
|
|
|
json_t *toJson() const;
|
2021-08-10 10:12:48 -04:00
|
|
|
};
|
2021-07-01 22:26:44 +02:00
|
|
|
|
2023-08-28 09:34:02 +02:00
|
|
|
} // namespace node
|
|
|
|
} // namespace villas
|