Skip to content

Commit

Permalink
Add codegen support for Daqmx Read apis which have multiple out param…
Browse files Browse the repository at this point in the history
…s. (#1129)

* 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

* merged latest main

---------

Co-authored-by: Rohan Doshi <rohan.doshi@ni.com>
Co-authored-by: Raghav Rawat <raghavrawat@ni.com>
  • Loading branch information
3 people authored Nov 27, 2024
1 parent 06ed455 commit b966222
Show file tree
Hide file tree
Showing 11 changed files with 2,108 additions and 381 deletions.
324 changes: 290 additions & 34 deletions generated/nidaqmx/nidaqmx.proto

Large diffs are not rendered by default.

288 changes: 288 additions & 0 deletions generated/nidaqmx/nidaqmx_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8072,6 +8072,34 @@ read_ctr_freq(const StubPtr& stub, const nidevice_grpc::Session& task, const pb:
return response;
}

BeginReadCtrFreqResponse
begin_read_ctr_freq(const StubPtr& stub, const nidevice_grpc::Session& task, const pb::int32& num_samps_per_chan, const double& timeout, const simple_variant<GroupBy, pb::int32>& interleaved, const pb::uint32& array_size_in_samps)
{
::grpc::ClientContext context;

auto request = BeginReadCtrFreqRequest{};
request.mutable_task()->CopyFrom(task);
request.set_num_samps_per_chan(num_samps_per_chan);
request.set_timeout(timeout);
const auto interleaved_ptr = interleaved.get_if<GroupBy>();
const auto interleaved_raw_ptr = interleaved.get_if<pb::int32>();
if (interleaved_ptr) {
request.set_interleaved(*interleaved_ptr);
}
else if (interleaved_raw_ptr) {
request.set_interleaved_raw(*interleaved_raw_ptr);
}
request.set_array_size_in_samps(array_size_in_samps);

auto response = BeginReadCtrFreqResponse{};

raise_if_error(
stub->BeginReadCtrFreq(&context, request, &response),
context);

return response;
}

ReadCtrFreqScalarResponse
read_ctr_freq_scalar(const StubPtr& stub, const nidevice_grpc::Session& task, const double& timeout)
{
Expand All @@ -8090,6 +8118,24 @@ read_ctr_freq_scalar(const StubPtr& stub, const nidevice_grpc::Session& task, co
return response;
}

BeginReadCtrFreqScalarResponse
begin_read_ctr_freq_scalar(const StubPtr& stub, const nidevice_grpc::Session& task, const double& timeout)
{
::grpc::ClientContext context;

auto request = BeginReadCtrFreqScalarRequest{};
request.mutable_task()->CopyFrom(task);
request.set_timeout(timeout);

auto response = BeginReadCtrFreqScalarResponse{};

raise_if_error(
stub->BeginReadCtrFreqScalar(&context, request, &response),
context);

return response;
}

ReadCtrTicksResponse
read_ctr_ticks(const StubPtr& stub, const nidevice_grpc::Session& task, const pb::int32& num_samps_per_chan, const double& timeout, const simple_variant<GroupBy, pb::int32>& interleaved, const pb::uint32& array_size_in_samps)
{
Expand Down Expand Up @@ -8118,6 +8164,34 @@ read_ctr_ticks(const StubPtr& stub, const nidevice_grpc::Session& task, const pb
return response;
}

BeginReadCtrTicksResponse
begin_read_ctr_ticks(const StubPtr& stub, const nidevice_grpc::Session& task, const pb::int32& num_samps_per_chan, const double& timeout, const simple_variant<GroupBy, pb::int32>& interleaved, const pb::uint32& array_size_in_samps)
{
::grpc::ClientContext context;

auto request = BeginReadCtrTicksRequest{};
request.mutable_task()->CopyFrom(task);
request.set_num_samps_per_chan(num_samps_per_chan);
request.set_timeout(timeout);
const auto interleaved_ptr = interleaved.get_if<GroupBy>();
const auto interleaved_raw_ptr = interleaved.get_if<pb::int32>();
if (interleaved_ptr) {
request.set_interleaved(*interleaved_ptr);
}
else if (interleaved_raw_ptr) {
request.set_interleaved_raw(*interleaved_raw_ptr);
}
request.set_array_size_in_samps(array_size_in_samps);

auto response = BeginReadCtrTicksResponse{};

raise_if_error(
stub->BeginReadCtrTicks(&context, request, &response),
context);

return response;
}

ReadCtrTicksScalarResponse
read_ctr_ticks_scalar(const StubPtr& stub, const nidevice_grpc::Session& task, const double& timeout)
{
Expand All @@ -8136,6 +8210,24 @@ read_ctr_ticks_scalar(const StubPtr& stub, const nidevice_grpc::Session& task, c
return response;
}

BeginReadCtrTicksScalarResponse
begin_read_ctr_ticks_scalar(const StubPtr& stub, const nidevice_grpc::Session& task, const double& timeout)
{
::grpc::ClientContext context;

auto request = BeginReadCtrTicksScalarRequest{};
request.mutable_task()->CopyFrom(task);
request.set_timeout(timeout);

auto response = BeginReadCtrTicksScalarResponse{};

raise_if_error(
stub->BeginReadCtrTicksScalar(&context, request, &response),
context);

return response;
}

ReadCtrTimeResponse
read_ctr_time(const StubPtr& stub, const nidevice_grpc::Session& task, const pb::int32& num_samps_per_chan, const double& timeout, const simple_variant<GroupBy, pb::int32>& interleaved, const pb::uint32& array_size_in_samps)
{
Expand Down Expand Up @@ -8164,6 +8256,34 @@ read_ctr_time(const StubPtr& stub, const nidevice_grpc::Session& task, const pb:
return response;
}

BeginReadCtrTimeResponse
begin_read_ctr_time(const StubPtr& stub, const nidevice_grpc::Session& task, const pb::int32& num_samps_per_chan, const double& timeout, const simple_variant<GroupBy, pb::int32>& interleaved, const pb::uint32& array_size_in_samps)
{
::grpc::ClientContext context;

auto request = BeginReadCtrTimeRequest{};
request.mutable_task()->CopyFrom(task);
request.set_num_samps_per_chan(num_samps_per_chan);
request.set_timeout(timeout);
const auto interleaved_ptr = interleaved.get_if<GroupBy>();
const auto interleaved_raw_ptr = interleaved.get_if<pb::int32>();
if (interleaved_ptr) {
request.set_interleaved(*interleaved_ptr);
}
else if (interleaved_raw_ptr) {
request.set_interleaved_raw(*interleaved_raw_ptr);
}
request.set_array_size_in_samps(array_size_in_samps);

auto response = BeginReadCtrTimeResponse{};

raise_if_error(
stub->BeginReadCtrTime(&context, request, &response),
context);

return response;
}

ReadCtrTimeScalarResponse
read_ctr_time_scalar(const StubPtr& stub, const nidevice_grpc::Session& task, const double& timeout)
{
Expand All @@ -8182,6 +8302,24 @@ read_ctr_time_scalar(const StubPtr& stub, const nidevice_grpc::Session& task, co
return response;
}

BeginReadCtrTimeScalarResponse
begin_read_ctr_time_scalar(const StubPtr& stub, const nidevice_grpc::Session& task, const double& timeout)
{
::grpc::ClientContext context;

auto request = BeginReadCtrTimeScalarRequest{};
request.mutable_task()->CopyFrom(task);
request.set_timeout(timeout);

auto response = BeginReadCtrTimeScalarResponse{};

raise_if_error(
stub->BeginReadCtrTimeScalar(&context, request, &response),
context);

return response;
}

ReadDigitalLinesResponse
read_digital_lines(const StubPtr& stub, const nidevice_grpc::Session& task, const pb::int32& num_samps_per_chan, const double& timeout, const simple_variant<GroupBy, pb::int32>& fill_mode, const pb::uint32& array_size_in_bytes)
{
Expand Down Expand Up @@ -8210,6 +8348,34 @@ read_digital_lines(const StubPtr& stub, const nidevice_grpc::Session& task, cons
return response;
}

BeginReadDigitalLinesResponse
begin_read_digital_lines(const StubPtr& stub, const nidevice_grpc::Session& task, const pb::int32& num_samps_per_chan, const double& timeout, const simple_variant<GroupBy, pb::int32>& fill_mode, const pb::uint32& array_size_in_bytes)
{
::grpc::ClientContext context;

auto request = BeginReadDigitalLinesRequest{};
request.mutable_task()->CopyFrom(task);
request.set_num_samps_per_chan(num_samps_per_chan);
request.set_timeout(timeout);
const auto fill_mode_ptr = fill_mode.get_if<GroupBy>();
const auto fill_mode_raw_ptr = fill_mode.get_if<pb::int32>();
if (fill_mode_ptr) {
request.set_fill_mode(*fill_mode_ptr);
}
else if (fill_mode_raw_ptr) {
request.set_fill_mode_raw(*fill_mode_raw_ptr);
}
request.set_array_size_in_bytes(array_size_in_bytes);

auto response = BeginReadDigitalLinesResponse{};

raise_if_error(
stub->BeginReadDigitalLines(&context, request, &response),
context);

return response;
}

ReadDigitalScalarU32Response
read_digital_scalar_u32(const StubPtr& stub, const nidevice_grpc::Session& task, const double& timeout)
{
Expand Down Expand Up @@ -8386,6 +8552,34 @@ read_digital_u8(const StubPtr& stub, const nidevice_grpc::Session& task, const p
return response;
}

BeginReadDigitalU8Response
begin_read_digital_u8(const StubPtr& stub, const nidevice_grpc::Session& task, const pb::int32& num_samps_per_chan, const double& timeout, const simple_variant<GroupBy, pb::int32>& fill_mode, const pb::uint32& array_size_in_samps)
{
::grpc::ClientContext context;

auto request = BeginReadDigitalU8Request{};
request.mutable_task()->CopyFrom(task);
request.set_num_samps_per_chan(num_samps_per_chan);
request.set_timeout(timeout);
const auto fill_mode_ptr = fill_mode.get_if<GroupBy>();
const auto fill_mode_raw_ptr = fill_mode.get_if<pb::int32>();
if (fill_mode_ptr) {
request.set_fill_mode(*fill_mode_ptr);
}
else if (fill_mode_raw_ptr) {
request.set_fill_mode_raw(*fill_mode_raw_ptr);
}
request.set_array_size_in_samps(array_size_in_samps);

auto response = BeginReadDigitalU8Response{};

raise_if_error(
stub->BeginReadDigitalU8(&context, request, &response),
context);

return response;
}

ReadPowerBinaryI16Response
read_power_binary_i16(const StubPtr& stub, const nidevice_grpc::Session& task, const pb::int32& num_samps_per_chan, const double& timeout, const simple_variant<GroupBy, pb::int32>& fill_mode, const pb::uint32& array_size_in_samps)
{
Expand Down Expand Up @@ -8414,6 +8608,34 @@ read_power_binary_i16(const StubPtr& stub, const nidevice_grpc::Session& task, c
return response;
}

BeginReadPowerBinaryI16Response
begin_read_power_binary_i16(const StubPtr& stub, const nidevice_grpc::Session& task, const pb::int32& num_samps_per_chan, const double& timeout, const simple_variant<GroupBy, pb::int32>& fill_mode, const pb::uint32& array_size_in_samps)
{
::grpc::ClientContext context;

auto request = BeginReadPowerBinaryI16Request{};
request.mutable_task()->CopyFrom(task);
request.set_num_samps_per_chan(num_samps_per_chan);
request.set_timeout(timeout);
const auto fill_mode_ptr = fill_mode.get_if<GroupBy>();
const auto fill_mode_raw_ptr = fill_mode.get_if<pb::int32>();
if (fill_mode_ptr) {
request.set_fill_mode(*fill_mode_ptr);
}
else if (fill_mode_raw_ptr) {
request.set_fill_mode_raw(*fill_mode_raw_ptr);
}
request.set_array_size_in_samps(array_size_in_samps);

auto response = BeginReadPowerBinaryI16Response{};

raise_if_error(
stub->BeginReadPowerBinaryI16(&context, request, &response),
context);

return response;
}

ReadPowerF64Response
read_power_f64(const StubPtr& stub, const nidevice_grpc::Session& task, const pb::int32& num_samps_per_chan, const double& timeout, const simple_variant<GroupBy, pb::int32>& fill_mode, const pb::uint32& array_size_in_samps)
{
Expand Down Expand Up @@ -8442,6 +8664,34 @@ read_power_f64(const StubPtr& stub, const nidevice_grpc::Session& task, const pb
return response;
}

BeginReadPowerF64Response
begin_read_power_f64(const StubPtr& stub, const nidevice_grpc::Session& task, const pb::int32& num_samps_per_chan, const double& timeout, const simple_variant<GroupBy, pb::int32>& fill_mode, const pb::uint32& array_size_in_samps)
{
::grpc::ClientContext context;

auto request = BeginReadPowerF64Request{};
request.mutable_task()->CopyFrom(task);
request.set_num_samps_per_chan(num_samps_per_chan);
request.set_timeout(timeout);
const auto fill_mode_ptr = fill_mode.get_if<GroupBy>();
const auto fill_mode_raw_ptr = fill_mode.get_if<pb::int32>();
if (fill_mode_ptr) {
request.set_fill_mode(*fill_mode_ptr);
}
else if (fill_mode_raw_ptr) {
request.set_fill_mode_raw(*fill_mode_raw_ptr);
}
request.set_array_size_in_samps(array_size_in_samps);

auto response = BeginReadPowerF64Response{};

raise_if_error(
stub->BeginReadPowerF64(&context, request, &response),
context);

return response;
}

ReadPowerScalarF64Response
read_power_scalar_f64(const StubPtr& stub, const nidevice_grpc::Session& task, const double& timeout)
{
Expand All @@ -8460,6 +8710,24 @@ read_power_scalar_f64(const StubPtr& stub, const nidevice_grpc::Session& task, c
return response;
}

BeginReadPowerScalarF64Response
begin_read_power_scalar_f64(const StubPtr& stub, const nidevice_grpc::Session& task, const double& timeout)
{
::grpc::ClientContext context;

auto request = BeginReadPowerScalarF64Request{};
request.mutable_task()->CopyFrom(task);
request.set_timeout(timeout);

auto response = BeginReadPowerScalarF64Response{};

raise_if_error(
stub->BeginReadPowerScalarF64(&context, request, &response),
context);

return response;
}

ReadRawResponse
read_raw(const StubPtr& stub, const nidevice_grpc::Session& task, const pb::int32& num_samps_per_chan, const double& timeout, const pb::uint32& array_size_in_bytes)
{
Expand All @@ -8480,6 +8748,26 @@ read_raw(const StubPtr& stub, const nidevice_grpc::Session& task, const pb::int3
return response;
}

BeginReadRawResponse
begin_read_raw(const StubPtr& stub, const nidevice_grpc::Session& task, const pb::int32& num_samps_per_chan, const double& timeout, const pb::uint32& array_size_in_bytes)
{
::grpc::ClientContext context;

auto request = BeginReadRawRequest{};
request.mutable_task()->CopyFrom(task);
request.set_num_samps_per_chan(num_samps_per_chan);
request.set_timeout(timeout);
request.set_array_size_in_bytes(array_size_in_bytes);

auto response = BeginReadRawResponse{};

raise_if_error(
stub->BeginReadRaw(&context, request, &response),
context);

return response;
}

std::unique_ptr<grpc::ClientReader<RegisterDoneEventResponse>>
register_done_event(const StubPtr& stub, ::grpc::ClientContext& context, const nidevice_grpc::Session& task)
{
Expand Down
Loading

0 comments on commit b966222

Please sign in to comment.