2023-09-04 12:21:37 +02: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
|
|
|
*
|
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
|
2020-01-21 14:20:25 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2022-04-01 14:55:08 +02:00
|
|
|
#include <villas/node.hpp>
|
2023-09-07 11:46:39 +02:00
|
|
|
#include <villas/node/config.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:
|
2023-09-07 11:46:39 +02:00
|
|
|
// Place any configuration and per-node state here
|
2020-01-21 14:20:25 +01:00
|
|
|
|
2023-09-07 11:46:39 +02:00
|
|
|
// Settings
|
|
|
|
int setting1;
|
2022-04-01 14:55:08 +02:00
|
|
|
|
2023-09-07 11:46:39 +02:00
|
|
|
std::string setting2;
|
2022-04-01 14:55:08 +02:00
|
|
|
|
2023-09-07 11:46:39 +02:00
|
|
|
// States
|
|
|
|
int state1;
|
|
|
|
struct timespec start_time;
|
2020-01-21 14:20:25 +01:00
|
|
|
|
2023-09-07 11:46:39 +02:00
|
|
|
virtual int _read(struct Sample *smps[], unsigned cnt);
|
2020-01-21 14:20:25 +01:00
|
|
|
|
2023-09-07 11:46:39 +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-09-07 11:46:39 +02:00
|
|
|
ExampleNode(const uuid_t &id = {}, const std::string &name = "");
|
2020-01-21 14:20:25 +01:00
|
|
|
|
2023-09-07 11:46:39 +02:00
|
|
|
/* All of the following virtual-declared functions are optional.
|
2024-02-29 21:47:13 +01:00
|
|
|
* Have a look at node.hpp/node.cpp for the default behaviour.
|
|
|
|
*/
|
2020-01-21 14:20:25 +01:00
|
|
|
|
2023-09-07 11:46:39 +02:00
|
|
|
virtual ~ExampleNode();
|
2020-01-21 14:20:25 +01:00
|
|
|
|
2023-09-07 11:46:39 +02:00
|
|
|
virtual int prepare();
|
2020-01-21 14:20:25 +01:00
|
|
|
|
2023-09-07 11:46:39 +02:00
|
|
|
virtual int parse(json_t *json);
|
2020-01-21 14:20:25 +01:00
|
|
|
|
2023-09-07 11:46:39 +02:00
|
|
|
virtual int check();
|
2020-01-21 14:20:25 +01:00
|
|
|
|
2023-09-07 11:46:39 +02:00
|
|
|
virtual int start();
|
2020-01-21 14:20:25 +01:00
|
|
|
|
2024-04-09 14:19:01 +02:00
|
|
|
// virtual int stop();
|
2020-01-21 14:20:25 +01:00
|
|
|
|
2024-04-09 14:19:01 +02:00
|
|
|
// virtual int pause();
|
2020-01-21 14:26:56 +01:00
|
|
|
|
2024-04-09 14:19:01 +02:00
|
|
|
// virtual int resume();
|
2020-01-21 14:26:56 +01:00
|
|
|
|
2024-04-09 14:19:01 +02:00
|
|
|
// virtual int restart();
|
2020-01-21 14:20:25 +01:00
|
|
|
|
2024-04-09 14:19:01 +02:00
|
|
|
// virtual int reverse();
|
2020-01-21 14:20:25 +01:00
|
|
|
|
2024-04-09 14:19:01 +02:00
|
|
|
// virtual std::vector<int> getPollFDs();
|
2020-01-21 14:20:25 +01:00
|
|
|
|
2024-04-09 14:19:01 +02:00
|
|
|
// virtual std::vector<int> getNetemFDs();
|
2022-04-01 14:55:08 +02:00
|
|
|
|
2024-04-09 14:19:01 +02:00
|
|
|
// virtual struct villas::node::memory::Type *getMemoryType();
|
2022-04-01 14:55:08 +02:00
|
|
|
|
2023-09-07 11:46:39 +02:00
|
|
|
virtual const std::string &getDetails();
|
2022-04-01 14:55:08 +02:00
|
|
|
};
|
2020-01-21 14:20:25 +01:00
|
|
|
|
2023-08-28 09:34:02 +02:00
|
|
|
} // namespace node
|
|
|
|
} // namespace villas
|