2020-01-21 14:20:25 +01:00
|
|
|
/** An example get started with new implementations of new node-types
|
2022-04-01 14:55:08 +02:00
|
|
|
*
|
|
|
|
* This example does not do any particulary useful.
|
|
|
|
* It is just a skeleton to get you started with new node-types.
|
2020-01-21 14:20:25 +01:00
|
|
|
*
|
|
|
|
* @file
|
2022-12-14 17:41:58 +01:00
|
|
|
* @author Steffen Vogel <post@steffenvogel.de>
|
2022-03-15 09:28:57 -04:00
|
|
|
* @copyright 2014-2022, Institute for Automation of Complex Power Systems, EONERC
|
2022-07-04 18:20:03 +02:00
|
|
|
* @license Apache 2.0
|
2020-01-21 14:20:25 +01:00
|
|
|
*********************************************************************************/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2021-08-10 10:12:48 -04:00
|
|
|
#include <villas/node/config.hpp>
|
2022-04-01 14:55:08 +02:00
|
|
|
#include <villas/node.hpp>
|
2021-08-10 10:12:48 -04:00
|
|
|
#include <villas/timing.hpp>
|
|
|
|
|
|
|
|
namespace villas {
|
|
|
|
namespace node {
|
2020-01-21 14:20:25 +01:00
|
|
|
|
2021-06-21 16:11:42 -04:00
|
|
|
/* Forward declarations */
|
2022-04-01 14:55:08 +02:00
|
|
|
struct Sample;
|
2021-06-21 16:11:42 -04:00
|
|
|
|
2022-04-01 14:55:08 +02:00
|
|
|
class ExampleNode : public Node {
|
2020-01-21 14:20:25 +01:00
|
|
|
|
2022-04-01 14:55:08 +02:00
|
|
|
protected:
|
|
|
|
/* Place any configuration and per-node state here */
|
2020-01-21 14:20:25 +01:00
|
|
|
|
2022-04-01 14:55:08 +02:00
|
|
|
/* Settings */
|
|
|
|
int setting1;
|
|
|
|
|
|
|
|
std::string setting2;
|
|
|
|
|
|
|
|
/* States */
|
|
|
|
int state1;
|
|
|
|
struct timespec start_time;
|
2020-01-21 14:20:25 +01:00
|
|
|
|
2022-04-01 14:55:08 +02:00
|
|
|
virtual
|
|
|
|
int _read(struct Sample *smps[], unsigned cnt);
|
2020-01-21 14:20:25 +01:00
|
|
|
|
2022-04-01 14:55:08 +02:00
|
|
|
virtual
|
|
|
|
int _write(struct Sample *smps[], unsigned cnt);
|
2020-01-21 14:20:25 +01:00
|
|
|
|
2022-04-01 14:55:08 +02:00
|
|
|
public:
|
2023-06-30 10:51:01 +02:00
|
|
|
ExampleNode(const uuid_t &id = {}, const std::string &name = "");
|
2020-01-21 14:20:25 +01:00
|
|
|
|
2022-04-01 14:55:08 +02:00
|
|
|
/* All of the following virtual-declared functions are optional.
|
|
|
|
* Have a look at node.hpp/node.cpp for the default behaviour.
|
|
|
|
*/
|
2020-01-21 14:20:25 +01:00
|
|
|
|
2022-04-01 14:55:08 +02:00
|
|
|
virtual
|
|
|
|
~ExampleNode();
|
2020-01-21 14:20:25 +01:00
|
|
|
|
2022-04-01 14:55:08 +02:00
|
|
|
virtual
|
|
|
|
int prepare();
|
2020-01-21 14:20:25 +01:00
|
|
|
|
2022-04-01 14:55:08 +02:00
|
|
|
virtual
|
2023-06-30 10:51:01 +02:00
|
|
|
int parse(json_t *json);
|
2020-01-21 14:20:25 +01:00
|
|
|
|
2022-04-01 14:55:08 +02:00
|
|
|
/** Validate node configuration. */
|
|
|
|
virtual
|
|
|
|
int check();
|
2020-01-21 14:20:25 +01:00
|
|
|
|
2022-04-01 14:55:08 +02:00
|
|
|
virtual
|
|
|
|
int start();
|
2020-01-21 14:20:25 +01:00
|
|
|
|
2022-04-01 14:55:08 +02:00
|
|
|
// virtual
|
|
|
|
// int stop();
|
2020-01-21 14:20:25 +01:00
|
|
|
|
2022-04-01 14:55:08 +02:00
|
|
|
// virtual
|
|
|
|
// int pause();
|
2020-01-21 14:26:56 +01:00
|
|
|
|
2022-04-01 14:55:08 +02:00
|
|
|
// virtual
|
|
|
|
// int resume();
|
2020-01-21 14:26:56 +01:00
|
|
|
|
2022-04-01 14:55:08 +02:00
|
|
|
// virtual
|
|
|
|
// int restart();
|
2020-01-21 14:20:25 +01:00
|
|
|
|
2022-04-01 14:55:08 +02:00
|
|
|
// virtual
|
|
|
|
// int reverse();
|
2020-01-21 14:20:25 +01:00
|
|
|
|
2022-04-01 14:55:08 +02:00
|
|
|
// virtual
|
|
|
|
// std::vector<int> getPollFDs();
|
2020-01-21 14:20:25 +01:00
|
|
|
|
2022-04-01 14:55:08 +02:00
|
|
|
// virtual
|
|
|
|
// std::vector<int> getNetemFDs();
|
|
|
|
|
|
|
|
// virtual
|
|
|
|
// struct villas::node::memory::Type * getMemoryType();
|
|
|
|
|
|
|
|
virtual
|
|
|
|
const std::string & getDetails();
|
|
|
|
};
|
2020-01-21 14:20:25 +01:00
|
|
|
|
|
|
|
|
2023-08-28 09:34:02 +02:00
|
|
|
} // namespace node
|
|
|
|
} // namespace villas
|