2019-06-05 18:59:45 +02:00
|
|
|
/** Node-type for exec node-types.
|
|
|
|
*
|
|
|
|
* @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
|
2019-06-05 18:59:45 +02:00
|
|
|
*********************************************************************************/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2021-08-10 10:12:48 -04:00
|
|
|
#include <villas/node.hpp>
|
2019-06-05 18:59:45 +02:00
|
|
|
#include <villas/popen.hpp>
|
2021-05-10 00:12:30 +02:00
|
|
|
#include <villas/format.hpp>
|
2019-06-05 18:59:45 +02:00
|
|
|
|
2021-08-10 10:12:48 -04:00
|
|
|
namespace villas {
|
|
|
|
namespace node {
|
|
|
|
|
2019-06-05 18:59:45 +02:00
|
|
|
/* Forward declarations */
|
2021-08-10 10:12:48 -04:00
|
|
|
struct Sample;
|
|
|
|
|
|
|
|
class ExecNode : public Node {
|
2019-06-05 18:59:45 +02:00
|
|
|
|
2021-08-10 10:12:48 -04:00
|
|
|
protected:
|
2019-06-05 18:59:45 +02:00
|
|
|
std::unique_ptr<villas::utils::Popen> proc;
|
2021-08-10 10:12:48 -04:00
|
|
|
std::unique_ptr<Format> formatter;
|
|
|
|
|
|
|
|
FILE *stream_in, *stream_out;
|
2019-06-05 18:59:45 +02:00
|
|
|
|
|
|
|
bool flush;
|
2019-06-23 10:51:26 +02:00
|
|
|
bool shell;
|
2021-08-10 10:12:48 -04:00
|
|
|
|
2019-06-23 10:51:26 +02:00
|
|
|
std::string working_dir;
|
2019-06-05 18:59:45 +02:00
|
|
|
std::string command;
|
2021-08-10 10:12:48 -04:00
|
|
|
|
2019-06-23 10:51:26 +02:00
|
|
|
villas::utils::Popen::arg_list arguments;
|
|
|
|
villas::utils::Popen::env_map environment;
|
2021-05-10 00:12:30 +02:00
|
|
|
|
2021-08-10 10:12:48 -04:00
|
|
|
virtual
|
|
|
|
int _read(struct Sample * smps[], unsigned cnt);
|
|
|
|
|
|
|
|
virtual
|
|
|
|
int _write(struct Sample * smps[], unsigned cnt);
|
|
|
|
|
|
|
|
public:
|
|
|
|
ExecNode(const std::string &name = "") :
|
|
|
|
Node(name),
|
|
|
|
stream_in(nullptr),
|
|
|
|
stream_out(nullptr),
|
|
|
|
flush(true),
|
|
|
|
shell(false)
|
|
|
|
{ }
|
2019-06-05 18:59:45 +02:00
|
|
|
|
2021-08-10 10:12:48 -04:00
|
|
|
virtual
|
|
|
|
~ExecNode();
|
2019-06-05 18:59:45 +02:00
|
|
|
|
2021-08-10 10:12:48 -04:00
|
|
|
virtual
|
|
|
|
const std::string & getDetails();
|
2019-06-05 18:59:45 +02:00
|
|
|
|
2021-08-10 10:12:48 -04:00
|
|
|
virtual
|
|
|
|
int start();
|
2019-06-05 18:59:45 +02:00
|
|
|
|
2021-08-10 10:12:48 -04:00
|
|
|
virtual
|
|
|
|
int stop();
|
2019-06-05 18:59:45 +02:00
|
|
|
|
2021-08-10 10:12:48 -04:00
|
|
|
virtual
|
|
|
|
int prepare();
|
2019-06-05 18:59:45 +02:00
|
|
|
|
2021-08-10 10:12:48 -04:00
|
|
|
virtual
|
|
|
|
int parse(json_t *json, const uuid_t sn_uuid);
|
|
|
|
|
|
|
|
virtual
|
|
|
|
std::vector<int> getPollFDs();
|
|
|
|
};
|
2019-06-05 18:59:45 +02:00
|
|
|
|
2021-08-10 10:12:48 -04:00
|
|
|
} /* namespace node */
|
|
|
|
} /* namespace villas */
|