2017-07-06 23:48:19 +02:00
|
|
|
/* Node type: Node-type for testing Round-trip Time.
|
|
|
|
*
|
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
|
2017-07-06 23:48:19 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2021-05-10 00:12:30 +02:00
|
|
|
#include <villas/format.hpp>
|
2023-09-07 11:46:39 +02:00
|
|
|
#include <villas/list.hpp>
|
2024-04-09 23:39:13 +02:00
|
|
|
#include <villas/node.hpp>
|
2020-03-04 13:06:28 +01:00
|
|
|
#include <villas/task.hpp>
|
2017-07-06 23:48:19 +02:00
|
|
|
|
2021-08-10 10:12:48 -04:00
|
|
|
namespace villas {
|
|
|
|
namespace node {
|
|
|
|
|
2017-09-16 15:34:16 +02:00
|
|
|
// Forward declarations
|
2021-08-10 10:12:48 -04:00
|
|
|
struct Sample;
|
|
|
|
|
2024-04-09 23:39:13 +02:00
|
|
|
class TestRTT : public Node {
|
2017-09-16 15:34:16 +02:00
|
|
|
|
2024-04-09 23:39:13 +02:00
|
|
|
protected:
|
|
|
|
class Case {
|
|
|
|
friend TestRTT;
|
2017-09-16 15:34:16 +02:00
|
|
|
|
2024-04-09 23:39:13 +02:00
|
|
|
protected:
|
|
|
|
TestRTT *node;
|
2021-02-16 14:15:14 +01:00
|
|
|
|
2024-04-09 23:39:13 +02:00
|
|
|
int id;
|
|
|
|
double rate;
|
|
|
|
unsigned values;
|
|
|
|
unsigned limit; // The number of samples we take per test.
|
|
|
|
|
|
|
|
std::string filename;
|
|
|
|
std::string filename_formatted;
|
|
|
|
|
|
|
|
public:
|
|
|
|
Case(TestRTT *n, int id, int rate, int values, int limit,
|
2024-04-10 09:01:27 +02:00
|
|
|
const std::string & filename)
|
2024-04-09 23:39:13 +02:00
|
|
|
: node(n), id(id), rate(rate), values(values), limit(limit),
|
|
|
|
filename(filename){};
|
2017-07-06 23:48:19 +02:00
|
|
|
|
2024-04-09 23:39:13 +02:00
|
|
|
int start();
|
|
|
|
int stop();
|
|
|
|
};
|
|
|
|
|
|
|
|
Task task; // The periodic task for test_rtt_read()
|
|
|
|
Format::Ptr formatter; // The format of the output file
|
2023-09-07 11:46:39 +02:00
|
|
|
FILE *stream;
|
2017-09-16 15:34:16 +02:00
|
|
|
|
2024-04-09 11:17:49 +02:00
|
|
|
double cooldown; // Number of seconds to wait between tests.
|
2017-09-16 15:34:16 +02:00
|
|
|
|
2024-05-23 18:59:43 +02:00
|
|
|
unsigned counter;
|
2017-07-06 23:48:19 +02:00
|
|
|
|
2024-04-09 23:39:13 +02:00
|
|
|
std::list<Case> cases; // List of test cases
|
|
|
|
std::list<Case>::iterator current_case;
|
2017-07-06 23:48:19 +02:00
|
|
|
|
2024-04-09 23:39:13 +02:00
|
|
|
std::string output; // The directory where we place the results.
|
|
|
|
std::string prefix; // An optional prefix in the filename.
|
2017-07-06 23:48:19 +02:00
|
|
|
|
2024-04-09 23:39:13 +02:00
|
|
|
virtual int _read(struct Sample *smps[], unsigned cnt);
|
2021-08-10 10:12:48 -04:00
|
|
|
|
2024-04-09 23:39:13 +02:00
|
|
|
virtual int _write(struct Sample *smps[], unsigned cnt);
|
2021-08-10 10:12:48 -04:00
|
|
|
|
2024-04-09 23:39:13 +02:00
|
|
|
public:
|
|
|
|
TestRTT(const uuid_t &id = {}, const std::string &name = "")
|
2024-04-10 09:01:27 +02:00
|
|
|
: Node(id, name), task(CLOCK_MONOTONIC), formatter(nullptr), stream(nullptr), cooldown(0), counter(-1) {}
|
2021-08-10 10:12:48 -04:00
|
|
|
|
2024-04-09 23:39:13 +02:00
|
|
|
virtual ~TestRTT(){};
|
2021-08-10 10:12:48 -04:00
|
|
|
|
2024-04-09 23:39:13 +02:00
|
|
|
virtual int prepare();
|
2017-07-06 23:48:19 +02:00
|
|
|
|
2024-04-09 23:39:13 +02:00
|
|
|
virtual int parse(json_t *json);
|
2017-07-06 23:48:19 +02:00
|
|
|
|
2024-04-09 23:39:13 +02:00
|
|
|
virtual int start();
|
2017-07-06 23:48:19 +02:00
|
|
|
|
2024-04-09 23:39:13 +02:00
|
|
|
virtual int stop();
|
2017-07-06 23:48:19 +02:00
|
|
|
|
2024-04-09 23:39:13 +02:00
|
|
|
virtual std::vector<int> getPollFDs();
|
2017-07-06 23:48:19 +02:00
|
|
|
|
2024-04-09 23:39:13 +02:00
|
|
|
virtual const std::string &getDetails();
|
|
|
|
};
|
2017-07-06 23:48:19 +02:00
|
|
|
|
2023-08-28 09:34:02 +02:00
|
|
|
} // namespace node
|
|
|
|
} // namespace villas
|