Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
PJungkamp committed Oct 15, 2024
1 parent edd113a commit 041b761
Show file tree
Hide file tree
Showing 3 changed files with 396 additions and 31 deletions.
1 change: 1 addition & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@
boxfort
clang-tools
criterion
gdb
jq
libffi
libgit2
Expand Down
91 changes: 60 additions & 31 deletions include/villas/nodes/c37_118.hpp
Original file line number Diff line number Diff line change
@@ -1,48 +1,77 @@
/**
* @file
* @author Philipp Jungkamp <[email protected]>
* @copyright 2014-2022, Institute for Automation of Complex Power Systems, EONERC
* @license Apache 2.0
*********************************************************************************/
/* Node type: C37-118.
*
* Author: Philipp Jungkamp <[email protected]>
* SPDX-FileCopyrightText: 2014-2024 Institute for Automation of Complex Power Systems, RWTH Aachen University
* SPDX-License-Identifier: Apache-2.0
*/

#pragma once

#include <cstdint>
#include <string>
#include <optional>
#include <villas/nodes/c37_118/parser.hpp>
#include <villas/node/config.hpp>
#include <variant>
#include <vector>
#include <villas/node.hpp>
#include <villas/node/config.hpp>
#include <villas/nodes/c37_118/parser.hpp>
#include <villas/queue_signalled.h>
#include <villas/signal.hpp>
#include <villas/socket_addr.hpp>
#include <villas/timing.hpp>

namespace villas {
namespace node {
namespace c37_118 {
namespace villas::node::c37_118 {

class C37_118 : public Node {
protected:
struct Input {
std::string address;
} input;
using parser::Parser;
using types::Frame;
using types::Config;

virtual
int _read(struct Sample *smps[], unsigned cnt) override;
class C37_118 final : public Node {
private:
struct Server {
std::string addr;
uint16_t port;
int socktype;
Config config;

public:
C37_118(const std::string &name = "");
int listener_fd;
std::vector<int> connection_fds;
};

struct Client {
std::string addr;
uint16_t port;
uint16_t idcode;
int socktype;

virtual
~C37_118() override;
std::optional<Config> config;
int connection_fd;
std::vector<unsigned char> recv_buf = std::vector<unsigned char>(1024);
Parser parser;

virtual
int parse(json_t *json, const uuid_t sn_uuid) override;
void send(Frame::Variant message, timespec ts = time_now());
std::optional<Frame> recv();
};

virtual
int start() override;
std::variant<Server, Client> role;

void parseServer(json_t *json);
void parseClient(json_t *json);

void prepareServer(Server &server);
void prepareClient(Client &client);

virtual int _read(struct Sample *smps[], unsigned cnt) override;

public:
C37_118(const uuid_t &id = {}, const std::string &name = "") : Node{id, name} {}

virtual
int stop() override;
virtual ~C37_118() override;
virtual int parse(json_t *json) override;
virtual int prepare() override;
virtual int start() override;
virtual int stop() override;
virtual std::vector<int> getPollFDs() override;
};

} /* namespace c37_118 */
} /* namespace node */
} /* namespace villas */
} // namespace villas::node::c37_118
Loading

0 comments on commit 041b761

Please sign in to comment.