From f02fd4e6ceb72911c31d2ae53a2e083e0e100168 Mon Sep 17 00:00:00 2001 From: Ryan Eckenrode Date: Tue, 29 Mar 2022 16:03:57 -0500 Subject: [PATCH 01/18] Initial impl of IO Trace service --- CMakeLists.txt | 14 +-- generated/niiotrace/niiotrace.proto | 35 ++++++ generated/niiotrace/niiotrace_client.cpp | 39 ++++++ generated/niiotrace/niiotrace_client.h | 29 +++++ generated/niiotrace/niiotrace_library.cpp | 50 ++++++++ generated/niiotrace/niiotrace_library.h | 36 ++++++ .../niiotrace/niiotrace_library_interface.h | 22 ++++ generated/niiotrace/niiotrace_mock_library.h | 26 ++++ generated/niiotrace/niiotrace_service.cpp | 72 +++++++++++ generated/niiotrace/niiotrace_service.h | 54 ++++++++ .../niiotrace/niiotrace_service_registrar.cpp | 52 ++++++++ .../niiotrace/niiotrace_service_registrar.h | 30 +++++ generated/register_all_services.cpp | 6 + imports/include/NiSpyAPI.h | 118 ++++++++++++++++++ imports/lib/win64/NiSpyLog.lib | Bin 0 -> 21250 bytes source/codegen/metadata/niiotrace/CHANGES.md | 0 source/codegen/metadata/niiotrace/__init__.py | 11 ++ .../codegen/metadata/niiotrace/attributes.py | 2 + .../metadata/niiotrace/attributes_addon.py | 6 + source/codegen/metadata/niiotrace/config.py | 30 +++++ .../metadata/niiotrace/config_addon.py | 2 + source/codegen/metadata/niiotrace/enums.py | 3 + .../codegen/metadata/niiotrace/enums_addon.py | 6 + .../codegen/metadata/niiotrace/functions.py | 25 ++++ .../metadata/niiotrace/functions_addon.py | 5 + source/custom/niiotrace_service.custom.cpp | 5 + 26 files changed, 671 insertions(+), 7 deletions(-) create mode 100644 generated/niiotrace/niiotrace.proto create mode 100644 generated/niiotrace/niiotrace_client.cpp create mode 100644 generated/niiotrace/niiotrace_client.h create mode 100644 generated/niiotrace/niiotrace_library.cpp create mode 100644 generated/niiotrace/niiotrace_library.h create mode 100644 generated/niiotrace/niiotrace_library_interface.h create mode 100644 generated/niiotrace/niiotrace_mock_library.h create mode 100644 generated/niiotrace/niiotrace_service.cpp create mode 100644 generated/niiotrace/niiotrace_service.h create mode 100644 generated/niiotrace/niiotrace_service_registrar.cpp create mode 100644 generated/niiotrace/niiotrace_service_registrar.h create mode 100644 imports/include/NiSpyAPI.h create mode 100644 imports/lib/win64/NiSpyLog.lib create mode 100644 source/codegen/metadata/niiotrace/CHANGES.md create mode 100644 source/codegen/metadata/niiotrace/__init__.py create mode 100644 source/codegen/metadata/niiotrace/attributes.py create mode 100644 source/codegen/metadata/niiotrace/attributes_addon.py create mode 100644 source/codegen/metadata/niiotrace/config.py create mode 100644 source/codegen/metadata/niiotrace/config_addon.py create mode 100644 source/codegen/metadata/niiotrace/enums.py create mode 100644 source/codegen/metadata/niiotrace/enums_addon.py create mode 100644 source/codegen/metadata/niiotrace/functions.py create mode 100644 source/codegen/metadata/niiotrace/functions_addon.py create mode 100644 source/custom/niiotrace_service.custom.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index d2316932b..d21fdcf8d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -76,7 +76,7 @@ set(metadata_dir ${CMAKE_SOURCE_DIR}/source/codegen/metadata) set(service_output_dir ${CMAKE_SOURCE_DIR}/generated) set(codegen_dir ${CMAKE_SOURCE_DIR}/source/codegen) set(custom_dir ${CMAKE_SOURCE_DIR}/source/custom) -set(nidrivers "nidaqmx" "nidcpower" "nidigitalpattern" "nidmm" "nifake" "nifake_extension" "nifake_non_ivi" "nifgen" "nirfmxbluetooth" "nirfmxinstr" "nirfmxlte" "nirfmxnr" "nirfmxspecan" "nirfmxwlan" "nirfsa" "nirfsg" "niscope" "niswitch" "nisync" "nitclk" "nixnet" "nixnetsocket") +set(nidrivers "nidaqmx" "nidcpower" "nidigitalpattern" "nidmm" "nifake" "nifake_extension" "nifake_non_ivi" "nifgen" "niiotrace" "nirfmxbluetooth" "nirfmxinstr" "nirfmxlte" "nirfmxnr" "nirfmxspecan" "nirfmxwlan" "nirfsa" "nirfsg" "niscope" "niswitch" "nisync" "nitclk" "nixnet" "nixnetsocket") #---------------------------------------------------------------------- # Create NI Driver APIs proto and server files @@ -307,9 +307,9 @@ target_link_libraries(ni_grpc_device_server set_target_properties(ni_grpc_device_server PROPERTIES BUILD_WITH_INSTALL_RPATH TRUE) if(WIN32) - target_link_libraries(ni_grpc_device_server Delayimp nidaqmx nidcpower niDigital nidmm niFgen niScope niRFmxBT niRFmxInstr niRFmxLTE niRFmxNR niRFmxSpecAn niRFmxWLAN niRFSA niRFSG niswitch nisync niTClk nixnet nixntipstack) - set_target_properties(ni_grpc_device_server PROPERTIES LINK_FLAGS "/DELAYLOAD:nicaiu.dll /DELAYLOAD:nidcpower.dll /DELAYLOAD:niDigital_64.dll /DELAYLOAD:nidmm_64.dll /DELAYLOAD:niFgen_64.dll /DELAYLOAD:niRFmxBT.dll /DELAYLOAD:niRFmxInstr.dll /DELAYLOAD:niRFmxLTE.dll /DELAYLOAD:niRFmxNR.dll /DELAYLOAD:niRFmxSpecAn.dll /DELAYLOAD:niRFmxWLAN.dll /DELAYLOAD:niRFSA_64.dll /DELAYLOAD:niRFSG_64.dll /DELAYLOAD:niScope.dll /DELAYLOAD:niswitch.dll /DELAYLOAD:nisync.dll /DELAYLOAD:niTClk_64.dll /DELAYLOAD:nixnet.dll /DELAYLOAD:nixntipstack.dll") - set(ni_grpc_device_server CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /DELAYLOAD:nicaiu.dll /DELAYLOAD:nidcpower.dll /DELAYLOAD:niDigital_64.dll /DELAYLOAD:nidmm_64.dll /DELAYLOAD:niFgen_64.dll /DELAYLOAD:niScope.dll /DELAYLOAD:niRFmxBT.dll /DELAYLOAD:niRFmxInstr.dll /DELAYLOAD:niRFmxLTE.dll /DELAYLOAD:niRFmxNR.dll /DELAYLOAD:niRFmxSpecAn.dll /DELAYLOAD:niRFmxWLAN.dll /DELAYLOAD:niRFSA_64.dll /DELAYLOAD:niRFSG_64.dll /DELAYLOAD:niswitch.dll /DELAYLOAD:nisync.dll /DELAYLOAD:niTClk_64.dll /DELAYLOAD:nixnet.dll /DELAYLOAD:nixntipstack.dll") + target_link_libraries(ni_grpc_device_server Delayimp nidaqmx nidcpower niDigital nidmm niFgen NiSpyLog niScope niRFmxBT niRFmxInstr niRFmxLTE niRFmxNR niRFmxSpecAn niRFmxWLAN niRFSA niRFSG niswitch nisync niTClk nixnet nixntipstack) + set_target_properties(ni_grpc_device_server PROPERTIES LINK_FLAGS "/DELAYLOAD:nicaiu.dll /DELAYLOAD:nidcpower.dll /DELAYLOAD:niDigital_64.dll /DELAYLOAD:nidmm_64.dll /DELAYLOAD:niFgen_64.dll /DELAYLOAD:NiSpyLog.dll /DELAYLOAD:niRFmxBT.dll /DELAYLOAD:niRFmxInstr.dll /DELAYLOAD:niRFmxLTE.dll /DELAYLOAD:niRFmxNR.dll /DELAYLOAD:niRFmxSpecAn.dll /DELAYLOAD:niRFmxWLAN.dll /DELAYLOAD:niRFSA_64.dll /DELAYLOAD:niRFSG_64.dll /DELAYLOAD:niScope.dll /DELAYLOAD:niswitch.dll /DELAYLOAD:nisync.dll /DELAYLOAD:niTClk_64.dll /DELAYLOAD:nixnet.dll /DELAYLOAD:nixntipstack.dll") + set(ni_grpc_device_server CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /DELAYLOAD:nicaiu.dll /DELAYLOAD:nidcpower.dll /DELAYLOAD:niDigital_64.dll /DELAYLOAD:nidmm_64.dll /DELAYLOAD:niFgen_64.dll /DELAYLOAD:NiSpyLog.dll /DELAYLOAD:niScope.dll /DELAYLOAD:niRFmxBT.dll /DELAYLOAD:niRFmxInstr.dll /DELAYLOAD:niRFmxLTE.dll /DELAYLOAD:niRFmxNR.dll /DELAYLOAD:niRFmxSpecAn.dll /DELAYLOAD:niRFmxWLAN.dll /DELAYLOAD:niRFSA_64.dll /DELAYLOAD:niRFSG_64.dll /DELAYLOAD:niswitch.dll /DELAYLOAD:nisync.dll /DELAYLOAD:niTClk_64.dll /DELAYLOAD:nixnet.dll /DELAYLOAD:nixntipstack.dll") endif() #---------------------------------------------------------------------- @@ -520,9 +520,9 @@ add_custom_command( $/) if(WIN32) - target_link_libraries(SystemTestsRunner Delayimp nidaqmx nidcpower niDigital nidmm niFgen niRFmxBT niRFmxInstr niRFmxLTE niRFmxNR niRFmxSpecAn niRFmxWLAN niRFSA niRFSG niScope niswitch nisync niTClk nixnet nixntipstack) - set_target_properties(SystemTestsRunner PROPERTIES LINK_FLAGS "/DELAYLOAD:nicaiu.dll /DELAYLOAD:nidcpower.dll /DELAYLOAD:niDigital_64.dll /DELAYLOAD:nidmm_64.dll /DELAYLOAD:niFgen_64.dll /DELAYLOAD:niRFmxBT.dll /DELAYLOAD:niRFmxInstr.dll /DELAYLOAD:niRFmxLTE.dll /DELAYLOAD:niRFmxNR.dll /DELAYLOAD:niRFmxSpecAn.dll /DELAYLOAD:niRFmxWLAN.dll /DELAYLOAD:niRFSA_64.dll /DELAYLOAD:niRFSG_64.dll /DELAYLOAD:niScope.dll /DELAYLOAD:niswitch.dll /DELAYLOAD:nisync.dll /DELAYLOAD:niTClk_64.dll /DELAYLOAD:nixnet.dll /DELAYLOAD:nixntipstack.dll") - set(SystemTestsRunner CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /DELAYLOAD:nicaiu.dll /DELAYLOAD:nidcpower.dll /DELAYLOAD:niDigital_64.dll /DELAYLOAD:nidmm_64.dll /DELAYLOAD:niFgen_64.dll /DELAYLOAD:niRFmxBT.dll /DELAYLOAD:niRFmxInstr.dll /DELAYLOAD:niRFmxLTE.dll /DELAYLOAD:niRFmxNR.dll /DELAYLOAD:niRFmxSpecAn.dll /DELAYLOAD:niRFmxWLAN.dll /DELAYLOAD:niRFSA_64.dll /DELAYLOAD:niRFSG_64.dll /DELAYLOAD:niScope.dll /DELAYLOAD:niswitch.dll /DELAYLOAD:nisync.dll /DELAYLOAD:niTClk_64.dll /DELAYLOAD:nixnet.dll /DELAYLOAD:nixntipstack.dll") + target_link_libraries(SystemTestsRunner Delayimp nidaqmx nidcpower niDigital nidmm niFgen NiSpyLog niRFmxBT niRFmxInstr niRFmxLTE niRFmxNR niRFmxSpecAn niRFmxWLAN niRFSA niRFSG niScope niswitch nisync niTClk nixnet nixntipstack) + set_target_properties(SystemTestsRunner PROPERTIES LINK_FLAGS "/DELAYLOAD:nicaiu.dll /DELAYLOAD:nidcpower.dll /DELAYLOAD:niDigital_64.dll /DELAYLOAD:nidmm_64.dll /DELAYLOAD:niFgen_64.dll /DELAYLOAD:NiSpyLog.dll /DELAYLOAD:niRFmxBT.dll /DELAYLOAD:niRFmxInstr.dll /DELAYLOAD:niRFmxLTE.dll /DELAYLOAD:niRFmxNR.dll /DELAYLOAD:niRFmxSpecAn.dll /DELAYLOAD:niRFmxWLAN.dll /DELAYLOAD:niRFSA_64.dll /DELAYLOAD:niRFSG_64.dll /DELAYLOAD:niScope.dll /DELAYLOAD:niswitch.dll /DELAYLOAD:nisync.dll /DELAYLOAD:niTClk_64.dll /DELAYLOAD:nixnet.dll /DELAYLOAD:nixntipstack.dll") + set(SystemTestsRunner CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /DELAYLOAD:nicaiu.dll /DELAYLOAD:nidcpower.dll /DELAYLOAD:niDigital_64.dll /DELAYLOAD:nidmm_64.dll /DELAYLOAD:niFgen_64.dll /DELAYLOAD:NiSpyLog.dll /DELAYLOAD:niRFmxBT.dll /DELAYLOAD:niRFmxInstr.dll /DELAYLOAD:niRFmxLTE.dll /DELAYLOAD:niRFmxNR.dll /DELAYLOAD:niRFmxSpecAn.dll /DELAYLOAD:niRFmxWLAN.dll /DELAYLOAD:niRFSA_64.dll /DELAYLOAD:niRFSG_64.dll /DELAYLOAD:niScope.dll /DELAYLOAD:niswitch.dll /DELAYLOAD:nisync.dll /DELAYLOAD:niTClk_64.dll /DELAYLOAD:nixnet.dll /DELAYLOAD:nixntipstack.dll") endif() # Hook up different google test runners to CTest diff --git a/generated/niiotrace/niiotrace.proto b/generated/niiotrace/niiotrace.proto new file mode 100644 index 000000000..53a07b690 --- /dev/null +++ b/generated/niiotrace/niiotrace.proto @@ -0,0 +1,35 @@ + +//--------------------------------------------------------------------- +// This file is automatically generated. All manual edits will be lost. +//--------------------------------------------------------------------- +// Proto file for the NI-IOTRACE Metadata +//--------------------------------------------------------------------- +syntax = "proto3"; + +option java_multiple_files = true; +option java_package = "com.ni.grpc.iotrace"; +option java_outer_classname = "NiIOTrace"; +option csharp_namespace = "NationalInstruments.Grpc.IOTrace"; + +package niiotrace_grpc; + +import "session.proto"; + +service NiIOTrace { + rpc StartTracing(StartTracingRequest) returns (StartTracingResponse); +} + +enum NiIOTraceAttribute { + NIIOTRACE_ATTRIBUTE_UNSPECIFIED = 0; +} + +message StartTracingRequest { + int32 log_file_setting = 1; + string file_path_string = 2; + int32 file_write_mode = 3; +} + +message StartTracingResponse { + int32 status = 1; +} + diff --git a/generated/niiotrace/niiotrace_client.cpp b/generated/niiotrace/niiotrace_client.cpp new file mode 100644 index 000000000..4ad5295be --- /dev/null +++ b/generated/niiotrace/niiotrace_client.cpp @@ -0,0 +1,39 @@ + +//--------------------------------------------------------------------- +// This file is automatically generated. All manual edits will be lost. +//--------------------------------------------------------------------- +// EXPERIMENTAL Client convenience wrapper for NI-IOTRACE. +//--------------------------------------------------------------------- +#include "niiotrace_client.h" + +#include + +#include + +#include +#include +#include +#include + +namespace niiotrace_grpc::experimental::client { + +StartTracingResponse +start_tracing(const StubPtr& stub, const pb::int32& log_file_setting, const pb::string& file_path_string, const pb::int32& file_write_mode) +{ + ::grpc::ClientContext context; + + auto request = StartTracingRequest{}; + request.set_log_file_setting(log_file_setting); + request.set_file_path_string(file_path_string); + request.set_file_write_mode(file_write_mode); + + auto response = StartTracingResponse{}; + + raise_if_error( + stub->StartTracing(&context, request, &response)); + + return response; +} + + +} // namespace niiotrace_grpc::experimental::client diff --git a/generated/niiotrace/niiotrace_client.h b/generated/niiotrace/niiotrace_client.h new file mode 100644 index 000000000..499379e28 --- /dev/null +++ b/generated/niiotrace/niiotrace_client.h @@ -0,0 +1,29 @@ + +//--------------------------------------------------------------------- +// This file is automatically generated. All manual edits will be lost. +//--------------------------------------------------------------------- +// EXPERIMENTAL Client convenience wrapper for NI-IOTRACE. +//--------------------------------------------------------------------- +#ifndef NIIOTRACE_GRPC_CLIENT_H +#define NIIOTRACE_GRPC_CLIENT_H + +#include + +#include +#include + +#include +#include + +namespace niiotrace_grpc::experimental::client { + +namespace pb = ::google::protobuf; +using StubPtr = std::unique_ptr; +using namespace nidevice_grpc::experimental::client; + + +StartTracingResponse start_tracing(const StubPtr& stub, const pb::int32& log_file_setting, const pb::string& file_path_string, const pb::int32& file_write_mode); + +} // namespace niiotrace_grpc::experimental::client + +#endif /* NIIOTRACE_GRPC_CLIENT_H */ diff --git a/generated/niiotrace/niiotrace_library.cpp b/generated/niiotrace/niiotrace_library.cpp new file mode 100644 index 000000000..9845be757 --- /dev/null +++ b/generated/niiotrace/niiotrace_library.cpp @@ -0,0 +1,50 @@ +//--------------------------------------------------------------------- +// This file is automatically generated. All manual edits will be lost. +//--------------------------------------------------------------------- +// Service implementation for the NI-IOTRACE Metadata +//--------------------------------------------------------------------- +#include "niiotrace_library.h" + +#if defined(_MSC_VER) +static const char* kLibraryName = "NiSpyLog.dll"; +#else +static const char* kLibraryName = "liblibNiSpyLog.so"; +#endif + +namespace niiotrace_grpc { + +NiIOTraceLibrary::NiIOTraceLibrary() : shared_library_(kLibraryName) +{ + shared_library_.load(); + bool loaded = shared_library_.is_loaded(); + memset(&function_pointers_, 0, sizeof(function_pointers_)); + if (!loaded) { + return; + } + function_pointers_.StartTracing = reinterpret_cast(shared_library_.get_function_pointer("nispy_StartSpying")); +} + +NiIOTraceLibrary::~NiIOTraceLibrary() +{ +} + +::grpc::Status NiIOTraceLibrary::check_function_exists(std::string functionName) +{ + return shared_library_.function_exists(functionName.c_str()) + ? ::grpc::Status::OK + : ::grpc::Status(::grpc::NOT_FOUND, "Could not find the function " + functionName); +} + +int32_t NiIOTraceLibrary::StartTracing(int32_t logFileSetting, const char filePathString[], int32_t fileWriteMode) +{ + if (!function_pointers_.StartTracing) { + throw nidevice_grpc::LibraryLoadException("Could not find nispy_StartSpying."); + } +#if defined(_MSC_VER) + return nispy_StartSpying(static_cast(logFileSetting), filePathString, static_cast(fileWriteMode)); +#else + return function_pointers_.StartTracing(logFileSetting, filePathString, fileWriteMode); +#endif +} + +} // namespace niiotrace_grpc diff --git a/generated/niiotrace/niiotrace_library.h b/generated/niiotrace/niiotrace_library.h new file mode 100644 index 000000000..6e683c02c --- /dev/null +++ b/generated/niiotrace/niiotrace_library.h @@ -0,0 +1,36 @@ +//--------------------------------------------------------------------- +// This file is automatically generated. All manual edits will be lost. +//--------------------------------------------------------------------- +// Real implementation of LibraryInterface for NI-IOTRACE +//--------------------------------------------------------------------- +#ifndef NIIOTRACE_GRPC_LIBRARY_H +#define NIIOTRACE_GRPC_LIBRARY_H + +#include "niiotrace_library_interface.h" + +#include + +namespace niiotrace_grpc { + +class NiIOTraceLibrary : public niiotrace_grpc::NiIOTraceLibraryInterface { + public: + NiIOTraceLibrary(); + virtual ~NiIOTraceLibrary(); + + ::grpc::Status check_function_exists(std::string functionName); + int32_t StartTracing(int32_t logFileSetting, const char filePathString[], int32_t fileWriteMode); + + private: + using StartTracingPtr = decltype(&nispy_StartSpying); + + typedef struct FunctionPointers { + StartTracingPtr StartTracing; + } FunctionLoadStatus; + + nidevice_grpc::SharedLibrary shared_library_; + FunctionPointers function_pointers_; +}; + +} // namespace niiotrace_grpc + +#endif // NIIOTRACE_GRPC_LIBRARY_H diff --git a/generated/niiotrace/niiotrace_library_interface.h b/generated/niiotrace/niiotrace_library_interface.h new file mode 100644 index 000000000..3fe5863b0 --- /dev/null +++ b/generated/niiotrace/niiotrace_library_interface.h @@ -0,0 +1,22 @@ +//--------------------------------------------------------------------- +// This file is automatically generated. All manual edits will be lost. +//--------------------------------------------------------------------- +// Library wrapper for implementing interactions with NI-IOTRACE +//--------------------------------------------------------------------- +#ifndef NIIOTRACE_GRPC_LIBRARY_WRAPPER_H +#define NIIOTRACE_GRPC_LIBRARY_WRAPPER_H + +#include +#include + +namespace niiotrace_grpc { + +class NiIOTraceLibraryInterface { + public: + virtual ~NiIOTraceLibraryInterface() {} + + virtual int32_t StartTracing(int32_t logFileSetting, const char filePathString[], int32_t fileWriteMode) = 0; +}; + +} // namespace niiotrace_grpc +#endif // NIIOTRACE_GRPC_LIBRARY_WRAPPER_H diff --git a/generated/niiotrace/niiotrace_mock_library.h b/generated/niiotrace/niiotrace_mock_library.h new file mode 100644 index 000000000..810215a39 --- /dev/null +++ b/generated/niiotrace/niiotrace_mock_library.h @@ -0,0 +1,26 @@ +//--------------------------------------------------------------------- +// This file is automatically generated. All manual edits will be lost. +//--------------------------------------------------------------------- +// Mock of LibraryInterface for NI-IOTRACE +//--------------------------------------------------------------------- +#ifndef NIIOTRACE_GRPC_MOCK_LIBRARY_H +#define NIIOTRACE_GRPC_MOCK_LIBRARY_H + +#include +#include + +#include "niiotrace_library_interface.h" + +namespace ni { +namespace tests { +namespace unit { + +class NiIOTraceMockLibrary : public niiotrace_grpc::NiIOTraceLibraryInterface { + public: + MOCK_METHOD(int32_t, StartTracing, (int32_t logFileSetting, const char filePathString[], int32_t fileWriteMode), (override)); +}; + +} // namespace unit +} // namespace tests +} // namespace ni +#endif // NIIOTRACE_GRPC_MOCK_LIBRARY_H diff --git a/generated/niiotrace/niiotrace_service.cpp b/generated/niiotrace/niiotrace_service.cpp new file mode 100644 index 000000000..ee539882c --- /dev/null +++ b/generated/niiotrace/niiotrace_service.cpp @@ -0,0 +1,72 @@ + +//--------------------------------------------------------------------- +// This file is automatically generated. All manual edits will be lost. +//--------------------------------------------------------------------- +// Service implementation for the NI-IOTRACE Metadata +//--------------------------------------------------------------------- +#include "niiotrace_service.h" + +#include +#include +#include +#include +#include +#include + +namespace niiotrace_grpc { + + using nidevice_grpc::converters::allocate_output_storage; + using nidevice_grpc::converters::calculate_linked_array_size; + using nidevice_grpc::converters::convert_from_grpc; + using nidevice_grpc::converters::convert_to_grpc; + using nidevice_grpc::converters::MatchState; + + NiIOTraceService::NiIOTraceService( + NiIOTraceLibraryInterface* library, + ResourceRepositorySharedPtr resource_repository, + const NiIOTraceFeatureToggles& feature_toggles) + : library_(library), + session_repository_(resource_repository), + feature_toggles_(feature_toggles) + { + } + + NiIOTraceService::~NiIOTraceService() + { + } + + // Returns true if it's safe to use outputs of a method with the given status. + inline bool status_ok(int32 status) + { + return status >= 0; + } + + //--------------------------------------------------------------------- + //--------------------------------------------------------------------- + ::grpc::Status NiIOTraceService::StartTracing(::grpc::ServerContext* context, const StartTracingRequest* request, StartTracingResponse* response) + { + if (context->IsCancelled()) { + return ::grpc::Status::CANCELLED; + } + try { + int32_t log_file_setting = request->log_file_setting(); + auto file_path_string = request->file_path_string().c_str(); + int32_t file_write_mode = request->file_write_mode(); + auto status = library_->StartTracing(log_file_setting, file_path_string, file_write_mode); + response->set_status(status); + return ::grpc::Status::OK; + } + catch (nidevice_grpc::LibraryLoadException& ex) { + return ::grpc::Status(::grpc::NOT_FOUND, ex.what()); + } + } + + + NiIOTraceFeatureToggles::NiIOTraceFeatureToggles( + const nidevice_grpc::FeatureToggles& feature_toggles) + : is_enabled( + feature_toggles.is_feature_enabled("niiotrace", CodeReadiness::kRelease)) + { + } +} // namespace niiotrace_grpc + diff --git a/generated/niiotrace/niiotrace_service.h b/generated/niiotrace/niiotrace_service.h new file mode 100644 index 000000000..621109def --- /dev/null +++ b/generated/niiotrace/niiotrace_service.h @@ -0,0 +1,54 @@ + +//--------------------------------------------------------------------- +// This file is automatically generated. All manual edits will be lost. +//--------------------------------------------------------------------- +// Service header for the NI-IOTRACE Metadata +//--------------------------------------------------------------------- +#ifndef NIIOTRACE_GRPC_SERVICE_H +#define NIIOTRACE_GRPC_SERVICE_H + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "niiotrace_library_interface.h" + +namespace niiotrace_grpc { + +struct NiIOTraceFeatureToggles +{ + using CodeReadiness = nidevice_grpc::FeatureToggles::CodeReadiness; + NiIOTraceFeatureToggles(const nidevice_grpc::FeatureToggles& feature_toggles = {}); + + bool is_enabled; +}; + +class NiIOTraceService final : public NiIOTrace::Service { +public: + using ResourceRepositorySharedPtr = std::shared_ptr>; + + NiIOTraceService( + NiIOTraceLibraryInterface* library, + ResourceRepositorySharedPtr resource_repository, + const NiIOTraceFeatureToggles& feature_toggles = {}); + virtual ~NiIOTraceService(); + + ::grpc::Status StartTracing(::grpc::ServerContext* context, const StartTracingRequest* request, StartTracingResponse* response) override; +private: + NiIOTraceLibraryInterface* library_; + ResourceRepositorySharedPtr session_repository_; + + NiIOTraceFeatureToggles feature_toggles_; +}; + +} // namespace niiotrace_grpc + +#endif // NIIOTRACE_GRPC_SERVICE_H diff --git a/generated/niiotrace/niiotrace_service_registrar.cpp b/generated/niiotrace/niiotrace_service_registrar.cpp new file mode 100644 index 000000000..dbaa799fd --- /dev/null +++ b/generated/niiotrace/niiotrace_service_registrar.cpp @@ -0,0 +1,52 @@ + +//--------------------------------------------------------------------- +// This file is automatically generated. All manual edits will be lost. +//--------------------------------------------------------------------- +// Service registrar implementation for the NI-IOTRACE Metadata +//--------------------------------------------------------------------- +#include "niiotrace_library.h" + +#include + +#include "niiotrace_service.h" +#include "niiotrace_service_registrar.h" + +namespace niiotrace_grpc { + +namespace { +struct LibraryAndService { + LibraryAndService( + const std::shared_ptr>& resource_repository, + const NiIOTraceFeatureToggles& feature_toggles) + : library(), + service( + &library, + resource_repository, + feature_toggles) { + } + NiIOTraceLibrary library; + NiIOTraceService service; +}; +} + +std::shared_ptr register_service( + grpc::ServerBuilder& builder, + const std::shared_ptr>& resource_repository, + const nidevice_grpc::FeatureToggles& feature_toggles) +{ + auto toggles = NiIOTraceFeatureToggles(feature_toggles); + + if (toggles.is_enabled) + { + auto library_and_service_ptr = std::make_shared( + resource_repository, + toggles); + auto& service = library_and_service_ptr->service; + builder.RegisterService(&service); + return library_and_service_ptr; + } + + return {}; +} + +} // niiotrace_grpc diff --git a/generated/niiotrace/niiotrace_service_registrar.h b/generated/niiotrace/niiotrace_service_registrar.h new file mode 100644 index 000000000..2825bcd0f --- /dev/null +++ b/generated/niiotrace/niiotrace_service_registrar.h @@ -0,0 +1,30 @@ + +//--------------------------------------------------------------------- +// This file is automatically generated. All manual edits will be lost. +//--------------------------------------------------------------------- +// Service registrar header for the NI-IOTRACE Metadata +//--------------------------------------------------------------------- +#ifndef NIIOTRACE_GRPC_SERVICE_REGISTRAR_H +#define NIIOTRACE_GRPC_SERVICE_REGISTRAR_H +#include +#include + +#include + +#include // for ViSession + +namespace grpc { +class ServerBuilder; +} + +namespace niiotrace_grpc { +using CodeReadiness = nidevice_grpc::FeatureToggles::CodeReadiness; + +std::shared_ptr register_service( + grpc::ServerBuilder& server_builder, + const std::shared_ptr>& resource_repository, + const nidevice_grpc::FeatureToggles& feature_toggles); + +} // niiotrace_grpc + +#endif // NIIOTRACE_GRPC_SERVICE_REGISTRAR_H diff --git a/generated/register_all_services.cpp b/generated/register_all_services.cpp index b6f61bc52..1016199a4 100644 --- a/generated/register_all_services.cpp +++ b/generated/register_all_services.cpp @@ -16,6 +16,7 @@ #include "nidigitalpattern/nidigitalpattern_service_registrar.h" #include "nidmm/nidmm_service_registrar.h" #include "nifgen/nifgen_service_registrar.h" +#include "niiotrace/niiotrace_service_registrar.h" #if defined(_MSC_VER) #include "nirfmxbluetooth/nirfmxbluetooth_service_registrar.h" #endif // defined(_MSC_VER) @@ -92,6 +93,11 @@ std::shared_ptr register_all_services( server_builder, vi_session_repository, feature_toggles)); + service_vector->push_back( + niiotrace_grpc::register_service( + server_builder, + vi_session_repository, + feature_toggles)); #if defined(_MSC_VER) service_vector->push_back( nirfmxbluetooth_grpc::register_service( diff --git a/imports/include/NiSpyAPI.h b/imports/include/NiSpyAPI.h new file mode 100644 index 000000000..e3081a8e7 --- /dev/null +++ b/imports/include/NiSpyAPI.h @@ -0,0 +1,118 @@ +/* NiSpyAPI.h */ +/* */ +/* This file is the main include file for using the NI Spy Programmatic API. */ +/* */ +/* Contained within this header are the functions to be called by a client */ +/* application as well as enumerations detailing parameters and error return */ +/* values. */ + +#if !defined(_NI_SPY_API_H_) +#define _NI_SPY_API_H_ + +#include + +#if defined(WIN32) || defined(_WIN32) || defined(_WIN64) + #define NISPY_API_APITYPE __stdcall + #if defined(NISPY_EXPORT_CWRAPPER) + #define NISPY_API_CWRAPPER __declspec(dllexport) + #else + #define NISPY_API_CWRAPPER __declspec(dllimport) + #endif + #define NISPY_API_CWRAPPER_END +#else + #define NISPY_API_APITYPE + #define NISPY_API_CWRAPPER + #if defined(__MACH__) + #define NISPY_API_CWRAPPER_END __attribute__((weak_import)) + #else + #define NISPY_API_CWRAPPER_END + #endif +#endif + +/* This enum corresponds to the logFileSetting specified in nispy_StartSpying */ +enum eNiSpyLogFileSetting +{ + klogFileSettingNoFile = -1, + kLogFileSettingSpy, + kLogFileSettingPlainText, + kLogFileSettingCommaSeparated, + kLogFileSettingXml +}; + +#if !defined(__cplusplus) && !defined(__cplusplus__) +typedef enum eNiSpyLogFileSetting eNiSpyLogFileSetting; +#endif + +/* This enum represents the error codes returned by the Spy API calls */ +enum eNiSpyAPICommandStatus +{ + kCommandSuccess = 0, + kCommandFailedNoExecute = -303200, + kCommandFailedIncompatibleState = -303201, + kCommandFailedUnableToOpenLogFile = -303202, + kCommandFailedSpyGUIClosed = -303203, + kCommandFailedInvalidSettings = -303204, + kCommandFailedBadParameter = -303205, + kCommandFailedInternalFailure = -303206, + kCommandFailedInvalidFileExtension = -303207, + kCommandFailedBufferTooSmall = -303208, + kCommandFailedFileAlreadyExists = -303209 +}; + +#if !defined(__cplusplus) && !defined(__cplusplus__) +typedef enum eNiSpyAPICommandStatus eNiSpyAPICommandStatus; +#endif + +/* This enum represents the valid write modes for the nispy_StartSpying call */ +enum eNiSpyAPIFileWriteMode +{ + kCreateOnly = 0, + kCreateOrAppend, + kCreateOrOverwrite +}; + +#if !defined(__cplusplus) && !defined(__cplusplus__) +typedef enum eNiSpyAPIFileWriteMode eNiSpyAPIFileWriteMode; +#endif + +/* Functions supported by the NI Spy Programmatic API begin here */ +#if defined(__cplusplus) || defined(__cplusplus__) +extern "C" { +#endif + +/* nispy_GetApplicationPath returns the path to the application for launch. + It is the user's responsibility to actually launch the application. */ +NISPY_API_CWRAPPER eNiSpyAPICommandStatus NISPY_API_APITYPE + nispy_GetApplicationPath(char * pathString, size_t pathStringSize) +NISPY_API_CWRAPPER_END; + +/* nispy_StartSpying initiates spying on calls. This command will only succeed + if NI Spy has been launched. logFileSetting specifies how the log should be + stored to file and filePathString is a path to the desired log file. + For overwriteFile, zero is false (append) and any nonzero value is true. */ +NISPY_API_CWRAPPER eNiSpyAPICommandStatus NISPY_API_APITYPE + nispy_StartSpying(eNiSpyLogFileSetting logFileSetting, const char * filePathString, eNiSpyAPIFileWriteMode fileWriteMode ) +NISPY_API_CWRAPPER_END; + +/* nispy_StopSpying halts spying on calls. */ +NISPY_API_CWRAPPER eNiSpyAPICommandStatus NISPY_API_APITYPE + nispy_StopSpying(void) +NISPY_API_CWRAPPER_END; + +/* nispy_WriteTextEntry places a debug message into the current Spy log. + This message also gets exported to the log file if logging to a file. */ +NISPY_API_CWRAPPER eNiSpyAPICommandStatus NISPY_API_APITYPE + nispy_WriteTextEntry(const char * message) +NISPY_API_CWRAPPER_END; + +/* nispy_CloseSpy closes the NI Spy application. This implies that logging is halted + and the program will need to be relaunched if more calls need to be logged. */ +NISPY_API_CWRAPPER eNiSpyAPICommandStatus NISPY_API_APITYPE + nispy_CloseSpy(void) +NISPY_API_CWRAPPER_END; + +#if defined(__cplusplus) || defined(__cplusplus__) +} /* extern "C" closing brace */ +#endif + +#endif diff --git a/imports/lib/win64/NiSpyLog.lib b/imports/lib/win64/NiSpyLog.lib new file mode 100644 index 0000000000000000000000000000000000000000..b222949613ea4a7753407fcecb463e10023a8973 GIT binary patch literal 21250 zcmd5^O>7)R7Jm7M5KKq{Ss)=!Fp2YnGvj#1c78lPw#Ts(+nLx-VnCbm*lx!o>=|oj z9BraVi#Q;V_P`M#j%bevA%xH#5aPsXl|!`RfcCIL5eE*O5JCv{RaaNftM00ro^)Hg zExq(q)$8}Y`hWFaIfu^|s|(8mJ5RUEPcqfr*PTlDrO(Lu2{)Nar~3HMxt##;F2JcT z0lIz!NOS;XZ*m&KB1Y*vr|vZXMrW2e^~?b;dcZ0D5al4{ ze&y6V58%)*_(tmcfm8pt0F2Il!>JE38TBI;qqBKV=PUq5=X*Gv`vTKQ$=_Xi6W>UK z_c#sR#rh!S<~R+14#3Fzgww!w0EbY<0Mh73oW?r=7>y=4jlBiH=<;Wr@+gndm7h3` z+y-ED3G2sb;(bn+?qeG1vc+lqLzIg&(ave|HvmRg?s2;KH2|YY>?4QX!8g*y>zqcg zEg6mNbLnS%BW1C@84VxclvxB|WVLZR|1q`~(uE~XSI+}5%A;c7e#)p& z7@NpnnVKmK=cb3I#_}^)rV5j#>9srKm0M6KOkNuw4|2d?1q)}G8ND`nxiFla$wFpi zWxcj+4P|izmu}mZbv2jG&d$DuvP!FK1#NL=$}TSYKg;K`vtyR`t%)U*Ny(VmT=sgx zV*h43rt8&G`PN{uW?RFB8-*LzVr{`Hmn^Fx`%ypF;|_-q&Uo|^MnXtnJbDSEAtW#! zy@X34BrqPmgj@&-j7KlwVh9P0M=ya4B5g-A9=(LiA#`9odI^OvA{?g7jcTcG2PeZI zoeV~vOeU?K4TB+P!y|sK!KG6{DVfg$Wf7eOS_Ta+9sbI1`Pf$$(SfgJ(BRS`ul$ye zcV!VB>{S29Uv}GCXDjvxWii`Dugz!xT2hmPKu94-_ri?&IO5;MbgtzNC%X{}*UvFl@^*H~AsuB}+z z#N>!sYG$Zv7umK!Fq@4cjgC0mW=CmbZiMI<^=*v7_!LE%PD75A%B9-!gk7uQd~~f? zMS+twWiQxh^rGpk;13oOG1>gsP-S(sSY8Z5kTU0si+0`R9b8|+wTONZD5H82LEIYG z6gt^#HoGu2iXi2?oH%#YthB)49a^>*-WV&_>c#Sc)S7aE!;5vfZdYriN}1x5T#jzn zN7l;=)9VWh*hiFeS}t+8Cn}5BJqyLUPpXvfaOSHOCJ_5FS1!)4NXiDvs3uc(eZ5-F zt=Ow}xjtRGYZq?WWxHBhQ0S)T4N7b(#$yoQ>ZOzJ$5ztw$&x$()#qNJ^G&Y2$fZg> zLUM)Ve6d%uPR2BQt|PaRTc%jM##a!C&u1cgaFY2)FR*m3a*%%EcKpy#te zwaWxll5CU+5^(=*^h7x18$CIv&9iHznLBIfh8SfQmb-9{v9{0MG#h! zVOI@^Q0NkDH)df``&_@nMwA~>^Ds6*7!5r+xb3gqDc~IP%}CG|@KuKw53N*cHja6h z+e=a&=LkPz|D~QQ*Q2DU4eWXOD;G3_xna$5H)r#-Lo2mpL}3gE{sfQ|&f z%`9f1GdZ6ISnCE@J_9h<12CIH9!!6a>F+T80MieV=hqy-d@sN+NI&!eeA^H3%~|{w zf6w9XJpQ)Mp??|umS5oe_awlZNcRQ-?jp_{e*gI}z$fTy-9CUkNFR*?bdIBs8{cn@ z0ep5D`SJiiT>-d_3eR5xcz*)mKE5q1`w)5CG5y;l%0-^9F9Phu-|rw@$KMa}n|&zf zXQT&MzXOQ3m;q=*%#Ts8r3>h1y^8V>BS@cO`dw^_gKz+Lz!UHo?1IPPN!ST( zupOR)r(q8~3wvQd?1MkSGw>X|0MCO3S$GLLU;r|31h&F?coDY2A-DjCp&fR^Dd>kj zNWn398O}l{oP$^3G$i0S9EBuwLl>l>7tTNroP-mw2{!*v@rPg#Mj!{nI3UEYE$9zx zcC=QX+jZVtv&YozM>P9N%^pOvm(=V#H2X)*Uc)B-x+d;MjlU+FYvu>kd}#2~8C+Vt z-IabJ-ss9AgKy5@#^P(Bwl%?Ex^?$ta8MaQX1IfSnyY7j`(LY9^xTnTx z!^L57nPh0&Y*y1~%q8w&AkN755u|S!?wy1gLzK7sgC}Rj)EZ|s<|FY9higJb5d~x*~9fHad2*RH??sD zn<02%vUkMiIvyHs((%wRnvREto^(7kq^9GcVJICB4X^2Vh$}-IwQXV_HETNRE>TCP zn%hbOLuorSjcn1*Q%aycr(~errevUfrevTUrevVKrDUL8rDTwu2%Tc<<(S0t%0JkPa5jd4J^qVh zu<`bq zKu>Ek$^slVjqtEq`m9I_AlZ^qK_F)8^9FO~P#$D5+1z2tKhrpUeSTvft`us9=eW?8DT4d3m zj%hcEzD0n)iG=&MVE15GX|Y%@cA(dpKl||YPo)32=`HxSAn}#Uhu&!Zw6PcB2|kvz zp#7`O_}+_NT=wjul{yA{ckjT=`%V!$hVlKu%{>#Pg=(c%S*o{pP91L_ADcv9bMV=P zSxgf~fIeULYd8M8&G|)PP>Y4i>Kdy1!OcyZ{`iA_gUrD6+YF-C7J#GivdD4j$B|r~ z9>#+ofya|->u}G((yjFn_{ocFoXZbeP5W?ILv72P9$&VS4r;YN5S=y|d+Z>kH1ZeQSQ~LG(?y!YJ=dMnY`-{fS)PlZd$4LDZe-*=bmUZh0J= zu(ueo*+F~bu(ukq*%^N0u(uhpnR{U4u(unrndf2Suy+`-nNwrqupcvGGk?j(VLxuf zX0DiM*!|)U%6#h?2F5X>%~llM{BGinlhmS#Fgt%*v(BADt)4Jy<@l8-oYX#HuuUzp z%fVJUy_)+DBWab^^iwCc$dh`l0*f$JB1~(TaNG2_fdx2D+^6)ofyFmY+}(QIz``3R z?$dhQz@i%`?jAjEV8M+Ocds5du-L|lyHAfBSZG_u_5O}GXh%Jx$8}xl6b&yhxqq`6 z_SBsg$0*+#e;n72XZ6^@rL<+_WVficTOR0hDr4b@MqNUU=t0sL)8!o zil(jjKNb9^`=hAsi%eTxgh_&>iBNMRp`OjNhj#uvDvs!3~57(IKt)vF?N{IoMY z!^OiQ>5$gwZ~}EW%yck?*&-pE<{G=v8^>)cNx_zP+kP?CeEU3JZpOREs9}VtU^LB= zh84BL(Ja2d35}+ysSRJ|nu=hFYUS52S&?@olQ--r)65thjn*nD&8%z3k#!8Q9qDq^ zRRW}mFe{Dc`1g(ELx|TY@aQfqt!1t6qdj5)_Te2syyF6|5hSM7k&wgGtw$IaJ}edk zI6<&@OtL1)Z@p%zlzPp63DHgpv_MQ-s$k3OkZH7>k}*ZBTmqzts4e=6hv&O=>3ZGc zZP6})76|RrI<<~z8lR^n%*KULQ9+6vwKWq2OWZ`D@>{Q&X{ILynsmbhO z`u*tYCT_jPz3RQ}G}ibm!PMXSp|yO3wMx_CY#yHr;HxW5H3-$t2FvTbhbdiBq7bc* zW6d09me+*_9=ZD@!L{6{rk!m7@qBliBruu?)s`A7kDcx_9u{uh{=WjIK(V%{<)P9W pU=m!*Et=9qir77fEWs1U7^y;1B2=4dB6aLW!k~xdyHF-o@V^w;w+jFO literal 0 HcmV?d00001 diff --git a/source/codegen/metadata/niiotrace/CHANGES.md b/source/codegen/metadata/niiotrace/CHANGES.md new file mode 100644 index 000000000..e69de29bb diff --git a/source/codegen/metadata/niiotrace/__init__.py b/source/codegen/metadata/niiotrace/__init__.py new file mode 100644 index 000000000..479c7c96a --- /dev/null +++ b/source/codegen/metadata/niiotrace/__init__.py @@ -0,0 +1,11 @@ +from .functions import functions +from .attributes import attributes +from .enums import enums +from .config import config + +metadata = { + "functions" : functions, + "attributes" : attributes, + "enums" : enums, + "config" : config +} \ No newline at end of file diff --git a/source/codegen/metadata/niiotrace/attributes.py b/source/codegen/metadata/niiotrace/attributes.py new file mode 100644 index 000000000..4395c908a --- /dev/null +++ b/source/codegen/metadata/niiotrace/attributes.py @@ -0,0 +1,2 @@ +# -*- coding: utf-8 -*- +attributes = {} diff --git a/source/codegen/metadata/niiotrace/attributes_addon.py b/source/codegen/metadata/niiotrace/attributes_addon.py new file mode 100644 index 000000000..65af90534 --- /dev/null +++ b/source/codegen/metadata/niiotrace/attributes_addon.py @@ -0,0 +1,6 @@ +# These dictionaries are applied to the generated attributes dictionary at build time +# Any changes to the API should be made here. attributes.py is code generated + +attributes_override_metadata = { +} + diff --git a/source/codegen/metadata/niiotrace/config.py b/source/codegen/metadata/niiotrace/config.py new file mode 100644 index 000000000..316816228 --- /dev/null +++ b/source/codegen/metadata/niiotrace/config.py @@ -0,0 +1,30 @@ +# -*- coding: utf-8 -*- +# This file is generated from NI-IO Trace API metadata version 18.2 +config = { + "api_version": "18.2", + "c_header": "NiSpyAPI.h", + "c_function_prefix": "nispy_", + "service_class_prefix": "NiIOTrace", + "java_package": "com.ni.grpc.iotrace", + "csharp_namespace": "NationalInstruments.Grpc.IOTrace", + "namespace_component": "niiotrace", + "close_function": "Close", + "custom_types": [], + "type_to_grpc_type": { + "char[]": "string", + "int32_t": "int32", + "int": "int32", + }, + "driver_name": "NI-IOTRACE", + "init_function": "InitWithOptions", + "status_ok": "status >= 0", + "library_info": { + "Linux": {"64bit": {"name": "libNiSpyLog", "type": "cdll"}}, + "Windows": { + "32bit": {"name": "NiSpyLog.dll", "type": "windll"}, + "64bit": {"name": "NiSpyLog.dll", "type": "cdll"}, + }, + }, + "metadata_version": "2.0", + "module_name": "niiotrace", +} diff --git a/source/codegen/metadata/niiotrace/config_addon.py b/source/codegen/metadata/niiotrace/config_addon.py new file mode 100644 index 000000000..e5928fb3f --- /dev/null +++ b/source/codegen/metadata/niiotrace/config_addon.py @@ -0,0 +1,2 @@ +# We need to maintain the version here since it needs to be updated by the build process on GitHub +config_additional_config = {} diff --git a/source/codegen/metadata/niiotrace/enums.py b/source/codegen/metadata/niiotrace/enums.py new file mode 100644 index 000000000..4b9db3c2e --- /dev/null +++ b/source/codegen/metadata/niiotrace/enums.py @@ -0,0 +1,3 @@ +# -*- coding: utf-8 -*- +# This file is generated from NI-SCOPE API metadata version 20.5.0d7 +enums = {} diff --git a/source/codegen/metadata/niiotrace/enums_addon.py b/source/codegen/metadata/niiotrace/enums_addon.py new file mode 100644 index 000000000..2ecd181b7 --- /dev/null +++ b/source/codegen/metadata/niiotrace/enums_addon.py @@ -0,0 +1,6 @@ +# These dictionaries are applied to the generated enums dictionary at build time +# Any changes to the API should be made here. enums.py is code generated + +enums_override_metadata = { +} + diff --git a/source/codegen/metadata/niiotrace/functions.py b/source/codegen/metadata/niiotrace/functions.py new file mode 100644 index 000000000..3e6aae9c4 --- /dev/null +++ b/source/codegen/metadata/niiotrace/functions.py @@ -0,0 +1,25 @@ +# -*- coding: utf-8 -*- +# This file is generated from NI-SCOPE API metadata version 20.5.0d7 +functions = { + 'StartTracing': { + 'cname': 'nispy_StartSpying', + 'parameters': [ + { + 'direction': 'in', + 'name': 'logFileSetting', + 'type': 'int32_t' + }, + { + 'direction': 'in', + 'name': 'filePathString', + 'type': 'const char[]' + }, + { + 'direction': 'in', + 'name': 'fileWriteMode', + 'type': 'int32_t' + } + ], + 'returns': 'int32_t' + }, +} diff --git a/source/codegen/metadata/niiotrace/functions_addon.py b/source/codegen/metadata/niiotrace/functions_addon.py new file mode 100644 index 000000000..cca5b4cec --- /dev/null +++ b/source/codegen/metadata/niiotrace/functions_addon.py @@ -0,0 +1,5 @@ +# These dictionaries are merged with the extracted function metadata at build time. +# Changes to the metadata should be made here, because functions.py is generated thus any changes get overwritten. + +functions_override_metadata = { +} diff --git a/source/custom/niiotrace_service.custom.cpp b/source/custom/niiotrace_service.custom.cpp new file mode 100644 index 000000000..57c75703f --- /dev/null +++ b/source/custom/niiotrace_service.custom.cpp @@ -0,0 +1,5 @@ +#include + +namespace niiotrace_grpc { + +} // namespace niiotrace_grpc From 46f07839c215d6b6e8718abfd625aa6019932cc1 Mon Sep 17 00:00:00 2001 From: Ryan Eckenrode Date: Wed, 30 Mar 2022 16:26:45 -0500 Subject: [PATCH 02/18] Add a test for the first function. --- CMakeLists.txt | 1 + .../system/ni_io_trace_driver_api_tests.cpp | 83 +++++++++++++++++++ 2 files changed, 84 insertions(+) create mode 100644 source/tests/system/ni_io_trace_driver_api_tests.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index d21fdcf8d..3f0c00e63 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -460,6 +460,7 @@ set(system_test_runner_sources "source/tests/system/nidmm_session_tests.cpp" "source/tests/system/nifgen_driver_api_tests.cpp" "source/tests/system/nifgen_session_tests.cpp" + "source/tests/system/ni_io_trace_driver_api_tests.cpp" "source/tests/system/nirfsa_driver_api_tests.cpp" "source/tests/system/nirfsg_driver_api_tests.cpp" "source/tests/system/nirfsg_session_tests.cpp" diff --git a/source/tests/system/ni_io_trace_driver_api_tests.cpp b/source/tests/system/ni_io_trace_driver_api_tests.cpp new file mode 100644 index 000000000..de2a79950 --- /dev/null +++ b/source/tests/system/ni_io_trace_driver_api_tests.cpp @@ -0,0 +1,83 @@ +#include +#include +#include + +#include +#include +#include +#include + +#include "device_server.h" +#include "enumerate_devices.h" +#include "niRFSAErrors.h" +#include "nirfsa/nirfsa_client.h" +#include "niscope/niscope_client.h" +#include "nitclk/nitclk_client.h" + +using namespace niiotrace_grpc; +namespace client = niiotrace_grpc::experimental::client; +namespace pb = google::protobuf; +using namespace ::testing; +using nlohmann::json; +using namespace std::string_literals; // for trailing ""s string literal syntax; + +namespace ni { +namespace tests { +namespace system { +namespace { + +class NiIOTraceDriverApiTests : public ::testing::Test { + protected: + NiIOTraceDriverApiTests() + : device_server_(DeviceServerInterface::Singleton()), + stub_(NiIOTrace::NewStub(device_server_->InProcessChannel())) + { + device_server_->ResetServer(); + } + virtual ~NiIOTraceDriverApiTests() {} + + void TearDown() override + { + device_server_->ResetServer(); + } + + template + std::unique_ptr create_stub() + { + return TService::NewStub(device_server_->InProcessChannel()); + } + + std::unique_ptr& stub() + { + return stub_; + } + + private: + DeviceServerInterface* device_server_; + std::unique_ptr stub_; +}; + +TEST_F(NiIOTraceDriverApiTests, IOTraceIsStarted_StartTracing_Success) +{ + // Pre-requisite for test, start the IO Trace application + + std::string path = "C:\\Users\\reckenro\\Documents\\text-output.txt"; + auto start_tracing_response = client::start_tracing(stub(), 1, path, 1); + + EXPECT_EQ(0, start_tracing_response.status()); +} + +TEST_F(NiIOTraceDriverApiTests, IOTraceIsStarted_StartTracingWithInvalidArgs_InvalidArgsResponse) +{ + // Pre-requisite for test, start the IO Trace application + + std::string path = ""; // Empty string not allowed for file path. + auto start_tracing_response = client::start_tracing(stub(), 1, path, 1); + + EXPECT_EQ(0, start_tracing_response.status()); +} + +} // namespace +} // namespace system +} // namespace tests +} // namespace ni From 1af6c1affd0f021efb38392268bacdb54e25d18c Mon Sep 17 00:00:00 2001 From: Ryan Eckenrode Date: Wed, 30 Mar 2022 17:17:31 -0500 Subject: [PATCH 03/18] Handful of updates (ni-io to just io, fix enum conversion gen, test cleanup) --- CMakeLists.txt | 4 +-- .../niiotrace.proto => iotrace/iotrace.proto} | 12 +++---- .../iotrace_client.cpp} | 10 +++--- .../iotrace_client.h} | 16 ++++----- .../iotrace_library.cpp} | 18 +++++----- .../iotrace_library.h} | 22 ++++++------ generated/iotrace/iotrace_library_interface.h | 22 ++++++++++++ .../iotrace_mock_library.h} | 14 ++++---- .../iotrace_service.cpp} | 26 +++++++------- .../iotrace_service.h} | 36 +++++++++---------- .../iotrace_service_registrar.cpp} | 24 ++++++------- .../iotrace_service_registrar.h} | 16 ++++----- .../niiotrace/niiotrace_library_interface.h | 22 ------------ generated/register_all_services.cpp | 13 +++---- .../{niiotrace => iotrace}/CHANGES.md | 0 .../{niiotrace => iotrace}/__init__.py | 0 .../{niiotrace => iotrace}/attributes.py | 0 .../attributes_addon.py | 0 .../metadata/{niiotrace => iotrace}/config.py | 16 +++++---- .../{niiotrace => iotrace}/config_addon.py | 0 .../metadata/{niiotrace => iotrace}/enums.py | 0 .../{niiotrace => iotrace}/enums_addon.py | 0 .../{niiotrace => iotrace}/functions.py | 6 ++-- .../{niiotrace => iotrace}/functions_addon.py | 0 source/custom/iotrace_service.custom.cpp | 5 +++ source/custom/niiotrace_service.custom.cpp | 5 --- ...r_api_tests.cpp => io_trace_api_tests.cpp} | 24 ++++++------- 27 files changed, 158 insertions(+), 153 deletions(-) rename generated/{niiotrace/niiotrace.proto => iotrace/iotrace.proto} (79%) rename generated/{niiotrace/niiotrace_client.cpp => iotrace/iotrace_client.cpp} (80%) rename generated/{niiotrace/niiotrace_client.h => iotrace/iotrace_client.h} (65%) rename generated/{niiotrace/niiotrace_library.cpp => iotrace/iotrace_library.cpp} (66%) rename generated/{niiotrace/niiotrace_library.h => iotrace/iotrace_library.h} (57%) create mode 100644 generated/iotrace/iotrace_library_interface.h rename generated/{niiotrace/niiotrace_mock_library.h => iotrace/iotrace_mock_library.h} (52%) rename generated/{niiotrace/niiotrace_service.cpp => iotrace/iotrace_service.cpp} (69%) rename generated/{niiotrace/niiotrace_service.h => iotrace/iotrace_service.h} (59%) rename generated/{niiotrace/niiotrace_service_registrar.cpp => iotrace/iotrace_service_registrar.cpp} (70%) rename generated/{niiotrace/niiotrace_service_registrar.h => iotrace/iotrace_service_registrar.h} (69%) delete mode 100644 generated/niiotrace/niiotrace_library_interface.h rename source/codegen/metadata/{niiotrace => iotrace}/CHANGES.md (100%) rename source/codegen/metadata/{niiotrace => iotrace}/__init__.py (100%) rename source/codegen/metadata/{niiotrace => iotrace}/attributes.py (100%) rename source/codegen/metadata/{niiotrace => iotrace}/attributes_addon.py (100%) rename source/codegen/metadata/{niiotrace => iotrace}/config.py (59%) rename source/codegen/metadata/{niiotrace => iotrace}/config_addon.py (100%) rename source/codegen/metadata/{niiotrace => iotrace}/enums.py (100%) rename source/codegen/metadata/{niiotrace => iotrace}/enums_addon.py (100%) rename source/codegen/metadata/{niiotrace => iotrace}/functions.py (74%) rename source/codegen/metadata/{niiotrace => iotrace}/functions_addon.py (100%) create mode 100644 source/custom/iotrace_service.custom.cpp delete mode 100644 source/custom/niiotrace_service.custom.cpp rename source/tests/system/{ni_io_trace_driver_api_tests.cpp => io_trace_api_tests.cpp} (71%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3f0c00e63..083ac7b16 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -76,7 +76,7 @@ set(metadata_dir ${CMAKE_SOURCE_DIR}/source/codegen/metadata) set(service_output_dir ${CMAKE_SOURCE_DIR}/generated) set(codegen_dir ${CMAKE_SOURCE_DIR}/source/codegen) set(custom_dir ${CMAKE_SOURCE_DIR}/source/custom) -set(nidrivers "nidaqmx" "nidcpower" "nidigitalpattern" "nidmm" "nifake" "nifake_extension" "nifake_non_ivi" "nifgen" "niiotrace" "nirfmxbluetooth" "nirfmxinstr" "nirfmxlte" "nirfmxnr" "nirfmxspecan" "nirfmxwlan" "nirfsa" "nirfsg" "niscope" "niswitch" "nisync" "nitclk" "nixnet" "nixnetsocket") +set(nidrivers "iotrace" "nidaqmx" "nidcpower" "nidigitalpattern" "nidmm" "nifake" "nifake_extension" "nifake_non_ivi" "nifgen" "nirfmxbluetooth" "nirfmxinstr" "nirfmxlte" "nirfmxnr" "nirfmxspecan" "nirfmxwlan" "nirfsa" "nirfsg" "niscope" "niswitch" "nisync" "nitclk" "nixnet" "nixnetsocket") #---------------------------------------------------------------------- # Create NI Driver APIs proto and server files @@ -460,7 +460,7 @@ set(system_test_runner_sources "source/tests/system/nidmm_session_tests.cpp" "source/tests/system/nifgen_driver_api_tests.cpp" "source/tests/system/nifgen_session_tests.cpp" - "source/tests/system/ni_io_trace_driver_api_tests.cpp" + "source/tests/system/io_trace_api_tests.cpp" "source/tests/system/nirfsa_driver_api_tests.cpp" "source/tests/system/nirfsg_driver_api_tests.cpp" "source/tests/system/nirfsg_session_tests.cpp" diff --git a/generated/niiotrace/niiotrace.proto b/generated/iotrace/iotrace.proto similarity index 79% rename from generated/niiotrace/niiotrace.proto rename to generated/iotrace/iotrace.proto index 53a07b690..0a032dee6 100644 --- a/generated/niiotrace/niiotrace.proto +++ b/generated/iotrace/iotrace.proto @@ -2,25 +2,25 @@ //--------------------------------------------------------------------- // This file is automatically generated. All manual edits will be lost. //--------------------------------------------------------------------- -// Proto file for the NI-IOTRACE Metadata +// Proto file for the IO-TRACE Metadata //--------------------------------------------------------------------- syntax = "proto3"; option java_multiple_files = true; option java_package = "com.ni.grpc.iotrace"; -option java_outer_classname = "NiIOTrace"; +option java_outer_classname = "IOTrace"; option csharp_namespace = "NationalInstruments.Grpc.IOTrace"; -package niiotrace_grpc; +package iotrace_grpc; import "session.proto"; -service NiIOTrace { +service IOTrace { rpc StartTracing(StartTracingRequest) returns (StartTracingResponse); } -enum NiIOTraceAttribute { - NIIOTRACE_ATTRIBUTE_UNSPECIFIED = 0; +enum IOTraceAttribute { + IOTRACE_ATTRIBUTE_UNSPECIFIED = 0; } message StartTracingRequest { diff --git a/generated/niiotrace/niiotrace_client.cpp b/generated/iotrace/iotrace_client.cpp similarity index 80% rename from generated/niiotrace/niiotrace_client.cpp rename to generated/iotrace/iotrace_client.cpp index 4ad5295be..1f0d41917 100644 --- a/generated/niiotrace/niiotrace_client.cpp +++ b/generated/iotrace/iotrace_client.cpp @@ -2,20 +2,20 @@ //--------------------------------------------------------------------- // This file is automatically generated. All manual edits will be lost. //--------------------------------------------------------------------- -// EXPERIMENTAL Client convenience wrapper for NI-IOTRACE. +// EXPERIMENTAL Client convenience wrapper for IO-TRACE. //--------------------------------------------------------------------- -#include "niiotrace_client.h" +#include "iotrace_client.h" #include -#include +#include #include #include #include #include -namespace niiotrace_grpc::experimental::client { +namespace iotrace_grpc::experimental::client { StartTracingResponse start_tracing(const StubPtr& stub, const pb::int32& log_file_setting, const pb::string& file_path_string, const pb::int32& file_write_mode) @@ -36,4 +36,4 @@ start_tracing(const StubPtr& stub, const pb::int32& log_file_setting, const pb:: } -} // namespace niiotrace_grpc::experimental::client +} // namespace iotrace_grpc::experimental::client diff --git a/generated/niiotrace/niiotrace_client.h b/generated/iotrace/iotrace_client.h similarity index 65% rename from generated/niiotrace/niiotrace_client.h rename to generated/iotrace/iotrace_client.h index 499379e28..031e98ad8 100644 --- a/generated/niiotrace/niiotrace_client.h +++ b/generated/iotrace/iotrace_client.h @@ -2,28 +2,28 @@ //--------------------------------------------------------------------- // This file is automatically generated. All manual edits will be lost. //--------------------------------------------------------------------- -// EXPERIMENTAL Client convenience wrapper for NI-IOTRACE. +// EXPERIMENTAL Client convenience wrapper for IO-TRACE. //--------------------------------------------------------------------- -#ifndef NIIOTRACE_GRPC_CLIENT_H -#define NIIOTRACE_GRPC_CLIENT_H +#ifndef IOTRACE_GRPC_CLIENT_H +#define IOTRACE_GRPC_CLIENT_H #include -#include +#include #include #include #include -namespace niiotrace_grpc::experimental::client { +namespace iotrace_grpc::experimental::client { namespace pb = ::google::protobuf; -using StubPtr = std::unique_ptr; +using StubPtr = std::unique_ptr; using namespace nidevice_grpc::experimental::client; StartTracingResponse start_tracing(const StubPtr& stub, const pb::int32& log_file_setting, const pb::string& file_path_string, const pb::int32& file_write_mode); -} // namespace niiotrace_grpc::experimental::client +} // namespace iotrace_grpc::experimental::client -#endif /* NIIOTRACE_GRPC_CLIENT_H */ +#endif /* IOTRACE_GRPC_CLIENT_H */ diff --git a/generated/niiotrace/niiotrace_library.cpp b/generated/iotrace/iotrace_library.cpp similarity index 66% rename from generated/niiotrace/niiotrace_library.cpp rename to generated/iotrace/iotrace_library.cpp index 9845be757..d5c57dfce 100644 --- a/generated/niiotrace/niiotrace_library.cpp +++ b/generated/iotrace/iotrace_library.cpp @@ -1,9 +1,9 @@ //--------------------------------------------------------------------- // This file is automatically generated. All manual edits will be lost. //--------------------------------------------------------------------- -// Service implementation for the NI-IOTRACE Metadata +// Service implementation for the IO-TRACE Metadata //--------------------------------------------------------------------- -#include "niiotrace_library.h" +#include "iotrace_library.h" #if defined(_MSC_VER) static const char* kLibraryName = "NiSpyLog.dll"; @@ -11,9 +11,9 @@ static const char* kLibraryName = "NiSpyLog.dll"; static const char* kLibraryName = "liblibNiSpyLog.so"; #endif -namespace niiotrace_grpc { +namespace iotrace_grpc { -NiIOTraceLibrary::NiIOTraceLibrary() : shared_library_(kLibraryName) +IOTraceLibrary::IOTraceLibrary() : shared_library_(kLibraryName) { shared_library_.load(); bool loaded = shared_library_.is_loaded(); @@ -24,27 +24,27 @@ NiIOTraceLibrary::NiIOTraceLibrary() : shared_library_(kLibraryName) function_pointers_.StartTracing = reinterpret_cast(shared_library_.get_function_pointer("nispy_StartSpying")); } -NiIOTraceLibrary::~NiIOTraceLibrary() +IOTraceLibrary::~IOTraceLibrary() { } -::grpc::Status NiIOTraceLibrary::check_function_exists(std::string functionName) +::grpc::Status IOTraceLibrary::check_function_exists(std::string functionName) { return shared_library_.function_exists(functionName.c_str()) ? ::grpc::Status::OK : ::grpc::Status(::grpc::NOT_FOUND, "Could not find the function " + functionName); } -int32_t NiIOTraceLibrary::StartTracing(int32_t logFileSetting, const char filePathString[], int32_t fileWriteMode) +int32_t IOTraceLibrary::StartTracing(eNiSpyLogFileSetting logFileSetting, const char filePathString[], eNiSpyAPIFileWriteMode fileWriteMode) { if (!function_pointers_.StartTracing) { throw nidevice_grpc::LibraryLoadException("Could not find nispy_StartSpying."); } #if defined(_MSC_VER) - return nispy_StartSpying(static_cast(logFileSetting), filePathString, static_cast(fileWriteMode)); + return nispy_StartSpying(logFileSetting, filePathString, fileWriteMode); #else return function_pointers_.StartTracing(logFileSetting, filePathString, fileWriteMode); #endif } -} // namespace niiotrace_grpc +} // namespace iotrace_grpc diff --git a/generated/niiotrace/niiotrace_library.h b/generated/iotrace/iotrace_library.h similarity index 57% rename from generated/niiotrace/niiotrace_library.h rename to generated/iotrace/iotrace_library.h index 6e683c02c..99019f0c0 100644 --- a/generated/niiotrace/niiotrace_library.h +++ b/generated/iotrace/iotrace_library.h @@ -1,24 +1,24 @@ //--------------------------------------------------------------------- // This file is automatically generated. All manual edits will be lost. //--------------------------------------------------------------------- -// Real implementation of LibraryInterface for NI-IOTRACE +// Real implementation of LibraryInterface for IO-TRACE //--------------------------------------------------------------------- -#ifndef NIIOTRACE_GRPC_LIBRARY_H -#define NIIOTRACE_GRPC_LIBRARY_H +#ifndef IOTRACE_GRPC_LIBRARY_H +#define IOTRACE_GRPC_LIBRARY_H -#include "niiotrace_library_interface.h" +#include "iotrace_library_interface.h" #include -namespace niiotrace_grpc { +namespace iotrace_grpc { -class NiIOTraceLibrary : public niiotrace_grpc::NiIOTraceLibraryInterface { +class IOTraceLibrary : public iotrace_grpc::IOTraceLibraryInterface { public: - NiIOTraceLibrary(); - virtual ~NiIOTraceLibrary(); + IOTraceLibrary(); + virtual ~IOTraceLibrary(); ::grpc::Status check_function_exists(std::string functionName); - int32_t StartTracing(int32_t logFileSetting, const char filePathString[], int32_t fileWriteMode); + int32_t StartTracing(eNiSpyLogFileSetting logFileSetting, const char filePathString[], eNiSpyAPIFileWriteMode fileWriteMode); private: using StartTracingPtr = decltype(&nispy_StartSpying); @@ -31,6 +31,6 @@ class NiIOTraceLibrary : public niiotrace_grpc::NiIOTraceLibraryInterface { FunctionPointers function_pointers_; }; -} // namespace niiotrace_grpc +} // namespace iotrace_grpc -#endif // NIIOTRACE_GRPC_LIBRARY_H +#endif // IOTRACE_GRPC_LIBRARY_H diff --git a/generated/iotrace/iotrace_library_interface.h b/generated/iotrace/iotrace_library_interface.h new file mode 100644 index 000000000..93e325712 --- /dev/null +++ b/generated/iotrace/iotrace_library_interface.h @@ -0,0 +1,22 @@ +//--------------------------------------------------------------------- +// This file is automatically generated. All manual edits will be lost. +//--------------------------------------------------------------------- +// Library wrapper for implementing interactions with IO-TRACE +//--------------------------------------------------------------------- +#ifndef IOTRACE_GRPC_LIBRARY_WRAPPER_H +#define IOTRACE_GRPC_LIBRARY_WRAPPER_H + +#include +#include + +namespace iotrace_grpc { + +class IOTraceLibraryInterface { + public: + virtual ~IOTraceLibraryInterface() {} + + virtual int32_t StartTracing(eNiSpyLogFileSetting logFileSetting, const char filePathString[], eNiSpyAPIFileWriteMode fileWriteMode) = 0; +}; + +} // namespace iotrace_grpc +#endif // IOTRACE_GRPC_LIBRARY_WRAPPER_H diff --git a/generated/niiotrace/niiotrace_mock_library.h b/generated/iotrace/iotrace_mock_library.h similarity index 52% rename from generated/niiotrace/niiotrace_mock_library.h rename to generated/iotrace/iotrace_mock_library.h index 810215a39..2f38edcbe 100644 --- a/generated/niiotrace/niiotrace_mock_library.h +++ b/generated/iotrace/iotrace_mock_library.h @@ -1,26 +1,26 @@ //--------------------------------------------------------------------- // This file is automatically generated. All manual edits will be lost. //--------------------------------------------------------------------- -// Mock of LibraryInterface for NI-IOTRACE +// Mock of LibraryInterface for IO-TRACE //--------------------------------------------------------------------- -#ifndef NIIOTRACE_GRPC_MOCK_LIBRARY_H -#define NIIOTRACE_GRPC_MOCK_LIBRARY_H +#ifndef IOTRACE_GRPC_MOCK_LIBRARY_H +#define IOTRACE_GRPC_MOCK_LIBRARY_H #include #include -#include "niiotrace_library_interface.h" +#include "iotrace_library_interface.h" namespace ni { namespace tests { namespace unit { -class NiIOTraceMockLibrary : public niiotrace_grpc::NiIOTraceLibraryInterface { +class IOTraceMockLibrary : public iotrace_grpc::IOTraceLibraryInterface { public: - MOCK_METHOD(int32_t, StartTracing, (int32_t logFileSetting, const char filePathString[], int32_t fileWriteMode), (override)); + MOCK_METHOD(int32_t, StartTracing, (eNiSpyLogFileSetting logFileSetting, const char filePathString[], eNiSpyAPIFileWriteMode fileWriteMode), (override)); }; } // namespace unit } // namespace tests } // namespace ni -#endif // NIIOTRACE_GRPC_MOCK_LIBRARY_H +#endif // IOTRACE_GRPC_MOCK_LIBRARY_H diff --git a/generated/niiotrace/niiotrace_service.cpp b/generated/iotrace/iotrace_service.cpp similarity index 69% rename from generated/niiotrace/niiotrace_service.cpp rename to generated/iotrace/iotrace_service.cpp index ee539882c..ef5711d28 100644 --- a/generated/niiotrace/niiotrace_service.cpp +++ b/generated/iotrace/iotrace_service.cpp @@ -2,9 +2,9 @@ //--------------------------------------------------------------------- // This file is automatically generated. All manual edits will be lost. //--------------------------------------------------------------------- -// Service implementation for the NI-IOTRACE Metadata +// Service implementation for the IO-TRACE Metadata //--------------------------------------------------------------------- -#include "niiotrace_service.h" +#include "iotrace_service.h" #include #include @@ -13,7 +13,7 @@ #include #include -namespace niiotrace_grpc { +namespace iotrace_grpc { using nidevice_grpc::converters::allocate_output_storage; using nidevice_grpc::converters::calculate_linked_array_size; @@ -21,17 +21,17 @@ namespace niiotrace_grpc { using nidevice_grpc::converters::convert_to_grpc; using nidevice_grpc::converters::MatchState; - NiIOTraceService::NiIOTraceService( - NiIOTraceLibraryInterface* library, + IOTraceService::IOTraceService( + IOTraceLibraryInterface* library, ResourceRepositorySharedPtr resource_repository, - const NiIOTraceFeatureToggles& feature_toggles) + const IOTraceFeatureToggles& feature_toggles) : library_(library), session_repository_(resource_repository), feature_toggles_(feature_toggles) { } - NiIOTraceService::~NiIOTraceService() + IOTraceService::~IOTraceService() { } @@ -43,15 +43,15 @@ namespace niiotrace_grpc { //--------------------------------------------------------------------- //--------------------------------------------------------------------- - ::grpc::Status NiIOTraceService::StartTracing(::grpc::ServerContext* context, const StartTracingRequest* request, StartTracingResponse* response) + ::grpc::Status IOTraceService::StartTracing(::grpc::ServerContext* context, const StartTracingRequest* request, StartTracingResponse* response) { if (context->IsCancelled()) { return ::grpc::Status::CANCELLED; } try { - int32_t log_file_setting = request->log_file_setting(); + auto log_file_setting = convert_from_grpc(request->log_file_setting()); auto file_path_string = request->file_path_string().c_str(); - int32_t file_write_mode = request->file_write_mode(); + auto file_write_mode = convert_from_grpc(request->file_write_mode()); auto status = library_->StartTracing(log_file_setting, file_path_string, file_write_mode); response->set_status(status); return ::grpc::Status::OK; @@ -62,11 +62,11 @@ namespace niiotrace_grpc { } - NiIOTraceFeatureToggles::NiIOTraceFeatureToggles( + IOTraceFeatureToggles::IOTraceFeatureToggles( const nidevice_grpc::FeatureToggles& feature_toggles) : is_enabled( - feature_toggles.is_feature_enabled("niiotrace", CodeReadiness::kRelease)) + feature_toggles.is_feature_enabled("iotrace", CodeReadiness::kRelease)) { } -} // namespace niiotrace_grpc +} // namespace iotrace_grpc diff --git a/generated/niiotrace/niiotrace_service.h b/generated/iotrace/iotrace_service.h similarity index 59% rename from generated/niiotrace/niiotrace_service.h rename to generated/iotrace/iotrace_service.h index 621109def..b233f70f8 100644 --- a/generated/niiotrace/niiotrace_service.h +++ b/generated/iotrace/iotrace_service.h @@ -2,12 +2,12 @@ //--------------------------------------------------------------------- // This file is automatically generated. All manual edits will be lost. //--------------------------------------------------------------------- -// Service header for the NI-IOTRACE Metadata +// Service header for the IO-TRACE Metadata //--------------------------------------------------------------------- -#ifndef NIIOTRACE_GRPC_SERVICE_H -#define NIIOTRACE_GRPC_SERVICE_H +#ifndef IOTRACE_GRPC_SERVICE_H +#define IOTRACE_GRPC_SERVICE_H -#include +#include #include #include #include @@ -19,36 +19,36 @@ #include #include -#include "niiotrace_library_interface.h" +#include "iotrace_library_interface.h" -namespace niiotrace_grpc { +namespace iotrace_grpc { -struct NiIOTraceFeatureToggles +struct IOTraceFeatureToggles { using CodeReadiness = nidevice_grpc::FeatureToggles::CodeReadiness; - NiIOTraceFeatureToggles(const nidevice_grpc::FeatureToggles& feature_toggles = {}); + IOTraceFeatureToggles(const nidevice_grpc::FeatureToggles& feature_toggles = {}); bool is_enabled; }; -class NiIOTraceService final : public NiIOTrace::Service { +class IOTraceService final : public IOTrace::Service { public: - using ResourceRepositorySharedPtr = std::shared_ptr>; + using ResourceRepositorySharedPtr = std::shared_ptr>; - NiIOTraceService( - NiIOTraceLibraryInterface* library, + IOTraceService( + IOTraceLibraryInterface* library, ResourceRepositorySharedPtr resource_repository, - const NiIOTraceFeatureToggles& feature_toggles = {}); - virtual ~NiIOTraceService(); + const IOTraceFeatureToggles& feature_toggles = {}); + virtual ~IOTraceService(); ::grpc::Status StartTracing(::grpc::ServerContext* context, const StartTracingRequest* request, StartTracingResponse* response) override; private: - NiIOTraceLibraryInterface* library_; + IOTraceLibraryInterface* library_; ResourceRepositorySharedPtr session_repository_; - NiIOTraceFeatureToggles feature_toggles_; + IOTraceFeatureToggles feature_toggles_; }; -} // namespace niiotrace_grpc +} // namespace iotrace_grpc -#endif // NIIOTRACE_GRPC_SERVICE_H +#endif // IOTRACE_GRPC_SERVICE_H diff --git a/generated/niiotrace/niiotrace_service_registrar.cpp b/generated/iotrace/iotrace_service_registrar.cpp similarity index 70% rename from generated/niiotrace/niiotrace_service_registrar.cpp rename to generated/iotrace/iotrace_service_registrar.cpp index dbaa799fd..88df32e5a 100644 --- a/generated/niiotrace/niiotrace_service_registrar.cpp +++ b/generated/iotrace/iotrace_service_registrar.cpp @@ -2,39 +2,39 @@ //--------------------------------------------------------------------- // This file is automatically generated. All manual edits will be lost. //--------------------------------------------------------------------- -// Service registrar implementation for the NI-IOTRACE Metadata +// Service registrar implementation for the IO-TRACE Metadata //--------------------------------------------------------------------- -#include "niiotrace_library.h" +#include "iotrace_library.h" #include -#include "niiotrace_service.h" -#include "niiotrace_service_registrar.h" +#include "iotrace_service.h" +#include "iotrace_service_registrar.h" -namespace niiotrace_grpc { +namespace iotrace_grpc { namespace { struct LibraryAndService { LibraryAndService( - const std::shared_ptr>& resource_repository, - const NiIOTraceFeatureToggles& feature_toggles) + const std::shared_ptr>& resource_repository, + const IOTraceFeatureToggles& feature_toggles) : library(), service( &library, resource_repository, feature_toggles) { } - NiIOTraceLibrary library; - NiIOTraceService service; + IOTraceLibrary library; + IOTraceService service; }; } std::shared_ptr register_service( grpc::ServerBuilder& builder, - const std::shared_ptr>& resource_repository, + const std::shared_ptr>& resource_repository, const nidevice_grpc::FeatureToggles& feature_toggles) { - auto toggles = NiIOTraceFeatureToggles(feature_toggles); + auto toggles = IOTraceFeatureToggles(feature_toggles); if (toggles.is_enabled) { @@ -49,4 +49,4 @@ std::shared_ptr register_service( return {}; } -} // niiotrace_grpc +} // iotrace_grpc diff --git a/generated/niiotrace/niiotrace_service_registrar.h b/generated/iotrace/iotrace_service_registrar.h similarity index 69% rename from generated/niiotrace/niiotrace_service_registrar.h rename to generated/iotrace/iotrace_service_registrar.h index 2825bcd0f..dd60c407a 100644 --- a/generated/niiotrace/niiotrace_service_registrar.h +++ b/generated/iotrace/iotrace_service_registrar.h @@ -2,29 +2,29 @@ //--------------------------------------------------------------------- // This file is automatically generated. All manual edits will be lost. //--------------------------------------------------------------------- -// Service registrar header for the NI-IOTRACE Metadata +// Service registrar header for the IO-TRACE Metadata //--------------------------------------------------------------------- -#ifndef NIIOTRACE_GRPC_SERVICE_REGISTRAR_H -#define NIIOTRACE_GRPC_SERVICE_REGISTRAR_H +#ifndef IOTRACE_GRPC_SERVICE_REGISTRAR_H +#define IOTRACE_GRPC_SERVICE_REGISTRAR_H #include #include #include -#include // for ViSession +#include // for int32_t namespace grpc { class ServerBuilder; } -namespace niiotrace_grpc { +namespace iotrace_grpc { using CodeReadiness = nidevice_grpc::FeatureToggles::CodeReadiness; std::shared_ptr register_service( grpc::ServerBuilder& server_builder, - const std::shared_ptr>& resource_repository, + const std::shared_ptr>& resource_repository, const nidevice_grpc::FeatureToggles& feature_toggles); -} // niiotrace_grpc +} // iotrace_grpc -#endif // NIIOTRACE_GRPC_SERVICE_REGISTRAR_H +#endif // IOTRACE_GRPC_SERVICE_REGISTRAR_H diff --git a/generated/niiotrace/niiotrace_library_interface.h b/generated/niiotrace/niiotrace_library_interface.h deleted file mode 100644 index 3fe5863b0..000000000 --- a/generated/niiotrace/niiotrace_library_interface.h +++ /dev/null @@ -1,22 +0,0 @@ -//--------------------------------------------------------------------- -// This file is automatically generated. All manual edits will be lost. -//--------------------------------------------------------------------- -// Library wrapper for implementing interactions with NI-IOTRACE -//--------------------------------------------------------------------- -#ifndef NIIOTRACE_GRPC_LIBRARY_WRAPPER_H -#define NIIOTRACE_GRPC_LIBRARY_WRAPPER_H - -#include -#include - -namespace niiotrace_grpc { - -class NiIOTraceLibraryInterface { - public: - virtual ~NiIOTraceLibraryInterface() {} - - virtual int32_t StartTracing(int32_t logFileSetting, const char filePathString[], int32_t fileWriteMode) = 0; -}; - -} // namespace niiotrace_grpc -#endif // NIIOTRACE_GRPC_LIBRARY_WRAPPER_H diff --git a/generated/register_all_services.cpp b/generated/register_all_services.cpp index 1016199a4..5753719ba 100644 --- a/generated/register_all_services.cpp +++ b/generated/register_all_services.cpp @@ -11,12 +11,12 @@ #include #include +#include "iotrace/iotrace_service_registrar.h" #include "nidaqmx/nidaqmx_service_registrar.h" #include "nidcpower/nidcpower_service_registrar.h" #include "nidigitalpattern/nidigitalpattern_service_registrar.h" #include "nidmm/nidmm_service_registrar.h" #include "nifgen/nifgen_service_registrar.h" -#include "niiotrace/niiotrace_service_registrar.h" #if defined(_MSC_VER) #include "nirfmxbluetooth/nirfmxbluetooth_service_registrar.h" #endif // defined(_MSC_VER) @@ -58,6 +58,7 @@ std::shared_ptr register_all_services( service_vector->end(), {session_repository, core_service}); + auto int32_t_repository = std::make_shared>(session_repository.get()); auto task_handle_repository = std::make_shared>(session_repository.get()); auto vi_session_repository = std::make_shared>(session_repository.get()); #if defined(_MSC_VER) @@ -68,6 +69,11 @@ std::shared_ptr register_all_services( auto nx_socket_repository = std::make_shared>(session_repository.get()); auto nx_ip_stack_ref_t_repository = std::make_shared>(session_repository.get()); + service_vector->push_back( + iotrace_grpc::register_service( + server_builder, + int32_t_repository, + feature_toggles)); service_vector->push_back( nidaqmx_grpc::register_service( server_builder, @@ -93,11 +99,6 @@ std::shared_ptr register_all_services( server_builder, vi_session_repository, feature_toggles)); - service_vector->push_back( - niiotrace_grpc::register_service( - server_builder, - vi_session_repository, - feature_toggles)); #if defined(_MSC_VER) service_vector->push_back( nirfmxbluetooth_grpc::register_service( diff --git a/source/codegen/metadata/niiotrace/CHANGES.md b/source/codegen/metadata/iotrace/CHANGES.md similarity index 100% rename from source/codegen/metadata/niiotrace/CHANGES.md rename to source/codegen/metadata/iotrace/CHANGES.md diff --git a/source/codegen/metadata/niiotrace/__init__.py b/source/codegen/metadata/iotrace/__init__.py similarity index 100% rename from source/codegen/metadata/niiotrace/__init__.py rename to source/codegen/metadata/iotrace/__init__.py diff --git a/source/codegen/metadata/niiotrace/attributes.py b/source/codegen/metadata/iotrace/attributes.py similarity index 100% rename from source/codegen/metadata/niiotrace/attributes.py rename to source/codegen/metadata/iotrace/attributes.py diff --git a/source/codegen/metadata/niiotrace/attributes_addon.py b/source/codegen/metadata/iotrace/attributes_addon.py similarity index 100% rename from source/codegen/metadata/niiotrace/attributes_addon.py rename to source/codegen/metadata/iotrace/attributes_addon.py diff --git a/source/codegen/metadata/niiotrace/config.py b/source/codegen/metadata/iotrace/config.py similarity index 59% rename from source/codegen/metadata/niiotrace/config.py rename to source/codegen/metadata/iotrace/config.py index 316816228..e0a415a34 100644 --- a/source/codegen/metadata/niiotrace/config.py +++ b/source/codegen/metadata/iotrace/config.py @@ -1,22 +1,24 @@ # -*- coding: utf-8 -*- -# This file is generated from NI-IO Trace API metadata version 18.2 +# This file is generated from IOO Trace API metadata version 18.2 config = { "api_version": "18.2", "c_header": "NiSpyAPI.h", "c_function_prefix": "nispy_", - "service_class_prefix": "NiIOTrace", + "service_class_prefix": "IOTrace", "java_package": "com.ni.grpc.iotrace", "csharp_namespace": "NationalInstruments.Grpc.IOTrace", - "namespace_component": "niiotrace", - "close_function": "Close", + "namespace_component": "iotrace", + "close_function": "Doesn't matter, there isn't one", + "resource_handle_type": "int32_t", # Note: This api shouldn't have "sessions", this is just to appease the build temporarily. "custom_types": [], "type_to_grpc_type": { "char[]": "string", "int32_t": "int32", "int": "int32", + "eNiSpyLogFileSetting": "int32", + "eNiSpyAPIFileWriteMode": "int32", }, - "driver_name": "NI-IOTRACE", - "init_function": "InitWithOptions", + "driver_name": "IO-TRACE", "status_ok": "status >= 0", "library_info": { "Linux": {"64bit": {"name": "libNiSpyLog", "type": "cdll"}}, @@ -26,5 +28,5 @@ }, }, "metadata_version": "2.0", - "module_name": "niiotrace", + "module_name": "iotrace", } diff --git a/source/codegen/metadata/niiotrace/config_addon.py b/source/codegen/metadata/iotrace/config_addon.py similarity index 100% rename from source/codegen/metadata/niiotrace/config_addon.py rename to source/codegen/metadata/iotrace/config_addon.py diff --git a/source/codegen/metadata/niiotrace/enums.py b/source/codegen/metadata/iotrace/enums.py similarity index 100% rename from source/codegen/metadata/niiotrace/enums.py rename to source/codegen/metadata/iotrace/enums.py diff --git a/source/codegen/metadata/niiotrace/enums_addon.py b/source/codegen/metadata/iotrace/enums_addon.py similarity index 100% rename from source/codegen/metadata/niiotrace/enums_addon.py rename to source/codegen/metadata/iotrace/enums_addon.py diff --git a/source/codegen/metadata/niiotrace/functions.py b/source/codegen/metadata/iotrace/functions.py similarity index 74% rename from source/codegen/metadata/niiotrace/functions.py rename to source/codegen/metadata/iotrace/functions.py index 3e6aae9c4..a0edaa17e 100644 --- a/source/codegen/metadata/niiotrace/functions.py +++ b/source/codegen/metadata/iotrace/functions.py @@ -7,7 +7,8 @@ { 'direction': 'in', 'name': 'logFileSetting', - 'type': 'int32_t' + 'type': 'eNiSpyLogFileSetting', + 'supports_standard_copy_convert': True, }, { 'direction': 'in', @@ -17,7 +18,8 @@ { 'direction': 'in', 'name': 'fileWriteMode', - 'type': 'int32_t' + 'type': 'eNiSpyAPIFileWriteMode', + 'supports_standard_copy_convert': True } ], 'returns': 'int32_t' diff --git a/source/codegen/metadata/niiotrace/functions_addon.py b/source/codegen/metadata/iotrace/functions_addon.py similarity index 100% rename from source/codegen/metadata/niiotrace/functions_addon.py rename to source/codegen/metadata/iotrace/functions_addon.py diff --git a/source/custom/iotrace_service.custom.cpp b/source/custom/iotrace_service.custom.cpp new file mode 100644 index 000000000..6dbfaaa6a --- /dev/null +++ b/source/custom/iotrace_service.custom.cpp @@ -0,0 +1,5 @@ +#include + +namespace iotrace_grpc { + +} // namespace iotrace_grpc diff --git a/source/custom/niiotrace_service.custom.cpp b/source/custom/niiotrace_service.custom.cpp deleted file mode 100644 index 57c75703f..000000000 --- a/source/custom/niiotrace_service.custom.cpp +++ /dev/null @@ -1,5 +0,0 @@ -#include - -namespace niiotrace_grpc { - -} // namespace niiotrace_grpc diff --git a/source/tests/system/ni_io_trace_driver_api_tests.cpp b/source/tests/system/io_trace_api_tests.cpp similarity index 71% rename from source/tests/system/ni_io_trace_driver_api_tests.cpp rename to source/tests/system/io_trace_api_tests.cpp index de2a79950..62838b2df 100644 --- a/source/tests/system/ni_io_trace_driver_api_tests.cpp +++ b/source/tests/system/io_trace_api_tests.cpp @@ -1,6 +1,6 @@ #include #include -#include +#include #include #include @@ -14,8 +14,8 @@ #include "niscope/niscope_client.h" #include "nitclk/nitclk_client.h" -using namespace niiotrace_grpc; -namespace client = niiotrace_grpc::experimental::client; +using namespace iotrace_grpc; +namespace client = iotrace_grpc::experimental::client; namespace pb = google::protobuf; using namespace ::testing; using nlohmann::json; @@ -26,15 +26,15 @@ namespace tests { namespace system { namespace { -class NiIOTraceDriverApiTests : public ::testing::Test { +class IOTraceApiTests : public ::testing::Test { protected: - NiIOTraceDriverApiTests() + IOTraceApiTests() : device_server_(DeviceServerInterface::Singleton()), - stub_(NiIOTrace::NewStub(device_server_->InProcessChannel())) + stub_(IOTrace::NewStub(device_server_->InProcessChannel())) { device_server_->ResetServer(); } - virtual ~NiIOTraceDriverApiTests() {} + virtual ~IOTraceApiTests() {} void TearDown() override { @@ -47,17 +47,17 @@ class NiIOTraceDriverApiTests : public ::testing::Test { return TService::NewStub(device_server_->InProcessChannel()); } - std::unique_ptr& stub() + std::unique_ptr& stub() { return stub_; } private: DeviceServerInterface* device_server_; - std::unique_ptr stub_; + std::unique_ptr stub_; }; -TEST_F(NiIOTraceDriverApiTests, IOTraceIsStarted_StartTracing_Success) +TEST_F(IOTraceApiTests, IOTraceIsStarted_StartTracing_Success) { // Pre-requisite for test, start the IO Trace application @@ -67,14 +67,14 @@ TEST_F(NiIOTraceDriverApiTests, IOTraceIsStarted_StartTracing_Success) EXPECT_EQ(0, start_tracing_response.status()); } -TEST_F(NiIOTraceDriverApiTests, IOTraceIsStarted_StartTracingWithInvalidArgs_InvalidArgsResponse) +TEST_F(IOTraceApiTests, IOTraceIsStarted_StartTracingWithInvalidArgs_InvalidArgsResponse) { // Pre-requisite for test, start the IO Trace application std::string path = ""; // Empty string not allowed for file path. auto start_tracing_response = client::start_tracing(stub(), 1, path, 1); - EXPECT_EQ(0, start_tracing_response.status()); + EXPECT_EQ(-303204, start_tracing_response.status()); } } // namespace From 7fa71cb6bc0c6685023a3e0da1838aa47d1c985c Mon Sep 17 00:00:00 2001 From: Ryan Eckenrode Date: Wed, 30 Mar 2022 17:29:35 -0500 Subject: [PATCH 04/18] GetApplicationPath --- generated/iotrace/iotrace.proto | 9 ++++++++ generated/iotrace/iotrace_client.cpp | 15 ++++++++++++ generated/iotrace/iotrace_client.h | 1 + generated/iotrace/iotrace_library.cpp | 13 +++++++++++ generated/iotrace/iotrace_library.h | 3 +++ generated/iotrace/iotrace_library_interface.h | 1 + generated/iotrace/iotrace_mock_library.h | 1 + generated/iotrace/iotrace_service.cpp | 23 +++++++++++++++++++ generated/iotrace/iotrace_service.h | 1 + source/codegen/metadata/iotrace/functions.py | 22 ++++++++++++++++++ 10 files changed, 89 insertions(+) diff --git a/generated/iotrace/iotrace.proto b/generated/iotrace/iotrace.proto index 0a032dee6..6fa0bcb5d 100644 --- a/generated/iotrace/iotrace.proto +++ b/generated/iotrace/iotrace.proto @@ -16,6 +16,7 @@ package iotrace_grpc; import "session.proto"; service IOTrace { + rpc GetApplicationPath(GetApplicationPathRequest) returns (GetApplicationPathResponse); rpc StartTracing(StartTracingRequest) returns (StartTracingResponse); } @@ -23,6 +24,14 @@ enum IOTraceAttribute { IOTRACE_ATTRIBUTE_UNSPECIFIED = 0; } +message GetApplicationPathRequest { +} + +message GetApplicationPathResponse { + int32 status = 1; + string path_string = 2; +} + message StartTracingRequest { int32 log_file_setting = 1; string file_path_string = 2; diff --git a/generated/iotrace/iotrace_client.cpp b/generated/iotrace/iotrace_client.cpp index 1f0d41917..8eb5aeac7 100644 --- a/generated/iotrace/iotrace_client.cpp +++ b/generated/iotrace/iotrace_client.cpp @@ -17,6 +17,21 @@ namespace iotrace_grpc::experimental::client { +GetApplicationPathResponse +get_application_path(const StubPtr& stub) +{ + ::grpc::ClientContext context; + + auto request = GetApplicationPathRequest{}; + + auto response = GetApplicationPathResponse{}; + + raise_if_error( + stub->GetApplicationPath(&context, request, &response)); + + return response; +} + StartTracingResponse start_tracing(const StubPtr& stub, const pb::int32& log_file_setting, const pb::string& file_path_string, const pb::int32& file_write_mode) { diff --git a/generated/iotrace/iotrace_client.h b/generated/iotrace/iotrace_client.h index 031e98ad8..5c89dcadb 100644 --- a/generated/iotrace/iotrace_client.h +++ b/generated/iotrace/iotrace_client.h @@ -22,6 +22,7 @@ using StubPtr = std::unique_ptr; using namespace nidevice_grpc::experimental::client; +GetApplicationPathResponse get_application_path(const StubPtr& stub); StartTracingResponse start_tracing(const StubPtr& stub, const pb::int32& log_file_setting, const pb::string& file_path_string, const pb::int32& file_write_mode); } // namespace iotrace_grpc::experimental::client diff --git a/generated/iotrace/iotrace_library.cpp b/generated/iotrace/iotrace_library.cpp index d5c57dfce..2cea8e411 100644 --- a/generated/iotrace/iotrace_library.cpp +++ b/generated/iotrace/iotrace_library.cpp @@ -21,6 +21,7 @@ IOTraceLibrary::IOTraceLibrary() : shared_library_(kLibraryName) if (!loaded) { return; } + function_pointers_.GetApplicationPath = reinterpret_cast(shared_library_.get_function_pointer("nispy_GetApplicationPath")); function_pointers_.StartTracing = reinterpret_cast(shared_library_.get_function_pointer("nispy_StartSpying")); } @@ -35,6 +36,18 @@ ::grpc::Status IOTraceLibrary::check_function_exists(std::string functionName) : ::grpc::Status(::grpc::NOT_FOUND, "Could not find the function " + functionName); } +int32_t IOTraceLibrary::GetApplicationPath(char pathString[256], int32_t pathStringSize) +{ + if (!function_pointers_.GetApplicationPath) { + throw nidevice_grpc::LibraryLoadException("Could not find nispy_GetApplicationPath."); + } +#if defined(_MSC_VER) + return nispy_GetApplicationPath(pathString, pathStringSize); +#else + return function_pointers_.GetApplicationPath(pathString, pathStringSize); +#endif +} + int32_t IOTraceLibrary::StartTracing(eNiSpyLogFileSetting logFileSetting, const char filePathString[], eNiSpyAPIFileWriteMode fileWriteMode) { if (!function_pointers_.StartTracing) { diff --git a/generated/iotrace/iotrace_library.h b/generated/iotrace/iotrace_library.h index 99019f0c0..7846c6c07 100644 --- a/generated/iotrace/iotrace_library.h +++ b/generated/iotrace/iotrace_library.h @@ -18,12 +18,15 @@ class IOTraceLibrary : public iotrace_grpc::IOTraceLibraryInterface { virtual ~IOTraceLibrary(); ::grpc::Status check_function_exists(std::string functionName); + int32_t GetApplicationPath(char pathString[256], int32_t pathStringSize); int32_t StartTracing(eNiSpyLogFileSetting logFileSetting, const char filePathString[], eNiSpyAPIFileWriteMode fileWriteMode); private: + using GetApplicationPathPtr = decltype(&nispy_GetApplicationPath); using StartTracingPtr = decltype(&nispy_StartSpying); typedef struct FunctionPointers { + GetApplicationPathPtr GetApplicationPath; StartTracingPtr StartTracing; } FunctionLoadStatus; diff --git a/generated/iotrace/iotrace_library_interface.h b/generated/iotrace/iotrace_library_interface.h index 93e325712..fbfc3ed71 100644 --- a/generated/iotrace/iotrace_library_interface.h +++ b/generated/iotrace/iotrace_library_interface.h @@ -15,6 +15,7 @@ class IOTraceLibraryInterface { public: virtual ~IOTraceLibraryInterface() {} + virtual int32_t GetApplicationPath(char pathString[256], int32_t pathStringSize) = 0; virtual int32_t StartTracing(eNiSpyLogFileSetting logFileSetting, const char filePathString[], eNiSpyAPIFileWriteMode fileWriteMode) = 0; }; diff --git a/generated/iotrace/iotrace_mock_library.h b/generated/iotrace/iotrace_mock_library.h index 2f38edcbe..a1efe4ca3 100644 --- a/generated/iotrace/iotrace_mock_library.h +++ b/generated/iotrace/iotrace_mock_library.h @@ -17,6 +17,7 @@ namespace unit { class IOTraceMockLibrary : public iotrace_grpc::IOTraceLibraryInterface { public: + MOCK_METHOD(int32_t, GetApplicationPath, (char pathString[256], int32_t pathStringSize), (override)); MOCK_METHOD(int32_t, StartTracing, (eNiSpyLogFileSetting logFileSetting, const char filePathString[], eNiSpyAPIFileWriteMode fileWriteMode), (override)); }; diff --git a/generated/iotrace/iotrace_service.cpp b/generated/iotrace/iotrace_service.cpp index ef5711d28..decab6848 100644 --- a/generated/iotrace/iotrace_service.cpp +++ b/generated/iotrace/iotrace_service.cpp @@ -41,6 +41,29 @@ namespace iotrace_grpc { return status >= 0; } + //--------------------------------------------------------------------- + //--------------------------------------------------------------------- + ::grpc::Status IOTraceService::GetApplicationPath(::grpc::ServerContext* context, const GetApplicationPathRequest* request, GetApplicationPathResponse* response) + { + if (context->IsCancelled()) { + return ::grpc::Status::CANCELLED; + } + try { + auto path_string_size = 256; + std::string path_string(256 - 1, '\0'); + auto status = library_->GetApplicationPath((char*)path_string.data(), path_string_size); + response->set_status(status); + if (status_ok(status)) { + response->set_path_string(path_string); + nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_path_string())); + } + return ::grpc::Status::OK; + } + catch (nidevice_grpc::LibraryLoadException& ex) { + return ::grpc::Status(::grpc::NOT_FOUND, ex.what()); + } + } + //--------------------------------------------------------------------- //--------------------------------------------------------------------- ::grpc::Status IOTraceService::StartTracing(::grpc::ServerContext* context, const StartTracingRequest* request, StartTracingResponse* response) diff --git a/generated/iotrace/iotrace_service.h b/generated/iotrace/iotrace_service.h index b233f70f8..3499a956b 100644 --- a/generated/iotrace/iotrace_service.h +++ b/generated/iotrace/iotrace_service.h @@ -41,6 +41,7 @@ class IOTraceService final : public IOTrace::Service { const IOTraceFeatureToggles& feature_toggles = {}); virtual ~IOTraceService(); + ::grpc::Status GetApplicationPath(::grpc::ServerContext* context, const GetApplicationPathRequest* request, GetApplicationPathResponse* response) override; ::grpc::Status StartTracing(::grpc::ServerContext* context, const StartTracingRequest* request, StartTracingResponse* response) override; private: IOTraceLibraryInterface* library_; diff --git a/source/codegen/metadata/iotrace/functions.py b/source/codegen/metadata/iotrace/functions.py index a0edaa17e..2e789dc72 100644 --- a/source/codegen/metadata/iotrace/functions.py +++ b/source/codegen/metadata/iotrace/functions.py @@ -1,6 +1,28 @@ # -*- coding: utf-8 -*- # This file is generated from NI-SCOPE API metadata version 20.5.0d7 functions = { + 'GetApplicationPath': { + 'cname': 'nispy_GetApplicationPath', + 'parameters': [ + { + 'direction': 'out', + 'name': 'pathString', + 'type': 'char[]', + 'size': { + 'mechanism': 'fixed', + 'value': '256' + } + }, + { + 'direction': 'in', + 'name': 'pathStringSize', + 'type': 'int32_t', + 'include_in_proto': False, + 'hardcoded_value': '256' + } + ], + 'returns': 'int32_t' + }, 'StartTracing': { 'cname': 'nispy_StartSpying', 'parameters': [ From 884eb0eff5d16f101a0e222254bc03489b424541 Mon Sep 17 00:00:00 2001 From: Ryan Eckenrode Date: Wed, 30 Mar 2022 17:36:59 -0500 Subject: [PATCH 05/18] Add StopTracing. --- generated/iotrace/iotrace.proto | 8 ++++++++ generated/iotrace/iotrace_client.cpp | 15 +++++++++++++++ generated/iotrace/iotrace_client.h | 1 + generated/iotrace/iotrace_library.cpp | 13 +++++++++++++ generated/iotrace/iotrace_library.h | 3 +++ generated/iotrace/iotrace_library_interface.h | 1 + generated/iotrace/iotrace_mock_library.h | 1 + generated/iotrace/iotrace_service.cpp | 17 +++++++++++++++++ generated/iotrace/iotrace_service.h | 1 + source/codegen/metadata/iotrace/functions.py | 6 ++++++ 10 files changed, 66 insertions(+) diff --git a/generated/iotrace/iotrace.proto b/generated/iotrace/iotrace.proto index 6fa0bcb5d..fdc330ed0 100644 --- a/generated/iotrace/iotrace.proto +++ b/generated/iotrace/iotrace.proto @@ -18,6 +18,7 @@ import "session.proto"; service IOTrace { rpc GetApplicationPath(GetApplicationPathRequest) returns (GetApplicationPathResponse); rpc StartTracing(StartTracingRequest) returns (StartTracingResponse); + rpc StopTracing(StopTracingRequest) returns (StopTracingResponse); } enum IOTraceAttribute { @@ -42,3 +43,10 @@ message StartTracingResponse { int32 status = 1; } +message StopTracingRequest { +} + +message StopTracingResponse { + int32 status = 1; +} + diff --git a/generated/iotrace/iotrace_client.cpp b/generated/iotrace/iotrace_client.cpp index 8eb5aeac7..a30212377 100644 --- a/generated/iotrace/iotrace_client.cpp +++ b/generated/iotrace/iotrace_client.cpp @@ -50,5 +50,20 @@ start_tracing(const StubPtr& stub, const pb::int32& log_file_setting, const pb:: return response; } +StopTracingResponse +stop_tracing(const StubPtr& stub) +{ + ::grpc::ClientContext context; + + auto request = StopTracingRequest{}; + + auto response = StopTracingResponse{}; + + raise_if_error( + stub->StopTracing(&context, request, &response)); + + return response; +} + } // namespace iotrace_grpc::experimental::client diff --git a/generated/iotrace/iotrace_client.h b/generated/iotrace/iotrace_client.h index 5c89dcadb..c430cbd76 100644 --- a/generated/iotrace/iotrace_client.h +++ b/generated/iotrace/iotrace_client.h @@ -24,6 +24,7 @@ using namespace nidevice_grpc::experimental::client; GetApplicationPathResponse get_application_path(const StubPtr& stub); StartTracingResponse start_tracing(const StubPtr& stub, const pb::int32& log_file_setting, const pb::string& file_path_string, const pb::int32& file_write_mode); +StopTracingResponse stop_tracing(const StubPtr& stub); } // namespace iotrace_grpc::experimental::client diff --git a/generated/iotrace/iotrace_library.cpp b/generated/iotrace/iotrace_library.cpp index 2cea8e411..174563e4e 100644 --- a/generated/iotrace/iotrace_library.cpp +++ b/generated/iotrace/iotrace_library.cpp @@ -23,6 +23,7 @@ IOTraceLibrary::IOTraceLibrary() : shared_library_(kLibraryName) } function_pointers_.GetApplicationPath = reinterpret_cast(shared_library_.get_function_pointer("nispy_GetApplicationPath")); function_pointers_.StartTracing = reinterpret_cast(shared_library_.get_function_pointer("nispy_StartSpying")); + function_pointers_.StopTracing = reinterpret_cast(shared_library_.get_function_pointer("nispy_StopSpying")); } IOTraceLibrary::~IOTraceLibrary() @@ -60,4 +61,16 @@ int32_t IOTraceLibrary::StartTracing(eNiSpyLogFileSetting logFileSetting, const #endif } +int32_t IOTraceLibrary::StopTracing() +{ + if (!function_pointers_.StopTracing) { + throw nidevice_grpc::LibraryLoadException("Could not find nispy_StopSpying."); + } +#if defined(_MSC_VER) + return nispy_StopSpying(); +#else + return function_pointers_.StopTracing(); +#endif +} + } // namespace iotrace_grpc diff --git a/generated/iotrace/iotrace_library.h b/generated/iotrace/iotrace_library.h index 7846c6c07..be02e1403 100644 --- a/generated/iotrace/iotrace_library.h +++ b/generated/iotrace/iotrace_library.h @@ -20,14 +20,17 @@ class IOTraceLibrary : public iotrace_grpc::IOTraceLibraryInterface { ::grpc::Status check_function_exists(std::string functionName); int32_t GetApplicationPath(char pathString[256], int32_t pathStringSize); int32_t StartTracing(eNiSpyLogFileSetting logFileSetting, const char filePathString[], eNiSpyAPIFileWriteMode fileWriteMode); + int32_t StopTracing(); private: using GetApplicationPathPtr = decltype(&nispy_GetApplicationPath); using StartTracingPtr = decltype(&nispy_StartSpying); + using StopTracingPtr = decltype(&nispy_StopSpying); typedef struct FunctionPointers { GetApplicationPathPtr GetApplicationPath; StartTracingPtr StartTracing; + StopTracingPtr StopTracing; } FunctionLoadStatus; nidevice_grpc::SharedLibrary shared_library_; diff --git a/generated/iotrace/iotrace_library_interface.h b/generated/iotrace/iotrace_library_interface.h index fbfc3ed71..f0ab924a7 100644 --- a/generated/iotrace/iotrace_library_interface.h +++ b/generated/iotrace/iotrace_library_interface.h @@ -17,6 +17,7 @@ class IOTraceLibraryInterface { virtual int32_t GetApplicationPath(char pathString[256], int32_t pathStringSize) = 0; virtual int32_t StartTracing(eNiSpyLogFileSetting logFileSetting, const char filePathString[], eNiSpyAPIFileWriteMode fileWriteMode) = 0; + virtual int32_t StopTracing() = 0; }; } // namespace iotrace_grpc diff --git a/generated/iotrace/iotrace_mock_library.h b/generated/iotrace/iotrace_mock_library.h index a1efe4ca3..1b6e8996b 100644 --- a/generated/iotrace/iotrace_mock_library.h +++ b/generated/iotrace/iotrace_mock_library.h @@ -19,6 +19,7 @@ class IOTraceMockLibrary : public iotrace_grpc::IOTraceLibraryInterface { public: MOCK_METHOD(int32_t, GetApplicationPath, (char pathString[256], int32_t pathStringSize), (override)); MOCK_METHOD(int32_t, StartTracing, (eNiSpyLogFileSetting logFileSetting, const char filePathString[], eNiSpyAPIFileWriteMode fileWriteMode), (override)); + MOCK_METHOD(int32_t, StopTracing, (), (override)); }; } // namespace unit diff --git a/generated/iotrace/iotrace_service.cpp b/generated/iotrace/iotrace_service.cpp index decab6848..68685c32d 100644 --- a/generated/iotrace/iotrace_service.cpp +++ b/generated/iotrace/iotrace_service.cpp @@ -84,6 +84,23 @@ namespace iotrace_grpc { } } + //--------------------------------------------------------------------- + //--------------------------------------------------------------------- + ::grpc::Status IOTraceService::StopTracing(::grpc::ServerContext* context, const StopTracingRequest* request, StopTracingResponse* response) + { + if (context->IsCancelled()) { + return ::grpc::Status::CANCELLED; + } + try { + auto status = library_->StopTracing(); + response->set_status(status); + return ::grpc::Status::OK; + } + catch (nidevice_grpc::LibraryLoadException& ex) { + return ::grpc::Status(::grpc::NOT_FOUND, ex.what()); + } + } + IOTraceFeatureToggles::IOTraceFeatureToggles( const nidevice_grpc::FeatureToggles& feature_toggles) diff --git a/generated/iotrace/iotrace_service.h b/generated/iotrace/iotrace_service.h index 3499a956b..58464c7dd 100644 --- a/generated/iotrace/iotrace_service.h +++ b/generated/iotrace/iotrace_service.h @@ -43,6 +43,7 @@ class IOTraceService final : public IOTrace::Service { ::grpc::Status GetApplicationPath(::grpc::ServerContext* context, const GetApplicationPathRequest* request, GetApplicationPathResponse* response) override; ::grpc::Status StartTracing(::grpc::ServerContext* context, const StartTracingRequest* request, StartTracingResponse* response) override; + ::grpc::Status StopTracing(::grpc::ServerContext* context, const StopTracingRequest* request, StopTracingResponse* response) override; private: IOTraceLibraryInterface* library_; ResourceRepositorySharedPtr session_repository_; diff --git a/source/codegen/metadata/iotrace/functions.py b/source/codegen/metadata/iotrace/functions.py index 2e789dc72..219410431 100644 --- a/source/codegen/metadata/iotrace/functions.py +++ b/source/codegen/metadata/iotrace/functions.py @@ -46,4 +46,10 @@ ], 'returns': 'int32_t' }, + 'StopTracing': { + 'cname': 'nispy_StopSpying', + 'parameters': [ + ], + 'returns': 'int32_t' + }, } From 1b3eee91fd33e3446a5482674398ac21f565f30a Mon Sep 17 00:00:00 2001 From: Ryan Eckenrode Date: Wed, 30 Mar 2022 17:40:27 -0500 Subject: [PATCH 06/18] Add LogMessage. --- generated/iotrace/iotrace.proto | 9 +++++++++ generated/iotrace/iotrace_client.cpp | 16 ++++++++++++++++ generated/iotrace/iotrace_client.h | 1 + generated/iotrace/iotrace_library.cpp | 13 +++++++++++++ generated/iotrace/iotrace_library.h | 3 +++ generated/iotrace/iotrace_library_interface.h | 1 + generated/iotrace/iotrace_mock_library.h | 1 + generated/iotrace/iotrace_service.cpp | 18 ++++++++++++++++++ generated/iotrace/iotrace_service.h | 1 + source/codegen/metadata/iotrace/functions.py | 11 +++++++++++ 10 files changed, 74 insertions(+) diff --git a/generated/iotrace/iotrace.proto b/generated/iotrace/iotrace.proto index fdc330ed0..3fab69b77 100644 --- a/generated/iotrace/iotrace.proto +++ b/generated/iotrace/iotrace.proto @@ -19,6 +19,7 @@ service IOTrace { rpc GetApplicationPath(GetApplicationPathRequest) returns (GetApplicationPathResponse); rpc StartTracing(StartTracingRequest) returns (StartTracingResponse); rpc StopTracing(StopTracingRequest) returns (StopTracingResponse); + rpc LogMessage(LogMessageRequest) returns (LogMessageResponse); } enum IOTraceAttribute { @@ -50,3 +51,11 @@ message StopTracingResponse { int32 status = 1; } +message LogMessageRequest { + string message = 1; +} + +message LogMessageResponse { + int32 status = 1; +} + diff --git a/generated/iotrace/iotrace_client.cpp b/generated/iotrace/iotrace_client.cpp index a30212377..4151dbcb8 100644 --- a/generated/iotrace/iotrace_client.cpp +++ b/generated/iotrace/iotrace_client.cpp @@ -65,5 +65,21 @@ stop_tracing(const StubPtr& stub) return response; } +LogMessageResponse +log_message(const StubPtr& stub, const pb::string& message) +{ + ::grpc::ClientContext context; + + auto request = LogMessageRequest{}; + request.set_message(message); + + auto response = LogMessageResponse{}; + + raise_if_error( + stub->LogMessage(&context, request, &response)); + + return response; +} + } // namespace iotrace_grpc::experimental::client diff --git a/generated/iotrace/iotrace_client.h b/generated/iotrace/iotrace_client.h index c430cbd76..54e289835 100644 --- a/generated/iotrace/iotrace_client.h +++ b/generated/iotrace/iotrace_client.h @@ -25,6 +25,7 @@ using namespace nidevice_grpc::experimental::client; GetApplicationPathResponse get_application_path(const StubPtr& stub); StartTracingResponse start_tracing(const StubPtr& stub, const pb::int32& log_file_setting, const pb::string& file_path_string, const pb::int32& file_write_mode); StopTracingResponse stop_tracing(const StubPtr& stub); +LogMessageResponse log_message(const StubPtr& stub, const pb::string& message); } // namespace iotrace_grpc::experimental::client diff --git a/generated/iotrace/iotrace_library.cpp b/generated/iotrace/iotrace_library.cpp index 174563e4e..ee32927e7 100644 --- a/generated/iotrace/iotrace_library.cpp +++ b/generated/iotrace/iotrace_library.cpp @@ -24,6 +24,7 @@ IOTraceLibrary::IOTraceLibrary() : shared_library_(kLibraryName) function_pointers_.GetApplicationPath = reinterpret_cast(shared_library_.get_function_pointer("nispy_GetApplicationPath")); function_pointers_.StartTracing = reinterpret_cast(shared_library_.get_function_pointer("nispy_StartSpying")); function_pointers_.StopTracing = reinterpret_cast(shared_library_.get_function_pointer("nispy_StopSpying")); + function_pointers_.LogMessage = reinterpret_cast(shared_library_.get_function_pointer("nispy_WriteTextEntry")); } IOTraceLibrary::~IOTraceLibrary() @@ -73,4 +74,16 @@ int32_t IOTraceLibrary::StopTracing() #endif } +int32_t IOTraceLibrary::LogMessage(const char message[]) +{ + if (!function_pointers_.LogMessage) { + throw nidevice_grpc::LibraryLoadException("Could not find nispy_WriteTextEntry."); + } +#if defined(_MSC_VER) + return nispy_WriteTextEntry(message); +#else + return function_pointers_.LogMessage(message); +#endif +} + } // namespace iotrace_grpc diff --git a/generated/iotrace/iotrace_library.h b/generated/iotrace/iotrace_library.h index be02e1403..43efac3dd 100644 --- a/generated/iotrace/iotrace_library.h +++ b/generated/iotrace/iotrace_library.h @@ -21,16 +21,19 @@ class IOTraceLibrary : public iotrace_grpc::IOTraceLibraryInterface { int32_t GetApplicationPath(char pathString[256], int32_t pathStringSize); int32_t StartTracing(eNiSpyLogFileSetting logFileSetting, const char filePathString[], eNiSpyAPIFileWriteMode fileWriteMode); int32_t StopTracing(); + int32_t LogMessage(const char message[]); private: using GetApplicationPathPtr = decltype(&nispy_GetApplicationPath); using StartTracingPtr = decltype(&nispy_StartSpying); using StopTracingPtr = decltype(&nispy_StopSpying); + using LogMessagePtr = decltype(&nispy_WriteTextEntry); typedef struct FunctionPointers { GetApplicationPathPtr GetApplicationPath; StartTracingPtr StartTracing; StopTracingPtr StopTracing; + LogMessagePtr LogMessage; } FunctionLoadStatus; nidevice_grpc::SharedLibrary shared_library_; diff --git a/generated/iotrace/iotrace_library_interface.h b/generated/iotrace/iotrace_library_interface.h index f0ab924a7..f687487ed 100644 --- a/generated/iotrace/iotrace_library_interface.h +++ b/generated/iotrace/iotrace_library_interface.h @@ -18,6 +18,7 @@ class IOTraceLibraryInterface { virtual int32_t GetApplicationPath(char pathString[256], int32_t pathStringSize) = 0; virtual int32_t StartTracing(eNiSpyLogFileSetting logFileSetting, const char filePathString[], eNiSpyAPIFileWriteMode fileWriteMode) = 0; virtual int32_t StopTracing() = 0; + virtual int32_t LogMessage(const char message[]) = 0; }; } // namespace iotrace_grpc diff --git a/generated/iotrace/iotrace_mock_library.h b/generated/iotrace/iotrace_mock_library.h index 1b6e8996b..6c6b98049 100644 --- a/generated/iotrace/iotrace_mock_library.h +++ b/generated/iotrace/iotrace_mock_library.h @@ -20,6 +20,7 @@ class IOTraceMockLibrary : public iotrace_grpc::IOTraceLibraryInterface { MOCK_METHOD(int32_t, GetApplicationPath, (char pathString[256], int32_t pathStringSize), (override)); MOCK_METHOD(int32_t, StartTracing, (eNiSpyLogFileSetting logFileSetting, const char filePathString[], eNiSpyAPIFileWriteMode fileWriteMode), (override)); MOCK_METHOD(int32_t, StopTracing, (), (override)); + MOCK_METHOD(int32_t, LogMessage, (const char message[]), (override)); }; } // namespace unit diff --git a/generated/iotrace/iotrace_service.cpp b/generated/iotrace/iotrace_service.cpp index 68685c32d..9d5f433dd 100644 --- a/generated/iotrace/iotrace_service.cpp +++ b/generated/iotrace/iotrace_service.cpp @@ -101,6 +101,24 @@ namespace iotrace_grpc { } } + //--------------------------------------------------------------------- + //--------------------------------------------------------------------- + ::grpc::Status IOTraceService::LogMessage(::grpc::ServerContext* context, const LogMessageRequest* request, LogMessageResponse* response) + { + if (context->IsCancelled()) { + return ::grpc::Status::CANCELLED; + } + try { + auto message = request->message().c_str(); + auto status = library_->LogMessage(message); + response->set_status(status); + return ::grpc::Status::OK; + } + catch (nidevice_grpc::LibraryLoadException& ex) { + return ::grpc::Status(::grpc::NOT_FOUND, ex.what()); + } + } + IOTraceFeatureToggles::IOTraceFeatureToggles( const nidevice_grpc::FeatureToggles& feature_toggles) diff --git a/generated/iotrace/iotrace_service.h b/generated/iotrace/iotrace_service.h index 58464c7dd..258306389 100644 --- a/generated/iotrace/iotrace_service.h +++ b/generated/iotrace/iotrace_service.h @@ -44,6 +44,7 @@ class IOTraceService final : public IOTrace::Service { ::grpc::Status GetApplicationPath(::grpc::ServerContext* context, const GetApplicationPathRequest* request, GetApplicationPathResponse* response) override; ::grpc::Status StartTracing(::grpc::ServerContext* context, const StartTracingRequest* request, StartTracingResponse* response) override; ::grpc::Status StopTracing(::grpc::ServerContext* context, const StopTracingRequest* request, StopTracingResponse* response) override; + ::grpc::Status LogMessage(::grpc::ServerContext* context, const LogMessageRequest* request, LogMessageResponse* response) override; private: IOTraceLibraryInterface* library_; ResourceRepositorySharedPtr session_repository_; diff --git a/source/codegen/metadata/iotrace/functions.py b/source/codegen/metadata/iotrace/functions.py index 219410431..121d78751 100644 --- a/source/codegen/metadata/iotrace/functions.py +++ b/source/codegen/metadata/iotrace/functions.py @@ -52,4 +52,15 @@ ], 'returns': 'int32_t' }, + 'LogMessage': { + 'cname': 'nispy_WriteTextEntry', + 'parameters': [ + { + 'direction': 'in', + 'name': 'message', + 'type': 'const char[]' + } + ], + 'returns': 'int32_t' + } } From b13293e3a7a163d762f241128e199c86e2b30dd3 Mon Sep 17 00:00:00 2001 From: Ryan Eckenrode Date: Wed, 30 Mar 2022 17:42:52 -0500 Subject: [PATCH 07/18] Add CloseIOTrace --- generated/iotrace/iotrace.proto | 26 ++++++---- generated/iotrace/iotrace_client.cpp | 47 ++++++++++++------- generated/iotrace/iotrace_client.h | 3 +- generated/iotrace/iotrace_library.cpp | 39 ++++++++++----- generated/iotrace/iotrace_library.h | 9 ++-- generated/iotrace/iotrace_library_interface.h | 3 +- generated/iotrace/iotrace_mock_library.h | 3 +- generated/iotrace/iotrace_service.cpp | 37 +++++++++++---- generated/iotrace/iotrace_service.h | 3 +- source/codegen/metadata/iotrace/functions.py | 30 +++++++----- 10 files changed, 133 insertions(+), 67 deletions(-) diff --git a/generated/iotrace/iotrace.proto b/generated/iotrace/iotrace.proto index 3fab69b77..77dd5f7d8 100644 --- a/generated/iotrace/iotrace.proto +++ b/generated/iotrace/iotrace.proto @@ -16,16 +16,24 @@ package iotrace_grpc; import "session.proto"; service IOTrace { + rpc CloseIOTrace(CloseIOTraceRequest) returns (CloseIOTraceResponse); rpc GetApplicationPath(GetApplicationPathRequest) returns (GetApplicationPathResponse); + rpc LogMessage(LogMessageRequest) returns (LogMessageResponse); rpc StartTracing(StartTracingRequest) returns (StartTracingResponse); rpc StopTracing(StopTracingRequest) returns (StopTracingResponse); - rpc LogMessage(LogMessageRequest) returns (LogMessageResponse); } enum IOTraceAttribute { IOTRACE_ATTRIBUTE_UNSPECIFIED = 0; } +message CloseIOTraceRequest { +} + +message CloseIOTraceResponse { + int32 status = 1; +} + message GetApplicationPathRequest { } @@ -34,6 +42,14 @@ message GetApplicationPathResponse { string path_string = 2; } +message LogMessageRequest { + string message = 1; +} + +message LogMessageResponse { + int32 status = 1; +} + message StartTracingRequest { int32 log_file_setting = 1; string file_path_string = 2; @@ -51,11 +67,3 @@ message StopTracingResponse { int32 status = 1; } -message LogMessageRequest { - string message = 1; -} - -message LogMessageResponse { - int32 status = 1; -} - diff --git a/generated/iotrace/iotrace_client.cpp b/generated/iotrace/iotrace_client.cpp index 4151dbcb8..e8caad52f 100644 --- a/generated/iotrace/iotrace_client.cpp +++ b/generated/iotrace/iotrace_client.cpp @@ -17,6 +17,21 @@ namespace iotrace_grpc::experimental::client { +CloseIOTraceResponse +close_io_trace(const StubPtr& stub) +{ + ::grpc::ClientContext context; + + auto request = CloseIOTraceRequest{}; + + auto response = CloseIOTraceResponse{}; + + raise_if_error( + stub->CloseIOTrace(&context, request, &response)); + + return response; +} + GetApplicationPathResponse get_application_path(const StubPtr& stub) { @@ -32,6 +47,22 @@ get_application_path(const StubPtr& stub) return response; } +LogMessageResponse +log_message(const StubPtr& stub, const pb::string& message) +{ + ::grpc::ClientContext context; + + auto request = LogMessageRequest{}; + request.set_message(message); + + auto response = LogMessageResponse{}; + + raise_if_error( + stub->LogMessage(&context, request, &response)); + + return response; +} + StartTracingResponse start_tracing(const StubPtr& stub, const pb::int32& log_file_setting, const pb::string& file_path_string, const pb::int32& file_write_mode) { @@ -65,21 +96,5 @@ stop_tracing(const StubPtr& stub) return response; } -LogMessageResponse -log_message(const StubPtr& stub, const pb::string& message) -{ - ::grpc::ClientContext context; - - auto request = LogMessageRequest{}; - request.set_message(message); - - auto response = LogMessageResponse{}; - - raise_if_error( - stub->LogMessage(&context, request, &response)); - - return response; -} - } // namespace iotrace_grpc::experimental::client diff --git a/generated/iotrace/iotrace_client.h b/generated/iotrace/iotrace_client.h index 54e289835..6a492cc09 100644 --- a/generated/iotrace/iotrace_client.h +++ b/generated/iotrace/iotrace_client.h @@ -22,10 +22,11 @@ using StubPtr = std::unique_ptr; using namespace nidevice_grpc::experimental::client; +CloseIOTraceResponse close_io_trace(const StubPtr& stub); GetApplicationPathResponse get_application_path(const StubPtr& stub); +LogMessageResponse log_message(const StubPtr& stub, const pb::string& message); StartTracingResponse start_tracing(const StubPtr& stub, const pb::int32& log_file_setting, const pb::string& file_path_string, const pb::int32& file_write_mode); StopTracingResponse stop_tracing(const StubPtr& stub); -LogMessageResponse log_message(const StubPtr& stub, const pb::string& message); } // namespace iotrace_grpc::experimental::client diff --git a/generated/iotrace/iotrace_library.cpp b/generated/iotrace/iotrace_library.cpp index ee32927e7..ae5f004b4 100644 --- a/generated/iotrace/iotrace_library.cpp +++ b/generated/iotrace/iotrace_library.cpp @@ -21,10 +21,11 @@ IOTraceLibrary::IOTraceLibrary() : shared_library_(kLibraryName) if (!loaded) { return; } + function_pointers_.CloseIOTrace = reinterpret_cast(shared_library_.get_function_pointer("nispy_CloseSpy")); function_pointers_.GetApplicationPath = reinterpret_cast(shared_library_.get_function_pointer("nispy_GetApplicationPath")); + function_pointers_.LogMessage = reinterpret_cast(shared_library_.get_function_pointer("nispy_WriteTextEntry")); function_pointers_.StartTracing = reinterpret_cast(shared_library_.get_function_pointer("nispy_StartSpying")); function_pointers_.StopTracing = reinterpret_cast(shared_library_.get_function_pointer("nispy_StopSpying")); - function_pointers_.LogMessage = reinterpret_cast(shared_library_.get_function_pointer("nispy_WriteTextEntry")); } IOTraceLibrary::~IOTraceLibrary() @@ -38,6 +39,18 @@ ::grpc::Status IOTraceLibrary::check_function_exists(std::string functionName) : ::grpc::Status(::grpc::NOT_FOUND, "Could not find the function " + functionName); } +int32_t IOTraceLibrary::CloseIOTrace() +{ + if (!function_pointers_.CloseIOTrace) { + throw nidevice_grpc::LibraryLoadException("Could not find nispy_CloseSpy."); + } +#if defined(_MSC_VER) + return nispy_CloseSpy(); +#else + return function_pointers_.CloseIOTrace(); +#endif +} + int32_t IOTraceLibrary::GetApplicationPath(char pathString[256], int32_t pathStringSize) { if (!function_pointers_.GetApplicationPath) { @@ -50,6 +63,18 @@ int32_t IOTraceLibrary::GetApplicationPath(char pathString[256], int32_t pathStr #endif } +int32_t IOTraceLibrary::LogMessage(const char message[]) +{ + if (!function_pointers_.LogMessage) { + throw nidevice_grpc::LibraryLoadException("Could not find nispy_WriteTextEntry."); + } +#if defined(_MSC_VER) + return nispy_WriteTextEntry(message); +#else + return function_pointers_.LogMessage(message); +#endif +} + int32_t IOTraceLibrary::StartTracing(eNiSpyLogFileSetting logFileSetting, const char filePathString[], eNiSpyAPIFileWriteMode fileWriteMode) { if (!function_pointers_.StartTracing) { @@ -74,16 +99,4 @@ int32_t IOTraceLibrary::StopTracing() #endif } -int32_t IOTraceLibrary::LogMessage(const char message[]) -{ - if (!function_pointers_.LogMessage) { - throw nidevice_grpc::LibraryLoadException("Could not find nispy_WriteTextEntry."); - } -#if defined(_MSC_VER) - return nispy_WriteTextEntry(message); -#else - return function_pointers_.LogMessage(message); -#endif -} - } // namespace iotrace_grpc diff --git a/generated/iotrace/iotrace_library.h b/generated/iotrace/iotrace_library.h index 43efac3dd..3f2fdd3c3 100644 --- a/generated/iotrace/iotrace_library.h +++ b/generated/iotrace/iotrace_library.h @@ -18,22 +18,25 @@ class IOTraceLibrary : public iotrace_grpc::IOTraceLibraryInterface { virtual ~IOTraceLibrary(); ::grpc::Status check_function_exists(std::string functionName); + int32_t CloseIOTrace(); int32_t GetApplicationPath(char pathString[256], int32_t pathStringSize); + int32_t LogMessage(const char message[]); int32_t StartTracing(eNiSpyLogFileSetting logFileSetting, const char filePathString[], eNiSpyAPIFileWriteMode fileWriteMode); int32_t StopTracing(); - int32_t LogMessage(const char message[]); private: + using CloseIOTracePtr = decltype(&nispy_CloseSpy); using GetApplicationPathPtr = decltype(&nispy_GetApplicationPath); + using LogMessagePtr = decltype(&nispy_WriteTextEntry); using StartTracingPtr = decltype(&nispy_StartSpying); using StopTracingPtr = decltype(&nispy_StopSpying); - using LogMessagePtr = decltype(&nispy_WriteTextEntry); typedef struct FunctionPointers { + CloseIOTracePtr CloseIOTrace; GetApplicationPathPtr GetApplicationPath; + LogMessagePtr LogMessage; StartTracingPtr StartTracing; StopTracingPtr StopTracing; - LogMessagePtr LogMessage; } FunctionLoadStatus; nidevice_grpc::SharedLibrary shared_library_; diff --git a/generated/iotrace/iotrace_library_interface.h b/generated/iotrace/iotrace_library_interface.h index f687487ed..e0ebaffff 100644 --- a/generated/iotrace/iotrace_library_interface.h +++ b/generated/iotrace/iotrace_library_interface.h @@ -15,10 +15,11 @@ class IOTraceLibraryInterface { public: virtual ~IOTraceLibraryInterface() {} + virtual int32_t CloseIOTrace() = 0; virtual int32_t GetApplicationPath(char pathString[256], int32_t pathStringSize) = 0; + virtual int32_t LogMessage(const char message[]) = 0; virtual int32_t StartTracing(eNiSpyLogFileSetting logFileSetting, const char filePathString[], eNiSpyAPIFileWriteMode fileWriteMode) = 0; virtual int32_t StopTracing() = 0; - virtual int32_t LogMessage(const char message[]) = 0; }; } // namespace iotrace_grpc diff --git a/generated/iotrace/iotrace_mock_library.h b/generated/iotrace/iotrace_mock_library.h index 6c6b98049..e84591bef 100644 --- a/generated/iotrace/iotrace_mock_library.h +++ b/generated/iotrace/iotrace_mock_library.h @@ -17,10 +17,11 @@ namespace unit { class IOTraceMockLibrary : public iotrace_grpc::IOTraceLibraryInterface { public: + MOCK_METHOD(int32_t, CloseIOTrace, (), (override)); MOCK_METHOD(int32_t, GetApplicationPath, (char pathString[256], int32_t pathStringSize), (override)); + MOCK_METHOD(int32_t, LogMessage, (const char message[]), (override)); MOCK_METHOD(int32_t, StartTracing, (eNiSpyLogFileSetting logFileSetting, const char filePathString[], eNiSpyAPIFileWriteMode fileWriteMode), (override)); MOCK_METHOD(int32_t, StopTracing, (), (override)); - MOCK_METHOD(int32_t, LogMessage, (const char message[]), (override)); }; } // namespace unit diff --git a/generated/iotrace/iotrace_service.cpp b/generated/iotrace/iotrace_service.cpp index 9d5f433dd..b531e3fd8 100644 --- a/generated/iotrace/iotrace_service.cpp +++ b/generated/iotrace/iotrace_service.cpp @@ -41,6 +41,23 @@ namespace iotrace_grpc { return status >= 0; } + //--------------------------------------------------------------------- + //--------------------------------------------------------------------- + ::grpc::Status IOTraceService::CloseIOTrace(::grpc::ServerContext* context, const CloseIOTraceRequest* request, CloseIOTraceResponse* response) + { + if (context->IsCancelled()) { + return ::grpc::Status::CANCELLED; + } + try { + auto status = library_->CloseIOTrace(); + response->set_status(status); + return ::grpc::Status::OK; + } + catch (nidevice_grpc::LibraryLoadException& ex) { + return ::grpc::Status(::grpc::NOT_FOUND, ex.what()); + } + } + //--------------------------------------------------------------------- //--------------------------------------------------------------------- ::grpc::Status IOTraceService::GetApplicationPath(::grpc::ServerContext* context, const GetApplicationPathRequest* request, GetApplicationPathResponse* response) @@ -66,16 +83,14 @@ namespace iotrace_grpc { //--------------------------------------------------------------------- //--------------------------------------------------------------------- - ::grpc::Status IOTraceService::StartTracing(::grpc::ServerContext* context, const StartTracingRequest* request, StartTracingResponse* response) + ::grpc::Status IOTraceService::LogMessage(::grpc::ServerContext* context, const LogMessageRequest* request, LogMessageResponse* response) { if (context->IsCancelled()) { return ::grpc::Status::CANCELLED; } try { - auto log_file_setting = convert_from_grpc(request->log_file_setting()); - auto file_path_string = request->file_path_string().c_str(); - auto file_write_mode = convert_from_grpc(request->file_write_mode()); - auto status = library_->StartTracing(log_file_setting, file_path_string, file_write_mode); + auto message = request->message().c_str(); + auto status = library_->LogMessage(message); response->set_status(status); return ::grpc::Status::OK; } @@ -86,13 +101,16 @@ namespace iotrace_grpc { //--------------------------------------------------------------------- //--------------------------------------------------------------------- - ::grpc::Status IOTraceService::StopTracing(::grpc::ServerContext* context, const StopTracingRequest* request, StopTracingResponse* response) + ::grpc::Status IOTraceService::StartTracing(::grpc::ServerContext* context, const StartTracingRequest* request, StartTracingResponse* response) { if (context->IsCancelled()) { return ::grpc::Status::CANCELLED; } try { - auto status = library_->StopTracing(); + auto log_file_setting = convert_from_grpc(request->log_file_setting()); + auto file_path_string = request->file_path_string().c_str(); + auto file_write_mode = convert_from_grpc(request->file_write_mode()); + auto status = library_->StartTracing(log_file_setting, file_path_string, file_write_mode); response->set_status(status); return ::grpc::Status::OK; } @@ -103,14 +121,13 @@ namespace iotrace_grpc { //--------------------------------------------------------------------- //--------------------------------------------------------------------- - ::grpc::Status IOTraceService::LogMessage(::grpc::ServerContext* context, const LogMessageRequest* request, LogMessageResponse* response) + ::grpc::Status IOTraceService::StopTracing(::grpc::ServerContext* context, const StopTracingRequest* request, StopTracingResponse* response) { if (context->IsCancelled()) { return ::grpc::Status::CANCELLED; } try { - auto message = request->message().c_str(); - auto status = library_->LogMessage(message); + auto status = library_->StopTracing(); response->set_status(status); return ::grpc::Status::OK; } diff --git a/generated/iotrace/iotrace_service.h b/generated/iotrace/iotrace_service.h index 258306389..7a8a2c951 100644 --- a/generated/iotrace/iotrace_service.h +++ b/generated/iotrace/iotrace_service.h @@ -41,10 +41,11 @@ class IOTraceService final : public IOTrace::Service { const IOTraceFeatureToggles& feature_toggles = {}); virtual ~IOTraceService(); + ::grpc::Status CloseIOTrace(::grpc::ServerContext* context, const CloseIOTraceRequest* request, CloseIOTraceResponse* response) override; ::grpc::Status GetApplicationPath(::grpc::ServerContext* context, const GetApplicationPathRequest* request, GetApplicationPathResponse* response) override; + ::grpc::Status LogMessage(::grpc::ServerContext* context, const LogMessageRequest* request, LogMessageResponse* response) override; ::grpc::Status StartTracing(::grpc::ServerContext* context, const StartTracingRequest* request, StartTracingResponse* response) override; ::grpc::Status StopTracing(::grpc::ServerContext* context, const StopTracingRequest* request, StopTracingResponse* response) override; - ::grpc::Status LogMessage(::grpc::ServerContext* context, const LogMessageRequest* request, LogMessageResponse* response) override; private: IOTraceLibraryInterface* library_; ResourceRepositorySharedPtr session_repository_; diff --git a/source/codegen/metadata/iotrace/functions.py b/source/codegen/metadata/iotrace/functions.py index 121d78751..e34aba6ed 100644 --- a/source/codegen/metadata/iotrace/functions.py +++ b/source/codegen/metadata/iotrace/functions.py @@ -1,6 +1,12 @@ # -*- coding: utf-8 -*- # This file is generated from NI-SCOPE API metadata version 20.5.0d7 functions = { + 'CloseIOTrace': { + 'cname': 'nispy_CloseSpy', + 'parameters': [ + ], + 'returns': 'int32_t' + }, 'GetApplicationPath': { 'cname': 'nispy_GetApplicationPath', 'parameters': [ @@ -23,6 +29,17 @@ ], 'returns': 'int32_t' }, + 'LogMessage': { + 'cname': 'nispy_WriteTextEntry', + 'parameters': [ + { + 'direction': 'in', + 'name': 'message', + 'type': 'const char[]' + } + ], + 'returns': 'int32_t' + }, 'StartTracing': { 'cname': 'nispy_StartSpying', 'parameters': [ @@ -51,16 +68,5 @@ 'parameters': [ ], 'returns': 'int32_t' - }, - 'LogMessage': { - 'cname': 'nispy_WriteTextEntry', - 'parameters': [ - { - 'direction': 'in', - 'name': 'message', - 'type': 'const char[]' - } - ], - 'returns': 'int32_t' - } + }, } From f0f480c3f92226d4492453f0406ed119f23ac34d Mon Sep 17 00:00:00 2001 From: Ryan Eckenrode Date: Wed, 30 Mar 2022 17:43:39 -0500 Subject: [PATCH 08/18] Change GetApplicationPath to GetIOTracePath --- generated/iotrace/iotrace.proto | 6 +++--- generated/iotrace/iotrace_client.cpp | 10 +++++----- generated/iotrace/iotrace_client.h | 2 +- generated/iotrace/iotrace_library.cpp | 8 ++++---- generated/iotrace/iotrace_library.h | 6 +++--- generated/iotrace/iotrace_library_interface.h | 2 +- generated/iotrace/iotrace_mock_library.h | 2 +- generated/iotrace/iotrace_service.cpp | 4 ++-- generated/iotrace/iotrace_service.h | 2 +- source/codegen/metadata/iotrace/functions.py | 2 +- 10 files changed, 22 insertions(+), 22 deletions(-) diff --git a/generated/iotrace/iotrace.proto b/generated/iotrace/iotrace.proto index 77dd5f7d8..6806e5caf 100644 --- a/generated/iotrace/iotrace.proto +++ b/generated/iotrace/iotrace.proto @@ -17,7 +17,7 @@ import "session.proto"; service IOTrace { rpc CloseIOTrace(CloseIOTraceRequest) returns (CloseIOTraceResponse); - rpc GetApplicationPath(GetApplicationPathRequest) returns (GetApplicationPathResponse); + rpc GetIOTracePath(GetIOTracePathRequest) returns (GetIOTracePathResponse); rpc LogMessage(LogMessageRequest) returns (LogMessageResponse); rpc StartTracing(StartTracingRequest) returns (StartTracingResponse); rpc StopTracing(StopTracingRequest) returns (StopTracingResponse); @@ -34,10 +34,10 @@ message CloseIOTraceResponse { int32 status = 1; } -message GetApplicationPathRequest { +message GetIOTracePathRequest { } -message GetApplicationPathResponse { +message GetIOTracePathResponse { int32 status = 1; string path_string = 2; } diff --git a/generated/iotrace/iotrace_client.cpp b/generated/iotrace/iotrace_client.cpp index e8caad52f..49b93a4e6 100644 --- a/generated/iotrace/iotrace_client.cpp +++ b/generated/iotrace/iotrace_client.cpp @@ -32,17 +32,17 @@ close_io_trace(const StubPtr& stub) return response; } -GetApplicationPathResponse -get_application_path(const StubPtr& stub) +GetIOTracePathResponse +get_io_trace_path(const StubPtr& stub) { ::grpc::ClientContext context; - auto request = GetApplicationPathRequest{}; + auto request = GetIOTracePathRequest{}; - auto response = GetApplicationPathResponse{}; + auto response = GetIOTracePathResponse{}; raise_if_error( - stub->GetApplicationPath(&context, request, &response)); + stub->GetIOTracePath(&context, request, &response)); return response; } diff --git a/generated/iotrace/iotrace_client.h b/generated/iotrace/iotrace_client.h index 6a492cc09..947a973bc 100644 --- a/generated/iotrace/iotrace_client.h +++ b/generated/iotrace/iotrace_client.h @@ -23,7 +23,7 @@ using namespace nidevice_grpc::experimental::client; CloseIOTraceResponse close_io_trace(const StubPtr& stub); -GetApplicationPathResponse get_application_path(const StubPtr& stub); +GetIOTracePathResponse get_io_trace_path(const StubPtr& stub); LogMessageResponse log_message(const StubPtr& stub, const pb::string& message); StartTracingResponse start_tracing(const StubPtr& stub, const pb::int32& log_file_setting, const pb::string& file_path_string, const pb::int32& file_write_mode); StopTracingResponse stop_tracing(const StubPtr& stub); diff --git a/generated/iotrace/iotrace_library.cpp b/generated/iotrace/iotrace_library.cpp index ae5f004b4..842b930df 100644 --- a/generated/iotrace/iotrace_library.cpp +++ b/generated/iotrace/iotrace_library.cpp @@ -22,7 +22,7 @@ IOTraceLibrary::IOTraceLibrary() : shared_library_(kLibraryName) return; } function_pointers_.CloseIOTrace = reinterpret_cast(shared_library_.get_function_pointer("nispy_CloseSpy")); - function_pointers_.GetApplicationPath = reinterpret_cast(shared_library_.get_function_pointer("nispy_GetApplicationPath")); + function_pointers_.GetIOTracePath = reinterpret_cast(shared_library_.get_function_pointer("nispy_GetApplicationPath")); function_pointers_.LogMessage = reinterpret_cast(shared_library_.get_function_pointer("nispy_WriteTextEntry")); function_pointers_.StartTracing = reinterpret_cast(shared_library_.get_function_pointer("nispy_StartSpying")); function_pointers_.StopTracing = reinterpret_cast(shared_library_.get_function_pointer("nispy_StopSpying")); @@ -51,15 +51,15 @@ int32_t IOTraceLibrary::CloseIOTrace() #endif } -int32_t IOTraceLibrary::GetApplicationPath(char pathString[256], int32_t pathStringSize) +int32_t IOTraceLibrary::GetIOTracePath(char pathString[256], int32_t pathStringSize) { - if (!function_pointers_.GetApplicationPath) { + if (!function_pointers_.GetIOTracePath) { throw nidevice_grpc::LibraryLoadException("Could not find nispy_GetApplicationPath."); } #if defined(_MSC_VER) return nispy_GetApplicationPath(pathString, pathStringSize); #else - return function_pointers_.GetApplicationPath(pathString, pathStringSize); + return function_pointers_.GetIOTracePath(pathString, pathStringSize); #endif } diff --git a/generated/iotrace/iotrace_library.h b/generated/iotrace/iotrace_library.h index 3f2fdd3c3..43a696d11 100644 --- a/generated/iotrace/iotrace_library.h +++ b/generated/iotrace/iotrace_library.h @@ -19,21 +19,21 @@ class IOTraceLibrary : public iotrace_grpc::IOTraceLibraryInterface { ::grpc::Status check_function_exists(std::string functionName); int32_t CloseIOTrace(); - int32_t GetApplicationPath(char pathString[256], int32_t pathStringSize); + int32_t GetIOTracePath(char pathString[256], int32_t pathStringSize); int32_t LogMessage(const char message[]); int32_t StartTracing(eNiSpyLogFileSetting logFileSetting, const char filePathString[], eNiSpyAPIFileWriteMode fileWriteMode); int32_t StopTracing(); private: using CloseIOTracePtr = decltype(&nispy_CloseSpy); - using GetApplicationPathPtr = decltype(&nispy_GetApplicationPath); + using GetIOTracePathPtr = decltype(&nispy_GetApplicationPath); using LogMessagePtr = decltype(&nispy_WriteTextEntry); using StartTracingPtr = decltype(&nispy_StartSpying); using StopTracingPtr = decltype(&nispy_StopSpying); typedef struct FunctionPointers { CloseIOTracePtr CloseIOTrace; - GetApplicationPathPtr GetApplicationPath; + GetIOTracePathPtr GetIOTracePath; LogMessagePtr LogMessage; StartTracingPtr StartTracing; StopTracingPtr StopTracing; diff --git a/generated/iotrace/iotrace_library_interface.h b/generated/iotrace/iotrace_library_interface.h index e0ebaffff..3382f9dcb 100644 --- a/generated/iotrace/iotrace_library_interface.h +++ b/generated/iotrace/iotrace_library_interface.h @@ -16,7 +16,7 @@ class IOTraceLibraryInterface { virtual ~IOTraceLibraryInterface() {} virtual int32_t CloseIOTrace() = 0; - virtual int32_t GetApplicationPath(char pathString[256], int32_t pathStringSize) = 0; + virtual int32_t GetIOTracePath(char pathString[256], int32_t pathStringSize) = 0; virtual int32_t LogMessage(const char message[]) = 0; virtual int32_t StartTracing(eNiSpyLogFileSetting logFileSetting, const char filePathString[], eNiSpyAPIFileWriteMode fileWriteMode) = 0; virtual int32_t StopTracing() = 0; diff --git a/generated/iotrace/iotrace_mock_library.h b/generated/iotrace/iotrace_mock_library.h index e84591bef..76e7fb168 100644 --- a/generated/iotrace/iotrace_mock_library.h +++ b/generated/iotrace/iotrace_mock_library.h @@ -18,7 +18,7 @@ namespace unit { class IOTraceMockLibrary : public iotrace_grpc::IOTraceLibraryInterface { public: MOCK_METHOD(int32_t, CloseIOTrace, (), (override)); - MOCK_METHOD(int32_t, GetApplicationPath, (char pathString[256], int32_t pathStringSize), (override)); + MOCK_METHOD(int32_t, GetIOTracePath, (char pathString[256], int32_t pathStringSize), (override)); MOCK_METHOD(int32_t, LogMessage, (const char message[]), (override)); MOCK_METHOD(int32_t, StartTracing, (eNiSpyLogFileSetting logFileSetting, const char filePathString[], eNiSpyAPIFileWriteMode fileWriteMode), (override)); MOCK_METHOD(int32_t, StopTracing, (), (override)); diff --git a/generated/iotrace/iotrace_service.cpp b/generated/iotrace/iotrace_service.cpp index b531e3fd8..213060557 100644 --- a/generated/iotrace/iotrace_service.cpp +++ b/generated/iotrace/iotrace_service.cpp @@ -60,7 +60,7 @@ namespace iotrace_grpc { //--------------------------------------------------------------------- //--------------------------------------------------------------------- - ::grpc::Status IOTraceService::GetApplicationPath(::grpc::ServerContext* context, const GetApplicationPathRequest* request, GetApplicationPathResponse* response) + ::grpc::Status IOTraceService::GetIOTracePath(::grpc::ServerContext* context, const GetIOTracePathRequest* request, GetIOTracePathResponse* response) { if (context->IsCancelled()) { return ::grpc::Status::CANCELLED; @@ -68,7 +68,7 @@ namespace iotrace_grpc { try { auto path_string_size = 256; std::string path_string(256 - 1, '\0'); - auto status = library_->GetApplicationPath((char*)path_string.data(), path_string_size); + auto status = library_->GetIOTracePath((char*)path_string.data(), path_string_size); response->set_status(status); if (status_ok(status)) { response->set_path_string(path_string); diff --git a/generated/iotrace/iotrace_service.h b/generated/iotrace/iotrace_service.h index 7a8a2c951..e92e228c7 100644 --- a/generated/iotrace/iotrace_service.h +++ b/generated/iotrace/iotrace_service.h @@ -42,7 +42,7 @@ class IOTraceService final : public IOTrace::Service { virtual ~IOTraceService(); ::grpc::Status CloseIOTrace(::grpc::ServerContext* context, const CloseIOTraceRequest* request, CloseIOTraceResponse* response) override; - ::grpc::Status GetApplicationPath(::grpc::ServerContext* context, const GetApplicationPathRequest* request, GetApplicationPathResponse* response) override; + ::grpc::Status GetIOTracePath(::grpc::ServerContext* context, const GetIOTracePathRequest* request, GetIOTracePathResponse* response) override; ::grpc::Status LogMessage(::grpc::ServerContext* context, const LogMessageRequest* request, LogMessageResponse* response) override; ::grpc::Status StartTracing(::grpc::ServerContext* context, const StartTracingRequest* request, StartTracingResponse* response) override; ::grpc::Status StopTracing(::grpc::ServerContext* context, const StopTracingRequest* request, StopTracingResponse* response) override; diff --git a/source/codegen/metadata/iotrace/functions.py b/source/codegen/metadata/iotrace/functions.py index e34aba6ed..73887eee7 100644 --- a/source/codegen/metadata/iotrace/functions.py +++ b/source/codegen/metadata/iotrace/functions.py @@ -7,7 +7,7 @@ ], 'returns': 'int32_t' }, - 'GetApplicationPath': { + 'GetIOTracePath': { 'cname': 'nispy_GetApplicationPath', 'parameters': [ { From 44cbef0b211c1664be53dc015d9013b612bbcd34 Mon Sep 17 00:00:00 2001 From: Ryan Eckenrode Date: Wed, 30 Mar 2022 17:50:45 -0500 Subject: [PATCH 09/18] Add a close test. --- source/tests/system/io_trace_api_tests.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/source/tests/system/io_trace_api_tests.cpp b/source/tests/system/io_trace_api_tests.cpp index 62838b2df..e837c380a 100644 --- a/source/tests/system/io_trace_api_tests.cpp +++ b/source/tests/system/io_trace_api_tests.cpp @@ -67,6 +67,15 @@ TEST_F(IOTraceApiTests, IOTraceIsStarted_StartTracing_Success) EXPECT_EQ(0, start_tracing_response.status()); } +TEST_F(IOTraceApiTests, IOTraceIsStarted_CloseIOTrace_Success) +{ + // Pre-requisite for test, start the IO Trace application + + auto start_tracing_response = client::close_io_trace(stub()); + + EXPECT_EQ(0, start_tracing_response.status()); +} + TEST_F(IOTraceApiTests, IOTraceIsStarted_StartTracingWithInvalidArgs_InvalidArgsResponse) { // Pre-requisite for test, start the IO Trace application From 8d9821f42c3dc876fa709314c47e86f36c5b9d82 Mon Sep 17 00:00:00 2001 From: Ryan Eckenrode Date: Wed, 30 Mar 2022 18:12:21 -0500 Subject: [PATCH 10/18] Tests for the remaining IO Trace methods. --- source/tests/system/io_trace_api_tests.cpp | 51 ++++++++++++++++------ 1 file changed, 38 insertions(+), 13 deletions(-) diff --git a/source/tests/system/io_trace_api_tests.cpp b/source/tests/system/io_trace_api_tests.cpp index e837c380a..190bb61ec 100644 --- a/source/tests/system/io_trace_api_tests.cpp +++ b/source/tests/system/io_trace_api_tests.cpp @@ -9,10 +9,6 @@ #include "device_server.h" #include "enumerate_devices.h" -#include "niRFSAErrors.h" -#include "nirfsa/nirfsa_client.h" -#include "niscope/niscope_client.h" -#include "nitclk/nitclk_client.h" using namespace iotrace_grpc; namespace client = iotrace_grpc::experimental::client; @@ -59,7 +55,7 @@ class IOTraceApiTests : public ::testing::Test { TEST_F(IOTraceApiTests, IOTraceIsStarted_StartTracing_Success) { - // Pre-requisite for test, start the IO Trace application + // Pre-requisite for test, IO Trace application is running std::string path = "C:\\Users\\reckenro\\Documents\\text-output.txt"; auto start_tracing_response = client::start_tracing(stub(), 1, path, 1); @@ -67,23 +63,52 @@ TEST_F(IOTraceApiTests, IOTraceIsStarted_StartTracing_Success) EXPECT_EQ(0, start_tracing_response.status()); } +TEST_F(IOTraceApiTests, IOTraceIsStarted_StartTracingWithInvalidArgs_InvalidArgsResponse) +{ + // Pre-requisite for test, IO Trace application is running + + std::string path = ""; // Empty string not allowed for file path. + auto start_tracing_response = client::start_tracing(stub(), 1, path, 1); + + EXPECT_EQ(-303204, start_tracing_response.status()); +} + +TEST_F(IOTraceApiTests, IOTraceIsStarted_StopTracing_Success) +{ + // Pre-requisite for test, IO Trace application is running + + auto stop_tracing_response = client::stop_tracing(stub()); + + EXPECT_EQ(0, stop_tracing_response.status()); +} + TEST_F(IOTraceApiTests, IOTraceIsStarted_CloseIOTrace_Success) { - // Pre-requisite for test, start the IO Trace application + // Pre-requisite for test, IO Trace application is running - auto start_tracing_response = client::close_io_trace(stub()); + auto close_trace_response = client::close_io_trace(stub()); - EXPECT_EQ(0, start_tracing_response.status()); + EXPECT_EQ(0, close_trace_response.status()); } -TEST_F(IOTraceApiTests, IOTraceIsStarted_StartTracingWithInvalidArgs_InvalidArgsResponse) +TEST_F(IOTraceApiTests, IOTraceIsInstalled_GetIOTracePath_SuccessAndGetsAppPath) { - // Pre-requisite for test, start the IO Trace application + // Pre-requisite for test, IO Trace application is running - std::string path = ""; // Empty string not allowed for file path. - auto start_tracing_response = client::start_tracing(stub(), 1, path, 1); + auto io_trace_path_response = client::get_io_trace_path(stub()); - EXPECT_EQ(-303204, start_tracing_response.status()); + EXPECT_EQ(0, io_trace_path_response.status()); + EXPECT_STRNE("", io_trace_path_response.path_string().c_str()); +} + +TEST_F(IOTraceApiTests, IOTraceIsStarted_LogMessage_Success) +{ + // Pre-requisite for test, IO Trace application is running + + std::string message = "Hello World!"; + auto log_message_response = client::log_message(stub(), message); + + EXPECT_EQ(0, log_message_response.status()); } } // namespace From b2ac12efff955f6c122535babb8c5da41d56304f Mon Sep 17 00:00:00 2001 From: Ryan Eckenrode Date: Thu, 31 Mar 2022 13:02:05 -0500 Subject: [PATCH 11/18] Add enums. --- generated/iotrace/iotrace.proto | 32 ++++++- generated/iotrace/iotrace_client.cpp | 2 +- generated/iotrace/iotrace_client.h | 2 +- generated/iotrace/iotrace_library.cpp | 10 +- generated/iotrace/iotrace_library.h | 10 +- generated/iotrace/iotrace_library_interface.h | 10 +- generated/iotrace/iotrace_mock_library.h | 10 +- source/codegen/client_helpers.py | 6 +- source/codegen/metadata/iotrace/config.py | 7 +- source/codegen/metadata/iotrace/enums.py | 94 ++++++++++++++++++- source/codegen/metadata/iotrace/functions.py | 16 ++-- source/codegen/metadata_validation.py | 1 + source/tests/system/io_trace_api_tests.cpp | 6 +- 13 files changed, 167 insertions(+), 39 deletions(-) diff --git a/generated/iotrace/iotrace.proto b/generated/iotrace/iotrace.proto index 6806e5caf..e0bc1668c 100644 --- a/generated/iotrace/iotrace.proto +++ b/generated/iotrace/iotrace.proto @@ -27,6 +27,34 @@ enum IOTraceAttribute { IOTRACE_ATTRIBUTE_UNSPECIFIED = 0; } +enum FileWriteMode { + FILE_WRITE_MODE_CreateOnly = 0; + FILE_WRITE_MODE_CreateOrAppend = 1; + FILE_WRITE_MODE_CreateOrOverwrite = 2; +} + +enum LogFileSetting { + LOG_FILE_SETTING_Spy = 0; + LOG_FILE_SETTING_NoFile = -1; + LOG_FILE_SETTING_PlainText = 1; + LOG_FILE_SETTING_CommaSeparated = 2; + LOG_FILE_SETTING_SettingXml = 3; +} + +enum CommandStatus { + COMMAND_STATUS_Success = 0; + COMMAND_STATUS_NoExecute = -303200; + COMMAND_STATUS_IncompatibleState = -303201; + COMMAND_STATUS_UnableToOpenLogFile = -303202; + COMMAND_STATUS_IOTraceClosed = -303203; + COMMAND_STATUS_InvalidSettings = -303204; + COMMAND_STATUS_BadParameter = -303205; + COMMAND_STATUS_InternalFailure = -303206; + COMMAND_STATUS_InvalidFileExtension = -303207; + COMMAND_STATUS_BufferTooSmall = -303208; + COMMAND_STATUS_FileAlreadyExists = -303209; +} + message CloseIOTraceRequest { } @@ -51,9 +79,9 @@ message LogMessageResponse { } message StartTracingRequest { - int32 log_file_setting = 1; + LogFileSetting log_file_setting = 1; string file_path_string = 2; - int32 file_write_mode = 3; + FileWriteMode file_write_mode = 3; } message StartTracingResponse { diff --git a/generated/iotrace/iotrace_client.cpp b/generated/iotrace/iotrace_client.cpp index 49b93a4e6..e2266fd93 100644 --- a/generated/iotrace/iotrace_client.cpp +++ b/generated/iotrace/iotrace_client.cpp @@ -64,7 +64,7 @@ log_message(const StubPtr& stub, const pb::string& message) } StartTracingResponse -start_tracing(const StubPtr& stub, const pb::int32& log_file_setting, const pb::string& file_path_string, const pb::int32& file_write_mode) +start_tracing(const StubPtr& stub, const LogFileSetting& log_file_setting, const pb::string& file_path_string, const FileWriteMode& file_write_mode) { ::grpc::ClientContext context; diff --git a/generated/iotrace/iotrace_client.h b/generated/iotrace/iotrace_client.h index 947a973bc..5f819ce38 100644 --- a/generated/iotrace/iotrace_client.h +++ b/generated/iotrace/iotrace_client.h @@ -25,7 +25,7 @@ using namespace nidevice_grpc::experimental::client; CloseIOTraceResponse close_io_trace(const StubPtr& stub); GetIOTracePathResponse get_io_trace_path(const StubPtr& stub); LogMessageResponse log_message(const StubPtr& stub, const pb::string& message); -StartTracingResponse start_tracing(const StubPtr& stub, const pb::int32& log_file_setting, const pb::string& file_path_string, const pb::int32& file_write_mode); +StartTracingResponse start_tracing(const StubPtr& stub, const LogFileSetting& log_file_setting, const pb::string& file_path_string, const FileWriteMode& file_write_mode); StopTracingResponse stop_tracing(const StubPtr& stub); } // namespace iotrace_grpc::experimental::client diff --git a/generated/iotrace/iotrace_library.cpp b/generated/iotrace/iotrace_library.cpp index 842b930df..16efbbdbf 100644 --- a/generated/iotrace/iotrace_library.cpp +++ b/generated/iotrace/iotrace_library.cpp @@ -39,7 +39,7 @@ ::grpc::Status IOTraceLibrary::check_function_exists(std::string functionName) : ::grpc::Status(::grpc::NOT_FOUND, "Could not find the function " + functionName); } -int32_t IOTraceLibrary::CloseIOTrace() +eNiSpyAPICommandStatus IOTraceLibrary::CloseIOTrace() { if (!function_pointers_.CloseIOTrace) { throw nidevice_grpc::LibraryLoadException("Could not find nispy_CloseSpy."); @@ -51,7 +51,7 @@ int32_t IOTraceLibrary::CloseIOTrace() #endif } -int32_t IOTraceLibrary::GetIOTracePath(char pathString[256], int32_t pathStringSize) +eNiSpyAPICommandStatus IOTraceLibrary::GetIOTracePath(char pathString[256], int32_t pathStringSize) { if (!function_pointers_.GetIOTracePath) { throw nidevice_grpc::LibraryLoadException("Could not find nispy_GetApplicationPath."); @@ -63,7 +63,7 @@ int32_t IOTraceLibrary::GetIOTracePath(char pathString[256], int32_t pathStringS #endif } -int32_t IOTraceLibrary::LogMessage(const char message[]) +eNiSpyAPICommandStatus IOTraceLibrary::LogMessage(const char message[]) { if (!function_pointers_.LogMessage) { throw nidevice_grpc::LibraryLoadException("Could not find nispy_WriteTextEntry."); @@ -75,7 +75,7 @@ int32_t IOTraceLibrary::LogMessage(const char message[]) #endif } -int32_t IOTraceLibrary::StartTracing(eNiSpyLogFileSetting logFileSetting, const char filePathString[], eNiSpyAPIFileWriteMode fileWriteMode) +eNiSpyAPICommandStatus IOTraceLibrary::StartTracing(eNiSpyLogFileSetting logFileSetting, const char filePathString[], eNiSpyAPIFileWriteMode fileWriteMode) { if (!function_pointers_.StartTracing) { throw nidevice_grpc::LibraryLoadException("Could not find nispy_StartSpying."); @@ -87,7 +87,7 @@ int32_t IOTraceLibrary::StartTracing(eNiSpyLogFileSetting logFileSetting, const #endif } -int32_t IOTraceLibrary::StopTracing() +eNiSpyAPICommandStatus IOTraceLibrary::StopTracing() { if (!function_pointers_.StopTracing) { throw nidevice_grpc::LibraryLoadException("Could not find nispy_StopSpying."); diff --git a/generated/iotrace/iotrace_library.h b/generated/iotrace/iotrace_library.h index 43a696d11..34c51daa7 100644 --- a/generated/iotrace/iotrace_library.h +++ b/generated/iotrace/iotrace_library.h @@ -18,11 +18,11 @@ class IOTraceLibrary : public iotrace_grpc::IOTraceLibraryInterface { virtual ~IOTraceLibrary(); ::grpc::Status check_function_exists(std::string functionName); - int32_t CloseIOTrace(); - int32_t GetIOTracePath(char pathString[256], int32_t pathStringSize); - int32_t LogMessage(const char message[]); - int32_t StartTracing(eNiSpyLogFileSetting logFileSetting, const char filePathString[], eNiSpyAPIFileWriteMode fileWriteMode); - int32_t StopTracing(); + eNiSpyAPICommandStatus CloseIOTrace(); + eNiSpyAPICommandStatus GetIOTracePath(char pathString[256], int32_t pathStringSize); + eNiSpyAPICommandStatus LogMessage(const char message[]); + eNiSpyAPICommandStatus StartTracing(eNiSpyLogFileSetting logFileSetting, const char filePathString[], eNiSpyAPIFileWriteMode fileWriteMode); + eNiSpyAPICommandStatus StopTracing(); private: using CloseIOTracePtr = decltype(&nispy_CloseSpy); diff --git a/generated/iotrace/iotrace_library_interface.h b/generated/iotrace/iotrace_library_interface.h index 3382f9dcb..80e8cc278 100644 --- a/generated/iotrace/iotrace_library_interface.h +++ b/generated/iotrace/iotrace_library_interface.h @@ -15,11 +15,11 @@ class IOTraceLibraryInterface { public: virtual ~IOTraceLibraryInterface() {} - virtual int32_t CloseIOTrace() = 0; - virtual int32_t GetIOTracePath(char pathString[256], int32_t pathStringSize) = 0; - virtual int32_t LogMessage(const char message[]) = 0; - virtual int32_t StartTracing(eNiSpyLogFileSetting logFileSetting, const char filePathString[], eNiSpyAPIFileWriteMode fileWriteMode) = 0; - virtual int32_t StopTracing() = 0; + virtual eNiSpyAPICommandStatus CloseIOTrace() = 0; + virtual eNiSpyAPICommandStatus GetIOTracePath(char pathString[256], int32_t pathStringSize) = 0; + virtual eNiSpyAPICommandStatus LogMessage(const char message[]) = 0; + virtual eNiSpyAPICommandStatus StartTracing(eNiSpyLogFileSetting logFileSetting, const char filePathString[], eNiSpyAPIFileWriteMode fileWriteMode) = 0; + virtual eNiSpyAPICommandStatus StopTracing() = 0; }; } // namespace iotrace_grpc diff --git a/generated/iotrace/iotrace_mock_library.h b/generated/iotrace/iotrace_mock_library.h index 76e7fb168..cbfd13dc3 100644 --- a/generated/iotrace/iotrace_mock_library.h +++ b/generated/iotrace/iotrace_mock_library.h @@ -17,11 +17,11 @@ namespace unit { class IOTraceMockLibrary : public iotrace_grpc::IOTraceLibraryInterface { public: - MOCK_METHOD(int32_t, CloseIOTrace, (), (override)); - MOCK_METHOD(int32_t, GetIOTracePath, (char pathString[256], int32_t pathStringSize), (override)); - MOCK_METHOD(int32_t, LogMessage, (const char message[]), (override)); - MOCK_METHOD(int32_t, StartTracing, (eNiSpyLogFileSetting logFileSetting, const char filePathString[], eNiSpyAPIFileWriteMode fileWriteMode), (override)); - MOCK_METHOD(int32_t, StopTracing, (), (override)); + MOCK_METHOD(eNiSpyAPICommandStatus, CloseIOTrace, (), (override)); + MOCK_METHOD(eNiSpyAPICommandStatus, GetIOTracePath, (char pathString[256], int32_t pathStringSize), (override)); + MOCK_METHOD(eNiSpyAPICommandStatus, LogMessage, (const char message[]), (override)); + MOCK_METHOD(eNiSpyAPICommandStatus, StartTracing, (eNiSpyLogFileSetting logFileSetting, const char filePathString[], eNiSpyAPIFileWriteMode fileWriteMode), (override)); + MOCK_METHOD(eNiSpyAPICommandStatus, StopTracing, (), (override)); }; } // namespace unit diff --git a/source/codegen/client_helpers.py b/source/codegen/client_helpers.py index fcb41532b..8cfe2e5d5 100644 --- a/source/codegen/client_helpers.py +++ b/source/codegen/client_helpers.py @@ -124,6 +124,10 @@ def _const_ref_t(t: str) -> str: return f"const {t}&" +def _is_enum(param: dict) -> bool: + return param.get("actual_enum", False) + + def _get_param_mechanism(param: dict) -> ParamMechanism: if _is_grpc_array(param): return ParamMechanism.ARRAY @@ -133,7 +137,7 @@ def _get_param_mechanism(param: dict) -> ParamMechanism: return ParamMechanism.ENUM if "mapped-enum" in param: return ParamMechanism.MAPPED_ENUM - if _is_basic_type(param["grpc_type"]): + if _is_basic_type(param["grpc_type"]) or _is_enum(param): return ParamMechanism.BASIC return ParamMechanism.COPY diff --git a/source/codegen/metadata/iotrace/config.py b/source/codegen/metadata/iotrace/config.py index e0a415a34..79eb82e28 100644 --- a/source/codegen/metadata/iotrace/config.py +++ b/source/codegen/metadata/iotrace/config.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# This file is generated from IOO Trace API metadata version 18.2 +# This file is generated from IO Trace API metadata version 18.2 config = { "api_version": "18.2", "c_header": "NiSpyAPI.h", @@ -15,8 +15,9 @@ "char[]": "string", "int32_t": "int32", "int": "int32", - "eNiSpyLogFileSetting": "int32", - "eNiSpyAPIFileWriteMode": "int32", + "eNiSpyLogFileSetting": "LogFileSetting", + "eNiSpyAPIFileWriteMode": "FileWriteMode", + "eNiSpyAPICommandStatus": "CommandStatus", }, "driver_name": "IO-TRACE", "status_ok": "status >= 0", diff --git a/source/codegen/metadata/iotrace/enums.py b/source/codegen/metadata/iotrace/enums.py index 4b9db3c2e..e742b14c0 100644 --- a/source/codegen/metadata/iotrace/enums.py +++ b/source/codegen/metadata/iotrace/enums.py @@ -1,3 +1,95 @@ # -*- coding: utf-8 -*- # This file is generated from NI-SCOPE API metadata version 20.5.0d7 -enums = {} +enums = { + 'FileWriteMode': { + 'force-include': True, + 'values': [ + { + 'name': 'CreateOnly', + 'value': 0 + }, + { + 'name': 'CreateOrAppend', + 'value': 1 + }, + { + 'name': 'CreateOrOverwrite', + 'value': 2 + }, + ] + }, + 'LogFileSetting': { + 'force-include': True, + 'values': [ + { + 'name': 'NoFile', + 'value': -1 + }, + { + 'name': 'Spy', + 'value': 0 + }, + { + 'name': 'PlainText', + 'value': 1 + }, + { + 'name': 'CommaSeparated', + 'value': 2 + }, + { + 'name': 'SettingXml', + 'value': 3 + }, + ] + }, + 'CommandStatus': { + 'force-include': True, + 'values': [ + { + 'name': 'Success', + 'value': 0 + }, + { + 'name': 'NoExecute', + 'value': -303200 + }, + { + 'name': 'IncompatibleState', + 'value': -303201 + }, + { + 'name': 'UnableToOpenLogFile', + 'value': -303202 + }, + { + 'name': 'IOTraceClosed', + 'value': -303203 + }, + { + 'name': 'InvalidSettings', + 'value': -303204 + }, + { + 'name': 'BadParameter', + 'value': -303205 + }, + { + 'name': 'InternalFailure', + 'value': -303206 + }, + { + 'name': 'InvalidFileExtension', + 'value': -303207 + }, + { + 'name': 'BufferTooSmall', + 'value': -303208 + }, + { + 'name': 'FileAlreadyExists', + 'value': -303209 + }, + ] + }, +} diff --git a/source/codegen/metadata/iotrace/functions.py b/source/codegen/metadata/iotrace/functions.py index 73887eee7..c48deb35c 100644 --- a/source/codegen/metadata/iotrace/functions.py +++ b/source/codegen/metadata/iotrace/functions.py @@ -5,7 +5,7 @@ 'cname': 'nispy_CloseSpy', 'parameters': [ ], - 'returns': 'int32_t' + 'returns': 'eNiSpyAPICommandStatus' }, 'GetIOTracePath': { 'cname': 'nispy_GetApplicationPath', @@ -27,7 +27,7 @@ 'hardcoded_value': '256' } ], - 'returns': 'int32_t' + 'returns': 'eNiSpyAPICommandStatus' }, 'LogMessage': { 'cname': 'nispy_WriteTextEntry', @@ -38,7 +38,7 @@ 'type': 'const char[]' } ], - 'returns': 'int32_t' + 'returns': 'eNiSpyAPICommandStatus' }, 'StartTracing': { 'cname': 'nispy_StartSpying', @@ -48,6 +48,7 @@ 'name': 'logFileSetting', 'type': 'eNiSpyLogFileSetting', 'supports_standard_copy_convert': True, + 'actual_enum': True }, { 'direction': 'in', @@ -58,15 +59,16 @@ 'direction': 'in', 'name': 'fileWriteMode', 'type': 'eNiSpyAPIFileWriteMode', - 'supports_standard_copy_convert': True - } + 'supports_standard_copy_convert': True, + 'actual_enum': True + }, ], - 'returns': 'int32_t' + 'returns': 'eNiSpyAPICommandStatus' }, 'StopTracing': { 'cname': 'nispy_StopSpying', 'parameters': [ ], - 'returns': 'int32_t' + 'returns': 'eNiSpyAPICommandStatus' }, } diff --git a/source/codegen/metadata_validation.py b/source/codegen/metadata_validation.py index 06bcb9dfc..256fa9d15 100644 --- a/source/codegen/metadata_validation.py +++ b/source/codegen/metadata_validation.py @@ -85,6 +85,7 @@ class RULES: Optional("additional_arguments_to_output_allocation"): [str], Optional("proto_only"): bool, Optional("input_passed_by_ptr"): bool, + Optional("actual_enum"): bool, } ) diff --git a/source/tests/system/io_trace_api_tests.cpp b/source/tests/system/io_trace_api_tests.cpp index 190bb61ec..9cd45d282 100644 --- a/source/tests/system/io_trace_api_tests.cpp +++ b/source/tests/system/io_trace_api_tests.cpp @@ -58,7 +58,7 @@ TEST_F(IOTraceApiTests, IOTraceIsStarted_StartTracing_Success) // Pre-requisite for test, IO Trace application is running std::string path = "C:\\Users\\reckenro\\Documents\\text-output.txt"; - auto start_tracing_response = client::start_tracing(stub(), 1, path, 1); + auto start_tracing_response = client::start_tracing(stub(), LOG_FILE_SETTING_PlainText, path, FILE_WRITE_MODE_CreateOrAppend); EXPECT_EQ(0, start_tracing_response.status()); } @@ -68,9 +68,9 @@ TEST_F(IOTraceApiTests, IOTraceIsStarted_StartTracingWithInvalidArgs_InvalidArgs // Pre-requisite for test, IO Trace application is running std::string path = ""; // Empty string not allowed for file path. - auto start_tracing_response = client::start_tracing(stub(), 1, path, 1); + auto start_tracing_response = client::start_tracing(stub(), LOG_FILE_SETTING_PlainText, path, FILE_WRITE_MODE_CreateOrAppend); - EXPECT_EQ(-303204, start_tracing_response.status()); + EXPECT_EQ(COMMAND_STATUS_InvalidSettings, start_tracing_response.status()); } TEST_F(IOTraceApiTests, IOTraceIsStarted_StopTracing_Success) From 63234dab7fd7f648799939a9b83d0af16b4c72e4 Mon Sep 17 00:00:00 2001 From: Ryan Eckenrode Date: Thu, 31 Mar 2022 13:14:08 -0500 Subject: [PATCH 12/18] Set iotrace service to next release. --- generated/iotrace/iotrace_service.cpp | 2 +- source/codegen/metadata/iotrace/config.py | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/generated/iotrace/iotrace_service.cpp b/generated/iotrace/iotrace_service.cpp index 213060557..57cd0c926 100644 --- a/generated/iotrace/iotrace_service.cpp +++ b/generated/iotrace/iotrace_service.cpp @@ -140,7 +140,7 @@ namespace iotrace_grpc { IOTraceFeatureToggles::IOTraceFeatureToggles( const nidevice_grpc::FeatureToggles& feature_toggles) : is_enabled( - feature_toggles.is_feature_enabled("iotrace", CodeReadiness::kRelease)) + feature_toggles.is_feature_enabled("iotrace", CodeReadiness::kNextRelease)) { } } // namespace iotrace_grpc diff --git a/source/codegen/metadata/iotrace/config.py b/source/codegen/metadata/iotrace/config.py index 79eb82e28..67e0ced0f 100644 --- a/source/codegen/metadata/iotrace/config.py +++ b/source/codegen/metadata/iotrace/config.py @@ -30,4 +30,5 @@ }, "metadata_version": "2.0", "module_name": "iotrace", + "code_readiness": "NextRelease", } From 34698f6633b161e656fcd96333ef3229be83a92a Mon Sep 17 00:00:00 2001 From: Ryan Eckenrode Date: Thu, 31 Mar 2022 13:32:40 -0500 Subject: [PATCH 13/18] Mark GetIOTracePath as a private method. --- generated/iotrace/iotrace.proto | 9 -------- generated/iotrace/iotrace_client.cpp | 15 ------------- generated/iotrace/iotrace_client.h | 1 - generated/iotrace/iotrace_library.cpp | 8 ++----- generated/iotrace/iotrace_library.h | 2 +- generated/iotrace/iotrace_service.cpp | 23 -------------------- generated/iotrace/iotrace_service.h | 1 - source/codegen/metadata/iotrace/functions.py | 2 +- source/tests/system/io_trace_api_tests.cpp | 8 ++++--- 9 files changed, 9 insertions(+), 60 deletions(-) diff --git a/generated/iotrace/iotrace.proto b/generated/iotrace/iotrace.proto index e0bc1668c..93bfc04b3 100644 --- a/generated/iotrace/iotrace.proto +++ b/generated/iotrace/iotrace.proto @@ -17,7 +17,6 @@ import "session.proto"; service IOTrace { rpc CloseIOTrace(CloseIOTraceRequest) returns (CloseIOTraceResponse); - rpc GetIOTracePath(GetIOTracePathRequest) returns (GetIOTracePathResponse); rpc LogMessage(LogMessageRequest) returns (LogMessageResponse); rpc StartTracing(StartTracingRequest) returns (StartTracingResponse); rpc StopTracing(StopTracingRequest) returns (StopTracingResponse); @@ -62,14 +61,6 @@ message CloseIOTraceResponse { int32 status = 1; } -message GetIOTracePathRequest { -} - -message GetIOTracePathResponse { - int32 status = 1; - string path_string = 2; -} - message LogMessageRequest { string message = 1; } diff --git a/generated/iotrace/iotrace_client.cpp b/generated/iotrace/iotrace_client.cpp index e2266fd93..c2d5596ed 100644 --- a/generated/iotrace/iotrace_client.cpp +++ b/generated/iotrace/iotrace_client.cpp @@ -32,21 +32,6 @@ close_io_trace(const StubPtr& stub) return response; } -GetIOTracePathResponse -get_io_trace_path(const StubPtr& stub) -{ - ::grpc::ClientContext context; - - auto request = GetIOTracePathRequest{}; - - auto response = GetIOTracePathResponse{}; - - raise_if_error( - stub->GetIOTracePath(&context, request, &response)); - - return response; -} - LogMessageResponse log_message(const StubPtr& stub, const pb::string& message) { diff --git a/generated/iotrace/iotrace_client.h b/generated/iotrace/iotrace_client.h index 5f819ce38..0801ea137 100644 --- a/generated/iotrace/iotrace_client.h +++ b/generated/iotrace/iotrace_client.h @@ -23,7 +23,6 @@ using namespace nidevice_grpc::experimental::client; CloseIOTraceResponse close_io_trace(const StubPtr& stub); -GetIOTracePathResponse get_io_trace_path(const StubPtr& stub); LogMessageResponse log_message(const StubPtr& stub, const pb::string& message); StartTracingResponse start_tracing(const StubPtr& stub, const LogFileSetting& log_file_setting, const pb::string& file_path_string, const FileWriteMode& file_write_mode); StopTracingResponse stop_tracing(const StubPtr& stub); diff --git a/generated/iotrace/iotrace_library.cpp b/generated/iotrace/iotrace_library.cpp index 16efbbdbf..277e87081 100644 --- a/generated/iotrace/iotrace_library.cpp +++ b/generated/iotrace/iotrace_library.cpp @@ -22,7 +22,7 @@ IOTraceLibrary::IOTraceLibrary() : shared_library_(kLibraryName) return; } function_pointers_.CloseIOTrace = reinterpret_cast(shared_library_.get_function_pointer("nispy_CloseSpy")); - function_pointers_.GetIOTracePath = reinterpret_cast(shared_library_.get_function_pointer("nispy_GetApplicationPath")); + function_pointers_.GetIOTracePath = reinterpret_cast(shared_library_.get_function_pointer("nispy_GetIOTracePath")); function_pointers_.LogMessage = reinterpret_cast(shared_library_.get_function_pointer("nispy_WriteTextEntry")); function_pointers_.StartTracing = reinterpret_cast(shared_library_.get_function_pointer("nispy_StartSpying")); function_pointers_.StopTracing = reinterpret_cast(shared_library_.get_function_pointer("nispy_StopSpying")); @@ -54,13 +54,9 @@ eNiSpyAPICommandStatus IOTraceLibrary::CloseIOTrace() eNiSpyAPICommandStatus IOTraceLibrary::GetIOTracePath(char pathString[256], int32_t pathStringSize) { if (!function_pointers_.GetIOTracePath) { - throw nidevice_grpc::LibraryLoadException("Could not find nispy_GetApplicationPath."); + throw nidevice_grpc::LibraryLoadException("Could not find nispy_GetIOTracePath."); } -#if defined(_MSC_VER) - return nispy_GetApplicationPath(pathString, pathStringSize); -#else return function_pointers_.GetIOTracePath(pathString, pathStringSize); -#endif } eNiSpyAPICommandStatus IOTraceLibrary::LogMessage(const char message[]) diff --git a/generated/iotrace/iotrace_library.h b/generated/iotrace/iotrace_library.h index 34c51daa7..26d0085da 100644 --- a/generated/iotrace/iotrace_library.h +++ b/generated/iotrace/iotrace_library.h @@ -26,7 +26,7 @@ class IOTraceLibrary : public iotrace_grpc::IOTraceLibraryInterface { private: using CloseIOTracePtr = decltype(&nispy_CloseSpy); - using GetIOTracePathPtr = decltype(&nispy_GetApplicationPath); + using GetIOTracePathPtr = eNiSpyAPICommandStatus (*)(char pathString[256], int32_t pathStringSize); using LogMessagePtr = decltype(&nispy_WriteTextEntry); using StartTracingPtr = decltype(&nispy_StartSpying); using StopTracingPtr = decltype(&nispy_StopSpying); diff --git a/generated/iotrace/iotrace_service.cpp b/generated/iotrace/iotrace_service.cpp index 57cd0c926..4ec341f98 100644 --- a/generated/iotrace/iotrace_service.cpp +++ b/generated/iotrace/iotrace_service.cpp @@ -58,29 +58,6 @@ namespace iotrace_grpc { } } - //--------------------------------------------------------------------- - //--------------------------------------------------------------------- - ::grpc::Status IOTraceService::GetIOTracePath(::grpc::ServerContext* context, const GetIOTracePathRequest* request, GetIOTracePathResponse* response) - { - if (context->IsCancelled()) { - return ::grpc::Status::CANCELLED; - } - try { - auto path_string_size = 256; - std::string path_string(256 - 1, '\0'); - auto status = library_->GetIOTracePath((char*)path_string.data(), path_string_size); - response->set_status(status); - if (status_ok(status)) { - response->set_path_string(path_string); - nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_path_string())); - } - return ::grpc::Status::OK; - } - catch (nidevice_grpc::LibraryLoadException& ex) { - return ::grpc::Status(::grpc::NOT_FOUND, ex.what()); - } - } - //--------------------------------------------------------------------- //--------------------------------------------------------------------- ::grpc::Status IOTraceService::LogMessage(::grpc::ServerContext* context, const LogMessageRequest* request, LogMessageResponse* response) diff --git a/generated/iotrace/iotrace_service.h b/generated/iotrace/iotrace_service.h index e92e228c7..6397f03b1 100644 --- a/generated/iotrace/iotrace_service.h +++ b/generated/iotrace/iotrace_service.h @@ -42,7 +42,6 @@ class IOTraceService final : public IOTrace::Service { virtual ~IOTraceService(); ::grpc::Status CloseIOTrace(::grpc::ServerContext* context, const CloseIOTraceRequest* request, CloseIOTraceResponse* response) override; - ::grpc::Status GetIOTracePath(::grpc::ServerContext* context, const GetIOTracePathRequest* request, GetIOTracePathResponse* response) override; ::grpc::Status LogMessage(::grpc::ServerContext* context, const LogMessageRequest* request, LogMessageResponse* response) override; ::grpc::Status StartTracing(::grpc::ServerContext* context, const StartTracingRequest* request, StartTracingResponse* response) override; ::grpc::Status StopTracing(::grpc::ServerContext* context, const StopTracingRequest* request, StopTracingResponse* response) override; diff --git a/source/codegen/metadata/iotrace/functions.py b/source/codegen/metadata/iotrace/functions.py index c48deb35c..ac38ffe66 100644 --- a/source/codegen/metadata/iotrace/functions.py +++ b/source/codegen/metadata/iotrace/functions.py @@ -8,7 +8,7 @@ 'returns': 'eNiSpyAPICommandStatus' }, 'GetIOTracePath': { - 'cname': 'nispy_GetApplicationPath', + 'codegen_method': 'private', 'parameters': [ { 'direction': 'out', diff --git a/source/tests/system/io_trace_api_tests.cpp b/source/tests/system/io_trace_api_tests.cpp index 9cd45d282..eaf414811 100644 --- a/source/tests/system/io_trace_api_tests.cpp +++ b/source/tests/system/io_trace_api_tests.cpp @@ -95,10 +95,12 @@ TEST_F(IOTraceApiTests, IOTraceIsInstalled_GetIOTracePath_SuccessAndGetsAppPath) { // Pre-requisite for test, IO Trace application is running - auto io_trace_path_response = client::get_io_trace_path(stub()); + // TODO: This should become launch io trace test. - EXPECT_EQ(0, io_trace_path_response.status()); - EXPECT_STRNE("", io_trace_path_response.path_string().c_str()); + // auto io_trace_path_response = client::get_io_trace_path(stub()); + + // EXPECT_EQ(0, io_trace_path_response.status()); + // EXPECT_STRNE("", io_trace_path_response.path_string().c_str()); } TEST_F(IOTraceApiTests, IOTraceIsStarted_LogMessage_Success) From 02dec6bb5cc119cf172f7eb2edfcf84ce8659ccb Mon Sep 17 00:00:00 2001 From: Ryan Eckenrode Date: Thu, 31 Mar 2022 16:32:26 -0500 Subject: [PATCH 14/18] Implement LaunchIOTrace. --- generated/iotrace/iotrace.proto | 8 ++++++ generated/iotrace/iotrace_client.cpp | 15 +++++++++++ generated/iotrace/iotrace_client.h | 1 + generated/iotrace/iotrace_library.cpp | 4 +-- generated/iotrace/iotrace_service.h | 1 + source/codegen/common_helpers.py | 4 +-- source/codegen/metadata/iotrace/functions.py | 6 +++++ source/codegen/metadata_validation.py | 1 + source/codegen/service_helpers.py | 2 +- source/custom/iotrace_service.custom.cpp | 28 ++++++++++++++++++++ source/tests/system/io_trace_api_tests.cpp | 17 +++++------- 11 files changed, 72 insertions(+), 15 deletions(-) diff --git a/generated/iotrace/iotrace.proto b/generated/iotrace/iotrace.proto index 93bfc04b3..1174df97f 100644 --- a/generated/iotrace/iotrace.proto +++ b/generated/iotrace/iotrace.proto @@ -18,6 +18,7 @@ import "session.proto"; service IOTrace { rpc CloseIOTrace(CloseIOTraceRequest) returns (CloseIOTraceResponse); rpc LogMessage(LogMessageRequest) returns (LogMessageResponse); + rpc OpenIOTrace(OpenIOTraceRequest) returns (OpenIOTraceResponse); rpc StartTracing(StartTracingRequest) returns (StartTracingResponse); rpc StopTracing(StopTracingRequest) returns (StopTracingResponse); } @@ -69,6 +70,13 @@ message LogMessageResponse { int32 status = 1; } +message OpenIOTraceRequest { +} + +message OpenIOTraceResponse { + int32 status = 1; +} + message StartTracingRequest { LogFileSetting log_file_setting = 1; string file_path_string = 2; diff --git a/generated/iotrace/iotrace_client.cpp b/generated/iotrace/iotrace_client.cpp index c2d5596ed..45f2525f3 100644 --- a/generated/iotrace/iotrace_client.cpp +++ b/generated/iotrace/iotrace_client.cpp @@ -48,6 +48,21 @@ log_message(const StubPtr& stub, const pb::string& message) return response; } +OpenIOTraceResponse +open_io_trace(const StubPtr& stub) +{ + ::grpc::ClientContext context; + + auto request = OpenIOTraceRequest{}; + + auto response = OpenIOTraceResponse{}; + + raise_if_error( + stub->OpenIOTrace(&context, request, &response)); + + return response; +} + StartTracingResponse start_tracing(const StubPtr& stub, const LogFileSetting& log_file_setting, const pb::string& file_path_string, const FileWriteMode& file_write_mode) { diff --git a/generated/iotrace/iotrace_client.h b/generated/iotrace/iotrace_client.h index 0801ea137..f54d711d5 100644 --- a/generated/iotrace/iotrace_client.h +++ b/generated/iotrace/iotrace_client.h @@ -24,6 +24,7 @@ using namespace nidevice_grpc::experimental::client; CloseIOTraceResponse close_io_trace(const StubPtr& stub); LogMessageResponse log_message(const StubPtr& stub, const pb::string& message); +OpenIOTraceResponse open_io_trace(const StubPtr& stub); StartTracingResponse start_tracing(const StubPtr& stub, const LogFileSetting& log_file_setting, const pb::string& file_path_string, const FileWriteMode& file_write_mode); StopTracingResponse stop_tracing(const StubPtr& stub); diff --git a/generated/iotrace/iotrace_library.cpp b/generated/iotrace/iotrace_library.cpp index 277e87081..db3805422 100644 --- a/generated/iotrace/iotrace_library.cpp +++ b/generated/iotrace/iotrace_library.cpp @@ -22,7 +22,7 @@ IOTraceLibrary::IOTraceLibrary() : shared_library_(kLibraryName) return; } function_pointers_.CloseIOTrace = reinterpret_cast(shared_library_.get_function_pointer("nispy_CloseSpy")); - function_pointers_.GetIOTracePath = reinterpret_cast(shared_library_.get_function_pointer("nispy_GetIOTracePath")); + function_pointers_.GetIOTracePath = reinterpret_cast(shared_library_.get_function_pointer("nispy_GetApplicationPath")); function_pointers_.LogMessage = reinterpret_cast(shared_library_.get_function_pointer("nispy_WriteTextEntry")); function_pointers_.StartTracing = reinterpret_cast(shared_library_.get_function_pointer("nispy_StartSpying")); function_pointers_.StopTracing = reinterpret_cast(shared_library_.get_function_pointer("nispy_StopSpying")); @@ -54,7 +54,7 @@ eNiSpyAPICommandStatus IOTraceLibrary::CloseIOTrace() eNiSpyAPICommandStatus IOTraceLibrary::GetIOTracePath(char pathString[256], int32_t pathStringSize) { if (!function_pointers_.GetIOTracePath) { - throw nidevice_grpc::LibraryLoadException("Could not find nispy_GetIOTracePath."); + throw nidevice_grpc::LibraryLoadException("Could not find nispy_GetApplicationPath."); } return function_pointers_.GetIOTracePath(pathString, pathStringSize); } diff --git a/generated/iotrace/iotrace_service.h b/generated/iotrace/iotrace_service.h index 6397f03b1..ce2658ae8 100644 --- a/generated/iotrace/iotrace_service.h +++ b/generated/iotrace/iotrace_service.h @@ -43,6 +43,7 @@ class IOTraceService final : public IOTrace::Service { ::grpc::Status CloseIOTrace(::grpc::ServerContext* context, const CloseIOTraceRequest* request, CloseIOTraceResponse* response) override; ::grpc::Status LogMessage(::grpc::ServerContext* context, const LogMessageRequest* request, LogMessageResponse* response) override; + ::grpc::Status OpenIOTrace(::grpc::ServerContext* context, const OpenIOTraceRequest* request, OpenIOTraceResponse* response) override; ::grpc::Status StartTracing(::grpc::ServerContext* context, const StartTracingRequest* request, StartTracingResponse* response) override; ::grpc::Status StopTracing(::grpc::ServerContext* context, const StopTracingRequest* request, StopTracingResponse* response) override; private: diff --git a/source/codegen/common_helpers.py b/source/codegen/common_helpers.py index b371bdf68..820b07ccf 100644 --- a/source/codegen/common_helpers.py +++ b/source/codegen/common_helpers.py @@ -435,7 +435,7 @@ def pascal_to_snake(pascal_string): def filter_proto_rpc_functions(functions): """Return function metadata only for functions to include for generating proto rpc methods.""" - functions_for_proto = {"public", "CustomCode", "CustomCodeCustomProtoMessage"} + functions_for_proto = {"public", "CustomCode", "CustomCodeCustomProtoMessage", "CustomGrpcOnly"} return [ name for name, function in functions.items() @@ -445,7 +445,7 @@ def filter_proto_rpc_functions(functions): def filter_proto_rpc_functions_for_message(functions): """Return function metadata only for functions to include for generating proto rpc messages.""" - functions_for_proto = {"public", "CustomCode"} + functions_for_proto = {"public", "CustomCode", "CustomGrpcOnly"} return [ name for name, function in functions.items() diff --git a/source/codegen/metadata/iotrace/functions.py b/source/codegen/metadata/iotrace/functions.py index ac38ffe66..3e5b9dba5 100644 --- a/source/codegen/metadata/iotrace/functions.py +++ b/source/codegen/metadata/iotrace/functions.py @@ -8,6 +8,7 @@ 'returns': 'eNiSpyAPICommandStatus' }, 'GetIOTracePath': { + 'cname': 'nispy_GetApplicationPath', 'codegen_method': 'private', 'parameters': [ { @@ -40,6 +41,11 @@ ], 'returns': 'eNiSpyAPICommandStatus' }, + 'OpenIOTrace': { + 'codegen_method': 'CustomGrpcOnly', + 'parameters': [], + 'returns': 'eNiSpyAPICommandStatus' + }, 'StartTracing': { 'cname': 'nispy_StartSpying', 'parameters': [ diff --git a/source/codegen/metadata_validation.py b/source/codegen/metadata_validation.py index 256fa9d15..393911b11 100644 --- a/source/codegen/metadata_validation.py +++ b/source/codegen/metadata_validation.py @@ -104,6 +104,7 @@ class RULES: "no", "python-only", "CustomCodeCustomProtoMessage", + "CustomGrpcOnly" ), ), Optional("init_method"): bool, diff --git a/source/codegen/service_helpers.py b/source/codegen/service_helpers.py index 054fdee7e..92917efe7 100644 --- a/source/codegen/service_helpers.py +++ b/source/codegen/service_helpers.py @@ -316,7 +316,7 @@ def filter_api_functions(functions, only_mockable_functions=True): """Filter function metadata to only include those to be generated into the API library.""" def filter_function(function): - if function.get("codegen_method", "") == "no": + if function.get("codegen_method", "") in ["no", "CustomGrpcOnly"]: return False if only_mockable_functions and not common_helpers.can_mock_function(function["parameters"]): return False diff --git a/source/custom/iotrace_service.custom.cpp b/source/custom/iotrace_service.custom.cpp index 6dbfaaa6a..d30d1c186 100644 --- a/source/custom/iotrace_service.custom.cpp +++ b/source/custom/iotrace_service.custom.cpp @@ -1,5 +1,33 @@ #include +#include + +#include +#include +using namespace std::string_literals; namespace iotrace_grpc { +//--------------------------------------------------------------------- +//--------------------------------------------------------------------- +// TODO: This is hacky. Make this proper (support Linux, validate correct way to launch IO Trace, etc.) +::grpc::Status IOTraceService::OpenIOTrace(::grpc::ServerContext* context, const OpenIOTraceRequest* request, OpenIOTraceResponse* response) +{ + if (context->IsCancelled()) { + return ::grpc::Status::CANCELLED; + } + try { + auto path_string_size = 256; + std::string path_string(path_string_size - 1, '\0'); + auto status = library_->GetIOTracePath((char*)path_string.data(), path_string_size); + response->set_status(status); + if (status >= 0) { + ShellExecute(NULL, "open", path_string.c_str(), NULL, NULL, SW_SHOWDEFAULT); + } + + return ::grpc::Status::OK; + } + catch (nidevice_grpc::LibraryLoadException& ex) { + return ::grpc::Status(::grpc::NOT_FOUND, ex.what()); + } +} } // namespace iotrace_grpc diff --git a/source/tests/system/io_trace_api_tests.cpp b/source/tests/system/io_trace_api_tests.cpp index eaf414811..c95c0a9f0 100644 --- a/source/tests/system/io_trace_api_tests.cpp +++ b/source/tests/system/io_trace_api_tests.cpp @@ -57,8 +57,8 @@ TEST_F(IOTraceApiTests, IOTraceIsStarted_StartTracing_Success) { // Pre-requisite for test, IO Trace application is running - std::string path = "C:\\Users\\reckenro\\Documents\\text-output.txt"; - auto start_tracing_response = client::start_tracing(stub(), LOG_FILE_SETTING_PlainText, path, FILE_WRITE_MODE_CreateOrAppend); + std::string path = "C:\\Users\\reckenro\\Documents\\text-output.nitrace"; + auto start_tracing_response = client::start_tracing(stub(), LOG_FILE_SETTING_Spy, path, FILE_WRITE_MODE_CreateOrOverwrite); EXPECT_EQ(0, start_tracing_response.status()); } @@ -68,7 +68,7 @@ TEST_F(IOTraceApiTests, IOTraceIsStarted_StartTracingWithInvalidArgs_InvalidArgs // Pre-requisite for test, IO Trace application is running std::string path = ""; // Empty string not allowed for file path. - auto start_tracing_response = client::start_tracing(stub(), LOG_FILE_SETTING_PlainText, path, FILE_WRITE_MODE_CreateOrAppend); + auto start_tracing_response = client::start_tracing(stub(), LOG_FILE_SETTING_Spy, path, FILE_WRITE_MODE_CreateOrAppend); EXPECT_EQ(COMMAND_STATUS_InvalidSettings, start_tracing_response.status()); } @@ -91,16 +91,13 @@ TEST_F(IOTraceApiTests, IOTraceIsStarted_CloseIOTrace_Success) EXPECT_EQ(0, close_trace_response.status()); } -TEST_F(IOTraceApiTests, IOTraceIsInstalled_GetIOTracePath_SuccessAndGetsAppPath) +TEST_F(IOTraceApiTests, IOTraceIsInstalled_OpenIOTrace_SuccessAndOpensIOTrace) { - // Pre-requisite for test, IO Trace application is running - - // TODO: This should become launch io trace test. + // Pre-requisite for test, IO Trace application is installed - // auto io_trace_path_response = client::get_io_trace_path(stub()); + auto open_io_trace = client::open_io_trace(stub()); - // EXPECT_EQ(0, io_trace_path_response.status()); - // EXPECT_STRNE("", io_trace_path_response.path_string().c_str()); + EXPECT_EQ(0, open_io_trace.status()); } TEST_F(IOTraceApiTests, IOTraceIsStarted_LogMessage_Success) From 6c81a6628facc3a919d58c07e7f6e09fafdcf03f Mon Sep 17 00:00:00 2001 From: Ryan Eckenrode Date: Thu, 31 Mar 2022 16:49:21 -0500 Subject: [PATCH 15/18] Run Black on metadata_validation. --- source/codegen/metadata_validation.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/codegen/metadata_validation.py b/source/codegen/metadata_validation.py index 393911b11..94f4eba98 100644 --- a/source/codegen/metadata_validation.py +++ b/source/codegen/metadata_validation.py @@ -104,7 +104,7 @@ class RULES: "no", "python-only", "CustomCodeCustomProtoMessage", - "CustomGrpcOnly" + "CustomGrpcOnly", ), ), Optional("init_method"): bool, From 1c3de9f6482475e4941e2b9bd98975552a8495d7 Mon Sep 17 00:00:00 2001 From: Ryan Eckenrode Date: Thu, 31 Mar 2022 18:12:42 -0500 Subject: [PATCH 16/18] Upload artifacts for testing. --- .github/workflows/build_cmake.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build_cmake.yml b/.github/workflows/build_cmake.yml index a2307235c..7d34895c2 100644 --- a/.github/workflows/build_cmake.yml +++ b/.github/workflows/build_cmake.yml @@ -155,7 +155,7 @@ jobs: - name: Upload Windows Server Information Artifact uses: actions/upload-artifact@v2 - if: ${{ (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/heads/releases')) && (runner.os == 'Windows') }} + if: ${{ (runner.os == 'Windows') }} with: name: ni-grpc-device-server-windows-x64 path: | @@ -165,7 +165,7 @@ jobs: - name: Upload Windows Server Binaries Artifact uses: actions/upload-artifact@v2 - if: ${{ (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/heads/releases')) && (runner.os == 'Windows') }} + if: ${{ (runner.os == 'Windows') }} with: name: ni-grpc-device-server-windows-x64 path: | @@ -175,7 +175,7 @@ jobs: - name: Upload Windows Test Binaries Artifact uses: actions/upload-artifact@v2 - if: ${{ (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/heads/releases')) && (runner.os == 'Windows') }} + if: ${{ (runner.os == 'Windows') }} with: name: ni-grpc-device-tests-windows-x64 path: | From 11a675a6dee309bcb50c1730300e0c9b8a8c9281 Mon Sep 17 00:00:00 2001 From: Ryan Eckenrode Date: Thu, 31 Mar 2022 18:13:53 -0500 Subject: [PATCH 17/18] Also upload client artifacts. --- .github/workflows/create_client_artifacts.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/create_client_artifacts.yml b/.github/workflows/create_client_artifacts.yml index 2d04631d6..c05d38996 100644 --- a/.github/workflows/create_client_artifacts.yml +++ b/.github/workflows/create_client_artifacts.yml @@ -52,7 +52,7 @@ jobs: - name: Upload Windows Client Files Artifact uses: actions/upload-artifact@v2 - if: ${{ (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/heads/releases')) && (runner.os == 'Windows') }} + if: ${{ (runner.os == 'Windows') }} with: name: ni-grpc-device-client path: | From 3cd6dacff92dd8d1432d5b2f74b943774eb2f339 Mon Sep 17 00:00:00 2001 From: Ryan Eckenrode Date: Fri, 1 Apr 2022 09:54:48 -0500 Subject: [PATCH 18/18] Incorporate IO Trace in graph-measurement example. --- examples/niscope/graph-measurement.py | 111 ++++++++++++++------- source/tests/system/io_trace_api_tests.cpp | 2 +- 2 files changed, 77 insertions(+), 36 deletions(-) diff --git a/examples/niscope/graph-measurement.py b/examples/niscope/graph-measurement.py index 78280c2b9..e12d54b2c 100644 --- a/examples/niscope/graph-measurement.py +++ b/examples/niscope/graph-measurement.py @@ -37,6 +37,8 @@ import matplotlib.pyplot as plt import niscope_pb2 as niscope_types import niscope_pb2_grpc as grpc_scope +import iotrace_pb2 as iotrace_types +import iotrace_pb2_grpc as grpc_iotrace SERVER_ADDRESS = "localhost" SERVER_PORT = "31763" @@ -67,13 +69,50 @@ def check_for_error(vi, status): raise Exception(error_message_response.error_message) +def simple_check_for_error(status, message): + """Raise an exception if the status indicates an error.""" + if status < 0: + raise Exception(f"Status check failed {status}: {message}") + + +def start_tracing(): + """Launch IO Trace and start tracing""" + print("Start tracing...") + open_response = iotrace_client.OpenIOTrace(iotrace_types.OpenIOTraceRequest()) + simple_check_for_error(open_response.status, "Launching IO Trace failed.") + time.sleep(4) + start_tracing_response = iotrace_client.StartTracing( + iotrace_types.StartTracingRequest( + log_file_setting=iotrace_types.LogFileSetting.LOG_FILE_SETTING_Spy, + file_path_string="C:\\dev\\traces\\graph-measurement.nitrace", + file_write_mode=iotrace_types.FileWriteMode.FILE_WRITE_MODE_CreateOrOverwrite, + ) + ) + simple_check_for_error(start_tracing_response.status, "Start tracing failed.") + + +def stop_tracing(): + """Stop tracing and close IO Trace""" + input("\nHit enter to stop tracing and close IO Trace...\n") + stop_tracing_response = iotrace_client.StopTracing(iotrace_types.StopTracingRequest()) + simple_check_for_error(stop_tracing_response.status, "Stop tracing failed.") + time.sleep(0.5) + close_io_trace_response = iotrace_client.CloseIOTrace(iotrace_types.CloseIOTraceRequest()) + simple_check_for_error(close_io_trace_response.status, "Close IO Trace failed.") + + # Create the communication channel for the remote host (in this case we are connecting to a local # server) and create a connection to the NI-SCOPE service channel = grpc.insecure_channel(f"{SERVER_ADDRESS}:{SERVER_PORT}") niscope_client = grpc_scope.NiScopeStub(channel) +iotrace_client = grpc_iotrace.IOTraceStub(channel) try: # Initialize the scope + start_tracing() + + input("\nHit enter to start measurement.\n") + init_result = niscope_client.InitWithOptions( niscope_types.InitWithOptionsRequest( session_name="demo", resource_name=RESOURCE, id_query=False, option_string=OPTIONS @@ -143,46 +182,47 @@ def check_for_error(vi, status): # Setup a plot to draw the captured waveform fig = plt.gcf() + plot_open = True fig.show() + + def on_close(event): + global plot_open + plot_open = False + + fig.canvas.mpl_connect("close_event", on_close) fig.canvas.draw() - print("\nReading values in loop. CTRL+C to stop.\n") - try: - while True: - # Clear the plot and setup the axis - plt.clf() - plt.axis([0, 100, -6, 6]) - # Read a waveform from the scope - read_result = niscope_client.Read( - niscope_types.ReadRequest( - vi=vi, channel_list=CHANNELS, timeout=1, num_samples=10000 - ) - ) - check_for_error(vi, read_result.status) - values = read_result.waveform[0:10] - print(values) - - # Update the plot with the new waveform - plt.plot(read_result.waveform[0:100]) - fig.canvas.draw() - plt.pause(0.001) - - # Fetch the measured average frequency - fetch_result = niscope_client.FetchMeasurementStats( - niscope_types.FetchMeasurementStatsRequest( - vi=vi, - channel_list=CHANNELS, - timeout=1, - scalar_meas_function=niscope_types.ScalarMeasurement.SCALAR_MEASUREMENT_NISCOPE_VAL_AVERAGE_FREQUENCY, - ) + while plot_open: + # Clear the plot and setup the axis + plt.clf() + plt.axis([0, 100, -6, 6]) + # Read a waveform from the scope + read_result = niscope_client.Read( + niscope_types.ReadRequest(vi=vi, channel_list=CHANNELS, timeout=1, num_samples=10000) + ) + check_for_error(vi, read_result.status) + values = read_result.waveform[0:10] + print(values) + + # Update the plot with the new waveform + plt.plot(read_result.waveform[0:100], color="green") + fig.canvas.draw() + plt.pause(0.001) + + # Fetch the measured average frequency + fetch_result = niscope_client.FetchMeasurementStats( + niscope_types.FetchMeasurementStatsRequest( + vi=vi, + channel_list=CHANNELS, + timeout=1, + scalar_meas_function=niscope_types.ScalarMeasurement.SCALAR_MEASUREMENT_NISCOPE_VAL_AVERAGE_FREQUENCY, ) - check_for_error(vi, fetch_result.status) - print("Average Frequency: " + str("%.2f" % round(fetch_result.result[0], 2)) + " Hz") - print("") + ) + check_for_error(vi, fetch_result.status) + print("Average Frequency: " + str("%.2f" % round(fetch_result.result[0], 2)) + " Hz") + print("") - time.sleep(0.1) - except KeyboardInterrupt: - pass + time.sleep(0.1) except grpc.RpcError as rpc_error: error_message = rpc_error.details() @@ -198,3 +238,4 @@ def check_for_error(vi, status): if "vi" in vars() and vi.id != 0: # close the session. check_for_error(vi, (niscope_client.Close(niscope_types.CloseRequest(vi=vi))).status) + stop_tracing() diff --git a/source/tests/system/io_trace_api_tests.cpp b/source/tests/system/io_trace_api_tests.cpp index c95c0a9f0..b5a00f43e 100644 --- a/source/tests/system/io_trace_api_tests.cpp +++ b/source/tests/system/io_trace_api_tests.cpp @@ -57,7 +57,7 @@ TEST_F(IOTraceApiTests, IOTraceIsStarted_StartTracing_Success) { // Pre-requisite for test, IO Trace application is running - std::string path = "C:\\Users\\reckenro\\Documents\\text-output.nitrace"; + std::string path = "C:\\dev\\reckenro\\Docs\\text-output.nitrace"; auto start_tracing_response = client::start_tracing(stub(), LOG_FILE_SETTING_Spy, path, FILE_WRITE_MODE_CreateOrOverwrite); EXPECT_EQ(0, start_tracing_response.status());