Skip to content

Commit

Permalink
include WriteI64 as well for auto-generation
Browse files Browse the repository at this point in the history
  • Loading branch information
amehra-ni committed Aug 6, 2024
1 parent d7d9977 commit 8dc9064
Show file tree
Hide file tree
Showing 11 changed files with 77 additions and 3 deletions.
11 changes: 11 additions & 0 deletions generated/nifpga/nifpga.proto
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ service NiFpga {
rpc WriteFxp64(WriteFxp64Request) returns (WriteFxp64Response);
rpc WriteI16(WriteI16Request) returns (WriteI16Response);
rpc WriteI32(WriteI32Request) returns (WriteI32Response);
rpc WriteI64(WriteI64Request) returns (WriteI64Response);
rpc WriteI8(WriteI8Request) returns (WriteI8Response);
rpc WriteSgl(WriteSglRequest) returns (WriteSglResponse);
rpc WriteU16(WriteU16Request) returns (WriteU16Response);
Expand Down Expand Up @@ -928,6 +929,16 @@ message WriteI32Response {
int32 status = 1;
}

message WriteI64Request {
nidevice_grpc.Session session = 1;
uint32 control = 2;
int64 value = 3;
}

message WriteI64Response {
int32 status = 1;
}

message WriteI8Request {
nidevice_grpc.Session session = 1;
uint32 control = 2;
Expand Down
19 changes: 19 additions & 0 deletions generated/nifpga/nifpga_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1461,6 +1461,25 @@ write_i32(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::
return response;
}

WriteI64Response
write_i64(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& control, const pb::int64& value)
{
::grpc::ClientContext context;

auto request = WriteI64Request{};
request.mutable_session()->CopyFrom(session);
request.set_control(control);
request.set_value(value);

auto response = WriteI64Response{};

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

return response;
}

WriteI8Response
write_i8(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& control, const pb::int32& value)
{
Expand Down
1 change: 1 addition & 0 deletions generated/nifpga/nifpga_client.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ WriteFifoU8Response write_fifo_u8(const StubPtr& stub, const nidevice_grpc::Sess
WriteFxp64Response write_fxp64(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& control, const FxpTypeInfo& type_info, const pb::uint64& value);
WriteI16Response write_i16(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& control, const pb::int32& value);
WriteI32Response write_i32(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& control, const pb::int32& value);
WriteI64Response write_i64(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& control, const pb::int64& value);
WriteI8Response write_i8(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& control, const pb::int32& value);
WriteSglResponse write_sgl(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& control, const float& value);
WriteU16Response write_u16(const StubPtr& stub, const nidevice_grpc::Session& session, const pb::uint32& control, const pb::uint32& value);
Expand Down
5 changes: 5 additions & 0 deletions generated/nifpga/nifpga_compilation_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,11 @@ NiFpga_Status WriteI32(NiFpga_Session session, uint32_t control, int32_t value)
return NiFpga_WriteI32(session, control, value);
}

NiFpga_Status WriteI64(NiFpga_Session session, uint32_t control, int64_t value)
{
return NiFpga_WriteI64(session, control, value);
}

NiFpga_Status WriteI8(NiFpga_Session session, uint32_t control, int8_t value)
{
return NiFpga_WriteI8(session, control, value);
Expand Down
9 changes: 9 additions & 0 deletions generated/nifpga/nifpga_library.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ NiFpgaLibrary::NiFpgaLibrary(std::shared_ptr<nidevice_grpc::SharedLibraryInterfa
function_pointers_.WriteFxp64 = reinterpret_cast<WriteFxp64Ptr>(shared_library_->get_function_pointer("NiFpgaDll_WriteFxp64"));
function_pointers_.WriteI16 = reinterpret_cast<WriteI16Ptr>(shared_library_->get_function_pointer("NiFpgaDll_WriteI16"));
function_pointers_.WriteI32 = reinterpret_cast<WriteI32Ptr>(shared_library_->get_function_pointer("NiFpgaDll_WriteI32"));
function_pointers_.WriteI64 = reinterpret_cast<WriteI64Ptr>(shared_library_->get_function_pointer("NiFpgaDll_WriteI64"));
function_pointers_.WriteI8 = reinterpret_cast<WriteI8Ptr>(shared_library_->get_function_pointer("NiFpgaDll_WriteI8"));
function_pointers_.WriteSgl = reinterpret_cast<WriteSglPtr>(shared_library_->get_function_pointer("NiFpgaDll_WriteSgl"));
function_pointers_.WriteU16 = reinterpret_cast<WriteU16Ptr>(shared_library_->get_function_pointer("NiFpgaDll_WriteU16"));
Expand Down Expand Up @@ -730,6 +731,14 @@ NiFpga_Status NiFpgaLibrary::WriteI32(NiFpga_Session session, uint32_t control,
return function_pointers_.WriteI32(session, control, value);
}

NiFpga_Status NiFpgaLibrary::WriteI64(NiFpga_Session session, uint32_t control, int64_t value)
{
if (!function_pointers_.WriteI64) {
throw nidevice_grpc::LibraryLoadException("Could not find NiFpga_WriteI64.");
}
return function_pointers_.WriteI64(session, control, value);
}

NiFpga_Status NiFpgaLibrary::WriteI8(NiFpga_Session session, uint32_t control, int8_t value)
{
if (!function_pointers_.WriteI8) {
Expand Down
3 changes: 3 additions & 0 deletions generated/nifpga/nifpga_library.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ class NiFpgaLibrary : public nifpga_grpc::NiFpgaLibraryInterface {
NiFpga_Status WriteFxp64(NiFpga_Session session, uint32_t control, NiFpga_FxpTypeInfo typeInfo, uint64_t value) override;
NiFpga_Status WriteI16(NiFpga_Session session, uint32_t control, int16_t value) override;
NiFpga_Status WriteI32(NiFpga_Session session, uint32_t control, int32_t value) override;
NiFpga_Status WriteI64(NiFpga_Session session, uint32_t control, int64_t value) override;
NiFpga_Status WriteI8(NiFpga_Session session, uint32_t control, int8_t value) override;
NiFpga_Status WriteSgl(NiFpga_Session session, uint32_t control, float value) override;
NiFpga_Status WriteU16(NiFpga_Session session, uint32_t control, uint16_t value) override;
Expand Down Expand Up @@ -181,6 +182,7 @@ class NiFpgaLibrary : public nifpga_grpc::NiFpgaLibraryInterface {
using WriteFxp64Ptr = decltype(&NiFpga_WriteFxp64);
using WriteI16Ptr = decltype(&NiFpga_WriteI16);
using WriteI32Ptr = decltype(&NiFpga_WriteI32);
using WriteI64Ptr = decltype(&NiFpga_WriteI64);
using WriteI8Ptr = decltype(&NiFpga_WriteI8);
using WriteSglPtr = decltype(&NiFpga_WriteSgl);
using WriteU16Ptr = decltype(&NiFpga_WriteU16);
Expand Down Expand Up @@ -265,6 +267,7 @@ class NiFpgaLibrary : public nifpga_grpc::NiFpgaLibraryInterface {
WriteFxp64Ptr WriteFxp64;
WriteI16Ptr WriteI16;
WriteI32Ptr WriteI32;
WriteI64Ptr WriteI64;
WriteI8Ptr WriteI8;
WriteSglPtr WriteSgl;
WriteU16Ptr WriteU16;
Expand Down
1 change: 1 addition & 0 deletions generated/nifpga/nifpga_library_interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ class NiFpgaLibraryInterface {
virtual NiFpga_Status WriteFxp64(NiFpga_Session session, uint32_t control, NiFpga_FxpTypeInfo typeInfo, uint64_t value) = 0;
virtual NiFpga_Status WriteI16(NiFpga_Session session, uint32_t control, int16_t value) = 0;
virtual NiFpga_Status WriteI32(NiFpga_Session session, uint32_t control, int32_t value) = 0;
virtual NiFpga_Status WriteI64(NiFpga_Session session, uint32_t control, int64_t value) = 0;
virtual NiFpga_Status WriteI8(NiFpga_Session session, uint32_t control, int8_t value) = 0;
virtual NiFpga_Status WriteSgl(NiFpga_Session session, uint32_t control, float value) = 0;
virtual NiFpga_Status WriteU16(NiFpga_Session session, uint32_t control, uint16_t value) = 0;
Expand Down
1 change: 1 addition & 0 deletions generated/nifpga/nifpga_mock_library.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ class NiFpgaMockLibrary : public nifpga_grpc::NiFpgaLibraryInterface {
MOCK_METHOD(NiFpga_Status, WriteFxp64, (NiFpga_Session session, uint32_t control, NiFpga_FxpTypeInfo typeInfo, uint64_t value), (override));
MOCK_METHOD(NiFpga_Status, WriteI16, (NiFpga_Session session, uint32_t control, int16_t value), (override));
MOCK_METHOD(NiFpga_Status, WriteI32, (NiFpga_Session session, uint32_t control, int32_t value), (override));
MOCK_METHOD(NiFpga_Status, WriteI64, (NiFpga_Session session, uint32_t control, int64_t value), (override));
MOCK_METHOD(NiFpga_Status, WriteI8, (NiFpga_Session session, uint32_t control, int8_t value), (override));
MOCK_METHOD(NiFpga_Status, WriteSgl, (NiFpga_Session session, uint32_t control, float value), (override));
MOCK_METHOD(NiFpga_Status, WriteU16, (NiFpga_Session session, uint32_t control, uint16_t value), (override));
Expand Down
24 changes: 24 additions & 0 deletions generated/nifpga/nifpga_service.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2232,6 +2232,30 @@ namespace nifpga_grpc {
}
}

//---------------------------------------------------------------------
//---------------------------------------------------------------------
::grpc::Status NiFpgaService::WriteI64(::grpc::ServerContext* context, const WriteI64Request* request, WriteI64Response* response)
{
if (context->IsCancelled()) {
return ::grpc::Status::CANCELLED;
}
try {
auto session_grpc_session = request->session();
NiFpga_Session session = session_repository_->access_session(session_grpc_session.name());
uint32_t control = request->control();
int64_t value = request->value();
auto status = library_->WriteI64(session, control, value);
if (!status_ok(status)) {
return ConvertApiErrorStatusForNiFpga_Session(context, status, session);
}
response->set_status(status);
return ::grpc::Status::OK;
}
catch (nidevice_grpc::NonDriverException& ex) {
return ex.GetStatus();
}
}

//---------------------------------------------------------------------
//---------------------------------------------------------------------
::grpc::Status NiFpgaService::WriteI8(::grpc::ServerContext* context, const WriteI8Request* request, WriteI8Response* response)
Expand Down
1 change: 1 addition & 0 deletions generated/nifpga/nifpga_service.h
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ class NiFpgaService final : public NiFpga::Service {
::grpc::Status WriteFxp64(::grpc::ServerContext* context, const WriteFxp64Request* request, WriteFxp64Response* response) override;
::grpc::Status WriteI16(::grpc::ServerContext* context, const WriteI16Request* request, WriteI16Response* response) override;
::grpc::Status WriteI32(::grpc::ServerContext* context, const WriteI32Request* request, WriteI32Response* response) override;
::grpc::Status WriteI64(::grpc::ServerContext* context, const WriteI64Request* request, WriteI64Response* response) override;
::grpc::Status WriteI8(::grpc::ServerContext* context, const WriteI8Request* request, WriteI8Response* response) override;
::grpc::Status WriteSgl(::grpc::ServerContext* context, const WriteSglRequest* request, WriteSglResponse* response) override;
::grpc::Status WriteU16(::grpc::ServerContext* context, const WriteU16Request* request, WriteU16Response* response) override;
Expand Down
5 changes: 2 additions & 3 deletions source/codegen/metadata/nifpga/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -2830,7 +2830,7 @@
{
'direction': 'in',
'name': 'value',
'type': 'int64'
'type': 'int64_t'
}
],
'returns': 'NiFpga_Status'
Expand Down Expand Up @@ -3922,7 +3922,6 @@
'returns': 'NiFpga_Status'
},
'WriteI64': {
'codegen_method': 'no',
'parameters': [
{
'direction': 'in',
Expand All @@ -3937,7 +3936,7 @@
{
'direction': 'in',
'name': 'value',
'type': 'int64'
'type': 'int64_t'
}
],
'returns': 'NiFpga_Status'
Expand Down

0 comments on commit 8dc9064

Please sign in to comment.