From 9b1f51429cbeeb64abe9b6e37c5ab09dfd75e701 Mon Sep 17 00:00:00 2001 From: sagrahar Date: Fri, 25 Oct 2024 02:54:55 +0530 Subject: [PATCH 01/34] adding support for sideband streaming --- .gitmodules | 3 + CMakeLists.txt | 26 +- source/protobuf/data_moniker.proto | 79 +++++ source/server/core_server.cpp | 35 +- source/server/core_services_registrar.cpp | 5 + source/server/data_moniker_service.cpp | 298 ++++++++++++++++++ source/server/data_moniker_service.h | 47 +++ source/server/server_configuration_parser.cpp | 7 + source/server/server_configuration_parser.h | 1 + third_party/grpc-sideband | 1 + 10 files changed, 500 insertions(+), 2 deletions(-) create mode 100644 source/protobuf/data_moniker.proto create mode 100644 source/server/data_moniker_service.cpp create mode 100644 source/server/data_moniker_service.h create mode 160000 third_party/grpc-sideband diff --git a/.gitmodules b/.gitmodules index 3917d0cf0..dd74a5297 100644 --- a/.gitmodules +++ b/.gitmodules @@ -10,3 +10,6 @@ [submodule "third_party/utfcpp"] path = third_party/utfcpp url = https://github.com/nemtrif/utfcpp +[submodule "third_party/grpc-sideband"] + path = third_party/grpc-sideband + url = https://github.com/ni/grpc-sideband.git diff --git a/CMakeLists.txt b/CMakeLists.txt index cdbec02b4..b710c9ce4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -31,11 +31,13 @@ endif() option(USE_NILRT_LEGACY_TOOLCHAIN "Enable to use tools and libraries from a NILRT compile toolchain." OFF) option(USE_PYTHON_VIRTUALENV "Enable to use the automatically-generated python venv, local to this project source." ON) option(USE_SUBMODULE_LIBS "Enable to link against the submodule libraries, rather than their native-OS equivalents." ON) +option(INCLUDE_SIDEBAND_RDMA "Include support for RDMA sideband transfers" OFF) +option(SIDEBAND_STATIC "Build static library, disabled by default" ON) #---------------------------------------------------------------------- # Setup build dependencies, according to the toolchain options. #---------------------------------------------------------------------- - + add_subdirectory(third_party/grpc-sideband ${CMAKE_CURRENT_BINARY_DIR}/grpc-sideband) if(USE_SUBMODULE_LIBS) # The archetypical WIN32 build case # protobuf_INSTALL must be turned OFF whenever building it as a cmake subdir. @@ -117,6 +119,8 @@ include_directories( "./generated" "./imports/include" "./source" + "./third_party/grpc-sideband/src" + "./third_party/grpc-sideband/moniker_src" ) if(WIN32) link_directories("./imports/lib/win64") @@ -272,6 +276,7 @@ get_filename_component(nidevice_proto "imports/protobuf/nidevice.proto" ABSOLUTE get_filename_component(deviceid_restricted_proto "source/protobuf_restricted/deviceid_restricted.proto" ABSOLUTE) get_filename_component(debugsessionproperties_restricted_proto "source/protobuf_restricted/debugsessionproperties_restricted.proto" ABSOLUTE) get_filename_component(calibrationoperations_restricted_proto "source/protobuf_restricted/calibrationoperations_restricted.proto" ABSOLUTE) +get_filename_component(data_moniker_proto "source/protobuf/data_moniker.proto" ABSOLUTE) get_filename_component(session_proto_path "${session_proto}" PATH) #---------------------------------------------------------------------- @@ -299,6 +304,7 @@ function(GenerateGrpcSources) -I "${proto_path}" ${protobuf_includes_arg} -I ${CMAKE_SOURCE_DIR}/imports/protobuf + -I ${CMAKE_SOURCE_DIR}/source/protobuf --plugin=protoc-gen-grpc="${_GRPC_CPP_PLUGIN_EXECUTABLE}" "${proto_file}" DEPENDS "${proto_file}" "${session_proto}") @@ -326,6 +332,10 @@ set(calibrationoperations_restricted_proto_srcs "${proto_srcs_dir}/calibrationop set(calibrationoperations_restricted_proto_hdrs "${proto_srcs_dir}/calibrationoperations_restricted.pb.h") set(calibrationoperations_restricted_grpc_srcs "${proto_srcs_dir}/calibrationoperations_restricted.grpc.pb.cc") set(calibrationoperations_restricted_grpc_hdrs "${proto_srcs_dir}/calibrationoperations_restricted.grpc.pb.h") +set(data_moniker_proto_srcs "${proto_srcs_dir}/data_moniker.pb.cc") +set(data_moniker_proto_hdrs "${proto_srcs_dir}/data_moniker.pb.h") +set(data_moniker_grpc_srcs "${proto_srcs_dir}/data_moniker.grpc.pb.cc") +set(data_moniker_grpc_hdrs "${proto_srcs_dir}/data_moniker.grpc.pb.h") GenerateGrpcSources( PROTO @@ -400,6 +410,16 @@ set(nidriver_service_library_hdrs "${calibrationoperations_restricted_grpc_hdrs}" ) +GenerateGrpcSources( + PROTO + ${data_moniker_proto} + OUTPUT + "${data_moniker_proto_srcs}" + "${data_moniker_proto_hdrs}" + "${data_moniker_grpc_srcs}" + "${data_moniker_grpc_hdrs}" +) + foreach(api ${nidrivers}) GenerateGrpcSources( PROTO @@ -444,6 +464,9 @@ add_executable(ni_grpc_device_server "source/server/syscfg_library.cpp" "source/server/syscfg_resource_accessor.cpp" "source/server/syscfg_session_handler.cpp" + "source/server/data_moniker_service.cpp" + ${data_moniker_proto_srcs} + ${data_moniker_grpc_srcs} ${nidevice_proto_srcs} ${session_proto_srcs} ${session_grpc_srcs} @@ -528,6 +551,7 @@ set(server_lib_deps ${_REFLECTION} ${_UTF8CPP} ${CMAKE_DL_LIBS} + ni_grpc_sideband nlohmann_json::nlohmann_json ) diff --git a/source/protobuf/data_moniker.proto b/source/protobuf/data_moniker.proto new file mode 100644 index 000000000..1799c57a7 --- /dev/null +++ b/source/protobuf/data_moniker.proto @@ -0,0 +1,79 @@ +syntax = "proto3"; + +option cc_enable_arenas = true; +option csharp_namespace = "NationalInstruments.DataMonikers"; + +package ni.data_monikers; + +import "google/protobuf/any.proto"; + +service DataMoniker { + rpc BeginSidebandStream(BeginMonikerSidebandStreamRequest) returns (BeginMonikerSidebandStreamResponse) {}; + rpc StreamReadWrite(stream MonikerWriteRequest) returns (stream MonikerReadResponse) {}; + rpc StreamRead(MonikerList) returns (stream MonikerReadResponse) {}; + rpc StreamWrite(stream MonikerWriteRequest) returns (stream StreamWriteResponse) {}; +} + +enum SidebandStrategy +{ + UNKNOWN = 0; + GRPC = 1; + SHARED_MEMORY = 2; + DOUBLE_BUFFERED_SHARED_MEMORY = 3; + SOCKETS = 4; + SOCKETS_LOW_LATENCY = 5; + HYPERVISOR_SOCKETS = 6; + RDMA = 7; + RDMA_LOW_LATENCY = 8; +} + +message BeginMonikerSidebandStreamRequest { + SidebandStrategy strategy = 1; + MonikerList monikers = 2; +} + +message BeginMonikerSidebandStreamResponse { + SidebandStrategy strategy = 1; + string connection_url = 2; + string sideband_identifier = 3; + sint64 buffer_size = 4; +} + +message Moniker { + string service_location = 1; + string data_source = 2; + int64 data_instance = 3; +} + +message MonikerWriteRequest { + oneof write_data { + MonikerList monikers = 1; + MonikerValues data = 2; + } +} + +message MonikerReadResponse { + MonikerValues data = 1; +} + +message MonikerList { + repeated Moniker read_monikers = 2; + repeated Moniker write_monikers = 3; +} + +message MonikerValues { + repeated google.protobuf.Any values = 1; +} + +message SidebandWriteRequest { + bool cancel = 1; + MonikerValues values = 2; +} + +message SidebandReadResponse { + bool cancel = 1; + MonikerValues values = 2; +} + +message StreamWriteResponse { +} diff --git a/source/server/core_server.cpp b/source/server/core_server.cpp index 3c97a1451..f56cfd571 100644 --- a/source/server/core_server.cpp +++ b/source/server/core_server.cpp @@ -1,8 +1,9 @@ #include #include #include - +#include #include +#include #include "feature_toggles.h" #include "logging.h" @@ -12,6 +13,7 @@ #if defined(__GNUC__) #include "linux/daemonize.h" #include "linux/syslog_logging.h" + #include #endif #if defined(_WIN32) #include "windows/console_ctrl_handler.h" @@ -24,6 +26,7 @@ using FeatureState = nidevice_grpc::FeatureToggles::FeatureState; struct ServerConfiguration { std::string config_file_path; std::string server_address; + std::string sideband_ip; std::string server_cert; std::string server_key; std::string root_cert; @@ -41,6 +44,7 @@ static ServerConfiguration GetConfiguration(const std::string& config_file_path) config.config_file_path = server_config_parser.get_config_file_path(); config.server_address = server_config_parser.parse_address(); + config.sideband_ip = server_config_parser.parse_sideband_ip(); config.server_cert = server_config_parser.parse_server_cert(); config.server_key = server_config_parser.parse_server_key(); config.root_cert = server_config_parser.parse_root_cert(); @@ -103,6 +107,10 @@ static void RunServer(const ServerConfiguration& config) server = builder.BuildAndStart(); } + auto sideband_socket_thread = new std::thread(RunSidebandSocketsAccept, config.sideband_ip.c_str(), 50055); + // auto sideband_rdma_send_thread = new std::thread(AcceptSidebandRdmaSendRequests); + // auto sideband_rdma_recv_thread = new std::thread(AcceptSidebandRdmaReceiveRequests); + if (!server) { nidevice_grpc::logging::log( nidevice_grpc::logging::Level_Error, @@ -221,6 +229,14 @@ Options parse_options(int argc, char** argv) return options; } +static void SysFsWrite(const std::string& fileName, const std::string& value) +{ + std::ofstream fout; + fout.open(fileName); + fout << value; + fout.close(); +} + int main(int argc, char** argv) { auto options = parse_options(argc, argv); @@ -239,6 +255,23 @@ int main(int argc, char** argv) #if defined(_WIN32) nidevice_grpc::set_console_ctrl_handler(&StopServer); #endif +#ifndef _WIN32 + SysFsWrite("/dev/cgroup/cpuset/system_set/cpus", "0-5"); + SysFsWrite("/dev/cgroup/cpuset/LabVIEW_ScanEngine_set", "0-5"); + SysFsWrite("/dev/cgroup/cpuset/LabVIEW_tl_set/cpus", "6-8"); + SysFsWrite("/dev/cgroup/cpuset/LabVIEW_tl_set/cpu_exclusive", "1"); + + sched_param schedParam; + schedParam.sched_priority = 95; + sched_setscheduler(0, SCHED_FIFO, &schedParam); + + cpu_set_t cpuSet; + CPU_ZERO(&cpuSet); + CPU_SET(6, &cpuSet); + sched_setaffinity(0, sizeof(cpu_set_t), &cpuSet); + + mlockall(MCL_CURRENT|MCL_FUTURE); +#endif RunServer(config); return EXIT_SUCCESS; diff --git a/source/server/core_services_registrar.cpp b/source/server/core_services_registrar.cpp index eb320f8c9..bfcefc4ba 100644 --- a/source/server/core_services_registrar.cpp +++ b/source/server/core_services_registrar.cpp @@ -4,6 +4,7 @@ #include "debug_session_properties_restricted_service_registrar.h" #include "server_reset_observer_registrar_interface.h" #include "session_utilities_service_registrar.h" +#include "data_moniker_service.h" namespace nidevice_grpc { void register_core_services( @@ -25,5 +26,9 @@ void register_core_services( server_builder, feature_toggles, *server_reset_observer_registrar)); + + auto moniker_service = std::make_shared(); + server_builder.RegisterService(moniker_service.get()); + service_vector->push_back(moniker_service); } } // namespace nidevice_grpc diff --git a/source/server/data_moniker_service.cpp b/source/server/data_moniker_service.cpp new file mode 100644 index 000000000..580a4abb3 --- /dev/null +++ b/source/server/data_moniker_service.cpp @@ -0,0 +1,298 @@ +//--------------------------------------------------------------------- +//--------------------------------------------------------------------- +#include +#include +#include +#include +#include +#include "data_moniker_service.h" +#ifndef _WIN32 +#include +#endif + +#include +#include + +//--------------------------------------------------------------------- +//--------------------------------------------------------------------- +using grpc::Server; +using grpc::ServerBuilder; +using grpc::ServerContext; +using grpc::Status; +using grpc::ServerWriter; +using grpc::ServerReaderWriter; +using std::string; +using ni::data_monikers::DataMoniker; +using ni::data_monikers::MonikerList; +using ni::data_monikers::MonikerWriteRequest; +using ni::data_monikers::MonikerReadResponse; +using ni::data_monikers::StreamWriteResponse; +using ni::data_monikers::SidebandWriteRequest; +using ni::data_monikers::SidebandReadResponse; +using ni::data_monikers::BeginMonikerSidebandStreamRequest; +using ni::data_monikers::BeginMonikerSidebandStreamResponse; +using google::protobuf::Arena; + +static void SysFsWrite(const std::string& fileName, const std::string& value) +{ + std::ofstream fout; + fout.open(fileName); + fout << value; + fout.close(); +} + +namespace ni::data_monikers +{ + //--------------------------------------------------------------------- + //--------------------------------------------------------------------- + DataMonikerService* DataMonikerService::s_Server; + + //--------------------------------------------------------------------- + //--------------------------------------------------------------------- + DataMonikerService::DataMonikerService() + { + s_Server = this; + } + + //--------------------------------------------------------------------- + //--------------------------------------------------------------------- + void DataMonikerService::RegisterMonikerEndpoint(string endpointName, MonikerEndpointPtr endpoint) + { + s_Server->_endpoints.emplace(endpointName, endpoint); + } + + //--------------------------------------------------------------------- + //--------------------------------------------------------------------- + void DataMonikerService::RegisterMonikerInstance(string endpointName, void* instanceData, Moniker& moniker) + { + moniker.set_data_instance(reinterpret_cast(instanceData)); + moniker.set_service_location("local"); + moniker.set_data_source(endpointName); + } + + //--------------------------------------------------------------------- + //--------------------------------------------------------------------- + void DataMonikerService::InitiateMonikerList(const MonikerList& monikers, EndpointList* readers, EndpointList* writers) + { + for (auto readMoniker: monikers.read_monikers()) + { + auto instance = readMoniker.data_instance(); + auto source = readMoniker.data_source(); + auto it = _endpoints.find(source); + MonikerEndpointPtr ptr = nullptr; + if (it != _endpoints.end()) + { + ptr = (*it).second; + } + readers->push_back(EndpointInstance(ptr, reinterpret_cast(instance))); + } + for (auto writeMoniker: monikers.write_monikers()) + { + auto instance = writeMoniker.data_instance(); + auto source = writeMoniker.data_source(); + auto it = _endpoints.find(source); + MonikerEndpointPtr ptr = nullptr; + if (it != _endpoints.end()) + { + ptr = (*it).second; + } + writers->push_back(EndpointInstance(ptr, reinterpret_cast(instance))); + } + } + + //--------------------------------------------------------------------- + //--------------------------------------------------------------------- + void DataMonikerService::RunSidebandReadWriteLoop(string sidebandIdentifier, ::SidebandStrategy strategy, EndpointList* readers, EndpointList* writers) + { + std::cout << "Enter RunSidebandReadWriteLoop" << std::endl; + + #ifndef _WIN32 + if (strategy == ::SidebandStrategy::RDMA_LOW_LATENCY || + strategy == ::SidebandStrategy::SOCKETS_LOW_LATENCY) + { + pid_t threadId = syscall(SYS_gettid); + ::SysFsWrite("/dev/cgroup/cpuset/LabVIEW_tl_set/tasks", std::to_string(threadId)); + + cpu_set_t cpuSet; + CPU_ZERO(&cpuSet); + CPU_SET(8, &cpuSet); + //CPU_SET(8, &cpuSet); + sched_setaffinity(threadId, sizeof(cpu_set_t), &cpuSet); + } + #endif + + google::protobuf::Arena arena; + int64_t sidebandToken; + GetOwnerSidebandDataToken(sidebandIdentifier.c_str(), &sidebandToken); + while (true) + { + auto writeRequest = google::protobuf::Arena::CreateMessage(&arena); + if (!ReadSidebandMessage(sidebandToken, writeRequest)) + { + break; + } + if (writeRequest->cancel()) + { + std::cout << "Cancelled." << std::endl; + break; + } + if (writers->size() > 0) + { + int x = 0; + if (writers->size() != writeRequest->values().values_size()) + { + std::cout << "ERROR: The number of writers and values read did not match" << std::endl; + std::cout << "Expected: " << writers->size() << std::endl; + std::cout << "Actual: " << writeRequest->values().values_size() << std::endl; + break; + } + for (auto writer: *writers) + { + std::get<0>(writer)(std::get<1>(writer), arena, const_cast(writeRequest->values().values(x++))); + } + } + auto readResult = Arena::CreateMessage(&arena); + if (readResult->GetArena() != &arena) + { + std::cout << "No Arena 111" << std::endl; + } + if (readers->size() > 0) + { + int x = 0; + for (auto reader: *readers) + { + auto readValue = readResult->mutable_values()->add_values(); + if (readValue->GetArena() != &arena) + { + std::cout << "No Arena" << std::endl; + } + std::get<0>(reader)(std::get<1>(reader), arena, *readValue); + } + } + if (!WriteSidebandMessage(sidebandToken, *readResult)) + { + std::cout << "Failed to write" << std::endl; + break; + } + arena.Reset(); + std::this_thread::sleep_for(std::chrono::microseconds(10)); + } + delete readers; + delete writers; + CloseSidebandData(sidebandToken); + std::cout << "Exit RunSidebandReadWriteLoop" << std::endl; + } + + //--------------------------------------------------------------------- + //--------------------------------------------------------------------- + Status DataMonikerService::BeginSidebandStream(ServerContext* context, const BeginMonikerSidebandStreamRequest* request, BeginMonikerSidebandStreamResponse* response) + { + std::cout << "Enter BeginSidebandStream" << std::endl; + auto bufferSize = 1024 * 1024; + auto strategy = static_cast<::SidebandStrategy>(request->strategy()); + + char identifier[32] = {}; + InitOwnerSidebandData(strategy, bufferSize, identifier);; + response->set_strategy(request->strategy()); + response->set_sideband_identifier(identifier); + response->set_connection_url(GetConnectionAddress(strategy)); + response->set_buffer_size(bufferSize); + QueueSidebandConnection(strategy, identifier, true, true, bufferSize); + + auto writers = new EndpointList(); + auto readers = new EndpointList(); + InitiateMonikerList(request->monikers(), readers, writers); + + std::cout << "Starting thread with RunSidebandReadWriteLoop()" << std::endl; + auto thread = new std::thread(RunSidebandReadWriteLoop, identifier, strategy, readers, writers); + thread->detach(); + + std::cout << "Exit BeginSidebandStream" << std::endl; + return Status::OK; + } + + //--------------------------------------------------------------------- + //--------------------------------------------------------------------- + Status DataMonikerService::StreamReadWrite(ServerContext* context, ServerReaderWriter* stream) + { + EndpointList writers; + EndpointList readers; + MonikerWriteRequest writeRequest; + stream->Read(&writeRequest); + InitiateMonikerList(writeRequest.monikers(), &readers, &writers); + + google::protobuf::Arena arena; + while (stream->Read(&writeRequest) && !context->IsCancelled()) + { + int x = 0; + for (auto writer: writers) + { + std::get<0>(writer)(std::get<1>(writer), arena, const_cast(writeRequest.data().values(x++))); + } + + MonikerReadResponse readResult; + for (auto reader: readers) + { + auto readValue = readResult.mutable_data()->add_values(); + std::get<0>(reader)(std::get<1>(reader), arena, *readValue); + } + stream->Write(readResult); + arena.Reset(); + } + return Status::OK; + } + + //--------------------------------------------------------------------- + //--------------------------------------------------------------------- + Status DataMonikerService::StreamRead(ServerContext* context, const MonikerList* request, ServerWriter* writer) + { + EndpointList writers; + EndpointList readers; + InitiateMonikerList(*request, &readers, &writers); + + google::protobuf::Arena arena; + while (!context->IsCancelled()) + { + MonikerReadResponse readResult; + for (auto reader: readers) + { + auto readValue = readResult.mutable_data()->add_values(); + std::get<0>(reader)(std::get<1>(reader), arena, *readValue); + } + writer->Write(readResult); + arena.Reset(); + } + return Status::OK; + } + + //--------------------------------------------------------------------- + //--------------------------------------------------------------------- + Status DataMonikerService::StreamWrite(ServerContext* context, ServerReaderWriter* stream) + { + #ifndef _WIN32 + cpu_set_t cpuSet; + CPU_ZERO(&cpuSet); + CPU_SET(1, &cpuSet); + sched_setaffinity(0, sizeof(cpu_set_t), &cpuSet); + #endif + + EndpointList writers; + EndpointList readers; + MonikerWriteRequest writeRequest; + stream->Read(&writeRequest); + InitiateMonikerList(writeRequest.monikers(), &readers, &writers); + + int x = 0; + google::protobuf::Arena arena; + while (stream->Read(&writeRequest) && !context->IsCancelled()) + { + x = 0; + for (auto writer: writers) + { + std::get<0>(writer)(std::get<1>(writer), arena, const_cast(writeRequest.data().values(x++))); + } + arena.Reset(); + } + return Status::OK; + } +} diff --git a/source/server/data_moniker_service.h b/source/server/data_moniker_service.h new file mode 100644 index 000000000..660308533 --- /dev/null +++ b/source/server/data_moniker_service.h @@ -0,0 +1,47 @@ +//--------------------------------------------------------------------- +// Implementation of NI Data Moniker Service +//--------------------------------------------------------------------- +#pragma once + +//--------------------------------------------------------------------- +//--------------------------------------------------------------------- +#include +#include +#include +#include +#include + +//--------------------------------------------------------------------- +//--------------------------------------------------------------------- +namespace ni::data_monikers +{ + //--------------------------------------------------------------------- + //--------------------------------------------------------------------- + using MonikerEndpointPtr = std::add_pointer<::grpc::Status(void*, google::protobuf::Arena& arena, google::protobuf::Any&)>::type; + using EndpointInstance = std::tuple; + using EndpointList = std::vector; + + //--------------------------------------------------------------------- + //--------------------------------------------------------------------- + class DataMonikerService final : public DataMoniker::Service + { + public: + DataMonikerService(); + ::grpc::Status BeginSidebandStream(grpc::ServerContext* context, const ni::data_monikers::BeginMonikerSidebandStreamRequest* request, ni::data_monikers::BeginMonikerSidebandStreamResponse* response) override; + ::grpc::Status StreamReadWrite(::grpc::ServerContext* context, ::grpc::ServerReaderWriter* stream) override; + ::grpc::Status StreamRead(::grpc::ServerContext* context, const MonikerList* request, ::grpc::ServerWriter* writer); + ::grpc::Status StreamWrite(::grpc::ServerContext* context, ::grpc::ServerReaderWriter* stream); + + public: + static void RegisterMonikerEndpoint(std::string endpointName, MonikerEndpointPtr endpoint); + static void RegisterMonikerInstance(std::string endpointName, void* instanceData, Moniker& moniker); + + private: + static DataMonikerService* s_Server; + std::map _endpoints; + + private: + void InitiateMonikerList(const MonikerList& monikers, EndpointList* readers, EndpointList* writers); + static void RunSidebandReadWriteLoop(std::string sidebandIdentifier, ::SidebandStrategy strategy, EndpointList* readers, EndpointList* writers); + }; +} diff --git a/source/server/server_configuration_parser.cpp b/source/server/server_configuration_parser.cpp index 85df0702c..a6c42c42f 100644 --- a/source/server/server_configuration_parser.cpp +++ b/source/server/server_configuration_parser.cpp @@ -17,6 +17,7 @@ namespace nidevice_grpc { static const char* kDefaultFilename = "server_config.json"; static const char* kAddressJsonKey = "address"; static const char* kPortJsonKey = "port"; +static const char* kSidebandIpJsonKey = "sideband_ip"; static const char* kServerCertJsonKey = "server_cert"; static const char* kServerKeyJsonKey = "server_key"; static const char* kRootCertJsonKey = "root_cert"; @@ -101,6 +102,12 @@ std::string ServerConfigurationParser::parse_address() const return address; } +std::string ServerConfigurationParser::parse_sideband_ip() const +{ + auto it = config_file_.find(kSidebandIpJsonKey); + return it != config_file_.end() ? it->get() : ""; +} + std::string ServerConfigurationParser::parse_server_cert() const { auto file_name = parse_key_from_security_section(kServerCertJsonKey); diff --git a/source/server/server_configuration_parser.h b/source/server/server_configuration_parser.h index ea3b57a34..f75625b66 100644 --- a/source/server/server_configuration_parser.h +++ b/source/server/server_configuration_parser.h @@ -36,6 +36,7 @@ class ServerConfigurationParser { const std::string& get_config_file_path() const { return config_file_path_; } std::string parse_address() const; + std::string parse_sideband_ip() const; std::string parse_server_cert() const; std::string parse_server_key() const; std::string parse_root_cert() const; diff --git a/third_party/grpc-sideband b/third_party/grpc-sideband new file mode 160000 index 000000000..c9db4ec01 --- /dev/null +++ b/third_party/grpc-sideband @@ -0,0 +1 @@ +Subproject commit c9db4ec01ad8bf7055ade7ee4136307bf30d9a03 From 2a45cc7d0d18cfa63f69a1e9bebd9c3d80fe41d1 Mon Sep 17 00:00:00 2001 From: sagrahar Date: Fri, 25 Oct 2024 14:29:13 +0530 Subject: [PATCH 02/34] updating grpc-sideband submodule to latest --- third_party/grpc-sideband | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/third_party/grpc-sideband b/third_party/grpc-sideband index c9db4ec01..b1cd68892 160000 --- a/third_party/grpc-sideband +++ b/third_party/grpc-sideband @@ -1 +1 @@ -Subproject commit c9db4ec01ad8bf7055ade7ee4136307bf30d9a03 +Subproject commit b1cd688921128044054592315327b7768e7f894c From 59e91ce89ac1ff6661ed1dd5f1ec3229e742a443 Mon Sep 17 00:00:00 2001 From: sagrahar Date: Fri, 25 Oct 2024 20:27:26 +0530 Subject: [PATCH 03/34] adding data_moniker source and generated files to Integration and System test runners --- CMakeLists.txt | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b710c9ce4..18eafb45d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -448,6 +448,7 @@ add_executable(ni_grpc_device_server "source/server/calibration_operations_restricted_service.cpp" "source/server/core_server.cpp" "source/server/core_services_registrar.cpp" + "source/server/data_moniker_service.cpp" "source/server/debug_session_properties_restricted_service_registrar.cpp" "source/server/debug_session_properties_restricted_service.cpp" "source/server/device_enumerator.cpp" @@ -464,7 +465,6 @@ add_executable(ni_grpc_device_server "source/server/syscfg_library.cpp" "source/server/syscfg_resource_accessor.cpp" "source/server/syscfg_session_handler.cpp" - "source/server/data_moniker_service.cpp" ${data_moniker_proto_srcs} ${data_moniker_grpc_srcs} ${nidevice_proto_srcs} @@ -590,6 +590,7 @@ add_executable(IntegrationTestsRunner "source/server/calibration_operations_restricted_service_registrar.cpp" "source/server/calibration_operations_restricted_service.cpp" "source/server/core_services_registrar.cpp" + "source/server/data_moniker_service.cpp" "source/server/debug_session_properties_restricted_service_registrar.cpp" "source/server/debug_session_properties_restricted_service.cpp" "source/server/device_enumerator.cpp" @@ -603,6 +604,8 @@ add_executable(IntegrationTestsRunner "source/server/syscfg_library.cpp" "source/server/syscfg_resource_accessor.cpp" "source/server/syscfg_session_handler.cpp" + ${data_moniker_proto_srcs} + ${data_moniker_grpc_srcs} ${nidevice_proto_srcs} ${session_proto_srcs} ${session_grpc_srcs} @@ -807,6 +810,7 @@ set(system_test_runner_sources "source/tests/system/visa_session_tests.cpp" "source/server/calibration_operations_restricted_service_registrar.cpp" "source/server/calibration_operations_restricted_service.cpp" + "source/server/data_moniker_service.cpp" "source/server/debug_session_properties_restricted_service_registrar.cpp" "source/server/debug_session_properties_restricted_service.cpp" "source/server/device_enumerator.cpp" @@ -820,6 +824,8 @@ set(system_test_runner_sources "source/server/syscfg_library.cpp" "source/server/syscfg_resource_accessor.cpp" "source/server/syscfg_session_handler.cpp" + ${data_moniker_proto_srcs} + ${data_moniker_grpc_srcs} ${nidevice_proto_srcs} ${session_proto_srcs} ${session_grpc_srcs} From a3aedc18c33a5ed29c4eb71e7df859f8c0e17d11 Mon Sep 17 00:00:00 2001 From: Ayush Mehra Date: Mon, 28 Oct 2024 03:31:17 -0700 Subject: [PATCH 04/34] Initial auto-generation --- generated/nifpga/nifpga.proto | 397 ++++ generated/nifpga/nifpga_client.cpp | 584 +++++ generated/nifpga/nifpga_client.h | 32 + generated/nifpga/nifpga_service.cpp | 1925 +++++++++++++++++ generated/nifpga/nifpga_service.h | 66 + source/codegen/common_helpers.py | 22 + source/codegen/metadata/nifpga/config.py | 6 +- .../codegen/metadata/nifpga/custom_proto.mako | 35 + source/codegen/metadata/nifpga/functions.py | 66 +- source/codegen/metadata_mutation.py | 46 +- source/codegen/metadata_validation.py | 7 +- source/codegen/service_helpers.py | 106 +- source/codegen/templates/proto.mako | 9 +- .../templates/register_all_services.cpp.mako | 20 +- source/codegen/templates/service.cpp.mako | 19 + source/codegen/templates/service.h.mako | 15 + source/codegen/templates/service_helpers.mako | 194 +- 17 files changed, 3538 insertions(+), 11 deletions(-) create mode 100644 source/codegen/metadata/nifpga/custom_proto.mako diff --git a/generated/nifpga/nifpga.proto b/generated/nifpga/nifpga.proto index efeeba644..7cc6d5f3c 100644 --- a/generated/nifpga/nifpga.proto +++ b/generated/nifpga/nifpga.proto @@ -6,6 +6,7 @@ //--------------------------------------------------------------------- syntax = "proto3"; +option cc_enable_arenas = true; option java_multiple_files = true; option java_package = "com.ni.grpc.nifpga"; option java_outer_classname = "NiFpga"; @@ -14,6 +15,7 @@ option csharp_namespace = "NationalInstruments.Grpc.NiFpga"; package nifpga_grpc; import "session.proto"; +import "data_moniker.proto"; service NiFpga { rpc Abort(AbortRequest) returns (AbortResponse); @@ -35,14 +37,22 @@ service NiFpga { rpc ReadArrayBool(ReadArrayBoolRequest) returns (ReadArrayBoolResponse); rpc ReadArrayDbl(ReadArrayDblRequest) returns (ReadArrayDblResponse); rpc ReadArrayI16(ReadArrayI16Request) returns (ReadArrayI16Response); + rpc BeginReadArrayI16(BeginReadArrayI16Request) returns (BeginReadArrayI16Response); rpc ReadArrayI32(ReadArrayI32Request) returns (ReadArrayI32Response); + rpc BeginReadArrayI32(BeginReadArrayI32Request) returns (BeginReadArrayI32Response); rpc ReadArrayI64(ReadArrayI64Request) returns (ReadArrayI64Response); + rpc BeginReadArrayI64(BeginReadArrayI64Request) returns (BeginReadArrayI64Response); rpc ReadArrayI8(ReadArrayI8Request) returns (ReadArrayI8Response); + rpc BeginReadArrayI8(BeginReadArrayI8Request) returns (BeginReadArrayI8Response); rpc ReadArraySgl(ReadArraySglRequest) returns (ReadArraySglResponse); rpc ReadArrayU16(ReadArrayU16Request) returns (ReadArrayU16Response); + rpc BeginReadArrayU16(BeginReadArrayU16Request) returns (BeginReadArrayU16Response); rpc ReadArrayU32(ReadArrayU32Request) returns (ReadArrayU32Response); + rpc BeginReadArrayU32(BeginReadArrayU32Request) returns (BeginReadArrayU32Response); rpc ReadArrayU64(ReadArrayU64Request) returns (ReadArrayU64Response); + rpc BeginReadArrayU64(BeginReadArrayU64Request) returns (BeginReadArrayU64Response); rpc ReadArrayU8(ReadArrayU8Request) returns (ReadArrayU8Response); + rpc BeginReadArrayU8(BeginReadArrayU8Request) returns (BeginReadArrayU8Response); rpc ReadBool(ReadBoolRequest) returns (ReadBoolResponse); rpc ReadDbl(ReadDblRequest) returns (ReadDblResponse); rpc ReadFifoBool(ReadFifoBoolRequest) returns (ReadFifoBoolResponse); @@ -57,14 +67,22 @@ service NiFpga { rpc ReadFifoU64(ReadFifoU64Request) returns (ReadFifoU64Response); rpc ReadFifoU8(ReadFifoU8Request) returns (ReadFifoU8Response); rpc ReadI16(ReadI16Request) returns (ReadI16Response); + rpc BeginReadI16(BeginReadI16Request) returns (BeginReadI16Response); rpc ReadI32(ReadI32Request) returns (ReadI32Response); + rpc BeginReadI32(BeginReadI32Request) returns (BeginReadI32Response); rpc ReadI64(ReadI64Request) returns (ReadI64Response); + rpc BeginReadI64(BeginReadI64Request) returns (BeginReadI64Response); rpc ReadI8(ReadI8Request) returns (ReadI8Response); + rpc BeginReadI8(BeginReadI8Request) returns (BeginReadI8Response); rpc ReadSgl(ReadSglRequest) returns (ReadSglResponse); rpc ReadU16(ReadU16Request) returns (ReadU16Response); + rpc BeginReadU16(BeginReadU16Request) returns (BeginReadU16Response); rpc ReadU32(ReadU32Request) returns (ReadU32Response); + rpc BeginReadU32(BeginReadU32Request) returns (BeginReadU32Response); rpc ReadU64(ReadU64Request) returns (ReadU64Response); + rpc BeginReadU64(BeginReadU64Request) returns (BeginReadU64Response); rpc ReadU8(ReadU8Request) returns (ReadU8Response); + rpc BeginReadU8(BeginReadU8Request) returns (BeginReadU8Response); rpc ReleaseFifoElements(ReleaseFifoElementsRequest) returns (ReleaseFifoElementsResponse); rpc Reset(ResetRequest) returns (ResetResponse); rpc Run(RunRequest) returns (RunResponse); @@ -79,14 +97,22 @@ service NiFpga { rpc WriteArrayBool(WriteArrayBoolRequest) returns (WriteArrayBoolResponse); rpc WriteArrayDbl(WriteArrayDblRequest) returns (WriteArrayDblResponse); rpc WriteArrayI16(WriteArrayI16Request) returns (WriteArrayI16Response); + rpc BeginWriteArrayI16(BeginWriteArrayI16Request) returns (BeginWriteArrayI16Response); rpc WriteArrayI32(WriteArrayI32Request) returns (WriteArrayI32Response); + rpc BeginWriteArrayI32(BeginWriteArrayI32Request) returns (BeginWriteArrayI32Response); rpc WriteArrayI64(WriteArrayI64Request) returns (WriteArrayI64Response); + rpc BeginWriteArrayI64(BeginWriteArrayI64Request) returns (BeginWriteArrayI64Response); rpc WriteArrayI8(WriteArrayI8Request) returns (WriteArrayI8Response); + rpc BeginWriteArrayI8(BeginWriteArrayI8Request) returns (BeginWriteArrayI8Response); rpc WriteArraySgl(WriteArraySglRequest) returns (WriteArraySglResponse); rpc WriteArrayU16(WriteArrayU16Request) returns (WriteArrayU16Response); + rpc BeginWriteArrayU16(BeginWriteArrayU16Request) returns (BeginWriteArrayU16Response); rpc WriteArrayU32(WriteArrayU32Request) returns (WriteArrayU32Response); + rpc BeginWriteArrayU32(BeginWriteArrayU32Request) returns (BeginWriteArrayU32Response); rpc WriteArrayU64(WriteArrayU64Request) returns (WriteArrayU64Response); + rpc BeginWriteArrayU64(BeginWriteArrayU64Request) returns (BeginWriteArrayU64Response); rpc WriteArrayU8(WriteArrayU8Request) returns (WriteArrayU8Response); + rpc BeginWriteArrayU8(BeginWriteArrayU8Request) returns (BeginWriteArrayU8Response); rpc WriteBool(WriteBoolRequest) returns (WriteBoolResponse); rpc WriteDbl(WriteDblRequest) returns (WriteDblResponse); rpc WriteFifoBool(WriteFifoBoolRequest) returns (WriteFifoBoolResponse); @@ -101,14 +127,22 @@ service NiFpga { rpc WriteFifoU64(WriteFifoU64Request) returns (WriteFifoU64Response); rpc WriteFifoU8(WriteFifoU8Request) returns (WriteFifoU8Response); rpc WriteI16(WriteI16Request) returns (WriteI16Response); + rpc BeginWriteI16(BeginWriteI16Request) returns (BeginWriteI16Response); rpc WriteI32(WriteI32Request) returns (WriteI32Response); + rpc BeginWriteI32(BeginWriteI32Request) returns (BeginWriteI32Response); rpc WriteI64(WriteI64Request) returns (WriteI64Response); + rpc BeginWriteI64(BeginWriteI64Request) returns (BeginWriteI64Response); rpc WriteI8(WriteI8Request) returns (WriteI8Response); + rpc BeginWriteI8(BeginWriteI8Request) returns (BeginWriteI8Response); rpc WriteSgl(WriteSglRequest) returns (WriteSglResponse); rpc WriteU16(WriteU16Request) returns (WriteU16Response); + rpc BeginWriteU16(BeginWriteU16Request) returns (BeginWriteU16Response); rpc WriteU32(WriteU32Request) returns (WriteU32Response); + rpc BeginWriteU32(BeginWriteU32Request) returns (BeginWriteU32Response); rpc WriteU64(WriteU64Request) returns (WriteU64Response); + rpc BeginWriteU64(BeginWriteU64Request) returns (BeginWriteU64Response); rpc WriteU8(WriteU8Request) returns (WriteU8Response); + rpc BeginWriteU8(BeginWriteU8Request) returns (BeginWriteU8Response); } enum CloseAttribute { @@ -198,6 +232,41 @@ enum RunAttribute { RUN_ATTRIBUTE_WAIT_UNTIL_DONE = 1; } +message I32Data { + int32 value = 1; +} + +message U32Data { + uint32 value = 1; +} + +message I64Data { + int64 value = 1; +} + +message U64Data { + uint64 value = 1; +} + +message BoolData { + bool value = 1; +} + +message ArrayI32Data { + repeated int32 value = 1; +} + +message ArrayU32Data { + repeated uint32 value = 1; +} + +message ArrayI64Data { + repeated int64 value = 1; +} + +message ArrayU64Data { + repeated uint64 value = 1; +} message AbortRequest { nidevice_grpc.Session session = 1; } @@ -412,6 +481,17 @@ message ReadArrayI16Response { repeated int32 array = 2; } +message BeginReadArrayI16Request { + nidevice_grpc.Session session = 1; + uint32 indicator = 2; + uint32 size = 3; +} + +message BeginReadArrayI16Response { + int32 status = 1; + ni.data_monikers.Moniker moniker = 2; +} + message ReadArrayI32Request { nidevice_grpc.Session session = 1; uint32 indicator = 2; @@ -423,6 +503,17 @@ message ReadArrayI32Response { repeated int32 array = 2; } +message BeginReadArrayI32Request { + nidevice_grpc.Session session = 1; + uint32 indicator = 2; + uint32 size = 3; +} + +message BeginReadArrayI32Response { + int32 status = 1; + ni.data_monikers.Moniker moniker = 2; +} + message ReadArrayI64Request { nidevice_grpc.Session session = 1; uint32 indicator = 2; @@ -434,6 +525,17 @@ message ReadArrayI64Response { repeated int64 array = 2; } +message BeginReadArrayI64Request { + nidevice_grpc.Session session = 1; + uint32 indicator = 2; + uint32 size = 3; +} + +message BeginReadArrayI64Response { + int32 status = 1; + ni.data_monikers.Moniker moniker = 2; +} + message ReadArrayI8Request { nidevice_grpc.Session session = 1; uint32 indicator = 2; @@ -445,6 +547,17 @@ message ReadArrayI8Response { repeated int32 array = 2; } +message BeginReadArrayI8Request { + nidevice_grpc.Session session = 1; + uint32 indicator = 2; + uint32 size = 3; +} + +message BeginReadArrayI8Response { + int32 status = 1; + ni.data_monikers.Moniker moniker = 2; +} + message ReadArraySglRequest { nidevice_grpc.Session session = 1; uint32 indicator = 2; @@ -467,6 +580,17 @@ message ReadArrayU16Response { repeated uint32 array = 2; } +message BeginReadArrayU16Request { + nidevice_grpc.Session session = 1; + uint32 indicator = 2; + uint32 size = 3; +} + +message BeginReadArrayU16Response { + int32 status = 1; + ni.data_monikers.Moniker moniker = 2; +} + message ReadArrayU32Request { nidevice_grpc.Session session = 1; uint32 indicator = 2; @@ -478,6 +602,17 @@ message ReadArrayU32Response { repeated uint32 array = 2; } +message BeginReadArrayU32Request { + nidevice_grpc.Session session = 1; + uint32 indicator = 2; + uint32 size = 3; +} + +message BeginReadArrayU32Response { + int32 status = 1; + ni.data_monikers.Moniker moniker = 2; +} + message ReadArrayU64Request { nidevice_grpc.Session session = 1; uint32 indicator = 2; @@ -489,6 +624,17 @@ message ReadArrayU64Response { repeated uint64 array = 2; } +message BeginReadArrayU64Request { + nidevice_grpc.Session session = 1; + uint32 indicator = 2; + uint32 size = 3; +} + +message BeginReadArrayU64Response { + int32 status = 1; + ni.data_monikers.Moniker moniker = 2; +} + message ReadArrayU8Request { nidevice_grpc.Session session = 1; uint32 indicator = 2; @@ -500,6 +646,17 @@ message ReadArrayU8Response { repeated uint32 array = 2; } +message BeginReadArrayU8Request { + nidevice_grpc.Session session = 1; + uint32 indicator = 2; + uint32 size = 3; +} + +message BeginReadArrayU8Response { + int32 status = 1; + ni.data_monikers.Moniker moniker = 2; +} + message ReadBoolRequest { nidevice_grpc.Session session = 1; uint32 indicator = 2; @@ -673,6 +830,16 @@ message ReadI16Response { int32 value = 2; } +message BeginReadI16Request { + nidevice_grpc.Session session = 1; + uint32 indicator = 2; +} + +message BeginReadI16Response { + int32 status = 1; + ni.data_monikers.Moniker moniker = 2; +} + message ReadI32Request { nidevice_grpc.Session session = 1; uint32 indicator = 2; @@ -683,6 +850,16 @@ message ReadI32Response { int32 value = 2; } +message BeginReadI32Request { + nidevice_grpc.Session session = 1; + uint32 indicator = 2; +} + +message BeginReadI32Response { + int32 status = 1; + ni.data_monikers.Moniker moniker = 2; +} + message ReadI64Request { nidevice_grpc.Session session = 1; uint32 indicator = 2; @@ -693,6 +870,16 @@ message ReadI64Response { int64 value = 2; } +message BeginReadI64Request { + nidevice_grpc.Session session = 1; + uint32 indicator = 2; +} + +message BeginReadI64Response { + int32 status = 1; + ni.data_monikers.Moniker moniker = 2; +} + message ReadI8Request { nidevice_grpc.Session session = 1; uint32 indicator = 2; @@ -703,6 +890,16 @@ message ReadI8Response { int32 value = 2; } +message BeginReadI8Request { + nidevice_grpc.Session session = 1; + uint32 indicator = 2; +} + +message BeginReadI8Response { + int32 status = 1; + ni.data_monikers.Moniker moniker = 2; +} + message ReadSglRequest { nidevice_grpc.Session session = 1; uint32 indicator = 2; @@ -723,6 +920,16 @@ message ReadU16Response { uint32 value = 2; } +message BeginReadU16Request { + nidevice_grpc.Session session = 1; + uint32 indicator = 2; +} + +message BeginReadU16Response { + int32 status = 1; + ni.data_monikers.Moniker moniker = 2; +} + message ReadU32Request { nidevice_grpc.Session session = 1; uint32 indicator = 2; @@ -733,6 +940,16 @@ message ReadU32Response { uint32 value = 2; } +message BeginReadU32Request { + nidevice_grpc.Session session = 1; + uint32 indicator = 2; +} + +message BeginReadU32Response { + int32 status = 1; + ni.data_monikers.Moniker moniker = 2; +} + message ReadU64Request { nidevice_grpc.Session session = 1; uint32 indicator = 2; @@ -743,6 +960,16 @@ message ReadU64Response { uint64 value = 2; } +message BeginReadU64Request { + nidevice_grpc.Session session = 1; + uint32 indicator = 2; +} + +message BeginReadU64Response { + int32 status = 1; + ni.data_monikers.Moniker moniker = 2; +} + message ReadU8Request { nidevice_grpc.Session session = 1; uint32 indicator = 2; @@ -753,6 +980,16 @@ message ReadU8Response { uint32 value = 2; } +message BeginReadU8Request { + nidevice_grpc.Session session = 1; + uint32 indicator = 2; +} + +message BeginReadU8Response { + int32 status = 1; + ni.data_monikers.Moniker moniker = 2; +} + message ReleaseFifoElementsRequest { nidevice_grpc.Session session = 1; uint32 fifo = 2; @@ -908,6 +1145,16 @@ message WriteArrayI16Response { int32 status = 1; } +message BeginWriteArrayI16Request { + nidevice_grpc.Session session = 1; + uint32 control = 2; +} + +message BeginWriteArrayI16Response { + int32 status = 1; + ni.data_monikers.Moniker moniker = 2; +} + message WriteArrayI32Request { nidevice_grpc.Session session = 1; uint32 control = 2; @@ -918,6 +1165,16 @@ message WriteArrayI32Response { int32 status = 1; } +message BeginWriteArrayI32Request { + nidevice_grpc.Session session = 1; + uint32 control = 2; +} + +message BeginWriteArrayI32Response { + int32 status = 1; + ni.data_monikers.Moniker moniker = 2; +} + message WriteArrayI64Request { nidevice_grpc.Session session = 1; uint32 control = 2; @@ -928,6 +1185,16 @@ message WriteArrayI64Response { int32 status = 1; } +message BeginWriteArrayI64Request { + nidevice_grpc.Session session = 1; + uint32 control = 2; +} + +message BeginWriteArrayI64Response { + int32 status = 1; + ni.data_monikers.Moniker moniker = 2; +} + message WriteArrayI8Request { nidevice_grpc.Session session = 1; uint32 control = 2; @@ -938,6 +1205,16 @@ message WriteArrayI8Response { int32 status = 1; } +message BeginWriteArrayI8Request { + nidevice_grpc.Session session = 1; + uint32 control = 2; +} + +message BeginWriteArrayI8Response { + int32 status = 1; + ni.data_monikers.Moniker moniker = 2; +} + message WriteArraySglRequest { nidevice_grpc.Session session = 1; uint32 control = 2; @@ -958,6 +1235,16 @@ message WriteArrayU16Response { int32 status = 1; } +message BeginWriteArrayU16Request { + nidevice_grpc.Session session = 1; + uint32 control = 2; +} + +message BeginWriteArrayU16Response { + int32 status = 1; + ni.data_monikers.Moniker moniker = 2; +} + message WriteArrayU32Request { nidevice_grpc.Session session = 1; uint32 control = 2; @@ -968,6 +1255,16 @@ message WriteArrayU32Response { int32 status = 1; } +message BeginWriteArrayU32Request { + nidevice_grpc.Session session = 1; + uint32 control = 2; +} + +message BeginWriteArrayU32Response { + int32 status = 1; + ni.data_monikers.Moniker moniker = 2; +} + message WriteArrayU64Request { nidevice_grpc.Session session = 1; uint32 control = 2; @@ -978,6 +1275,16 @@ message WriteArrayU64Response { int32 status = 1; } +message BeginWriteArrayU64Request { + nidevice_grpc.Session session = 1; + uint32 control = 2; +} + +message BeginWriteArrayU64Response { + int32 status = 1; + ni.data_monikers.Moniker moniker = 2; +} + message WriteArrayU8Request { nidevice_grpc.Session session = 1; uint32 control = 2; @@ -988,6 +1295,16 @@ message WriteArrayU8Response { int32 status = 1; } +message BeginWriteArrayU8Request { + nidevice_grpc.Session session = 1; + uint32 control = 2; +} + +message BeginWriteArrayU8Response { + int32 status = 1; + ni.data_monikers.Moniker moniker = 2; +} + message WriteBoolRequest { nidevice_grpc.Session session = 1; uint32 control = 2; @@ -1150,6 +1467,16 @@ message WriteI16Response { int32 status = 1; } +message BeginWriteI16Request { + nidevice_grpc.Session session = 1; + uint32 control = 2; +} + +message BeginWriteI16Response { + int32 status = 1; + ni.data_monikers.Moniker moniker = 2; +} + message WriteI32Request { nidevice_grpc.Session session = 1; uint32 control = 2; @@ -1160,6 +1487,16 @@ message WriteI32Response { int32 status = 1; } +message BeginWriteI32Request { + nidevice_grpc.Session session = 1; + uint32 control = 2; +} + +message BeginWriteI32Response { + int32 status = 1; + ni.data_monikers.Moniker moniker = 2; +} + message WriteI64Request { nidevice_grpc.Session session = 1; uint32 control = 2; @@ -1170,6 +1507,16 @@ message WriteI64Response { int32 status = 1; } +message BeginWriteI64Request { + nidevice_grpc.Session session = 1; + uint32 control = 2; +} + +message BeginWriteI64Response { + int32 status = 1; + ni.data_monikers.Moniker moniker = 2; +} + message WriteI8Request { nidevice_grpc.Session session = 1; uint32 control = 2; @@ -1180,6 +1527,16 @@ message WriteI8Response { int32 status = 1; } +message BeginWriteI8Request { + nidevice_grpc.Session session = 1; + uint32 control = 2; +} + +message BeginWriteI8Response { + int32 status = 1; + ni.data_monikers.Moniker moniker = 2; +} + message WriteSglRequest { nidevice_grpc.Session session = 1; uint32 control = 2; @@ -1200,6 +1557,16 @@ message WriteU16Response { int32 status = 1; } +message BeginWriteU16Request { + nidevice_grpc.Session session = 1; + uint32 control = 2; +} + +message BeginWriteU16Response { + int32 status = 1; + ni.data_monikers.Moniker moniker = 2; +} + message WriteU32Request { nidevice_grpc.Session session = 1; uint32 control = 2; @@ -1210,6 +1577,16 @@ message WriteU32Response { int32 status = 1; } +message BeginWriteU32Request { + nidevice_grpc.Session session = 1; + uint32 control = 2; +} + +message BeginWriteU32Response { + int32 status = 1; + ni.data_monikers.Moniker moniker = 2; +} + message WriteU64Request { nidevice_grpc.Session session = 1; uint32 control = 2; @@ -1220,6 +1597,16 @@ message WriteU64Response { int32 status = 1; } +message BeginWriteU64Request { + nidevice_grpc.Session session = 1; + uint32 control = 2; +} + +message BeginWriteU64Response { + int32 status = 1; + ni.data_monikers.Moniker moniker = 2; +} + message WriteU8Request { nidevice_grpc.Session session = 1; uint32 control = 2; @@ -1230,3 +1617,13 @@ message WriteU8Response { int32 status = 1; } +message BeginWriteU8Request { + nidevice_grpc.Session session = 1; + uint32 control = 2; +} + +message BeginWriteU8Response { + int32 status = 1; + ni.data_monikers.Moniker moniker = 2; +} + diff --git a/generated/nifpga/nifpga_client.cpp b/generated/nifpga/nifpga_client.cpp index 0aebb58ad..8b33126ca 100644 --- a/generated/nifpga/nifpga_client.cpp +++ b/generated/nifpga/nifpga_client.cpp @@ -409,6 +409,25 @@ read_array_i16(const StubPtr& stub, const nidevice_grpc::Session& session, const return response; } +BeginReadArrayI16Response +begin_read_array_i16(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& indicator, const pb::uint32& size) +{ + ::grpc::ClientContext context; + + auto request = BeginReadArrayI16Request{}; + request.mutable_session()->CopyFrom(session); + request.set_indicator(indicator); + request.set_size(size); + + auto response = BeginReadArrayI16Response{}; + + raise_if_error( + stub->BeginReadArrayI16(&context, request, &response), + context); + + return response; +} + ReadArrayI32Response read_array_i32(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& indicator, const pb::uint32& size) { @@ -428,6 +447,25 @@ read_array_i32(const StubPtr& stub, const nidevice_grpc::Session& session, const return response; } +BeginReadArrayI32Response +begin_read_array_i32(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& indicator, const pb::uint32& size) +{ + ::grpc::ClientContext context; + + auto request = BeginReadArrayI32Request{}; + request.mutable_session()->CopyFrom(session); + request.set_indicator(indicator); + request.set_size(size); + + auto response = BeginReadArrayI32Response{}; + + raise_if_error( + stub->BeginReadArrayI32(&context, request, &response), + context); + + return response; +} + ReadArrayI64Response read_array_i64(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& indicator, const pb::uint32& size) { @@ -447,6 +485,25 @@ read_array_i64(const StubPtr& stub, const nidevice_grpc::Session& session, const return response; } +BeginReadArrayI64Response +begin_read_array_i64(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& indicator, const pb::uint32& size) +{ + ::grpc::ClientContext context; + + auto request = BeginReadArrayI64Request{}; + request.mutable_session()->CopyFrom(session); + request.set_indicator(indicator); + request.set_size(size); + + auto response = BeginReadArrayI64Response{}; + + raise_if_error( + stub->BeginReadArrayI64(&context, request, &response), + context); + + return response; +} + ReadArrayI8Response read_array_i8(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& indicator, const pb::uint32& size) { @@ -466,6 +523,25 @@ read_array_i8(const StubPtr& stub, const nidevice_grpc::Session& session, const return response; } +BeginReadArrayI8Response +begin_read_array_i8(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& indicator, const pb::uint32& size) +{ + ::grpc::ClientContext context; + + auto request = BeginReadArrayI8Request{}; + request.mutable_session()->CopyFrom(session); + request.set_indicator(indicator); + request.set_size(size); + + auto response = BeginReadArrayI8Response{}; + + raise_if_error( + stub->BeginReadArrayI8(&context, request, &response), + context); + + return response; +} + ReadArraySglResponse read_array_sgl(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& indicator, const pb::uint32& size) { @@ -504,6 +580,25 @@ read_array_u16(const StubPtr& stub, const nidevice_grpc::Session& session, const return response; } +BeginReadArrayU16Response +begin_read_array_u16(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& indicator, const pb::uint32& size) +{ + ::grpc::ClientContext context; + + auto request = BeginReadArrayU16Request{}; + request.mutable_session()->CopyFrom(session); + request.set_indicator(indicator); + request.set_size(size); + + auto response = BeginReadArrayU16Response{}; + + raise_if_error( + stub->BeginReadArrayU16(&context, request, &response), + context); + + return response; +} + ReadArrayU32Response read_array_u32(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& indicator, const pb::uint32& size) { @@ -523,6 +618,25 @@ read_array_u32(const StubPtr& stub, const nidevice_grpc::Session& session, const return response; } +BeginReadArrayU32Response +begin_read_array_u32(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& indicator, const pb::uint32& size) +{ + ::grpc::ClientContext context; + + auto request = BeginReadArrayU32Request{}; + request.mutable_session()->CopyFrom(session); + request.set_indicator(indicator); + request.set_size(size); + + auto response = BeginReadArrayU32Response{}; + + raise_if_error( + stub->BeginReadArrayU32(&context, request, &response), + context); + + return response; +} + ReadArrayU64Response read_array_u64(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& indicator, const pb::uint32& size) { @@ -542,6 +656,25 @@ read_array_u64(const StubPtr& stub, const nidevice_grpc::Session& session, const return response; } +BeginReadArrayU64Response +begin_read_array_u64(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& indicator, const pb::uint32& size) +{ + ::grpc::ClientContext context; + + auto request = BeginReadArrayU64Request{}; + request.mutable_session()->CopyFrom(session); + request.set_indicator(indicator); + request.set_size(size); + + auto response = BeginReadArrayU64Response{}; + + raise_if_error( + stub->BeginReadArrayU64(&context, request, &response), + context); + + return response; +} + ReadArrayU8Response read_array_u8(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& indicator, const pb::uint32& size) { @@ -561,6 +694,25 @@ read_array_u8(const StubPtr& stub, const nidevice_grpc::Session& session, const return response; } +BeginReadArrayU8Response +begin_read_array_u8(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& indicator, const pb::uint32& size) +{ + ::grpc::ClientContext context; + + auto request = BeginReadArrayU8Request{}; + request.mutable_session()->CopyFrom(session); + request.set_indicator(indicator); + request.set_size(size); + + auto response = BeginReadArrayU8Response{}; + + raise_if_error( + stub->BeginReadArrayU8(&context, request, &response), + context); + + return response; +} + ReadBoolResponse read_bool(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& indicator) { @@ -835,6 +987,24 @@ read_i16(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::u return response; } +BeginReadI16Response +begin_read_i16(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& indicator) +{ + ::grpc::ClientContext context; + + auto request = BeginReadI16Request{}; + request.mutable_session()->CopyFrom(session); + request.set_indicator(indicator); + + auto response = BeginReadI16Response{}; + + raise_if_error( + stub->BeginReadI16(&context, request, &response), + context); + + return response; +} + ReadI32Response read_i32(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& indicator) { @@ -853,6 +1023,24 @@ read_i32(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::u return response; } +BeginReadI32Response +begin_read_i32(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& indicator) +{ + ::grpc::ClientContext context; + + auto request = BeginReadI32Request{}; + request.mutable_session()->CopyFrom(session); + request.set_indicator(indicator); + + auto response = BeginReadI32Response{}; + + raise_if_error( + stub->BeginReadI32(&context, request, &response), + context); + + return response; +} + ReadI64Response read_i64(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& indicator) { @@ -871,6 +1059,24 @@ read_i64(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::u return response; } +BeginReadI64Response +begin_read_i64(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& indicator) +{ + ::grpc::ClientContext context; + + auto request = BeginReadI64Request{}; + request.mutable_session()->CopyFrom(session); + request.set_indicator(indicator); + + auto response = BeginReadI64Response{}; + + raise_if_error( + stub->BeginReadI64(&context, request, &response), + context); + + return response; +} + ReadI8Response read_i8(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& indicator) { @@ -889,6 +1095,24 @@ read_i8(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::ui return response; } +BeginReadI8Response +begin_read_i8(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& indicator) +{ + ::grpc::ClientContext context; + + auto request = BeginReadI8Request{}; + request.mutable_session()->CopyFrom(session); + request.set_indicator(indicator); + + auto response = BeginReadI8Response{}; + + raise_if_error( + stub->BeginReadI8(&context, request, &response), + context); + + return response; +} + ReadSglResponse read_sgl(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& indicator) { @@ -925,6 +1149,24 @@ read_u16(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::u return response; } +BeginReadU16Response +begin_read_u16(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& indicator) +{ + ::grpc::ClientContext context; + + auto request = BeginReadU16Request{}; + request.mutable_session()->CopyFrom(session); + request.set_indicator(indicator); + + auto response = BeginReadU16Response{}; + + raise_if_error( + stub->BeginReadU16(&context, request, &response), + context); + + return response; +} + ReadU32Response read_u32(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& indicator) { @@ -943,6 +1185,24 @@ read_u32(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::u return response; } +BeginReadU32Response +begin_read_u32(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& indicator) +{ + ::grpc::ClientContext context; + + auto request = BeginReadU32Request{}; + request.mutable_session()->CopyFrom(session); + request.set_indicator(indicator); + + auto response = BeginReadU32Response{}; + + raise_if_error( + stub->BeginReadU32(&context, request, &response), + context); + + return response; +} + ReadU64Response read_u64(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& indicator) { @@ -961,6 +1221,24 @@ read_u64(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::u return response; } +BeginReadU64Response +begin_read_u64(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& indicator) +{ + ::grpc::ClientContext context; + + auto request = BeginReadU64Request{}; + request.mutable_session()->CopyFrom(session); + request.set_indicator(indicator); + + auto response = BeginReadU64Response{}; + + raise_if_error( + stub->BeginReadU64(&context, request, &response), + context); + + return response; +} + ReadU8Response read_u8(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& indicator) { @@ -979,6 +1257,24 @@ read_u8(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::ui return response; } +BeginReadU8Response +begin_read_u8(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& indicator) +{ + ::grpc::ClientContext context; + + auto request = BeginReadU8Request{}; + request.mutable_session()->CopyFrom(session); + request.set_indicator(indicator); + + auto response = BeginReadU8Response{}; + + raise_if_error( + stub->BeginReadU8(&context, request, &response), + context); + + return response; +} + ReleaseFifoElementsResponse release_fifo_elements(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& fifo, const pb::uint32& elements) { @@ -1278,6 +1574,24 @@ write_array_i16(const StubPtr& stub, const nidevice_grpc::Session& session, cons return response; } +BeginWriteArrayI16Response +begin_write_array_i16(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& control) +{ + ::grpc::ClientContext context; + + auto request = BeginWriteArrayI16Request{}; + request.mutable_session()->CopyFrom(session); + request.set_control(control); + + auto response = BeginWriteArrayI16Response{}; + + raise_if_error( + stub->BeginWriteArrayI16(&context, request, &response), + context); + + return response; +} + WriteArrayI32Response write_array_i32(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& control, const std::vector& array) { @@ -1297,6 +1611,24 @@ write_array_i32(const StubPtr& stub, const nidevice_grpc::Session& session, cons return response; } +BeginWriteArrayI32Response +begin_write_array_i32(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& control) +{ + ::grpc::ClientContext context; + + auto request = BeginWriteArrayI32Request{}; + request.mutable_session()->CopyFrom(session); + request.set_control(control); + + auto response = BeginWriteArrayI32Response{}; + + raise_if_error( + stub->BeginWriteArrayI32(&context, request, &response), + context); + + return response; +} + WriteArrayI64Response write_array_i64(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& control, const std::vector& array) { @@ -1316,6 +1648,24 @@ write_array_i64(const StubPtr& stub, const nidevice_grpc::Session& session, cons return response; } +BeginWriteArrayI64Response +begin_write_array_i64(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& control) +{ + ::grpc::ClientContext context; + + auto request = BeginWriteArrayI64Request{}; + request.mutable_session()->CopyFrom(session); + request.set_control(control); + + auto response = BeginWriteArrayI64Response{}; + + raise_if_error( + stub->BeginWriteArrayI64(&context, request, &response), + context); + + return response; +} + WriteArrayI8Response write_array_i8(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& control, const std::vector& array) { @@ -1335,6 +1685,24 @@ write_array_i8(const StubPtr& stub, const nidevice_grpc::Session& session, const return response; } +BeginWriteArrayI8Response +begin_write_array_i8(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& control) +{ + ::grpc::ClientContext context; + + auto request = BeginWriteArrayI8Request{}; + request.mutable_session()->CopyFrom(session); + request.set_control(control); + + auto response = BeginWriteArrayI8Response{}; + + raise_if_error( + stub->BeginWriteArrayI8(&context, request, &response), + context); + + return response; +} + WriteArraySglResponse write_array_sgl(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& control, const std::vector& array) { @@ -1373,6 +1741,24 @@ write_array_u16(const StubPtr& stub, const nidevice_grpc::Session& session, cons return response; } +BeginWriteArrayU16Response +begin_write_array_u16(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& control) +{ + ::grpc::ClientContext context; + + auto request = BeginWriteArrayU16Request{}; + request.mutable_session()->CopyFrom(session); + request.set_control(control); + + auto response = BeginWriteArrayU16Response{}; + + raise_if_error( + stub->BeginWriteArrayU16(&context, request, &response), + context); + + return response; +} + WriteArrayU32Response write_array_u32(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& control, const std::vector& array) { @@ -1392,6 +1778,24 @@ write_array_u32(const StubPtr& stub, const nidevice_grpc::Session& session, cons return response; } +BeginWriteArrayU32Response +begin_write_array_u32(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& control) +{ + ::grpc::ClientContext context; + + auto request = BeginWriteArrayU32Request{}; + request.mutable_session()->CopyFrom(session); + request.set_control(control); + + auto response = BeginWriteArrayU32Response{}; + + raise_if_error( + stub->BeginWriteArrayU32(&context, request, &response), + context); + + return response; +} + WriteArrayU64Response write_array_u64(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& control, const std::vector& array) { @@ -1411,6 +1815,24 @@ write_array_u64(const StubPtr& stub, const nidevice_grpc::Session& session, cons return response; } +BeginWriteArrayU64Response +begin_write_array_u64(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& control) +{ + ::grpc::ClientContext context; + + auto request = BeginWriteArrayU64Request{}; + request.mutable_session()->CopyFrom(session); + request.set_control(control); + + auto response = BeginWriteArrayU64Response{}; + + raise_if_error( + stub->BeginWriteArrayU64(&context, request, &response), + context); + + return response; +} + WriteArrayU8Response write_array_u8(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& control, const std::vector& array) { @@ -1430,6 +1852,24 @@ write_array_u8(const StubPtr& stub, const nidevice_grpc::Session& session, const return response; } +BeginWriteArrayU8Response +begin_write_array_u8(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& control) +{ + ::grpc::ClientContext context; + + auto request = BeginWriteArrayU8Request{}; + request.mutable_session()->CopyFrom(session); + request.set_control(control); + + auto response = BeginWriteArrayU8Response{}; + + raise_if_error( + stub->BeginWriteArrayU8(&context, request, &response), + context); + + return response; +} + WriteBoolResponse write_bool(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& control, const bool& value) { @@ -1707,6 +2147,24 @@ write_i16(const StubPtr& stub, const nidevice_grpc::Session& session, const pb:: return response; } +BeginWriteI16Response +begin_write_i16(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& control) +{ + ::grpc::ClientContext context; + + auto request = BeginWriteI16Request{}; + request.mutable_session()->CopyFrom(session); + request.set_control(control); + + auto response = BeginWriteI16Response{}; + + raise_if_error( + stub->BeginWriteI16(&context, request, &response), + context); + + return response; +} + WriteI32Response write_i32(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& control, const pb::int32& value) { @@ -1726,6 +2184,24 @@ write_i32(const StubPtr& stub, const nidevice_grpc::Session& session, const pb:: return response; } +BeginWriteI32Response +begin_write_i32(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& control) +{ + ::grpc::ClientContext context; + + auto request = BeginWriteI32Request{}; + request.mutable_session()->CopyFrom(session); + request.set_control(control); + + auto response = BeginWriteI32Response{}; + + raise_if_error( + stub->BeginWriteI32(&context, request, &response), + context); + + return response; +} + WriteI64Response write_i64(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& control, const pb::int64& value) { @@ -1745,6 +2221,24 @@ write_i64(const StubPtr& stub, const nidevice_grpc::Session& session, const pb:: return response; } +BeginWriteI64Response +begin_write_i64(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& control) +{ + ::grpc::ClientContext context; + + auto request = BeginWriteI64Request{}; + request.mutable_session()->CopyFrom(session); + request.set_control(control); + + auto response = BeginWriteI64Response{}; + + raise_if_error( + stub->BeginWriteI64(&context, request, &response), + context); + + return response; +} + WriteI8Response write_i8(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& control, const pb::int32& value) { @@ -1764,6 +2258,24 @@ write_i8(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::u return response; } +BeginWriteI8Response +begin_write_i8(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& control) +{ + ::grpc::ClientContext context; + + auto request = BeginWriteI8Request{}; + request.mutable_session()->CopyFrom(session); + request.set_control(control); + + auto response = BeginWriteI8Response{}; + + raise_if_error( + stub->BeginWriteI8(&context, request, &response), + context); + + return response; +} + WriteSglResponse write_sgl(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& control, const float& value) { @@ -1802,6 +2314,24 @@ write_u16(const StubPtr& stub, const nidevice_grpc::Session& session, const pb:: return response; } +BeginWriteU16Response +begin_write_u16(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& control) +{ + ::grpc::ClientContext context; + + auto request = BeginWriteU16Request{}; + request.mutable_session()->CopyFrom(session); + request.set_control(control); + + auto response = BeginWriteU16Response{}; + + raise_if_error( + stub->BeginWriteU16(&context, request, &response), + context); + + return response; +} + WriteU32Response write_u32(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& control, const pb::uint32& value) { @@ -1821,6 +2351,24 @@ write_u32(const StubPtr& stub, const nidevice_grpc::Session& session, const pb:: return response; } +BeginWriteU32Response +begin_write_u32(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& control) +{ + ::grpc::ClientContext context; + + auto request = BeginWriteU32Request{}; + request.mutable_session()->CopyFrom(session); + request.set_control(control); + + auto response = BeginWriteU32Response{}; + + raise_if_error( + stub->BeginWriteU32(&context, request, &response), + context); + + return response; +} + WriteU64Response write_u64(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& control, const pb::uint64& value) { @@ -1840,6 +2388,24 @@ write_u64(const StubPtr& stub, const nidevice_grpc::Session& session, const pb:: return response; } +BeginWriteU64Response +begin_write_u64(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& control) +{ + ::grpc::ClientContext context; + + auto request = BeginWriteU64Request{}; + request.mutable_session()->CopyFrom(session); + request.set_control(control); + + auto response = BeginWriteU64Response{}; + + raise_if_error( + stub->BeginWriteU64(&context, request, &response), + context); + + return response; +} + WriteU8Response write_u8(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& control, const pb::uint32& value) { @@ -1859,5 +2425,23 @@ write_u8(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::u return response; } +BeginWriteU8Response +begin_write_u8(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& control) +{ + ::grpc::ClientContext context; + + auto request = BeginWriteU8Request{}; + request.mutable_session()->CopyFrom(session); + request.set_control(control); + + auto response = BeginWriteU8Response{}; + + raise_if_error( + stub->BeginWriteU8(&context, request, &response), + context); + + return response; +} + } // namespace nifpga_grpc::experimental::client diff --git a/generated/nifpga/nifpga_client.h b/generated/nifpga/nifpga_client.h index 76d25aeac..217de441f 100644 --- a/generated/nifpga/nifpga_client.h +++ b/generated/nifpga/nifpga_client.h @@ -41,14 +41,22 @@ OpenResponse open(const StubPtr& stub, const std::string& bitfile, const std::st ReadArrayBoolResponse read_array_bool(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& indicator, const pb::uint32& size); ReadArrayDblResponse read_array_dbl(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& indicator, const pb::uint32& size); ReadArrayI16Response read_array_i16(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& indicator, const pb::uint32& size); +BeginReadArrayI16Response begin_read_array_i16(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& indicator, const pb::uint32& size); ReadArrayI32Response read_array_i32(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& indicator, const pb::uint32& size); +BeginReadArrayI32Response begin_read_array_i32(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& indicator, const pb::uint32& size); ReadArrayI64Response read_array_i64(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& indicator, const pb::uint32& size); +BeginReadArrayI64Response begin_read_array_i64(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& indicator, const pb::uint32& size); ReadArrayI8Response read_array_i8(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& indicator, const pb::uint32& size); +BeginReadArrayI8Response begin_read_array_i8(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& indicator, const pb::uint32& size); ReadArraySglResponse read_array_sgl(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& indicator, const pb::uint32& size); ReadArrayU16Response read_array_u16(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& indicator, const pb::uint32& size); +BeginReadArrayU16Response begin_read_array_u16(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& indicator, const pb::uint32& size); ReadArrayU32Response read_array_u32(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& indicator, const pb::uint32& size); +BeginReadArrayU32Response begin_read_array_u32(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& indicator, const pb::uint32& size); ReadArrayU64Response read_array_u64(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& indicator, const pb::uint32& size); +BeginReadArrayU64Response begin_read_array_u64(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& indicator, const pb::uint32& size); ReadArrayU8Response read_array_u8(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& indicator, const pb::uint32& size); +BeginReadArrayU8Response begin_read_array_u8(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& indicator, const pb::uint32& size); ReadBoolResponse read_bool(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& indicator); ReadDblResponse read_dbl(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& indicator); ReadFifoBoolResponse read_fifo_bool(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& fifo, const pb::uint32& number_of_elements, const pb::uint32& timeout); @@ -63,14 +71,22 @@ ReadFifoU32Response read_fifo_u32(const StubPtr& stub, const nidevice_grpc::Sess ReadFifoU64Response read_fifo_u64(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& fifo, const pb::uint32& number_of_elements, const pb::uint32& timeout); ReadFifoU8Response read_fifo_u8(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& fifo, const pb::uint32& number_of_elements, const pb::uint32& timeout); ReadI16Response read_i16(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& indicator); +BeginReadI16Response begin_read_i16(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& indicator); ReadI32Response read_i32(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& indicator); +BeginReadI32Response begin_read_i32(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& indicator); ReadI64Response read_i64(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& indicator); +BeginReadI64Response begin_read_i64(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& indicator); ReadI8Response read_i8(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& indicator); +BeginReadI8Response begin_read_i8(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& indicator); ReadSglResponse read_sgl(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& indicator); ReadU16Response read_u16(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& indicator); +BeginReadU16Response begin_read_u16(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& indicator); ReadU32Response read_u32(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& indicator); +BeginReadU32Response begin_read_u32(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& indicator); ReadU64Response read_u64(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& indicator); +BeginReadU64Response begin_read_u64(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& indicator); ReadU8Response read_u8(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& indicator); +BeginReadU8Response begin_read_u8(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& indicator); ReleaseFifoElementsResponse release_fifo_elements(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& fifo, const pb::uint32& elements); ResetResponse reset(const StubPtr& stub, const nidevice_grpc::Session& session); RunResponse run(const StubPtr& stub, const nidevice_grpc::Session& session, const simple_variant& attribute); @@ -85,14 +101,22 @@ WaitOnIrqsResponse wait_on_irqs(const StubPtr& stub, const nidevice_grpc::Sessio WriteArrayBoolResponse write_array_bool(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& control, const std::vector& array); WriteArrayDblResponse write_array_dbl(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& control, const std::vector& array); WriteArrayI16Response write_array_i16(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& control, const std::vector& array); +BeginWriteArrayI16Response begin_write_array_i16(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& control); WriteArrayI32Response write_array_i32(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& control, const std::vector& array); +BeginWriteArrayI32Response begin_write_array_i32(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& control); WriteArrayI64Response write_array_i64(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& control, const std::vector& array); +BeginWriteArrayI64Response begin_write_array_i64(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& control); WriteArrayI8Response write_array_i8(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& control, const std::vector& array); +BeginWriteArrayI8Response begin_write_array_i8(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& control); WriteArraySglResponse write_array_sgl(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& control, const std::vector& array); WriteArrayU16Response write_array_u16(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& control, const std::vector& array); +BeginWriteArrayU16Response begin_write_array_u16(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& control); WriteArrayU32Response write_array_u32(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& control, const std::vector& array); +BeginWriteArrayU32Response begin_write_array_u32(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& control); WriteArrayU64Response write_array_u64(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& control, const std::vector& array); +BeginWriteArrayU64Response begin_write_array_u64(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& control); WriteArrayU8Response write_array_u8(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& control, const std::vector& array); +BeginWriteArrayU8Response begin_write_array_u8(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& control); WriteBoolResponse write_bool(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& control, const bool& value); WriteDblResponse write_dbl(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& control, const double& value); WriteFifoBoolResponse write_fifo_bool(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& fifo, const std::vector& data, const pb::uint32& timeout); @@ -107,14 +131,22 @@ WriteFifoU32Response write_fifo_u32(const StubPtr& stub, const nidevice_grpc::Se WriteFifoU64Response write_fifo_u64(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& fifo, const std::vector& data, const pb::uint32& timeout); WriteFifoU8Response write_fifo_u8(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& fifo, const std::vector& data, const pb::uint32& timeout); WriteI16Response write_i16(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& control, const pb::int32& value); +BeginWriteI16Response begin_write_i16(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& control); WriteI32Response write_i32(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& control, const pb::int32& value); +BeginWriteI32Response begin_write_i32(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& control); WriteI64Response write_i64(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& control, const pb::int64& value); +BeginWriteI64Response begin_write_i64(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& control); WriteI8Response write_i8(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& control, const pb::int32& value); +BeginWriteI8Response begin_write_i8(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& control); WriteSglResponse write_sgl(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& control, const float& value); WriteU16Response write_u16(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& control, const pb::uint32& value); +BeginWriteU16Response begin_write_u16(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& control); WriteU32Response write_u32(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& control, const pb::uint32& value); +BeginWriteU32Response begin_write_u32(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& control); WriteU64Response write_u64(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& control, const pb::uint64& value); +BeginWriteU64Response begin_write_u64(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& control); WriteU8Response write_u8(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& control, const pb::uint32& value); +BeginWriteU8Response begin_write_u8(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& control); } // namespace nifpga_grpc::experimental::client diff --git a/generated/nifpga/nifpga_service.cpp b/generated/nifpga/nifpga_service.cpp index 383305eae..e695fa25f 100644 --- a/generated/nifpga/nifpga_service.cpp +++ b/generated/nifpga/nifpga_service.cpp @@ -12,6 +12,8 @@ #include #include #include +#include +#include namespace nifpga_grpc { @@ -41,6 +43,73 @@ namespace nifpga_grpc { return status >= 0; } +void RegisterMoniker() +{ + + ::ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerReadArrayI16", MonikerReadArrayI16); + + ::ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerReadArrayI32", MonikerReadArrayI32); + + ::ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerReadArrayI64", MonikerReadArrayI64); + + ::ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerReadArrayI8", MonikerReadArrayI8); + + ::ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerReadArrayU16", MonikerReadArrayU16); + + ::ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerReadArrayU32", MonikerReadArrayU32); + + ::ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerReadArrayU64", MonikerReadArrayU64); + + ::ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerReadArrayU8", MonikerReadArrayU8); + + ::ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerReadI16", MonikerReadI16); + + ::ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerReadI32", MonikerReadI32); + + ::ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerReadI64", MonikerReadI64); + + ::ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerReadI8", MonikerReadI8); + + ::ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerReadU16", MonikerReadU16); + + ::ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerReadU32", MonikerReadU32); + + ::ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerReadU64", MonikerReadU64); + + ::ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerReadU8", MonikerReadU8); + + ::ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerWriteArrayI16", MonikerWriteArrayI16); + + ::ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerWriteArrayI32", MonikerWriteArrayI32); + + ::ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerWriteArrayI64", MonikerWriteArrayI64); + + ::ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerWriteArrayI8", MonikerWriteArrayI8); + + ::ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerWriteArrayU16", MonikerWriteArrayU16); + + ::ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerWriteArrayU32", MonikerWriteArrayU32); + + ::ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerWriteArrayU64", MonikerWriteArrayU64); + + ::ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerWriteArrayU8", MonikerWriteArrayU8); + + ::ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerWriteI16", MonikerWriteI16); + + ::ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerWriteI32", MonikerWriteI32); + + ::ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerWriteI64", MonikerWriteI64); + + ::ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerWriteI8", MonikerWriteI8); + + ::ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerWriteU16", MonikerWriteU16); + + ::ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerWriteU32", MonikerWriteU32); + + ::ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerWriteU64", MonikerWriteU64); + + ::ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerWriteU8", MonikerWriteU8); +} //--------------------------------------------------------------------- //--------------------------------------------------------------------- ::grpc::Status NiFpgaService::Abort(::grpc::ServerContext* context, const AbortRequest* request, AbortResponse* response) @@ -633,6 +702,71 @@ namespace nifpga_grpc { } } + +struct MonikerReadArrayI16Data +{ + NiFpga_Session session; + uint32_t indicator; + size_t size; + nifpga_grpc::ArrayI32Data data; + std::shared_ptr library; +}; + +::grpc::Status NiFpgaService::BeginReadArrayI16(::grpc::ServerContext* context, const BeginReadArrayI16Request* request, BeginReadArrayI16Response* response) +{ + if (context->IsCancelled()) { + return ::grpc::Status::CANCELLED; + } + try { + auto session_grpc_session = request->session(); + NiFpga_Session session = session_repository_->access_session(session_grpc_session.name()); + uint32_t indicator = request->indicator(); + size_t size = request->size(); + + MonikerReadArrayI16Data* data = new MonikerReadArrayI16Data(); + data->session = session; + data->indicator = indicator; + data->size = size; + data->library = std::shared_ptr(library_); + + data->data.mutable_value()->Reserve(request->size()); + data->data.mutable_value()->Resize(request->size(), 0); + ni::data_monikers::Moniker* moniker = new ni::data_monikers::Moniker(); + ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerReadArrayI16", data, *moniker); + response->set_allocated_moniker(moniker); + return ::grpc::Status::OK; + } + catch (std::exception& ex) { + return ::grpc::Status(::grpc::UNKNOWN, ex.what()); + } +} +::grpc::Status MonikerReadArrayI16(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData) +{ + MonikerReadArrayI16Data* function_data = (MonikerReadArrayI16Data*)data; + auto library = function_data->library; + + auto session = function_data->session; + auto indicator = function_data->indicator; + auto size = function_data->size; + + std::vector array(size); + auto status = library->ReadArrayI16(session, indicator, array.data(), size); + if (status >= 0) { + std::transform( + array.begin(), + array.begin() + size, + function_data->data.mutable_value()->begin(), + [&](auto x) { + return x; + }); + packedData.PackFrom(function_data->data); + } + if (status < 0) { + std::cout << "MonikerReadArrayI16 error: " << status << std::endl; + } + return ::grpc::Status::OK; +} + //--------------------------------------------------------------------- //--------------------------------------------------------------------- ::grpc::Status NiFpgaService::ReadArrayI32(::grpc::ServerContext* context, const ReadArrayI32Request* request, ReadArrayI32Response* response) @@ -659,6 +793,71 @@ namespace nifpga_grpc { } } + +struct MonikerReadArrayI32Data +{ + NiFpga_Session session; + uint32_t indicator; + size_t size; + nifpga_grpc::ArrayI32Data data; + std::shared_ptr library; +}; + +::grpc::Status NiFpgaService::BeginReadArrayI32(::grpc::ServerContext* context, const BeginReadArrayI32Request* request, BeginReadArrayI32Response* response) +{ + if (context->IsCancelled()) { + return ::grpc::Status::CANCELLED; + } + try { + auto session_grpc_session = request->session(); + NiFpga_Session session = session_repository_->access_session(session_grpc_session.name()); + uint32_t indicator = request->indicator(); + size_t size = request->size(); + + MonikerReadArrayI32Data* data = new MonikerReadArrayI32Data(); + data->session = session; + data->indicator = indicator; + data->size = size; + data->library = std::shared_ptr(library_); + + data->data.mutable_value()->Reserve(request->size()); + data->data.mutable_value()->Resize(request->size(), 0); + ni::data_monikers::Moniker* moniker = new ni::data_monikers::Moniker(); + ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerReadArrayI32", data, *moniker); + response->set_allocated_moniker(moniker); + return ::grpc::Status::OK; + } + catch (std::exception& ex) { + return ::grpc::Status(::grpc::UNKNOWN, ex.what()); + } +} +::grpc::Status MonikerReadArrayI32(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData) +{ + MonikerReadArrayI32Data* function_data = (MonikerReadArrayI32Data*)data; + auto library = function_data->library; + + auto session = function_data->session; + auto indicator = function_data->indicator; + auto size = function_data->size; + + int32_t* array = new int32_t[size]; + auto status = library->ReadArrayI32(session, indicator, array, size); + if (status >= 0) { + std::transform( + array, + array + size, + function_data->data.mutable_value()->begin(), + [&](auto x) { + return x; + }); + packedData.PackFrom(function_data->data); + } + if (status < 0) { + std::cout << "MonikerReadArrayI32 error: " << status << std::endl; + } + return ::grpc::Status::OK; +} + //--------------------------------------------------------------------- //--------------------------------------------------------------------- ::grpc::Status NiFpgaService::ReadArrayI64(::grpc::ServerContext* context, const ReadArrayI64Request* request, ReadArrayI64Response* response) @@ -685,6 +884,71 @@ namespace nifpga_grpc { } } + +struct MonikerReadArrayI64Data +{ + NiFpga_Session session; + uint32_t indicator; + size_t size; + nifpga_grpc::ArrayI64Data data; + std::shared_ptr library; +}; + +::grpc::Status NiFpgaService::BeginReadArrayI64(::grpc::ServerContext* context, const BeginReadArrayI64Request* request, BeginReadArrayI64Response* response) +{ + if (context->IsCancelled()) { + return ::grpc::Status::CANCELLED; + } + try { + auto session_grpc_session = request->session(); + NiFpga_Session session = session_repository_->access_session(session_grpc_session.name()); + uint32_t indicator = request->indicator(); + size_t size = request->size(); + + MonikerReadArrayI64Data* data = new MonikerReadArrayI64Data(); + data->session = session; + data->indicator = indicator; + data->size = size; + data->library = std::shared_ptr(library_); + + data->data.mutable_value()->Reserve(request->size()); + data->data.mutable_value()->Resize(request->size(), 0); + ni::data_monikers::Moniker* moniker = new ni::data_monikers::Moniker(); + ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerReadArrayI64", data, *moniker); + response->set_allocated_moniker(moniker); + return ::grpc::Status::OK; + } + catch (std::exception& ex) { + return ::grpc::Status(::grpc::UNKNOWN, ex.what()); + } +} +::grpc::Status MonikerReadArrayI64(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData) +{ + MonikerReadArrayI64Data* function_data = (MonikerReadArrayI64Data*)data; + auto library = function_data->library; + + auto session = function_data->session; + auto indicator = function_data->indicator; + auto size = function_data->size; + + int64_t* array = new int64_t[size]; + auto status = library->ReadArrayI64(session, indicator, array, size); + if (status >= 0) { + std::transform( + array, + array + size, + function_data->data.mutable_value()->begin(), + [&](auto x) { + return x; + }); + packedData.PackFrom(function_data->data); + } + if (status < 0) { + std::cout << "MonikerReadArrayI64 error: " << status << std::endl; + } + return ::grpc::Status::OK; +} + //--------------------------------------------------------------------- //--------------------------------------------------------------------- ::grpc::Status NiFpgaService::ReadArrayI8(::grpc::ServerContext* context, const ReadArrayI8Request* request, ReadArrayI8Response* response) @@ -719,6 +983,71 @@ namespace nifpga_grpc { } } + +struct MonikerReadArrayI8Data +{ + NiFpga_Session session; + uint32_t indicator; + size_t size; + nifpga_grpc::ArrayI32Data data; + std::shared_ptr library; +}; + +::grpc::Status NiFpgaService::BeginReadArrayI8(::grpc::ServerContext* context, const BeginReadArrayI8Request* request, BeginReadArrayI8Response* response) +{ + if (context->IsCancelled()) { + return ::grpc::Status::CANCELLED; + } + try { + auto session_grpc_session = request->session(); + NiFpga_Session session = session_repository_->access_session(session_grpc_session.name()); + uint32_t indicator = request->indicator(); + size_t size = request->size(); + + MonikerReadArrayI8Data* data = new MonikerReadArrayI8Data(); + data->session = session; + data->indicator = indicator; + data->size = size; + data->library = std::shared_ptr(library_); + + data->data.mutable_value()->Reserve(request->size()); + data->data.mutable_value()->Resize(request->size(), 0); + ni::data_monikers::Moniker* moniker = new ni::data_monikers::Moniker(); + ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerReadArrayI8", data, *moniker); + response->set_allocated_moniker(moniker); + return ::grpc::Status::OK; + } + catch (std::exception& ex) { + return ::grpc::Status(::grpc::UNKNOWN, ex.what()); + } +} +::grpc::Status MonikerReadArrayI8(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData) +{ + MonikerReadArrayI8Data* function_data = (MonikerReadArrayI8Data*)data; + auto library = function_data->library; + + auto session = function_data->session; + auto indicator = function_data->indicator; + auto size = function_data->size; + + std::vector array(size); + auto status = library->ReadArrayI8(session, indicator, array.data(), size); + if (status >= 0) { + std::transform( + array.begin(), + array.begin() + size, + function_data->data.mutable_value()->begin(), + [&](auto x) { + return x; + }); + packedData.PackFrom(function_data->data); + } + if (status < 0) { + std::cout << "MonikerReadArrayI8 error: " << status << std::endl; + } + return ::grpc::Status::OK; +} + //--------------------------------------------------------------------- //--------------------------------------------------------------------- ::grpc::Status NiFpgaService::ReadArraySgl(::grpc::ServerContext* context, const ReadArraySglRequest* request, ReadArraySglResponse* response) @@ -779,6 +1108,71 @@ namespace nifpga_grpc { } } + +struct MonikerReadArrayU16Data +{ + NiFpga_Session session; + uint32_t indicator; + size_t size; + nifpga_grpc::ArrayU32Data data; + std::shared_ptr library; +}; + +::grpc::Status NiFpgaService::BeginReadArrayU16(::grpc::ServerContext* context, const BeginReadArrayU16Request* request, BeginReadArrayU16Response* response) +{ + if (context->IsCancelled()) { + return ::grpc::Status::CANCELLED; + } + try { + auto session_grpc_session = request->session(); + NiFpga_Session session = session_repository_->access_session(session_grpc_session.name()); + uint32_t indicator = request->indicator(); + size_t size = request->size(); + + MonikerReadArrayU16Data* data = new MonikerReadArrayU16Data(); + data->session = session; + data->indicator = indicator; + data->size = size; + data->library = std::shared_ptr(library_); + + data->data.mutable_value()->Reserve(request->size()); + data->data.mutable_value()->Resize(request->size(), 0); + ni::data_monikers::Moniker* moniker = new ni::data_monikers::Moniker(); + ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerReadArrayU16", data, *moniker); + response->set_allocated_moniker(moniker); + return ::grpc::Status::OK; + } + catch (std::exception& ex) { + return ::grpc::Status(::grpc::UNKNOWN, ex.what()); + } +} +::grpc::Status MonikerReadArrayU16(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData) +{ + MonikerReadArrayU16Data* function_data = (MonikerReadArrayU16Data*)data; + auto library = function_data->library; + + auto session = function_data->session; + auto indicator = function_data->indicator; + auto size = function_data->size; + + std::vector array(size); + auto status = library->ReadArrayU16(session, indicator, array.data(), size); + if (status >= 0) { + std::transform( + array.begin(), + array.begin() + size, + function_data->data.mutable_value()->begin(), + [&](auto x) { + return x; + }); + packedData.PackFrom(function_data->data); + } + if (status < 0) { + std::cout << "MonikerReadArrayU16 error: " << status << std::endl; + } + return ::grpc::Status::OK; +} + //--------------------------------------------------------------------- //--------------------------------------------------------------------- ::grpc::Status NiFpgaService::ReadArrayU32(::grpc::ServerContext* context, const ReadArrayU32Request* request, ReadArrayU32Response* response) @@ -805,6 +1199,71 @@ namespace nifpga_grpc { } } + +struct MonikerReadArrayU32Data +{ + NiFpga_Session session; + uint32_t indicator; + size_t size; + nifpga_grpc::ArrayU32Data data; + std::shared_ptr library; +}; + +::grpc::Status NiFpgaService::BeginReadArrayU32(::grpc::ServerContext* context, const BeginReadArrayU32Request* request, BeginReadArrayU32Response* response) +{ + if (context->IsCancelled()) { + return ::grpc::Status::CANCELLED; + } + try { + auto session_grpc_session = request->session(); + NiFpga_Session session = session_repository_->access_session(session_grpc_session.name()); + uint32_t indicator = request->indicator(); + size_t size = request->size(); + + MonikerReadArrayU32Data* data = new MonikerReadArrayU32Data(); + data->session = session; + data->indicator = indicator; + data->size = size; + data->library = std::shared_ptr(library_); + + data->data.mutable_value()->Reserve(request->size()); + data->data.mutable_value()->Resize(request->size(), 0); + ni::data_monikers::Moniker* moniker = new ni::data_monikers::Moniker(); + ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerReadArrayU32", data, *moniker); + response->set_allocated_moniker(moniker); + return ::grpc::Status::OK; + } + catch (std::exception& ex) { + return ::grpc::Status(::grpc::UNKNOWN, ex.what()); + } +} +::grpc::Status MonikerReadArrayU32(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData) +{ + MonikerReadArrayU32Data* function_data = (MonikerReadArrayU32Data*)data; + auto library = function_data->library; + + auto session = function_data->session; + auto indicator = function_data->indicator; + auto size = function_data->size; + + uint32_t* array = new uint32_t[size]; + auto status = library->ReadArrayU32(session, indicator, array, size); + if (status >= 0) { + std::transform( + array, + array + size, + function_data->data.mutable_value()->begin(), + [&](auto x) { + return x; + }); + packedData.PackFrom(function_data->data); + } + if (status < 0) { + std::cout << "MonikerReadArrayU32 error: " << status << std::endl; + } + return ::grpc::Status::OK; +} + //--------------------------------------------------------------------- //--------------------------------------------------------------------- ::grpc::Status NiFpgaService::ReadArrayU64(::grpc::ServerContext* context, const ReadArrayU64Request* request, ReadArrayU64Response* response) @@ -831,6 +1290,71 @@ namespace nifpga_grpc { } } + +struct MonikerReadArrayU64Data +{ + NiFpga_Session session; + uint32_t indicator; + size_t size; + nifpga_grpc::ArrayU64Data data; + std::shared_ptr library; +}; + +::grpc::Status NiFpgaService::BeginReadArrayU64(::grpc::ServerContext* context, const BeginReadArrayU64Request* request, BeginReadArrayU64Response* response) +{ + if (context->IsCancelled()) { + return ::grpc::Status::CANCELLED; + } + try { + auto session_grpc_session = request->session(); + NiFpga_Session session = session_repository_->access_session(session_grpc_session.name()); + uint32_t indicator = request->indicator(); + size_t size = request->size(); + + MonikerReadArrayU64Data* data = new MonikerReadArrayU64Data(); + data->session = session; + data->indicator = indicator; + data->size = size; + data->library = std::shared_ptr(library_); + + data->data.mutable_value()->Reserve(request->size()); + data->data.mutable_value()->Resize(request->size(), 0); + ni::data_monikers::Moniker* moniker = new ni::data_monikers::Moniker(); + ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerReadArrayU64", data, *moniker); + response->set_allocated_moniker(moniker); + return ::grpc::Status::OK; + } + catch (std::exception& ex) { + return ::grpc::Status(::grpc::UNKNOWN, ex.what()); + } +} +::grpc::Status MonikerReadArrayU64(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData) +{ + MonikerReadArrayU64Data* function_data = (MonikerReadArrayU64Data*)data; + auto library = function_data->library; + + auto session = function_data->session; + auto indicator = function_data->indicator; + auto size = function_data->size; + + uint64_t* array = new uint64_t[size]; + auto status = library->ReadArrayU64(session, indicator, array, size); + if (status >= 0) { + std::transform( + array, + array + size, + function_data->data.mutable_value()->begin(), + [&](auto x) { + return x; + }); + packedData.PackFrom(function_data->data); + } + if (status < 0) { + std::cout << "MonikerReadArrayU64 error: " << status << std::endl; + } + return ::grpc::Status::OK; +} + //--------------------------------------------------------------------- //--------------------------------------------------------------------- ::grpc::Status NiFpgaService::ReadArrayU8(::grpc::ServerContext* context, const ReadArrayU8Request* request, ReadArrayU8Response* response) @@ -865,6 +1389,71 @@ namespace nifpga_grpc { } } + +struct MonikerReadArrayU8Data +{ + NiFpga_Session session; + uint32_t indicator; + size_t size; + nifpga_grpc::ArrayU32Data data; + std::shared_ptr library; +}; + +::grpc::Status NiFpgaService::BeginReadArrayU8(::grpc::ServerContext* context, const BeginReadArrayU8Request* request, BeginReadArrayU8Response* response) +{ + if (context->IsCancelled()) { + return ::grpc::Status::CANCELLED; + } + try { + auto session_grpc_session = request->session(); + NiFpga_Session session = session_repository_->access_session(session_grpc_session.name()); + uint32_t indicator = request->indicator(); + size_t size = request->size(); + + MonikerReadArrayU8Data* data = new MonikerReadArrayU8Data(); + data->session = session; + data->indicator = indicator; + data->size = size; + data->library = std::shared_ptr(library_); + + data->data.mutable_value()->Reserve(request->size()); + data->data.mutable_value()->Resize(request->size(), 0); + ni::data_monikers::Moniker* moniker = new ni::data_monikers::Moniker(); + ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerReadArrayU8", data, *moniker); + response->set_allocated_moniker(moniker); + return ::grpc::Status::OK; + } + catch (std::exception& ex) { + return ::grpc::Status(::grpc::UNKNOWN, ex.what()); + } +} +::grpc::Status MonikerReadArrayU8(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData) +{ + MonikerReadArrayU8Data* function_data = (MonikerReadArrayU8Data*)data; + auto library = function_data->library; + + auto session = function_data->session; + auto indicator = function_data->indicator; + auto size = function_data->size; + + std::vector array(size); + auto status = library->ReadArrayU8(session, indicator, array.data(), size); + if (status >= 0) { + std::transform( + array.begin(), + array.begin() + size, + function_data->data.mutable_value()->begin(), + [&](auto x) { + return x; + }); + packedData.PackFrom(function_data->data); + } + if (status < 0) { + std::cout << "MonikerReadArrayU8 error: " << status << std::endl; + } + return ::grpc::Status::OK; +} + //--------------------------------------------------------------------- //--------------------------------------------------------------------- ::grpc::Status NiFpgaService::ReadBool(::grpc::ServerContext* context, const ReadBoolRequest* request, ReadBoolResponse* response) @@ -1291,6 +1880,59 @@ namespace nifpga_grpc { } } + +struct MonikerReadI16Data +{ + NiFpga_Session session; + uint32_t indicator; + nifpga_grpc::I32Data data; + std::shared_ptr library; +}; + +::grpc::Status NiFpgaService::BeginReadI16(::grpc::ServerContext* context, const BeginReadI16Request* request, BeginReadI16Response* response) +{ + if (context->IsCancelled()) { + return ::grpc::Status::CANCELLED; + } + try { + auto session_grpc_session = request->session(); + NiFpga_Session session = session_repository_->access_session(session_grpc_session.name()); + uint32_t indicator = request->indicator(); + + MonikerReadI16Data* data = new MonikerReadI16Data(); + data->session = session; + data->indicator = indicator; + data->library = std::shared_ptr(library_); + + ni::data_monikers::Moniker* moniker = new ni::data_monikers::Moniker(); + ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerReadI16", data, *moniker); + response->set_allocated_moniker(moniker); + return ::grpc::Status::OK; + } + catch (std::exception& ex) { + return ::grpc::Status(::grpc::UNKNOWN, ex.what()); + } +} +::grpc::Status MonikerReadI16(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData) +{ + MonikerReadI16Data* function_data = (MonikerReadI16Data*)data; + auto library = function_data->library; + + auto session = function_data->session; + auto indicator = function_data->indicator; + + int16_t value = 0; + auto status = library->ReadI16(session, indicator, &value); + function_data->data.set_value(value); + if (status >= 0) { + packedData.PackFrom(function_data->data); + } + if (status < 0) { + std::cout << "MonikerReadI16 error: " << status << std::endl; + } + return ::grpc::Status::OK; +} + //--------------------------------------------------------------------- //--------------------------------------------------------------------- ::grpc::Status NiFpgaService::ReadI32(::grpc::ServerContext* context, const ReadI32Request* request, ReadI32Response* response) @@ -1316,6 +1958,59 @@ namespace nifpga_grpc { } } + +struct MonikerReadI32Data +{ + NiFpga_Session session; + uint32_t indicator; + nifpga_grpc::I32Data data; + std::shared_ptr library; +}; + +::grpc::Status NiFpgaService::BeginReadI32(::grpc::ServerContext* context, const BeginReadI32Request* request, BeginReadI32Response* response) +{ + if (context->IsCancelled()) { + return ::grpc::Status::CANCELLED; + } + try { + auto session_grpc_session = request->session(); + NiFpga_Session session = session_repository_->access_session(session_grpc_session.name()); + uint32_t indicator = request->indicator(); + + MonikerReadI32Data* data = new MonikerReadI32Data(); + data->session = session; + data->indicator = indicator; + data->library = std::shared_ptr(library_); + + ni::data_monikers::Moniker* moniker = new ni::data_monikers::Moniker(); + ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerReadI32", data, *moniker); + response->set_allocated_moniker(moniker); + return ::grpc::Status::OK; + } + catch (std::exception& ex) { + return ::grpc::Status(::grpc::UNKNOWN, ex.what()); + } +} +::grpc::Status MonikerReadI32(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData) +{ + MonikerReadI32Data* function_data = (MonikerReadI32Data*)data; + auto library = function_data->library; + + auto session = function_data->session; + auto indicator = function_data->indicator; + + int32_t value = 0; + auto status = library->ReadI32(session, indicator, &value); + function_data->data.set_value(value); + if (status >= 0) { + packedData.PackFrom(function_data->data); + } + if (status < 0) { + std::cout << "MonikerReadI32 error: " << status << std::endl; + } + return ::grpc::Status::OK; +} + //--------------------------------------------------------------------- //--------------------------------------------------------------------- ::grpc::Status NiFpgaService::ReadI64(::grpc::ServerContext* context, const ReadI64Request* request, ReadI64Response* response) @@ -1341,6 +2036,59 @@ namespace nifpga_grpc { } } + +struct MonikerReadI64Data +{ + NiFpga_Session session; + uint32_t indicator; + nifpga_grpc::I64Data data; + std::shared_ptr library; +}; + +::grpc::Status NiFpgaService::BeginReadI64(::grpc::ServerContext* context, const BeginReadI64Request* request, BeginReadI64Response* response) +{ + if (context->IsCancelled()) { + return ::grpc::Status::CANCELLED; + } + try { + auto session_grpc_session = request->session(); + NiFpga_Session session = session_repository_->access_session(session_grpc_session.name()); + uint32_t indicator = request->indicator(); + + MonikerReadI64Data* data = new MonikerReadI64Data(); + data->session = session; + data->indicator = indicator; + data->library = std::shared_ptr(library_); + + ni::data_monikers::Moniker* moniker = new ni::data_monikers::Moniker(); + ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerReadI64", data, *moniker); + response->set_allocated_moniker(moniker); + return ::grpc::Status::OK; + } + catch (std::exception& ex) { + return ::grpc::Status(::grpc::UNKNOWN, ex.what()); + } +} +::grpc::Status MonikerReadI64(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData) +{ + MonikerReadI64Data* function_data = (MonikerReadI64Data*)data; + auto library = function_data->library; + + auto session = function_data->session; + auto indicator = function_data->indicator; + + int64_t value = 0; + auto status = library->ReadI64(session, indicator, &value); + function_data->data.set_value(value); + if (status >= 0) { + packedData.PackFrom(function_data->data); + } + if (status < 0) { + std::cout << "MonikerReadI64 error: " << status << std::endl; + } + return ::grpc::Status::OK; +} + //--------------------------------------------------------------------- //--------------------------------------------------------------------- ::grpc::Status NiFpgaService::ReadI8(::grpc::ServerContext* context, const ReadI8Request* request, ReadI8Response* response) @@ -1366,6 +2114,59 @@ namespace nifpga_grpc { } } + +struct MonikerReadI8Data +{ + NiFpga_Session session; + uint32_t indicator; + nifpga_grpc::I32Data data; + std::shared_ptr library; +}; + +::grpc::Status NiFpgaService::BeginReadI8(::grpc::ServerContext* context, const BeginReadI8Request* request, BeginReadI8Response* response) +{ + if (context->IsCancelled()) { + return ::grpc::Status::CANCELLED; + } + try { + auto session_grpc_session = request->session(); + NiFpga_Session session = session_repository_->access_session(session_grpc_session.name()); + uint32_t indicator = request->indicator(); + + MonikerReadI8Data* data = new MonikerReadI8Data(); + data->session = session; + data->indicator = indicator; + data->library = std::shared_ptr(library_); + + ni::data_monikers::Moniker* moniker = new ni::data_monikers::Moniker(); + ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerReadI8", data, *moniker); + response->set_allocated_moniker(moniker); + return ::grpc::Status::OK; + } + catch (std::exception& ex) { + return ::grpc::Status(::grpc::UNKNOWN, ex.what()); + } +} +::grpc::Status MonikerReadI8(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData) +{ + MonikerReadI8Data* function_data = (MonikerReadI8Data*)data; + auto library = function_data->library; + + auto session = function_data->session; + auto indicator = function_data->indicator; + + int8_t value = 0; + auto status = library->ReadI8(session, indicator, &value); + function_data->data.set_value(value); + if (status >= 0) { + packedData.PackFrom(function_data->data); + } + if (status < 0) { + std::cout << "MonikerReadI8 error: " << status << std::endl; + } + return ::grpc::Status::OK; +} + //--------------------------------------------------------------------- //--------------------------------------------------------------------- ::grpc::Status NiFpgaService::ReadSgl(::grpc::ServerContext* context, const ReadSglRequest* request, ReadSglResponse* response) @@ -1416,6 +2217,59 @@ namespace nifpga_grpc { } } + +struct MonikerReadU16Data +{ + NiFpga_Session session; + uint32_t indicator; + nifpga_grpc::U32Data data; + std::shared_ptr library; +}; + +::grpc::Status NiFpgaService::BeginReadU16(::grpc::ServerContext* context, const BeginReadU16Request* request, BeginReadU16Response* response) +{ + if (context->IsCancelled()) { + return ::grpc::Status::CANCELLED; + } + try { + auto session_grpc_session = request->session(); + NiFpga_Session session = session_repository_->access_session(session_grpc_session.name()); + uint32_t indicator = request->indicator(); + + MonikerReadU16Data* data = new MonikerReadU16Data(); + data->session = session; + data->indicator = indicator; + data->library = std::shared_ptr(library_); + + ni::data_monikers::Moniker* moniker = new ni::data_monikers::Moniker(); + ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerReadU16", data, *moniker); + response->set_allocated_moniker(moniker); + return ::grpc::Status::OK; + } + catch (std::exception& ex) { + return ::grpc::Status(::grpc::UNKNOWN, ex.what()); + } +} +::grpc::Status MonikerReadU16(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData) +{ + MonikerReadU16Data* function_data = (MonikerReadU16Data*)data; + auto library = function_data->library; + + auto session = function_data->session; + auto indicator = function_data->indicator; + + uint16_t value = 0; + auto status = library->ReadU16(session, indicator, &value); + function_data->data.set_value(value); + if (status >= 0) { + packedData.PackFrom(function_data->data); + } + if (status < 0) { + std::cout << "MonikerReadU16 error: " << status << std::endl; + } + return ::grpc::Status::OK; +} + //--------------------------------------------------------------------- //--------------------------------------------------------------------- ::grpc::Status NiFpgaService::ReadU32(::grpc::ServerContext* context, const ReadU32Request* request, ReadU32Response* response) @@ -1441,6 +2295,59 @@ namespace nifpga_grpc { } } + +struct MonikerReadU32Data +{ + NiFpga_Session session; + uint32_t indicator; + nifpga_grpc::U32Data data; + std::shared_ptr library; +}; + +::grpc::Status NiFpgaService::BeginReadU32(::grpc::ServerContext* context, const BeginReadU32Request* request, BeginReadU32Response* response) +{ + if (context->IsCancelled()) { + return ::grpc::Status::CANCELLED; + } + try { + auto session_grpc_session = request->session(); + NiFpga_Session session = session_repository_->access_session(session_grpc_session.name()); + uint32_t indicator = request->indicator(); + + MonikerReadU32Data* data = new MonikerReadU32Data(); + data->session = session; + data->indicator = indicator; + data->library = std::shared_ptr(library_); + + ni::data_monikers::Moniker* moniker = new ni::data_monikers::Moniker(); + ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerReadU32", data, *moniker); + response->set_allocated_moniker(moniker); + return ::grpc::Status::OK; + } + catch (std::exception& ex) { + return ::grpc::Status(::grpc::UNKNOWN, ex.what()); + } +} +::grpc::Status MonikerReadU32(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData) +{ + MonikerReadU32Data* function_data = (MonikerReadU32Data*)data; + auto library = function_data->library; + + auto session = function_data->session; + auto indicator = function_data->indicator; + + uint32_t value = 0; + auto status = library->ReadU32(session, indicator, &value); + function_data->data.set_value(value); + if (status >= 0) { + packedData.PackFrom(function_data->data); + } + if (status < 0) { + std::cout << "MonikerReadU32 error: " << status << std::endl; + } + return ::grpc::Status::OK; +} + //--------------------------------------------------------------------- //--------------------------------------------------------------------- ::grpc::Status NiFpgaService::ReadU64(::grpc::ServerContext* context, const ReadU64Request* request, ReadU64Response* response) @@ -1466,6 +2373,59 @@ namespace nifpga_grpc { } } + +struct MonikerReadU64Data +{ + NiFpga_Session session; + uint32_t indicator; + nifpga_grpc::U64Data data; + std::shared_ptr library; +}; + +::grpc::Status NiFpgaService::BeginReadU64(::grpc::ServerContext* context, const BeginReadU64Request* request, BeginReadU64Response* response) +{ + if (context->IsCancelled()) { + return ::grpc::Status::CANCELLED; + } + try { + auto session_grpc_session = request->session(); + NiFpga_Session session = session_repository_->access_session(session_grpc_session.name()); + uint32_t indicator = request->indicator(); + + MonikerReadU64Data* data = new MonikerReadU64Data(); + data->session = session; + data->indicator = indicator; + data->library = std::shared_ptr(library_); + + ni::data_monikers::Moniker* moniker = new ni::data_monikers::Moniker(); + ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerReadU64", data, *moniker); + response->set_allocated_moniker(moniker); + return ::grpc::Status::OK; + } + catch (std::exception& ex) { + return ::grpc::Status(::grpc::UNKNOWN, ex.what()); + } +} +::grpc::Status MonikerReadU64(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData) +{ + MonikerReadU64Data* function_data = (MonikerReadU64Data*)data; + auto library = function_data->library; + + auto session = function_data->session; + auto indicator = function_data->indicator; + + uint64_t value = 0; + auto status = library->ReadU64(session, indicator, &value); + function_data->data.set_value(value); + if (status >= 0) { + packedData.PackFrom(function_data->data); + } + if (status < 0) { + std::cout << "MonikerReadU64 error: " << status << std::endl; + } + return ::grpc::Status::OK; +} + //--------------------------------------------------------------------- //--------------------------------------------------------------------- ::grpc::Status NiFpgaService::ReadU8(::grpc::ServerContext* context, const ReadU8Request* request, ReadU8Response* response) @@ -1491,6 +2451,59 @@ namespace nifpga_grpc { } } + +struct MonikerReadU8Data +{ + NiFpga_Session session; + uint32_t indicator; + nifpga_grpc::U32Data data; + std::shared_ptr library; +}; + +::grpc::Status NiFpgaService::BeginReadU8(::grpc::ServerContext* context, const BeginReadU8Request* request, BeginReadU8Response* response) +{ + if (context->IsCancelled()) { + return ::grpc::Status::CANCELLED; + } + try { + auto session_grpc_session = request->session(); + NiFpga_Session session = session_repository_->access_session(session_grpc_session.name()); + uint32_t indicator = request->indicator(); + + MonikerReadU8Data* data = new MonikerReadU8Data(); + data->session = session; + data->indicator = indicator; + data->library = std::shared_ptr(library_); + + ni::data_monikers::Moniker* moniker = new ni::data_monikers::Moniker(); + ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerReadU8", data, *moniker); + response->set_allocated_moniker(moniker); + return ::grpc::Status::OK; + } + catch (std::exception& ex) { + return ::grpc::Status(::grpc::UNKNOWN, ex.what()); + } +} +::grpc::Status MonikerReadU8(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData) +{ + MonikerReadU8Data* function_data = (MonikerReadU8Data*)data; + auto library = function_data->library; + + auto session = function_data->session; + auto indicator = function_data->indicator; + + uint8_t value = 0; + auto status = library->ReadU8(session, indicator, &value); + function_data->data.set_value(value); + if (status >= 0) { + packedData.PackFrom(function_data->data); + } + if (status < 0) { + std::cout << "MonikerReadU8 error: " << status << std::endl; + } + return ::grpc::Status::OK; +} + //--------------------------------------------------------------------- //--------------------------------------------------------------------- ::grpc::Status NiFpgaService::ReleaseFifoElements(::grpc::ServerContext* context, const ReleaseFifoElementsRequest* request, ReleaseFifoElementsResponse* response) @@ -1925,6 +2938,72 @@ namespace nifpga_grpc { } } + +struct MonikerWriteArrayI16Data +{ + NiFpga_Session session; + uint32_t control; + nifpga_grpc::ArrayI32Data data; + std::shared_ptr library; +}; + +::grpc::Status NiFpgaService::BeginWriteArrayI16(::grpc::ServerContext* context, const BeginWriteArrayI16Request* request, BeginWriteArrayI16Response* response) +{ + if (context->IsCancelled()) { + return ::grpc::Status::CANCELLED; + } + try { + auto session_grpc_session = request->session(); + NiFpga_Session session = session_repository_->access_session(session_grpc_session.name()); + uint32_t control = request->control(); + + MonikerWriteArrayI16Data* data = new MonikerWriteArrayI16Data(); + data->session = session; + data->control = control; + data->library = std::shared_ptr(library_); + + ni::data_monikers::Moniker* moniker = new ni::data_monikers::Moniker(); + ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerWriteArrayI16", data, *moniker); + response->set_allocated_moniker(moniker); + return ::grpc::Status::OK; + } + catch (std::exception& ex) { + return ::grpc::Status(::grpc::UNKNOWN, ex.what()); + } +} +::grpc::Status MonikerWriteArrayI16(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData) +{ + MonikerWriteArrayI16Data* function_data = (MonikerWriteArrayI16Data*)data; + auto library = function_data->library; + + auto session = function_data->session; + auto control = function_data->control; + + ArrayI32Data arrayi32_data; + packedData.UnpackTo(&arrayi32_data); + auto data_array = arrayi32_data.value(); + auto array = std::vector(); + auto size = data_array.size(); + array.reserve(size); + std::transform( + data_array.begin(), + data_array.end(), + std::back_inserter(array), + [](auto x) { + if (x < std::numeric_limits::min() || x > std::numeric_limits::max()) { + std::string message("value " + std::to_string(x) + " doesn't fit in datatype int16_t"); + throw nidevice_grpc::ValueOutOfRangeException(message); + } + return static_cast(x); + }); + + auto status = library->WriteArrayI16(session, control, array.data(), size); + if (status < 0) { + std::cout << "MonikerWriteArrayI16 error: " << status << std::endl; + } + return ::grpc::Status::OK; +} + //--------------------------------------------------------------------- //--------------------------------------------------------------------- ::grpc::Status NiFpgaService::WriteArrayI32(::grpc::ServerContext* context, const WriteArrayI32Request* request, WriteArrayI32Response* response) @@ -1950,6 +3029,60 @@ namespace nifpga_grpc { } } + +struct MonikerWriteArrayI32Data +{ + NiFpga_Session session; + uint32_t control; + nifpga_grpc::ArrayI32Data data; + std::shared_ptr library; +}; + +::grpc::Status NiFpgaService::BeginWriteArrayI32(::grpc::ServerContext* context, const BeginWriteArrayI32Request* request, BeginWriteArrayI32Response* response) +{ + if (context->IsCancelled()) { + return ::grpc::Status::CANCELLED; + } + try { + auto session_grpc_session = request->session(); + NiFpga_Session session = session_repository_->access_session(session_grpc_session.name()); + uint32_t control = request->control(); + + MonikerWriteArrayI32Data* data = new MonikerWriteArrayI32Data(); + data->session = session; + data->control = control; + data->library = std::shared_ptr(library_); + + ni::data_monikers::Moniker* moniker = new ni::data_monikers::Moniker(); + ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerWriteArrayI32", data, *moniker); + response->set_allocated_moniker(moniker); + return ::grpc::Status::OK; + } + catch (std::exception& ex) { + return ::grpc::Status(::grpc::UNKNOWN, ex.what()); + } +} +::grpc::Status MonikerWriteArrayI32(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData) +{ + MonikerWriteArrayI32Data* function_data = (MonikerWriteArrayI32Data*)data; + auto library = function_data->library; + + auto session = function_data->session; + auto control = function_data->control; + + ArrayI32Data arrayi32_data; + packedData.UnpackTo(&arrayi32_data); + auto data_array = arrayi32_data.value(); + auto array = const_cast(arrayi32_data.value().data()); + auto size = data_array.size(); + + auto status = library->WriteArrayI32(session, control, array, size); + if (status < 0) { + std::cout << "MonikerWriteArrayI32 error: " << status << std::endl; + } + return ::grpc::Status::OK; +} + //--------------------------------------------------------------------- //--------------------------------------------------------------------- ::grpc::Status NiFpgaService::WriteArrayI64(::grpc::ServerContext* context, const WriteArrayI64Request* request, WriteArrayI64Response* response) @@ -1975,6 +3108,60 @@ namespace nifpga_grpc { } } + +struct MonikerWriteArrayI64Data +{ + NiFpga_Session session; + uint32_t control; + nifpga_grpc::ArrayI64Data data; + std::shared_ptr library; +}; + +::grpc::Status NiFpgaService::BeginWriteArrayI64(::grpc::ServerContext* context, const BeginWriteArrayI64Request* request, BeginWriteArrayI64Response* response) +{ + if (context->IsCancelled()) { + return ::grpc::Status::CANCELLED; + } + try { + auto session_grpc_session = request->session(); + NiFpga_Session session = session_repository_->access_session(session_grpc_session.name()); + uint32_t control = request->control(); + + MonikerWriteArrayI64Data* data = new MonikerWriteArrayI64Data(); + data->session = session; + data->control = control; + data->library = std::shared_ptr(library_); + + ni::data_monikers::Moniker* moniker = new ni::data_monikers::Moniker(); + ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerWriteArrayI64", data, *moniker); + response->set_allocated_moniker(moniker); + return ::grpc::Status::OK; + } + catch (std::exception& ex) { + return ::grpc::Status(::grpc::UNKNOWN, ex.what()); + } +} +::grpc::Status MonikerWriteArrayI64(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData) +{ + MonikerWriteArrayI64Data* function_data = (MonikerWriteArrayI64Data*)data; + auto library = function_data->library; + + auto session = function_data->session; + auto control = function_data->control; + + ArrayI64Data arrayi64_data; + packedData.UnpackTo(&arrayi64_data); + auto data_array = arrayi64_data.value(); + auto array = const_cast(arrayi64_data.value().data()); + auto size = data_array.size(); + + auto status = library->WriteArrayI64(session, control, array, size); + if (status < 0) { + std::cout << "MonikerWriteArrayI64 error: " << status << std::endl; + } + return ::grpc::Status::OK; +} + //--------------------------------------------------------------------- //--------------------------------------------------------------------- ::grpc::Status NiFpgaService::WriteArrayI8(::grpc::ServerContext* context, const WriteArrayI8Request* request, WriteArrayI8Response* response) @@ -2017,6 +3204,72 @@ namespace nifpga_grpc { } } + +struct MonikerWriteArrayI8Data +{ + NiFpga_Session session; + uint32_t control; + nifpga_grpc::ArrayI32Data data; + std::shared_ptr library; +}; + +::grpc::Status NiFpgaService::BeginWriteArrayI8(::grpc::ServerContext* context, const BeginWriteArrayI8Request* request, BeginWriteArrayI8Response* response) +{ + if (context->IsCancelled()) { + return ::grpc::Status::CANCELLED; + } + try { + auto session_grpc_session = request->session(); + NiFpga_Session session = session_repository_->access_session(session_grpc_session.name()); + uint32_t control = request->control(); + + MonikerWriteArrayI8Data* data = new MonikerWriteArrayI8Data(); + data->session = session; + data->control = control; + data->library = std::shared_ptr(library_); + + ni::data_monikers::Moniker* moniker = new ni::data_monikers::Moniker(); + ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerWriteArrayI8", data, *moniker); + response->set_allocated_moniker(moniker); + return ::grpc::Status::OK; + } + catch (std::exception& ex) { + return ::grpc::Status(::grpc::UNKNOWN, ex.what()); + } +} +::grpc::Status MonikerWriteArrayI8(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData) +{ + MonikerWriteArrayI8Data* function_data = (MonikerWriteArrayI8Data*)data; + auto library = function_data->library; + + auto session = function_data->session; + auto control = function_data->control; + + ArrayI32Data arrayi32_data; + packedData.UnpackTo(&arrayi32_data); + auto data_array = arrayi32_data.value(); + auto array = std::vector(); + auto size = data_array.size(); + array.reserve(size); + std::transform( + data_array.begin(), + data_array.end(), + std::back_inserter(array), + [](auto x) { + if (x < std::numeric_limits::min() || x > std::numeric_limits::max()) { + std::string message("value " + std::to_string(x) + " doesn't fit in datatype int8_t"); + throw nidevice_grpc::ValueOutOfRangeException(message); + } + return static_cast(x); + }); + + auto status = library->WriteArrayI8(session, control, array.data(), size); + if (status < 0) { + std::cout << "MonikerWriteArrayI8 error: " << status << std::endl; + } + return ::grpc::Status::OK; +} + //--------------------------------------------------------------------- //--------------------------------------------------------------------- ::grpc::Status NiFpgaService::WriteArraySgl(::grpc::ServerContext* context, const WriteArraySglRequest* request, WriteArraySglResponse* response) @@ -2084,6 +3337,72 @@ namespace nifpga_grpc { } } + +struct MonikerWriteArrayU16Data +{ + NiFpga_Session session; + uint32_t control; + nifpga_grpc::ArrayU32Data data; + std::shared_ptr library; +}; + +::grpc::Status NiFpgaService::BeginWriteArrayU16(::grpc::ServerContext* context, const BeginWriteArrayU16Request* request, BeginWriteArrayU16Response* response) +{ + if (context->IsCancelled()) { + return ::grpc::Status::CANCELLED; + } + try { + auto session_grpc_session = request->session(); + NiFpga_Session session = session_repository_->access_session(session_grpc_session.name()); + uint32_t control = request->control(); + + MonikerWriteArrayU16Data* data = new MonikerWriteArrayU16Data(); + data->session = session; + data->control = control; + data->library = std::shared_ptr(library_); + + ni::data_monikers::Moniker* moniker = new ni::data_monikers::Moniker(); + ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerWriteArrayU16", data, *moniker); + response->set_allocated_moniker(moniker); + return ::grpc::Status::OK; + } + catch (std::exception& ex) { + return ::grpc::Status(::grpc::UNKNOWN, ex.what()); + } +} +::grpc::Status MonikerWriteArrayU16(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData) +{ + MonikerWriteArrayU16Data* function_data = (MonikerWriteArrayU16Data*)data; + auto library = function_data->library; + + auto session = function_data->session; + auto control = function_data->control; + + ArrayU32Data arrayu32_data; + packedData.UnpackTo(&arrayu32_data); + auto data_array = arrayu32_data.value(); + auto array = std::vector(); + auto size = data_array.size(); + array.reserve(size); + std::transform( + data_array.begin(), + data_array.end(), + std::back_inserter(array), + [](auto x) { + if (x < std::numeric_limits::min() || x > std::numeric_limits::max()) { + std::string message("value " + std::to_string(x) + " doesn't fit in datatype uint16_t"); + throw nidevice_grpc::ValueOutOfRangeException(message); + } + return static_cast(x); + }); + + auto status = library->WriteArrayU16(session, control, array.data(), size); + if (status < 0) { + std::cout << "MonikerWriteArrayU16 error: " << status << std::endl; + } + return ::grpc::Status::OK; +} + //--------------------------------------------------------------------- //--------------------------------------------------------------------- ::grpc::Status NiFpgaService::WriteArrayU32(::grpc::ServerContext* context, const WriteArrayU32Request* request, WriteArrayU32Response* response) @@ -2109,6 +3428,60 @@ namespace nifpga_grpc { } } + +struct MonikerWriteArrayU32Data +{ + NiFpga_Session session; + uint32_t control; + nifpga_grpc::ArrayU32Data data; + std::shared_ptr library; +}; + +::grpc::Status NiFpgaService::BeginWriteArrayU32(::grpc::ServerContext* context, const BeginWriteArrayU32Request* request, BeginWriteArrayU32Response* response) +{ + if (context->IsCancelled()) { + return ::grpc::Status::CANCELLED; + } + try { + auto session_grpc_session = request->session(); + NiFpga_Session session = session_repository_->access_session(session_grpc_session.name()); + uint32_t control = request->control(); + + MonikerWriteArrayU32Data* data = new MonikerWriteArrayU32Data(); + data->session = session; + data->control = control; + data->library = std::shared_ptr(library_); + + ni::data_monikers::Moniker* moniker = new ni::data_monikers::Moniker(); + ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerWriteArrayU32", data, *moniker); + response->set_allocated_moniker(moniker); + return ::grpc::Status::OK; + } + catch (std::exception& ex) { + return ::grpc::Status(::grpc::UNKNOWN, ex.what()); + } +} +::grpc::Status MonikerWriteArrayU32(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData) +{ + MonikerWriteArrayU32Data* function_data = (MonikerWriteArrayU32Data*)data; + auto library = function_data->library; + + auto session = function_data->session; + auto control = function_data->control; + + ArrayU32Data arrayu32_data; + packedData.UnpackTo(&arrayu32_data); + auto data_array = arrayu32_data.value(); + auto array = const_cast(arrayu32_data.value().data()); + auto size = data_array.size(); + + auto status = library->WriteArrayU32(session, control, array, size); + if (status < 0) { + std::cout << "MonikerWriteArrayU32 error: " << status << std::endl; + } + return ::grpc::Status::OK; +} + //--------------------------------------------------------------------- //--------------------------------------------------------------------- ::grpc::Status NiFpgaService::WriteArrayU64(::grpc::ServerContext* context, const WriteArrayU64Request* request, WriteArrayU64Response* response) @@ -2134,6 +3507,60 @@ namespace nifpga_grpc { } } + +struct MonikerWriteArrayU64Data +{ + NiFpga_Session session; + uint32_t control; + nifpga_grpc::ArrayU64Data data; + std::shared_ptr library; +}; + +::grpc::Status NiFpgaService::BeginWriteArrayU64(::grpc::ServerContext* context, const BeginWriteArrayU64Request* request, BeginWriteArrayU64Response* response) +{ + if (context->IsCancelled()) { + return ::grpc::Status::CANCELLED; + } + try { + auto session_grpc_session = request->session(); + NiFpga_Session session = session_repository_->access_session(session_grpc_session.name()); + uint32_t control = request->control(); + + MonikerWriteArrayU64Data* data = new MonikerWriteArrayU64Data(); + data->session = session; + data->control = control; + data->library = std::shared_ptr(library_); + + ni::data_monikers::Moniker* moniker = new ni::data_monikers::Moniker(); + ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerWriteArrayU64", data, *moniker); + response->set_allocated_moniker(moniker); + return ::grpc::Status::OK; + } + catch (std::exception& ex) { + return ::grpc::Status(::grpc::UNKNOWN, ex.what()); + } +} +::grpc::Status MonikerWriteArrayU64(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData) +{ + MonikerWriteArrayU64Data* function_data = (MonikerWriteArrayU64Data*)data; + auto library = function_data->library; + + auto session = function_data->session; + auto control = function_data->control; + + ArrayU64Data arrayu64_data; + packedData.UnpackTo(&arrayu64_data); + auto data_array = arrayu64_data.value(); + auto array = const_cast(arrayu64_data.value().data()); + auto size = data_array.size(); + + auto status = library->WriteArrayU64(session, control, array, size); + if (status < 0) { + std::cout << "MonikerWriteArrayU64 error: " << status << std::endl; + } + return ::grpc::Status::OK; +} + //--------------------------------------------------------------------- //--------------------------------------------------------------------- ::grpc::Status NiFpgaService::WriteArrayU8(::grpc::ServerContext* context, const WriteArrayU8Request* request, WriteArrayU8Response* response) @@ -2176,6 +3603,72 @@ namespace nifpga_grpc { } } + +struct MonikerWriteArrayU8Data +{ + NiFpga_Session session; + uint32_t control; + nifpga_grpc::ArrayU32Data data; + std::shared_ptr library; +}; + +::grpc::Status NiFpgaService::BeginWriteArrayU8(::grpc::ServerContext* context, const BeginWriteArrayU8Request* request, BeginWriteArrayU8Response* response) +{ + if (context->IsCancelled()) { + return ::grpc::Status::CANCELLED; + } + try { + auto session_grpc_session = request->session(); + NiFpga_Session session = session_repository_->access_session(session_grpc_session.name()); + uint32_t control = request->control(); + + MonikerWriteArrayU8Data* data = new MonikerWriteArrayU8Data(); + data->session = session; + data->control = control; + data->library = std::shared_ptr(library_); + + ni::data_monikers::Moniker* moniker = new ni::data_monikers::Moniker(); + ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerWriteArrayU8", data, *moniker); + response->set_allocated_moniker(moniker); + return ::grpc::Status::OK; + } + catch (std::exception& ex) { + return ::grpc::Status(::grpc::UNKNOWN, ex.what()); + } +} +::grpc::Status MonikerWriteArrayU8(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData) +{ + MonikerWriteArrayU8Data* function_data = (MonikerWriteArrayU8Data*)data; + auto library = function_data->library; + + auto session = function_data->session; + auto control = function_data->control; + + ArrayU32Data arrayu32_data; + packedData.UnpackTo(&arrayu32_data); + auto data_array = arrayu32_data.value(); + auto array = std::vector(); + auto size = data_array.size(); + array.reserve(size); + std::transform( + data_array.begin(), + data_array.end(), + std::back_inserter(array), + [](auto x) { + if (x < std::numeric_limits::min() || x > std::numeric_limits::max()) { + std::string message("value " + std::to_string(x) + " doesn't fit in datatype uint8_t"); + throw nidevice_grpc::ValueOutOfRangeException(message); + } + return static_cast(x); + }); + + auto status = library->WriteArrayU8(session, control, array.data(), size); + if (status < 0) { + std::cout << "MonikerWriteArrayU8 error: " << status << std::endl; + } + return ::grpc::Status::OK; +} + //--------------------------------------------------------------------- //--------------------------------------------------------------------- ::grpc::Status NiFpgaService::WriteBool(::grpc::ServerContext* context, const WriteBoolRequest* request, WriteBoolResponse* response) @@ -2633,6 +4126,62 @@ namespace nifpga_grpc { } } + +struct MonikerWriteI16Data +{ + NiFpga_Session session; + uint32_t control; + nifpga_grpc::I32Data data; + std::shared_ptr library; +}; + +::grpc::Status NiFpgaService::BeginWriteI16(::grpc::ServerContext* context, const BeginWriteI16Request* request, BeginWriteI16Response* response) +{ + if (context->IsCancelled()) { + return ::grpc::Status::CANCELLED; + } + try { + auto session_grpc_session = request->session(); + NiFpga_Session session = session_repository_->access_session(session_grpc_session.name()); + uint32_t control = request->control(); + + MonikerWriteI16Data* data = new MonikerWriteI16Data(); + data->session = session; + data->control = control; + data->library = std::shared_ptr(library_); + + ni::data_monikers::Moniker* moniker = new ni::data_monikers::Moniker(); + ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerWriteI16", data, *moniker); + response->set_allocated_moniker(moniker); + return ::grpc::Status::OK; + } + catch (std::exception& ex) { + return ::grpc::Status(::grpc::UNKNOWN, ex.what()); + } +} +::grpc::Status MonikerWriteI16(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData) +{ + MonikerWriteI16Data* function_data = (MonikerWriteI16Data*)data; + auto library = function_data->library; + + auto session = function_data->session; + auto control = function_data->control; + + I32Data i32_data; + packedData.UnpackTo(&i32_data); + int32_t value = i32_data.value(); + if (value < std::numeric_limits::min() || value > std::numeric_limits::max()) { + std::string message("value " + std::to_string(value) + " doesn't fit in datatype int16_t"); + throw nidevice_grpc::ValueOutOfRangeException(message); + } + + auto status = library->WriteI16(session, control, value); + if (status < 0) { + std::cout << "MonikerWriteI16 error: " << status << std::endl; + } + return ::grpc::Status::OK; +} + //--------------------------------------------------------------------- //--------------------------------------------------------------------- ::grpc::Status NiFpgaService::WriteI32(::grpc::ServerContext* context, const WriteI32Request* request, WriteI32Response* response) @@ -2657,6 +4206,58 @@ namespace nifpga_grpc { } } + +struct MonikerWriteI32Data +{ + NiFpga_Session session; + uint32_t control; + nifpga_grpc::I32Data data; + std::shared_ptr library; +}; + +::grpc::Status NiFpgaService::BeginWriteI32(::grpc::ServerContext* context, const BeginWriteI32Request* request, BeginWriteI32Response* response) +{ + if (context->IsCancelled()) { + return ::grpc::Status::CANCELLED; + } + try { + auto session_grpc_session = request->session(); + NiFpga_Session session = session_repository_->access_session(session_grpc_session.name()); + uint32_t control = request->control(); + + MonikerWriteI32Data* data = new MonikerWriteI32Data(); + data->session = session; + data->control = control; + data->library = std::shared_ptr(library_); + + ni::data_monikers::Moniker* moniker = new ni::data_monikers::Moniker(); + ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerWriteI32", data, *moniker); + response->set_allocated_moniker(moniker); + return ::grpc::Status::OK; + } + catch (std::exception& ex) { + return ::grpc::Status(::grpc::UNKNOWN, ex.what()); + } +} +::grpc::Status MonikerWriteI32(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData) +{ + MonikerWriteI32Data* function_data = (MonikerWriteI32Data*)data; + auto library = function_data->library; + + auto session = function_data->session; + auto control = function_data->control; + + I32Data i32_data; + packedData.UnpackTo(&i32_data); + int32_t value = i32_data.value(); + + auto status = library->WriteI32(session, control, value); + if (status < 0) { + std::cout << "MonikerWriteI32 error: " << status << std::endl; + } + return ::grpc::Status::OK; +} + //--------------------------------------------------------------------- //--------------------------------------------------------------------- ::grpc::Status NiFpgaService::WriteI64(::grpc::ServerContext* context, const WriteI64Request* request, WriteI64Response* response) @@ -2681,6 +4282,58 @@ namespace nifpga_grpc { } } + +struct MonikerWriteI64Data +{ + NiFpga_Session session; + uint32_t control; + nifpga_grpc::I64Data data; + std::shared_ptr library; +}; + +::grpc::Status NiFpgaService::BeginWriteI64(::grpc::ServerContext* context, const BeginWriteI64Request* request, BeginWriteI64Response* response) +{ + if (context->IsCancelled()) { + return ::grpc::Status::CANCELLED; + } + try { + auto session_grpc_session = request->session(); + NiFpga_Session session = session_repository_->access_session(session_grpc_session.name()); + uint32_t control = request->control(); + + MonikerWriteI64Data* data = new MonikerWriteI64Data(); + data->session = session; + data->control = control; + data->library = std::shared_ptr(library_); + + ni::data_monikers::Moniker* moniker = new ni::data_monikers::Moniker(); + ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerWriteI64", data, *moniker); + response->set_allocated_moniker(moniker); + return ::grpc::Status::OK; + } + catch (std::exception& ex) { + return ::grpc::Status(::grpc::UNKNOWN, ex.what()); + } +} +::grpc::Status MonikerWriteI64(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData) +{ + MonikerWriteI64Data* function_data = (MonikerWriteI64Data*)data; + auto library = function_data->library; + + auto session = function_data->session; + auto control = function_data->control; + + I64Data i64_data; + packedData.UnpackTo(&i64_data); + int64_t value = i64_data.value(); + + auto status = library->WriteI64(session, control, value); + if (status < 0) { + std::cout << "MonikerWriteI64 error: " << status << std::endl; + } + return ::grpc::Status::OK; +} + //--------------------------------------------------------------------- //--------------------------------------------------------------------- ::grpc::Status NiFpgaService::WriteI8(::grpc::ServerContext* context, const WriteI8Request* request, WriteI8Response* response) @@ -2714,6 +4367,62 @@ namespace nifpga_grpc { } } + +struct MonikerWriteI8Data +{ + NiFpga_Session session; + uint32_t control; + nifpga_grpc::I32Data data; + std::shared_ptr library; +}; + +::grpc::Status NiFpgaService::BeginWriteI8(::grpc::ServerContext* context, const BeginWriteI8Request* request, BeginWriteI8Response* response) +{ + if (context->IsCancelled()) { + return ::grpc::Status::CANCELLED; + } + try { + auto session_grpc_session = request->session(); + NiFpga_Session session = session_repository_->access_session(session_grpc_session.name()); + uint32_t control = request->control(); + + MonikerWriteI8Data* data = new MonikerWriteI8Data(); + data->session = session; + data->control = control; + data->library = std::shared_ptr(library_); + + ni::data_monikers::Moniker* moniker = new ni::data_monikers::Moniker(); + ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerWriteI8", data, *moniker); + response->set_allocated_moniker(moniker); + return ::grpc::Status::OK; + } + catch (std::exception& ex) { + return ::grpc::Status(::grpc::UNKNOWN, ex.what()); + } +} +::grpc::Status MonikerWriteI8(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData) +{ + MonikerWriteI8Data* function_data = (MonikerWriteI8Data*)data; + auto library = function_data->library; + + auto session = function_data->session; + auto control = function_data->control; + + I32Data i32_data; + packedData.UnpackTo(&i32_data); + int32_t value = i32_data.value(); + if (value < std::numeric_limits::min() || value > std::numeric_limits::max()) { + std::string message("value " + std::to_string(value) + " doesn't fit in datatype int8_t"); + throw nidevice_grpc::ValueOutOfRangeException(message); + } + + auto status = library->WriteI8(session, control, value); + if (status < 0) { + std::cout << "MonikerWriteI8 error: " << status << std::endl; + } + return ::grpc::Status::OK; +} + //--------------------------------------------------------------------- //--------------------------------------------------------------------- ::grpc::Status NiFpgaService::WriteSgl(::grpc::ServerContext* context, const WriteSglRequest* request, WriteSglResponse* response) @@ -2771,6 +4480,62 @@ namespace nifpga_grpc { } } + +struct MonikerWriteU16Data +{ + NiFpga_Session session; + uint32_t control; + nifpga_grpc::U32Data data; + std::shared_ptr library; +}; + +::grpc::Status NiFpgaService::BeginWriteU16(::grpc::ServerContext* context, const BeginWriteU16Request* request, BeginWriteU16Response* response) +{ + if (context->IsCancelled()) { + return ::grpc::Status::CANCELLED; + } + try { + auto session_grpc_session = request->session(); + NiFpga_Session session = session_repository_->access_session(session_grpc_session.name()); + uint32_t control = request->control(); + + MonikerWriteU16Data* data = new MonikerWriteU16Data(); + data->session = session; + data->control = control; + data->library = std::shared_ptr(library_); + + ni::data_monikers::Moniker* moniker = new ni::data_monikers::Moniker(); + ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerWriteU16", data, *moniker); + response->set_allocated_moniker(moniker); + return ::grpc::Status::OK; + } + catch (std::exception& ex) { + return ::grpc::Status(::grpc::UNKNOWN, ex.what()); + } +} +::grpc::Status MonikerWriteU16(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData) +{ + MonikerWriteU16Data* function_data = (MonikerWriteU16Data*)data; + auto library = function_data->library; + + auto session = function_data->session; + auto control = function_data->control; + + U32Data u32_data; + packedData.UnpackTo(&u32_data); + uint32_t value = u32_data.value(); + if (value < std::numeric_limits::min() || value > std::numeric_limits::max()) { + std::string message("value " + std::to_string(value) + " doesn't fit in datatype uint16_t"); + throw nidevice_grpc::ValueOutOfRangeException(message); + } + + auto status = library->WriteU16(session, control, value); + if (status < 0) { + std::cout << "MonikerWriteU16 error: " << status << std::endl; + } + return ::grpc::Status::OK; +} + //--------------------------------------------------------------------- //--------------------------------------------------------------------- ::grpc::Status NiFpgaService::WriteU32(::grpc::ServerContext* context, const WriteU32Request* request, WriteU32Response* response) @@ -2795,6 +4560,58 @@ namespace nifpga_grpc { } } + +struct MonikerWriteU32Data +{ + NiFpga_Session session; + uint32_t control; + nifpga_grpc::U32Data data; + std::shared_ptr library; +}; + +::grpc::Status NiFpgaService::BeginWriteU32(::grpc::ServerContext* context, const BeginWriteU32Request* request, BeginWriteU32Response* response) +{ + if (context->IsCancelled()) { + return ::grpc::Status::CANCELLED; + } + try { + auto session_grpc_session = request->session(); + NiFpga_Session session = session_repository_->access_session(session_grpc_session.name()); + uint32_t control = request->control(); + + MonikerWriteU32Data* data = new MonikerWriteU32Data(); + data->session = session; + data->control = control; + data->library = std::shared_ptr(library_); + + ni::data_monikers::Moniker* moniker = new ni::data_monikers::Moniker(); + ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerWriteU32", data, *moniker); + response->set_allocated_moniker(moniker); + return ::grpc::Status::OK; + } + catch (std::exception& ex) { + return ::grpc::Status(::grpc::UNKNOWN, ex.what()); + } +} +::grpc::Status MonikerWriteU32(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData) +{ + MonikerWriteU32Data* function_data = (MonikerWriteU32Data*)data; + auto library = function_data->library; + + auto session = function_data->session; + auto control = function_data->control; + + U32Data u32_data; + packedData.UnpackTo(&u32_data); + uint32_t value = u32_data.value(); + + auto status = library->WriteU32(session, control, value); + if (status < 0) { + std::cout << "MonikerWriteU32 error: " << status << std::endl; + } + return ::grpc::Status::OK; +} + //--------------------------------------------------------------------- //--------------------------------------------------------------------- ::grpc::Status NiFpgaService::WriteU64(::grpc::ServerContext* context, const WriteU64Request* request, WriteU64Response* response) @@ -2819,6 +4636,58 @@ namespace nifpga_grpc { } } + +struct MonikerWriteU64Data +{ + NiFpga_Session session; + uint32_t control; + nifpga_grpc::U64Data data; + std::shared_ptr library; +}; + +::grpc::Status NiFpgaService::BeginWriteU64(::grpc::ServerContext* context, const BeginWriteU64Request* request, BeginWriteU64Response* response) +{ + if (context->IsCancelled()) { + return ::grpc::Status::CANCELLED; + } + try { + auto session_grpc_session = request->session(); + NiFpga_Session session = session_repository_->access_session(session_grpc_session.name()); + uint32_t control = request->control(); + + MonikerWriteU64Data* data = new MonikerWriteU64Data(); + data->session = session; + data->control = control; + data->library = std::shared_ptr(library_); + + ni::data_monikers::Moniker* moniker = new ni::data_monikers::Moniker(); + ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerWriteU64", data, *moniker); + response->set_allocated_moniker(moniker); + return ::grpc::Status::OK; + } + catch (std::exception& ex) { + return ::grpc::Status(::grpc::UNKNOWN, ex.what()); + } +} +::grpc::Status MonikerWriteU64(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData) +{ + MonikerWriteU64Data* function_data = (MonikerWriteU64Data*)data; + auto library = function_data->library; + + auto session = function_data->session; + auto control = function_data->control; + + U64Data u64_data; + packedData.UnpackTo(&u64_data); + uint64_t value = u64_data.value(); + + auto status = library->WriteU64(session, control, value); + if (status < 0) { + std::cout << "MonikerWriteU64 error: " << status << std::endl; + } + return ::grpc::Status::OK; +} + //--------------------------------------------------------------------- //--------------------------------------------------------------------- ::grpc::Status NiFpgaService::WriteU8(::grpc::ServerContext* context, const WriteU8Request* request, WriteU8Response* response) @@ -2853,6 +4722,62 @@ namespace nifpga_grpc { } +struct MonikerWriteU8Data +{ + NiFpga_Session session; + uint32_t control; + nifpga_grpc::U32Data data; + std::shared_ptr library; +}; + +::grpc::Status NiFpgaService::BeginWriteU8(::grpc::ServerContext* context, const BeginWriteU8Request* request, BeginWriteU8Response* response) +{ + if (context->IsCancelled()) { + return ::grpc::Status::CANCELLED; + } + try { + auto session_grpc_session = request->session(); + NiFpga_Session session = session_repository_->access_session(session_grpc_session.name()); + uint32_t control = request->control(); + + MonikerWriteU8Data* data = new MonikerWriteU8Data(); + data->session = session; + data->control = control; + data->library = std::shared_ptr(library_); + + ni::data_monikers::Moniker* moniker = new ni::data_monikers::Moniker(); + ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerWriteU8", data, *moniker); + response->set_allocated_moniker(moniker); + return ::grpc::Status::OK; + } + catch (std::exception& ex) { + return ::grpc::Status(::grpc::UNKNOWN, ex.what()); + } +} +::grpc::Status MonikerWriteU8(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData) +{ + MonikerWriteU8Data* function_data = (MonikerWriteU8Data*)data; + auto library = function_data->library; + + auto session = function_data->session; + auto control = function_data->control; + + U32Data u32_data; + packedData.UnpackTo(&u32_data); + uint32_t value = u32_data.value(); + if (value < std::numeric_limits::min() || value > std::numeric_limits::max()) { + std::string message("value " + std::to_string(value) + " doesn't fit in datatype uint8_t"); + throw nidevice_grpc::ValueOutOfRangeException(message); + } + + auto status = library->WriteU8(session, control, value); + if (status < 0) { + std::cout << "MonikerWriteU8 error: " << status << std::endl; + } + return ::grpc::Status::OK; +} + + NiFpgaFeatureToggles::NiFpgaFeatureToggles( const nidevice_grpc::FeatureToggles& feature_toggles) : is_enabled( diff --git a/generated/nifpga/nifpga_service.h b/generated/nifpga/nifpga_service.h index 965d41a7e..708417050 100644 --- a/generated/nifpga/nifpga_service.h +++ b/generated/nifpga/nifpga_service.h @@ -30,6 +30,40 @@ struct NiFpgaFeatureToggles bool is_enabled; }; +void RegisterMonikers(); + +::grpc::Status MonikerReadArrayI16(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData); +::grpc::Status MonikerReadArrayI32(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData); +::grpc::Status MonikerReadArrayI64(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData); +::grpc::Status MonikerReadArrayI8(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData); +::grpc::Status MonikerReadArrayU16(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData); +::grpc::Status MonikerReadArrayU32(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData); +::grpc::Status MonikerReadArrayU64(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData); +::grpc::Status MonikerReadArrayU8(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData); +::grpc::Status MonikerReadI16(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData); +::grpc::Status MonikerReadI32(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData); +::grpc::Status MonikerReadI64(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData); +::grpc::Status MonikerReadI8(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData); +::grpc::Status MonikerReadU16(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData); +::grpc::Status MonikerReadU32(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData); +::grpc::Status MonikerReadU64(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData); +::grpc::Status MonikerReadU8(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData); +::grpc::Status MonikerWriteArrayI16(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData); +::grpc::Status MonikerWriteArrayI32(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData); +::grpc::Status MonikerWriteArrayI64(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData); +::grpc::Status MonikerWriteArrayI8(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData); +::grpc::Status MonikerWriteArrayU16(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData); +::grpc::Status MonikerWriteArrayU32(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData); +::grpc::Status MonikerWriteArrayU64(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData); +::grpc::Status MonikerWriteArrayU8(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData); +::grpc::Status MonikerWriteI16(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData); +::grpc::Status MonikerWriteI32(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData); +::grpc::Status MonikerWriteI64(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData); +::grpc::Status MonikerWriteI8(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData); +::grpc::Status MonikerWriteU16(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData); +::grpc::Status MonikerWriteU32(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData); +::grpc::Status MonikerWriteU64(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData); +::grpc::Status MonikerWriteU8(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData); class NiFpgaService final : public NiFpga::Service { public: @@ -61,14 +95,22 @@ class NiFpgaService final : public NiFpga::Service { ::grpc::Status ReadArrayBool(::grpc::ServerContext* context, const ReadArrayBoolRequest* request, ReadArrayBoolResponse* response) override; ::grpc::Status ReadArrayDbl(::grpc::ServerContext* context, const ReadArrayDblRequest* request, ReadArrayDblResponse* response) override; ::grpc::Status ReadArrayI16(::grpc::ServerContext* context, const ReadArrayI16Request* request, ReadArrayI16Response* response) override; + ::grpc::Status BeginReadArrayI16(::grpc::ServerContext* context, const BeginReadArrayI16Request* request, BeginReadArrayI16Response* response) override; ::grpc::Status ReadArrayI32(::grpc::ServerContext* context, const ReadArrayI32Request* request, ReadArrayI32Response* response) override; + ::grpc::Status BeginReadArrayI32(::grpc::ServerContext* context, const BeginReadArrayI32Request* request, BeginReadArrayI32Response* response) override; ::grpc::Status ReadArrayI64(::grpc::ServerContext* context, const ReadArrayI64Request* request, ReadArrayI64Response* response) override; + ::grpc::Status BeginReadArrayI64(::grpc::ServerContext* context, const BeginReadArrayI64Request* request, BeginReadArrayI64Response* response) override; ::grpc::Status ReadArrayI8(::grpc::ServerContext* context, const ReadArrayI8Request* request, ReadArrayI8Response* response) override; + ::grpc::Status BeginReadArrayI8(::grpc::ServerContext* context, const BeginReadArrayI8Request* request, BeginReadArrayI8Response* response) override; ::grpc::Status ReadArraySgl(::grpc::ServerContext* context, const ReadArraySglRequest* request, ReadArraySglResponse* response) override; ::grpc::Status ReadArrayU16(::grpc::ServerContext* context, const ReadArrayU16Request* request, ReadArrayU16Response* response) override; + ::grpc::Status BeginReadArrayU16(::grpc::ServerContext* context, const BeginReadArrayU16Request* request, BeginReadArrayU16Response* response) override; ::grpc::Status ReadArrayU32(::grpc::ServerContext* context, const ReadArrayU32Request* request, ReadArrayU32Response* response) override; + ::grpc::Status BeginReadArrayU32(::grpc::ServerContext* context, const BeginReadArrayU32Request* request, BeginReadArrayU32Response* response) override; ::grpc::Status ReadArrayU64(::grpc::ServerContext* context, const ReadArrayU64Request* request, ReadArrayU64Response* response) override; + ::grpc::Status BeginReadArrayU64(::grpc::ServerContext* context, const BeginReadArrayU64Request* request, BeginReadArrayU64Response* response) override; ::grpc::Status ReadArrayU8(::grpc::ServerContext* context, const ReadArrayU8Request* request, ReadArrayU8Response* response) override; + ::grpc::Status BeginReadArrayU8(::grpc::ServerContext* context, const BeginReadArrayU8Request* request, BeginReadArrayU8Response* response) override; ::grpc::Status ReadBool(::grpc::ServerContext* context, const ReadBoolRequest* request, ReadBoolResponse* response) override; ::grpc::Status ReadDbl(::grpc::ServerContext* context, const ReadDblRequest* request, ReadDblResponse* response) override; ::grpc::Status ReadFifoBool(::grpc::ServerContext* context, const ReadFifoBoolRequest* request, ReadFifoBoolResponse* response) override; @@ -83,14 +125,22 @@ class NiFpgaService final : public NiFpga::Service { ::grpc::Status ReadFifoU64(::grpc::ServerContext* context, const ReadFifoU64Request* request, ReadFifoU64Response* response) override; ::grpc::Status ReadFifoU8(::grpc::ServerContext* context, const ReadFifoU8Request* request, ReadFifoU8Response* response) override; ::grpc::Status ReadI16(::grpc::ServerContext* context, const ReadI16Request* request, ReadI16Response* response) override; + ::grpc::Status BeginReadI16(::grpc::ServerContext* context, const BeginReadI16Request* request, BeginReadI16Response* response) override; ::grpc::Status ReadI32(::grpc::ServerContext* context, const ReadI32Request* request, ReadI32Response* response) override; + ::grpc::Status BeginReadI32(::grpc::ServerContext* context, const BeginReadI32Request* request, BeginReadI32Response* response) override; ::grpc::Status ReadI64(::grpc::ServerContext* context, const ReadI64Request* request, ReadI64Response* response) override; + ::grpc::Status BeginReadI64(::grpc::ServerContext* context, const BeginReadI64Request* request, BeginReadI64Response* response) override; ::grpc::Status ReadI8(::grpc::ServerContext* context, const ReadI8Request* request, ReadI8Response* response) override; + ::grpc::Status BeginReadI8(::grpc::ServerContext* context, const BeginReadI8Request* request, BeginReadI8Response* response) override; ::grpc::Status ReadSgl(::grpc::ServerContext* context, const ReadSglRequest* request, ReadSglResponse* response) override; ::grpc::Status ReadU16(::grpc::ServerContext* context, const ReadU16Request* request, ReadU16Response* response) override; + ::grpc::Status BeginReadU16(::grpc::ServerContext* context, const BeginReadU16Request* request, BeginReadU16Response* response) override; ::grpc::Status ReadU32(::grpc::ServerContext* context, const ReadU32Request* request, ReadU32Response* response) override; + ::grpc::Status BeginReadU32(::grpc::ServerContext* context, const BeginReadU32Request* request, BeginReadU32Response* response) override; ::grpc::Status ReadU64(::grpc::ServerContext* context, const ReadU64Request* request, ReadU64Response* response) override; + ::grpc::Status BeginReadU64(::grpc::ServerContext* context, const BeginReadU64Request* request, BeginReadU64Response* response) override; ::grpc::Status ReadU8(::grpc::ServerContext* context, const ReadU8Request* request, ReadU8Response* response) override; + ::grpc::Status BeginReadU8(::grpc::ServerContext* context, const BeginReadU8Request* request, BeginReadU8Response* response) override; ::grpc::Status ReleaseFifoElements(::grpc::ServerContext* context, const ReleaseFifoElementsRequest* request, ReleaseFifoElementsResponse* response) override; ::grpc::Status Reset(::grpc::ServerContext* context, const ResetRequest* request, ResetResponse* response) override; ::grpc::Status Run(::grpc::ServerContext* context, const RunRequest* request, RunResponse* response) override; @@ -105,14 +155,22 @@ class NiFpgaService final : public NiFpga::Service { ::grpc::Status WriteArrayBool(::grpc::ServerContext* context, const WriteArrayBoolRequest* request, WriteArrayBoolResponse* response) override; ::grpc::Status WriteArrayDbl(::grpc::ServerContext* context, const WriteArrayDblRequest* request, WriteArrayDblResponse* response) override; ::grpc::Status WriteArrayI16(::grpc::ServerContext* context, const WriteArrayI16Request* request, WriteArrayI16Response* response) override; + ::grpc::Status BeginWriteArrayI16(::grpc::ServerContext* context, const BeginWriteArrayI16Request* request, BeginWriteArrayI16Response* response) override; ::grpc::Status WriteArrayI32(::grpc::ServerContext* context, const WriteArrayI32Request* request, WriteArrayI32Response* response) override; + ::grpc::Status BeginWriteArrayI32(::grpc::ServerContext* context, const BeginWriteArrayI32Request* request, BeginWriteArrayI32Response* response) override; ::grpc::Status WriteArrayI64(::grpc::ServerContext* context, const WriteArrayI64Request* request, WriteArrayI64Response* response) override; + ::grpc::Status BeginWriteArrayI64(::grpc::ServerContext* context, const BeginWriteArrayI64Request* request, BeginWriteArrayI64Response* response) override; ::grpc::Status WriteArrayI8(::grpc::ServerContext* context, const WriteArrayI8Request* request, WriteArrayI8Response* response) override; + ::grpc::Status BeginWriteArrayI8(::grpc::ServerContext* context, const BeginWriteArrayI8Request* request, BeginWriteArrayI8Response* response) override; ::grpc::Status WriteArraySgl(::grpc::ServerContext* context, const WriteArraySglRequest* request, WriteArraySglResponse* response) override; ::grpc::Status WriteArrayU16(::grpc::ServerContext* context, const WriteArrayU16Request* request, WriteArrayU16Response* response) override; + ::grpc::Status BeginWriteArrayU16(::grpc::ServerContext* context, const BeginWriteArrayU16Request* request, BeginWriteArrayU16Response* response) override; ::grpc::Status WriteArrayU32(::grpc::ServerContext* context, const WriteArrayU32Request* request, WriteArrayU32Response* response) override; + ::grpc::Status BeginWriteArrayU32(::grpc::ServerContext* context, const BeginWriteArrayU32Request* request, BeginWriteArrayU32Response* response) override; ::grpc::Status WriteArrayU64(::grpc::ServerContext* context, const WriteArrayU64Request* request, WriteArrayU64Response* response) override; + ::grpc::Status BeginWriteArrayU64(::grpc::ServerContext* context, const BeginWriteArrayU64Request* request, BeginWriteArrayU64Response* response) override; ::grpc::Status WriteArrayU8(::grpc::ServerContext* context, const WriteArrayU8Request* request, WriteArrayU8Response* response) override; + ::grpc::Status BeginWriteArrayU8(::grpc::ServerContext* context, const BeginWriteArrayU8Request* request, BeginWriteArrayU8Response* response) override; ::grpc::Status WriteBool(::grpc::ServerContext* context, const WriteBoolRequest* request, WriteBoolResponse* response) override; ::grpc::Status WriteDbl(::grpc::ServerContext* context, const WriteDblRequest* request, WriteDblResponse* response) override; ::grpc::Status WriteFifoBool(::grpc::ServerContext* context, const WriteFifoBoolRequest* request, WriteFifoBoolResponse* response) override; @@ -127,14 +185,22 @@ class NiFpgaService final : public NiFpga::Service { ::grpc::Status WriteFifoU64(::grpc::ServerContext* context, const WriteFifoU64Request* request, WriteFifoU64Response* response) override; ::grpc::Status WriteFifoU8(::grpc::ServerContext* context, const WriteFifoU8Request* request, WriteFifoU8Response* response) override; ::grpc::Status WriteI16(::grpc::ServerContext* context, const WriteI16Request* request, WriteI16Response* response) override; + ::grpc::Status BeginWriteI16(::grpc::ServerContext* context, const BeginWriteI16Request* request, BeginWriteI16Response* response) override; ::grpc::Status WriteI32(::grpc::ServerContext* context, const WriteI32Request* request, WriteI32Response* response) override; + ::grpc::Status BeginWriteI32(::grpc::ServerContext* context, const BeginWriteI32Request* request, BeginWriteI32Response* response) override; ::grpc::Status WriteI64(::grpc::ServerContext* context, const WriteI64Request* request, WriteI64Response* response) override; + ::grpc::Status BeginWriteI64(::grpc::ServerContext* context, const BeginWriteI64Request* request, BeginWriteI64Response* response) override; ::grpc::Status WriteI8(::grpc::ServerContext* context, const WriteI8Request* request, WriteI8Response* response) override; + ::grpc::Status BeginWriteI8(::grpc::ServerContext* context, const BeginWriteI8Request* request, BeginWriteI8Response* response) override; ::grpc::Status WriteSgl(::grpc::ServerContext* context, const WriteSglRequest* request, WriteSglResponse* response) override; ::grpc::Status WriteU16(::grpc::ServerContext* context, const WriteU16Request* request, WriteU16Response* response) override; + ::grpc::Status BeginWriteU16(::grpc::ServerContext* context, const BeginWriteU16Request* request, BeginWriteU16Response* response) override; ::grpc::Status WriteU32(::grpc::ServerContext* context, const WriteU32Request* request, WriteU32Response* response) override; + ::grpc::Status BeginWriteU32(::grpc::ServerContext* context, const BeginWriteU32Request* request, BeginWriteU32Response* response) override; ::grpc::Status WriteU64(::grpc::ServerContext* context, const WriteU64Request* request, WriteU64Response* response) override; + ::grpc::Status BeginWriteU64(::grpc::ServerContext* context, const BeginWriteU64Request* request, BeginWriteU64Response* response) override; ::grpc::Status WriteU8(::grpc::ServerContext* context, const WriteU8Request* request, WriteU8Response* response) override; + ::grpc::Status BeginWriteU8(::grpc::ServerContext* context, const BeginWriteU8Request* request, BeginWriteU8Response* response) override; private: LibrarySharedPtr library_; ResourceRepositorySharedPtr session_repository_; diff --git a/source/codegen/common_helpers.py b/source/codegen/common_helpers.py index c283d4449..2c02c2418 100644 --- a/source/codegen/common_helpers.py +++ b/source/codegen/common_helpers.py @@ -32,6 +32,12 @@ def is_input_parameter(parameter): """Whether the parameter is an input parameter.""" return "in" in parameter["direction"] +def get_streaming_parameter(parameters: List[dict]) -> dict: + for param in parameters: + if param.get("is_streaming_type", False) == True: + return param + return None + def levels_of_pointer_indirection(parameter: dict) -> int: """Levels of pointer indirection for pointer. I.e. number of '*'s.""" @@ -1194,3 +1200,19 @@ def get_params_needing_initialization(parameters: List[dict]) -> List[dict]: * Outputs that are calculated/populated after the API call. """ return [p for p in parameters if not (is_return_value(p) or is_get_last_error_output_param(p))] + + +def filter_data_moniker_functions(functions): + """Return function metadata only for functions that use the data moniker service.""" + return [ + name + for name, function in functions.items() + if function.get("data_moniker_support", False) + ] + + +def get_data_moniker_function_name(function_name, function_data): + """Return the corresponding moniker function name for the given C API function.""" + if function_data.get("moniker_cname", None): + return function_data["moniker_cname"] + return function_name.replace("Begin", "Moniker") \ No newline at end of file diff --git a/source/codegen/metadata/nifpga/config.py b/source/codegen/metadata/nifpga/config.py index 26fcd4a22..e61d248c9 100644 --- a/source/codegen/metadata/nifpga/config.py +++ b/source/codegen/metadata/nifpga/config.py @@ -13,6 +13,7 @@ 'code_readiness': 'Release', 'driver_name': 'NI-FPGA', 'status_ok': 'status >= 0', + 'additional_protos': ['data_moniker.proto'], 'resource_handle_type': ['NiFpga_Session'], 'type_to_grpc_type': { 'NiFpga_Session': 'nidevice_grpc.Session', @@ -30,6 +31,9 @@ 'NiFpga_Bool': 'bool', 'NiFpga_FifoProperty': 'uint32', }, + 'use_moniker_service': True, + 'use_dynload_msvc': True, + 'use_protobuf_arenas': True, 'custom_types': [], 'library_info': { 'Linux': { @@ -54,4 +58,4 @@ 'module_name': 'nifpga', 'session_class_description': 'An NI-FPGA session.', 'session_handle_parameter_name': 'session' -} +} \ No newline at end of file diff --git a/source/codegen/metadata/nifpga/custom_proto.mako b/source/codegen/metadata/nifpga/custom_proto.mako new file mode 100644 index 000000000..19f03d497 --- /dev/null +++ b/source/codegen/metadata/nifpga/custom_proto.mako @@ -0,0 +1,35 @@ +message I32Data { + int32 value = 1; +} + +message U32Data { + uint32 value = 1; +} + +message I64Data { + int64 value = 1; +} + +message U64Data { + uint64 value = 1; +} + +message BoolData { + bool value = 1; +} + +message ArrayI32Data { + repeated int32 value = 1; +} + +message ArrayU32Data { + repeated uint32 value = 1; +} + +message ArrayI64Data { + repeated int64 value = 1; +} + +message ArrayU64Data { + repeated uint64 value = 1; +} \ No newline at end of file diff --git a/source/codegen/metadata/nifpga/functions.py b/source/codegen/metadata/nifpga/functions.py index 046f9e857..a9e98a0af 100644 --- a/source/codegen/metadata/nifpga/functions.py +++ b/source/codegen/metadata/nifpga/functions.py @@ -1715,6 +1715,7 @@ 'returns': 'NiFpga_Status' }, 'ReadArrayI16': { + 'moniker_supports_streaming': True, 'parameters': [ { 'direction': 'in', @@ -1728,6 +1729,7 @@ }, { 'direction': 'out', + 'is_streaming_type': True, 'name': 'array', 'size': { 'mechanism': 'passed-in', @@ -1744,6 +1746,7 @@ 'returns': 'NiFpga_Status' }, 'ReadArrayI32': { + 'moniker_supports_streaming': True, 'parameters': [ { 'direction': 'in', @@ -1757,6 +1760,7 @@ }, { 'direction': 'out', + 'is_streaming_type': True, 'name': 'array', 'size': { 'mechanism': 'passed-in', @@ -1773,6 +1777,7 @@ 'returns': 'NiFpga_Status' }, 'ReadArrayI64': { + 'moniker_supports_streaming': True, 'parameters': [ { 'direction': 'in', @@ -1786,6 +1791,7 @@ }, { 'direction': 'out', + 'is_streaming_type': True, 'name': 'array', 'size': { 'mechanism': 'passed-in', @@ -1802,6 +1808,7 @@ 'returns': 'NiFpga_Status' }, 'ReadArrayI8': { + 'moniker_supports_streaming': True, 'parameters': [ { 'direction': 'in', @@ -1815,6 +1822,7 @@ }, { 'direction': 'out', + 'is_streaming_type': True, 'name': 'array', 'size': { 'mechanism': 'passed-in', @@ -1860,6 +1868,7 @@ 'returns': 'NiFpga_Status' }, 'ReadArrayU16': { + 'moniker_supports_streaming': True, 'parameters': [ { 'direction': 'in', @@ -1873,6 +1882,7 @@ }, { 'direction': 'out', + 'is_streaming_type': True, 'name': 'array', 'size': { 'mechanism': 'passed-in', @@ -1889,6 +1899,7 @@ 'returns': 'NiFpga_Status' }, 'ReadArrayU32': { + 'moniker_supports_streaming': True, 'parameters': [ { 'direction': 'in', @@ -1902,6 +1913,7 @@ }, { 'direction': 'out', + 'is_streaming_type': True, 'name': 'array', 'size': { 'mechanism': 'passed-in', @@ -1918,6 +1930,7 @@ 'returns': 'NiFpga_Status' }, 'ReadArrayU64': { + 'moniker_supports_streaming': True, 'parameters': [ { 'direction': 'in', @@ -1931,6 +1944,7 @@ }, { 'direction': 'out', + 'is_streaming_type': True, 'name': 'array', 'size': { 'mechanism': 'passed-in', @@ -1947,6 +1961,7 @@ 'returns': 'NiFpga_Status' }, 'ReadArrayU8': { + 'moniker_supports_streaming': True, 'parameters': [ { 'direction': 'in', @@ -1960,6 +1975,7 @@ }, { 'direction': 'out', + 'is_streaming_type': True, 'name': 'array', 'size': { 'mechanism': 'passed-in', @@ -2516,6 +2532,7 @@ 'returns': 'NiFpga_Status' }, 'ReadI16': { + 'moniker_supports_streaming': True, 'parameters': [ { 'direction': 'in', @@ -2529,6 +2546,7 @@ }, { 'direction': 'out', + 'is_streaming_type': True, 'name': 'value', 'type': 'int16_t' } @@ -2536,6 +2554,7 @@ 'returns': 'NiFpga_Status' }, 'ReadI32': { + 'moniker_supports_streaming': True, 'parameters': [ { 'direction': 'in', @@ -2549,6 +2568,7 @@ }, { 'direction': 'out', + 'is_streaming_type': True, 'name': 'value', 'type': 'int32_t' } @@ -2556,6 +2576,7 @@ 'returns': 'NiFpga_Status' }, 'ReadI64': { + 'moniker_supports_streaming': True, 'parameters': [ { 'direction': 'in', @@ -2569,6 +2590,7 @@ }, { 'direction': 'out', + 'is_streaming_type': True, 'name': 'value', 'type': 'int64_t' } @@ -2576,6 +2598,7 @@ 'returns': 'NiFpga_Status' }, 'ReadI8': { + 'moniker_supports_streaming': True, 'parameters': [ { 'direction': 'in', @@ -2589,6 +2612,7 @@ }, { 'direction': 'out', + 'is_streaming_type': True, 'name': 'value', 'type': 'int8_t' } @@ -2616,6 +2640,7 @@ 'returns': 'NiFpga_Status' }, 'ReadU16': { + 'moniker_supports_streaming': True, 'parameters': [ { 'direction': 'in', @@ -2629,6 +2654,7 @@ }, { 'direction': 'out', + 'is_streaming_type': True, 'name': 'value', 'type': 'uint16_t' } @@ -2636,6 +2662,7 @@ 'returns': 'NiFpga_Status' }, 'ReadU32': { + 'moniker_supports_streaming': True, 'parameters': [ { 'direction': 'in', @@ -2649,6 +2676,7 @@ }, { 'direction': 'out', + 'is_streaming_type': True, 'name': 'value', 'type': 'uint32_t' } @@ -2656,6 +2684,7 @@ 'returns': 'NiFpga_Status' }, 'ReadU64': { + 'moniker_supports_streaming': True, 'parameters': [ { 'direction': 'in', @@ -2669,6 +2698,7 @@ }, { 'direction': 'out', + 'is_streaming_type': True, 'name': 'value', 'type': 'uint64_t' } @@ -2676,6 +2706,7 @@ 'returns': 'NiFpga_Status' }, 'ReadU8': { + 'moniker_supports_streaming': True, 'parameters': [ { 'direction': 'in', @@ -2689,6 +2720,7 @@ }, { 'direction': 'out', + 'is_streaming_type': True, 'name': 'value', 'type': 'uint8_t' } @@ -3082,6 +3114,7 @@ 'returns': 'NiFpga_Status' }, 'WriteArrayI16': { + 'moniker_supports_streaming': True, 'parameters': [ { 'direction': 'in', @@ -3095,6 +3128,7 @@ }, { 'direction': 'in', + 'is_streaming_type': True, 'name': 'array', 'size': { 'mechanism': 'len', @@ -3111,6 +3145,7 @@ 'returns': 'NiFpga_Status' }, 'WriteArrayI32': { + 'moniker_supports_streaming': True, 'parameters': [ { 'direction': 'in', @@ -3124,6 +3159,7 @@ }, { 'direction': 'in', + 'is_streaming_type': True, 'name': 'array', 'size': { 'mechanism': 'len', @@ -3140,6 +3176,7 @@ 'returns': 'NiFpga_Status' }, 'WriteArrayI64': { + 'moniker_supports_streaming': True, 'parameters': [ { 'direction': 'in', @@ -3153,6 +3190,7 @@ }, { 'direction': 'in', + 'is_streaming_type': True, 'name': 'array', 'size': { 'mechanism': 'len', @@ -3169,6 +3207,7 @@ 'returns': 'NiFpga_Status' }, 'WriteArrayI8': { + 'moniker_supports_streaming': True, 'parameters': [ { 'direction': 'in', @@ -3182,6 +3221,7 @@ }, { 'direction': 'in', + 'is_streaming_type': True, 'name': 'array', 'size': { 'mechanism': 'len', @@ -3227,6 +3267,7 @@ 'returns': 'NiFpga_Status' }, 'WriteArrayU16': { + 'moniker_supports_streaming': True, 'parameters': [ { 'direction': 'in', @@ -3240,6 +3281,7 @@ }, { 'direction': 'in', + 'is_streaming_type': True, 'name': 'array', 'size': { 'mechanism': 'len', @@ -3256,6 +3298,7 @@ 'returns': 'NiFpga_Status' }, 'WriteArrayU32': { + 'moniker_supports_streaming': True, 'parameters': [ { 'direction': 'in', @@ -3269,6 +3312,7 @@ }, { 'direction': 'in', + 'is_streaming_type': True, 'name': 'array', 'size': { 'mechanism': 'len', @@ -3285,6 +3329,7 @@ 'returns': 'NiFpga_Status' }, 'WriteArrayU64': { + 'moniker_supports_streaming': True, 'parameters': [ { 'direction': 'in', @@ -3298,6 +3343,7 @@ }, { 'direction': 'in', + 'is_streaming_type': True, 'name': 'array', 'size': { 'mechanism': 'len', @@ -3314,6 +3360,7 @@ 'returns': 'NiFpga_Status' }, 'WriteArrayU8': { + 'moniker_supports_streaming': True, 'parameters': [ { 'direction': 'in', @@ -3327,6 +3374,7 @@ }, { 'direction': 'in', + 'is_streaming_type': True, 'name': 'array', 'size': { 'mechanism': 'len', @@ -3879,6 +3927,7 @@ 'returns': 'NiFpga_Status' }, 'WriteI16': { + 'moniker_supports_streaming': True, 'parameters': [ { 'direction': 'in', @@ -3892,6 +3941,7 @@ }, { 'direction': 'in', + 'is_streaming_type': True, 'name': 'value', 'type': 'int16_t' } @@ -3899,6 +3949,7 @@ 'returns': 'NiFpga_Status' }, 'WriteI32': { + 'moniker_supports_streaming': True, 'parameters': [ { 'direction': 'in', @@ -3912,6 +3963,7 @@ }, { 'direction': 'in', + 'is_streaming_type': True, 'name': 'value', 'type': 'int32_t' } @@ -3919,6 +3971,7 @@ 'returns': 'NiFpga_Status' }, 'WriteI64': { + 'moniker_supports_streaming': True, 'parameters': [ { 'direction': 'in', @@ -3932,6 +3985,7 @@ }, { 'direction': 'in', + 'is_streaming_type': True, 'name': 'value', 'type': 'int64_t' } @@ -3939,6 +3993,7 @@ 'returns': 'NiFpga_Status' }, 'WriteI8': { + 'moniker_supports_streaming': True, 'parameters': [ { 'direction': 'in', @@ -3952,6 +4007,7 @@ }, { 'direction': 'in', + 'is_streaming_type': True, 'name': 'value', 'type': 'int8_t' } @@ -3979,6 +4035,7 @@ 'returns': 'NiFpga_Status' }, 'WriteU16': { + 'moniker_supports_streaming': True, 'parameters': [ { 'direction': 'in', @@ -3992,6 +4049,7 @@ }, { 'direction': 'in', + 'is_streaming_type': True, 'name': 'value', 'type': 'uint16_t' } @@ -3999,6 +4057,7 @@ 'returns': 'NiFpga_Status' }, 'WriteU32': { + 'moniker_supports_streaming': True, 'parameters': [ { 'direction': 'in', @@ -4012,6 +4071,7 @@ }, { 'direction': 'in', + 'is_streaming_type': True, 'name': 'value', 'type': 'uint32_t' } @@ -4019,6 +4079,7 @@ 'returns': 'NiFpga_Status' }, 'WriteU64': { + 'moniker_supports_streaming': True, 'parameters': [ { 'direction': 'in', @@ -4032,6 +4093,7 @@ }, { 'direction': 'in', + 'is_streaming_type': True, 'name': 'value', 'type': 'uint64_t' } @@ -4039,6 +4101,7 @@ 'returns': 'NiFpga_Status' }, 'WriteU8': { + 'moniker_supports_streaming': True, 'parameters': [ { 'direction': 'in', @@ -4052,10 +4115,11 @@ }, { 'direction': 'in', + 'is_streaming_type': True, 'name': 'value', 'type': 'uint8_t' } ], 'returns': 'NiFpga_Status' } -} +} \ No newline at end of file diff --git a/source/codegen/metadata_mutation.py b/source/codegen/metadata_mutation.py index 26fba6ac1..622df474c 100644 --- a/source/codegen/metadata_mutation.py +++ b/source/codegen/metadata_mutation.py @@ -4,6 +4,7 @@ from typing import Any, Dict, Optional import common_helpers +import copy RESERVED_WORDS = [ "abstract", @@ -117,6 +118,18 @@ def mutate(metadata: dict): if config["driver_name"] in _ALREADY_MUTATED: return + # Generate new streaming APIs for functions that support it. + all_functions = {} + + for function_name, function in metadata["functions"].items(): + all_functions[function_name] = function + + if function.get('moniker_supports_streaming') is True: + new_function_name = f"Begin{function_name}" + all_functions[new_function_name] = generate_streaming_metadata(function) + + metadata["functions"] = all_functions + move_zero_enums_to_front(metadata["enums"]) for custom_type in config["custom_types"]: @@ -124,8 +137,7 @@ def mutate(metadata: dict): set_grpc_type_for_custom_type_fields(fields, config) attribute_expander = AttributeAccessorExpander(metadata) - for function_name in metadata["functions"]: - function = metadata["functions"][function_name] + for function_name, function in metadata["functions"].items(): parameters = function["parameters"] add_get_last_error_params_if_needed(function, config) sanitize_names(parameters) @@ -138,6 +150,34 @@ def mutate(metadata: dict): attribute_expander.expand_attribute_value_params(function) attribute_expander.patch_attribute_enum_type(function_name, function) +def generate_streaming_metadata(function: dict) -> dict: + """Generate the streaming API metadata for a given function.""" + + streaming_parameters = [] + + for param in function['parameters']: + new_param = copy.deepcopy(param) + if new_param.get('is_streaming_type', False) is True: + new_param['include_in_proto'] = False + streaming_parameters.append(new_param) + + # Add the additional out parameter at the end + streaming_parameters.append({ + 'direction': 'out', + 'grpc_type': 'ni.data_monikers.Moniker', + 'name': 'moniker', + 'type': 'ni::data_monikers::Moniker' + }) + + # Construct the streaming API metadata + streaming_metadata = { + 'data_moniker_support': True, + 'exclude_from_library': True, + 'parameters': streaming_parameters, + 'returns': function['returns'] + } + + return streaming_metadata def sanitize_names(parameters): """Sanitize name fields on a list of parameter objects. @@ -477,4 +517,4 @@ def add_get_last_error_params_if_needed(function_data: Dict[str, Any], config: d "name": get_last_error_field["name"], "type": get_last_error_field["type"], } - ) + ) \ No newline at end of file diff --git a/source/codegen/metadata_validation.py b/source/codegen/metadata_validation.py index 471f8ea11..6c1a36697 100644 --- a/source/codegen/metadata_validation.py +++ b/source/codegen/metadata_validation.py @@ -124,6 +124,7 @@ class RULES: Optional("python_default_value"): Or(str, bool, int, float, None), Optional("is_grpc_enum"): bool, Optional("return_on_error_key"): str, + Optional("is_streaming_type"): bool, } ) @@ -173,6 +174,10 @@ class RULES: Optional("is_python_factory"): bool, Optional("python_description"): str, Optional("timeout_error"): str, + Optional("exclude_from_library"): bool, + Optional("data_moniker_support"): bool, + Optional("moniker_streaming_type"): str, + Optional("moniker_supports_streaming"): bool, } ) @@ -507,4 +512,4 @@ def _is_string_type(parameter: dict, metadata: dict) -> bool: grpc_type = parameter.get("grpc_type", None) if grpc_type is None: grpc_type = common_helpers.get_grpc_type(parameter["type"], metadata["config"]) - return grpc_type == "string" + return grpc_type == "string" \ No newline at end of file diff --git a/source/codegen/service_helpers.py b/source/codegen/service_helpers.py index f806e7636..71c45e1b8 100644 --- a/source/codegen/service_helpers.py +++ b/source/codegen/service_helpers.py @@ -318,7 +318,7 @@ def filter_api_functions(functions, only_mockable_functions=True): """Filter function metadata to only include those to be generated into the API library.""" def filter_function(function): - if function.get("codegen_method", "") == "no": + if function.get("codegen_method", "") == "no" or function.get("exclude_from_library", False): return False if only_mockable_functions and not common_helpers.can_mock_function(function["parameters"]): return False @@ -707,3 +707,107 @@ def get_protobuf_cpplib_type(grpc_type: str) -> str: return "std::string" return grpc_type + + +def create_moniker_function_name(function_name: str) -> str: + """Get the function name for the moniker function.""" + return f"Moniker{function_name.replace('Begin', '')}" + + +def get_coerced_type_and_presence(streaming_type: str) -> tuple: + """ + Get the coerced type and check if the coerced type is present in the type map. + This handles both scalar types and array types like int8_t[] or uint16_t[]. + + Args: + streaming_type (str): The streaming type (scalar or array). + + Returns: + tuple: A tuple containing coerced_type (str) and is_coerced_type_present (bool). + """ + type_map = { + 'int8_t': 'int32_t', + 'uint8_t': 'uint32_t', + 'int16_t': 'int32_t', + 'uint16_t': 'uint32_t', + } + + base_type = streaming_type.replace('[]', '') + + coerced_type = type_map.get(base_type, base_type) + is_coerced_type_present = base_type in type_map + + return coerced_type, is_coerced_type_present + + +def get_grpc_streaming_type(coerced_type: str) -> str: + """ + Get the gRPC streaming type for the given coerced type. + + Args: + coerced_type (str): The coerced type. + + Returns: + str: The gRPC streaming type. + """ + grpc_map = { + 'int8_t': 'I32', + 'uint8_t': 'U32', + 'int16_t': 'I32', + 'uint16_t': 'U32', + 'uint32_t': 'U32', + 'int32_t': 'I32', + 'uint64_t': 'U64', + 'int64_t': 'I64', + "int16_t[]" : 'ArrayI32', + "int8_t[]" : 'ArrayI32', + "int32_t[]" : 'ArrayI32', + "int64_t[]" : 'ArrayI64', + "uint16_t[]" : 'ArrayU32', + "uint8_t[]" : 'ArrayU32', + "uint32_t[]" : 'ArrayU32', + "uint64_t[]" : 'ArrayU64', + } + + grpc_streaming_type = grpc_map.get(coerced_type, 'U32') + + return grpc_streaming_type + +def get_streaming_type(parameters) -> str: + """ + Get the streaming type from the function data. + + Args: + function_name (dict): The function data dictionary. + + Returns: + str: The streaming type if found, otherwise 'None'. + """ + for param in parameters: + if param.get('is_streaming_type', False) == True: + return param['type'] + return None + +def include_param(param, streaming_param): + if not param.get('is_streaming_type', False): + if streaming_param and streaming_param['direction'] == 'in' and common_helpers.is_array(streaming_param['type']): + if param['name'] != streaming_param['size']['value']: + return True + else: + return False + else: + return True + else: + return False + +def get_size_param_name(streaming_param) -> str: + if common_helpers.is_array(streaming_param['type']): + return streaming_param['size']['value'] + else: + return None + +def get_c_api_name(function_name) -> str: + if function_name.startswith("Begin"): + base_name = function_name[len("Begin"):] + return f"{base_name}" + return f"{function_name}" \ No newline at end of file diff --git a/source/codegen/templates/proto.mako b/source/codegen/templates/proto.mako index 0e1e5a126..f49d5f894 100644 --- a/source/codegen/templates/proto.mako +++ b/source/codegen/templates/proto.mako @@ -9,6 +9,8 @@ functions = data["functions"] service_class_prefix = config["service_class_prefix"] function_enums = common_helpers.get_function_enums(functions, enums) external_proto_deps = common_helpers.list_external_proto_dependencies(functions) +additional_protos = config.get("additional_protos", []) +additional_protos.extend(external_proto_deps) %>\ <%namespace name="mako_helper" file="/proto_helpers.mako"/>\ @@ -19,6 +21,9 @@ external_proto_deps = common_helpers.list_external_proto_dependencies(functions) //--------------------------------------------------------------------- syntax = "proto3"; +% if config.get("use_protobuf_arenas", False): +option cc_enable_arenas = true; +% endif option java_multiple_files = true; option java_package = "${config["java_package"]}"; option java_outer_classname = "${service_class_prefix}"; @@ -30,7 +35,7 @@ package ${config["namespace_component"]}_grpc; import "nidevice.proto"; % endif import "session.proto"; -% for proto in external_proto_deps: +% for proto in additional_protos: import "${proto}"; % endfor @@ -63,4 +68,4 @@ ${mako_helper.define_request_message(function, input_parameters)}\ ${mako_helper.define_response_message(function, output_parameters)}\ -% endfor +% endfor \ No newline at end of file diff --git a/source/codegen/templates/register_all_services.cpp.mako b/source/codegen/templates/register_all_services.cpp.mako index 83bb672a0..a0361bef6 100644 --- a/source/codegen/templates/register_all_services.cpp.mako +++ b/source/codegen/templates/register_all_services.cpp.mako @@ -17,6 +17,7 @@ repository_type_to_config = service_helpers.list_session_repository_handle_types #include #include +#include % for config in driver_configs: <% @@ -24,6 +25,9 @@ repository_type_to_config = service_helpers.list_session_repository_handle_types %>\ <%block filter="common_helpers.os_conditional_compile_block(config)">\ #include "${module_name}/${module_name}_service_registrar.h" +% if config.get("use_moniker_service", False): +#include "${module_name}/${module_name}_service.h" +% endif \ % endfor @@ -38,6 +42,9 @@ std::shared_ptr>> register_all_services( auto session_repository = std::make_shared(); service_vector->push_back(session_repository); nidevice_grpc::register_core_services(service_vector, server_builder, session_repository, feature_toggles); + auto moniker_service = std::make_shared(); + server_builder.RegisterService(moniker_service.get()); + service_vector->push_back(moniker_service); % for type_name, config in repository_type_to_config.items(): <%block filter="common_helpers.os_conditional_compile_block(config)">\ @@ -60,9 +67,20 @@ std::shared_ptr>> register_all_services( % endfor feature_toggles)); \ +% endfor +% for driver in drivers: +<% + config = driver["config"] + namespace = f"{config['namespace_component']}_grpc" +%>\ +% if config.get("use_moniker_service", False): +<%block filter="common_helpers.os_conditional_compile_block(config)">\ + ${namespace}::RegisterMonikers(); +\ +% endif % endfor return service_vector; } -} // nidevice_grpc +} // nidevice_grpc \ No newline at end of file diff --git a/source/codegen/templates/service.cpp.mako b/source/codegen/templates/service.cpp.mako index f353ed736..45ddf702f 100644 --- a/source/codegen/templates/service.cpp.mako +++ b/source/codegen/templates/service.cpp.mako @@ -13,6 +13,7 @@ custom_types = common_helpers.get_custom_types(config) has_async_functions = any(service_helpers.get_async_functions(functions)) has_two_dimension_functions = any(service_helpers.get_functions_with_two_dimension_param(functions)) function_names = service_helpers.filter_proto_rpc_functions_to_generate(functions) +data_moniker_functions = common_helpers.filter_data_moniker_functions(functions) # If there are any non-mockable functions, we need to call the library directly, which # means we need another include file any_non_mockable_functions = any(not common_helpers.can_mock_function(functions[name]['parameters']) for name in function_names) @@ -51,6 +52,10 @@ resource_repository_deps = service_helpers.get_driver_shared_resource_repository % if any_non_mockable_functions: #include "${module_name}_library.h" % endif +% if data_moniker_functions: +#include +#include +% endif namespace ${config["namespace_component"]}_grpc { @@ -99,6 +104,16 @@ namespace ${config["namespace_component"]}_grpc { } } +% endif +% if data_moniker_functions: +void RegisterMoniker() +{ +% for function_name in service_helpers.filter_proto_rpc_functions_to_generate(functions): +% if function_name in data_moniker_functions: +${mako_helper.register_moniker_functions(function_name)}\ +% endif +% endfor +} % endif % for function_name in service_helpers.filter_proto_rpc_functions_to_generate(functions): <% @@ -110,6 +125,9 @@ namespace ${config["namespace_component"]}_grpc { response_type = service_helpers.get_response_type(method_name) is_async_streaming = common_helpers.has_async_streaming_response(function_data) %>\ +% if function_name in data_moniker_functions: +${mako_helper.define_streaming_api(function_name=function_name, function_data=function_data, parameters=parameters)}\ +% else: //--------------------------------------------------------------------- //--------------------------------------------------------------------- % if is_async_streaming: @@ -146,6 +164,7 @@ ${mako_helper.define_simple_method_body(function_name=function_name, function_da } } % endif +% endif % endfor diff --git a/source/codegen/templates/service.h.mako b/source/codegen/templates/service.h.mako index 09c9e6cc0..614c6e9c0 100644 --- a/source/codegen/templates/service.h.mako +++ b/source/codegen/templates/service.h.mako @@ -17,6 +17,7 @@ custom_types = common_helpers.get_custom_types(config) (input_custom_types, output_custom_types) = common_helpers.get_input_and_output_custom_types(config, functions) resource_repository_deps = service_helpers.get_driver_shared_resource_repository_ptr_deps(config, functions) resource_handle_types = service_helpers.get_resource_handle_types(config) +data_moniker_functions = common_helpers.filter_data_moniker_functions(functions) async_functions = service_helpers.get_async_functions(functions) has_async_functions = any(async_functions) @@ -59,6 +60,20 @@ struct ${service_class_prefix}FeatureToggles bool ${service_helpers.get_toggle_member_name(toggle)}; % endfor }; +% if config.get("use_moniker_service", False): +void RegisterMonikers(); + +% for function in data_moniker_functions: +<% + method_name = common_helpers.get_data_moniker_function_name(function, functions[function]) +%>\ +% if config.get("use_protobuf_arenas", False): +::grpc::Status ${method_name}(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData); +% else: +::grpc::Status ${method_name}(void* data, google::protobuf::Any& packedData); +% endif +% endfor +% endif % if type_from_enum != "": enum TypeIdentifier { ${type_from_enum} }; diff --git a/source/codegen/templates/service_helpers.mako b/source/codegen/templates/service_helpers.mako index aee41c31f..06340cba3 100644 --- a/source/codegen/templates/service_helpers.mako +++ b/source/codegen/templates/service_helpers.mako @@ -271,6 +271,198 @@ ${populate_response(function_data=function_data, parameters=parameters)}\ return ::grpc::Status::OK;\ +<%def name="register_moniker_functions(function_name)"> +<% moniker_function_name = service_helpers.create_moniker_function_name(function_name) +%> ::ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("${moniker_function_name}", ${moniker_function_name}); + + +<%def name="define_streaming_api(function_name, function_data, parameters)"> +<% + config = data['config'] + input_params = [p for p in parameters if common_helpers.is_input_parameter(p)] + output_params = [p for p in parameters if common_helpers.is_output_parameter(p)] + service_class_prefix = config["service_class_prefix"] + request_param = service_helpers.get_request_param(function_name) + response_param = service_helpers.get_response_param(function_name) + struct_name = f"Moniker{function_name.replace('Begin', '')}Data" if function_name.startswith('Begin') else f"Moniker{function_name}Data" + moniker_function_name = service_helpers.create_moniker_function_name(function_name) + c_api_name = service_helpers.get_c_api_name(function_name) + streaming_param = common_helpers.get_streaming_parameter(parameters) + streaming_type = streaming_param['type'] + coerced_type, is_coerced_type_present = service_helpers.get_coerced_type_and_presence(streaming_type) + grpc_streaming_type = service_helpers.get_grpc_streaming_type(streaming_type) + is_array = common_helpers.is_array(streaming_type) +%>\ +struct ${struct_name} +{ + % for param in input_params: + % if service_helpers.include_param(param, streaming_param): + ${param['type']} ${param['name']}; + % endif + % endfor + ${service_class_prefix.lower()}_grpc::${grpc_streaming_type}Data data; + std::shared_ptr<${service_class_prefix}LibraryInterface> library; +}; + +::grpc::Status ${service_class_prefix}Service::${function_name}(::grpc::ServerContext* context, ${request_param}, ${response_param}) +{ + if (context->IsCancelled()) { + return ::grpc::Status::CANCELLED; + } + try { +${initialize_streaming_input_param(function_name, input_params, parameters, streaming_param)} + ${struct_name}* data = new ${struct_name}(); + ${initialize_begin_input_param(input_params, streaming_param)}\ + data->library = std::shared_ptr<${service_class_prefix}LibraryInterface>(library_); + ${initialize_service_output_params(output_params)}\ + ni::data_monikers::Moniker* moniker = new ni::data_monikers::Moniker(); + ni::data_monikers::DataMonikerService::RegisterMonikerInstance("${moniker_function_name}", data, *moniker); + response->set_allocated_moniker(moniker); + return ::grpc::Status::OK; + } + catch (std::exception& ex) { + return ::grpc::Status(::grpc::UNKNOWN, ex.what()); + } +} +<% + arg_string= service_helpers.create_args(parameters) + arg_string = arg_string.replace(", &moniker", "").strip() + data_type = streaming_type.replace("[]", "") +%>\ +::grpc::Status ${moniker_function_name}(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData) +{ + ${struct_name}* function_data = (${struct_name}*)data; + auto library = function_data->library; + ${initialize_non_array_parameters(input_params, streaming_param)}\ + % if streaming_param and streaming_param['direction'] == 'out': + ${handle_out_direction(c_api_name, arg_string, data_type, streaming_type, is_coerced_type_present, streaming_param)}\ + % elif streaming_param and streaming_param['direction'] == 'in': + ${handle_in_direction(c_api_name, arg_string, data_type, grpc_streaming_type, streaming_type, coerced_type, is_coerced_type_present, is_array)}\ + % endif + if (status < 0) { + std::cout << "${moniker_function_name} error: " << status << std::endl; + } + return ::grpc::Status::OK; +} + + +<%def name="handle_out_direction(c_api_name, arg_string, data_type, streaming_type, is_coerced_type_present, streaming_param)"> +<% + size = service_helpers.get_size_param_name(streaming_param) +%>\ + % if common_helpers.is_array(streaming_type): + % if is_coerced_type_present: + std::vector<${data_type}> array(${size}); + % else: + ${data_type}* array = new ${data_type}[${size}]; + % endif + auto status = library->${c_api_name}(${arg_string}); + % if is_coerced_type_present: + if (status >= 0) { + std::transform( + array.begin(), + array.begin() + ${size}, + function_data->data.mutable_value()->begin(), + [&](auto x) { + return x; + }); + packedData.PackFrom(function_data->data); + } + % else: + if (status >= 0) { + std::transform( + array, + array + ${size}, + function_data->data.mutable_value()->begin(), + [&](auto x) { + return x; + }); + packedData.PackFrom(function_data->data); + } + % endif + % else: + ${streaming_type} value = 0; + auto status = library->${c_api_name}(${arg_string}); + function_data->data.set_value(value); + if (status >= 0) { + packedData.PackFrom(function_data->data); + } + % endif + + +<%def name="handle_in_direction(c_api_name, arg_string, data_type, grpc_streaming_type, streaming_type, coerced_type, is_coerced_type_present, is_array)"> + ${grpc_streaming_type}Data ${grpc_streaming_type.lower()}_data; + packedData.UnpackTo(&${grpc_streaming_type.lower()}_data); +% if is_array: + % if is_coerced_type_present: + auto data_array = ${grpc_streaming_type.lower()}_data.value(); + auto array = std::vector<${data_type}>(); + auto size = data_array.size(); + array.reserve(size); + std::transform( + data_array.begin(), + data_array.end(), + std::back_inserter(array), + [](auto x) { + if (x < std::numeric_limits<${data_type}>::min() || x > std::numeric_limits<${data_type}>::max()) { + std::string message("value " + std::to_string(x) + " doesn't fit in datatype ${data_type}"); + throw nidevice_grpc::ValueOutOfRangeException(message); + } + return static_cast<${data_type}>(x); + }); +% else: + auto data_array = ${grpc_streaming_type.lower()}_data.value(); + auto array = const_cast<${data_type}*>(${grpc_streaming_type.lower()}_data.value().data()); + auto size = data_array.size(); +% endif +% else: + ${coerced_type} value = ${grpc_streaming_type.lower()}_data.value(); +% if is_coerced_type_present: + if (value < std::numeric_limits<${streaming_type}>::min() || value > std::numeric_limits<${streaming_type}>::max()) { + std::string message("value " + std::to_string(value) + " doesn't fit in datatype ${streaming_type}"); + throw nidevice_grpc::ValueOutOfRangeException(message); + } +% endif +% endif + + auto status = library->${c_api_name}(${arg_string}); + + +## Initialize an bgin input parameter for an API call. +<%def name="initialize_begin_input_param(input_params, streaming_param)">\ +% for param in input_params: +% if service_helpers.include_param(param, streaming_param): + data->${param['name']} = ${param['name']}; +% endif +% endfor + + +## Initialize an bgin input parameter for an API call. +<%def name="initialize_streaming_input_param(function_name, input_params, parameters, streaming_param)">\ +% for param in input_params: +% if service_helpers.include_param(param, streaming_param): +${initialize_input_param(function_name, param, parameters)}\ +% endif +% endfor + + +<%def name="initialize_non_array_parameters(input_params, streaming_param)"> +% for param in input_params: + % if service_helpers.include_param(param, streaming_param): + auto ${param['name']} = function_data->${param['name']}; + % endif +% endfor + + +<%def name="initialize_service_output_params(output_params)"> +% for param in output_params: +% if common_helpers.is_array(param['type']): + data->data.mutable_value()->Reserve(request->size()); + data->data.mutable_value()->Resize(request->size(), 0); +% endif +% endfor + + ## Initialize the input parameters to the API call. <%def name="initialize_input_params(function_name, parameters)">\ <% @@ -977,4 +1169,4 @@ ${copy_to_response_with_transform(source_buffer=parameter_name, parameter_name=p ${auto_decl}status = ${service_helpers.get_status_expression(function_data)}; % endif \ - + \ No newline at end of file From cbfd8e8b753e254ed20d9332f3e7b1b774478864 Mon Sep 17 00:00:00 2001 From: Ayush Mehra Date: Mon, 28 Oct 2024 03:45:35 -0700 Subject: [PATCH 05/34] update grpc-streaming_type --- generated/nifpga/nifpga_service.cpp | 104 +++++++++--------- source/codegen/metadata/nifpga/functions.py | 34 +++++- source/codegen/metadata_validation.py | 1 + source/codegen/service_helpers.py | 33 ------ source/codegen/templates/service_helpers.mako | 14 +-- 5 files changed, 93 insertions(+), 93 deletions(-) diff --git a/generated/nifpga/nifpga_service.cpp b/generated/nifpga/nifpga_service.cpp index e695fa25f..d571a3c2e 100644 --- a/generated/nifpga/nifpga_service.cpp +++ b/generated/nifpga/nifpga_service.cpp @@ -2979,9 +2979,9 @@ ::grpc::Status MonikerWriteArrayI16(void* data, google::protobuf::Arena& arena, auto session = function_data->session; auto control = function_data->control; - ArrayI32Data arrayi32_data; - packedData.UnpackTo(&arrayi32_data); - auto data_array = arrayi32_data.value(); + ArrayI32Data arrayi32data_message; + packedData.UnpackTo(&arrayi32data_message); + auto data_array = arrayi32data_data.value(); auto array = std::vector(); auto size = data_array.size(); array.reserve(size); @@ -3070,10 +3070,10 @@ ::grpc::Status MonikerWriteArrayI32(void* data, google::protobuf::Arena& arena, auto session = function_data->session; auto control = function_data->control; - ArrayI32Data arrayi32_data; - packedData.UnpackTo(&arrayi32_data); - auto data_array = arrayi32_data.value(); - auto array = const_cast(arrayi32_data.value().data()); + ArrayI32Data arrayi32data_message; + packedData.UnpackTo(&arrayi32data_message); + auto data_array = arrayi32data_message.value(); + auto array = const_cast(arrayi32data_message.value().data()); auto size = data_array.size(); auto status = library->WriteArrayI32(session, control, array, size); @@ -3149,10 +3149,10 @@ ::grpc::Status MonikerWriteArrayI64(void* data, google::protobuf::Arena& arena, auto session = function_data->session; auto control = function_data->control; - ArrayI64Data arrayi64_data; - packedData.UnpackTo(&arrayi64_data); - auto data_array = arrayi64_data.value(); - auto array = const_cast(arrayi64_data.value().data()); + ArrayI64Data arrayi64data_message; + packedData.UnpackTo(&arrayi64data_message); + auto data_array = arrayi64data_message.value(); + auto array = const_cast(arrayi64data_message.value().data()); auto size = data_array.size(); auto status = library->WriteArrayI64(session, control, array, size); @@ -3245,9 +3245,9 @@ ::grpc::Status MonikerWriteArrayI8(void* data, google::protobuf::Arena& arena, g auto session = function_data->session; auto control = function_data->control; - ArrayI32Data arrayi32_data; - packedData.UnpackTo(&arrayi32_data); - auto data_array = arrayi32_data.value(); + ArrayI32Data arrayi32data_message; + packedData.UnpackTo(&arrayi32data_message); + auto data_array = arrayi32data_data.value(); auto array = std::vector(); auto size = data_array.size(); array.reserve(size); @@ -3378,9 +3378,9 @@ ::grpc::Status MonikerWriteArrayU16(void* data, google::protobuf::Arena& arena, auto session = function_data->session; auto control = function_data->control; - ArrayU32Data arrayu32_data; - packedData.UnpackTo(&arrayu32_data); - auto data_array = arrayu32_data.value(); + ArrayU32Data arrayu32data_message; + packedData.UnpackTo(&arrayu32data_message); + auto data_array = arrayu32data_data.value(); auto array = std::vector(); auto size = data_array.size(); array.reserve(size); @@ -3469,10 +3469,10 @@ ::grpc::Status MonikerWriteArrayU32(void* data, google::protobuf::Arena& arena, auto session = function_data->session; auto control = function_data->control; - ArrayU32Data arrayu32_data; - packedData.UnpackTo(&arrayu32_data); - auto data_array = arrayu32_data.value(); - auto array = const_cast(arrayu32_data.value().data()); + ArrayU32Data arrayu32data_message; + packedData.UnpackTo(&arrayu32data_message); + auto data_array = arrayu32data_message.value(); + auto array = const_cast(arrayu32data_message.value().data()); auto size = data_array.size(); auto status = library->WriteArrayU32(session, control, array, size); @@ -3548,10 +3548,10 @@ ::grpc::Status MonikerWriteArrayU64(void* data, google::protobuf::Arena& arena, auto session = function_data->session; auto control = function_data->control; - ArrayU64Data arrayu64_data; - packedData.UnpackTo(&arrayu64_data); - auto data_array = arrayu64_data.value(); - auto array = const_cast(arrayu64_data.value().data()); + ArrayU64Data arrayu64data_message; + packedData.UnpackTo(&arrayu64data_message); + auto data_array = arrayu64data_message.value(); + auto array = const_cast(arrayu64data_message.value().data()); auto size = data_array.size(); auto status = library->WriteArrayU64(session, control, array, size); @@ -3644,9 +3644,9 @@ ::grpc::Status MonikerWriteArrayU8(void* data, google::protobuf::Arena& arena, g auto session = function_data->session; auto control = function_data->control; - ArrayU32Data arrayu32_data; - packedData.UnpackTo(&arrayu32_data); - auto data_array = arrayu32_data.value(); + ArrayU32Data arrayu32data_message; + packedData.UnpackTo(&arrayu32data_message); + auto data_array = arrayu32data_data.value(); auto array = std::vector(); auto size = data_array.size(); array.reserve(size); @@ -4167,9 +4167,9 @@ ::grpc::Status MonikerWriteI16(void* data, google::protobuf::Arena& arena, googl auto session = function_data->session; auto control = function_data->control; - I32Data i32_data; - packedData.UnpackTo(&i32_data); - int32_t value = i32_data.value(); + I32Data i32data_message; + packedData.UnpackTo(&i32data_message); + int32_t value = i32data_message.value(); if (value < std::numeric_limits::min() || value > std::numeric_limits::max()) { std::string message("value " + std::to_string(value) + " doesn't fit in datatype int16_t"); throw nidevice_grpc::ValueOutOfRangeException(message); @@ -4247,9 +4247,9 @@ ::grpc::Status MonikerWriteI32(void* data, google::protobuf::Arena& arena, googl auto session = function_data->session; auto control = function_data->control; - I32Data i32_data; - packedData.UnpackTo(&i32_data); - int32_t value = i32_data.value(); + I32Data i32data_message; + packedData.UnpackTo(&i32data_message); + int32_t value = i32data_message.value(); auto status = library->WriteI32(session, control, value); if (status < 0) { @@ -4323,9 +4323,9 @@ ::grpc::Status MonikerWriteI64(void* data, google::protobuf::Arena& arena, googl auto session = function_data->session; auto control = function_data->control; - I64Data i64_data; - packedData.UnpackTo(&i64_data); - int64_t value = i64_data.value(); + I64Data i64data_message; + packedData.UnpackTo(&i64data_message); + int64_t value = i64data_message.value(); auto status = library->WriteI64(session, control, value); if (status < 0) { @@ -4408,9 +4408,9 @@ ::grpc::Status MonikerWriteI8(void* data, google::protobuf::Arena& arena, google auto session = function_data->session; auto control = function_data->control; - I32Data i32_data; - packedData.UnpackTo(&i32_data); - int32_t value = i32_data.value(); + I32Data i32data_message; + packedData.UnpackTo(&i32data_message); + int32_t value = i32data_message.value(); if (value < std::numeric_limits::min() || value > std::numeric_limits::max()) { std::string message("value " + std::to_string(value) + " doesn't fit in datatype int8_t"); throw nidevice_grpc::ValueOutOfRangeException(message); @@ -4521,9 +4521,9 @@ ::grpc::Status MonikerWriteU16(void* data, google::protobuf::Arena& arena, googl auto session = function_data->session; auto control = function_data->control; - U32Data u32_data; - packedData.UnpackTo(&u32_data); - uint32_t value = u32_data.value(); + U32Data u32data_message; + packedData.UnpackTo(&u32data_message); + uint32_t value = u32data_message.value(); if (value < std::numeric_limits::min() || value > std::numeric_limits::max()) { std::string message("value " + std::to_string(value) + " doesn't fit in datatype uint16_t"); throw nidevice_grpc::ValueOutOfRangeException(message); @@ -4601,9 +4601,9 @@ ::grpc::Status MonikerWriteU32(void* data, google::protobuf::Arena& arena, googl auto session = function_data->session; auto control = function_data->control; - U32Data u32_data; - packedData.UnpackTo(&u32_data); - uint32_t value = u32_data.value(); + U32Data u32data_message; + packedData.UnpackTo(&u32data_message); + uint32_t value = u32data_message.value(); auto status = library->WriteU32(session, control, value); if (status < 0) { @@ -4677,9 +4677,9 @@ ::grpc::Status MonikerWriteU64(void* data, google::protobuf::Arena& arena, googl auto session = function_data->session; auto control = function_data->control; - U64Data u64_data; - packedData.UnpackTo(&u64_data); - uint64_t value = u64_data.value(); + U64Data u64data_message; + packedData.UnpackTo(&u64data_message); + uint64_t value = u64data_message.value(); auto status = library->WriteU64(session, control, value); if (status < 0) { @@ -4762,9 +4762,9 @@ ::grpc::Status MonikerWriteU8(void* data, google::protobuf::Arena& arena, google auto session = function_data->session; auto control = function_data->control; - U32Data u32_data; - packedData.UnpackTo(&u32_data); - uint32_t value = u32_data.value(); + U32Data u32data_message; + packedData.UnpackTo(&u32data_message); + uint32_t value = u32data_message.value(); if (value < std::numeric_limits::min() || value > std::numeric_limits::max()) { std::string message("value " + std::to_string(value) + " doesn't fit in datatype uint8_t"); throw nidevice_grpc::ValueOutOfRangeException(message); diff --git a/source/codegen/metadata/nifpga/functions.py b/source/codegen/metadata/nifpga/functions.py index a9e98a0af..1e9da83b1 100644 --- a/source/codegen/metadata/nifpga/functions.py +++ b/source/codegen/metadata/nifpga/functions.py @@ -1729,6 +1729,7 @@ }, { 'direction': 'out', + 'grpc_streaming_type': 'ArrayI32Data', 'is_streaming_type': True, 'name': 'array', 'size': { @@ -1760,6 +1761,7 @@ }, { 'direction': 'out', + 'grpc_streaming_type': 'ArrayI32Data', 'is_streaming_type': True, 'name': 'array', 'size': { @@ -1791,6 +1793,7 @@ }, { 'direction': 'out', + 'grpc_streaming_type': 'ArrayI64Data', 'is_streaming_type': True, 'name': 'array', 'size': { @@ -1822,6 +1825,7 @@ }, { 'direction': 'out', + 'grpc_streaming_type': 'ArrayI32Data', 'is_streaming_type': True, 'name': 'array', 'size': { @@ -1882,6 +1886,7 @@ }, { 'direction': 'out', + 'grpc_streaming_type': 'ArrayU32Data', 'is_streaming_type': True, 'name': 'array', 'size': { @@ -1913,6 +1918,7 @@ }, { 'direction': 'out', + 'grpc_streaming_type': 'ArrayU32Data', 'is_streaming_type': True, 'name': 'array', 'size': { @@ -1944,6 +1950,7 @@ }, { 'direction': 'out', + 'grpc_streaming_type': 'ArrayU64Data', 'is_streaming_type': True, 'name': 'array', 'size': { @@ -1975,6 +1982,7 @@ }, { 'direction': 'out', + 'grpc_streaming_type': 'ArrayU32Data', 'is_streaming_type': True, 'name': 'array', 'size': { @@ -2546,6 +2554,7 @@ }, { 'direction': 'out', + 'grpc_streaming_type': 'I32Data', 'is_streaming_type': True, 'name': 'value', 'type': 'int16_t' @@ -2568,6 +2577,7 @@ }, { 'direction': 'out', + 'grpc_streaming_type': 'I32Data', 'is_streaming_type': True, 'name': 'value', 'type': 'int32_t' @@ -2590,6 +2600,7 @@ }, { 'direction': 'out', + 'grpc_streaming_type': 'I64Data', 'is_streaming_type': True, 'name': 'value', 'type': 'int64_t' @@ -2612,6 +2623,7 @@ }, { 'direction': 'out', + 'grpc_streaming_type': 'I32Data', 'is_streaming_type': True, 'name': 'value', 'type': 'int8_t' @@ -2654,6 +2666,7 @@ }, { 'direction': 'out', + 'grpc_streaming_type': 'U32Data', 'is_streaming_type': True, 'name': 'value', 'type': 'uint16_t' @@ -2676,6 +2689,7 @@ }, { 'direction': 'out', + 'grpc_streaming_type': 'U32Data', 'is_streaming_type': True, 'name': 'value', 'type': 'uint32_t' @@ -2698,6 +2712,7 @@ }, { 'direction': 'out', + 'grpc_streaming_type': 'U64Data', 'is_streaming_type': True, 'name': 'value', 'type': 'uint64_t' @@ -2720,6 +2735,7 @@ }, { 'direction': 'out', + 'grpc_streaming_type': 'U32Data', 'is_streaming_type': True, 'name': 'value', 'type': 'uint8_t' @@ -3128,6 +3144,7 @@ }, { 'direction': 'in', + 'grpc_streaming_type': 'ArrayI32Data', 'is_streaming_type': True, 'name': 'array', 'size': { @@ -3159,6 +3176,7 @@ }, { 'direction': 'in', + 'grpc_streaming_type': 'ArrayI32Data', 'is_streaming_type': True, 'name': 'array', 'size': { @@ -3190,6 +3208,7 @@ }, { 'direction': 'in', + 'grpc_streaming_type': 'ArrayI64Data', 'is_streaming_type': True, 'name': 'array', 'size': { @@ -3221,6 +3240,7 @@ }, { 'direction': 'in', + 'grpc_streaming_type': 'ArrayI32Data', 'is_streaming_type': True, 'name': 'array', 'size': { @@ -3281,6 +3301,7 @@ }, { 'direction': 'in', + 'grpc_streaming_type': 'ArrayU32Data', 'is_streaming_type': True, 'name': 'array', 'size': { @@ -3312,6 +3333,7 @@ }, { 'direction': 'in', + 'grpc_streaming_type': 'ArrayU32Data', 'is_streaming_type': True, 'name': 'array', 'size': { @@ -3343,6 +3365,7 @@ }, { 'direction': 'in', + 'grpc_streaming_type': 'ArrayU64Data', 'is_streaming_type': True, 'name': 'array', 'size': { @@ -3374,6 +3397,7 @@ }, { 'direction': 'in', + 'grpc_streaming_type': 'ArrayU32Data', 'is_streaming_type': True, 'name': 'array', 'size': { @@ -3941,6 +3965,7 @@ }, { 'direction': 'in', + 'grpc_streaming_type': 'I32Data', 'is_streaming_type': True, 'name': 'value', 'type': 'int16_t' @@ -3963,6 +3988,7 @@ }, { 'direction': 'in', + 'grpc_streaming_type': 'I32Data', 'is_streaming_type': True, 'name': 'value', 'type': 'int32_t' @@ -3985,6 +4011,7 @@ }, { 'direction': 'in', + 'grpc_streaming_type': 'I64Data', 'is_streaming_type': True, 'name': 'value', 'type': 'int64_t' @@ -4007,6 +4034,7 @@ }, { 'direction': 'in', + 'grpc_streaming_type': 'I32Data', 'is_streaming_type': True, 'name': 'value', 'type': 'int8_t' @@ -4049,6 +4077,7 @@ }, { 'direction': 'in', + 'grpc_streaming_type': 'U32Data', 'is_streaming_type': True, 'name': 'value', 'type': 'uint16_t' @@ -4071,6 +4100,7 @@ }, { 'direction': 'in', + 'grpc_streaming_type': 'U32Data', 'is_streaming_type': True, 'name': 'value', 'type': 'uint32_t' @@ -4093,6 +4123,7 @@ }, { 'direction': 'in', + 'grpc_streaming_type': 'U64Data', 'is_streaming_type': True, 'name': 'value', 'type': 'uint64_t' @@ -4115,6 +4146,7 @@ }, { 'direction': 'in', + 'grpc_streaming_type': 'U32Data', 'is_streaming_type': True, 'name': 'value', 'type': 'uint8_t' @@ -4122,4 +4154,4 @@ ], 'returns': 'NiFpga_Status' } -} \ No newline at end of file +} diff --git a/source/codegen/metadata_validation.py b/source/codegen/metadata_validation.py index 6c1a36697..fb02419de 100644 --- a/source/codegen/metadata_validation.py +++ b/source/codegen/metadata_validation.py @@ -125,6 +125,7 @@ class RULES: Optional("is_grpc_enum"): bool, Optional("return_on_error_key"): str, Optional("is_streaming_type"): bool, + Optional("grpc_streaming_type"): str, } ) diff --git a/source/codegen/service_helpers.py b/source/codegen/service_helpers.py index 71c45e1b8..039593087 100644 --- a/source/codegen/service_helpers.py +++ b/source/codegen/service_helpers.py @@ -740,39 +740,6 @@ def get_coerced_type_and_presence(streaming_type: str) -> tuple: return coerced_type, is_coerced_type_present -def get_grpc_streaming_type(coerced_type: str) -> str: - """ - Get the gRPC streaming type for the given coerced type. - - Args: - coerced_type (str): The coerced type. - - Returns: - str: The gRPC streaming type. - """ - grpc_map = { - 'int8_t': 'I32', - 'uint8_t': 'U32', - 'int16_t': 'I32', - 'uint16_t': 'U32', - 'uint32_t': 'U32', - 'int32_t': 'I32', - 'uint64_t': 'U64', - 'int64_t': 'I64', - "int16_t[]" : 'ArrayI32', - "int8_t[]" : 'ArrayI32', - "int32_t[]" : 'ArrayI32', - "int64_t[]" : 'ArrayI64', - "uint16_t[]" : 'ArrayU32', - "uint8_t[]" : 'ArrayU32', - "uint32_t[]" : 'ArrayU32', - "uint64_t[]" : 'ArrayU64', - } - - grpc_streaming_type = grpc_map.get(coerced_type, 'U32') - - return grpc_streaming_type - def get_streaming_type(parameters) -> str: """ Get the streaming type from the function data. diff --git a/source/codegen/templates/service_helpers.mako b/source/codegen/templates/service_helpers.mako index 06340cba3..cf4a4c0bd 100644 --- a/source/codegen/templates/service_helpers.mako +++ b/source/codegen/templates/service_helpers.mako @@ -290,7 +290,7 @@ ${populate_response(function_data=function_data, parameters=parameters)}\ streaming_param = common_helpers.get_streaming_parameter(parameters) streaming_type = streaming_param['type'] coerced_type, is_coerced_type_present = service_helpers.get_coerced_type_and_presence(streaming_type) - grpc_streaming_type = service_helpers.get_grpc_streaming_type(streaming_type) + grpc_streaming_type = streaming_param['grpc_streaming_type'] is_array = common_helpers.is_array(streaming_type) %>\ struct ${struct_name} @@ -300,7 +300,7 @@ struct ${struct_name} ${param['type']} ${param['name']}; % endif % endfor - ${service_class_prefix.lower()}_grpc::${grpc_streaming_type}Data data; + ${service_class_prefix.lower()}_grpc::${grpc_streaming_type} data; std::shared_ptr<${service_class_prefix}LibraryInterface> library; }; @@ -391,8 +391,8 @@ ${initialize_streaming_input_param(function_name, input_params, parameters, stre <%def name="handle_in_direction(c_api_name, arg_string, data_type, grpc_streaming_type, streaming_type, coerced_type, is_coerced_type_present, is_array)"> - ${grpc_streaming_type}Data ${grpc_streaming_type.lower()}_data; - packedData.UnpackTo(&${grpc_streaming_type.lower()}_data); + ${grpc_streaming_type} ${grpc_streaming_type.lower()}_message; + packedData.UnpackTo(&${grpc_streaming_type.lower()}_message); % if is_array: % if is_coerced_type_present: auto data_array = ${grpc_streaming_type.lower()}_data.value(); @@ -411,12 +411,12 @@ ${initialize_streaming_input_param(function_name, input_params, parameters, stre return static_cast<${data_type}>(x); }); % else: - auto data_array = ${grpc_streaming_type.lower()}_data.value(); - auto array = const_cast<${data_type}*>(${grpc_streaming_type.lower()}_data.value().data()); + auto data_array = ${grpc_streaming_type.lower()}_message.value(); + auto array = const_cast<${data_type}*>(${grpc_streaming_type.lower()}_message.value().data()); auto size = data_array.size(); % endif % else: - ${coerced_type} value = ${grpc_streaming_type.lower()}_data.value(); + ${coerced_type} value = ${grpc_streaming_type.lower()}_message.value(); % if is_coerced_type_present: if (value < std::numeric_limits<${streaming_type}>::min() || value > std::numeric_limits<${streaming_type}>::max()) { std::string message("value " + std::to_string(value) + " doesn't fit in datatype ${streaming_type}"); From 8de6fc99ed7354116e9ab1438c810999c73a5759 Mon Sep 17 00:00:00 2001 From: sagrahar Date: Tue, 29 Oct 2024 16:09:48 +0530 Subject: [PATCH 06/34] adding sideband_address to the server_config.json --- source/config/localhost_config.json | 1 + source/server/core_server.cpp | 6 +++--- source/server/server_configuration_parser.cpp | 6 +++--- source/server/server_configuration_parser.h | 2 +- 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/source/config/localhost_config.json b/source/config/localhost_config.json index 977488aa1..de72d5de6 100644 --- a/source/config/localhost_config.json +++ b/source/config/localhost_config.json @@ -1,6 +1,7 @@ { "address": "[::1]", "port": 31763, + "sideband_address": "[::1]", "security" : { "server_cert": "", "server_key": "", diff --git a/source/server/core_server.cpp b/source/server/core_server.cpp index f56cfd571..b44149871 100644 --- a/source/server/core_server.cpp +++ b/source/server/core_server.cpp @@ -26,7 +26,7 @@ using FeatureState = nidevice_grpc::FeatureToggles::FeatureState; struct ServerConfiguration { std::string config_file_path; std::string server_address; - std::string sideband_ip; + std::string sideband_address; std::string server_cert; std::string server_key; std::string root_cert; @@ -44,7 +44,7 @@ static ServerConfiguration GetConfiguration(const std::string& config_file_path) config.config_file_path = server_config_parser.get_config_file_path(); config.server_address = server_config_parser.parse_address(); - config.sideband_ip = server_config_parser.parse_sideband_ip(); + config.sideband_address = server_config_parser.parse_sideband_address(); config.server_cert = server_config_parser.parse_server_cert(); config.server_key = server_config_parser.parse_server_key(); config.root_cert = server_config_parser.parse_root_cert(); @@ -107,7 +107,7 @@ static void RunServer(const ServerConfiguration& config) server = builder.BuildAndStart(); } - auto sideband_socket_thread = new std::thread(RunSidebandSocketsAccept, config.sideband_ip.c_str(), 50055); + auto sideband_socket_thread = new std::thread(RunSidebandSocketsAccept, config.sideband_address.c_str(), 50055); // auto sideband_rdma_send_thread = new std::thread(AcceptSidebandRdmaSendRequests); // auto sideband_rdma_recv_thread = new std::thread(AcceptSidebandRdmaReceiveRequests); diff --git a/source/server/server_configuration_parser.cpp b/source/server/server_configuration_parser.cpp index a6c42c42f..5ac64b6a5 100644 --- a/source/server/server_configuration_parser.cpp +++ b/source/server/server_configuration_parser.cpp @@ -17,7 +17,7 @@ namespace nidevice_grpc { static const char* kDefaultFilename = "server_config.json"; static const char* kAddressJsonKey = "address"; static const char* kPortJsonKey = "port"; -static const char* kSidebandIpJsonKey = "sideband_ip"; +static const char* kSidebandAddressJsonKey = "sideband_address"; static const char* kServerCertJsonKey = "server_cert"; static const char* kServerKeyJsonKey = "server_key"; static const char* kRootCertJsonKey = "root_cert"; @@ -102,9 +102,9 @@ std::string ServerConfigurationParser::parse_address() const return address; } -std::string ServerConfigurationParser::parse_sideband_ip() const +std::string ServerConfigurationParser::parse_sideband_address() const { - auto it = config_file_.find(kSidebandIpJsonKey); + auto it = config_file_.find(kSidebandAddressJsonKey); return it != config_file_.end() ? it->get() : ""; } diff --git a/source/server/server_configuration_parser.h b/source/server/server_configuration_parser.h index f75625b66..72396e857 100644 --- a/source/server/server_configuration_parser.h +++ b/source/server/server_configuration_parser.h @@ -36,7 +36,7 @@ class ServerConfigurationParser { const std::string& get_config_file_path() const { return config_file_path_; } std::string parse_address() const; - std::string parse_sideband_ip() const; + std::string parse_sideband_address() const; std::string parse_server_cert() const; std::string parse_server_key() const; std::string parse_root_cert() const; From 165405f77cbbf58e33579f147e2e39b570b232aa Mon Sep 17 00:00:00 2001 From: sagrahar Date: Wed, 30 Oct 2024 04:11:08 +0530 Subject: [PATCH 07/34] adding the sideband_streaming functionality under a feature toggle --- source/server/core_server.cpp | 13 ++++++++----- source/server/core_services_registrar.cpp | 9 ++++++--- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/source/server/core_server.cpp b/source/server/core_server.cpp index b44149871..f1a9e580e 100644 --- a/source/server/core_server.cpp +++ b/source/server/core_server.cpp @@ -22,6 +22,7 @@ #include "version.h" using FeatureState = nidevice_grpc::FeatureToggles::FeatureState; +using FeatureToggles = nidevice_grpc::FeatureToggles; struct ServerConfiguration { std::string config_file_path; @@ -107,9 +108,12 @@ static void RunServer(const ServerConfiguration& config) server = builder.BuildAndStart(); } - auto sideband_socket_thread = new std::thread(RunSidebandSocketsAccept, config.sideband_address.c_str(), 50055); - // auto sideband_rdma_send_thread = new std::thread(AcceptSidebandRdmaSendRequests); - // auto sideband_rdma_recv_thread = new std::thread(AcceptSidebandRdmaReceiveRequests); + if (config.feature_toggles.is_feature_enabled("sideband_streaming", FeatureToggles::CodeReadiness::kNextRelease)) + { + auto sideband_socket_thread = new std::thread(RunSidebandSocketsAccept, config.sideband_address.c_str(), 50055); + // auto sideband_rdma_send_thread = new std::thread(AcceptSidebandRdmaSendRequests); + // auto sideband_rdma_recv_thread = new std::thread(AcceptSidebandRdmaReceiveRequests); + } if (!server) { nidevice_grpc::logging::log( @@ -254,8 +258,7 @@ int main(int argc, char** argv) #endif #if defined(_WIN32) nidevice_grpc::set_console_ctrl_handler(&StopServer); -#endif -#ifndef _WIN32 +#else SysFsWrite("/dev/cgroup/cpuset/system_set/cpus", "0-5"); SysFsWrite("/dev/cgroup/cpuset/LabVIEW_ScanEngine_set", "0-5"); SysFsWrite("/dev/cgroup/cpuset/LabVIEW_tl_set/cpus", "6-8"); diff --git a/source/server/core_services_registrar.cpp b/source/server/core_services_registrar.cpp index bfcefc4ba..8d57d7fb9 100644 --- a/source/server/core_services_registrar.cpp +++ b/source/server/core_services_registrar.cpp @@ -27,8 +27,11 @@ void register_core_services( feature_toggles, *server_reset_observer_registrar)); - auto moniker_service = std::make_shared(); - server_builder.RegisterService(moniker_service.get()); - service_vector->push_back(moniker_service); + if (feature_toggles.is_feature_enabled("sideband_streaming", FeatureToggles::CodeReadiness::kNextRelease)) + { + auto moniker_service = std::make_shared(); + server_builder.RegisterService(moniker_service.get()); + service_vector->push_back(moniker_service); + } } } // namespace nidevice_grpc From 4bf578519fd6d8ad6d96c615de26e0ee9de07cc4 Mon Sep 17 00:00:00 2001 From: Ayush Mehra Date: Tue, 29 Oct 2024 23:34:26 -0700 Subject: [PATCH 08/34] Fix some format changes --- generated/nifpga/nifpga_service.cpp | 8 ++-- generated/register_all_services.cpp | 8 +++- source/codegen/common_helpers.py | 11 +++-- source/codegen/metadata_mutation.py | 35 ++++++++------- source/codegen/service_helpers.py | 45 +++++++++++-------- source/codegen/templates/service_helpers.mako | 2 +- 6 files changed, 64 insertions(+), 45 deletions(-) diff --git a/generated/nifpga/nifpga_service.cpp b/generated/nifpga/nifpga_service.cpp index d571a3c2e..b5de426cc 100644 --- a/generated/nifpga/nifpga_service.cpp +++ b/generated/nifpga/nifpga_service.cpp @@ -2981,7 +2981,7 @@ ::grpc::Status MonikerWriteArrayI16(void* data, google::protobuf::Arena& arena, ArrayI32Data arrayi32data_message; packedData.UnpackTo(&arrayi32data_message); - auto data_array = arrayi32data_data.value(); + auto data_array = arrayi32data_message.value(); auto array = std::vector(); auto size = data_array.size(); array.reserve(size); @@ -3247,7 +3247,7 @@ ::grpc::Status MonikerWriteArrayI8(void* data, google::protobuf::Arena& arena, g ArrayI32Data arrayi32data_message; packedData.UnpackTo(&arrayi32data_message); - auto data_array = arrayi32data_data.value(); + auto data_array = arrayi32data_message.value(); auto array = std::vector(); auto size = data_array.size(); array.reserve(size); @@ -3380,7 +3380,7 @@ ::grpc::Status MonikerWriteArrayU16(void* data, google::protobuf::Arena& arena, ArrayU32Data arrayu32data_message; packedData.UnpackTo(&arrayu32data_message); - auto data_array = arrayu32data_data.value(); + auto data_array = arrayu32data_message.value(); auto array = std::vector(); auto size = data_array.size(); array.reserve(size); @@ -3646,7 +3646,7 @@ ::grpc::Status MonikerWriteArrayU8(void* data, google::protobuf::Arena& arena, g ArrayU32Data arrayu32data_message; packedData.UnpackTo(&arrayu32data_message); - auto data_array = arrayu32data_data.value(); + auto data_array = arrayu32data_message.value(); auto array = std::vector(); auto size = data_array.size(); array.reserve(size); diff --git a/generated/register_all_services.cpp b/generated/register_all_services.cpp index 27609f129..ed31208ed 100644 --- a/generated/register_all_services.cpp +++ b/generated/register_all_services.cpp @@ -10,6 +10,7 @@ #include #include +#include #include "nidaqmx/nidaqmx_service_registrar.h" #include "nidcpower/nidcpower_service_registrar.h" @@ -17,6 +18,7 @@ #include "nidmm/nidmm_service_registrar.h" #include "nifgen/nifgen_service_registrar.h" #include "nifpga/nifpga_service_registrar.h" +#include "nifpga/nifpga_service.h" #if defined(_MSC_VER) #include "nimxlcterminaladaptor_restricted/nimxlcterminaladaptor_restricted_service_registrar.h" #endif // defined(_MSC_VER) @@ -91,6 +93,9 @@ std::shared_ptr>> register_all_services( auto session_repository = std::make_shared(); service_vector->push_back(session_repository); nidevice_grpc::register_core_services(service_vector, server_builder, session_repository, feature_toggles); + auto moniker_service = std::make_shared(); + server_builder.RegisterService(moniker_service.get()); + service_vector->push_back(moniker_service); auto task_handle_repository = std::make_shared>(session_repository); auto vi_session_repository = std::make_shared>(session_repository); @@ -326,8 +331,9 @@ std::shared_ptr>> register_all_services( vi_session_repository, vi_object_repository, feature_toggles)); + nifpga_grpc::RegisterMonikers(); return service_vector; } -} // nidevice_grpc +} // nidevice_grpc \ No newline at end of file diff --git a/source/codegen/common_helpers.py b/source/codegen/common_helpers.py index 2c02c2418..75ce43f2d 100644 --- a/source/codegen/common_helpers.py +++ b/source/codegen/common_helpers.py @@ -32,9 +32,10 @@ def is_input_parameter(parameter): """Whether the parameter is an input parameter.""" return "in" in parameter["direction"] -def get_streaming_parameter(parameters: List[dict]) -> dict: + +def get_streaming_parameter(parameters: List[Dict]) -> Optional[Dict]: for param in parameters: - if param.get("is_streaming_type", False) == True: + if param.get("is_streaming_type", False): return param return None @@ -1205,9 +1206,7 @@ def get_params_needing_initialization(parameters: List[dict]) -> List[dict]: def filter_data_moniker_functions(functions): """Return function metadata only for functions that use the data moniker service.""" return [ - name - for name, function in functions.items() - if function.get("data_moniker_support", False) + name for name, function in functions.items() if function.get("data_moniker_support", False) ] @@ -1215,4 +1214,4 @@ def get_data_moniker_function_name(function_name, function_data): """Return the corresponding moniker function name for the given C API function.""" if function_data.get("moniker_cname", None): return function_data["moniker_cname"] - return function_name.replace("Begin", "Moniker") \ No newline at end of file + return function_name.replace("Begin", "Moniker") diff --git a/source/codegen/metadata_mutation.py b/source/codegen/metadata_mutation.py index 622df474c..d163f5587 100644 --- a/source/codegen/metadata_mutation.py +++ b/source/codegen/metadata_mutation.py @@ -4,6 +4,7 @@ from typing import Any, Dict, Optional import common_helpers + import copy RESERVED_WORDS = [ @@ -124,7 +125,7 @@ def mutate(metadata: dict): for function_name, function in metadata["functions"].items(): all_functions[function_name] = function - if function.get('moniker_supports_streaming') is True: + if function.get("moniker_supports_streaming") is True: new_function_name = f"Begin{function_name}" all_functions[new_function_name] = generate_streaming_metadata(function) @@ -150,35 +151,39 @@ def mutate(metadata: dict): attribute_expander.expand_attribute_value_params(function) attribute_expander.patch_attribute_enum_type(function_name, function) + def generate_streaming_metadata(function: dict) -> dict: """Generate the streaming API metadata for a given function.""" streaming_parameters = [] - for param in function['parameters']: + for param in function["parameters"]: new_param = copy.deepcopy(param) - if new_param.get('is_streaming_type', False) is True: - new_param['include_in_proto'] = False + if new_param.get("is_streaming_type", False) is True: + new_param["include_in_proto"] = False streaming_parameters.append(new_param) # Add the additional out parameter at the end - streaming_parameters.append({ - 'direction': 'out', - 'grpc_type': 'ni.data_monikers.Moniker', - 'name': 'moniker', - 'type': 'ni::data_monikers::Moniker' - }) + streaming_parameters.append( + { + "direction": "out", + "grpc_type": "ni.data_monikers.Moniker", + "name": "moniker", + "type": "ni::data_monikers::Moniker", + } + ) # Construct the streaming API metadata streaming_metadata = { - 'data_moniker_support': True, - 'exclude_from_library': True, - 'parameters': streaming_parameters, - 'returns': function['returns'] + "data_moniker_support": True, + "exclude_from_library": True, + "parameters": streaming_parameters, + "returns": function["returns"], } return streaming_metadata + def sanitize_names(parameters): """Sanitize name fields on a list of parameter objects. @@ -517,4 +522,4 @@ def add_get_last_error_params_if_needed(function_data: Dict[str, Any], config: d "name": get_last_error_field["name"], "type": get_last_error_field["type"], } - ) \ No newline at end of file + ) diff --git a/source/codegen/service_helpers.py b/source/codegen/service_helpers.py index 039593087..a30b07297 100644 --- a/source/codegen/service_helpers.py +++ b/source/codegen/service_helpers.py @@ -318,7 +318,9 @@ def filter_api_functions(functions, only_mockable_functions=True): """Filter function metadata to only include those to be generated into the API library.""" def filter_function(function): - if function.get("codegen_method", "") == "no" or function.get("exclude_from_library", False): + if function.get("codegen_method", "") == "no" or function.get( + "exclude_from_library", False + ): return False if only_mockable_functions and not common_helpers.can_mock_function(function["parameters"]): return False @@ -718,22 +720,22 @@ def get_coerced_type_and_presence(streaming_type: str) -> tuple: """ Get the coerced type and check if the coerced type is present in the type map. This handles both scalar types and array types like int8_t[] or uint16_t[]. - + Args: streaming_type (str): The streaming type (scalar or array). - + Returns: tuple: A tuple containing coerced_type (str) and is_coerced_type_present (bool). """ type_map = { - 'int8_t': 'int32_t', - 'uint8_t': 'uint32_t', - 'int16_t': 'int32_t', - 'uint16_t': 'uint32_t', + "int8_t": "int32_t", + "uint8_t": "uint32_t", + "int16_t": "int32_t", + "uint16_t": "uint32_t", } - base_type = streaming_type.replace('[]', '') - + base_type = streaming_type.replace("[]", "") + coerced_type = type_map.get(base_type, base_type) is_coerced_type_present = base_type in type_map @@ -751,14 +753,19 @@ def get_streaming_type(parameters) -> str: str: The streaming type if found, otherwise 'None'. """ for param in parameters: - if param.get('is_streaming_type', False) == True: - return param['type'] + if param.get("is_streaming_type", False) == True: + return param["type"] return None + def include_param(param, streaming_param): - if not param.get('is_streaming_type', False): - if streaming_param and streaming_param['direction'] == 'in' and common_helpers.is_array(streaming_param['type']): - if param['name'] != streaming_param['size']['value']: + if not param.get("is_streaming_type", False): + if ( + streaming_param + and streaming_param["direction"] == "in" + and common_helpers.is_array(streaming_param["type"]) + ): + if param["name"] != streaming_param["size"]["value"]: return True else: return False @@ -767,14 +774,16 @@ def include_param(param, streaming_param): else: return False + def get_size_param_name(streaming_param) -> str: - if common_helpers.is_array(streaming_param['type']): - return streaming_param['size']['value'] + if common_helpers.is_array(streaming_param["type"]): + return streaming_param["size"]["value"] else: return None + def get_c_api_name(function_name) -> str: if function_name.startswith("Begin"): - base_name = function_name[len("Begin"):] + base_name = function_name[len("Begin") :] return f"{base_name}" - return f"{function_name}" \ No newline at end of file + return f"{function_name}" diff --git a/source/codegen/templates/service_helpers.mako b/source/codegen/templates/service_helpers.mako index cf4a4c0bd..88c0a4318 100644 --- a/source/codegen/templates/service_helpers.mako +++ b/source/codegen/templates/service_helpers.mako @@ -395,7 +395,7 @@ ${initialize_streaming_input_param(function_name, input_params, parameters, stre packedData.UnpackTo(&${grpc_streaming_type.lower()}_message); % if is_array: % if is_coerced_type_present: - auto data_array = ${grpc_streaming_type.lower()}_data.value(); + auto data_array = ${grpc_streaming_type.lower()}_message.value(); auto array = std::vector<${data_type}>(); auto size = data_array.size(); array.reserve(size); From b7d8f156df40aaeb973f593c9d9846ab962cf835 Mon Sep 17 00:00:00 2001 From: sagrahar Date: Fri, 1 Nov 2024 11:36:45 +0530 Subject: [PATCH 09/34] adding RT specific scheduling under feature toggle --- source/server/core_server.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/source/server/core_server.cpp b/source/server/core_server.cpp index f1a9e580e..680dd010c 100644 --- a/source/server/core_server.cpp +++ b/source/server/core_server.cpp @@ -259,6 +259,8 @@ int main(int argc, char** argv) #if defined(_WIN32) nidevice_grpc::set_console_ctrl_handler(&StopServer); #else + if (config.feature_toggles.is_feature_enabled("sideband_streaming", FeatureToggles::CodeReadiness::kNextRelease)) + { SysFsWrite("/dev/cgroup/cpuset/system_set/cpus", "0-5"); SysFsWrite("/dev/cgroup/cpuset/LabVIEW_ScanEngine_set", "0-5"); SysFsWrite("/dev/cgroup/cpuset/LabVIEW_tl_set/cpus", "6-8"); @@ -274,6 +276,7 @@ int main(int argc, char** argv) sched_setaffinity(0, sizeof(cpu_set_t), &cpuSet); mlockall(MCL_CURRENT|MCL_FUTURE); + } #endif RunServer(config); From 3dc83c8d2451101342612354d32df9b06b4217ad Mon Sep 17 00:00:00 2001 From: Ayush Mehra Date: Sun, 3 Nov 2024 19:53:52 -0800 Subject: [PATCH 10/34] Fixing some build issues --- source/codegen/common_helpers.py | 1 + source/codegen/metadata_mutation.py | 4 +--- source/codegen/metadata_validation.py | 3 ++- source/codegen/service_helpers.py | 25 +++++++------------------ 4 files changed, 11 insertions(+), 22 deletions(-) diff --git a/source/codegen/common_helpers.py b/source/codegen/common_helpers.py index 75ce43f2d..c808a7737 100644 --- a/source/codegen/common_helpers.py +++ b/source/codegen/common_helpers.py @@ -34,6 +34,7 @@ def is_input_parameter(parameter): def get_streaming_parameter(parameters: List[Dict]) -> Optional[Dict]: + """Get the streaming parameter from the list of parameters.""" for param in parameters: if param.get("is_streaming_type", False): return param diff --git a/source/codegen/metadata_mutation.py b/source/codegen/metadata_mutation.py index d163f5587..d57b22fc8 100644 --- a/source/codegen/metadata_mutation.py +++ b/source/codegen/metadata_mutation.py @@ -2,11 +2,10 @@ from collections import namedtuple from typing import Any, Dict, Optional +import copy import common_helpers -import copy - RESERVED_WORDS = [ "abstract", "as", @@ -154,7 +153,6 @@ def mutate(metadata: dict): def generate_streaming_metadata(function: dict) -> dict: """Generate the streaming API metadata for a given function.""" - streaming_parameters = [] for param in function["parameters"]: diff --git a/source/codegen/metadata_validation.py b/source/codegen/metadata_validation.py index fb02419de..4306ade0e 100644 --- a/source/codegen/metadata_validation.py +++ b/source/codegen/metadata_validation.py @@ -1,4 +1,5 @@ """Metadata validation.""" + from typing import Any, Dict, List, Set import common_helpers @@ -513,4 +514,4 @@ def _is_string_type(parameter: dict, metadata: dict) -> bool: grpc_type = parameter.get("grpc_type", None) if grpc_type is None: grpc_type = common_helpers.get_grpc_type(parameter["type"], metadata["config"]) - return grpc_type == "string" \ No newline at end of file + return grpc_type == "string" diff --git a/source/codegen/service_helpers.py b/source/codegen/service_helpers.py index a30b07297..17ee46270 100644 --- a/source/codegen/service_helpers.py +++ b/source/codegen/service_helpers.py @@ -717,15 +717,9 @@ def create_moniker_function_name(function_name: str) -> str: def get_coerced_type_and_presence(streaming_type: str) -> tuple: - """ - Get the coerced type and check if the coerced type is present in the type map. - This handles both scalar types and array types like int8_t[] or uint16_t[]. + """Get the coerced type and check if the coerced type is present in the type map. - Args: - streaming_type (str): The streaming type (scalar or array). - - Returns: - tuple: A tuple containing coerced_type (str) and is_coerced_type_present (bool). + This handles both scalar types and array types like int8_t[] or uint16_t[]. """ type_map = { "int8_t": "int32_t", @@ -743,22 +737,15 @@ def get_coerced_type_and_presence(streaming_type: str) -> tuple: def get_streaming_type(parameters) -> str: - """ - Get the streaming type from the function data. - - Args: - function_name (dict): The function data dictionary. - - Returns: - str: The streaming type if found, otherwise 'None'. - """ + """Get the streaming type from the function data.""" for param in parameters: - if param.get("is_streaming_type", False) == True: + if param.get("is_streaming_type", False): return param["type"] return None def include_param(param, streaming_param): + """Determine if a parameter should be included based on streaming conditions.""" if not param.get("is_streaming_type", False): if ( streaming_param @@ -776,6 +763,7 @@ def include_param(param, streaming_param): def get_size_param_name(streaming_param) -> str: + """Get the size parameter name for the given streaming parameter.""" if common_helpers.is_array(streaming_param["type"]): return streaming_param["size"]["value"] else: @@ -783,6 +771,7 @@ def get_size_param_name(streaming_param) -> str: def get_c_api_name(function_name) -> str: + """Get the C API name for the given function name.""" if function_name.startswith("Begin"): base_name = function_name[len("Begin") :] return f"{base_name}" From 329ca43aabcfa37f773266a43470b384ffc6e0a4 Mon Sep 17 00:00:00 2001 From: Ayush Mehra Date: Sun, 3 Nov 2024 19:56:47 -0800 Subject: [PATCH 11/34] include copy at top --- source/codegen/metadata_mutation.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/codegen/metadata_mutation.py b/source/codegen/metadata_mutation.py index d57b22fc8..4092ef61c 100644 --- a/source/codegen/metadata_mutation.py +++ b/source/codegen/metadata_mutation.py @@ -1,8 +1,8 @@ """Metadata mutation.""" +import copy from collections import namedtuple from typing import Any, Dict, Optional -import copy import common_helpers From 25ce023f280060fdaa2c40ac2f869bbbd92ebc86 Mon Sep 17 00:00:00 2001 From: Ayush Mehra Date: Mon, 4 Nov 2024 01:34:49 -0800 Subject: [PATCH 12/34] resolve minor comments --- CMakeLists.txt | 47 +- .../protobuf/data_moniker.proto | 0 source/server/core_server.cpp | 37 +- source/server/data_moniker_service.cpp | 453 ++++++++---------- 4 files changed, 250 insertions(+), 287 deletions(-) rename {source => imports}/protobuf/data_moniker.proto (100%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 18eafb45d..7186c089b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -31,13 +31,12 @@ endif() option(USE_NILRT_LEGACY_TOOLCHAIN "Enable to use tools and libraries from a NILRT compile toolchain." OFF) option(USE_PYTHON_VIRTUALENV "Enable to use the automatically-generated python venv, local to this project source." ON) option(USE_SUBMODULE_LIBS "Enable to link against the submodule libraries, rather than their native-OS equivalents." ON) -option(INCLUDE_SIDEBAND_RDMA "Include support for RDMA sideband transfers" OFF) -option(SIDEBAND_STATIC "Build static library, disabled by default" ON) +option(INCLUDE_SIDEBAND_RDMA "Include support for RDMA sideband transfers." OFF) +option(SIDEBAND_STATIC "Link grpc-sideband statically to current application." ON) #---------------------------------------------------------------------- # Setup build dependencies, according to the toolchain options. #---------------------------------------------------------------------- - add_subdirectory(third_party/grpc-sideband ${CMAKE_CURRENT_BINARY_DIR}/grpc-sideband) if(USE_SUBMODULE_LIBS) # The archetypical WIN32 build case # protobuf_INSTALL must be turned OFF whenever building it as a cmake subdir. @@ -48,6 +47,7 @@ if(USE_SUBMODULE_LIBS) add_subdirectory(third_party/gtest ${CMAKE_CURRENT_BINARY_DIR}/gtest EXCLUDE_FROM_ALL) add_subdirectory(third_party/json ${CMAKE_CURRENT_BINARY_DIR}/json) add_subdirectory(third_party/utfcpp ${CMAKE_CURRENT_BINARY_DIR}/utfcpp) + add_subdirectory(third_party/grpc-sideband ${CMAKE_CURRENT_BINARY_DIR}/grpc-sideband) set(_PROTOBUF_PROTOC $) set(_REFLECTION grpc++_reflection) @@ -56,6 +56,7 @@ if(USE_SUBMODULE_LIBS) set(_GRPC_GRPCPP grpc++) set(_PROTOBUF_LIBPROTOBUF libprotobuf) set(_UTF8CPP utf8cpp) + set(_GRPC_SIDEBAND ni_grpc_sideband) else() find_program(_PROTOBUF_PROTOC protoc) find_program(_GRPC_CPP_PLUGIN_EXECUTABLE grpc_cpp_plugin) @@ -73,6 +74,7 @@ else() find_library(_GRPC_GRPCPP grpc++) find_library(_PROTOBUF_LIBPROTOBUF protobuf) find_library(_REFLECTION grpc++_reflection) + find_library(_GRPC_SIDEBAND ni_grpc_sideband REQUIRED) find_package(gRPC REQUIRED) find_package(GTest REQUIRED) @@ -276,7 +278,7 @@ get_filename_component(nidevice_proto "imports/protobuf/nidevice.proto" ABSOLUTE get_filename_component(deviceid_restricted_proto "source/protobuf_restricted/deviceid_restricted.proto" ABSOLUTE) get_filename_component(debugsessionproperties_restricted_proto "source/protobuf_restricted/debugsessionproperties_restricted.proto" ABSOLUTE) get_filename_component(calibrationoperations_restricted_proto "source/protobuf_restricted/calibrationoperations_restricted.proto" ABSOLUTE) -get_filename_component(data_moniker_proto "source/protobuf/data_moniker.proto" ABSOLUTE) +get_filename_component(data_moniker_proto "imports/protobuf/data_moniker.proto" ABSOLUTE) get_filename_component(session_proto_path "${session_proto}" PATH) #---------------------------------------------------------------------- @@ -304,7 +306,6 @@ function(GenerateGrpcSources) -I "${proto_path}" ${protobuf_includes_arg} -I ${CMAKE_SOURCE_DIR}/imports/protobuf - -I ${CMAKE_SOURCE_DIR}/source/protobuf --plugin=protoc-gen-grpc="${_GRPC_CPP_PLUGIN_EXECUTABLE}" "${proto_file}" DEPENDS "${proto_file}" "${session_proto}") @@ -395,6 +396,16 @@ GenerateGrpcSources( "${calibrationoperations_restricted_grpc_hdrs}" ) +GenerateGrpcSources( + PROTO + ${data_moniker_proto} + OUTPUT + "${data_moniker_proto_srcs}" + "${data_moniker_proto_hdrs}" + "${data_moniker_grpc_srcs}" + "${data_moniker_grpc_hdrs}" +) + set(nidriver_service_library_hdrs ${nidriver_service_library_hdrs} "${session_proto_hdrs}" @@ -410,16 +421,6 @@ set(nidriver_service_library_hdrs "${calibrationoperations_restricted_grpc_hdrs}" ) -GenerateGrpcSources( - PROTO - ${data_moniker_proto} - OUTPUT - "${data_moniker_proto_srcs}" - "${data_moniker_proto_hdrs}" - "${data_moniker_grpc_srcs}" - "${data_moniker_grpc_hdrs}" -) - foreach(api ${nidrivers}) GenerateGrpcSources( PROTO @@ -465,8 +466,6 @@ add_executable(ni_grpc_device_server "source/server/syscfg_library.cpp" "source/server/syscfg_resource_accessor.cpp" "source/server/syscfg_session_handler.cpp" - ${data_moniker_proto_srcs} - ${data_moniker_grpc_srcs} ${nidevice_proto_srcs} ${session_proto_srcs} ${session_grpc_srcs} @@ -478,6 +477,8 @@ add_executable(ni_grpc_device_server ${debugsessionproperties_restricted_grpc_srcs} ${calibrationoperations_restricted_proto_srcs} ${calibrationoperations_restricted_grpc_srcs} + ${data_moniker_proto_srcs} + ${data_moniker_grpc_srcs} ${nidriver_service_srcs}) # Enable warnings only on source that we own, not generated code or dependencies @@ -551,7 +552,7 @@ set(server_lib_deps ${_REFLECTION} ${_UTF8CPP} ${CMAKE_DL_LIBS} - ni_grpc_sideband + ${_GRPC_SIDEBAND} nlohmann_json::nlohmann_json ) @@ -604,8 +605,6 @@ add_executable(IntegrationTestsRunner "source/server/syscfg_library.cpp" "source/server/syscfg_resource_accessor.cpp" "source/server/syscfg_session_handler.cpp" - ${data_moniker_proto_srcs} - ${data_moniker_grpc_srcs} ${nidevice_proto_srcs} ${session_proto_srcs} ${session_grpc_srcs} @@ -617,6 +616,8 @@ add_executable(IntegrationTestsRunner ${debugsessionproperties_restricted_grpc_srcs} ${calibrationoperations_restricted_proto_srcs} ${calibrationoperations_restricted_grpc_srcs} + ${data_moniker_proto_srcs} + ${data_moniker_grpc_srcs} ${nidriver_service_srcs} "${proto_srcs_dir}/nifake.pb.cc" "${proto_srcs_dir}/nifake.grpc.pb.cc" @@ -700,6 +701,8 @@ add_executable(UnitTestsRunner ${debugsessionproperties_restricted_grpc_srcs} ${calibrationoperations_restricted_proto_srcs} ${calibrationoperations_restricted_grpc_srcs} + ${data_moniker_proto_srcs} + ${data_moniker_grpc_srcs} "${proto_srcs_dir}/nifake.pb.cc" "${proto_srcs_dir}/nifake.grpc.pb.cc" "${proto_srcs_dir}/nifake_extension.pb.cc" @@ -824,8 +827,6 @@ set(system_test_runner_sources "source/server/syscfg_library.cpp" "source/server/syscfg_resource_accessor.cpp" "source/server/syscfg_session_handler.cpp" - ${data_moniker_proto_srcs} - ${data_moniker_grpc_srcs} ${nidevice_proto_srcs} ${session_proto_srcs} ${session_grpc_srcs} @@ -837,6 +838,8 @@ set(system_test_runner_sources ${debugsessionproperties_restricted_grpc_srcs} ${calibrationoperations_restricted_proto_srcs} ${calibrationoperations_restricted_grpc_srcs} + ${data_moniker_proto_srcs} + ${data_moniker_grpc_srcs} ${nidriver_service_srcs} ${nidriver_client_srcs} ) diff --git a/source/protobuf/data_moniker.proto b/imports/protobuf/data_moniker.proto similarity index 100% rename from source/protobuf/data_moniker.proto rename to imports/protobuf/data_moniker.proto diff --git a/source/server/core_server.cpp b/source/server/core_server.cpp index 680dd010c..c3a61aac5 100644 --- a/source/server/core_server.cpp +++ b/source/server/core_server.cpp @@ -2,6 +2,7 @@ #include #include #include + #include #include @@ -11,9 +12,10 @@ #include "server_security_configuration.h" #if defined(__GNUC__) + #include + #include "linux/daemonize.h" #include "linux/syslog_logging.h" - #include #endif #if defined(_WIN32) #include "windows/console_ctrl_handler.h" @@ -78,9 +80,9 @@ static void RunServer(const ServerConfiguration& config) { if (!config.config_file_path.empty()) { nidevice_grpc::logging::log( - nidevice_grpc::logging::Level_Info, - "Using server configuration from %s", - config.config_file_path.c_str()); + nidevice_grpc::logging::Level_Info, + "Using server configuration from %s", + config.config_file_path.c_str()); } grpc::EnableDefaultHealthCheckService(true); @@ -106,13 +108,11 @@ static void RunServer(const ServerConfiguration& config) return; } server = builder.BuildAndStart(); - } - - if (config.feature_toggles.is_feature_enabled("sideband_streaming", FeatureToggles::CodeReadiness::kNextRelease)) - { - auto sideband_socket_thread = new std::thread(RunSidebandSocketsAccept, config.sideband_address.c_str(), 50055); - // auto sideband_rdma_send_thread = new std::thread(AcceptSidebandRdmaSendRequests); - // auto sideband_rdma_recv_thread = new std::thread(AcceptSidebandRdmaReceiveRequests); + if (config.feature_toggles.is_feature_enabled("sideband_streaming", FeatureToggles::CodeReadiness::kNextRelease)) { + auto sideband_socket_thread = new std::thread(RunSidebandSocketsAccept, config.sideband_address.c_str(), 50055); + // auto sideband_rdma_send_thread = new std::thread(AcceptSidebandRdmaSendRequests); + // auto sideband_rdma_recv_thread = new std::thread(AcceptSidebandRdmaReceiveRequests); + } } if (!server) { @@ -195,7 +195,7 @@ Options parse_options(int argc, char** argv) } else #endif - if (strcmp("--help", argv[i]) == 0 || strcmp("-h", argv[i]) == 0) { + if (strcmp("--help", argv[i]) == 0 || strcmp("-h", argv[i]) == 0) { nidevice_grpc::logging::log(nidevice_grpc::logging::Level_Info, usage); exit(EXIT_SUCCESS); } @@ -235,10 +235,10 @@ Options parse_options(int argc, char** argv) static void SysFsWrite(const std::string& fileName, const std::string& value) { - std::ofstream fout; - fout.open(fileName); - fout << value; - fout.close(); + std::ofstream fout; + fout.open(fileName); + fout << value; + fout.close(); } int main(int argc, char** argv) @@ -259,8 +259,7 @@ int main(int argc, char** argv) #if defined(_WIN32) nidevice_grpc::set_console_ctrl_handler(&StopServer); #else - if (config.feature_toggles.is_feature_enabled("sideband_streaming", FeatureToggles::CodeReadiness::kNextRelease)) - { + if (config.feature_toggles.is_feature_enabled("sideband_streaming", FeatureToggles::CodeReadiness::kNextRelease)) { SysFsWrite("/dev/cgroup/cpuset/system_set/cpus", "0-5"); SysFsWrite("/dev/cgroup/cpuset/LabVIEW_ScanEngine_set", "0-5"); SysFsWrite("/dev/cgroup/cpuset/LabVIEW_tl_set/cpus", "6-8"); @@ -275,7 +274,7 @@ int main(int argc, char** argv) CPU_SET(6, &cpuSet); sched_setaffinity(0, sizeof(cpu_set_t), &cpuSet); - mlockall(MCL_CURRENT|MCL_FUTURE); + mlockall(MCL_CURRENT | MCL_FUTURE); } #endif diff --git a/source/server/data_moniker_service.cpp b/source/server/data_moniker_service.cpp index 580a4abb3..176f3ad40 100644 --- a/source/server/data_moniker_service.cpp +++ b/source/server/data_moniker_service.cpp @@ -1,13 +1,15 @@ //--------------------------------------------------------------------- //--------------------------------------------------------------------- -#include -#include +#include "data_moniker_service.h" + #include -#include #include -#include "data_moniker_service.h" +#include + +#include +#include #ifndef _WIN32 -#include + #include #endif #include @@ -15,284 +17,243 @@ //--------------------------------------------------------------------- //--------------------------------------------------------------------- +using google::protobuf::Arena; using grpc::Server; using grpc::ServerBuilder; using grpc::ServerContext; -using grpc::Status; -using grpc::ServerWriter; using grpc::ServerReaderWriter; -using std::string; +using grpc::ServerWriter; +using grpc::Status; +using ni::data_monikers::BeginMonikerSidebandStreamRequest; +using ni::data_monikers::BeginMonikerSidebandStreamResponse; using ni::data_monikers::DataMoniker; using ni::data_monikers::MonikerList; -using ni::data_monikers::MonikerWriteRequest; using ni::data_monikers::MonikerReadResponse; -using ni::data_monikers::StreamWriteResponse; -using ni::data_monikers::SidebandWriteRequest; +using ni::data_monikers::MonikerWriteRequest; using ni::data_monikers::SidebandReadResponse; -using ni::data_monikers::BeginMonikerSidebandStreamRequest; -using ni::data_monikers::BeginMonikerSidebandStreamResponse; -using google::protobuf::Arena; +using ni::data_monikers::SidebandWriteRequest; +using ni::data_monikers::StreamWriteResponse; +using std::string; static void SysFsWrite(const std::string& fileName, const std::string& value) { - std::ofstream fout; - fout.open(fileName); - fout << value; - fout.close(); + std::ofstream fout; + fout.open(fileName); + fout << value; + fout.close(); } -namespace ni::data_monikers +namespace ni::data_monikers { +//--------------------------------------------------------------------- +//--------------------------------------------------------------------- +DataMonikerService* DataMonikerService::s_Server; + +//--------------------------------------------------------------------- +//--------------------------------------------------------------------- +DataMonikerService::DataMonikerService() { - //--------------------------------------------------------------------- - //--------------------------------------------------------------------- - DataMonikerService* DataMonikerService::s_Server; + s_Server = this; +} - //--------------------------------------------------------------------- - //--------------------------------------------------------------------- - DataMonikerService::DataMonikerService() - { - s_Server = this; - } +//--------------------------------------------------------------------- +//--------------------------------------------------------------------- +void DataMonikerService::RegisterMonikerEndpoint(string endpointName, MonikerEndpointPtr endpoint) +{ + s_Server->_endpoints.emplace(endpointName, endpoint); +} - //--------------------------------------------------------------------- - //--------------------------------------------------------------------- - void DataMonikerService::RegisterMonikerEndpoint(string endpointName, MonikerEndpointPtr endpoint) - { - s_Server->_endpoints.emplace(endpointName, endpoint); - } +//--------------------------------------------------------------------- +//--------------------------------------------------------------------- +void DataMonikerService::RegisterMonikerInstance(string endpointName, void* instanceData, Moniker& moniker) +{ + moniker.set_data_instance(reinterpret_cast(instanceData)); + moniker.set_service_location("local"); + moniker.set_data_source(endpointName); +} - //--------------------------------------------------------------------- - //--------------------------------------------------------------------- - void DataMonikerService::RegisterMonikerInstance(string endpointName, void* instanceData, Moniker& moniker) - { - moniker.set_data_instance(reinterpret_cast(instanceData)); - moniker.set_service_location("local"); - moniker.set_data_source(endpointName); +//--------------------------------------------------------------------- +//--------------------------------------------------------------------- +void DataMonikerService::InitiateMonikerList(const MonikerList& monikers, EndpointList* readers, EndpointList* writers) +{ + for (auto readMoniker : monikers.read_monikers()) { + auto instance = readMoniker.data_instance(); + auto source = readMoniker.data_source(); + auto it = _endpoints.find(source); + MonikerEndpointPtr ptr = nullptr; + if (it != _endpoints.end()) { + ptr = (*it).second; } - - //--------------------------------------------------------------------- - //--------------------------------------------------------------------- - void DataMonikerService::InitiateMonikerList(const MonikerList& monikers, EndpointList* readers, EndpointList* writers) - { - for (auto readMoniker: monikers.read_monikers()) - { - auto instance = readMoniker.data_instance(); - auto source = readMoniker.data_source(); - auto it = _endpoints.find(source); - MonikerEndpointPtr ptr = nullptr; - if (it != _endpoints.end()) - { - ptr = (*it).second; - } - readers->push_back(EndpointInstance(ptr, reinterpret_cast(instance))); - } - for (auto writeMoniker: monikers.write_monikers()) - { - auto instance = writeMoniker.data_instance(); - auto source = writeMoniker.data_source(); - auto it = _endpoints.find(source); - MonikerEndpointPtr ptr = nullptr; - if (it != _endpoints.end()) - { - ptr = (*it).second; - } - writers->push_back(EndpointInstance(ptr, reinterpret_cast(instance))); - } + readers->push_back(EndpointInstance(ptr, reinterpret_cast(instance))); + } + for (auto writeMoniker : monikers.write_monikers()) { + auto instance = writeMoniker.data_instance(); + auto source = writeMoniker.data_source(); + auto it = _endpoints.find(source); + MonikerEndpointPtr ptr = nullptr; + if (it != _endpoints.end()) { + ptr = (*it).second; } + writers->push_back(EndpointInstance(ptr, reinterpret_cast(instance))); + } +} - //--------------------------------------------------------------------- - //--------------------------------------------------------------------- - void DataMonikerService::RunSidebandReadWriteLoop(string sidebandIdentifier, ::SidebandStrategy strategy, EndpointList* readers, EndpointList* writers) - { - std::cout << "Enter RunSidebandReadWriteLoop" << std::endl; - - #ifndef _WIN32 - if (strategy == ::SidebandStrategy::RDMA_LOW_LATENCY || - strategy == ::SidebandStrategy::SOCKETS_LOW_LATENCY) - { - pid_t threadId = syscall(SYS_gettid); - ::SysFsWrite("/dev/cgroup/cpuset/LabVIEW_tl_set/tasks", std::to_string(threadId)); +//--------------------------------------------------------------------- +//--------------------------------------------------------------------- +void DataMonikerService::RunSidebandReadWriteLoop(string sidebandIdentifier, ::SidebandStrategy strategy, EndpointList* readers, EndpointList* writers) +{ +#ifndef _WIN32 + if (strategy == ::SidebandStrategy::RDMA_LOW_LATENCY || + strategy == ::SidebandStrategy::SOCKETS_LOW_LATENCY) { + pid_t threadId = syscall(SYS_gettid); + ::SysFsWrite("/dev/cgroup/cpuset/LabVIEW_tl_set/tasks", std::to_string(threadId)); - cpu_set_t cpuSet; - CPU_ZERO(&cpuSet); - CPU_SET(8, &cpuSet); - //CPU_SET(8, &cpuSet); - sched_setaffinity(threadId, sizeof(cpu_set_t), &cpuSet); - } - #endif + cpu_set_t cpuSet; + CPU_ZERO(&cpuSet); + CPU_SET(8, &cpuSet); + sched_setaffinity(threadId, sizeof(cpu_set_t), &cpuSet); + } +#endif - google::protobuf::Arena arena; - int64_t sidebandToken; - GetOwnerSidebandDataToken(sidebandIdentifier.c_str(), &sidebandToken); - while (true) - { - auto writeRequest = google::protobuf::Arena::CreateMessage(&arena); - if (!ReadSidebandMessage(sidebandToken, writeRequest)) - { - break; - } - if (writeRequest->cancel()) - { - std::cout << "Cancelled." << std::endl; - break; - } - if (writers->size() > 0) - { - int x = 0; - if (writers->size() != writeRequest->values().values_size()) - { - std::cout << "ERROR: The number of writers and values read did not match" << std::endl; - std::cout << "Expected: " << writers->size() << std::endl; - std::cout << "Actual: " << writeRequest->values().values_size() << std::endl; - break; - } - for (auto writer: *writers) - { - std::get<0>(writer)(std::get<1>(writer), arena, const_cast(writeRequest->values().values(x++))); - } - } - auto readResult = Arena::CreateMessage(&arena); - if (readResult->GetArena() != &arena) - { - std::cout << "No Arena 111" << std::endl; - } - if (readers->size() > 0) - { - int x = 0; - for (auto reader: *readers) - { - auto readValue = readResult->mutable_values()->add_values(); - if (readValue->GetArena() != &arena) - { - std::cout << "No Arena" << std::endl; - } - std::get<0>(reader)(std::get<1>(reader), arena, *readValue); - } - } - if (!WriteSidebandMessage(sidebandToken, *readResult)) - { - std::cout << "Failed to write" << std::endl; - break; - } - arena.Reset(); - std::this_thread::sleep_for(std::chrono::microseconds(10)); - } - delete readers; - delete writers; - CloseSidebandData(sidebandToken); - std::cout << "Exit RunSidebandReadWriteLoop" << std::endl; + google::protobuf::Arena arena; + int64_t sidebandToken; + GetOwnerSidebandDataToken(sidebandIdentifier.c_str(), &sidebandToken); + while (true) { + auto writeRequest = google::protobuf::Arena::CreateMessage(&arena); + if (!ReadSidebandMessage(sidebandToken, writeRequest)) { + break; } + if (writeRequest->cancel()) { + break; + } + if (writers->size() > 0) { + int x = 0; + if (writers->size() != writeRequest->values().values_size()) { + break; + } + for (auto writer : *writers) { + std::get<0>(writer)(std::get<1>(writer), arena, const_cast(writeRequest->values().values(x++))); + } + } + auto readResult = Arena::CreateMessage(&arena); + if (readers->size() > 0) { + int x = 0; + for (auto reader : *readers) { + auto readValue = readResult->mutable_values()->add_values(); + std::get<0>(reader)(std::get<1>(reader), arena, *readValue); + } + } + if (!WriteSidebandMessage(sidebandToken, *readResult)) { + break; + } + arena.Reset(); + std::this_thread::sleep_for(std::chrono::microseconds(10)); + } + delete readers; + delete writers; + CloseSidebandData(sidebandToken); +} - //--------------------------------------------------------------------- - //--------------------------------------------------------------------- - Status DataMonikerService::BeginSidebandStream(ServerContext* context, const BeginMonikerSidebandStreamRequest* request, BeginMonikerSidebandStreamResponse* response) - { - std::cout << "Enter BeginSidebandStream" << std::endl; - auto bufferSize = 1024 * 1024; - auto strategy = static_cast<::SidebandStrategy>(request->strategy()); +//--------------------------------------------------------------------- +//--------------------------------------------------------------------- +Status DataMonikerService::BeginSidebandStream(ServerContext* context, const BeginMonikerSidebandStreamRequest* request, BeginMonikerSidebandStreamResponse* response) +{ + auto bufferSize = 1024 * 1024; + auto strategy = static_cast<::SidebandStrategy>(request->strategy()); - char identifier[32] = {}; - InitOwnerSidebandData(strategy, bufferSize, identifier);; - response->set_strategy(request->strategy()); - response->set_sideband_identifier(identifier); - response->set_connection_url(GetConnectionAddress(strategy)); - response->set_buffer_size(bufferSize); - QueueSidebandConnection(strategy, identifier, true, true, bufferSize); + char identifier[32] = {}; + InitOwnerSidebandData(strategy, bufferSize, identifier); + ; + response->set_strategy(request->strategy()); + response->set_sideband_identifier(identifier); + response->set_connection_url(GetConnectionAddress(strategy)); + response->set_buffer_size(bufferSize); + QueueSidebandConnection(strategy, identifier, true, true, bufferSize); - auto writers = new EndpointList(); - auto readers = new EndpointList(); - InitiateMonikerList(request->monikers(), readers, writers); + auto writers = new EndpointList(); + auto readers = new EndpointList(); + InitiateMonikerList(request->monikers(), readers, writers); - std::cout << "Starting thread with RunSidebandReadWriteLoop()" << std::endl; - auto thread = new std::thread(RunSidebandReadWriteLoop, identifier, strategy, readers, writers); - thread->detach(); + auto thread = new std::thread(RunSidebandReadWriteLoop, identifier, strategy, readers, writers); + thread->detach(); - std::cout << "Exit BeginSidebandStream" << std::endl; - return Status::OK; - } + return Status::OK; +} - //--------------------------------------------------------------------- - //--------------------------------------------------------------------- - Status DataMonikerService::StreamReadWrite(ServerContext* context, ServerReaderWriter* stream) - { - EndpointList writers; - EndpointList readers; - MonikerWriteRequest writeRequest; - stream->Read(&writeRequest); - InitiateMonikerList(writeRequest.monikers(), &readers, &writers); +//--------------------------------------------------------------------- +//--------------------------------------------------------------------- +Status DataMonikerService::StreamReadWrite(ServerContext* context, ServerReaderWriter* stream) +{ + EndpointList writers; + EndpointList readers; + MonikerWriteRequest writeRequest; + stream->Read(&writeRequest); + InitiateMonikerList(writeRequest.monikers(), &readers, &writers); - google::protobuf::Arena arena; - while (stream->Read(&writeRequest) && !context->IsCancelled()) - { - int x = 0; - for (auto writer: writers) - { - std::get<0>(writer)(std::get<1>(writer), arena, const_cast(writeRequest.data().values(x++))); - } + google::protobuf::Arena arena; + while (stream->Read(&writeRequest) && !context->IsCancelled()) { + int x = 0; + for (auto writer : writers) { + std::get<0>(writer)(std::get<1>(writer), arena, const_cast(writeRequest.data().values(x++))); + } - MonikerReadResponse readResult; - for (auto reader: readers) - { - auto readValue = readResult.mutable_data()->add_values(); - std::get<0>(reader)(std::get<1>(reader), arena, *readValue); - } - stream->Write(readResult); - arena.Reset(); - } - return Status::OK; + MonikerReadResponse readResult; + for (auto reader : readers) { + auto readValue = readResult.mutable_data()->add_values(); + std::get<0>(reader)(std::get<1>(reader), arena, *readValue); } + stream->Write(readResult); + arena.Reset(); + } + return Status::OK; +} - //--------------------------------------------------------------------- - //--------------------------------------------------------------------- - Status DataMonikerService::StreamRead(ServerContext* context, const MonikerList* request, ServerWriter* writer) - { - EndpointList writers; - EndpointList readers; - InitiateMonikerList(*request, &readers, &writers); +//--------------------------------------------------------------------- +//--------------------------------------------------------------------- +Status DataMonikerService::StreamRead(ServerContext* context, const MonikerList* request, ServerWriter* writer) +{ + EndpointList writers; + EndpointList readers; + InitiateMonikerList(*request, &readers, &writers); - google::protobuf::Arena arena; - while (!context->IsCancelled()) - { - MonikerReadResponse readResult; - for (auto reader: readers) - { - auto readValue = readResult.mutable_data()->add_values(); - std::get<0>(reader)(std::get<1>(reader), arena, *readValue); - } - writer->Write(readResult); - arena.Reset(); - } - return Status::OK; + google::protobuf::Arena arena; + while (!context->IsCancelled()) { + MonikerReadResponse readResult; + for (auto reader : readers) { + auto readValue = readResult.mutable_data()->add_values(); + std::get<0>(reader)(std::get<1>(reader), arena, *readValue); } + writer->Write(readResult); + arena.Reset(); + } + return Status::OK; +} - //--------------------------------------------------------------------- - //--------------------------------------------------------------------- - Status DataMonikerService::StreamWrite(ServerContext* context, ServerReaderWriter* stream) - { - #ifndef _WIN32 - cpu_set_t cpuSet; - CPU_ZERO(&cpuSet); - CPU_SET(1, &cpuSet); - sched_setaffinity(0, sizeof(cpu_set_t), &cpuSet); - #endif +//--------------------------------------------------------------------- +//--------------------------------------------------------------------- +Status DataMonikerService::StreamWrite(ServerContext* context, ServerReaderWriter* stream) +{ +#ifndef _WIN32 + cpu_set_t cpuSet; + CPU_ZERO(&cpuSet); + CPU_SET(1, &cpuSet); + sched_setaffinity(0, sizeof(cpu_set_t), &cpuSet); +#endif - EndpointList writers; - EndpointList readers; - MonikerWriteRequest writeRequest; - stream->Read(&writeRequest); - InitiateMonikerList(writeRequest.monikers(), &readers, &writers); + EndpointList writers; + EndpointList readers; + MonikerWriteRequest writeRequest; + stream->Read(&writeRequest); + InitiateMonikerList(writeRequest.monikers(), &readers, &writers); - int x = 0; - google::protobuf::Arena arena; - while (stream->Read(&writeRequest) && !context->IsCancelled()) - { - x = 0; - for (auto writer: writers) - { - std::get<0>(writer)(std::get<1>(writer), arena, const_cast(writeRequest.data().values(x++))); - } - arena.Reset(); - } - return Status::OK; + int x = 0; + google::protobuf::Arena arena; + while (stream->Read(&writeRequest) && !context->IsCancelled()) { + x = 0; + for (auto writer : writers) { + std::get<0>(writer)(std::get<1>(writer), arena, const_cast(writeRequest.data().values(x++))); } + arena.Reset(); + } + return Status::OK; } +} // namespace ni::data_monikers From b2858b20dd6687ba95916b27b65ba29715edfe0a Mon Sep 17 00:00:00 2001 From: Ayush Mehra Date: Mon, 4 Nov 2024 02:19:11 -0800 Subject: [PATCH 13/34] add feature toggle helper --- source/server/core_server.cpp | 5 +++-- source/server/core_services_registrar.cpp | 5 ++--- source/server/data_moniker_service.cpp | 6 ++++++ source/server/data_moniker_service.h | 2 ++ 4 files changed, 13 insertions(+), 5 deletions(-) diff --git a/source/server/core_server.cpp b/source/server/core_server.cpp index c3a61aac5..9521e6810 100644 --- a/source/server/core_server.cpp +++ b/source/server/core_server.cpp @@ -22,6 +22,7 @@ #endif #include "version.h" +#include "data_moniker_service.h" using FeatureState = nidevice_grpc::FeatureToggles::FeatureState; using FeatureToggles = nidevice_grpc::FeatureToggles; @@ -108,7 +109,7 @@ static void RunServer(const ServerConfiguration& config) return; } server = builder.BuildAndStart(); - if (config.feature_toggles.is_feature_enabled("sideband_streaming", FeatureToggles::CodeReadiness::kNextRelease)) { + if (ni::data_monikers::is_sideband_streaming_enabled(config.feature_toggles)) { auto sideband_socket_thread = new std::thread(RunSidebandSocketsAccept, config.sideband_address.c_str(), 50055); // auto sideband_rdma_send_thread = new std::thread(AcceptSidebandRdmaSendRequests); // auto sideband_rdma_recv_thread = new std::thread(AcceptSidebandRdmaReceiveRequests); @@ -259,7 +260,7 @@ int main(int argc, char** argv) #if defined(_WIN32) nidevice_grpc::set_console_ctrl_handler(&StopServer); #else - if (config.feature_toggles.is_feature_enabled("sideband_streaming", FeatureToggles::CodeReadiness::kNextRelease)) { + if (ni::data_monikers::is_sideband_streaming_enabled(config.feature_toggles)) { SysFsWrite("/dev/cgroup/cpuset/system_set/cpus", "0-5"); SysFsWrite("/dev/cgroup/cpuset/LabVIEW_ScanEngine_set", "0-5"); SysFsWrite("/dev/cgroup/cpuset/LabVIEW_tl_set/cpus", "6-8"); diff --git a/source/server/core_services_registrar.cpp b/source/server/core_services_registrar.cpp index 8d57d7fb9..fa5869845 100644 --- a/source/server/core_services_registrar.cpp +++ b/source/server/core_services_registrar.cpp @@ -1,10 +1,10 @@ #include "core_services_registrar.h" #include "calibration_operations_restricted_service_registrar.h" +#include "data_moniker_service.h" #include "debug_session_properties_restricted_service_registrar.h" #include "server_reset_observer_registrar_interface.h" #include "session_utilities_service_registrar.h" -#include "data_moniker_service.h" namespace nidevice_grpc { void register_core_services( @@ -27,8 +27,7 @@ void register_core_services( feature_toggles, *server_reset_observer_registrar)); - if (feature_toggles.is_feature_enabled("sideband_streaming", FeatureToggles::CodeReadiness::kNextRelease)) - { + if (ni::data_monikers::is_sideband_streaming_enabled(feature_toggles)) { auto moniker_service = std::make_shared(); server_builder.RegisterService(moniker_service.get()); service_vector->push_back(moniker_service); diff --git a/source/server/data_moniker_service.cpp b/source/server/data_moniker_service.cpp index 176f3ad40..961ab24cc 100644 --- a/source/server/data_moniker_service.cpp +++ b/source/server/data_moniker_service.cpp @@ -44,6 +44,12 @@ static void SysFsWrite(const std::string& fileName, const std::string& value) } namespace ni::data_monikers { + +bool is_sideband_streaming_enabled(const nidevice_grpc::FeatureToggles& feature_toggles) +{ + return feature_toggles.is_feature_enabled("sideband_streaming", nidevice_grpc::FeatureToggles::CodeReadiness::kNextRelease); +} + //--------------------------------------------------------------------- //--------------------------------------------------------------------- DataMonikerService* DataMonikerService::s_Server; diff --git a/source/server/data_moniker_service.h b/source/server/data_moniker_service.h index 660308533..b8420927b 100644 --- a/source/server/data_moniker_service.h +++ b/source/server/data_moniker_service.h @@ -10,11 +10,13 @@ #include #include #include +#include "feature_toggles.h" //--------------------------------------------------------------------- //--------------------------------------------------------------------- namespace ni::data_monikers { + bool is_sideband_streaming_enabled(const nidevice_grpc::FeatureToggles& feature_toggles); //--------------------------------------------------------------------- //--------------------------------------------------------------------- using MonikerEndpointPtr = std::add_pointer<::grpc::Status(void*, google::protobuf::Arena& arena, google::protobuf::Any&)>::type; From 0771d7fefe736cffd21fa9031743141fa71feaab Mon Sep 17 00:00:00 2001 From: Ayush Mehra Date: Mon, 4 Nov 2024 20:39:39 -0800 Subject: [PATCH 14/34] fixing minor comments --- source/codegen/common_helpers.py | 6 +- source/codegen/metadata/nifpga/config.py | 2 +- source/codegen/metadata/nifpga/functions.py | 128 +++++++++--------- source/codegen/metadata_mutation.py | 5 +- source/codegen/metadata_validation.py | 4 +- source/codegen/service_helpers.py | 2 +- .../templates/register_all_services.cpp.mako | 4 +- source/codegen/templates/service.cpp.mako | 10 +- source/codegen/templates/service.h.mako | 6 +- 9 files changed, 81 insertions(+), 86 deletions(-) diff --git a/source/codegen/common_helpers.py b/source/codegen/common_helpers.py index c808a7737..035cda849 100644 --- a/source/codegen/common_helpers.py +++ b/source/codegen/common_helpers.py @@ -1204,15 +1204,13 @@ def get_params_needing_initialization(parameters: List[dict]) -> List[dict]: return [p for p in parameters if not (is_return_value(p) or is_get_last_error_output_param(p))] -def filter_data_moniker_functions(functions): +def filter_streaming_functions(functions): """Return function metadata only for functions that use the data moniker service.""" return [ - name for name, function in functions.items() if function.get("data_moniker_support", False) + name for name, function in functions.items() if function.get("is_streaming_api", False) ] def get_data_moniker_function_name(function_name, function_data): """Return the corresponding moniker function name for the given C API function.""" - if function_data.get("moniker_cname", None): - return function_data["moniker_cname"] return function_name.replace("Begin", "Moniker") diff --git a/source/codegen/metadata/nifpga/config.py b/source/codegen/metadata/nifpga/config.py index e61d248c9..8a2dce1e9 100644 --- a/source/codegen/metadata/nifpga/config.py +++ b/source/codegen/metadata/nifpga/config.py @@ -31,7 +31,7 @@ 'NiFpga_Bool': 'bool', 'NiFpga_FifoProperty': 'uint32', }, - 'use_moniker_service': True, + 'has_streaming_api': True, 'use_dynload_msvc': True, 'use_protobuf_arenas': True, 'custom_types': [], diff --git a/source/codegen/metadata/nifpga/functions.py b/source/codegen/metadata/nifpga/functions.py index 1e9da83b1..ce517594a 100644 --- a/source/codegen/metadata/nifpga/functions.py +++ b/source/codegen/metadata/nifpga/functions.py @@ -1715,7 +1715,6 @@ 'returns': 'NiFpga_Status' }, 'ReadArrayI16': { - 'moniker_supports_streaming': True, 'parameters': [ { 'direction': 'in', @@ -1744,10 +1743,10 @@ 'type': 'size_t' } ], - 'returns': 'NiFpga_Status' + 'returns': 'NiFpga_Status', + 'supports_streaming': True }, 'ReadArrayI32': { - 'moniker_supports_streaming': True, 'parameters': [ { 'direction': 'in', @@ -1776,10 +1775,10 @@ 'type': 'size_t' } ], - 'returns': 'NiFpga_Status' + 'returns': 'NiFpga_Status', + 'supports_streaming': True }, 'ReadArrayI64': { - 'moniker_supports_streaming': True, 'parameters': [ { 'direction': 'in', @@ -1808,10 +1807,10 @@ 'type': 'size_t' } ], - 'returns': 'NiFpga_Status' + 'returns': 'NiFpga_Status', + 'supports_streaming': True }, 'ReadArrayI8': { - 'moniker_supports_streaming': True, 'parameters': [ { 'direction': 'in', @@ -1840,7 +1839,8 @@ 'type': 'size_t' } ], - 'returns': 'NiFpga_Status' + 'returns': 'NiFpga_Status', + 'supports_streaming': True }, 'ReadArraySgl': { 'parameters': [ @@ -1872,7 +1872,6 @@ 'returns': 'NiFpga_Status' }, 'ReadArrayU16': { - 'moniker_supports_streaming': True, 'parameters': [ { 'direction': 'in', @@ -1901,10 +1900,10 @@ 'type': 'size_t' } ], - 'returns': 'NiFpga_Status' + 'returns': 'NiFpga_Status', + 'supports_streaming': True }, 'ReadArrayU32': { - 'moniker_supports_streaming': True, 'parameters': [ { 'direction': 'in', @@ -1933,10 +1932,10 @@ 'type': 'size_t' } ], - 'returns': 'NiFpga_Status' + 'returns': 'NiFpga_Status', + 'supports_streaming': True }, 'ReadArrayU64': { - 'moniker_supports_streaming': True, 'parameters': [ { 'direction': 'in', @@ -1965,10 +1964,10 @@ 'type': 'size_t' } ], - 'returns': 'NiFpga_Status' + 'returns': 'NiFpga_Status', + 'supports_streaming': True }, 'ReadArrayU8': { - 'moniker_supports_streaming': True, 'parameters': [ { 'direction': 'in', @@ -1997,7 +1996,8 @@ 'type': 'size_t' } ], - 'returns': 'NiFpga_Status' + 'returns': 'NiFpga_Status', + 'supports_streaming': True }, 'ReadBool': { 'parameters': [ @@ -2540,7 +2540,6 @@ 'returns': 'NiFpga_Status' }, 'ReadI16': { - 'moniker_supports_streaming': True, 'parameters': [ { 'direction': 'in', @@ -2560,10 +2559,10 @@ 'type': 'int16_t' } ], - 'returns': 'NiFpga_Status' + 'returns': 'NiFpga_Status', + 'supports_streaming': True }, 'ReadI32': { - 'moniker_supports_streaming': True, 'parameters': [ { 'direction': 'in', @@ -2583,10 +2582,10 @@ 'type': 'int32_t' } ], - 'returns': 'NiFpga_Status' + 'returns': 'NiFpga_Status', + 'supports_streaming': True }, 'ReadI64': { - 'moniker_supports_streaming': True, 'parameters': [ { 'direction': 'in', @@ -2606,10 +2605,10 @@ 'type': 'int64_t' } ], - 'returns': 'NiFpga_Status' + 'returns': 'NiFpga_Status', + 'supports_streaming': True }, 'ReadI8': { - 'moniker_supports_streaming': True, 'parameters': [ { 'direction': 'in', @@ -2629,7 +2628,8 @@ 'type': 'int8_t' } ], - 'returns': 'NiFpga_Status' + 'returns': 'NiFpga_Status', + 'supports_streaming': True }, 'ReadSgl': { 'parameters': [ @@ -2652,7 +2652,6 @@ 'returns': 'NiFpga_Status' }, 'ReadU16': { - 'moniker_supports_streaming': True, 'parameters': [ { 'direction': 'in', @@ -2672,10 +2671,10 @@ 'type': 'uint16_t' } ], - 'returns': 'NiFpga_Status' + 'returns': 'NiFpga_Status', + 'supports_streaming': True }, 'ReadU32': { - 'moniker_supports_streaming': True, 'parameters': [ { 'direction': 'in', @@ -2695,10 +2694,10 @@ 'type': 'uint32_t' } ], - 'returns': 'NiFpga_Status' + 'returns': 'NiFpga_Status', + 'supports_streaming': True }, 'ReadU64': { - 'moniker_supports_streaming': True, 'parameters': [ { 'direction': 'in', @@ -2718,10 +2717,10 @@ 'type': 'uint64_t' } ], - 'returns': 'NiFpga_Status' + 'returns': 'NiFpga_Status', + 'supports_streaming': True }, 'ReadU8': { - 'moniker_supports_streaming': True, 'parameters': [ { 'direction': 'in', @@ -2741,7 +2740,8 @@ 'type': 'uint8_t' } ], - 'returns': 'NiFpga_Status' + 'returns': 'NiFpga_Status', + 'supports_streaming': True }, 'ReleaseFifoElements': { 'parameters': [ @@ -3130,7 +3130,6 @@ 'returns': 'NiFpga_Status' }, 'WriteArrayI16': { - 'moniker_supports_streaming': True, 'parameters': [ { 'direction': 'in', @@ -3159,10 +3158,10 @@ 'type': 'size_t' } ], - 'returns': 'NiFpga_Status' + 'returns': 'NiFpga_Status', + 'supports_streaming': True }, 'WriteArrayI32': { - 'moniker_supports_streaming': True, 'parameters': [ { 'direction': 'in', @@ -3191,10 +3190,10 @@ 'type': 'size_t' } ], - 'returns': 'NiFpga_Status' + 'returns': 'NiFpga_Status', + 'supports_streaming': True }, 'WriteArrayI64': { - 'moniker_supports_streaming': True, 'parameters': [ { 'direction': 'in', @@ -3223,10 +3222,10 @@ 'type': 'size_t' } ], - 'returns': 'NiFpga_Status' + 'returns': 'NiFpga_Status', + 'supports_streaming': True }, 'WriteArrayI8': { - 'moniker_supports_streaming': True, 'parameters': [ { 'direction': 'in', @@ -3255,7 +3254,8 @@ 'type': 'size_t' } ], - 'returns': 'NiFpga_Status' + 'returns': 'NiFpga_Status', + 'supports_streaming': True }, 'WriteArraySgl': { 'parameters': [ @@ -3287,7 +3287,6 @@ 'returns': 'NiFpga_Status' }, 'WriteArrayU16': { - 'moniker_supports_streaming': True, 'parameters': [ { 'direction': 'in', @@ -3316,10 +3315,10 @@ 'type': 'size_t' } ], - 'returns': 'NiFpga_Status' + 'returns': 'NiFpga_Status', + 'supports_streaming': True }, 'WriteArrayU32': { - 'moniker_supports_streaming': True, 'parameters': [ { 'direction': 'in', @@ -3348,10 +3347,10 @@ 'type': 'size_t' } ], - 'returns': 'NiFpga_Status' + 'returns': 'NiFpga_Status', + 'supports_streaming': True }, 'WriteArrayU64': { - 'moniker_supports_streaming': True, 'parameters': [ { 'direction': 'in', @@ -3380,10 +3379,10 @@ 'type': 'size_t' } ], - 'returns': 'NiFpga_Status' + 'returns': 'NiFpga_Status', + 'supports_streaming': True }, 'WriteArrayU8': { - 'moniker_supports_streaming': True, 'parameters': [ { 'direction': 'in', @@ -3412,7 +3411,8 @@ 'type': 'size_t' } ], - 'returns': 'NiFpga_Status' + 'returns': 'NiFpga_Status', + 'supports_streaming': True }, 'WriteBool': { 'parameters': [ @@ -3951,7 +3951,6 @@ 'returns': 'NiFpga_Status' }, 'WriteI16': { - 'moniker_supports_streaming': True, 'parameters': [ { 'direction': 'in', @@ -3971,10 +3970,10 @@ 'type': 'int16_t' } ], - 'returns': 'NiFpga_Status' + 'returns': 'NiFpga_Status', + 'supports_streaming': True }, 'WriteI32': { - 'moniker_supports_streaming': True, 'parameters': [ { 'direction': 'in', @@ -3994,10 +3993,10 @@ 'type': 'int32_t' } ], - 'returns': 'NiFpga_Status' + 'returns': 'NiFpga_Status', + 'supports_streaming': True }, 'WriteI64': { - 'moniker_supports_streaming': True, 'parameters': [ { 'direction': 'in', @@ -4017,10 +4016,10 @@ 'type': 'int64_t' } ], - 'returns': 'NiFpga_Status' + 'returns': 'NiFpga_Status', + 'supports_streaming': True }, 'WriteI8': { - 'moniker_supports_streaming': True, 'parameters': [ { 'direction': 'in', @@ -4040,7 +4039,8 @@ 'type': 'int8_t' } ], - 'returns': 'NiFpga_Status' + 'returns': 'NiFpga_Status', + 'supports_streaming': True }, 'WriteSgl': { 'parameters': [ @@ -4063,7 +4063,6 @@ 'returns': 'NiFpga_Status' }, 'WriteU16': { - 'moniker_supports_streaming': True, 'parameters': [ { 'direction': 'in', @@ -4083,10 +4082,10 @@ 'type': 'uint16_t' } ], - 'returns': 'NiFpga_Status' + 'returns': 'NiFpga_Status', + 'supports_streaming': True }, 'WriteU32': { - 'moniker_supports_streaming': True, 'parameters': [ { 'direction': 'in', @@ -4106,10 +4105,10 @@ 'type': 'uint32_t' } ], - 'returns': 'NiFpga_Status' + 'returns': 'NiFpga_Status', + 'supports_streaming': True }, 'WriteU64': { - 'moniker_supports_streaming': True, 'parameters': [ { 'direction': 'in', @@ -4129,10 +4128,10 @@ 'type': 'uint64_t' } ], - 'returns': 'NiFpga_Status' + 'returns': 'NiFpga_Status', + 'supports_streaming': True }, 'WriteU8': { - 'moniker_supports_streaming': True, 'parameters': [ { 'direction': 'in', @@ -4152,6 +4151,7 @@ 'type': 'uint8_t' } ], - 'returns': 'NiFpga_Status' + 'returns': 'NiFpga_Status', + 'supports_streaming': True } } diff --git a/source/codegen/metadata_mutation.py b/source/codegen/metadata_mutation.py index 4092ef61c..44fa6dbfa 100644 --- a/source/codegen/metadata_mutation.py +++ b/source/codegen/metadata_mutation.py @@ -124,7 +124,7 @@ def mutate(metadata: dict): for function_name, function in metadata["functions"].items(): all_functions[function_name] = function - if function.get("moniker_supports_streaming") is True: + if function.get("supports_streaming") is True: new_function_name = f"Begin{function_name}" all_functions[new_function_name] = generate_streaming_metadata(function) @@ -173,8 +173,7 @@ def generate_streaming_metadata(function: dict) -> dict: # Construct the streaming API metadata streaming_metadata = { - "data_moniker_support": True, - "exclude_from_library": True, + "is_streaming_api": True, "parameters": streaming_parameters, "returns": function["returns"], } diff --git a/source/codegen/metadata_validation.py b/source/codegen/metadata_validation.py index 4306ade0e..ced095e94 100644 --- a/source/codegen/metadata_validation.py +++ b/source/codegen/metadata_validation.py @@ -176,10 +176,8 @@ class RULES: Optional("is_python_factory"): bool, Optional("python_description"): str, Optional("timeout_error"): str, - Optional("exclude_from_library"): bool, - Optional("data_moniker_support"): bool, + Optional("supports_streaming"): bool, Optional("moniker_streaming_type"): str, - Optional("moniker_supports_streaming"): bool, } ) diff --git a/source/codegen/service_helpers.py b/source/codegen/service_helpers.py index 17ee46270..0f27fae0f 100644 --- a/source/codegen/service_helpers.py +++ b/source/codegen/service_helpers.py @@ -319,7 +319,7 @@ def filter_api_functions(functions, only_mockable_functions=True): def filter_function(function): if function.get("codegen_method", "") == "no" or function.get( - "exclude_from_library", False + "is_streaming_api", False ): return False if only_mockable_functions and not common_helpers.can_mock_function(function["parameters"]): diff --git a/source/codegen/templates/register_all_services.cpp.mako b/source/codegen/templates/register_all_services.cpp.mako index a0361bef6..600eb2449 100644 --- a/source/codegen/templates/register_all_services.cpp.mako +++ b/source/codegen/templates/register_all_services.cpp.mako @@ -25,7 +25,7 @@ repository_type_to_config = service_helpers.list_session_repository_handle_types %>\ <%block filter="common_helpers.os_conditional_compile_block(config)">\ #include "${module_name}/${module_name}_service_registrar.h" -% if config.get("use_moniker_service", False): +% if config.get("has_streaming_api", False): #include "${module_name}/${module_name}_service.h" % endif \ @@ -73,7 +73,7 @@ std::shared_ptr>> register_all_services( config = driver["config"] namespace = f"{config['namespace_component']}_grpc" %>\ -% if config.get("use_moniker_service", False): +% if config.get("has_streaming_api", False): <%block filter="common_helpers.os_conditional_compile_block(config)">\ ${namespace}::RegisterMonikers(); \ diff --git a/source/codegen/templates/service.cpp.mako b/source/codegen/templates/service.cpp.mako index 45ddf702f..e4f467ceb 100644 --- a/source/codegen/templates/service.cpp.mako +++ b/source/codegen/templates/service.cpp.mako @@ -13,7 +13,7 @@ custom_types = common_helpers.get_custom_types(config) has_async_functions = any(service_helpers.get_async_functions(functions)) has_two_dimension_functions = any(service_helpers.get_functions_with_two_dimension_param(functions)) function_names = service_helpers.filter_proto_rpc_functions_to_generate(functions) -data_moniker_functions = common_helpers.filter_data_moniker_functions(functions) +streaming_functions = common_helpers.filter_streaming_functions(functions) # If there are any non-mockable functions, we need to call the library directly, which # means we need another include file any_non_mockable_functions = any(not common_helpers.can_mock_function(functions[name]['parameters']) for name in function_names) @@ -52,7 +52,7 @@ resource_repository_deps = service_helpers.get_driver_shared_resource_repository % if any_non_mockable_functions: #include "${module_name}_library.h" % endif -% if data_moniker_functions: +% if streaming_functions: #include #include % endif @@ -105,11 +105,11 @@ namespace ${config["namespace_component"]}_grpc { } % endif -% if data_moniker_functions: +% if streaming_functions: void RegisterMoniker() { % for function_name in service_helpers.filter_proto_rpc_functions_to_generate(functions): -% if function_name in data_moniker_functions: +% if function_name in streaming_functions: ${mako_helper.register_moniker_functions(function_name)}\ % endif % endfor @@ -125,7 +125,7 @@ ${mako_helper.register_moniker_functions(function_name)}\ response_type = service_helpers.get_response_type(method_name) is_async_streaming = common_helpers.has_async_streaming_response(function_data) %>\ -% if function_name in data_moniker_functions: +% if function_name in streaming_functions: ${mako_helper.define_streaming_api(function_name=function_name, function_data=function_data, parameters=parameters)}\ % else: //--------------------------------------------------------------------- diff --git a/source/codegen/templates/service.h.mako b/source/codegen/templates/service.h.mako index 614c6e9c0..3cadabaf5 100644 --- a/source/codegen/templates/service.h.mako +++ b/source/codegen/templates/service.h.mako @@ -17,7 +17,7 @@ custom_types = common_helpers.get_custom_types(config) (input_custom_types, output_custom_types) = common_helpers.get_input_and_output_custom_types(config, functions) resource_repository_deps = service_helpers.get_driver_shared_resource_repository_ptr_deps(config, functions) resource_handle_types = service_helpers.get_resource_handle_types(config) -data_moniker_functions = common_helpers.filter_data_moniker_functions(functions) +streaming_functions = common_helpers.filter_streaming_functions(functions) async_functions = service_helpers.get_async_functions(functions) has_async_functions = any(async_functions) @@ -60,10 +60,10 @@ struct ${service_class_prefix}FeatureToggles bool ${service_helpers.get_toggle_member_name(toggle)}; % endfor }; -% if config.get("use_moniker_service", False): +% if config.get("has_streaming_api", False): void RegisterMonikers(); -% for function in data_moniker_functions: +% for function in streaming_functions: <% method_name = common_helpers.get_data_moniker_function_name(function, functions[function]) %>\ From b8e5c490f93d294ca9709b11217bdfb976d01d3a Mon Sep 17 00:00:00 2001 From: Ayush Mehra Date: Tue, 5 Nov 2024 01:46:51 -0800 Subject: [PATCH 15/34] resolving comments --- generated/register_all_services.cpp | 9 ++++++--- source/codegen/common_helpers.py | 4 +--- source/codegen/metadata/nifpga/config.py | 2 -- source/codegen/service_helpers.py | 4 +--- source/codegen/templates/proto.mako | 2 +- .../codegen/templates/register_all_services.cpp.mako | 10 ++++++---- source/codegen/templates/service.h.mako | 2 +- 7 files changed, 16 insertions(+), 17 deletions(-) diff --git a/generated/register_all_services.cpp b/generated/register_all_services.cpp index ed31208ed..48f2c55cb 100644 --- a/generated/register_all_services.cpp +++ b/generated/register_all_services.cpp @@ -93,9 +93,11 @@ std::shared_ptr>> register_all_services( auto session_repository = std::make_shared(); service_vector->push_back(session_repository); nidevice_grpc::register_core_services(service_vector, server_builder, session_repository, feature_toggles); - auto moniker_service = std::make_shared(); - server_builder.RegisterService(moniker_service.get()); - service_vector->push_back(moniker_service); + if (ni::data_monikers::is_sideband_streaming_enabled(feature_toggles)) { + auto moniker_service = std::make_shared(); + server_builder.RegisterService(moniker_service.get()); + service_vector->push_back(moniker_service); + } auto task_handle_repository = std::make_shared>(session_repository); auto vi_session_repository = std::make_shared>(session_repository); @@ -331,6 +333,7 @@ std::shared_ptr>> register_all_services( vi_session_repository, vi_object_repository, feature_toggles)); + nifpga_grpc::RegisterMonikers(); return service_vector; diff --git a/source/codegen/common_helpers.py b/source/codegen/common_helpers.py index 035cda849..f6870b38f 100644 --- a/source/codegen/common_helpers.py +++ b/source/codegen/common_helpers.py @@ -1206,9 +1206,7 @@ def get_params_needing_initialization(parameters: List[dict]) -> List[dict]: def filter_streaming_functions(functions): """Return function metadata only for functions that use the data moniker service.""" - return [ - name for name, function in functions.items() if function.get("is_streaming_api", False) - ] + return [name for name, function in functions.items() if function.get("is_streaming_api", False)] def get_data_moniker_function_name(function_name, function_data): diff --git a/source/codegen/metadata/nifpga/config.py b/source/codegen/metadata/nifpga/config.py index 8a2dce1e9..eba3bd69d 100644 --- a/source/codegen/metadata/nifpga/config.py +++ b/source/codegen/metadata/nifpga/config.py @@ -32,8 +32,6 @@ 'NiFpga_FifoProperty': 'uint32', }, 'has_streaming_api': True, - 'use_dynload_msvc': True, - 'use_protobuf_arenas': True, 'custom_types': [], 'library_info': { 'Linux': { diff --git a/source/codegen/service_helpers.py b/source/codegen/service_helpers.py index 0f27fae0f..8ccccf7b6 100644 --- a/source/codegen/service_helpers.py +++ b/source/codegen/service_helpers.py @@ -318,9 +318,7 @@ def filter_api_functions(functions, only_mockable_functions=True): """Filter function metadata to only include those to be generated into the API library.""" def filter_function(function): - if function.get("codegen_method", "") == "no" or function.get( - "is_streaming_api", False - ): + if function.get("codegen_method", "") == "no" or function.get("is_streaming_api", False): return False if only_mockable_functions and not common_helpers.can_mock_function(function["parameters"]): return False diff --git a/source/codegen/templates/proto.mako b/source/codegen/templates/proto.mako index f49d5f894..c7259350e 100644 --- a/source/codegen/templates/proto.mako +++ b/source/codegen/templates/proto.mako @@ -21,7 +21,7 @@ additional_protos.extend(external_proto_deps) //--------------------------------------------------------------------- syntax = "proto3"; -% if config.get("use_protobuf_arenas", False): +% if config.get("has_streaming_api", False): option cc_enable_arenas = true; % endif option java_multiple_files = true; diff --git a/source/codegen/templates/register_all_services.cpp.mako b/source/codegen/templates/register_all_services.cpp.mako index 600eb2449..3c704f0cc 100644 --- a/source/codegen/templates/register_all_services.cpp.mako +++ b/source/codegen/templates/register_all_services.cpp.mako @@ -42,9 +42,11 @@ std::shared_ptr>> register_all_services( auto session_repository = std::make_shared(); service_vector->push_back(session_repository); nidevice_grpc::register_core_services(service_vector, server_builder, session_repository, feature_toggles); - auto moniker_service = std::make_shared(); - server_builder.RegisterService(moniker_service.get()); - service_vector->push_back(moniker_service); + if (ni::data_monikers::is_sideband_streaming_enabled(feature_toggles)) { + auto moniker_service = std::make_shared(); + server_builder.RegisterService(moniker_service.get()); + service_vector->push_back(moniker_service); + } % for type_name, config in repository_type_to_config.items(): <%block filter="common_helpers.os_conditional_compile_block(config)">\ @@ -74,7 +76,7 @@ std::shared_ptr>> register_all_services( namespace = f"{config['namespace_component']}_grpc" %>\ % if config.get("has_streaming_api", False): -<%block filter="common_helpers.os_conditional_compile_block(config)">\ +<%block filter="common_helpers.os_conditional_compile_block(config)"> ${namespace}::RegisterMonikers(); \ % endif diff --git a/source/codegen/templates/service.h.mako b/source/codegen/templates/service.h.mako index 3cadabaf5..9715422aa 100644 --- a/source/codegen/templates/service.h.mako +++ b/source/codegen/templates/service.h.mako @@ -67,7 +67,7 @@ void RegisterMonikers(); <% method_name = common_helpers.get_data_moniker_function_name(function, functions[function]) %>\ -% if config.get("use_protobuf_arenas", False): +% if config.get("has_streaming_api", False): ::grpc::Status ${method_name}(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData); % else: ::grpc::Status ${method_name}(void* data, google::protobuf::Any& packedData); From a90f681370ad9178ff40605a1cc19512670ee5f8 Mon Sep 17 00:00:00 2001 From: Ayush Mehra Date: Tue, 5 Nov 2024 05:47:49 -0800 Subject: [PATCH 16/34] review comments --- generated/nifpga/nifpga_service.cpp | 1 - generated/nifpga/nifpga_service.h | 2 +- generated/register_all_services.cpp | 2 +- source/codegen/common_helpers.py | 2 +- source/codegen/service_helpers.py | 5 ----- .../codegen/templates/register_all_services.cpp.mako | 2 +- source/codegen/templates/service.cpp.mako | 11 +++++------ source/codegen/templates/service.h.mako | 10 +++++----- source/codegen/templates/service_helpers.mako | 4 ++-- 9 files changed, 16 insertions(+), 23 deletions(-) diff --git a/generated/nifpga/nifpga_service.cpp b/generated/nifpga/nifpga_service.cpp index b5de426cc..a3df9867d 100644 --- a/generated/nifpga/nifpga_service.cpp +++ b/generated/nifpga/nifpga_service.cpp @@ -12,7 +12,6 @@ #include #include #include -#include #include namespace nifpga_grpc { diff --git a/generated/nifpga/nifpga_service.h b/generated/nifpga/nifpga_service.h index 708417050..0203e7071 100644 --- a/generated/nifpga/nifpga_service.h +++ b/generated/nifpga/nifpga_service.h @@ -30,7 +30,7 @@ struct NiFpgaFeatureToggles bool is_enabled; }; -void RegisterMonikers(); +void RegisterMonikerEndpoints(); ::grpc::Status MonikerReadArrayI16(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData); ::grpc::Status MonikerReadArrayI32(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData); diff --git a/generated/register_all_services.cpp b/generated/register_all_services.cpp index 48f2c55cb..9f3c1b311 100644 --- a/generated/register_all_services.cpp +++ b/generated/register_all_services.cpp @@ -334,7 +334,7 @@ std::shared_ptr>> register_all_services( vi_object_repository, feature_toggles)); - nifpga_grpc::RegisterMonikers(); + nifpga_grpc::RegisterMonikerEndpoints(); return service_vector; } diff --git a/source/codegen/common_helpers.py b/source/codegen/common_helpers.py index f6870b38f..ec670a05d 100644 --- a/source/codegen/common_helpers.py +++ b/source/codegen/common_helpers.py @@ -1209,6 +1209,6 @@ def filter_streaming_functions(functions): return [name for name, function in functions.items() if function.get("is_streaming_api", False)] -def get_data_moniker_function_name(function_name, function_data): +def get_data_moniker_function_name(function_name): """Return the corresponding moniker function name for the given C API function.""" return function_name.replace("Begin", "Moniker") diff --git a/source/codegen/service_helpers.py b/source/codegen/service_helpers.py index 8ccccf7b6..bb885b41f 100644 --- a/source/codegen/service_helpers.py +++ b/source/codegen/service_helpers.py @@ -709,11 +709,6 @@ def get_protobuf_cpplib_type(grpc_type: str) -> str: return grpc_type -def create_moniker_function_name(function_name: str) -> str: - """Get the function name for the moniker function.""" - return f"Moniker{function_name.replace('Begin', '')}" - - def get_coerced_type_and_presence(streaming_type: str) -> tuple: """Get the coerced type and check if the coerced type is present in the type map. diff --git a/source/codegen/templates/register_all_services.cpp.mako b/source/codegen/templates/register_all_services.cpp.mako index 3c704f0cc..a25a97a8e 100644 --- a/source/codegen/templates/register_all_services.cpp.mako +++ b/source/codegen/templates/register_all_services.cpp.mako @@ -77,7 +77,7 @@ std::shared_ptr>> register_all_services( %>\ % if config.get("has_streaming_api", False): <%block filter="common_helpers.os_conditional_compile_block(config)"> - ${namespace}::RegisterMonikers(); + ${namespace}::RegisterMonikerEndpoints(); \ % endif % endfor diff --git a/source/codegen/templates/service.cpp.mako b/source/codegen/templates/service.cpp.mako index e4f467ceb..08befa151 100644 --- a/source/codegen/templates/service.cpp.mako +++ b/source/codegen/templates/service.cpp.mako @@ -13,7 +13,7 @@ custom_types = common_helpers.get_custom_types(config) has_async_functions = any(service_helpers.get_async_functions(functions)) has_two_dimension_functions = any(service_helpers.get_functions_with_two_dimension_param(functions)) function_names = service_helpers.filter_proto_rpc_functions_to_generate(functions) -streaming_functions = common_helpers.filter_streaming_functions(functions) +data_moniker_functions = common_helpers.filter_streaming_functions(functions) # If there are any non-mockable functions, we need to call the library directly, which # means we need another include file any_non_mockable_functions = any(not common_helpers.can_mock_function(functions[name]['parameters']) for name in function_names) @@ -52,8 +52,7 @@ resource_repository_deps = service_helpers.get_driver_shared_resource_repository % if any_non_mockable_functions: #include "${module_name}_library.h" % endif -% if streaming_functions: -#include +% if data_moniker_functions: #include % endif @@ -105,11 +104,11 @@ namespace ${config["namespace_component"]}_grpc { } % endif -% if streaming_functions: +% if data_moniker_functions: void RegisterMoniker() { % for function_name in service_helpers.filter_proto_rpc_functions_to_generate(functions): -% if function_name in streaming_functions: +% if function_name in data_moniker_functions: ${mako_helper.register_moniker_functions(function_name)}\ % endif % endfor @@ -125,7 +124,7 @@ ${mako_helper.register_moniker_functions(function_name)}\ response_type = service_helpers.get_response_type(method_name) is_async_streaming = common_helpers.has_async_streaming_response(function_data) %>\ -% if function_name in streaming_functions: +% if function_name in data_moniker_functions: ${mako_helper.define_streaming_api(function_name=function_name, function_data=function_data, parameters=parameters)}\ % else: //--------------------------------------------------------------------- diff --git a/source/codegen/templates/service.h.mako b/source/codegen/templates/service.h.mako index 9715422aa..2a4ec2cc9 100644 --- a/source/codegen/templates/service.h.mako +++ b/source/codegen/templates/service.h.mako @@ -17,7 +17,7 @@ custom_types = common_helpers.get_custom_types(config) (input_custom_types, output_custom_types) = common_helpers.get_input_and_output_custom_types(config, functions) resource_repository_deps = service_helpers.get_driver_shared_resource_repository_ptr_deps(config, functions) resource_handle_types = service_helpers.get_resource_handle_types(config) -streaming_functions = common_helpers.filter_streaming_functions(functions) +data_moniker_functions = common_helpers.filter_streaming_functions(functions) async_functions = service_helpers.get_async_functions(functions) has_async_functions = any(async_functions) @@ -60,12 +60,12 @@ struct ${service_class_prefix}FeatureToggles bool ${service_helpers.get_toggle_member_name(toggle)}; % endfor }; -% if config.get("has_streaming_api", False): -void RegisterMonikers(); +% if data_moniker_functions: +void RegisterMonikerEndpoints(); -% for function in streaming_functions: +% for function in data_moniker_functions: <% - method_name = common_helpers.get_data_moniker_function_name(function, functions[function]) + method_name = common_helpers.get_data_moniker_function_name(function) %>\ % if config.get("has_streaming_api", False): ::grpc::Status ${method_name}(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData); diff --git a/source/codegen/templates/service_helpers.mako b/source/codegen/templates/service_helpers.mako index 88c0a4318..7ebbc4598 100644 --- a/source/codegen/templates/service_helpers.mako +++ b/source/codegen/templates/service_helpers.mako @@ -272,7 +272,7 @@ ${populate_response(function_data=function_data, parameters=parameters)}\ <%def name="register_moniker_functions(function_name)"> -<% moniker_function_name = service_helpers.create_moniker_function_name(function_name) +<% moniker_function_name = common_helpers.get_data_moniker_function_name(function_name) %> ::ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("${moniker_function_name}", ${moniker_function_name}); @@ -285,7 +285,7 @@ ${populate_response(function_data=function_data, parameters=parameters)}\ request_param = service_helpers.get_request_param(function_name) response_param = service_helpers.get_response_param(function_name) struct_name = f"Moniker{function_name.replace('Begin', '')}Data" if function_name.startswith('Begin') else f"Moniker{function_name}Data" - moniker_function_name = service_helpers.create_moniker_function_name(function_name) + moniker_function_name = common_helpers.get_data_moniker_function_name(function_name) c_api_name = service_helpers.get_c_api_name(function_name) streaming_param = common_helpers.get_streaming_parameter(parameters) streaming_type = streaming_param['type'] From b4e473d72fb0ac7c0423cc240b5594ea21dab4eb Mon Sep 17 00:00:00 2001 From: Ayush Mehra Date: Tue, 5 Nov 2024 19:47:59 -0800 Subject: [PATCH 17/34] review comments --- generated/nifpga/nifpga_service.cpp | 2094 +++++++++-------- generated/nifpga/nifpga_service.h | 1 + source/codegen/templates/service.cpp.mako | 25 +- source/codegen/templates/service.h.mako | 1 + source/codegen/templates/service_helpers.mako | 93 +- 5 files changed, 1158 insertions(+), 1056 deletions(-) diff --git a/generated/nifpga/nifpga_service.cpp b/generated/nifpga/nifpga_service.cpp index a3df9867d..539bd2695 100644 --- a/generated/nifpga/nifpga_service.cpp +++ b/generated/nifpga/nifpga_service.cpp @@ -22,6 +22,270 @@ namespace nifpga_grpc { using nidevice_grpc::converters::convert_to_grpc; using nidevice_grpc::converters::MatchState; + struct MonikerReadArrayI16Data + { + NiFpga_Session session; + uint32_t indicator; + size_t size; + nifpga_grpc::ArrayI32Data data; + std::shared_ptr library; + }; + + struct MonikerReadArrayI32Data + { + NiFpga_Session session; + uint32_t indicator; + size_t size; + nifpga_grpc::ArrayI32Data data; + std::shared_ptr library; + }; + + struct MonikerReadArrayI64Data + { + NiFpga_Session session; + uint32_t indicator; + size_t size; + nifpga_grpc::ArrayI64Data data; + std::shared_ptr library; + }; + + struct MonikerReadArrayI8Data + { + NiFpga_Session session; + uint32_t indicator; + size_t size; + nifpga_grpc::ArrayI32Data data; + std::shared_ptr library; + }; + + struct MonikerReadArrayU16Data + { + NiFpga_Session session; + uint32_t indicator; + size_t size; + nifpga_grpc::ArrayU32Data data; + std::shared_ptr library; + }; + + struct MonikerReadArrayU32Data + { + NiFpga_Session session; + uint32_t indicator; + size_t size; + nifpga_grpc::ArrayU32Data data; + std::shared_ptr library; + }; + + struct MonikerReadArrayU64Data + { + NiFpga_Session session; + uint32_t indicator; + size_t size; + nifpga_grpc::ArrayU64Data data; + std::shared_ptr library; + }; + + struct MonikerReadArrayU8Data + { + NiFpga_Session session; + uint32_t indicator; + size_t size; + nifpga_grpc::ArrayU32Data data; + std::shared_ptr library; + }; + + struct MonikerReadI16Data + { + NiFpga_Session session; + uint32_t indicator; + nifpga_grpc::I32Data data; + std::shared_ptr library; + }; + + struct MonikerReadI32Data + { + NiFpga_Session session; + uint32_t indicator; + nifpga_grpc::I32Data data; + std::shared_ptr library; + }; + + struct MonikerReadI64Data + { + NiFpga_Session session; + uint32_t indicator; + nifpga_grpc::I64Data data; + std::shared_ptr library; + }; + + struct MonikerReadI8Data + { + NiFpga_Session session; + uint32_t indicator; + nifpga_grpc::I32Data data; + std::shared_ptr library; + }; + + struct MonikerReadU16Data + { + NiFpga_Session session; + uint32_t indicator; + nifpga_grpc::U32Data data; + std::shared_ptr library; + }; + + struct MonikerReadU32Data + { + NiFpga_Session session; + uint32_t indicator; + nifpga_grpc::U32Data data; + std::shared_ptr library; + }; + + struct MonikerReadU64Data + { + NiFpga_Session session; + uint32_t indicator; + nifpga_grpc::U64Data data; + std::shared_ptr library; + }; + + struct MonikerReadU8Data + { + NiFpga_Session session; + uint32_t indicator; + nifpga_grpc::U32Data data; + std::shared_ptr library; + }; + + struct MonikerWriteArrayI16Data + { + NiFpga_Session session; + uint32_t control; + nifpga_grpc::ArrayI32Data data; + std::shared_ptr library; + }; + + struct MonikerWriteArrayI32Data + { + NiFpga_Session session; + uint32_t control; + nifpga_grpc::ArrayI32Data data; + std::shared_ptr library; + }; + + struct MonikerWriteArrayI64Data + { + NiFpga_Session session; + uint32_t control; + nifpga_grpc::ArrayI64Data data; + std::shared_ptr library; + }; + + struct MonikerWriteArrayI8Data + { + NiFpga_Session session; + uint32_t control; + nifpga_grpc::ArrayI32Data data; + std::shared_ptr library; + }; + + struct MonikerWriteArrayU16Data + { + NiFpga_Session session; + uint32_t control; + nifpga_grpc::ArrayU32Data data; + std::shared_ptr library; + }; + + struct MonikerWriteArrayU32Data + { + NiFpga_Session session; + uint32_t control; + nifpga_grpc::ArrayU32Data data; + std::shared_ptr library; + }; + + struct MonikerWriteArrayU64Data + { + NiFpga_Session session; + uint32_t control; + nifpga_grpc::ArrayU64Data data; + std::shared_ptr library; + }; + + struct MonikerWriteArrayU8Data + { + NiFpga_Session session; + uint32_t control; + nifpga_grpc::ArrayU32Data data; + std::shared_ptr library; + }; + + struct MonikerWriteI16Data + { + NiFpga_Session session; + uint32_t control; + nifpga_grpc::I32Data data; + std::shared_ptr library; + }; + + struct MonikerWriteI32Data + { + NiFpga_Session session; + uint32_t control; + nifpga_grpc::I32Data data; + std::shared_ptr library; + }; + + struct MonikerWriteI64Data + { + NiFpga_Session session; + uint32_t control; + nifpga_grpc::I64Data data; + std::shared_ptr library; + }; + + struct MonikerWriteI8Data + { + NiFpga_Session session; + uint32_t control; + nifpga_grpc::I32Data data; + std::shared_ptr library; + }; + + struct MonikerWriteU16Data + { + NiFpga_Session session; + uint32_t control; + nifpga_grpc::U32Data data; + std::shared_ptr library; + }; + + struct MonikerWriteU32Data + { + NiFpga_Session session; + uint32_t control; + nifpga_grpc::U32Data data; + std::shared_ptr library; + }; + + struct MonikerWriteU64Data + { + NiFpga_Session session; + uint32_t control; + nifpga_grpc::U64Data data; + std::shared_ptr library; + }; + + struct MonikerWriteU8Data + { + NiFpga_Session session; + uint32_t control; + nifpga_grpc::U32Data data; + std::shared_ptr library; + }; + NiFpgaService::NiFpgaService( LibrarySharedPtr library, ResourceRepositorySharedPtr resource_repository, @@ -42,7 +306,7 @@ namespace nifpga_grpc { return status >= 0; } -void RegisterMoniker() +void RegisterMonikerEndpoints() { ::ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerReadArrayI16", MonikerReadArrayI16); @@ -67,47 +331,807 @@ void RegisterMoniker() ::ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerReadI64", MonikerReadI64); - ::ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerReadI8", MonikerReadI8); + ::ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerReadI8", MonikerReadI8); + + ::ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerReadU16", MonikerReadU16); + + ::ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerReadU32", MonikerReadU32); + + ::ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerReadU64", MonikerReadU64); + + ::ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerReadU8", MonikerReadU8); + + ::ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerWriteArrayI16", MonikerWriteArrayI16); + + ::ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerWriteArrayI32", MonikerWriteArrayI32); + + ::ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerWriteArrayI64", MonikerWriteArrayI64); + + ::ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerWriteArrayI8", MonikerWriteArrayI8); + + ::ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerWriteArrayU16", MonikerWriteArrayU16); + + ::ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerWriteArrayU32", MonikerWriteArrayU32); + + ::ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerWriteArrayU64", MonikerWriteArrayU64); + + ::ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerWriteArrayU8", MonikerWriteArrayU8); + + ::ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerWriteI16", MonikerWriteI16); + + ::ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerWriteI32", MonikerWriteI32); + + ::ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerWriteI64", MonikerWriteI64); + + ::ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerWriteI8", MonikerWriteI8); + + ::ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerWriteU16", MonikerWriteU16); + + ::ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerWriteU32", MonikerWriteU32); + + ::ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerWriteU64", MonikerWriteU64); + + ::ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerWriteU8", MonikerWriteU8); +} + +::grpc::Status MonikerReadArrayI16(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData) +{ + MonikerReadArrayI16Data* function_data = (MonikerReadArrayI16Data*)data; + auto library = function_data->library; + + auto session = function_data->session; + auto indicator = function_data->indicator; + auto size = function_data->size; + + std::vector array(size); + auto status = library->ReadArrayI16(session, indicator, array.data(), size); + if (status >= 0) { + std::transform( + array.begin(), + array.begin() + size, + function_data->data.mutable_value()->begin(), + [&](auto x) { + return x; + }); + packedData.PackFrom(function_data->data); + } + if (status < 0) { + std::cout << "MonikerReadArrayI16 error: " << status << std::endl; + } + return ::grpc::Status::OK; +} + +::grpc::Status MonikerReadArrayI32(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData) +{ + MonikerReadArrayI32Data* function_data = (MonikerReadArrayI32Data*)data; + auto library = function_data->library; + + auto session = function_data->session; + auto indicator = function_data->indicator; + auto size = function_data->size; + + int32_t* array = new int32_t[size]; + auto status = library->ReadArrayI32(session, indicator, array, size); + if (status >= 0) { + std::transform( + array, + array + size, + function_data->data.mutable_value()->begin(), + [&](auto x) { + return x; + }); + packedData.PackFrom(function_data->data); + } + if (status < 0) { + std::cout << "MonikerReadArrayI32 error: " << status << std::endl; + } + return ::grpc::Status::OK; +} + +::grpc::Status MonikerReadArrayI64(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData) +{ + MonikerReadArrayI64Data* function_data = (MonikerReadArrayI64Data*)data; + auto library = function_data->library; + + auto session = function_data->session; + auto indicator = function_data->indicator; + auto size = function_data->size; + + int64_t* array = new int64_t[size]; + auto status = library->ReadArrayI64(session, indicator, array, size); + if (status >= 0) { + std::transform( + array, + array + size, + function_data->data.mutable_value()->begin(), + [&](auto x) { + return x; + }); + packedData.PackFrom(function_data->data); + } + if (status < 0) { + std::cout << "MonikerReadArrayI64 error: " << status << std::endl; + } + return ::grpc::Status::OK; +} + +::grpc::Status MonikerReadArrayI8(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData) +{ + MonikerReadArrayI8Data* function_data = (MonikerReadArrayI8Data*)data; + auto library = function_data->library; + + auto session = function_data->session; + auto indicator = function_data->indicator; + auto size = function_data->size; + + std::vector array(size); + auto status = library->ReadArrayI8(session, indicator, array.data(), size); + if (status >= 0) { + std::transform( + array.begin(), + array.begin() + size, + function_data->data.mutable_value()->begin(), + [&](auto x) { + return x; + }); + packedData.PackFrom(function_data->data); + } + if (status < 0) { + std::cout << "MonikerReadArrayI8 error: " << status << std::endl; + } + return ::grpc::Status::OK; +} + +::grpc::Status MonikerReadArrayU16(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData) +{ + MonikerReadArrayU16Data* function_data = (MonikerReadArrayU16Data*)data; + auto library = function_data->library; + + auto session = function_data->session; + auto indicator = function_data->indicator; + auto size = function_data->size; + + std::vector array(size); + auto status = library->ReadArrayU16(session, indicator, array.data(), size); + if (status >= 0) { + std::transform( + array.begin(), + array.begin() + size, + function_data->data.mutable_value()->begin(), + [&](auto x) { + return x; + }); + packedData.PackFrom(function_data->data); + } + if (status < 0) { + std::cout << "MonikerReadArrayU16 error: " << status << std::endl; + } + return ::grpc::Status::OK; +} + +::grpc::Status MonikerReadArrayU32(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData) +{ + MonikerReadArrayU32Data* function_data = (MonikerReadArrayU32Data*)data; + auto library = function_data->library; + + auto session = function_data->session; + auto indicator = function_data->indicator; + auto size = function_data->size; + + uint32_t* array = new uint32_t[size]; + auto status = library->ReadArrayU32(session, indicator, array, size); + if (status >= 0) { + std::transform( + array, + array + size, + function_data->data.mutable_value()->begin(), + [&](auto x) { + return x; + }); + packedData.PackFrom(function_data->data); + } + if (status < 0) { + std::cout << "MonikerReadArrayU32 error: " << status << std::endl; + } + return ::grpc::Status::OK; +} + +::grpc::Status MonikerReadArrayU64(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData) +{ + MonikerReadArrayU64Data* function_data = (MonikerReadArrayU64Data*)data; + auto library = function_data->library; + + auto session = function_data->session; + auto indicator = function_data->indicator; + auto size = function_data->size; + + uint64_t* array = new uint64_t[size]; + auto status = library->ReadArrayU64(session, indicator, array, size); + if (status >= 0) { + std::transform( + array, + array + size, + function_data->data.mutable_value()->begin(), + [&](auto x) { + return x; + }); + packedData.PackFrom(function_data->data); + } + if (status < 0) { + std::cout << "MonikerReadArrayU64 error: " << status << std::endl; + } + return ::grpc::Status::OK; +} + +::grpc::Status MonikerReadArrayU8(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData) +{ + MonikerReadArrayU8Data* function_data = (MonikerReadArrayU8Data*)data; + auto library = function_data->library; + + auto session = function_data->session; + auto indicator = function_data->indicator; + auto size = function_data->size; + + std::vector array(size); + auto status = library->ReadArrayU8(session, indicator, array.data(), size); + if (status >= 0) { + std::transform( + array.begin(), + array.begin() + size, + function_data->data.mutable_value()->begin(), + [&](auto x) { + return x; + }); + packedData.PackFrom(function_data->data); + } + if (status < 0) { + std::cout << "MonikerReadArrayU8 error: " << status << std::endl; + } + return ::grpc::Status::OK; +} + +::grpc::Status MonikerReadI16(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData) +{ + MonikerReadI16Data* function_data = (MonikerReadI16Data*)data; + auto library = function_data->library; + + auto session = function_data->session; + auto indicator = function_data->indicator; + + int16_t value = 0; + auto status = library->ReadI16(session, indicator, &value); + function_data->data.set_value(value); + if (status >= 0) { + packedData.PackFrom(function_data->data); + } + if (status < 0) { + std::cout << "MonikerReadI16 error: " << status << std::endl; + } + return ::grpc::Status::OK; +} + +::grpc::Status MonikerReadI32(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData) +{ + MonikerReadI32Data* function_data = (MonikerReadI32Data*)data; + auto library = function_data->library; + + auto session = function_data->session; + auto indicator = function_data->indicator; + + int32_t value = 0; + auto status = library->ReadI32(session, indicator, &value); + function_data->data.set_value(value); + if (status >= 0) { + packedData.PackFrom(function_data->data); + } + if (status < 0) { + std::cout << "MonikerReadI32 error: " << status << std::endl; + } + return ::grpc::Status::OK; +} + +::grpc::Status MonikerReadI64(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData) +{ + MonikerReadI64Data* function_data = (MonikerReadI64Data*)data; + auto library = function_data->library; + + auto session = function_data->session; + auto indicator = function_data->indicator; + + int64_t value = 0; + auto status = library->ReadI64(session, indicator, &value); + function_data->data.set_value(value); + if (status >= 0) { + packedData.PackFrom(function_data->data); + } + if (status < 0) { + std::cout << "MonikerReadI64 error: " << status << std::endl; + } + return ::grpc::Status::OK; +} + +::grpc::Status MonikerReadI8(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData) +{ + MonikerReadI8Data* function_data = (MonikerReadI8Data*)data; + auto library = function_data->library; + + auto session = function_data->session; + auto indicator = function_data->indicator; + + int8_t value = 0; + auto status = library->ReadI8(session, indicator, &value); + function_data->data.set_value(value); + if (status >= 0) { + packedData.PackFrom(function_data->data); + } + if (status < 0) { + std::cout << "MonikerReadI8 error: " << status << std::endl; + } + return ::grpc::Status::OK; +} + +::grpc::Status MonikerReadU16(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData) +{ + MonikerReadU16Data* function_data = (MonikerReadU16Data*)data; + auto library = function_data->library; + + auto session = function_data->session; + auto indicator = function_data->indicator; + + uint16_t value = 0; + auto status = library->ReadU16(session, indicator, &value); + function_data->data.set_value(value); + if (status >= 0) { + packedData.PackFrom(function_data->data); + } + if (status < 0) { + std::cout << "MonikerReadU16 error: " << status << std::endl; + } + return ::grpc::Status::OK; +} + +::grpc::Status MonikerReadU32(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData) +{ + MonikerReadU32Data* function_data = (MonikerReadU32Data*)data; + auto library = function_data->library; + + auto session = function_data->session; + auto indicator = function_data->indicator; + + uint32_t value = 0; + auto status = library->ReadU32(session, indicator, &value); + function_data->data.set_value(value); + if (status >= 0) { + packedData.PackFrom(function_data->data); + } + if (status < 0) { + std::cout << "MonikerReadU32 error: " << status << std::endl; + } + return ::grpc::Status::OK; +} + +::grpc::Status MonikerReadU64(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData) +{ + MonikerReadU64Data* function_data = (MonikerReadU64Data*)data; + auto library = function_data->library; + + auto session = function_data->session; + auto indicator = function_data->indicator; + + uint64_t value = 0; + auto status = library->ReadU64(session, indicator, &value); + function_data->data.set_value(value); + if (status >= 0) { + packedData.PackFrom(function_data->data); + } + if (status < 0) { + std::cout << "MonikerReadU64 error: " << status << std::endl; + } + return ::grpc::Status::OK; +} + +::grpc::Status MonikerReadU8(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData) +{ + MonikerReadU8Data* function_data = (MonikerReadU8Data*)data; + auto library = function_data->library; + + auto session = function_data->session; + auto indicator = function_data->indicator; + + uint8_t value = 0; + auto status = library->ReadU8(session, indicator, &value); + function_data->data.set_value(value); + if (status >= 0) { + packedData.PackFrom(function_data->data); + } + if (status < 0) { + std::cout << "MonikerReadU8 error: " << status << std::endl; + } + return ::grpc::Status::OK; +} + +::grpc::Status MonikerWriteArrayI16(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData) +{ + MonikerWriteArrayI16Data* function_data = (MonikerWriteArrayI16Data*)data; + auto library = function_data->library; + + auto session = function_data->session; + auto control = function_data->control; + + ArrayI32Data arrayi32data_message; + packedData.UnpackTo(&arrayi32data_message); + auto data_array = arrayi32data_message.value(); + auto array = std::vector(); + auto size = data_array.size(); + array.reserve(size); + std::transform( + data_array.begin(), + data_array.end(), + std::back_inserter(array), + [](auto x) { + if (x < std::numeric_limits::min() || x > std::numeric_limits::max()) { + std::string message("value " + std::to_string(x) + " doesn't fit in datatype int16_t"); + throw nidevice_grpc::ValueOutOfRangeException(message); + } + return static_cast(x); + }); + + auto status = library->WriteArrayI16(session, control, array.data(), size); + if (status < 0) { + std::cout << "MonikerWriteArrayI16 error: " << status << std::endl; + } + return ::grpc::Status::OK; +} + +::grpc::Status MonikerWriteArrayI32(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData) +{ + MonikerWriteArrayI32Data* function_data = (MonikerWriteArrayI32Data*)data; + auto library = function_data->library; + + auto session = function_data->session; + auto control = function_data->control; + + ArrayI32Data arrayi32data_message; + packedData.UnpackTo(&arrayi32data_message); + auto data_array = arrayi32data_message.value(); + auto array = const_cast(arrayi32data_message.value().data()); + auto size = data_array.size(); + + auto status = library->WriteArrayI32(session, control, array, size); + if (status < 0) { + std::cout << "MonikerWriteArrayI32 error: " << status << std::endl; + } + return ::grpc::Status::OK; +} + +::grpc::Status MonikerWriteArrayI64(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData) +{ + MonikerWriteArrayI64Data* function_data = (MonikerWriteArrayI64Data*)data; + auto library = function_data->library; + + auto session = function_data->session; + auto control = function_data->control; + + ArrayI64Data arrayi64data_message; + packedData.UnpackTo(&arrayi64data_message); + auto data_array = arrayi64data_message.value(); + auto array = const_cast(arrayi64data_message.value().data()); + auto size = data_array.size(); + + auto status = library->WriteArrayI64(session, control, array, size); + if (status < 0) { + std::cout << "MonikerWriteArrayI64 error: " << status << std::endl; + } + return ::grpc::Status::OK; +} + +::grpc::Status MonikerWriteArrayI8(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData) +{ + MonikerWriteArrayI8Data* function_data = (MonikerWriteArrayI8Data*)data; + auto library = function_data->library; + + auto session = function_data->session; + auto control = function_data->control; + + ArrayI32Data arrayi32data_message; + packedData.UnpackTo(&arrayi32data_message); + auto data_array = arrayi32data_message.value(); + auto array = std::vector(); + auto size = data_array.size(); + array.reserve(size); + std::transform( + data_array.begin(), + data_array.end(), + std::back_inserter(array), + [](auto x) { + if (x < std::numeric_limits::min() || x > std::numeric_limits::max()) { + std::string message("value " + std::to_string(x) + " doesn't fit in datatype int8_t"); + throw nidevice_grpc::ValueOutOfRangeException(message); + } + return static_cast(x); + }); + + auto status = library->WriteArrayI8(session, control, array.data(), size); + if (status < 0) { + std::cout << "MonikerWriteArrayI8 error: " << status << std::endl; + } + return ::grpc::Status::OK; +} + +::grpc::Status MonikerWriteArrayU16(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData) +{ + MonikerWriteArrayU16Data* function_data = (MonikerWriteArrayU16Data*)data; + auto library = function_data->library; + + auto session = function_data->session; + auto control = function_data->control; + + ArrayU32Data arrayu32data_message; + packedData.UnpackTo(&arrayu32data_message); + auto data_array = arrayu32data_message.value(); + auto array = std::vector(); + auto size = data_array.size(); + array.reserve(size); + std::transform( + data_array.begin(), + data_array.end(), + std::back_inserter(array), + [](auto x) { + if (x < std::numeric_limits::min() || x > std::numeric_limits::max()) { + std::string message("value " + std::to_string(x) + " doesn't fit in datatype uint16_t"); + throw nidevice_grpc::ValueOutOfRangeException(message); + } + return static_cast(x); + }); + + auto status = library->WriteArrayU16(session, control, array.data(), size); + if (status < 0) { + std::cout << "MonikerWriteArrayU16 error: " << status << std::endl; + } + return ::grpc::Status::OK; +} + +::grpc::Status MonikerWriteArrayU32(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData) +{ + MonikerWriteArrayU32Data* function_data = (MonikerWriteArrayU32Data*)data; + auto library = function_data->library; + + auto session = function_data->session; + auto control = function_data->control; + + ArrayU32Data arrayu32data_message; + packedData.UnpackTo(&arrayu32data_message); + auto data_array = arrayu32data_message.value(); + auto array = const_cast(arrayu32data_message.value().data()); + auto size = data_array.size(); + + auto status = library->WriteArrayU32(session, control, array, size); + if (status < 0) { + std::cout << "MonikerWriteArrayU32 error: " << status << std::endl; + } + return ::grpc::Status::OK; +} - ::ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerReadU16", MonikerReadU16); +::grpc::Status MonikerWriteArrayU64(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData) +{ + MonikerWriteArrayU64Data* function_data = (MonikerWriteArrayU64Data*)data; + auto library = function_data->library; + + auto session = function_data->session; + auto control = function_data->control; + + ArrayU64Data arrayu64data_message; + packedData.UnpackTo(&arrayu64data_message); + auto data_array = arrayu64data_message.value(); + auto array = const_cast(arrayu64data_message.value().data()); + auto size = data_array.size(); - ::ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerReadU32", MonikerReadU32); + auto status = library->WriteArrayU64(session, control, array, size); + if (status < 0) { + std::cout << "MonikerWriteArrayU64 error: " << status << std::endl; + } + return ::grpc::Status::OK; +} - ::ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerReadU64", MonikerReadU64); +::grpc::Status MonikerWriteArrayU8(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData) +{ + MonikerWriteArrayU8Data* function_data = (MonikerWriteArrayU8Data*)data; + auto library = function_data->library; + + auto session = function_data->session; + auto control = function_data->control; + + ArrayU32Data arrayu32data_message; + packedData.UnpackTo(&arrayu32data_message); + auto data_array = arrayu32data_message.value(); + auto array = std::vector(); + auto size = data_array.size(); + array.reserve(size); + std::transform( + data_array.begin(), + data_array.end(), + std::back_inserter(array), + [](auto x) { + if (x < std::numeric_limits::min() || x > std::numeric_limits::max()) { + std::string message("value " + std::to_string(x) + " doesn't fit in datatype uint8_t"); + throw nidevice_grpc::ValueOutOfRangeException(message); + } + return static_cast(x); + }); - ::ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerReadU8", MonikerReadU8); + auto status = library->WriteArrayU8(session, control, array.data(), size); + if (status < 0) { + std::cout << "MonikerWriteArrayU8 error: " << status << std::endl; + } + return ::grpc::Status::OK; +} - ::ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerWriteArrayI16", MonikerWriteArrayI16); +::grpc::Status MonikerWriteI16(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData) +{ + MonikerWriteI16Data* function_data = (MonikerWriteI16Data*)data; + auto library = function_data->library; + + auto session = function_data->session; + auto control = function_data->control; + + I32Data i32data_message; + packedData.UnpackTo(&i32data_message); + int32_t value = i32data_message.value(); + if (value < std::numeric_limits::min() || value > std::numeric_limits::max()) { + std::string message("value " + std::to_string(value) + " doesn't fit in datatype int16_t"); + throw nidevice_grpc::ValueOutOfRangeException(message); + } - ::ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerWriteArrayI32", MonikerWriteArrayI32); + auto status = library->WriteI16(session, control, value); + if (status < 0) { + std::cout << "MonikerWriteI16 error: " << status << std::endl; + } + return ::grpc::Status::OK; +} - ::ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerWriteArrayI64", MonikerWriteArrayI64); +::grpc::Status MonikerWriteI32(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData) +{ + MonikerWriteI32Data* function_data = (MonikerWriteI32Data*)data; + auto library = function_data->library; + + auto session = function_data->session; + auto control = function_data->control; + + I32Data i32data_message; + packedData.UnpackTo(&i32data_message); + int32_t value = i32data_message.value(); - ::ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerWriteArrayI8", MonikerWriteArrayI8); + auto status = library->WriteI32(session, control, value); + if (status < 0) { + std::cout << "MonikerWriteI32 error: " << status << std::endl; + } + return ::grpc::Status::OK; +} - ::ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerWriteArrayU16", MonikerWriteArrayU16); +::grpc::Status MonikerWriteI64(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData) +{ + MonikerWriteI64Data* function_data = (MonikerWriteI64Data*)data; + auto library = function_data->library; + + auto session = function_data->session; + auto control = function_data->control; + + I64Data i64data_message; + packedData.UnpackTo(&i64data_message); + int64_t value = i64data_message.value(); - ::ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerWriteArrayU32", MonikerWriteArrayU32); + auto status = library->WriteI64(session, control, value); + if (status < 0) { + std::cout << "MonikerWriteI64 error: " << status << std::endl; + } + return ::grpc::Status::OK; +} - ::ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerWriteArrayU64", MonikerWriteArrayU64); +::grpc::Status MonikerWriteI8(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData) +{ + MonikerWriteI8Data* function_data = (MonikerWriteI8Data*)data; + auto library = function_data->library; + + auto session = function_data->session; + auto control = function_data->control; + + I32Data i32data_message; + packedData.UnpackTo(&i32data_message); + int32_t value = i32data_message.value(); + if (value < std::numeric_limits::min() || value > std::numeric_limits::max()) { + std::string message("value " + std::to_string(value) + " doesn't fit in datatype int8_t"); + throw nidevice_grpc::ValueOutOfRangeException(message); + } - ::ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerWriteArrayU8", MonikerWriteArrayU8); + auto status = library->WriteI8(session, control, value); + if (status < 0) { + std::cout << "MonikerWriteI8 error: " << status << std::endl; + } + return ::grpc::Status::OK; +} - ::ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerWriteI16", MonikerWriteI16); +::grpc::Status MonikerWriteU16(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData) +{ + MonikerWriteU16Data* function_data = (MonikerWriteU16Data*)data; + auto library = function_data->library; + + auto session = function_data->session; + auto control = function_data->control; + + U32Data u32data_message; + packedData.UnpackTo(&u32data_message); + uint32_t value = u32data_message.value(); + if (value < std::numeric_limits::min() || value > std::numeric_limits::max()) { + std::string message("value " + std::to_string(value) + " doesn't fit in datatype uint16_t"); + throw nidevice_grpc::ValueOutOfRangeException(message); + } - ::ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerWriteI32", MonikerWriteI32); + auto status = library->WriteU16(session, control, value); + if (status < 0) { + std::cout << "MonikerWriteU16 error: " << status << std::endl; + } + return ::grpc::Status::OK; +} - ::ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerWriteI64", MonikerWriteI64); +::grpc::Status MonikerWriteU32(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData) +{ + MonikerWriteU32Data* function_data = (MonikerWriteU32Data*)data; + auto library = function_data->library; + + auto session = function_data->session; + auto control = function_data->control; + + U32Data u32data_message; + packedData.UnpackTo(&u32data_message); + uint32_t value = u32data_message.value(); - ::ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerWriteI8", MonikerWriteI8); + auto status = library->WriteU32(session, control, value); + if (status < 0) { + std::cout << "MonikerWriteU32 error: " << status << std::endl; + } + return ::grpc::Status::OK; +} - ::ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerWriteU16", MonikerWriteU16); +::grpc::Status MonikerWriteU64(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData) +{ + MonikerWriteU64Data* function_data = (MonikerWriteU64Data*)data; + auto library = function_data->library; + + auto session = function_data->session; + auto control = function_data->control; + + U64Data u64data_message; + packedData.UnpackTo(&u64data_message); + uint64_t value = u64data_message.value(); - ::ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerWriteU32", MonikerWriteU32); + auto status = library->WriteU64(session, control, value); + if (status < 0) { + std::cout << "MonikerWriteU64 error: " << status << std::endl; + } + return ::grpc::Status::OK; +} - ::ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerWriteU64", MonikerWriteU64); +::grpc::Status MonikerWriteU8(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData) +{ + MonikerWriteU8Data* function_data = (MonikerWriteU8Data*)data; + auto library = function_data->library; + + auto session = function_data->session; + auto control = function_data->control; + + U32Data u32data_message; + packedData.UnpackTo(&u32data_message); + uint32_t value = u32data_message.value(); + if (value < std::numeric_limits::min() || value > std::numeric_limits::max()) { + std::string message("value " + std::to_string(value) + " doesn't fit in datatype uint8_t"); + throw nidevice_grpc::ValueOutOfRangeException(message); + } - ::ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerWriteU8", MonikerWriteU8); + auto status = library->WriteU8(session, control, value); + if (status < 0) { + std::cout << "MonikerWriteU8 error: " << status << std::endl; + } + return ::grpc::Status::OK; } //--------------------------------------------------------------------- //--------------------------------------------------------------------- @@ -702,14 +1726,6 @@ void RegisterMoniker() } -struct MonikerReadArrayI16Data -{ - NiFpga_Session session; - uint32_t indicator; - size_t size; - nifpga_grpc::ArrayI32Data data; - std::shared_ptr library; -}; ::grpc::Status NiFpgaService::BeginReadArrayI16(::grpc::ServerContext* context, const BeginReadArrayI16Request* request, BeginReadArrayI16Response* response) { @@ -728,42 +1744,16 @@ ::grpc::Status NiFpgaService::BeginReadArrayI16(::grpc::ServerContext* context, data->size = size; data->library = std::shared_ptr(library_); - data->data.mutable_value()->Reserve(request->size()); - data->data.mutable_value()->Resize(request->size(), 0); + data->data.mutable_value()->Reserve(request->size()); + data->data.mutable_value()->Resize(request->size(), 0); ni::data_monikers::Moniker* moniker = new ni::data_monikers::Moniker(); ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerReadArrayI16", data, *moniker); response->set_allocated_moniker(moniker); return ::grpc::Status::OK; } - catch (std::exception& ex) { - return ::grpc::Status(::grpc::UNKNOWN, ex.what()); - } -} -::grpc::Status MonikerReadArrayI16(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData) -{ - MonikerReadArrayI16Data* function_data = (MonikerReadArrayI16Data*)data; - auto library = function_data->library; - - auto session = function_data->session; - auto indicator = function_data->indicator; - auto size = function_data->size; - - std::vector array(size); - auto status = library->ReadArrayI16(session, indicator, array.data(), size); - if (status >= 0) { - std::transform( - array.begin(), - array.begin() + size, - function_data->data.mutable_value()->begin(), - [&](auto x) { - return x; - }); - packedData.PackFrom(function_data->data); - } - if (status < 0) { - std::cout << "MonikerReadArrayI16 error: " << status << std::endl; + catch (std::exception& ex) { + return ::grpc::Status(::grpc::UNKNOWN, ex.what()); } - return ::grpc::Status::OK; } //--------------------------------------------------------------------- @@ -793,14 +1783,6 @@ ::grpc::Status MonikerReadArrayI16(void* data, google::protobuf::Arena& arena, g } -struct MonikerReadArrayI32Data -{ - NiFpga_Session session; - uint32_t indicator; - size_t size; - nifpga_grpc::ArrayI32Data data; - std::shared_ptr library; -}; ::grpc::Status NiFpgaService::BeginReadArrayI32(::grpc::ServerContext* context, const BeginReadArrayI32Request* request, BeginReadArrayI32Response* response) { @@ -819,8 +1801,8 @@ ::grpc::Status NiFpgaService::BeginReadArrayI32(::grpc::ServerContext* context, data->size = size; data->library = std::shared_ptr(library_); - data->data.mutable_value()->Reserve(request->size()); - data->data.mutable_value()->Resize(request->size(), 0); + data->data.mutable_value()->Reserve(request->size()); + data->data.mutable_value()->Resize(request->size(), 0); ni::data_monikers::Moniker* moniker = new ni::data_monikers::Moniker(); ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerReadArrayI32", data, *moniker); response->set_allocated_moniker(moniker); @@ -830,32 +1812,6 @@ ::grpc::Status NiFpgaService::BeginReadArrayI32(::grpc::ServerContext* context, return ::grpc::Status(::grpc::UNKNOWN, ex.what()); } } -::grpc::Status MonikerReadArrayI32(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData) -{ - MonikerReadArrayI32Data* function_data = (MonikerReadArrayI32Data*)data; - auto library = function_data->library; - - auto session = function_data->session; - auto indicator = function_data->indicator; - auto size = function_data->size; - - int32_t* array = new int32_t[size]; - auto status = library->ReadArrayI32(session, indicator, array, size); - if (status >= 0) { - std::transform( - array, - array + size, - function_data->data.mutable_value()->begin(), - [&](auto x) { - return x; - }); - packedData.PackFrom(function_data->data); - } - if (status < 0) { - std::cout << "MonikerReadArrayI32 error: " << status << std::endl; - } - return ::grpc::Status::OK; -} //--------------------------------------------------------------------- //--------------------------------------------------------------------- @@ -884,14 +1840,6 @@ ::grpc::Status MonikerReadArrayI32(void* data, google::protobuf::Arena& arena, g } -struct MonikerReadArrayI64Data -{ - NiFpga_Session session; - uint32_t indicator; - size_t size; - nifpga_grpc::ArrayI64Data data; - std::shared_ptr library; -}; ::grpc::Status NiFpgaService::BeginReadArrayI64(::grpc::ServerContext* context, const BeginReadArrayI64Request* request, BeginReadArrayI64Response* response) { @@ -910,8 +1858,8 @@ ::grpc::Status NiFpgaService::BeginReadArrayI64(::grpc::ServerContext* context, data->size = size; data->library = std::shared_ptr(library_); - data->data.mutable_value()->Reserve(request->size()); - data->data.mutable_value()->Resize(request->size(), 0); + data->data.mutable_value()->Reserve(request->size()); + data->data.mutable_value()->Resize(request->size(), 0); ni::data_monikers::Moniker* moniker = new ni::data_monikers::Moniker(); ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerReadArrayI64", data, *moniker); response->set_allocated_moniker(moniker); @@ -921,32 +1869,6 @@ ::grpc::Status NiFpgaService::BeginReadArrayI64(::grpc::ServerContext* context, return ::grpc::Status(::grpc::UNKNOWN, ex.what()); } } -::grpc::Status MonikerReadArrayI64(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData) -{ - MonikerReadArrayI64Data* function_data = (MonikerReadArrayI64Data*)data; - auto library = function_data->library; - - auto session = function_data->session; - auto indicator = function_data->indicator; - auto size = function_data->size; - - int64_t* array = new int64_t[size]; - auto status = library->ReadArrayI64(session, indicator, array, size); - if (status >= 0) { - std::transform( - array, - array + size, - function_data->data.mutable_value()->begin(), - [&](auto x) { - return x; - }); - packedData.PackFrom(function_data->data); - } - if (status < 0) { - std::cout << "MonikerReadArrayI64 error: " << status << std::endl; - } - return ::grpc::Status::OK; -} //--------------------------------------------------------------------- //--------------------------------------------------------------------- @@ -983,14 +1905,6 @@ ::grpc::Status MonikerReadArrayI64(void* data, google::protobuf::Arena& arena, g } -struct MonikerReadArrayI8Data -{ - NiFpga_Session session; - uint32_t indicator; - size_t size; - nifpga_grpc::ArrayI32Data data; - std::shared_ptr library; -}; ::grpc::Status NiFpgaService::BeginReadArrayI8(::grpc::ServerContext* context, const BeginReadArrayI8Request* request, BeginReadArrayI8Response* response) { @@ -1009,8 +1923,8 @@ ::grpc::Status NiFpgaService::BeginReadArrayI8(::grpc::ServerContext* context, c data->size = size; data->library = std::shared_ptr(library_); - data->data.mutable_value()->Reserve(request->size()); - data->data.mutable_value()->Resize(request->size(), 0); + data->data.mutable_value()->Reserve(request->size()); + data->data.mutable_value()->Resize(request->size(), 0); ni::data_monikers::Moniker* moniker = new ni::data_monikers::Moniker(); ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerReadArrayI8", data, *moniker); response->set_allocated_moniker(moniker); @@ -1020,32 +1934,6 @@ ::grpc::Status NiFpgaService::BeginReadArrayI8(::grpc::ServerContext* context, c return ::grpc::Status(::grpc::UNKNOWN, ex.what()); } } -::grpc::Status MonikerReadArrayI8(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData) -{ - MonikerReadArrayI8Data* function_data = (MonikerReadArrayI8Data*)data; - auto library = function_data->library; - - auto session = function_data->session; - auto indicator = function_data->indicator; - auto size = function_data->size; - - std::vector array(size); - auto status = library->ReadArrayI8(session, indicator, array.data(), size); - if (status >= 0) { - std::transform( - array.begin(), - array.begin() + size, - function_data->data.mutable_value()->begin(), - [&](auto x) { - return x; - }); - packedData.PackFrom(function_data->data); - } - if (status < 0) { - std::cout << "MonikerReadArrayI8 error: " << status << std::endl; - } - return ::grpc::Status::OK; -} //--------------------------------------------------------------------- //--------------------------------------------------------------------- @@ -1108,14 +1996,6 @@ ::grpc::Status MonikerReadArrayI8(void* data, google::protobuf::Arena& arena, go } -struct MonikerReadArrayU16Data -{ - NiFpga_Session session; - uint32_t indicator; - size_t size; - nifpga_grpc::ArrayU32Data data; - std::shared_ptr library; -}; ::grpc::Status NiFpgaService::BeginReadArrayU16(::grpc::ServerContext* context, const BeginReadArrayU16Request* request, BeginReadArrayU16Response* response) { @@ -1134,8 +2014,8 @@ ::grpc::Status NiFpgaService::BeginReadArrayU16(::grpc::ServerContext* context, data->size = size; data->library = std::shared_ptr(library_); - data->data.mutable_value()->Reserve(request->size()); - data->data.mutable_value()->Resize(request->size(), 0); + data->data.mutable_value()->Reserve(request->size()); + data->data.mutable_value()->Resize(request->size(), 0); ni::data_monikers::Moniker* moniker = new ni::data_monikers::Moniker(); ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerReadArrayU16", data, *moniker); response->set_allocated_moniker(moniker); @@ -1145,32 +2025,6 @@ ::grpc::Status NiFpgaService::BeginReadArrayU16(::grpc::ServerContext* context, return ::grpc::Status(::grpc::UNKNOWN, ex.what()); } } -::grpc::Status MonikerReadArrayU16(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData) -{ - MonikerReadArrayU16Data* function_data = (MonikerReadArrayU16Data*)data; - auto library = function_data->library; - - auto session = function_data->session; - auto indicator = function_data->indicator; - auto size = function_data->size; - - std::vector array(size); - auto status = library->ReadArrayU16(session, indicator, array.data(), size); - if (status >= 0) { - std::transform( - array.begin(), - array.begin() + size, - function_data->data.mutable_value()->begin(), - [&](auto x) { - return x; - }); - packedData.PackFrom(function_data->data); - } - if (status < 0) { - std::cout << "MonikerReadArrayU16 error: " << status << std::endl; - } - return ::grpc::Status::OK; -} //--------------------------------------------------------------------- //--------------------------------------------------------------------- @@ -1199,14 +2053,6 @@ ::grpc::Status MonikerReadArrayU16(void* data, google::protobuf::Arena& arena, g } -struct MonikerReadArrayU32Data -{ - NiFpga_Session session; - uint32_t indicator; - size_t size; - nifpga_grpc::ArrayU32Data data; - std::shared_ptr library; -}; ::grpc::Status NiFpgaService::BeginReadArrayU32(::grpc::ServerContext* context, const BeginReadArrayU32Request* request, BeginReadArrayU32Response* response) { @@ -1225,8 +2071,8 @@ ::grpc::Status NiFpgaService::BeginReadArrayU32(::grpc::ServerContext* context, data->size = size; data->library = std::shared_ptr(library_); - data->data.mutable_value()->Reserve(request->size()); - data->data.mutable_value()->Resize(request->size(), 0); + data->data.mutable_value()->Reserve(request->size()); + data->data.mutable_value()->Resize(request->size(), 0); ni::data_monikers::Moniker* moniker = new ni::data_monikers::Moniker(); ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerReadArrayU32", data, *moniker); response->set_allocated_moniker(moniker); @@ -1236,32 +2082,6 @@ ::grpc::Status NiFpgaService::BeginReadArrayU32(::grpc::ServerContext* context, return ::grpc::Status(::grpc::UNKNOWN, ex.what()); } } -::grpc::Status MonikerReadArrayU32(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData) -{ - MonikerReadArrayU32Data* function_data = (MonikerReadArrayU32Data*)data; - auto library = function_data->library; - - auto session = function_data->session; - auto indicator = function_data->indicator; - auto size = function_data->size; - - uint32_t* array = new uint32_t[size]; - auto status = library->ReadArrayU32(session, indicator, array, size); - if (status >= 0) { - std::transform( - array, - array + size, - function_data->data.mutable_value()->begin(), - [&](auto x) { - return x; - }); - packedData.PackFrom(function_data->data); - } - if (status < 0) { - std::cout << "MonikerReadArrayU32 error: " << status << std::endl; - } - return ::grpc::Status::OK; -} //--------------------------------------------------------------------- //--------------------------------------------------------------------- @@ -1290,14 +2110,6 @@ ::grpc::Status MonikerReadArrayU32(void* data, google::protobuf::Arena& arena, g } -struct MonikerReadArrayU64Data -{ - NiFpga_Session session; - uint32_t indicator; - size_t size; - nifpga_grpc::ArrayU64Data data; - std::shared_ptr library; -}; ::grpc::Status NiFpgaService::BeginReadArrayU64(::grpc::ServerContext* context, const BeginReadArrayU64Request* request, BeginReadArrayU64Response* response) { @@ -1316,8 +2128,8 @@ ::grpc::Status NiFpgaService::BeginReadArrayU64(::grpc::ServerContext* context, data->size = size; data->library = std::shared_ptr(library_); - data->data.mutable_value()->Reserve(request->size()); - data->data.mutable_value()->Resize(request->size(), 0); + data->data.mutable_value()->Reserve(request->size()); + data->data.mutable_value()->Resize(request->size(), 0); ni::data_monikers::Moniker* moniker = new ni::data_monikers::Moniker(); ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerReadArrayU64", data, *moniker); response->set_allocated_moniker(moniker); @@ -1327,32 +2139,6 @@ ::grpc::Status NiFpgaService::BeginReadArrayU64(::grpc::ServerContext* context, return ::grpc::Status(::grpc::UNKNOWN, ex.what()); } } -::grpc::Status MonikerReadArrayU64(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData) -{ - MonikerReadArrayU64Data* function_data = (MonikerReadArrayU64Data*)data; - auto library = function_data->library; - - auto session = function_data->session; - auto indicator = function_data->indicator; - auto size = function_data->size; - - uint64_t* array = new uint64_t[size]; - auto status = library->ReadArrayU64(session, indicator, array, size); - if (status >= 0) { - std::transform( - array, - array + size, - function_data->data.mutable_value()->begin(), - [&](auto x) { - return x; - }); - packedData.PackFrom(function_data->data); - } - if (status < 0) { - std::cout << "MonikerReadArrayU64 error: " << status << std::endl; - } - return ::grpc::Status::OK; -} //--------------------------------------------------------------------- //--------------------------------------------------------------------- @@ -1389,14 +2175,6 @@ ::grpc::Status MonikerReadArrayU64(void* data, google::protobuf::Arena& arena, g } -struct MonikerReadArrayU8Data -{ - NiFpga_Session session; - uint32_t indicator; - size_t size; - nifpga_grpc::ArrayU32Data data; - std::shared_ptr library; -}; ::grpc::Status NiFpgaService::BeginReadArrayU8(::grpc::ServerContext* context, const BeginReadArrayU8Request* request, BeginReadArrayU8Response* response) { @@ -1415,8 +2193,8 @@ ::grpc::Status NiFpgaService::BeginReadArrayU8(::grpc::ServerContext* context, c data->size = size; data->library = std::shared_ptr(library_); - data->data.mutable_value()->Reserve(request->size()); - data->data.mutable_value()->Resize(request->size(), 0); + data->data.mutable_value()->Reserve(request->size()); + data->data.mutable_value()->Resize(request->size(), 0); ni::data_monikers::Moniker* moniker = new ni::data_monikers::Moniker(); ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerReadArrayU8", data, *moniker); response->set_allocated_moniker(moniker); @@ -1426,32 +2204,6 @@ ::grpc::Status NiFpgaService::BeginReadArrayU8(::grpc::ServerContext* context, c return ::grpc::Status(::grpc::UNKNOWN, ex.what()); } } -::grpc::Status MonikerReadArrayU8(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData) -{ - MonikerReadArrayU8Data* function_data = (MonikerReadArrayU8Data*)data; - auto library = function_data->library; - - auto session = function_data->session; - auto indicator = function_data->indicator; - auto size = function_data->size; - - std::vector array(size); - auto status = library->ReadArrayU8(session, indicator, array.data(), size); - if (status >= 0) { - std::transform( - array.begin(), - array.begin() + size, - function_data->data.mutable_value()->begin(), - [&](auto x) { - return x; - }); - packedData.PackFrom(function_data->data); - } - if (status < 0) { - std::cout << "MonikerReadArrayU8 error: " << status << std::endl; - } - return ::grpc::Status::OK; -} //--------------------------------------------------------------------- //--------------------------------------------------------------------- @@ -1880,13 +2632,6 @@ ::grpc::Status MonikerReadArrayU8(void* data, google::protobuf::Arena& arena, go } -struct MonikerReadI16Data -{ - NiFpga_Session session; - uint32_t indicator; - nifpga_grpc::I32Data data; - std::shared_ptr library; -}; ::grpc::Status NiFpgaService::BeginReadI16(::grpc::ServerContext* context, const BeginReadI16Request* request, BeginReadI16Response* response) { @@ -1912,25 +2657,6 @@ ::grpc::Status NiFpgaService::BeginReadI16(::grpc::ServerContext* context, const return ::grpc::Status(::grpc::UNKNOWN, ex.what()); } } -::grpc::Status MonikerReadI16(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData) -{ - MonikerReadI16Data* function_data = (MonikerReadI16Data*)data; - auto library = function_data->library; - - auto session = function_data->session; - auto indicator = function_data->indicator; - - int16_t value = 0; - auto status = library->ReadI16(session, indicator, &value); - function_data->data.set_value(value); - if (status >= 0) { - packedData.PackFrom(function_data->data); - } - if (status < 0) { - std::cout << "MonikerReadI16 error: " << status << std::endl; - } - return ::grpc::Status::OK; -} //--------------------------------------------------------------------- //--------------------------------------------------------------------- @@ -1958,13 +2684,6 @@ ::grpc::Status MonikerReadI16(void* data, google::protobuf::Arena& arena, google } -struct MonikerReadI32Data -{ - NiFpga_Session session; - uint32_t indicator; - nifpga_grpc::I32Data data; - std::shared_ptr library; -}; ::grpc::Status NiFpgaService::BeginReadI32(::grpc::ServerContext* context, const BeginReadI32Request* request, BeginReadI32Response* response) { @@ -1990,25 +2709,6 @@ ::grpc::Status NiFpgaService::BeginReadI32(::grpc::ServerContext* context, const return ::grpc::Status(::grpc::UNKNOWN, ex.what()); } } -::grpc::Status MonikerReadI32(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData) -{ - MonikerReadI32Data* function_data = (MonikerReadI32Data*)data; - auto library = function_data->library; - - auto session = function_data->session; - auto indicator = function_data->indicator; - - int32_t value = 0; - auto status = library->ReadI32(session, indicator, &value); - function_data->data.set_value(value); - if (status >= 0) { - packedData.PackFrom(function_data->data); - } - if (status < 0) { - std::cout << "MonikerReadI32 error: " << status << std::endl; - } - return ::grpc::Status::OK; -} //--------------------------------------------------------------------- //--------------------------------------------------------------------- @@ -2036,13 +2736,6 @@ ::grpc::Status MonikerReadI32(void* data, google::protobuf::Arena& arena, google } -struct MonikerReadI64Data -{ - NiFpga_Session session; - uint32_t indicator; - nifpga_grpc::I64Data data; - std::shared_ptr library; -}; ::grpc::Status NiFpgaService::BeginReadI64(::grpc::ServerContext* context, const BeginReadI64Request* request, BeginReadI64Response* response) { @@ -2064,28 +2757,9 @@ ::grpc::Status NiFpgaService::BeginReadI64(::grpc::ServerContext* context, const response->set_allocated_moniker(moniker); return ::grpc::Status::OK; } - catch (std::exception& ex) { - return ::grpc::Status(::grpc::UNKNOWN, ex.what()); - } -} -::grpc::Status MonikerReadI64(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData) -{ - MonikerReadI64Data* function_data = (MonikerReadI64Data*)data; - auto library = function_data->library; - - auto session = function_data->session; - auto indicator = function_data->indicator; - - int64_t value = 0; - auto status = library->ReadI64(session, indicator, &value); - function_data->data.set_value(value); - if (status >= 0) { - packedData.PackFrom(function_data->data); - } - if (status < 0) { - std::cout << "MonikerReadI64 error: " << status << std::endl; - } - return ::grpc::Status::OK; + catch (std::exception& ex) { + return ::grpc::Status(::grpc::UNKNOWN, ex.what()); + } } //--------------------------------------------------------------------- @@ -2114,13 +2788,6 @@ ::grpc::Status MonikerReadI64(void* data, google::protobuf::Arena& arena, google } -struct MonikerReadI8Data -{ - NiFpga_Session session; - uint32_t indicator; - nifpga_grpc::I32Data data; - std::shared_ptr library; -}; ::grpc::Status NiFpgaService::BeginReadI8(::grpc::ServerContext* context, const BeginReadI8Request* request, BeginReadI8Response* response) { @@ -2146,25 +2813,6 @@ ::grpc::Status NiFpgaService::BeginReadI8(::grpc::ServerContext* context, const return ::grpc::Status(::grpc::UNKNOWN, ex.what()); } } -::grpc::Status MonikerReadI8(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData) -{ - MonikerReadI8Data* function_data = (MonikerReadI8Data*)data; - auto library = function_data->library; - - auto session = function_data->session; - auto indicator = function_data->indicator; - - int8_t value = 0; - auto status = library->ReadI8(session, indicator, &value); - function_data->data.set_value(value); - if (status >= 0) { - packedData.PackFrom(function_data->data); - } - if (status < 0) { - std::cout << "MonikerReadI8 error: " << status << std::endl; - } - return ::grpc::Status::OK; -} //--------------------------------------------------------------------- //--------------------------------------------------------------------- @@ -2217,13 +2865,6 @@ ::grpc::Status MonikerReadI8(void* data, google::protobuf::Arena& arena, google: } -struct MonikerReadU16Data -{ - NiFpga_Session session; - uint32_t indicator; - nifpga_grpc::U32Data data; - std::shared_ptr library; -}; ::grpc::Status NiFpgaService::BeginReadU16(::grpc::ServerContext* context, const BeginReadU16Request* request, BeginReadU16Response* response) { @@ -2249,25 +2890,6 @@ ::grpc::Status NiFpgaService::BeginReadU16(::grpc::ServerContext* context, const return ::grpc::Status(::grpc::UNKNOWN, ex.what()); } } -::grpc::Status MonikerReadU16(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData) -{ - MonikerReadU16Data* function_data = (MonikerReadU16Data*)data; - auto library = function_data->library; - - auto session = function_data->session; - auto indicator = function_data->indicator; - - uint16_t value = 0; - auto status = library->ReadU16(session, indicator, &value); - function_data->data.set_value(value); - if (status >= 0) { - packedData.PackFrom(function_data->data); - } - if (status < 0) { - std::cout << "MonikerReadU16 error: " << status << std::endl; - } - return ::grpc::Status::OK; -} //--------------------------------------------------------------------- //--------------------------------------------------------------------- @@ -2295,13 +2917,6 @@ ::grpc::Status MonikerReadU16(void* data, google::protobuf::Arena& arena, google } -struct MonikerReadU32Data -{ - NiFpga_Session session; - uint32_t indicator; - nifpga_grpc::U32Data data; - std::shared_ptr library; -}; ::grpc::Status NiFpgaService::BeginReadU32(::grpc::ServerContext* context, const BeginReadU32Request* request, BeginReadU32Response* response) { @@ -2327,25 +2942,6 @@ ::grpc::Status NiFpgaService::BeginReadU32(::grpc::ServerContext* context, const return ::grpc::Status(::grpc::UNKNOWN, ex.what()); } } -::grpc::Status MonikerReadU32(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData) -{ - MonikerReadU32Data* function_data = (MonikerReadU32Data*)data; - auto library = function_data->library; - - auto session = function_data->session; - auto indicator = function_data->indicator; - - uint32_t value = 0; - auto status = library->ReadU32(session, indicator, &value); - function_data->data.set_value(value); - if (status >= 0) { - packedData.PackFrom(function_data->data); - } - if (status < 0) { - std::cout << "MonikerReadU32 error: " << status << std::endl; - } - return ::grpc::Status::OK; -} //--------------------------------------------------------------------- //--------------------------------------------------------------------- @@ -2373,13 +2969,6 @@ ::grpc::Status MonikerReadU32(void* data, google::protobuf::Arena& arena, google } -struct MonikerReadU64Data -{ - NiFpga_Session session; - uint32_t indicator; - nifpga_grpc::U64Data data; - std::shared_ptr library; -}; ::grpc::Status NiFpgaService::BeginReadU64(::grpc::ServerContext* context, const BeginReadU64Request* request, BeginReadU64Response* response) { @@ -2405,25 +2994,6 @@ ::grpc::Status NiFpgaService::BeginReadU64(::grpc::ServerContext* context, const return ::grpc::Status(::grpc::UNKNOWN, ex.what()); } } -::grpc::Status MonikerReadU64(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData) -{ - MonikerReadU64Data* function_data = (MonikerReadU64Data*)data; - auto library = function_data->library; - - auto session = function_data->session; - auto indicator = function_data->indicator; - - uint64_t value = 0; - auto status = library->ReadU64(session, indicator, &value); - function_data->data.set_value(value); - if (status >= 0) { - packedData.PackFrom(function_data->data); - } - if (status < 0) { - std::cout << "MonikerReadU64 error: " << status << std::endl; - } - return ::grpc::Status::OK; -} //--------------------------------------------------------------------- //--------------------------------------------------------------------- @@ -2451,13 +3021,6 @@ ::grpc::Status MonikerReadU64(void* data, google::protobuf::Arena& arena, google } -struct MonikerReadU8Data -{ - NiFpga_Session session; - uint32_t indicator; - nifpga_grpc::U32Data data; - std::shared_ptr library; -}; ::grpc::Status NiFpgaService::BeginReadU8(::grpc::ServerContext* context, const BeginReadU8Request* request, BeginReadU8Response* response) { @@ -2483,25 +3046,6 @@ ::grpc::Status NiFpgaService::BeginReadU8(::grpc::ServerContext* context, const return ::grpc::Status(::grpc::UNKNOWN, ex.what()); } } -::grpc::Status MonikerReadU8(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData) -{ - MonikerReadU8Data* function_data = (MonikerReadU8Data*)data; - auto library = function_data->library; - - auto session = function_data->session; - auto indicator = function_data->indicator; - - uint8_t value = 0; - auto status = library->ReadU8(session, indicator, &value); - function_data->data.set_value(value); - if (status >= 0) { - packedData.PackFrom(function_data->data); - } - if (status < 0) { - std::cout << "MonikerReadU8 error: " << status << std::endl; - } - return ::grpc::Status::OK; -} //--------------------------------------------------------------------- //--------------------------------------------------------------------- @@ -2938,13 +3482,6 @@ ::grpc::Status MonikerReadU8(void* data, google::protobuf::Arena& arena, google: } -struct MonikerWriteArrayI16Data -{ - NiFpga_Session session; - uint32_t control; - nifpga_grpc::ArrayI32Data data; - std::shared_ptr library; -}; ::grpc::Status NiFpgaService::BeginWriteArrayI16(::grpc::ServerContext* context, const BeginWriteArrayI16Request* request, BeginWriteArrayI16Response* response) { @@ -2970,38 +3507,6 @@ ::grpc::Status NiFpgaService::BeginWriteArrayI16(::grpc::ServerContext* context, return ::grpc::Status(::grpc::UNKNOWN, ex.what()); } } -::grpc::Status MonikerWriteArrayI16(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData) -{ - MonikerWriteArrayI16Data* function_data = (MonikerWriteArrayI16Data*)data; - auto library = function_data->library; - - auto session = function_data->session; - auto control = function_data->control; - - ArrayI32Data arrayi32data_message; - packedData.UnpackTo(&arrayi32data_message); - auto data_array = arrayi32data_message.value(); - auto array = std::vector(); - auto size = data_array.size(); - array.reserve(size); - std::transform( - data_array.begin(), - data_array.end(), - std::back_inserter(array), - [](auto x) { - if (x < std::numeric_limits::min() || x > std::numeric_limits::max()) { - std::string message("value " + std::to_string(x) + " doesn't fit in datatype int16_t"); - throw nidevice_grpc::ValueOutOfRangeException(message); - } - return static_cast(x); - }); - - auto status = library->WriteArrayI16(session, control, array.data(), size); - if (status < 0) { - std::cout << "MonikerWriteArrayI16 error: " << status << std::endl; - } - return ::grpc::Status::OK; -} //--------------------------------------------------------------------- //--------------------------------------------------------------------- @@ -3029,13 +3534,6 @@ ::grpc::Status MonikerWriteArrayI16(void* data, google::protobuf::Arena& arena, } -struct MonikerWriteArrayI32Data -{ - NiFpga_Session session; - uint32_t control; - nifpga_grpc::ArrayI32Data data; - std::shared_ptr library; -}; ::grpc::Status NiFpgaService::BeginWriteArrayI32(::grpc::ServerContext* context, const BeginWriteArrayI32Request* request, BeginWriteArrayI32Response* response) { @@ -3061,26 +3559,6 @@ ::grpc::Status NiFpgaService::BeginWriteArrayI32(::grpc::ServerContext* context, return ::grpc::Status(::grpc::UNKNOWN, ex.what()); } } -::grpc::Status MonikerWriteArrayI32(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData) -{ - MonikerWriteArrayI32Data* function_data = (MonikerWriteArrayI32Data*)data; - auto library = function_data->library; - - auto session = function_data->session; - auto control = function_data->control; - - ArrayI32Data arrayi32data_message; - packedData.UnpackTo(&arrayi32data_message); - auto data_array = arrayi32data_message.value(); - auto array = const_cast(arrayi32data_message.value().data()); - auto size = data_array.size(); - - auto status = library->WriteArrayI32(session, control, array, size); - if (status < 0) { - std::cout << "MonikerWriteArrayI32 error: " << status << std::endl; - } - return ::grpc::Status::OK; -} //--------------------------------------------------------------------- //--------------------------------------------------------------------- @@ -3108,13 +3586,6 @@ ::grpc::Status MonikerWriteArrayI32(void* data, google::protobuf::Arena& arena, } -struct MonikerWriteArrayI64Data -{ - NiFpga_Session session; - uint32_t control; - nifpga_grpc::ArrayI64Data data; - std::shared_ptr library; -}; ::grpc::Status NiFpgaService::BeginWriteArrayI64(::grpc::ServerContext* context, const BeginWriteArrayI64Request* request, BeginWriteArrayI64Response* response) { @@ -3140,26 +3611,6 @@ ::grpc::Status NiFpgaService::BeginWriteArrayI64(::grpc::ServerContext* context, return ::grpc::Status(::grpc::UNKNOWN, ex.what()); } } -::grpc::Status MonikerWriteArrayI64(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData) -{ - MonikerWriteArrayI64Data* function_data = (MonikerWriteArrayI64Data*)data; - auto library = function_data->library; - - auto session = function_data->session; - auto control = function_data->control; - - ArrayI64Data arrayi64data_message; - packedData.UnpackTo(&arrayi64data_message); - auto data_array = arrayi64data_message.value(); - auto array = const_cast(arrayi64data_message.value().data()); - auto size = data_array.size(); - - auto status = library->WriteArrayI64(session, control, array, size); - if (status < 0) { - std::cout << "MonikerWriteArrayI64 error: " << status << std::endl; - } - return ::grpc::Status::OK; -} //--------------------------------------------------------------------- //--------------------------------------------------------------------- @@ -3204,13 +3655,6 @@ ::grpc::Status MonikerWriteArrayI64(void* data, google::protobuf::Arena& arena, } -struct MonikerWriteArrayI8Data -{ - NiFpga_Session session; - uint32_t control; - nifpga_grpc::ArrayI32Data data; - std::shared_ptr library; -}; ::grpc::Status NiFpgaService::BeginWriteArrayI8(::grpc::ServerContext* context, const BeginWriteArrayI8Request* request, BeginWriteArrayI8Response* response) { @@ -3236,38 +3680,6 @@ ::grpc::Status NiFpgaService::BeginWriteArrayI8(::grpc::ServerContext* context, return ::grpc::Status(::grpc::UNKNOWN, ex.what()); } } -::grpc::Status MonikerWriteArrayI8(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData) -{ - MonikerWriteArrayI8Data* function_data = (MonikerWriteArrayI8Data*)data; - auto library = function_data->library; - - auto session = function_data->session; - auto control = function_data->control; - - ArrayI32Data arrayi32data_message; - packedData.UnpackTo(&arrayi32data_message); - auto data_array = arrayi32data_message.value(); - auto array = std::vector(); - auto size = data_array.size(); - array.reserve(size); - std::transform( - data_array.begin(), - data_array.end(), - std::back_inserter(array), - [](auto x) { - if (x < std::numeric_limits::min() || x > std::numeric_limits::max()) { - std::string message("value " + std::to_string(x) + " doesn't fit in datatype int8_t"); - throw nidevice_grpc::ValueOutOfRangeException(message); - } - return static_cast(x); - }); - - auto status = library->WriteArrayI8(session, control, array.data(), size); - if (status < 0) { - std::cout << "MonikerWriteArrayI8 error: " << status << std::endl; - } - return ::grpc::Status::OK; -} //--------------------------------------------------------------------- //--------------------------------------------------------------------- @@ -3337,13 +3749,6 @@ ::grpc::Status MonikerWriteArrayI8(void* data, google::protobuf::Arena& arena, g } -struct MonikerWriteArrayU16Data -{ - NiFpga_Session session; - uint32_t control; - nifpga_grpc::ArrayU32Data data; - std::shared_ptr library; -}; ::grpc::Status NiFpgaService::BeginWriteArrayU16(::grpc::ServerContext* context, const BeginWriteArrayU16Request* request, BeginWriteArrayU16Response* response) { @@ -3355,51 +3760,19 @@ ::grpc::Status NiFpgaService::BeginWriteArrayU16(::grpc::ServerContext* context, NiFpga_Session session = session_repository_->access_session(session_grpc_session.name()); uint32_t control = request->control(); - MonikerWriteArrayU16Data* data = new MonikerWriteArrayU16Data(); - data->session = session; - data->control = control; - data->library = std::shared_ptr(library_); - - ni::data_monikers::Moniker* moniker = new ni::data_monikers::Moniker(); - ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerWriteArrayU16", data, *moniker); - response->set_allocated_moniker(moniker); - return ::grpc::Status::OK; - } - catch (std::exception& ex) { - return ::grpc::Status(::grpc::UNKNOWN, ex.what()); - } -} -::grpc::Status MonikerWriteArrayU16(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData) -{ - MonikerWriteArrayU16Data* function_data = (MonikerWriteArrayU16Data*)data; - auto library = function_data->library; - - auto session = function_data->session; - auto control = function_data->control; - - ArrayU32Data arrayu32data_message; - packedData.UnpackTo(&arrayu32data_message); - auto data_array = arrayu32data_message.value(); - auto array = std::vector(); - auto size = data_array.size(); - array.reserve(size); - std::transform( - data_array.begin(), - data_array.end(), - std::back_inserter(array), - [](auto x) { - if (x < std::numeric_limits::min() || x > std::numeric_limits::max()) { - std::string message("value " + std::to_string(x) + " doesn't fit in datatype uint16_t"); - throw nidevice_grpc::ValueOutOfRangeException(message); - } - return static_cast(x); - }); - - auto status = library->WriteArrayU16(session, control, array.data(), size); - if (status < 0) { - std::cout << "MonikerWriteArrayU16 error: " << status << std::endl; + MonikerWriteArrayU16Data* data = new MonikerWriteArrayU16Data(); + data->session = session; + data->control = control; + data->library = std::shared_ptr(library_); + + ni::data_monikers::Moniker* moniker = new ni::data_monikers::Moniker(); + ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerWriteArrayU16", data, *moniker); + response->set_allocated_moniker(moniker); + return ::grpc::Status::OK; + } + catch (std::exception& ex) { + return ::grpc::Status(::grpc::UNKNOWN, ex.what()); } - return ::grpc::Status::OK; } //--------------------------------------------------------------------- @@ -3428,13 +3801,6 @@ ::grpc::Status MonikerWriteArrayU16(void* data, google::protobuf::Arena& arena, } -struct MonikerWriteArrayU32Data -{ - NiFpga_Session session; - uint32_t control; - nifpga_grpc::ArrayU32Data data; - std::shared_ptr library; -}; ::grpc::Status NiFpgaService::BeginWriteArrayU32(::grpc::ServerContext* context, const BeginWriteArrayU32Request* request, BeginWriteArrayU32Response* response) { @@ -3460,26 +3826,6 @@ ::grpc::Status NiFpgaService::BeginWriteArrayU32(::grpc::ServerContext* context, return ::grpc::Status(::grpc::UNKNOWN, ex.what()); } } -::grpc::Status MonikerWriteArrayU32(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData) -{ - MonikerWriteArrayU32Data* function_data = (MonikerWriteArrayU32Data*)data; - auto library = function_data->library; - - auto session = function_data->session; - auto control = function_data->control; - - ArrayU32Data arrayu32data_message; - packedData.UnpackTo(&arrayu32data_message); - auto data_array = arrayu32data_message.value(); - auto array = const_cast(arrayu32data_message.value().data()); - auto size = data_array.size(); - - auto status = library->WriteArrayU32(session, control, array, size); - if (status < 0) { - std::cout << "MonikerWriteArrayU32 error: " << status << std::endl; - } - return ::grpc::Status::OK; -} //--------------------------------------------------------------------- //--------------------------------------------------------------------- @@ -3507,13 +3853,6 @@ ::grpc::Status MonikerWriteArrayU32(void* data, google::protobuf::Arena& arena, } -struct MonikerWriteArrayU64Data -{ - NiFpga_Session session; - uint32_t control; - nifpga_grpc::ArrayU64Data data; - std::shared_ptr library; -}; ::grpc::Status NiFpgaService::BeginWriteArrayU64(::grpc::ServerContext* context, const BeginWriteArrayU64Request* request, BeginWriteArrayU64Response* response) { @@ -3539,26 +3878,6 @@ ::grpc::Status NiFpgaService::BeginWriteArrayU64(::grpc::ServerContext* context, return ::grpc::Status(::grpc::UNKNOWN, ex.what()); } } -::grpc::Status MonikerWriteArrayU64(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData) -{ - MonikerWriteArrayU64Data* function_data = (MonikerWriteArrayU64Data*)data; - auto library = function_data->library; - - auto session = function_data->session; - auto control = function_data->control; - - ArrayU64Data arrayu64data_message; - packedData.UnpackTo(&arrayu64data_message); - auto data_array = arrayu64data_message.value(); - auto array = const_cast(arrayu64data_message.value().data()); - auto size = data_array.size(); - - auto status = library->WriteArrayU64(session, control, array, size); - if (status < 0) { - std::cout << "MonikerWriteArrayU64 error: " << status << std::endl; - } - return ::grpc::Status::OK; -} //--------------------------------------------------------------------- //--------------------------------------------------------------------- @@ -3603,13 +3922,6 @@ ::grpc::Status MonikerWriteArrayU64(void* data, google::protobuf::Arena& arena, } -struct MonikerWriteArrayU8Data -{ - NiFpga_Session session; - uint32_t control; - nifpga_grpc::ArrayU32Data data; - std::shared_ptr library; -}; ::grpc::Status NiFpgaService::BeginWriteArrayU8(::grpc::ServerContext* context, const BeginWriteArrayU8Request* request, BeginWriteArrayU8Response* response) { @@ -3635,38 +3947,6 @@ ::grpc::Status NiFpgaService::BeginWriteArrayU8(::grpc::ServerContext* context, return ::grpc::Status(::grpc::UNKNOWN, ex.what()); } } -::grpc::Status MonikerWriteArrayU8(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData) -{ - MonikerWriteArrayU8Data* function_data = (MonikerWriteArrayU8Data*)data; - auto library = function_data->library; - - auto session = function_data->session; - auto control = function_data->control; - - ArrayU32Data arrayu32data_message; - packedData.UnpackTo(&arrayu32data_message); - auto data_array = arrayu32data_message.value(); - auto array = std::vector(); - auto size = data_array.size(); - array.reserve(size); - std::transform( - data_array.begin(), - data_array.end(), - std::back_inserter(array), - [](auto x) { - if (x < std::numeric_limits::min() || x > std::numeric_limits::max()) { - std::string message("value " + std::to_string(x) + " doesn't fit in datatype uint8_t"); - throw nidevice_grpc::ValueOutOfRangeException(message); - } - return static_cast(x); - }); - - auto status = library->WriteArrayU8(session, control, array.data(), size); - if (status < 0) { - std::cout << "MonikerWriteArrayU8 error: " << status << std::endl; - } - return ::grpc::Status::OK; -} //--------------------------------------------------------------------- //--------------------------------------------------------------------- @@ -4126,13 +4406,6 @@ ::grpc::Status MonikerWriteArrayU8(void* data, google::protobuf::Arena& arena, g } -struct MonikerWriteI16Data -{ - NiFpga_Session session; - uint32_t control; - nifpga_grpc::I32Data data; - std::shared_ptr library; -}; ::grpc::Status NiFpgaService::BeginWriteI16(::grpc::ServerContext* context, const BeginWriteI16Request* request, BeginWriteI16Response* response) { @@ -4158,28 +4431,6 @@ ::grpc::Status NiFpgaService::BeginWriteI16(::grpc::ServerContext* context, cons return ::grpc::Status(::grpc::UNKNOWN, ex.what()); } } -::grpc::Status MonikerWriteI16(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData) -{ - MonikerWriteI16Data* function_data = (MonikerWriteI16Data*)data; - auto library = function_data->library; - - auto session = function_data->session; - auto control = function_data->control; - - I32Data i32data_message; - packedData.UnpackTo(&i32data_message); - int32_t value = i32data_message.value(); - if (value < std::numeric_limits::min() || value > std::numeric_limits::max()) { - std::string message("value " + std::to_string(value) + " doesn't fit in datatype int16_t"); - throw nidevice_grpc::ValueOutOfRangeException(message); - } - - auto status = library->WriteI16(session, control, value); - if (status < 0) { - std::cout << "MonikerWriteI16 error: " << status << std::endl; - } - return ::grpc::Status::OK; -} //--------------------------------------------------------------------- //--------------------------------------------------------------------- @@ -4206,13 +4457,6 @@ ::grpc::Status MonikerWriteI16(void* data, google::protobuf::Arena& arena, googl } -struct MonikerWriteI32Data -{ - NiFpga_Session session; - uint32_t control; - nifpga_grpc::I32Data data; - std::shared_ptr library; -}; ::grpc::Status NiFpgaService::BeginWriteI32(::grpc::ServerContext* context, const BeginWriteI32Request* request, BeginWriteI32Response* response) { @@ -4238,24 +4482,6 @@ ::grpc::Status NiFpgaService::BeginWriteI32(::grpc::ServerContext* context, cons return ::grpc::Status(::grpc::UNKNOWN, ex.what()); } } -::grpc::Status MonikerWriteI32(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData) -{ - MonikerWriteI32Data* function_data = (MonikerWriteI32Data*)data; - auto library = function_data->library; - - auto session = function_data->session; - auto control = function_data->control; - - I32Data i32data_message; - packedData.UnpackTo(&i32data_message); - int32_t value = i32data_message.value(); - - auto status = library->WriteI32(session, control, value); - if (status < 0) { - std::cout << "MonikerWriteI32 error: " << status << std::endl; - } - return ::grpc::Status::OK; -} //--------------------------------------------------------------------- //--------------------------------------------------------------------- @@ -4282,13 +4508,6 @@ ::grpc::Status MonikerWriteI32(void* data, google::protobuf::Arena& arena, googl } -struct MonikerWriteI64Data -{ - NiFpga_Session session; - uint32_t control; - nifpga_grpc::I64Data data; - std::shared_ptr library; -}; ::grpc::Status NiFpgaService::BeginWriteI64(::grpc::ServerContext* context, const BeginWriteI64Request* request, BeginWriteI64Response* response) { @@ -4314,24 +4533,6 @@ ::grpc::Status NiFpgaService::BeginWriteI64(::grpc::ServerContext* context, cons return ::grpc::Status(::grpc::UNKNOWN, ex.what()); } } -::grpc::Status MonikerWriteI64(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData) -{ - MonikerWriteI64Data* function_data = (MonikerWriteI64Data*)data; - auto library = function_data->library; - - auto session = function_data->session; - auto control = function_data->control; - - I64Data i64data_message; - packedData.UnpackTo(&i64data_message); - int64_t value = i64data_message.value(); - - auto status = library->WriteI64(session, control, value); - if (status < 0) { - std::cout << "MonikerWriteI64 error: " << status << std::endl; - } - return ::grpc::Status::OK; -} //--------------------------------------------------------------------- //--------------------------------------------------------------------- @@ -4367,13 +4568,6 @@ ::grpc::Status MonikerWriteI64(void* data, google::protobuf::Arena& arena, googl } -struct MonikerWriteI8Data -{ - NiFpga_Session session; - uint32_t control; - nifpga_grpc::I32Data data; - std::shared_ptr library; -}; ::grpc::Status NiFpgaService::BeginWriteI8(::grpc::ServerContext* context, const BeginWriteI8Request* request, BeginWriteI8Response* response) { @@ -4399,28 +4593,6 @@ ::grpc::Status NiFpgaService::BeginWriteI8(::grpc::ServerContext* context, const return ::grpc::Status(::grpc::UNKNOWN, ex.what()); } } -::grpc::Status MonikerWriteI8(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData) -{ - MonikerWriteI8Data* function_data = (MonikerWriteI8Data*)data; - auto library = function_data->library; - - auto session = function_data->session; - auto control = function_data->control; - - I32Data i32data_message; - packedData.UnpackTo(&i32data_message); - int32_t value = i32data_message.value(); - if (value < std::numeric_limits::min() || value > std::numeric_limits::max()) { - std::string message("value " + std::to_string(value) + " doesn't fit in datatype int8_t"); - throw nidevice_grpc::ValueOutOfRangeException(message); - } - - auto status = library->WriteI8(session, control, value); - if (status < 0) { - std::cout << "MonikerWriteI8 error: " << status << std::endl; - } - return ::grpc::Status::OK; -} //--------------------------------------------------------------------- //--------------------------------------------------------------------- @@ -4480,13 +4652,6 @@ ::grpc::Status MonikerWriteI8(void* data, google::protobuf::Arena& arena, google } -struct MonikerWriteU16Data -{ - NiFpga_Session session; - uint32_t control; - nifpga_grpc::U32Data data; - std::shared_ptr library; -}; ::grpc::Status NiFpgaService::BeginWriteU16(::grpc::ServerContext* context, const BeginWriteU16Request* request, BeginWriteU16Response* response) { @@ -4512,28 +4677,6 @@ ::grpc::Status NiFpgaService::BeginWriteU16(::grpc::ServerContext* context, cons return ::grpc::Status(::grpc::UNKNOWN, ex.what()); } } -::grpc::Status MonikerWriteU16(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData) -{ - MonikerWriteU16Data* function_data = (MonikerWriteU16Data*)data; - auto library = function_data->library; - - auto session = function_data->session; - auto control = function_data->control; - - U32Data u32data_message; - packedData.UnpackTo(&u32data_message); - uint32_t value = u32data_message.value(); - if (value < std::numeric_limits::min() || value > std::numeric_limits::max()) { - std::string message("value " + std::to_string(value) + " doesn't fit in datatype uint16_t"); - throw nidevice_grpc::ValueOutOfRangeException(message); - } - - auto status = library->WriteU16(session, control, value); - if (status < 0) { - std::cout << "MonikerWriteU16 error: " << status << std::endl; - } - return ::grpc::Status::OK; -} //--------------------------------------------------------------------- //--------------------------------------------------------------------- @@ -4560,13 +4703,6 @@ ::grpc::Status MonikerWriteU16(void* data, google::protobuf::Arena& arena, googl } -struct MonikerWriteU32Data -{ - NiFpga_Session session; - uint32_t control; - nifpga_grpc::U32Data data; - std::shared_ptr library; -}; ::grpc::Status NiFpgaService::BeginWriteU32(::grpc::ServerContext* context, const BeginWriteU32Request* request, BeginWriteU32Response* response) { @@ -4592,24 +4728,6 @@ ::grpc::Status NiFpgaService::BeginWriteU32(::grpc::ServerContext* context, cons return ::grpc::Status(::grpc::UNKNOWN, ex.what()); } } -::grpc::Status MonikerWriteU32(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData) -{ - MonikerWriteU32Data* function_data = (MonikerWriteU32Data*)data; - auto library = function_data->library; - - auto session = function_data->session; - auto control = function_data->control; - - U32Data u32data_message; - packedData.UnpackTo(&u32data_message); - uint32_t value = u32data_message.value(); - - auto status = library->WriteU32(session, control, value); - if (status < 0) { - std::cout << "MonikerWriteU32 error: " << status << std::endl; - } - return ::grpc::Status::OK; -} //--------------------------------------------------------------------- //--------------------------------------------------------------------- @@ -4636,13 +4754,6 @@ ::grpc::Status MonikerWriteU32(void* data, google::protobuf::Arena& arena, googl } -struct MonikerWriteU64Data -{ - NiFpga_Session session; - uint32_t control; - nifpga_grpc::U64Data data; - std::shared_ptr library; -}; ::grpc::Status NiFpgaService::BeginWriteU64(::grpc::ServerContext* context, const BeginWriteU64Request* request, BeginWriteU64Response* response) { @@ -4668,24 +4779,6 @@ ::grpc::Status NiFpgaService::BeginWriteU64(::grpc::ServerContext* context, cons return ::grpc::Status(::grpc::UNKNOWN, ex.what()); } } -::grpc::Status MonikerWriteU64(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData) -{ - MonikerWriteU64Data* function_data = (MonikerWriteU64Data*)data; - auto library = function_data->library; - - auto session = function_data->session; - auto control = function_data->control; - - U64Data u64data_message; - packedData.UnpackTo(&u64data_message); - uint64_t value = u64data_message.value(); - - auto status = library->WriteU64(session, control, value); - if (status < 0) { - std::cout << "MonikerWriteU64 error: " << status << std::endl; - } - return ::grpc::Status::OK; -} //--------------------------------------------------------------------- //--------------------------------------------------------------------- @@ -4721,13 +4814,6 @@ ::grpc::Status MonikerWriteU64(void* data, google::protobuf::Arena& arena, googl } -struct MonikerWriteU8Data -{ - NiFpga_Session session; - uint32_t control; - nifpga_grpc::U32Data data; - std::shared_ptr library; -}; ::grpc::Status NiFpgaService::BeginWriteU8(::grpc::ServerContext* context, const BeginWriteU8Request* request, BeginWriteU8Response* response) { @@ -4753,28 +4839,6 @@ ::grpc::Status NiFpgaService::BeginWriteU8(::grpc::ServerContext* context, const return ::grpc::Status(::grpc::UNKNOWN, ex.what()); } } -::grpc::Status MonikerWriteU8(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData) -{ - MonikerWriteU8Data* function_data = (MonikerWriteU8Data*)data; - auto library = function_data->library; - - auto session = function_data->session; - auto control = function_data->control; - - U32Data u32data_message; - packedData.UnpackTo(&u32data_message); - uint32_t value = u32data_message.value(); - if (value < std::numeric_limits::min() || value > std::numeric_limits::max()) { - std::string message("value " + std::to_string(value) + " doesn't fit in datatype uint8_t"); - throw nidevice_grpc::ValueOutOfRangeException(message); - } - - auto status = library->WriteU8(session, control, value); - if (status < 0) { - std::cout << "MonikerWriteU8 error: " << status << std::endl; - } - return ::grpc::Status::OK; -} NiFpgaFeatureToggles::NiFpgaFeatureToggles( diff --git a/generated/nifpga/nifpga_service.h b/generated/nifpga/nifpga_service.h index 0203e7071..d764ed69b 100644 --- a/generated/nifpga/nifpga_service.h +++ b/generated/nifpga/nifpga_service.h @@ -30,6 +30,7 @@ struct NiFpgaFeatureToggles bool is_enabled; }; + void RegisterMonikerEndpoints(); ::grpc::Status MonikerReadArrayI16(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData); diff --git a/source/codegen/templates/service.cpp.mako b/source/codegen/templates/service.cpp.mako index 08befa151..97c3d5eab 100644 --- a/source/codegen/templates/service.cpp.mako +++ b/source/codegen/templates/service.cpp.mako @@ -12,15 +12,15 @@ custom_types = common_helpers.get_custom_types(config) (input_custom_types, output_custom_types) = common_helpers.get_input_and_output_custom_types(config, functions) has_async_functions = any(service_helpers.get_async_functions(functions)) has_two_dimension_functions = any(service_helpers.get_functions_with_two_dimension_param(functions)) -function_names = service_helpers.filter_proto_rpc_functions_to_generate(functions) +functions_to_generate = service_helpers.filter_proto_rpc_functions_to_generate(functions) data_moniker_functions = common_helpers.filter_streaming_functions(functions) # If there are any non-mockable functions, we need to call the library directly, which # means we need another include file -any_non_mockable_functions = any(not common_helpers.can_mock_function(functions[name]['parameters']) for name in function_names) +any_non_mockable_functions = any(not common_helpers.can_mock_function(functions[name]['parameters']) for name in functions_to_generate) # Define the constant for buffer too small if we have any of these functions. any_ivi_dance_functions = any( common_helpers.has_ivi_dance_with_a_twist_param(functions[name]['parameters']) or - common_helpers.has_ivi_dance_param(functions[name]['parameters']) for name in function_names) + common_helpers.has_ivi_dance_param(functions[name]['parameters']) for name in functions_to_generate) resource_repository_deps = service_helpers.get_driver_shared_resource_repository_ptr_deps(config, functions) %>\ @@ -63,6 +63,15 @@ namespace ${config["namespace_component"]}_grpc { using nidevice_grpc::converters::convert_from_grpc; using nidevice_grpc::converters::convert_to_grpc; using nidevice_grpc::converters::MatchState; +% for function_name in service_helpers.filter_proto_rpc_functions_to_generate(functions): +% if function_name in data_moniker_functions: +<% +function_data = functions[function_name] +parameters = function_data['parameters'] +%> +${mako_helper.define_moniker_streaming_structs(function_name=function_name, function_data=function_data, parameters=parameters)}\ +% endif +% endfor % if any_ivi_dance_functions: const auto kErrorReadBufferTooSmall = -200229; @@ -105,7 +114,7 @@ namespace ${config["namespace_component"]}_grpc { % endif % if data_moniker_functions: -void RegisterMoniker() +void RegisterMonikerEndpoints() { % for function_name in service_helpers.filter_proto_rpc_functions_to_generate(functions): % if function_name in data_moniker_functions: @@ -115,6 +124,14 @@ ${mako_helper.register_moniker_functions(function_name)}\ } % endif % for function_name in service_helpers.filter_proto_rpc_functions_to_generate(functions): +% if function_name in data_moniker_functions: +<% +function_data = functions[function_name] +%> +${mako_helper.define_moniker_function_body(function_name=function_name, function_data=function_data)}\ +% endif +% endfor +% for function_name in service_helpers.filter_proto_rpc_functions_to_generate(functions): <% function_data = functions[function_name] method_name = common_helpers.snake_to_pascal(function_name) diff --git a/source/codegen/templates/service.h.mako b/source/codegen/templates/service.h.mako index 2a4ec2cc9..9610fd31d 100644 --- a/source/codegen/templates/service.h.mako +++ b/source/codegen/templates/service.h.mako @@ -61,6 +61,7 @@ struct ${service_class_prefix}FeatureToggles % endfor }; % if data_moniker_functions: + void RegisterMonikerEndpoints(); % for function in data_moniker_functions: diff --git a/source/codegen/templates/service_helpers.mako b/source/codegen/templates/service_helpers.mako index 7ebbc4598..49f0de6b8 100644 --- a/source/codegen/templates/service_helpers.mako +++ b/source/codegen/templates/service_helpers.mako @@ -276,33 +276,72 @@ ${populate_response(function_data=function_data, parameters=parameters)}\ %> ::ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("${moniker_function_name}", ${moniker_function_name}); -<%def name="define_streaming_api(function_name, function_data, parameters)"> +<%def name="define_moniker_streaming_structs(function_name, function_data, parameters)">\ <% config = data['config'] - input_params = [p for p in parameters if common_helpers.is_input_parameter(p)] - output_params = [p for p in parameters if common_helpers.is_output_parameter(p)] + input_params = [p for p in function_data['parameters'] if common_helpers.is_input_parameter(p)] + streaming_param = common_helpers.get_streaming_parameter(function_data['parameters']) service_class_prefix = config["service_class_prefix"] - request_param = service_helpers.get_request_param(function_name) - response_param = service_helpers.get_response_param(function_name) + grpc_streaming_type = streaming_param['grpc_streaming_type'] + struct_name = f"Moniker{function_name.replace('Begin', '')}Data" if function_name.startswith('Begin') else f"Moniker{function_name}Data" +%>\ + struct ${struct_name} + { + % for param in input_params: + % if service_helpers.include_param(param, streaming_param): + ${param['type']} ${param['name']}; + % endif + % endfor + ${service_class_prefix.lower()}_grpc::${grpc_streaming_type} data; + std::shared_ptr<${service_class_prefix}LibraryInterface> library; + }; + + +<%def name="define_moniker_function_body(function_name, function_data)">\ +<% + config = data['config'] struct_name = f"Moniker{function_name.replace('Begin', '')}Data" if function_name.startswith('Begin') else f"Moniker{function_name}Data" moniker_function_name = common_helpers.get_data_moniker_function_name(function_name) - c_api_name = service_helpers.get_c_api_name(function_name) - streaming_param = common_helpers.get_streaming_parameter(parameters) + streaming_param = common_helpers.get_streaming_parameter(function_data['parameters']) streaming_type = streaming_param['type'] coerced_type, is_coerced_type_present = service_helpers.get_coerced_type_and_presence(streaming_type) grpc_streaming_type = streaming_param['grpc_streaming_type'] is_array = common_helpers.is_array(streaming_type) + arg_string = service_helpers.create_args(function_data['parameters']) + arg_string = arg_string.replace(", &moniker", "").strip() + data_type = streaming_type.replace("[]", "") + c_api_name = service_helpers.get_c_api_name(function_name) + input_params = [p for p in function_data['parameters'] if common_helpers.is_input_parameter(p)] %>\ -struct ${struct_name} +::grpc::Status ${moniker_function_name}(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData) { - % for param in input_params: - % if service_helpers.include_param(param, streaming_param): - ${param['type']} ${param['name']}; + ${struct_name}* function_data = (${struct_name}*)data; + auto library = function_data->library; + ${initialize_non_array_parameters(input_params, streaming_param)}\ + % if streaming_param and streaming_param['direction'] == 'out': + ${handle_out_direction(c_api_name, arg_string, data_type, streaming_type, is_coerced_type_present, streaming_param)}\ + % elif streaming_param and streaming_param['direction'] == 'in': + ${handle_in_direction(c_api_name, arg_string, data_type, grpc_streaming_type, streaming_type, coerced_type, is_coerced_type_present, is_array)}\ % endif - % endfor - ${service_class_prefix.lower()}_grpc::${grpc_streaming_type} data; - std::shared_ptr<${service_class_prefix}LibraryInterface> library; -}; + if (status < 0) { + std::cout << "${moniker_function_name} error: " << status << std::endl; + } + return ::grpc::Status::OK; +} + + +<%def name="define_streaming_api(function_name, function_data, parameters)"> +<% + config = data['config'] + input_params = [p for p in parameters if common_helpers.is_input_parameter(p)] + output_params = [p for p in parameters if common_helpers.is_output_parameter(p)] + service_class_prefix = config["service_class_prefix"] + request_param = service_helpers.get_request_param(function_name) + response_param = service_helpers.get_response_param(function_name) + struct_name = f"Moniker{function_name.replace('Begin', '')}Data" if function_name.startswith('Begin') else f"Moniker{function_name}Data" + moniker_function_name = common_helpers.get_data_moniker_function_name(function_name) + streaming_param = common_helpers.get_streaming_parameter(parameters) +%>\ ::grpc::Status ${service_class_prefix}Service::${function_name}(::grpc::ServerContext* context, ${request_param}, ${response_param}) { @@ -324,26 +363,6 @@ ${initialize_streaming_input_param(function_name, input_params, parameters, stre return ::grpc::Status(::grpc::UNKNOWN, ex.what()); } } -<% - arg_string= service_helpers.create_args(parameters) - arg_string = arg_string.replace(", &moniker", "").strip() - data_type = streaming_type.replace("[]", "") -%>\ -::grpc::Status ${moniker_function_name}(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData) -{ - ${struct_name}* function_data = (${struct_name}*)data; - auto library = function_data->library; - ${initialize_non_array_parameters(input_params, streaming_param)}\ - % if streaming_param and streaming_param['direction'] == 'out': - ${handle_out_direction(c_api_name, arg_string, data_type, streaming_type, is_coerced_type_present, streaming_param)}\ - % elif streaming_param and streaming_param['direction'] == 'in': - ${handle_in_direction(c_api_name, arg_string, data_type, grpc_streaming_type, streaming_type, coerced_type, is_coerced_type_present, is_array)}\ - % endif - if (status < 0) { - std::cout << "${moniker_function_name} error: " << status << std::endl; - } - return ::grpc::Status::OK; -} <%def name="handle_out_direction(c_api_name, arg_string, data_type, streaming_type, is_coerced_type_present, streaming_param)"> @@ -457,8 +476,8 @@ ${initialize_input_param(function_name, param, parameters)}\ <%def name="initialize_service_output_params(output_params)"> % for param in output_params: % if common_helpers.is_array(param['type']): - data->data.mutable_value()->Reserve(request->size()); - data->data.mutable_value()->Resize(request->size(), 0); + data->data.mutable_value()->Reserve(request->size()); + data->data.mutable_value()->Resize(request->size(), 0); % endif % endfor From 19ddbb3dbe4c5e42c0798dc83878a9fedf562673 Mon Sep 17 00:00:00 2001 From: Ayush Mehra Date: Wed, 6 Nov 2024 00:13:38 -0800 Subject: [PATCH 18/34] update filter streaming functions --- source/codegen/common_helpers.py | 10 +++++++--- .../templates/register_all_services.cpp.mako | 8 ++++++-- source/codegen/templates/service.cpp.mako | 16 ++++++++-------- source/codegen/templates/service_helpers.mako | 2 +- 4 files changed, 22 insertions(+), 14 deletions(-) diff --git a/source/codegen/common_helpers.py b/source/codegen/common_helpers.py index ec670a05d..13f8dbfbf 100644 --- a/source/codegen/common_helpers.py +++ b/source/codegen/common_helpers.py @@ -1204,9 +1204,13 @@ def get_params_needing_initialization(parameters: List[dict]) -> List[dict]: return [p for p in parameters if not (is_return_value(p) or is_get_last_error_output_param(p))] -def filter_streaming_functions(functions): - """Return function metadata only for functions that use the data moniker service.""" - return [name for name, function in functions.items() if function.get("is_streaming_api", False)] +def filter_streaming_functions(functions, functions_to_generate=None): + """Return function metadata only for functions that use the data moniker service and need to be generated.""" + if functions_to_generate is None: + functions_to_generate = functions.keys() + return [ + name for name in functions_to_generate if functions[name].get("is_streaming_api", False) + ] def get_data_moniker_function_name(function_name): diff --git a/source/codegen/templates/register_all_services.cpp.mako b/source/codegen/templates/register_all_services.cpp.mako index a25a97a8e..dee6ebdfc 100644 --- a/source/codegen/templates/register_all_services.cpp.mako +++ b/source/codegen/templates/register_all_services.cpp.mako @@ -70,17 +70,21 @@ std::shared_ptr>> register_all_services( feature_toggles)); \ % endfor +% if any(config.get("has_streaming_api", False) for config in driver_configs): + if (ni::data_monikers::is_sideband_streaming_enabled(feature_toggles)) { % for driver in drivers: <% config = driver["config"] namespace = f"{config['namespace_component']}_grpc" %>\ % if config.get("has_streaming_api", False): -<%block filter="common_helpers.os_conditional_compile_block(config)"> - ${namespace}::RegisterMonikerEndpoints(); +<%block filter="common_helpers.os_conditional_compile_block(config)">\ + ${namespace}::RegisterMonikerEndpoints(); \ % endif % endfor + } +% endif return service_vector; } diff --git a/source/codegen/templates/service.cpp.mako b/source/codegen/templates/service.cpp.mako index 97c3d5eab..aa4e517fa 100644 --- a/source/codegen/templates/service.cpp.mako +++ b/source/codegen/templates/service.cpp.mako @@ -13,7 +13,7 @@ custom_types = common_helpers.get_custom_types(config) has_async_functions = any(service_helpers.get_async_functions(functions)) has_two_dimension_functions = any(service_helpers.get_functions_with_two_dimension_param(functions)) functions_to_generate = service_helpers.filter_proto_rpc_functions_to_generate(functions) -data_moniker_functions = common_helpers.filter_streaming_functions(functions) +streaming_functions_to_generate = common_helpers.filter_streaming_functions(functions, functions_to_generate) # If there are any non-mockable functions, we need to call the library directly, which # means we need another include file any_non_mockable_functions = any(not common_helpers.can_mock_function(functions[name]['parameters']) for name in functions_to_generate) @@ -52,7 +52,7 @@ resource_repository_deps = service_helpers.get_driver_shared_resource_repository % if any_non_mockable_functions: #include "${module_name}_library.h" % endif -% if data_moniker_functions: +% if streaming_functions_to_generate: #include % endif @@ -64,7 +64,7 @@ namespace ${config["namespace_component"]}_grpc { using nidevice_grpc::converters::convert_to_grpc; using nidevice_grpc::converters::MatchState; % for function_name in service_helpers.filter_proto_rpc_functions_to_generate(functions): -% if function_name in data_moniker_functions: +% if function_name in streaming_functions_to_generate: <% function_data = functions[function_name] parameters = function_data['parameters'] @@ -113,18 +113,18 @@ ${mako_helper.define_moniker_streaming_structs(function_name=function_name, func } % endif -% if data_moniker_functions: +% if streaming_functions_to_generate: void RegisterMonikerEndpoints() { % for function_name in service_helpers.filter_proto_rpc_functions_to_generate(functions): -% if function_name in data_moniker_functions: +% if function_name in streaming_functions_to_generate: ${mako_helper.register_moniker_functions(function_name)}\ % endif % endfor } % endif % for function_name in service_helpers.filter_proto_rpc_functions_to_generate(functions): -% if function_name in data_moniker_functions: +% if function_name in streaming_functions_to_generate: <% function_data = functions[function_name] %> @@ -141,8 +141,8 @@ ${mako_helper.define_moniker_function_body(function_name=function_name, function response_type = service_helpers.get_response_type(method_name) is_async_streaming = common_helpers.has_async_streaming_response(function_data) %>\ -% if function_name in data_moniker_functions: -${mako_helper.define_streaming_api(function_name=function_name, function_data=function_data, parameters=parameters)}\ +% if function_name in streaming_functions_to_generate: +${mako_helper.define_streaming_api_body(function_name=function_name, function_data=function_data, parameters=parameters)}\ % else: //--------------------------------------------------------------------- //--------------------------------------------------------------------- diff --git a/source/codegen/templates/service_helpers.mako b/source/codegen/templates/service_helpers.mako index 49f0de6b8..eb76c628b 100644 --- a/source/codegen/templates/service_helpers.mako +++ b/source/codegen/templates/service_helpers.mako @@ -330,7 +330,7 @@ ${populate_response(function_data=function_data, parameters=parameters)}\ } -<%def name="define_streaming_api(function_name, function_data, parameters)"> +<%def name="define_streaming_api_body(function_name, function_data, parameters)"> <% config = data['config'] input_params = [p for p in parameters if common_helpers.is_input_parameter(p)] From 9f023269ccfd8eba8edaf0613addfc5e99d86639 Mon Sep 17 00:00:00 2001 From: Ayush Mehra Date: Wed, 6 Nov 2024 00:54:49 -0800 Subject: [PATCH 19/34] use streaming_functions_to_generate --- generated/register_all_services.cpp | 5 +++-- source/codegen/common_helpers.py | 2 +- source/codegen/templates/service.cpp.mako | 12 +++--------- 3 files changed, 7 insertions(+), 12 deletions(-) diff --git a/generated/register_all_services.cpp b/generated/register_all_services.cpp index 9f3c1b311..c6647506e 100644 --- a/generated/register_all_services.cpp +++ b/generated/register_all_services.cpp @@ -333,8 +333,9 @@ std::shared_ptr>> register_all_services( vi_session_repository, vi_object_repository, feature_toggles)); - - nifpga_grpc::RegisterMonikerEndpoints(); + if (ni::data_monikers::is_sideband_streaming_enabled(feature_toggles)) { + nifpga_grpc::RegisterMonikerEndpoints(); + } return service_vector; } diff --git a/source/codegen/common_helpers.py b/source/codegen/common_helpers.py index 13f8dbfbf..5c026a6f0 100644 --- a/source/codegen/common_helpers.py +++ b/source/codegen/common_helpers.py @@ -1205,7 +1205,7 @@ def get_params_needing_initialization(parameters: List[dict]) -> List[dict]: def filter_streaming_functions(functions, functions_to_generate=None): - """Return function metadata only for functions that use the data moniker service and need to be generated.""" + """Returns streaming functions that needs to be generated.""" if functions_to_generate is None: functions_to_generate = functions.keys() return [ diff --git a/source/codegen/templates/service.cpp.mako b/source/codegen/templates/service.cpp.mako index aa4e517fa..49296b0a4 100644 --- a/source/codegen/templates/service.cpp.mako +++ b/source/codegen/templates/service.cpp.mako @@ -63,14 +63,12 @@ namespace ${config["namespace_component"]}_grpc { using nidevice_grpc::converters::convert_from_grpc; using nidevice_grpc::converters::convert_to_grpc; using nidevice_grpc::converters::MatchState; -% for function_name in service_helpers.filter_proto_rpc_functions_to_generate(functions): -% if function_name in streaming_functions_to_generate: +% for function_name in streaming_functions_to_generate: <% function_data = functions[function_name] parameters = function_data['parameters'] %> ${mako_helper.define_moniker_streaming_structs(function_name=function_name, function_data=function_data, parameters=parameters)}\ -% endif % endfor % if any_ivi_dance_functions: @@ -116,20 +114,16 @@ ${mako_helper.define_moniker_streaming_structs(function_name=function_name, func % if streaming_functions_to_generate: void RegisterMonikerEndpoints() { -% for function_name in service_helpers.filter_proto_rpc_functions_to_generate(functions): -% if function_name in streaming_functions_to_generate: +% for function_name in streaming_functions_to_generate: ${mako_helper.register_moniker_functions(function_name)}\ -% endif % endfor } % endif -% for function_name in service_helpers.filter_proto_rpc_functions_to_generate(functions): -% if function_name in streaming_functions_to_generate: +% for function_name in streaming_functions_to_generate: <% function_data = functions[function_name] %> ${mako_helper.define_moniker_function_body(function_name=function_name, function_data=function_data)}\ -% endif % endfor % for function_name in service_helpers.filter_proto_rpc_functions_to_generate(functions): <% From 98bec2eea8240c6178222715fe532665fc7072ba Mon Sep 17 00:00:00 2001 From: Ayush Mehra Date: Wed, 6 Nov 2024 01:16:52 -0800 Subject: [PATCH 20/34] move define_streaming_api_body under else block --- generated/nifpga/nifpga_service.cpp | 544 +++++++++--------- source/codegen/common_helpers.py | 7 +- source/codegen/templates/service.cpp.mako | 6 +- source/codegen/templates/service_helpers.mako | 14 +- 4 files changed, 297 insertions(+), 274 deletions(-) diff --git a/generated/nifpga/nifpga_service.cpp b/generated/nifpga/nifpga_service.cpp index 539bd2695..769ae6289 100644 --- a/generated/nifpga/nifpga_service.cpp +++ b/generated/nifpga/nifpga_service.cpp @@ -1725,14 +1725,15 @@ ::grpc::Status MonikerWriteU8(void* data, google::protobuf::Arena& arena, google } } - - -::grpc::Status NiFpgaService::BeginReadArrayI16(::grpc::ServerContext* context, const BeginReadArrayI16Request* request, BeginReadArrayI16Response* response) -{ + //--------------------------------------------------------------------- + //--------------------------------------------------------------------- + ::grpc::Status NiFpgaService::BeginReadArrayI16(::grpc::ServerContext* context, const BeginReadArrayI16Request* request, BeginReadArrayI16Response* response) + { if (context->IsCancelled()) { - return ::grpc::Status::CANCELLED; + return ::grpc::Status::CANCELLED; } try { + auto session_grpc_session = request->session(); NiFpga_Session session = session_repository_->access_session(session_grpc_session.name()); uint32_t indicator = request->indicator(); @@ -1751,10 +1752,10 @@ ::grpc::Status NiFpgaService::BeginReadArrayI16(::grpc::ServerContext* context, response->set_allocated_moniker(moniker); return ::grpc::Status::OK; } - catch (std::exception& ex) { - return ::grpc::Status(::grpc::UNKNOWN, ex.what()); + catch (nidevice_grpc::NonDriverException& ex) { + return ex.GetStatus(); } -} + } //--------------------------------------------------------------------- //--------------------------------------------------------------------- @@ -1782,14 +1783,15 @@ ::grpc::Status NiFpgaService::BeginReadArrayI16(::grpc::ServerContext* context, } } - - -::grpc::Status NiFpgaService::BeginReadArrayI32(::grpc::ServerContext* context, const BeginReadArrayI32Request* request, BeginReadArrayI32Response* response) -{ + //--------------------------------------------------------------------- + //--------------------------------------------------------------------- + ::grpc::Status NiFpgaService::BeginReadArrayI32(::grpc::ServerContext* context, const BeginReadArrayI32Request* request, BeginReadArrayI32Response* response) + { if (context->IsCancelled()) { - return ::grpc::Status::CANCELLED; + return ::grpc::Status::CANCELLED; } try { + auto session_grpc_session = request->session(); NiFpga_Session session = session_repository_->access_session(session_grpc_session.name()); uint32_t indicator = request->indicator(); @@ -1808,10 +1810,10 @@ ::grpc::Status NiFpgaService::BeginReadArrayI32(::grpc::ServerContext* context, response->set_allocated_moniker(moniker); return ::grpc::Status::OK; } - catch (std::exception& ex) { - return ::grpc::Status(::grpc::UNKNOWN, ex.what()); + catch (nidevice_grpc::NonDriverException& ex) { + return ex.GetStatus(); } -} + } //--------------------------------------------------------------------- //--------------------------------------------------------------------- @@ -1839,14 +1841,15 @@ ::grpc::Status NiFpgaService::BeginReadArrayI32(::grpc::ServerContext* context, } } - - -::grpc::Status NiFpgaService::BeginReadArrayI64(::grpc::ServerContext* context, const BeginReadArrayI64Request* request, BeginReadArrayI64Response* response) -{ + //--------------------------------------------------------------------- + //--------------------------------------------------------------------- + ::grpc::Status NiFpgaService::BeginReadArrayI64(::grpc::ServerContext* context, const BeginReadArrayI64Request* request, BeginReadArrayI64Response* response) + { if (context->IsCancelled()) { - return ::grpc::Status::CANCELLED; + return ::grpc::Status::CANCELLED; } try { + auto session_grpc_session = request->session(); NiFpga_Session session = session_repository_->access_session(session_grpc_session.name()); uint32_t indicator = request->indicator(); @@ -1865,10 +1868,10 @@ ::grpc::Status NiFpgaService::BeginReadArrayI64(::grpc::ServerContext* context, response->set_allocated_moniker(moniker); return ::grpc::Status::OK; } - catch (std::exception& ex) { - return ::grpc::Status(::grpc::UNKNOWN, ex.what()); + catch (nidevice_grpc::NonDriverException& ex) { + return ex.GetStatus(); } -} + } //--------------------------------------------------------------------- //--------------------------------------------------------------------- @@ -1904,14 +1907,15 @@ ::grpc::Status NiFpgaService::BeginReadArrayI64(::grpc::ServerContext* context, } } - - -::grpc::Status NiFpgaService::BeginReadArrayI8(::grpc::ServerContext* context, const BeginReadArrayI8Request* request, BeginReadArrayI8Response* response) -{ + //--------------------------------------------------------------------- + //--------------------------------------------------------------------- + ::grpc::Status NiFpgaService::BeginReadArrayI8(::grpc::ServerContext* context, const BeginReadArrayI8Request* request, BeginReadArrayI8Response* response) + { if (context->IsCancelled()) { - return ::grpc::Status::CANCELLED; + return ::grpc::Status::CANCELLED; } try { + auto session_grpc_session = request->session(); NiFpga_Session session = session_repository_->access_session(session_grpc_session.name()); uint32_t indicator = request->indicator(); @@ -1930,10 +1934,10 @@ ::grpc::Status NiFpgaService::BeginReadArrayI8(::grpc::ServerContext* context, c response->set_allocated_moniker(moniker); return ::grpc::Status::OK; } - catch (std::exception& ex) { - return ::grpc::Status(::grpc::UNKNOWN, ex.what()); + catch (nidevice_grpc::NonDriverException& ex) { + return ex.GetStatus(); } -} + } //--------------------------------------------------------------------- //--------------------------------------------------------------------- @@ -1995,14 +1999,15 @@ ::grpc::Status NiFpgaService::BeginReadArrayI8(::grpc::ServerContext* context, c } } - - -::grpc::Status NiFpgaService::BeginReadArrayU16(::grpc::ServerContext* context, const BeginReadArrayU16Request* request, BeginReadArrayU16Response* response) -{ + //--------------------------------------------------------------------- + //--------------------------------------------------------------------- + ::grpc::Status NiFpgaService::BeginReadArrayU16(::grpc::ServerContext* context, const BeginReadArrayU16Request* request, BeginReadArrayU16Response* response) + { if (context->IsCancelled()) { - return ::grpc::Status::CANCELLED; + return ::grpc::Status::CANCELLED; } try { + auto session_grpc_session = request->session(); NiFpga_Session session = session_repository_->access_session(session_grpc_session.name()); uint32_t indicator = request->indicator(); @@ -2021,10 +2026,10 @@ ::grpc::Status NiFpgaService::BeginReadArrayU16(::grpc::ServerContext* context, response->set_allocated_moniker(moniker); return ::grpc::Status::OK; } - catch (std::exception& ex) { - return ::grpc::Status(::grpc::UNKNOWN, ex.what()); + catch (nidevice_grpc::NonDriverException& ex) { + return ex.GetStatus(); } -} + } //--------------------------------------------------------------------- //--------------------------------------------------------------------- @@ -2052,14 +2057,15 @@ ::grpc::Status NiFpgaService::BeginReadArrayU16(::grpc::ServerContext* context, } } - - -::grpc::Status NiFpgaService::BeginReadArrayU32(::grpc::ServerContext* context, const BeginReadArrayU32Request* request, BeginReadArrayU32Response* response) -{ + //--------------------------------------------------------------------- + //--------------------------------------------------------------------- + ::grpc::Status NiFpgaService::BeginReadArrayU32(::grpc::ServerContext* context, const BeginReadArrayU32Request* request, BeginReadArrayU32Response* response) + { if (context->IsCancelled()) { - return ::grpc::Status::CANCELLED; + return ::grpc::Status::CANCELLED; } try { + auto session_grpc_session = request->session(); NiFpga_Session session = session_repository_->access_session(session_grpc_session.name()); uint32_t indicator = request->indicator(); @@ -2078,10 +2084,10 @@ ::grpc::Status NiFpgaService::BeginReadArrayU32(::grpc::ServerContext* context, response->set_allocated_moniker(moniker); return ::grpc::Status::OK; } - catch (std::exception& ex) { - return ::grpc::Status(::grpc::UNKNOWN, ex.what()); + catch (nidevice_grpc::NonDriverException& ex) { + return ex.GetStatus(); } -} + } //--------------------------------------------------------------------- //--------------------------------------------------------------------- @@ -2109,14 +2115,15 @@ ::grpc::Status NiFpgaService::BeginReadArrayU32(::grpc::ServerContext* context, } } - - -::grpc::Status NiFpgaService::BeginReadArrayU64(::grpc::ServerContext* context, const BeginReadArrayU64Request* request, BeginReadArrayU64Response* response) -{ + //--------------------------------------------------------------------- + //--------------------------------------------------------------------- + ::grpc::Status NiFpgaService::BeginReadArrayU64(::grpc::ServerContext* context, const BeginReadArrayU64Request* request, BeginReadArrayU64Response* response) + { if (context->IsCancelled()) { - return ::grpc::Status::CANCELLED; + return ::grpc::Status::CANCELLED; } try { + auto session_grpc_session = request->session(); NiFpga_Session session = session_repository_->access_session(session_grpc_session.name()); uint32_t indicator = request->indicator(); @@ -2135,10 +2142,10 @@ ::grpc::Status NiFpgaService::BeginReadArrayU64(::grpc::ServerContext* context, response->set_allocated_moniker(moniker); return ::grpc::Status::OK; } - catch (std::exception& ex) { - return ::grpc::Status(::grpc::UNKNOWN, ex.what()); + catch (nidevice_grpc::NonDriverException& ex) { + return ex.GetStatus(); } -} + } //--------------------------------------------------------------------- //--------------------------------------------------------------------- @@ -2174,14 +2181,15 @@ ::grpc::Status NiFpgaService::BeginReadArrayU64(::grpc::ServerContext* context, } } - - -::grpc::Status NiFpgaService::BeginReadArrayU8(::grpc::ServerContext* context, const BeginReadArrayU8Request* request, BeginReadArrayU8Response* response) -{ + //--------------------------------------------------------------------- + //--------------------------------------------------------------------- + ::grpc::Status NiFpgaService::BeginReadArrayU8(::grpc::ServerContext* context, const BeginReadArrayU8Request* request, BeginReadArrayU8Response* response) + { if (context->IsCancelled()) { - return ::grpc::Status::CANCELLED; + return ::grpc::Status::CANCELLED; } try { + auto session_grpc_session = request->session(); NiFpga_Session session = session_repository_->access_session(session_grpc_session.name()); uint32_t indicator = request->indicator(); @@ -2200,10 +2208,10 @@ ::grpc::Status NiFpgaService::BeginReadArrayU8(::grpc::ServerContext* context, c response->set_allocated_moniker(moniker); return ::grpc::Status::OK; } - catch (std::exception& ex) { - return ::grpc::Status(::grpc::UNKNOWN, ex.what()); + catch (nidevice_grpc::NonDriverException& ex) { + return ex.GetStatus(); } -} + } //--------------------------------------------------------------------- //--------------------------------------------------------------------- @@ -2631,14 +2639,15 @@ ::grpc::Status NiFpgaService::BeginReadArrayU8(::grpc::ServerContext* context, c } } - - -::grpc::Status NiFpgaService::BeginReadI16(::grpc::ServerContext* context, const BeginReadI16Request* request, BeginReadI16Response* response) -{ + //--------------------------------------------------------------------- + //--------------------------------------------------------------------- + ::grpc::Status NiFpgaService::BeginReadI16(::grpc::ServerContext* context, const BeginReadI16Request* request, BeginReadI16Response* response) + { if (context->IsCancelled()) { - return ::grpc::Status::CANCELLED; + return ::grpc::Status::CANCELLED; } try { + auto session_grpc_session = request->session(); NiFpga_Session session = session_repository_->access_session(session_grpc_session.name()); uint32_t indicator = request->indicator(); @@ -2653,10 +2662,10 @@ ::grpc::Status NiFpgaService::BeginReadI16(::grpc::ServerContext* context, const response->set_allocated_moniker(moniker); return ::grpc::Status::OK; } - catch (std::exception& ex) { - return ::grpc::Status(::grpc::UNKNOWN, ex.what()); + catch (nidevice_grpc::NonDriverException& ex) { + return ex.GetStatus(); } -} + } //--------------------------------------------------------------------- //--------------------------------------------------------------------- @@ -2683,14 +2692,15 @@ ::grpc::Status NiFpgaService::BeginReadI16(::grpc::ServerContext* context, const } } - - -::grpc::Status NiFpgaService::BeginReadI32(::grpc::ServerContext* context, const BeginReadI32Request* request, BeginReadI32Response* response) -{ + //--------------------------------------------------------------------- + //--------------------------------------------------------------------- + ::grpc::Status NiFpgaService::BeginReadI32(::grpc::ServerContext* context, const BeginReadI32Request* request, BeginReadI32Response* response) + { if (context->IsCancelled()) { - return ::grpc::Status::CANCELLED; + return ::grpc::Status::CANCELLED; } try { + auto session_grpc_session = request->session(); NiFpga_Session session = session_repository_->access_session(session_grpc_session.name()); uint32_t indicator = request->indicator(); @@ -2705,10 +2715,10 @@ ::grpc::Status NiFpgaService::BeginReadI32(::grpc::ServerContext* context, const response->set_allocated_moniker(moniker); return ::grpc::Status::OK; } - catch (std::exception& ex) { - return ::grpc::Status(::grpc::UNKNOWN, ex.what()); + catch (nidevice_grpc::NonDriverException& ex) { + return ex.GetStatus(); } -} + } //--------------------------------------------------------------------- //--------------------------------------------------------------------- @@ -2735,14 +2745,15 @@ ::grpc::Status NiFpgaService::BeginReadI32(::grpc::ServerContext* context, const } } - - -::grpc::Status NiFpgaService::BeginReadI64(::grpc::ServerContext* context, const BeginReadI64Request* request, BeginReadI64Response* response) -{ + //--------------------------------------------------------------------- + //--------------------------------------------------------------------- + ::grpc::Status NiFpgaService::BeginReadI64(::grpc::ServerContext* context, const BeginReadI64Request* request, BeginReadI64Response* response) + { if (context->IsCancelled()) { - return ::grpc::Status::CANCELLED; + return ::grpc::Status::CANCELLED; } try { + auto session_grpc_session = request->session(); NiFpga_Session session = session_repository_->access_session(session_grpc_session.name()); uint32_t indicator = request->indicator(); @@ -2757,10 +2768,10 @@ ::grpc::Status NiFpgaService::BeginReadI64(::grpc::ServerContext* context, const response->set_allocated_moniker(moniker); return ::grpc::Status::OK; } - catch (std::exception& ex) { - return ::grpc::Status(::grpc::UNKNOWN, ex.what()); + catch (nidevice_grpc::NonDriverException& ex) { + return ex.GetStatus(); } -} + } //--------------------------------------------------------------------- //--------------------------------------------------------------------- @@ -2787,14 +2798,15 @@ ::grpc::Status NiFpgaService::BeginReadI64(::grpc::ServerContext* context, const } } - - -::grpc::Status NiFpgaService::BeginReadI8(::grpc::ServerContext* context, const BeginReadI8Request* request, BeginReadI8Response* response) -{ + //--------------------------------------------------------------------- + //--------------------------------------------------------------------- + ::grpc::Status NiFpgaService::BeginReadI8(::grpc::ServerContext* context, const BeginReadI8Request* request, BeginReadI8Response* response) + { if (context->IsCancelled()) { - return ::grpc::Status::CANCELLED; + return ::grpc::Status::CANCELLED; } try { + auto session_grpc_session = request->session(); NiFpga_Session session = session_repository_->access_session(session_grpc_session.name()); uint32_t indicator = request->indicator(); @@ -2809,10 +2821,10 @@ ::grpc::Status NiFpgaService::BeginReadI8(::grpc::ServerContext* context, const response->set_allocated_moniker(moniker); return ::grpc::Status::OK; } - catch (std::exception& ex) { - return ::grpc::Status(::grpc::UNKNOWN, ex.what()); + catch (nidevice_grpc::NonDriverException& ex) { + return ex.GetStatus(); } -} + } //--------------------------------------------------------------------- //--------------------------------------------------------------------- @@ -2864,14 +2876,15 @@ ::grpc::Status NiFpgaService::BeginReadI8(::grpc::ServerContext* context, const } } - - -::grpc::Status NiFpgaService::BeginReadU16(::grpc::ServerContext* context, const BeginReadU16Request* request, BeginReadU16Response* response) -{ + //--------------------------------------------------------------------- + //--------------------------------------------------------------------- + ::grpc::Status NiFpgaService::BeginReadU16(::grpc::ServerContext* context, const BeginReadU16Request* request, BeginReadU16Response* response) + { if (context->IsCancelled()) { - return ::grpc::Status::CANCELLED; + return ::grpc::Status::CANCELLED; } try { + auto session_grpc_session = request->session(); NiFpga_Session session = session_repository_->access_session(session_grpc_session.name()); uint32_t indicator = request->indicator(); @@ -2886,10 +2899,10 @@ ::grpc::Status NiFpgaService::BeginReadU16(::grpc::ServerContext* context, const response->set_allocated_moniker(moniker); return ::grpc::Status::OK; } - catch (std::exception& ex) { - return ::grpc::Status(::grpc::UNKNOWN, ex.what()); + catch (nidevice_grpc::NonDriverException& ex) { + return ex.GetStatus(); } -} + } //--------------------------------------------------------------------- //--------------------------------------------------------------------- @@ -2916,14 +2929,15 @@ ::grpc::Status NiFpgaService::BeginReadU16(::grpc::ServerContext* context, const } } - - -::grpc::Status NiFpgaService::BeginReadU32(::grpc::ServerContext* context, const BeginReadU32Request* request, BeginReadU32Response* response) -{ + //--------------------------------------------------------------------- + //--------------------------------------------------------------------- + ::grpc::Status NiFpgaService::BeginReadU32(::grpc::ServerContext* context, const BeginReadU32Request* request, BeginReadU32Response* response) + { if (context->IsCancelled()) { - return ::grpc::Status::CANCELLED; + return ::grpc::Status::CANCELLED; } try { + auto session_grpc_session = request->session(); NiFpga_Session session = session_repository_->access_session(session_grpc_session.name()); uint32_t indicator = request->indicator(); @@ -2938,10 +2952,10 @@ ::grpc::Status NiFpgaService::BeginReadU32(::grpc::ServerContext* context, const response->set_allocated_moniker(moniker); return ::grpc::Status::OK; } - catch (std::exception& ex) { - return ::grpc::Status(::grpc::UNKNOWN, ex.what()); + catch (nidevice_grpc::NonDriverException& ex) { + return ex.GetStatus(); } -} + } //--------------------------------------------------------------------- //--------------------------------------------------------------------- @@ -2968,14 +2982,15 @@ ::grpc::Status NiFpgaService::BeginReadU32(::grpc::ServerContext* context, const } } - - -::grpc::Status NiFpgaService::BeginReadU64(::grpc::ServerContext* context, const BeginReadU64Request* request, BeginReadU64Response* response) -{ + //--------------------------------------------------------------------- + //--------------------------------------------------------------------- + ::grpc::Status NiFpgaService::BeginReadU64(::grpc::ServerContext* context, const BeginReadU64Request* request, BeginReadU64Response* response) + { if (context->IsCancelled()) { - return ::grpc::Status::CANCELLED; + return ::grpc::Status::CANCELLED; } try { + auto session_grpc_session = request->session(); NiFpga_Session session = session_repository_->access_session(session_grpc_session.name()); uint32_t indicator = request->indicator(); @@ -2990,10 +3005,10 @@ ::grpc::Status NiFpgaService::BeginReadU64(::grpc::ServerContext* context, const response->set_allocated_moniker(moniker); return ::grpc::Status::OK; } - catch (std::exception& ex) { - return ::grpc::Status(::grpc::UNKNOWN, ex.what()); + catch (nidevice_grpc::NonDriverException& ex) { + return ex.GetStatus(); } -} + } //--------------------------------------------------------------------- //--------------------------------------------------------------------- @@ -3020,14 +3035,15 @@ ::grpc::Status NiFpgaService::BeginReadU64(::grpc::ServerContext* context, const } } - - -::grpc::Status NiFpgaService::BeginReadU8(::grpc::ServerContext* context, const BeginReadU8Request* request, BeginReadU8Response* response) -{ + //--------------------------------------------------------------------- + //--------------------------------------------------------------------- + ::grpc::Status NiFpgaService::BeginReadU8(::grpc::ServerContext* context, const BeginReadU8Request* request, BeginReadU8Response* response) + { if (context->IsCancelled()) { - return ::grpc::Status::CANCELLED; + return ::grpc::Status::CANCELLED; } try { + auto session_grpc_session = request->session(); NiFpga_Session session = session_repository_->access_session(session_grpc_session.name()); uint32_t indicator = request->indicator(); @@ -3042,10 +3058,10 @@ ::grpc::Status NiFpgaService::BeginReadU8(::grpc::ServerContext* context, const response->set_allocated_moniker(moniker); return ::grpc::Status::OK; } - catch (std::exception& ex) { - return ::grpc::Status(::grpc::UNKNOWN, ex.what()); + catch (nidevice_grpc::NonDriverException& ex) { + return ex.GetStatus(); } -} + } //--------------------------------------------------------------------- //--------------------------------------------------------------------- @@ -3481,14 +3497,15 @@ ::grpc::Status NiFpgaService::BeginReadU8(::grpc::ServerContext* context, const } } - - -::grpc::Status NiFpgaService::BeginWriteArrayI16(::grpc::ServerContext* context, const BeginWriteArrayI16Request* request, BeginWriteArrayI16Response* response) -{ + //--------------------------------------------------------------------- + //--------------------------------------------------------------------- + ::grpc::Status NiFpgaService::BeginWriteArrayI16(::grpc::ServerContext* context, const BeginWriteArrayI16Request* request, BeginWriteArrayI16Response* response) + { if (context->IsCancelled()) { - return ::grpc::Status::CANCELLED; + return ::grpc::Status::CANCELLED; } try { + auto session_grpc_session = request->session(); NiFpga_Session session = session_repository_->access_session(session_grpc_session.name()); uint32_t control = request->control(); @@ -3503,10 +3520,10 @@ ::grpc::Status NiFpgaService::BeginWriteArrayI16(::grpc::ServerContext* context, response->set_allocated_moniker(moniker); return ::grpc::Status::OK; } - catch (std::exception& ex) { - return ::grpc::Status(::grpc::UNKNOWN, ex.what()); + catch (nidevice_grpc::NonDriverException& ex) { + return ex.GetStatus(); } -} + } //--------------------------------------------------------------------- //--------------------------------------------------------------------- @@ -3533,14 +3550,15 @@ ::grpc::Status NiFpgaService::BeginWriteArrayI16(::grpc::ServerContext* context, } } - - -::grpc::Status NiFpgaService::BeginWriteArrayI32(::grpc::ServerContext* context, const BeginWriteArrayI32Request* request, BeginWriteArrayI32Response* response) -{ + //--------------------------------------------------------------------- + //--------------------------------------------------------------------- + ::grpc::Status NiFpgaService::BeginWriteArrayI32(::grpc::ServerContext* context, const BeginWriteArrayI32Request* request, BeginWriteArrayI32Response* response) + { if (context->IsCancelled()) { - return ::grpc::Status::CANCELLED; + return ::grpc::Status::CANCELLED; } try { + auto session_grpc_session = request->session(); NiFpga_Session session = session_repository_->access_session(session_grpc_session.name()); uint32_t control = request->control(); @@ -3555,10 +3573,10 @@ ::grpc::Status NiFpgaService::BeginWriteArrayI32(::grpc::ServerContext* context, response->set_allocated_moniker(moniker); return ::grpc::Status::OK; } - catch (std::exception& ex) { - return ::grpc::Status(::grpc::UNKNOWN, ex.what()); + catch (nidevice_grpc::NonDriverException& ex) { + return ex.GetStatus(); } -} + } //--------------------------------------------------------------------- //--------------------------------------------------------------------- @@ -3585,14 +3603,15 @@ ::grpc::Status NiFpgaService::BeginWriteArrayI32(::grpc::ServerContext* context, } } - - -::grpc::Status NiFpgaService::BeginWriteArrayI64(::grpc::ServerContext* context, const BeginWriteArrayI64Request* request, BeginWriteArrayI64Response* response) -{ + //--------------------------------------------------------------------- + //--------------------------------------------------------------------- + ::grpc::Status NiFpgaService::BeginWriteArrayI64(::grpc::ServerContext* context, const BeginWriteArrayI64Request* request, BeginWriteArrayI64Response* response) + { if (context->IsCancelled()) { - return ::grpc::Status::CANCELLED; + return ::grpc::Status::CANCELLED; } try { + auto session_grpc_session = request->session(); NiFpga_Session session = session_repository_->access_session(session_grpc_session.name()); uint32_t control = request->control(); @@ -3607,10 +3626,10 @@ ::grpc::Status NiFpgaService::BeginWriteArrayI64(::grpc::ServerContext* context, response->set_allocated_moniker(moniker); return ::grpc::Status::OK; } - catch (std::exception& ex) { - return ::grpc::Status(::grpc::UNKNOWN, ex.what()); + catch (nidevice_grpc::NonDriverException& ex) { + return ex.GetStatus(); } -} + } //--------------------------------------------------------------------- //--------------------------------------------------------------------- @@ -3654,14 +3673,15 @@ ::grpc::Status NiFpgaService::BeginWriteArrayI64(::grpc::ServerContext* context, } } - - -::grpc::Status NiFpgaService::BeginWriteArrayI8(::grpc::ServerContext* context, const BeginWriteArrayI8Request* request, BeginWriteArrayI8Response* response) -{ + //--------------------------------------------------------------------- + //--------------------------------------------------------------------- + ::grpc::Status NiFpgaService::BeginWriteArrayI8(::grpc::ServerContext* context, const BeginWriteArrayI8Request* request, BeginWriteArrayI8Response* response) + { if (context->IsCancelled()) { - return ::grpc::Status::CANCELLED; + return ::grpc::Status::CANCELLED; } try { + auto session_grpc_session = request->session(); NiFpga_Session session = session_repository_->access_session(session_grpc_session.name()); uint32_t control = request->control(); @@ -3676,10 +3696,10 @@ ::grpc::Status NiFpgaService::BeginWriteArrayI8(::grpc::ServerContext* context, response->set_allocated_moniker(moniker); return ::grpc::Status::OK; } - catch (std::exception& ex) { - return ::grpc::Status(::grpc::UNKNOWN, ex.what()); + catch (nidevice_grpc::NonDriverException& ex) { + return ex.GetStatus(); } -} + } //--------------------------------------------------------------------- //--------------------------------------------------------------------- @@ -3748,14 +3768,15 @@ ::grpc::Status NiFpgaService::BeginWriteArrayI8(::grpc::ServerContext* context, } } - - -::grpc::Status NiFpgaService::BeginWriteArrayU16(::grpc::ServerContext* context, const BeginWriteArrayU16Request* request, BeginWriteArrayU16Response* response) -{ + //--------------------------------------------------------------------- + //--------------------------------------------------------------------- + ::grpc::Status NiFpgaService::BeginWriteArrayU16(::grpc::ServerContext* context, const BeginWriteArrayU16Request* request, BeginWriteArrayU16Response* response) + { if (context->IsCancelled()) { - return ::grpc::Status::CANCELLED; + return ::grpc::Status::CANCELLED; } try { + auto session_grpc_session = request->session(); NiFpga_Session session = session_repository_->access_session(session_grpc_session.name()); uint32_t control = request->control(); @@ -3770,10 +3791,10 @@ ::grpc::Status NiFpgaService::BeginWriteArrayU16(::grpc::ServerContext* context, response->set_allocated_moniker(moniker); return ::grpc::Status::OK; } - catch (std::exception& ex) { - return ::grpc::Status(::grpc::UNKNOWN, ex.what()); + catch (nidevice_grpc::NonDriverException& ex) { + return ex.GetStatus(); } -} + } //--------------------------------------------------------------------- //--------------------------------------------------------------------- @@ -3800,14 +3821,15 @@ ::grpc::Status NiFpgaService::BeginWriteArrayU16(::grpc::ServerContext* context, } } - - -::grpc::Status NiFpgaService::BeginWriteArrayU32(::grpc::ServerContext* context, const BeginWriteArrayU32Request* request, BeginWriteArrayU32Response* response) -{ + //--------------------------------------------------------------------- + //--------------------------------------------------------------------- + ::grpc::Status NiFpgaService::BeginWriteArrayU32(::grpc::ServerContext* context, const BeginWriteArrayU32Request* request, BeginWriteArrayU32Response* response) + { if (context->IsCancelled()) { - return ::grpc::Status::CANCELLED; + return ::grpc::Status::CANCELLED; } try { + auto session_grpc_session = request->session(); NiFpga_Session session = session_repository_->access_session(session_grpc_session.name()); uint32_t control = request->control(); @@ -3822,10 +3844,10 @@ ::grpc::Status NiFpgaService::BeginWriteArrayU32(::grpc::ServerContext* context, response->set_allocated_moniker(moniker); return ::grpc::Status::OK; } - catch (std::exception& ex) { - return ::grpc::Status(::grpc::UNKNOWN, ex.what()); + catch (nidevice_grpc::NonDriverException& ex) { + return ex.GetStatus(); } -} + } //--------------------------------------------------------------------- //--------------------------------------------------------------------- @@ -3852,14 +3874,15 @@ ::grpc::Status NiFpgaService::BeginWriteArrayU32(::grpc::ServerContext* context, } } - - -::grpc::Status NiFpgaService::BeginWriteArrayU64(::grpc::ServerContext* context, const BeginWriteArrayU64Request* request, BeginWriteArrayU64Response* response) -{ + //--------------------------------------------------------------------- + //--------------------------------------------------------------------- + ::grpc::Status NiFpgaService::BeginWriteArrayU64(::grpc::ServerContext* context, const BeginWriteArrayU64Request* request, BeginWriteArrayU64Response* response) + { if (context->IsCancelled()) { - return ::grpc::Status::CANCELLED; + return ::grpc::Status::CANCELLED; } try { + auto session_grpc_session = request->session(); NiFpga_Session session = session_repository_->access_session(session_grpc_session.name()); uint32_t control = request->control(); @@ -3874,10 +3897,10 @@ ::grpc::Status NiFpgaService::BeginWriteArrayU64(::grpc::ServerContext* context, response->set_allocated_moniker(moniker); return ::grpc::Status::OK; } - catch (std::exception& ex) { - return ::grpc::Status(::grpc::UNKNOWN, ex.what()); + catch (nidevice_grpc::NonDriverException& ex) { + return ex.GetStatus(); } -} + } //--------------------------------------------------------------------- //--------------------------------------------------------------------- @@ -3921,14 +3944,15 @@ ::grpc::Status NiFpgaService::BeginWriteArrayU64(::grpc::ServerContext* context, } } - - -::grpc::Status NiFpgaService::BeginWriteArrayU8(::grpc::ServerContext* context, const BeginWriteArrayU8Request* request, BeginWriteArrayU8Response* response) -{ + //--------------------------------------------------------------------- + //--------------------------------------------------------------------- + ::grpc::Status NiFpgaService::BeginWriteArrayU8(::grpc::ServerContext* context, const BeginWriteArrayU8Request* request, BeginWriteArrayU8Response* response) + { if (context->IsCancelled()) { - return ::grpc::Status::CANCELLED; + return ::grpc::Status::CANCELLED; } try { + auto session_grpc_session = request->session(); NiFpga_Session session = session_repository_->access_session(session_grpc_session.name()); uint32_t control = request->control(); @@ -3943,10 +3967,10 @@ ::grpc::Status NiFpgaService::BeginWriteArrayU8(::grpc::ServerContext* context, response->set_allocated_moniker(moniker); return ::grpc::Status::OK; } - catch (std::exception& ex) { - return ::grpc::Status(::grpc::UNKNOWN, ex.what()); + catch (nidevice_grpc::NonDriverException& ex) { + return ex.GetStatus(); } -} + } //--------------------------------------------------------------------- //--------------------------------------------------------------------- @@ -4405,14 +4429,15 @@ ::grpc::Status NiFpgaService::BeginWriteArrayU8(::grpc::ServerContext* context, } } - - -::grpc::Status NiFpgaService::BeginWriteI16(::grpc::ServerContext* context, const BeginWriteI16Request* request, BeginWriteI16Response* response) -{ + //--------------------------------------------------------------------- + //--------------------------------------------------------------------- + ::grpc::Status NiFpgaService::BeginWriteI16(::grpc::ServerContext* context, const BeginWriteI16Request* request, BeginWriteI16Response* response) + { if (context->IsCancelled()) { - return ::grpc::Status::CANCELLED; + return ::grpc::Status::CANCELLED; } try { + auto session_grpc_session = request->session(); NiFpga_Session session = session_repository_->access_session(session_grpc_session.name()); uint32_t control = request->control(); @@ -4427,10 +4452,10 @@ ::grpc::Status NiFpgaService::BeginWriteI16(::grpc::ServerContext* context, cons response->set_allocated_moniker(moniker); return ::grpc::Status::OK; } - catch (std::exception& ex) { - return ::grpc::Status(::grpc::UNKNOWN, ex.what()); + catch (nidevice_grpc::NonDriverException& ex) { + return ex.GetStatus(); } -} + } //--------------------------------------------------------------------- //--------------------------------------------------------------------- @@ -4456,14 +4481,15 @@ ::grpc::Status NiFpgaService::BeginWriteI16(::grpc::ServerContext* context, cons } } - - -::grpc::Status NiFpgaService::BeginWriteI32(::grpc::ServerContext* context, const BeginWriteI32Request* request, BeginWriteI32Response* response) -{ + //--------------------------------------------------------------------- + //--------------------------------------------------------------------- + ::grpc::Status NiFpgaService::BeginWriteI32(::grpc::ServerContext* context, const BeginWriteI32Request* request, BeginWriteI32Response* response) + { if (context->IsCancelled()) { - return ::grpc::Status::CANCELLED; + return ::grpc::Status::CANCELLED; } try { + auto session_grpc_session = request->session(); NiFpga_Session session = session_repository_->access_session(session_grpc_session.name()); uint32_t control = request->control(); @@ -4478,10 +4504,10 @@ ::grpc::Status NiFpgaService::BeginWriteI32(::grpc::ServerContext* context, cons response->set_allocated_moniker(moniker); return ::grpc::Status::OK; } - catch (std::exception& ex) { - return ::grpc::Status(::grpc::UNKNOWN, ex.what()); + catch (nidevice_grpc::NonDriverException& ex) { + return ex.GetStatus(); } -} + } //--------------------------------------------------------------------- //--------------------------------------------------------------------- @@ -4507,14 +4533,15 @@ ::grpc::Status NiFpgaService::BeginWriteI32(::grpc::ServerContext* context, cons } } - - -::grpc::Status NiFpgaService::BeginWriteI64(::grpc::ServerContext* context, const BeginWriteI64Request* request, BeginWriteI64Response* response) -{ + //--------------------------------------------------------------------- + //--------------------------------------------------------------------- + ::grpc::Status NiFpgaService::BeginWriteI64(::grpc::ServerContext* context, const BeginWriteI64Request* request, BeginWriteI64Response* response) + { if (context->IsCancelled()) { - return ::grpc::Status::CANCELLED; + return ::grpc::Status::CANCELLED; } try { + auto session_grpc_session = request->session(); NiFpga_Session session = session_repository_->access_session(session_grpc_session.name()); uint32_t control = request->control(); @@ -4529,10 +4556,10 @@ ::grpc::Status NiFpgaService::BeginWriteI64(::grpc::ServerContext* context, cons response->set_allocated_moniker(moniker); return ::grpc::Status::OK; } - catch (std::exception& ex) { - return ::grpc::Status(::grpc::UNKNOWN, ex.what()); + catch (nidevice_grpc::NonDriverException& ex) { + return ex.GetStatus(); } -} + } //--------------------------------------------------------------------- //--------------------------------------------------------------------- @@ -4567,14 +4594,15 @@ ::grpc::Status NiFpgaService::BeginWriteI64(::grpc::ServerContext* context, cons } } - - -::grpc::Status NiFpgaService::BeginWriteI8(::grpc::ServerContext* context, const BeginWriteI8Request* request, BeginWriteI8Response* response) -{ + //--------------------------------------------------------------------- + //--------------------------------------------------------------------- + ::grpc::Status NiFpgaService::BeginWriteI8(::grpc::ServerContext* context, const BeginWriteI8Request* request, BeginWriteI8Response* response) + { if (context->IsCancelled()) { - return ::grpc::Status::CANCELLED; + return ::grpc::Status::CANCELLED; } try { + auto session_grpc_session = request->session(); NiFpga_Session session = session_repository_->access_session(session_grpc_session.name()); uint32_t control = request->control(); @@ -4589,10 +4617,10 @@ ::grpc::Status NiFpgaService::BeginWriteI8(::grpc::ServerContext* context, const response->set_allocated_moniker(moniker); return ::grpc::Status::OK; } - catch (std::exception& ex) { - return ::grpc::Status(::grpc::UNKNOWN, ex.what()); + catch (nidevice_grpc::NonDriverException& ex) { + return ex.GetStatus(); } -} + } //--------------------------------------------------------------------- //--------------------------------------------------------------------- @@ -4651,14 +4679,15 @@ ::grpc::Status NiFpgaService::BeginWriteI8(::grpc::ServerContext* context, const } } - - -::grpc::Status NiFpgaService::BeginWriteU16(::grpc::ServerContext* context, const BeginWriteU16Request* request, BeginWriteU16Response* response) -{ + //--------------------------------------------------------------------- + //--------------------------------------------------------------------- + ::grpc::Status NiFpgaService::BeginWriteU16(::grpc::ServerContext* context, const BeginWriteU16Request* request, BeginWriteU16Response* response) + { if (context->IsCancelled()) { - return ::grpc::Status::CANCELLED; + return ::grpc::Status::CANCELLED; } try { + auto session_grpc_session = request->session(); NiFpga_Session session = session_repository_->access_session(session_grpc_session.name()); uint32_t control = request->control(); @@ -4673,10 +4702,10 @@ ::grpc::Status NiFpgaService::BeginWriteU16(::grpc::ServerContext* context, cons response->set_allocated_moniker(moniker); return ::grpc::Status::OK; } - catch (std::exception& ex) { - return ::grpc::Status(::grpc::UNKNOWN, ex.what()); + catch (nidevice_grpc::NonDriverException& ex) { + return ex.GetStatus(); } -} + } //--------------------------------------------------------------------- //--------------------------------------------------------------------- @@ -4702,14 +4731,15 @@ ::grpc::Status NiFpgaService::BeginWriteU16(::grpc::ServerContext* context, cons } } - - -::grpc::Status NiFpgaService::BeginWriteU32(::grpc::ServerContext* context, const BeginWriteU32Request* request, BeginWriteU32Response* response) -{ + //--------------------------------------------------------------------- + //--------------------------------------------------------------------- + ::grpc::Status NiFpgaService::BeginWriteU32(::grpc::ServerContext* context, const BeginWriteU32Request* request, BeginWriteU32Response* response) + { if (context->IsCancelled()) { - return ::grpc::Status::CANCELLED; + return ::grpc::Status::CANCELLED; } try { + auto session_grpc_session = request->session(); NiFpga_Session session = session_repository_->access_session(session_grpc_session.name()); uint32_t control = request->control(); @@ -4724,10 +4754,10 @@ ::grpc::Status NiFpgaService::BeginWriteU32(::grpc::ServerContext* context, cons response->set_allocated_moniker(moniker); return ::grpc::Status::OK; } - catch (std::exception& ex) { - return ::grpc::Status(::grpc::UNKNOWN, ex.what()); + catch (nidevice_grpc::NonDriverException& ex) { + return ex.GetStatus(); } -} + } //--------------------------------------------------------------------- //--------------------------------------------------------------------- @@ -4753,14 +4783,15 @@ ::grpc::Status NiFpgaService::BeginWriteU32(::grpc::ServerContext* context, cons } } - - -::grpc::Status NiFpgaService::BeginWriteU64(::grpc::ServerContext* context, const BeginWriteU64Request* request, BeginWriteU64Response* response) -{ + //--------------------------------------------------------------------- + //--------------------------------------------------------------------- + ::grpc::Status NiFpgaService::BeginWriteU64(::grpc::ServerContext* context, const BeginWriteU64Request* request, BeginWriteU64Response* response) + { if (context->IsCancelled()) { - return ::grpc::Status::CANCELLED; + return ::grpc::Status::CANCELLED; } try { + auto session_grpc_session = request->session(); NiFpga_Session session = session_repository_->access_session(session_grpc_session.name()); uint32_t control = request->control(); @@ -4775,10 +4806,10 @@ ::grpc::Status NiFpgaService::BeginWriteU64(::grpc::ServerContext* context, cons response->set_allocated_moniker(moniker); return ::grpc::Status::OK; } - catch (std::exception& ex) { - return ::grpc::Status(::grpc::UNKNOWN, ex.what()); + catch (nidevice_grpc::NonDriverException& ex) { + return ex.GetStatus(); } -} + } //--------------------------------------------------------------------- //--------------------------------------------------------------------- @@ -4813,14 +4844,15 @@ ::grpc::Status NiFpgaService::BeginWriteU64(::grpc::ServerContext* context, cons } } - - -::grpc::Status NiFpgaService::BeginWriteU8(::grpc::ServerContext* context, const BeginWriteU8Request* request, BeginWriteU8Response* response) -{ + //--------------------------------------------------------------------- + //--------------------------------------------------------------------- + ::grpc::Status NiFpgaService::BeginWriteU8(::grpc::ServerContext* context, const BeginWriteU8Request* request, BeginWriteU8Response* response) + { if (context->IsCancelled()) { - return ::grpc::Status::CANCELLED; + return ::grpc::Status::CANCELLED; } try { + auto session_grpc_session = request->session(); NiFpga_Session session = session_repository_->access_session(session_grpc_session.name()); uint32_t control = request->control(); @@ -4835,10 +4867,10 @@ ::grpc::Status NiFpgaService::BeginWriteU8(::grpc::ServerContext* context, const response->set_allocated_moniker(moniker); return ::grpc::Status::OK; } - catch (std::exception& ex) { - return ::grpc::Status(::grpc::UNKNOWN, ex.what()); + catch (nidevice_grpc::NonDriverException& ex) { + return ex.GetStatus(); } -} + } NiFpgaFeatureToggles::NiFpgaFeatureToggles( diff --git a/source/codegen/common_helpers.py b/source/codegen/common_helpers.py index 5c026a6f0..3cc93aacc 100644 --- a/source/codegen/common_helpers.py +++ b/source/codegen/common_helpers.py @@ -1205,7 +1205,7 @@ def get_params_needing_initialization(parameters: List[dict]) -> List[dict]: def filter_streaming_functions(functions, functions_to_generate=None): - """Returns streaming functions that needs to be generated.""" + """Return streaming functions that need to be generated.""" if functions_to_generate is None: functions_to_generate = functions.keys() return [ @@ -1216,3 +1216,8 @@ def filter_streaming_functions(functions, functions_to_generate=None): def get_data_moniker_function_name(function_name): """Return the corresponding moniker function name for the given C API function.""" return function_name.replace("Begin", "Moniker") + + +def is_function_in_streaming_functions(function_name, streaming_functions_to_generate): + """Check if a function name is in the streaming functions to generate.""" + return function_name in streaming_functions_to_generate diff --git a/source/codegen/templates/service.cpp.mako b/source/codegen/templates/service.cpp.mako index 49296b0a4..2e5fec5f5 100644 --- a/source/codegen/templates/service.cpp.mako +++ b/source/codegen/templates/service.cpp.mako @@ -135,9 +135,6 @@ ${mako_helper.define_moniker_function_body(function_name=function_name, function response_type = service_helpers.get_response_type(method_name) is_async_streaming = common_helpers.has_async_streaming_response(function_data) %>\ -% if function_name in streaming_functions_to_generate: -${mako_helper.define_streaming_api_body(function_name=function_name, function_data=function_data, parameters=parameters)}\ -% else: //--------------------------------------------------------------------- //--------------------------------------------------------------------- % if is_async_streaming: @@ -165,6 +162,8 @@ ${mako_helper.define_ivi_dance_method_body(function_name=function_name, function ${mako_helper.define_ivi_dance_with_a_twist_method_body(function_name=function_name, function_data=function_data, parameters=parameters)} % elif common_helpers.has_repeated_varargs_parameter(parameters): ${mako_helper.define_repeated_varargs_method_body(function_name=function_name, function_data=function_data, parameters=parameters)} +% elif common_helpers.is_function_in_streaming_functions(function_name, streaming_functions_to_generate): +${mako_helper.define_streaming_api_body(function_name=function_name, function_data=function_data, parameters=parameters)} % else: ${mako_helper.define_simple_method_body(function_name=function_name, function_data=function_data, parameters=parameters)} % endif @@ -174,7 +173,6 @@ ${mako_helper.define_simple_method_body(function_name=function_name, function_da } } % endif -% endif % endfor diff --git a/source/codegen/templates/service_helpers.mako b/source/codegen/templates/service_helpers.mako index eb76c628b..309a16a7a 100644 --- a/source/codegen/templates/service_helpers.mako +++ b/source/codegen/templates/service_helpers.mako @@ -342,13 +342,6 @@ ${populate_response(function_data=function_data, parameters=parameters)}\ moniker_function_name = common_helpers.get_data_moniker_function_name(function_name) streaming_param = common_helpers.get_streaming_parameter(parameters) %>\ - -::grpc::Status ${service_class_prefix}Service::${function_name}(::grpc::ServerContext* context, ${request_param}, ${response_param}) -{ - if (context->IsCancelled()) { - return ::grpc::Status::CANCELLED; - } - try { ${initialize_streaming_input_param(function_name, input_params, parameters, streaming_param)} ${struct_name}* data = new ${struct_name}(); ${initialize_begin_input_param(input_params, streaming_param)}\ @@ -357,12 +350,7 @@ ${initialize_streaming_input_param(function_name, input_params, parameters, stre ni::data_monikers::Moniker* moniker = new ni::data_monikers::Moniker(); ni::data_monikers::DataMonikerService::RegisterMonikerInstance("${moniker_function_name}", data, *moniker); response->set_allocated_moniker(moniker); - return ::grpc::Status::OK; - } - catch (std::exception& ex) { - return ::grpc::Status(::grpc::UNKNOWN, ex.what()); - } -} + return ::grpc::Status::OK;\ <%def name="handle_out_direction(c_api_name, arg_string, data_type, streaming_type, is_coerced_type_present, streaming_param)"> From 9b370e218e699e333202c00ed80a6b50aa020e48 Mon Sep 17 00:00:00 2001 From: Ayush Mehra Date: Wed, 6 Nov 2024 08:06:24 -0800 Subject: [PATCH 21/34] Resolve merge conflicts --- generated/nifpga/nifpga_service.cpp | 134 +++++++++--------- source/codegen/common_helpers.py | 2 +- source/codegen/metadata/nifpga/config.py | 2 +- source/codegen/templates/proto.mako | 2 +- .../templates/register_all_services.cpp.mako | 6 +- source/codegen/templates/service.cpp.mako | 10 +- source/codegen/templates/service.h.mako | 6 +- source/codegen/templates/service_helpers.mako | 6 +- 8 files changed, 83 insertions(+), 85 deletions(-) diff --git a/generated/nifpga/nifpga_service.cpp b/generated/nifpga/nifpga_service.cpp index 769ae6289..e51a8f7d5 100644 --- a/generated/nifpga/nifpga_service.cpp +++ b/generated/nifpga/nifpga_service.cpp @@ -306,73 +306,73 @@ namespace nifpga_grpc { return status >= 0; } -void RegisterMonikerEndpoints() -{ - - ::ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerReadArrayI16", MonikerReadArrayI16); - - ::ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerReadArrayI32", MonikerReadArrayI32); - - ::ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerReadArrayI64", MonikerReadArrayI64); - - ::ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerReadArrayI8", MonikerReadArrayI8); - - ::ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerReadArrayU16", MonikerReadArrayU16); - - ::ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerReadArrayU32", MonikerReadArrayU32); - - ::ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerReadArrayU64", MonikerReadArrayU64); - - ::ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerReadArrayU8", MonikerReadArrayU8); - - ::ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerReadI16", MonikerReadI16); - - ::ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerReadI32", MonikerReadI32); - - ::ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerReadI64", MonikerReadI64); - - ::ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerReadI8", MonikerReadI8); - - ::ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerReadU16", MonikerReadU16); - - ::ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerReadU32", MonikerReadU32); - - ::ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerReadU64", MonikerReadU64); - - ::ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerReadU8", MonikerReadU8); - - ::ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerWriteArrayI16", MonikerWriteArrayI16); - - ::ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerWriteArrayI32", MonikerWriteArrayI32); - - ::ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerWriteArrayI64", MonikerWriteArrayI64); - - ::ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerWriteArrayI8", MonikerWriteArrayI8); - - ::ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerWriteArrayU16", MonikerWriteArrayU16); - - ::ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerWriteArrayU32", MonikerWriteArrayU32); - - ::ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerWriteArrayU64", MonikerWriteArrayU64); - - ::ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerWriteArrayU8", MonikerWriteArrayU8); - - ::ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerWriteI16", MonikerWriteI16); - - ::ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerWriteI32", MonikerWriteI32); - - ::ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerWriteI64", MonikerWriteI64); - - ::ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerWriteI8", MonikerWriteI8); - - ::ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerWriteU16", MonikerWriteU16); - - ::ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerWriteU32", MonikerWriteU32); - - ::ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerWriteU64", MonikerWriteU64); - - ::ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerWriteU8", MonikerWriteU8); -} + void RegisterMonikerEndpoints() + { + + ::ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerReadArrayI16", MonikerReadArrayI16); + + ::ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerReadArrayI32", MonikerReadArrayI32); + + ::ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerReadArrayI64", MonikerReadArrayI64); + + ::ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerReadArrayI8", MonikerReadArrayI8); + + ::ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerReadArrayU16", MonikerReadArrayU16); + + ::ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerReadArrayU32", MonikerReadArrayU32); + + ::ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerReadArrayU64", MonikerReadArrayU64); + + ::ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerReadArrayU8", MonikerReadArrayU8); + + ::ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerReadI16", MonikerReadI16); + + ::ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerReadI32", MonikerReadI32); + + ::ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerReadI64", MonikerReadI64); + + ::ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerReadI8", MonikerReadI8); + + ::ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerReadU16", MonikerReadU16); + + ::ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerReadU32", MonikerReadU32); + + ::ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerReadU64", MonikerReadU64); + + ::ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerReadU8", MonikerReadU8); + + ::ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerWriteArrayI16", MonikerWriteArrayI16); + + ::ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerWriteArrayI32", MonikerWriteArrayI32); + + ::ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerWriteArrayI64", MonikerWriteArrayI64); + + ::ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerWriteArrayI8", MonikerWriteArrayI8); + + ::ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerWriteArrayU16", MonikerWriteArrayU16); + + ::ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerWriteArrayU32", MonikerWriteArrayU32); + + ::ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerWriteArrayU64", MonikerWriteArrayU64); + + ::ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerWriteArrayU8", MonikerWriteArrayU8); + + ::ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerWriteI16", MonikerWriteI16); + + ::ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerWriteI32", MonikerWriteI32); + + ::ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerWriteI64", MonikerWriteI64); + + ::ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerWriteI8", MonikerWriteI8); + + ::ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerWriteU16", MonikerWriteU16); + + ::ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerWriteU32", MonikerWriteU32); + + ::ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerWriteU64", MonikerWriteU64); + + ::ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerWriteU8", MonikerWriteU8); + } ::grpc::Status MonikerReadArrayI16(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData) { diff --git a/source/codegen/common_helpers.py b/source/codegen/common_helpers.py index 3cc93aacc..ba2ee9529 100644 --- a/source/codegen/common_helpers.py +++ b/source/codegen/common_helpers.py @@ -1204,7 +1204,7 @@ def get_params_needing_initialization(parameters: List[dict]) -> List[dict]: return [p for p in parameters if not (is_return_value(p) or is_get_last_error_output_param(p))] -def filter_streaming_functions(functions, functions_to_generate=None): +def filter_moniker_streaming_functions (functions, functions_to_generate=None): """Return streaming functions that need to be generated.""" if functions_to_generate is None: functions_to_generate = functions.keys() diff --git a/source/codegen/metadata/nifpga/config.py b/source/codegen/metadata/nifpga/config.py index eba3bd69d..d7629d109 100644 --- a/source/codegen/metadata/nifpga/config.py +++ b/source/codegen/metadata/nifpga/config.py @@ -31,7 +31,7 @@ 'NiFpga_Bool': 'bool', 'NiFpga_FifoProperty': 'uint32', }, - 'has_streaming_api': True, + 'has_moniker_streaming_apis': True, 'custom_types': [], 'library_info': { 'Linux': { diff --git a/source/codegen/templates/proto.mako b/source/codegen/templates/proto.mako index c7259350e..ba9f1b448 100644 --- a/source/codegen/templates/proto.mako +++ b/source/codegen/templates/proto.mako @@ -21,7 +21,7 @@ additional_protos.extend(external_proto_deps) //--------------------------------------------------------------------- syntax = "proto3"; -% if config.get("has_streaming_api", False): +% if config.get("has_moniker_streaming_apis", False): option cc_enable_arenas = true; % endif option java_multiple_files = true; diff --git a/source/codegen/templates/register_all_services.cpp.mako b/source/codegen/templates/register_all_services.cpp.mako index dee6ebdfc..54f623617 100644 --- a/source/codegen/templates/register_all_services.cpp.mako +++ b/source/codegen/templates/register_all_services.cpp.mako @@ -25,7 +25,7 @@ repository_type_to_config = service_helpers.list_session_repository_handle_types %>\ <%block filter="common_helpers.os_conditional_compile_block(config)">\ #include "${module_name}/${module_name}_service_registrar.h" -% if config.get("has_streaming_api", False): +% if config.get("has_moniker_streaming_apis", False): #include "${module_name}/${module_name}_service.h" % endif \ @@ -70,14 +70,14 @@ std::shared_ptr>> register_all_services( feature_toggles)); \ % endfor -% if any(config.get("has_streaming_api", False) for config in driver_configs): +% if any(config.get("has_moniker_streaming_apis", False) for config in driver_configs): if (ni::data_monikers::is_sideband_streaming_enabled(feature_toggles)) { % for driver in drivers: <% config = driver["config"] namespace = f"{config['namespace_component']}_grpc" %>\ -% if config.get("has_streaming_api", False): +% if config.get("has_moniker_streaming_apis", False): <%block filter="common_helpers.os_conditional_compile_block(config)">\ ${namespace}::RegisterMonikerEndpoints(); \ diff --git a/source/codegen/templates/service.cpp.mako b/source/codegen/templates/service.cpp.mako index 2e5fec5f5..fb282e7a4 100644 --- a/source/codegen/templates/service.cpp.mako +++ b/source/codegen/templates/service.cpp.mako @@ -13,7 +13,7 @@ custom_types = common_helpers.get_custom_types(config) has_async_functions = any(service_helpers.get_async_functions(functions)) has_two_dimension_functions = any(service_helpers.get_functions_with_two_dimension_param(functions)) functions_to_generate = service_helpers.filter_proto_rpc_functions_to_generate(functions) -streaming_functions_to_generate = common_helpers.filter_streaming_functions(functions, functions_to_generate) +streaming_functions_to_generate = common_helpers.filter_moniker_streaming_functions (functions, functions_to_generate) # If there are any non-mockable functions, we need to call the library directly, which # means we need another include file any_non_mockable_functions = any(not common_helpers.can_mock_function(functions[name]['parameters']) for name in functions_to_generate) @@ -112,12 +112,12 @@ ${mako_helper.define_moniker_streaming_structs(function_name=function_name, func % endif % if streaming_functions_to_generate: -void RegisterMonikerEndpoints() -{ + void RegisterMonikerEndpoints() + { % for function_name in streaming_functions_to_generate: -${mako_helper.register_moniker_functions(function_name)}\ + ${mako_helper.register_moniker_functions(function_name)}\ % endfor -} + } % endif % for function_name in streaming_functions_to_generate: <% diff --git a/source/codegen/templates/service.h.mako b/source/codegen/templates/service.h.mako index 9610fd31d..7aad0b437 100644 --- a/source/codegen/templates/service.h.mako +++ b/source/codegen/templates/service.h.mako @@ -17,7 +17,7 @@ custom_types = common_helpers.get_custom_types(config) (input_custom_types, output_custom_types) = common_helpers.get_input_and_output_custom_types(config, functions) resource_repository_deps = service_helpers.get_driver_shared_resource_repository_ptr_deps(config, functions) resource_handle_types = service_helpers.get_resource_handle_types(config) -data_moniker_functions = common_helpers.filter_streaming_functions(functions) +data_moniker_functions = common_helpers.filter_moniker_streaming_functions (functions) async_functions = service_helpers.get_async_functions(functions) has_async_functions = any(async_functions) @@ -68,11 +68,7 @@ void RegisterMonikerEndpoints(); <% method_name = common_helpers.get_data_moniker_function_name(function) %>\ -% if config.get("has_streaming_api", False): ::grpc::Status ${method_name}(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData); -% else: -::grpc::Status ${method_name}(void* data, google::protobuf::Any& packedData); -% endif % endfor % endif diff --git a/source/codegen/templates/service_helpers.mako b/source/codegen/templates/service_helpers.mako index 309a16a7a..c61e613a3 100644 --- a/source/codegen/templates/service_helpers.mako +++ b/source/codegen/templates/service_helpers.mako @@ -272,8 +272,10 @@ ${populate_response(function_data=function_data, parameters=parameters)}\ <%def name="register_moniker_functions(function_name)"> -<% moniker_function_name = common_helpers.get_data_moniker_function_name(function_name) -%> ::ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("${moniker_function_name}", ${moniker_function_name}); +<% + moniker_function_name = common_helpers.get_data_moniker_function_name(function_name) +%>\ + ::ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("${moniker_function_name}", ${moniker_function_name}); <%def name="define_moniker_streaming_structs(function_name, function_data, parameters)">\ From 9a5b2814695d88f088e81c3c1a4aa1e3e583b9fc Mon Sep 17 00:00:00 2001 From: Ayush Mehra Date: Wed, 6 Nov 2024 08:25:54 -0800 Subject: [PATCH 22/34] fix build --- source/codegen/common_helpers.py | 4 +--- source/codegen/templates/service.h.mako | 5 +++-- source/server/data_moniker_service.cpp | 1 - 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/source/codegen/common_helpers.py b/source/codegen/common_helpers.py index ba2ee9529..fbd128029 100644 --- a/source/codegen/common_helpers.py +++ b/source/codegen/common_helpers.py @@ -1204,10 +1204,8 @@ def get_params_needing_initialization(parameters: List[dict]) -> List[dict]: return [p for p in parameters if not (is_return_value(p) or is_get_last_error_output_param(p))] -def filter_moniker_streaming_functions (functions, functions_to_generate=None): +def filter_moniker_streaming_functions(functions, functions_to_generate): """Return streaming functions that need to be generated.""" - if functions_to_generate is None: - functions_to_generate = functions.keys() return [ name for name in functions_to_generate if functions[name].get("is_streaming_api", False) ] diff --git a/source/codegen/templates/service.h.mako b/source/codegen/templates/service.h.mako index 7aad0b437..9c09f6b13 100644 --- a/source/codegen/templates/service.h.mako +++ b/source/codegen/templates/service.h.mako @@ -17,7 +17,8 @@ custom_types = common_helpers.get_custom_types(config) (input_custom_types, output_custom_types) = common_helpers.get_input_and_output_custom_types(config, functions) resource_repository_deps = service_helpers.get_driver_shared_resource_repository_ptr_deps(config, functions) resource_handle_types = service_helpers.get_resource_handle_types(config) -data_moniker_functions = common_helpers.filter_moniker_streaming_functions (functions) +functions_to_generate = common_helpers.filter_proto_rpc_functions(functions) +data_moniker_functions = common_helpers.filter_moniker_streaming_functions(functions, functions_to_generate) async_functions = service_helpers.get_async_functions(functions) has_async_functions = any(async_functions) @@ -91,7 +92,7 @@ public: const ${service_class_prefix}FeatureToggles& feature_toggles = {}); virtual ~${service_class_prefix}Service(); -% for function in common_helpers.filter_proto_rpc_functions(functions): +% for function in functions_to_generate: <% f = functions[function] method_name = common_helpers.snake_to_pascal(function) diff --git a/source/server/data_moniker_service.cpp b/source/server/data_moniker_service.cpp index c2fad7280..88470b3a6 100644 --- a/source/server/data_moniker_service.cpp +++ b/source/server/data_moniker_service.cpp @@ -168,7 +168,6 @@ Status DataMonikerService::BeginSidebandStream(ServerContext* context, const Beg char identifier[32] = {}; InitOwnerSidebandData(strategy, bufferSize, identifier); - response->set_strategy(request->strategy()); response->set_sideband_identifier(identifier); response->set_connection_url(GetConnectionAddress(strategy)); From 903fa1f8f96f9bb096c2464bb23d04ab2e51e7ab Mon Sep 17 00:00:00 2001 From: Ayush Mehra Date: Thu, 7 Nov 2024 03:08:53 -0800 Subject: [PATCH 23/34] resolve comments --- generated/nifpga/nifpga_service.cpp | 200 ++++++++---------- generated/register_all_services.cpp | 5 - source/codegen/common_helpers.py | 35 +++ source/codegen/service_helpers.py | 20 -- .../templates/register_all_services.cpp.mako | 5 - source/codegen/templates/service.cpp.mako | 2 +- source/codegen/templates/service_helpers.mako | 131 +++++++----- 7 files changed, 205 insertions(+), 193 deletions(-) diff --git a/generated/nifpga/nifpga_service.cpp b/generated/nifpga/nifpga_service.cpp index e51a8f7d5..648488eb5 100644 --- a/generated/nifpga/nifpga_service.cpp +++ b/generated/nifpga/nifpga_service.cpp @@ -308,70 +308,38 @@ namespace nifpga_grpc { void RegisterMonikerEndpoints() { - - ::ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerReadArrayI16", MonikerReadArrayI16); - - ::ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerReadArrayI32", MonikerReadArrayI32); - - ::ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerReadArrayI64", MonikerReadArrayI64); - - ::ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerReadArrayI8", MonikerReadArrayI8); - - ::ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerReadArrayU16", MonikerReadArrayU16); - - ::ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerReadArrayU32", MonikerReadArrayU32); - - ::ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerReadArrayU64", MonikerReadArrayU64); - - ::ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerReadArrayU8", MonikerReadArrayU8); - - ::ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerReadI16", MonikerReadI16); - - ::ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerReadI32", MonikerReadI32); - - ::ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerReadI64", MonikerReadI64); - - ::ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerReadI8", MonikerReadI8); - - ::ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerReadU16", MonikerReadU16); - - ::ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerReadU32", MonikerReadU32); - - ::ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerReadU64", MonikerReadU64); - - ::ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerReadU8", MonikerReadU8); - - ::ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerWriteArrayI16", MonikerWriteArrayI16); - - ::ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerWriteArrayI32", MonikerWriteArrayI32); - - ::ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerWriteArrayI64", MonikerWriteArrayI64); - - ::ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerWriteArrayI8", MonikerWriteArrayI8); - - ::ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerWriteArrayU16", MonikerWriteArrayU16); - - ::ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerWriteArrayU32", MonikerWriteArrayU32); - - ::ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerWriteArrayU64", MonikerWriteArrayU64); - - ::ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerWriteArrayU8", MonikerWriteArrayU8); - - ::ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerWriteI16", MonikerWriteI16); - - ::ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerWriteI32", MonikerWriteI32); - - ::ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerWriteI64", MonikerWriteI64); - - ::ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerWriteI8", MonikerWriteI8); - - ::ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerWriteU16", MonikerWriteU16); - - ::ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerWriteU32", MonikerWriteU32); - - ::ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerWriteU64", MonikerWriteU64); - - ::ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerWriteU8", MonikerWriteU8); + ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerReadArrayI16", MonikerReadArrayI16); + ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerReadArrayI32", MonikerReadArrayI32); + ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerReadArrayI64", MonikerReadArrayI64); + ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerReadArrayI8", MonikerReadArrayI8); + ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerReadArrayU16", MonikerReadArrayU16); + ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerReadArrayU32", MonikerReadArrayU32); + ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerReadArrayU64", MonikerReadArrayU64); + ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerReadArrayU8", MonikerReadArrayU8); + ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerReadI16", MonikerReadI16); + ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerReadI32", MonikerReadI32); + ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerReadI64", MonikerReadI64); + ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerReadI8", MonikerReadI8); + ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerReadU16", MonikerReadU16); + ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerReadU32", MonikerReadU32); + ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerReadU64", MonikerReadU64); + ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerReadU8", MonikerReadU8); + ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerWriteArrayI16", MonikerWriteArrayI16); + ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerWriteArrayI32", MonikerWriteArrayI32); + ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerWriteArrayI64", MonikerWriteArrayI64); + ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerWriteArrayI8", MonikerWriteArrayI8); + ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerWriteArrayU16", MonikerWriteArrayU16); + ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerWriteArrayU32", MonikerWriteArrayU32); + ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerWriteArrayU64", MonikerWriteArrayU64); + ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerWriteArrayU8", MonikerWriteArrayU8); + ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerWriteI16", MonikerWriteI16); + ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerWriteI32", MonikerWriteI32); + ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerWriteI64", MonikerWriteI64); + ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerWriteI8", MonikerWriteI8); + ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerWriteU16", MonikerWriteU16); + ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerWriteU32", MonikerWriteU32); + ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerWriteU64", MonikerWriteU64); + ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerWriteU8", MonikerWriteU8); } ::grpc::Status MonikerReadArrayI16(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData) @@ -395,6 +363,7 @@ ::grpc::Status MonikerReadArrayI16(void* data, google::protobuf::Arena& arena, g }); packedData.PackFrom(function_data->data); } + if (status < 0) { std::cout << "MonikerReadArrayI16 error: " << status << std::endl; } @@ -422,6 +391,7 @@ ::grpc::Status MonikerReadArrayI32(void* data, google::protobuf::Arena& arena, g }); packedData.PackFrom(function_data->data); } + if (status < 0) { std::cout << "MonikerReadArrayI32 error: " << status << std::endl; } @@ -449,6 +419,7 @@ ::grpc::Status MonikerReadArrayI64(void* data, google::protobuf::Arena& arena, g }); packedData.PackFrom(function_data->data); } + if (status < 0) { std::cout << "MonikerReadArrayI64 error: " << status << std::endl; } @@ -476,6 +447,7 @@ ::grpc::Status MonikerReadArrayI8(void* data, google::protobuf::Arena& arena, go }); packedData.PackFrom(function_data->data); } + if (status < 0) { std::cout << "MonikerReadArrayI8 error: " << status << std::endl; } @@ -503,6 +475,7 @@ ::grpc::Status MonikerReadArrayU16(void* data, google::protobuf::Arena& arena, g }); packedData.PackFrom(function_data->data); } + if (status < 0) { std::cout << "MonikerReadArrayU16 error: " << status << std::endl; } @@ -530,6 +503,7 @@ ::grpc::Status MonikerReadArrayU32(void* data, google::protobuf::Arena& arena, g }); packedData.PackFrom(function_data->data); } + if (status < 0) { std::cout << "MonikerReadArrayU32 error: " << status << std::endl; } @@ -557,6 +531,7 @@ ::grpc::Status MonikerReadArrayU64(void* data, google::protobuf::Arena& arena, g }); packedData.PackFrom(function_data->data); } + if (status < 0) { std::cout << "MonikerReadArrayU64 error: " << status << std::endl; } @@ -584,6 +559,7 @@ ::grpc::Status MonikerReadArrayU8(void* data, google::protobuf::Arena& arena, go }); packedData.PackFrom(function_data->data); } + if (status < 0) { std::cout << "MonikerReadArrayU8 error: " << status << std::endl; } @@ -604,6 +580,7 @@ ::grpc::Status MonikerReadI16(void* data, google::protobuf::Arena& arena, google if (status >= 0) { packedData.PackFrom(function_data->data); } + if (status < 0) { std::cout << "MonikerReadI16 error: " << status << std::endl; } @@ -624,6 +601,7 @@ ::grpc::Status MonikerReadI32(void* data, google::protobuf::Arena& arena, google if (status >= 0) { packedData.PackFrom(function_data->data); } + if (status < 0) { std::cout << "MonikerReadI32 error: " << status << std::endl; } @@ -644,6 +622,7 @@ ::grpc::Status MonikerReadI64(void* data, google::protobuf::Arena& arena, google if (status >= 0) { packedData.PackFrom(function_data->data); } + if (status < 0) { std::cout << "MonikerReadI64 error: " << status << std::endl; } @@ -664,6 +643,7 @@ ::grpc::Status MonikerReadI8(void* data, google::protobuf::Arena& arena, google: if (status >= 0) { packedData.PackFrom(function_data->data); } + if (status < 0) { std::cout << "MonikerReadI8 error: " << status << std::endl; } @@ -684,6 +664,7 @@ ::grpc::Status MonikerReadU16(void* data, google::protobuf::Arena& arena, google if (status >= 0) { packedData.PackFrom(function_data->data); } + if (status < 0) { std::cout << "MonikerReadU16 error: " << status << std::endl; } @@ -704,6 +685,7 @@ ::grpc::Status MonikerReadU32(void* data, google::protobuf::Arena& arena, google if (status >= 0) { packedData.PackFrom(function_data->data); } + if (status < 0) { std::cout << "MonikerReadU32 error: " << status << std::endl; } @@ -724,6 +706,7 @@ ::grpc::Status MonikerReadU64(void* data, google::protobuf::Arena& arena, google if (status >= 0) { packedData.PackFrom(function_data->data); } + if (status < 0) { std::cout << "MonikerReadU64 error: " << status << std::endl; } @@ -744,6 +727,7 @@ ::grpc::Status MonikerReadU8(void* data, google::protobuf::Arena& arena, google: if (status >= 0) { packedData.PackFrom(function_data->data); } + if (status < 0) { std::cout << "MonikerReadU8 error: " << status << std::endl; } @@ -793,7 +777,7 @@ ::grpc::Status MonikerWriteArrayI32(void* data, google::protobuf::Arena& arena, ArrayI32Data arrayi32data_message; packedData.UnpackTo(&arrayi32data_message); - auto data_array = arrayi32data_message.value(); + auto data_array = arrayi32data_message.value(); auto array = const_cast(arrayi32data_message.value().data()); auto size = data_array.size(); @@ -814,7 +798,7 @@ ::grpc::Status MonikerWriteArrayI64(void* data, google::protobuf::Arena& arena, ArrayI64Data arrayi64data_message; packedData.UnpackTo(&arrayi64data_message); - auto data_array = arrayi64data_message.value(); + auto data_array = arrayi64data_message.value(); auto array = const_cast(arrayi64data_message.value().data()); auto size = data_array.size(); @@ -901,7 +885,7 @@ ::grpc::Status MonikerWriteArrayU32(void* data, google::protobuf::Arena& arena, ArrayU32Data arrayu32data_message; packedData.UnpackTo(&arrayu32data_message); - auto data_array = arrayu32data_message.value(); + auto data_array = arrayu32data_message.value(); auto array = const_cast(arrayu32data_message.value().data()); auto size = data_array.size(); @@ -922,7 +906,7 @@ ::grpc::Status MonikerWriteArrayU64(void* data, google::protobuf::Arena& arena, ArrayU64Data arrayu64data_message; packedData.UnpackTo(&arrayu64data_message); - auto data_array = arrayu64data_message.value(); + auto data_array = arrayu64data_message.value(); auto array = const_cast(arrayu64data_message.value().data()); auto size = data_array.size(); @@ -976,7 +960,7 @@ ::grpc::Status MonikerWriteI16(void* data, google::protobuf::Arena& arena, googl I32Data i32data_message; packedData.UnpackTo(&i32data_message); - int32_t value = i32data_message.value(); + auto value = i32data_message.value(); if (value < std::numeric_limits::min() || value > std::numeric_limits::max()) { std::string message("value " + std::to_string(value) + " doesn't fit in datatype int16_t"); throw nidevice_grpc::ValueOutOfRangeException(message); @@ -999,7 +983,7 @@ ::grpc::Status MonikerWriteI32(void* data, google::protobuf::Arena& arena, googl I32Data i32data_message; packedData.UnpackTo(&i32data_message); - int32_t value = i32data_message.value(); + auto value = i32data_message.value(); auto status = library->WriteI32(session, control, value); if (status < 0) { @@ -1018,7 +1002,7 @@ ::grpc::Status MonikerWriteI64(void* data, google::protobuf::Arena& arena, googl I64Data i64data_message; packedData.UnpackTo(&i64data_message); - int64_t value = i64data_message.value(); + auto value = i64data_message.value(); auto status = library->WriteI64(session, control, value); if (status < 0) { @@ -1037,7 +1021,7 @@ ::grpc::Status MonikerWriteI8(void* data, google::protobuf::Arena& arena, google I32Data i32data_message; packedData.UnpackTo(&i32data_message); - int32_t value = i32data_message.value(); + auto value = i32data_message.value(); if (value < std::numeric_limits::min() || value > std::numeric_limits::max()) { std::string message("value " + std::to_string(value) + " doesn't fit in datatype int8_t"); throw nidevice_grpc::ValueOutOfRangeException(message); @@ -1060,7 +1044,7 @@ ::grpc::Status MonikerWriteU16(void* data, google::protobuf::Arena& arena, googl U32Data u32data_message; packedData.UnpackTo(&u32data_message); - uint32_t value = u32data_message.value(); + auto value = u32data_message.value(); if (value < std::numeric_limits::min() || value > std::numeric_limits::max()) { std::string message("value " + std::to_string(value) + " doesn't fit in datatype uint16_t"); throw nidevice_grpc::ValueOutOfRangeException(message); @@ -1083,7 +1067,7 @@ ::grpc::Status MonikerWriteU32(void* data, google::protobuf::Arena& arena, googl U32Data u32data_message; packedData.UnpackTo(&u32data_message); - uint32_t value = u32data_message.value(); + auto value = u32data_message.value(); auto status = library->WriteU32(session, control, value); if (status < 0) { @@ -1102,7 +1086,7 @@ ::grpc::Status MonikerWriteU64(void* data, google::protobuf::Arena& arena, googl U64Data u64data_message; packedData.UnpackTo(&u64data_message); - uint64_t value = u64data_message.value(); + auto value = u64data_message.value(); auto status = library->WriteU64(session, control, value); if (status < 0) { @@ -1121,7 +1105,7 @@ ::grpc::Status MonikerWriteU8(void* data, google::protobuf::Arena& arena, google U32Data u32data_message; packedData.UnpackTo(&u32data_message); - uint32_t value = u32data_message.value(); + auto value = u32data_message.value(); if (value < std::numeric_limits::min() || value > std::numeric_limits::max()) { std::string message("value " + std::to_string(value) + " doesn't fit in datatype uint8_t"); throw nidevice_grpc::ValueOutOfRangeException(message); @@ -1733,7 +1717,6 @@ ::grpc::Status MonikerWriteU8(void* data, google::protobuf::Arena& arena, google return ::grpc::Status::CANCELLED; } try { - auto session_grpc_session = request->session(); NiFpga_Session session = session_repository_->access_session(session_grpc_session.name()); uint32_t indicator = request->indicator(); @@ -1750,6 +1733,7 @@ ::grpc::Status MonikerWriteU8(void* data, google::protobuf::Arena& arena, google ni::data_monikers::Moniker* moniker = new ni::data_monikers::Moniker(); ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerReadArrayI16", data, *moniker); response->set_allocated_moniker(moniker); + response->set_status(0); return ::grpc::Status::OK; } catch (nidevice_grpc::NonDriverException& ex) { @@ -1791,7 +1775,6 @@ ::grpc::Status MonikerWriteU8(void* data, google::protobuf::Arena& arena, google return ::grpc::Status::CANCELLED; } try { - auto session_grpc_session = request->session(); NiFpga_Session session = session_repository_->access_session(session_grpc_session.name()); uint32_t indicator = request->indicator(); @@ -1808,6 +1791,7 @@ ::grpc::Status MonikerWriteU8(void* data, google::protobuf::Arena& arena, google ni::data_monikers::Moniker* moniker = new ni::data_monikers::Moniker(); ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerReadArrayI32", data, *moniker); response->set_allocated_moniker(moniker); + response->set_status(0); return ::grpc::Status::OK; } catch (nidevice_grpc::NonDriverException& ex) { @@ -1849,7 +1833,6 @@ ::grpc::Status MonikerWriteU8(void* data, google::protobuf::Arena& arena, google return ::grpc::Status::CANCELLED; } try { - auto session_grpc_session = request->session(); NiFpga_Session session = session_repository_->access_session(session_grpc_session.name()); uint32_t indicator = request->indicator(); @@ -1866,6 +1849,7 @@ ::grpc::Status MonikerWriteU8(void* data, google::protobuf::Arena& arena, google ni::data_monikers::Moniker* moniker = new ni::data_monikers::Moniker(); ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerReadArrayI64", data, *moniker); response->set_allocated_moniker(moniker); + response->set_status(0); return ::grpc::Status::OK; } catch (nidevice_grpc::NonDriverException& ex) { @@ -1915,7 +1899,6 @@ ::grpc::Status MonikerWriteU8(void* data, google::protobuf::Arena& arena, google return ::grpc::Status::CANCELLED; } try { - auto session_grpc_session = request->session(); NiFpga_Session session = session_repository_->access_session(session_grpc_session.name()); uint32_t indicator = request->indicator(); @@ -1932,6 +1915,7 @@ ::grpc::Status MonikerWriteU8(void* data, google::protobuf::Arena& arena, google ni::data_monikers::Moniker* moniker = new ni::data_monikers::Moniker(); ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerReadArrayI8", data, *moniker); response->set_allocated_moniker(moniker); + response->set_status(0); return ::grpc::Status::OK; } catch (nidevice_grpc::NonDriverException& ex) { @@ -2007,7 +1991,6 @@ ::grpc::Status MonikerWriteU8(void* data, google::protobuf::Arena& arena, google return ::grpc::Status::CANCELLED; } try { - auto session_grpc_session = request->session(); NiFpga_Session session = session_repository_->access_session(session_grpc_session.name()); uint32_t indicator = request->indicator(); @@ -2024,6 +2007,7 @@ ::grpc::Status MonikerWriteU8(void* data, google::protobuf::Arena& arena, google ni::data_monikers::Moniker* moniker = new ni::data_monikers::Moniker(); ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerReadArrayU16", data, *moniker); response->set_allocated_moniker(moniker); + response->set_status(0); return ::grpc::Status::OK; } catch (nidevice_grpc::NonDriverException& ex) { @@ -2065,7 +2049,6 @@ ::grpc::Status MonikerWriteU8(void* data, google::protobuf::Arena& arena, google return ::grpc::Status::CANCELLED; } try { - auto session_grpc_session = request->session(); NiFpga_Session session = session_repository_->access_session(session_grpc_session.name()); uint32_t indicator = request->indicator(); @@ -2082,6 +2065,7 @@ ::grpc::Status MonikerWriteU8(void* data, google::protobuf::Arena& arena, google ni::data_monikers::Moniker* moniker = new ni::data_monikers::Moniker(); ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerReadArrayU32", data, *moniker); response->set_allocated_moniker(moniker); + response->set_status(0); return ::grpc::Status::OK; } catch (nidevice_grpc::NonDriverException& ex) { @@ -2123,7 +2107,6 @@ ::grpc::Status MonikerWriteU8(void* data, google::protobuf::Arena& arena, google return ::grpc::Status::CANCELLED; } try { - auto session_grpc_session = request->session(); NiFpga_Session session = session_repository_->access_session(session_grpc_session.name()); uint32_t indicator = request->indicator(); @@ -2140,6 +2123,7 @@ ::grpc::Status MonikerWriteU8(void* data, google::protobuf::Arena& arena, google ni::data_monikers::Moniker* moniker = new ni::data_monikers::Moniker(); ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerReadArrayU64", data, *moniker); response->set_allocated_moniker(moniker); + response->set_status(0); return ::grpc::Status::OK; } catch (nidevice_grpc::NonDriverException& ex) { @@ -2189,7 +2173,6 @@ ::grpc::Status MonikerWriteU8(void* data, google::protobuf::Arena& arena, google return ::grpc::Status::CANCELLED; } try { - auto session_grpc_session = request->session(); NiFpga_Session session = session_repository_->access_session(session_grpc_session.name()); uint32_t indicator = request->indicator(); @@ -2206,6 +2189,7 @@ ::grpc::Status MonikerWriteU8(void* data, google::protobuf::Arena& arena, google ni::data_monikers::Moniker* moniker = new ni::data_monikers::Moniker(); ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerReadArrayU8", data, *moniker); response->set_allocated_moniker(moniker); + response->set_status(0); return ::grpc::Status::OK; } catch (nidevice_grpc::NonDriverException& ex) { @@ -2647,7 +2631,6 @@ ::grpc::Status MonikerWriteU8(void* data, google::protobuf::Arena& arena, google return ::grpc::Status::CANCELLED; } try { - auto session_grpc_session = request->session(); NiFpga_Session session = session_repository_->access_session(session_grpc_session.name()); uint32_t indicator = request->indicator(); @@ -2660,6 +2643,7 @@ ::grpc::Status MonikerWriteU8(void* data, google::protobuf::Arena& arena, google ni::data_monikers::Moniker* moniker = new ni::data_monikers::Moniker(); ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerReadI16", data, *moniker); response->set_allocated_moniker(moniker); + response->set_status(0); return ::grpc::Status::OK; } catch (nidevice_grpc::NonDriverException& ex) { @@ -2700,7 +2684,6 @@ ::grpc::Status MonikerWriteU8(void* data, google::protobuf::Arena& arena, google return ::grpc::Status::CANCELLED; } try { - auto session_grpc_session = request->session(); NiFpga_Session session = session_repository_->access_session(session_grpc_session.name()); uint32_t indicator = request->indicator(); @@ -2713,6 +2696,7 @@ ::grpc::Status MonikerWriteU8(void* data, google::protobuf::Arena& arena, google ni::data_monikers::Moniker* moniker = new ni::data_monikers::Moniker(); ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerReadI32", data, *moniker); response->set_allocated_moniker(moniker); + response->set_status(0); return ::grpc::Status::OK; } catch (nidevice_grpc::NonDriverException& ex) { @@ -2753,7 +2737,6 @@ ::grpc::Status MonikerWriteU8(void* data, google::protobuf::Arena& arena, google return ::grpc::Status::CANCELLED; } try { - auto session_grpc_session = request->session(); NiFpga_Session session = session_repository_->access_session(session_grpc_session.name()); uint32_t indicator = request->indicator(); @@ -2766,6 +2749,7 @@ ::grpc::Status MonikerWriteU8(void* data, google::protobuf::Arena& arena, google ni::data_monikers::Moniker* moniker = new ni::data_monikers::Moniker(); ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerReadI64", data, *moniker); response->set_allocated_moniker(moniker); + response->set_status(0); return ::grpc::Status::OK; } catch (nidevice_grpc::NonDriverException& ex) { @@ -2806,7 +2790,6 @@ ::grpc::Status MonikerWriteU8(void* data, google::protobuf::Arena& arena, google return ::grpc::Status::CANCELLED; } try { - auto session_grpc_session = request->session(); NiFpga_Session session = session_repository_->access_session(session_grpc_session.name()); uint32_t indicator = request->indicator(); @@ -2819,6 +2802,7 @@ ::grpc::Status MonikerWriteU8(void* data, google::protobuf::Arena& arena, google ni::data_monikers::Moniker* moniker = new ni::data_monikers::Moniker(); ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerReadI8", data, *moniker); response->set_allocated_moniker(moniker); + response->set_status(0); return ::grpc::Status::OK; } catch (nidevice_grpc::NonDriverException& ex) { @@ -2884,7 +2868,6 @@ ::grpc::Status MonikerWriteU8(void* data, google::protobuf::Arena& arena, google return ::grpc::Status::CANCELLED; } try { - auto session_grpc_session = request->session(); NiFpga_Session session = session_repository_->access_session(session_grpc_session.name()); uint32_t indicator = request->indicator(); @@ -2897,6 +2880,7 @@ ::grpc::Status MonikerWriteU8(void* data, google::protobuf::Arena& arena, google ni::data_monikers::Moniker* moniker = new ni::data_monikers::Moniker(); ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerReadU16", data, *moniker); response->set_allocated_moniker(moniker); + response->set_status(0); return ::grpc::Status::OK; } catch (nidevice_grpc::NonDriverException& ex) { @@ -2937,7 +2921,6 @@ ::grpc::Status MonikerWriteU8(void* data, google::protobuf::Arena& arena, google return ::grpc::Status::CANCELLED; } try { - auto session_grpc_session = request->session(); NiFpga_Session session = session_repository_->access_session(session_grpc_session.name()); uint32_t indicator = request->indicator(); @@ -2950,6 +2933,7 @@ ::grpc::Status MonikerWriteU8(void* data, google::protobuf::Arena& arena, google ni::data_monikers::Moniker* moniker = new ni::data_monikers::Moniker(); ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerReadU32", data, *moniker); response->set_allocated_moniker(moniker); + response->set_status(0); return ::grpc::Status::OK; } catch (nidevice_grpc::NonDriverException& ex) { @@ -2990,7 +2974,6 @@ ::grpc::Status MonikerWriteU8(void* data, google::protobuf::Arena& arena, google return ::grpc::Status::CANCELLED; } try { - auto session_grpc_session = request->session(); NiFpga_Session session = session_repository_->access_session(session_grpc_session.name()); uint32_t indicator = request->indicator(); @@ -3003,6 +2986,7 @@ ::grpc::Status MonikerWriteU8(void* data, google::protobuf::Arena& arena, google ni::data_monikers::Moniker* moniker = new ni::data_monikers::Moniker(); ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerReadU64", data, *moniker); response->set_allocated_moniker(moniker); + response->set_status(0); return ::grpc::Status::OK; } catch (nidevice_grpc::NonDriverException& ex) { @@ -3043,7 +3027,6 @@ ::grpc::Status MonikerWriteU8(void* data, google::protobuf::Arena& arena, google return ::grpc::Status::CANCELLED; } try { - auto session_grpc_session = request->session(); NiFpga_Session session = session_repository_->access_session(session_grpc_session.name()); uint32_t indicator = request->indicator(); @@ -3056,6 +3039,7 @@ ::grpc::Status MonikerWriteU8(void* data, google::protobuf::Arena& arena, google ni::data_monikers::Moniker* moniker = new ni::data_monikers::Moniker(); ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerReadU8", data, *moniker); response->set_allocated_moniker(moniker); + response->set_status(0); return ::grpc::Status::OK; } catch (nidevice_grpc::NonDriverException& ex) { @@ -3505,7 +3489,6 @@ ::grpc::Status MonikerWriteU8(void* data, google::protobuf::Arena& arena, google return ::grpc::Status::CANCELLED; } try { - auto session_grpc_session = request->session(); NiFpga_Session session = session_repository_->access_session(session_grpc_session.name()); uint32_t control = request->control(); @@ -3518,6 +3501,7 @@ ::grpc::Status MonikerWriteU8(void* data, google::protobuf::Arena& arena, google ni::data_monikers::Moniker* moniker = new ni::data_monikers::Moniker(); ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerWriteArrayI16", data, *moniker); response->set_allocated_moniker(moniker); + response->set_status(0); return ::grpc::Status::OK; } catch (nidevice_grpc::NonDriverException& ex) { @@ -3558,7 +3542,6 @@ ::grpc::Status MonikerWriteU8(void* data, google::protobuf::Arena& arena, google return ::grpc::Status::CANCELLED; } try { - auto session_grpc_session = request->session(); NiFpga_Session session = session_repository_->access_session(session_grpc_session.name()); uint32_t control = request->control(); @@ -3571,6 +3554,7 @@ ::grpc::Status MonikerWriteU8(void* data, google::protobuf::Arena& arena, google ni::data_monikers::Moniker* moniker = new ni::data_monikers::Moniker(); ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerWriteArrayI32", data, *moniker); response->set_allocated_moniker(moniker); + response->set_status(0); return ::grpc::Status::OK; } catch (nidevice_grpc::NonDriverException& ex) { @@ -3611,7 +3595,6 @@ ::grpc::Status MonikerWriteU8(void* data, google::protobuf::Arena& arena, google return ::grpc::Status::CANCELLED; } try { - auto session_grpc_session = request->session(); NiFpga_Session session = session_repository_->access_session(session_grpc_session.name()); uint32_t control = request->control(); @@ -3624,6 +3607,7 @@ ::grpc::Status MonikerWriteU8(void* data, google::protobuf::Arena& arena, google ni::data_monikers::Moniker* moniker = new ni::data_monikers::Moniker(); ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerWriteArrayI64", data, *moniker); response->set_allocated_moniker(moniker); + response->set_status(0); return ::grpc::Status::OK; } catch (nidevice_grpc::NonDriverException& ex) { @@ -3681,7 +3665,6 @@ ::grpc::Status MonikerWriteU8(void* data, google::protobuf::Arena& arena, google return ::grpc::Status::CANCELLED; } try { - auto session_grpc_session = request->session(); NiFpga_Session session = session_repository_->access_session(session_grpc_session.name()); uint32_t control = request->control(); @@ -3694,6 +3677,7 @@ ::grpc::Status MonikerWriteU8(void* data, google::protobuf::Arena& arena, google ni::data_monikers::Moniker* moniker = new ni::data_monikers::Moniker(); ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerWriteArrayI8", data, *moniker); response->set_allocated_moniker(moniker); + response->set_status(0); return ::grpc::Status::OK; } catch (nidevice_grpc::NonDriverException& ex) { @@ -3776,7 +3760,6 @@ ::grpc::Status MonikerWriteU8(void* data, google::protobuf::Arena& arena, google return ::grpc::Status::CANCELLED; } try { - auto session_grpc_session = request->session(); NiFpga_Session session = session_repository_->access_session(session_grpc_session.name()); uint32_t control = request->control(); @@ -3789,6 +3772,7 @@ ::grpc::Status MonikerWriteU8(void* data, google::protobuf::Arena& arena, google ni::data_monikers::Moniker* moniker = new ni::data_monikers::Moniker(); ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerWriteArrayU16", data, *moniker); response->set_allocated_moniker(moniker); + response->set_status(0); return ::grpc::Status::OK; } catch (nidevice_grpc::NonDriverException& ex) { @@ -3829,7 +3813,6 @@ ::grpc::Status MonikerWriteU8(void* data, google::protobuf::Arena& arena, google return ::grpc::Status::CANCELLED; } try { - auto session_grpc_session = request->session(); NiFpga_Session session = session_repository_->access_session(session_grpc_session.name()); uint32_t control = request->control(); @@ -3842,6 +3825,7 @@ ::grpc::Status MonikerWriteU8(void* data, google::protobuf::Arena& arena, google ni::data_monikers::Moniker* moniker = new ni::data_monikers::Moniker(); ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerWriteArrayU32", data, *moniker); response->set_allocated_moniker(moniker); + response->set_status(0); return ::grpc::Status::OK; } catch (nidevice_grpc::NonDriverException& ex) { @@ -3882,7 +3866,6 @@ ::grpc::Status MonikerWriteU8(void* data, google::protobuf::Arena& arena, google return ::grpc::Status::CANCELLED; } try { - auto session_grpc_session = request->session(); NiFpga_Session session = session_repository_->access_session(session_grpc_session.name()); uint32_t control = request->control(); @@ -3895,6 +3878,7 @@ ::grpc::Status MonikerWriteU8(void* data, google::protobuf::Arena& arena, google ni::data_monikers::Moniker* moniker = new ni::data_monikers::Moniker(); ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerWriteArrayU64", data, *moniker); response->set_allocated_moniker(moniker); + response->set_status(0); return ::grpc::Status::OK; } catch (nidevice_grpc::NonDriverException& ex) { @@ -3952,7 +3936,6 @@ ::grpc::Status MonikerWriteU8(void* data, google::protobuf::Arena& arena, google return ::grpc::Status::CANCELLED; } try { - auto session_grpc_session = request->session(); NiFpga_Session session = session_repository_->access_session(session_grpc_session.name()); uint32_t control = request->control(); @@ -3965,6 +3948,7 @@ ::grpc::Status MonikerWriteU8(void* data, google::protobuf::Arena& arena, google ni::data_monikers::Moniker* moniker = new ni::data_monikers::Moniker(); ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerWriteArrayU8", data, *moniker); response->set_allocated_moniker(moniker); + response->set_status(0); return ::grpc::Status::OK; } catch (nidevice_grpc::NonDriverException& ex) { @@ -4437,7 +4421,6 @@ ::grpc::Status MonikerWriteU8(void* data, google::protobuf::Arena& arena, google return ::grpc::Status::CANCELLED; } try { - auto session_grpc_session = request->session(); NiFpga_Session session = session_repository_->access_session(session_grpc_session.name()); uint32_t control = request->control(); @@ -4450,6 +4433,7 @@ ::grpc::Status MonikerWriteU8(void* data, google::protobuf::Arena& arena, google ni::data_monikers::Moniker* moniker = new ni::data_monikers::Moniker(); ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerWriteI16", data, *moniker); response->set_allocated_moniker(moniker); + response->set_status(0); return ::grpc::Status::OK; } catch (nidevice_grpc::NonDriverException& ex) { @@ -4489,7 +4473,6 @@ ::grpc::Status MonikerWriteU8(void* data, google::protobuf::Arena& arena, google return ::grpc::Status::CANCELLED; } try { - auto session_grpc_session = request->session(); NiFpga_Session session = session_repository_->access_session(session_grpc_session.name()); uint32_t control = request->control(); @@ -4502,6 +4485,7 @@ ::grpc::Status MonikerWriteU8(void* data, google::protobuf::Arena& arena, google ni::data_monikers::Moniker* moniker = new ni::data_monikers::Moniker(); ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerWriteI32", data, *moniker); response->set_allocated_moniker(moniker); + response->set_status(0); return ::grpc::Status::OK; } catch (nidevice_grpc::NonDriverException& ex) { @@ -4541,7 +4525,6 @@ ::grpc::Status MonikerWriteU8(void* data, google::protobuf::Arena& arena, google return ::grpc::Status::CANCELLED; } try { - auto session_grpc_session = request->session(); NiFpga_Session session = session_repository_->access_session(session_grpc_session.name()); uint32_t control = request->control(); @@ -4554,6 +4537,7 @@ ::grpc::Status MonikerWriteU8(void* data, google::protobuf::Arena& arena, google ni::data_monikers::Moniker* moniker = new ni::data_monikers::Moniker(); ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerWriteI64", data, *moniker); response->set_allocated_moniker(moniker); + response->set_status(0); return ::grpc::Status::OK; } catch (nidevice_grpc::NonDriverException& ex) { @@ -4602,7 +4586,6 @@ ::grpc::Status MonikerWriteU8(void* data, google::protobuf::Arena& arena, google return ::grpc::Status::CANCELLED; } try { - auto session_grpc_session = request->session(); NiFpga_Session session = session_repository_->access_session(session_grpc_session.name()); uint32_t control = request->control(); @@ -4615,6 +4598,7 @@ ::grpc::Status MonikerWriteU8(void* data, google::protobuf::Arena& arena, google ni::data_monikers::Moniker* moniker = new ni::data_monikers::Moniker(); ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerWriteI8", data, *moniker); response->set_allocated_moniker(moniker); + response->set_status(0); return ::grpc::Status::OK; } catch (nidevice_grpc::NonDriverException& ex) { @@ -4687,7 +4671,6 @@ ::grpc::Status MonikerWriteU8(void* data, google::protobuf::Arena& arena, google return ::grpc::Status::CANCELLED; } try { - auto session_grpc_session = request->session(); NiFpga_Session session = session_repository_->access_session(session_grpc_session.name()); uint32_t control = request->control(); @@ -4700,6 +4683,7 @@ ::grpc::Status MonikerWriteU8(void* data, google::protobuf::Arena& arena, google ni::data_monikers::Moniker* moniker = new ni::data_monikers::Moniker(); ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerWriteU16", data, *moniker); response->set_allocated_moniker(moniker); + response->set_status(0); return ::grpc::Status::OK; } catch (nidevice_grpc::NonDriverException& ex) { @@ -4739,7 +4723,6 @@ ::grpc::Status MonikerWriteU8(void* data, google::protobuf::Arena& arena, google return ::grpc::Status::CANCELLED; } try { - auto session_grpc_session = request->session(); NiFpga_Session session = session_repository_->access_session(session_grpc_session.name()); uint32_t control = request->control(); @@ -4752,6 +4735,7 @@ ::grpc::Status MonikerWriteU8(void* data, google::protobuf::Arena& arena, google ni::data_monikers::Moniker* moniker = new ni::data_monikers::Moniker(); ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerWriteU32", data, *moniker); response->set_allocated_moniker(moniker); + response->set_status(0); return ::grpc::Status::OK; } catch (nidevice_grpc::NonDriverException& ex) { @@ -4791,7 +4775,6 @@ ::grpc::Status MonikerWriteU8(void* data, google::protobuf::Arena& arena, google return ::grpc::Status::CANCELLED; } try { - auto session_grpc_session = request->session(); NiFpga_Session session = session_repository_->access_session(session_grpc_session.name()); uint32_t control = request->control(); @@ -4804,6 +4787,7 @@ ::grpc::Status MonikerWriteU8(void* data, google::protobuf::Arena& arena, google ni::data_monikers::Moniker* moniker = new ni::data_monikers::Moniker(); ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerWriteU64", data, *moniker); response->set_allocated_moniker(moniker); + response->set_status(0); return ::grpc::Status::OK; } catch (nidevice_grpc::NonDriverException& ex) { @@ -4852,7 +4836,6 @@ ::grpc::Status MonikerWriteU8(void* data, google::protobuf::Arena& arena, google return ::grpc::Status::CANCELLED; } try { - auto session_grpc_session = request->session(); NiFpga_Session session = session_repository_->access_session(session_grpc_session.name()); uint32_t control = request->control(); @@ -4865,6 +4848,7 @@ ::grpc::Status MonikerWriteU8(void* data, google::protobuf::Arena& arena, google ni::data_monikers::Moniker* moniker = new ni::data_monikers::Moniker(); ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerWriteU8", data, *moniker); response->set_allocated_moniker(moniker); + response->set_status(0); return ::grpc::Status::OK; } catch (nidevice_grpc::NonDriverException& ex) { diff --git a/generated/register_all_services.cpp b/generated/register_all_services.cpp index 940fd1f3f..294b162fb 100644 --- a/generated/register_all_services.cpp +++ b/generated/register_all_services.cpp @@ -93,11 +93,6 @@ std::shared_ptr>> register_all_services( auto session_repository = std::make_shared(); service_vector->push_back(session_repository); nidevice_grpc::register_core_services(service_vector, server_builder, session_repository, feature_toggles); - if (ni::data_monikers::is_sideband_streaming_enabled(feature_toggles)) { - auto moniker_service = std::make_shared(); - server_builder.RegisterService(moniker_service.get()); - service_vector->push_back(moniker_service); - } auto task_handle_repository = std::make_shared>(session_repository); auto vi_session_repository = std::make_shared>(session_repository); diff --git a/source/codegen/common_helpers.py b/source/codegen/common_helpers.py index fbd128029..90363453d 100644 --- a/source/codegen/common_helpers.py +++ b/source/codegen/common_helpers.py @@ -1216,6 +1216,41 @@ def get_data_moniker_function_name(function_name): return function_name.replace("Begin", "Moniker") +def get_data_moniker_struct_name(function_name): + """Return the corresponding moniker function name for the given C API function.""" + return f"{function_name.replace('Begin', 'Moniker')}Data" + + def is_function_in_streaming_functions(function_name, streaming_functions_to_generate): """Check if a function name is in the streaming functions to generate.""" return function_name in streaming_functions_to_generate + + +def _is_streaming_param_input_array(streaming_param): + """Check if the streaming parameter is an input array.""" + return ( + streaming_param + and streaming_param["direction"] == "in" + and is_array(streaming_param["type"]) + ) + + +def get_input_streaming_param(parameters): + """Determine if a parameter should be included based on streaming conditions.""" + streaming_param = None + for param in parameters: + if param.get("is_streaming_type", False): + streaming_param = param + break + + params = [] + for param in parameters: + if is_input_parameter(param): + if not param.get("is_streaming_type", False): + if _is_streaming_param_input_array(streaming_param): + size_param_name = streaming_param["size"]["value"] + if param["name"] != size_param_name: + params.append(param) + else: + params.append(param) + return params diff --git a/source/codegen/service_helpers.py b/source/codegen/service_helpers.py index bb885b41f..bcc85e220 100644 --- a/source/codegen/service_helpers.py +++ b/source/codegen/service_helpers.py @@ -709,26 +709,6 @@ def get_protobuf_cpplib_type(grpc_type: str) -> str: return grpc_type -def get_coerced_type_and_presence(streaming_type: str) -> tuple: - """Get the coerced type and check if the coerced type is present in the type map. - - This handles both scalar types and array types like int8_t[] or uint16_t[]. - """ - type_map = { - "int8_t": "int32_t", - "uint8_t": "uint32_t", - "int16_t": "int32_t", - "uint16_t": "uint32_t", - } - - base_type = streaming_type.replace("[]", "") - - coerced_type = type_map.get(base_type, base_type) - is_coerced_type_present = base_type in type_map - - return coerced_type, is_coerced_type_present - - def get_streaming_type(parameters) -> str: """Get the streaming type from the function data.""" for param in parameters: diff --git a/source/codegen/templates/register_all_services.cpp.mako b/source/codegen/templates/register_all_services.cpp.mako index 54f623617..cfd84cc94 100644 --- a/source/codegen/templates/register_all_services.cpp.mako +++ b/source/codegen/templates/register_all_services.cpp.mako @@ -42,11 +42,6 @@ std::shared_ptr>> register_all_services( auto session_repository = std::make_shared(); service_vector->push_back(session_repository); nidevice_grpc::register_core_services(service_vector, server_builder, session_repository, feature_toggles); - if (ni::data_monikers::is_sideband_streaming_enabled(feature_toggles)) { - auto moniker_service = std::make_shared(); - server_builder.RegisterService(moniker_service.get()); - service_vector->push_back(moniker_service); - } % for type_name, config in repository_type_to_config.items(): <%block filter="common_helpers.os_conditional_compile_block(config)">\ diff --git a/source/codegen/templates/service.cpp.mako b/source/codegen/templates/service.cpp.mako index fb282e7a4..ba25d7cde 100644 --- a/source/codegen/templates/service.cpp.mako +++ b/source/codegen/templates/service.cpp.mako @@ -68,7 +68,7 @@ namespace ${config["namespace_component"]}_grpc { function_data = functions[function_name] parameters = function_data['parameters'] %> -${mako_helper.define_moniker_streaming_structs(function_name=function_name, function_data=function_data, parameters=parameters)}\ +${mako_helper.define_moniker_streaming_struct(function_name=function_name, parameters=parameters)}\ % endfor % if any_ivi_dance_functions: diff --git a/source/codegen/templates/service_helpers.mako b/source/codegen/templates/service_helpers.mako index c61e613a3..b4e7073d9 100644 --- a/source/codegen/templates/service_helpers.mako +++ b/source/codegen/templates/service_helpers.mako @@ -271,28 +271,26 @@ ${populate_response(function_data=function_data, parameters=parameters)}\ return ::grpc::Status::OK;\ -<%def name="register_moniker_functions(function_name)"> +<%def name="register_moniker_functions(function_name)">\ <% moniker_function_name = common_helpers.get_data_moniker_function_name(function_name) %>\ - ::ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("${moniker_function_name}", ${moniker_function_name}); + ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("${moniker_function_name}", ${moniker_function_name}); -<%def name="define_moniker_streaming_structs(function_name, function_data, parameters)">\ +<%def name="define_moniker_streaming_struct(function_name, parameters)">\ <% config = data['config'] - input_params = [p for p in function_data['parameters'] if common_helpers.is_input_parameter(p)] - streaming_param = common_helpers.get_streaming_parameter(function_data['parameters']) + streaming_param = common_helpers.get_streaming_parameter(parameters) service_class_prefix = config["service_class_prefix"] grpc_streaming_type = streaming_param['grpc_streaming_type'] - struct_name = f"Moniker{function_name.replace('Begin', '')}Data" if function_name.startswith('Begin') else f"Moniker{function_name}Data" + struct_name = common_helpers.get_data_moniker_struct_name(function_name) + streaming_param_to_include = common_helpers.get_input_streaming_param(parameters) %>\ struct ${struct_name} { - % for param in input_params: - % if service_helpers.include_param(param, streaming_param): + % for param in streaming_param_to_include: ${param['type']} ${param['name']}; - % endif % endfor ${service_class_prefix.lower()}_grpc::${grpc_streaming_type} data; std::shared_ptr<${service_class_prefix}LibraryInterface> library; @@ -302,11 +300,10 @@ ${populate_response(function_data=function_data, parameters=parameters)}\ <%def name="define_moniker_function_body(function_name, function_data)">\ <% config = data['config'] - struct_name = f"Moniker{function_name.replace('Begin', '')}Data" if function_name.startswith('Begin') else f"Moniker{function_name}Data" + struct_name = common_helpers.get_data_moniker_struct_name(function_name) moniker_function_name = common_helpers.get_data_moniker_function_name(function_name) streaming_param = common_helpers.get_streaming_parameter(function_data['parameters']) streaming_type = streaming_param['type'] - coerced_type, is_coerced_type_present = service_helpers.get_coerced_type_and_presence(streaming_type) grpc_streaming_type = streaming_param['grpc_streaming_type'] is_array = common_helpers.is_array(streaming_type) arg_string = service_helpers.create_args(function_data['parameters']) @@ -321,9 +318,9 @@ ${populate_response(function_data=function_data, parameters=parameters)}\ auto library = function_data->library; ${initialize_non_array_parameters(input_params, streaming_param)}\ % if streaming_param and streaming_param['direction'] == 'out': - ${handle_out_direction(c_api_name, arg_string, data_type, streaming_type, is_coerced_type_present, streaming_param)}\ + ${streaming_handle_out_direction(c_api_name, arg_string, data_type, streaming_type, streaming_param)}\ % elif streaming_param and streaming_param['direction'] == 'in': - ${handle_in_direction(c_api_name, arg_string, data_type, grpc_streaming_type, streaming_type, coerced_type, is_coerced_type_present, is_array)}\ + ${streaming_handle_in_direction(c_api_name, arg_string, data_type, grpc_streaming_type, streaming_type, streaming_param)}\ % endif if (status < 0) { std::cout << "${moniker_function_name} error: " << status << std::endl; @@ -332,41 +329,53 @@ ${populate_response(function_data=function_data, parameters=parameters)}\ } -<%def name="define_streaming_api_body(function_name, function_data, parameters)"> +<%def name="define_streaming_api_body(function_name, function_data, parameters)">\ <% config = data['config'] - input_params = [p for p in parameters if common_helpers.is_input_parameter(p)] output_params = [p for p in parameters if common_helpers.is_output_parameter(p)] service_class_prefix = config["service_class_prefix"] request_param = service_helpers.get_request_param(function_name) response_param = service_helpers.get_response_param(function_name) - struct_name = f"Moniker{function_name.replace('Begin', '')}Data" if function_name.startswith('Begin') else f"Moniker{function_name}Data" + struct_name = common_helpers.get_data_moniker_struct_name(function_name) moniker_function_name = common_helpers.get_data_moniker_function_name(function_name) streaming_param = common_helpers.get_streaming_parameter(parameters) + streaming_param_to_include = common_helpers.get_input_streaming_param(parameters) %>\ -${initialize_streaming_input_param(function_name, input_params, parameters, streaming_param)} +${initialize_streaming_input_param(function_name, streaming_param_to_include, parameters, streaming_param)} ${struct_name}* data = new ${struct_name}(); - ${initialize_begin_input_param(input_params, streaming_param)}\ + ${initialize_begin_input_param(streaming_param_to_include, streaming_param)}\ data->library = std::shared_ptr<${service_class_prefix}LibraryInterface>(library_); ${initialize_service_output_params(output_params)}\ ni::data_monikers::Moniker* moniker = new ni::data_monikers::Moniker(); ni::data_monikers::DataMonikerService::RegisterMonikerInstance("${moniker_function_name}", data, *moniker); response->set_allocated_moniker(moniker); + response->set_status(0); return ::grpc::Status::OK;\ -<%def name="handle_out_direction(c_api_name, arg_string, data_type, streaming_type, is_coerced_type_present, streaming_param)"> +<%def name="streaming_handle_out_direction(c_api_name, arg_string, data_type, streaming_type, streaming_param)"> <% - size = service_helpers.get_size_param_name(streaming_param) + is_array = common_helpers.is_array(streaming_type) %>\ - % if common_helpers.is_array(streaming_type): - % if is_coerced_type_present: - std::vector<${data_type}> array(${size}); - % else: - ${data_type}* array = new ${data_type}[${size}]; - % endif +% if is_array: + ${streaming_handle_out_direction_array(c_api_name, arg_string, data_type, streaming_param)} +% else: + ${streaming_handle_out_direction_scaler(c_api_name, arg_string, streaming_type)} +% endif + + +<%def name="streaming_handle_out_direction_array(c_api_name, arg_string, data_type, streaming_param)">\ +<% + is_coerced = service_helpers.is_output_array_that_needs_coercion(streaming_param) + size = service_helpers.get_size_param_name(streaming_param) +%>\ +% if is_coerced: +std::vector<${data_type}> array(${size}); +% else: +${data_type}* array = new ${data_type}[${size}]; +% endif auto status = library->${c_api_name}(${arg_string}); - % if is_coerced_type_present: +% if is_coerced: if (status >= 0) { std::transform( array.begin(), @@ -377,7 +386,7 @@ ${initialize_streaming_input_param(function_name, input_params, parameters, stre }); packedData.PackFrom(function_data->data); } - % else: +% else: if (status >= 0) { std::transform( array, @@ -388,23 +397,52 @@ ${initialize_streaming_input_param(function_name, input_params, parameters, stre }); packedData.PackFrom(function_data->data); } - % endif - % else: - ${streaming_type} value = 0; +% endif + + +<%def name="streaming_handle_out_direction_scaler(c_api_name, arg_string, streaming_type)">\ +${streaming_type} value = 0; auto status = library->${c_api_name}(${arg_string}); function_data->data.set_value(value); if (status >= 0) { packedData.PackFrom(function_data->data); } - % endif -<%def name="handle_in_direction(c_api_name, arg_string, data_type, grpc_streaming_type, streaming_type, coerced_type, is_coerced_type_present, is_array)"> +<%def name="streaming_handle_in_direction(c_api_name, arg_string, data_type, grpc_streaming_type, streaming_type, streaming_param)"> +<% + is_array = common_helpers.is_array(streaming_type) +%>\ ${grpc_streaming_type} ${grpc_streaming_type.lower()}_message; packedData.UnpackTo(&${grpc_streaming_type.lower()}_message); % if is_array: - % if is_coerced_type_present: - auto data_array = ${grpc_streaming_type.lower()}_message.value(); + ${streaming_handle_in_direction_array(data_type, grpc_streaming_type, streaming_param)}\ +% else: + ${streaming_handle_in_direction_scaler(grpc_streaming_type, streaming_type, streaming_param)}\ +% endif + + auto status = library->${c_api_name}(${arg_string}); + + +<%def name="streaming_handle_in_direction_scaler(grpc_streaming_type, streaming_type, streaming_param)">\ +<% + is_coerced = service_helpers.is_scalar_input_that_needs_coercion(streaming_param) +%>\ +auto value = ${grpc_streaming_type.lower()}_message.value(); +% if is_coerced: + if (value < std::numeric_limits<${streaming_type}>::min() || value > std::numeric_limits<${streaming_type}>::max()) { + std::string message("value " + std::to_string(value) + " doesn't fit in datatype ${streaming_type}"); + throw nidevice_grpc::ValueOutOfRangeException(message); + } +% endif + + +<%def name="streaming_handle_in_direction_array(data_type, grpc_streaming_type, streaming_param)">\ +<% + is_coerced = service_helpers.is_input_array_that_needs_coercion(streaming_param) +%>\ +% if is_coerced: +auto data_array = ${grpc_streaming_type.lower()}_message.value(); auto array = std::vector<${data_type}>(); auto size = data_array.size(); array.reserve(size); @@ -424,34 +462,19 @@ ${initialize_streaming_input_param(function_name, input_params, parameters, stre auto array = const_cast<${data_type}*>(${grpc_streaming_type.lower()}_message.value().data()); auto size = data_array.size(); % endif -% else: - ${coerced_type} value = ${grpc_streaming_type.lower()}_message.value(); -% if is_coerced_type_present: - if (value < std::numeric_limits<${streaming_type}>::min() || value > std::numeric_limits<${streaming_type}>::max()) { - std::string message("value " + std::to_string(value) + " doesn't fit in datatype ${streaming_type}"); - throw nidevice_grpc::ValueOutOfRangeException(message); - } -% endif -% endif - - auto status = library->${c_api_name}(${arg_string}); ## Initialize an bgin input parameter for an API call. -<%def name="initialize_begin_input_param(input_params, streaming_param)">\ -% for param in input_params: -% if service_helpers.include_param(param, streaming_param): +<%def name="initialize_begin_input_param(streaming_param_to_include, streaming_param)">\ +% for param in streaming_param_to_include: data->${param['name']} = ${param['name']}; -% endif % endfor ## Initialize an bgin input parameter for an API call. -<%def name="initialize_streaming_input_param(function_name, input_params, parameters, streaming_param)">\ -% for param in input_params: -% if service_helpers.include_param(param, streaming_param): +<%def name="initialize_streaming_input_param(function_name, streaming_param_to_include, parameters, streaming_param)">\ +% for param in streaming_param_to_include: ${initialize_input_param(function_name, param, parameters)}\ -% endif % endfor From e5c98791d771df8ac8d9c899ac7869ebce020e2b Mon Sep 17 00:00:00 2001 From: Ayush Mehra Date: Thu, 7 Nov 2024 03:17:02 -0800 Subject: [PATCH 24/34] remove unused functions --- source/codegen/service_helpers.py | 18 ------------------ source/codegen/templates/service_helpers.mako | 11 ++++------- 2 files changed, 4 insertions(+), 25 deletions(-) diff --git a/source/codegen/service_helpers.py b/source/codegen/service_helpers.py index bcc85e220..e4b62dc62 100644 --- a/source/codegen/service_helpers.py +++ b/source/codegen/service_helpers.py @@ -717,24 +717,6 @@ def get_streaming_type(parameters) -> str: return None -def include_param(param, streaming_param): - """Determine if a parameter should be included based on streaming conditions.""" - if not param.get("is_streaming_type", False): - if ( - streaming_param - and streaming_param["direction"] == "in" - and common_helpers.is_array(streaming_param["type"]) - ): - if param["name"] != streaming_param["size"]["value"]: - return True - else: - return False - else: - return True - else: - return False - - def get_size_param_name(streaming_param) -> str: """Get the size parameter name for the given streaming parameter.""" if common_helpers.is_array(streaming_param["type"]): diff --git a/source/codegen/templates/service_helpers.mako b/source/codegen/templates/service_helpers.mako index b4e7073d9..bc81360e1 100644 --- a/source/codegen/templates/service_helpers.mako +++ b/source/codegen/templates/service_helpers.mako @@ -305,18 +305,17 @@ ${populate_response(function_data=function_data, parameters=parameters)}\ streaming_param = common_helpers.get_streaming_parameter(function_data['parameters']) streaming_type = streaming_param['type'] grpc_streaming_type = streaming_param['grpc_streaming_type'] - is_array = common_helpers.is_array(streaming_type) arg_string = service_helpers.create_args(function_data['parameters']) arg_string = arg_string.replace(", &moniker", "").strip() data_type = streaming_type.replace("[]", "") c_api_name = service_helpers.get_c_api_name(function_name) - input_params = [p for p in function_data['parameters'] if common_helpers.is_input_parameter(p)] + streaming_param_to_include = common_helpers.get_input_streaming_param(function_data['parameters']) %>\ ::grpc::Status ${moniker_function_name}(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData) { ${struct_name}* function_data = (${struct_name}*)data; auto library = function_data->library; - ${initialize_non_array_parameters(input_params, streaming_param)}\ + ${initialize_moniker_streaming_parameters(streaming_param_to_include)}\ % if streaming_param and streaming_param['direction'] == 'out': ${streaming_handle_out_direction(c_api_name, arg_string, data_type, streaming_type, streaming_param)}\ % elif streaming_param and streaming_param['direction'] == 'in': @@ -478,11 +477,9 @@ ${initialize_input_param(function_name, param, parameters)}\ % endfor -<%def name="initialize_non_array_parameters(input_params, streaming_param)"> -% for param in input_params: - % if service_helpers.include_param(param, streaming_param): +<%def name="initialize_moniker_streaming_parameters(streaming_param_to_include)"> +% for param in streaming_param_to_include: auto ${param['name']} = function_data->${param['name']}; - % endif % endfor From b6f207d050195516f02657d10fe4edabf10a0d49 Mon Sep 17 00:00:00 2001 From: Ayush Mehra Date: Fri, 8 Nov 2024 03:01:30 -0800 Subject: [PATCH 25/34] delete[] array --- generated/nifpga/nifpga_service.cpp | 260 +++++++++--------- source/codegen/templates/service_helpers.mako | 9 +- 2 files changed, 137 insertions(+), 132 deletions(-) diff --git a/generated/nifpga/nifpga_service.cpp b/generated/nifpga/nifpga_service.cpp index 648488eb5..03cf1346b 100644 --- a/generated/nifpga/nifpga_service.cpp +++ b/generated/nifpga/nifpga_service.cpp @@ -391,6 +391,7 @@ ::grpc::Status MonikerReadArrayI32(void* data, google::protobuf::Arena& arena, g }); packedData.PackFrom(function_data->data); } + delete[] array; if (status < 0) { std::cout << "MonikerReadArrayI32 error: " << status << std::endl; @@ -419,6 +420,7 @@ ::grpc::Status MonikerReadArrayI64(void* data, google::protobuf::Arena& arena, g }); packedData.PackFrom(function_data->data); } + delete[] array; if (status < 0) { std::cout << "MonikerReadArrayI64 error: " << status << std::endl; @@ -503,6 +505,7 @@ ::grpc::Status MonikerReadArrayU32(void* data, google::protobuf::Arena& arena, g }); packedData.PackFrom(function_data->data); } + delete[] array; if (status < 0) { std::cout << "MonikerReadArrayU32 error: " << status << std::endl; @@ -531,6 +534,7 @@ ::grpc::Status MonikerReadArrayU64(void* data, google::protobuf::Arena& arena, g }); packedData.PackFrom(function_data->data); } + delete[] array; if (status < 0) { std::cout << "MonikerReadArrayU64 error: " << status << std::endl; @@ -1722,7 +1726,7 @@ ::grpc::Status MonikerWriteU8(void* data, google::protobuf::Arena& arena, google uint32_t indicator = request->indicator(); size_t size = request->size(); - MonikerReadArrayI16Data* data = new MonikerReadArrayI16Data(); + auto data = std::make_unique(); data->session = session; data->indicator = indicator; data->size = size; @@ -1730,9 +1734,9 @@ ::grpc::Status MonikerWriteU8(void* data, google::protobuf::Arena& arena, google data->data.mutable_value()->Reserve(request->size()); data->data.mutable_value()->Resize(request->size(), 0); - ni::data_monikers::Moniker* moniker = new ni::data_monikers::Moniker(); - ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerReadArrayI16", data, *moniker); - response->set_allocated_moniker(moniker); + auto moniker = std::make_unique(); + ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerReadArrayI16", data.get(), *moniker); + response->set_allocated_moniker(moniker.release()); response->set_status(0); return ::grpc::Status::OK; } @@ -1780,7 +1784,7 @@ ::grpc::Status MonikerWriteU8(void* data, google::protobuf::Arena& arena, google uint32_t indicator = request->indicator(); size_t size = request->size(); - MonikerReadArrayI32Data* data = new MonikerReadArrayI32Data(); + auto data = std::make_unique(); data->session = session; data->indicator = indicator; data->size = size; @@ -1788,9 +1792,9 @@ ::grpc::Status MonikerWriteU8(void* data, google::protobuf::Arena& arena, google data->data.mutable_value()->Reserve(request->size()); data->data.mutable_value()->Resize(request->size(), 0); - ni::data_monikers::Moniker* moniker = new ni::data_monikers::Moniker(); - ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerReadArrayI32", data, *moniker); - response->set_allocated_moniker(moniker); + auto moniker = std::make_unique(); + ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerReadArrayI32", data.get(), *moniker); + response->set_allocated_moniker(moniker.release()); response->set_status(0); return ::grpc::Status::OK; } @@ -1838,7 +1842,7 @@ ::grpc::Status MonikerWriteU8(void* data, google::protobuf::Arena& arena, google uint32_t indicator = request->indicator(); size_t size = request->size(); - MonikerReadArrayI64Data* data = new MonikerReadArrayI64Data(); + auto data = std::make_unique(); data->session = session; data->indicator = indicator; data->size = size; @@ -1846,9 +1850,9 @@ ::grpc::Status MonikerWriteU8(void* data, google::protobuf::Arena& arena, google data->data.mutable_value()->Reserve(request->size()); data->data.mutable_value()->Resize(request->size(), 0); - ni::data_monikers::Moniker* moniker = new ni::data_monikers::Moniker(); - ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerReadArrayI64", data, *moniker); - response->set_allocated_moniker(moniker); + auto moniker = std::make_unique(); + ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerReadArrayI64", data.get(), *moniker); + response->set_allocated_moniker(moniker.release()); response->set_status(0); return ::grpc::Status::OK; } @@ -1904,7 +1908,7 @@ ::grpc::Status MonikerWriteU8(void* data, google::protobuf::Arena& arena, google uint32_t indicator = request->indicator(); size_t size = request->size(); - MonikerReadArrayI8Data* data = new MonikerReadArrayI8Data(); + auto data = std::make_unique(); data->session = session; data->indicator = indicator; data->size = size; @@ -1912,9 +1916,9 @@ ::grpc::Status MonikerWriteU8(void* data, google::protobuf::Arena& arena, google data->data.mutable_value()->Reserve(request->size()); data->data.mutable_value()->Resize(request->size(), 0); - ni::data_monikers::Moniker* moniker = new ni::data_monikers::Moniker(); - ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerReadArrayI8", data, *moniker); - response->set_allocated_moniker(moniker); + auto moniker = std::make_unique(); + ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerReadArrayI8", data.get(), *moniker); + response->set_allocated_moniker(moniker.release()); response->set_status(0); return ::grpc::Status::OK; } @@ -1996,7 +2000,7 @@ ::grpc::Status MonikerWriteU8(void* data, google::protobuf::Arena& arena, google uint32_t indicator = request->indicator(); size_t size = request->size(); - MonikerReadArrayU16Data* data = new MonikerReadArrayU16Data(); + auto data = std::make_unique(); data->session = session; data->indicator = indicator; data->size = size; @@ -2004,9 +2008,9 @@ ::grpc::Status MonikerWriteU8(void* data, google::protobuf::Arena& arena, google data->data.mutable_value()->Reserve(request->size()); data->data.mutable_value()->Resize(request->size(), 0); - ni::data_monikers::Moniker* moniker = new ni::data_monikers::Moniker(); - ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerReadArrayU16", data, *moniker); - response->set_allocated_moniker(moniker); + auto moniker = std::make_unique(); + ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerReadArrayU16", data.get(), *moniker); + response->set_allocated_moniker(moniker.release()); response->set_status(0); return ::grpc::Status::OK; } @@ -2054,7 +2058,7 @@ ::grpc::Status MonikerWriteU8(void* data, google::protobuf::Arena& arena, google uint32_t indicator = request->indicator(); size_t size = request->size(); - MonikerReadArrayU32Data* data = new MonikerReadArrayU32Data(); + auto data = std::make_unique(); data->session = session; data->indicator = indicator; data->size = size; @@ -2062,9 +2066,9 @@ ::grpc::Status MonikerWriteU8(void* data, google::protobuf::Arena& arena, google data->data.mutable_value()->Reserve(request->size()); data->data.mutable_value()->Resize(request->size(), 0); - ni::data_monikers::Moniker* moniker = new ni::data_monikers::Moniker(); - ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerReadArrayU32", data, *moniker); - response->set_allocated_moniker(moniker); + auto moniker = std::make_unique(); + ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerReadArrayU32", data.get(), *moniker); + response->set_allocated_moniker(moniker.release()); response->set_status(0); return ::grpc::Status::OK; } @@ -2112,7 +2116,7 @@ ::grpc::Status MonikerWriteU8(void* data, google::protobuf::Arena& arena, google uint32_t indicator = request->indicator(); size_t size = request->size(); - MonikerReadArrayU64Data* data = new MonikerReadArrayU64Data(); + auto data = std::make_unique(); data->session = session; data->indicator = indicator; data->size = size; @@ -2120,9 +2124,9 @@ ::grpc::Status MonikerWriteU8(void* data, google::protobuf::Arena& arena, google data->data.mutable_value()->Reserve(request->size()); data->data.mutable_value()->Resize(request->size(), 0); - ni::data_monikers::Moniker* moniker = new ni::data_monikers::Moniker(); - ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerReadArrayU64", data, *moniker); - response->set_allocated_moniker(moniker); + auto moniker = std::make_unique(); + ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerReadArrayU64", data.get(), *moniker); + response->set_allocated_moniker(moniker.release()); response->set_status(0); return ::grpc::Status::OK; } @@ -2178,7 +2182,7 @@ ::grpc::Status MonikerWriteU8(void* data, google::protobuf::Arena& arena, google uint32_t indicator = request->indicator(); size_t size = request->size(); - MonikerReadArrayU8Data* data = new MonikerReadArrayU8Data(); + auto data = std::make_unique(); data->session = session; data->indicator = indicator; data->size = size; @@ -2186,9 +2190,9 @@ ::grpc::Status MonikerWriteU8(void* data, google::protobuf::Arena& arena, google data->data.mutable_value()->Reserve(request->size()); data->data.mutable_value()->Resize(request->size(), 0); - ni::data_monikers::Moniker* moniker = new ni::data_monikers::Moniker(); - ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerReadArrayU8", data, *moniker); - response->set_allocated_moniker(moniker); + auto moniker = std::make_unique(); + ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerReadArrayU8", data.get(), *moniker); + response->set_allocated_moniker(moniker.release()); response->set_status(0); return ::grpc::Status::OK; } @@ -2635,14 +2639,14 @@ ::grpc::Status MonikerWriteU8(void* data, google::protobuf::Arena& arena, google NiFpga_Session session = session_repository_->access_session(session_grpc_session.name()); uint32_t indicator = request->indicator(); - MonikerReadI16Data* data = new MonikerReadI16Data(); + auto data = std::make_unique(); data->session = session; data->indicator = indicator; data->library = std::shared_ptr(library_); - ni::data_monikers::Moniker* moniker = new ni::data_monikers::Moniker(); - ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerReadI16", data, *moniker); - response->set_allocated_moniker(moniker); + auto moniker = std::make_unique(); + ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerReadI16", data.get(), *moniker); + response->set_allocated_moniker(moniker.release()); response->set_status(0); return ::grpc::Status::OK; } @@ -2688,14 +2692,14 @@ ::grpc::Status MonikerWriteU8(void* data, google::protobuf::Arena& arena, google NiFpga_Session session = session_repository_->access_session(session_grpc_session.name()); uint32_t indicator = request->indicator(); - MonikerReadI32Data* data = new MonikerReadI32Data(); + auto data = std::make_unique(); data->session = session; data->indicator = indicator; data->library = std::shared_ptr(library_); - ni::data_monikers::Moniker* moniker = new ni::data_monikers::Moniker(); - ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerReadI32", data, *moniker); - response->set_allocated_moniker(moniker); + auto moniker = std::make_unique(); + ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerReadI32", data.get(), *moniker); + response->set_allocated_moniker(moniker.release()); response->set_status(0); return ::grpc::Status::OK; } @@ -2741,14 +2745,14 @@ ::grpc::Status MonikerWriteU8(void* data, google::protobuf::Arena& arena, google NiFpga_Session session = session_repository_->access_session(session_grpc_session.name()); uint32_t indicator = request->indicator(); - MonikerReadI64Data* data = new MonikerReadI64Data(); + auto data = std::make_unique(); data->session = session; data->indicator = indicator; data->library = std::shared_ptr(library_); - ni::data_monikers::Moniker* moniker = new ni::data_monikers::Moniker(); - ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerReadI64", data, *moniker); - response->set_allocated_moniker(moniker); + auto moniker = std::make_unique(); + ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerReadI64", data.get(), *moniker); + response->set_allocated_moniker(moniker.release()); response->set_status(0); return ::grpc::Status::OK; } @@ -2794,14 +2798,14 @@ ::grpc::Status MonikerWriteU8(void* data, google::protobuf::Arena& arena, google NiFpga_Session session = session_repository_->access_session(session_grpc_session.name()); uint32_t indicator = request->indicator(); - MonikerReadI8Data* data = new MonikerReadI8Data(); + auto data = std::make_unique(); data->session = session; data->indicator = indicator; data->library = std::shared_ptr(library_); - ni::data_monikers::Moniker* moniker = new ni::data_monikers::Moniker(); - ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerReadI8", data, *moniker); - response->set_allocated_moniker(moniker); + auto moniker = std::make_unique(); + ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerReadI8", data.get(), *moniker); + response->set_allocated_moniker(moniker.release()); response->set_status(0); return ::grpc::Status::OK; } @@ -2872,14 +2876,14 @@ ::grpc::Status MonikerWriteU8(void* data, google::protobuf::Arena& arena, google NiFpga_Session session = session_repository_->access_session(session_grpc_session.name()); uint32_t indicator = request->indicator(); - MonikerReadU16Data* data = new MonikerReadU16Data(); + auto data = std::make_unique(); data->session = session; data->indicator = indicator; data->library = std::shared_ptr(library_); - ni::data_monikers::Moniker* moniker = new ni::data_monikers::Moniker(); - ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerReadU16", data, *moniker); - response->set_allocated_moniker(moniker); + auto moniker = std::make_unique(); + ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerReadU16", data.get(), *moniker); + response->set_allocated_moniker(moniker.release()); response->set_status(0); return ::grpc::Status::OK; } @@ -2925,14 +2929,14 @@ ::grpc::Status MonikerWriteU8(void* data, google::protobuf::Arena& arena, google NiFpga_Session session = session_repository_->access_session(session_grpc_session.name()); uint32_t indicator = request->indicator(); - MonikerReadU32Data* data = new MonikerReadU32Data(); + auto data = std::make_unique(); data->session = session; data->indicator = indicator; data->library = std::shared_ptr(library_); - ni::data_monikers::Moniker* moniker = new ni::data_monikers::Moniker(); - ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerReadU32", data, *moniker); - response->set_allocated_moniker(moniker); + auto moniker = std::make_unique(); + ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerReadU32", data.get(), *moniker); + response->set_allocated_moniker(moniker.release()); response->set_status(0); return ::grpc::Status::OK; } @@ -2978,14 +2982,14 @@ ::grpc::Status MonikerWriteU8(void* data, google::protobuf::Arena& arena, google NiFpga_Session session = session_repository_->access_session(session_grpc_session.name()); uint32_t indicator = request->indicator(); - MonikerReadU64Data* data = new MonikerReadU64Data(); + auto data = std::make_unique(); data->session = session; data->indicator = indicator; data->library = std::shared_ptr(library_); - ni::data_monikers::Moniker* moniker = new ni::data_monikers::Moniker(); - ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerReadU64", data, *moniker); - response->set_allocated_moniker(moniker); + auto moniker = std::make_unique(); + ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerReadU64", data.get(), *moniker); + response->set_allocated_moniker(moniker.release()); response->set_status(0); return ::grpc::Status::OK; } @@ -3031,14 +3035,14 @@ ::grpc::Status MonikerWriteU8(void* data, google::protobuf::Arena& arena, google NiFpga_Session session = session_repository_->access_session(session_grpc_session.name()); uint32_t indicator = request->indicator(); - MonikerReadU8Data* data = new MonikerReadU8Data(); + auto data = std::make_unique(); data->session = session; data->indicator = indicator; data->library = std::shared_ptr(library_); - ni::data_monikers::Moniker* moniker = new ni::data_monikers::Moniker(); - ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerReadU8", data, *moniker); - response->set_allocated_moniker(moniker); + auto moniker = std::make_unique(); + ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerReadU8", data.get(), *moniker); + response->set_allocated_moniker(moniker.release()); response->set_status(0); return ::grpc::Status::OK; } @@ -3493,14 +3497,14 @@ ::grpc::Status MonikerWriteU8(void* data, google::protobuf::Arena& arena, google NiFpga_Session session = session_repository_->access_session(session_grpc_session.name()); uint32_t control = request->control(); - MonikerWriteArrayI16Data* data = new MonikerWriteArrayI16Data(); + auto data = std::make_unique(); data->session = session; data->control = control; data->library = std::shared_ptr(library_); - ni::data_monikers::Moniker* moniker = new ni::data_monikers::Moniker(); - ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerWriteArrayI16", data, *moniker); - response->set_allocated_moniker(moniker); + auto moniker = std::make_unique(); + ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerWriteArrayI16", data.get(), *moniker); + response->set_allocated_moniker(moniker.release()); response->set_status(0); return ::grpc::Status::OK; } @@ -3546,14 +3550,14 @@ ::grpc::Status MonikerWriteU8(void* data, google::protobuf::Arena& arena, google NiFpga_Session session = session_repository_->access_session(session_grpc_session.name()); uint32_t control = request->control(); - MonikerWriteArrayI32Data* data = new MonikerWriteArrayI32Data(); + auto data = std::make_unique(); data->session = session; data->control = control; data->library = std::shared_ptr(library_); - ni::data_monikers::Moniker* moniker = new ni::data_monikers::Moniker(); - ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerWriteArrayI32", data, *moniker); - response->set_allocated_moniker(moniker); + auto moniker = std::make_unique(); + ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerWriteArrayI32", data.get(), *moniker); + response->set_allocated_moniker(moniker.release()); response->set_status(0); return ::grpc::Status::OK; } @@ -3599,14 +3603,14 @@ ::grpc::Status MonikerWriteU8(void* data, google::protobuf::Arena& arena, google NiFpga_Session session = session_repository_->access_session(session_grpc_session.name()); uint32_t control = request->control(); - MonikerWriteArrayI64Data* data = new MonikerWriteArrayI64Data(); + auto data = std::make_unique(); data->session = session; data->control = control; data->library = std::shared_ptr(library_); - ni::data_monikers::Moniker* moniker = new ni::data_monikers::Moniker(); - ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerWriteArrayI64", data, *moniker); - response->set_allocated_moniker(moniker); + auto moniker = std::make_unique(); + ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerWriteArrayI64", data.get(), *moniker); + response->set_allocated_moniker(moniker.release()); response->set_status(0); return ::grpc::Status::OK; } @@ -3669,14 +3673,14 @@ ::grpc::Status MonikerWriteU8(void* data, google::protobuf::Arena& arena, google NiFpga_Session session = session_repository_->access_session(session_grpc_session.name()); uint32_t control = request->control(); - MonikerWriteArrayI8Data* data = new MonikerWriteArrayI8Data(); + auto data = std::make_unique(); data->session = session; data->control = control; data->library = std::shared_ptr(library_); - ni::data_monikers::Moniker* moniker = new ni::data_monikers::Moniker(); - ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerWriteArrayI8", data, *moniker); - response->set_allocated_moniker(moniker); + auto moniker = std::make_unique(); + ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerWriteArrayI8", data.get(), *moniker); + response->set_allocated_moniker(moniker.release()); response->set_status(0); return ::grpc::Status::OK; } @@ -3764,14 +3768,14 @@ ::grpc::Status MonikerWriteU8(void* data, google::protobuf::Arena& arena, google NiFpga_Session session = session_repository_->access_session(session_grpc_session.name()); uint32_t control = request->control(); - MonikerWriteArrayU16Data* data = new MonikerWriteArrayU16Data(); + auto data = std::make_unique(); data->session = session; data->control = control; data->library = std::shared_ptr(library_); - ni::data_monikers::Moniker* moniker = new ni::data_monikers::Moniker(); - ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerWriteArrayU16", data, *moniker); - response->set_allocated_moniker(moniker); + auto moniker = std::make_unique(); + ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerWriteArrayU16", data.get(), *moniker); + response->set_allocated_moniker(moniker.release()); response->set_status(0); return ::grpc::Status::OK; } @@ -3817,14 +3821,14 @@ ::grpc::Status MonikerWriteU8(void* data, google::protobuf::Arena& arena, google NiFpga_Session session = session_repository_->access_session(session_grpc_session.name()); uint32_t control = request->control(); - MonikerWriteArrayU32Data* data = new MonikerWriteArrayU32Data(); + auto data = std::make_unique(); data->session = session; data->control = control; data->library = std::shared_ptr(library_); - ni::data_monikers::Moniker* moniker = new ni::data_monikers::Moniker(); - ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerWriteArrayU32", data, *moniker); - response->set_allocated_moniker(moniker); + auto moniker = std::make_unique(); + ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerWriteArrayU32", data.get(), *moniker); + response->set_allocated_moniker(moniker.release()); response->set_status(0); return ::grpc::Status::OK; } @@ -3870,14 +3874,14 @@ ::grpc::Status MonikerWriteU8(void* data, google::protobuf::Arena& arena, google NiFpga_Session session = session_repository_->access_session(session_grpc_session.name()); uint32_t control = request->control(); - MonikerWriteArrayU64Data* data = new MonikerWriteArrayU64Data(); + auto data = std::make_unique(); data->session = session; data->control = control; data->library = std::shared_ptr(library_); - ni::data_monikers::Moniker* moniker = new ni::data_monikers::Moniker(); - ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerWriteArrayU64", data, *moniker); - response->set_allocated_moniker(moniker); + auto moniker = std::make_unique(); + ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerWriteArrayU64", data.get(), *moniker); + response->set_allocated_moniker(moniker.release()); response->set_status(0); return ::grpc::Status::OK; } @@ -3940,14 +3944,14 @@ ::grpc::Status MonikerWriteU8(void* data, google::protobuf::Arena& arena, google NiFpga_Session session = session_repository_->access_session(session_grpc_session.name()); uint32_t control = request->control(); - MonikerWriteArrayU8Data* data = new MonikerWriteArrayU8Data(); + auto data = std::make_unique(); data->session = session; data->control = control; data->library = std::shared_ptr(library_); - ni::data_monikers::Moniker* moniker = new ni::data_monikers::Moniker(); - ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerWriteArrayU8", data, *moniker); - response->set_allocated_moniker(moniker); + auto moniker = std::make_unique(); + ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerWriteArrayU8", data.get(), *moniker); + response->set_allocated_moniker(moniker.release()); response->set_status(0); return ::grpc::Status::OK; } @@ -4425,14 +4429,14 @@ ::grpc::Status MonikerWriteU8(void* data, google::protobuf::Arena& arena, google NiFpga_Session session = session_repository_->access_session(session_grpc_session.name()); uint32_t control = request->control(); - MonikerWriteI16Data* data = new MonikerWriteI16Data(); + auto data = std::make_unique(); data->session = session; data->control = control; data->library = std::shared_ptr(library_); - ni::data_monikers::Moniker* moniker = new ni::data_monikers::Moniker(); - ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerWriteI16", data, *moniker); - response->set_allocated_moniker(moniker); + auto moniker = std::make_unique(); + ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerWriteI16", data.get(), *moniker); + response->set_allocated_moniker(moniker.release()); response->set_status(0); return ::grpc::Status::OK; } @@ -4477,14 +4481,14 @@ ::grpc::Status MonikerWriteU8(void* data, google::protobuf::Arena& arena, google NiFpga_Session session = session_repository_->access_session(session_grpc_session.name()); uint32_t control = request->control(); - MonikerWriteI32Data* data = new MonikerWriteI32Data(); + auto data = std::make_unique(); data->session = session; data->control = control; data->library = std::shared_ptr(library_); - ni::data_monikers::Moniker* moniker = new ni::data_monikers::Moniker(); - ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerWriteI32", data, *moniker); - response->set_allocated_moniker(moniker); + auto moniker = std::make_unique(); + ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerWriteI32", data.get(), *moniker); + response->set_allocated_moniker(moniker.release()); response->set_status(0); return ::grpc::Status::OK; } @@ -4529,14 +4533,14 @@ ::grpc::Status MonikerWriteU8(void* data, google::protobuf::Arena& arena, google NiFpga_Session session = session_repository_->access_session(session_grpc_session.name()); uint32_t control = request->control(); - MonikerWriteI64Data* data = new MonikerWriteI64Data(); + auto data = std::make_unique(); data->session = session; data->control = control; data->library = std::shared_ptr(library_); - ni::data_monikers::Moniker* moniker = new ni::data_monikers::Moniker(); - ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerWriteI64", data, *moniker); - response->set_allocated_moniker(moniker); + auto moniker = std::make_unique(); + ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerWriteI64", data.get(), *moniker); + response->set_allocated_moniker(moniker.release()); response->set_status(0); return ::grpc::Status::OK; } @@ -4590,14 +4594,14 @@ ::grpc::Status MonikerWriteU8(void* data, google::protobuf::Arena& arena, google NiFpga_Session session = session_repository_->access_session(session_grpc_session.name()); uint32_t control = request->control(); - MonikerWriteI8Data* data = new MonikerWriteI8Data(); + auto data = std::make_unique(); data->session = session; data->control = control; data->library = std::shared_ptr(library_); - ni::data_monikers::Moniker* moniker = new ni::data_monikers::Moniker(); - ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerWriteI8", data, *moniker); - response->set_allocated_moniker(moniker); + auto moniker = std::make_unique(); + ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerWriteI8", data.get(), *moniker); + response->set_allocated_moniker(moniker.release()); response->set_status(0); return ::grpc::Status::OK; } @@ -4675,14 +4679,14 @@ ::grpc::Status MonikerWriteU8(void* data, google::protobuf::Arena& arena, google NiFpga_Session session = session_repository_->access_session(session_grpc_session.name()); uint32_t control = request->control(); - MonikerWriteU16Data* data = new MonikerWriteU16Data(); + auto data = std::make_unique(); data->session = session; data->control = control; data->library = std::shared_ptr(library_); - ni::data_monikers::Moniker* moniker = new ni::data_monikers::Moniker(); - ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerWriteU16", data, *moniker); - response->set_allocated_moniker(moniker); + auto moniker = std::make_unique(); + ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerWriteU16", data.get(), *moniker); + response->set_allocated_moniker(moniker.release()); response->set_status(0); return ::grpc::Status::OK; } @@ -4727,14 +4731,14 @@ ::grpc::Status MonikerWriteU8(void* data, google::protobuf::Arena& arena, google NiFpga_Session session = session_repository_->access_session(session_grpc_session.name()); uint32_t control = request->control(); - MonikerWriteU32Data* data = new MonikerWriteU32Data(); + auto data = std::make_unique(); data->session = session; data->control = control; data->library = std::shared_ptr(library_); - ni::data_monikers::Moniker* moniker = new ni::data_monikers::Moniker(); - ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerWriteU32", data, *moniker); - response->set_allocated_moniker(moniker); + auto moniker = std::make_unique(); + ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerWriteU32", data.get(), *moniker); + response->set_allocated_moniker(moniker.release()); response->set_status(0); return ::grpc::Status::OK; } @@ -4779,14 +4783,14 @@ ::grpc::Status MonikerWriteU8(void* data, google::protobuf::Arena& arena, google NiFpga_Session session = session_repository_->access_session(session_grpc_session.name()); uint32_t control = request->control(); - MonikerWriteU64Data* data = new MonikerWriteU64Data(); + auto data = std::make_unique(); data->session = session; data->control = control; data->library = std::shared_ptr(library_); - ni::data_monikers::Moniker* moniker = new ni::data_monikers::Moniker(); - ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerWriteU64", data, *moniker); - response->set_allocated_moniker(moniker); + auto moniker = std::make_unique(); + ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerWriteU64", data.get(), *moniker); + response->set_allocated_moniker(moniker.release()); response->set_status(0); return ::grpc::Status::OK; } @@ -4840,14 +4844,14 @@ ::grpc::Status MonikerWriteU8(void* data, google::protobuf::Arena& arena, google NiFpga_Session session = session_repository_->access_session(session_grpc_session.name()); uint32_t control = request->control(); - MonikerWriteU8Data* data = new MonikerWriteU8Data(); + auto data = std::make_unique(); data->session = session; data->control = control; data->library = std::shared_ptr(library_); - ni::data_monikers::Moniker* moniker = new ni::data_monikers::Moniker(); - ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerWriteU8", data, *moniker); - response->set_allocated_moniker(moniker); + auto moniker = std::make_unique(); + ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerWriteU8", data.get(), *moniker); + response->set_allocated_moniker(moniker.release()); response->set_status(0); return ::grpc::Status::OK; } diff --git a/source/codegen/templates/service_helpers.mako b/source/codegen/templates/service_helpers.mako index bc81360e1..70b3c4ce6 100644 --- a/source/codegen/templates/service_helpers.mako +++ b/source/codegen/templates/service_helpers.mako @@ -341,13 +341,13 @@ ${populate_response(function_data=function_data, parameters=parameters)}\ streaming_param_to_include = common_helpers.get_input_streaming_param(parameters) %>\ ${initialize_streaming_input_param(function_name, streaming_param_to_include, parameters, streaming_param)} - ${struct_name}* data = new ${struct_name}(); + auto data = std::make_unique<${struct_name}>(); ${initialize_begin_input_param(streaming_param_to_include, streaming_param)}\ data->library = std::shared_ptr<${service_class_prefix}LibraryInterface>(library_); ${initialize_service_output_params(output_params)}\ - ni::data_monikers::Moniker* moniker = new ni::data_monikers::Moniker(); - ni::data_monikers::DataMonikerService::RegisterMonikerInstance("${moniker_function_name}", data, *moniker); - response->set_allocated_moniker(moniker); + auto moniker = std::make_unique(); + ni::data_monikers::DataMonikerService::RegisterMonikerInstance("${moniker_function_name}", data.get(), *moniker); + response->set_allocated_moniker(moniker.release()); response->set_status(0); return ::grpc::Status::OK;\ @@ -396,6 +396,7 @@ ${data_type}* array = new ${data_type}[${size}]; }); packedData.PackFrom(function_data->data); } + delete[] array; % endif From b45ead6c438eaff0469fffbb2144afe510446a01 Mon Sep 17 00:00:00 2001 From: Ayush Mehra Date: Fri, 8 Nov 2024 08:22:36 -0800 Subject: [PATCH 26/34] use vector instead of raw array --- generated/nifpga/nifpga_service.cpp | 16 ++++++++-------- source/codegen/templates/service_helpers.mako | 4 ++-- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/generated/nifpga/nifpga_service.cpp b/generated/nifpga/nifpga_service.cpp index 03cf1346b..18d9bece9 100644 --- a/generated/nifpga/nifpga_service.cpp +++ b/generated/nifpga/nifpga_service.cpp @@ -379,7 +379,8 @@ ::grpc::Status MonikerReadArrayI32(void* data, google::protobuf::Arena& arena, g auto indicator = function_data->indicator; auto size = function_data->size; - int32_t* array = new int32_t[size]; + auto array_storage = std::vector(); + auto array = array_storage.data(); auto status = library->ReadArrayI32(session, indicator, array, size); if (status >= 0) { std::transform( @@ -391,7 +392,6 @@ ::grpc::Status MonikerReadArrayI32(void* data, google::protobuf::Arena& arena, g }); packedData.PackFrom(function_data->data); } - delete[] array; if (status < 0) { std::cout << "MonikerReadArrayI32 error: " << status << std::endl; @@ -408,7 +408,8 @@ ::grpc::Status MonikerReadArrayI64(void* data, google::protobuf::Arena& arena, g auto indicator = function_data->indicator; auto size = function_data->size; - int64_t* array = new int64_t[size]; + auto array_storage = std::vector(); + auto array = array_storage.data(); auto status = library->ReadArrayI64(session, indicator, array, size); if (status >= 0) { std::transform( @@ -420,7 +421,6 @@ ::grpc::Status MonikerReadArrayI64(void* data, google::protobuf::Arena& arena, g }); packedData.PackFrom(function_data->data); } - delete[] array; if (status < 0) { std::cout << "MonikerReadArrayI64 error: " << status << std::endl; @@ -493,7 +493,8 @@ ::grpc::Status MonikerReadArrayU32(void* data, google::protobuf::Arena& arena, g auto indicator = function_data->indicator; auto size = function_data->size; - uint32_t* array = new uint32_t[size]; + auto array_storage = std::vector(); + auto array = array_storage.data(); auto status = library->ReadArrayU32(session, indicator, array, size); if (status >= 0) { std::transform( @@ -505,7 +506,6 @@ ::grpc::Status MonikerReadArrayU32(void* data, google::protobuf::Arena& arena, g }); packedData.PackFrom(function_data->data); } - delete[] array; if (status < 0) { std::cout << "MonikerReadArrayU32 error: " << status << std::endl; @@ -522,7 +522,8 @@ ::grpc::Status MonikerReadArrayU64(void* data, google::protobuf::Arena& arena, g auto indicator = function_data->indicator; auto size = function_data->size; - uint64_t* array = new uint64_t[size]; + auto array_storage = std::vector(); + auto array = array_storage.data(); auto status = library->ReadArrayU64(session, indicator, array, size); if (status >= 0) { std::transform( @@ -534,7 +535,6 @@ ::grpc::Status MonikerReadArrayU64(void* data, google::protobuf::Arena& arena, g }); packedData.PackFrom(function_data->data); } - delete[] array; if (status < 0) { std::cout << "MonikerReadArrayU64 error: " << status << std::endl; diff --git a/source/codegen/templates/service_helpers.mako b/source/codegen/templates/service_helpers.mako index 70b3c4ce6..83fc231c6 100644 --- a/source/codegen/templates/service_helpers.mako +++ b/source/codegen/templates/service_helpers.mako @@ -371,7 +371,8 @@ ${initialize_streaming_input_param(function_name, streaming_param_to_include, pa % if is_coerced: std::vector<${data_type}> array(${size}); % else: -${data_type}* array = new ${data_type}[${size}]; +auto array_storage = std::vector<${data_type}>(); + auto array = array_storage.data(); % endif auto status = library->${c_api_name}(${arg_string}); % if is_coerced: @@ -396,7 +397,6 @@ ${data_type}* array = new ${data_type}[${size}]; }); packedData.PackFrom(function_data->data); } - delete[] array; % endif From cd8f8c90ca156a8d1b3264c60b28faf5f2b307ec Mon Sep 17 00:00:00 2001 From: Ayush Mehra Date: Fri, 8 Nov 2024 19:42:00 -0800 Subject: [PATCH 27/34] Fix indentation --- generated/nifpga/nifpga_service.cpp | 432 ++++++++---------- source/codegen/templates/service_helpers.mako | 58 +-- 2 files changed, 229 insertions(+), 261 deletions(-) diff --git a/generated/nifpga/nifpga_service.cpp b/generated/nifpga/nifpga_service.cpp index 18d9bece9..ced6f94d7 100644 --- a/generated/nifpga/nifpga_service.cpp +++ b/generated/nifpga/nifpga_service.cpp @@ -345,8 +345,7 @@ namespace nifpga_grpc { ::grpc::Status MonikerReadArrayI16(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData) { MonikerReadArrayI16Data* function_data = (MonikerReadArrayI16Data*)data; - auto library = function_data->library; - + auto library = function_data->library; auto session = function_data->session; auto indicator = function_data->indicator; auto size = function_data->size; @@ -354,14 +353,14 @@ ::grpc::Status MonikerReadArrayI16(void* data, google::protobuf::Arena& arena, g std::vector array(size); auto status = library->ReadArrayI16(session, indicator, array.data(), size); if (status >= 0) { - std::transform( - array.begin(), - array.begin() + size, - function_data->data.mutable_value()->begin(), - [&](auto x) { - return x; - }); - packedData.PackFrom(function_data->data); + std::transform( + array.begin(), + array.begin() + size, + function_data->data.mutable_value()->begin(), + [&](auto x) { + return x; + }); + packedData.PackFrom(function_data->data); } if (status < 0) { @@ -373,8 +372,7 @@ ::grpc::Status MonikerReadArrayI16(void* data, google::protobuf::Arena& arena, g ::grpc::Status MonikerReadArrayI32(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData) { MonikerReadArrayI32Data* function_data = (MonikerReadArrayI32Data*)data; - auto library = function_data->library; - + auto library = function_data->library; auto session = function_data->session; auto indicator = function_data->indicator; auto size = function_data->size; @@ -383,14 +381,14 @@ ::grpc::Status MonikerReadArrayI32(void* data, google::protobuf::Arena& arena, g auto array = array_storage.data(); auto status = library->ReadArrayI32(session, indicator, array, size); if (status >= 0) { - std::transform( - array, - array + size, - function_data->data.mutable_value()->begin(), - [&](auto x) { - return x; - }); - packedData.PackFrom(function_data->data); + std::transform( + array, + array + size, + function_data->data.mutable_value()->begin(), + [&](auto x) { + return x; + }); + packedData.PackFrom(function_data->data); } if (status < 0) { @@ -402,8 +400,7 @@ ::grpc::Status MonikerReadArrayI32(void* data, google::protobuf::Arena& arena, g ::grpc::Status MonikerReadArrayI64(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData) { MonikerReadArrayI64Data* function_data = (MonikerReadArrayI64Data*)data; - auto library = function_data->library; - + auto library = function_data->library; auto session = function_data->session; auto indicator = function_data->indicator; auto size = function_data->size; @@ -412,14 +409,14 @@ ::grpc::Status MonikerReadArrayI64(void* data, google::protobuf::Arena& arena, g auto array = array_storage.data(); auto status = library->ReadArrayI64(session, indicator, array, size); if (status >= 0) { - std::transform( - array, - array + size, - function_data->data.mutable_value()->begin(), - [&](auto x) { - return x; - }); - packedData.PackFrom(function_data->data); + std::transform( + array, + array + size, + function_data->data.mutable_value()->begin(), + [&](auto x) { + return x; + }); + packedData.PackFrom(function_data->data); } if (status < 0) { @@ -431,8 +428,7 @@ ::grpc::Status MonikerReadArrayI64(void* data, google::protobuf::Arena& arena, g ::grpc::Status MonikerReadArrayI8(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData) { MonikerReadArrayI8Data* function_data = (MonikerReadArrayI8Data*)data; - auto library = function_data->library; - + auto library = function_data->library; auto session = function_data->session; auto indicator = function_data->indicator; auto size = function_data->size; @@ -440,14 +436,14 @@ ::grpc::Status MonikerReadArrayI8(void* data, google::protobuf::Arena& arena, go std::vector array(size); auto status = library->ReadArrayI8(session, indicator, array.data(), size); if (status >= 0) { - std::transform( - array.begin(), - array.begin() + size, - function_data->data.mutable_value()->begin(), - [&](auto x) { - return x; - }); - packedData.PackFrom(function_data->data); + std::transform( + array.begin(), + array.begin() + size, + function_data->data.mutable_value()->begin(), + [&](auto x) { + return x; + }); + packedData.PackFrom(function_data->data); } if (status < 0) { @@ -459,8 +455,7 @@ ::grpc::Status MonikerReadArrayI8(void* data, google::protobuf::Arena& arena, go ::grpc::Status MonikerReadArrayU16(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData) { MonikerReadArrayU16Data* function_data = (MonikerReadArrayU16Data*)data; - auto library = function_data->library; - + auto library = function_data->library; auto session = function_data->session; auto indicator = function_data->indicator; auto size = function_data->size; @@ -468,14 +463,14 @@ ::grpc::Status MonikerReadArrayU16(void* data, google::protobuf::Arena& arena, g std::vector array(size); auto status = library->ReadArrayU16(session, indicator, array.data(), size); if (status >= 0) { - std::transform( - array.begin(), - array.begin() + size, - function_data->data.mutable_value()->begin(), - [&](auto x) { - return x; - }); - packedData.PackFrom(function_data->data); + std::transform( + array.begin(), + array.begin() + size, + function_data->data.mutable_value()->begin(), + [&](auto x) { + return x; + }); + packedData.PackFrom(function_data->data); } if (status < 0) { @@ -487,8 +482,7 @@ ::grpc::Status MonikerReadArrayU16(void* data, google::protobuf::Arena& arena, g ::grpc::Status MonikerReadArrayU32(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData) { MonikerReadArrayU32Data* function_data = (MonikerReadArrayU32Data*)data; - auto library = function_data->library; - + auto library = function_data->library; auto session = function_data->session; auto indicator = function_data->indicator; auto size = function_data->size; @@ -497,14 +491,14 @@ ::grpc::Status MonikerReadArrayU32(void* data, google::protobuf::Arena& arena, g auto array = array_storage.data(); auto status = library->ReadArrayU32(session, indicator, array, size); if (status >= 0) { - std::transform( - array, - array + size, - function_data->data.mutable_value()->begin(), - [&](auto x) { - return x; - }); - packedData.PackFrom(function_data->data); + std::transform( + array, + array + size, + function_data->data.mutable_value()->begin(), + [&](auto x) { + return x; + }); + packedData.PackFrom(function_data->data); } if (status < 0) { @@ -516,8 +510,7 @@ ::grpc::Status MonikerReadArrayU32(void* data, google::protobuf::Arena& arena, g ::grpc::Status MonikerReadArrayU64(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData) { MonikerReadArrayU64Data* function_data = (MonikerReadArrayU64Data*)data; - auto library = function_data->library; - + auto library = function_data->library; auto session = function_data->session; auto indicator = function_data->indicator; auto size = function_data->size; @@ -526,14 +519,14 @@ ::grpc::Status MonikerReadArrayU64(void* data, google::protobuf::Arena& arena, g auto array = array_storage.data(); auto status = library->ReadArrayU64(session, indicator, array, size); if (status >= 0) { - std::transform( - array, - array + size, - function_data->data.mutable_value()->begin(), - [&](auto x) { - return x; - }); - packedData.PackFrom(function_data->data); + std::transform( + array, + array + size, + function_data->data.mutable_value()->begin(), + [&](auto x) { + return x; + }); + packedData.PackFrom(function_data->data); } if (status < 0) { @@ -545,8 +538,7 @@ ::grpc::Status MonikerReadArrayU64(void* data, google::protobuf::Arena& arena, g ::grpc::Status MonikerReadArrayU8(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData) { MonikerReadArrayU8Data* function_data = (MonikerReadArrayU8Data*)data; - auto library = function_data->library; - + auto library = function_data->library; auto session = function_data->session; auto indicator = function_data->indicator; auto size = function_data->size; @@ -554,14 +546,14 @@ ::grpc::Status MonikerReadArrayU8(void* data, google::protobuf::Arena& arena, go std::vector array(size); auto status = library->ReadArrayU8(session, indicator, array.data(), size); if (status >= 0) { - std::transform( - array.begin(), - array.begin() + size, - function_data->data.mutable_value()->begin(), - [&](auto x) { - return x; - }); - packedData.PackFrom(function_data->data); + std::transform( + array.begin(), + array.begin() + size, + function_data->data.mutable_value()->begin(), + [&](auto x) { + return x; + }); + packedData.PackFrom(function_data->data); } if (status < 0) { @@ -573,8 +565,7 @@ ::grpc::Status MonikerReadArrayU8(void* data, google::protobuf::Arena& arena, go ::grpc::Status MonikerReadI16(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData) { MonikerReadI16Data* function_data = (MonikerReadI16Data*)data; - auto library = function_data->library; - + auto library = function_data->library; auto session = function_data->session; auto indicator = function_data->indicator; @@ -594,8 +585,7 @@ ::grpc::Status MonikerReadI16(void* data, google::protobuf::Arena& arena, google ::grpc::Status MonikerReadI32(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData) { MonikerReadI32Data* function_data = (MonikerReadI32Data*)data; - auto library = function_data->library; - + auto library = function_data->library; auto session = function_data->session; auto indicator = function_data->indicator; @@ -615,8 +605,7 @@ ::grpc::Status MonikerReadI32(void* data, google::protobuf::Arena& arena, google ::grpc::Status MonikerReadI64(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData) { MonikerReadI64Data* function_data = (MonikerReadI64Data*)data; - auto library = function_data->library; - + auto library = function_data->library; auto session = function_data->session; auto indicator = function_data->indicator; @@ -636,8 +625,7 @@ ::grpc::Status MonikerReadI64(void* data, google::protobuf::Arena& arena, google ::grpc::Status MonikerReadI8(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData) { MonikerReadI8Data* function_data = (MonikerReadI8Data*)data; - auto library = function_data->library; - + auto library = function_data->library; auto session = function_data->session; auto indicator = function_data->indicator; @@ -657,8 +645,7 @@ ::grpc::Status MonikerReadI8(void* data, google::protobuf::Arena& arena, google: ::grpc::Status MonikerReadU16(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData) { MonikerReadU16Data* function_data = (MonikerReadU16Data*)data; - auto library = function_data->library; - + auto library = function_data->library; auto session = function_data->session; auto indicator = function_data->indicator; @@ -678,8 +665,7 @@ ::grpc::Status MonikerReadU16(void* data, google::protobuf::Arena& arena, google ::grpc::Status MonikerReadU32(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData) { MonikerReadU32Data* function_data = (MonikerReadU32Data*)data; - auto library = function_data->library; - + auto library = function_data->library; auto session = function_data->session; auto indicator = function_data->indicator; @@ -699,8 +685,7 @@ ::grpc::Status MonikerReadU32(void* data, google::protobuf::Arena& arena, google ::grpc::Status MonikerReadU64(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData) { MonikerReadU64Data* function_data = (MonikerReadU64Data*)data; - auto library = function_data->library; - + auto library = function_data->library; auto session = function_data->session; auto indicator = function_data->indicator; @@ -720,8 +705,7 @@ ::grpc::Status MonikerReadU64(void* data, google::protobuf::Arena& arena, google ::grpc::Status MonikerReadU8(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData) { MonikerReadU8Data* function_data = (MonikerReadU8Data*)data; - auto library = function_data->library; - + auto library = function_data->library; auto session = function_data->session; auto indicator = function_data->indicator; @@ -741,8 +725,7 @@ ::grpc::Status MonikerReadU8(void* data, google::protobuf::Arena& arena, google: ::grpc::Status MonikerWriteArrayI16(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData) { MonikerWriteArrayI16Data* function_data = (MonikerWriteArrayI16Data*)data; - auto library = function_data->library; - + auto library = function_data->library; auto session = function_data->session; auto control = function_data->control; @@ -753,16 +736,16 @@ ::grpc::Status MonikerWriteArrayI16(void* data, google::protobuf::Arena& arena, auto size = data_array.size(); array.reserve(size); std::transform( - data_array.begin(), - data_array.end(), - std::back_inserter(array), - [](auto x) { - if (x < std::numeric_limits::min() || x > std::numeric_limits::max()) { - std::string message("value " + std::to_string(x) + " doesn't fit in datatype int16_t"); - throw nidevice_grpc::ValueOutOfRangeException(message); - } - return static_cast(x); - }); + data_array.begin(), + data_array.end(), + std::back_inserter(array), + [](auto x) { + if (x < std::numeric_limits::min() || x > std::numeric_limits::max()) { + std::string message("value " + std::to_string(x) + " doesn't fit in datatype int16_t"); + throw nidevice_grpc::ValueOutOfRangeException(message); + } + return static_cast(x); + }); auto status = library->WriteArrayI16(session, control, array.data(), size); if (status < 0) { @@ -774,8 +757,7 @@ ::grpc::Status MonikerWriteArrayI16(void* data, google::protobuf::Arena& arena, ::grpc::Status MonikerWriteArrayI32(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData) { MonikerWriteArrayI32Data* function_data = (MonikerWriteArrayI32Data*)data; - auto library = function_data->library; - + auto library = function_data->library; auto session = function_data->session; auto control = function_data->control; @@ -795,8 +777,7 @@ ::grpc::Status MonikerWriteArrayI32(void* data, google::protobuf::Arena& arena, ::grpc::Status MonikerWriteArrayI64(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData) { MonikerWriteArrayI64Data* function_data = (MonikerWriteArrayI64Data*)data; - auto library = function_data->library; - + auto library = function_data->library; auto session = function_data->session; auto control = function_data->control; @@ -816,8 +797,7 @@ ::grpc::Status MonikerWriteArrayI64(void* data, google::protobuf::Arena& arena, ::grpc::Status MonikerWriteArrayI8(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData) { MonikerWriteArrayI8Data* function_data = (MonikerWriteArrayI8Data*)data; - auto library = function_data->library; - + auto library = function_data->library; auto session = function_data->session; auto control = function_data->control; @@ -828,16 +808,16 @@ ::grpc::Status MonikerWriteArrayI8(void* data, google::protobuf::Arena& arena, g auto size = data_array.size(); array.reserve(size); std::transform( - data_array.begin(), - data_array.end(), - std::back_inserter(array), - [](auto x) { - if (x < std::numeric_limits::min() || x > std::numeric_limits::max()) { - std::string message("value " + std::to_string(x) + " doesn't fit in datatype int8_t"); - throw nidevice_grpc::ValueOutOfRangeException(message); - } - return static_cast(x); - }); + data_array.begin(), + data_array.end(), + std::back_inserter(array), + [](auto x) { + if (x < std::numeric_limits::min() || x > std::numeric_limits::max()) { + std::string message("value " + std::to_string(x) + " doesn't fit in datatype int8_t"); + throw nidevice_grpc::ValueOutOfRangeException(message); + } + return static_cast(x); + }); auto status = library->WriteArrayI8(session, control, array.data(), size); if (status < 0) { @@ -849,8 +829,7 @@ ::grpc::Status MonikerWriteArrayI8(void* data, google::protobuf::Arena& arena, g ::grpc::Status MonikerWriteArrayU16(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData) { MonikerWriteArrayU16Data* function_data = (MonikerWriteArrayU16Data*)data; - auto library = function_data->library; - + auto library = function_data->library; auto session = function_data->session; auto control = function_data->control; @@ -861,16 +840,16 @@ ::grpc::Status MonikerWriteArrayU16(void* data, google::protobuf::Arena& arena, auto size = data_array.size(); array.reserve(size); std::transform( - data_array.begin(), - data_array.end(), - std::back_inserter(array), - [](auto x) { - if (x < std::numeric_limits::min() || x > std::numeric_limits::max()) { - std::string message("value " + std::to_string(x) + " doesn't fit in datatype uint16_t"); - throw nidevice_grpc::ValueOutOfRangeException(message); - } - return static_cast(x); - }); + data_array.begin(), + data_array.end(), + std::back_inserter(array), + [](auto x) { + if (x < std::numeric_limits::min() || x > std::numeric_limits::max()) { + std::string message("value " + std::to_string(x) + " doesn't fit in datatype uint16_t"); + throw nidevice_grpc::ValueOutOfRangeException(message); + } + return static_cast(x); + }); auto status = library->WriteArrayU16(session, control, array.data(), size); if (status < 0) { @@ -882,8 +861,7 @@ ::grpc::Status MonikerWriteArrayU16(void* data, google::protobuf::Arena& arena, ::grpc::Status MonikerWriteArrayU32(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData) { MonikerWriteArrayU32Data* function_data = (MonikerWriteArrayU32Data*)data; - auto library = function_data->library; - + auto library = function_data->library; auto session = function_data->session; auto control = function_data->control; @@ -903,8 +881,7 @@ ::grpc::Status MonikerWriteArrayU32(void* data, google::protobuf::Arena& arena, ::grpc::Status MonikerWriteArrayU64(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData) { MonikerWriteArrayU64Data* function_data = (MonikerWriteArrayU64Data*)data; - auto library = function_data->library; - + auto library = function_data->library; auto session = function_data->session; auto control = function_data->control; @@ -924,8 +901,7 @@ ::grpc::Status MonikerWriteArrayU64(void* data, google::protobuf::Arena& arena, ::grpc::Status MonikerWriteArrayU8(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData) { MonikerWriteArrayU8Data* function_data = (MonikerWriteArrayU8Data*)data; - auto library = function_data->library; - + auto library = function_data->library; auto session = function_data->session; auto control = function_data->control; @@ -936,16 +912,16 @@ ::grpc::Status MonikerWriteArrayU8(void* data, google::protobuf::Arena& arena, g auto size = data_array.size(); array.reserve(size); std::transform( - data_array.begin(), - data_array.end(), - std::back_inserter(array), - [](auto x) { - if (x < std::numeric_limits::min() || x > std::numeric_limits::max()) { - std::string message("value " + std::to_string(x) + " doesn't fit in datatype uint8_t"); - throw nidevice_grpc::ValueOutOfRangeException(message); - } - return static_cast(x); - }); + data_array.begin(), + data_array.end(), + std::back_inserter(array), + [](auto x) { + if (x < std::numeric_limits::min() || x > std::numeric_limits::max()) { + std::string message("value " + std::to_string(x) + " doesn't fit in datatype uint8_t"); + throw nidevice_grpc::ValueOutOfRangeException(message); + } + return static_cast(x); + }); auto status = library->WriteArrayU8(session, control, array.data(), size); if (status < 0) { @@ -957,8 +933,7 @@ ::grpc::Status MonikerWriteArrayU8(void* data, google::protobuf::Arena& arena, g ::grpc::Status MonikerWriteI16(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData) { MonikerWriteI16Data* function_data = (MonikerWriteI16Data*)data; - auto library = function_data->library; - + auto library = function_data->library; auto session = function_data->session; auto control = function_data->control; @@ -980,8 +955,7 @@ ::grpc::Status MonikerWriteI16(void* data, google::protobuf::Arena& arena, googl ::grpc::Status MonikerWriteI32(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData) { MonikerWriteI32Data* function_data = (MonikerWriteI32Data*)data; - auto library = function_data->library; - + auto library = function_data->library; auto session = function_data->session; auto control = function_data->control; @@ -999,8 +973,7 @@ ::grpc::Status MonikerWriteI32(void* data, google::protobuf::Arena& arena, googl ::grpc::Status MonikerWriteI64(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData) { MonikerWriteI64Data* function_data = (MonikerWriteI64Data*)data; - auto library = function_data->library; - + auto library = function_data->library; auto session = function_data->session; auto control = function_data->control; @@ -1018,8 +991,7 @@ ::grpc::Status MonikerWriteI64(void* data, google::protobuf::Arena& arena, googl ::grpc::Status MonikerWriteI8(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData) { MonikerWriteI8Data* function_data = (MonikerWriteI8Data*)data; - auto library = function_data->library; - + auto library = function_data->library; auto session = function_data->session; auto control = function_data->control; @@ -1041,8 +1013,7 @@ ::grpc::Status MonikerWriteI8(void* data, google::protobuf::Arena& arena, google ::grpc::Status MonikerWriteU16(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData) { MonikerWriteU16Data* function_data = (MonikerWriteU16Data*)data; - auto library = function_data->library; - + auto library = function_data->library; auto session = function_data->session; auto control = function_data->control; @@ -1064,8 +1035,7 @@ ::grpc::Status MonikerWriteU16(void* data, google::protobuf::Arena& arena, googl ::grpc::Status MonikerWriteU32(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData) { MonikerWriteU32Data* function_data = (MonikerWriteU32Data*)data; - auto library = function_data->library; - + auto library = function_data->library; auto session = function_data->session; auto control = function_data->control; @@ -1083,8 +1053,7 @@ ::grpc::Status MonikerWriteU32(void* data, google::protobuf::Arena& arena, googl ::grpc::Status MonikerWriteU64(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData) { MonikerWriteU64Data* function_data = (MonikerWriteU64Data*)data; - auto library = function_data->library; - + auto library = function_data->library; auto session = function_data->session; auto control = function_data->control; @@ -1102,8 +1071,7 @@ ::grpc::Status MonikerWriteU64(void* data, google::protobuf::Arena& arena, googl ::grpc::Status MonikerWriteU8(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData) { MonikerWriteU8Data* function_data = (MonikerWriteU8Data*)data; - auto library = function_data->library; - + auto library = function_data->library; auto session = function_data->session; auto control = function_data->control; @@ -1726,8 +1694,8 @@ ::grpc::Status MonikerWriteU8(void* data, google::protobuf::Arena& arena, google uint32_t indicator = request->indicator(); size_t size = request->size(); - auto data = std::make_unique(); - data->session = session; + auto data = std::make_unique(); + data->session = session; data->indicator = indicator; data->size = size; data->library = std::shared_ptr(library_); @@ -1784,8 +1752,8 @@ ::grpc::Status MonikerWriteU8(void* data, google::protobuf::Arena& arena, google uint32_t indicator = request->indicator(); size_t size = request->size(); - auto data = std::make_unique(); - data->session = session; + auto data = std::make_unique(); + data->session = session; data->indicator = indicator; data->size = size; data->library = std::shared_ptr(library_); @@ -1842,8 +1810,8 @@ ::grpc::Status MonikerWriteU8(void* data, google::protobuf::Arena& arena, google uint32_t indicator = request->indicator(); size_t size = request->size(); - auto data = std::make_unique(); - data->session = session; + auto data = std::make_unique(); + data->session = session; data->indicator = indicator; data->size = size; data->library = std::shared_ptr(library_); @@ -1908,8 +1876,8 @@ ::grpc::Status MonikerWriteU8(void* data, google::protobuf::Arena& arena, google uint32_t indicator = request->indicator(); size_t size = request->size(); - auto data = std::make_unique(); - data->session = session; + auto data = std::make_unique(); + data->session = session; data->indicator = indicator; data->size = size; data->library = std::shared_ptr(library_); @@ -2000,8 +1968,8 @@ ::grpc::Status MonikerWriteU8(void* data, google::protobuf::Arena& arena, google uint32_t indicator = request->indicator(); size_t size = request->size(); - auto data = std::make_unique(); - data->session = session; + auto data = std::make_unique(); + data->session = session; data->indicator = indicator; data->size = size; data->library = std::shared_ptr(library_); @@ -2058,8 +2026,8 @@ ::grpc::Status MonikerWriteU8(void* data, google::protobuf::Arena& arena, google uint32_t indicator = request->indicator(); size_t size = request->size(); - auto data = std::make_unique(); - data->session = session; + auto data = std::make_unique(); + data->session = session; data->indicator = indicator; data->size = size; data->library = std::shared_ptr(library_); @@ -2116,8 +2084,8 @@ ::grpc::Status MonikerWriteU8(void* data, google::protobuf::Arena& arena, google uint32_t indicator = request->indicator(); size_t size = request->size(); - auto data = std::make_unique(); - data->session = session; + auto data = std::make_unique(); + data->session = session; data->indicator = indicator; data->size = size; data->library = std::shared_ptr(library_); @@ -2182,8 +2150,8 @@ ::grpc::Status MonikerWriteU8(void* data, google::protobuf::Arena& arena, google uint32_t indicator = request->indicator(); size_t size = request->size(); - auto data = std::make_unique(); - data->session = session; + auto data = std::make_unique(); + data->session = session; data->indicator = indicator; data->size = size; data->library = std::shared_ptr(library_); @@ -2639,8 +2607,8 @@ ::grpc::Status MonikerWriteU8(void* data, google::protobuf::Arena& arena, google NiFpga_Session session = session_repository_->access_session(session_grpc_session.name()); uint32_t indicator = request->indicator(); - auto data = std::make_unique(); - data->session = session; + auto data = std::make_unique(); + data->session = session; data->indicator = indicator; data->library = std::shared_ptr(library_); @@ -2692,8 +2660,8 @@ ::grpc::Status MonikerWriteU8(void* data, google::protobuf::Arena& arena, google NiFpga_Session session = session_repository_->access_session(session_grpc_session.name()); uint32_t indicator = request->indicator(); - auto data = std::make_unique(); - data->session = session; + auto data = std::make_unique(); + data->session = session; data->indicator = indicator; data->library = std::shared_ptr(library_); @@ -2745,8 +2713,8 @@ ::grpc::Status MonikerWriteU8(void* data, google::protobuf::Arena& arena, google NiFpga_Session session = session_repository_->access_session(session_grpc_session.name()); uint32_t indicator = request->indicator(); - auto data = std::make_unique(); - data->session = session; + auto data = std::make_unique(); + data->session = session; data->indicator = indicator; data->library = std::shared_ptr(library_); @@ -2798,8 +2766,8 @@ ::grpc::Status MonikerWriteU8(void* data, google::protobuf::Arena& arena, google NiFpga_Session session = session_repository_->access_session(session_grpc_session.name()); uint32_t indicator = request->indicator(); - auto data = std::make_unique(); - data->session = session; + auto data = std::make_unique(); + data->session = session; data->indicator = indicator; data->library = std::shared_ptr(library_); @@ -2876,8 +2844,8 @@ ::grpc::Status MonikerWriteU8(void* data, google::protobuf::Arena& arena, google NiFpga_Session session = session_repository_->access_session(session_grpc_session.name()); uint32_t indicator = request->indicator(); - auto data = std::make_unique(); - data->session = session; + auto data = std::make_unique(); + data->session = session; data->indicator = indicator; data->library = std::shared_ptr(library_); @@ -2929,8 +2897,8 @@ ::grpc::Status MonikerWriteU8(void* data, google::protobuf::Arena& arena, google NiFpga_Session session = session_repository_->access_session(session_grpc_session.name()); uint32_t indicator = request->indicator(); - auto data = std::make_unique(); - data->session = session; + auto data = std::make_unique(); + data->session = session; data->indicator = indicator; data->library = std::shared_ptr(library_); @@ -2982,8 +2950,8 @@ ::grpc::Status MonikerWriteU8(void* data, google::protobuf::Arena& arena, google NiFpga_Session session = session_repository_->access_session(session_grpc_session.name()); uint32_t indicator = request->indicator(); - auto data = std::make_unique(); - data->session = session; + auto data = std::make_unique(); + data->session = session; data->indicator = indicator; data->library = std::shared_ptr(library_); @@ -3035,8 +3003,8 @@ ::grpc::Status MonikerWriteU8(void* data, google::protobuf::Arena& arena, google NiFpga_Session session = session_repository_->access_session(session_grpc_session.name()); uint32_t indicator = request->indicator(); - auto data = std::make_unique(); - data->session = session; + auto data = std::make_unique(); + data->session = session; data->indicator = indicator; data->library = std::shared_ptr(library_); @@ -3497,8 +3465,8 @@ ::grpc::Status MonikerWriteU8(void* data, google::protobuf::Arena& arena, google NiFpga_Session session = session_repository_->access_session(session_grpc_session.name()); uint32_t control = request->control(); - auto data = std::make_unique(); - data->session = session; + auto data = std::make_unique(); + data->session = session; data->control = control; data->library = std::shared_ptr(library_); @@ -3550,8 +3518,8 @@ ::grpc::Status MonikerWriteU8(void* data, google::protobuf::Arena& arena, google NiFpga_Session session = session_repository_->access_session(session_grpc_session.name()); uint32_t control = request->control(); - auto data = std::make_unique(); - data->session = session; + auto data = std::make_unique(); + data->session = session; data->control = control; data->library = std::shared_ptr(library_); @@ -3603,8 +3571,8 @@ ::grpc::Status MonikerWriteU8(void* data, google::protobuf::Arena& arena, google NiFpga_Session session = session_repository_->access_session(session_grpc_session.name()); uint32_t control = request->control(); - auto data = std::make_unique(); - data->session = session; + auto data = std::make_unique(); + data->session = session; data->control = control; data->library = std::shared_ptr(library_); @@ -3673,8 +3641,8 @@ ::grpc::Status MonikerWriteU8(void* data, google::protobuf::Arena& arena, google NiFpga_Session session = session_repository_->access_session(session_grpc_session.name()); uint32_t control = request->control(); - auto data = std::make_unique(); - data->session = session; + auto data = std::make_unique(); + data->session = session; data->control = control; data->library = std::shared_ptr(library_); @@ -3768,8 +3736,8 @@ ::grpc::Status MonikerWriteU8(void* data, google::protobuf::Arena& arena, google NiFpga_Session session = session_repository_->access_session(session_grpc_session.name()); uint32_t control = request->control(); - auto data = std::make_unique(); - data->session = session; + auto data = std::make_unique(); + data->session = session; data->control = control; data->library = std::shared_ptr(library_); @@ -3821,8 +3789,8 @@ ::grpc::Status MonikerWriteU8(void* data, google::protobuf::Arena& arena, google NiFpga_Session session = session_repository_->access_session(session_grpc_session.name()); uint32_t control = request->control(); - auto data = std::make_unique(); - data->session = session; + auto data = std::make_unique(); + data->session = session; data->control = control; data->library = std::shared_ptr(library_); @@ -3874,8 +3842,8 @@ ::grpc::Status MonikerWriteU8(void* data, google::protobuf::Arena& arena, google NiFpga_Session session = session_repository_->access_session(session_grpc_session.name()); uint32_t control = request->control(); - auto data = std::make_unique(); - data->session = session; + auto data = std::make_unique(); + data->session = session; data->control = control; data->library = std::shared_ptr(library_); @@ -3944,8 +3912,8 @@ ::grpc::Status MonikerWriteU8(void* data, google::protobuf::Arena& arena, google NiFpga_Session session = session_repository_->access_session(session_grpc_session.name()); uint32_t control = request->control(); - auto data = std::make_unique(); - data->session = session; + auto data = std::make_unique(); + data->session = session; data->control = control; data->library = std::shared_ptr(library_); @@ -4429,8 +4397,8 @@ ::grpc::Status MonikerWriteU8(void* data, google::protobuf::Arena& arena, google NiFpga_Session session = session_repository_->access_session(session_grpc_session.name()); uint32_t control = request->control(); - auto data = std::make_unique(); - data->session = session; + auto data = std::make_unique(); + data->session = session; data->control = control; data->library = std::shared_ptr(library_); @@ -4481,8 +4449,8 @@ ::grpc::Status MonikerWriteU8(void* data, google::protobuf::Arena& arena, google NiFpga_Session session = session_repository_->access_session(session_grpc_session.name()); uint32_t control = request->control(); - auto data = std::make_unique(); - data->session = session; + auto data = std::make_unique(); + data->session = session; data->control = control; data->library = std::shared_ptr(library_); @@ -4533,8 +4501,8 @@ ::grpc::Status MonikerWriteU8(void* data, google::protobuf::Arena& arena, google NiFpga_Session session = session_repository_->access_session(session_grpc_session.name()); uint32_t control = request->control(); - auto data = std::make_unique(); - data->session = session; + auto data = std::make_unique(); + data->session = session; data->control = control; data->library = std::shared_ptr(library_); @@ -4594,8 +4562,8 @@ ::grpc::Status MonikerWriteU8(void* data, google::protobuf::Arena& arena, google NiFpga_Session session = session_repository_->access_session(session_grpc_session.name()); uint32_t control = request->control(); - auto data = std::make_unique(); - data->session = session; + auto data = std::make_unique(); + data->session = session; data->control = control; data->library = std::shared_ptr(library_); @@ -4679,8 +4647,8 @@ ::grpc::Status MonikerWriteU8(void* data, google::protobuf::Arena& arena, google NiFpga_Session session = session_repository_->access_session(session_grpc_session.name()); uint32_t control = request->control(); - auto data = std::make_unique(); - data->session = session; + auto data = std::make_unique(); + data->session = session; data->control = control; data->library = std::shared_ptr(library_); @@ -4731,8 +4699,8 @@ ::grpc::Status MonikerWriteU8(void* data, google::protobuf::Arena& arena, google NiFpga_Session session = session_repository_->access_session(session_grpc_session.name()); uint32_t control = request->control(); - auto data = std::make_unique(); - data->session = session; + auto data = std::make_unique(); + data->session = session; data->control = control; data->library = std::shared_ptr(library_); @@ -4783,8 +4751,8 @@ ::grpc::Status MonikerWriteU8(void* data, google::protobuf::Arena& arena, google NiFpga_Session session = session_repository_->access_session(session_grpc_session.name()); uint32_t control = request->control(); - auto data = std::make_unique(); - data->session = session; + auto data = std::make_unique(); + data->session = session; data->control = control; data->library = std::shared_ptr(library_); @@ -4844,8 +4812,8 @@ ::grpc::Status MonikerWriteU8(void* data, google::protobuf::Arena& arena, google NiFpga_Session session = session_repository_->access_session(session_grpc_session.name()); uint32_t control = request->control(); - auto data = std::make_unique(); - data->session = session; + auto data = std::make_unique(); + data->session = session; data->control = control; data->library = std::shared_ptr(library_); diff --git a/source/codegen/templates/service_helpers.mako b/source/codegen/templates/service_helpers.mako index 83fc231c6..49edcfbb9 100644 --- a/source/codegen/templates/service_helpers.mako +++ b/source/codegen/templates/service_helpers.mako @@ -314,7 +314,7 @@ ${populate_response(function_data=function_data, parameters=parameters)}\ ::grpc::Status ${moniker_function_name}(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData) { ${struct_name}* function_data = (${struct_name}*)data; - auto library = function_data->library; + auto library = function_data->library;\ ${initialize_moniker_streaming_parameters(streaming_param_to_include)}\ % if streaming_param and streaming_param['direction'] == 'out': ${streaming_handle_out_direction(c_api_name, arg_string, data_type, streaming_type, streaming_param)}\ @@ -341,7 +341,7 @@ ${populate_response(function_data=function_data, parameters=parameters)}\ streaming_param_to_include = common_helpers.get_input_streaming_param(parameters) %>\ ${initialize_streaming_input_param(function_name, streaming_param_to_include, parameters, streaming_param)} - auto data = std::make_unique<${struct_name}>(); + auto data = std::make_unique<${struct_name}>();\ ${initialize_begin_input_param(streaming_param_to_include, streaming_param)}\ data->library = std::shared_ptr<${service_class_prefix}LibraryInterface>(library_); ${initialize_service_output_params(output_params)}\ @@ -377,25 +377,25 @@ auto array_storage = std::vector<${data_type}>(); auto status = library->${c_api_name}(${arg_string}); % if is_coerced: if (status >= 0) { - std::transform( - array.begin(), - array.begin() + ${size}, - function_data->data.mutable_value()->begin(), - [&](auto x) { - return x; - }); - packedData.PackFrom(function_data->data); + std::transform( + array.begin(), + array.begin() + ${size}, + function_data->data.mutable_value()->begin(), + [&](auto x) { + return x; + }); + packedData.PackFrom(function_data->data); } % else: if (status >= 0) { - std::transform( - array, - array + ${size}, - function_data->data.mutable_value()->begin(), - [&](auto x) { - return x; - }); - packedData.PackFrom(function_data->data); + std::transform( + array, + array + ${size}, + function_data->data.mutable_value()->begin(), + [&](auto x) { + return x; + }); + packedData.PackFrom(function_data->data); } % endif @@ -447,16 +447,16 @@ auto data_array = ${grpc_streaming_type.lower()}_message.value(); auto size = data_array.size(); array.reserve(size); std::transform( - data_array.begin(), - data_array.end(), - std::back_inserter(array), - [](auto x) { - if (x < std::numeric_limits<${data_type}>::min() || x > std::numeric_limits<${data_type}>::max()) { - std::string message("value " + std::to_string(x) + " doesn't fit in datatype ${data_type}"); - throw nidevice_grpc::ValueOutOfRangeException(message); - } - return static_cast<${data_type}>(x); - }); + data_array.begin(), + data_array.end(), + std::back_inserter(array), + [](auto x) { + if (x < std::numeric_limits<${data_type}>::min() || x > std::numeric_limits<${data_type}>::max()) { + std::string message("value " + std::to_string(x) + " doesn't fit in datatype ${data_type}"); + throw nidevice_grpc::ValueOutOfRangeException(message); + } + return static_cast<${data_type}>(x); + }); % else: auto data_array = ${grpc_streaming_type.lower()}_message.value(); auto array = const_cast<${data_type}*>(${grpc_streaming_type.lower()}_message.value().data()); @@ -465,7 +465,7 @@ auto data_array = ${grpc_streaming_type.lower()}_message.value(); ## Initialize an bgin input parameter for an API call. -<%def name="initialize_begin_input_param(streaming_param_to_include, streaming_param)">\ +<%def name="initialize_begin_input_param(streaming_param_to_include, streaming_param)"> % for param in streaming_param_to_include: data->${param['name']} = ${param['name']}; % endfor From c2464b04a1ff2421ee77c9ed9d9436c6b34923f3 Mon Sep 17 00:00:00 2001 From: Ayush Mehra Date: Sun, 10 Nov 2024 19:35:03 -0800 Subject: [PATCH 28/34] include boolean functions --- generated/nifpga/nifpga.proto | 49 ++++ generated/nifpga/nifpga_client.cpp | 73 +++++ generated/nifpga/nifpga_client.h | 4 + generated/nifpga/nifpga_service.cpp | 256 +++++++++++++++++- generated/nifpga/nifpga_service.h | 8 + .../codegen/metadata/nifpga/custom_proto.mako | 4 + source/codegen/metadata/nifpga/functions.py | 20 +- source/codegen/templates/service_helpers.mako | 4 +- 8 files changed, 408 insertions(+), 10 deletions(-) diff --git a/generated/nifpga/nifpga.proto b/generated/nifpga/nifpga.proto index 7cc6d5f3c..e7cb4f824 100644 --- a/generated/nifpga/nifpga.proto +++ b/generated/nifpga/nifpga.proto @@ -35,6 +35,7 @@ service NiFpga { rpc GetFpgaViState(GetFpgaViStateRequest) returns (GetFpgaViStateResponse); rpc Open(OpenRequest) returns (OpenResponse); rpc ReadArrayBool(ReadArrayBoolRequest) returns (ReadArrayBoolResponse); + rpc BeginReadArrayBool(BeginReadArrayBoolRequest) returns (BeginReadArrayBoolResponse); rpc ReadArrayDbl(ReadArrayDblRequest) returns (ReadArrayDblResponse); rpc ReadArrayI16(ReadArrayI16Request) returns (ReadArrayI16Response); rpc BeginReadArrayI16(BeginReadArrayI16Request) returns (BeginReadArrayI16Response); @@ -54,6 +55,7 @@ service NiFpga { rpc ReadArrayU8(ReadArrayU8Request) returns (ReadArrayU8Response); rpc BeginReadArrayU8(BeginReadArrayU8Request) returns (BeginReadArrayU8Response); rpc ReadBool(ReadBoolRequest) returns (ReadBoolResponse); + rpc BeginReadBool(BeginReadBoolRequest) returns (BeginReadBoolResponse); rpc ReadDbl(ReadDblRequest) returns (ReadDblResponse); rpc ReadFifoBool(ReadFifoBoolRequest) returns (ReadFifoBoolResponse); rpc ReadFifoDbl(ReadFifoDblRequest) returns (ReadFifoDblResponse); @@ -95,6 +97,7 @@ service NiFpga { rpc UnreserveFifo(UnreserveFifoRequest) returns (UnreserveFifoResponse); rpc WaitOnIrqs(WaitOnIrqsRequest) returns (WaitOnIrqsResponse); rpc WriteArrayBool(WriteArrayBoolRequest) returns (WriteArrayBoolResponse); + rpc BeginWriteArrayBool(BeginWriteArrayBoolRequest) returns (BeginWriteArrayBoolResponse); rpc WriteArrayDbl(WriteArrayDblRequest) returns (WriteArrayDblResponse); rpc WriteArrayI16(WriteArrayI16Request) returns (WriteArrayI16Response); rpc BeginWriteArrayI16(BeginWriteArrayI16Request) returns (BeginWriteArrayI16Response); @@ -114,6 +117,7 @@ service NiFpga { rpc WriteArrayU8(WriteArrayU8Request) returns (WriteArrayU8Response); rpc BeginWriteArrayU8(BeginWriteArrayU8Request) returns (BeginWriteArrayU8Response); rpc WriteBool(WriteBoolRequest) returns (WriteBoolResponse); + rpc BeginWriteBool(BeginWriteBoolRequest) returns (BeginWriteBoolResponse); rpc WriteDbl(WriteDblRequest) returns (WriteDblResponse); rpc WriteFifoBool(WriteFifoBoolRequest) returns (WriteFifoBoolResponse); rpc WriteFifoDbl(WriteFifoDblRequest) returns (WriteFifoDblResponse); @@ -267,6 +271,10 @@ message ArrayI64Data { message ArrayU64Data { repeated uint64 value = 1; } + +message ArrayBoolData { + repeated bool value = 1; +} message AbortRequest { nidevice_grpc.Session session = 1; } @@ -459,6 +467,17 @@ message ReadArrayBoolResponse { repeated bool array = 2; } +message BeginReadArrayBoolRequest { + nidevice_grpc.Session session = 1; + uint32 indicator = 2; + uint32 size = 3; +} + +message BeginReadArrayBoolResponse { + int32 status = 1; + ni.data_monikers.Moniker moniker = 2; +} + message ReadArrayDblRequest { nidevice_grpc.Session session = 1; uint32 indicator = 2; @@ -667,6 +686,16 @@ message ReadBoolResponse { bool value = 2; } +message BeginReadBoolRequest { + nidevice_grpc.Session session = 1; + uint32 indicator = 2; +} + +message BeginReadBoolResponse { + int32 status = 1; + ni.data_monikers.Moniker moniker = 2; +} + message ReadDblRequest { nidevice_grpc.Session session = 1; uint32 indicator = 2; @@ -1125,6 +1154,16 @@ message WriteArrayBoolResponse { int32 status = 1; } +message BeginWriteArrayBoolRequest { + nidevice_grpc.Session session = 1; + uint32 control = 2; +} + +message BeginWriteArrayBoolResponse { + int32 status = 1; + ni.data_monikers.Moniker moniker = 2; +} + message WriteArrayDblRequest { nidevice_grpc.Session session = 1; uint32 control = 2; @@ -1315,6 +1354,16 @@ message WriteBoolResponse { int32 status = 1; } +message BeginWriteBoolRequest { + nidevice_grpc.Session session = 1; + uint32 control = 2; +} + +message BeginWriteBoolResponse { + int32 status = 1; + ni.data_monikers.Moniker moniker = 2; +} + message WriteDblRequest { nidevice_grpc.Session session = 1; uint32 control = 2; diff --git a/generated/nifpga/nifpga_client.cpp b/generated/nifpga/nifpga_client.cpp index 8b33126ca..ac2871b6f 100644 --- a/generated/nifpga/nifpga_client.cpp +++ b/generated/nifpga/nifpga_client.cpp @@ -371,6 +371,25 @@ read_array_bool(const StubPtr& stub, const nidevice_grpc::Session& session, cons return response; } +BeginReadArrayBoolResponse +begin_read_array_bool(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& indicator, const pb::uint32& size) +{ + ::grpc::ClientContext context; + + auto request = BeginReadArrayBoolRequest{}; + request.mutable_session()->CopyFrom(session); + request.set_indicator(indicator); + request.set_size(size); + + auto response = BeginReadArrayBoolResponse{}; + + raise_if_error( + stub->BeginReadArrayBool(&context, request, &response), + context); + + return response; +} + ReadArrayDblResponse read_array_dbl(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& indicator, const pb::uint32& size) { @@ -731,6 +750,24 @@ read_bool(const StubPtr& stub, const nidevice_grpc::Session& session, const pb:: return response; } +BeginReadBoolResponse +begin_read_bool(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& indicator) +{ + ::grpc::ClientContext context; + + auto request = BeginReadBoolRequest{}; + request.mutable_session()->CopyFrom(session); + request.set_indicator(indicator); + + auto response = BeginReadBoolResponse{}; + + raise_if_error( + stub->BeginReadBool(&context, request, &response), + context); + + return response; +} + ReadDblResponse read_dbl(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& indicator) { @@ -1536,6 +1573,24 @@ write_array_bool(const StubPtr& stub, const nidevice_grpc::Session& session, con return response; } +BeginWriteArrayBoolResponse +begin_write_array_bool(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& control) +{ + ::grpc::ClientContext context; + + auto request = BeginWriteArrayBoolRequest{}; + request.mutable_session()->CopyFrom(session); + request.set_control(control); + + auto response = BeginWriteArrayBoolResponse{}; + + raise_if_error( + stub->BeginWriteArrayBool(&context, request, &response), + context); + + return response; +} + WriteArrayDblResponse write_array_dbl(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& control, const std::vector& array) { @@ -1889,6 +1944,24 @@ write_bool(const StubPtr& stub, const nidevice_grpc::Session& session, const pb: return response; } +BeginWriteBoolResponse +begin_write_bool(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& control) +{ + ::grpc::ClientContext context; + + auto request = BeginWriteBoolRequest{}; + request.mutable_session()->CopyFrom(session); + request.set_control(control); + + auto response = BeginWriteBoolResponse{}; + + raise_if_error( + stub->BeginWriteBool(&context, request, &response), + context); + + return response; +} + WriteDblResponse write_dbl(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& control, const double& value) { diff --git a/generated/nifpga/nifpga_client.h b/generated/nifpga/nifpga_client.h index 217de441f..f021b3c59 100644 --- a/generated/nifpga/nifpga_client.h +++ b/generated/nifpga/nifpga_client.h @@ -39,6 +39,7 @@ GetFifoPropertyU64Response get_fifo_property_u64(const StubPtr& stub, const nide GetFpgaViStateResponse get_fpga_vi_state(const StubPtr& stub, const nidevice_grpc::Session& session); OpenResponse open(const StubPtr& stub, const std::string& bitfile, const std::string& signature, const std::string& resource, const simple_variant& attribute, const nidevice_grpc::SessionInitializationBehavior& initialization_behavior = nidevice_grpc::SESSION_INITIALIZATION_BEHAVIOR_UNSPECIFIED); ReadArrayBoolResponse read_array_bool(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& indicator, const pb::uint32& size); +BeginReadArrayBoolResponse begin_read_array_bool(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& indicator, const pb::uint32& size); ReadArrayDblResponse read_array_dbl(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& indicator, const pb::uint32& size); ReadArrayI16Response read_array_i16(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& indicator, const pb::uint32& size); BeginReadArrayI16Response begin_read_array_i16(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& indicator, const pb::uint32& size); @@ -58,6 +59,7 @@ BeginReadArrayU64Response begin_read_array_u64(const StubPtr& stub, const nidevi ReadArrayU8Response read_array_u8(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& indicator, const pb::uint32& size); BeginReadArrayU8Response begin_read_array_u8(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& indicator, const pb::uint32& size); ReadBoolResponse read_bool(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& indicator); +BeginReadBoolResponse begin_read_bool(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& indicator); ReadDblResponse read_dbl(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& indicator); ReadFifoBoolResponse read_fifo_bool(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& fifo, const pb::uint32& number_of_elements, const pb::uint32& timeout); ReadFifoDblResponse read_fifo_dbl(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& fifo, const pb::uint32& number_of_elements, const pb::uint32& timeout); @@ -99,6 +101,7 @@ StopFifoResponse stop_fifo(const StubPtr& stub, const nidevice_grpc::Session& se UnreserveFifoResponse unreserve_fifo(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& fifo); WaitOnIrqsResponse wait_on_irqs(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& irqs, const pb::uint32& timeout); WriteArrayBoolResponse write_array_bool(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& control, const std::vector& array); +BeginWriteArrayBoolResponse begin_write_array_bool(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& control); WriteArrayDblResponse write_array_dbl(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& control, const std::vector& array); WriteArrayI16Response write_array_i16(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& control, const std::vector& array); BeginWriteArrayI16Response begin_write_array_i16(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& control); @@ -118,6 +121,7 @@ BeginWriteArrayU64Response begin_write_array_u64(const StubPtr& stub, const nide WriteArrayU8Response write_array_u8(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& control, const std::vector& array); BeginWriteArrayU8Response begin_write_array_u8(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& control); WriteBoolResponse write_bool(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& control, const bool& value); +BeginWriteBoolResponse begin_write_bool(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& control); WriteDblResponse write_dbl(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& control, const double& value); WriteFifoBoolResponse write_fifo_bool(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& fifo, const std::vector& data, const pb::uint32& timeout); WriteFifoDblResponse write_fifo_dbl(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& fifo, const std::vector& data, const pb::uint32& timeout); diff --git a/generated/nifpga/nifpga_service.cpp b/generated/nifpga/nifpga_service.cpp index ced6f94d7..1d24ee881 100644 --- a/generated/nifpga/nifpga_service.cpp +++ b/generated/nifpga/nifpga_service.cpp @@ -22,6 +22,15 @@ namespace nifpga_grpc { using nidevice_grpc::converters::convert_to_grpc; using nidevice_grpc::converters::MatchState; + struct MonikerReadArrayBoolData + { + NiFpga_Session session; + uint32_t indicator; + size_t size; + nifpga_grpc::ArrayBoolData data; + std::shared_ptr library; + }; + struct MonikerReadArrayI16Data { NiFpga_Session session; @@ -94,6 +103,14 @@ namespace nifpga_grpc { std::shared_ptr library; }; + struct MonikerReadBoolData + { + NiFpga_Session session; + uint32_t indicator; + nifpga_grpc::BoolData data; + std::shared_ptr library; + }; + struct MonikerReadI16Data { NiFpga_Session session; @@ -158,6 +175,14 @@ namespace nifpga_grpc { std::shared_ptr library; }; + struct MonikerWriteArrayBoolData + { + NiFpga_Session session; + uint32_t control; + nifpga_grpc::ArrayBoolData data; + std::shared_ptr library; + }; + struct MonikerWriteArrayI16Data { NiFpga_Session session; @@ -222,6 +247,14 @@ namespace nifpga_grpc { std::shared_ptr library; }; + struct MonikerWriteBoolData + { + NiFpga_Session session; + uint32_t control; + nifpga_grpc::BoolData data; + std::shared_ptr library; + }; + struct MonikerWriteI16Data { NiFpga_Session session; @@ -308,6 +341,7 @@ namespace nifpga_grpc { void RegisterMonikerEndpoints() { + ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerReadArrayBool", MonikerReadArrayBool); ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerReadArrayI16", MonikerReadArrayI16); ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerReadArrayI32", MonikerReadArrayI32); ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerReadArrayI64", MonikerReadArrayI64); @@ -316,6 +350,7 @@ namespace nifpga_grpc { ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerReadArrayU32", MonikerReadArrayU32); ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerReadArrayU64", MonikerReadArrayU64); ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerReadArrayU8", MonikerReadArrayU8); + ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerReadBool", MonikerReadBool); ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerReadI16", MonikerReadI16); ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerReadI32", MonikerReadI32); ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerReadI64", MonikerReadI64); @@ -324,6 +359,7 @@ namespace nifpga_grpc { ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerReadU32", MonikerReadU32); ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerReadU64", MonikerReadU64); ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerReadU8", MonikerReadU8); + ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerWriteArrayBool", MonikerWriteArrayBool); ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerWriteArrayI16", MonikerWriteArrayI16); ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerWriteArrayI32", MonikerWriteArrayI32); ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerWriteArrayI64", MonikerWriteArrayI64); @@ -332,6 +368,7 @@ namespace nifpga_grpc { ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerWriteArrayU32", MonikerWriteArrayU32); ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerWriteArrayU64", MonikerWriteArrayU64); ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerWriteArrayU8", MonikerWriteArrayU8); + ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerWriteBool", MonikerWriteBool); ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerWriteI16", MonikerWriteI16); ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerWriteI32", MonikerWriteI32); ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerWriteI64", MonikerWriteI64); @@ -342,6 +379,34 @@ namespace nifpga_grpc { ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerWriteU8", MonikerWriteU8); } +::grpc::Status MonikerReadArrayBool(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData) +{ + MonikerReadArrayBoolData* function_data = (MonikerReadArrayBoolData*)data; + auto library = function_data->library; + auto session = function_data->session; + auto indicator = function_data->indicator; + auto size = function_data->size; + + auto array_storage = std::vector(); + auto array = array_storage.data(); + auto status = library->ReadArrayBool(session, indicator, array.data(), size); + if (status >= 0) { + std::transform( + array, + array + size, + function_data->data.mutable_value()->begin(), + [&](auto x) { + return x; + }); + packedData.PackFrom(function_data->data); + } + + if (status < 0) { + std::cout << "MonikerReadArrayBool error: " << status << std::endl; + } + return ::grpc::Status::OK; +} + ::grpc::Status MonikerReadArrayI16(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData) { MonikerReadArrayI16Data* function_data = (MonikerReadArrayI16Data*)data; @@ -562,6 +627,26 @@ ::grpc::Status MonikerReadArrayU8(void* data, google::protobuf::Arena& arena, go return ::grpc::Status::OK; } +::grpc::Status MonikerReadBool(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData) +{ + MonikerReadBoolData* function_data = (MonikerReadBoolData*)data; + auto library = function_data->library; + auto session = function_data->session; + auto indicator = function_data->indicator; + + NiFpga_Bool value = 0; + auto status = library->ReadBool(session, indicator, &value); + function_data->data.set_value(value); + if (status >= 0) { + packedData.PackFrom(function_data->data); + } + + if (status < 0) { + std::cout << "MonikerReadBool error: " << status << std::endl; + } + return ::grpc::Status::OK; +} + ::grpc::Status MonikerReadI16(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData) { MonikerReadI16Data* function_data = (MonikerReadI16Data*)data; @@ -722,6 +807,27 @@ ::grpc::Status MonikerReadU8(void* data, google::protobuf::Arena& arena, google: return ::grpc::Status::OK; } +::grpc::Status MonikerWriteArrayBool(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData) +{ + MonikerWriteArrayBoolData* function_data = (MonikerWriteArrayBoolData*)data; + auto library = function_data->library; + auto session = function_data->session; + auto control = function_data->control; + + ArrayBoolData arraybooldata_message; + packedData.UnpackTo(&arraybooldata_message); + + auto data_array = arraybooldata_message.value(); + auto array = const_cast(arraybooldata_message.value().data()); + auto size = data_array.size(); + + auto status = library->WriteArrayBool(session, control, array.data(), size); + if (status < 0) { + std::cout << "MonikerWriteArrayBool error: " << status << std::endl; + } + return ::grpc::Status::OK; +} + ::grpc::Status MonikerWriteArrayI16(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData) { MonikerWriteArrayI16Data* function_data = (MonikerWriteArrayI16Data*)data; @@ -731,6 +837,7 @@ ::grpc::Status MonikerWriteArrayI16(void* data, google::protobuf::Arena& arena, ArrayI32Data arrayi32data_message; packedData.UnpackTo(&arrayi32data_message); + auto data_array = arrayi32data_message.value(); auto array = std::vector(); auto size = data_array.size(); @@ -763,7 +870,8 @@ ::grpc::Status MonikerWriteArrayI32(void* data, google::protobuf::Arena& arena, ArrayI32Data arrayi32data_message; packedData.UnpackTo(&arrayi32data_message); - auto data_array = arrayi32data_message.value(); + + auto data_array = arrayi32data_message.value(); auto array = const_cast(arrayi32data_message.value().data()); auto size = data_array.size(); @@ -783,7 +891,8 @@ ::grpc::Status MonikerWriteArrayI64(void* data, google::protobuf::Arena& arena, ArrayI64Data arrayi64data_message; packedData.UnpackTo(&arrayi64data_message); - auto data_array = arrayi64data_message.value(); + + auto data_array = arrayi64data_message.value(); auto array = const_cast(arrayi64data_message.value().data()); auto size = data_array.size(); @@ -803,6 +912,7 @@ ::grpc::Status MonikerWriteArrayI8(void* data, google::protobuf::Arena& arena, g ArrayI32Data arrayi32data_message; packedData.UnpackTo(&arrayi32data_message); + auto data_array = arrayi32data_message.value(); auto array = std::vector(); auto size = data_array.size(); @@ -835,6 +945,7 @@ ::grpc::Status MonikerWriteArrayU16(void* data, google::protobuf::Arena& arena, ArrayU32Data arrayu32data_message; packedData.UnpackTo(&arrayu32data_message); + auto data_array = arrayu32data_message.value(); auto array = std::vector(); auto size = data_array.size(); @@ -867,7 +978,8 @@ ::grpc::Status MonikerWriteArrayU32(void* data, google::protobuf::Arena& arena, ArrayU32Data arrayu32data_message; packedData.UnpackTo(&arrayu32data_message); - auto data_array = arrayu32data_message.value(); + + auto data_array = arrayu32data_message.value(); auto array = const_cast(arrayu32data_message.value().data()); auto size = data_array.size(); @@ -887,7 +999,8 @@ ::grpc::Status MonikerWriteArrayU64(void* data, google::protobuf::Arena& arena, ArrayU64Data arrayu64data_message; packedData.UnpackTo(&arrayu64data_message); - auto data_array = arrayu64data_message.value(); + + auto data_array = arrayu64data_message.value(); auto array = const_cast(arrayu64data_message.value().data()); auto size = data_array.size(); @@ -907,6 +1020,7 @@ ::grpc::Status MonikerWriteArrayU8(void* data, google::protobuf::Arena& arena, g ArrayU32Data arrayu32data_message; packedData.UnpackTo(&arrayu32data_message); + auto data_array = arrayu32data_message.value(); auto array = std::vector(); auto size = data_array.size(); @@ -930,6 +1044,24 @@ ::grpc::Status MonikerWriteArrayU8(void* data, google::protobuf::Arena& arena, g return ::grpc::Status::OK; } +::grpc::Status MonikerWriteBool(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData) +{ + MonikerWriteBoolData* function_data = (MonikerWriteBoolData*)data; + auto library = function_data->library; + auto session = function_data->session; + auto control = function_data->control; + + BoolData booldata_message; + packedData.UnpackTo(&booldata_message); + auto value = booldata_message.value(); + + auto status = library->WriteBool(session, control, value); + if (status < 0) { + std::cout << "MonikerWriteBool error: " << status << std::endl; + } + return ::grpc::Status::OK; +} + ::grpc::Status MonikerWriteI16(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData) { MonikerWriteI16Data* function_data = (MonikerWriteI16Data*)data; @@ -1621,6 +1753,38 @@ ::grpc::Status MonikerWriteU8(void* data, google::protobuf::Arena& arena, google } } + //--------------------------------------------------------------------- + //--------------------------------------------------------------------- + ::grpc::Status NiFpgaService::BeginReadArrayBool(::grpc::ServerContext* context, const BeginReadArrayBoolRequest* request, BeginReadArrayBoolResponse* response) + { + if (context->IsCancelled()) { + return ::grpc::Status::CANCELLED; + } + try { + auto session_grpc_session = request->session(); + NiFpga_Session session = session_repository_->access_session(session_grpc_session.name()); + uint32_t indicator = request->indicator(); + size_t size = request->size(); + + auto data = std::make_unique(); + data->session = session; + data->indicator = indicator; + data->size = size; + data->library = std::shared_ptr(library_); + + data->data.mutable_value()->Reserve(request->size()); + data->data.mutable_value()->Resize(request->size(), 0); + auto moniker = std::make_unique(); + ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerReadArrayBool", data.get(), *moniker); + response->set_allocated_moniker(moniker.release()); + response->set_status(0); + return ::grpc::Status::OK; + } + catch (nidevice_grpc::NonDriverException& ex) { + return ex.GetStatus(); + } + } + //--------------------------------------------------------------------- //--------------------------------------------------------------------- ::grpc::Status NiFpgaService::ReadArrayDbl(::grpc::ServerContext* context, const ReadArrayDblRequest* request, ReadArrayDblResponse* response) @@ -2194,6 +2358,34 @@ ::grpc::Status MonikerWriteU8(void* data, google::protobuf::Arena& arena, google } } + //--------------------------------------------------------------------- + //--------------------------------------------------------------------- + ::grpc::Status NiFpgaService::BeginReadBool(::grpc::ServerContext* context, const BeginReadBoolRequest* request, BeginReadBoolResponse* response) + { + if (context->IsCancelled()) { + return ::grpc::Status::CANCELLED; + } + try { + auto session_grpc_session = request->session(); + NiFpga_Session session = session_repository_->access_session(session_grpc_session.name()); + uint32_t indicator = request->indicator(); + + auto data = std::make_unique(); + data->session = session; + data->indicator = indicator; + data->library = std::shared_ptr(library_); + + auto moniker = std::make_unique(); + ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerReadBool", data.get(), *moniker); + response->set_allocated_moniker(moniker.release()); + response->set_status(0); + return ::grpc::Status::OK; + } + catch (nidevice_grpc::NonDriverException& ex) { + return ex.GetStatus(); + } + } + //--------------------------------------------------------------------- //--------------------------------------------------------------------- ::grpc::Status NiFpgaService::ReadDbl(::grpc::ServerContext* context, const ReadDblRequest* request, ReadDblResponse* response) @@ -3386,6 +3578,34 @@ ::grpc::Status MonikerWriteU8(void* data, google::protobuf::Arena& arena, google } } + //--------------------------------------------------------------------- + //--------------------------------------------------------------------- + ::grpc::Status NiFpgaService::BeginWriteArrayBool(::grpc::ServerContext* context, const BeginWriteArrayBoolRequest* request, BeginWriteArrayBoolResponse* response) + { + if (context->IsCancelled()) { + return ::grpc::Status::CANCELLED; + } + try { + auto session_grpc_session = request->session(); + NiFpga_Session session = session_repository_->access_session(session_grpc_session.name()); + uint32_t control = request->control(); + + auto data = std::make_unique(); + data->session = session; + data->control = control; + data->library = std::shared_ptr(library_); + + auto moniker = std::make_unique(); + ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerWriteArrayBool", data.get(), *moniker); + response->set_allocated_moniker(moniker.release()); + response->set_status(0); + return ::grpc::Status::OK; + } + catch (nidevice_grpc::NonDriverException& ex) { + return ex.GetStatus(); + } + } + //--------------------------------------------------------------------- //--------------------------------------------------------------------- ::grpc::Status NiFpgaService::WriteArrayDbl(::grpc::ServerContext* context, const WriteArrayDblRequest* request, WriteArrayDblResponse* response) @@ -3952,6 +4172,34 @@ ::grpc::Status MonikerWriteU8(void* data, google::protobuf::Arena& arena, google } } + //--------------------------------------------------------------------- + //--------------------------------------------------------------------- + ::grpc::Status NiFpgaService::BeginWriteBool(::grpc::ServerContext* context, const BeginWriteBoolRequest* request, BeginWriteBoolResponse* response) + { + if (context->IsCancelled()) { + return ::grpc::Status::CANCELLED; + } + try { + auto session_grpc_session = request->session(); + NiFpga_Session session = session_repository_->access_session(session_grpc_session.name()); + uint32_t control = request->control(); + + auto data = std::make_unique(); + data->session = session; + data->control = control; + data->library = std::shared_ptr(library_); + + auto moniker = std::make_unique(); + ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerWriteBool", data.get(), *moniker); + response->set_allocated_moniker(moniker.release()); + response->set_status(0); + return ::grpc::Status::OK; + } + catch (nidevice_grpc::NonDriverException& ex) { + return ex.GetStatus(); + } + } + //--------------------------------------------------------------------- //--------------------------------------------------------------------- ::grpc::Status NiFpgaService::WriteDbl(::grpc::ServerContext* context, const WriteDblRequest* request, WriteDblResponse* response) diff --git a/generated/nifpga/nifpga_service.h b/generated/nifpga/nifpga_service.h index d764ed69b..4a920bba1 100644 --- a/generated/nifpga/nifpga_service.h +++ b/generated/nifpga/nifpga_service.h @@ -33,6 +33,7 @@ struct NiFpgaFeatureToggles void RegisterMonikerEndpoints(); +::grpc::Status MonikerReadArrayBool(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData); ::grpc::Status MonikerReadArrayI16(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData); ::grpc::Status MonikerReadArrayI32(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData); ::grpc::Status MonikerReadArrayI64(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData); @@ -41,6 +42,7 @@ ::grpc::Status MonikerReadArrayU16(void* data, google::protobuf::Arena& arena, g ::grpc::Status MonikerReadArrayU32(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData); ::grpc::Status MonikerReadArrayU64(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData); ::grpc::Status MonikerReadArrayU8(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData); +::grpc::Status MonikerReadBool(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData); ::grpc::Status MonikerReadI16(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData); ::grpc::Status MonikerReadI32(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData); ::grpc::Status MonikerReadI64(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData); @@ -49,6 +51,7 @@ ::grpc::Status MonikerReadU16(void* data, google::protobuf::Arena& arena, google ::grpc::Status MonikerReadU32(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData); ::grpc::Status MonikerReadU64(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData); ::grpc::Status MonikerReadU8(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData); +::grpc::Status MonikerWriteArrayBool(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData); ::grpc::Status MonikerWriteArrayI16(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData); ::grpc::Status MonikerWriteArrayI32(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData); ::grpc::Status MonikerWriteArrayI64(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData); @@ -57,6 +60,7 @@ ::grpc::Status MonikerWriteArrayU16(void* data, google::protobuf::Arena& arena, ::grpc::Status MonikerWriteArrayU32(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData); ::grpc::Status MonikerWriteArrayU64(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData); ::grpc::Status MonikerWriteArrayU8(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData); +::grpc::Status MonikerWriteBool(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData); ::grpc::Status MonikerWriteI16(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData); ::grpc::Status MonikerWriteI32(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData); ::grpc::Status MonikerWriteI64(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData); @@ -94,6 +98,7 @@ class NiFpgaService final : public NiFpga::Service { ::grpc::Status GetFpgaViState(::grpc::ServerContext* context, const GetFpgaViStateRequest* request, GetFpgaViStateResponse* response) override; ::grpc::Status Open(::grpc::ServerContext* context, const OpenRequest* request, OpenResponse* response) override; ::grpc::Status ReadArrayBool(::grpc::ServerContext* context, const ReadArrayBoolRequest* request, ReadArrayBoolResponse* response) override; + ::grpc::Status BeginReadArrayBool(::grpc::ServerContext* context, const BeginReadArrayBoolRequest* request, BeginReadArrayBoolResponse* response) override; ::grpc::Status ReadArrayDbl(::grpc::ServerContext* context, const ReadArrayDblRequest* request, ReadArrayDblResponse* response) override; ::grpc::Status ReadArrayI16(::grpc::ServerContext* context, const ReadArrayI16Request* request, ReadArrayI16Response* response) override; ::grpc::Status BeginReadArrayI16(::grpc::ServerContext* context, const BeginReadArrayI16Request* request, BeginReadArrayI16Response* response) override; @@ -113,6 +118,7 @@ class NiFpgaService final : public NiFpga::Service { ::grpc::Status ReadArrayU8(::grpc::ServerContext* context, const ReadArrayU8Request* request, ReadArrayU8Response* response) override; ::grpc::Status BeginReadArrayU8(::grpc::ServerContext* context, const BeginReadArrayU8Request* request, BeginReadArrayU8Response* response) override; ::grpc::Status ReadBool(::grpc::ServerContext* context, const ReadBoolRequest* request, ReadBoolResponse* response) override; + ::grpc::Status BeginReadBool(::grpc::ServerContext* context, const BeginReadBoolRequest* request, BeginReadBoolResponse* response) override; ::grpc::Status ReadDbl(::grpc::ServerContext* context, const ReadDblRequest* request, ReadDblResponse* response) override; ::grpc::Status ReadFifoBool(::grpc::ServerContext* context, const ReadFifoBoolRequest* request, ReadFifoBoolResponse* response) override; ::grpc::Status ReadFifoDbl(::grpc::ServerContext* context, const ReadFifoDblRequest* request, ReadFifoDblResponse* response) override; @@ -154,6 +160,7 @@ class NiFpgaService final : public NiFpga::Service { ::grpc::Status UnreserveFifo(::grpc::ServerContext* context, const UnreserveFifoRequest* request, UnreserveFifoResponse* response) override; ::grpc::Status WaitOnIrqs(::grpc::ServerContext* context, const WaitOnIrqsRequest* request, WaitOnIrqsResponse* response) override; ::grpc::Status WriteArrayBool(::grpc::ServerContext* context, const WriteArrayBoolRequest* request, WriteArrayBoolResponse* response) override; + ::grpc::Status BeginWriteArrayBool(::grpc::ServerContext* context, const BeginWriteArrayBoolRequest* request, BeginWriteArrayBoolResponse* response) override; ::grpc::Status WriteArrayDbl(::grpc::ServerContext* context, const WriteArrayDblRequest* request, WriteArrayDblResponse* response) override; ::grpc::Status WriteArrayI16(::grpc::ServerContext* context, const WriteArrayI16Request* request, WriteArrayI16Response* response) override; ::grpc::Status BeginWriteArrayI16(::grpc::ServerContext* context, const BeginWriteArrayI16Request* request, BeginWriteArrayI16Response* response) override; @@ -173,6 +180,7 @@ class NiFpgaService final : public NiFpga::Service { ::grpc::Status WriteArrayU8(::grpc::ServerContext* context, const WriteArrayU8Request* request, WriteArrayU8Response* response) override; ::grpc::Status BeginWriteArrayU8(::grpc::ServerContext* context, const BeginWriteArrayU8Request* request, BeginWriteArrayU8Response* response) override; ::grpc::Status WriteBool(::grpc::ServerContext* context, const WriteBoolRequest* request, WriteBoolResponse* response) override; + ::grpc::Status BeginWriteBool(::grpc::ServerContext* context, const BeginWriteBoolRequest* request, BeginWriteBoolResponse* response) override; ::grpc::Status WriteDbl(::grpc::ServerContext* context, const WriteDblRequest* request, WriteDblResponse* response) override; ::grpc::Status WriteFifoBool(::grpc::ServerContext* context, const WriteFifoBoolRequest* request, WriteFifoBoolResponse* response) override; ::grpc::Status WriteFifoDbl(::grpc::ServerContext* context, const WriteFifoDblRequest* request, WriteFifoDblResponse* response) override; diff --git a/source/codegen/metadata/nifpga/custom_proto.mako b/source/codegen/metadata/nifpga/custom_proto.mako index 19f03d497..0c31f3fca 100644 --- a/source/codegen/metadata/nifpga/custom_proto.mako +++ b/source/codegen/metadata/nifpga/custom_proto.mako @@ -32,4 +32,8 @@ message ArrayI64Data { message ArrayU64Data { repeated uint64 value = 1; +} + +message ArrayBoolData { + repeated bool value = 1; } \ No newline at end of file diff --git a/source/codegen/metadata/nifpga/functions.py b/source/codegen/metadata/nifpga/functions.py index ce517594a..cb020deab 100644 --- a/source/codegen/metadata/nifpga/functions.py +++ b/source/codegen/metadata/nifpga/functions.py @@ -1670,6 +1670,8 @@ }, { 'direction': 'out', + 'grpc_streaming_type': 'ArrayBoolData', + 'is_streaming_type': True, 'name': 'array', 'size': { 'mechanism': 'passed-in', @@ -1683,7 +1685,8 @@ 'type': 'size_t' } ], - 'returns': 'NiFpga_Status' + 'returns': 'NiFpga_Status', + 'supports_streaming': True }, 'ReadArrayDbl': { 'parameters': [ @@ -2013,11 +2016,14 @@ }, { 'direction': 'out', + 'grpc_streaming_type': 'BoolData', + 'is_streaming_type': True, 'name': 'value', 'type': 'NiFpga_Bool' } ], - 'returns': 'NiFpga_Status' + 'returns': 'NiFpga_Status', + 'supports_streaming': True }, 'ReadDbl': { 'parameters': [ @@ -3085,6 +3091,8 @@ }, { 'direction': 'in', + 'grpc_streaming_type': 'ArrayBoolData', + 'is_streaming_type': True, 'name': 'array', 'size': { 'mechanism': 'len', @@ -3098,7 +3106,8 @@ 'type': 'size_t' } ], - 'returns': 'NiFpga_Status' + 'returns': 'NiFpga_Status', + 'supports_streaming': True }, 'WriteArrayDbl': { 'parameters': [ @@ -3428,11 +3437,14 @@ }, { 'direction': 'in', + 'grpc_streaming_type': 'BoolData', + 'is_streaming_type': True, 'name': 'value', 'type': 'NiFpga_Bool' } ], - 'returns': 'NiFpga_Status' + 'returns': 'NiFpga_Status', + 'supports_streaming': True }, 'WriteDbl': { 'parameters': [ diff --git a/source/codegen/templates/service_helpers.mako b/source/codegen/templates/service_helpers.mako index 49edcfbb9..14d056ecd 100644 --- a/source/codegen/templates/service_helpers.mako +++ b/source/codegen/templates/service_helpers.mako @@ -437,12 +437,12 @@ auto value = ${grpc_streaming_type.lower()}_message.value(); % endif -<%def name="streaming_handle_in_direction_array(data_type, grpc_streaming_type, streaming_param)">\ +<%def name="streaming_handle_in_direction_array(data_type, grpc_streaming_type, streaming_param)"> <% is_coerced = service_helpers.is_input_array_that_needs_coercion(streaming_param) %>\ % if is_coerced: -auto data_array = ${grpc_streaming_type.lower()}_message.value(); + auto data_array = ${grpc_streaming_type.lower()}_message.value(); auto array = std::vector<${data_type}>(); auto size = data_array.size(); array.reserve(size); From 62afa439dc21ba658f87260b12afae278c21282e Mon Sep 17 00:00:00 2001 From: Ayush Mehra Date: Sun, 10 Nov 2024 20:32:55 -0800 Subject: [PATCH 29/34] Revert "include boolean functions" This reverts commit c2464b04a1ff2421ee77c9ed9d9436c6b34923f3. --- generated/nifpga/nifpga.proto | 49 ---- generated/nifpga/nifpga_client.cpp | 73 ----- generated/nifpga/nifpga_client.h | 4 - generated/nifpga/nifpga_service.cpp | 256 +----------------- generated/nifpga/nifpga_service.h | 8 - .../codegen/metadata/nifpga/custom_proto.mako | 4 - source/codegen/metadata/nifpga/functions.py | 20 +- source/codegen/templates/service_helpers.mako | 4 +- 8 files changed, 10 insertions(+), 408 deletions(-) diff --git a/generated/nifpga/nifpga.proto b/generated/nifpga/nifpga.proto index e7cb4f824..7cc6d5f3c 100644 --- a/generated/nifpga/nifpga.proto +++ b/generated/nifpga/nifpga.proto @@ -35,7 +35,6 @@ service NiFpga { rpc GetFpgaViState(GetFpgaViStateRequest) returns (GetFpgaViStateResponse); rpc Open(OpenRequest) returns (OpenResponse); rpc ReadArrayBool(ReadArrayBoolRequest) returns (ReadArrayBoolResponse); - rpc BeginReadArrayBool(BeginReadArrayBoolRequest) returns (BeginReadArrayBoolResponse); rpc ReadArrayDbl(ReadArrayDblRequest) returns (ReadArrayDblResponse); rpc ReadArrayI16(ReadArrayI16Request) returns (ReadArrayI16Response); rpc BeginReadArrayI16(BeginReadArrayI16Request) returns (BeginReadArrayI16Response); @@ -55,7 +54,6 @@ service NiFpga { rpc ReadArrayU8(ReadArrayU8Request) returns (ReadArrayU8Response); rpc BeginReadArrayU8(BeginReadArrayU8Request) returns (BeginReadArrayU8Response); rpc ReadBool(ReadBoolRequest) returns (ReadBoolResponse); - rpc BeginReadBool(BeginReadBoolRequest) returns (BeginReadBoolResponse); rpc ReadDbl(ReadDblRequest) returns (ReadDblResponse); rpc ReadFifoBool(ReadFifoBoolRequest) returns (ReadFifoBoolResponse); rpc ReadFifoDbl(ReadFifoDblRequest) returns (ReadFifoDblResponse); @@ -97,7 +95,6 @@ service NiFpga { rpc UnreserveFifo(UnreserveFifoRequest) returns (UnreserveFifoResponse); rpc WaitOnIrqs(WaitOnIrqsRequest) returns (WaitOnIrqsResponse); rpc WriteArrayBool(WriteArrayBoolRequest) returns (WriteArrayBoolResponse); - rpc BeginWriteArrayBool(BeginWriteArrayBoolRequest) returns (BeginWriteArrayBoolResponse); rpc WriteArrayDbl(WriteArrayDblRequest) returns (WriteArrayDblResponse); rpc WriteArrayI16(WriteArrayI16Request) returns (WriteArrayI16Response); rpc BeginWriteArrayI16(BeginWriteArrayI16Request) returns (BeginWriteArrayI16Response); @@ -117,7 +114,6 @@ service NiFpga { rpc WriteArrayU8(WriteArrayU8Request) returns (WriteArrayU8Response); rpc BeginWriteArrayU8(BeginWriteArrayU8Request) returns (BeginWriteArrayU8Response); rpc WriteBool(WriteBoolRequest) returns (WriteBoolResponse); - rpc BeginWriteBool(BeginWriteBoolRequest) returns (BeginWriteBoolResponse); rpc WriteDbl(WriteDblRequest) returns (WriteDblResponse); rpc WriteFifoBool(WriteFifoBoolRequest) returns (WriteFifoBoolResponse); rpc WriteFifoDbl(WriteFifoDblRequest) returns (WriteFifoDblResponse); @@ -271,10 +267,6 @@ message ArrayI64Data { message ArrayU64Data { repeated uint64 value = 1; } - -message ArrayBoolData { - repeated bool value = 1; -} message AbortRequest { nidevice_grpc.Session session = 1; } @@ -467,17 +459,6 @@ message ReadArrayBoolResponse { repeated bool array = 2; } -message BeginReadArrayBoolRequest { - nidevice_grpc.Session session = 1; - uint32 indicator = 2; - uint32 size = 3; -} - -message BeginReadArrayBoolResponse { - int32 status = 1; - ni.data_monikers.Moniker moniker = 2; -} - message ReadArrayDblRequest { nidevice_grpc.Session session = 1; uint32 indicator = 2; @@ -686,16 +667,6 @@ message ReadBoolResponse { bool value = 2; } -message BeginReadBoolRequest { - nidevice_grpc.Session session = 1; - uint32 indicator = 2; -} - -message BeginReadBoolResponse { - int32 status = 1; - ni.data_monikers.Moniker moniker = 2; -} - message ReadDblRequest { nidevice_grpc.Session session = 1; uint32 indicator = 2; @@ -1154,16 +1125,6 @@ message WriteArrayBoolResponse { int32 status = 1; } -message BeginWriteArrayBoolRequest { - nidevice_grpc.Session session = 1; - uint32 control = 2; -} - -message BeginWriteArrayBoolResponse { - int32 status = 1; - ni.data_monikers.Moniker moniker = 2; -} - message WriteArrayDblRequest { nidevice_grpc.Session session = 1; uint32 control = 2; @@ -1354,16 +1315,6 @@ message WriteBoolResponse { int32 status = 1; } -message BeginWriteBoolRequest { - nidevice_grpc.Session session = 1; - uint32 control = 2; -} - -message BeginWriteBoolResponse { - int32 status = 1; - ni.data_monikers.Moniker moniker = 2; -} - message WriteDblRequest { nidevice_grpc.Session session = 1; uint32 control = 2; diff --git a/generated/nifpga/nifpga_client.cpp b/generated/nifpga/nifpga_client.cpp index ac2871b6f..8b33126ca 100644 --- a/generated/nifpga/nifpga_client.cpp +++ b/generated/nifpga/nifpga_client.cpp @@ -371,25 +371,6 @@ read_array_bool(const StubPtr& stub, const nidevice_grpc::Session& session, cons return response; } -BeginReadArrayBoolResponse -begin_read_array_bool(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& indicator, const pb::uint32& size) -{ - ::grpc::ClientContext context; - - auto request = BeginReadArrayBoolRequest{}; - request.mutable_session()->CopyFrom(session); - request.set_indicator(indicator); - request.set_size(size); - - auto response = BeginReadArrayBoolResponse{}; - - raise_if_error( - stub->BeginReadArrayBool(&context, request, &response), - context); - - return response; -} - ReadArrayDblResponse read_array_dbl(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& indicator, const pb::uint32& size) { @@ -750,24 +731,6 @@ read_bool(const StubPtr& stub, const nidevice_grpc::Session& session, const pb:: return response; } -BeginReadBoolResponse -begin_read_bool(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& indicator) -{ - ::grpc::ClientContext context; - - auto request = BeginReadBoolRequest{}; - request.mutable_session()->CopyFrom(session); - request.set_indicator(indicator); - - auto response = BeginReadBoolResponse{}; - - raise_if_error( - stub->BeginReadBool(&context, request, &response), - context); - - return response; -} - ReadDblResponse read_dbl(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& indicator) { @@ -1573,24 +1536,6 @@ write_array_bool(const StubPtr& stub, const nidevice_grpc::Session& session, con return response; } -BeginWriteArrayBoolResponse -begin_write_array_bool(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& control) -{ - ::grpc::ClientContext context; - - auto request = BeginWriteArrayBoolRequest{}; - request.mutable_session()->CopyFrom(session); - request.set_control(control); - - auto response = BeginWriteArrayBoolResponse{}; - - raise_if_error( - stub->BeginWriteArrayBool(&context, request, &response), - context); - - return response; -} - WriteArrayDblResponse write_array_dbl(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& control, const std::vector& array) { @@ -1944,24 +1889,6 @@ write_bool(const StubPtr& stub, const nidevice_grpc::Session& session, const pb: return response; } -BeginWriteBoolResponse -begin_write_bool(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& control) -{ - ::grpc::ClientContext context; - - auto request = BeginWriteBoolRequest{}; - request.mutable_session()->CopyFrom(session); - request.set_control(control); - - auto response = BeginWriteBoolResponse{}; - - raise_if_error( - stub->BeginWriteBool(&context, request, &response), - context); - - return response; -} - WriteDblResponse write_dbl(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& control, const double& value) { diff --git a/generated/nifpga/nifpga_client.h b/generated/nifpga/nifpga_client.h index f021b3c59..217de441f 100644 --- a/generated/nifpga/nifpga_client.h +++ b/generated/nifpga/nifpga_client.h @@ -39,7 +39,6 @@ GetFifoPropertyU64Response get_fifo_property_u64(const StubPtr& stub, const nide GetFpgaViStateResponse get_fpga_vi_state(const StubPtr& stub, const nidevice_grpc::Session& session); OpenResponse open(const StubPtr& stub, const std::string& bitfile, const std::string& signature, const std::string& resource, const simple_variant& attribute, const nidevice_grpc::SessionInitializationBehavior& initialization_behavior = nidevice_grpc::SESSION_INITIALIZATION_BEHAVIOR_UNSPECIFIED); ReadArrayBoolResponse read_array_bool(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& indicator, const pb::uint32& size); -BeginReadArrayBoolResponse begin_read_array_bool(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& indicator, const pb::uint32& size); ReadArrayDblResponse read_array_dbl(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& indicator, const pb::uint32& size); ReadArrayI16Response read_array_i16(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& indicator, const pb::uint32& size); BeginReadArrayI16Response begin_read_array_i16(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& indicator, const pb::uint32& size); @@ -59,7 +58,6 @@ BeginReadArrayU64Response begin_read_array_u64(const StubPtr& stub, const nidevi ReadArrayU8Response read_array_u8(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& indicator, const pb::uint32& size); BeginReadArrayU8Response begin_read_array_u8(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& indicator, const pb::uint32& size); ReadBoolResponse read_bool(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& indicator); -BeginReadBoolResponse begin_read_bool(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& indicator); ReadDblResponse read_dbl(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& indicator); ReadFifoBoolResponse read_fifo_bool(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& fifo, const pb::uint32& number_of_elements, const pb::uint32& timeout); ReadFifoDblResponse read_fifo_dbl(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& fifo, const pb::uint32& number_of_elements, const pb::uint32& timeout); @@ -101,7 +99,6 @@ StopFifoResponse stop_fifo(const StubPtr& stub, const nidevice_grpc::Session& se UnreserveFifoResponse unreserve_fifo(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& fifo); WaitOnIrqsResponse wait_on_irqs(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& irqs, const pb::uint32& timeout); WriteArrayBoolResponse write_array_bool(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& control, const std::vector& array); -BeginWriteArrayBoolResponse begin_write_array_bool(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& control); WriteArrayDblResponse write_array_dbl(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& control, const std::vector& array); WriteArrayI16Response write_array_i16(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& control, const std::vector& array); BeginWriteArrayI16Response begin_write_array_i16(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& control); @@ -121,7 +118,6 @@ BeginWriteArrayU64Response begin_write_array_u64(const StubPtr& stub, const nide WriteArrayU8Response write_array_u8(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& control, const std::vector& array); BeginWriteArrayU8Response begin_write_array_u8(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& control); WriteBoolResponse write_bool(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& control, const bool& value); -BeginWriteBoolResponse begin_write_bool(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& control); WriteDblResponse write_dbl(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& control, const double& value); WriteFifoBoolResponse write_fifo_bool(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& fifo, const std::vector& data, const pb::uint32& timeout); WriteFifoDblResponse write_fifo_dbl(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& fifo, const std::vector& data, const pb::uint32& timeout); diff --git a/generated/nifpga/nifpga_service.cpp b/generated/nifpga/nifpga_service.cpp index 1d24ee881..ced6f94d7 100644 --- a/generated/nifpga/nifpga_service.cpp +++ b/generated/nifpga/nifpga_service.cpp @@ -22,15 +22,6 @@ namespace nifpga_grpc { using nidevice_grpc::converters::convert_to_grpc; using nidevice_grpc::converters::MatchState; - struct MonikerReadArrayBoolData - { - NiFpga_Session session; - uint32_t indicator; - size_t size; - nifpga_grpc::ArrayBoolData data; - std::shared_ptr library; - }; - struct MonikerReadArrayI16Data { NiFpga_Session session; @@ -103,14 +94,6 @@ namespace nifpga_grpc { std::shared_ptr library; }; - struct MonikerReadBoolData - { - NiFpga_Session session; - uint32_t indicator; - nifpga_grpc::BoolData data; - std::shared_ptr library; - }; - struct MonikerReadI16Data { NiFpga_Session session; @@ -175,14 +158,6 @@ namespace nifpga_grpc { std::shared_ptr library; }; - struct MonikerWriteArrayBoolData - { - NiFpga_Session session; - uint32_t control; - nifpga_grpc::ArrayBoolData data; - std::shared_ptr library; - }; - struct MonikerWriteArrayI16Data { NiFpga_Session session; @@ -247,14 +222,6 @@ namespace nifpga_grpc { std::shared_ptr library; }; - struct MonikerWriteBoolData - { - NiFpga_Session session; - uint32_t control; - nifpga_grpc::BoolData data; - std::shared_ptr library; - }; - struct MonikerWriteI16Data { NiFpga_Session session; @@ -341,7 +308,6 @@ namespace nifpga_grpc { void RegisterMonikerEndpoints() { - ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerReadArrayBool", MonikerReadArrayBool); ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerReadArrayI16", MonikerReadArrayI16); ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerReadArrayI32", MonikerReadArrayI32); ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerReadArrayI64", MonikerReadArrayI64); @@ -350,7 +316,6 @@ namespace nifpga_grpc { ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerReadArrayU32", MonikerReadArrayU32); ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerReadArrayU64", MonikerReadArrayU64); ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerReadArrayU8", MonikerReadArrayU8); - ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerReadBool", MonikerReadBool); ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerReadI16", MonikerReadI16); ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerReadI32", MonikerReadI32); ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerReadI64", MonikerReadI64); @@ -359,7 +324,6 @@ namespace nifpga_grpc { ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerReadU32", MonikerReadU32); ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerReadU64", MonikerReadU64); ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerReadU8", MonikerReadU8); - ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerWriteArrayBool", MonikerWriteArrayBool); ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerWriteArrayI16", MonikerWriteArrayI16); ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerWriteArrayI32", MonikerWriteArrayI32); ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerWriteArrayI64", MonikerWriteArrayI64); @@ -368,7 +332,6 @@ namespace nifpga_grpc { ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerWriteArrayU32", MonikerWriteArrayU32); ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerWriteArrayU64", MonikerWriteArrayU64); ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerWriteArrayU8", MonikerWriteArrayU8); - ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerWriteBool", MonikerWriteBool); ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerWriteI16", MonikerWriteI16); ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerWriteI32", MonikerWriteI32); ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerWriteI64", MonikerWriteI64); @@ -379,34 +342,6 @@ namespace nifpga_grpc { ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerWriteU8", MonikerWriteU8); } -::grpc::Status MonikerReadArrayBool(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData) -{ - MonikerReadArrayBoolData* function_data = (MonikerReadArrayBoolData*)data; - auto library = function_data->library; - auto session = function_data->session; - auto indicator = function_data->indicator; - auto size = function_data->size; - - auto array_storage = std::vector(); - auto array = array_storage.data(); - auto status = library->ReadArrayBool(session, indicator, array.data(), size); - if (status >= 0) { - std::transform( - array, - array + size, - function_data->data.mutable_value()->begin(), - [&](auto x) { - return x; - }); - packedData.PackFrom(function_data->data); - } - - if (status < 0) { - std::cout << "MonikerReadArrayBool error: " << status << std::endl; - } - return ::grpc::Status::OK; -} - ::grpc::Status MonikerReadArrayI16(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData) { MonikerReadArrayI16Data* function_data = (MonikerReadArrayI16Data*)data; @@ -627,26 +562,6 @@ ::grpc::Status MonikerReadArrayU8(void* data, google::protobuf::Arena& arena, go return ::grpc::Status::OK; } -::grpc::Status MonikerReadBool(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData) -{ - MonikerReadBoolData* function_data = (MonikerReadBoolData*)data; - auto library = function_data->library; - auto session = function_data->session; - auto indicator = function_data->indicator; - - NiFpga_Bool value = 0; - auto status = library->ReadBool(session, indicator, &value); - function_data->data.set_value(value); - if (status >= 0) { - packedData.PackFrom(function_data->data); - } - - if (status < 0) { - std::cout << "MonikerReadBool error: " << status << std::endl; - } - return ::grpc::Status::OK; -} - ::grpc::Status MonikerReadI16(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData) { MonikerReadI16Data* function_data = (MonikerReadI16Data*)data; @@ -807,27 +722,6 @@ ::grpc::Status MonikerReadU8(void* data, google::protobuf::Arena& arena, google: return ::grpc::Status::OK; } -::grpc::Status MonikerWriteArrayBool(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData) -{ - MonikerWriteArrayBoolData* function_data = (MonikerWriteArrayBoolData*)data; - auto library = function_data->library; - auto session = function_data->session; - auto control = function_data->control; - - ArrayBoolData arraybooldata_message; - packedData.UnpackTo(&arraybooldata_message); - - auto data_array = arraybooldata_message.value(); - auto array = const_cast(arraybooldata_message.value().data()); - auto size = data_array.size(); - - auto status = library->WriteArrayBool(session, control, array.data(), size); - if (status < 0) { - std::cout << "MonikerWriteArrayBool error: " << status << std::endl; - } - return ::grpc::Status::OK; -} - ::grpc::Status MonikerWriteArrayI16(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData) { MonikerWriteArrayI16Data* function_data = (MonikerWriteArrayI16Data*)data; @@ -837,7 +731,6 @@ ::grpc::Status MonikerWriteArrayI16(void* data, google::protobuf::Arena& arena, ArrayI32Data arrayi32data_message; packedData.UnpackTo(&arrayi32data_message); - auto data_array = arrayi32data_message.value(); auto array = std::vector(); auto size = data_array.size(); @@ -870,8 +763,7 @@ ::grpc::Status MonikerWriteArrayI32(void* data, google::protobuf::Arena& arena, ArrayI32Data arrayi32data_message; packedData.UnpackTo(&arrayi32data_message); - - auto data_array = arrayi32data_message.value(); + auto data_array = arrayi32data_message.value(); auto array = const_cast(arrayi32data_message.value().data()); auto size = data_array.size(); @@ -891,8 +783,7 @@ ::grpc::Status MonikerWriteArrayI64(void* data, google::protobuf::Arena& arena, ArrayI64Data arrayi64data_message; packedData.UnpackTo(&arrayi64data_message); - - auto data_array = arrayi64data_message.value(); + auto data_array = arrayi64data_message.value(); auto array = const_cast(arrayi64data_message.value().data()); auto size = data_array.size(); @@ -912,7 +803,6 @@ ::grpc::Status MonikerWriteArrayI8(void* data, google::protobuf::Arena& arena, g ArrayI32Data arrayi32data_message; packedData.UnpackTo(&arrayi32data_message); - auto data_array = arrayi32data_message.value(); auto array = std::vector(); auto size = data_array.size(); @@ -945,7 +835,6 @@ ::grpc::Status MonikerWriteArrayU16(void* data, google::protobuf::Arena& arena, ArrayU32Data arrayu32data_message; packedData.UnpackTo(&arrayu32data_message); - auto data_array = arrayu32data_message.value(); auto array = std::vector(); auto size = data_array.size(); @@ -978,8 +867,7 @@ ::grpc::Status MonikerWriteArrayU32(void* data, google::protobuf::Arena& arena, ArrayU32Data arrayu32data_message; packedData.UnpackTo(&arrayu32data_message); - - auto data_array = arrayu32data_message.value(); + auto data_array = arrayu32data_message.value(); auto array = const_cast(arrayu32data_message.value().data()); auto size = data_array.size(); @@ -999,8 +887,7 @@ ::grpc::Status MonikerWriteArrayU64(void* data, google::protobuf::Arena& arena, ArrayU64Data arrayu64data_message; packedData.UnpackTo(&arrayu64data_message); - - auto data_array = arrayu64data_message.value(); + auto data_array = arrayu64data_message.value(); auto array = const_cast(arrayu64data_message.value().data()); auto size = data_array.size(); @@ -1020,7 +907,6 @@ ::grpc::Status MonikerWriteArrayU8(void* data, google::protobuf::Arena& arena, g ArrayU32Data arrayu32data_message; packedData.UnpackTo(&arrayu32data_message); - auto data_array = arrayu32data_message.value(); auto array = std::vector(); auto size = data_array.size(); @@ -1044,24 +930,6 @@ ::grpc::Status MonikerWriteArrayU8(void* data, google::protobuf::Arena& arena, g return ::grpc::Status::OK; } -::grpc::Status MonikerWriteBool(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData) -{ - MonikerWriteBoolData* function_data = (MonikerWriteBoolData*)data; - auto library = function_data->library; - auto session = function_data->session; - auto control = function_data->control; - - BoolData booldata_message; - packedData.UnpackTo(&booldata_message); - auto value = booldata_message.value(); - - auto status = library->WriteBool(session, control, value); - if (status < 0) { - std::cout << "MonikerWriteBool error: " << status << std::endl; - } - return ::grpc::Status::OK; -} - ::grpc::Status MonikerWriteI16(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData) { MonikerWriteI16Data* function_data = (MonikerWriteI16Data*)data; @@ -1753,38 +1621,6 @@ ::grpc::Status MonikerWriteU8(void* data, google::protobuf::Arena& arena, google } } - //--------------------------------------------------------------------- - //--------------------------------------------------------------------- - ::grpc::Status NiFpgaService::BeginReadArrayBool(::grpc::ServerContext* context, const BeginReadArrayBoolRequest* request, BeginReadArrayBoolResponse* response) - { - if (context->IsCancelled()) { - return ::grpc::Status::CANCELLED; - } - try { - auto session_grpc_session = request->session(); - NiFpga_Session session = session_repository_->access_session(session_grpc_session.name()); - uint32_t indicator = request->indicator(); - size_t size = request->size(); - - auto data = std::make_unique(); - data->session = session; - data->indicator = indicator; - data->size = size; - data->library = std::shared_ptr(library_); - - data->data.mutable_value()->Reserve(request->size()); - data->data.mutable_value()->Resize(request->size(), 0); - auto moniker = std::make_unique(); - ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerReadArrayBool", data.get(), *moniker); - response->set_allocated_moniker(moniker.release()); - response->set_status(0); - return ::grpc::Status::OK; - } - catch (nidevice_grpc::NonDriverException& ex) { - return ex.GetStatus(); - } - } - //--------------------------------------------------------------------- //--------------------------------------------------------------------- ::grpc::Status NiFpgaService::ReadArrayDbl(::grpc::ServerContext* context, const ReadArrayDblRequest* request, ReadArrayDblResponse* response) @@ -2358,34 +2194,6 @@ ::grpc::Status MonikerWriteU8(void* data, google::protobuf::Arena& arena, google } } - //--------------------------------------------------------------------- - //--------------------------------------------------------------------- - ::grpc::Status NiFpgaService::BeginReadBool(::grpc::ServerContext* context, const BeginReadBoolRequest* request, BeginReadBoolResponse* response) - { - if (context->IsCancelled()) { - return ::grpc::Status::CANCELLED; - } - try { - auto session_grpc_session = request->session(); - NiFpga_Session session = session_repository_->access_session(session_grpc_session.name()); - uint32_t indicator = request->indicator(); - - auto data = std::make_unique(); - data->session = session; - data->indicator = indicator; - data->library = std::shared_ptr(library_); - - auto moniker = std::make_unique(); - ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerReadBool", data.get(), *moniker); - response->set_allocated_moniker(moniker.release()); - response->set_status(0); - return ::grpc::Status::OK; - } - catch (nidevice_grpc::NonDriverException& ex) { - return ex.GetStatus(); - } - } - //--------------------------------------------------------------------- //--------------------------------------------------------------------- ::grpc::Status NiFpgaService::ReadDbl(::grpc::ServerContext* context, const ReadDblRequest* request, ReadDblResponse* response) @@ -3578,34 +3386,6 @@ ::grpc::Status MonikerWriteU8(void* data, google::protobuf::Arena& arena, google } } - //--------------------------------------------------------------------- - //--------------------------------------------------------------------- - ::grpc::Status NiFpgaService::BeginWriteArrayBool(::grpc::ServerContext* context, const BeginWriteArrayBoolRequest* request, BeginWriteArrayBoolResponse* response) - { - if (context->IsCancelled()) { - return ::grpc::Status::CANCELLED; - } - try { - auto session_grpc_session = request->session(); - NiFpga_Session session = session_repository_->access_session(session_grpc_session.name()); - uint32_t control = request->control(); - - auto data = std::make_unique(); - data->session = session; - data->control = control; - data->library = std::shared_ptr(library_); - - auto moniker = std::make_unique(); - ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerWriteArrayBool", data.get(), *moniker); - response->set_allocated_moniker(moniker.release()); - response->set_status(0); - return ::grpc::Status::OK; - } - catch (nidevice_grpc::NonDriverException& ex) { - return ex.GetStatus(); - } - } - //--------------------------------------------------------------------- //--------------------------------------------------------------------- ::grpc::Status NiFpgaService::WriteArrayDbl(::grpc::ServerContext* context, const WriteArrayDblRequest* request, WriteArrayDblResponse* response) @@ -4172,34 +3952,6 @@ ::grpc::Status MonikerWriteU8(void* data, google::protobuf::Arena& arena, google } } - //--------------------------------------------------------------------- - //--------------------------------------------------------------------- - ::grpc::Status NiFpgaService::BeginWriteBool(::grpc::ServerContext* context, const BeginWriteBoolRequest* request, BeginWriteBoolResponse* response) - { - if (context->IsCancelled()) { - return ::grpc::Status::CANCELLED; - } - try { - auto session_grpc_session = request->session(); - NiFpga_Session session = session_repository_->access_session(session_grpc_session.name()); - uint32_t control = request->control(); - - auto data = std::make_unique(); - data->session = session; - data->control = control; - data->library = std::shared_ptr(library_); - - auto moniker = std::make_unique(); - ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerWriteBool", data.get(), *moniker); - response->set_allocated_moniker(moniker.release()); - response->set_status(0); - return ::grpc::Status::OK; - } - catch (nidevice_grpc::NonDriverException& ex) { - return ex.GetStatus(); - } - } - //--------------------------------------------------------------------- //--------------------------------------------------------------------- ::grpc::Status NiFpgaService::WriteDbl(::grpc::ServerContext* context, const WriteDblRequest* request, WriteDblResponse* response) diff --git a/generated/nifpga/nifpga_service.h b/generated/nifpga/nifpga_service.h index 4a920bba1..d764ed69b 100644 --- a/generated/nifpga/nifpga_service.h +++ b/generated/nifpga/nifpga_service.h @@ -33,7 +33,6 @@ struct NiFpgaFeatureToggles void RegisterMonikerEndpoints(); -::grpc::Status MonikerReadArrayBool(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData); ::grpc::Status MonikerReadArrayI16(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData); ::grpc::Status MonikerReadArrayI32(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData); ::grpc::Status MonikerReadArrayI64(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData); @@ -42,7 +41,6 @@ ::grpc::Status MonikerReadArrayU16(void* data, google::protobuf::Arena& arena, g ::grpc::Status MonikerReadArrayU32(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData); ::grpc::Status MonikerReadArrayU64(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData); ::grpc::Status MonikerReadArrayU8(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData); -::grpc::Status MonikerReadBool(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData); ::grpc::Status MonikerReadI16(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData); ::grpc::Status MonikerReadI32(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData); ::grpc::Status MonikerReadI64(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData); @@ -51,7 +49,6 @@ ::grpc::Status MonikerReadU16(void* data, google::protobuf::Arena& arena, google ::grpc::Status MonikerReadU32(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData); ::grpc::Status MonikerReadU64(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData); ::grpc::Status MonikerReadU8(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData); -::grpc::Status MonikerWriteArrayBool(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData); ::grpc::Status MonikerWriteArrayI16(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData); ::grpc::Status MonikerWriteArrayI32(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData); ::grpc::Status MonikerWriteArrayI64(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData); @@ -60,7 +57,6 @@ ::grpc::Status MonikerWriteArrayU16(void* data, google::protobuf::Arena& arena, ::grpc::Status MonikerWriteArrayU32(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData); ::grpc::Status MonikerWriteArrayU64(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData); ::grpc::Status MonikerWriteArrayU8(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData); -::grpc::Status MonikerWriteBool(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData); ::grpc::Status MonikerWriteI16(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData); ::grpc::Status MonikerWriteI32(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData); ::grpc::Status MonikerWriteI64(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData); @@ -98,7 +94,6 @@ class NiFpgaService final : public NiFpga::Service { ::grpc::Status GetFpgaViState(::grpc::ServerContext* context, const GetFpgaViStateRequest* request, GetFpgaViStateResponse* response) override; ::grpc::Status Open(::grpc::ServerContext* context, const OpenRequest* request, OpenResponse* response) override; ::grpc::Status ReadArrayBool(::grpc::ServerContext* context, const ReadArrayBoolRequest* request, ReadArrayBoolResponse* response) override; - ::grpc::Status BeginReadArrayBool(::grpc::ServerContext* context, const BeginReadArrayBoolRequest* request, BeginReadArrayBoolResponse* response) override; ::grpc::Status ReadArrayDbl(::grpc::ServerContext* context, const ReadArrayDblRequest* request, ReadArrayDblResponse* response) override; ::grpc::Status ReadArrayI16(::grpc::ServerContext* context, const ReadArrayI16Request* request, ReadArrayI16Response* response) override; ::grpc::Status BeginReadArrayI16(::grpc::ServerContext* context, const BeginReadArrayI16Request* request, BeginReadArrayI16Response* response) override; @@ -118,7 +113,6 @@ class NiFpgaService final : public NiFpga::Service { ::grpc::Status ReadArrayU8(::grpc::ServerContext* context, const ReadArrayU8Request* request, ReadArrayU8Response* response) override; ::grpc::Status BeginReadArrayU8(::grpc::ServerContext* context, const BeginReadArrayU8Request* request, BeginReadArrayU8Response* response) override; ::grpc::Status ReadBool(::grpc::ServerContext* context, const ReadBoolRequest* request, ReadBoolResponse* response) override; - ::grpc::Status BeginReadBool(::grpc::ServerContext* context, const BeginReadBoolRequest* request, BeginReadBoolResponse* response) override; ::grpc::Status ReadDbl(::grpc::ServerContext* context, const ReadDblRequest* request, ReadDblResponse* response) override; ::grpc::Status ReadFifoBool(::grpc::ServerContext* context, const ReadFifoBoolRequest* request, ReadFifoBoolResponse* response) override; ::grpc::Status ReadFifoDbl(::grpc::ServerContext* context, const ReadFifoDblRequest* request, ReadFifoDblResponse* response) override; @@ -160,7 +154,6 @@ class NiFpgaService final : public NiFpga::Service { ::grpc::Status UnreserveFifo(::grpc::ServerContext* context, const UnreserveFifoRequest* request, UnreserveFifoResponse* response) override; ::grpc::Status WaitOnIrqs(::grpc::ServerContext* context, const WaitOnIrqsRequest* request, WaitOnIrqsResponse* response) override; ::grpc::Status WriteArrayBool(::grpc::ServerContext* context, const WriteArrayBoolRequest* request, WriteArrayBoolResponse* response) override; - ::grpc::Status BeginWriteArrayBool(::grpc::ServerContext* context, const BeginWriteArrayBoolRequest* request, BeginWriteArrayBoolResponse* response) override; ::grpc::Status WriteArrayDbl(::grpc::ServerContext* context, const WriteArrayDblRequest* request, WriteArrayDblResponse* response) override; ::grpc::Status WriteArrayI16(::grpc::ServerContext* context, const WriteArrayI16Request* request, WriteArrayI16Response* response) override; ::grpc::Status BeginWriteArrayI16(::grpc::ServerContext* context, const BeginWriteArrayI16Request* request, BeginWriteArrayI16Response* response) override; @@ -180,7 +173,6 @@ class NiFpgaService final : public NiFpga::Service { ::grpc::Status WriteArrayU8(::grpc::ServerContext* context, const WriteArrayU8Request* request, WriteArrayU8Response* response) override; ::grpc::Status BeginWriteArrayU8(::grpc::ServerContext* context, const BeginWriteArrayU8Request* request, BeginWriteArrayU8Response* response) override; ::grpc::Status WriteBool(::grpc::ServerContext* context, const WriteBoolRequest* request, WriteBoolResponse* response) override; - ::grpc::Status BeginWriteBool(::grpc::ServerContext* context, const BeginWriteBoolRequest* request, BeginWriteBoolResponse* response) override; ::grpc::Status WriteDbl(::grpc::ServerContext* context, const WriteDblRequest* request, WriteDblResponse* response) override; ::grpc::Status WriteFifoBool(::grpc::ServerContext* context, const WriteFifoBoolRequest* request, WriteFifoBoolResponse* response) override; ::grpc::Status WriteFifoDbl(::grpc::ServerContext* context, const WriteFifoDblRequest* request, WriteFifoDblResponse* response) override; diff --git a/source/codegen/metadata/nifpga/custom_proto.mako b/source/codegen/metadata/nifpga/custom_proto.mako index 0c31f3fca..19f03d497 100644 --- a/source/codegen/metadata/nifpga/custom_proto.mako +++ b/source/codegen/metadata/nifpga/custom_proto.mako @@ -32,8 +32,4 @@ message ArrayI64Data { message ArrayU64Data { repeated uint64 value = 1; -} - -message ArrayBoolData { - repeated bool value = 1; } \ No newline at end of file diff --git a/source/codegen/metadata/nifpga/functions.py b/source/codegen/metadata/nifpga/functions.py index cb020deab..ce517594a 100644 --- a/source/codegen/metadata/nifpga/functions.py +++ b/source/codegen/metadata/nifpga/functions.py @@ -1670,8 +1670,6 @@ }, { 'direction': 'out', - 'grpc_streaming_type': 'ArrayBoolData', - 'is_streaming_type': True, 'name': 'array', 'size': { 'mechanism': 'passed-in', @@ -1685,8 +1683,7 @@ 'type': 'size_t' } ], - 'returns': 'NiFpga_Status', - 'supports_streaming': True + 'returns': 'NiFpga_Status' }, 'ReadArrayDbl': { 'parameters': [ @@ -2016,14 +2013,11 @@ }, { 'direction': 'out', - 'grpc_streaming_type': 'BoolData', - 'is_streaming_type': True, 'name': 'value', 'type': 'NiFpga_Bool' } ], - 'returns': 'NiFpga_Status', - 'supports_streaming': True + 'returns': 'NiFpga_Status' }, 'ReadDbl': { 'parameters': [ @@ -3091,8 +3085,6 @@ }, { 'direction': 'in', - 'grpc_streaming_type': 'ArrayBoolData', - 'is_streaming_type': True, 'name': 'array', 'size': { 'mechanism': 'len', @@ -3106,8 +3098,7 @@ 'type': 'size_t' } ], - 'returns': 'NiFpga_Status', - 'supports_streaming': True + 'returns': 'NiFpga_Status' }, 'WriteArrayDbl': { 'parameters': [ @@ -3437,14 +3428,11 @@ }, { 'direction': 'in', - 'grpc_streaming_type': 'BoolData', - 'is_streaming_type': True, 'name': 'value', 'type': 'NiFpga_Bool' } ], - 'returns': 'NiFpga_Status', - 'supports_streaming': True + 'returns': 'NiFpga_Status' }, 'WriteDbl': { 'parameters': [ diff --git a/source/codegen/templates/service_helpers.mako b/source/codegen/templates/service_helpers.mako index 14d056ecd..49edcfbb9 100644 --- a/source/codegen/templates/service_helpers.mako +++ b/source/codegen/templates/service_helpers.mako @@ -437,12 +437,12 @@ auto value = ${grpc_streaming_type.lower()}_message.value(); % endif -<%def name="streaming_handle_in_direction_array(data_type, grpc_streaming_type, streaming_param)"> +<%def name="streaming_handle_in_direction_array(data_type, grpc_streaming_type, streaming_param)">\ <% is_coerced = service_helpers.is_input_array_that_needs_coercion(streaming_param) %>\ % if is_coerced: - auto data_array = ${grpc_streaming_type.lower()}_message.value(); +auto data_array = ${grpc_streaming_type.lower()}_message.value(); auto array = std::vector<${data_type}>(); auto size = data_array.size(); array.reserve(size); From 0ac96fcf18476cb0ca7a6945a3369b2f0be9b987 Mon Sep 17 00:00:00 2001 From: Ayush Mehra Date: Sun, 10 Nov 2024 20:35:20 -0800 Subject: [PATCH 30/34] fix indentation --- generated/nifpga/nifpga_service.cpp | 16 ++++++++++++---- source/codegen/templates/service_helpers.mako | 4 ++-- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/generated/nifpga/nifpga_service.cpp b/generated/nifpga/nifpga_service.cpp index ced6f94d7..04f3f4c37 100644 --- a/generated/nifpga/nifpga_service.cpp +++ b/generated/nifpga/nifpga_service.cpp @@ -731,6 +731,7 @@ ::grpc::Status MonikerWriteArrayI16(void* data, google::protobuf::Arena& arena, ArrayI32Data arrayi32data_message; packedData.UnpackTo(&arrayi32data_message); + auto data_array = arrayi32data_message.value(); auto array = std::vector(); auto size = data_array.size(); @@ -763,7 +764,8 @@ ::grpc::Status MonikerWriteArrayI32(void* data, google::protobuf::Arena& arena, ArrayI32Data arrayi32data_message; packedData.UnpackTo(&arrayi32data_message); - auto data_array = arrayi32data_message.value(); + + auto data_array = arrayi32data_message.value(); auto array = const_cast(arrayi32data_message.value().data()); auto size = data_array.size(); @@ -783,7 +785,8 @@ ::grpc::Status MonikerWriteArrayI64(void* data, google::protobuf::Arena& arena, ArrayI64Data arrayi64data_message; packedData.UnpackTo(&arrayi64data_message); - auto data_array = arrayi64data_message.value(); + + auto data_array = arrayi64data_message.value(); auto array = const_cast(arrayi64data_message.value().data()); auto size = data_array.size(); @@ -803,6 +806,7 @@ ::grpc::Status MonikerWriteArrayI8(void* data, google::protobuf::Arena& arena, g ArrayI32Data arrayi32data_message; packedData.UnpackTo(&arrayi32data_message); + auto data_array = arrayi32data_message.value(); auto array = std::vector(); auto size = data_array.size(); @@ -835,6 +839,7 @@ ::grpc::Status MonikerWriteArrayU16(void* data, google::protobuf::Arena& arena, ArrayU32Data arrayu32data_message; packedData.UnpackTo(&arrayu32data_message); + auto data_array = arrayu32data_message.value(); auto array = std::vector(); auto size = data_array.size(); @@ -867,7 +872,8 @@ ::grpc::Status MonikerWriteArrayU32(void* data, google::protobuf::Arena& arena, ArrayU32Data arrayu32data_message; packedData.UnpackTo(&arrayu32data_message); - auto data_array = arrayu32data_message.value(); + + auto data_array = arrayu32data_message.value(); auto array = const_cast(arrayu32data_message.value().data()); auto size = data_array.size(); @@ -887,7 +893,8 @@ ::grpc::Status MonikerWriteArrayU64(void* data, google::protobuf::Arena& arena, ArrayU64Data arrayu64data_message; packedData.UnpackTo(&arrayu64data_message); - auto data_array = arrayu64data_message.value(); + + auto data_array = arrayu64data_message.value(); auto array = const_cast(arrayu64data_message.value().data()); auto size = data_array.size(); @@ -907,6 +914,7 @@ ::grpc::Status MonikerWriteArrayU8(void* data, google::protobuf::Arena& arena, g ArrayU32Data arrayu32data_message; packedData.UnpackTo(&arrayu32data_message); + auto data_array = arrayu32data_message.value(); auto array = std::vector(); auto size = data_array.size(); diff --git a/source/codegen/templates/service_helpers.mako b/source/codegen/templates/service_helpers.mako index 49edcfbb9..14d056ecd 100644 --- a/source/codegen/templates/service_helpers.mako +++ b/source/codegen/templates/service_helpers.mako @@ -437,12 +437,12 @@ auto value = ${grpc_streaming_type.lower()}_message.value(); % endif -<%def name="streaming_handle_in_direction_array(data_type, grpc_streaming_type, streaming_param)">\ +<%def name="streaming_handle_in_direction_array(data_type, grpc_streaming_type, streaming_param)"> <% is_coerced = service_helpers.is_input_array_that_needs_coercion(streaming_param) %>\ % if is_coerced: -auto data_array = ${grpc_streaming_type.lower()}_message.value(); + auto data_array = ${grpc_streaming_type.lower()}_message.value(); auto array = std::vector<${data_type}>(); auto size = data_array.size(); array.reserve(size); From 83d45bb8ed173537d09f6f90458fc685d18645fd Mon Sep 17 00:00:00 2001 From: Ayush Mehra Date: Mon, 11 Nov 2024 00:13:32 -0800 Subject: [PATCH 31/34] Add boolean functions --- generated/nifpga/nifpga.proto | 49 ++++ generated/nifpga/nifpga_client.cpp | 73 ++++++ generated/nifpga/nifpga_client.h | 4 + generated/nifpga/nifpga_service.cpp | 239 ++++++++++++++++++ generated/nifpga/nifpga_service.h | 8 + .../codegen/metadata/nifpga/custom_proto.mako | 4 + source/codegen/metadata/nifpga/functions.py | 22 +- source/codegen/templates/service_helpers.mako | 12 +- 8 files changed, 403 insertions(+), 8 deletions(-) diff --git a/generated/nifpga/nifpga.proto b/generated/nifpga/nifpga.proto index 7cc6d5f3c..e7cb4f824 100644 --- a/generated/nifpga/nifpga.proto +++ b/generated/nifpga/nifpga.proto @@ -35,6 +35,7 @@ service NiFpga { rpc GetFpgaViState(GetFpgaViStateRequest) returns (GetFpgaViStateResponse); rpc Open(OpenRequest) returns (OpenResponse); rpc ReadArrayBool(ReadArrayBoolRequest) returns (ReadArrayBoolResponse); + rpc BeginReadArrayBool(BeginReadArrayBoolRequest) returns (BeginReadArrayBoolResponse); rpc ReadArrayDbl(ReadArrayDblRequest) returns (ReadArrayDblResponse); rpc ReadArrayI16(ReadArrayI16Request) returns (ReadArrayI16Response); rpc BeginReadArrayI16(BeginReadArrayI16Request) returns (BeginReadArrayI16Response); @@ -54,6 +55,7 @@ service NiFpga { rpc ReadArrayU8(ReadArrayU8Request) returns (ReadArrayU8Response); rpc BeginReadArrayU8(BeginReadArrayU8Request) returns (BeginReadArrayU8Response); rpc ReadBool(ReadBoolRequest) returns (ReadBoolResponse); + rpc BeginReadBool(BeginReadBoolRequest) returns (BeginReadBoolResponse); rpc ReadDbl(ReadDblRequest) returns (ReadDblResponse); rpc ReadFifoBool(ReadFifoBoolRequest) returns (ReadFifoBoolResponse); rpc ReadFifoDbl(ReadFifoDblRequest) returns (ReadFifoDblResponse); @@ -95,6 +97,7 @@ service NiFpga { rpc UnreserveFifo(UnreserveFifoRequest) returns (UnreserveFifoResponse); rpc WaitOnIrqs(WaitOnIrqsRequest) returns (WaitOnIrqsResponse); rpc WriteArrayBool(WriteArrayBoolRequest) returns (WriteArrayBoolResponse); + rpc BeginWriteArrayBool(BeginWriteArrayBoolRequest) returns (BeginWriteArrayBoolResponse); rpc WriteArrayDbl(WriteArrayDblRequest) returns (WriteArrayDblResponse); rpc WriteArrayI16(WriteArrayI16Request) returns (WriteArrayI16Response); rpc BeginWriteArrayI16(BeginWriteArrayI16Request) returns (BeginWriteArrayI16Response); @@ -114,6 +117,7 @@ service NiFpga { rpc WriteArrayU8(WriteArrayU8Request) returns (WriteArrayU8Response); rpc BeginWriteArrayU8(BeginWriteArrayU8Request) returns (BeginWriteArrayU8Response); rpc WriteBool(WriteBoolRequest) returns (WriteBoolResponse); + rpc BeginWriteBool(BeginWriteBoolRequest) returns (BeginWriteBoolResponse); rpc WriteDbl(WriteDblRequest) returns (WriteDblResponse); rpc WriteFifoBool(WriteFifoBoolRequest) returns (WriteFifoBoolResponse); rpc WriteFifoDbl(WriteFifoDblRequest) returns (WriteFifoDblResponse); @@ -267,6 +271,10 @@ message ArrayI64Data { message ArrayU64Data { repeated uint64 value = 1; } + +message ArrayBoolData { + repeated bool value = 1; +} message AbortRequest { nidevice_grpc.Session session = 1; } @@ -459,6 +467,17 @@ message ReadArrayBoolResponse { repeated bool array = 2; } +message BeginReadArrayBoolRequest { + nidevice_grpc.Session session = 1; + uint32 indicator = 2; + uint32 size = 3; +} + +message BeginReadArrayBoolResponse { + int32 status = 1; + ni.data_monikers.Moniker moniker = 2; +} + message ReadArrayDblRequest { nidevice_grpc.Session session = 1; uint32 indicator = 2; @@ -667,6 +686,16 @@ message ReadBoolResponse { bool value = 2; } +message BeginReadBoolRequest { + nidevice_grpc.Session session = 1; + uint32 indicator = 2; +} + +message BeginReadBoolResponse { + int32 status = 1; + ni.data_monikers.Moniker moniker = 2; +} + message ReadDblRequest { nidevice_grpc.Session session = 1; uint32 indicator = 2; @@ -1125,6 +1154,16 @@ message WriteArrayBoolResponse { int32 status = 1; } +message BeginWriteArrayBoolRequest { + nidevice_grpc.Session session = 1; + uint32 control = 2; +} + +message BeginWriteArrayBoolResponse { + int32 status = 1; + ni.data_monikers.Moniker moniker = 2; +} + message WriteArrayDblRequest { nidevice_grpc.Session session = 1; uint32 control = 2; @@ -1315,6 +1354,16 @@ message WriteBoolResponse { int32 status = 1; } +message BeginWriteBoolRequest { + nidevice_grpc.Session session = 1; + uint32 control = 2; +} + +message BeginWriteBoolResponse { + int32 status = 1; + ni.data_monikers.Moniker moniker = 2; +} + message WriteDblRequest { nidevice_grpc.Session session = 1; uint32 control = 2; diff --git a/generated/nifpga/nifpga_client.cpp b/generated/nifpga/nifpga_client.cpp index 8b33126ca..ac2871b6f 100644 --- a/generated/nifpga/nifpga_client.cpp +++ b/generated/nifpga/nifpga_client.cpp @@ -371,6 +371,25 @@ read_array_bool(const StubPtr& stub, const nidevice_grpc::Session& session, cons return response; } +BeginReadArrayBoolResponse +begin_read_array_bool(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& indicator, const pb::uint32& size) +{ + ::grpc::ClientContext context; + + auto request = BeginReadArrayBoolRequest{}; + request.mutable_session()->CopyFrom(session); + request.set_indicator(indicator); + request.set_size(size); + + auto response = BeginReadArrayBoolResponse{}; + + raise_if_error( + stub->BeginReadArrayBool(&context, request, &response), + context); + + return response; +} + ReadArrayDblResponse read_array_dbl(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& indicator, const pb::uint32& size) { @@ -731,6 +750,24 @@ read_bool(const StubPtr& stub, const nidevice_grpc::Session& session, const pb:: return response; } +BeginReadBoolResponse +begin_read_bool(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& indicator) +{ + ::grpc::ClientContext context; + + auto request = BeginReadBoolRequest{}; + request.mutable_session()->CopyFrom(session); + request.set_indicator(indicator); + + auto response = BeginReadBoolResponse{}; + + raise_if_error( + stub->BeginReadBool(&context, request, &response), + context); + + return response; +} + ReadDblResponse read_dbl(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& indicator) { @@ -1536,6 +1573,24 @@ write_array_bool(const StubPtr& stub, const nidevice_grpc::Session& session, con return response; } +BeginWriteArrayBoolResponse +begin_write_array_bool(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& control) +{ + ::grpc::ClientContext context; + + auto request = BeginWriteArrayBoolRequest{}; + request.mutable_session()->CopyFrom(session); + request.set_control(control); + + auto response = BeginWriteArrayBoolResponse{}; + + raise_if_error( + stub->BeginWriteArrayBool(&context, request, &response), + context); + + return response; +} + WriteArrayDblResponse write_array_dbl(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& control, const std::vector& array) { @@ -1889,6 +1944,24 @@ write_bool(const StubPtr& stub, const nidevice_grpc::Session& session, const pb: return response; } +BeginWriteBoolResponse +begin_write_bool(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& control) +{ + ::grpc::ClientContext context; + + auto request = BeginWriteBoolRequest{}; + request.mutable_session()->CopyFrom(session); + request.set_control(control); + + auto response = BeginWriteBoolResponse{}; + + raise_if_error( + stub->BeginWriteBool(&context, request, &response), + context); + + return response; +} + WriteDblResponse write_dbl(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& control, const double& value) { diff --git a/generated/nifpga/nifpga_client.h b/generated/nifpga/nifpga_client.h index 217de441f..f021b3c59 100644 --- a/generated/nifpga/nifpga_client.h +++ b/generated/nifpga/nifpga_client.h @@ -39,6 +39,7 @@ GetFifoPropertyU64Response get_fifo_property_u64(const StubPtr& stub, const nide GetFpgaViStateResponse get_fpga_vi_state(const StubPtr& stub, const nidevice_grpc::Session& session); OpenResponse open(const StubPtr& stub, const std::string& bitfile, const std::string& signature, const std::string& resource, const simple_variant& attribute, const nidevice_grpc::SessionInitializationBehavior& initialization_behavior = nidevice_grpc::SESSION_INITIALIZATION_BEHAVIOR_UNSPECIFIED); ReadArrayBoolResponse read_array_bool(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& indicator, const pb::uint32& size); +BeginReadArrayBoolResponse begin_read_array_bool(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& indicator, const pb::uint32& size); ReadArrayDblResponse read_array_dbl(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& indicator, const pb::uint32& size); ReadArrayI16Response read_array_i16(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& indicator, const pb::uint32& size); BeginReadArrayI16Response begin_read_array_i16(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& indicator, const pb::uint32& size); @@ -58,6 +59,7 @@ BeginReadArrayU64Response begin_read_array_u64(const StubPtr& stub, const nidevi ReadArrayU8Response read_array_u8(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& indicator, const pb::uint32& size); BeginReadArrayU8Response begin_read_array_u8(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& indicator, const pb::uint32& size); ReadBoolResponse read_bool(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& indicator); +BeginReadBoolResponse begin_read_bool(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& indicator); ReadDblResponse read_dbl(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& indicator); ReadFifoBoolResponse read_fifo_bool(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& fifo, const pb::uint32& number_of_elements, const pb::uint32& timeout); ReadFifoDblResponse read_fifo_dbl(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& fifo, const pb::uint32& number_of_elements, const pb::uint32& timeout); @@ -99,6 +101,7 @@ StopFifoResponse stop_fifo(const StubPtr& stub, const nidevice_grpc::Session& se UnreserveFifoResponse unreserve_fifo(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& fifo); WaitOnIrqsResponse wait_on_irqs(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& irqs, const pb::uint32& timeout); WriteArrayBoolResponse write_array_bool(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& control, const std::vector& array); +BeginWriteArrayBoolResponse begin_write_array_bool(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& control); WriteArrayDblResponse write_array_dbl(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& control, const std::vector& array); WriteArrayI16Response write_array_i16(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& control, const std::vector& array); BeginWriteArrayI16Response begin_write_array_i16(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& control); @@ -118,6 +121,7 @@ BeginWriteArrayU64Response begin_write_array_u64(const StubPtr& stub, const nide WriteArrayU8Response write_array_u8(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& control, const std::vector& array); BeginWriteArrayU8Response begin_write_array_u8(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& control); WriteBoolResponse write_bool(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& control, const bool& value); +BeginWriteBoolResponse begin_write_bool(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& control); WriteDblResponse write_dbl(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& control, const double& value); WriteFifoBoolResponse write_fifo_bool(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& fifo, const std::vector& data, const pb::uint32& timeout); WriteFifoDblResponse write_fifo_dbl(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& fifo, const std::vector& data, const pb::uint32& timeout); diff --git a/generated/nifpga/nifpga_service.cpp b/generated/nifpga/nifpga_service.cpp index 04f3f4c37..1a2a63e9c 100644 --- a/generated/nifpga/nifpga_service.cpp +++ b/generated/nifpga/nifpga_service.cpp @@ -22,6 +22,15 @@ namespace nifpga_grpc { using nidevice_grpc::converters::convert_to_grpc; using nidevice_grpc::converters::MatchState; + struct MonikerReadArrayBoolData + { + NiFpga_Session session; + uint32_t indicator; + size_t size; + nifpga_grpc::ArrayBoolData data; + std::shared_ptr library; + }; + struct MonikerReadArrayI16Data { NiFpga_Session session; @@ -94,6 +103,14 @@ namespace nifpga_grpc { std::shared_ptr library; }; + struct MonikerReadBoolData + { + NiFpga_Session session; + uint32_t indicator; + nifpga_grpc::BoolData data; + std::shared_ptr library; + }; + struct MonikerReadI16Data { NiFpga_Session session; @@ -158,6 +175,14 @@ namespace nifpga_grpc { std::shared_ptr library; }; + struct MonikerWriteArrayBoolData + { + NiFpga_Session session; + uint32_t control; + nifpga_grpc::ArrayBoolData data; + std::shared_ptr library; + }; + struct MonikerWriteArrayI16Data { NiFpga_Session session; @@ -222,6 +247,14 @@ namespace nifpga_grpc { std::shared_ptr library; }; + struct MonikerWriteBoolData + { + NiFpga_Session session; + uint32_t control; + nifpga_grpc::BoolData data; + std::shared_ptr library; + }; + struct MonikerWriteI16Data { NiFpga_Session session; @@ -308,6 +341,7 @@ namespace nifpga_grpc { void RegisterMonikerEndpoints() { + ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerReadArrayBool", MonikerReadArrayBool); ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerReadArrayI16", MonikerReadArrayI16); ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerReadArrayI32", MonikerReadArrayI32); ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerReadArrayI64", MonikerReadArrayI64); @@ -316,6 +350,7 @@ namespace nifpga_grpc { ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerReadArrayU32", MonikerReadArrayU32); ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerReadArrayU64", MonikerReadArrayU64); ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerReadArrayU8", MonikerReadArrayU8); + ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerReadBool", MonikerReadBool); ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerReadI16", MonikerReadI16); ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerReadI32", MonikerReadI32); ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerReadI64", MonikerReadI64); @@ -324,6 +359,7 @@ namespace nifpga_grpc { ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerReadU32", MonikerReadU32); ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerReadU64", MonikerReadU64); ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerReadU8", MonikerReadU8); + ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerWriteArrayBool", MonikerWriteArrayBool); ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerWriteArrayI16", MonikerWriteArrayI16); ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerWriteArrayI32", MonikerWriteArrayI32); ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerWriteArrayI64", MonikerWriteArrayI64); @@ -332,6 +368,7 @@ namespace nifpga_grpc { ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerWriteArrayU32", MonikerWriteArrayU32); ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerWriteArrayU64", MonikerWriteArrayU64); ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerWriteArrayU8", MonikerWriteArrayU8); + ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerWriteBool", MonikerWriteBool); ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerWriteI16", MonikerWriteI16); ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerWriteI32", MonikerWriteI32); ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerWriteI64", MonikerWriteI64); @@ -342,6 +379,33 @@ namespace nifpga_grpc { ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerWriteU8", MonikerWriteU8); } +::grpc::Status MonikerReadArrayBool(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData) +{ + MonikerReadArrayBoolData* function_data = (MonikerReadArrayBoolData*)data; + auto library = function_data->library; + auto session = function_data->session; + auto indicator = function_data->indicator; + auto size = function_data->size; + + std::vector array(size, NiFpga_Bool()); + auto status = library->ReadArrayBool(session, indicator, array.data(), size); + if (status >= 0) { + std::transform( + array.begin(), + array.begin() + size, + function_data->data.mutable_value()->begin(), + [&](auto x) { + return x; + }); + packedData.PackFrom(function_data->data); + } + + if (status < 0) { + std::cout << "MonikerReadArrayBool error: " << status << std::endl; + } + return ::grpc::Status::OK; +} + ::grpc::Status MonikerReadArrayI16(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData) { MonikerReadArrayI16Data* function_data = (MonikerReadArrayI16Data*)data; @@ -562,6 +626,26 @@ ::grpc::Status MonikerReadArrayU8(void* data, google::protobuf::Arena& arena, go return ::grpc::Status::OK; } +::grpc::Status MonikerReadBool(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData) +{ + MonikerReadBoolData* function_data = (MonikerReadBoolData*)data; + auto library = function_data->library; + auto session = function_data->session; + auto indicator = function_data->indicator; + + NiFpga_Bool value = 0; + auto status = library->ReadBool(session, indicator, &value); + function_data->data.set_value(value); + if (status >= 0) { + packedData.PackFrom(function_data->data); + } + + if (status < 0) { + std::cout << "MonikerReadBool error: " << status << std::endl; + } + return ::grpc::Status::OK; +} + ::grpc::Status MonikerReadI16(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData) { MonikerReadI16Data* function_data = (MonikerReadI16Data*)data; @@ -722,6 +806,27 @@ ::grpc::Status MonikerReadU8(void* data, google::protobuf::Arena& arena, google: return ::grpc::Status::OK; } +::grpc::Status MonikerWriteArrayBool(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData) +{ + MonikerWriteArrayBoolData* function_data = (MonikerWriteArrayBoolData*)data; + auto library = function_data->library; + auto session = function_data->session; + auto control = function_data->control; + + ArrayBoolData arraybooldata_message; + packedData.UnpackTo(&arraybooldata_message); + + auto data_array = arraybooldata_message.value(); + std::vector array(data_array.begin(), data_array.end()); + auto size = data_array.size(); + + auto status = library->WriteArrayBool(session, control, array.data(), size); + if (status < 0) { + std::cout << "MonikerWriteArrayBool error: " << status << std::endl; + } + return ::grpc::Status::OK; +} + ::grpc::Status MonikerWriteArrayI16(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData) { MonikerWriteArrayI16Data* function_data = (MonikerWriteArrayI16Data*)data; @@ -938,6 +1043,24 @@ ::grpc::Status MonikerWriteArrayU8(void* data, google::protobuf::Arena& arena, g return ::grpc::Status::OK; } +::grpc::Status MonikerWriteBool(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData) +{ + MonikerWriteBoolData* function_data = (MonikerWriteBoolData*)data; + auto library = function_data->library; + auto session = function_data->session; + auto control = function_data->control; + + BoolData booldata_message; + packedData.UnpackTo(&booldata_message); + auto value = booldata_message.value(); + + auto status = library->WriteBool(session, control, value); + if (status < 0) { + std::cout << "MonikerWriteBool error: " << status << std::endl; + } + return ::grpc::Status::OK; +} + ::grpc::Status MonikerWriteI16(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData) { MonikerWriteI16Data* function_data = (MonikerWriteI16Data*)data; @@ -1629,6 +1752,38 @@ ::grpc::Status MonikerWriteU8(void* data, google::protobuf::Arena& arena, google } } + //--------------------------------------------------------------------- + //--------------------------------------------------------------------- + ::grpc::Status NiFpgaService::BeginReadArrayBool(::grpc::ServerContext* context, const BeginReadArrayBoolRequest* request, BeginReadArrayBoolResponse* response) + { + if (context->IsCancelled()) { + return ::grpc::Status::CANCELLED; + } + try { + auto session_grpc_session = request->session(); + NiFpga_Session session = session_repository_->access_session(session_grpc_session.name()); + uint32_t indicator = request->indicator(); + size_t size = request->size(); + + auto data = std::make_unique(); + data->session = session; + data->indicator = indicator; + data->size = size; + data->library = std::shared_ptr(library_); + + data->data.mutable_value()->Reserve(request->size()); + data->data.mutable_value()->Resize(request->size(), 0); + auto moniker = std::make_unique(); + ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerReadArrayBool", data.get(), *moniker); + response->set_allocated_moniker(moniker.release()); + response->set_status(0); + return ::grpc::Status::OK; + } + catch (nidevice_grpc::NonDriverException& ex) { + return ex.GetStatus(); + } + } + //--------------------------------------------------------------------- //--------------------------------------------------------------------- ::grpc::Status NiFpgaService::ReadArrayDbl(::grpc::ServerContext* context, const ReadArrayDblRequest* request, ReadArrayDblResponse* response) @@ -2202,6 +2357,34 @@ ::grpc::Status MonikerWriteU8(void* data, google::protobuf::Arena& arena, google } } + //--------------------------------------------------------------------- + //--------------------------------------------------------------------- + ::grpc::Status NiFpgaService::BeginReadBool(::grpc::ServerContext* context, const BeginReadBoolRequest* request, BeginReadBoolResponse* response) + { + if (context->IsCancelled()) { + return ::grpc::Status::CANCELLED; + } + try { + auto session_grpc_session = request->session(); + NiFpga_Session session = session_repository_->access_session(session_grpc_session.name()); + uint32_t indicator = request->indicator(); + + auto data = std::make_unique(); + data->session = session; + data->indicator = indicator; + data->library = std::shared_ptr(library_); + + auto moniker = std::make_unique(); + ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerReadBool", data.get(), *moniker); + response->set_allocated_moniker(moniker.release()); + response->set_status(0); + return ::grpc::Status::OK; + } + catch (nidevice_grpc::NonDriverException& ex) { + return ex.GetStatus(); + } + } + //--------------------------------------------------------------------- //--------------------------------------------------------------------- ::grpc::Status NiFpgaService::ReadDbl(::grpc::ServerContext* context, const ReadDblRequest* request, ReadDblResponse* response) @@ -3394,6 +3577,34 @@ ::grpc::Status MonikerWriteU8(void* data, google::protobuf::Arena& arena, google } } + //--------------------------------------------------------------------- + //--------------------------------------------------------------------- + ::grpc::Status NiFpgaService::BeginWriteArrayBool(::grpc::ServerContext* context, const BeginWriteArrayBoolRequest* request, BeginWriteArrayBoolResponse* response) + { + if (context->IsCancelled()) { + return ::grpc::Status::CANCELLED; + } + try { + auto session_grpc_session = request->session(); + NiFpga_Session session = session_repository_->access_session(session_grpc_session.name()); + uint32_t control = request->control(); + + auto data = std::make_unique(); + data->session = session; + data->control = control; + data->library = std::shared_ptr(library_); + + auto moniker = std::make_unique(); + ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerWriteArrayBool", data.get(), *moniker); + response->set_allocated_moniker(moniker.release()); + response->set_status(0); + return ::grpc::Status::OK; + } + catch (nidevice_grpc::NonDriverException& ex) { + return ex.GetStatus(); + } + } + //--------------------------------------------------------------------- //--------------------------------------------------------------------- ::grpc::Status NiFpgaService::WriteArrayDbl(::grpc::ServerContext* context, const WriteArrayDblRequest* request, WriteArrayDblResponse* response) @@ -3960,6 +4171,34 @@ ::grpc::Status MonikerWriteU8(void* data, google::protobuf::Arena& arena, google } } + //--------------------------------------------------------------------- + //--------------------------------------------------------------------- + ::grpc::Status NiFpgaService::BeginWriteBool(::grpc::ServerContext* context, const BeginWriteBoolRequest* request, BeginWriteBoolResponse* response) + { + if (context->IsCancelled()) { + return ::grpc::Status::CANCELLED; + } + try { + auto session_grpc_session = request->session(); + NiFpga_Session session = session_repository_->access_session(session_grpc_session.name()); + uint32_t control = request->control(); + + auto data = std::make_unique(); + data->session = session; + data->control = control; + data->library = std::shared_ptr(library_); + + auto moniker = std::make_unique(); + ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerWriteBool", data.get(), *moniker); + response->set_allocated_moniker(moniker.release()); + response->set_status(0); + return ::grpc::Status::OK; + } + catch (nidevice_grpc::NonDriverException& ex) { + return ex.GetStatus(); + } + } + //--------------------------------------------------------------------- //--------------------------------------------------------------------- ::grpc::Status NiFpgaService::WriteDbl(::grpc::ServerContext* context, const WriteDblRequest* request, WriteDblResponse* response) diff --git a/generated/nifpga/nifpga_service.h b/generated/nifpga/nifpga_service.h index d764ed69b..4a920bba1 100644 --- a/generated/nifpga/nifpga_service.h +++ b/generated/nifpga/nifpga_service.h @@ -33,6 +33,7 @@ struct NiFpgaFeatureToggles void RegisterMonikerEndpoints(); +::grpc::Status MonikerReadArrayBool(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData); ::grpc::Status MonikerReadArrayI16(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData); ::grpc::Status MonikerReadArrayI32(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData); ::grpc::Status MonikerReadArrayI64(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData); @@ -41,6 +42,7 @@ ::grpc::Status MonikerReadArrayU16(void* data, google::protobuf::Arena& arena, g ::grpc::Status MonikerReadArrayU32(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData); ::grpc::Status MonikerReadArrayU64(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData); ::grpc::Status MonikerReadArrayU8(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData); +::grpc::Status MonikerReadBool(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData); ::grpc::Status MonikerReadI16(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData); ::grpc::Status MonikerReadI32(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData); ::grpc::Status MonikerReadI64(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData); @@ -49,6 +51,7 @@ ::grpc::Status MonikerReadU16(void* data, google::protobuf::Arena& arena, google ::grpc::Status MonikerReadU32(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData); ::grpc::Status MonikerReadU64(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData); ::grpc::Status MonikerReadU8(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData); +::grpc::Status MonikerWriteArrayBool(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData); ::grpc::Status MonikerWriteArrayI16(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData); ::grpc::Status MonikerWriteArrayI32(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData); ::grpc::Status MonikerWriteArrayI64(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData); @@ -57,6 +60,7 @@ ::grpc::Status MonikerWriteArrayU16(void* data, google::protobuf::Arena& arena, ::grpc::Status MonikerWriteArrayU32(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData); ::grpc::Status MonikerWriteArrayU64(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData); ::grpc::Status MonikerWriteArrayU8(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData); +::grpc::Status MonikerWriteBool(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData); ::grpc::Status MonikerWriteI16(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData); ::grpc::Status MonikerWriteI32(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData); ::grpc::Status MonikerWriteI64(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData); @@ -94,6 +98,7 @@ class NiFpgaService final : public NiFpga::Service { ::grpc::Status GetFpgaViState(::grpc::ServerContext* context, const GetFpgaViStateRequest* request, GetFpgaViStateResponse* response) override; ::grpc::Status Open(::grpc::ServerContext* context, const OpenRequest* request, OpenResponse* response) override; ::grpc::Status ReadArrayBool(::grpc::ServerContext* context, const ReadArrayBoolRequest* request, ReadArrayBoolResponse* response) override; + ::grpc::Status BeginReadArrayBool(::grpc::ServerContext* context, const BeginReadArrayBoolRequest* request, BeginReadArrayBoolResponse* response) override; ::grpc::Status ReadArrayDbl(::grpc::ServerContext* context, const ReadArrayDblRequest* request, ReadArrayDblResponse* response) override; ::grpc::Status ReadArrayI16(::grpc::ServerContext* context, const ReadArrayI16Request* request, ReadArrayI16Response* response) override; ::grpc::Status BeginReadArrayI16(::grpc::ServerContext* context, const BeginReadArrayI16Request* request, BeginReadArrayI16Response* response) override; @@ -113,6 +118,7 @@ class NiFpgaService final : public NiFpga::Service { ::grpc::Status ReadArrayU8(::grpc::ServerContext* context, const ReadArrayU8Request* request, ReadArrayU8Response* response) override; ::grpc::Status BeginReadArrayU8(::grpc::ServerContext* context, const BeginReadArrayU8Request* request, BeginReadArrayU8Response* response) override; ::grpc::Status ReadBool(::grpc::ServerContext* context, const ReadBoolRequest* request, ReadBoolResponse* response) override; + ::grpc::Status BeginReadBool(::grpc::ServerContext* context, const BeginReadBoolRequest* request, BeginReadBoolResponse* response) override; ::grpc::Status ReadDbl(::grpc::ServerContext* context, const ReadDblRequest* request, ReadDblResponse* response) override; ::grpc::Status ReadFifoBool(::grpc::ServerContext* context, const ReadFifoBoolRequest* request, ReadFifoBoolResponse* response) override; ::grpc::Status ReadFifoDbl(::grpc::ServerContext* context, const ReadFifoDblRequest* request, ReadFifoDblResponse* response) override; @@ -154,6 +160,7 @@ class NiFpgaService final : public NiFpga::Service { ::grpc::Status UnreserveFifo(::grpc::ServerContext* context, const UnreserveFifoRequest* request, UnreserveFifoResponse* response) override; ::grpc::Status WaitOnIrqs(::grpc::ServerContext* context, const WaitOnIrqsRequest* request, WaitOnIrqsResponse* response) override; ::grpc::Status WriteArrayBool(::grpc::ServerContext* context, const WriteArrayBoolRequest* request, WriteArrayBoolResponse* response) override; + ::grpc::Status BeginWriteArrayBool(::grpc::ServerContext* context, const BeginWriteArrayBoolRequest* request, BeginWriteArrayBoolResponse* response) override; ::grpc::Status WriteArrayDbl(::grpc::ServerContext* context, const WriteArrayDblRequest* request, WriteArrayDblResponse* response) override; ::grpc::Status WriteArrayI16(::grpc::ServerContext* context, const WriteArrayI16Request* request, WriteArrayI16Response* response) override; ::grpc::Status BeginWriteArrayI16(::grpc::ServerContext* context, const BeginWriteArrayI16Request* request, BeginWriteArrayI16Response* response) override; @@ -173,6 +180,7 @@ class NiFpgaService final : public NiFpga::Service { ::grpc::Status WriteArrayU8(::grpc::ServerContext* context, const WriteArrayU8Request* request, WriteArrayU8Response* response) override; ::grpc::Status BeginWriteArrayU8(::grpc::ServerContext* context, const BeginWriteArrayU8Request* request, BeginWriteArrayU8Response* response) override; ::grpc::Status WriteBool(::grpc::ServerContext* context, const WriteBoolRequest* request, WriteBoolResponse* response) override; + ::grpc::Status BeginWriteBool(::grpc::ServerContext* context, const BeginWriteBoolRequest* request, BeginWriteBoolResponse* response) override; ::grpc::Status WriteDbl(::grpc::ServerContext* context, const WriteDblRequest* request, WriteDblResponse* response) override; ::grpc::Status WriteFifoBool(::grpc::ServerContext* context, const WriteFifoBoolRequest* request, WriteFifoBoolResponse* response) override; ::grpc::Status WriteFifoDbl(::grpc::ServerContext* context, const WriteFifoDblRequest* request, WriteFifoDblResponse* response) override; diff --git a/source/codegen/metadata/nifpga/custom_proto.mako b/source/codegen/metadata/nifpga/custom_proto.mako index 19f03d497..0c31f3fca 100644 --- a/source/codegen/metadata/nifpga/custom_proto.mako +++ b/source/codegen/metadata/nifpga/custom_proto.mako @@ -32,4 +32,8 @@ message ArrayI64Data { message ArrayU64Data { repeated uint64 value = 1; +} + +message ArrayBoolData { + repeated bool value = 1; } \ No newline at end of file diff --git a/source/codegen/metadata/nifpga/functions.py b/source/codegen/metadata/nifpga/functions.py index ce517594a..fd7e55009 100644 --- a/source/codegen/metadata/nifpga/functions.py +++ b/source/codegen/metadata/nifpga/functions.py @@ -1670,6 +1670,8 @@ }, { 'direction': 'out', + 'grpc_streaming_type': 'ArrayBoolData', + 'is_streaming_type': True, 'name': 'array', 'size': { 'mechanism': 'passed-in', @@ -1683,7 +1685,8 @@ 'type': 'size_t' } ], - 'returns': 'NiFpga_Status' + 'returns': 'NiFpga_Status', + 'supports_streaming': True }, 'ReadArrayDbl': { 'parameters': [ @@ -2013,11 +2016,14 @@ }, { 'direction': 'out', + 'grpc_streaming_type': 'BoolData', + 'is_streaming_type': True, 'name': 'value', 'type': 'NiFpga_Bool' } ], - 'returns': 'NiFpga_Status' + 'returns': 'NiFpga_Status', + 'supports_streaming': True }, 'ReadDbl': { 'parameters': [ @@ -3085,6 +3091,8 @@ }, { 'direction': 'in', + 'grpc_streaming_type': 'ArrayBoolData', + 'is_streaming_type': True, 'name': 'array', 'size': { 'mechanism': 'len', @@ -3098,7 +3106,8 @@ 'type': 'size_t' } ], - 'returns': 'NiFpga_Status' + 'returns': 'NiFpga_Status', + 'supports_streaming': True }, 'WriteArrayDbl': { 'parameters': [ @@ -3428,11 +3437,14 @@ }, { 'direction': 'in', + 'grpc_streaming_type': 'BoolData', + 'is_streaming_type': True, 'name': 'value', 'type': 'NiFpga_Bool' } ], - 'returns': 'NiFpga_Status' + 'returns': 'NiFpga_Status', + 'supports_streaming': True }, 'WriteDbl': { 'parameters': [ @@ -4154,4 +4166,4 @@ 'returns': 'NiFpga_Status', 'supports_streaming': True } -} +} \ No newline at end of file diff --git a/source/codegen/templates/service_helpers.mako b/source/codegen/templates/service_helpers.mako index 14d056ecd..7d022f26f 100644 --- a/source/codegen/templates/service_helpers.mako +++ b/source/codegen/templates/service_helpers.mako @@ -368,14 +368,16 @@ ${initialize_streaming_input_param(function_name, streaming_param_to_include, pa is_coerced = service_helpers.is_output_array_that_needs_coercion(streaming_param) size = service_helpers.get_size_param_name(streaming_param) %>\ -% if is_coerced: +% if common_helpers.supports_standard_copy_conversion_routines(streaming_param): +std::vector<${data_type}> array(${size}, ${data_type}()); +% elif is_coerced: std::vector<${data_type}> array(${size}); % else: auto array_storage = std::vector<${data_type}>(); auto array = array_storage.data(); % endif auto status = library->${c_api_name}(${arg_string}); -% if is_coerced: +% if is_coerced or common_helpers.supports_standard_copy_conversion_routines(streaming_param): if (status >= 0) { std::transform( array.begin(), @@ -441,7 +443,11 @@ auto value = ${grpc_streaming_type.lower()}_message.value(); <% is_coerced = service_helpers.is_input_array_that_needs_coercion(streaming_param) %>\ -% if is_coerced: +% if common_helpers.supports_standard_copy_conversion_routines(streaming_param): + auto data_array = ${grpc_streaming_type.lower()}_message.value(); + std::vector<${data_type}> array(data_array.begin(), data_array.end()); + auto size = data_array.size(); +% elif is_coerced: auto data_array = ${grpc_streaming_type.lower()}_message.value(); auto array = std::vector<${data_type}>(); auto size = data_array.size(); From ca85ec12db1a8f8b3bc9bd8ed041e46c1ecea3d1 Mon Sep 17 00:00:00 2001 From: Ayush Mehra Date: Mon, 11 Nov 2024 01:54:58 -0800 Subject: [PATCH 32/34] Move RegisterMonikerEndpoints inside of driver specific registrar --- generated/nifpga/nifpga_service_registrar.cpp | 6 ++++++ generated/register_all_services.cpp | 4 ---- .../templates/register_all_services.cpp.mako | 16 ---------------- .../codegen/templates/service_registrar.cpp.mako | 15 +++++++++++++++ 4 files changed, 21 insertions(+), 20 deletions(-) diff --git a/generated/nifpga/nifpga_service_registrar.cpp b/generated/nifpga/nifpga_service_registrar.cpp index 5cc12cd1d..199b41b6b 100644 --- a/generated/nifpga/nifpga_service_registrar.cpp +++ b/generated/nifpga/nifpga_service_registrar.cpp @@ -10,6 +10,7 @@ #include "nifpga_service.h" #include "nifpga_service_registrar.h" +#include namespace nifpga_grpc { @@ -28,6 +29,11 @@ std::shared_ptr register_service( resource_repository, toggles); builder.RegisterService(service.get()); + + if (ni::data_monikers::is_sideband_streaming_enabled(feature_toggles)) { + nifpga_grpc::RegisterMonikerEndpoints(); + } + return service; } diff --git a/generated/register_all_services.cpp b/generated/register_all_services.cpp index 294b162fb..093feeb5e 100644 --- a/generated/register_all_services.cpp +++ b/generated/register_all_services.cpp @@ -10,7 +10,6 @@ #include #include -#include #include "nidaqmx/nidaqmx_service_registrar.h" #include "nidcpower/nidcpower_service_registrar.h" @@ -329,9 +328,6 @@ std::shared_ptr>> register_all_services( vi_session_repository, vi_object_repository, feature_toggles)); - if (ni::data_monikers::is_sideband_streaming_enabled(feature_toggles)) { - nifpga_grpc::RegisterMonikerEndpoints(); - } return service_vector; } diff --git a/source/codegen/templates/register_all_services.cpp.mako b/source/codegen/templates/register_all_services.cpp.mako index cfd84cc94..a716cb633 100644 --- a/source/codegen/templates/register_all_services.cpp.mako +++ b/source/codegen/templates/register_all_services.cpp.mako @@ -17,7 +17,6 @@ repository_type_to_config = service_helpers.list_session_repository_handle_types #include #include -#include % for config in driver_configs: <% @@ -65,21 +64,6 @@ std::shared_ptr>> register_all_services( feature_toggles)); \ % endfor -% if any(config.get("has_moniker_streaming_apis", False) for config in driver_configs): - if (ni::data_monikers::is_sideband_streaming_enabled(feature_toggles)) { -% for driver in drivers: -<% - config = driver["config"] - namespace = f"{config['namespace_component']}_grpc" -%>\ -% if config.get("has_moniker_streaming_apis", False): -<%block filter="common_helpers.os_conditional_compile_block(config)">\ - ${namespace}::RegisterMonikerEndpoints(); -\ -% endif -% endfor - } -% endif return service_vector; } diff --git a/source/codegen/templates/service_registrar.cpp.mako b/source/codegen/templates/service_registrar.cpp.mako index f35f4dfd7..2dcfdf22a 100644 --- a/source/codegen/templates/service_registrar.cpp.mako +++ b/source/codegen/templates/service_registrar.cpp.mako @@ -21,6 +21,9 @@ service_class_prefix = config["service_class_prefix"] #include "${module_name}_service.h" #include "${module_name}_service_registrar.h" +% if config.get("has_moniker_streaming_apis", False): +#include +% endif namespace ${namespace} { @@ -43,6 +46,18 @@ std::shared_ptr register_service( % endfor toggles); builder.RegisterService(service.get()); +% if config.get("has_moniker_streaming_apis", False): + + if (ni::data_monikers::is_sideband_streaming_enabled(feature_toggles)) { +<% + namespace = f"{config['namespace_component']}_grpc" +%>\ +<%block filter="common_helpers.os_conditional_compile_block(config)">\ + ${namespace}::RegisterMonikerEndpoints(); +\ + } + +% endif return service; } From 0dd6460e7bb3d09a87dab126b77bfe273522c923 Mon Sep 17 00:00:00 2001 From: Ayush Mehra Date: Mon, 11 Nov 2024 19:32:35 -0800 Subject: [PATCH 33/34] remove unused code --- generated/register_all_services.cpp | 1 - source/codegen/templates/register_all_services.cpp.mako | 3 --- source/server/data_moniker_service.cpp | 1 + 3 files changed, 1 insertion(+), 4 deletions(-) diff --git a/generated/register_all_services.cpp b/generated/register_all_services.cpp index 093feeb5e..f361574be 100644 --- a/generated/register_all_services.cpp +++ b/generated/register_all_services.cpp @@ -17,7 +17,6 @@ #include "nidmm/nidmm_service_registrar.h" #include "nifgen/nifgen_service_registrar.h" #include "nifpga/nifpga_service_registrar.h" -#include "nifpga/nifpga_service.h" #if defined(_MSC_VER) #include "nimxlcterminaladaptor_restricted/nimxlcterminaladaptor_restricted_service_registrar.h" #endif // defined(_MSC_VER) diff --git a/source/codegen/templates/register_all_services.cpp.mako b/source/codegen/templates/register_all_services.cpp.mako index a716cb633..5c9eb493f 100644 --- a/source/codegen/templates/register_all_services.cpp.mako +++ b/source/codegen/templates/register_all_services.cpp.mako @@ -24,9 +24,6 @@ repository_type_to_config = service_helpers.list_session_repository_handle_types %>\ <%block filter="common_helpers.os_conditional_compile_block(config)">\ #include "${module_name}/${module_name}_service_registrar.h" -% if config.get("has_moniker_streaming_apis", False): -#include "${module_name}/${module_name}_service.h" -% endif \ % endfor diff --git a/source/server/data_moniker_service.cpp b/source/server/data_moniker_service.cpp index 88470b3a6..60066c9cc 100644 --- a/source/server/data_moniker_service.cpp +++ b/source/server/data_moniker_service.cpp @@ -168,6 +168,7 @@ Status DataMonikerService::BeginSidebandStream(ServerContext* context, const Beg char identifier[32] = {}; InitOwnerSidebandData(strategy, bufferSize, identifier); + response->set_strategy(request->strategy()); response->set_sideband_identifier(identifier); response->set_connection_url(GetConnectionAddress(strategy)); From 81e05ec7fef901005bf31c41d44f285abc0b7857 Mon Sep 17 00:00:00 2001 From: Ayush Mehra Date: Mon, 11 Nov 2024 20:05:31 -0800 Subject: [PATCH 34/34] revert register_all_services.cpp.mako --- generated/register_all_services.cpp | 2 +- source/codegen/templates/register_all_services.cpp.mako | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/generated/register_all_services.cpp b/generated/register_all_services.cpp index f361574be..e3fd95720 100644 --- a/generated/register_all_services.cpp +++ b/generated/register_all_services.cpp @@ -331,4 +331,4 @@ std::shared_ptr>> register_all_services( return service_vector; } -} // nidevice_grpc \ No newline at end of file +} // nidevice_grpc diff --git a/source/codegen/templates/register_all_services.cpp.mako b/source/codegen/templates/register_all_services.cpp.mako index 5c9eb493f..83bb672a0 100644 --- a/source/codegen/templates/register_all_services.cpp.mako +++ b/source/codegen/templates/register_all_services.cpp.mako @@ -65,4 +65,4 @@ std::shared_ptr>> register_all_services( return service_vector; } -} // nidevice_grpc \ No newline at end of file +} // nidevice_grpc