From 4f6e50c2306e66fff2f8b388f69de1cff39d57a2 Mon Sep 17 00:00:00 2001 From: Rohan Doshi Date: Tue, 26 Nov 2024 17:02:48 +0530 Subject: [PATCH] Moniker streaming functions return standard reponse message instead of custom data type (#1122) ### What does this Pull Request accomplish? - Values returned from streaming APIs are now in `StreamingResponse` message. - Most of the custom codegen written for Moniker APIs was needed because output was not in standard "response" message. With this change, I was able to delete most of the custom codegen written for streaming functionality. ### Why should this Pull Request be merged? Moniker functions used for streaming data to/from clients used to return custom data types defined in `custom_proto.mako` file for DAQ and FPGA. This has multiple limitations. - The custom types had only one field `value` for streaming. Read APIs with multiple out parameters need multiple values in response. - Response was not provided in standard `Response` message that other grpc APIs use. ### What testing has been done? - Existing integration tests for FPGA streaming APIs pass. - Executed sample client tests with StreamRead/StreamWrite and validated results. --- generated/nidaqmx/nidaqmx.proto | 170 ++++ generated/nidaqmx/nidaqmx_service.cpp | 644 +++++++----- generated/nifpga/nifpga.proto | 286 ++++++ generated/nifpga/nifpga_service.cpp | 943 +++++++++++------- source/codegen/common_helpers.py | 73 +- source/codegen/service_helpers.py | 29 +- source/codegen/templates/proto.mako | 4 + source/codegen/templates/proto_helpers.mako | 25 + source/codegen/templates/service.cpp.mako | 16 +- source/codegen/templates/service_helpers.mako | 335 +++---- .../ni_fake_fpga_streaming_tests.cpp | 40 +- 11 files changed, 1652 insertions(+), 913 deletions(-) diff --git a/generated/nidaqmx/nidaqmx.proto b/generated/nidaqmx/nidaqmx.proto index 7e726dc5b..53f244e73 100644 --- a/generated/nidaqmx/nidaqmx.proto +++ b/generated/nidaqmx/nidaqmx.proto @@ -8518,6 +8518,12 @@ message BeginReadAnalogF64Response { ni.data_monikers.Moniker moniker = 2; } +message ReadAnalogF64StreamingResponse { + int32 status = 1; + repeated double read_array = 2; + int32 samps_per_chan_read = 3; +} + message ReadAnalogScalarF64Request { nidevice_grpc.Session task = 1; double timeout = 2; @@ -8538,6 +8544,11 @@ message BeginReadAnalogScalarF64Response { ni.data_monikers.Moniker moniker = 2; } +message ReadAnalogScalarF64StreamingResponse { + int32 status = 1; + double value = 2; +} + message ReadBinaryI16Request { nidevice_grpc.Session task = 1; int32 num_samps_per_chan = 2; @@ -8571,6 +8582,12 @@ message BeginReadBinaryI16Response { ni.data_monikers.Moniker moniker = 2; } +message ReadBinaryI16StreamingResponse { + int32 status = 1; + repeated int32 read_array = 2; + int32 samps_per_chan_read = 3; +} + message ReadBinaryI32Request { nidevice_grpc.Session task = 1; int32 num_samps_per_chan = 2; @@ -8604,6 +8621,12 @@ message BeginReadBinaryI32Response { ni.data_monikers.Moniker moniker = 2; } +message ReadBinaryI32StreamingResponse { + int32 status = 1; + repeated int32 read_array = 2; + int32 samps_per_chan_read = 3; +} + message ReadBinaryU16Request { nidevice_grpc.Session task = 1; int32 num_samps_per_chan = 2; @@ -8637,6 +8660,12 @@ message BeginReadBinaryU16Response { ni.data_monikers.Moniker moniker = 2; } +message ReadBinaryU16StreamingResponse { + int32 status = 1; + repeated uint32 read_array = 2; + int32 samps_per_chan_read = 3; +} + message ReadBinaryU32Request { nidevice_grpc.Session task = 1; int32 num_samps_per_chan = 2; @@ -8670,6 +8699,12 @@ message BeginReadBinaryU32Response { ni.data_monikers.Moniker moniker = 2; } +message ReadBinaryU32StreamingResponse { + int32 status = 1; + repeated uint32 read_array = 2; + int32 samps_per_chan_read = 3; +} + message ReadCounterF64Request { nidevice_grpc.Session task = 1; int32 num_samps_per_chan = 2; @@ -8695,6 +8730,12 @@ message BeginReadCounterF64Response { ni.data_monikers.Moniker moniker = 2; } +message ReadCounterF64StreamingResponse { + int32 status = 1; + repeated double read_array = 2; + int32 samps_per_chan_read = 3; +} + message ReadCounterF64ExRequest { nidevice_grpc.Session task = 1; int32 num_samps_per_chan = 2; @@ -8728,6 +8769,12 @@ message BeginReadCounterF64ExResponse { ni.data_monikers.Moniker moniker = 2; } +message ReadCounterF64ExStreamingResponse { + int32 status = 1; + repeated double read_array = 2; + int32 samps_per_chan_read = 3; +} + message ReadCounterScalarF64Request { nidevice_grpc.Session task = 1; double timeout = 2; @@ -8748,6 +8795,11 @@ message BeginReadCounterScalarF64Response { ni.data_monikers.Moniker moniker = 2; } +message ReadCounterScalarF64StreamingResponse { + int32 status = 1; + double value = 2; +} + message ReadCounterScalarU32Request { nidevice_grpc.Session task = 1; double timeout = 2; @@ -8768,6 +8820,11 @@ message BeginReadCounterScalarU32Response { ni.data_monikers.Moniker moniker = 2; } +message ReadCounterScalarU32StreamingResponse { + int32 status = 1; + uint32 value = 2; +} + message ReadCounterU32Request { nidevice_grpc.Session task = 1; int32 num_samps_per_chan = 2; @@ -8793,6 +8850,12 @@ message BeginReadCounterU32Response { ni.data_monikers.Moniker moniker = 2; } +message ReadCounterU32StreamingResponse { + int32 status = 1; + repeated uint32 read_array = 2; + int32 samps_per_chan_read = 3; +} + message ReadCounterU32ExRequest { nidevice_grpc.Session task = 1; int32 num_samps_per_chan = 2; @@ -8826,6 +8889,12 @@ message BeginReadCounterU32ExResponse { ni.data_monikers.Moniker moniker = 2; } +message ReadCounterU32ExStreamingResponse { + int32 status = 1; + repeated uint32 read_array = 2; + int32 samps_per_chan_read = 3; +} + message ReadCtrFreqRequest { nidevice_grpc.Session task = 1; int32 num_samps_per_chan = 2; @@ -8951,6 +9020,11 @@ message BeginReadDigitalScalarU32Response { ni.data_monikers.Moniker moniker = 2; } +message ReadDigitalScalarU32StreamingResponse { + int32 status = 1; + uint32 value = 2; +} + message ReadDigitalU16Request { nidevice_grpc.Session task = 1; int32 num_samps_per_chan = 2; @@ -8984,6 +9058,12 @@ message BeginReadDigitalU16Response { ni.data_monikers.Moniker moniker = 2; } +message ReadDigitalU16StreamingResponse { + int32 status = 1; + repeated uint32 read_array = 2; + int32 samps_per_chan_read = 3; +} + message ReadDigitalU32Request { nidevice_grpc.Session task = 1; int32 num_samps_per_chan = 2; @@ -9017,6 +9097,12 @@ message BeginReadDigitalU32Response { ni.data_monikers.Moniker moniker = 2; } +message ReadDigitalU32StreamingResponse { + int32 status = 1; + repeated uint32 read_array = 2; + int32 samps_per_chan_read = 3; +} + message ReadDigitalU8Request { nidevice_grpc.Session task = 1; int32 num_samps_per_chan = 2; @@ -10405,6 +10491,11 @@ message BeginWaitForNextSampleClockResponse { ni.data_monikers.Moniker moniker = 2; } +message WaitForNextSampleClockStreamingResponse { + int32 status = 1; + bool is_late = 2; +} + message WaitForValidTimestampRequest { nidevice_grpc.Session task = 1; oneof timestamp_event_enum { @@ -10461,6 +10552,15 @@ message BeginWriteAnalogF64Response { ni.data_monikers.Moniker moniker = 2; } +message WriteAnalogF64StreamingRequest { + repeated double write_array = 1; +} + +message WriteAnalogF64StreamingResponse { + int32 status = 1; + int32 samps_per_chan_written = 2; +} + message WriteAnalogScalarF64Request { nidevice_grpc.Session task = 1; bool auto_start = 2; @@ -10483,6 +10583,14 @@ message BeginWriteAnalogScalarF64Response { ni.data_monikers.Moniker moniker = 2; } +message WriteAnalogScalarF64StreamingRequest { + double value = 1; +} + +message WriteAnalogScalarF64StreamingResponse { + int32 status = 1; +} + message WriteBinaryI16Request { nidevice_grpc.Session task = 1; int32 num_samps_per_chan = 2; @@ -10516,6 +10624,15 @@ message BeginWriteBinaryI16Response { ni.data_monikers.Moniker moniker = 2; } +message WriteBinaryI16StreamingRequest { + repeated int32 write_array = 1; +} + +message WriteBinaryI16StreamingResponse { + int32 status = 1; + int32 samps_per_chan_written = 2; +} + message WriteBinaryI32Request { nidevice_grpc.Session task = 1; int32 num_samps_per_chan = 2; @@ -10549,6 +10666,15 @@ message BeginWriteBinaryI32Response { ni.data_monikers.Moniker moniker = 2; } +message WriteBinaryI32StreamingRequest { + repeated int32 write_array = 1; +} + +message WriteBinaryI32StreamingResponse { + int32 status = 1; + int32 samps_per_chan_written = 2; +} + message WriteBinaryU16Request { nidevice_grpc.Session task = 1; int32 num_samps_per_chan = 2; @@ -10582,6 +10708,15 @@ message BeginWriteBinaryU16Response { ni.data_monikers.Moniker moniker = 2; } +message WriteBinaryU16StreamingRequest { + repeated uint32 write_array = 1; +} + +message WriteBinaryU16StreamingResponse { + int32 status = 1; + int32 samps_per_chan_written = 2; +} + message WriteBinaryU32Request { nidevice_grpc.Session task = 1; int32 num_samps_per_chan = 2; @@ -10615,6 +10750,15 @@ message BeginWriteBinaryU32Response { ni.data_monikers.Moniker moniker = 2; } +message WriteBinaryU32StreamingRequest { + repeated uint32 write_array = 1; +} + +message WriteBinaryU32StreamingResponse { + int32 status = 1; + int32 samps_per_chan_written = 2; +} + message WriteCtrFreqRequest { nidevice_grpc.Session task = 1; int32 num_samps_per_chan = 2; @@ -10744,6 +10888,14 @@ message BeginWriteDigitalScalarU32Response { ni.data_monikers.Moniker moniker = 2; } +message WriteDigitalScalarU32StreamingRequest { + uint32 value = 1; +} + +message WriteDigitalScalarU32StreamingResponse { + int32 status = 1; +} + message WriteDigitalU16Request { nidevice_grpc.Session task = 1; int32 num_samps_per_chan = 2; @@ -10777,6 +10929,15 @@ message BeginWriteDigitalU16Response { ni.data_monikers.Moniker moniker = 2; } +message WriteDigitalU16StreamingRequest { + repeated uint32 write_array = 1; +} + +message WriteDigitalU16StreamingResponse { + int32 status = 1; + int32 samps_per_chan_written = 2; +} + message WriteDigitalU32Request { nidevice_grpc.Session task = 1; int32 num_samps_per_chan = 2; @@ -10810,6 +10971,15 @@ message BeginWriteDigitalU32Response { ni.data_monikers.Moniker moniker = 2; } +message WriteDigitalU32StreamingRequest { + repeated uint32 write_array = 1; +} + +message WriteDigitalU32StreamingResponse { + int32 status = 1; + int32 samps_per_chan_written = 2; +} + message WriteDigitalU8Request { nidevice_grpc.Session task = 1; int32 num_samps_per_chan = 2; diff --git a/generated/nidaqmx/nidaqmx_service.cpp b/generated/nidaqmx/nidaqmx_service.cpp index 1acd25300..fc96c1d36 100644 --- a/generated/nidaqmx/nidaqmx_service.cpp +++ b/generated/nidaqmx/nidaqmx_service.cpp @@ -33,7 +33,7 @@ namespace nidaqmx_grpc { int32 fill_mode; uInt32 array_size_in_samps; bool32* reserved; - nidaqmx_grpc::ArrayDoubleData data; + nidaqmx_grpc::ReadAnalogF64StreamingResponse response; std::shared_ptr library; }; @@ -42,7 +42,7 @@ namespace nidaqmx_grpc { TaskHandle task; float64 timeout; bool32* reserved; - nidaqmx_grpc::DoubleData data; + nidaqmx_grpc::ReadAnalogScalarF64StreamingResponse response; std::shared_ptr library; }; @@ -54,7 +54,7 @@ namespace nidaqmx_grpc { int32 fill_mode; uInt32 array_size_in_samps; bool32* reserved; - nidaqmx_grpc::ArrayI16Data data; + nidaqmx_grpc::ReadBinaryI16StreamingResponse response; std::shared_ptr library; }; @@ -66,7 +66,7 @@ namespace nidaqmx_grpc { int32 fill_mode; uInt32 array_size_in_samps; bool32* reserved; - nidaqmx_grpc::ArrayI32Data data; + nidaqmx_grpc::ReadBinaryI32StreamingResponse response; std::shared_ptr library; }; @@ -78,7 +78,7 @@ namespace nidaqmx_grpc { int32 fill_mode; uInt32 array_size_in_samps; bool32* reserved; - nidaqmx_grpc::ArrayU16Data data; + nidaqmx_grpc::ReadBinaryU16StreamingResponse response; std::shared_ptr library; }; @@ -90,7 +90,7 @@ namespace nidaqmx_grpc { int32 fill_mode; uInt32 array_size_in_samps; bool32* reserved; - nidaqmx_grpc::ArrayU32Data data; + nidaqmx_grpc::ReadBinaryU32StreamingResponse response; std::shared_ptr library; }; @@ -101,7 +101,7 @@ namespace nidaqmx_grpc { float64 timeout; uInt32 array_size_in_samps; bool32* reserved; - nidaqmx_grpc::ArrayDoubleData data; + nidaqmx_grpc::ReadCounterF64StreamingResponse response; std::shared_ptr library; }; @@ -113,7 +113,7 @@ namespace nidaqmx_grpc { int32 fill_mode; uInt32 array_size_in_samps; bool32* reserved; - nidaqmx_grpc::ArrayDoubleData data; + nidaqmx_grpc::ReadCounterF64ExStreamingResponse response; std::shared_ptr library; }; @@ -122,7 +122,7 @@ namespace nidaqmx_grpc { TaskHandle task; float64 timeout; bool32* reserved; - nidaqmx_grpc::DoubleData data; + nidaqmx_grpc::ReadCounterScalarF64StreamingResponse response; std::shared_ptr library; }; @@ -131,7 +131,7 @@ namespace nidaqmx_grpc { TaskHandle task; float64 timeout; bool32* reserved; - nidaqmx_grpc::U32Data data; + nidaqmx_grpc::ReadCounterScalarU32StreamingResponse response; std::shared_ptr library; }; @@ -142,7 +142,7 @@ namespace nidaqmx_grpc { float64 timeout; uInt32 array_size_in_samps; bool32* reserved; - nidaqmx_grpc::ArrayU32Data data; + nidaqmx_grpc::ReadCounterU32StreamingResponse response; std::shared_ptr library; }; @@ -154,7 +154,7 @@ namespace nidaqmx_grpc { int32 fill_mode; uInt32 array_size_in_samps; bool32* reserved; - nidaqmx_grpc::ArrayU32Data data; + nidaqmx_grpc::ReadCounterU32ExStreamingResponse response; std::shared_ptr library; }; @@ -163,7 +163,7 @@ namespace nidaqmx_grpc { TaskHandle task; float64 timeout; bool32* reserved; - nidaqmx_grpc::U32Data data; + nidaqmx_grpc::ReadDigitalScalarU32StreamingResponse response; std::shared_ptr library; }; @@ -175,7 +175,7 @@ namespace nidaqmx_grpc { int32 fill_mode; uInt32 array_size_in_samps; bool32* reserved; - nidaqmx_grpc::ArrayU16Data data; + nidaqmx_grpc::ReadDigitalU16StreamingResponse response; std::shared_ptr library; }; @@ -187,7 +187,7 @@ namespace nidaqmx_grpc { int32 fill_mode; uInt32 array_size_in_samps; bool32* reserved; - nidaqmx_grpc::ArrayU32Data data; + nidaqmx_grpc::ReadDigitalU32StreamingResponse response; std::shared_ptr library; }; @@ -195,7 +195,7 @@ namespace nidaqmx_grpc { { TaskHandle task; float64 timeout; - nidaqmx_grpc::BoolData data; + nidaqmx_grpc::WaitForNextSampleClockStreamingResponse response; std::shared_ptr library; }; @@ -207,7 +207,8 @@ namespace nidaqmx_grpc { float64 timeout; int32 data_layout; bool32* reserved; - nidaqmx_grpc::ArrayDoubleData data; + nidaqmx_grpc::WriteAnalogF64StreamingRequest request; + nidaqmx_grpc::WriteAnalogF64StreamingResponse response; std::shared_ptr library; }; @@ -217,7 +218,8 @@ namespace nidaqmx_grpc { bool32 auto_start; float64 timeout; bool32* reserved; - nidaqmx_grpc::DoubleData data; + nidaqmx_grpc::WriteAnalogScalarF64StreamingRequest request; + nidaqmx_grpc::WriteAnalogScalarF64StreamingResponse response; std::shared_ptr library; }; @@ -229,7 +231,8 @@ namespace nidaqmx_grpc { float64 timeout; int32 data_layout; bool32* reserved; - nidaqmx_grpc::ArrayI16Data data; + nidaqmx_grpc::WriteBinaryI16StreamingRequest request; + nidaqmx_grpc::WriteBinaryI16StreamingResponse response; std::shared_ptr library; }; @@ -241,7 +244,8 @@ namespace nidaqmx_grpc { float64 timeout; int32 data_layout; bool32* reserved; - nidaqmx_grpc::ArrayI32Data data; + nidaqmx_grpc::WriteBinaryI32StreamingRequest request; + nidaqmx_grpc::WriteBinaryI32StreamingResponse response; std::shared_ptr library; }; @@ -253,7 +257,8 @@ namespace nidaqmx_grpc { float64 timeout; int32 data_layout; bool32* reserved; - nidaqmx_grpc::ArrayU16Data data; + nidaqmx_grpc::WriteBinaryU16StreamingRequest request; + nidaqmx_grpc::WriteBinaryU16StreamingResponse response; std::shared_ptr library; }; @@ -265,7 +270,8 @@ namespace nidaqmx_grpc { float64 timeout; int32 data_layout; bool32* reserved; - nidaqmx_grpc::ArrayU32Data data; + nidaqmx_grpc::WriteBinaryU32StreamingRequest request; + nidaqmx_grpc::WriteBinaryU32StreamingResponse response; std::shared_ptr library; }; @@ -275,7 +281,8 @@ namespace nidaqmx_grpc { bool32 auto_start; float64 timeout; bool32* reserved; - nidaqmx_grpc::U32Data data; + nidaqmx_grpc::WriteDigitalScalarU32StreamingRequest request; + nidaqmx_grpc::WriteDigitalScalarU32StreamingResponse response; std::shared_ptr library; }; @@ -287,7 +294,8 @@ namespace nidaqmx_grpc { float64 timeout; int32 data_layout; bool32* reserved; - nidaqmx_grpc::ArrayU16Data data; + nidaqmx_grpc::WriteDigitalU16StreamingRequest request; + nidaqmx_grpc::WriteDigitalU16StreamingResponse response; std::shared_ptr library; }; @@ -299,7 +307,8 @@ namespace nidaqmx_grpc { float64 timeout; int32 data_layout; bool32* reserved; - nidaqmx_grpc::ArrayU32Data data; + nidaqmx_grpc::WriteDigitalU32StreamingRequest request; + nidaqmx_grpc::WriteDigitalU32StreamingResponse response; std::shared_ptr library; }; @@ -359,23 +368,28 @@ ::grpc::Status MonikerReadAnalogF64(void* data, google::protobuf::Arena& arena, { MonikerReadAnalogF64Data* function_data = static_cast(data); auto library = function_data->library; + auto response = &function_data->response; auto task = function_data->task; auto num_samps_per_chan = function_data->num_samps_per_chan; auto timeout = function_data->timeout; auto fill_mode = function_data->fill_mode; auto array_size_in_samps = function_data->array_size_in_samps; auto reserved = function_data->reserved; + response->mutable_read_array()->Resize(array_size_in_samps, 0); + float64* read_array = response->mutable_read_array()->mutable_data(); + int32 samps_per_chan_read {}; - int32 samps_per_chan_read = {}; - function_data->data.mutable_value()->Resize(array_size_in_samps, 0); - auto read_array = function_data->data.mutable_value()->mutable_data(); auto status = library->ReadAnalogF64(task, num_samps_per_chan, timeout, fill_mode, read_array, array_size_in_samps, &samps_per_chan_read, reserved); - if (status >= 0) { - packedData.PackFrom(function_data->data); - } - if (status < 0) { - std::cout << "MonikerReadAnalogF64 error: " << status << std::endl; + if (status >= 0) + { + response->set_status(status); + response->set_samps_per_chan_read(samps_per_chan_read); + packedData.PackFrom(*response); + } + else + { + return ::grpc::Status(grpc::StatusCode::UNKNOWN, "ni-error: " + status); } return ::grpc::Status::OK; } @@ -384,19 +398,23 @@ ::grpc::Status MonikerReadAnalogScalarF64(void* data, google::protobuf::Arena& a { MonikerReadAnalogScalarF64Data* function_data = static_cast(data); auto library = function_data->library; + auto response = &function_data->response; auto task = function_data->task; auto timeout = function_data->timeout; auto reserved = function_data->reserved; - float64 value {}; + auto status = library->ReadAnalogScalarF64(task, timeout, &value, reserved); - function_data->data.set_value(value); - if (status >= 0) { - packedData.PackFrom(function_data->data); - } - if (status < 0) { - std::cout << "MonikerReadAnalogScalarF64 error: " << status << std::endl; + if (status >= 0) + { + response->set_status(status); + response->set_value(value); + packedData.PackFrom(*response); + } + else + { + return ::grpc::Status(grpc::StatusCode::UNKNOWN, "ni-error: " + status); } return ::grpc::Status::OK; } @@ -405,29 +423,36 @@ ::grpc::Status MonikerReadBinaryI16(void* data, google::protobuf::Arena& arena, { MonikerReadBinaryI16Data* function_data = static_cast(data); auto library = function_data->library; + auto response = &function_data->response; auto task = function_data->task; auto num_samps_per_chan = function_data->num_samps_per_chan; auto timeout = function_data->timeout; auto fill_mode = function_data->fill_mode; auto array_size_in_samps = function_data->array_size_in_samps; auto reserved = function_data->reserved; - - int32 samps_per_chan_read = {}; std::vector read_array(array_size_in_samps); + int32 samps_per_chan_read {}; + auto status = library->ReadBinaryI16(task, num_samps_per_chan, timeout, fill_mode, read_array.data(), array_size_in_samps, &samps_per_chan_read, reserved); - if (status >= 0) { - std::transform( - read_array.begin(), - read_array.begin() + array_size_in_samps, - function_data->data.mutable_value()->begin(), - [&](auto x) { - return x; - }); - packedData.PackFrom(function_data->data); - } - if (status < 0) { - std::cout << "MonikerReadBinaryI16 error: " << status << std::endl; + if (status >= 0) + { + response->set_status(status); + response->mutable_read_array()->Clear(); + response->mutable_read_array()->Reserve(array_size_in_samps); + std::transform( + read_array.begin(), + read_array.begin() + array_size_in_samps, + google::protobuf::RepeatedFieldBackInserter(response->mutable_read_array()), + [&](auto x) { + return x; + }); + response->set_samps_per_chan_read(samps_per_chan_read); + packedData.PackFrom(*response); + } + else + { + return ::grpc::Status(grpc::StatusCode::UNKNOWN, "ni-error: " + status); } return ::grpc::Status::OK; } @@ -436,23 +461,28 @@ ::grpc::Status MonikerReadBinaryI32(void* data, google::protobuf::Arena& arena, { MonikerReadBinaryI32Data* function_data = static_cast(data); auto library = function_data->library; + auto response = &function_data->response; auto task = function_data->task; auto num_samps_per_chan = function_data->num_samps_per_chan; auto timeout = function_data->timeout; auto fill_mode = function_data->fill_mode; auto array_size_in_samps = function_data->array_size_in_samps; auto reserved = function_data->reserved; + response->mutable_read_array()->Resize(array_size_in_samps, 0); + int32* read_array = reinterpret_cast(response->mutable_read_array()->mutable_data()); + int32 samps_per_chan_read {}; - int32 samps_per_chan_read = {}; - function_data->data.mutable_value()->Resize(array_size_in_samps, 0); - auto read_array = reinterpret_cast(function_data->data.mutable_value()->mutable_data()); auto status = library->ReadBinaryI32(task, num_samps_per_chan, timeout, fill_mode, read_array, array_size_in_samps, &samps_per_chan_read, reserved); - if (status >= 0) { - packedData.PackFrom(function_data->data); - } - if (status < 0) { - std::cout << "MonikerReadBinaryI32 error: " << status << std::endl; + if (status >= 0) + { + response->set_status(status); + response->set_samps_per_chan_read(samps_per_chan_read); + packedData.PackFrom(*response); + } + else + { + return ::grpc::Status(grpc::StatusCode::UNKNOWN, "ni-error: " + status); } return ::grpc::Status::OK; } @@ -461,29 +491,36 @@ ::grpc::Status MonikerReadBinaryU16(void* data, google::protobuf::Arena& arena, { MonikerReadBinaryU16Data* function_data = static_cast(data); auto library = function_data->library; + auto response = &function_data->response; auto task = function_data->task; auto num_samps_per_chan = function_data->num_samps_per_chan; auto timeout = function_data->timeout; auto fill_mode = function_data->fill_mode; auto array_size_in_samps = function_data->array_size_in_samps; auto reserved = function_data->reserved; - - int32 samps_per_chan_read = {}; std::vector read_array(array_size_in_samps); + int32 samps_per_chan_read {}; + auto status = library->ReadBinaryU16(task, num_samps_per_chan, timeout, fill_mode, read_array.data(), array_size_in_samps, &samps_per_chan_read, reserved); - if (status >= 0) { - std::transform( - read_array.begin(), - read_array.begin() + array_size_in_samps, - function_data->data.mutable_value()->begin(), - [&](auto x) { - return x; - }); - packedData.PackFrom(function_data->data); - } - if (status < 0) { - std::cout << "MonikerReadBinaryU16 error: " << status << std::endl; + if (status >= 0) + { + response->set_status(status); + response->mutable_read_array()->Clear(); + response->mutable_read_array()->Reserve(array_size_in_samps); + std::transform( + read_array.begin(), + read_array.begin() + array_size_in_samps, + google::protobuf::RepeatedFieldBackInserter(response->mutable_read_array()), + [&](auto x) { + return x; + }); + response->set_samps_per_chan_read(samps_per_chan_read); + packedData.PackFrom(*response); + } + else + { + return ::grpc::Status(grpc::StatusCode::UNKNOWN, "ni-error: " + status); } return ::grpc::Status::OK; } @@ -492,23 +529,28 @@ ::grpc::Status MonikerReadBinaryU32(void* data, google::protobuf::Arena& arena, { MonikerReadBinaryU32Data* function_data = static_cast(data); auto library = function_data->library; + auto response = &function_data->response; auto task = function_data->task; auto num_samps_per_chan = function_data->num_samps_per_chan; auto timeout = function_data->timeout; auto fill_mode = function_data->fill_mode; auto array_size_in_samps = function_data->array_size_in_samps; auto reserved = function_data->reserved; + response->mutable_read_array()->Resize(array_size_in_samps, 0); + uInt32* read_array = reinterpret_cast(response->mutable_read_array()->mutable_data()); + int32 samps_per_chan_read {}; - int32 samps_per_chan_read = {}; - function_data->data.mutable_value()->Resize(array_size_in_samps, 0); - auto read_array = reinterpret_cast(function_data->data.mutable_value()->mutable_data()); auto status = library->ReadBinaryU32(task, num_samps_per_chan, timeout, fill_mode, read_array, array_size_in_samps, &samps_per_chan_read, reserved); - if (status >= 0) { - packedData.PackFrom(function_data->data); - } - if (status < 0) { - std::cout << "MonikerReadBinaryU32 error: " << status << std::endl; + if (status >= 0) + { + response->set_status(status); + response->set_samps_per_chan_read(samps_per_chan_read); + packedData.PackFrom(*response); + } + else + { + return ::grpc::Status(grpc::StatusCode::UNKNOWN, "ni-error: " + status); } return ::grpc::Status::OK; } @@ -517,22 +559,27 @@ ::grpc::Status MonikerReadCounterF64(void* data, google::protobuf::Arena& arena, { MonikerReadCounterF64Data* function_data = static_cast(data); auto library = function_data->library; + auto response = &function_data->response; auto task = function_data->task; auto num_samps_per_chan = function_data->num_samps_per_chan; auto timeout = function_data->timeout; auto array_size_in_samps = function_data->array_size_in_samps; auto reserved = function_data->reserved; + response->mutable_read_array()->Resize(array_size_in_samps, 0); + float64* read_array = response->mutable_read_array()->mutable_data(); + int32 samps_per_chan_read {}; - int32 samps_per_chan_read = {}; - function_data->data.mutable_value()->Resize(array_size_in_samps, 0); - auto read_array = function_data->data.mutable_value()->mutable_data(); auto status = library->ReadCounterF64(task, num_samps_per_chan, timeout, read_array, array_size_in_samps, &samps_per_chan_read, reserved); - if (status >= 0) { - packedData.PackFrom(function_data->data); - } - if (status < 0) { - std::cout << "MonikerReadCounterF64 error: " << status << std::endl; + if (status >= 0) + { + response->set_status(status); + response->set_samps_per_chan_read(samps_per_chan_read); + packedData.PackFrom(*response); + } + else + { + return ::grpc::Status(grpc::StatusCode::UNKNOWN, "ni-error: " + status); } return ::grpc::Status::OK; } @@ -541,23 +588,28 @@ ::grpc::Status MonikerReadCounterF64Ex(void* data, google::protobuf::Arena& aren { MonikerReadCounterF64ExData* function_data = static_cast(data); auto library = function_data->library; + auto response = &function_data->response; auto task = function_data->task; auto num_samps_per_chan = function_data->num_samps_per_chan; auto timeout = function_data->timeout; auto fill_mode = function_data->fill_mode; auto array_size_in_samps = function_data->array_size_in_samps; auto reserved = function_data->reserved; + response->mutable_read_array()->Resize(array_size_in_samps, 0); + float64* read_array = response->mutable_read_array()->mutable_data(); + int32 samps_per_chan_read {}; - int32 samps_per_chan_read = {}; - function_data->data.mutable_value()->Resize(array_size_in_samps, 0); - auto read_array = function_data->data.mutable_value()->mutable_data(); auto status = library->ReadCounterF64Ex(task, num_samps_per_chan, timeout, fill_mode, read_array, array_size_in_samps, &samps_per_chan_read, reserved); - if (status >= 0) { - packedData.PackFrom(function_data->data); - } - if (status < 0) { - std::cout << "MonikerReadCounterF64Ex error: " << status << std::endl; + if (status >= 0) + { + response->set_status(status); + response->set_samps_per_chan_read(samps_per_chan_read); + packedData.PackFrom(*response); + } + else + { + return ::grpc::Status(grpc::StatusCode::UNKNOWN, "ni-error: " + status); } return ::grpc::Status::OK; } @@ -566,19 +618,23 @@ ::grpc::Status MonikerReadCounterScalarF64(void* data, google::protobuf::Arena& { MonikerReadCounterScalarF64Data* function_data = static_cast(data); auto library = function_data->library; + auto response = &function_data->response; auto task = function_data->task; auto timeout = function_data->timeout; auto reserved = function_data->reserved; - float64 value {}; + auto status = library->ReadCounterScalarF64(task, timeout, &value, reserved); - function_data->data.set_value(value); - if (status >= 0) { - packedData.PackFrom(function_data->data); - } - if (status < 0) { - std::cout << "MonikerReadCounterScalarF64 error: " << status << std::endl; + if (status >= 0) + { + response->set_status(status); + response->set_value(value); + packedData.PackFrom(*response); + } + else + { + return ::grpc::Status(grpc::StatusCode::UNKNOWN, "ni-error: " + status); } return ::grpc::Status::OK; } @@ -587,19 +643,23 @@ ::grpc::Status MonikerReadCounterScalarU32(void* data, google::protobuf::Arena& { MonikerReadCounterScalarU32Data* function_data = static_cast(data); auto library = function_data->library; + auto response = &function_data->response; auto task = function_data->task; auto timeout = function_data->timeout; auto reserved = function_data->reserved; - uInt32 value {}; + auto status = library->ReadCounterScalarU32(task, timeout, &value, reserved); - function_data->data.set_value(value); - if (status >= 0) { - packedData.PackFrom(function_data->data); - } - if (status < 0) { - std::cout << "MonikerReadCounterScalarU32 error: " << status << std::endl; + if (status >= 0) + { + response->set_status(status); + response->set_value(value); + packedData.PackFrom(*response); + } + else + { + return ::grpc::Status(grpc::StatusCode::UNKNOWN, "ni-error: " + status); } return ::grpc::Status::OK; } @@ -608,22 +668,27 @@ ::grpc::Status MonikerReadCounterU32(void* data, google::protobuf::Arena& arena, { MonikerReadCounterU32Data* function_data = static_cast(data); auto library = function_data->library; + auto response = &function_data->response; auto task = function_data->task; auto num_samps_per_chan = function_data->num_samps_per_chan; auto timeout = function_data->timeout; auto array_size_in_samps = function_data->array_size_in_samps; auto reserved = function_data->reserved; + response->mutable_read_array()->Resize(array_size_in_samps, 0); + uInt32* read_array = reinterpret_cast(response->mutable_read_array()->mutable_data()); + int32 samps_per_chan_read {}; - int32 samps_per_chan_read = {}; - function_data->data.mutable_value()->Resize(array_size_in_samps, 0); - auto read_array = reinterpret_cast(function_data->data.mutable_value()->mutable_data()); auto status = library->ReadCounterU32(task, num_samps_per_chan, timeout, read_array, array_size_in_samps, &samps_per_chan_read, reserved); - if (status >= 0) { - packedData.PackFrom(function_data->data); - } - if (status < 0) { - std::cout << "MonikerReadCounterU32 error: " << status << std::endl; + if (status >= 0) + { + response->set_status(status); + response->set_samps_per_chan_read(samps_per_chan_read); + packedData.PackFrom(*response); + } + else + { + return ::grpc::Status(grpc::StatusCode::UNKNOWN, "ni-error: " + status); } return ::grpc::Status::OK; } @@ -632,23 +697,28 @@ ::grpc::Status MonikerReadCounterU32Ex(void* data, google::protobuf::Arena& aren { MonikerReadCounterU32ExData* function_data = static_cast(data); auto library = function_data->library; + auto response = &function_data->response; auto task = function_data->task; auto num_samps_per_chan = function_data->num_samps_per_chan; auto timeout = function_data->timeout; auto fill_mode = function_data->fill_mode; auto array_size_in_samps = function_data->array_size_in_samps; auto reserved = function_data->reserved; + response->mutable_read_array()->Resize(array_size_in_samps, 0); + uInt32* read_array = reinterpret_cast(response->mutable_read_array()->mutable_data()); + int32 samps_per_chan_read {}; - int32 samps_per_chan_read = {}; - function_data->data.mutable_value()->Resize(array_size_in_samps, 0); - auto read_array = reinterpret_cast(function_data->data.mutable_value()->mutable_data()); auto status = library->ReadCounterU32Ex(task, num_samps_per_chan, timeout, fill_mode, read_array, array_size_in_samps, &samps_per_chan_read, reserved); - if (status >= 0) { - packedData.PackFrom(function_data->data); - } - if (status < 0) { - std::cout << "MonikerReadCounterU32Ex error: " << status << std::endl; + if (status >= 0) + { + response->set_status(status); + response->set_samps_per_chan_read(samps_per_chan_read); + packedData.PackFrom(*response); + } + else + { + return ::grpc::Status(grpc::StatusCode::UNKNOWN, "ni-error: " + status); } return ::grpc::Status::OK; } @@ -657,19 +727,23 @@ ::grpc::Status MonikerReadDigitalScalarU32(void* data, google::protobuf::Arena& { MonikerReadDigitalScalarU32Data* function_data = static_cast(data); auto library = function_data->library; + auto response = &function_data->response; auto task = function_data->task; auto timeout = function_data->timeout; auto reserved = function_data->reserved; - uInt32 value {}; + auto status = library->ReadDigitalScalarU32(task, timeout, &value, reserved); - function_data->data.set_value(value); - if (status >= 0) { - packedData.PackFrom(function_data->data); - } - if (status < 0) { - std::cout << "MonikerReadDigitalScalarU32 error: " << status << std::endl; + if (status >= 0) + { + response->set_status(status); + response->set_value(value); + packedData.PackFrom(*response); + } + else + { + return ::grpc::Status(grpc::StatusCode::UNKNOWN, "ni-error: " + status); } return ::grpc::Status::OK; } @@ -678,29 +752,36 @@ ::grpc::Status MonikerReadDigitalU16(void* data, google::protobuf::Arena& arena, { MonikerReadDigitalU16Data* function_data = static_cast(data); auto library = function_data->library; + auto response = &function_data->response; auto task = function_data->task; auto num_samps_per_chan = function_data->num_samps_per_chan; auto timeout = function_data->timeout; auto fill_mode = function_data->fill_mode; auto array_size_in_samps = function_data->array_size_in_samps; auto reserved = function_data->reserved; - - int32 samps_per_chan_read = {}; std::vector read_array(array_size_in_samps); + int32 samps_per_chan_read {}; + auto status = library->ReadDigitalU16(task, num_samps_per_chan, timeout, fill_mode, read_array.data(), array_size_in_samps, &samps_per_chan_read, reserved); - if (status >= 0) { - std::transform( - read_array.begin(), - read_array.begin() + array_size_in_samps, - function_data->data.mutable_value()->begin(), - [&](auto x) { - return x; - }); - packedData.PackFrom(function_data->data); - } - if (status < 0) { - std::cout << "MonikerReadDigitalU16 error: " << status << std::endl; + if (status >= 0) + { + response->set_status(status); + response->mutable_read_array()->Clear(); + response->mutable_read_array()->Reserve(array_size_in_samps); + std::transform( + read_array.begin(), + read_array.begin() + array_size_in_samps, + google::protobuf::RepeatedFieldBackInserter(response->mutable_read_array()), + [&](auto x) { + return x; + }); + response->set_samps_per_chan_read(samps_per_chan_read); + packedData.PackFrom(*response); + } + else + { + return ::grpc::Status(grpc::StatusCode::UNKNOWN, "ni-error: " + status); } return ::grpc::Status::OK; } @@ -709,23 +790,28 @@ ::grpc::Status MonikerReadDigitalU32(void* data, google::protobuf::Arena& arena, { MonikerReadDigitalU32Data* function_data = static_cast(data); auto library = function_data->library; + auto response = &function_data->response; auto task = function_data->task; auto num_samps_per_chan = function_data->num_samps_per_chan; auto timeout = function_data->timeout; auto fill_mode = function_data->fill_mode; auto array_size_in_samps = function_data->array_size_in_samps; auto reserved = function_data->reserved; + response->mutable_read_array()->Resize(array_size_in_samps, 0); + uInt32* read_array = reinterpret_cast(response->mutable_read_array()->mutable_data()); + int32 samps_per_chan_read {}; - int32 samps_per_chan_read = {}; - function_data->data.mutable_value()->Resize(array_size_in_samps, 0); - auto read_array = reinterpret_cast(function_data->data.mutable_value()->mutable_data()); auto status = library->ReadDigitalU32(task, num_samps_per_chan, timeout, fill_mode, read_array, array_size_in_samps, &samps_per_chan_read, reserved); - if (status >= 0) { - packedData.PackFrom(function_data->data); - } - if (status < 0) { - std::cout << "MonikerReadDigitalU32 error: " << status << std::endl; + if (status >= 0) + { + response->set_status(status); + response->set_samps_per_chan_read(samps_per_chan_read); + packedData.PackFrom(*response); + } + else + { + return ::grpc::Status(grpc::StatusCode::UNKNOWN, "ni-error: " + status); } return ::grpc::Status::OK; } @@ -734,18 +820,22 @@ ::grpc::Status MonikerWaitForNextSampleClock(void* data, google::protobuf::Arena { MonikerWaitForNextSampleClockData* function_data = static_cast(data); auto library = function_data->library; + auto response = &function_data->response; auto task = function_data->task; auto timeout = function_data->timeout; - bool32 is_late {}; + auto status = library->WaitForNextSampleClock(task, timeout, &is_late); - function_data->data.set_value(is_late); - if (status >= 0) { - packedData.PackFrom(function_data->data); - } - if (status < 0) { - std::cout << "MonikerWaitForNextSampleClock error: " << status << std::endl; + if (status >= 0) + { + response->set_status(status); + response->set_is_late(is_late); + packedData.PackFrom(*response); + } + else + { + return ::grpc::Status(grpc::StatusCode::UNKNOWN, "ni-error: " + status); } return ::grpc::Status::OK; } @@ -754,14 +844,15 @@ ::grpc::Status MonikerWriteAnalogF64(void* data, google::protobuf::Arena& arena, { MonikerWriteAnalogF64Data* function_data = static_cast(data); auto library = function_data->library; + auto response = &function_data->response; auto task = function_data->task; auto num_samps_per_chan = function_data->num_samps_per_chan; auto auto_start = function_data->auto_start; auto timeout = function_data->timeout; auto data_layout = function_data->data_layout; auto reserved = function_data->reserved; + int32 samps_per_chan_written {}; - int32 samps_per_chan_written = {}; ArrayDoubleData arraydoubledata_message; packedData.UnpackTo(&arraydoubledata_message); @@ -770,8 +861,10 @@ ::grpc::Status MonikerWriteAnalogF64(void* data, google::protobuf::Arena& arena, auto size = data_array.size(); auto status = library->WriteAnalogF64(task, num_samps_per_chan, auto_start, timeout, data_layout, write_array, &samps_per_chan_written, reserved); - if (status < 0) { - std::cout << "MonikerWriteAnalogF64 error: " << status << std::endl; + + if (status < 0) + { + return ::grpc::Status(grpc::StatusCode::UNKNOWN, "ni-error: " + status); } return ::grpc::Status::OK; } @@ -780,6 +873,7 @@ ::grpc::Status MonikerWriteAnalogScalarF64(void* data, google::protobuf::Arena& { MonikerWriteAnalogScalarF64Data* function_data = static_cast(data); auto library = function_data->library; + auto response = &function_data->response; auto task = function_data->task; auto auto_start = function_data->auto_start; auto timeout = function_data->timeout; @@ -790,8 +884,10 @@ ::grpc::Status MonikerWriteAnalogScalarF64(void* data, google::protobuf::Arena& auto value = doubledata_message.value(); auto status = library->WriteAnalogScalarF64(task, auto_start, timeout, value, reserved); - if (status < 0) { - std::cout << "MonikerWriteAnalogScalarF64 error: " << status << std::endl; + + if (status < 0) + { + return ::grpc::Status(grpc::StatusCode::UNKNOWN, "ni-error: " + status); } return ::grpc::Status::OK; } @@ -800,14 +896,15 @@ ::grpc::Status MonikerWriteBinaryI16(void* data, google::protobuf::Arena& arena, { MonikerWriteBinaryI16Data* function_data = static_cast(data); auto library = function_data->library; + auto response = &function_data->response; auto task = function_data->task; auto num_samps_per_chan = function_data->num_samps_per_chan; auto auto_start = function_data->auto_start; auto timeout = function_data->timeout; auto data_layout = function_data->data_layout; auto reserved = function_data->reserved; + int32 samps_per_chan_written {}; - int32 samps_per_chan_written = {}; ArrayI16Data arrayi16data_message; packedData.UnpackTo(&arrayi16data_message); @@ -828,8 +925,10 @@ ::grpc::Status MonikerWriteBinaryI16(void* data, google::protobuf::Arena& arena, }); auto status = library->WriteBinaryI16(task, num_samps_per_chan, auto_start, timeout, data_layout, write_array.data(), &samps_per_chan_written, reserved); - if (status < 0) { - std::cout << "MonikerWriteBinaryI16 error: " << status << std::endl; + + if (status < 0) + { + return ::grpc::Status(grpc::StatusCode::UNKNOWN, "ni-error: " + status); } return ::grpc::Status::OK; } @@ -838,14 +937,15 @@ ::grpc::Status MonikerWriteBinaryI32(void* data, google::protobuf::Arena& arena, { MonikerWriteBinaryI32Data* function_data = static_cast(data); auto library = function_data->library; + auto response = &function_data->response; auto task = function_data->task; auto num_samps_per_chan = function_data->num_samps_per_chan; auto auto_start = function_data->auto_start; auto timeout = function_data->timeout; auto data_layout = function_data->data_layout; auto reserved = function_data->reserved; + int32 samps_per_chan_written {}; - int32 samps_per_chan_written = {}; ArrayI32Data arrayi32data_message; packedData.UnpackTo(&arrayi32data_message); @@ -854,8 +954,10 @@ ::grpc::Status MonikerWriteBinaryI32(void* data, google::protobuf::Arena& arena, auto size = data_array.size(); auto status = library->WriteBinaryI32(task, num_samps_per_chan, auto_start, timeout, data_layout, write_array, &samps_per_chan_written, reserved); - if (status < 0) { - std::cout << "MonikerWriteBinaryI32 error: " << status << std::endl; + + if (status < 0) + { + return ::grpc::Status(grpc::StatusCode::UNKNOWN, "ni-error: " + status); } return ::grpc::Status::OK; } @@ -864,14 +966,15 @@ ::grpc::Status MonikerWriteBinaryU16(void* data, google::protobuf::Arena& arena, { MonikerWriteBinaryU16Data* function_data = static_cast(data); auto library = function_data->library; + auto response = &function_data->response; auto task = function_data->task; auto num_samps_per_chan = function_data->num_samps_per_chan; auto auto_start = function_data->auto_start; auto timeout = function_data->timeout; auto data_layout = function_data->data_layout; auto reserved = function_data->reserved; + int32 samps_per_chan_written {}; - int32 samps_per_chan_written = {}; ArrayU16Data arrayu16data_message; packedData.UnpackTo(&arrayu16data_message); @@ -892,8 +995,10 @@ ::grpc::Status MonikerWriteBinaryU16(void* data, google::protobuf::Arena& arena, }); auto status = library->WriteBinaryU16(task, num_samps_per_chan, auto_start, timeout, data_layout, write_array.data(), &samps_per_chan_written, reserved); - if (status < 0) { - std::cout << "MonikerWriteBinaryU16 error: " << status << std::endl; + + if (status < 0) + { + return ::grpc::Status(grpc::StatusCode::UNKNOWN, "ni-error: " + status); } return ::grpc::Status::OK; } @@ -902,14 +1007,15 @@ ::grpc::Status MonikerWriteBinaryU32(void* data, google::protobuf::Arena& arena, { MonikerWriteBinaryU32Data* function_data = static_cast(data); auto library = function_data->library; + auto response = &function_data->response; auto task = function_data->task; auto num_samps_per_chan = function_data->num_samps_per_chan; auto auto_start = function_data->auto_start; auto timeout = function_data->timeout; auto data_layout = function_data->data_layout; auto reserved = function_data->reserved; + int32 samps_per_chan_written {}; - int32 samps_per_chan_written = {}; ArrayU32Data arrayu32data_message; packedData.UnpackTo(&arrayu32data_message); @@ -918,8 +1024,10 @@ ::grpc::Status MonikerWriteBinaryU32(void* data, google::protobuf::Arena& arena, auto size = data_array.size(); auto status = library->WriteBinaryU32(task, num_samps_per_chan, auto_start, timeout, data_layout, write_array, &samps_per_chan_written, reserved); - if (status < 0) { - std::cout << "MonikerWriteBinaryU32 error: " << status << std::endl; + + if (status < 0) + { + return ::grpc::Status(grpc::StatusCode::UNKNOWN, "ni-error: " + status); } return ::grpc::Status::OK; } @@ -928,6 +1036,7 @@ ::grpc::Status MonikerWriteDigitalScalarU32(void* data, google::protobuf::Arena& { MonikerWriteDigitalScalarU32Data* function_data = static_cast(data); auto library = function_data->library; + auto response = &function_data->response; auto task = function_data->task; auto auto_start = function_data->auto_start; auto timeout = function_data->timeout; @@ -938,8 +1047,10 @@ ::grpc::Status MonikerWriteDigitalScalarU32(void* data, google::protobuf::Arena& auto value = u32data_message.value(); auto status = library->WriteDigitalScalarU32(task, auto_start, timeout, value, reserved); - if (status < 0) { - std::cout << "MonikerWriteDigitalScalarU32 error: " << status << std::endl; + + if (status < 0) + { + return ::grpc::Status(grpc::StatusCode::UNKNOWN, "ni-error: " + status); } return ::grpc::Status::OK; } @@ -948,14 +1059,15 @@ ::grpc::Status MonikerWriteDigitalU16(void* data, google::protobuf::Arena& arena { MonikerWriteDigitalU16Data* function_data = static_cast(data); auto library = function_data->library; + auto response = &function_data->response; auto task = function_data->task; auto num_samps_per_chan = function_data->num_samps_per_chan; auto auto_start = function_data->auto_start; auto timeout = function_data->timeout; auto data_layout = function_data->data_layout; auto reserved = function_data->reserved; + int32 samps_per_chan_written {}; - int32 samps_per_chan_written = {}; ArrayU16Data arrayu16data_message; packedData.UnpackTo(&arrayu16data_message); @@ -976,8 +1088,10 @@ ::grpc::Status MonikerWriteDigitalU16(void* data, google::protobuf::Arena& arena }); auto status = library->WriteDigitalU16(task, num_samps_per_chan, auto_start, timeout, data_layout, write_array.data(), &samps_per_chan_written, reserved); - if (status < 0) { - std::cout << "MonikerWriteDigitalU16 error: " << status << std::endl; + + if (status < 0) + { + return ::grpc::Status(grpc::StatusCode::UNKNOWN, "ni-error: " + status); } return ::grpc::Status::OK; } @@ -986,14 +1100,15 @@ ::grpc::Status MonikerWriteDigitalU32(void* data, google::protobuf::Arena& arena { MonikerWriteDigitalU32Data* function_data = static_cast(data); auto library = function_data->library; + auto response = &function_data->response; auto task = function_data->task; auto num_samps_per_chan = function_data->num_samps_per_chan; auto auto_start = function_data->auto_start; auto timeout = function_data->timeout; auto data_layout = function_data->data_layout; auto reserved = function_data->reserved; + int32 samps_per_chan_written {}; - int32 samps_per_chan_written = {}; ArrayU32Data arrayu32data_message; packedData.UnpackTo(&arrayu32data_message); @@ -1002,11 +1117,14 @@ ::grpc::Status MonikerWriteDigitalU32(void* data, google::protobuf::Arena& arena auto size = data_array.size(); auto status = library->WriteDigitalU32(task, num_samps_per_chan, auto_start, timeout, data_layout, write_array, &samps_per_chan_written, reserved); - if (status < 0) { - std::cout << "MonikerWriteDigitalU32 error: " << status << std::endl; + + if (status < 0) + { + return ::grpc::Status(grpc::StatusCode::UNKNOWN, "ni-error: " + status); } return ::grpc::Status::OK; } + //--------------------------------------------------------------------- //--------------------------------------------------------------------- ::grpc::Status NiDAQmxService::AddCDAQSyncConnection(::grpc::ServerContext* context, const AddCDAQSyncConnectionRequest* request, AddCDAQSyncConnectionResponse* response) @@ -14198,7 +14316,7 @@ ::grpc::Status MonikerWriteDigitalU32(void* data, google::protobuf::Arena& arena uInt32 array_size_in_samps = request->array_size_in_samps(); auto reserved = nullptr; - auto data = std::make_unique(); + auto data = std::make_unique(); data->task = task; data->num_samps_per_chan = num_samps_per_chan; data->timeout = timeout; @@ -14206,9 +14324,9 @@ ::grpc::Status MonikerWriteDigitalU32(void* data, google::protobuf::Arena& arena data->array_size_in_samps = array_size_in_samps; data->reserved = reserved; data->library = std::shared_ptr(library_); - - data->data.mutable_value()->Reserve(request->array_size_in_samps()); - data->data.mutable_value()->Resize(request->array_size_in_samps(), 0); + + data->response.mutable_read_array()->Reserve(request->array_size_in_samps()); + data->response.mutable_read_array()->Resize(request->array_size_in_samps(), 0); auto moniker = std::make_unique(); ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerReadAnalogF64", data.release(), *moniker); response->set_allocated_moniker(moniker.release()); @@ -14259,12 +14377,12 @@ ::grpc::Status MonikerWriteDigitalU32(void* data, google::protobuf::Arena& arena float64 timeout = request->timeout(); auto reserved = nullptr; - auto data = std::make_unique(); + auto data = std::make_unique(); data->task = task; data->timeout = timeout; data->reserved = reserved; data->library = std::shared_ptr(library_); - + auto moniker = std::make_unique(); ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerReadAnalogScalarF64", data.release(), *moniker); response->set_allocated_moniker(moniker.release()); @@ -14362,7 +14480,7 @@ ::grpc::Status MonikerWriteDigitalU32(void* data, google::protobuf::Arena& arena uInt32 array_size_in_samps = request->array_size_in_samps(); auto reserved = nullptr; - auto data = std::make_unique(); + auto data = std::make_unique(); data->task = task; data->num_samps_per_chan = num_samps_per_chan; data->timeout = timeout; @@ -14370,9 +14488,9 @@ ::grpc::Status MonikerWriteDigitalU32(void* data, google::protobuf::Arena& arena data->array_size_in_samps = array_size_in_samps; data->reserved = reserved; data->library = std::shared_ptr(library_); - - data->data.mutable_value()->Reserve(request->array_size_in_samps()); - data->data.mutable_value()->Resize(request->array_size_in_samps(), 0); + + data->response.mutable_read_array()->Reserve(request->array_size_in_samps()); + data->response.mutable_read_array()->Resize(request->array_size_in_samps(), 0); auto moniker = std::make_unique(); ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerReadBinaryI16", data.release(), *moniker); response->set_allocated_moniker(moniker.release()); @@ -14462,7 +14580,7 @@ ::grpc::Status MonikerWriteDigitalU32(void* data, google::protobuf::Arena& arena uInt32 array_size_in_samps = request->array_size_in_samps(); auto reserved = nullptr; - auto data = std::make_unique(); + auto data = std::make_unique(); data->task = task; data->num_samps_per_chan = num_samps_per_chan; data->timeout = timeout; @@ -14470,9 +14588,9 @@ ::grpc::Status MonikerWriteDigitalU32(void* data, google::protobuf::Arena& arena data->array_size_in_samps = array_size_in_samps; data->reserved = reserved; data->library = std::shared_ptr(library_); - - data->data.mutable_value()->Reserve(request->array_size_in_samps()); - data->data.mutable_value()->Resize(request->array_size_in_samps(), 0); + + data->response.mutable_read_array()->Reserve(request->array_size_in_samps()); + data->response.mutable_read_array()->Resize(request->array_size_in_samps(), 0); auto moniker = std::make_unique(); ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerReadBinaryI32", data.release(), *moniker); response->set_allocated_moniker(moniker.release()); @@ -14570,7 +14688,7 @@ ::grpc::Status MonikerWriteDigitalU32(void* data, google::protobuf::Arena& arena uInt32 array_size_in_samps = request->array_size_in_samps(); auto reserved = nullptr; - auto data = std::make_unique(); + auto data = std::make_unique(); data->task = task; data->num_samps_per_chan = num_samps_per_chan; data->timeout = timeout; @@ -14578,9 +14696,9 @@ ::grpc::Status MonikerWriteDigitalU32(void* data, google::protobuf::Arena& arena data->array_size_in_samps = array_size_in_samps; data->reserved = reserved; data->library = std::shared_ptr(library_); - - data->data.mutable_value()->Reserve(request->array_size_in_samps()); - data->data.mutable_value()->Resize(request->array_size_in_samps(), 0); + + data->response.mutable_read_array()->Reserve(request->array_size_in_samps()); + data->response.mutable_read_array()->Resize(request->array_size_in_samps(), 0); auto moniker = std::make_unique(); ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerReadBinaryU16", data.release(), *moniker); response->set_allocated_moniker(moniker.release()); @@ -14670,7 +14788,7 @@ ::grpc::Status MonikerWriteDigitalU32(void* data, google::protobuf::Arena& arena uInt32 array_size_in_samps = request->array_size_in_samps(); auto reserved = nullptr; - auto data = std::make_unique(); + auto data = std::make_unique(); data->task = task; data->num_samps_per_chan = num_samps_per_chan; data->timeout = timeout; @@ -14678,9 +14796,9 @@ ::grpc::Status MonikerWriteDigitalU32(void* data, google::protobuf::Arena& arena data->array_size_in_samps = array_size_in_samps; data->reserved = reserved; data->library = std::shared_ptr(library_); - - data->data.mutable_value()->Reserve(request->array_size_in_samps()); - data->data.mutable_value()->Resize(request->array_size_in_samps(), 0); + + data->response.mutable_read_array()->Reserve(request->array_size_in_samps()); + data->response.mutable_read_array()->Resize(request->array_size_in_samps(), 0); auto moniker = std::make_unique(); ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerReadBinaryU32", data.release(), *moniker); response->set_allocated_moniker(moniker.release()); @@ -14738,16 +14856,16 @@ ::grpc::Status MonikerWriteDigitalU32(void* data, google::protobuf::Arena& arena uInt32 array_size_in_samps = request->array_size_in_samps(); auto reserved = nullptr; - auto data = std::make_unique(); + auto data = std::make_unique(); data->task = task; data->num_samps_per_chan = num_samps_per_chan; data->timeout = timeout; data->array_size_in_samps = array_size_in_samps; data->reserved = reserved; data->library = std::shared_ptr(library_); - - data->data.mutable_value()->Reserve(request->array_size_in_samps()); - data->data.mutable_value()->Resize(request->array_size_in_samps(), 0); + + data->response.mutable_read_array()->Reserve(request->array_size_in_samps()); + data->response.mutable_read_array()->Resize(request->array_size_in_samps(), 0); auto moniker = std::make_unique(); ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerReadCounterF64", data.release(), *moniker); response->set_allocated_moniker(moniker.release()); @@ -14837,7 +14955,7 @@ ::grpc::Status MonikerWriteDigitalU32(void* data, google::protobuf::Arena& arena uInt32 array_size_in_samps = request->array_size_in_samps(); auto reserved = nullptr; - auto data = std::make_unique(); + auto data = std::make_unique(); data->task = task; data->num_samps_per_chan = num_samps_per_chan; data->timeout = timeout; @@ -14845,9 +14963,9 @@ ::grpc::Status MonikerWriteDigitalU32(void* data, google::protobuf::Arena& arena data->array_size_in_samps = array_size_in_samps; data->reserved = reserved; data->library = std::shared_ptr(library_); - - data->data.mutable_value()->Reserve(request->array_size_in_samps()); - data->data.mutable_value()->Resize(request->array_size_in_samps(), 0); + + data->response.mutable_read_array()->Reserve(request->array_size_in_samps()); + data->response.mutable_read_array()->Resize(request->array_size_in_samps(), 0); auto moniker = std::make_unique(); ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerReadCounterF64Ex", data.release(), *moniker); response->set_allocated_moniker(moniker.release()); @@ -14898,12 +15016,12 @@ ::grpc::Status MonikerWriteDigitalU32(void* data, google::protobuf::Arena& arena float64 timeout = request->timeout(); auto reserved = nullptr; - auto data = std::make_unique(); + auto data = std::make_unique(); data->task = task; data->timeout = timeout; data->reserved = reserved; data->library = std::shared_ptr(library_); - + auto moniker = std::make_unique(); ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerReadCounterScalarF64", data.release(), *moniker); response->set_allocated_moniker(moniker.release()); @@ -14954,12 +15072,12 @@ ::grpc::Status MonikerWriteDigitalU32(void* data, google::protobuf::Arena& arena float64 timeout = request->timeout(); auto reserved = nullptr; - auto data = std::make_unique(); + auto data = std::make_unique(); data->task = task; data->timeout = timeout; data->reserved = reserved; data->library = std::shared_ptr(library_); - + auto moniker = std::make_unique(); ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerReadCounterScalarU32", data.release(), *moniker); response->set_allocated_moniker(moniker.release()); @@ -15017,16 +15135,16 @@ ::grpc::Status MonikerWriteDigitalU32(void* data, google::protobuf::Arena& arena uInt32 array_size_in_samps = request->array_size_in_samps(); auto reserved = nullptr; - auto data = std::make_unique(); + auto data = std::make_unique(); data->task = task; data->num_samps_per_chan = num_samps_per_chan; data->timeout = timeout; data->array_size_in_samps = array_size_in_samps; data->reserved = reserved; data->library = std::shared_ptr(library_); - - data->data.mutable_value()->Reserve(request->array_size_in_samps()); - data->data.mutable_value()->Resize(request->array_size_in_samps(), 0); + + data->response.mutable_read_array()->Reserve(request->array_size_in_samps()); + data->response.mutable_read_array()->Resize(request->array_size_in_samps(), 0); auto moniker = std::make_unique(); ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerReadCounterU32", data.release(), *moniker); response->set_allocated_moniker(moniker.release()); @@ -15116,7 +15234,7 @@ ::grpc::Status MonikerWriteDigitalU32(void* data, google::protobuf::Arena& arena uInt32 array_size_in_samps = request->array_size_in_samps(); auto reserved = nullptr; - auto data = std::make_unique(); + auto data = std::make_unique(); data->task = task; data->num_samps_per_chan = num_samps_per_chan; data->timeout = timeout; @@ -15124,9 +15242,9 @@ ::grpc::Status MonikerWriteDigitalU32(void* data, google::protobuf::Arena& arena data->array_size_in_samps = array_size_in_samps; data->reserved = reserved; data->library = std::shared_ptr(library_); - - data->data.mutable_value()->Reserve(request->array_size_in_samps()); - data->data.mutable_value()->Resize(request->array_size_in_samps(), 0); + + data->response.mutable_read_array()->Reserve(request->array_size_in_samps()); + data->response.mutable_read_array()->Resize(request->array_size_in_samps(), 0); auto moniker = std::make_unique(); ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerReadCounterU32Ex", data.release(), *moniker); response->set_allocated_moniker(moniker.release()); @@ -15457,12 +15575,12 @@ ::grpc::Status MonikerWriteDigitalU32(void* data, google::protobuf::Arena& arena float64 timeout = request->timeout(); auto reserved = nullptr; - auto data = std::make_unique(); + auto data = std::make_unique(); data->task = task; data->timeout = timeout; data->reserved = reserved; data->library = std::shared_ptr(library_); - + auto moniker = std::make_unique(); ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerReadDigitalScalarU32", data.release(), *moniker); response->set_allocated_moniker(moniker.release()); @@ -15560,7 +15678,7 @@ ::grpc::Status MonikerWriteDigitalU32(void* data, google::protobuf::Arena& arena uInt32 array_size_in_samps = request->array_size_in_samps(); auto reserved = nullptr; - auto data = std::make_unique(); + auto data = std::make_unique(); data->task = task; data->num_samps_per_chan = num_samps_per_chan; data->timeout = timeout; @@ -15568,9 +15686,9 @@ ::grpc::Status MonikerWriteDigitalU32(void* data, google::protobuf::Arena& arena data->array_size_in_samps = array_size_in_samps; data->reserved = reserved; data->library = std::shared_ptr(library_); - - data->data.mutable_value()->Reserve(request->array_size_in_samps()); - data->data.mutable_value()->Resize(request->array_size_in_samps(), 0); + + data->response.mutable_read_array()->Reserve(request->array_size_in_samps()); + data->response.mutable_read_array()->Resize(request->array_size_in_samps(), 0); auto moniker = std::make_unique(); ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerReadDigitalU16", data.release(), *moniker); response->set_allocated_moniker(moniker.release()); @@ -15660,7 +15778,7 @@ ::grpc::Status MonikerWriteDigitalU32(void* data, google::protobuf::Arena& arena uInt32 array_size_in_samps = request->array_size_in_samps(); auto reserved = nullptr; - auto data = std::make_unique(); + auto data = std::make_unique(); data->task = task; data->num_samps_per_chan = num_samps_per_chan; data->timeout = timeout; @@ -15668,9 +15786,9 @@ ::grpc::Status MonikerWriteDigitalU32(void* data, google::protobuf::Arena& arena data->array_size_in_samps = array_size_in_samps; data->reserved = reserved; data->library = std::shared_ptr(library_); - - data->data.mutable_value()->Reserve(request->array_size_in_samps()); - data->data.mutable_value()->Resize(request->array_size_in_samps(), 0); + + data->response.mutable_read_array()->Reserve(request->array_size_in_samps()); + data->response.mutable_read_array()->Resize(request->array_size_in_samps(), 0); auto moniker = std::make_unique(); ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerReadDigitalU32", data.release(), *moniker); response->set_allocated_moniker(moniker.release()); @@ -20197,11 +20315,11 @@ ::grpc::Status MonikerWriteDigitalU32(void* data, google::protobuf::Arena& arena TaskHandle task = session_repository_->access_session(task_grpc_session.name()); float64 timeout = request->timeout(); - auto data = std::make_unique(); + auto data = std::make_unique(); data->task = task; data->timeout = timeout; data->library = std::shared_ptr(library_); - + auto moniker = std::make_unique(); ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerWaitForNextSampleClock", data.release(), *moniker); response->set_allocated_moniker(moniker.release()); @@ -20354,7 +20472,7 @@ ::grpc::Status MonikerWriteDigitalU32(void* data, google::protobuf::Arena& arena auto reserved = nullptr; - auto data = std::make_unique(); + auto data = std::make_unique(); data->task = task; data->num_samps_per_chan = num_samps_per_chan; data->auto_start = auto_start; @@ -20362,7 +20480,7 @@ ::grpc::Status MonikerWriteDigitalU32(void* data, google::protobuf::Arena& arena data->data_layout = data_layout; data->reserved = reserved; data->library = std::shared_ptr(library_); - + auto moniker = std::make_unique(); ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerWriteAnalogF64", data.release(), *moniker); response->set_allocated_moniker(moniker.release()); @@ -20414,13 +20532,13 @@ ::grpc::Status MonikerWriteDigitalU32(void* data, google::protobuf::Arena& arena float64 timeout = request->timeout(); auto reserved = nullptr; - auto data = std::make_unique(); + auto data = std::make_unique(); data->task = task; data->auto_start = auto_start; data->timeout = timeout; data->reserved = reserved; data->library = std::shared_ptr(library_); - + auto moniker = std::make_unique(); ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerWriteAnalogScalarF64", data.release(), *moniker); response->set_allocated_moniker(moniker.release()); @@ -20526,7 +20644,7 @@ ::grpc::Status MonikerWriteDigitalU32(void* data, google::protobuf::Arena& arena auto reserved = nullptr; - auto data = std::make_unique(); + auto data = std::make_unique(); data->task = task; data->num_samps_per_chan = num_samps_per_chan; data->auto_start = auto_start; @@ -20534,7 +20652,7 @@ ::grpc::Status MonikerWriteDigitalU32(void* data, google::protobuf::Arena& arena data->data_layout = data_layout; data->reserved = reserved; data->library = std::shared_ptr(library_); - + auto moniker = std::make_unique(); ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerWriteBinaryI16", data.release(), *moniker); response->set_allocated_moniker(moniker.release()); @@ -20623,7 +20741,7 @@ ::grpc::Status MonikerWriteDigitalU32(void* data, google::protobuf::Arena& arena auto reserved = nullptr; - auto data = std::make_unique(); + auto data = std::make_unique(); data->task = task; data->num_samps_per_chan = num_samps_per_chan; data->auto_start = auto_start; @@ -20631,7 +20749,7 @@ ::grpc::Status MonikerWriteDigitalU32(void* data, google::protobuf::Arena& arena data->data_layout = data_layout; data->reserved = reserved; data->library = std::shared_ptr(library_); - + auto moniker = std::make_unique(); ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerWriteBinaryI32", data.release(), *moniker); response->set_allocated_moniker(moniker.release()); @@ -20737,7 +20855,7 @@ ::grpc::Status MonikerWriteDigitalU32(void* data, google::protobuf::Arena& arena auto reserved = nullptr; - auto data = std::make_unique(); + auto data = std::make_unique(); data->task = task; data->num_samps_per_chan = num_samps_per_chan; data->auto_start = auto_start; @@ -20745,7 +20863,7 @@ ::grpc::Status MonikerWriteDigitalU32(void* data, google::protobuf::Arena& arena data->data_layout = data_layout; data->reserved = reserved; data->library = std::shared_ptr(library_); - + auto moniker = std::make_unique(); ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerWriteBinaryU16", data.release(), *moniker); response->set_allocated_moniker(moniker.release()); @@ -20834,7 +20952,7 @@ ::grpc::Status MonikerWriteDigitalU32(void* data, google::protobuf::Arena& arena auto reserved = nullptr; - auto data = std::make_unique(); + auto data = std::make_unique(); data->task = task; data->num_samps_per_chan = num_samps_per_chan; data->auto_start = auto_start; @@ -20842,7 +20960,7 @@ ::grpc::Status MonikerWriteDigitalU32(void* data, google::protobuf::Arena& arena data->data_layout = data_layout; data->reserved = reserved; data->library = std::shared_ptr(library_); - + auto moniker = std::make_unique(); ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerWriteBinaryU32", data.release(), *moniker); response->set_allocated_moniker(moniker.release()); @@ -21162,13 +21280,13 @@ ::grpc::Status MonikerWriteDigitalU32(void* data, google::protobuf::Arena& arena float64 timeout = request->timeout(); auto reserved = nullptr; - auto data = std::make_unique(); + auto data = std::make_unique(); data->task = task; data->auto_start = auto_start; data->timeout = timeout; data->reserved = reserved; data->library = std::shared_ptr(library_); - + auto moniker = std::make_unique(); ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerWriteDigitalScalarU32", data.release(), *moniker); response->set_allocated_moniker(moniker.release()); @@ -21274,7 +21392,7 @@ ::grpc::Status MonikerWriteDigitalU32(void* data, google::protobuf::Arena& arena auto reserved = nullptr; - auto data = std::make_unique(); + auto data = std::make_unique(); data->task = task; data->num_samps_per_chan = num_samps_per_chan; data->auto_start = auto_start; @@ -21282,7 +21400,7 @@ ::grpc::Status MonikerWriteDigitalU32(void* data, google::protobuf::Arena& arena data->data_layout = data_layout; data->reserved = reserved; data->library = std::shared_ptr(library_); - + auto moniker = std::make_unique(); ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerWriteDigitalU16", data.release(), *moniker); response->set_allocated_moniker(moniker.release()); @@ -21371,7 +21489,7 @@ ::grpc::Status MonikerWriteDigitalU32(void* data, google::protobuf::Arena& arena auto reserved = nullptr; - auto data = std::make_unique(); + auto data = std::make_unique(); data->task = task; data->num_samps_per_chan = num_samps_per_chan; data->auto_start = auto_start; @@ -21379,7 +21497,7 @@ ::grpc::Status MonikerWriteDigitalU32(void* data, google::protobuf::Arena& arena data->data_layout = data_layout; data->reserved = reserved; data->library = std::shared_ptr(library_); - + auto moniker = std::make_unique(); ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerWriteDigitalU32", data.release(), *moniker); response->set_allocated_moniker(moniker.release()); diff --git a/generated/nifpga/nifpga.proto b/generated/nifpga/nifpga.proto index ecf2de121..70c1f74ad 100644 --- a/generated/nifpga/nifpga.proto +++ b/generated/nifpga/nifpga.proto @@ -502,6 +502,11 @@ message BeginReadArrayBoolResponse { ni.data_monikers.Moniker moniker = 2; } +message ReadArrayBoolStreamingResponse { + int32 status = 1; + repeated bool array = 2; +} + message ReadArrayDblRequest { nidevice_grpc.Session session = 1; uint32 indicator = 2; @@ -524,6 +529,11 @@ message BeginReadArrayDblResponse { ni.data_monikers.Moniker moniker = 2; } +message ReadArrayDblStreamingResponse { + int32 status = 1; + repeated double array = 2; +} + message ReadArrayI16Request { nidevice_grpc.Session session = 1; uint32 indicator = 2; @@ -546,6 +556,11 @@ message BeginReadArrayI16Response { ni.data_monikers.Moniker moniker = 2; } +message ReadArrayI16StreamingResponse { + int32 status = 1; + repeated int32 array = 2; +} + message ReadArrayI32Request { nidevice_grpc.Session session = 1; uint32 indicator = 2; @@ -568,6 +583,11 @@ message BeginReadArrayI32Response { ni.data_monikers.Moniker moniker = 2; } +message ReadArrayI32StreamingResponse { + int32 status = 1; + repeated int32 array = 2; +} + message ReadArrayI64Request { nidevice_grpc.Session session = 1; uint32 indicator = 2; @@ -590,6 +610,11 @@ message BeginReadArrayI64Response { ni.data_monikers.Moniker moniker = 2; } +message ReadArrayI64StreamingResponse { + int32 status = 1; + repeated int64 array = 2; +} + message ReadArrayI8Request { nidevice_grpc.Session session = 1; uint32 indicator = 2; @@ -612,6 +637,11 @@ message BeginReadArrayI8Response { ni.data_monikers.Moniker moniker = 2; } +message ReadArrayI8StreamingResponse { + int32 status = 1; + repeated int32 array = 2; +} + message ReadArraySglRequest { nidevice_grpc.Session session = 1; uint32 indicator = 2; @@ -634,6 +664,11 @@ message BeginReadArraySglResponse { ni.data_monikers.Moniker moniker = 2; } +message ReadArraySglStreamingResponse { + int32 status = 1; + repeated float array = 2; +} + message ReadArrayU16Request { nidevice_grpc.Session session = 1; uint32 indicator = 2; @@ -656,6 +691,11 @@ message BeginReadArrayU16Response { ni.data_monikers.Moniker moniker = 2; } +message ReadArrayU16StreamingResponse { + int32 status = 1; + repeated uint32 array = 2; +} + message ReadArrayU32Request { nidevice_grpc.Session session = 1; uint32 indicator = 2; @@ -678,6 +718,11 @@ message BeginReadArrayU32Response { ni.data_monikers.Moniker moniker = 2; } +message ReadArrayU32StreamingResponse { + int32 status = 1; + repeated uint32 array = 2; +} + message ReadArrayU64Request { nidevice_grpc.Session session = 1; uint32 indicator = 2; @@ -700,6 +745,11 @@ message BeginReadArrayU64Response { ni.data_monikers.Moniker moniker = 2; } +message ReadArrayU64StreamingResponse { + int32 status = 1; + repeated uint64 array = 2; +} + message ReadArrayU8Request { nidevice_grpc.Session session = 1; uint32 indicator = 2; @@ -722,6 +772,11 @@ message BeginReadArrayU8Response { ni.data_monikers.Moniker moniker = 2; } +message ReadArrayU8StreamingResponse { + int32 status = 1; + repeated uint32 array = 2; +} + message ReadBoolRequest { nidevice_grpc.Session session = 1; uint32 indicator = 2; @@ -742,6 +797,11 @@ message BeginReadBoolResponse { ni.data_monikers.Moniker moniker = 2; } +message ReadBoolStreamingResponse { + int32 status = 1; + bool value = 2; +} + message ReadDblRequest { nidevice_grpc.Session session = 1; uint32 indicator = 2; @@ -762,6 +822,11 @@ message BeginReadDblResponse { ni.data_monikers.Moniker moniker = 2; } +message ReadDblStreamingResponse { + int32 status = 1; + double value = 2; +} + message ReadFifoBoolRequest { nidevice_grpc.Session session = 1; uint32 fifo = 2; @@ -925,6 +990,11 @@ message BeginReadI16Response { ni.data_monikers.Moniker moniker = 2; } +message ReadI16StreamingResponse { + int32 status = 1; + int32 value = 2; +} + message ReadI32Request { nidevice_grpc.Session session = 1; uint32 indicator = 2; @@ -945,6 +1015,11 @@ message BeginReadI32Response { ni.data_monikers.Moniker moniker = 2; } +message ReadI32StreamingResponse { + int32 status = 1; + int32 value = 2; +} + message ReadI64Request { nidevice_grpc.Session session = 1; uint32 indicator = 2; @@ -965,6 +1040,11 @@ message BeginReadI64Response { ni.data_monikers.Moniker moniker = 2; } +message ReadI64StreamingResponse { + int32 status = 1; + int64 value = 2; +} + message ReadI8Request { nidevice_grpc.Session session = 1; uint32 indicator = 2; @@ -985,6 +1065,11 @@ message BeginReadI8Response { ni.data_monikers.Moniker moniker = 2; } +message ReadI8StreamingResponse { + int32 status = 1; + int32 value = 2; +} + message ReadSglRequest { nidevice_grpc.Session session = 1; uint32 indicator = 2; @@ -1005,6 +1090,11 @@ message BeginReadSglResponse { ni.data_monikers.Moniker moniker = 2; } +message ReadSglStreamingResponse { + int32 status = 1; + float value = 2; +} + message ReadU16Request { nidevice_grpc.Session session = 1; uint32 indicator = 2; @@ -1025,6 +1115,11 @@ message BeginReadU16Response { ni.data_monikers.Moniker moniker = 2; } +message ReadU16StreamingResponse { + int32 status = 1; + uint32 value = 2; +} + message ReadU32Request { nidevice_grpc.Session session = 1; uint32 indicator = 2; @@ -1045,6 +1140,11 @@ message BeginReadU32Response { ni.data_monikers.Moniker moniker = 2; } +message ReadU32StreamingResponse { + int32 status = 1; + uint32 value = 2; +} + message ReadU64Request { nidevice_grpc.Session session = 1; uint32 indicator = 2; @@ -1065,6 +1165,11 @@ message BeginReadU64Response { ni.data_monikers.Moniker moniker = 2; } +message ReadU64StreamingResponse { + int32 status = 1; + uint64 value = 2; +} + message ReadU8Request { nidevice_grpc.Session session = 1; uint32 indicator = 2; @@ -1085,6 +1190,11 @@ message BeginReadU8Response { ni.data_monikers.Moniker moniker = 2; } +message ReadU8StreamingResponse { + int32 status = 1; + uint32 value = 2; +} + message ReleaseFifoElementsRequest { nidevice_grpc.Session session = 1; uint32 fifo = 2; @@ -1230,6 +1340,14 @@ message BeginWriteArrayBoolResponse { ni.data_monikers.Moniker moniker = 2; } +message WriteArrayBoolStreamingRequest { + repeated bool array = 1; +} + +message WriteArrayBoolStreamingResponse { + int32 status = 1; +} + message WriteArrayDblRequest { nidevice_grpc.Session session = 1; uint32 control = 2; @@ -1250,6 +1368,14 @@ message BeginWriteArrayDblResponse { ni.data_monikers.Moniker moniker = 2; } +message WriteArrayDblStreamingRequest { + repeated double array = 1; +} + +message WriteArrayDblStreamingResponse { + int32 status = 1; +} + message WriteArrayI16Request { nidevice_grpc.Session session = 1; uint32 control = 2; @@ -1270,6 +1396,14 @@ message BeginWriteArrayI16Response { ni.data_monikers.Moniker moniker = 2; } +message WriteArrayI16StreamingRequest { + repeated int32 array = 1; +} + +message WriteArrayI16StreamingResponse { + int32 status = 1; +} + message WriteArrayI32Request { nidevice_grpc.Session session = 1; uint32 control = 2; @@ -1290,6 +1424,14 @@ message BeginWriteArrayI32Response { ni.data_monikers.Moniker moniker = 2; } +message WriteArrayI32StreamingRequest { + repeated int32 array = 1; +} + +message WriteArrayI32StreamingResponse { + int32 status = 1; +} + message WriteArrayI64Request { nidevice_grpc.Session session = 1; uint32 control = 2; @@ -1310,6 +1452,14 @@ message BeginWriteArrayI64Response { ni.data_monikers.Moniker moniker = 2; } +message WriteArrayI64StreamingRequest { + repeated int64 array = 1; +} + +message WriteArrayI64StreamingResponse { + int32 status = 1; +} + message WriteArrayI8Request { nidevice_grpc.Session session = 1; uint32 control = 2; @@ -1330,6 +1480,14 @@ message BeginWriteArrayI8Response { ni.data_monikers.Moniker moniker = 2; } +message WriteArrayI8StreamingRequest { + repeated int32 array = 1; +} + +message WriteArrayI8StreamingResponse { + int32 status = 1; +} + message WriteArraySglRequest { nidevice_grpc.Session session = 1; uint32 control = 2; @@ -1350,6 +1508,14 @@ message BeginWriteArraySglResponse { ni.data_monikers.Moniker moniker = 2; } +message WriteArraySglStreamingRequest { + repeated float array = 1; +} + +message WriteArraySglStreamingResponse { + int32 status = 1; +} + message WriteArrayU16Request { nidevice_grpc.Session session = 1; uint32 control = 2; @@ -1370,6 +1536,14 @@ message BeginWriteArrayU16Response { ni.data_monikers.Moniker moniker = 2; } +message WriteArrayU16StreamingRequest { + repeated uint32 array = 1; +} + +message WriteArrayU16StreamingResponse { + int32 status = 1; +} + message WriteArrayU32Request { nidevice_grpc.Session session = 1; uint32 control = 2; @@ -1390,6 +1564,14 @@ message BeginWriteArrayU32Response { ni.data_monikers.Moniker moniker = 2; } +message WriteArrayU32StreamingRequest { + repeated uint32 array = 1; +} + +message WriteArrayU32StreamingResponse { + int32 status = 1; +} + message WriteArrayU64Request { nidevice_grpc.Session session = 1; uint32 control = 2; @@ -1410,6 +1592,14 @@ message BeginWriteArrayU64Response { ni.data_monikers.Moniker moniker = 2; } +message WriteArrayU64StreamingRequest { + repeated uint64 array = 1; +} + +message WriteArrayU64StreamingResponse { + int32 status = 1; +} + message WriteArrayU8Request { nidevice_grpc.Session session = 1; uint32 control = 2; @@ -1430,6 +1620,14 @@ message BeginWriteArrayU8Response { ni.data_monikers.Moniker moniker = 2; } +message WriteArrayU8StreamingRequest { + repeated uint32 array = 1; +} + +message WriteArrayU8StreamingResponse { + int32 status = 1; +} + message WriteBoolRequest { nidevice_grpc.Session session = 1; uint32 control = 2; @@ -1450,6 +1648,14 @@ message BeginWriteBoolResponse { ni.data_monikers.Moniker moniker = 2; } +message WriteBoolStreamingRequest { + bool value = 1; +} + +message WriteBoolStreamingResponse { + int32 status = 1; +} + message WriteDblRequest { nidevice_grpc.Session session = 1; uint32 control = 2; @@ -1470,6 +1676,14 @@ message BeginWriteDblResponse { ni.data_monikers.Moniker moniker = 2; } +message WriteDblStreamingRequest { + double value = 1; +} + +message WriteDblStreamingResponse { + int32 status = 1; +} + message WriteFifoBoolRequest { nidevice_grpc.Session session = 1; uint32 fifo = 2; @@ -1622,6 +1836,14 @@ message BeginWriteI16Response { ni.data_monikers.Moniker moniker = 2; } +message WriteI16StreamingRequest { + int32 value = 1; +} + +message WriteI16StreamingResponse { + int32 status = 1; +} + message WriteI32Request { nidevice_grpc.Session session = 1; uint32 control = 2; @@ -1642,6 +1864,14 @@ message BeginWriteI32Response { ni.data_monikers.Moniker moniker = 2; } +message WriteI32StreamingRequest { + int32 value = 1; +} + +message WriteI32StreamingResponse { + int32 status = 1; +} + message WriteI64Request { nidevice_grpc.Session session = 1; uint32 control = 2; @@ -1662,6 +1892,14 @@ message BeginWriteI64Response { ni.data_monikers.Moniker moniker = 2; } +message WriteI64StreamingRequest { + int64 value = 1; +} + +message WriteI64StreamingResponse { + int32 status = 1; +} + message WriteI8Request { nidevice_grpc.Session session = 1; uint32 control = 2; @@ -1682,6 +1920,14 @@ message BeginWriteI8Response { ni.data_monikers.Moniker moniker = 2; } +message WriteI8StreamingRequest { + int32 value = 1; +} + +message WriteI8StreamingResponse { + int32 status = 1; +} + message WriteSglRequest { nidevice_grpc.Session session = 1; uint32 control = 2; @@ -1702,6 +1948,14 @@ message BeginWriteSglResponse { ni.data_monikers.Moniker moniker = 2; } +message WriteSglStreamingRequest { + float value = 1; +} + +message WriteSglStreamingResponse { + int32 status = 1; +} + message WriteU16Request { nidevice_grpc.Session session = 1; uint32 control = 2; @@ -1722,6 +1976,14 @@ message BeginWriteU16Response { ni.data_monikers.Moniker moniker = 2; } +message WriteU16StreamingRequest { + uint32 value = 1; +} + +message WriteU16StreamingResponse { + int32 status = 1; +} + message WriteU32Request { nidevice_grpc.Session session = 1; uint32 control = 2; @@ -1742,6 +2004,14 @@ message BeginWriteU32Response { ni.data_monikers.Moniker moniker = 2; } +message WriteU32StreamingRequest { + uint32 value = 1; +} + +message WriteU32StreamingResponse { + int32 status = 1; +} + message WriteU64Request { nidevice_grpc.Session session = 1; uint32 control = 2; @@ -1762,6 +2032,14 @@ message BeginWriteU64Response { ni.data_monikers.Moniker moniker = 2; } +message WriteU64StreamingRequest { + uint64 value = 1; +} + +message WriteU64StreamingResponse { + int32 status = 1; +} + message WriteU8Request { nidevice_grpc.Session session = 1; uint32 control = 2; @@ -1782,3 +2060,11 @@ message BeginWriteU8Response { ni.data_monikers.Moniker moniker = 2; } +message WriteU8StreamingRequest { + uint32 value = 1; +} + +message WriteU8StreamingResponse { + int32 status = 1; +} + diff --git a/generated/nifpga/nifpga_service.cpp b/generated/nifpga/nifpga_service.cpp index 86c5651cb..78671d3cc 100644 --- a/generated/nifpga/nifpga_service.cpp +++ b/generated/nifpga/nifpga_service.cpp @@ -27,7 +27,7 @@ namespace nifpga_grpc { NiFpga_Session session; uint32_t indicator; size_t size; - nifpga_grpc::ArrayBoolData data; + nifpga_grpc::ReadArrayBoolStreamingResponse response; std::shared_ptr library; }; @@ -36,7 +36,7 @@ namespace nifpga_grpc { NiFpga_Session session; uint32_t indicator; size_t size; - nifpga_grpc::ArrayDoubleData data; + nifpga_grpc::ReadArrayDblStreamingResponse response; std::shared_ptr library; }; @@ -45,7 +45,7 @@ namespace nifpga_grpc { NiFpga_Session session; uint32_t indicator; size_t size; - nifpga_grpc::ArrayI32Data data; + nifpga_grpc::ReadArrayI16StreamingResponse response; std::shared_ptr library; }; @@ -54,7 +54,7 @@ namespace nifpga_grpc { NiFpga_Session session; uint32_t indicator; size_t size; - nifpga_grpc::ArrayI32Data data; + nifpga_grpc::ReadArrayI32StreamingResponse response; std::shared_ptr library; }; @@ -63,7 +63,7 @@ namespace nifpga_grpc { NiFpga_Session session; uint32_t indicator; size_t size; - nifpga_grpc::ArrayI64Data data; + nifpga_grpc::ReadArrayI64StreamingResponse response; std::shared_ptr library; }; @@ -72,7 +72,7 @@ namespace nifpga_grpc { NiFpga_Session session; uint32_t indicator; size_t size; - nifpga_grpc::ArrayI32Data data; + nifpga_grpc::ReadArrayI8StreamingResponse response; std::shared_ptr library; }; @@ -81,7 +81,7 @@ namespace nifpga_grpc { NiFpga_Session session; uint32_t indicator; size_t size; - nifpga_grpc::ArrayFloatData data; + nifpga_grpc::ReadArraySglStreamingResponse response; std::shared_ptr library; }; @@ -90,7 +90,7 @@ namespace nifpga_grpc { NiFpga_Session session; uint32_t indicator; size_t size; - nifpga_grpc::ArrayU32Data data; + nifpga_grpc::ReadArrayU16StreamingResponse response; std::shared_ptr library; }; @@ -99,7 +99,7 @@ namespace nifpga_grpc { NiFpga_Session session; uint32_t indicator; size_t size; - nifpga_grpc::ArrayU32Data data; + nifpga_grpc::ReadArrayU32StreamingResponse response; std::shared_ptr library; }; @@ -108,7 +108,7 @@ namespace nifpga_grpc { NiFpga_Session session; uint32_t indicator; size_t size; - nifpga_grpc::ArrayU64Data data; + nifpga_grpc::ReadArrayU64StreamingResponse response; std::shared_ptr library; }; @@ -117,7 +117,7 @@ namespace nifpga_grpc { NiFpga_Session session; uint32_t indicator; size_t size; - nifpga_grpc::ArrayU32Data data; + nifpga_grpc::ReadArrayU8StreamingResponse response; std::shared_ptr library; }; @@ -125,7 +125,7 @@ namespace nifpga_grpc { { NiFpga_Session session; uint32_t indicator; - nifpga_grpc::BoolData data; + nifpga_grpc::ReadBoolStreamingResponse response; std::shared_ptr library; }; @@ -133,7 +133,7 @@ namespace nifpga_grpc { { NiFpga_Session session; uint32_t indicator; - nifpga_grpc::DoubleData data; + nifpga_grpc::ReadDblStreamingResponse response; std::shared_ptr library; }; @@ -141,7 +141,7 @@ namespace nifpga_grpc { { NiFpga_Session session; uint32_t indicator; - nifpga_grpc::I32Data data; + nifpga_grpc::ReadI16StreamingResponse response; std::shared_ptr library; }; @@ -149,7 +149,7 @@ namespace nifpga_grpc { { NiFpga_Session session; uint32_t indicator; - nifpga_grpc::I32Data data; + nifpga_grpc::ReadI32StreamingResponse response; std::shared_ptr library; }; @@ -157,7 +157,7 @@ namespace nifpga_grpc { { NiFpga_Session session; uint32_t indicator; - nifpga_grpc::I64Data data; + nifpga_grpc::ReadI64StreamingResponse response; std::shared_ptr library; }; @@ -165,7 +165,7 @@ namespace nifpga_grpc { { NiFpga_Session session; uint32_t indicator; - nifpga_grpc::I32Data data; + nifpga_grpc::ReadI8StreamingResponse response; std::shared_ptr library; }; @@ -173,7 +173,7 @@ namespace nifpga_grpc { { NiFpga_Session session; uint32_t indicator; - nifpga_grpc::FloatData data; + nifpga_grpc::ReadSglStreamingResponse response; std::shared_ptr library; }; @@ -181,7 +181,7 @@ namespace nifpga_grpc { { NiFpga_Session session; uint32_t indicator; - nifpga_grpc::U32Data data; + nifpga_grpc::ReadU16StreamingResponse response; std::shared_ptr library; }; @@ -189,7 +189,7 @@ namespace nifpga_grpc { { NiFpga_Session session; uint32_t indicator; - nifpga_grpc::U32Data data; + nifpga_grpc::ReadU32StreamingResponse response; std::shared_ptr library; }; @@ -197,7 +197,7 @@ namespace nifpga_grpc { { NiFpga_Session session; uint32_t indicator; - nifpga_grpc::U64Data data; + nifpga_grpc::ReadU64StreamingResponse response; std::shared_ptr library; }; @@ -205,7 +205,7 @@ namespace nifpga_grpc { { NiFpga_Session session; uint32_t indicator; - nifpga_grpc::U32Data data; + nifpga_grpc::ReadU8StreamingResponse response; std::shared_ptr library; }; @@ -213,7 +213,8 @@ namespace nifpga_grpc { { NiFpga_Session session; uint32_t control; - nifpga_grpc::ArrayBoolData data; + nifpga_grpc::WriteArrayBoolStreamingRequest request; + nifpga_grpc::WriteArrayBoolStreamingResponse response; std::shared_ptr library; }; @@ -221,7 +222,8 @@ namespace nifpga_grpc { { NiFpga_Session session; uint32_t control; - nifpga_grpc::ArrayDoubleData data; + nifpga_grpc::WriteArrayDblStreamingRequest request; + nifpga_grpc::WriteArrayDblStreamingResponse response; std::shared_ptr library; }; @@ -229,7 +231,8 @@ namespace nifpga_grpc { { NiFpga_Session session; uint32_t control; - nifpga_grpc::ArrayI32Data data; + nifpga_grpc::WriteArrayI16StreamingRequest request; + nifpga_grpc::WriteArrayI16StreamingResponse response; std::shared_ptr library; }; @@ -237,7 +240,8 @@ namespace nifpga_grpc { { NiFpga_Session session; uint32_t control; - nifpga_grpc::ArrayI32Data data; + nifpga_grpc::WriteArrayI32StreamingRequest request; + nifpga_grpc::WriteArrayI32StreamingResponse response; std::shared_ptr library; }; @@ -245,7 +249,8 @@ namespace nifpga_grpc { { NiFpga_Session session; uint32_t control; - nifpga_grpc::ArrayI64Data data; + nifpga_grpc::WriteArrayI64StreamingRequest request; + nifpga_grpc::WriteArrayI64StreamingResponse response; std::shared_ptr library; }; @@ -253,7 +258,8 @@ namespace nifpga_grpc { { NiFpga_Session session; uint32_t control; - nifpga_grpc::ArrayI32Data data; + nifpga_grpc::WriteArrayI8StreamingRequest request; + nifpga_grpc::WriteArrayI8StreamingResponse response; std::shared_ptr library; }; @@ -261,7 +267,8 @@ namespace nifpga_grpc { { NiFpga_Session session; uint32_t control; - nifpga_grpc::ArrayFloatData data; + nifpga_grpc::WriteArraySglStreamingRequest request; + nifpga_grpc::WriteArraySglStreamingResponse response; std::shared_ptr library; }; @@ -269,7 +276,8 @@ namespace nifpga_grpc { { NiFpga_Session session; uint32_t control; - nifpga_grpc::ArrayU32Data data; + nifpga_grpc::WriteArrayU16StreamingRequest request; + nifpga_grpc::WriteArrayU16StreamingResponse response; std::shared_ptr library; }; @@ -277,7 +285,8 @@ namespace nifpga_grpc { { NiFpga_Session session; uint32_t control; - nifpga_grpc::ArrayU32Data data; + nifpga_grpc::WriteArrayU32StreamingRequest request; + nifpga_grpc::WriteArrayU32StreamingResponse response; std::shared_ptr library; }; @@ -285,7 +294,8 @@ namespace nifpga_grpc { { NiFpga_Session session; uint32_t control; - nifpga_grpc::ArrayU64Data data; + nifpga_grpc::WriteArrayU64StreamingRequest request; + nifpga_grpc::WriteArrayU64StreamingResponse response; std::shared_ptr library; }; @@ -293,7 +303,8 @@ namespace nifpga_grpc { { NiFpga_Session session; uint32_t control; - nifpga_grpc::ArrayU32Data data; + nifpga_grpc::WriteArrayU8StreamingRequest request; + nifpga_grpc::WriteArrayU8StreamingResponse response; std::shared_ptr library; }; @@ -301,7 +312,8 @@ namespace nifpga_grpc { { NiFpga_Session session; uint32_t control; - nifpga_grpc::BoolData data; + nifpga_grpc::WriteBoolStreamingRequest request; + nifpga_grpc::WriteBoolStreamingResponse response; std::shared_ptr library; }; @@ -309,7 +321,8 @@ namespace nifpga_grpc { { NiFpga_Session session; uint32_t control; - nifpga_grpc::DoubleData data; + nifpga_grpc::WriteDblStreamingRequest request; + nifpga_grpc::WriteDblStreamingResponse response; std::shared_ptr library; }; @@ -317,7 +330,8 @@ namespace nifpga_grpc { { NiFpga_Session session; uint32_t control; - nifpga_grpc::I32Data data; + nifpga_grpc::WriteI16StreamingRequest request; + nifpga_grpc::WriteI16StreamingResponse response; std::shared_ptr library; }; @@ -325,7 +339,8 @@ namespace nifpga_grpc { { NiFpga_Session session; uint32_t control; - nifpga_grpc::I32Data data; + nifpga_grpc::WriteI32StreamingRequest request; + nifpga_grpc::WriteI32StreamingResponse response; std::shared_ptr library; }; @@ -333,7 +348,8 @@ namespace nifpga_grpc { { NiFpga_Session session; uint32_t control; - nifpga_grpc::I64Data data; + nifpga_grpc::WriteI64StreamingRequest request; + nifpga_grpc::WriteI64StreamingResponse response; std::shared_ptr library; }; @@ -341,7 +357,8 @@ namespace nifpga_grpc { { NiFpga_Session session; uint32_t control; - nifpga_grpc::I32Data data; + nifpga_grpc::WriteI8StreamingRequest request; + nifpga_grpc::WriteI8StreamingResponse response; std::shared_ptr library; }; @@ -349,7 +366,8 @@ namespace nifpga_grpc { { NiFpga_Session session; uint32_t control; - nifpga_grpc::FloatData data; + nifpga_grpc::WriteSglStreamingRequest request; + nifpga_grpc::WriteSglStreamingResponse response; std::shared_ptr library; }; @@ -357,7 +375,8 @@ namespace nifpga_grpc { { NiFpga_Session session; uint32_t control; - nifpga_grpc::U32Data data; + nifpga_grpc::WriteU16StreamingRequest request; + nifpga_grpc::WriteU16StreamingResponse response; std::shared_ptr library; }; @@ -365,7 +384,8 @@ namespace nifpga_grpc { { NiFpga_Session session; uint32_t control; - nifpga_grpc::U32Data data; + nifpga_grpc::WriteU32StreamingRequest request; + nifpga_grpc::WriteU32StreamingResponse response; std::shared_ptr library; }; @@ -373,7 +393,8 @@ namespace nifpga_grpc { { NiFpga_Session session; uint32_t control; - nifpga_grpc::U64Data data; + nifpga_grpc::WriteU64StreamingRequest request; + nifpga_grpc::WriteU64StreamingResponse response; std::shared_ptr library; }; @@ -381,7 +402,8 @@ namespace nifpga_grpc { { NiFpga_Session session; uint32_t control; - nifpga_grpc::U32Data data; + nifpga_grpc::WriteU8StreamingRequest request; + nifpga_grpc::WriteU8StreamingResponse response; std::shared_ptr library; }; @@ -457,25 +479,23 @@ ::grpc::Status MonikerReadArrayBool(void* data, google::protobuf::Arena& arena, { MonikerReadArrayBoolData* function_data = static_cast(data); auto library = function_data->library; + auto response = &function_data->response; 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; + if (status >= 0) + { + response->set_status(status); + convert_to_grpc(array, response->mutable_array()); + packedData.PackFrom(*response); + } + else + { + return ::grpc::Status(grpc::StatusCode::UNKNOWN, "ni-error: " + status); } return ::grpc::Status::OK; } @@ -484,19 +504,23 @@ ::grpc::Status MonikerReadArrayDbl(void* data, google::protobuf::Arena& arena, g { MonikerReadArrayDblData* function_data = static_cast(data); auto library = function_data->library; + auto response = &function_data->response; auto session = function_data->session; auto indicator = function_data->indicator; auto size = function_data->size; + response->mutable_array()->Resize(size, 0); + double* array = response->mutable_array()->mutable_data(); - function_data->data.mutable_value()->Resize(size, 0); - auto array = function_data->data.mutable_value()->mutable_data(); auto status = library->ReadArrayDbl(session, indicator, array, size); - if (status >= 0) { - packedData.PackFrom(function_data->data); - } - if (status < 0) { - std::cout << "MonikerReadArrayDbl error: " << status << std::endl; + if (status >= 0) + { + response->set_status(status); + packedData.PackFrom(*response); + } + else + { + return ::grpc::Status(grpc::StatusCode::UNKNOWN, "ni-error: " + status); } return ::grpc::Status::OK; } @@ -505,25 +529,31 @@ ::grpc::Status MonikerReadArrayI16(void* data, google::protobuf::Arena& arena, g { MonikerReadArrayI16Data* function_data = static_cast(data); auto library = function_data->library; + auto response = &function_data->response; 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; + if (status >= 0) + { + response->set_status(status); + response->mutable_array()->Clear(); + response->mutable_array()->Reserve(size); + std::transform( + array.begin(), + array.begin() + size, + google::protobuf::RepeatedFieldBackInserter(response->mutable_array()), + [&](auto x) { + return x; + }); + packedData.PackFrom(*response); + } + else + { + return ::grpc::Status(grpc::StatusCode::UNKNOWN, "ni-error: " + status); } return ::grpc::Status::OK; } @@ -532,19 +562,23 @@ ::grpc::Status MonikerReadArrayI32(void* data, google::protobuf::Arena& arena, g { MonikerReadArrayI32Data* function_data = static_cast(data); auto library = function_data->library; + auto response = &function_data->response; auto session = function_data->session; auto indicator = function_data->indicator; auto size = function_data->size; + response->mutable_array()->Resize(size, 0); + int32_t* array = response->mutable_array()->mutable_data(); - function_data->data.mutable_value()->Resize(size, 0); - auto array = function_data->data.mutable_value()->mutable_data(); auto status = library->ReadArrayI32(session, indicator, array, size); - if (status >= 0) { - packedData.PackFrom(function_data->data); - } - if (status < 0) { - std::cout << "MonikerReadArrayI32 error: " << status << std::endl; + if (status >= 0) + { + response->set_status(status); + packedData.PackFrom(*response); + } + else + { + return ::grpc::Status(grpc::StatusCode::UNKNOWN, "ni-error: " + status); } return ::grpc::Status::OK; } @@ -553,19 +587,23 @@ ::grpc::Status MonikerReadArrayI64(void* data, google::protobuf::Arena& arena, g { MonikerReadArrayI64Data* function_data = static_cast(data); auto library = function_data->library; + auto response = &function_data->response; auto session = function_data->session; auto indicator = function_data->indicator; auto size = function_data->size; + response->mutable_array()->Resize(size, 0); + int64_t* array = response->mutable_array()->mutable_data(); - function_data->data.mutable_value()->Resize(size, 0); - auto array = function_data->data.mutable_value()->mutable_data(); auto status = library->ReadArrayI64(session, indicator, array, size); - if (status >= 0) { - packedData.PackFrom(function_data->data); - } - if (status < 0) { - std::cout << "MonikerReadArrayI64 error: " << status << std::endl; + if (status >= 0) + { + response->set_status(status); + packedData.PackFrom(*response); + } + else + { + return ::grpc::Status(grpc::StatusCode::UNKNOWN, "ni-error: " + status); } return ::grpc::Status::OK; } @@ -574,25 +612,31 @@ ::grpc::Status MonikerReadArrayI8(void* data, google::protobuf::Arena& arena, go { MonikerReadArrayI8Data* function_data = static_cast(data); auto library = function_data->library; + auto response = &function_data->response; 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; + if (status >= 0) + { + response->set_status(status); + response->mutable_array()->Clear(); + response->mutable_array()->Reserve(size); + std::transform( + array.begin(), + array.begin() + size, + google::protobuf::RepeatedFieldBackInserter(response->mutable_array()), + [&](auto x) { + return x; + }); + packedData.PackFrom(*response); + } + else + { + return ::grpc::Status(grpc::StatusCode::UNKNOWN, "ni-error: " + status); } return ::grpc::Status::OK; } @@ -601,19 +645,23 @@ ::grpc::Status MonikerReadArraySgl(void* data, google::protobuf::Arena& arena, g { MonikerReadArraySglData* function_data = static_cast(data); auto library = function_data->library; + auto response = &function_data->response; auto session = function_data->session; auto indicator = function_data->indicator; auto size = function_data->size; + response->mutable_array()->Resize(size, 0); + float* array = response->mutable_array()->mutable_data(); - function_data->data.mutable_value()->Resize(size, 0); - auto array = function_data->data.mutable_value()->mutable_data(); auto status = library->ReadArraySgl(session, indicator, array, size); - if (status >= 0) { - packedData.PackFrom(function_data->data); - } - if (status < 0) { - std::cout << "MonikerReadArraySgl error: " << status << std::endl; + if (status >= 0) + { + response->set_status(status); + packedData.PackFrom(*response); + } + else + { + return ::grpc::Status(grpc::StatusCode::UNKNOWN, "ni-error: " + status); } return ::grpc::Status::OK; } @@ -622,25 +670,31 @@ ::grpc::Status MonikerReadArrayU16(void* data, google::protobuf::Arena& arena, g { MonikerReadArrayU16Data* function_data = static_cast(data); auto library = function_data->library; + auto response = &function_data->response; 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; + if (status >= 0) + { + response->set_status(status); + response->mutable_array()->Clear(); + response->mutable_array()->Reserve(size); + std::transform( + array.begin(), + array.begin() + size, + google::protobuf::RepeatedFieldBackInserter(response->mutable_array()), + [&](auto x) { + return x; + }); + packedData.PackFrom(*response); + } + else + { + return ::grpc::Status(grpc::StatusCode::UNKNOWN, "ni-error: " + status); } return ::grpc::Status::OK; } @@ -649,19 +703,23 @@ ::grpc::Status MonikerReadArrayU32(void* data, google::protobuf::Arena& arena, g { MonikerReadArrayU32Data* function_data = static_cast(data); auto library = function_data->library; + auto response = &function_data->response; auto session = function_data->session; auto indicator = function_data->indicator; auto size = function_data->size; + response->mutable_array()->Resize(size, 0); + uint32_t* array = response->mutable_array()->mutable_data(); - function_data->data.mutable_value()->Resize(size, 0); - auto array = function_data->data.mutable_value()->mutable_data(); auto status = library->ReadArrayU32(session, indicator, array, size); - if (status >= 0) { - packedData.PackFrom(function_data->data); - } - if (status < 0) { - std::cout << "MonikerReadArrayU32 error: " << status << std::endl; + if (status >= 0) + { + response->set_status(status); + packedData.PackFrom(*response); + } + else + { + return ::grpc::Status(grpc::StatusCode::UNKNOWN, "ni-error: " + status); } return ::grpc::Status::OK; } @@ -670,19 +728,23 @@ ::grpc::Status MonikerReadArrayU64(void* data, google::protobuf::Arena& arena, g { MonikerReadArrayU64Data* function_data = static_cast(data); auto library = function_data->library; + auto response = &function_data->response; auto session = function_data->session; auto indicator = function_data->indicator; auto size = function_data->size; + response->mutable_array()->Resize(size, 0); + uint64_t* array = response->mutable_array()->mutable_data(); - function_data->data.mutable_value()->Resize(size, 0); - auto array = function_data->data.mutable_value()->mutable_data(); auto status = library->ReadArrayU64(session, indicator, array, size); - if (status >= 0) { - packedData.PackFrom(function_data->data); - } - if (status < 0) { - std::cout << "MonikerReadArrayU64 error: " << status << std::endl; + if (status >= 0) + { + response->set_status(status); + packedData.PackFrom(*response); + } + else + { + return ::grpc::Status(grpc::StatusCode::UNKNOWN, "ni-error: " + status); } return ::grpc::Status::OK; } @@ -691,25 +753,31 @@ ::grpc::Status MonikerReadArrayU8(void* data, google::protobuf::Arena& arena, go { MonikerReadArrayU8Data* function_data = static_cast(data); auto library = function_data->library; + auto response = &function_data->response; 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; + if (status >= 0) + { + response->set_status(status); + response->mutable_array()->Clear(); + response->mutable_array()->Reserve(size); + std::transform( + array.begin(), + array.begin() + size, + google::protobuf::RepeatedFieldBackInserter(response->mutable_array()), + [&](auto x) { + return x; + }); + packedData.PackFrom(*response); + } + else + { + return ::grpc::Status(grpc::StatusCode::UNKNOWN, "ni-error: " + status); } return ::grpc::Status::OK; } @@ -718,18 +786,22 @@ ::grpc::Status MonikerReadBool(void* data, google::protobuf::Arena& arena, googl { MonikerReadBoolData* function_data = static_cast(data); auto library = function_data->library; + auto response = &function_data->response; auto session = function_data->session; auto indicator = function_data->indicator; - NiFpga_Bool value {}; + 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; + if (status >= 0) + { + response->set_status(status); + response->set_value(value); + packedData.PackFrom(*response); + } + else + { + return ::grpc::Status(grpc::StatusCode::UNKNOWN, "ni-error: " + status); } return ::grpc::Status::OK; } @@ -738,18 +810,22 @@ ::grpc::Status MonikerReadDbl(void* data, google::protobuf::Arena& arena, google { MonikerReadDblData* function_data = static_cast(data); auto library = function_data->library; + auto response = &function_data->response; auto session = function_data->session; auto indicator = function_data->indicator; - double value {}; + auto status = library->ReadDbl(session, indicator, &value); - function_data->data.set_value(value); - if (status >= 0) { - packedData.PackFrom(function_data->data); - } - if (status < 0) { - std::cout << "MonikerReadDbl error: " << status << std::endl; + if (status >= 0) + { + response->set_status(status); + response->set_value(value); + packedData.PackFrom(*response); + } + else + { + return ::grpc::Status(grpc::StatusCode::UNKNOWN, "ni-error: " + status); } return ::grpc::Status::OK; } @@ -758,18 +834,22 @@ ::grpc::Status MonikerReadI16(void* data, google::protobuf::Arena& arena, google { MonikerReadI16Data* function_data = static_cast(data); auto library = function_data->library; + auto response = &function_data->response; auto session = function_data->session; auto indicator = function_data->indicator; - int16_t value {}; + 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; + if (status >= 0) + { + response->set_status(status); + response->set_value(value); + packedData.PackFrom(*response); + } + else + { + return ::grpc::Status(grpc::StatusCode::UNKNOWN, "ni-error: " + status); } return ::grpc::Status::OK; } @@ -778,18 +858,22 @@ ::grpc::Status MonikerReadI32(void* data, google::protobuf::Arena& arena, google { MonikerReadI32Data* function_data = static_cast(data); auto library = function_data->library; + auto response = &function_data->response; auto session = function_data->session; auto indicator = function_data->indicator; - int32_t value {}; + 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; + if (status >= 0) + { + response->set_status(status); + response->set_value(value); + packedData.PackFrom(*response); + } + else + { + return ::grpc::Status(grpc::StatusCode::UNKNOWN, "ni-error: " + status); } return ::grpc::Status::OK; } @@ -798,18 +882,22 @@ ::grpc::Status MonikerReadI64(void* data, google::protobuf::Arena& arena, google { MonikerReadI64Data* function_data = static_cast(data); auto library = function_data->library; + auto response = &function_data->response; auto session = function_data->session; auto indicator = function_data->indicator; - int64_t value {}; + 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; + if (status >= 0) + { + response->set_status(status); + response->set_value(value); + packedData.PackFrom(*response); + } + else + { + return ::grpc::Status(grpc::StatusCode::UNKNOWN, "ni-error: " + status); } return ::grpc::Status::OK; } @@ -818,18 +906,22 @@ ::grpc::Status MonikerReadI8(void* data, google::protobuf::Arena& arena, google: { MonikerReadI8Data* function_data = static_cast(data); auto library = function_data->library; + auto response = &function_data->response; auto session = function_data->session; auto indicator = function_data->indicator; - int8_t value {}; + 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; + if (status >= 0) + { + response->set_status(status); + response->set_value(value); + packedData.PackFrom(*response); + } + else + { + return ::grpc::Status(grpc::StatusCode::UNKNOWN, "ni-error: " + status); } return ::grpc::Status::OK; } @@ -838,18 +930,22 @@ ::grpc::Status MonikerReadSgl(void* data, google::protobuf::Arena& arena, google { MonikerReadSglData* function_data = static_cast(data); auto library = function_data->library; + auto response = &function_data->response; auto session = function_data->session; auto indicator = function_data->indicator; - float value {}; + auto status = library->ReadSgl(session, indicator, &value); - function_data->data.set_value(value); - if (status >= 0) { - packedData.PackFrom(function_data->data); - } - if (status < 0) { - std::cout << "MonikerReadSgl error: " << status << std::endl; + if (status >= 0) + { + response->set_status(status); + response->set_value(value); + packedData.PackFrom(*response); + } + else + { + return ::grpc::Status(grpc::StatusCode::UNKNOWN, "ni-error: " + status); } return ::grpc::Status::OK; } @@ -858,18 +954,22 @@ ::grpc::Status MonikerReadU16(void* data, google::protobuf::Arena& arena, google { MonikerReadU16Data* function_data = static_cast(data); auto library = function_data->library; + auto response = &function_data->response; auto session = function_data->session; auto indicator = function_data->indicator; - uint16_t value {}; + 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; + if (status >= 0) + { + response->set_status(status); + response->set_value(value); + packedData.PackFrom(*response); + } + else + { + return ::grpc::Status(grpc::StatusCode::UNKNOWN, "ni-error: " + status); } return ::grpc::Status::OK; } @@ -878,18 +978,22 @@ ::grpc::Status MonikerReadU32(void* data, google::protobuf::Arena& arena, google { MonikerReadU32Data* function_data = static_cast(data); auto library = function_data->library; + auto response = &function_data->response; auto session = function_data->session; auto indicator = function_data->indicator; - uint32_t value {}; + 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; + if (status >= 0) + { + response->set_status(status); + response->set_value(value); + packedData.PackFrom(*response); + } + else + { + return ::grpc::Status(grpc::StatusCode::UNKNOWN, "ni-error: " + status); } return ::grpc::Status::OK; } @@ -898,18 +1002,22 @@ ::grpc::Status MonikerReadU64(void* data, google::protobuf::Arena& arena, google { MonikerReadU64Data* function_data = static_cast(data); auto library = function_data->library; + auto response = &function_data->response; auto session = function_data->session; auto indicator = function_data->indicator; - uint64_t value {}; + 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; + if (status >= 0) + { + response->set_status(status); + response->set_value(value); + packedData.PackFrom(*response); + } + else + { + return ::grpc::Status(grpc::StatusCode::UNKNOWN, "ni-error: " + status); } return ::grpc::Status::OK; } @@ -918,18 +1026,22 @@ ::grpc::Status MonikerReadU8(void* data, google::protobuf::Arena& arena, google: { MonikerReadU8Data* function_data = static_cast(data); auto library = function_data->library; + auto response = &function_data->response; auto session = function_data->session; auto indicator = function_data->indicator; - uint8_t value {}; + 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; + if (status >= 0) + { + response->set_status(status); + response->set_value(value); + packedData.PackFrom(*response); + } + else + { + return ::grpc::Status(grpc::StatusCode::UNKNOWN, "ni-error: " + status); } return ::grpc::Status::OK; } @@ -938,6 +1050,7 @@ ::grpc::Status MonikerWriteArrayBool(void* data, google::protobuf::Arena& arena, { MonikerWriteArrayBoolData* function_data = static_cast(data); auto library = function_data->library; + auto response = &function_data->response; auto session = function_data->session; auto control = function_data->control; @@ -949,8 +1062,10 @@ ::grpc::Status MonikerWriteArrayBool(void* data, google::protobuf::Arena& arena, auto size = data_array.size(); auto status = library->WriteArrayBool(session, control, array.data(), size); - if (status < 0) { - std::cout << "MonikerWriteArrayBool error: " << status << std::endl; + + if (status < 0) + { + return ::grpc::Status(grpc::StatusCode::UNKNOWN, "ni-error: " + status); } return ::grpc::Status::OK; } @@ -959,6 +1074,7 @@ ::grpc::Status MonikerWriteArrayDbl(void* data, google::protobuf::Arena& arena, { MonikerWriteArrayDblData* function_data = static_cast(data); auto library = function_data->library; + auto response = &function_data->response; auto session = function_data->session; auto control = function_data->control; @@ -970,8 +1086,10 @@ ::grpc::Status MonikerWriteArrayDbl(void* data, google::protobuf::Arena& arena, auto size = data_array.size(); auto status = library->WriteArrayDbl(session, control, array, size); - if (status < 0) { - std::cout << "MonikerWriteArrayDbl error: " << status << std::endl; + + if (status < 0) + { + return ::grpc::Status(grpc::StatusCode::UNKNOWN, "ni-error: " + status); } return ::grpc::Status::OK; } @@ -980,6 +1098,7 @@ ::grpc::Status MonikerWriteArrayI16(void* data, google::protobuf::Arena& arena, { MonikerWriteArrayI16Data* function_data = static_cast(data); auto library = function_data->library; + auto response = &function_data->response; auto session = function_data->session; auto control = function_data->control; @@ -1003,8 +1122,10 @@ ::grpc::Status MonikerWriteArrayI16(void* data, google::protobuf::Arena& arena, }); auto status = library->WriteArrayI16(session, control, array.data(), size); - if (status < 0) { - std::cout << "MonikerWriteArrayI16 error: " << status << std::endl; + + if (status < 0) + { + return ::grpc::Status(grpc::StatusCode::UNKNOWN, "ni-error: " + status); } return ::grpc::Status::OK; } @@ -1013,6 +1134,7 @@ ::grpc::Status MonikerWriteArrayI32(void* data, google::protobuf::Arena& arena, { MonikerWriteArrayI32Data* function_data = static_cast(data); auto library = function_data->library; + auto response = &function_data->response; auto session = function_data->session; auto control = function_data->control; @@ -1024,8 +1146,10 @@ ::grpc::Status MonikerWriteArrayI32(void* data, google::protobuf::Arena& arena, auto size = data_array.size(); auto status = library->WriteArrayI32(session, control, array, size); - if (status < 0) { - std::cout << "MonikerWriteArrayI32 error: " << status << std::endl; + + if (status < 0) + { + return ::grpc::Status(grpc::StatusCode::UNKNOWN, "ni-error: " + status); } return ::grpc::Status::OK; } @@ -1034,6 +1158,7 @@ ::grpc::Status MonikerWriteArrayI64(void* data, google::protobuf::Arena& arena, { MonikerWriteArrayI64Data* function_data = static_cast(data); auto library = function_data->library; + auto response = &function_data->response; auto session = function_data->session; auto control = function_data->control; @@ -1045,8 +1170,10 @@ ::grpc::Status MonikerWriteArrayI64(void* data, google::protobuf::Arena& arena, auto size = data_array.size(); auto status = library->WriteArrayI64(session, control, array, size); - if (status < 0) { - std::cout << "MonikerWriteArrayI64 error: " << status << std::endl; + + if (status < 0) + { + return ::grpc::Status(grpc::StatusCode::UNKNOWN, "ni-error: " + status); } return ::grpc::Status::OK; } @@ -1055,6 +1182,7 @@ ::grpc::Status MonikerWriteArrayI8(void* data, google::protobuf::Arena& arena, g { MonikerWriteArrayI8Data* function_data = static_cast(data); auto library = function_data->library; + auto response = &function_data->response; auto session = function_data->session; auto control = function_data->control; @@ -1078,8 +1206,10 @@ ::grpc::Status MonikerWriteArrayI8(void* data, google::protobuf::Arena& arena, g }); auto status = library->WriteArrayI8(session, control, array.data(), size); - if (status < 0) { - std::cout << "MonikerWriteArrayI8 error: " << status << std::endl; + + if (status < 0) + { + return ::grpc::Status(grpc::StatusCode::UNKNOWN, "ni-error: " + status); } return ::grpc::Status::OK; } @@ -1088,6 +1218,7 @@ ::grpc::Status MonikerWriteArraySgl(void* data, google::protobuf::Arena& arena, { MonikerWriteArraySglData* function_data = static_cast(data); auto library = function_data->library; + auto response = &function_data->response; auto session = function_data->session; auto control = function_data->control; @@ -1099,8 +1230,10 @@ ::grpc::Status MonikerWriteArraySgl(void* data, google::protobuf::Arena& arena, auto size = data_array.size(); auto status = library->WriteArraySgl(session, control, array, size); - if (status < 0) { - std::cout << "MonikerWriteArraySgl error: " << status << std::endl; + + if (status < 0) + { + return ::grpc::Status(grpc::StatusCode::UNKNOWN, "ni-error: " + status); } return ::grpc::Status::OK; } @@ -1109,6 +1242,7 @@ ::grpc::Status MonikerWriteArrayU16(void* data, google::protobuf::Arena& arena, { MonikerWriteArrayU16Data* function_data = static_cast(data); auto library = function_data->library; + auto response = &function_data->response; auto session = function_data->session; auto control = function_data->control; @@ -1132,8 +1266,10 @@ ::grpc::Status MonikerWriteArrayU16(void* data, google::protobuf::Arena& arena, }); auto status = library->WriteArrayU16(session, control, array.data(), size); - if (status < 0) { - std::cout << "MonikerWriteArrayU16 error: " << status << std::endl; + + if (status < 0) + { + return ::grpc::Status(grpc::StatusCode::UNKNOWN, "ni-error: " + status); } return ::grpc::Status::OK; } @@ -1142,6 +1278,7 @@ ::grpc::Status MonikerWriteArrayU32(void* data, google::protobuf::Arena& arena, { MonikerWriteArrayU32Data* function_data = static_cast(data); auto library = function_data->library; + auto response = &function_data->response; auto session = function_data->session; auto control = function_data->control; @@ -1153,8 +1290,10 @@ ::grpc::Status MonikerWriteArrayU32(void* data, google::protobuf::Arena& arena, auto size = data_array.size(); auto status = library->WriteArrayU32(session, control, array, size); - if (status < 0) { - std::cout << "MonikerWriteArrayU32 error: " << status << std::endl; + + if (status < 0) + { + return ::grpc::Status(grpc::StatusCode::UNKNOWN, "ni-error: " + status); } return ::grpc::Status::OK; } @@ -1163,6 +1302,7 @@ ::grpc::Status MonikerWriteArrayU64(void* data, google::protobuf::Arena& arena, { MonikerWriteArrayU64Data* function_data = static_cast(data); auto library = function_data->library; + auto response = &function_data->response; auto session = function_data->session; auto control = function_data->control; @@ -1174,8 +1314,10 @@ ::grpc::Status MonikerWriteArrayU64(void* data, google::protobuf::Arena& arena, auto size = data_array.size(); auto status = library->WriteArrayU64(session, control, array, size); - if (status < 0) { - std::cout << "MonikerWriteArrayU64 error: " << status << std::endl; + + if (status < 0) + { + return ::grpc::Status(grpc::StatusCode::UNKNOWN, "ni-error: " + status); } return ::grpc::Status::OK; } @@ -1184,6 +1326,7 @@ ::grpc::Status MonikerWriteArrayU8(void* data, google::protobuf::Arena& arena, g { MonikerWriteArrayU8Data* function_data = static_cast(data); auto library = function_data->library; + auto response = &function_data->response; auto session = function_data->session; auto control = function_data->control; @@ -1207,8 +1350,10 @@ ::grpc::Status MonikerWriteArrayU8(void* data, google::protobuf::Arena& arena, g }); auto status = library->WriteArrayU8(session, control, array.data(), size); - if (status < 0) { - std::cout << "MonikerWriteArrayU8 error: " << status << std::endl; + + if (status < 0) + { + return ::grpc::Status(grpc::StatusCode::UNKNOWN, "ni-error: " + status); } return ::grpc::Status::OK; } @@ -1217,6 +1362,7 @@ ::grpc::Status MonikerWriteBool(void* data, google::protobuf::Arena& arena, goog { MonikerWriteBoolData* function_data = static_cast(data); auto library = function_data->library; + auto response = &function_data->response; auto session = function_data->session; auto control = function_data->control; @@ -1225,8 +1371,10 @@ ::grpc::Status MonikerWriteBool(void* data, google::protobuf::Arena& arena, goog auto value = booldata_message.value(); auto status = library->WriteBool(session, control, value); - if (status < 0) { - std::cout << "MonikerWriteBool error: " << status << std::endl; + + if (status < 0) + { + return ::grpc::Status(grpc::StatusCode::UNKNOWN, "ni-error: " + status); } return ::grpc::Status::OK; } @@ -1235,6 +1383,7 @@ ::grpc::Status MonikerWriteDbl(void* data, google::protobuf::Arena& arena, googl { MonikerWriteDblData* function_data = static_cast(data); auto library = function_data->library; + auto response = &function_data->response; auto session = function_data->session; auto control = function_data->control; @@ -1243,8 +1392,10 @@ ::grpc::Status MonikerWriteDbl(void* data, google::protobuf::Arena& arena, googl auto value = doubledata_message.value(); auto status = library->WriteDbl(session, control, value); - if (status < 0) { - std::cout << "MonikerWriteDbl error: " << status << std::endl; + + if (status < 0) + { + return ::grpc::Status(grpc::StatusCode::UNKNOWN, "ni-error: " + status); } return ::grpc::Status::OK; } @@ -1253,6 +1404,7 @@ ::grpc::Status MonikerWriteI16(void* data, google::protobuf::Arena& arena, googl { MonikerWriteI16Data* function_data = static_cast(data); auto library = function_data->library; + auto response = &function_data->response; auto session = function_data->session; auto control = function_data->control; @@ -1265,8 +1417,10 @@ ::grpc::Status MonikerWriteI16(void* data, google::protobuf::Arena& arena, googl } auto status = library->WriteI16(session, control, value); - if (status < 0) { - std::cout << "MonikerWriteI16 error: " << status << std::endl; + + if (status < 0) + { + return ::grpc::Status(grpc::StatusCode::UNKNOWN, "ni-error: " + status); } return ::grpc::Status::OK; } @@ -1275,6 +1429,7 @@ ::grpc::Status MonikerWriteI32(void* data, google::protobuf::Arena& arena, googl { MonikerWriteI32Data* function_data = static_cast(data); auto library = function_data->library; + auto response = &function_data->response; auto session = function_data->session; auto control = function_data->control; @@ -1283,8 +1438,10 @@ ::grpc::Status MonikerWriteI32(void* data, google::protobuf::Arena& arena, googl auto value = i32data_message.value(); auto status = library->WriteI32(session, control, value); - if (status < 0) { - std::cout << "MonikerWriteI32 error: " << status << std::endl; + + if (status < 0) + { + return ::grpc::Status(grpc::StatusCode::UNKNOWN, "ni-error: " + status); } return ::grpc::Status::OK; } @@ -1293,6 +1450,7 @@ ::grpc::Status MonikerWriteI64(void* data, google::protobuf::Arena& arena, googl { MonikerWriteI64Data* function_data = static_cast(data); auto library = function_data->library; + auto response = &function_data->response; auto session = function_data->session; auto control = function_data->control; @@ -1301,8 +1459,10 @@ ::grpc::Status MonikerWriteI64(void* data, google::protobuf::Arena& arena, googl auto value = i64data_message.value(); auto status = library->WriteI64(session, control, value); - if (status < 0) { - std::cout << "MonikerWriteI64 error: " << status << std::endl; + + if (status < 0) + { + return ::grpc::Status(grpc::StatusCode::UNKNOWN, "ni-error: " + status); } return ::grpc::Status::OK; } @@ -1311,6 +1471,7 @@ ::grpc::Status MonikerWriteI8(void* data, google::protobuf::Arena& arena, google { MonikerWriteI8Data* function_data = static_cast(data); auto library = function_data->library; + auto response = &function_data->response; auto session = function_data->session; auto control = function_data->control; @@ -1323,8 +1484,10 @@ ::grpc::Status MonikerWriteI8(void* data, google::protobuf::Arena& arena, google } auto status = library->WriteI8(session, control, value); - if (status < 0) { - std::cout << "MonikerWriteI8 error: " << status << std::endl; + + if (status < 0) + { + return ::grpc::Status(grpc::StatusCode::UNKNOWN, "ni-error: " + status); } return ::grpc::Status::OK; } @@ -1333,6 +1496,7 @@ ::grpc::Status MonikerWriteSgl(void* data, google::protobuf::Arena& arena, googl { MonikerWriteSglData* function_data = static_cast(data); auto library = function_data->library; + auto response = &function_data->response; auto session = function_data->session; auto control = function_data->control; @@ -1341,8 +1505,10 @@ ::grpc::Status MonikerWriteSgl(void* data, google::protobuf::Arena& arena, googl auto value = floatdata_message.value(); auto status = library->WriteSgl(session, control, value); - if (status < 0) { - std::cout << "MonikerWriteSgl error: " << status << std::endl; + + if (status < 0) + { + return ::grpc::Status(grpc::StatusCode::UNKNOWN, "ni-error: " + status); } return ::grpc::Status::OK; } @@ -1351,6 +1517,7 @@ ::grpc::Status MonikerWriteU16(void* data, google::protobuf::Arena& arena, googl { MonikerWriteU16Data* function_data = static_cast(data); auto library = function_data->library; + auto response = &function_data->response; auto session = function_data->session; auto control = function_data->control; @@ -1363,8 +1530,10 @@ ::grpc::Status MonikerWriteU16(void* data, google::protobuf::Arena& arena, googl } auto status = library->WriteU16(session, control, value); - if (status < 0) { - std::cout << "MonikerWriteU16 error: " << status << std::endl; + + if (status < 0) + { + return ::grpc::Status(grpc::StatusCode::UNKNOWN, "ni-error: " + status); } return ::grpc::Status::OK; } @@ -1373,6 +1542,7 @@ ::grpc::Status MonikerWriteU32(void* data, google::protobuf::Arena& arena, googl { MonikerWriteU32Data* function_data = static_cast(data); auto library = function_data->library; + auto response = &function_data->response; auto session = function_data->session; auto control = function_data->control; @@ -1381,8 +1551,10 @@ ::grpc::Status MonikerWriteU32(void* data, google::protobuf::Arena& arena, googl auto value = u32data_message.value(); auto status = library->WriteU32(session, control, value); - if (status < 0) { - std::cout << "MonikerWriteU32 error: " << status << std::endl; + + if (status < 0) + { + return ::grpc::Status(grpc::StatusCode::UNKNOWN, "ni-error: " + status); } return ::grpc::Status::OK; } @@ -1391,6 +1563,7 @@ ::grpc::Status MonikerWriteU64(void* data, google::protobuf::Arena& arena, googl { MonikerWriteU64Data* function_data = static_cast(data); auto library = function_data->library; + auto response = &function_data->response; auto session = function_data->session; auto control = function_data->control; @@ -1399,8 +1572,10 @@ ::grpc::Status MonikerWriteU64(void* data, google::protobuf::Arena& arena, googl auto value = u64data_message.value(); auto status = library->WriteU64(session, control, value); - if (status < 0) { - std::cout << "MonikerWriteU64 error: " << status << std::endl; + + if (status < 0) + { + return ::grpc::Status(grpc::StatusCode::UNKNOWN, "ni-error: " + status); } return ::grpc::Status::OK; } @@ -1409,6 +1584,7 @@ ::grpc::Status MonikerWriteU8(void* data, google::protobuf::Arena& arena, google { MonikerWriteU8Data* function_data = static_cast(data); auto library = function_data->library; + auto response = &function_data->response; auto session = function_data->session; auto control = function_data->control; @@ -1421,11 +1597,14 @@ ::grpc::Status MonikerWriteU8(void* data, google::protobuf::Arena& arena, google } auto status = library->WriteU8(session, control, value); - if (status < 0) { - std::cout << "MonikerWriteU8 error: " << status << std::endl; + + if (status < 0) + { + return ::grpc::Status(grpc::StatusCode::UNKNOWN, "ni-error: " + status); } return ::grpc::Status::OK; } + //--------------------------------------------------------------------- //--------------------------------------------------------------------- ::grpc::Status NiFpgaService::Abort(::grpc::ServerContext* context, const AbortRequest* request, AbortResponse* response) @@ -1971,14 +2150,14 @@ ::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(); + 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); + + data->response.mutable_array()->Reserve(request->size()); + data->response.mutable_array()->Resize(request->size(), 0); auto moniker = std::make_unique(); ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerReadArrayBool", data.release(), *moniker); response->set_allocated_moniker(moniker.release()); @@ -2029,14 +2208,14 @@ ::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(); + 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); + + data->response.mutable_array()->Reserve(request->size()); + data->response.mutable_array()->Resize(request->size(), 0); auto moniker = std::make_unique(); ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerReadArrayDbl", data.release(), *moniker); response->set_allocated_moniker(moniker.release()); @@ -2095,14 +2274,14 @@ ::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(); + 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); + + data->response.mutable_array()->Reserve(request->size()); + data->response.mutable_array()->Resize(request->size(), 0); auto moniker = std::make_unique(); ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerReadArrayI16", data.release(), *moniker); response->set_allocated_moniker(moniker.release()); @@ -2153,14 +2332,14 @@ ::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(); + 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); + + data->response.mutable_array()->Reserve(request->size()); + data->response.mutable_array()->Resize(request->size(), 0); auto moniker = std::make_unique(); ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerReadArrayI32", data.release(), *moniker); response->set_allocated_moniker(moniker.release()); @@ -2211,14 +2390,14 @@ ::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(); + 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); + + data->response.mutable_array()->Reserve(request->size()); + data->response.mutable_array()->Resize(request->size(), 0); auto moniker = std::make_unique(); ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerReadArrayI64", data.release(), *moniker); response->set_allocated_moniker(moniker.release()); @@ -2277,14 +2456,14 @@ ::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(); + 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); + + data->response.mutable_array()->Reserve(request->size()); + data->response.mutable_array()->Resize(request->size(), 0); auto moniker = std::make_unique(); ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerReadArrayI8", data.release(), *moniker); response->set_allocated_moniker(moniker.release()); @@ -2335,14 +2514,14 @@ ::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(); + 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); + + data->response.mutable_array()->Reserve(request->size()); + data->response.mutable_array()->Resize(request->size(), 0); auto moniker = std::make_unique(); ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerReadArraySgl", data.release(), *moniker); response->set_allocated_moniker(moniker.release()); @@ -2401,14 +2580,14 @@ ::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(); + 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); + + data->response.mutable_array()->Reserve(request->size()); + data->response.mutable_array()->Resize(request->size(), 0); auto moniker = std::make_unique(); ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerReadArrayU16", data.release(), *moniker); response->set_allocated_moniker(moniker.release()); @@ -2459,14 +2638,14 @@ ::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(); + 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); + + data->response.mutable_array()->Reserve(request->size()); + data->response.mutable_array()->Resize(request->size(), 0); auto moniker = std::make_unique(); ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerReadArrayU32", data.release(), *moniker); response->set_allocated_moniker(moniker.release()); @@ -2517,14 +2696,14 @@ ::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(); + 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); + + data->response.mutable_array()->Reserve(request->size()); + data->response.mutable_array()->Resize(request->size(), 0); auto moniker = std::make_unique(); ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerReadArrayU64", data.release(), *moniker); response->set_allocated_moniker(moniker.release()); @@ -2583,14 +2762,14 @@ ::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(); + 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); + + data->response.mutable_array()->Reserve(request->size()); + data->response.mutable_array()->Resize(request->size(), 0); auto moniker = std::make_unique(); ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerReadArrayU8", data.release(), *moniker); response->set_allocated_moniker(moniker.release()); @@ -2639,11 +2818,11 @@ ::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(); + 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.release(), *moniker); response->set_allocated_moniker(moniker.release()); @@ -2692,11 +2871,11 @@ ::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(); + 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("MonikerReadDbl", data.release(), *moniker); response->set_allocated_moniker(moniker.release()); @@ -3096,11 +3275,11 @@ ::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(); + 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("MonikerReadI16", data.release(), *moniker); response->set_allocated_moniker(moniker.release()); @@ -3149,11 +3328,11 @@ ::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(); + 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("MonikerReadI32", data.release(), *moniker); response->set_allocated_moniker(moniker.release()); @@ -3202,11 +3381,11 @@ ::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(); + 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("MonikerReadI64", data.release(), *moniker); response->set_allocated_moniker(moniker.release()); @@ -3255,11 +3434,11 @@ ::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(); + 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("MonikerReadI8", data.release(), *moniker); response->set_allocated_moniker(moniker.release()); @@ -3308,11 +3487,11 @@ ::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(); + 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("MonikerReadSgl", data.release(), *moniker); response->set_allocated_moniker(moniker.release()); @@ -3361,11 +3540,11 @@ ::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(); + 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("MonikerReadU16", data.release(), *moniker); response->set_allocated_moniker(moniker.release()); @@ -3414,11 +3593,11 @@ ::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(); + 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("MonikerReadU32", data.release(), *moniker); response->set_allocated_moniker(moniker.release()); @@ -3467,11 +3646,11 @@ ::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(); + 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("MonikerReadU64", data.release(), *moniker); response->set_allocated_moniker(moniker.release()); @@ -3520,11 +3699,11 @@ ::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(); + 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("MonikerReadU8", data.release(), *moniker); response->set_allocated_moniker(moniker.release()); @@ -3915,11 +4094,11 @@ ::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(); + 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.release(), *moniker); response->set_allocated_moniker(moniker.release()); @@ -3968,11 +4147,11 @@ ::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(); + 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("MonikerWriteArrayDbl", data.release(), *moniker); response->set_allocated_moniker(moniker.release()); @@ -4038,11 +4217,11 @@ ::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(); + 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("MonikerWriteArrayI16", data.release(), *moniker); response->set_allocated_moniker(moniker.release()); @@ -4091,11 +4270,11 @@ ::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(); + 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("MonikerWriteArrayI32", data.release(), *moniker); response->set_allocated_moniker(moniker.release()); @@ -4144,11 +4323,11 @@ ::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(); + 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("MonikerWriteArrayI64", data.release(), *moniker); response->set_allocated_moniker(moniker.release()); @@ -4214,11 +4393,11 @@ ::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(); + 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("MonikerWriteArrayI8", data.release(), *moniker); response->set_allocated_moniker(moniker.release()); @@ -4267,11 +4446,11 @@ ::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(); + 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("MonikerWriteArraySgl", data.release(), *moniker); response->set_allocated_moniker(moniker.release()); @@ -4337,11 +4516,11 @@ ::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(); + 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("MonikerWriteArrayU16", data.release(), *moniker); response->set_allocated_moniker(moniker.release()); @@ -4390,11 +4569,11 @@ ::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(); + 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("MonikerWriteArrayU32", data.release(), *moniker); response->set_allocated_moniker(moniker.release()); @@ -4443,11 +4622,11 @@ ::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(); + 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("MonikerWriteArrayU64", data.release(), *moniker); response->set_allocated_moniker(moniker.release()); @@ -4513,11 +4692,11 @@ ::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(); + 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("MonikerWriteArrayU8", data.release(), *moniker); response->set_allocated_moniker(moniker.release()); @@ -4565,11 +4744,11 @@ ::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(); + 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.release(), *moniker); response->set_allocated_moniker(moniker.release()); @@ -4617,11 +4796,11 @@ ::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(); + 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("MonikerWriteDbl", data.release(), *moniker); response->set_allocated_moniker(moniker.release()); @@ -5054,11 +5233,11 @@ ::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(); + 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("MonikerWriteI16", data.release(), *moniker); response->set_allocated_moniker(moniker.release()); @@ -5106,11 +5285,11 @@ ::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(); + 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("MonikerWriteI32", data.release(), *moniker); response->set_allocated_moniker(moniker.release()); @@ -5158,11 +5337,11 @@ ::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(); + 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("MonikerWriteI64", data.release(), *moniker); response->set_allocated_moniker(moniker.release()); @@ -5219,11 +5398,11 @@ ::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(); + 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("MonikerWriteI8", data.release(), *moniker); response->set_allocated_moniker(moniker.release()); @@ -5271,11 +5450,11 @@ ::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(); + 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("MonikerWriteSgl", data.release(), *moniker); response->set_allocated_moniker(moniker.release()); @@ -5332,11 +5511,11 @@ ::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(); + 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("MonikerWriteU16", data.release(), *moniker); response->set_allocated_moniker(moniker.release()); @@ -5384,11 +5563,11 @@ ::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(); + 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("MonikerWriteU32", data.release(), *moniker); response->set_allocated_moniker(moniker.release()); @@ -5436,11 +5615,11 @@ ::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(); + 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("MonikerWriteU64", data.release(), *moniker); response->set_allocated_moniker(moniker.release()); @@ -5497,11 +5676,11 @@ ::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(); + 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("MonikerWriteU8", data.release(), *moniker); response->set_allocated_moniker(moniker.release()); diff --git a/source/codegen/common_helpers.py b/source/codegen/common_helpers.py index 8c5957a89..fdb42bb64 100644 --- a/source/codegen/common_helpers.py +++ b/source/codegen/common_helpers.py @@ -3,7 +3,7 @@ import os import re from collections import defaultdict, namedtuple -from typing import Any, Dict, List, NamedTuple, Optional +from typing import Any, Dict, List, NamedTuple, Optional, Tuple _NIDEVICE_COMMON_MESSAGE_TYPES = ( "nidevice_grpc.NIComplexNumber", @@ -1204,29 +1204,73 @@ 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): +def filter_moniker_streaming_functions( + functions: dict, functions_to_generate: List[str] +) -> List[str]: """Return streaming functions that need to be generated.""" return [ - name for name in functions_to_generate if functions[name].get("is_streaming_api", False) + name for name in functions_to_generate if is_moniker_streaming_function(functions[name]) ] -def get_data_moniker_function_name(function_name): +def is_moniker_streaming_function(function: dict) -> bool: + """Whether this function is for streaming data through moniker.""" + return function.get("is_streaming_api", False) + + +def get_data_moniker_function_name(function_name: str) -> str: """Return the corresponding moniker function name for the given C API function.""" 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 get_data_moniker_struct_name(begin_function_name: str) -> str: + """Return the Moniker function name. + + Input expected is Begin* streaming API name. + """ + return f"{begin_function_name.replace('Begin', 'Moniker')}Data" + +def get_data_moniker_request_message_type(begin_function_name: str) -> str: + """Return the request message type for Moniker functions. -def is_function_in_streaming_functions(function_name, streaming_functions_to_generate): + Input expected is Begin* streaming API name. + """ + return f"{begin_function_name.replace('Begin', '')}StreamingRequest" + + +def get_data_moniker_response_message_type(begin_function_name: str) -> str: + """Return the response message type for Moniker functions. + + Input expected is Begin* streaming API name. + """ + return f"{begin_function_name.replace('Begin', '')}StreamingResponse" + + +def get_data_moniker_function_parameters(function: dict) -> Tuple[List[dict], List[dict]]: + """Return moniker function parameters split into input/output. + + Input expected is equivalent non-streaming function. + Add a default "status" output parameter if there isn't one already. + """ + parameter_array = filter_parameters_for_grpc_fields(function["parameters"]) + input_parameters = [ + p for p in parameter_array if is_input_parameter(p) and p.get("is_streaming_type", False) + ] + default_status_param = {"name": "status", "type": "int32", "grpc_type": "int32"} + output_parameters = [default_status_param] + output_parameters.extend([p for p in parameter_array if is_output_parameter(p)]) + return (input_parameters, output_parameters) + + +def is_function_in_streaming_functions( + function_name: str, streaming_functions_to_generate: List[str] +): """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): +def _is_streaming_param_input_array(streaming_param: dict) -> bool: """Check if the streaming parameter is an input array.""" return ( streaming_param @@ -1235,14 +1279,9 @@ def _is_streaming_param_input_array(streaming_param): ) -def get_input_streaming_params(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 - +def get_non_streaming_input_parameters(parameters: List[dict]) -> List[dict]: + """Determine if a parameter should be passed from Begin streaming API to Moniker function.""" + streaming_param = get_first_streaming_parameter(parameters) params = [] for param in parameters: if is_input_parameter(param) and not param.get("is_streaming_type", False): diff --git a/source/codegen/service_helpers.py b/source/codegen/service_helpers.py index 71dcbeb8c..7ba907666 100644 --- a/source/codegen/service_helpers.py +++ b/source/codegen/service_helpers.py @@ -709,15 +709,7 @@ def get_protobuf_cpplib_type(grpc_type: str) -> str: return grpc_type -def get_streaming_type(parameters) -> str: - """Get the streaming type from the function data.""" - for param in parameters: - if param.get("is_streaming_type", False): - return param["type"] - return None - - -def get_size_param_name(streaming_param) -> str: +def get_size_param_name(streaming_param: dict) -> str: """Get the size parameter name for the given streaming parameter. The size is only present for read arrays, which have an "out" direction. @@ -726,22 +718,3 @@ def get_size_param_name(streaming_param) -> str: return common_helpers.camel_to_snake(streaming_param["size"]["value"]) else: return None - - -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}" - return f"{function_name}" - - -def is_secondary_streaming_param(param, first_streaming_param) -> bool: - """Check if a parameter is a secondry streaming type parameter.""" - return param.get("is_streaming_type", False) and param["name"] != first_streaming_param["name"] - - -def get_output_streaming_params_to_define(parameters, first_streaming_param) -> List[dict]: - """Get the list of output streaming parameters that need to be defined.""" - output_params = [p for p in parameters if common_helpers.is_output_parameter(p)] - return [p for p in output_params if is_secondary_streaming_param(p, first_streaming_param)] diff --git a/source/codegen/templates/proto.mako b/source/codegen/templates/proto.mako index ba9f1b448..8bba31343 100644 --- a/source/codegen/templates/proto.mako +++ b/source/codegen/templates/proto.mako @@ -68,4 +68,8 @@ ${mako_helper.define_request_message(function, input_parameters)}\ ${mako_helper.define_response_message(function, output_parameters)}\ +% if common_helpers.is_moniker_streaming_function(functions[function]): +${mako_helper.define_moniker_request_response_messages(function, functions)}\ + +% endif % endfor \ No newline at end of file diff --git a/source/codegen/templates/proto_helpers.mako b/source/codegen/templates/proto_helpers.mako index 6ba300c22..92a8cb6c8 100644 --- a/source/codegen/templates/proto_helpers.mako +++ b/source/codegen/templates/proto_helpers.mako @@ -113,6 +113,31 @@ message ${common_helpers.snake_to_pascal(function)}Response { } +## Define a proto request and response messages for Moniker function. +<%def name="define_moniker_request_response_messages(begin_function_name, functions)">\ +<% + non_streaming_function_name = begin_function_name.replace("Begin", "") + input_parameters, output_parameters = common_helpers.get_data_moniker_function_parameters(functions[non_streaming_function_name]) + request_parameters = proto_helpers.get_message_parameter_definitions(input_parameters) + response_parameters = proto_helpers.get_message_parameter_definitions(output_parameters) + request_message_type = common_helpers.get_data_moniker_request_message_type(begin_function_name) + response_message_type = common_helpers.get_data_moniker_response_message_type(begin_function_name) +%>\ +% if request_parameters: +message ${request_message_type} { +% for parameter in request_parameters: + ${parameter["type"]} ${parameter["name"]} = ${parameter["grpc_field_number"]}; +% endfor +} + +% endif +message ${response_message_type} { +% for parameter in response_parameters: + ${parameter["type"]} ${parameter["name"]} = ${parameter["grpc_field_number"]}; +% endfor +} + + ## Define a proto message for a given custom type. <%def name="define_custom_type(custom_type)">\ <% diff --git a/source/codegen/templates/service.cpp.mako b/source/codegen/templates/service.cpp.mako index ba25d7cde..aa55edbd5 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_moniker_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) @@ -67,8 +67,11 @@ namespace ${config["namespace_component"]}_grpc { <% function_data = functions[function_name] parameters = function_data['parameters'] +non_streaming_function_name = function_name.replace("Begin", "") +input_parameters, output_parameters = common_helpers.get_data_moniker_function_parameters(functions[non_streaming_function_name]) +has_input_parameters = len(input_parameters) != 0 %> -${mako_helper.define_moniker_streaming_struct(function_name=function_name, parameters=parameters)}\ +${mako_helper.define_moniker_streaming_struct(begin_function_name=function_name, parameters=parameters, has_input_parameters=has_input_parameters)}\ % endfor % if any_ivi_dance_functions: @@ -118,12 +121,11 @@ ${mako_helper.define_moniker_streaming_struct(function_name=function_name, param ${mako_helper.register_moniker_functions(function_name)}\ % endfor } + % endif % 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)}\ +${mako_helper.define_moniker_function_body(function_name=function_name, functions=functions)}\ + % endfor % for function_name in service_helpers.filter_proto_rpc_functions_to_generate(functions): <% @@ -163,7 +165,7 @@ ${mako_helper.define_ivi_dance_with_a_twist_method_body(function_name=function_n % 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)} +${mako_helper.define_streaming_api_body(function_name=function_name, parameters=parameters)} % else: ${mako_helper.define_simple_method_body(function_name=function_name, function_data=function_data, parameters=parameters)} % endif diff --git a/source/codegen/templates/service_helpers.mako b/source/codegen/templates/service_helpers.mako index 22149771e..666f52e88 100644 --- a/source/codegen/templates/service_helpers.mako +++ b/source/codegen/templates/service_helpers.mako @@ -26,7 +26,7 @@ add_session_snippet = f'add_session(grpc_device_session_name, init_lambda, cleanup_lambda, {session_behavior_param_name}, &{session_initialized_param_name})' %>\ ${initialize_input_params(function_name, parameters)} -${initialize_output_params(output_parameters_to_initialize)}\ +${initialize_output_params(output_parameters_to_initialize, indent_level=1)}\ auto init_lambda = [&] () { ## If the session is not returned, it's an output param and need to be declared before calling. % if not service_helpers.is_session_returned_from_function(parameters): @@ -64,7 +64,7 @@ ${populate_response(function_data=function_data, parameters=parameters, init_met initiating_driver_c_name = f'{initiating_driver_input_var_name}_grpc_session' %>\ ${initialize_input_params(function_name, parameters)} -${initialize_output_params(output_parameters_to_initialize)}\ +${initialize_output_params(output_parameters_to_initialize, indent_level=1)}\ auto initiating_session_name = ${initiating_driver_c_name}.name(); auto init_lambda = [&] () { ${cross_driver_dep.resource_handle_type} ${session_output_var_name}; @@ -98,9 +98,7 @@ ${call_library_method( ${populate_error_check(function_data, parameters, indent_level=1)}\ ${size_param['type']} ${common_helpers.get_cpp_local_name(size_param)} = status; -<%block filter="common_helpers.indent(1)">\ -${initialize_output_params(output_parameters)}\ -\ +${initialize_output_params(output_parameters, indent_level=2)}\ ${call_library_method( function_name=function_name, function_data=function_data, @@ -129,7 +127,7 @@ ${populate_response(function_data=function_data, parameters=parameters, indent_l scalar_output_parameters = [p for p in output_parameters if p not in array_output_parameters] %>\ ${initialize_input_params(function_name, non_ivi_params)}\ -${initialize_output_params(scalar_output_parameters)}\ +${initialize_output_params(scalar_output_parameters, indent_level=1)}\ while (true) { ${call_library_method( function_name=function_name, @@ -138,9 +136,7 @@ ${call_library_method( indent_level=1) }\ ${populate_error_check(function_data, parameters, indent_level=1)}\ -<%block filter="common_helpers.indent(1)">\ -${initialize_output_params(array_output_parameters)}\ -\ +${initialize_output_params(array_output_parameters, indent_level=2)}\ % for ivi_param_set in ivi_param_sets: % if not ivi_param_set.is_in_out_twist: auto ${ivi_param_set.size_param_name} = ${ivi_param_set.twist_param_name}; @@ -235,7 +231,7 @@ ${populate_error_check(function_data, parameters, indent_level=1, service_deref= output_parameters = [p for p in parameters if common_helpers.is_output_parameter(p)] %>\ ${initialize_input_params(function_name, parameters)}\ -${initialize_output_params(output_parameters)}\ +${initialize_output_params(output_parameters, indent_level=1)}\ ${set_output_vararg_parameter_sizes(parameters)}\ ${call_library_method( function_name=function_name, @@ -254,7 +250,7 @@ ${populate_response(function_data=function_data, parameters=parameters)}\ output_parameters = [p for p in parameters if common_helpers.is_output_parameter(p)] %>\ ${initialize_input_params(function_name, parameters)}\ -${initialize_output_params(output_parameters)}\ +${initialize_output_params(output_parameters, indent_level=1)}\ % if function_name == config['close_function'] or service_helpers.is_custom_close_method(function_data): <% session_param = common_helpers.get_first_session_param(parameters) @@ -278,18 +274,18 @@ ${populate_response(function_data=function_data, parameters=parameters)}\ ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("${moniker_function_name}", ${moniker_function_name}); -<%def name="define_moniker_streaming_struct(function_name, parameters)">\ +<%def name="define_moniker_streaming_struct(begin_function_name, parameters, has_input_parameters)">\ <% config = data['config'] - streaming_param = common_helpers.get_first_streaming_parameter(parameters) service_class_prefix = config["service_class_prefix"] - grpc_streaming_type = streaming_param['grpc_streaming_type'] - struct_name = common_helpers.get_data_moniker_struct_name(function_name) - streaming_params_to_include = common_helpers.get_input_streaming_params(parameters) + struct_name = common_helpers.get_data_moniker_struct_name(begin_function_name) + moniker_input_parameters = common_helpers.get_non_streaming_input_parameters(parameters) + request_message_type = common_helpers.get_data_moniker_request_message_type(begin_function_name) + response_message_type = common_helpers.get_data_moniker_response_message_type(begin_function_name) %>\ struct ${struct_name} { -% for parameter in streaming_params_to_include: +% for parameter in moniker_input_parameters: <% parameter_name = common_helpers.get_cpp_local_name(parameter) %>\ @@ -298,62 +294,54 @@ ${populate_response(function_data=function_data, parameters=parameters)}\ % else: ${parameter['type']} ${parameter_name}; % endif - % endfor - ${service_class_prefix.lower()}_grpc::${grpc_streaming_type} data; +% endfor +% if has_input_parameters: + ${service_class_prefix.lower()}_grpc::${request_message_type} request; +% endif + ${service_class_prefix.lower()}_grpc::${response_message_type} response; std::shared_ptr<${service_class_prefix}LibraryInterface> library; }; -<%def name="define_moniker_function_body(function_name, function_data)">\ +<%def name="define_moniker_function_body(function_name, functions)">\ <% - config = data['config'] + function_data = functions[function_name] struct_name = common_helpers.get_data_moniker_struct_name(function_name) moniker_function_name = common_helpers.get_data_moniker_function_name(function_name) + moniker_input_parameters = common_helpers.get_non_streaming_input_parameters(function_data['parameters']) streaming_param = common_helpers.get_first_streaming_parameter(function_data['parameters']) - streaming_type = streaming_param['type'] - grpc_streaming_type = streaming_param['grpc_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) - streaming_params_to_include = common_helpers.get_input_streaming_params(function_data['parameters']) - output_params_to_define = service_helpers.get_output_streaming_params_to_define(function_data['parameters'], streaming_param) + non_streaming_function_name = function_name.replace("Begin", "") + non_streaming_function_parameters = functions[non_streaming_function_name]['parameters'] + arg_string = service_helpers.create_args(non_streaming_function_parameters) + output_parameters = [p for p in non_streaming_function_parameters if common_helpers.is_output_parameter(p)] %>\ ::grpc::Status ${moniker_function_name}(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData) { ${struct_name}* function_data = static_cast<${struct_name}*>(data); - auto library = function_data->library;\ -${initialize_moniker_input_parameters(streaming_params_to_include)}\ -${initialize_moniker_output_parameters(output_params_to_define)}\ - % 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': -${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; - } + auto library = function_data->library; + auto response = &function_data->response; +${initialize_moniker_input_parameters(moniker_input_parameters)}\ +${initialize_output_params(output_parameters)}\ + % if streaming_param and streaming_param['direction'] == 'in': +${streaming_handle_in_direction(streaming_param)}\ + % endif + + auto status = library->${non_streaming_function_name}(${arg_string}); + +${populate_moniker_response_for_out_functions(output_parameters, streaming_param)}\ return ::grpc::Status::OK; } -<%def name="define_streaming_api_body(function_name, function_data, parameters)">\ +<%def name="define_streaming_api_body(function_name, parameters)">\ <% - config = data['config'] - 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 = 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_first_streaming_parameter(parameters) - streaming_params_to_include = common_helpers.get_input_streaming_params(parameters) + moniker_input_parameters = common_helpers.get_non_streaming_input_parameters(parameters) + output_parameters = [p for p in parameters if common_helpers.is_output_parameter(p)] %>\ -${initialize_streaming_input_param(function_name, streaming_params_to_include, parameters, streaming_param)} - auto data = std::make_unique<${struct_name}>();\ - ${initialize_begin_input_params(streaming_params_to_include, streaming_param)}\ - data->library = std::shared_ptr<${service_class_prefix}LibraryInterface>(library_); - ${initialize_service_output_params(output_params, streaming_param)}\ +${initialize_input_params(function_name, moniker_input_parameters)} +${initialize_moniker_struct(struct_name, moniker_input_parameters, output_parameters)}\ auto moniker = std::make_unique(); ni::data_monikers::DataMonikerService::RegisterMonikerInstance("${moniker_function_name}", data.release(), *moniker); response->set_allocated_moniker(moniker.release()); @@ -361,76 +349,19 @@ ${initialize_streaming_input_param(function_name, streaming_params_to_include, p return ::grpc::Status::OK;\ -<%def name="streaming_handle_out_direction(c_api_name, arg_string, data_type, streaming_type, streaming_param)"> -<% - is_array = common_helpers.is_array(streaming_type) -%>\ -% 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_param)} -% 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_param_name = service_helpers.get_size_param_name(streaming_param) - streaming_param_name = common_helpers.camel_to_snake(streaming_param['name']) - underlying_param_type = common_helpers.get_underlying_type_name(streaming_param["type"]) -%>\ -% if common_helpers.supports_standard_copy_conversion_routines(streaming_param): -std::vector<${data_type}> ${streaming_param_name}(${size_param_name}, ${data_type}()); -% elif is_coerced: -std::vector<${data_type}> ${streaming_param_name}(${size_param_name}); -% elif common_helpers.is_driver_typedef_with_same_size_but_different_qualifiers(underlying_param_type): -function_data->data.mutable_value()->Resize(${size_param_name}, 0); - auto ${streaming_param_name} = reinterpret_cast<${underlying_param_type}*>(function_data->data.mutable_value()->mutable_data()); -% else: -function_data->data.mutable_value()->Resize(${size_param_name}, 0); - auto ${streaming_param_name} = function_data->data.mutable_value()->mutable_data(); -% endif - auto status = library->${c_api_name}(${arg_string}); - if (status >= 0) { -% if is_coerced or common_helpers.supports_standard_copy_conversion_routines(streaming_param): - std::transform( - ${streaming_param_name}.begin(), - ${streaming_param_name}.begin() + ${size_param_name}, - function_data->data.mutable_value()->begin(), - [&](auto x) { - return x; - }); -% endif - packedData.PackFrom(function_data->data); - } - - -<%def name="streaming_handle_out_direction_scaler(c_api_name, arg_string, streaming_param)">\ -<% - parameter_name = common_helpers.get_cpp_local_name(streaming_param) -%>\ -${streaming_param['type']} ${parameter_name} {};\ - - auto status = library->${c_api_name}(${arg_string}); - function_data->data.set_value(${parameter_name}); - if (status >= 0) { - packedData.PackFrom(function_data->data); - } - - -<%def name="streaming_handle_in_direction(c_api_name, arg_string, data_type, grpc_streaming_type, streaming_type, streaming_param)"> +<%def name="streaming_handle_in_direction(streaming_param)"> <% + streaming_type = streaming_param['type'] + grpc_streaming_type = streaming_param['grpc_streaming_type'] 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: - ${streaming_handle_in_direction_array(data_type, grpc_streaming_type, streaming_param)}\ + ${streaming_handle_in_direction_array(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)">\ @@ -446,17 +377,18 @@ 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(grpc_streaming_type, streaming_param)"> <% is_coerced = service_helpers.is_input_array_that_needs_coercion(streaming_param) c_element_type_that_needs_coercion = service_helpers.get_c_element_type_for_array_that_needs_coercion(streaming_param) streaming_param_name = common_helpers.camel_to_snake(streaming_param['name']) - underlying_param_type = common_helpers.get_underlying_type_name(streaming_param["type"]).replace("const ", "") + underlying_param_type = common_helpers.get_underlying_type_name(streaming_param["type"]) + underlying_param_type_with_no_qualifiers = underlying_param_type.replace("const ", "") %>\ % if common_helpers.supports_standard_copy_conversion_routines(streaming_param): auto data_array = ${grpc_streaming_type.lower()}_message.value(); - std::vector<${data_type}> ${streaming_param_name}(data_array.begin(), data_array.end()); + std::vector<${underlying_param_type}> ${streaming_param_name}(data_array.begin(), data_array.end()); auto size = data_array.size(); % elif is_coerced: auto data_array = ${grpc_streaming_type.lower()}_message.value(); @@ -476,59 +408,68 @@ auto value = ${grpc_streaming_type.lower()}_message.value(); }); % else: auto data_array = ${grpc_streaming_type.lower()}_message.value(); -% if common_helpers.is_driver_typedef_with_same_size_but_different_qualifiers(underlying_param_type): - auto ${streaming_param_name} = reinterpret_cast<${data_type}*>(${grpc_streaming_type.lower()}_message.value().data()); +% if common_helpers.is_driver_typedef_with_same_size_but_different_qualifiers(underlying_param_type_with_no_qualifiers): + auto ${streaming_param_name} = reinterpret_cast<${underlying_param_type}*>(${grpc_streaming_type.lower()}_message.value().data()); % else: - auto ${streaming_param_name} = const_cast<${data_type}*>(${grpc_streaming_type.lower()}_message.value().data()); + auto ${streaming_param_name} = const_cast<${underlying_param_type}*>(${grpc_streaming_type.lower()}_message.value().data()); % endif auto size = data_array.size(); % endif -## Initialize an bgin input parameter for an API call. -<%def name="initialize_begin_input_params(streaming_params_to_include, streaming_param)"> -% for parameter in streaming_params_to_include: +<%def name="populate_moniker_response_for_out_functions(output_parameters, streaming_param)">\ +% if streaming_param['direction'] == 'out': + if (status >= 0) + { + response->set_status(status); +${set_response_values(output_parameters=output_parameters, init_method=false)}\ + packedData.PackFrom(*response); + } + else + { + ## TODO this is not needed if we can make populate_response work which returns error through `AddTrailingMetadata`. + ## But that needs `context` parameter which is not available in Moniker functions. + return ::grpc::Status(grpc::StatusCode::UNKNOWN, "ni-error: " + status); + } +% else: + if (status < 0) + { + return ::grpc::Status(grpc::StatusCode::UNKNOWN, "ni-error: " + status); + } +% endif + + +<%def name="initialize_moniker_struct(struct_name, moniker_input_parameters, output_parameters)">\ +<% + config = data['config'] + service_class_prefix = config["service_class_prefix"] + output_array_params = [p for p in output_parameters if common_helpers.is_array(p['type'])] +%>\ + auto data = std::make_unique<${struct_name}>(); +% for parameter in moniker_input_parameters: <% parameter_name = common_helpers.get_cpp_local_name(parameter) %>\ data->${parameter_name} = ${parameter_name}; % endfor - - -## Initialize an bgin input parameter for an API call. -<%def name="initialize_streaming_input_param(function_name, streaming_params_to_include, parameters, streaming_param)">\ -% for param in streaming_params_to_include: -${initialize_input_param(function_name, param, parameters)}\ -% endfor - + data->library = std::shared_ptr<${service_class_prefix}LibraryInterface>(library_); -<%def name="initialize_moniker_input_parameters(streaming_params_to_include)"> -% for parameter in streaming_params_to_include: +% for param in output_array_params: <% - parameter_name = common_helpers.get_cpp_local_name(parameter) + grpc_field_name = common_helpers.get_grpc_field_name(param) + size_param_name = service_helpers.get_size_param_name(param) %>\ - auto ${parameter_name} = function_data->${parameter_name}; + data->response.mutable_${grpc_field_name}()->Reserve(request->${size_param_name}()); + data->response.mutable_${grpc_field_name}()->Resize(request->${size_param_name}(), 0); % endfor -<%def name="initialize_moniker_output_parameters(output_params_to_define)">\ -% for parameter in output_params_to_define: +<%def name="initialize_moniker_input_parameters(moniker_input_parameters)">\ +% for parameter in moniker_input_parameters: <% parameter_name = common_helpers.get_cpp_local_name(parameter) -%> - ${parameter['type']} ${parameter_name} = {};\ -% endfor - - -<%def name="initialize_service_output_params(output_params, streaming_param)">\ -<% - size_param_name = service_helpers.get_size_param_name(streaming_param) -%> -% for param in output_params: -% if common_helpers.is_array(param['type']): - data->data.mutable_value()->Reserve(request->${size_param_name}()); - data->data.mutable_value()->Resize(request->${size_param_name}(), 0); -% endif +%>\ + auto ${parameter_name} = function_data->${parameter_name}; % endfor @@ -557,16 +498,16 @@ ${initialize_enum_array_input_param(function_name, parameter)} % elif common_helpers.is_enum(parameter): ${initialize_enum_input_param(function_name, parameter)} % elif 'hardcoded_value' in parameter: -${initialize_hardcoded_parameter(parameter)} + ${initialize_hardcoded_parameter(parameter)} % elif 'callback_token' in parameter or 'callback_params' in parameter: ## pass % elif "determine_size_from" in parameter: ${initialize_len_input_param(parameter, parameters)} % elif common_helpers.is_two_dimension_array_param(parameter): -${initialize_two_dimension_input_param(function_name, parameter, parameters)} +${initialize_two_dimension_input_param(parameter, parameters)} % elif service_helpers.is_size_param_passed_by_ptr(parameter): ${initialize_pointer_input_parameter(parameter)} % else: -${initialize_standard_input_param(function_name, parameter)} +${initialize_standard_input_param(parameter)} % endif @@ -793,14 +734,14 @@ ${initialize_standard_input_param(function_name, parameter)} ## Initialize an input parameter with the 'two-dimension' size mechanism. -<%def name="initialize_two_dimension_input_param(function_name, parameter, parameters)">\ +<%def name="initialize_two_dimension_input_param(parameter, parameters)">\ <% parameter_name = common_helpers.get_cpp_local_name(parameter) size_param_name = common_helpers.get_size_param(parameter) size_param = common_helpers.get_param_with_name(parameters, size_param_name) size_field_name = common_helpers.get_grpc_field_name(size_param) %>\ -${initialize_standard_input_param(function_name, parameter)} +${initialize_standard_input_param(parameter)} auto total_length = std::accumulate(request->${size_field_name}().cbegin(), request->${size_field_name}().cend(), 0); if (total_length != request->${parameter_name}_size()) { @@ -811,7 +752,7 @@ ${initialize_standard_input_param(function_name, parameter)} ## Initialize a 'hardcoded' param. <%def name="initialize_hardcoded_parameter(parameter)">\ - auto ${common_helpers.get_cpp_local_name(parameter)} = ${parameter['hardcoded_value']};\ + auto ${common_helpers.get_cpp_local_name(parameter)} = ${parameter['hardcoded_value']};\ ## Initialize an input parameter that's passed by pointer. @@ -821,7 +762,7 @@ ${initialize_standard_input_param(function_name, parameter)} ## Initialize an input parameter for an API call. -<%def name="initialize_standard_input_param(function_name, parameter)">\ +<%def name="initialize_standard_input_param(parameter)">\ <% config = data['config'] parameter_name = common_helpers.get_cpp_local_name(parameter) @@ -933,10 +874,11 @@ ${initialize_standard_input_param(function_name, parameter)} ## Initialize the output parameters for an API call. -<%def name="initialize_output_params(output_parameters)">\ +<%def name="initialize_output_params(output_parameters, indent_level=0)">\ <% output_parameters = common_helpers.get_params_needing_initialization(output_parameters) %>\ +<%block filter="common_helpers.indent(indent_level)">\ % for parameter in output_parameters: <% parameter_name = common_helpers.get_cpp_local_name(parameter) @@ -944,55 +886,56 @@ ${initialize_standard_input_param(function_name, parameter)} grpc_type = parameter["grpc_type"] grpc_cpp_lib_type = service_helpers.get_protobuf_cpplib_type(grpc_type) %>\ -% if 'hardcoded_value' in parameter: +% if 'hardcoded_value' in parameter: ${initialize_hardcoded_parameter(parameter)} -% elif common_helpers.supports_standard_output_allocation_routines(parameter): - auto ${parameter_name} = allocate_output_storage<${underlying_param_type}, ${grpc_cpp_lib_type}>(${str.join(", ", parameter.get("additional_arguments_to_output_allocation", []))}); -% elif common_helpers.is_repeating_parameter(parameter): - auto get_${parameter_name}_if = [](std::vector<${underlying_param_type}>& vector, int n) -> ${underlying_param_type}* { - if (vector.size() > n) { +% elif common_helpers.supports_standard_output_allocation_routines(parameter): + auto ${parameter_name} = allocate_output_storage<${underlying_param_type}, ${grpc_cpp_lib_type}>(${str.join(", ", parameter.get("additional_arguments_to_output_allocation", []))}); +% elif common_helpers.is_repeating_parameter(parameter): + auto get_${parameter_name}_if = [](std::vector<${underlying_param_type}>& vector, int n) -> ${underlying_param_type}* { + if (vector.size() > n) { ## Note that this code will not handle every datatype, but it works for all ## the ones we currently use with repeated varargs. - return &(vector[n]); - } - return nullptr; - }; - std::vector<${underlying_param_type}> ${parameter_name}Vector; -% elif common_helpers.is_repeated_varargs_parameter(parameter): # pass -% elif common_helpers.is_array(parameter['type']): + return &(vector[n]); + } + return nullptr; + }; + std::vector<${underlying_param_type}> ${parameter_name}Vector; +% elif common_helpers.is_repeated_varargs_parameter(parameter): # pass +% elif common_helpers.is_array(parameter['type']): <% buffer_size = common_helpers.get_buffer_size_expression(parameter) size = common_helpers.get_size_expression(parameter) %>\ -% if common_helpers.supports_standard_copy_conversion_routines(parameter): - std::vector<${underlying_param_type}> ${parameter_name}(${size}, ${underlying_param_type}()); +% if common_helpers.supports_standard_copy_conversion_routines(parameter): + std::vector<${underlying_param_type}> ${parameter_name}(${size}, ${underlying_param_type}()); ## Byte arrays are leveraging a string as a buffer, so we don't need to take special consideration of the null terminator. -% elif grpc_type == 'bytes': - std::string ${parameter_name}(${size}, '\0'); +% elif grpc_type == 'bytes': + std::string ${parameter_name}(${size}, '\0'); ## Driver string APIs require room in the buffer for the null terminator. We need to account for that when sizing the string. -% elif common_helpers.is_string_arg(parameter) and common_helpers.get_size_mechanism(parameter) == 'fixed': - std::string ${parameter_name}(${size}, '\0'); -% elif common_helpers.is_string_arg(parameter): - std::string ${parameter_name}; - if (${buffer_size} > 0) { - ${parameter_name}.resize(${size}); - } -% elif service_helpers.is_output_array_that_needs_coercion(parameter): - std::vector<${underlying_param_type}> ${parameter_name}(${size}); -% elif common_helpers.is_enum(parameter): - response->mutable_${parameter_name}_raw()->Resize(${size}, 0); - ${underlying_param_type}* ${parameter_name} = reinterpret_cast<${underlying_param_type}*>(response->mutable_${parameter_name}_raw()->mutable_data()); -% elif common_helpers.is_driver_typedef_with_same_size_but_different_qualifiers(underlying_param_type): - response->mutable_${parameter_name}()->Resize(${size}, 0); - ${underlying_param_type}* ${parameter_name} = reinterpret_cast<${underlying_param_type}*>(response->mutable_${parameter_name}()->mutable_data()); -% else: - response->mutable_${parameter_name}()->Resize(${size}, 0); - ${underlying_param_type}* ${parameter_name} = response->mutable_${parameter_name}()->mutable_data(); -% endif +% elif common_helpers.is_string_arg(parameter) and common_helpers.get_size_mechanism(parameter) == 'fixed': + std::string ${parameter_name}(${size}, '\0'); +% elif common_helpers.is_string_arg(parameter): + std::string ${parameter_name}; + if (${buffer_size} > 0) { + ${parameter_name}.resize(${size}); + } +% elif service_helpers.is_output_array_that_needs_coercion(parameter): + std::vector<${underlying_param_type}> ${parameter_name}(${size}); +% elif common_helpers.is_enum(parameter): + response->mutable_${parameter_name}_raw()->Resize(${size}, 0); + ${underlying_param_type}* ${parameter_name} = reinterpret_cast<${underlying_param_type}*>(response->mutable_${parameter_name}_raw()->mutable_data()); +% elif common_helpers.is_driver_typedef_with_same_size_but_different_qualifiers(underlying_param_type): + response->mutable_${parameter_name}()->Resize(${size}, 0); + ${underlying_param_type}* ${parameter_name} = reinterpret_cast<${underlying_param_type}*>(response->mutable_${parameter_name}()->mutable_data()); % else: - ${underlying_param_type} ${parameter_name} {}; + response->mutable_${parameter_name}()->Resize(${size}, 0); + ${underlying_param_type}* ${parameter_name} = response->mutable_${parameter_name}()->mutable_data(); % endif +% else: + ${underlying_param_type} ${parameter_name} {}; +% endif % endfor +\ diff --git a/source/tests/integration/ni_fake_fpga_streaming_tests.cpp b/source/tests/integration/ni_fake_fpga_streaming_tests.cpp index a4026c802..6382a101f 100644 --- a/source/tests/integration/ni_fake_fpga_streaming_tests.cpp +++ b/source/tests/integration/ni_fake_fpga_streaming_tests.cpp @@ -133,8 +133,8 @@ TEST_F(NiFakeFpgaStreamingTests, StreamRead_scalar) for (int i = 0; i < 5; i++) { // Read data - nifpga_grpc::I32Data read_value_i32; - nifpga_grpc::I64Data read_value_i64; + nifpga_grpc::ReadI32StreamingResponse read_value_i32; + nifpga_grpc::ReadI64StreamingResponse read_value_i64; ni::data_monikers::MonikerReadResponse read_result; stream->Read(&read_result); @@ -181,18 +181,18 @@ TEST_F(NiFakeFpgaStreamingTests, StreamRead_Array) for (int i = 0; i < 5; i++) { // Read data - nifpga_grpc::ArrayI32Data read_values_i32; - nifpga_grpc::ArrayI64Data read_values_i64; + nifpga_grpc::ReadArrayI32StreamingResponse read_values_i32; + nifpga_grpc::ReadArrayI64StreamingResponse read_values_i64; ni::data_monikers::MonikerReadResponse read_result; stream->Read(&read_result); read_result.data().values(0).UnpackTo(&read_values_i32); read_result.data().values(1).UnpackTo(&read_values_i64); - ASSERT_THAT(read_values_i32.value(), SizeIs(10)); - ASSERT_THAT(read_values_i32.value(), ElementsAreArray(data_int_i32)); - ASSERT_THAT(read_values_i64.value(), SizeIs(9)); - ASSERT_THAT(read_values_i64.value(), ElementsAreArray(data_int_i64)); + ASSERT_THAT(read_values_i32.array(), SizeIs(10)); + ASSERT_THAT(read_values_i32.array(), ElementsAreArray(data_int_i32)); + ASSERT_THAT(read_values_i64.array(), SizeIs(9)); + ASSERT_THAT(read_values_i64.array(), ElementsAreArray(data_int_i64)); } moniker_context.TryCancel(); @@ -319,18 +319,18 @@ TEST_F(NiFakeFpgaStreamingTests, StreamReadWrite_Array) write_stream->Write(write_data_request); - nifpga_grpc::ArrayI32Data read_values_i32; - nifpga_grpc::ArrayI64Data read_values_i64; + nifpga_grpc::ReadArrayI32StreamingResponse read_values_i32; + nifpga_grpc::ReadArrayI64StreamingResponse read_values_i64; ni::data_monikers::MonikerReadResponse read_result; write_stream->Read(&read_result); read_result.data().values(0).UnpackTo(&read_values_i32); read_result.data().values(1).UnpackTo(&read_values_i64); - ASSERT_THAT(read_values_i32.value(), SizeIs(read_size_i32)); - ASSERT_THAT(read_values_i32.value(), ElementsAreArray(read_data_int32)); - ASSERT_THAT(read_values_i64.value(), SizeIs(read_size_i64)); - ASSERT_THAT(read_values_i64.value(), ElementsAreArray(read_data_int64)); + ASSERT_THAT(read_values_i32.array(), SizeIs(read_size_i32)); + ASSERT_THAT(read_values_i32.array(), ElementsAreArray(read_data_int32)); + ASSERT_THAT(read_values_i64.array(), SizeIs(read_size_i64)); + ASSERT_THAT(read_values_i64.array(), ElementsAreArray(read_data_int64)); } write_stream->WritesDone(); @@ -405,18 +405,18 @@ TEST_F(NiFakeFpgaStreamingTests, DISABLED_SidebandStreamReadWrite_Array) WriteSidebandMessage(sideband_token, write_data_request); - nifpga_grpc::ArrayI32Data read_values_i32; - nifpga_grpc::ArrayI64Data read_values_i64; + nifpga_grpc::ReadArrayI32StreamingResponse read_values_i32; + nifpga_grpc::ReadArrayI64StreamingResponse read_values_i64; ni::data_monikers::SidebandReadResponse read_result; ReadSidebandMessage(sideband_token, &read_result); read_result.values().values(0).UnpackTo(&read_values_i32); read_result.values().values(1).UnpackTo(&read_values_i64); - ASSERT_THAT(read_values_i32.value(), SizeIs(10)); - ASSERT_THAT(read_values_i32.value(), ElementsAreArray(data_int32)); - ASSERT_THAT(read_values_i64.value(), SizeIs(9)); - ASSERT_THAT(read_values_i64.value(), ElementsAreArray(data_int64)); + ASSERT_THAT(read_values_i32.array(), SizeIs(10)); + ASSERT_THAT(read_values_i32.array(), ElementsAreArray(data_int32)); + ASSERT_THAT(read_values_i64.array(), SizeIs(9)); + ASSERT_THAT(read_values_i64.array(), ElementsAreArray(data_int64)); } ni::data_monikers::SidebandWriteRequest cancel_request;