From ef779723020644203d935cd579f05fde9d272cec Mon Sep 17 00:00:00 2001 From: Rohan Doshi Date: Mon, 18 Nov 2024 17:57:27 +0530 Subject: [PATCH] work-in-progress: codegen changes for service.cpp generation with response on moniker out param --- generated/nifpga/nifpga_service.cpp | 1149 ++++++++++------- source/codegen/templates/service.cpp.mako | 7 +- source/codegen/templates/service_helpers.mako | 92 +- 3 files changed, 753 insertions(+), 495 deletions(-) diff --git a/generated/nifpga/nifpga_service.cpp b/generated/nifpga/nifpga_service.cpp index c92db4fbe..2f1ebd9b0 100644 --- a/generated/nifpga/nifpga_service.cpp +++ b/generated/nifpga/nifpga_service.cpp @@ -456,26 +456,28 @@ namespace nifpga_grpc { ::grpc::Status MonikerReadArrayBool(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData) { MonikerReadArrayBoolData* function_data = static_cast(data); - auto library = function_data->library; + auto library = function_data->library; + auto response = function_data->data.mutable_response(); auto session = function_data->session; auto indicator = function_data->indicator; auto size = function_data->size; std::vector array(size, NiFpga_Bool()); auto status = library->ReadArrayBool(session, indicator, array.data(), size); - if (status >= 0) { - std::transform( - array.begin(), - array.begin() + size, - function_data->data.mutable_value()->begin(), - [&](auto x) { - return x; - }); - packedData.PackFrom(function_data->data); - } - if (status < 0) { - std::cout << "MonikerReadArrayBool error: " << status << std::endl; + /* TODO context is unavailable to return error the proper way. Also error API is member of service class, this function is not. + ::grpc::ServerContext* context = NULL; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiFpga_Session(context, status, session); + } + response->set_status(status); + convert_to_grpc(array, response->mutable_array()); + */ + if (status >= 0) + { + response->set_status(status); + convert_to_grpc(array, response->mutable_array()); + packedData.PackFrom(function_data->data); } return ::grpc::Status::OK; } @@ -483,27 +485,26 @@ ::grpc::Status MonikerReadArrayBool(void* data, google::protobuf::Arena& arena, ::grpc::Status MonikerReadArrayDbl(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData) { MonikerReadArrayDblData* function_data = static_cast(data); - auto library = function_data->library; + auto library = function_data->library; + auto response = function_data->data.mutable_response(); auto session = function_data->session; auto indicator = function_data->indicator; auto size = function_data->size; - auto array_storage = std::vector(size); - auto array = array_storage.data(); + auto array = response->mutable_array()->mutable_data(); auto status = library->ReadArrayDbl(session, indicator, array, size); - if (status >= 0) { - std::transform( - array, - array + size, - function_data->data.mutable_value()->begin(), - [&](auto x) { - return x; - }); - packedData.PackFrom(function_data->data); - } - if (status < 0) { - std::cout << "MonikerReadArrayDbl error: " << status << std::endl; + /* TODO context is unavailable to return error the proper way. Also error API is member of service class, this function is not. + ::grpc::ServerContext* context = NULL; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiFpga_Session(context, status, session); + } + response->set_status(status); + */ + if (status >= 0) + { + response->set_status(status); + packedData.PackFrom(function_data->data); } return ::grpc::Status::OK; } @@ -511,26 +512,44 @@ ::grpc::Status MonikerReadArrayDbl(void* data, google::protobuf::Arena& arena, g ::grpc::Status MonikerReadArrayI16(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData) { MonikerReadArrayI16Data* function_data = static_cast(data); - auto library = function_data->library; + auto library = function_data->library; + auto response = function_data->data.mutable_response(); auto session = function_data->session; auto indicator = function_data->indicator; auto size = function_data->size; std::vector array(size); auto status = library->ReadArrayI16(session, indicator, array.data(), size); - if (status >= 0) { - std::transform( - array.begin(), - array.begin() + size, - function_data->data.mutable_value()->begin(), - [&](auto x) { - return x; - }); - packedData.PackFrom(function_data->data); - } - if (status < 0) { - std::cout << "MonikerReadArrayI16 error: " << status << std::endl; + /* TODO context is unavailable to return error the proper way. Also error API is member of service class, this function is not. + ::grpc::ServerContext* context = NULL; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiFpga_Session(context, status, session); + } + response->set_status(status); + response->mutable_array()->Clear(); + response->mutable_array()->Reserve(size); + std::transform( + array.begin(), + array.begin() + size, + google::protobuf::RepeatedFieldBackInserter(response->mutable_array()), + [&](auto x) { + return x; + }); + */ + if (status >= 0) + { + response->set_status(status); + response->mutable_array()->Clear(); + response->mutable_array()->Reserve(size); + std::transform( + array.begin(), + array.begin() + size, + google::protobuf::RepeatedFieldBackInserter(response->mutable_array()), + [&](auto x) { + return x; + }); + packedData.PackFrom(function_data->data); } return ::grpc::Status::OK; } @@ -538,27 +557,26 @@ ::grpc::Status MonikerReadArrayI16(void* data, google::protobuf::Arena& arena, g ::grpc::Status MonikerReadArrayI32(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData) { MonikerReadArrayI32Data* function_data = static_cast(data); - auto library = function_data->library; + auto library = function_data->library; + auto response = function_data->data.mutable_response(); auto session = function_data->session; auto indicator = function_data->indicator; auto size = function_data->size; - auto array_storage = std::vector(size); - auto array = array_storage.data(); + auto array = response->mutable_array()->mutable_data(); auto status = library->ReadArrayI32(session, indicator, array, size); - if (status >= 0) { - std::transform( - array, - array + size, - function_data->data.mutable_value()->begin(), - [&](auto x) { - return x; - }); - packedData.PackFrom(function_data->data); - } - if (status < 0) { - std::cout << "MonikerReadArrayI32 error: " << status << std::endl; + /* TODO context is unavailable to return error the proper way. Also error API is member of service class, this function is not. + ::grpc::ServerContext* context = NULL; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiFpga_Session(context, status, session); + } + response->set_status(status); + */ + if (status >= 0) + { + response->set_status(status); + packedData.PackFrom(function_data->data); } return ::grpc::Status::OK; } @@ -566,27 +584,26 @@ ::grpc::Status MonikerReadArrayI32(void* data, google::protobuf::Arena& arena, g ::grpc::Status MonikerReadArrayI64(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData) { MonikerReadArrayI64Data* function_data = static_cast(data); - auto library = function_data->library; + auto library = function_data->library; + auto response = function_data->data.mutable_response(); auto session = function_data->session; auto indicator = function_data->indicator; auto size = function_data->size; - auto array_storage = std::vector(size); - auto array = array_storage.data(); + auto array = response->mutable_array()->mutable_data(); auto status = library->ReadArrayI64(session, indicator, array, size); - if (status >= 0) { - std::transform( - array, - array + size, - function_data->data.mutable_value()->begin(), - [&](auto x) { - return x; - }); - packedData.PackFrom(function_data->data); - } - if (status < 0) { - std::cout << "MonikerReadArrayI64 error: " << status << std::endl; + /* TODO context is unavailable to return error the proper way. Also error API is member of service class, this function is not. + ::grpc::ServerContext* context = NULL; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiFpga_Session(context, status, session); + } + response->set_status(status); + */ + if (status >= 0) + { + response->set_status(status); + packedData.PackFrom(function_data->data); } return ::grpc::Status::OK; } @@ -594,26 +611,44 @@ ::grpc::Status MonikerReadArrayI64(void* data, google::protobuf::Arena& arena, g ::grpc::Status MonikerReadArrayI8(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData) { MonikerReadArrayI8Data* function_data = static_cast(data); - auto library = function_data->library; + auto library = function_data->library; + auto response = function_data->data.mutable_response(); auto session = function_data->session; auto indicator = function_data->indicator; auto size = function_data->size; std::vector array(size); auto status = library->ReadArrayI8(session, indicator, array.data(), size); - if (status >= 0) { - std::transform( - array.begin(), - array.begin() + size, - function_data->data.mutable_value()->begin(), - [&](auto x) { - return x; - }); - packedData.PackFrom(function_data->data); - } - if (status < 0) { - std::cout << "MonikerReadArrayI8 error: " << status << std::endl; + /* TODO context is unavailable to return error the proper way. Also error API is member of service class, this function is not. + ::grpc::ServerContext* context = NULL; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiFpga_Session(context, status, session); + } + response->set_status(status); + response->mutable_array()->Clear(); + response->mutable_array()->Reserve(size); + std::transform( + array.begin(), + array.begin() + size, + google::protobuf::RepeatedFieldBackInserter(response->mutable_array()), + [&](auto x) { + return x; + }); + */ + if (status >= 0) + { + response->set_status(status); + response->mutable_array()->Clear(); + response->mutable_array()->Reserve(size); + std::transform( + array.begin(), + array.begin() + size, + google::protobuf::RepeatedFieldBackInserter(response->mutable_array()), + [&](auto x) { + return x; + }); + packedData.PackFrom(function_data->data); } return ::grpc::Status::OK; } @@ -621,27 +656,26 @@ ::grpc::Status MonikerReadArrayI8(void* data, google::protobuf::Arena& arena, go ::grpc::Status MonikerReadArraySgl(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData) { MonikerReadArraySglData* function_data = static_cast(data); - auto library = function_data->library; + auto library = function_data->library; + auto response = function_data->data.mutable_response(); auto session = function_data->session; auto indicator = function_data->indicator; auto size = function_data->size; - auto array_storage = std::vector(size); - auto array = array_storage.data(); + auto array = response->mutable_array()->mutable_data(); auto status = library->ReadArraySgl(session, indicator, array, size); - if (status >= 0) { - std::transform( - array, - array + size, - function_data->data.mutable_value()->begin(), - [&](auto x) { - return x; - }); - packedData.PackFrom(function_data->data); - } - if (status < 0) { - std::cout << "MonikerReadArraySgl error: " << status << std::endl; + /* TODO context is unavailable to return error the proper way. Also error API is member of service class, this function is not. + ::grpc::ServerContext* context = NULL; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiFpga_Session(context, status, session); + } + response->set_status(status); + */ + if (status >= 0) + { + response->set_status(status); + packedData.PackFrom(function_data->data); } return ::grpc::Status::OK; } @@ -649,26 +683,44 @@ ::grpc::Status MonikerReadArraySgl(void* data, google::protobuf::Arena& arena, g ::grpc::Status MonikerReadArrayU16(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData) { MonikerReadArrayU16Data* function_data = static_cast(data); - auto library = function_data->library; + auto library = function_data->library; + auto response = function_data->data.mutable_response(); auto session = function_data->session; auto indicator = function_data->indicator; auto size = function_data->size; std::vector array(size); auto status = library->ReadArrayU16(session, indicator, array.data(), size); - if (status >= 0) { - std::transform( - array.begin(), - array.begin() + size, - function_data->data.mutable_value()->begin(), - [&](auto x) { - return x; - }); - packedData.PackFrom(function_data->data); - } - if (status < 0) { - std::cout << "MonikerReadArrayU16 error: " << status << std::endl; + /* TODO context is unavailable to return error the proper way. Also error API is member of service class, this function is not. + ::grpc::ServerContext* context = NULL; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiFpga_Session(context, status, session); + } + response->set_status(status); + response->mutable_array()->Clear(); + response->mutable_array()->Reserve(size); + std::transform( + array.begin(), + array.begin() + size, + google::protobuf::RepeatedFieldBackInserter(response->mutable_array()), + [&](auto x) { + return x; + }); + */ + if (status >= 0) + { + response->set_status(status); + response->mutable_array()->Clear(); + response->mutable_array()->Reserve(size); + std::transform( + array.begin(), + array.begin() + size, + google::protobuf::RepeatedFieldBackInserter(response->mutable_array()), + [&](auto x) { + return x; + }); + packedData.PackFrom(function_data->data); } return ::grpc::Status::OK; } @@ -676,27 +728,26 @@ ::grpc::Status MonikerReadArrayU16(void* data, google::protobuf::Arena& arena, g ::grpc::Status MonikerReadArrayU32(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData) { MonikerReadArrayU32Data* function_data = static_cast(data); - auto library = function_data->library; + auto library = function_data->library; + auto response = function_data->data.mutable_response(); auto session = function_data->session; auto indicator = function_data->indicator; auto size = function_data->size; - auto array_storage = std::vector(size); - auto array = array_storage.data(); + auto array = response->mutable_array()->mutable_data(); auto status = library->ReadArrayU32(session, indicator, array, size); - if (status >= 0) { - std::transform( - array, - array + size, - function_data->data.mutable_value()->begin(), - [&](auto x) { - return x; - }); - packedData.PackFrom(function_data->data); - } - if (status < 0) { - std::cout << "MonikerReadArrayU32 error: " << status << std::endl; + /* TODO context is unavailable to return error the proper way. Also error API is member of service class, this function is not. + ::grpc::ServerContext* context = NULL; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiFpga_Session(context, status, session); + } + response->set_status(status); + */ + if (status >= 0) + { + response->set_status(status); + packedData.PackFrom(function_data->data); } return ::grpc::Status::OK; } @@ -704,27 +755,26 @@ ::grpc::Status MonikerReadArrayU32(void* data, google::protobuf::Arena& arena, g ::grpc::Status MonikerReadArrayU64(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData) { MonikerReadArrayU64Data* function_data = static_cast(data); - auto library = function_data->library; + auto library = function_data->library; + auto response = function_data->data.mutable_response(); auto session = function_data->session; auto indicator = function_data->indicator; auto size = function_data->size; - auto array_storage = std::vector(size); - auto array = array_storage.data(); + auto array = response->mutable_array()->mutable_data(); auto status = library->ReadArrayU64(session, indicator, array, size); - if (status >= 0) { - std::transform( - array, - array + size, - function_data->data.mutable_value()->begin(), - [&](auto x) { - return x; - }); - packedData.PackFrom(function_data->data); - } - if (status < 0) { - std::cout << "MonikerReadArrayU64 error: " << status << std::endl; + /* TODO context is unavailable to return error the proper way. Also error API is member of service class, this function is not. + ::grpc::ServerContext* context = NULL; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiFpga_Session(context, status, session); + } + response->set_status(status); + */ + if (status >= 0) + { + response->set_status(status); + packedData.PackFrom(function_data->data); } return ::grpc::Status::OK; } @@ -732,26 +782,44 @@ ::grpc::Status MonikerReadArrayU64(void* data, google::protobuf::Arena& arena, g ::grpc::Status MonikerReadArrayU8(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData) { MonikerReadArrayU8Data* function_data = static_cast(data); - auto library = function_data->library; + auto library = function_data->library; + auto response = function_data->data.mutable_response(); auto session = function_data->session; auto indicator = function_data->indicator; auto size = function_data->size; std::vector array(size); auto status = library->ReadArrayU8(session, indicator, array.data(), size); - if (status >= 0) { - std::transform( - array.begin(), - array.begin() + size, - function_data->data.mutable_value()->begin(), - [&](auto x) { - return x; - }); - packedData.PackFrom(function_data->data); - } - if (status < 0) { - std::cout << "MonikerReadArrayU8 error: " << status << std::endl; + /* TODO context is unavailable to return error the proper way. Also error API is member of service class, this function is not. + ::grpc::ServerContext* context = NULL; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiFpga_Session(context, status, session); + } + response->set_status(status); + response->mutable_array()->Clear(); + response->mutable_array()->Reserve(size); + std::transform( + array.begin(), + array.begin() + size, + google::protobuf::RepeatedFieldBackInserter(response->mutable_array()), + [&](auto x) { + return x; + }); + */ + if (status >= 0) + { + response->set_status(status); + response->mutable_array()->Clear(); + response->mutable_array()->Reserve(size); + std::transform( + array.begin(), + array.begin() + size, + google::protobuf::RepeatedFieldBackInserter(response->mutable_array()), + [&](auto x) { + return x; + }); + packedData.PackFrom(function_data->data); } return ::grpc::Status::OK; } @@ -759,19 +827,27 @@ ::grpc::Status MonikerReadArrayU8(void* data, google::protobuf::Arena& arena, go ::grpc::Status MonikerReadBool(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData) { MonikerReadBoolData* function_data = static_cast(data); - auto library = function_data->library; + auto library = function_data->library; + auto response = function_data->data.mutable_response(); auto session = function_data->session; auto indicator = function_data->indicator; - NiFpga_Bool value {}; +NiFpga_Bool value {}; auto status = library->ReadBool(session, indicator, &value); - function_data->data.set_value(value); - if (status >= 0) { - packedData.PackFrom(function_data->data); - } - if (status < 0) { - std::cout << "MonikerReadBool error: " << status << std::endl; + /* TODO context is unavailable to return error the proper way. Also error API is member of service class, this function is not. + ::grpc::ServerContext* context = NULL; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiFpga_Session(context, status, session); + } + response->set_status(status); + response->set_value(value); + */ + if (status >= 0) + { + response->set_status(status); + response->set_value(value); + packedData.PackFrom(function_data->data); } return ::grpc::Status::OK; } @@ -779,19 +855,27 @@ ::grpc::Status MonikerReadBool(void* data, google::protobuf::Arena& arena, googl ::grpc::Status MonikerReadDbl(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData) { MonikerReadDblData* function_data = static_cast(data); - auto library = function_data->library; + auto library = function_data->library; + auto response = function_data->data.mutable_response(); auto session = function_data->session; auto indicator = function_data->indicator; - double value {}; +double value {}; auto status = library->ReadDbl(session, indicator, &value); - function_data->data.set_value(value); - if (status >= 0) { - packedData.PackFrom(function_data->data); - } - if (status < 0) { - std::cout << "MonikerReadDbl error: " << status << std::endl; + /* TODO context is unavailable to return error the proper way. Also error API is member of service class, this function is not. + ::grpc::ServerContext* context = NULL; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiFpga_Session(context, status, session); + } + response->set_status(status); + response->set_value(value); + */ + if (status >= 0) + { + response->set_status(status); + response->set_value(value); + packedData.PackFrom(function_data->data); } return ::grpc::Status::OK; } @@ -799,19 +883,27 @@ ::grpc::Status MonikerReadDbl(void* data, google::protobuf::Arena& arena, google ::grpc::Status MonikerReadI16(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData) { MonikerReadI16Data* function_data = static_cast(data); - auto library = function_data->library; + auto library = function_data->library; + auto response = function_data->data.mutable_response(); auto session = function_data->session; auto indicator = function_data->indicator; - int16_t value {}; +int16_t value {}; auto status = library->ReadI16(session, indicator, &value); - function_data->data.set_value(value); - if (status >= 0) { - packedData.PackFrom(function_data->data); - } - if (status < 0) { - std::cout << "MonikerReadI16 error: " << status << std::endl; + /* TODO context is unavailable to return error the proper way. Also error API is member of service class, this function is not. + ::grpc::ServerContext* context = NULL; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiFpga_Session(context, status, session); + } + response->set_status(status); + response->set_value(value); + */ + if (status >= 0) + { + response->set_status(status); + response->set_value(value); + packedData.PackFrom(function_data->data); } return ::grpc::Status::OK; } @@ -819,19 +911,27 @@ ::grpc::Status MonikerReadI16(void* data, google::protobuf::Arena& arena, google ::grpc::Status MonikerReadI32(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData) { MonikerReadI32Data* function_data = static_cast(data); - auto library = function_data->library; + auto library = function_data->library; + auto response = function_data->data.mutable_response(); auto session = function_data->session; auto indicator = function_data->indicator; - int32_t value {}; +int32_t value {}; auto status = library->ReadI32(session, indicator, &value); - function_data->data.set_value(value); - if (status >= 0) { - packedData.PackFrom(function_data->data); - } - if (status < 0) { - std::cout << "MonikerReadI32 error: " << status << std::endl; + /* TODO context is unavailable to return error the proper way. Also error API is member of service class, this function is not. + ::grpc::ServerContext* context = NULL; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiFpga_Session(context, status, session); + } + response->set_status(status); + response->set_value(value); + */ + if (status >= 0) + { + response->set_status(status); + response->set_value(value); + packedData.PackFrom(function_data->data); } return ::grpc::Status::OK; } @@ -839,19 +939,27 @@ ::grpc::Status MonikerReadI32(void* data, google::protobuf::Arena& arena, google ::grpc::Status MonikerReadI64(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData) { MonikerReadI64Data* function_data = static_cast(data); - auto library = function_data->library; + auto library = function_data->library; + auto response = function_data->data.mutable_response(); auto session = function_data->session; auto indicator = function_data->indicator; - int64_t value {}; +int64_t value {}; auto status = library->ReadI64(session, indicator, &value); - function_data->data.set_value(value); - if (status >= 0) { - packedData.PackFrom(function_data->data); - } - if (status < 0) { - std::cout << "MonikerReadI64 error: " << status << std::endl; + /* TODO context is unavailable to return error the proper way. Also error API is member of service class, this function is not. + ::grpc::ServerContext* context = NULL; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiFpga_Session(context, status, session); + } + response->set_status(status); + response->set_value(value); + */ + if (status >= 0) + { + response->set_status(status); + response->set_value(value); + packedData.PackFrom(function_data->data); } return ::grpc::Status::OK; } @@ -859,19 +967,27 @@ ::grpc::Status MonikerReadI64(void* data, google::protobuf::Arena& arena, google ::grpc::Status MonikerReadI8(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData) { MonikerReadI8Data* function_data = static_cast(data); - auto library = function_data->library; + auto library = function_data->library; + auto response = function_data->data.mutable_response(); auto session = function_data->session; auto indicator = function_data->indicator; - int8_t value {}; +int8_t value {}; auto status = library->ReadI8(session, indicator, &value); - function_data->data.set_value(value); - if (status >= 0) { - packedData.PackFrom(function_data->data); - } - if (status < 0) { - std::cout << "MonikerReadI8 error: " << status << std::endl; + /* TODO context is unavailable to return error the proper way. Also error API is member of service class, this function is not. + ::grpc::ServerContext* context = NULL; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiFpga_Session(context, status, session); + } + response->set_status(status); + response->set_value(value); + */ + if (status >= 0) + { + response->set_status(status); + response->set_value(value); + packedData.PackFrom(function_data->data); } return ::grpc::Status::OK; } @@ -879,19 +995,27 @@ ::grpc::Status MonikerReadI8(void* data, google::protobuf::Arena& arena, google: ::grpc::Status MonikerReadSgl(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData) { MonikerReadSglData* function_data = static_cast(data); - auto library = function_data->library; + auto library = function_data->library; + auto response = function_data->data.mutable_response(); auto session = function_data->session; auto indicator = function_data->indicator; - float value {}; +float value {}; auto status = library->ReadSgl(session, indicator, &value); - function_data->data.set_value(value); - if (status >= 0) { - packedData.PackFrom(function_data->data); - } - if (status < 0) { - std::cout << "MonikerReadSgl error: " << status << std::endl; + /* TODO context is unavailable to return error the proper way. Also error API is member of service class, this function is not. + ::grpc::ServerContext* context = NULL; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiFpga_Session(context, status, session); + } + response->set_status(status); + response->set_value(value); + */ + if (status >= 0) + { + response->set_status(status); + response->set_value(value); + packedData.PackFrom(function_data->data); } return ::grpc::Status::OK; } @@ -899,19 +1023,27 @@ ::grpc::Status MonikerReadSgl(void* data, google::protobuf::Arena& arena, google ::grpc::Status MonikerReadU16(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData) { MonikerReadU16Data* function_data = static_cast(data); - auto library = function_data->library; + auto library = function_data->library; + auto response = function_data->data.mutable_response(); auto session = function_data->session; auto indicator = function_data->indicator; - uint16_t value {}; +uint16_t value {}; auto status = library->ReadU16(session, indicator, &value); - function_data->data.set_value(value); - if (status >= 0) { - packedData.PackFrom(function_data->data); - } - if (status < 0) { - std::cout << "MonikerReadU16 error: " << status << std::endl; + /* TODO context is unavailable to return error the proper way. Also error API is member of service class, this function is not. + ::grpc::ServerContext* context = NULL; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiFpga_Session(context, status, session); + } + response->set_status(status); + response->set_value(value); + */ + if (status >= 0) + { + response->set_status(status); + response->set_value(value); + packedData.PackFrom(function_data->data); } return ::grpc::Status::OK; } @@ -919,19 +1051,27 @@ ::grpc::Status MonikerReadU16(void* data, google::protobuf::Arena& arena, google ::grpc::Status MonikerReadU32(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData) { MonikerReadU32Data* function_data = static_cast(data); - auto library = function_data->library; + auto library = function_data->library; + auto response = function_data->data.mutable_response(); auto session = function_data->session; auto indicator = function_data->indicator; - uint32_t value {}; +uint32_t value {}; auto status = library->ReadU32(session, indicator, &value); - function_data->data.set_value(value); - if (status >= 0) { - packedData.PackFrom(function_data->data); - } - if (status < 0) { - std::cout << "MonikerReadU32 error: " << status << std::endl; + /* TODO context is unavailable to return error the proper way. Also error API is member of service class, this function is not. + ::grpc::ServerContext* context = NULL; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiFpga_Session(context, status, session); + } + response->set_status(status); + response->set_value(value); + */ + if (status >= 0) + { + response->set_status(status); + response->set_value(value); + packedData.PackFrom(function_data->data); } return ::grpc::Status::OK; } @@ -939,19 +1079,27 @@ ::grpc::Status MonikerReadU32(void* data, google::protobuf::Arena& arena, google ::grpc::Status MonikerReadU64(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData) { MonikerReadU64Data* function_data = static_cast(data); - auto library = function_data->library; + auto library = function_data->library; + auto response = function_data->data.mutable_response(); auto session = function_data->session; auto indicator = function_data->indicator; - uint64_t value {}; +uint64_t value {}; auto status = library->ReadU64(session, indicator, &value); - function_data->data.set_value(value); - if (status >= 0) { - packedData.PackFrom(function_data->data); - } - if (status < 0) { - std::cout << "MonikerReadU64 error: " << status << std::endl; + /* TODO context is unavailable to return error the proper way. Also error API is member of service class, this function is not. + ::grpc::ServerContext* context = NULL; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiFpga_Session(context, status, session); + } + response->set_status(status); + response->set_value(value); + */ + if (status >= 0) + { + response->set_status(status); + response->set_value(value); + packedData.PackFrom(function_data->data); } return ::grpc::Status::OK; } @@ -959,19 +1107,27 @@ ::grpc::Status MonikerReadU64(void* data, google::protobuf::Arena& arena, google ::grpc::Status MonikerReadU8(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData) { MonikerReadU8Data* function_data = static_cast(data); - auto library = function_data->library; + auto library = function_data->library; + auto response = function_data->data.mutable_response(); auto session = function_data->session; auto indicator = function_data->indicator; - uint8_t value {}; +uint8_t value {}; auto status = library->ReadU8(session, indicator, &value); - function_data->data.set_value(value); - if (status >= 0) { - packedData.PackFrom(function_data->data); - } - if (status < 0) { - std::cout << "MonikerReadU8 error: " << status << std::endl; + /* TODO context is unavailable to return error the proper way. Also error API is member of service class, this function is not. + ::grpc::ServerContext* context = NULL; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiFpga_Session(context, status, session); + } + response->set_status(status); + response->set_value(value); + */ + if (status >= 0) + { + response->set_status(status); + response->set_value(value); + packedData.PackFrom(function_data->data); } return ::grpc::Status::OK; } @@ -979,7 +1135,8 @@ ::grpc::Status MonikerReadU8(void* data, google::protobuf::Arena& arena, google: ::grpc::Status MonikerWriteArrayBool(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData) { MonikerWriteArrayBoolData* function_data = static_cast(data); - auto library = function_data->library; + auto library = function_data->library; + auto response = function_data->data.mutable_response(); auto session = function_data->session; auto control = function_data->control; @@ -991,16 +1148,21 @@ ::grpc::Status MonikerWriteArrayBool(void* data, google::protobuf::Arena& arena, auto size = data_array.size(); auto status = library->WriteArrayBool(session, control, array.data(), size); - if (status < 0) { - std::cout << "MonikerWriteArrayBool error: " << status << std::endl; - } + /* TODO context is unavailable to return error the proper way. Also error API is member of service class, this function is not. + ::grpc::ServerContext* context = NULL; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiFpga_Session(context, status, session); + } + response->set_status(status); + */ return ::grpc::Status::OK; } ::grpc::Status MonikerWriteArrayDbl(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData) { MonikerWriteArrayDblData* function_data = static_cast(data); - auto library = function_data->library; + auto library = function_data->library; + auto response = function_data->data.mutable_response(); auto session = function_data->session; auto control = function_data->control; @@ -1012,16 +1174,21 @@ ::grpc::Status MonikerWriteArrayDbl(void* data, google::protobuf::Arena& arena, auto size = data_array.size(); auto status = library->WriteArrayDbl(session, control, array, size); - if (status < 0) { - std::cout << "MonikerWriteArrayDbl error: " << status << std::endl; - } + /* TODO context is unavailable to return error the proper way. Also error API is member of service class, this function is not. + ::grpc::ServerContext* context = NULL; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiFpga_Session(context, status, session); + } + response->set_status(status); + */ return ::grpc::Status::OK; } ::grpc::Status MonikerWriteArrayI16(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData) { MonikerWriteArrayI16Data* function_data = static_cast(data); - auto library = function_data->library; + auto library = function_data->library; + auto response = function_data->data.mutable_response(); auto session = function_data->session; auto control = function_data->control; @@ -1045,16 +1212,21 @@ ::grpc::Status MonikerWriteArrayI16(void* data, google::protobuf::Arena& arena, }); auto status = library->WriteArrayI16(session, control, array.data(), size); - if (status < 0) { - std::cout << "MonikerWriteArrayI16 error: " << status << std::endl; - } + /* TODO context is unavailable to return error the proper way. Also error API is member of service class, this function is not. + ::grpc::ServerContext* context = NULL; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiFpga_Session(context, status, session); + } + response->set_status(status); + */ return ::grpc::Status::OK; } ::grpc::Status MonikerWriteArrayI32(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData) { MonikerWriteArrayI32Data* function_data = static_cast(data); - auto library = function_data->library; + auto library = function_data->library; + auto response = function_data->data.mutable_response(); auto session = function_data->session; auto control = function_data->control; @@ -1066,16 +1238,21 @@ ::grpc::Status MonikerWriteArrayI32(void* data, google::protobuf::Arena& arena, auto size = data_array.size(); auto status = library->WriteArrayI32(session, control, array, size); - if (status < 0) { - std::cout << "MonikerWriteArrayI32 error: " << status << std::endl; - } + /* TODO context is unavailable to return error the proper way. Also error API is member of service class, this function is not. + ::grpc::ServerContext* context = NULL; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiFpga_Session(context, status, session); + } + response->set_status(status); + */ return ::grpc::Status::OK; } ::grpc::Status MonikerWriteArrayI64(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData) { MonikerWriteArrayI64Data* function_data = static_cast(data); - auto library = function_data->library; + auto library = function_data->library; + auto response = function_data->data.mutable_response(); auto session = function_data->session; auto control = function_data->control; @@ -1087,16 +1264,21 @@ ::grpc::Status MonikerWriteArrayI64(void* data, google::protobuf::Arena& arena, auto size = data_array.size(); auto status = library->WriteArrayI64(session, control, array, size); - if (status < 0) { - std::cout << "MonikerWriteArrayI64 error: " << status << std::endl; - } + /* TODO context is unavailable to return error the proper way. Also error API is member of service class, this function is not. + ::grpc::ServerContext* context = NULL; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiFpga_Session(context, status, session); + } + response->set_status(status); + */ return ::grpc::Status::OK; } ::grpc::Status MonikerWriteArrayI8(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData) { MonikerWriteArrayI8Data* function_data = static_cast(data); - auto library = function_data->library; + auto library = function_data->library; + auto response = function_data->data.mutable_response(); auto session = function_data->session; auto control = function_data->control; @@ -1120,16 +1302,21 @@ ::grpc::Status MonikerWriteArrayI8(void* data, google::protobuf::Arena& arena, g }); auto status = library->WriteArrayI8(session, control, array.data(), size); - if (status < 0) { - std::cout << "MonikerWriteArrayI8 error: " << status << std::endl; - } + /* TODO context is unavailable to return error the proper way. Also error API is member of service class, this function is not. + ::grpc::ServerContext* context = NULL; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiFpga_Session(context, status, session); + } + response->set_status(status); + */ return ::grpc::Status::OK; } ::grpc::Status MonikerWriteArraySgl(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData) { MonikerWriteArraySglData* function_data = static_cast(data); - auto library = function_data->library; + auto library = function_data->library; + auto response = function_data->data.mutable_response(); auto session = function_data->session; auto control = function_data->control; @@ -1141,16 +1328,21 @@ ::grpc::Status MonikerWriteArraySgl(void* data, google::protobuf::Arena& arena, auto size = data_array.size(); auto status = library->WriteArraySgl(session, control, array, size); - if (status < 0) { - std::cout << "MonikerWriteArraySgl error: " << status << std::endl; - } + /* TODO context is unavailable to return error the proper way. Also error API is member of service class, this function is not. + ::grpc::ServerContext* context = NULL; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiFpga_Session(context, status, session); + } + response->set_status(status); + */ return ::grpc::Status::OK; } ::grpc::Status MonikerWriteArrayU16(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData) { MonikerWriteArrayU16Data* function_data = static_cast(data); - auto library = function_data->library; + auto library = function_data->library; + auto response = function_data->data.mutable_response(); auto session = function_data->session; auto control = function_data->control; @@ -1174,16 +1366,21 @@ ::grpc::Status MonikerWriteArrayU16(void* data, google::protobuf::Arena& arena, }); auto status = library->WriteArrayU16(session, control, array.data(), size); - if (status < 0) { - std::cout << "MonikerWriteArrayU16 error: " << status << std::endl; - } + /* TODO context is unavailable to return error the proper way. Also error API is member of service class, this function is not. + ::grpc::ServerContext* context = NULL; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiFpga_Session(context, status, session); + } + response->set_status(status); + */ return ::grpc::Status::OK; } ::grpc::Status MonikerWriteArrayU32(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData) { MonikerWriteArrayU32Data* function_data = static_cast(data); - auto library = function_data->library; + auto library = function_data->library; + auto response = function_data->data.mutable_response(); auto session = function_data->session; auto control = function_data->control; @@ -1195,16 +1392,21 @@ ::grpc::Status MonikerWriteArrayU32(void* data, google::protobuf::Arena& arena, auto size = data_array.size(); auto status = library->WriteArrayU32(session, control, array, size); - if (status < 0) { - std::cout << "MonikerWriteArrayU32 error: " << status << std::endl; - } + /* TODO context is unavailable to return error the proper way. Also error API is member of service class, this function is not. + ::grpc::ServerContext* context = NULL; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiFpga_Session(context, status, session); + } + response->set_status(status); + */ return ::grpc::Status::OK; } ::grpc::Status MonikerWriteArrayU64(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData) { MonikerWriteArrayU64Data* function_data = static_cast(data); - auto library = function_data->library; + auto library = function_data->library; + auto response = function_data->data.mutable_response(); auto session = function_data->session; auto control = function_data->control; @@ -1216,16 +1418,21 @@ ::grpc::Status MonikerWriteArrayU64(void* data, google::protobuf::Arena& arena, auto size = data_array.size(); auto status = library->WriteArrayU64(session, control, array, size); - if (status < 0) { - std::cout << "MonikerWriteArrayU64 error: " << status << std::endl; - } + /* TODO context is unavailable to return error the proper way. Also error API is member of service class, this function is not. + ::grpc::ServerContext* context = NULL; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiFpga_Session(context, status, session); + } + response->set_status(status); + */ return ::grpc::Status::OK; } ::grpc::Status MonikerWriteArrayU8(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData) { MonikerWriteArrayU8Data* function_data = static_cast(data); - auto library = function_data->library; + auto library = function_data->library; + auto response = function_data->data.mutable_response(); auto session = function_data->session; auto control = function_data->control; @@ -1249,16 +1456,21 @@ ::grpc::Status MonikerWriteArrayU8(void* data, google::protobuf::Arena& arena, g }); auto status = library->WriteArrayU8(session, control, array.data(), size); - if (status < 0) { - std::cout << "MonikerWriteArrayU8 error: " << status << std::endl; - } + /* TODO context is unavailable to return error the proper way. Also error API is member of service class, this function is not. + ::grpc::ServerContext* context = NULL; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiFpga_Session(context, status, session); + } + response->set_status(status); + */ return ::grpc::Status::OK; } ::grpc::Status MonikerWriteBool(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData) { MonikerWriteBoolData* function_data = static_cast(data); - auto library = function_data->library; + auto library = function_data->library; + auto response = function_data->data.mutable_response(); auto session = function_data->session; auto control = function_data->control; @@ -1267,16 +1479,21 @@ ::grpc::Status MonikerWriteBool(void* data, google::protobuf::Arena& arena, goog auto value = booldata_message.value(); auto status = library->WriteBool(session, control, value); - if (status < 0) { - std::cout << "MonikerWriteBool error: " << status << std::endl; - } + /* TODO context is unavailable to return error the proper way. Also error API is member of service class, this function is not. + ::grpc::ServerContext* context = NULL; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiFpga_Session(context, status, session); + } + response->set_status(status); + */ return ::grpc::Status::OK; } ::grpc::Status MonikerWriteDbl(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData) { MonikerWriteDblData* function_data = static_cast(data); - auto library = function_data->library; + auto library = function_data->library; + auto response = function_data->data.mutable_response(); auto session = function_data->session; auto control = function_data->control; @@ -1285,16 +1502,21 @@ ::grpc::Status MonikerWriteDbl(void* data, google::protobuf::Arena& arena, googl auto value = doubledata_message.value(); auto status = library->WriteDbl(session, control, value); - if (status < 0) { - std::cout << "MonikerWriteDbl error: " << status << std::endl; - } + /* TODO context is unavailable to return error the proper way. Also error API is member of service class, this function is not. + ::grpc::ServerContext* context = NULL; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiFpga_Session(context, status, session); + } + response->set_status(status); + */ return ::grpc::Status::OK; } ::grpc::Status MonikerWriteI16(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData) { MonikerWriteI16Data* function_data = static_cast(data); - auto library = function_data->library; + auto library = function_data->library; + auto response = function_data->data.mutable_response(); auto session = function_data->session; auto control = function_data->control; @@ -1307,16 +1529,21 @@ ::grpc::Status MonikerWriteI16(void* data, google::protobuf::Arena& arena, googl } auto status = library->WriteI16(session, control, value); - if (status < 0) { - std::cout << "MonikerWriteI16 error: " << status << std::endl; - } + /* TODO context is unavailable to return error the proper way. Also error API is member of service class, this function is not. + ::grpc::ServerContext* context = NULL; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiFpga_Session(context, status, session); + } + response->set_status(status); + */ return ::grpc::Status::OK; } ::grpc::Status MonikerWriteI32(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData) { MonikerWriteI32Data* function_data = static_cast(data); - auto library = function_data->library; + auto library = function_data->library; + auto response = function_data->data.mutable_response(); auto session = function_data->session; auto control = function_data->control; @@ -1325,16 +1552,21 @@ ::grpc::Status MonikerWriteI32(void* data, google::protobuf::Arena& arena, googl auto value = i32data_message.value(); auto status = library->WriteI32(session, control, value); - if (status < 0) { - std::cout << "MonikerWriteI32 error: " << status << std::endl; - } + /* TODO context is unavailable to return error the proper way. Also error API is member of service class, this function is not. + ::grpc::ServerContext* context = NULL; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiFpga_Session(context, status, session); + } + response->set_status(status); + */ return ::grpc::Status::OK; } ::grpc::Status MonikerWriteI64(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData) { MonikerWriteI64Data* function_data = static_cast(data); - auto library = function_data->library; + auto library = function_data->library; + auto response = function_data->data.mutable_response(); auto session = function_data->session; auto control = function_data->control; @@ -1343,16 +1575,21 @@ ::grpc::Status MonikerWriteI64(void* data, google::protobuf::Arena& arena, googl auto value = i64data_message.value(); auto status = library->WriteI64(session, control, value); - if (status < 0) { - std::cout << "MonikerWriteI64 error: " << status << std::endl; - } + /* TODO context is unavailable to return error the proper way. Also error API is member of service class, this function is not. + ::grpc::ServerContext* context = NULL; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiFpga_Session(context, status, session); + } + response->set_status(status); + */ return ::grpc::Status::OK; } ::grpc::Status MonikerWriteI8(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData) { MonikerWriteI8Data* function_data = static_cast(data); - auto library = function_data->library; + auto library = function_data->library; + auto response = function_data->data.mutable_response(); auto session = function_data->session; auto control = function_data->control; @@ -1365,16 +1602,21 @@ ::grpc::Status MonikerWriteI8(void* data, google::protobuf::Arena& arena, google } auto status = library->WriteI8(session, control, value); - if (status < 0) { - std::cout << "MonikerWriteI8 error: " << status << std::endl; - } + /* TODO context is unavailable to return error the proper way. Also error API is member of service class, this function is not. + ::grpc::ServerContext* context = NULL; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiFpga_Session(context, status, session); + } + response->set_status(status); + */ return ::grpc::Status::OK; } ::grpc::Status MonikerWriteSgl(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData) { MonikerWriteSglData* function_data = static_cast(data); - auto library = function_data->library; + auto library = function_data->library; + auto response = function_data->data.mutable_response(); auto session = function_data->session; auto control = function_data->control; @@ -1383,16 +1625,21 @@ ::grpc::Status MonikerWriteSgl(void* data, google::protobuf::Arena& arena, googl auto value = floatdata_message.value(); auto status = library->WriteSgl(session, control, value); - if (status < 0) { - std::cout << "MonikerWriteSgl error: " << status << std::endl; - } + /* TODO context is unavailable to return error the proper way. Also error API is member of service class, this function is not. + ::grpc::ServerContext* context = NULL; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiFpga_Session(context, status, session); + } + response->set_status(status); + */ return ::grpc::Status::OK; } ::grpc::Status MonikerWriteU16(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData) { MonikerWriteU16Data* function_data = static_cast(data); - auto library = function_data->library; + auto library = function_data->library; + auto response = function_data->data.mutable_response(); auto session = function_data->session; auto control = function_data->control; @@ -1405,16 +1652,21 @@ ::grpc::Status MonikerWriteU16(void* data, google::protobuf::Arena& arena, googl } auto status = library->WriteU16(session, control, value); - if (status < 0) { - std::cout << "MonikerWriteU16 error: " << status << std::endl; - } + /* TODO context is unavailable to return error the proper way. Also error API is member of service class, this function is not. + ::grpc::ServerContext* context = NULL; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiFpga_Session(context, status, session); + } + response->set_status(status); + */ return ::grpc::Status::OK; } ::grpc::Status MonikerWriteU32(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData) { MonikerWriteU32Data* function_data = static_cast(data); - auto library = function_data->library; + auto library = function_data->library; + auto response = function_data->data.mutable_response(); auto session = function_data->session; auto control = function_data->control; @@ -1423,16 +1675,21 @@ ::grpc::Status MonikerWriteU32(void* data, google::protobuf::Arena& arena, googl auto value = u32data_message.value(); auto status = library->WriteU32(session, control, value); - if (status < 0) { - std::cout << "MonikerWriteU32 error: " << status << std::endl; - } + /* TODO context is unavailable to return error the proper way. Also error API is member of service class, this function is not. + ::grpc::ServerContext* context = NULL; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiFpga_Session(context, status, session); + } + response->set_status(status); + */ return ::grpc::Status::OK; } ::grpc::Status MonikerWriteU64(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData) { MonikerWriteU64Data* function_data = static_cast(data); - auto library = function_data->library; + auto library = function_data->library; + auto response = function_data->data.mutable_response(); auto session = function_data->session; auto control = function_data->control; @@ -1441,16 +1698,21 @@ ::grpc::Status MonikerWriteU64(void* data, google::protobuf::Arena& arena, googl auto value = u64data_message.value(); auto status = library->WriteU64(session, control, value); - if (status < 0) { - std::cout << "MonikerWriteU64 error: " << status << std::endl; - } + /* TODO context is unavailable to return error the proper way. Also error API is member of service class, this function is not. + ::grpc::ServerContext* context = NULL; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiFpga_Session(context, status, session); + } + response->set_status(status); + */ return ::grpc::Status::OK; } ::grpc::Status MonikerWriteU8(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData) { MonikerWriteU8Data* function_data = static_cast(data); - auto library = function_data->library; + auto library = function_data->library; + auto response = function_data->data.mutable_response(); auto session = function_data->session; auto control = function_data->control; @@ -1463,11 +1725,16 @@ ::grpc::Status MonikerWriteU8(void* data, google::protobuf::Arena& arena, google } auto status = library->WriteU8(session, control, value); - if (status < 0) { - std::cout << "MonikerWriteU8 error: " << status << std::endl; - } + /* TODO context is unavailable to return error the proper way. Also error API is member of service class, this function is not. + ::grpc::ServerContext* context = NULL; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiFpga_Session(context, status, session); + } + response->set_status(status); + */ return ::grpc::Status::OK; } + //--------------------------------------------------------------------- //--------------------------------------------------------------------- ::grpc::Status NiFpgaService::Abort(::grpc::ServerContext* context, const AbortRequest* request, AbortResponse* response) @@ -2013,14 +2280,14 @@ ::grpc::Status MonikerWriteU8(void* data, google::protobuf::Arena& arena, google uint32_t indicator = request->indicator(); size_t size = request->size(); - auto data = std::make_unique(); + auto data = std::make_unique(); data->session = session; data->indicator = indicator; data->size = size; data->library = std::shared_ptr(library_); - - data->data.mutable_value()->Reserve(request->size()); - data->data.mutable_value()->Resize(request->size(), 0); + + data->data.mutable_response()->mutable_array()->Reserve(request->size()); + data->data.mutable_response()->mutable_array()->Resize(request->size(), 0); auto moniker = std::make_unique(); ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerReadArrayBool", data.release(), *moniker); response->set_allocated_moniker(moniker.release()); @@ -2071,14 +2338,14 @@ ::grpc::Status MonikerWriteU8(void* data, google::protobuf::Arena& arena, google uint32_t indicator = request->indicator(); size_t size = request->size(); - auto data = std::make_unique(); + auto data = std::make_unique(); data->session = session; data->indicator = indicator; data->size = size; data->library = std::shared_ptr(library_); - - data->data.mutable_value()->Reserve(request->size()); - data->data.mutable_value()->Resize(request->size(), 0); + + data->data.mutable_response()->mutable_array()->Reserve(request->size()); + data->data.mutable_response()->mutable_array()->Resize(request->size(), 0); auto moniker = std::make_unique(); ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerReadArrayDbl", data.release(), *moniker); response->set_allocated_moniker(moniker.release()); @@ -2137,14 +2404,14 @@ ::grpc::Status MonikerWriteU8(void* data, google::protobuf::Arena& arena, google uint32_t indicator = request->indicator(); size_t size = request->size(); - auto data = std::make_unique(); + auto data = std::make_unique(); data->session = session; data->indicator = indicator; data->size = size; data->library = std::shared_ptr(library_); - - data->data.mutable_value()->Reserve(request->size()); - data->data.mutable_value()->Resize(request->size(), 0); + + data->data.mutable_response()->mutable_array()->Reserve(request->size()); + data->data.mutable_response()->mutable_array()->Resize(request->size(), 0); auto moniker = std::make_unique(); ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerReadArrayI16", data.release(), *moniker); response->set_allocated_moniker(moniker.release()); @@ -2195,14 +2462,14 @@ ::grpc::Status MonikerWriteU8(void* data, google::protobuf::Arena& arena, google uint32_t indicator = request->indicator(); size_t size = request->size(); - auto data = std::make_unique(); + auto data = std::make_unique(); data->session = session; data->indicator = indicator; data->size = size; data->library = std::shared_ptr(library_); - - data->data.mutable_value()->Reserve(request->size()); - data->data.mutable_value()->Resize(request->size(), 0); + + data->data.mutable_response()->mutable_array()->Reserve(request->size()); + data->data.mutable_response()->mutable_array()->Resize(request->size(), 0); auto moniker = std::make_unique(); ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerReadArrayI32", data.release(), *moniker); response->set_allocated_moniker(moniker.release()); @@ -2253,14 +2520,14 @@ ::grpc::Status MonikerWriteU8(void* data, google::protobuf::Arena& arena, google uint32_t indicator = request->indicator(); size_t size = request->size(); - auto data = std::make_unique(); + auto data = std::make_unique(); data->session = session; data->indicator = indicator; data->size = size; data->library = std::shared_ptr(library_); - - data->data.mutable_value()->Reserve(request->size()); - data->data.mutable_value()->Resize(request->size(), 0); + + data->data.mutable_response()->mutable_array()->Reserve(request->size()); + data->data.mutable_response()->mutable_array()->Resize(request->size(), 0); auto moniker = std::make_unique(); ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerReadArrayI64", data.release(), *moniker); response->set_allocated_moniker(moniker.release()); @@ -2319,14 +2586,14 @@ ::grpc::Status MonikerWriteU8(void* data, google::protobuf::Arena& arena, google uint32_t indicator = request->indicator(); size_t size = request->size(); - auto data = std::make_unique(); + auto data = std::make_unique(); data->session = session; data->indicator = indicator; data->size = size; data->library = std::shared_ptr(library_); - - data->data.mutable_value()->Reserve(request->size()); - data->data.mutable_value()->Resize(request->size(), 0); + + data->data.mutable_response()->mutable_array()->Reserve(request->size()); + data->data.mutable_response()->mutable_array()->Resize(request->size(), 0); auto moniker = std::make_unique(); ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerReadArrayI8", data.release(), *moniker); response->set_allocated_moniker(moniker.release()); @@ -2377,14 +2644,14 @@ ::grpc::Status MonikerWriteU8(void* data, google::protobuf::Arena& arena, google uint32_t indicator = request->indicator(); size_t size = request->size(); - auto data = std::make_unique(); + auto data = std::make_unique(); data->session = session; data->indicator = indicator; data->size = size; data->library = std::shared_ptr(library_); - - data->data.mutable_value()->Reserve(request->size()); - data->data.mutable_value()->Resize(request->size(), 0); + + data->data.mutable_response()->mutable_array()->Reserve(request->size()); + data->data.mutable_response()->mutable_array()->Resize(request->size(), 0); auto moniker = std::make_unique(); ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerReadArraySgl", data.release(), *moniker); response->set_allocated_moniker(moniker.release()); @@ -2443,14 +2710,14 @@ ::grpc::Status MonikerWriteU8(void* data, google::protobuf::Arena& arena, google uint32_t indicator = request->indicator(); size_t size = request->size(); - auto data = std::make_unique(); + auto data = std::make_unique(); data->session = session; data->indicator = indicator; data->size = size; data->library = std::shared_ptr(library_); - - data->data.mutable_value()->Reserve(request->size()); - data->data.mutable_value()->Resize(request->size(), 0); + + data->data.mutable_response()->mutable_array()->Reserve(request->size()); + data->data.mutable_response()->mutable_array()->Resize(request->size(), 0); auto moniker = std::make_unique(); ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerReadArrayU16", data.release(), *moniker); response->set_allocated_moniker(moniker.release()); @@ -2501,14 +2768,14 @@ ::grpc::Status MonikerWriteU8(void* data, google::protobuf::Arena& arena, google uint32_t indicator = request->indicator(); size_t size = request->size(); - auto data = std::make_unique(); + auto data = std::make_unique(); data->session = session; data->indicator = indicator; data->size = size; data->library = std::shared_ptr(library_); - - data->data.mutable_value()->Reserve(request->size()); - data->data.mutable_value()->Resize(request->size(), 0); + + data->data.mutable_response()->mutable_array()->Reserve(request->size()); + data->data.mutable_response()->mutable_array()->Resize(request->size(), 0); auto moniker = std::make_unique(); ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerReadArrayU32", data.release(), *moniker); response->set_allocated_moniker(moniker.release()); @@ -2559,14 +2826,14 @@ ::grpc::Status MonikerWriteU8(void* data, google::protobuf::Arena& arena, google uint32_t indicator = request->indicator(); size_t size = request->size(); - auto data = std::make_unique(); + auto data = std::make_unique(); data->session = session; data->indicator = indicator; data->size = size; data->library = std::shared_ptr(library_); - - data->data.mutable_value()->Reserve(request->size()); - data->data.mutable_value()->Resize(request->size(), 0); + + data->data.mutable_response()->mutable_array()->Reserve(request->size()); + data->data.mutable_response()->mutable_array()->Resize(request->size(), 0); auto moniker = std::make_unique(); ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerReadArrayU64", data.release(), *moniker); response->set_allocated_moniker(moniker.release()); @@ -2625,14 +2892,14 @@ ::grpc::Status MonikerWriteU8(void* data, google::protobuf::Arena& arena, google uint32_t indicator = request->indicator(); size_t size = request->size(); - auto data = std::make_unique(); + auto data = std::make_unique(); data->session = session; data->indicator = indicator; data->size = size; data->library = std::shared_ptr(library_); - - data->data.mutable_value()->Reserve(request->size()); - data->data.mutable_value()->Resize(request->size(), 0); + + data->data.mutable_response()->mutable_array()->Reserve(request->size()); + data->data.mutable_response()->mutable_array()->Resize(request->size(), 0); auto moniker = std::make_unique(); ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerReadArrayU8", data.release(), *moniker); response->set_allocated_moniker(moniker.release()); @@ -2681,11 +2948,11 @@ ::grpc::Status MonikerWriteU8(void* data, google::protobuf::Arena& arena, google NiFpga_Session session = session_repository_->access_session(session_grpc_session.name()); uint32_t indicator = request->indicator(); - auto data = std::make_unique(); + auto data = std::make_unique(); data->session = session; data->indicator = indicator; data->library = std::shared_ptr(library_); - + auto moniker = std::make_unique(); ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerReadBool", data.release(), *moniker); response->set_allocated_moniker(moniker.release()); @@ -2734,11 +3001,11 @@ ::grpc::Status MonikerWriteU8(void* data, google::protobuf::Arena& arena, google NiFpga_Session session = session_repository_->access_session(session_grpc_session.name()); uint32_t indicator = request->indicator(); - auto data = std::make_unique(); + auto data = std::make_unique(); data->session = session; data->indicator = indicator; data->library = std::shared_ptr(library_); - + auto moniker = std::make_unique(); ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerReadDbl", data.release(), *moniker); response->set_allocated_moniker(moniker.release()); @@ -3138,11 +3405,11 @@ ::grpc::Status MonikerWriteU8(void* data, google::protobuf::Arena& arena, google NiFpga_Session session = session_repository_->access_session(session_grpc_session.name()); uint32_t indicator = request->indicator(); - auto data = std::make_unique(); + auto data = std::make_unique(); data->session = session; data->indicator = indicator; data->library = std::shared_ptr(library_); - + auto moniker = std::make_unique(); ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerReadI16", data.release(), *moniker); response->set_allocated_moniker(moniker.release()); @@ -3191,11 +3458,11 @@ ::grpc::Status MonikerWriteU8(void* data, google::protobuf::Arena& arena, google NiFpga_Session session = session_repository_->access_session(session_grpc_session.name()); uint32_t indicator = request->indicator(); - auto data = std::make_unique(); + auto data = std::make_unique(); data->session = session; data->indicator = indicator; data->library = std::shared_ptr(library_); - + auto moniker = std::make_unique(); ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerReadI32", data.release(), *moniker); response->set_allocated_moniker(moniker.release()); @@ -3244,11 +3511,11 @@ ::grpc::Status MonikerWriteU8(void* data, google::protobuf::Arena& arena, google NiFpga_Session session = session_repository_->access_session(session_grpc_session.name()); uint32_t indicator = request->indicator(); - auto data = std::make_unique(); + auto data = std::make_unique(); data->session = session; data->indicator = indicator; data->library = std::shared_ptr(library_); - + auto moniker = std::make_unique(); ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerReadI64", data.release(), *moniker); response->set_allocated_moniker(moniker.release()); @@ -3297,11 +3564,11 @@ ::grpc::Status MonikerWriteU8(void* data, google::protobuf::Arena& arena, google NiFpga_Session session = session_repository_->access_session(session_grpc_session.name()); uint32_t indicator = request->indicator(); - auto data = std::make_unique(); + auto data = std::make_unique(); data->session = session; data->indicator = indicator; data->library = std::shared_ptr(library_); - + auto moniker = std::make_unique(); ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerReadI8", data.release(), *moniker); response->set_allocated_moniker(moniker.release()); @@ -3350,11 +3617,11 @@ ::grpc::Status MonikerWriteU8(void* data, google::protobuf::Arena& arena, google NiFpga_Session session = session_repository_->access_session(session_grpc_session.name()); uint32_t indicator = request->indicator(); - auto data = std::make_unique(); + auto data = std::make_unique(); data->session = session; data->indicator = indicator; data->library = std::shared_ptr(library_); - + auto moniker = std::make_unique(); ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerReadSgl", data.release(), *moniker); response->set_allocated_moniker(moniker.release()); @@ -3403,11 +3670,11 @@ ::grpc::Status MonikerWriteU8(void* data, google::protobuf::Arena& arena, google NiFpga_Session session = session_repository_->access_session(session_grpc_session.name()); uint32_t indicator = request->indicator(); - auto data = std::make_unique(); + auto data = std::make_unique(); data->session = session; data->indicator = indicator; data->library = std::shared_ptr(library_); - + auto moniker = std::make_unique(); ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerReadU16", data.release(), *moniker); response->set_allocated_moniker(moniker.release()); @@ -3456,11 +3723,11 @@ ::grpc::Status MonikerWriteU8(void* data, google::protobuf::Arena& arena, google NiFpga_Session session = session_repository_->access_session(session_grpc_session.name()); uint32_t indicator = request->indicator(); - auto data = std::make_unique(); + auto data = std::make_unique(); data->session = session; data->indicator = indicator; data->library = std::shared_ptr(library_); - + auto moniker = std::make_unique(); ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerReadU32", data.release(), *moniker); response->set_allocated_moniker(moniker.release()); @@ -3509,11 +3776,11 @@ ::grpc::Status MonikerWriteU8(void* data, google::protobuf::Arena& arena, google NiFpga_Session session = session_repository_->access_session(session_grpc_session.name()); uint32_t indicator = request->indicator(); - auto data = std::make_unique(); + auto data = std::make_unique(); data->session = session; data->indicator = indicator; data->library = std::shared_ptr(library_); - + auto moniker = std::make_unique(); ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerReadU64", data.release(), *moniker); response->set_allocated_moniker(moniker.release()); @@ -3562,11 +3829,11 @@ ::grpc::Status MonikerWriteU8(void* data, google::protobuf::Arena& arena, google NiFpga_Session session = session_repository_->access_session(session_grpc_session.name()); uint32_t indicator = request->indicator(); - auto data = std::make_unique(); + auto data = std::make_unique(); data->session = session; data->indicator = indicator; data->library = std::shared_ptr(library_); - + auto moniker = std::make_unique(); ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerReadU8", data.release(), *moniker); response->set_allocated_moniker(moniker.release()); @@ -3957,11 +4224,11 @@ ::grpc::Status MonikerWriteU8(void* data, google::protobuf::Arena& arena, google NiFpga_Session session = session_repository_->access_session(session_grpc_session.name()); uint32_t control = request->control(); - auto data = std::make_unique(); + auto data = std::make_unique(); data->session = session; data->control = control; data->library = std::shared_ptr(library_); - + auto moniker = std::make_unique(); ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerWriteArrayBool", data.release(), *moniker); response->set_allocated_moniker(moniker.release()); @@ -4010,11 +4277,11 @@ ::grpc::Status MonikerWriteU8(void* data, google::protobuf::Arena& arena, google NiFpga_Session session = session_repository_->access_session(session_grpc_session.name()); uint32_t control = request->control(); - auto data = std::make_unique(); + auto data = std::make_unique(); data->session = session; data->control = control; data->library = std::shared_ptr(library_); - + auto moniker = std::make_unique(); ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerWriteArrayDbl", data.release(), *moniker); response->set_allocated_moniker(moniker.release()); @@ -4080,11 +4347,11 @@ ::grpc::Status MonikerWriteU8(void* data, google::protobuf::Arena& arena, google NiFpga_Session session = session_repository_->access_session(session_grpc_session.name()); uint32_t control = request->control(); - auto data = std::make_unique(); + auto data = std::make_unique(); data->session = session; data->control = control; data->library = std::shared_ptr(library_); - + auto moniker = std::make_unique(); ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerWriteArrayI16", data.release(), *moniker); response->set_allocated_moniker(moniker.release()); @@ -4133,11 +4400,11 @@ ::grpc::Status MonikerWriteU8(void* data, google::protobuf::Arena& arena, google NiFpga_Session session = session_repository_->access_session(session_grpc_session.name()); uint32_t control = request->control(); - auto data = std::make_unique(); + auto data = std::make_unique(); data->session = session; data->control = control; data->library = std::shared_ptr(library_); - + auto moniker = std::make_unique(); ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerWriteArrayI32", data.release(), *moniker); response->set_allocated_moniker(moniker.release()); @@ -4186,11 +4453,11 @@ ::grpc::Status MonikerWriteU8(void* data, google::protobuf::Arena& arena, google NiFpga_Session session = session_repository_->access_session(session_grpc_session.name()); uint32_t control = request->control(); - auto data = std::make_unique(); + auto data = std::make_unique(); data->session = session; data->control = control; data->library = std::shared_ptr(library_); - + auto moniker = std::make_unique(); ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerWriteArrayI64", data.release(), *moniker); response->set_allocated_moniker(moniker.release()); @@ -4256,11 +4523,11 @@ ::grpc::Status MonikerWriteU8(void* data, google::protobuf::Arena& arena, google NiFpga_Session session = session_repository_->access_session(session_grpc_session.name()); uint32_t control = request->control(); - auto data = std::make_unique(); + auto data = std::make_unique(); data->session = session; data->control = control; data->library = std::shared_ptr(library_); - + auto moniker = std::make_unique(); ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerWriteArrayI8", data.release(), *moniker); response->set_allocated_moniker(moniker.release()); @@ -4309,11 +4576,11 @@ ::grpc::Status MonikerWriteU8(void* data, google::protobuf::Arena& arena, google NiFpga_Session session = session_repository_->access_session(session_grpc_session.name()); uint32_t control = request->control(); - auto data = std::make_unique(); + auto data = std::make_unique(); data->session = session; data->control = control; data->library = std::shared_ptr(library_); - + auto moniker = std::make_unique(); ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerWriteArraySgl", data.release(), *moniker); response->set_allocated_moniker(moniker.release()); @@ -4379,11 +4646,11 @@ ::grpc::Status MonikerWriteU8(void* data, google::protobuf::Arena& arena, google NiFpga_Session session = session_repository_->access_session(session_grpc_session.name()); uint32_t control = request->control(); - auto data = std::make_unique(); + auto data = std::make_unique(); data->session = session; data->control = control; data->library = std::shared_ptr(library_); - + auto moniker = std::make_unique(); ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerWriteArrayU16", data.release(), *moniker); response->set_allocated_moniker(moniker.release()); @@ -4432,11 +4699,11 @@ ::grpc::Status MonikerWriteU8(void* data, google::protobuf::Arena& arena, google NiFpga_Session session = session_repository_->access_session(session_grpc_session.name()); uint32_t control = request->control(); - auto data = std::make_unique(); + auto data = std::make_unique(); data->session = session; data->control = control; data->library = std::shared_ptr(library_); - + auto moniker = std::make_unique(); ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerWriteArrayU32", data.release(), *moniker); response->set_allocated_moniker(moniker.release()); @@ -4485,11 +4752,11 @@ ::grpc::Status MonikerWriteU8(void* data, google::protobuf::Arena& arena, google NiFpga_Session session = session_repository_->access_session(session_grpc_session.name()); uint32_t control = request->control(); - auto data = std::make_unique(); + auto data = std::make_unique(); data->session = session; data->control = control; data->library = std::shared_ptr(library_); - + auto moniker = std::make_unique(); ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerWriteArrayU64", data.release(), *moniker); response->set_allocated_moniker(moniker.release()); @@ -4555,11 +4822,11 @@ ::grpc::Status MonikerWriteU8(void* data, google::protobuf::Arena& arena, google NiFpga_Session session = session_repository_->access_session(session_grpc_session.name()); uint32_t control = request->control(); - auto data = std::make_unique(); + auto data = std::make_unique(); data->session = session; data->control = control; data->library = std::shared_ptr(library_); - + auto moniker = std::make_unique(); ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerWriteArrayU8", data.release(), *moniker); response->set_allocated_moniker(moniker.release()); @@ -4607,11 +4874,11 @@ ::grpc::Status MonikerWriteU8(void* data, google::protobuf::Arena& arena, google NiFpga_Session session = session_repository_->access_session(session_grpc_session.name()); uint32_t control = request->control(); - auto data = std::make_unique(); + auto data = std::make_unique(); data->session = session; data->control = control; data->library = std::shared_ptr(library_); - + auto moniker = std::make_unique(); ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerWriteBool", data.release(), *moniker); response->set_allocated_moniker(moniker.release()); @@ -4659,11 +4926,11 @@ ::grpc::Status MonikerWriteU8(void* data, google::protobuf::Arena& arena, google NiFpga_Session session = session_repository_->access_session(session_grpc_session.name()); uint32_t control = request->control(); - auto data = std::make_unique(); + auto data = std::make_unique(); data->session = session; data->control = control; data->library = std::shared_ptr(library_); - + auto moniker = std::make_unique(); ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerWriteDbl", data.release(), *moniker); response->set_allocated_moniker(moniker.release()); @@ -5096,11 +5363,11 @@ ::grpc::Status MonikerWriteU8(void* data, google::protobuf::Arena& arena, google NiFpga_Session session = session_repository_->access_session(session_grpc_session.name()); uint32_t control = request->control(); - auto data = std::make_unique(); + auto data = std::make_unique(); data->session = session; data->control = control; data->library = std::shared_ptr(library_); - + auto moniker = std::make_unique(); ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerWriteI16", data.release(), *moniker); response->set_allocated_moniker(moniker.release()); @@ -5148,11 +5415,11 @@ ::grpc::Status MonikerWriteU8(void* data, google::protobuf::Arena& arena, google NiFpga_Session session = session_repository_->access_session(session_grpc_session.name()); uint32_t control = request->control(); - auto data = std::make_unique(); + auto data = std::make_unique(); data->session = session; data->control = control; data->library = std::shared_ptr(library_); - + auto moniker = std::make_unique(); ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerWriteI32", data.release(), *moniker); response->set_allocated_moniker(moniker.release()); @@ -5200,11 +5467,11 @@ ::grpc::Status MonikerWriteU8(void* data, google::protobuf::Arena& arena, google NiFpga_Session session = session_repository_->access_session(session_grpc_session.name()); uint32_t control = request->control(); - auto data = std::make_unique(); + auto data = std::make_unique(); data->session = session; data->control = control; data->library = std::shared_ptr(library_); - + auto moniker = std::make_unique(); ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerWriteI64", data.release(), *moniker); response->set_allocated_moniker(moniker.release()); @@ -5261,11 +5528,11 @@ ::grpc::Status MonikerWriteU8(void* data, google::protobuf::Arena& arena, google NiFpga_Session session = session_repository_->access_session(session_grpc_session.name()); uint32_t control = request->control(); - auto data = std::make_unique(); + auto data = std::make_unique(); data->session = session; data->control = control; data->library = std::shared_ptr(library_); - + auto moniker = std::make_unique(); ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerWriteI8", data.release(), *moniker); response->set_allocated_moniker(moniker.release()); @@ -5313,11 +5580,11 @@ ::grpc::Status MonikerWriteU8(void* data, google::protobuf::Arena& arena, google NiFpga_Session session = session_repository_->access_session(session_grpc_session.name()); uint32_t control = request->control(); - auto data = std::make_unique(); + auto data = std::make_unique(); data->session = session; data->control = control; data->library = std::shared_ptr(library_); - + auto moniker = std::make_unique(); ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerWriteSgl", data.release(), *moniker); response->set_allocated_moniker(moniker.release()); @@ -5374,11 +5641,11 @@ ::grpc::Status MonikerWriteU8(void* data, google::protobuf::Arena& arena, google NiFpga_Session session = session_repository_->access_session(session_grpc_session.name()); uint32_t control = request->control(); - auto data = std::make_unique(); + auto data = std::make_unique(); data->session = session; data->control = control; data->library = std::shared_ptr(library_); - + auto moniker = std::make_unique(); ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerWriteU16", data.release(), *moniker); response->set_allocated_moniker(moniker.release()); @@ -5426,11 +5693,11 @@ ::grpc::Status MonikerWriteU8(void* data, google::protobuf::Arena& arena, google NiFpga_Session session = session_repository_->access_session(session_grpc_session.name()); uint32_t control = request->control(); - auto data = std::make_unique(); + auto data = std::make_unique(); data->session = session; data->control = control; data->library = std::shared_ptr(library_); - + auto moniker = std::make_unique(); ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerWriteU32", data.release(), *moniker); response->set_allocated_moniker(moniker.release()); @@ -5478,11 +5745,11 @@ ::grpc::Status MonikerWriteU8(void* data, google::protobuf::Arena& arena, google NiFpga_Session session = session_repository_->access_session(session_grpc_session.name()); uint32_t control = request->control(); - auto data = std::make_unique(); + auto data = std::make_unique(); data->session = session; data->control = control; data->library = std::shared_ptr(library_); - + auto moniker = std::make_unique(); ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerWriteU64", data.release(), *moniker); response->set_allocated_moniker(moniker.release()); @@ -5539,11 +5806,11 @@ ::grpc::Status MonikerWriteU8(void* data, google::protobuf::Arena& arena, google NiFpga_Session session = session_repository_->access_session(session_grpc_session.name()); uint32_t control = request->control(); - auto data = std::make_unique(); + auto data = std::make_unique(); data->session = session; data->control = control; data->library = std::shared_ptr(library_); - + auto moniker = std::make_unique(); ni::data_monikers::DataMonikerService::RegisterMonikerInstance("MonikerWriteU8", data.release(), *moniker); response->set_allocated_moniker(moniker.release()); diff --git a/source/codegen/templates/service.cpp.mako b/source/codegen/templates/service.cpp.mako index ba25d7cde..58340062e 100644 --- a/source/codegen/templates/service.cpp.mako +++ b/source/codegen/templates/service.cpp.mako @@ -118,12 +118,11 @@ ${mako_helper.define_moniker_streaming_struct(function_name=function_name, param ${mako_helper.register_moniker_functions(function_name)}\ % endfor } + % endif % for function_name in streaming_functions_to_generate: -<% -function_data = functions[function_name] -%> -${mako_helper.define_moniker_function_body(function_name=function_name, function_data=function_data)}\ +${mako_helper.define_moniker_function_body(function_name=function_name, functions=functions)}\ + % endfor % for function_name in service_helpers.filter_proto_rpc_functions_to_generate(functions): <% diff --git a/source/codegen/templates/service_helpers.mako b/source/codegen/templates/service_helpers.mako index 567b0f89b..dd40ab36c 100644 --- a/source/codegen/templates/service_helpers.mako +++ b/source/codegen/templates/service_helpers.mako @@ -281,9 +281,7 @@ ${populate_response(function_data=function_data, parameters=parameters)}\ <%def name="define_moniker_streaming_struct(function_name, parameters)">\ <% config = data['config'] - streaming_param = common_helpers.get_streaming_parameter(parameters) service_class_prefix = config["service_class_prefix"] - grpc_streaming_type = streaming_param['grpc_streaming_type'] struct_name = common_helpers.get_data_moniker_struct_name(function_name) request_response_data_type = common_helpers.get_data_moniker_request_response_data_type(function_name) streaming_params_to_include = common_helpers.get_input_streaming_params(parameters) @@ -301,11 +299,13 @@ ${populate_response(function_data=function_data, parameters=parameters)}\ }; -<%def name="define_moniker_function_body(function_name, function_data)">\ +<%def name="define_moniker_function_body(function_name, functions)">\ <% config = data['config'] + function_data = functions[function_name] struct_name = common_helpers.get_data_moniker_struct_name(function_name) moniker_function_name = common_helpers.get_data_moniker_function_name(function_name) + non_streaming_function_name = function_name.replace("Begin", "") streaming_param = common_helpers.get_streaming_parameter(function_data['parameters']) streaming_type = streaming_param['type'] grpc_streaming_type = streaming_param['grpc_streaming_type'] @@ -314,20 +314,33 @@ ${populate_response(function_data=function_data, parameters=parameters)}\ data_type = streaming_type.replace("[]", "") c_api_name = service_helpers.get_c_api_name(function_name) streaming_params_to_include = common_helpers.get_input_streaming_params(function_data['parameters']) + output_parameters = [p for p in functions[non_streaming_function_name]['parameters'] if common_helpers.is_output_parameter(p)] %>\ ::grpc::Status ${moniker_function_name}(void* data, google::protobuf::Arena& arena, google::protobuf::Any& packedData) { ${struct_name}* function_data = static_cast<${struct_name}*>(data); - auto library = function_data->library;\ + auto library = function_data->library; + auto response = function_data->data.mutable_response();\ ${initialize_moniker_streaming_parameters(streaming_params_to_include)}\ % if streaming_param and streaming_param['direction'] == 'in': ${streaming_handle_in_direction(c_api_name, arg_string, data_type, grpc_streaming_type, streaming_type, streaming_param)}\ % elif streaming_param and streaming_param['direction'] == 'out': - ${streaming_handle_out_direction(c_api_name, arg_string, data_type, streaming_type, streaming_param, moniker_params)}\ + ${streaming_handle_out_direction(c_api_name, arg_string, data_type, streaming_param, moniker_params)}\ % endif - if (status < 0) { - std::cout << "${moniker_function_name} error: " << status << std::endl; + /* TODO context is unavailable to return error the proper way. Also error API is member of service class, this function is not. + ::grpc::ServerContext* context = NULL; +${populate_response(function_data=function_data, parameters=functions[non_streaming_function_name]['parameters'])}\ + */ +% if streaming_param['direction'] == 'out': + if (status >= 0) + { + response->set_status(status); +<%block filter="common_helpers.indent(-1)">\ +${set_response_values(output_parameters=output_parameters, init_method=false)}\ +\ + packedData.PackFrom(function_data->data); } +% endif return ::grpc::Status::OK; } @@ -345,10 +358,10 @@ ${populate_response(function_data=function_data, parameters=parameters)}\ streaming_params_to_include = common_helpers.get_input_streaming_params(parameters) %>\ ${initialize_streaming_input_param(function_name, streaming_params_to_include, parameters, streaming_param)} - auto data = std::make_unique<${struct_name}>();\ - ${initialize_begin_input_params(streaming_params_to_include, streaming_param)}\ + auto data = std::make_unique<${struct_name}>(); +${initialize_begin_input_params(streaming_params_to_include, streaming_param)}\ data->library = std::shared_ptr<${service_class_prefix}LibraryInterface>(library_); - ${initialize_service_output_params(output_params)}\ +${initialize_service_output_params(output_params)}\ auto moniker = std::make_unique(); ni::data_monikers::DataMonikerService::RegisterMonikerInstance("${moniker_function_name}", data.release(), *moniker); response->set_allocated_moniker(moniker.release()); @@ -356,14 +369,14 @@ ${initialize_streaming_input_param(function_name, streaming_params_to_include, p return ::grpc::Status::OK;\ -<%def name="streaming_handle_out_direction(c_api_name, arg_string, data_type, streaming_type, streaming_param, moniker_params)"> +<%def name="streaming_handle_out_direction(c_api_name, arg_string, data_type, streaming_param, moniker_params)"> <% - is_array = common_helpers.is_array(streaming_type) + is_array = common_helpers.is_array(streaming_param['type']) %>\ % if is_array: - ${streaming_handle_out_direction_array(c_api_name, arg_string, data_type, streaming_param)} +${streaming_handle_out_direction_array(c_api_name, arg_string, data_type, streaming_param)} % else: - ${streaming_handle_out_direction_scaler(c_api_name, arg_string, streaming_type, moniker_params)} +${streaming_handle_out_direction_scaler(c_api_name, arg_string, streaming_param, moniker_params)} % endif @@ -371,48 +384,24 @@ ${initialize_streaming_input_param(function_name, streaming_params_to_include, p <% is_coerced = service_helpers.is_output_array_that_needs_coercion(streaming_param) size = service_helpers.get_size_param_name(streaming_param) + streaming_param_field_name = common_helpers.get_grpc_field_name(streaming_param) %>\ % if common_helpers.supports_standard_copy_conversion_routines(streaming_param): -std::vector<${data_type}> array(${size}, ${data_type}()); + std::vector<${data_type}> ${streaming_param_field_name}(${size}, ${data_type}()); % elif is_coerced: -std::vector<${data_type}> array(${size}); + std::vector<${data_type}> ${streaming_param_field_name}(${size}); % else: -auto array_storage = std::vector<${data_type}>(${size}); - auto array = array_storage.data(); + auto ${streaming_param_field_name} = response->mutable_${streaming_param_field_name}()->mutable_data(); % endif auto status = library->${c_api_name}(${arg_string}); -% if is_coerced or common_helpers.supports_standard_copy_conversion_routines(streaming_param): - if (status >= 0) { - std::transform( - array.begin(), - array.begin() + ${size}, - function_data->data.mutable_value()->begin(), - [&](auto x) { - return x; - }); - packedData.PackFrom(function_data->data); - } -% else: - if (status >= 0) { - std::transform( - array, - array + ${size}, - function_data->data.mutable_value()->begin(), - [&](auto x) { - return x; - }); - packedData.PackFrom(function_data->data); - } -% endif -<%def name="streaming_handle_out_direction_scaler(c_api_name, arg_string, streaming_type, moniker_params)">\ -${streaming_type} value {}; +<%def name="streaming_handle_out_direction_scaler(c_api_name, arg_string, streaming_param, moniker_params)">\ +<% + streaming_param_field_name = common_helpers.get_grpc_field_name(streaming_param) +%>\ +${streaming_param['type']} value {}; auto status = library->${c_api_name}(${arg_string}); - function_data->data.set_value(value); - if (status >= 0) { - packedData.PackFrom(function_data->data); - } <%def name="streaming_handle_in_direction(c_api_name, arg_string, data_type, grpc_streaming_type, streaming_type, streaming_param)"> @@ -475,7 +464,7 @@ auto value = ${grpc_streaming_type.lower()}_message.value(); ## Initialize an bgin input parameter for an API call. -<%def name="initialize_begin_input_params(streaming_params_to_include, streaming_param)"> +<%def name="initialize_begin_input_params(streaming_params_to_include, streaming_param)">\ % for parameter in streaming_params_to_include: <% parameter_name = common_helpers.get_cpp_local_name(parameter) @@ -503,8 +492,11 @@ ${initialize_input_param(function_name, param, parameters)}\ <%def name="initialize_service_output_params(output_params)"> % for param in output_params: % if common_helpers.is_array(param['type']): - data->data.mutable_value()->Reserve(request->size()); - data->data.mutable_value()->Resize(request->size(), 0); +<% + grpc_field_name = common_helpers.get_grpc_field_name(param) +%>\ + data->data.mutable_response()->mutable_${grpc_field_name}()->Reserve(request->size()); + data->data.mutable_response()->mutable_${grpc_field_name}()->Resize(request->size(), 0); % endif % endfor