File tree Expand file tree Collapse file tree 7 files changed +708
-0
lines changed
Expand file tree Collapse file tree 7 files changed +708
-0
lines changed Original file line number Diff line number Diff line change @@ -80,6 +80,8 @@ find_package(Criterion)
8080find_package (OpalOrchestra )
8181find_package (LibXml2 )
8282find_package (OpalAsyncApi )
83+ find_package (Protobuf )
84+ find_package (gRPC )
8385
8486# Check for tools
8587find_program (PROTOBUFC_COMPILER NAMES protoc-c )
@@ -214,6 +216,7 @@ cmake_dependent_option(WITH_NODE_ULDAQ "Build with uldaq node-type"
214216cmake_dependent_option (WITH_NODE_WEBRTC "Build with webrtc node-type" "${WITH_DEFAULTS} " "WITH_WEB; LibDataChannel_FOUND" OFF )
215217cmake_dependent_option (WITH_NODE_WEBSOCKET "Build with websocket node-type" "${WITH_DEFAULTS} " "WITH_WEB" OFF )
216218cmake_dependent_option (WITH_NODE_ZEROMQ "Build with zeromq node-type" "${WITH_DEFAULTS} " "LIBZMQ_FOUND; NOT WITHOUT_GPL" OFF )
219+ cmake_dependent_option (WITH_GRPC "Build with grpc api" "${WITH_DEFAULTS} " "gRPC_FOUND" OFF )
217220
218221# Set a default for the build type
219222if ("${CMAKE_BUILD_TYPE} " STREQUAL "" )
Original file line number Diff line number Diff line change 1+ /* Universal Data-exchange API request.
2+ *
3+ * Author: Steffen Vogel <post@steffenvogel.de>
4+ * SPDX-FileCopyrightText: 2014-2023 Institute for Automation of Complex Power Systems, RWTH Aachen University
5+ * SPDX-License-Identifier: Apache-2.0
6+ */
7+
8+ #pragma once
9+
10+ #include < villas/api/requests/node.hpp>
11+ #include < villas/nodes/gateway.hpp>
12+
13+ namespace villas {
14+ namespace node {
15+
16+ // Forward declarations
17+ class Node ;
18+
19+ namespace api {
20+
21+ class GatewayRequest : public NodeRequest {
22+
23+ protected:
24+ GatewayNode *gateway_node;
25+
26+ public:
27+ using NodeRequest::NodeRequest;
28+
29+ void prepare () override ;
30+ };
31+
32+ } // namespace api
33+ } // namespace node
34+ } // namespace villas
Original file line number Diff line number Diff line change 1+ #pragma once
2+
3+ #include < pthread.h>
4+
5+ #include < villas/node.hpp>
6+ #include < villas/format.hpp>
7+
8+ namespace villas {
9+ namespace node {
10+
11+ // Forward declarations
12+ struct Sample ;
13+
14+ class GatewayNode : public Node {
15+ protected:
16+ int parse (json_t *json) override ;
17+
18+ int _read (struct Sample *smps[], unsigned cnt) override ;
19+ int _write (struct Sample *smps[], unsigned cnt) override ;
20+
21+ public:
22+ GatewayNode (const uuid_t &id = {}, const std::string &name = " " );
23+ enum ApiType { gRPC };
24+
25+ struct Direction {
26+ Sample *sample;
27+ pthread_cond_t cv;
28+ pthread_mutex_t mutex;
29+ char * buf;
30+ size_t buflen;
31+ size_t wbytes;
32+ };
33+
34+
35+ Direction read, write;
36+ std::string address;
37+ ApiType type;
38+
39+ Format *formatter;
40+
41+ char *buf;
42+ size_t buflen;
43+ size_t wbytes;
44+
45+ int prepare () override ;
46+
47+ int check () override ;
48+
49+ int start () override ;
50+
51+ int stop () override ;
52+
53+ ~GatewayNode ();
54+ };
55+
56+ } // namespace node
57+ } // namespace villas
Original file line number Diff line number Diff line change @@ -42,6 +42,20 @@ if(WITH_GRAPHVIZ)
4242 list (APPEND LIBRARIES PkgConfig::CGRAPH PkgConfig::GVC)
4343endif ()
4444
45+ if (WITH_GRPC)
46+ find_path (REFLECTION_INCLUDE_DIR
47+ NAMES grpc/reflection/v1alpha/reflection.pb.cc
48+ )
49+ if (REFLECTION_INCLUDE_DIR)
50+ list (APPEND API_SRC
51+ requests/gateway/grpc.cpp
52+ ${REFLECTION_INCLUDE_DIR} /grpc/reflection/v1alpha/reflection.pb.cc
53+ ${REFLECTION_INCLUDE_DIR} /grpc/reflection/v1alpha/reflection.grpc.pb.cc
54+ )
55+ list (APPEND LIBRARIES protobuf::libprotobuf gRPC::grpc++)
56+ endif ()
57+ endif ()
58+
4559add_library (api STATIC ${API_SRC} )
4660target_include_directories (api PUBLIC ${INCLUDE_DIRS} )
4761target_link_libraries (api PUBLIC ${LIBRARIES} )
You can’t perform that action at this time.
0 commit comments