From 8f66808aa9c3785b634024b9c0436a4402a70062 Mon Sep 17 00:00:00 2001 From: Raghav-NI <129742249+Raghav-NI@users.noreply.github.com> Date: Thu, 28 Nov 2024 14:34:26 +0530 Subject: [PATCH] Add codegen support for Daqmx Write apis which have multiple in params. (#1130) * add new meesage to proto for moniker streaming call * work-in-progress: codegen changes for service.cpp generation with response on moniker out param * run codegen after resolving merge conflicts * return failure error code from moniker APIs * update proto and struct to contain request and response messages * standardize to send output in response parameter for moniker APIs * fix black formatter issues * fix build error * cleanup scripts * fix tests * script and cpp cleanup * codegen for read apis with multiple out params * added condition to call reserve and resize functions for some param types * add type hints for python helpers * fix black formatter issues * return error status from Write* moniker functions * fix type hints * codegen for write apis with multiple out params * merged latest main * cleanup * resolved build errors * fixed failing tests * removed comment from code --------- Co-authored-by: Rohan Doshi Co-authored-by: Raghav Rawat --- generated/nidaqmx/nidaqmx.proto | 218 ++++ generated/nidaqmx/nidaqmx_client.cpp | 217 ++++ generated/nidaqmx/nidaqmx_client.h | 9 + generated/nidaqmx/nidaqmx_service.cpp | 1126 ++++++++++++++--- generated/nidaqmx/nidaqmx_service.h | 18 + generated/nifpga/nifpga_service.cpp | 344 ++--- source/codegen/common_helpers.py | 8 + source/codegen/metadata/nidaqmx/functions.py | 69 +- source/codegen/service_helpers.py | 11 - source/codegen/templates/service_helpers.mako | 76 +- .../ni_fake_fpga_streaming_tests.cpp | 24 +- 11 files changed, 1660 insertions(+), 460 deletions(-) diff --git a/generated/nidaqmx/nidaqmx.proto b/generated/nidaqmx/nidaqmx.proto index abfc5f4f3..716e79568 100644 --- a/generated/nidaqmx/nidaqmx.proto +++ b/generated/nidaqmx/nidaqmx.proto @@ -438,12 +438,19 @@ service NiDAQmx { rpc WriteBinaryU32(WriteBinaryU32Request) returns (WriteBinaryU32Response); rpc BeginWriteBinaryU32(BeginWriteBinaryU32Request) returns (BeginWriteBinaryU32Response); rpc WriteCtrFreq(WriteCtrFreqRequest) returns (WriteCtrFreqResponse); + rpc BeginWriteCtrFreq(BeginWriteCtrFreqRequest) returns (BeginWriteCtrFreqResponse); rpc WriteCtrFreqScalar(WriteCtrFreqScalarRequest) returns (WriteCtrFreqScalarResponse); + rpc BeginWriteCtrFreqScalar(BeginWriteCtrFreqScalarRequest) returns (BeginWriteCtrFreqScalarResponse); rpc WriteCtrTicks(WriteCtrTicksRequest) returns (WriteCtrTicksResponse); + rpc BeginWriteCtrTicks(BeginWriteCtrTicksRequest) returns (BeginWriteCtrTicksResponse); rpc WriteCtrTicksScalar(WriteCtrTicksScalarRequest) returns (WriteCtrTicksScalarResponse); + rpc BeginWriteCtrTicksScalar(BeginWriteCtrTicksScalarRequest) returns (BeginWriteCtrTicksScalarResponse); rpc WriteCtrTime(WriteCtrTimeRequest) returns (WriteCtrTimeResponse); + rpc BeginWriteCtrTime(BeginWriteCtrTimeRequest) returns (BeginWriteCtrTimeResponse); rpc WriteCtrTimeScalar(WriteCtrTimeScalarRequest) returns (WriteCtrTimeScalarResponse); + rpc BeginWriteCtrTimeScalar(BeginWriteCtrTimeScalarRequest) returns (BeginWriteCtrTimeScalarResponse); rpc WriteDigitalLines(WriteDigitalLinesRequest) returns (WriteDigitalLinesResponse); + rpc BeginWriteDigitalLines(BeginWriteDigitalLinesRequest) returns (BeginWriteDigitalLinesResponse); rpc WriteDigitalScalarU32(WriteDigitalScalarU32Request) returns (WriteDigitalScalarU32Response); rpc BeginWriteDigitalScalarU32(BeginWriteDigitalScalarU32Request) returns (BeginWriteDigitalScalarU32Response); rpc WriteDigitalU16(WriteDigitalU16Request) returns (WriteDigitalU16Response); @@ -451,7 +458,9 @@ service NiDAQmx { rpc WriteDigitalU32(WriteDigitalU32Request) returns (WriteDigitalU32Response); rpc BeginWriteDigitalU32(BeginWriteDigitalU32Request) returns (BeginWriteDigitalU32Response); rpc WriteDigitalU8(WriteDigitalU8Request) returns (WriteDigitalU8Response); + rpc BeginWriteDigitalU8(BeginWriteDigitalU8Request) returns (BeginWriteDigitalU8Response); rpc WriteRaw(WriteRawRequest) returns (WriteRawResponse); + rpc BeginWriteRaw(BeginWriteRawRequest) returns (BeginWriteRawResponse); rpc WriteToTEDSFromArray(WriteToTEDSFromArrayRequest) returns (WriteToTEDSFromArrayResponse); rpc WriteToTEDSFromFile(WriteToTEDSFromFileRequest) returns (WriteToTEDSFromFileResponse); } @@ -11033,6 +11042,32 @@ message WriteCtrFreqResponse { int32 num_samps_per_chan_written = 2; } +message BeginWriteCtrFreqRequest { + nidevice_grpc.Session task = 1; + int32 num_samps_per_chan = 2; + bool auto_start = 3; + double timeout = 4; + oneof data_layout_enum { + GroupBy data_layout = 5; + int32 data_layout_raw = 6; + } +} + +message BeginWriteCtrFreqResponse { + int32 status = 1; + ni.data_monikers.Moniker moniker = 2; +} + +message MonikerWriteCtrFreqRequest { + repeated double frequency = 1; + repeated double duty_cycle = 2; +} + +message MonikerWriteCtrFreqResponse { + int32 status = 1; + int32 num_samps_per_chan_written = 2; +} + message WriteCtrFreqScalarRequest { nidevice_grpc.Session task = 1; bool auto_start = 2; @@ -11045,6 +11080,26 @@ message WriteCtrFreqScalarResponse { int32 status = 1; } +message BeginWriteCtrFreqScalarRequest { + nidevice_grpc.Session task = 1; + bool auto_start = 2; + double timeout = 3; +} + +message BeginWriteCtrFreqScalarResponse { + int32 status = 1; + ni.data_monikers.Moniker moniker = 2; +} + +message MonikerWriteCtrFreqScalarRequest { + double frequency = 1; + double duty_cycle = 2; +} + +message MonikerWriteCtrFreqScalarResponse { + int32 status = 1; +} + message WriteCtrTicksRequest { nidevice_grpc.Session task = 1; int32 num_samps_per_chan = 2; @@ -11063,6 +11118,32 @@ message WriteCtrTicksResponse { int32 num_samps_per_chan_written = 2; } +message BeginWriteCtrTicksRequest { + nidevice_grpc.Session task = 1; + int32 num_samps_per_chan = 2; + bool auto_start = 3; + double timeout = 4; + oneof data_layout_enum { + GroupBy data_layout = 5; + int32 data_layout_raw = 6; + } +} + +message BeginWriteCtrTicksResponse { + int32 status = 1; + ni.data_monikers.Moniker moniker = 2; +} + +message MonikerWriteCtrTicksRequest { + repeated uint32 high_ticks = 1; + repeated uint32 low_ticks = 2; +} + +message MonikerWriteCtrTicksResponse { + int32 status = 1; + int32 num_samps_per_chan_written = 2; +} + message WriteCtrTicksScalarRequest { nidevice_grpc.Session task = 1; bool auto_start = 2; @@ -11075,6 +11156,26 @@ message WriteCtrTicksScalarResponse { int32 status = 1; } +message BeginWriteCtrTicksScalarRequest { + nidevice_grpc.Session task = 1; + bool auto_start = 2; + double timeout = 3; +} + +message BeginWriteCtrTicksScalarResponse { + int32 status = 1; + ni.data_monikers.Moniker moniker = 2; +} + +message MonikerWriteCtrTicksScalarRequest { + uint32 high_ticks = 1; + uint32 low_ticks = 2; +} + +message MonikerWriteCtrTicksScalarResponse { + int32 status = 1; +} + message WriteCtrTimeRequest { nidevice_grpc.Session task = 1; int32 num_samps_per_chan = 2; @@ -11093,6 +11194,32 @@ message WriteCtrTimeResponse { int32 num_samps_per_chan_written = 2; } +message BeginWriteCtrTimeRequest { + nidevice_grpc.Session task = 1; + int32 num_samps_per_chan = 2; + bool auto_start = 3; + double timeout = 4; + oneof data_layout_enum { + GroupBy data_layout = 5; + int32 data_layout_raw = 6; + } +} + +message BeginWriteCtrTimeResponse { + int32 status = 1; + ni.data_monikers.Moniker moniker = 2; +} + +message MonikerWriteCtrTimeRequest { + repeated double high_time = 1; + repeated double low_time = 2; +} + +message MonikerWriteCtrTimeResponse { + int32 status = 1; + int32 num_samps_per_chan_written = 2; +} + message WriteCtrTimeScalarRequest { nidevice_grpc.Session task = 1; bool auto_start = 2; @@ -11105,6 +11232,26 @@ message WriteCtrTimeScalarResponse { int32 status = 1; } +message BeginWriteCtrTimeScalarRequest { + nidevice_grpc.Session task = 1; + bool auto_start = 2; + double timeout = 3; +} + +message BeginWriteCtrTimeScalarResponse { + int32 status = 1; + ni.data_monikers.Moniker moniker = 2; +} + +message MonikerWriteCtrTimeScalarRequest { + double high_time = 1; + double low_time = 2; +} + +message MonikerWriteCtrTimeScalarResponse { + int32 status = 1; +} + message WriteDigitalLinesRequest { nidevice_grpc.Session task = 1; int32 num_samps_per_chan = 2; @@ -11122,6 +11269,31 @@ message WriteDigitalLinesResponse { int32 samps_per_chan_written = 2; } +message BeginWriteDigitalLinesRequest { + nidevice_grpc.Session task = 1; + int32 num_samps_per_chan = 2; + bool auto_start = 3; + double timeout = 4; + oneof data_layout_enum { + GroupBy data_layout = 5; + int32 data_layout_raw = 6; + } +} + +message BeginWriteDigitalLinesResponse { + int32 status = 1; + ni.data_monikers.Moniker moniker = 2; +} + +message MonikerWriteDigitalLinesRequest { + bytes write_array = 1; +} + +message MonikerWriteDigitalLinesResponse { + int32 status = 1; + int32 samps_per_chan_written = 2; +} + message WriteDigitalScalarU32Request { nidevice_grpc.Session task = 1; bool auto_start = 2; @@ -11253,6 +11425,31 @@ message WriteDigitalU8Response { int32 samps_per_chan_written = 2; } +message BeginWriteDigitalU8Request { + nidevice_grpc.Session task = 1; + int32 num_samps_per_chan = 2; + bool auto_start = 3; + double timeout = 4; + oneof data_layout_enum { + GroupBy data_layout = 5; + int32 data_layout_raw = 6; + } +} + +message BeginWriteDigitalU8Response { + int32 status = 1; + ni.data_monikers.Moniker moniker = 2; +} + +message MonikerWriteDigitalU8Request { + bytes write_array = 1; +} + +message MonikerWriteDigitalU8Response { + int32 status = 1; + int32 samps_per_chan_written = 2; +} + message WriteRawRequest { nidevice_grpc.Session task = 1; int32 num_samps = 2; @@ -11266,6 +11463,27 @@ message WriteRawResponse { int32 samps_per_chan_written = 2; } +message BeginWriteRawRequest { + nidevice_grpc.Session task = 1; + int32 num_samps = 2; + bool auto_start = 3; + double timeout = 4; +} + +message BeginWriteRawResponse { + int32 status = 1; + ni.data_monikers.Moniker moniker = 2; +} + +message MonikerWriteRawRequest { + bytes write_array = 1; +} + +message MonikerWriteRawResponse { + int32 status = 1; + int32 samps_per_chan_written = 2; +} + message WriteToTEDSFromArrayRequest { string physical_channel = 1; bytes bit_stream = 2; diff --git a/generated/nidaqmx/nidaqmx_client.cpp b/generated/nidaqmx/nidaqmx_client.cpp index ac5dd5f34..f7e4f9956 100644 --- a/generated/nidaqmx/nidaqmx_client.cpp +++ b/generated/nidaqmx/nidaqmx_client.cpp @@ -11751,6 +11751,34 @@ write_ctr_freq(const StubPtr& stub, const nidevice_grpc::Session& task, const pb return response; } +BeginWriteCtrFreqResponse +begin_write_ctr_freq(const StubPtr& stub, const nidevice_grpc::Session& task, const pb::int32& num_samps_per_chan, const bool& auto_start, const double& timeout, const simple_variant& data_layout) +{ + ::grpc::ClientContext context; + + auto request = BeginWriteCtrFreqRequest{}; + request.mutable_task()->CopyFrom(task); + request.set_num_samps_per_chan(num_samps_per_chan); + request.set_auto_start(auto_start); + request.set_timeout(timeout); + const auto data_layout_ptr = data_layout.get_if(); + const auto data_layout_raw_ptr = data_layout.get_if(); + if (data_layout_ptr) { + request.set_data_layout(*data_layout_ptr); + } + else if (data_layout_raw_ptr) { + request.set_data_layout_raw(*data_layout_raw_ptr); + } + + auto response = BeginWriteCtrFreqResponse{}; + + raise_if_error( + stub->BeginWriteCtrFreq(&context, request, &response), + context); + + return response; +} + WriteCtrFreqScalarResponse write_ctr_freq_scalar(const StubPtr& stub, const nidevice_grpc::Session& task, const bool& auto_start, const double& timeout, const double& frequency, const double& duty_cycle) { @@ -11772,6 +11800,25 @@ write_ctr_freq_scalar(const StubPtr& stub, const nidevice_grpc::Session& task, c return response; } +BeginWriteCtrFreqScalarResponse +begin_write_ctr_freq_scalar(const StubPtr& stub, const nidevice_grpc::Session& task, const bool& auto_start, const double& timeout) +{ + ::grpc::ClientContext context; + + auto request = BeginWriteCtrFreqScalarRequest{}; + request.mutable_task()->CopyFrom(task); + request.set_auto_start(auto_start); + request.set_timeout(timeout); + + auto response = BeginWriteCtrFreqScalarResponse{}; + + raise_if_error( + stub->BeginWriteCtrFreqScalar(&context, request, &response), + context); + + return response; +} + WriteCtrTicksResponse write_ctr_ticks(const StubPtr& stub, const nidevice_grpc::Session& task, const pb::int32& num_samps_per_chan, const bool& auto_start, const double& timeout, const simple_variant& data_layout, const std::vector& high_ticks, const std::vector& low_ticks) { @@ -11802,6 +11849,34 @@ write_ctr_ticks(const StubPtr& stub, const nidevice_grpc::Session& task, const p return response; } +BeginWriteCtrTicksResponse +begin_write_ctr_ticks(const StubPtr& stub, const nidevice_grpc::Session& task, const pb::int32& num_samps_per_chan, const bool& auto_start, const double& timeout, const simple_variant& data_layout) +{ + ::grpc::ClientContext context; + + auto request = BeginWriteCtrTicksRequest{}; + request.mutable_task()->CopyFrom(task); + request.set_num_samps_per_chan(num_samps_per_chan); + request.set_auto_start(auto_start); + request.set_timeout(timeout); + const auto data_layout_ptr = data_layout.get_if(); + const auto data_layout_raw_ptr = data_layout.get_if(); + if (data_layout_ptr) { + request.set_data_layout(*data_layout_ptr); + } + else if (data_layout_raw_ptr) { + request.set_data_layout_raw(*data_layout_raw_ptr); + } + + auto response = BeginWriteCtrTicksResponse{}; + + raise_if_error( + stub->BeginWriteCtrTicks(&context, request, &response), + context); + + return response; +} + WriteCtrTicksScalarResponse write_ctr_ticks_scalar(const StubPtr& stub, const nidevice_grpc::Session& task, const bool& auto_start, const double& timeout, const pb::uint32& high_ticks, const pb::uint32& low_ticks) { @@ -11823,6 +11898,25 @@ write_ctr_ticks_scalar(const StubPtr& stub, const nidevice_grpc::Session& task, return response; } +BeginWriteCtrTicksScalarResponse +begin_write_ctr_ticks_scalar(const StubPtr& stub, const nidevice_grpc::Session& task, const bool& auto_start, const double& timeout) +{ + ::grpc::ClientContext context; + + auto request = BeginWriteCtrTicksScalarRequest{}; + request.mutable_task()->CopyFrom(task); + request.set_auto_start(auto_start); + request.set_timeout(timeout); + + auto response = BeginWriteCtrTicksScalarResponse{}; + + raise_if_error( + stub->BeginWriteCtrTicksScalar(&context, request, &response), + context); + + return response; +} + WriteCtrTimeResponse write_ctr_time(const StubPtr& stub, const nidevice_grpc::Session& task, const pb::int32& num_samps_per_chan, const bool& auto_start, const double& timeout, const simple_variant& data_layout, const std::vector& high_time, const std::vector& low_time) { @@ -11853,6 +11947,34 @@ write_ctr_time(const StubPtr& stub, const nidevice_grpc::Session& task, const pb return response; } +BeginWriteCtrTimeResponse +begin_write_ctr_time(const StubPtr& stub, const nidevice_grpc::Session& task, const pb::int32& num_samps_per_chan, const bool& auto_start, const double& timeout, const simple_variant& data_layout) +{ + ::grpc::ClientContext context; + + auto request = BeginWriteCtrTimeRequest{}; + request.mutable_task()->CopyFrom(task); + request.set_num_samps_per_chan(num_samps_per_chan); + request.set_auto_start(auto_start); + request.set_timeout(timeout); + const auto data_layout_ptr = data_layout.get_if(); + const auto data_layout_raw_ptr = data_layout.get_if(); + if (data_layout_ptr) { + request.set_data_layout(*data_layout_ptr); + } + else if (data_layout_raw_ptr) { + request.set_data_layout_raw(*data_layout_raw_ptr); + } + + auto response = BeginWriteCtrTimeResponse{}; + + raise_if_error( + stub->BeginWriteCtrTime(&context, request, &response), + context); + + return response; +} + WriteCtrTimeScalarResponse write_ctr_time_scalar(const StubPtr& stub, const nidevice_grpc::Session& task, const bool& auto_start, const double& timeout, const double& high_time, const double& low_time) { @@ -11874,6 +11996,25 @@ write_ctr_time_scalar(const StubPtr& stub, const nidevice_grpc::Session& task, c return response; } +BeginWriteCtrTimeScalarResponse +begin_write_ctr_time_scalar(const StubPtr& stub, const nidevice_grpc::Session& task, const bool& auto_start, const double& timeout) +{ + ::grpc::ClientContext context; + + auto request = BeginWriteCtrTimeScalarRequest{}; + request.mutable_task()->CopyFrom(task); + request.set_auto_start(auto_start); + request.set_timeout(timeout); + + auto response = BeginWriteCtrTimeScalarResponse{}; + + raise_if_error( + stub->BeginWriteCtrTimeScalar(&context, request, &response), + context); + + return response; +} + WriteDigitalLinesResponse write_digital_lines(const StubPtr& stub, const nidevice_grpc::Session& task, const pb::int32& num_samps_per_chan, const bool& auto_start, const double& timeout, const simple_variant& data_layout, const std::string& write_array) { @@ -11903,6 +12044,34 @@ write_digital_lines(const StubPtr& stub, const nidevice_grpc::Session& task, con return response; } +BeginWriteDigitalLinesResponse +begin_write_digital_lines(const StubPtr& stub, const nidevice_grpc::Session& task, const pb::int32& num_samps_per_chan, const bool& auto_start, const double& timeout, const simple_variant& data_layout) +{ + ::grpc::ClientContext context; + + auto request = BeginWriteDigitalLinesRequest{}; + request.mutable_task()->CopyFrom(task); + request.set_num_samps_per_chan(num_samps_per_chan); + request.set_auto_start(auto_start); + request.set_timeout(timeout); + const auto data_layout_ptr = data_layout.get_if(); + const auto data_layout_raw_ptr = data_layout.get_if(); + if (data_layout_ptr) { + request.set_data_layout(*data_layout_ptr); + } + else if (data_layout_raw_ptr) { + request.set_data_layout_raw(*data_layout_raw_ptr); + } + + auto response = BeginWriteDigitalLinesResponse{}; + + raise_if_error( + stub->BeginWriteDigitalLines(&context, request, &response), + context); + + return response; +} + WriteDigitalScalarU32Response write_digital_scalar_u32(const StubPtr& stub, const nidevice_grpc::Session& task, const bool& auto_start, const double& timeout, const pb::uint32& value) { @@ -12085,6 +12254,34 @@ write_digital_u8(const StubPtr& stub, const nidevice_grpc::Session& task, const return response; } +BeginWriteDigitalU8Response +begin_write_digital_u8(const StubPtr& stub, const nidevice_grpc::Session& task, const pb::int32& num_samps_per_chan, const bool& auto_start, const double& timeout, const simple_variant& data_layout) +{ + ::grpc::ClientContext context; + + auto request = BeginWriteDigitalU8Request{}; + request.mutable_task()->CopyFrom(task); + request.set_num_samps_per_chan(num_samps_per_chan); + request.set_auto_start(auto_start); + request.set_timeout(timeout); + const auto data_layout_ptr = data_layout.get_if(); + const auto data_layout_raw_ptr = data_layout.get_if(); + if (data_layout_ptr) { + request.set_data_layout(*data_layout_ptr); + } + else if (data_layout_raw_ptr) { + request.set_data_layout_raw(*data_layout_raw_ptr); + } + + auto response = BeginWriteDigitalU8Response{}; + + raise_if_error( + stub->BeginWriteDigitalU8(&context, request, &response), + context); + + return response; +} + WriteRawResponse write_raw(const StubPtr& stub, const nidevice_grpc::Session& task, const pb::int32& num_samps, const bool& auto_start, const double& timeout, const std::string& write_array) { @@ -12106,6 +12303,26 @@ write_raw(const StubPtr& stub, const nidevice_grpc::Session& task, const pb::int return response; } +BeginWriteRawResponse +begin_write_raw(const StubPtr& stub, const nidevice_grpc::Session& task, const pb::int32& num_samps, const bool& auto_start, const double& timeout) +{ + ::grpc::ClientContext context; + + auto request = BeginWriteRawRequest{}; + request.mutable_task()->CopyFrom(task); + request.set_num_samps(num_samps); + request.set_auto_start(auto_start); + request.set_timeout(timeout); + + auto response = BeginWriteRawResponse{}; + + raise_if_error( + stub->BeginWriteRaw(&context, request, &response), + context); + + return response; +} + WriteToTEDSFromArrayResponse write_to_teds_from_array(const StubPtr& stub, const std::string& physical_channel, const std::string& bit_stream, const simple_variant& basic_teds_options) { diff --git a/generated/nidaqmx/nidaqmx_client.h b/generated/nidaqmx/nidaqmx_client.h index ee3164265..0c7022af0 100644 --- a/generated/nidaqmx/nidaqmx_client.h +++ b/generated/nidaqmx/nidaqmx_client.h @@ -441,12 +441,19 @@ BeginWriteBinaryU16Response begin_write_binary_u16(const StubPtr& stub, const ni WriteBinaryU32Response write_binary_u32(const StubPtr& stub, const nidevice_grpc::Session& task, const pb::int32& num_samps_per_chan, const bool& auto_start, const double& timeout, const simple_variant& data_layout, const std::vector& write_array); BeginWriteBinaryU32Response begin_write_binary_u32(const StubPtr& stub, const nidevice_grpc::Session& task, const pb::int32& num_samps_per_chan, const bool& auto_start, const double& timeout, const simple_variant& data_layout); WriteCtrFreqResponse write_ctr_freq(const StubPtr& stub, const nidevice_grpc::Session& task, const pb::int32& num_samps_per_chan, const bool& auto_start, const double& timeout, const simple_variant& data_layout, const std::vector& frequency, const std::vector& duty_cycle); +BeginWriteCtrFreqResponse begin_write_ctr_freq(const StubPtr& stub, const nidevice_grpc::Session& task, const pb::int32& num_samps_per_chan, const bool& auto_start, const double& timeout, const simple_variant& data_layout); WriteCtrFreqScalarResponse write_ctr_freq_scalar(const StubPtr& stub, const nidevice_grpc::Session& task, const bool& auto_start, const double& timeout, const double& frequency, const double& duty_cycle); +BeginWriteCtrFreqScalarResponse begin_write_ctr_freq_scalar(const StubPtr& stub, const nidevice_grpc::Session& task, const bool& auto_start, const double& timeout); WriteCtrTicksResponse write_ctr_ticks(const StubPtr& stub, const nidevice_grpc::Session& task, const pb::int32& num_samps_per_chan, const bool& auto_start, const double& timeout, const simple_variant& data_layout, const std::vector& high_ticks, const std::vector& low_ticks); +BeginWriteCtrTicksResponse begin_write_ctr_ticks(const StubPtr& stub, const nidevice_grpc::Session& task, const pb::int32& num_samps_per_chan, const bool& auto_start, const double& timeout, const simple_variant& data_layout); WriteCtrTicksScalarResponse write_ctr_ticks_scalar(const StubPtr& stub, const nidevice_grpc::Session& task, const bool& auto_start, const double& timeout, const pb::uint32& high_ticks, const pb::uint32& low_ticks); +BeginWriteCtrTicksScalarResponse begin_write_ctr_ticks_scalar(const StubPtr& stub, const nidevice_grpc::Session& task, const bool& auto_start, const double& timeout); WriteCtrTimeResponse write_ctr_time(const StubPtr& stub, const nidevice_grpc::Session& task, const pb::int32& num_samps_per_chan, const bool& auto_start, const double& timeout, const simple_variant& data_layout, const std::vector& high_time, const std::vector& low_time); +BeginWriteCtrTimeResponse begin_write_ctr_time(const StubPtr& stub, const nidevice_grpc::Session& task, const pb::int32& num_samps_per_chan, const bool& auto_start, const double& timeout, const simple_variant& data_layout); WriteCtrTimeScalarResponse write_ctr_time_scalar(const StubPtr& stub, const nidevice_grpc::Session& task, const bool& auto_start, const double& timeout, const double& high_time, const double& low_time); +BeginWriteCtrTimeScalarResponse begin_write_ctr_time_scalar(const StubPtr& stub, const nidevice_grpc::Session& task, const bool& auto_start, const double& timeout); WriteDigitalLinesResponse write_digital_lines(const StubPtr& stub, const nidevice_grpc::Session& task, const pb::int32& num_samps_per_chan, const bool& auto_start, const double& timeout, const simple_variant& data_layout, const std::string& write_array); +BeginWriteDigitalLinesResponse begin_write_digital_lines(const StubPtr& stub, const nidevice_grpc::Session& task, const pb::int32& num_samps_per_chan, const bool& auto_start, const double& timeout, const simple_variant& data_layout); WriteDigitalScalarU32Response write_digital_scalar_u32(const StubPtr& stub, const nidevice_grpc::Session& task, const bool& auto_start, const double& timeout, const pb::uint32& value); BeginWriteDigitalScalarU32Response begin_write_digital_scalar_u32(const StubPtr& stub, const nidevice_grpc::Session& task, const bool& auto_start, const double& timeout); WriteDigitalU16Response write_digital_u16(const StubPtr& stub, const nidevice_grpc::Session& task, const pb::int32& num_samps_per_chan, const bool& auto_start, const double& timeout, const simple_variant& data_layout, const std::vector& write_array); @@ -454,7 +461,9 @@ BeginWriteDigitalU16Response begin_write_digital_u16(const StubPtr& stub, const WriteDigitalU32Response write_digital_u32(const StubPtr& stub, const nidevice_grpc::Session& task, const pb::int32& num_samps_per_chan, const bool& auto_start, const double& timeout, const simple_variant& data_layout, const std::vector& write_array); BeginWriteDigitalU32Response begin_write_digital_u32(const StubPtr& stub, const nidevice_grpc::Session& task, const pb::int32& num_samps_per_chan, const bool& auto_start, const double& timeout, const simple_variant& data_layout); WriteDigitalU8Response write_digital_u8(const StubPtr& stub, const nidevice_grpc::Session& task, const pb::int32& num_samps_per_chan, const bool& auto_start, const double& timeout, const simple_variant& data_layout, const std::string& write_array); +BeginWriteDigitalU8Response begin_write_digital_u8(const StubPtr& stub, const nidevice_grpc::Session& task, const pb::int32& num_samps_per_chan, const bool& auto_start, const double& timeout, const simple_variant& data_layout); WriteRawResponse write_raw(const StubPtr& stub, const nidevice_grpc::Session& task, const pb::int32& num_samps, const bool& auto_start, const double& timeout, const std::string& write_array); +BeginWriteRawResponse begin_write_raw(const StubPtr& stub, const nidevice_grpc::Session& task, const pb::int32& num_samps, const bool& auto_start, const double& timeout); WriteToTEDSFromArrayResponse write_to_teds_from_array(const StubPtr& stub, const std::string& physical_channel, const std::string& bit_stream, const simple_variant& basic_teds_options); WriteToTEDSFromFileResponse write_to_teds_from_file(const StubPtr& stub, const std::string& physical_channel, const std::string& file_path, const simple_variant& basic_teds_options); diff --git a/generated/nidaqmx/nidaqmx_service.cpp b/generated/nidaqmx/nidaqmx_service.cpp index 856dc772e..13a6e07a7 100644 --- a/generated/nidaqmx/nidaqmx_service.cpp +++ b/generated/nidaqmx/nidaqmx_service.cpp @@ -406,6 +406,91 @@ namespace nidaqmx_grpc { std::shared_ptr library; }; + struct MonikerWriteCtrFreqData + { + TaskHandle task; + int32 num_samps_per_chan; + bool32 auto_start; + float64 timeout; + int32 data_layout; + bool32* reserved; + nidaqmx_grpc::MonikerWriteCtrFreqRequest request; + nidaqmx_grpc::MonikerWriteCtrFreqResponse response; + std::shared_ptr library; + }; + + struct MonikerWriteCtrFreqScalarData + { + TaskHandle task; + bool32 auto_start; + float64 timeout; + bool32* reserved; + nidaqmx_grpc::MonikerWriteCtrFreqScalarRequest request; + nidaqmx_grpc::MonikerWriteCtrFreqScalarResponse response; + std::shared_ptr library; + }; + + struct MonikerWriteCtrTicksData + { + TaskHandle task; + int32 num_samps_per_chan; + bool32 auto_start; + float64 timeout; + int32 data_layout; + bool32* reserved; + nidaqmx_grpc::MonikerWriteCtrTicksRequest request; + nidaqmx_grpc::MonikerWriteCtrTicksResponse response; + std::shared_ptr library; + }; + + struct MonikerWriteCtrTicksScalarData + { + TaskHandle task; + bool32 auto_start; + float64 timeout; + bool32* reserved; + nidaqmx_grpc::MonikerWriteCtrTicksScalarRequest request; + nidaqmx_grpc::MonikerWriteCtrTicksScalarResponse response; + std::shared_ptr library; + }; + + struct MonikerWriteCtrTimeData + { + TaskHandle task; + int32 num_samps_per_chan; + bool32 auto_start; + float64 timeout; + int32 data_layout; + bool32* reserved; + nidaqmx_grpc::MonikerWriteCtrTimeRequest request; + nidaqmx_grpc::MonikerWriteCtrTimeResponse response; + std::shared_ptr library; + }; + + struct MonikerWriteCtrTimeScalarData + { + TaskHandle task; + bool32 auto_start; + float64 timeout; + bool32* reserved; + nidaqmx_grpc::MonikerWriteCtrTimeScalarRequest request; + nidaqmx_grpc::MonikerWriteCtrTimeScalarResponse response; + std::shared_ptr library; + }; + + struct MonikerWriteDigitalLinesData + { + TaskHandle task; + int32 num_samps_per_chan; + bool32 auto_start; + float64 timeout; + int32 data_layout; + bool32* reserved; + nidaqmx_grpc::MonikerWriteDigitalLinesRequest request; + nidaqmx_grpc::MonikerWriteDigitalLinesResponse response; + std::shared_ptr library; + }; + struct MonikerWriteDigitalScalarU32Data { TaskHandle task; @@ -443,6 +528,31 @@ namespace nidaqmx_grpc { std::shared_ptr library; }; + struct MonikerWriteDigitalU8Data + { + TaskHandle task; + int32 num_samps_per_chan; + bool32 auto_start; + float64 timeout; + int32 data_layout; + bool32* reserved; + nidaqmx_grpc::MonikerWriteDigitalU8Request request; + nidaqmx_grpc::MonikerWriteDigitalU8Response response; + std::shared_ptr library; + }; + + struct MonikerWriteRawData + { + TaskHandle task; + int32 num_samps; + bool32 auto_start; + float64 timeout; + bool32* reserved; + nidaqmx_grpc::MonikerWriteRawRequest request; + nidaqmx_grpc::MonikerWriteRawResponse response; + std::shared_ptr library; + }; + const auto kErrorReadBufferTooSmall = -200229; const auto kWarningCAPIStringTruncatedToFitBuffer = 200026; @@ -502,9 +612,18 @@ namespace nidaqmx_grpc { ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerWriteBinaryI32", MonikerWriteBinaryI32); ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerWriteBinaryU16", MonikerWriteBinaryU16); ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerWriteBinaryU32", MonikerWriteBinaryU32); + ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerWriteCtrFreq", MonikerWriteCtrFreq); + ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerWriteCtrFreqScalar", MonikerWriteCtrFreqScalar); + ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerWriteCtrTicks", MonikerWriteCtrTicks); + ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerWriteCtrTicksScalar", MonikerWriteCtrTicksScalar); + ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerWriteCtrTime", MonikerWriteCtrTime); + ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerWriteCtrTimeScalar", MonikerWriteCtrTimeScalar); + ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerWriteDigitalLines", MonikerWriteDigitalLines); ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerWriteDigitalScalarU32", MonikerWriteDigitalScalarU32); ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerWriteDigitalU16", MonikerWriteDigitalU16); ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerWriteDigitalU32", MonikerWriteDigitalU32); + ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerWriteDigitalU8", MonikerWriteDigitalU8); + ni::data_monikers::DataMonikerService::RegisterMonikerEndpoint("MonikerWriteRaw", MonikerWriteRaw); } ::grpc::Status MonikerReadAnalogF64(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData) @@ -1372,13 +1491,10 @@ ::grpc::Status MonikerWriteAnalogF64(void* data, google::protobuf::Arena& arena, auto data_layout = function_data->data_layout; auto reserved = function_data->reserved; int32 samps_per_chan_written {}; + auto request = &function_data->request; - ArrayDoubleData arraydoubledata_message; - packedData.UnpackTo(&arraydoubledata_message); - - auto data_array = arraydoubledata_message.value(); - auto write_array = const_cast(arraydoubledata_message.value().data()); - auto size = data_array.size(); + packedData.UnpackTo(request); + auto write_array = const_cast(request->write_array().data()); auto status = library->WriteAnalogF64(task, num_samps_per_chan, auto_start, timeout, data_layout, write_array, &samps_per_chan_written, reserved); @@ -1398,10 +1514,10 @@ ::grpc::Status MonikerWriteAnalogScalarF64(void* data, google::protobuf::Arena& auto auto_start = function_data->auto_start; auto timeout = function_data->timeout; auto reserved = function_data->reserved; + auto request = &function_data->request; - DoubleData doubledata_message; - packedData.UnpackTo(&doubledata_message); - auto value = doubledata_message.value(); + packedData.UnpackTo(request); + float64 value = request->value(); auto status = library->WriteAnalogScalarF64(task, auto_start, timeout, value, reserved); @@ -1424,25 +1540,27 @@ ::grpc::Status MonikerWriteBinaryI16(void* data, google::protobuf::Arena& arena, auto data_layout = function_data->data_layout; auto reserved = function_data->reserved; int32 samps_per_chan_written {}; + auto request = &function_data->request; + + packedData.UnpackTo(request); + auto write_array_raw = request->write_array(); + auto write_array = std::vector(); + write_array.reserve(write_array_raw.size()); + std::transform( + write_array_raw.begin(), + write_array_raw.end(), + std::back_inserter(write_array), + [](auto x) { + if (x < std::numeric_limits::min() || x > std::numeric_limits::max()) { + std::string message("value "); + message.append(std::to_string(x)); + message.append(" doesn't fit in datatype "); + message.append("int16"); + throw nidevice_grpc::ValueOutOfRangeException(message); + } + return static_cast(x); + }); - ArrayI16Data arrayi16data_message; - packedData.UnpackTo(&arrayi16data_message); - - auto data_array = arrayi16data_message.value(); - auto write_array = std::vector(); - auto size = data_array.size(); - write_array.reserve(size); - std::transform( - data_array.begin(), - data_array.end(), - std::back_inserter(write_array), - [](auto x) { - if (x < std::numeric_limits::min() || x > std::numeric_limits::max()) { - std::string message("value " + std::to_string(x) + " doesn't fit in datatype int16"); - throw nidevice_grpc::ValueOutOfRangeException(message); - } - return static_cast(x); - }); auto status = library->WriteBinaryI16(task, num_samps_per_chan, auto_start, timeout, data_layout, write_array.data(), &samps_per_chan_written, reserved); @@ -1465,13 +1583,10 @@ ::grpc::Status MonikerWriteBinaryI32(void* data, google::protobuf::Arena& arena, auto data_layout = function_data->data_layout; auto reserved = function_data->reserved; int32 samps_per_chan_written {}; + auto request = &function_data->request; - ArrayI32Data arrayi32data_message; - packedData.UnpackTo(&arrayi32data_message); - - auto data_array = arrayi32data_message.value(); - auto write_array = reinterpret_cast(arrayi32data_message.value().data()); - auto size = data_array.size(); + packedData.UnpackTo(request); + auto write_array = reinterpret_cast(request->write_array().data()); auto status = library->WriteBinaryI32(task, num_samps_per_chan, auto_start, timeout, data_layout, write_array, &samps_per_chan_written, reserved); @@ -1494,25 +1609,27 @@ ::grpc::Status MonikerWriteBinaryU16(void* data, google::protobuf::Arena& arena, auto data_layout = function_data->data_layout; auto reserved = function_data->reserved; int32 samps_per_chan_written {}; + auto request = &function_data->request; + + packedData.UnpackTo(request); + auto write_array_raw = request->write_array(); + auto write_array = std::vector(); + write_array.reserve(write_array_raw.size()); + std::transform( + write_array_raw.begin(), + write_array_raw.end(), + std::back_inserter(write_array), + [](auto x) { + if (x < std::numeric_limits::min() || x > std::numeric_limits::max()) { + std::string message("value "); + message.append(std::to_string(x)); + message.append(" doesn't fit in datatype "); + message.append("uInt16"); + throw nidevice_grpc::ValueOutOfRangeException(message); + } + return static_cast(x); + }); - ArrayU16Data arrayu16data_message; - packedData.UnpackTo(&arrayu16data_message); - - auto data_array = arrayu16data_message.value(); - auto write_array = std::vector(); - auto size = data_array.size(); - write_array.reserve(size); - std::transform( - data_array.begin(), - data_array.end(), - std::back_inserter(write_array), - [](auto x) { - if (x < std::numeric_limits::min() || x > std::numeric_limits::max()) { - std::string message("value " + std::to_string(x) + " doesn't fit in datatype uInt16"); - throw nidevice_grpc::ValueOutOfRangeException(message); - } - return static_cast(x); - }); auto status = library->WriteBinaryU16(task, num_samps_per_chan, auto_start, timeout, data_layout, write_array.data(), &samps_per_chan_written, reserved); @@ -1535,13 +1652,10 @@ ::grpc::Status MonikerWriteBinaryU32(void* data, google::protobuf::Arena& arena, auto data_layout = function_data->data_layout; auto reserved = function_data->reserved; int32 samps_per_chan_written {}; + auto request = &function_data->request; - ArrayU32Data arrayu32data_message; - packedData.UnpackTo(&arrayu32data_message); - - auto data_array = arrayu32data_message.value(); - auto write_array = reinterpret_cast(arrayu32data_message.value().data()); - auto size = data_array.size(); + packedData.UnpackTo(request); + auto write_array = reinterpret_cast(request->write_array().data()); auto status = library->WriteBinaryU32(task, num_samps_per_chan, auto_start, timeout, data_layout, write_array, &samps_per_chan_written, reserved); @@ -1552,21 +1666,25 @@ ::grpc::Status MonikerWriteBinaryU32(void* data, google::protobuf::Arena& arena, return ::grpc::Status::OK; } -::grpc::Status MonikerWriteDigitalScalarU32(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData) +::grpc::Status MonikerWriteCtrFreq(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData) { - MonikerWriteDigitalScalarU32Data* function_data = static_cast(data); + MonikerWriteCtrFreqData* 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 num_samps_per_chan_written {}; + auto request = &function_data->request; - U32Data u32data_message; - packedData.UnpackTo(&u32data_message); - auto value = u32data_message.value(); + packedData.UnpackTo(request); + auto frequency = const_cast(request->frequency().data()); + auto duty_cycle = const_cast(request->duty_cycle().data()); - auto status = library->WriteDigitalScalarU32(task, auto_start, timeout, value, reserved); + auto status = library->WriteCtrFreq(task, num_samps_per_chan, auto_start, timeout, data_layout, frequency, duty_cycle, &num_samps_per_chan_written, reserved); if (status < 0) { @@ -1575,39 +1693,22 @@ ::grpc::Status MonikerWriteDigitalScalarU32(void* data, google::protobuf::Arena& return ::grpc::Status::OK; } -::grpc::Status MonikerWriteDigitalU16(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData) +::grpc::Status MonikerWriteCtrFreqScalar(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData) { - MonikerWriteDigitalU16Data* function_data = static_cast(data); + MonikerWriteCtrFreqScalarData* 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 {}; + auto request = &function_data->request; - ArrayU16Data arrayu16data_message; - packedData.UnpackTo(&arrayu16data_message); - - auto data_array = arrayu16data_message.value(); - auto write_array = std::vector(); - auto size = data_array.size(); - write_array.reserve(size); - std::transform( - data_array.begin(), - data_array.end(), - std::back_inserter(write_array), - [](auto x) { - if (x < std::numeric_limits::min() || x > std::numeric_limits::max()) { - std::string message("value " + std::to_string(x) + " doesn't fit in datatype uInt16"); - throw nidevice_grpc::ValueOutOfRangeException(message); - } - return static_cast(x); - }); + packedData.UnpackTo(request); + float64 frequency = request->frequency(); + float64 duty_cycle = request->duty_cycle(); - auto status = library->WriteDigitalU16(task, num_samps_per_chan, auto_start, timeout, data_layout, write_array.data(), &samps_per_chan_written, reserved); + auto status = library->WriteCtrFreqScalar(task, auto_start, timeout, frequency, duty_cycle, reserved); if (status < 0) { @@ -1616,9 +1717,9 @@ ::grpc::Status MonikerWriteDigitalU16(void* data, google::protobuf::Arena& arena return ::grpc::Status::OK; } -::grpc::Status MonikerWriteDigitalU32(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData) +::grpc::Status MonikerWriteCtrTicks(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData) { - MonikerWriteDigitalU32Data* function_data = static_cast(data); + MonikerWriteCtrTicksData* function_data = static_cast(data); auto library = function_data->library; auto response = &function_data->response; auto task = function_data->task; @@ -1627,16 +1728,14 @@ ::grpc::Status MonikerWriteDigitalU32(void* data, google::protobuf::Arena& arena auto timeout = function_data->timeout; auto data_layout = function_data->data_layout; auto reserved = function_data->reserved; - int32 samps_per_chan_written {}; + int32 num_samps_per_chan_written {}; + auto request = &function_data->request; - ArrayU32Data arrayu32data_message; - packedData.UnpackTo(&arrayu32data_message); - - auto data_array = arrayu32data_message.value(); - auto write_array = reinterpret_cast(arrayu32data_message.value().data()); - auto size = data_array.size(); + packedData.UnpackTo(request); + auto high_ticks = reinterpret_cast(request->high_ticks().data()); + auto low_ticks = reinterpret_cast(request->low_ticks().data()); - auto status = library->WriteDigitalU32(task, num_samps_per_chan, auto_start, timeout, data_layout, write_array, &samps_per_chan_written, reserved); + auto status = library->WriteCtrTicks(task, num_samps_per_chan, auto_start, timeout, data_layout, high_ticks, low_ticks, &num_samps_per_chan_written, reserved); if (status < 0) { @@ -1645,98 +1744,342 @@ ::grpc::Status MonikerWriteDigitalU32(void* data, google::protobuf::Arena& arena return ::grpc::Status::OK; } - //--------------------------------------------------------------------- - //--------------------------------------------------------------------- - ::grpc::Status NiDAQmxService::AddCDAQSyncConnection(::grpc::ServerContext* context, const AddCDAQSyncConnectionRequest* request, AddCDAQSyncConnectionResponse* response) - { - if (context->IsCancelled()) { - return ::grpc::Status::CANCELLED; - } - try { - auto port_list_mbcs = convert_from_grpc(request->port_list()); - auto port_list = port_list_mbcs.c_str(); - auto status = library_->AddCDAQSyncConnection(port_list); - if (!status_ok(status)) { - return ConvertApiErrorStatusForTaskHandle(context, status, 0); - } - response->set_status(status); - return ::grpc::Status::OK; - } - catch (nidevice_grpc::NonDriverException& ex) { - return ex.GetStatus(); - } - } +::grpc::Status MonikerWriteCtrTicksScalar(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData) +{ + MonikerWriteCtrTicksScalarData* 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; + auto reserved = function_data->reserved; + auto request = &function_data->request; - //--------------------------------------------------------------------- - //--------------------------------------------------------------------- - ::grpc::Status NiDAQmxService::AddGlobalChansToTask(::grpc::ServerContext* context, const AddGlobalChansToTaskRequest* request, AddGlobalChansToTaskResponse* response) - { - if (context->IsCancelled()) { - return ::grpc::Status::CANCELLED; - } - try { - auto task_grpc_session = request->task(); - TaskHandle task = session_repository_->access_session(task_grpc_session.name()); - auto channel_names_mbcs = convert_from_grpc(request->channel_names()); - auto channel_names = channel_names_mbcs.c_str(); - auto status = library_->AddGlobalChansToTask(task, channel_names); - if (!status_ok(status)) { - return ConvertApiErrorStatusForTaskHandle(context, status, task); - } - response->set_status(status); - return ::grpc::Status::OK; - } - catch (nidevice_grpc::NonDriverException& ex) { - return ex.GetStatus(); - } - } + packedData.UnpackTo(request); + uInt32 high_ticks = request->high_ticks(); + uInt32 low_ticks = request->low_ticks(); - //--------------------------------------------------------------------- - //--------------------------------------------------------------------- - ::grpc::Status NiDAQmxService::AddNetworkDevice(::grpc::ServerContext* context, const AddNetworkDeviceRequest* request, AddNetworkDeviceResponse* response) - { - if (context->IsCancelled()) { - return ::grpc::Status::CANCELLED; + auto status = library->WriteCtrTicksScalar(task, auto_start, timeout, high_ticks, low_ticks, reserved); + + if (status < 0) + { + return ::grpc::Status(grpc::StatusCode::UNKNOWN, "ni-error: " + status); } - try { - auto ip_address_mbcs = convert_from_grpc(request->ip_address()); - auto ip_address = ip_address_mbcs.c_str(); - auto device_name_mbcs = convert_from_grpc(request->device_name()); - auto device_name = device_name_mbcs.c_str(); - bool32 attempt_reservation = request->attempt_reservation(); - float64 timeout = request->timeout(); + return ::grpc::Status::OK; +} - while (true) { - auto status = library_->AddNetworkDevice(ip_address, device_name, attempt_reservation, timeout, nullptr, 0); - if (!status_ok(status)) { - return ConvertApiErrorStatusForTaskHandle(context, status, 0); - } - uInt32 device_name_out_buffer_size = status; +::grpc::Status MonikerWriteCtrTime(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData) +{ + MonikerWriteCtrTimeData* 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 num_samps_per_chan_written {}; + auto request = &function_data->request; - std::string device_name_out; - if (device_name_out_buffer_size > 0) { - device_name_out.resize(device_name_out_buffer_size - 1); - } - status = library_->AddNetworkDevice(ip_address, device_name, attempt_reservation, timeout, (char*)device_name_out.data(), device_name_out_buffer_size); - if (status == kErrorReadBufferTooSmall || status == kWarningCAPIStringTruncatedToFitBuffer || status > static_cast(device_name_out_buffer_size)) { - // buffer is now too small, try again - continue; - } - if (!status_ok(status)) { - return ConvertApiErrorStatusForTaskHandle(context, status, 0); - } - response->set_status(status); - std::string device_name_out_utf8; - convert_to_grpc(device_name_out, &device_name_out_utf8); - response->set_device_name_out(device_name_out_utf8); - nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_device_name_out())); - return ::grpc::Status::OK; - } - } - catch (nidevice_grpc::NonDriverException& ex) { - return ex.GetStatus(); - } - } + packedData.UnpackTo(request); + auto high_time = const_cast(request->high_time().data()); + auto low_time = const_cast(request->low_time().data()); + + auto status = library->WriteCtrTime(task, num_samps_per_chan, auto_start, timeout, data_layout, high_time, low_time, &num_samps_per_chan_written, reserved); + + if (status < 0) + { + return ::grpc::Status(grpc::StatusCode::UNKNOWN, "ni-error: " + status); + } + return ::grpc::Status::OK; +} + +::grpc::Status MonikerWriteCtrTimeScalar(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData) +{ + MonikerWriteCtrTimeScalarData* 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; + auto reserved = function_data->reserved; + auto request = &function_data->request; + + packedData.UnpackTo(request); + float64 high_time = request->high_time(); + float64 low_time = request->low_time(); + + auto status = library->WriteCtrTimeScalar(task, auto_start, timeout, high_time, low_time, reserved); + + if (status < 0) + { + return ::grpc::Status(grpc::StatusCode::UNKNOWN, "ni-error: " + status); + } + return ::grpc::Status::OK; +} + +::grpc::Status MonikerWriteDigitalLines(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData) +{ + MonikerWriteDigitalLinesData* 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 {}; + auto request = &function_data->request; + + packedData.UnpackTo(request); + const uInt8* write_array = (const uInt8*)request->write_array().c_str(); + + auto status = library->WriteDigitalLines(task, num_samps_per_chan, auto_start, timeout, data_layout, write_array, &samps_per_chan_written, reserved); + + if (status < 0) + { + return ::grpc::Status(grpc::StatusCode::UNKNOWN, "ni-error: " + status); + } + return ::grpc::Status::OK; +} + +::grpc::Status MonikerWriteDigitalScalarU32(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData) +{ + 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; + auto reserved = function_data->reserved; + auto request = &function_data->request; + + packedData.UnpackTo(request); + uInt32 value = request->value(); + + auto status = library->WriteDigitalScalarU32(task, auto_start, timeout, value, reserved); + + if (status < 0) + { + return ::grpc::Status(grpc::StatusCode::UNKNOWN, "ni-error: " + status); + } + return ::grpc::Status::OK; +} + +::grpc::Status MonikerWriteDigitalU16(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData) +{ + 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 {}; + auto request = &function_data->request; + + packedData.UnpackTo(request); + auto write_array_raw = request->write_array(); + auto write_array = std::vector(); + write_array.reserve(write_array_raw.size()); + std::transform( + write_array_raw.begin(), + write_array_raw.end(), + std::back_inserter(write_array), + [](auto x) { + if (x < std::numeric_limits::min() || x > std::numeric_limits::max()) { + std::string message("value "); + message.append(std::to_string(x)); + message.append(" doesn't fit in datatype "); + message.append("uInt16"); + throw nidevice_grpc::ValueOutOfRangeException(message); + } + return static_cast(x); + }); + + + 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) + { + return ::grpc::Status(grpc::StatusCode::UNKNOWN, "ni-error: " + status); + } + return ::grpc::Status::OK; +} + +::grpc::Status MonikerWriteDigitalU32(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData) +{ + 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 {}; + auto request = &function_data->request; + + packedData.UnpackTo(request); + auto write_array = reinterpret_cast(request->write_array().data()); + + auto status = library->WriteDigitalU32(task, num_samps_per_chan, auto_start, timeout, data_layout, write_array, &samps_per_chan_written, reserved); + + if (status < 0) + { + return ::grpc::Status(grpc::StatusCode::UNKNOWN, "ni-error: " + status); + } + return ::grpc::Status::OK; +} + +::grpc::Status MonikerWriteDigitalU8(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData) +{ + MonikerWriteDigitalU8Data* 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 {}; + auto request = &function_data->request; + + packedData.UnpackTo(request); + const uInt8* write_array = (const uInt8*)request->write_array().c_str(); + + auto status = library->WriteDigitalU8(task, num_samps_per_chan, auto_start, timeout, data_layout, write_array, &samps_per_chan_written, reserved); + + if (status < 0) + { + return ::grpc::Status(grpc::StatusCode::UNKNOWN, "ni-error: " + status); + } + return ::grpc::Status::OK; +} + +::grpc::Status MonikerWriteRaw(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData) +{ + MonikerWriteRawData* function_data = static_cast(data); + auto library = function_data->library; + auto response = &function_data->response; + auto task = function_data->task; + auto num_samps = function_data->num_samps; + auto auto_start = function_data->auto_start; + auto timeout = function_data->timeout; + auto reserved = function_data->reserved; + int32 samps_per_chan_written {}; + auto request = &function_data->request; + + packedData.UnpackTo(request); + const uInt8* write_array = (const uInt8*)request->write_array().c_str(); + + auto status = library->WriteRaw(task, num_samps, auto_start, timeout, write_array, &samps_per_chan_written, reserved); + + 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) + { + if (context->IsCancelled()) { + return ::grpc::Status::CANCELLED; + } + try { + auto port_list_mbcs = convert_from_grpc(request->port_list()); + auto port_list = port_list_mbcs.c_str(); + auto status = library_->AddCDAQSyncConnection(port_list); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(context, status, 0); + } + response->set_status(status); + return ::grpc::Status::OK; + } + catch (nidevice_grpc::NonDriverException& ex) { + return ex.GetStatus(); + } + } + + //--------------------------------------------------------------------- + //--------------------------------------------------------------------- + ::grpc::Status NiDAQmxService::AddGlobalChansToTask(::grpc::ServerContext* context, const AddGlobalChansToTaskRequest* request, AddGlobalChansToTaskResponse* response) + { + if (context->IsCancelled()) { + return ::grpc::Status::CANCELLED; + } + try { + auto task_grpc_session = request->task(); + TaskHandle task = session_repository_->access_session(task_grpc_session.name()); + auto channel_names_mbcs = convert_from_grpc(request->channel_names()); + auto channel_names = channel_names_mbcs.c_str(); + auto status = library_->AddGlobalChansToTask(task, channel_names); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(context, status, task); + } + response->set_status(status); + return ::grpc::Status::OK; + } + catch (nidevice_grpc::NonDriverException& ex) { + return ex.GetStatus(); + } + } + + //--------------------------------------------------------------------- + //--------------------------------------------------------------------- + ::grpc::Status NiDAQmxService::AddNetworkDevice(::grpc::ServerContext* context, const AddNetworkDeviceRequest* request, AddNetworkDeviceResponse* response) + { + if (context->IsCancelled()) { + return ::grpc::Status::CANCELLED; + } + try { + auto ip_address_mbcs = convert_from_grpc(request->ip_address()); + auto ip_address = ip_address_mbcs.c_str(); + auto device_name_mbcs = convert_from_grpc(request->device_name()); + auto device_name = device_name_mbcs.c_str(); + bool32 attempt_reservation = request->attempt_reservation(); + float64 timeout = request->timeout(); + + while (true) { + auto status = library_->AddNetworkDevice(ip_address, device_name, attempt_reservation, timeout, nullptr, 0); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(context, status, 0); + } + uInt32 device_name_out_buffer_size = status; + + std::string device_name_out; + if (device_name_out_buffer_size > 0) { + device_name_out.resize(device_name_out_buffer_size - 1); + } + status = library_->AddNetworkDevice(ip_address, device_name, attempt_reservation, timeout, (char*)device_name_out.data(), device_name_out_buffer_size); + if (status == kErrorReadBufferTooSmall || status == kWarningCAPIStringTruncatedToFitBuffer || status > static_cast(device_name_out_buffer_size)) { + // buffer is now too small, try again + continue; + } + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(context, status, 0); + } + response->set_status(status); + std::string device_name_out_utf8; + convert_to_grpc(device_name_out, &device_name_out_utf8); + response->set_device_name_out(device_name_out_utf8); + nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_device_name_out())); + return ::grpc::Status::OK; + } + } + catch (nidevice_grpc::NonDriverException& ex) { + return ex.GetStatus(); + } + } //--------------------------------------------------------------------- //--------------------------------------------------------------------- @@ -22076,6 +22419,57 @@ ::grpc::Status MonikerWriteDigitalU32(void* data, google::protobuf::Arena& arena } } + //--------------------------------------------------------------------- + //--------------------------------------------------------------------- + ::grpc::Status NiDAQmxService::BeginWriteCtrFreq(::grpc::ServerContext* context, const BeginWriteCtrFreqRequest* request, BeginWriteCtrFreqResponse* response) + { + if (context->IsCancelled()) { + return ::grpc::Status::CANCELLED; + } + try { + auto task_grpc_session = request->task(); + TaskHandle task = session_repository_->access_session(task_grpc_session.name()); + int32 num_samps_per_chan = request->num_samps_per_chan(); + bool32 auto_start = request->auto_start(); + float64 timeout = request->timeout(); + int32 data_layout; + switch (request->data_layout_enum_case()) { + case nidaqmx_grpc::BeginWriteCtrFreqRequest::DataLayoutEnumCase::kDataLayout: { + data_layout = static_cast(request->data_layout()); + break; + } + case nidaqmx_grpc::BeginWriteCtrFreqRequest::DataLayoutEnumCase::kDataLayoutRaw: { + data_layout = static_cast(request->data_layout_raw()); + break; + } + case nidaqmx_grpc::BeginWriteCtrFreqRequest::DataLayoutEnumCase::DATA_LAYOUT_ENUM_NOT_SET: { + return ::grpc::Status(::grpc::INVALID_ARGUMENT, "The value for data_layout was not specified or out of range"); + break; + } + } + + auto reserved = nullptr; + + auto data = std::make_unique(); + data->task = task; + data->num_samps_per_chan = num_samps_per_chan; + data->auto_start = auto_start; + data->timeout = timeout; + data->data_layout = data_layout; + data->reserved = reserved; + data->library = std::shared_ptr(library_); + + auto moniker = std::make_unique(); + ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerWriteCtrFreq", data.release(), *moniker); + response->set_allocated_moniker(moniker.release()); + response->set_status(0); + return ::grpc::Status::OK; + } + catch (nidevice_grpc::NonDriverException& ex) { + return ex.GetStatus(); + } + } + //--------------------------------------------------------------------- //--------------------------------------------------------------------- ::grpc::Status NiDAQmxService::WriteCtrFreqScalar(::grpc::ServerContext* context, const WriteCtrFreqScalarRequest* request, WriteCtrFreqScalarResponse* response) @@ -22091,11 +22485,90 @@ ::grpc::Status MonikerWriteDigitalU32(void* data, google::protobuf::Arena& arena float64 frequency = request->frequency(); float64 duty_cycle = request->duty_cycle(); auto reserved = nullptr; - auto status = library_->WriteCtrFreqScalar(task, auto_start, timeout, frequency, duty_cycle, reserved); + auto status = library_->WriteCtrFreqScalar(task, auto_start, timeout, frequency, duty_cycle, reserved); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(context, status, task); + } + response->set_status(status); + return ::grpc::Status::OK; + } + catch (nidevice_grpc::NonDriverException& ex) { + return ex.GetStatus(); + } + } + + //--------------------------------------------------------------------- + //--------------------------------------------------------------------- + ::grpc::Status NiDAQmxService::BeginWriteCtrFreqScalar(::grpc::ServerContext* context, const BeginWriteCtrFreqScalarRequest* request, BeginWriteCtrFreqScalarResponse* response) + { + if (context->IsCancelled()) { + return ::grpc::Status::CANCELLED; + } + try { + auto task_grpc_session = request->task(); + TaskHandle task = session_repository_->access_session(task_grpc_session.name()); + bool32 auto_start = request->auto_start(); + float64 timeout = request->timeout(); + auto reserved = nullptr; + + 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("MonikerWriteCtrFreqScalar", data.release(), *moniker); + response->set_allocated_moniker(moniker.release()); + response->set_status(0); + return ::grpc::Status::OK; + } + catch (nidevice_grpc::NonDriverException& ex) { + return ex.GetStatus(); + } + } + + //--------------------------------------------------------------------- + //--------------------------------------------------------------------- + ::grpc::Status NiDAQmxService::WriteCtrTicks(::grpc::ServerContext* context, const WriteCtrTicksRequest* request, WriteCtrTicksResponse* response) + { + if (context->IsCancelled()) { + return ::grpc::Status::CANCELLED; + } + try { + auto task_grpc_session = request->task(); + TaskHandle task = session_repository_->access_session(task_grpc_session.name()); + int32 num_samps_per_chan = request->num_samps_per_chan(); + bool32 auto_start = request->auto_start(); + float64 timeout = request->timeout(); + int32 data_layout; + switch (request->data_layout_enum_case()) { + case nidaqmx_grpc::WriteCtrTicksRequest::DataLayoutEnumCase::kDataLayout: { + data_layout = static_cast(request->data_layout()); + break; + } + case nidaqmx_grpc::WriteCtrTicksRequest::DataLayoutEnumCase::kDataLayoutRaw: { + data_layout = static_cast(request->data_layout_raw()); + break; + } + case nidaqmx_grpc::WriteCtrTicksRequest::DataLayoutEnumCase::DATA_LAYOUT_ENUM_NOT_SET: { + return ::grpc::Status(::grpc::INVALID_ARGUMENT, "The value for data_layout was not specified or out of range"); + break; + } + } + + auto high_ticks = reinterpret_cast(request->high_ticks().data()); + auto low_ticks = reinterpret_cast(request->low_ticks().data()); + auto reserved = nullptr; + int32 num_samps_per_chan_written {}; + auto status = library_->WriteCtrTicks(task, num_samps_per_chan, auto_start, timeout, data_layout, high_ticks, low_ticks, &num_samps_per_chan_written, reserved); + context->AddTrailingMetadata("ni-samps-per-chan-written", std::to_string(num_samps_per_chan_written)); if (!status_ok(status)) { return ConvertApiErrorStatusForTaskHandle(context, status, task); } response->set_status(status); + response->set_num_samps_per_chan_written(num_samps_per_chan_written); return ::grpc::Status::OK; } catch (nidevice_grpc::NonDriverException& ex) { @@ -22105,7 +22578,7 @@ ::grpc::Status MonikerWriteDigitalU32(void* data, google::protobuf::Arena& arena //--------------------------------------------------------------------- //--------------------------------------------------------------------- - ::grpc::Status NiDAQmxService::WriteCtrTicks(::grpc::ServerContext* context, const WriteCtrTicksRequest* request, WriteCtrTicksResponse* response) + ::grpc::Status NiDAQmxService::BeginWriteCtrTicks(::grpc::ServerContext* context, const BeginWriteCtrTicksRequest* request, BeginWriteCtrTicksResponse* response) { if (context->IsCancelled()) { return ::grpc::Status::CANCELLED; @@ -22118,31 +22591,35 @@ ::grpc::Status MonikerWriteDigitalU32(void* data, google::protobuf::Arena& arena float64 timeout = request->timeout(); int32 data_layout; switch (request->data_layout_enum_case()) { - case nidaqmx_grpc::WriteCtrTicksRequest::DataLayoutEnumCase::kDataLayout: { + case nidaqmx_grpc::BeginWriteCtrTicksRequest::DataLayoutEnumCase::kDataLayout: { data_layout = static_cast(request->data_layout()); break; } - case nidaqmx_grpc::WriteCtrTicksRequest::DataLayoutEnumCase::kDataLayoutRaw: { + case nidaqmx_grpc::BeginWriteCtrTicksRequest::DataLayoutEnumCase::kDataLayoutRaw: { data_layout = static_cast(request->data_layout_raw()); break; } - case nidaqmx_grpc::WriteCtrTicksRequest::DataLayoutEnumCase::DATA_LAYOUT_ENUM_NOT_SET: { + case nidaqmx_grpc::BeginWriteCtrTicksRequest::DataLayoutEnumCase::DATA_LAYOUT_ENUM_NOT_SET: { return ::grpc::Status(::grpc::INVALID_ARGUMENT, "The value for data_layout was not specified or out of range"); break; } } - auto high_ticks = reinterpret_cast(request->high_ticks().data()); - auto low_ticks = reinterpret_cast(request->low_ticks().data()); auto reserved = nullptr; - int32 num_samps_per_chan_written {}; - auto status = library_->WriteCtrTicks(task, num_samps_per_chan, auto_start, timeout, data_layout, high_ticks, low_ticks, &num_samps_per_chan_written, reserved); - context->AddTrailingMetadata("ni-samps-per-chan-written", std::to_string(num_samps_per_chan_written)); - if (!status_ok(status)) { - return ConvertApiErrorStatusForTaskHandle(context, status, task); - } - response->set_status(status); - response->set_num_samps_per_chan_written(num_samps_per_chan_written); + + auto data = std::make_unique(); + data->task = task; + data->num_samps_per_chan = num_samps_per_chan; + data->auto_start = auto_start; + data->timeout = timeout; + data->data_layout = data_layout; + data->reserved = reserved; + data->library = std::shared_ptr(library_); + + auto moniker = std::make_unique(); + ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerWriteCtrTicks", data.release(), *moniker); + response->set_allocated_moniker(moniker.release()); + response->set_status(0); return ::grpc::Status::OK; } catch (nidevice_grpc::NonDriverException& ex) { @@ -22177,6 +22654,38 @@ ::grpc::Status MonikerWriteDigitalU32(void* data, google::protobuf::Arena& arena } } + //--------------------------------------------------------------------- + //--------------------------------------------------------------------- + ::grpc::Status NiDAQmxService::BeginWriteCtrTicksScalar(::grpc::ServerContext* context, const BeginWriteCtrTicksScalarRequest* request, BeginWriteCtrTicksScalarResponse* response) + { + if (context->IsCancelled()) { + return ::grpc::Status::CANCELLED; + } + try { + auto task_grpc_session = request->task(); + TaskHandle task = session_repository_->access_session(task_grpc_session.name()); + bool32 auto_start = request->auto_start(); + float64 timeout = request->timeout(); + auto reserved = nullptr; + + 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("MonikerWriteCtrTicksScalar", data.release(), *moniker); + response->set_allocated_moniker(moniker.release()); + response->set_status(0); + return ::grpc::Status::OK; + } + catch (nidevice_grpc::NonDriverException& ex) { + return ex.GetStatus(); + } + } + //--------------------------------------------------------------------- //--------------------------------------------------------------------- ::grpc::Status NiDAQmxService::WriteCtrTime(::grpc::ServerContext* context, const WriteCtrTimeRequest* request, WriteCtrTimeResponse* response) @@ -22224,6 +22733,57 @@ ::grpc::Status MonikerWriteDigitalU32(void* data, google::protobuf::Arena& arena } } + //--------------------------------------------------------------------- + //--------------------------------------------------------------------- + ::grpc::Status NiDAQmxService::BeginWriteCtrTime(::grpc::ServerContext* context, const BeginWriteCtrTimeRequest* request, BeginWriteCtrTimeResponse* response) + { + if (context->IsCancelled()) { + return ::grpc::Status::CANCELLED; + } + try { + auto task_grpc_session = request->task(); + TaskHandle task = session_repository_->access_session(task_grpc_session.name()); + int32 num_samps_per_chan = request->num_samps_per_chan(); + bool32 auto_start = request->auto_start(); + float64 timeout = request->timeout(); + int32 data_layout; + switch (request->data_layout_enum_case()) { + case nidaqmx_grpc::BeginWriteCtrTimeRequest::DataLayoutEnumCase::kDataLayout: { + data_layout = static_cast(request->data_layout()); + break; + } + case nidaqmx_grpc::BeginWriteCtrTimeRequest::DataLayoutEnumCase::kDataLayoutRaw: { + data_layout = static_cast(request->data_layout_raw()); + break; + } + case nidaqmx_grpc::BeginWriteCtrTimeRequest::DataLayoutEnumCase::DATA_LAYOUT_ENUM_NOT_SET: { + return ::grpc::Status(::grpc::INVALID_ARGUMENT, "The value for data_layout was not specified or out of range"); + break; + } + } + + auto reserved = nullptr; + + auto data = std::make_unique(); + data->task = task; + data->num_samps_per_chan = num_samps_per_chan; + data->auto_start = auto_start; + data->timeout = timeout; + data->data_layout = data_layout; + data->reserved = reserved; + data->library = std::shared_ptr(library_); + + auto moniker = std::make_unique(); + ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerWriteCtrTime", data.release(), *moniker); + response->set_allocated_moniker(moniker.release()); + response->set_status(0); + return ::grpc::Status::OK; + } + catch (nidevice_grpc::NonDriverException& ex) { + return ex.GetStatus(); + } + } + //--------------------------------------------------------------------- //--------------------------------------------------------------------- ::grpc::Status NiDAQmxService::WriteCtrTimeScalar(::grpc::ServerContext* context, const WriteCtrTimeScalarRequest* request, WriteCtrTimeScalarResponse* response) @@ -22251,6 +22811,38 @@ ::grpc::Status MonikerWriteDigitalU32(void* data, google::protobuf::Arena& arena } } + //--------------------------------------------------------------------- + //--------------------------------------------------------------------- + ::grpc::Status NiDAQmxService::BeginWriteCtrTimeScalar(::grpc::ServerContext* context, const BeginWriteCtrTimeScalarRequest* request, BeginWriteCtrTimeScalarResponse* response) + { + if (context->IsCancelled()) { + return ::grpc::Status::CANCELLED; + } + try { + auto task_grpc_session = request->task(); + TaskHandle task = session_repository_->access_session(task_grpc_session.name()); + bool32 auto_start = request->auto_start(); + float64 timeout = request->timeout(); + auto reserved = nullptr; + + 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("MonikerWriteCtrTimeScalar", data.release(), *moniker); + response->set_allocated_moniker(moniker.release()); + response->set_status(0); + return ::grpc::Status::OK; + } + catch (nidevice_grpc::NonDriverException& ex) { + return ex.GetStatus(); + } + } + //--------------------------------------------------------------------- //--------------------------------------------------------------------- ::grpc::Status NiDAQmxService::WriteDigitalLines(::grpc::ServerContext* context, const WriteDigitalLinesRequest* request, WriteDigitalLinesResponse* response) @@ -22297,6 +22889,57 @@ ::grpc::Status MonikerWriteDigitalU32(void* data, google::protobuf::Arena& arena } } + //--------------------------------------------------------------------- + //--------------------------------------------------------------------- + ::grpc::Status NiDAQmxService::BeginWriteDigitalLines(::grpc::ServerContext* context, const BeginWriteDigitalLinesRequest* request, BeginWriteDigitalLinesResponse* response) + { + if (context->IsCancelled()) { + return ::grpc::Status::CANCELLED; + } + try { + auto task_grpc_session = request->task(); + TaskHandle task = session_repository_->access_session(task_grpc_session.name()); + int32 num_samps_per_chan = request->num_samps_per_chan(); + bool32 auto_start = request->auto_start(); + float64 timeout = request->timeout(); + int32 data_layout; + switch (request->data_layout_enum_case()) { + case nidaqmx_grpc::BeginWriteDigitalLinesRequest::DataLayoutEnumCase::kDataLayout: { + data_layout = static_cast(request->data_layout()); + break; + } + case nidaqmx_grpc::BeginWriteDigitalLinesRequest::DataLayoutEnumCase::kDataLayoutRaw: { + data_layout = static_cast(request->data_layout_raw()); + break; + } + case nidaqmx_grpc::BeginWriteDigitalLinesRequest::DataLayoutEnumCase::DATA_LAYOUT_ENUM_NOT_SET: { + return ::grpc::Status(::grpc::INVALID_ARGUMENT, "The value for data_layout was not specified or out of range"); + break; + } + } + + auto reserved = nullptr; + + auto data = std::make_unique(); + data->task = task; + data->num_samps_per_chan = num_samps_per_chan; + data->auto_start = auto_start; + data->timeout = timeout; + data->data_layout = data_layout; + data->reserved = reserved; + data->library = std::shared_ptr(library_); + + auto moniker = std::make_unique(); + ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerWriteDigitalLines", data.release(), *moniker); + response->set_allocated_moniker(moniker.release()); + response->set_status(0); + return ::grpc::Status::OK; + } + catch (nidevice_grpc::NonDriverException& ex) { + return ex.GetStatus(); + } + } + //--------------------------------------------------------------------- //--------------------------------------------------------------------- ::grpc::Status NiDAQmxService::WriteDigitalScalarU32(::grpc::ServerContext* context, const WriteDigitalScalarU32Request* request, WriteDigitalScalarU32Response* response) @@ -22612,6 +23255,57 @@ ::grpc::Status MonikerWriteDigitalU32(void* data, google::protobuf::Arena& arena } } + //--------------------------------------------------------------------- + //--------------------------------------------------------------------- + ::grpc::Status NiDAQmxService::BeginWriteDigitalU8(::grpc::ServerContext* context, const BeginWriteDigitalU8Request* request, BeginWriteDigitalU8Response* response) + { + if (context->IsCancelled()) { + return ::grpc::Status::CANCELLED; + } + try { + auto task_grpc_session = request->task(); + TaskHandle task = session_repository_->access_session(task_grpc_session.name()); + int32 num_samps_per_chan = request->num_samps_per_chan(); + bool32 auto_start = request->auto_start(); + float64 timeout = request->timeout(); + int32 data_layout; + switch (request->data_layout_enum_case()) { + case nidaqmx_grpc::BeginWriteDigitalU8Request::DataLayoutEnumCase::kDataLayout: { + data_layout = static_cast(request->data_layout()); + break; + } + case nidaqmx_grpc::BeginWriteDigitalU8Request::DataLayoutEnumCase::kDataLayoutRaw: { + data_layout = static_cast(request->data_layout_raw()); + break; + } + case nidaqmx_grpc::BeginWriteDigitalU8Request::DataLayoutEnumCase::DATA_LAYOUT_ENUM_NOT_SET: { + return ::grpc::Status(::grpc::INVALID_ARGUMENT, "The value for data_layout was not specified or out of range"); + break; + } + } + + auto reserved = nullptr; + + auto data = std::make_unique(); + data->task = task; + data->num_samps_per_chan = num_samps_per_chan; + data->auto_start = auto_start; + data->timeout = timeout; + data->data_layout = data_layout; + data->reserved = reserved; + data->library = std::shared_ptr(library_); + + auto moniker = std::make_unique(); + ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerWriteDigitalU8", data.release(), *moniker); + response->set_allocated_moniker(moniker.release()); + response->set_status(0); + return ::grpc::Status::OK; + } + catch (nidevice_grpc::NonDriverException& ex) { + return ex.GetStatus(); + } + } + //--------------------------------------------------------------------- //--------------------------------------------------------------------- ::grpc::Status NiDAQmxService::WriteRaw(::grpc::ServerContext* context, const WriteRawRequest* request, WriteRawResponse* response) @@ -22642,6 +23336,40 @@ ::grpc::Status MonikerWriteDigitalU32(void* data, google::protobuf::Arena& arena } } + //--------------------------------------------------------------------- + //--------------------------------------------------------------------- + ::grpc::Status NiDAQmxService::BeginWriteRaw(::grpc::ServerContext* context, const BeginWriteRawRequest* request, BeginWriteRawResponse* response) + { + if (context->IsCancelled()) { + return ::grpc::Status::CANCELLED; + } + try { + auto task_grpc_session = request->task(); + TaskHandle task = session_repository_->access_session(task_grpc_session.name()); + int32 num_samps = request->num_samps(); + bool32 auto_start = request->auto_start(); + float64 timeout = request->timeout(); + auto reserved = nullptr; + + auto data = std::make_unique(); + data->task = task; + data->num_samps = num_samps; + 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("MonikerWriteRaw", data.release(), *moniker); + response->set_allocated_moniker(moniker.release()); + response->set_status(0); + return ::grpc::Status::OK; + } + catch (nidevice_grpc::NonDriverException& ex) { + return ex.GetStatus(); + } + } + //--------------------------------------------------------------------- //--------------------------------------------------------------------- ::grpc::Status NiDAQmxService::WriteToTEDSFromArray(::grpc::ServerContext* context, const WriteToTEDSFromArrayRequest* request, WriteToTEDSFromArrayResponse* response) diff --git a/generated/nidaqmx/nidaqmx_service.h b/generated/nidaqmx/nidaqmx_service.h index fa8045f32..e127c1d1e 100644 --- a/generated/nidaqmx/nidaqmx_service.h +++ b/generated/nidaqmx/nidaqmx_service.h @@ -68,9 +68,18 @@ ::grpc::Status MonikerWriteBinaryI16(void* data, google::protobuf::Arena& arena, ::grpc::Status MonikerWriteBinaryI32(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData); ::grpc::Status MonikerWriteBinaryU16(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData); ::grpc::Status MonikerWriteBinaryU32(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData); +::grpc::Status MonikerWriteCtrFreq(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData); +::grpc::Status MonikerWriteCtrFreqScalar(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData); +::grpc::Status MonikerWriteCtrTicks(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData); +::grpc::Status MonikerWriteCtrTicksScalar(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData); +::grpc::Status MonikerWriteCtrTime(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData); +::grpc::Status MonikerWriteCtrTimeScalar(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData); +::grpc::Status MonikerWriteDigitalLines(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData); ::grpc::Status MonikerWriteDigitalScalarU32(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData); ::grpc::Status MonikerWriteDigitalU16(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData); ::grpc::Status MonikerWriteDigitalU32(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData); +::grpc::Status MonikerWriteDigitalU8(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData); +::grpc::Status MonikerWriteRaw(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData); class NiDAQmxService final : public NiDAQmx::WithCallbackMethod_RegisterSignalEvent>> { public: @@ -502,12 +511,19 @@ class NiDAQmxService final : public NiDAQmx::WithCallbackMethod_RegisterSignalEv ::grpc::Status WriteBinaryU32(::grpc::ServerContext* context, const WriteBinaryU32Request* request, WriteBinaryU32Response* response) override; ::grpc::Status BeginWriteBinaryU32(::grpc::ServerContext* context, const BeginWriteBinaryU32Request* request, BeginWriteBinaryU32Response* response) override; ::grpc::Status WriteCtrFreq(::grpc::ServerContext* context, const WriteCtrFreqRequest* request, WriteCtrFreqResponse* response) override; + ::grpc::Status BeginWriteCtrFreq(::grpc::ServerContext* context, const BeginWriteCtrFreqRequest* request, BeginWriteCtrFreqResponse* response) override; ::grpc::Status WriteCtrFreqScalar(::grpc::ServerContext* context, const WriteCtrFreqScalarRequest* request, WriteCtrFreqScalarResponse* response) override; + ::grpc::Status BeginWriteCtrFreqScalar(::grpc::ServerContext* context, const BeginWriteCtrFreqScalarRequest* request, BeginWriteCtrFreqScalarResponse* response) override; ::grpc::Status WriteCtrTicks(::grpc::ServerContext* context, const WriteCtrTicksRequest* request, WriteCtrTicksResponse* response) override; + ::grpc::Status BeginWriteCtrTicks(::grpc::ServerContext* context, const BeginWriteCtrTicksRequest* request, BeginWriteCtrTicksResponse* response) override; ::grpc::Status WriteCtrTicksScalar(::grpc::ServerContext* context, const WriteCtrTicksScalarRequest* request, WriteCtrTicksScalarResponse* response) override; + ::grpc::Status BeginWriteCtrTicksScalar(::grpc::ServerContext* context, const BeginWriteCtrTicksScalarRequest* request, BeginWriteCtrTicksScalarResponse* response) override; ::grpc::Status WriteCtrTime(::grpc::ServerContext* context, const WriteCtrTimeRequest* request, WriteCtrTimeResponse* response) override; + ::grpc::Status BeginWriteCtrTime(::grpc::ServerContext* context, const BeginWriteCtrTimeRequest* request, BeginWriteCtrTimeResponse* response) override; ::grpc::Status WriteCtrTimeScalar(::grpc::ServerContext* context, const WriteCtrTimeScalarRequest* request, WriteCtrTimeScalarResponse* response) override; + ::grpc::Status BeginWriteCtrTimeScalar(::grpc::ServerContext* context, const BeginWriteCtrTimeScalarRequest* request, BeginWriteCtrTimeScalarResponse* response) override; ::grpc::Status WriteDigitalLines(::grpc::ServerContext* context, const WriteDigitalLinesRequest* request, WriteDigitalLinesResponse* response) override; + ::grpc::Status BeginWriteDigitalLines(::grpc::ServerContext* context, const BeginWriteDigitalLinesRequest* request, BeginWriteDigitalLinesResponse* response) override; ::grpc::Status WriteDigitalScalarU32(::grpc::ServerContext* context, const WriteDigitalScalarU32Request* request, WriteDigitalScalarU32Response* response) override; ::grpc::Status BeginWriteDigitalScalarU32(::grpc::ServerContext* context, const BeginWriteDigitalScalarU32Request* request, BeginWriteDigitalScalarU32Response* response) override; ::grpc::Status WriteDigitalU16(::grpc::ServerContext* context, const WriteDigitalU16Request* request, WriteDigitalU16Response* response) override; @@ -515,7 +531,9 @@ class NiDAQmxService final : public NiDAQmx::WithCallbackMethod_RegisterSignalEv ::grpc::Status WriteDigitalU32(::grpc::ServerContext* context, const WriteDigitalU32Request* request, WriteDigitalU32Response* response) override; ::grpc::Status BeginWriteDigitalU32(::grpc::ServerContext* context, const BeginWriteDigitalU32Request* request, BeginWriteDigitalU32Response* response) override; ::grpc::Status WriteDigitalU8(::grpc::ServerContext* context, const WriteDigitalU8Request* request, WriteDigitalU8Response* response) override; + ::grpc::Status BeginWriteDigitalU8(::grpc::ServerContext* context, const BeginWriteDigitalU8Request* request, BeginWriteDigitalU8Response* response) override; ::grpc::Status WriteRaw(::grpc::ServerContext* context, const WriteRawRequest* request, WriteRawResponse* response) override; + ::grpc::Status BeginWriteRaw(::grpc::ServerContext* context, const BeginWriteRawRequest* request, BeginWriteRawResponse* response) override; ::grpc::Status WriteToTEDSFromArray(::grpc::ServerContext* context, const WriteToTEDSFromArrayRequest* request, WriteToTEDSFromArrayResponse* response) override; ::grpc::Status WriteToTEDSFromFile(::grpc::ServerContext* context, const WriteToTEDSFromFileRequest* request, WriteToTEDSFromFileResponse* response) override; private: diff --git a/generated/nifpga/nifpga_service.cpp b/generated/nifpga/nifpga_service.cpp index ed37dca81..0ae7254f1 100644 --- a/generated/nifpga/nifpga_service.cpp +++ b/generated/nifpga/nifpga_service.cpp @@ -1053,13 +1053,11 @@ ::grpc::Status MonikerWriteArrayBool(void* data, google::protobuf::Arena& arena, auto response = &function_data->response; auto session = function_data->session; auto control = function_data->control; + auto request = &function_data->request; - ArrayBoolData arraybooldata_message; - packedData.UnpackTo(&arraybooldata_message); - - auto data_array = arraybooldata_message.value(); - std::vector array(data_array.begin(), data_array.end()); - auto size = data_array.size(); + packedData.UnpackTo(request); + auto array = convert_from_grpc(request->array()); + size_t size = static_cast(request->array().size()); auto status = library->WriteArrayBool(session, control, array.data(), size); @@ -1077,13 +1075,11 @@ ::grpc::Status MonikerWriteArrayDbl(void* data, google::protobuf::Arena& arena, auto response = &function_data->response; auto session = function_data->session; auto control = function_data->control; + auto request = &function_data->request; - ArrayDoubleData arraydoubledata_message; - packedData.UnpackTo(&arraydoubledata_message); - - auto data_array = arraydoubledata_message.value(); - auto array = const_cast(arraydoubledata_message.value().data()); - auto size = data_array.size(); + packedData.UnpackTo(request); + auto array = const_cast(request->array().data()); + size_t size = static_cast(request->array().size()); auto status = library->WriteArrayDbl(session, control, array, size); @@ -1101,25 +1097,28 @@ ::grpc::Status MonikerWriteArrayI16(void* data, google::protobuf::Arena& arena, auto response = &function_data->response; auto session = function_data->session; auto control = function_data->control; + auto request = &function_data->request; - ArrayI32Data arrayi32data_message; - packedData.UnpackTo(&arrayi32data_message); - - auto data_array = arrayi32data_message.value(); - auto array = std::vector(); - auto size = data_array.size(); - array.reserve(size); - std::transform( - data_array.begin(), - data_array.end(), - std::back_inserter(array), - [](auto x) { - if (x < std::numeric_limits::min() || x > std::numeric_limits::max()) { - std::string message("value " + std::to_string(x) + " doesn't fit in datatype int16_t"); - throw nidevice_grpc::ValueOutOfRangeException(message); - } - return static_cast(x); - }); + packedData.UnpackTo(request); + auto array_raw = request->array(); + auto array = std::vector(); + array.reserve(array_raw.size()); + std::transform( + array_raw.begin(), + array_raw.end(), + std::back_inserter(array), + [](auto x) { + if (x < std::numeric_limits::min() || x > std::numeric_limits::max()) { + std::string message("value "); + message.append(std::to_string(x)); + message.append(" doesn't fit in datatype "); + message.append("int16_t"); + throw nidevice_grpc::ValueOutOfRangeException(message); + } + return static_cast(x); + }); + + size_t size = static_cast(request->array().size()); auto status = library->WriteArrayI16(session, control, array.data(), size); @@ -1137,13 +1136,11 @@ ::grpc::Status MonikerWriteArrayI32(void* data, google::protobuf::Arena& arena, auto response = &function_data->response; auto session = function_data->session; auto control = function_data->control; + auto request = &function_data->request; - ArrayI32Data arrayi32data_message; - packedData.UnpackTo(&arrayi32data_message); - - auto data_array = arrayi32data_message.value(); - auto array = const_cast(arrayi32data_message.value().data()); - auto size = data_array.size(); + packedData.UnpackTo(request); + auto array = const_cast(request->array().data()); + size_t size = static_cast(request->array().size()); auto status = library->WriteArrayI32(session, control, array, size); @@ -1161,13 +1158,11 @@ ::grpc::Status MonikerWriteArrayI64(void* data, google::protobuf::Arena& arena, auto response = &function_data->response; auto session = function_data->session; auto control = function_data->control; + auto request = &function_data->request; - ArrayI64Data arrayi64data_message; - packedData.UnpackTo(&arrayi64data_message); - - auto data_array = arrayi64data_message.value(); - auto array = const_cast(arrayi64data_message.value().data()); - auto size = data_array.size(); + packedData.UnpackTo(request); + auto array = const_cast(request->array().data()); + size_t size = static_cast(request->array().size()); auto status = library->WriteArrayI64(session, control, array, size); @@ -1185,25 +1180,28 @@ ::grpc::Status MonikerWriteArrayI8(void* data, google::protobuf::Arena& arena, g auto response = &function_data->response; auto session = function_data->session; auto control = function_data->control; + auto request = &function_data->request; - ArrayI32Data arrayi32data_message; - packedData.UnpackTo(&arrayi32data_message); - - auto data_array = arrayi32data_message.value(); - auto array = std::vector(); - auto size = data_array.size(); - array.reserve(size); - std::transform( - data_array.begin(), - data_array.end(), - std::back_inserter(array), - [](auto x) { - if (x < std::numeric_limits::min() || x > std::numeric_limits::max()) { - std::string message("value " + std::to_string(x) + " doesn't fit in datatype int8_t"); - throw nidevice_grpc::ValueOutOfRangeException(message); - } - return static_cast(x); - }); + packedData.UnpackTo(request); + auto array_raw = request->array(); + auto array = std::vector(); + array.reserve(array_raw.size()); + std::transform( + array_raw.begin(), + array_raw.end(), + std::back_inserter(array), + [](auto x) { + if (x < std::numeric_limits::min() || x > std::numeric_limits::max()) { + std::string message("value "); + message.append(std::to_string(x)); + message.append(" doesn't fit in datatype "); + message.append("int8_t"); + throw nidevice_grpc::ValueOutOfRangeException(message); + } + return static_cast(x); + }); + + size_t size = static_cast(request->array().size()); auto status = library->WriteArrayI8(session, control, array.data(), size); @@ -1221,13 +1219,11 @@ ::grpc::Status MonikerWriteArraySgl(void* data, google::protobuf::Arena& arena, auto response = &function_data->response; auto session = function_data->session; auto control = function_data->control; + auto request = &function_data->request; - ArrayFloatData arrayfloatdata_message; - packedData.UnpackTo(&arrayfloatdata_message); - - auto data_array = arrayfloatdata_message.value(); - auto array = const_cast(arrayfloatdata_message.value().data()); - auto size = data_array.size(); + packedData.UnpackTo(request); + auto array = const_cast(request->array().data()); + size_t size = static_cast(request->array().size()); auto status = library->WriteArraySgl(session, control, array, size); @@ -1245,25 +1241,28 @@ ::grpc::Status MonikerWriteArrayU16(void* data, google::protobuf::Arena& arena, auto response = &function_data->response; auto session = function_data->session; auto control = function_data->control; + auto request = &function_data->request; - ArrayU32Data arrayu32data_message; - packedData.UnpackTo(&arrayu32data_message); - - auto data_array = arrayu32data_message.value(); - auto array = std::vector(); - auto size = data_array.size(); - array.reserve(size); - std::transform( - data_array.begin(), - data_array.end(), - std::back_inserter(array), - [](auto x) { - if (x < std::numeric_limits::min() || x > std::numeric_limits::max()) { - std::string message("value " + std::to_string(x) + " doesn't fit in datatype uint16_t"); - throw nidevice_grpc::ValueOutOfRangeException(message); - } - return static_cast(x); - }); + packedData.UnpackTo(request); + auto array_raw = request->array(); + auto array = std::vector(); + array.reserve(array_raw.size()); + std::transform( + array_raw.begin(), + array_raw.end(), + std::back_inserter(array), + [](auto x) { + if (x < std::numeric_limits::min() || x > std::numeric_limits::max()) { + std::string message("value "); + message.append(std::to_string(x)); + message.append(" doesn't fit in datatype "); + message.append("uint16_t"); + throw nidevice_grpc::ValueOutOfRangeException(message); + } + return static_cast(x); + }); + + size_t size = static_cast(request->array().size()); auto status = library->WriteArrayU16(session, control, array.data(), size); @@ -1281,13 +1280,11 @@ ::grpc::Status MonikerWriteArrayU32(void* data, google::protobuf::Arena& arena, auto response = &function_data->response; auto session = function_data->session; auto control = function_data->control; + auto request = &function_data->request; - ArrayU32Data arrayu32data_message; - packedData.UnpackTo(&arrayu32data_message); - - auto data_array = arrayu32data_message.value(); - auto array = const_cast(arrayu32data_message.value().data()); - auto size = data_array.size(); + packedData.UnpackTo(request); + auto array = const_cast(request->array().data()); + size_t size = static_cast(request->array().size()); auto status = library->WriteArrayU32(session, control, array, size); @@ -1305,13 +1302,11 @@ ::grpc::Status MonikerWriteArrayU64(void* data, google::protobuf::Arena& arena, auto response = &function_data->response; auto session = function_data->session; auto control = function_data->control; + auto request = &function_data->request; - ArrayU64Data arrayu64data_message; - packedData.UnpackTo(&arrayu64data_message); - - auto data_array = arrayu64data_message.value(); - auto array = const_cast(arrayu64data_message.value().data()); - auto size = data_array.size(); + packedData.UnpackTo(request); + auto array = const_cast(request->array().data()); + size_t size = static_cast(request->array().size()); auto status = library->WriteArrayU64(session, control, array, size); @@ -1329,25 +1324,28 @@ ::grpc::Status MonikerWriteArrayU8(void* data, google::protobuf::Arena& arena, g auto response = &function_data->response; auto session = function_data->session; auto control = function_data->control; + auto request = &function_data->request; - ArrayU32Data arrayu32data_message; - packedData.UnpackTo(&arrayu32data_message); - - auto data_array = arrayu32data_message.value(); - auto array = std::vector(); - auto size = data_array.size(); - array.reserve(size); - std::transform( - data_array.begin(), - data_array.end(), - std::back_inserter(array), - [](auto x) { - if (x < std::numeric_limits::min() || x > std::numeric_limits::max()) { - std::string message("value " + std::to_string(x) + " doesn't fit in datatype uint8_t"); - throw nidevice_grpc::ValueOutOfRangeException(message); - } - return static_cast(x); - }); + packedData.UnpackTo(request); + auto array_raw = request->array(); + auto array = std::vector(); + array.reserve(array_raw.size()); + std::transform( + array_raw.begin(), + array_raw.end(), + std::back_inserter(array), + [](auto x) { + if (x < std::numeric_limits::min() || x > std::numeric_limits::max()) { + std::string message("value "); + message.append(std::to_string(x)); + message.append(" doesn't fit in datatype "); + message.append("uint8_t"); + throw nidevice_grpc::ValueOutOfRangeException(message); + } + return static_cast(x); + }); + + size_t size = static_cast(request->array().size()); auto status = library->WriteArrayU8(session, control, array.data(), size); @@ -1365,10 +1363,10 @@ ::grpc::Status MonikerWriteBool(void* data, google::protobuf::Arena& arena, goog auto response = &function_data->response; auto session = function_data->session; auto control = function_data->control; + auto request = &function_data->request; - BoolData booldata_message; - packedData.UnpackTo(&booldata_message); - auto value = booldata_message.value(); + packedData.UnpackTo(request); + NiFpga_Bool value = request->value(); auto status = library->WriteBool(session, control, value); @@ -1386,10 +1384,10 @@ ::grpc::Status MonikerWriteDbl(void* data, google::protobuf::Arena& arena, googl auto response = &function_data->response; auto session = function_data->session; auto control = function_data->control; + auto request = &function_data->request; - DoubleData doubledata_message; - packedData.UnpackTo(&doubledata_message); - auto value = doubledata_message.value(); + packedData.UnpackTo(request); + double value = request->value(); auto status = library->WriteDbl(session, control, value); @@ -1407,14 +1405,19 @@ ::grpc::Status MonikerWriteI16(void* data, google::protobuf::Arena& arena, googl auto response = &function_data->response; auto session = function_data->session; auto control = function_data->control; + auto request = &function_data->request; + + packedData.UnpackTo(request); + auto value_raw = request->value(); + if (value_raw < std::numeric_limits::min() || value_raw > std::numeric_limits::max()) { + std::string message("value "); + message.append(std::to_string(value_raw)); + message.append(" doesn't fit in datatype "); + message.append("int16_t"); + throw nidevice_grpc::ValueOutOfRangeException(message); + } + auto value = static_cast(value_raw); - I32Data i32data_message; - packedData.UnpackTo(&i32data_message); - auto value = i32data_message.value(); - if (value < std::numeric_limits::min() || value > std::numeric_limits::max()) { - std::string message("value " + std::to_string(value) + " doesn't fit in datatype int16_t"); - throw nidevice_grpc::ValueOutOfRangeException(message); - } auto status = library->WriteI16(session, control, value); @@ -1432,10 +1435,10 @@ ::grpc::Status MonikerWriteI32(void* data, google::protobuf::Arena& arena, googl auto response = &function_data->response; auto session = function_data->session; auto control = function_data->control; + auto request = &function_data->request; - I32Data i32data_message; - packedData.UnpackTo(&i32data_message); - auto value = i32data_message.value(); + packedData.UnpackTo(request); + int32_t value = request->value(); auto status = library->WriteI32(session, control, value); @@ -1453,10 +1456,10 @@ ::grpc::Status MonikerWriteI64(void* data, google::protobuf::Arena& arena, googl auto response = &function_data->response; auto session = function_data->session; auto control = function_data->control; + auto request = &function_data->request; - I64Data i64data_message; - packedData.UnpackTo(&i64data_message); - auto value = i64data_message.value(); + packedData.UnpackTo(request); + int64_t value = request->value(); auto status = library->WriteI64(session, control, value); @@ -1474,14 +1477,19 @@ ::grpc::Status MonikerWriteI8(void* data, google::protobuf::Arena& arena, google auto response = &function_data->response; auto session = function_data->session; auto control = function_data->control; + auto request = &function_data->request; + + packedData.UnpackTo(request); + auto value_raw = request->value(); + if (value_raw < std::numeric_limits::min() || value_raw > std::numeric_limits::max()) { + std::string message("value "); + message.append(std::to_string(value_raw)); + message.append(" doesn't fit in datatype "); + message.append("int8_t"); + throw nidevice_grpc::ValueOutOfRangeException(message); + } + auto value = static_cast(value_raw); - I32Data i32data_message; - packedData.UnpackTo(&i32data_message); - auto value = i32data_message.value(); - if (value < std::numeric_limits::min() || value > std::numeric_limits::max()) { - std::string message("value " + std::to_string(value) + " doesn't fit in datatype int8_t"); - throw nidevice_grpc::ValueOutOfRangeException(message); - } auto status = library->WriteI8(session, control, value); @@ -1499,10 +1507,10 @@ ::grpc::Status MonikerWriteSgl(void* data, google::protobuf::Arena& arena, googl auto response = &function_data->response; auto session = function_data->session; auto control = function_data->control; + auto request = &function_data->request; - FloatData floatdata_message; - packedData.UnpackTo(&floatdata_message); - auto value = floatdata_message.value(); + packedData.UnpackTo(request); + float value = request->value(); auto status = library->WriteSgl(session, control, value); @@ -1520,14 +1528,19 @@ ::grpc::Status MonikerWriteU16(void* data, google::protobuf::Arena& arena, googl auto response = &function_data->response; auto session = function_data->session; auto control = function_data->control; + auto request = &function_data->request; + + packedData.UnpackTo(request); + auto value_raw = request->value(); + if (value_raw < std::numeric_limits::min() || value_raw > std::numeric_limits::max()) { + std::string message("value "); + message.append(std::to_string(value_raw)); + message.append(" doesn't fit in datatype "); + message.append("uint16_t"); + throw nidevice_grpc::ValueOutOfRangeException(message); + } + auto value = static_cast(value_raw); - U32Data u32data_message; - packedData.UnpackTo(&u32data_message); - auto value = u32data_message.value(); - if (value < std::numeric_limits::min() || value > std::numeric_limits::max()) { - std::string message("value " + std::to_string(value) + " doesn't fit in datatype uint16_t"); - throw nidevice_grpc::ValueOutOfRangeException(message); - } auto status = library->WriteU16(session, control, value); @@ -1545,10 +1558,10 @@ ::grpc::Status MonikerWriteU32(void* data, google::protobuf::Arena& arena, googl auto response = &function_data->response; auto session = function_data->session; auto control = function_data->control; + auto request = &function_data->request; - U32Data u32data_message; - packedData.UnpackTo(&u32data_message); - auto value = u32data_message.value(); + packedData.UnpackTo(request); + uint32_t value = request->value(); auto status = library->WriteU32(session, control, value); @@ -1566,10 +1579,10 @@ ::grpc::Status MonikerWriteU64(void* data, google::protobuf::Arena& arena, googl auto response = &function_data->response; auto session = function_data->session; auto control = function_data->control; + auto request = &function_data->request; - U64Data u64data_message; - packedData.UnpackTo(&u64data_message); - auto value = u64data_message.value(); + packedData.UnpackTo(request); + uint64_t value = request->value(); auto status = library->WriteU64(session, control, value); @@ -1587,14 +1600,19 @@ ::grpc::Status MonikerWriteU8(void* data, google::protobuf::Arena& arena, google auto response = &function_data->response; auto session = function_data->session; auto control = function_data->control; + auto request = &function_data->request; + + packedData.UnpackTo(request); + auto value_raw = request->value(); + if (value_raw < std::numeric_limits::min() || value_raw > std::numeric_limits::max()) { + std::string message("value "); + message.append(std::to_string(value_raw)); + message.append(" doesn't fit in datatype "); + message.append("uint8_t"); + throw nidevice_grpc::ValueOutOfRangeException(message); + } + auto value = static_cast(value_raw); - U32Data u32data_message; - packedData.UnpackTo(&u32data_message); - auto value = u32data_message.value(); - if (value < std::numeric_limits::min() || value > std::numeric_limits::max()) { - std::string message("value " + std::to_string(value) + " doesn't fit in datatype uint8_t"); - throw nidevice_grpc::ValueOutOfRangeException(message); - } auto status = library->WriteU8(session, control, value); diff --git a/source/codegen/common_helpers.py b/source/codegen/common_helpers.py index 8af239e75..8eb14c426 100644 --- a/source/codegen/common_helpers.py +++ b/source/codegen/common_helpers.py @@ -1292,3 +1292,11 @@ def get_non_streaming_input_parameters(parameters: List[dict]) -> List[dict]: else: params.append(param) return params + + +def extend_input_params_with_size_params(input_parameters: List[dict], function_metadata: dict): + """Return the input_parameters list with size parameters added to it.""" + for param in input_parameters: + size_param_name = get_size_param(param) + size_param = [p for p in function_metadata["parameters"] if p["name"] == size_param_name] + input_parameters.extend(size_param) diff --git a/source/codegen/metadata/nidaqmx/functions.py b/source/codegen/metadata/nidaqmx/functions.py index ec89562b3..68ce37ab0 100644 --- a/source/codegen/metadata/nidaqmx/functions.py +++ b/source/codegen/metadata/nidaqmx/functions.py @@ -24771,8 +24771,10 @@ { 'ctypes_data_type': 'numpy.float64', 'direction': 'in', + 'grpc_streaming_type': 'ArrayDoubleData', 'is_list': True, 'is_optional_in_python': False, + 'is_streaming_type': True, 'name': 'frequency', 'python_data_type': 'float', 'python_type_annotation': 'List[float]', @@ -24781,8 +24783,10 @@ { 'ctypes_data_type': 'numpy.float64', 'direction': 'in', + 'grpc_streaming_type': 'ArrayDoubleData', 'is_list': True, 'is_optional_in_python': False, + 'is_streaming_type': True, 'name': 'dutyCycle', 'python_data_type': 'float', 'python_type_annotation': 'List[float]', @@ -24791,7 +24795,9 @@ { 'ctypes_data_type': 'ctypes.c_int', 'direction': 'out', + 'grpc_streaming_type': 'I32Data', 'is_optional_in_python': False, + 'is_streaming_type': True, 'name': 'numSampsPerChanWritten', 'python_data_type': 'int', 'python_description': '', @@ -24814,7 +24820,8 @@ } ], 'python_codegen_method': 'CustomCode', - 'returns': 'int32' + 'returns': 'int32', + 'supports_streaming': True }, 'WriteCtrFreqScalar': { 'calling_convention': 'StdCall', @@ -24852,7 +24859,9 @@ { 'ctypes_data_type': 'ctypes.c_double', 'direction': 'in', + 'grpc_streaming_type': 'DoubleData', 'is_optional_in_python': False, + 'is_streaming_type': True, 'name': 'frequency', 'python_data_type': 'float', 'python_type_annotation': 'float', @@ -24861,7 +24870,9 @@ { 'ctypes_data_type': 'ctypes.c_double', 'direction': 'in', + 'grpc_streaming_type': 'DoubleData', 'is_optional_in_python': False, + 'is_streaming_type': True, 'name': 'dutyCycle', 'python_data_type': 'float', 'python_type_annotation': 'float', @@ -24882,7 +24893,8 @@ } ], 'python_codegen_method': 'CustomCode', - 'returns': 'int32' + 'returns': 'int32', + 'supports_streaming': True }, 'WriteCtrTicks': { 'calling_convention': 'StdCall', @@ -24941,8 +24953,10 @@ { 'ctypes_data_type': 'numpy.uint32', 'direction': 'in', + 'grpc_streaming_type': 'ArrayU32Data', 'is_list': True, 'is_optional_in_python': False, + 'is_streaming_type': True, 'name': 'highTicks', 'python_data_type': 'int', 'python_type_annotation': 'List[int]', @@ -24951,8 +24965,10 @@ { 'ctypes_data_type': 'numpy.uint32', 'direction': 'in', + 'grpc_streaming_type': 'ArrayU32Data', 'is_list': True, 'is_optional_in_python': False, + 'is_streaming_type': True, 'name': 'lowTicks', 'python_data_type': 'int', 'python_type_annotation': 'List[int]', @@ -24961,7 +24977,9 @@ { 'ctypes_data_type': 'ctypes.c_int', 'direction': 'out', + 'grpc_streaming_type': 'I32Data', 'is_optional_in_python': False, + 'is_streaming_type': True, 'name': 'numSampsPerChanWritten', 'python_data_type': 'int', 'python_description': '', @@ -24984,7 +25002,8 @@ } ], 'python_codegen_method': 'CustomCode', - 'returns': 'int32' + 'returns': 'int32', + 'supports_streaming': True }, 'WriteCtrTicksScalar': { 'calling_convention': 'StdCall', @@ -25022,6 +25041,8 @@ { 'ctypes_data_type': 'ctypes.c_uint32', 'direction': 'in', + 'grpc_streaming_type': 'U32Data', + 'is_streaming_type': True, 'name': 'highTicks', 'python_data_type': 'int', 'type': 'uInt32' @@ -25029,6 +25050,8 @@ { 'ctypes_data_type': 'ctypes.c_uint32', 'direction': 'in', + 'grpc_streaming_type': 'U32Data', + 'is_streaming_type': True, 'name': 'lowTicks', 'python_data_type': 'int', 'type': 'uInt32' @@ -25048,7 +25071,8 @@ } ], 'python_codegen_method': 'CustomCode', - 'returns': 'int32' + 'returns': 'int32', + 'supports_streaming': True }, 'WriteCtrTime': { 'calling_convention': 'StdCall', @@ -25107,8 +25131,10 @@ { 'ctypes_data_type': 'numpy.float64', 'direction': 'in', + 'grpc_streaming_type': 'ArrayDoubleData', 'is_list': True, 'is_optional_in_python': False, + 'is_streaming_type': True, 'name': 'highTime', 'python_data_type': 'float', 'python_type_annotation': 'List[float]', @@ -25117,8 +25143,10 @@ { 'ctypes_data_type': 'numpy.float64', 'direction': 'in', + 'grpc_streaming_type': 'ArrayDoubleData', 'is_list': True, 'is_optional_in_python': False, + 'is_streaming_type': True, 'name': 'lowTime', 'python_data_type': 'float', 'python_type_annotation': 'List[float]', @@ -25127,7 +25155,9 @@ { 'ctypes_data_type': 'ctypes.c_int', 'direction': 'out', + 'grpc_streaming_type': 'I32Data', 'is_optional_in_python': False, + 'is_streaming_type': True, 'name': 'numSampsPerChanWritten', 'python_data_type': 'int', 'python_description': '', @@ -25150,7 +25180,8 @@ } ], 'python_codegen_method': 'CustomCode', - 'returns': 'int32' + 'returns': 'int32', + 'supports_streaming': True }, 'WriteCtrTimeScalar': { 'calling_convention': 'StdCall', @@ -25188,7 +25219,9 @@ { 'ctypes_data_type': 'ctypes.c_double', 'direction': 'in', + 'grpc_streaming_type': 'DoubleData', 'is_optional_in_python': False, + 'is_streaming_type': True, 'name': 'highTime', 'python_data_type': 'float', 'python_type_annotation': 'float', @@ -25197,7 +25230,9 @@ { 'ctypes_data_type': 'ctypes.c_double', 'direction': 'in', + 'grpc_streaming_type': 'DoubleData', 'is_optional_in_python': False, + 'is_streaming_type': True, 'name': 'lowTime', 'python_data_type': 'float', 'python_type_annotation': 'float', @@ -25218,7 +25253,8 @@ } ], 'python_codegen_method': 'CustomCode', - 'returns': 'int32' + 'returns': 'int32', + 'supports_streaming': True }, 'WriteDigitalLines': { 'calling_convention': 'StdCall', @@ -25277,8 +25313,10 @@ { 'ctypes_data_type': 'numpy.bool', 'direction': 'in', + 'grpc_streaming_type': 'ArrayU8Data', 'is_list': True, 'is_optional_in_python': False, + 'is_streaming_type': True, 'name': 'writeArray', 'python_data_type': 'int', 'python_description': '', @@ -25288,7 +25326,9 @@ { 'ctypes_data_type': 'ctypes.c_int', 'direction': 'out', + 'grpc_streaming_type': 'I32Data', 'is_optional_in_python': False, + 'is_streaming_type': True, 'name': 'sampsPerChanWritten', 'python_data_type': 'int', 'python_description': '', @@ -25311,7 +25351,8 @@ } ], 'python_codegen_method': 'CustomCode', - 'returns': 'int32' + 'returns': 'int32', + 'supports_streaming': True }, 'WriteDigitalScalarU32': { 'calling_convention': 'StdCall', @@ -25630,8 +25671,10 @@ { 'ctypes_data_type': 'numpy.uint8', 'direction': 'in', + 'grpc_streaming_type': 'ArrayU8Data', 'is_list': True, 'is_optional_in_python': False, + 'is_streaming_type': True, 'name': 'writeArray', 'python_data_type': 'int', 'python_description': '', @@ -25641,7 +25684,9 @@ { 'ctypes_data_type': 'ctypes.c_int', 'direction': 'out', + 'grpc_streaming_type': 'I32Data', 'is_optional_in_python': False, + 'is_streaming_type': True, 'name': 'sampsPerChanWritten', 'python_data_type': 'int', 'python_description': '', @@ -25664,7 +25709,8 @@ } ], 'python_codegen_method': 'CustomCode', - 'returns': 'int32' + 'returns': 'int32', + 'supports_streaming': True }, 'WriteRaw': { 'calling_convention': 'StdCall', @@ -25712,7 +25758,9 @@ { 'ctypes_data_type': 'numpy.generic', 'direction': 'in', + 'grpc_streaming_type': 'ArrayU8Data', 'is_optional_in_python': False, + 'is_streaming_type': True, 'name': 'writeArray', 'python_data_type': 'dynamic', 'python_type_annotation': 'dynamic', @@ -25721,7 +25769,9 @@ { 'ctypes_data_type': 'ctypes.c_int', 'direction': 'out', + 'grpc_streaming_type': 'I32Data', 'is_optional_in_python': False, + 'is_streaming_type': True, 'name': 'sampsPerChanWritten', 'python_data_type': 'int', 'python_description': '', @@ -25744,7 +25794,8 @@ } ], 'python_codegen_method': 'no', - 'returns': 'int32' + 'returns': 'int32', + 'supports_streaming': True }, 'WriteToTEDSFromArray': { 'calling_convention': 'StdCall', diff --git a/source/codegen/service_helpers.py b/source/codegen/service_helpers.py index 7ba907666..4edbe65b5 100644 --- a/source/codegen/service_helpers.py +++ b/source/codegen/service_helpers.py @@ -707,14 +707,3 @@ def get_protobuf_cpplib_type(grpc_type: str) -> str: return "std::string" return grpc_type - - -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. - """ - if common_helpers.is_array(streaming_param["type"]) and streaming_param["direction"] == "out": - return common_helpers.camel_to_snake(streaming_param["size"]["value"]) - else: - return None diff --git a/source/codegen/templates/service_helpers.mako b/source/codegen/templates/service_helpers.mako index 25acbabc3..5acadf327 100644 --- a/source/codegen/templates/service_helpers.mako +++ b/source/codegen/templates/service_helpers.mako @@ -323,7 +323,8 @@ ${populate_response(function_data=function_data, parameters=parameters)}\ ${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)}\ + auto request = &function_data->request; +${streaming_handle_in_direction(functions, function_name)}\ % endif auto status = library->${non_streaming_function_name}(${arg_string}); @@ -349,72 +350,15 @@ ${initialize_moniker_struct(struct_name, moniker_input_parameters, output_parame return ::grpc::Status::OK;\ -<%def name="streaming_handle_in_direction(streaming_param)"> +<%def name="streaming_handle_in_direction(functions, begin_function_name)"> <% - 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(grpc_streaming_type, streaming_param)}\ -% else: - ${streaming_handle_in_direction_scaler(grpc_streaming_type, streaming_type, streaming_param)}\ -% endif - - -<%def name="streaming_handle_in_direction_scaler(grpc_streaming_type, streaming_type, streaming_param)">\ -<% - is_coerced = service_helpers.is_scalar_input_that_needs_coercion(streaming_param) -%>\ -auto value = ${grpc_streaming_type.lower()}_message.value(); -% if is_coerced: - if (value < std::numeric_limits<${streaming_type}>::min() || value > std::numeric_limits<${streaming_type}>::max()) { - std::string message("value " + std::to_string(value) + " doesn't fit in datatype ${streaming_type}"); - throw nidevice_grpc::ValueOutOfRangeException(message); - } -% endif - - -<%def name="streaming_handle_in_direction_array(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"]) - underlying_param_type_with_no_qualifiers = underlying_param_type.replace("const ", "") - + request_message_type = common_helpers.get_data_moniker_request_message_type(begin_function_name) + 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]) + common_helpers.extend_input_params_with_size_params(input_parameters, functions[non_streaming_function_name])\ %>\ -% if common_helpers.supports_standard_copy_conversion_routines(streaming_param): - auto data_array = ${grpc_streaming_type.lower()}_message.value(); - 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(); - auto ${streaming_param_name} = std::vector<${c_element_type_that_needs_coercion}>(); - auto size = data_array.size(); - ${streaming_param_name}.reserve(size); - std::transform( - data_array.begin(), - data_array.end(), - std::back_inserter(${streaming_param_name}), - [](auto x) { - if (x < std::numeric_limits<${c_element_type_that_needs_coercion}>::min() || x > std::numeric_limits<${c_element_type_that_needs_coercion}>::max()) { - std::string message("value " + std::to_string(x) + " doesn't fit in datatype ${c_element_type_that_needs_coercion}"); - throw nidevice_grpc::ValueOutOfRangeException(message); - } - return static_cast<${c_element_type_that_needs_coercion}>(x); - }); -% 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_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<${underlying_param_type}*>(${grpc_streaming_type.lower()}_message.value().data()); -% endif - auto size = data_array.size(); -% endif + packedData.UnpackTo(request); +${initialize_input_params(non_streaming_function_name, input_parameters)}\ <%def name="populate_moniker_response_for_out_functions(output_parameters, streaming_param)">\ @@ -457,7 +401,7 @@ ${set_response_values(output_parameters=output_parameters, init_method=false)}\ % for param in output_array_params: <% grpc_field_name = common_helpers.get_grpc_field_name(param) - size_param_name = service_helpers.get_size_param_name(param) + size_param_name = common_helpers.camel_to_snake(common_helpers.get_size_param(param)) %>\ % if common_helpers.is_string_arg(param): data->response.mutable_${grpc_field_name}()->reserve(request->${size_param_name}()); diff --git a/source/tests/integration/ni_fake_fpga_streaming_tests.cpp b/source/tests/integration/ni_fake_fpga_streaming_tests.cpp index 99d8f4edf..7b47f2e3f 100644 --- a/source/tests/integration/ni_fake_fpga_streaming_tests.cpp +++ b/source/tests/integration/ni_fake_fpga_streaming_tests.cpp @@ -230,11 +230,11 @@ TEST_F(NiFakeFpgaStreamingTests, StreamWrite_Array) for (int i = 0; i < 5; i++) { // Write data - nifpga_grpc::ArrayI32Data write_values_array_i32; - nifpga_grpc::ArrayI64Data write_values_array_i64; + nifpga_grpc::MonikerWriteArrayI32Request write_values_array_i32; + nifpga_grpc::MonikerWriteArrayI64Request write_values_array_i64; - write_values_array_i32.mutable_value()->Add(data_int_i32.begin(), data_int_i32.end()); - write_values_array_i64.mutable_value()->Add(data_int_i64.begin(), data_int_i64.end()); + write_values_array_i32.mutable_array()->Add(data_int_i32.begin(), data_int_i32.end()); + write_values_array_i64.mutable_array()->Add(data_int_i64.begin(), data_int_i64.end()); ni::data_monikers::MonikerWriteRequest write_data_request; write_data_request.mutable_data()->add_values()->PackFrom(write_values_array_i32); @@ -302,11 +302,11 @@ TEST_F(NiFakeFpgaStreamingTests, StreamReadWrite_Array) for (int i = 0; i < 5; i++) { // Write data - nifpga_grpc::ArrayI32Data write_values_array_i32; - nifpga_grpc::ArrayI64Data write_values_array_i64; + nifpga_grpc::MonikerWriteArrayI32Request write_values_array_i32; + nifpga_grpc::MonikerWriteArrayI64Request write_values_array_i64; - write_values_array_i32.mutable_value()->Add(write_data_int32.begin(), write_data_int32.end()); - write_values_array_i64.mutable_value()->Add(write_data_int64.begin(), write_data_int64.end()); + write_values_array_i32.mutable_array()->Add(write_data_int32.begin(), write_data_int32.end()); + write_values_array_i64.mutable_array()->Add(write_data_int64.begin(), write_data_int64.end()); ni::data_monikers::MonikerWriteRequest write_data_request; write_data_request.mutable_data()->add_values()->PackFrom(write_values_array_i32); @@ -388,11 +388,11 @@ TEST_F(NiFakeFpgaStreamingTests, DISABLED_SidebandStreamReadWrite_Array) for (int i = 0; i < 5; i++) { // Write data - nifpga_grpc::ArrayI32Data write_values_array_i32; - nifpga_grpc::ArrayI64Data write_values_array_i64; + nifpga_grpc::MonikerWriteArrayI32Request write_values_array_i32; + nifpga_grpc::MonikerWriteArrayI64Request write_values_array_i64; - write_values_array_i32.mutable_value()->Add(write_data_int32.begin(), write_data_int32.end()); - write_values_array_i64.mutable_value()->Add(write_data_int64.begin(), write_data_int64.end()); + write_values_array_i32.mutable_array()->Add(write_data_int32.begin(), write_data_int32.end()); + write_values_array_i64.mutable_array()->Add(write_data_int64.begin(), write_data_int64.end()); ni::data_monikers::SidebandWriteRequest write_data_request; write_data_request.mutable_values()->add_values()->PackFrom(write_values_array_i32);