diff --git a/CMakeLists.txt b/CMakeLists.txt index 8d7a861af..a18f21630 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -359,6 +359,7 @@ add_executable(IntegrationTestsRunner "${service_output_dir}/nifake_non_ivi/nifake_non_ivi_client.cpp" "${service_output_dir}/nifake_non_ivi/nifake_non_ivi_service.cpp" "${custom_dir}/nifake_non_ivi_service.custom.cpp" + "${custom_dir}/nifake_service.custom.cpp" ) set(CMAKE_THREAD_PREFER_PTHREAD TRUE) @@ -370,7 +371,8 @@ target_link_libraries(IntegrationTestsRunner gmock ${_GRPC_GRPCPP} ${CMAKE_DL_LIBS} - Threads::Threads) + Threads::Threads + nlohmann_json::nlohmann_json) add_library(TestApi SHARED "source/tests/utilities/test_api.cpp") diff --git a/generated/nidaqmx/nidaqmx_service.cpp b/generated/nidaqmx/nidaqmx_service.cpp index 9617a74e6..5c414a81d 100644 --- a/generated/nidaqmx/nidaqmx_service.cpp +++ b/generated/nidaqmx/nidaqmx_service.cpp @@ -57,6 +57,9 @@ namespace nidaqmx_grpc { try { auto port_list = request->port_list().c_str(); auto status = library_->AddCDAQSyncConnection(port_list); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, 0); + } response->set_status(status); return ::grpc::Status::OK; } @@ -77,6 +80,9 @@ namespace nidaqmx_grpc { TaskHandle task = session_repository_->access_session(task_grpc_session.id(), task_grpc_session.name()); auto channel_names = request->channel_names().c_str(); auto status = library_->AddGlobalChansToTask(task, channel_names); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); + } response->set_status(status); return ::grpc::Status::OK; } @@ -100,9 +106,8 @@ namespace nidaqmx_grpc { while (true) { auto status = library_->AddNetworkDevice(ip_address, device_name, attempt_reservation, timeout, nullptr, 0); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, 0); } uInt32 device_name_out_buffer_size = status; @@ -115,11 +120,12 @@ namespace nidaqmx_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_device_name_out(device_name_out); - nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_device_name_out())); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, 0); } + response->set_status(status); + response->set_device_name_out(device_name_out); + nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_device_name_out())); return ::grpc::Status::OK; } } @@ -140,10 +146,11 @@ namespace nidaqmx_grpc { float64 timeout = request->timeout(); bool32 disconnected_ports_exist {}; auto status = library_->AreConfiguredCDAQSyncPortsDisconnected(chassis_devices_ports, timeout, &disconnected_ports_exist); - response->set_status(status); - if (status_ok(status)) { - response->set_disconnected_ports_exist(disconnected_ports_exist); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, 0); } + response->set_status(status); + response->set_disconnected_ports_exist(disconnected_ports_exist); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -162,6 +169,9 @@ namespace nidaqmx_grpc { auto chassis_devices_ports = request->chassis_devices_ports().c_str(); float64 timeout = request->timeout(); auto status = library_->AutoConfigureCDAQSyncConnections(chassis_devices_ports, timeout); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, 0); + } response->set_status(status); return ::grpc::Status::OK; } @@ -187,9 +197,10 @@ namespace nidaqmx_grpc { response->mutable_reverse_coeffs()->Resize((reverse_poly_order < 0) ? num_forward_coeffs_in : reverse_poly_order + 1, 0); float64* reverse_coeffs = response->mutable_reverse_coeffs()->mutable_data(); auto status = library_->CalculateReversePolyCoeff(forward_coeffs, num_forward_coeffs_in, min_val_x, max_val_x, num_points_to_compute, reverse_poly_order, reverse_coeffs); - response->set_status(status); - if (status_ok(status)) { + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, 0); } + response->set_status(status); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -227,6 +238,9 @@ namespace nidaqmx_grpc { float64 trigger_level = request->trigger_level(); uInt32 pretrigger_samples = request->pretrigger_samples(); auto status = library_->CfgAnlgEdgeRefTrig(task, trigger_source, trigger_slope, trigger_level, pretrigger_samples); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); + } response->set_status(status); return ::grpc::Status::OK; } @@ -264,6 +278,9 @@ namespace nidaqmx_grpc { float64 trigger_level = request->trigger_level(); auto status = library_->CfgAnlgEdgeStartTrig(task, trigger_source, trigger_slope, trigger_level); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); + } response->set_status(status); return ::grpc::Status::OK; } @@ -299,6 +316,9 @@ namespace nidaqmx_grpc { auto array_size = array_size_size_calculation.size; auto status = library_->CfgAnlgMultiEdgeRefTrig(task, trigger_sources, trigger_slope_array, trigger_level_array, pretrigger_samples, array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); + } response->set_status(status); return ::grpc::Status::OK; } @@ -333,6 +353,9 @@ namespace nidaqmx_grpc { auto array_size = array_size_size_calculation.size; auto status = library_->CfgAnlgMultiEdgeStartTrig(task, trigger_sources, trigger_slope_array, trigger_level_array, array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); + } response->set_status(status); return ::grpc::Status::OK; } @@ -372,6 +395,9 @@ namespace nidaqmx_grpc { float64 window_bottom = request->window_bottom(); uInt32 pretrigger_samples = request->pretrigger_samples(); auto status = library_->CfgAnlgWindowRefTrig(task, trigger_source, trigger_when, window_top, window_bottom, pretrigger_samples); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); + } response->set_status(status); return ::grpc::Status::OK; } @@ -410,6 +436,9 @@ namespace nidaqmx_grpc { float64 window_top = request->window_top(); float64 window_bottom = request->window_bottom(); auto status = library_->CfgAnlgWindowStartTrig(task, trigger_source, trigger_when, window_top, window_bottom); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); + } response->set_status(status); return ::grpc::Status::OK; } @@ -496,6 +525,9 @@ namespace nidaqmx_grpc { } auto status = library_->CfgBurstHandshakingTimingExportClock(task, sample_mode, samps_per_chan, sample_clk_rate, sample_clk_outp_term, sample_clk_pulse_polarity, pause_when, ready_event_active_level); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); + } response->set_status(status); return ::grpc::Status::OK; } @@ -582,6 +614,9 @@ namespace nidaqmx_grpc { } auto status = library_->CfgBurstHandshakingTimingImportClock(task, sample_mode, samps_per_chan, sample_clk_rate, sample_clk_src, sample_clk_active_edge, pause_when, ready_event_active_level); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); + } response->set_status(status); return ::grpc::Status::OK; } @@ -620,6 +655,9 @@ namespace nidaqmx_grpc { uInt64 samps_per_chan = request->samps_per_chan(); auto status = library_->CfgChangeDetectionTiming(task, rising_edge_chan, falling_edge_chan, sample_mode, samps_per_chan); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); + } response->set_status(status); return ::grpc::Status::OK; } @@ -657,6 +695,9 @@ namespace nidaqmx_grpc { uInt32 pretrigger_samples = request->pretrigger_samples(); auto status = library_->CfgDigEdgeRefTrig(task, trigger_source, trigger_edge, pretrigger_samples); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); + } response->set_status(status); return ::grpc::Status::OK; } @@ -693,6 +734,9 @@ namespace nidaqmx_grpc { } auto status = library_->CfgDigEdgeStartTrig(task, trigger_source, trigger_edge); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); + } response->set_status(status); return ::grpc::Status::OK; } @@ -731,6 +775,9 @@ namespace nidaqmx_grpc { uInt32 pretrigger_samples = request->pretrigger_samples(); auto status = library_->CfgDigPatternRefTrig(task, trigger_source, trigger_pattern, trigger_when, pretrigger_samples); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); + } response->set_status(status); return ::grpc::Status::OK; } @@ -768,6 +815,9 @@ namespace nidaqmx_grpc { } auto status = library_->CfgDigPatternStartTrig(task, trigger_source, trigger_pattern, trigger_when); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); + } response->set_status(status); return ::grpc::Status::OK; } @@ -804,6 +854,9 @@ namespace nidaqmx_grpc { uInt64 samps_per_chan = request->samps_per_chan(); auto status = library_->CfgHandshakingTiming(task, sample_mode, samps_per_chan); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); + } response->set_status(status); return ::grpc::Status::OK; } @@ -840,6 +893,9 @@ namespace nidaqmx_grpc { uInt64 samps_per_chan = request->samps_per_chan(); auto status = library_->CfgImplicitTiming(task, sample_mode, samps_per_chan); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); + } response->set_status(status); return ::grpc::Status::OK; } @@ -860,6 +916,9 @@ namespace nidaqmx_grpc { TaskHandle task = session_repository_->access_session(task_grpc_session.id(), task_grpc_session.name()); uInt32 num_samps_per_chan = request->num_samps_per_chan(); auto status = library_->CfgInputBuffer(task, num_samps_per_chan); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); + } response->set_status(status); return ::grpc::Status::OK; } @@ -880,6 +939,9 @@ namespace nidaqmx_grpc { TaskHandle task = session_repository_->access_session(task_grpc_session.id(), task_grpc_session.name()); uInt32 num_samps_per_chan = request->num_samps_per_chan(); auto status = library_->CfgOutputBuffer(task, num_samps_per_chan); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); + } response->set_status(status); return ::grpc::Status::OK; } @@ -934,6 +996,9 @@ namespace nidaqmx_grpc { uInt64 samps_per_chan = request->samps_per_chan(); auto status = library_->CfgPipelinedSampClkTiming(task, source, rate, active_edge, sample_mode, samps_per_chan); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); + } response->set_status(status); return ::grpc::Status::OK; } @@ -988,6 +1053,9 @@ namespace nidaqmx_grpc { uInt64 samps_per_chan = request->samps_per_chan(); auto status = library_->CfgSampClkTiming(task, source, rate, active_edge, sample_mode, samps_per_chan); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1024,6 +1092,9 @@ namespace nidaqmx_grpc { } auto status = library_->CfgTimeStartTrig(task, when, timescale); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1066,6 +1137,9 @@ namespace nidaqmx_grpc { auto array_size = array_size_size_calculation.size; auto status = library_->CfgWatchdogAOExpirStates(task, channel_names, expir_state_array, output_type_array, array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1096,6 +1170,9 @@ namespace nidaqmx_grpc { uInt32 array_size = static_cast(request->expir_state_array().size()); auto status = library_->CfgWatchdogCOExpirStates(task, channel_names, expir_state_array, array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1126,6 +1203,9 @@ namespace nidaqmx_grpc { uInt32 array_size = static_cast(request->expir_state_array().size()); auto status = library_->CfgWatchdogDOExpirStates(task, channel_names, expir_state_array, array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1144,6 +1224,9 @@ namespace nidaqmx_grpc { try { auto physical_channel = request->physical_channel().c_str(); auto status = library_->ClearTEDS(physical_channel); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, 0); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1164,6 +1247,9 @@ namespace nidaqmx_grpc { TaskHandle task = session_repository_->access_session(task_grpc_session.id(), task_grpc_session.name()); session_repository_->remove_session(task_grpc_session.id(), task_grpc_session.name()); auto status = library_->ClearTask(task); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1217,6 +1303,9 @@ namespace nidaqmx_grpc { } auto status = library_->ConfigureLogging(task, file_path, logging_mode, group_name, operation); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1236,6 +1325,9 @@ namespace nidaqmx_grpc { auto physical_channel = request->physical_channel().c_str(); auto file_path = request->file_path().c_str(); auto status = library_->ConfigureTEDS(physical_channel, file_path); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, 0); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1271,6 +1363,9 @@ namespace nidaqmx_grpc { } auto status = library_->ConnectTerms(source_terminal, destination_terminal, signal_modifiers); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, 0); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1306,6 +1401,9 @@ namespace nidaqmx_grpc { } auto status = library_->ControlWatchdogTask(task, action); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1397,6 +1495,9 @@ namespace nidaqmx_grpc { bool32 use_excit_for_scaling = request->use_excit_for_scaling(); auto custom_scale_name = request->custom_scale_name().c_str(); auto status = library_->CreateAIAccel4WireDCVoltageChan(task, physical_channel, name_to_assign_to_channel, terminal_config, min_val, max_val, units, sensitivity, sensitivity_units, voltage_excit_source, voltage_excit_val, use_excit_for_scaling, custom_scale_name); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1487,6 +1588,9 @@ namespace nidaqmx_grpc { float64 current_excit_val = request->current_excit_val(); auto custom_scale_name = request->custom_scale_name().c_str(); auto status = library_->CreateAIAccelChan(task, physical_channel, name_to_assign_to_channel, terminal_config, min_val, max_val, units, sensitivity, sensitivity_units, current_excit_source, current_excit_val, custom_scale_name); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1560,6 +1664,9 @@ namespace nidaqmx_grpc { auto custom_scale_name = request->custom_scale_name().c_str(); auto status = library_->CreateAIAccelChargeChan(task, physical_channel, name_to_assign_to_channel, terminal_config, min_val, max_val, units, sensitivity, sensitivity_units, custom_scale_name); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1634,6 +1741,9 @@ namespace nidaqmx_grpc { float64 nominal_bridge_resistance = request->nominal_bridge_resistance(); auto custom_scale_name = request->custom_scale_name().c_str(); auto status = library_->CreateAIBridgeChan(task, physical_channel, name_to_assign_to_channel, min_val, max_val, units, bridge_config, voltage_excit_source, voltage_excit_val, nominal_bridge_resistance, custom_scale_name); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1690,6 +1800,9 @@ namespace nidaqmx_grpc { auto custom_scale_name = request->custom_scale_name().c_str(); auto status = library_->CreateAIChargeChan(task, physical_channel, name_to_assign_to_channel, terminal_config, min_val, max_val, units, custom_scale_name); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1763,6 +1876,9 @@ namespace nidaqmx_grpc { float64 ext_shunt_resistor_val = request->ext_shunt_resistor_val(); auto custom_scale_name = request->custom_scale_name().c_str(); auto status = library_->CreateAICurrentChan(task, physical_channel, name_to_assign_to_channel, terminal_config, min_val, max_val, units, shunt_resistor_loc, ext_shunt_resistor_val, custom_scale_name); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1836,6 +1952,9 @@ namespace nidaqmx_grpc { float64 ext_shunt_resistor_val = request->ext_shunt_resistor_val(); auto custom_scale_name = request->custom_scale_name().c_str(); auto status = library_->CreateAICurrentRMSChan(task, physical_channel, name_to_assign_to_channel, terminal_config, min_val, max_val, units, shunt_resistor_loc, ext_shunt_resistor_val, custom_scale_name); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1946,6 +2065,9 @@ namespace nidaqmx_grpc { auto custom_scale_name = request->custom_scale_name().c_str(); auto status = library_->CreateAIForceBridgePolynomialChan(task, physical_channel, name_to_assign_to_channel, min_val, max_val, units, bridge_config, voltage_excit_source, voltage_excit_val, nominal_bridge_resistance, forward_coeffs, num_forward_coeffs, reverse_coeffs, num_reverse_coeffs, electrical_units, physical_units, custom_scale_name); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); + } response->set_status(status); return ::grpc::Status::OK; } @@ -2056,6 +2178,9 @@ namespace nidaqmx_grpc { auto custom_scale_name = request->custom_scale_name().c_str(); auto status = library_->CreateAIForceBridgeTableChan(task, physical_channel, name_to_assign_to_channel, min_val, max_val, units, bridge_config, voltage_excit_source, voltage_excit_val, nominal_bridge_resistance, electrical_vals, num_electrical_vals, electrical_units, physical_vals, num_physical_vals, physical_units, custom_scale_name); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); + } response->set_status(status); return ::grpc::Status::OK; } @@ -2166,6 +2291,9 @@ namespace nidaqmx_grpc { auto custom_scale_name = request->custom_scale_name().c_str(); auto status = library_->CreateAIForceBridgeTwoPointLinChan(task, physical_channel, name_to_assign_to_channel, min_val, max_val, units, bridge_config, voltage_excit_source, voltage_excit_val, nominal_bridge_resistance, first_electrical_val, second_electrical_val, electrical_units, first_physical_val, second_physical_val, physical_units, custom_scale_name); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); + } response->set_status(status); return ::grpc::Status::OK; } @@ -2256,6 +2384,9 @@ namespace nidaqmx_grpc { float64 current_excit_val = request->current_excit_val(); auto custom_scale_name = request->custom_scale_name().c_str(); auto status = library_->CreateAIForceIEPEChan(task, physical_channel, name_to_assign_to_channel, terminal_config, min_val, max_val, units, sensitivity, sensitivity_units, current_excit_source, current_excit_val, custom_scale_name); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); + } response->set_status(status); return ::grpc::Status::OK; } @@ -2298,6 +2429,9 @@ namespace nidaqmx_grpc { float64 hysteresis = request->hysteresis(); auto custom_scale_name = request->custom_scale_name().c_str(); auto status = library_->CreateAIFreqVoltageChan(task, physical_channel, name_to_assign_to_channel, min_val, max_val, units, threshold_level, hysteresis, custom_scale_name); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); + } response->set_status(status); return ::grpc::Status::OK; } @@ -2371,6 +2505,9 @@ namespace nidaqmx_grpc { float64 current_excit_val = request->current_excit_val(); auto custom_scale_name = request->custom_scale_name().c_str(); auto status = library_->CreateAIMicrophoneChan(task, physical_channel, name_to_assign_to_channel, terminal_config, units, mic_sensitivity, max_snd_press_level, current_excit_source, current_excit_val, custom_scale_name); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); + } response->set_status(status); return ::grpc::Status::OK; } @@ -2428,6 +2565,9 @@ namespace nidaqmx_grpc { auto custom_scale_name = request->custom_scale_name().c_str(); auto status = library_->CreateAIPosEddyCurrProxProbeChan(task, physical_channel, name_to_assign_to_channel, min_val, max_val, units, sensitivity, sensitivity_units, custom_scale_name); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); + } response->set_status(status); return ::grpc::Status::OK; } @@ -2519,6 +2659,9 @@ namespace nidaqmx_grpc { auto custom_scale_name = request->custom_scale_name().c_str(); auto status = library_->CreateAIPosLVDTChan(task, physical_channel, name_to_assign_to_channel, min_val, max_val, units, sensitivity, sensitivity_units, voltage_excit_source, voltage_excit_val, voltage_excit_freq, ac_excit_wire_mode, custom_scale_name); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); + } response->set_status(status); return ::grpc::Status::OK; } @@ -2610,6 +2753,9 @@ namespace nidaqmx_grpc { auto custom_scale_name = request->custom_scale_name().c_str(); auto status = library_->CreateAIPosRVDTChan(task, physical_channel, name_to_assign_to_channel, min_val, max_val, units, sensitivity, sensitivity_units, voltage_excit_source, voltage_excit_val, voltage_excit_freq, ac_excit_wire_mode, custom_scale_name); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); + } response->set_status(status); return ::grpc::Status::OK; } @@ -2720,6 +2866,9 @@ namespace nidaqmx_grpc { auto custom_scale_name = request->custom_scale_name().c_str(); auto status = library_->CreateAIPressureBridgePolynomialChan(task, physical_channel, name_to_assign_to_channel, min_val, max_val, units, bridge_config, voltage_excit_source, voltage_excit_val, nominal_bridge_resistance, forward_coeffs, num_forward_coeffs, reverse_coeffs, num_reverse_coeffs, electrical_units, physical_units, custom_scale_name); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); + } response->set_status(status); return ::grpc::Status::OK; } @@ -2830,6 +2979,9 @@ namespace nidaqmx_grpc { auto custom_scale_name = request->custom_scale_name().c_str(); auto status = library_->CreateAIPressureBridgeTableChan(task, physical_channel, name_to_assign_to_channel, min_val, max_val, units, bridge_config, voltage_excit_source, voltage_excit_val, nominal_bridge_resistance, electrical_vals, num_electrical_vals, electrical_units, physical_vals, num_physical_vals, physical_units, custom_scale_name); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); + } response->set_status(status); return ::grpc::Status::OK; } @@ -2940,6 +3092,9 @@ namespace nidaqmx_grpc { auto custom_scale_name = request->custom_scale_name().c_str(); auto status = library_->CreateAIPressureBridgeTwoPointLinChan(task, physical_channel, name_to_assign_to_channel, min_val, max_val, units, bridge_config, voltage_excit_source, voltage_excit_val, nominal_bridge_resistance, first_electrical_val, second_electrical_val, electrical_units, first_physical_val, second_physical_val, physical_units, custom_scale_name); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); + } response->set_status(status); return ::grpc::Status::OK; } @@ -3029,6 +3184,9 @@ namespace nidaqmx_grpc { float64 current_excit_val = request->current_excit_val(); float64 r0 = request->r0(); auto status = library_->CreateAIRTDChan(task, physical_channel, name_to_assign_to_channel, min_val, max_val, units, rtd_type, resistance_config, current_excit_source, current_excit_val, r0); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); + } response->set_status(status); return ::grpc::Status::OK; } @@ -3102,6 +3260,9 @@ namespace nidaqmx_grpc { float64 current_excit_val = request->current_excit_val(); auto custom_scale_name = request->custom_scale_name().c_str(); auto status = library_->CreateAIResistanceChan(task, physical_channel, name_to_assign_to_channel, min_val, max_val, units, resistance_config, current_excit_source, current_excit_val, custom_scale_name); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); + } response->set_status(status); return ::grpc::Status::OK; } @@ -3181,6 +3342,9 @@ namespace nidaqmx_grpc { float64 poisson_ratio = request->poisson_ratio(); float64 lead_wire_resistance = request->lead_wire_resistance(); auto status = library_->CreateAIRosetteStrainGageChan(task, physical_channel, name_to_assign_to_channel, min_val, max_val, rosette_type, gage_orientation, rosette_meas_types, num_rosette_meas_types, strain_config, voltage_excit_source, voltage_excit_val, gage_factor, nominal_gage_resistance, poisson_ratio, lead_wire_resistance); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); + } response->set_status(status); return ::grpc::Status::OK; } @@ -3259,6 +3423,9 @@ namespace nidaqmx_grpc { float64 lead_wire_resistance = request->lead_wire_resistance(); auto custom_scale_name = request->custom_scale_name().c_str(); auto status = library_->CreateAIStrainGageChan(task, physical_channel, name_to_assign_to_channel, min_val, max_val, units, strain_config, voltage_excit_source, voltage_excit_val, gage_factor, initial_bridge_voltage, nominal_gage_resistance, poisson_ratio, lead_wire_resistance, custom_scale_name); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); + } response->set_status(status); return ::grpc::Status::OK; } @@ -3296,6 +3463,9 @@ namespace nidaqmx_grpc { } auto status = library_->CreateAITempBuiltInSensorChan(task, physical_channel, name_to_assign_to_channel, units); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); + } response->set_status(status); return ::grpc::Status::OK; } @@ -3369,6 +3539,9 @@ namespace nidaqmx_grpc { float64 cjc_val = request->cjc_val(); auto cjc_channel = request->cjc_channel().c_str(); auto status = library_->CreateAIThrmcplChan(task, physical_channel, name_to_assign_to_channel, min_val, max_val, units, thermocouple_type, cjc_source, cjc_val, cjc_channel); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); + } response->set_status(status); return ::grpc::Status::OK; } @@ -3444,6 +3617,9 @@ namespace nidaqmx_grpc { float64 b = request->b(); float64 c = request->c(); auto status = library_->CreateAIThrmstrChanIex(task, physical_channel, name_to_assign_to_channel, min_val, max_val, units, resistance_config, current_excit_source, current_excit_val, a, b, c); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); + } response->set_status(status); return ::grpc::Status::OK; } @@ -3520,6 +3696,9 @@ namespace nidaqmx_grpc { float64 c = request->c(); float64 r1 = request->r1(); auto status = library_->CreateAIThrmstrChanVex(task, physical_channel, name_to_assign_to_channel, min_val, max_val, units, resistance_config, voltage_excit_source, voltage_excit_val, a, b, c, r1); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); + } response->set_status(status); return ::grpc::Status::OK; } @@ -3630,6 +3809,9 @@ namespace nidaqmx_grpc { auto custom_scale_name = request->custom_scale_name().c_str(); auto status = library_->CreateAITorqueBridgePolynomialChan(task, physical_channel, name_to_assign_to_channel, min_val, max_val, units, bridge_config, voltage_excit_source, voltage_excit_val, nominal_bridge_resistance, forward_coeffs, num_forward_coeffs, reverse_coeffs, num_reverse_coeffs, electrical_units, physical_units, custom_scale_name); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); + } response->set_status(status); return ::grpc::Status::OK; } @@ -3740,6 +3922,9 @@ namespace nidaqmx_grpc { auto custom_scale_name = request->custom_scale_name().c_str(); auto status = library_->CreateAITorqueBridgeTableChan(task, physical_channel, name_to_assign_to_channel, min_val, max_val, units, bridge_config, voltage_excit_source, voltage_excit_val, nominal_bridge_resistance, electrical_vals, num_electrical_vals, electrical_units, physical_vals, num_physical_vals, physical_units, custom_scale_name); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); + } response->set_status(status); return ::grpc::Status::OK; } @@ -3850,6 +4035,9 @@ namespace nidaqmx_grpc { auto custom_scale_name = request->custom_scale_name().c_str(); auto status = library_->CreateAITorqueBridgeTwoPointLinChan(task, physical_channel, name_to_assign_to_channel, min_val, max_val, units, bridge_config, voltage_excit_source, voltage_excit_val, nominal_bridge_resistance, first_electrical_val, second_electrical_val, electrical_units, first_physical_val, second_physical_val, physical_units, custom_scale_name); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); + } response->set_status(status); return ::grpc::Status::OK; } @@ -3940,6 +4128,9 @@ namespace nidaqmx_grpc { float64 current_excit_val = request->current_excit_val(); auto custom_scale_name = request->custom_scale_name().c_str(); auto status = library_->CreateAIVelocityIEPEChan(task, physical_channel, name_to_assign_to_channel, terminal_config, min_val, max_val, units, sensitivity, sensitivity_units, current_excit_source, current_excit_val, custom_scale_name); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); + } response->set_status(status); return ::grpc::Status::OK; } @@ -3996,6 +4187,9 @@ namespace nidaqmx_grpc { auto custom_scale_name = request->custom_scale_name().c_str(); auto status = library_->CreateAIVoltageChan(task, physical_channel, name_to_assign_to_channel, terminal_config, min_val, max_val, units, custom_scale_name); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); + } response->set_status(status); return ::grpc::Status::OK; } @@ -4086,6 +4280,9 @@ namespace nidaqmx_grpc { bool32 use_excit_for_scaling = request->use_excit_for_scaling(); auto custom_scale_name = request->custom_scale_name().c_str(); auto status = library_->CreateAIVoltageChanWithExcit(task, physical_channel, name_to_assign_to_channel, terminal_config, min_val, max_val, units, bridge_config, voltage_excit_source, voltage_excit_val, use_excit_for_scaling, custom_scale_name); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); + } response->set_status(status); return ::grpc::Status::OK; } @@ -4142,6 +4339,9 @@ namespace nidaqmx_grpc { auto custom_scale_name = request->custom_scale_name().c_str(); auto status = library_->CreateAIVoltageRMSChan(task, physical_channel, name_to_assign_to_channel, terminal_config, min_val, max_val, units, custom_scale_name); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); + } response->set_status(status); return ::grpc::Status::OK; } @@ -4182,6 +4382,9 @@ namespace nidaqmx_grpc { auto custom_scale_name = request->custom_scale_name().c_str(); auto status = library_->CreateAOCurrentChan(task, physical_channel, name_to_assign_to_channel, min_val, max_val, units, custom_scale_name); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); + } response->set_status(status); return ::grpc::Status::OK; } @@ -4222,6 +4425,9 @@ namespace nidaqmx_grpc { float64 amplitude = request->amplitude(); float64 offset = request->offset(); auto status = library_->CreateAOFuncGenChan(task, physical_channel, name_to_assign_to_channel, type, freq, amplitude, offset); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); + } response->set_status(status); return ::grpc::Status::OK; } @@ -4262,6 +4468,9 @@ namespace nidaqmx_grpc { auto custom_scale_name = request->custom_scale_name().c_str(); auto status = library_->CreateAOVoltageChan(task, physical_channel, name_to_assign_to_channel, min_val, max_val, units, custom_scale_name); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); + } response->set_status(status); return ::grpc::Status::OK; } @@ -4336,6 +4545,9 @@ namespace nidaqmx_grpc { float64 initial_angle = request->initial_angle(); auto custom_scale_name = request->custom_scale_name().c_str(); auto status = library_->CreateCIAngEncoderChan(task, counter, name_to_assign_to_channel, decoding_type, zidx_enable, zidx_val, zidx_phase, units, pulses_per_rev, initial_angle, custom_scale_name); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); + } response->set_status(status); return ::grpc::Status::OK; } @@ -4393,6 +4605,9 @@ namespace nidaqmx_grpc { uInt32 pulses_per_rev = request->pulses_per_rev(); auto custom_scale_name = request->custom_scale_name().c_str(); auto status = library_->CreateCIAngVelocityChan(task, counter, name_to_assign_to_channel, min_val, max_val, decoding_type, units, pulses_per_rev, custom_scale_name); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); + } response->set_status(status); return ::grpc::Status::OK; } @@ -4447,6 +4662,9 @@ namespace nidaqmx_grpc { } auto status = library_->CreateCICountEdgesChan(task, counter, name_to_assign_to_channel, edge, initial_count, count_direction); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); + } response->set_status(status); return ::grpc::Status::OK; } @@ -4487,6 +4705,9 @@ namespace nidaqmx_grpc { auto custom_scale_name = request->custom_scale_name().c_str(); auto status = library_->CreateCIDutyCycleChan(task, counter, name_to_assign_to_channel, min_freq, max_freq, edge, custom_scale_name); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); + } response->set_status(status); return ::grpc::Status::OK; } @@ -4561,6 +4782,9 @@ namespace nidaqmx_grpc { uInt32 divisor = request->divisor(); auto custom_scale_name = request->custom_scale_name().c_str(); auto status = library_->CreateCIFreqChan(task, counter, name_to_assign_to_channel, min_val, max_val, units, edge, meas_method, meas_time, divisor, custom_scale_name); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); + } response->set_status(status); return ::grpc::Status::OK; } @@ -4615,6 +4839,9 @@ namespace nidaqmx_grpc { auto custom_scale_name = request->custom_scale_name().c_str(); auto status = library_->CreateCIGPSTimestampChan(task, counter, name_to_assign_to_channel, units, sync_method, custom_scale_name); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); + } response->set_status(status); return ::grpc::Status::OK; } @@ -4689,6 +4916,9 @@ namespace nidaqmx_grpc { float64 initial_pos = request->initial_pos(); auto custom_scale_name = request->custom_scale_name().c_str(); auto status = library_->CreateCILinEncoderChan(task, counter, name_to_assign_to_channel, decoding_type, zidx_enable, zidx_val, zidx_phase, units, dist_per_pulse, initial_pos, custom_scale_name); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); + } response->set_status(status); return ::grpc::Status::OK; } @@ -4746,6 +4976,9 @@ namespace nidaqmx_grpc { float64 dist_per_pulse = request->dist_per_pulse(); auto custom_scale_name = request->custom_scale_name().c_str(); auto status = library_->CreateCILinVelocityChan(task, counter, name_to_assign_to_channel, min_val, max_val, decoding_type, units, dist_per_pulse, custom_scale_name); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); + } response->set_status(status); return ::grpc::Status::OK; } @@ -4820,6 +5053,9 @@ namespace nidaqmx_grpc { uInt32 divisor = request->divisor(); auto custom_scale_name = request->custom_scale_name().c_str(); auto status = library_->CreateCIPeriodChan(task, counter, name_to_assign_to_channel, min_val, max_val, units, edge, meas_method, meas_time, divisor, custom_scale_name); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); + } response->set_status(status); return ::grpc::Status::OK; } @@ -4859,6 +5095,9 @@ namespace nidaqmx_grpc { } auto status = library_->CreateCIPulseChanFreq(task, counter, name_to_assign_to_channel, min_val, max_val, units); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); + } response->set_status(status); return ::grpc::Status::OK; } @@ -4883,6 +5122,9 @@ namespace nidaqmx_grpc { float64 min_val = request->min_val(); float64 max_val = request->max_val(); auto status = library_->CreateCIPulseChanTicks(task, counter, name_to_assign_to_channel, source_terminal, min_val, max_val); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); + } response->set_status(status); return ::grpc::Status::OK; } @@ -4922,6 +5164,9 @@ namespace nidaqmx_grpc { } auto status = library_->CreateCIPulseChanTime(task, counter, name_to_assign_to_channel, min_val, max_val, units); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); + } response->set_status(status); return ::grpc::Status::OK; } @@ -4978,6 +5223,9 @@ namespace nidaqmx_grpc { auto custom_scale_name = request->custom_scale_name().c_str(); auto status = library_->CreateCIPulseWidthChan(task, counter, name_to_assign_to_channel, min_val, max_val, units, starting_edge, custom_scale_name); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); + } response->set_status(status); return ::grpc::Status::OK; } @@ -5018,6 +5266,9 @@ namespace nidaqmx_grpc { auto custom_scale_name = request->custom_scale_name().c_str(); auto status = library_->CreateCISemiPeriodChan(task, counter, name_to_assign_to_channel, min_val, max_val, units, custom_scale_name); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); + } response->set_status(status); return ::grpc::Status::OK; } @@ -5090,6 +5341,9 @@ namespace nidaqmx_grpc { auto custom_scale_name = request->custom_scale_name().c_str(); auto status = library_->CreateCITwoEdgeSepChan(task, counter, name_to_assign_to_channel, min_val, max_val, units, first_edge, second_edge, custom_scale_name); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); + } response->set_status(status); return ::grpc::Status::OK; } @@ -5146,6 +5400,9 @@ namespace nidaqmx_grpc { float64 freq = request->freq(); float64 duty_cycle = request->duty_cycle(); auto status = library_->CreateCOPulseChanFreq(task, counter, name_to_assign_to_channel, units, idle_state, initial_delay, freq, duty_cycle); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); + } response->set_status(status); return ::grpc::Status::OK; } @@ -5187,6 +5444,9 @@ namespace nidaqmx_grpc { int32 low_ticks = request->low_ticks(); int32 high_ticks = request->high_ticks(); auto status = library_->CreateCOPulseChanTicks(task, counter, name_to_assign_to_channel, source_terminal, idle_state, initial_delay, low_ticks, high_ticks); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); + } response->set_status(status); return ::grpc::Status::OK; } @@ -5243,6 +5503,9 @@ namespace nidaqmx_grpc { float64 low_time = request->low_time(); float64 high_time = request->high_time(); auto status = library_->CreateCOPulseChanTime(task, counter, name_to_assign_to_channel, units, idle_state, initial_delay, low_time, high_time); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); + } response->set_status(status); return ::grpc::Status::OK; } @@ -5280,6 +5543,9 @@ namespace nidaqmx_grpc { } auto status = library_->CreateDIChan(task, lines, name_to_assign_to_lines, line_grouping); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); + } response->set_status(status); return ::grpc::Status::OK; } @@ -5317,6 +5583,9 @@ namespace nidaqmx_grpc { } auto status = library_->CreateDOChan(task, lines, name_to_assign_to_lines, line_grouping); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); + } response->set_status(status); return ::grpc::Status::OK; } @@ -5354,6 +5623,9 @@ namespace nidaqmx_grpc { auto scaled_units = request->scaled_units().c_str(); auto status = library_->CreateLinScale(name, slope, y_intercept, pre_scaled_units, scaled_units); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, 0); + } response->set_status(status); return ::grpc::Status::OK; } @@ -5393,6 +5665,9 @@ namespace nidaqmx_grpc { auto scaled_units = request->scaled_units().c_str(); auto status = library_->CreateMapScale(name, prescaled_min, prescaled_max, scaled_min, scaled_max, pre_scaled_units, scaled_units); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, 0); + } response->set_status(status); return ::grpc::Status::OK; } @@ -5432,6 +5707,9 @@ namespace nidaqmx_grpc { auto scaled_units = request->scaled_units().c_str(); auto status = library_->CreatePolynomialScale(name, forward_coeffs, num_forward_coeffs_in, reverse_coeffs, num_reverse_coeffs_in, pre_scaled_units, scaled_units); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, 0); + } response->set_status(status); return ::grpc::Status::OK; } @@ -5505,6 +5783,9 @@ namespace nidaqmx_grpc { float64 current_excit_val = request->current_excit_val(); auto custom_scale_name = request->custom_scale_name().c_str(); auto status = library_->CreateTEDSAIAccelChan(task, physical_channel, name_to_assign_to_channel, terminal_config, min_val, max_val, units, current_excit_source, current_excit_val, custom_scale_name); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); + } response->set_status(status); return ::grpc::Status::OK; } @@ -5562,6 +5843,9 @@ namespace nidaqmx_grpc { float64 voltage_excit_val = request->voltage_excit_val(); auto custom_scale_name = request->custom_scale_name().c_str(); auto status = library_->CreateTEDSAIBridgeChan(task, physical_channel, name_to_assign_to_channel, min_val, max_val, units, voltage_excit_source, voltage_excit_val, custom_scale_name); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); + } response->set_status(status); return ::grpc::Status::OK; } @@ -5635,6 +5919,9 @@ namespace nidaqmx_grpc { float64 ext_shunt_resistor_val = request->ext_shunt_resistor_val(); auto custom_scale_name = request->custom_scale_name().c_str(); auto status = library_->CreateTEDSAICurrentChan(task, physical_channel, name_to_assign_to_channel, terminal_config, min_val, max_val, units, shunt_resistor_loc, ext_shunt_resistor_val, custom_scale_name); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); + } response->set_status(status); return ::grpc::Status::OK; } @@ -5692,6 +5979,9 @@ namespace nidaqmx_grpc { float64 voltage_excit_val = request->voltage_excit_val(); auto custom_scale_name = request->custom_scale_name().c_str(); auto status = library_->CreateTEDSAIForceBridgeChan(task, physical_channel, name_to_assign_to_channel, min_val, max_val, units, voltage_excit_source, voltage_excit_val, custom_scale_name); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); + } response->set_status(status); return ::grpc::Status::OK; } @@ -5765,6 +6055,9 @@ namespace nidaqmx_grpc { float64 current_excit_val = request->current_excit_val(); auto custom_scale_name = request->custom_scale_name().c_str(); auto status = library_->CreateTEDSAIForceIEPEChan(task, physical_channel, name_to_assign_to_channel, terminal_config, min_val, max_val, units, current_excit_source, current_excit_val, custom_scale_name); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); + } response->set_status(status); return ::grpc::Status::OK; } @@ -5837,6 +6130,9 @@ namespace nidaqmx_grpc { float64 current_excit_val = request->current_excit_val(); auto custom_scale_name = request->custom_scale_name().c_str(); auto status = library_->CreateTEDSAIMicrophoneChan(task, physical_channel, name_to_assign_to_channel, terminal_config, units, max_snd_press_level, current_excit_source, current_excit_val, custom_scale_name); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); + } response->set_status(status); return ::grpc::Status::OK; } @@ -5911,6 +6207,9 @@ namespace nidaqmx_grpc { auto custom_scale_name = request->custom_scale_name().c_str(); auto status = library_->CreateTEDSAIPosLVDTChan(task, physical_channel, name_to_assign_to_channel, min_val, max_val, units, voltage_excit_source, voltage_excit_val, voltage_excit_freq, ac_excit_wire_mode, custom_scale_name); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); + } response->set_status(status); return ::grpc::Status::OK; } @@ -5985,6 +6284,9 @@ namespace nidaqmx_grpc { auto custom_scale_name = request->custom_scale_name().c_str(); auto status = library_->CreateTEDSAIPosRVDTChan(task, physical_channel, name_to_assign_to_channel, min_val, max_val, units, voltage_excit_source, voltage_excit_val, voltage_excit_freq, ac_excit_wire_mode, custom_scale_name); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); + } response->set_status(status); return ::grpc::Status::OK; } @@ -6042,6 +6344,9 @@ namespace nidaqmx_grpc { float64 voltage_excit_val = request->voltage_excit_val(); auto custom_scale_name = request->custom_scale_name().c_str(); auto status = library_->CreateTEDSAIPressureBridgeChan(task, physical_channel, name_to_assign_to_channel, min_val, max_val, units, voltage_excit_source, voltage_excit_val, custom_scale_name); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); + } response->set_status(status); return ::grpc::Status::OK; } @@ -6114,6 +6419,9 @@ namespace nidaqmx_grpc { float64 current_excit_val = request->current_excit_val(); auto status = library_->CreateTEDSAIRTDChan(task, physical_channel, name_to_assign_to_channel, min_val, max_val, units, resistance_config, current_excit_source, current_excit_val); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); + } response->set_status(status); return ::grpc::Status::OK; } @@ -6187,6 +6495,9 @@ namespace nidaqmx_grpc { float64 current_excit_val = request->current_excit_val(); auto custom_scale_name = request->custom_scale_name().c_str(); auto status = library_->CreateTEDSAIResistanceChan(task, physical_channel, name_to_assign_to_channel, min_val, max_val, units, resistance_config, current_excit_source, current_excit_val, custom_scale_name); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); + } response->set_status(status); return ::grpc::Status::OK; } @@ -6246,6 +6557,9 @@ namespace nidaqmx_grpc { float64 lead_wire_resistance = request->lead_wire_resistance(); auto custom_scale_name = request->custom_scale_name().c_str(); auto status = library_->CreateTEDSAIStrainGageChan(task, physical_channel, name_to_assign_to_channel, min_val, max_val, units, voltage_excit_source, voltage_excit_val, initial_bridge_voltage, lead_wire_resistance, custom_scale_name); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); + } response->set_status(status); return ::grpc::Status::OK; } @@ -6303,6 +6617,9 @@ namespace nidaqmx_grpc { float64 cjc_val = request->cjc_val(); auto cjc_channel = request->cjc_channel().c_str(); auto status = library_->CreateTEDSAIThrmcplChan(task, physical_channel, name_to_assign_to_channel, min_val, max_val, units, cjc_source, cjc_val, cjc_channel); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); + } response->set_status(status); return ::grpc::Status::OK; } @@ -6375,6 +6692,9 @@ namespace nidaqmx_grpc { float64 current_excit_val = request->current_excit_val(); auto status = library_->CreateTEDSAIThrmstrChanIex(task, physical_channel, name_to_assign_to_channel, min_val, max_val, units, resistance_config, current_excit_source, current_excit_val); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); + } response->set_status(status); return ::grpc::Status::OK; } @@ -6448,6 +6768,9 @@ namespace nidaqmx_grpc { float64 voltage_excit_val = request->voltage_excit_val(); float64 r1 = request->r1(); auto status = library_->CreateTEDSAIThrmstrChanVex(task, physical_channel, name_to_assign_to_channel, min_val, max_val, units, resistance_config, voltage_excit_source, voltage_excit_val, r1); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); + } response->set_status(status); return ::grpc::Status::OK; } @@ -6505,6 +6828,9 @@ namespace nidaqmx_grpc { float64 voltage_excit_val = request->voltage_excit_val(); auto custom_scale_name = request->custom_scale_name().c_str(); auto status = library_->CreateTEDSAITorqueBridgeChan(task, physical_channel, name_to_assign_to_channel, min_val, max_val, units, voltage_excit_source, voltage_excit_val, custom_scale_name); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); + } response->set_status(status); return ::grpc::Status::OK; } @@ -6561,6 +6887,9 @@ namespace nidaqmx_grpc { auto custom_scale_name = request->custom_scale_name().c_str(); auto status = library_->CreateTEDSAIVoltageChan(task, physical_channel, name_to_assign_to_channel, terminal_config, min_val, max_val, units, custom_scale_name); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); + } response->set_status(status); return ::grpc::Status::OK; } @@ -6634,6 +6963,9 @@ namespace nidaqmx_grpc { float64 voltage_excit_val = request->voltage_excit_val(); auto custom_scale_name = request->custom_scale_name().c_str(); auto status = library_->CreateTEDSAIVoltageChanWithExcit(task, physical_channel, name_to_assign_to_channel, terminal_config, min_val, max_val, units, voltage_excit_source, voltage_excit_val, custom_scale_name); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); + } response->set_status(status); return ::grpc::Status::OK; } @@ -6673,6 +7005,9 @@ namespace nidaqmx_grpc { auto scaled_units = request->scaled_units().c_str(); auto status = library_->CreateTableScale(name, prescaled_vals, num_prescaled_vals_in, scaled_vals, num_scaled_vals_in, pre_scaled_units, scaled_units); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, 0); + } response->set_status(status); return ::grpc::Status::OK; } @@ -6700,10 +7035,11 @@ namespace nidaqmx_grpc { const std::string& grpc_device_session_name = request->session_name(); auto cleanup_lambda = [&] (TaskHandle id) { library_->ClearTask(id); }; int status = session_repository_->add_session(grpc_device_session_name, init_lambda, cleanup_lambda, session_id); - response->set_status(status); - if (status_ok(status)) { - response->mutable_task()->set_id(session_id); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, 0); } + response->set_status(status); + response->mutable_task()->set_id(session_id); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -6755,10 +7091,11 @@ namespace nidaqmx_grpc { const std::string& grpc_device_session_name = request->session_name(); auto cleanup_lambda = [&] (TaskHandle id) { library_->ClearTask(id); }; int status = session_repository_->add_session(grpc_device_session_name, init_lambda, cleanup_lambda, session_id); - response->set_status(status); - if (status_ok(status)) { - response->mutable_task()->set_id(session_id); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, 0); } + response->set_status(status); + response->mutable_task()->set_id(session_id); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -6790,10 +7127,11 @@ namespace nidaqmx_grpc { const std::string& grpc_device_session_name = request->session_name(); auto cleanup_lambda = [&] (TaskHandle id) { library_->ClearTask(id); }; int status = session_repository_->add_session(grpc_device_session_name, init_lambda, cleanup_lambda, session_id); - response->set_status(status); - if (status_ok(status)) { - response->mutable_task()->set_id(session_id); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, 0); } + response->set_status(status); + response->mutable_task()->set_id(session_id); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -6814,6 +7152,9 @@ namespace nidaqmx_grpc { try { auto device_name = request->device_name().c_str(); auto status = library_->DeleteNetworkDevice(device_name); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, 0); + } response->set_status(status); return ::grpc::Status::OK; } @@ -6832,6 +7173,9 @@ namespace nidaqmx_grpc { try { auto channel_name = request->channel_name().c_str(); auto status = library_->DeleteSavedGlobalChan(channel_name); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, 0); + } response->set_status(status); return ::grpc::Status::OK; } @@ -6850,6 +7194,9 @@ namespace nidaqmx_grpc { try { auto scale_name = request->scale_name().c_str(); auto status = library_->DeleteSavedScale(scale_name); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, 0); + } response->set_status(status); return ::grpc::Status::OK; } @@ -6868,6 +7215,9 @@ namespace nidaqmx_grpc { try { auto task_name = request->task_name().c_str(); auto status = library_->DeleteSavedTask(task_name); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, 0); + } response->set_status(status); return ::grpc::Status::OK; } @@ -6887,10 +7237,11 @@ namespace nidaqmx_grpc { auto device_name = request->device_name().c_str(); bool32 cal_supported {}; auto status = library_->DeviceSupportsCal(device_name, &cal_supported); - response->set_status(status); - if (status_ok(status)) { - response->set_cal_supported(cal_supported); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, 0); } + response->set_status(status); + response->set_cal_supported(cal_supported); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -6909,6 +7260,9 @@ namespace nidaqmx_grpc { auto task_grpc_session = request->task(); TaskHandle task = session_repository_->access_session(task_grpc_session.id(), task_grpc_session.name()); auto status = library_->DisableRefTrig(task); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); + } response->set_status(status); return ::grpc::Status::OK; } @@ -6928,6 +7282,9 @@ namespace nidaqmx_grpc { auto task_grpc_session = request->task(); TaskHandle task = session_repository_->access_session(task_grpc_session.id(), task_grpc_session.name()); auto status = library_->DisableStartTrig(task); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); + } response->set_status(status); return ::grpc::Status::OK; } @@ -6947,6 +7304,9 @@ namespace nidaqmx_grpc { auto source_terminal = request->source_terminal().c_str(); auto destination_terminal = request->destination_terminal().c_str(); auto status = library_->DisconnectTerms(source_terminal, destination_terminal); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, 0); + } response->set_status(status); return ::grpc::Status::OK; } @@ -6983,6 +7343,9 @@ namespace nidaqmx_grpc { auto output_terminal = request->output_terminal().c_str(); auto status = library_->ExportSignal(task, signal_id, output_terminal); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); + } response->set_status(status); return ::grpc::Status::OK; } @@ -7008,14 +7371,15 @@ namespace nidaqmx_grpc { uInt32 hour {}; uInt32 minute {}; auto status = library_->GetAIChanCalCalDate(task, channel_name, &year, &month, &day, &hour, &minute); - response->set_status(status); - if (status_ok(status)) { - response->set_year(year); - response->set_month(month); - response->set_day(day); - response->set_hour(hour); - response->set_minute(minute); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); } + response->set_status(status); + response->set_year(year); + response->set_month(month); + response->set_day(day); + response->set_hour(hour); + response->set_minute(minute); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -7040,14 +7404,15 @@ namespace nidaqmx_grpc { uInt32 hour {}; uInt32 minute {}; auto status = library_->GetAIChanCalExpDate(task, channel_name, &year, &month, &day, &hour, &minute); - response->set_status(status); - if (status_ok(status)) { - response->set_year(year); - response->set_month(month); - response->set_day(day); - response->set_hour(hour); - response->set_minute(minute); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); } + response->set_status(status); + response->set_year(year); + response->set_month(month); + response->set_day(day); + response->set_hour(hour); + response->set_minute(minute); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -7093,11 +7458,12 @@ namespace nidaqmx_grpc { std::vector stateVector; stateVector.resize(channels.size()); auto status = ((NiDAQmxLibrary*)library_)->GetAnalogPowerUpStates(device_name, get_channelName_if(channels, 0), get_state_if(stateVector, 0), get_channelType_if(channels, 0), get_channelName_if(channels, 1), get_state_if(stateVector, 1), get_channelType_if(channels, 1), get_channelName_if(channels, 2), get_state_if(stateVector, 2), get_channelType_if(channels, 2), get_channelName_if(channels, 3), get_state_if(stateVector, 3), get_channelType_if(channels, 3), get_channelName_if(channels, 4), get_state_if(stateVector, 4), get_channelType_if(channels, 4), get_channelName_if(channels, 5), get_state_if(stateVector, 5), get_channelType_if(channels, 5), get_channelName_if(channels, 6), get_state_if(stateVector, 6), get_channelType_if(channels, 6), get_channelName_if(channels, 7), get_state_if(stateVector, 7), get_channelType_if(channels, 7), get_channelName_if(channels, 8), get_state_if(stateVector, 8), get_channelType_if(channels, 8), get_channelName_if(channels, 9), get_state_if(stateVector, 9), get_channelType_if(channels, 9), get_channelName_if(channels, 10), get_state_if(stateVector, 10), get_channelType_if(channels, 10), get_channelName_if(channels, 11), get_state_if(stateVector, 11), get_channelType_if(channels, 11), get_channelName_if(channels, 12), get_state_if(stateVector, 12), get_channelType_if(channels, 12), get_channelName_if(channels, 13), get_state_if(stateVector, 13), get_channelType_if(channels, 13), get_channelName_if(channels, 14), get_state_if(stateVector, 14), get_channelType_if(channels, 14), get_channelName_if(channels, 15), get_state_if(stateVector, 15), get_channelType_if(channels, 15), get_channelName_if(channels, 16), get_state_if(stateVector, 16), get_channelType_if(channels, 16), get_channelName_if(channels, 17), get_state_if(stateVector, 17), get_channelType_if(channels, 17), get_channelName_if(channels, 18), get_state_if(stateVector, 18), get_channelType_if(channels, 18), get_channelName_if(channels, 19), get_state_if(stateVector, 19), get_channelType_if(channels, 19), get_channelName_if(channels, 20), get_state_if(stateVector, 20), get_channelType_if(channels, 20), get_channelName_if(channels, 21), get_state_if(stateVector, 21), get_channelType_if(channels, 21), get_channelName_if(channels, 22), get_state_if(stateVector, 22), get_channelType_if(channels, 22), get_channelName_if(channels, 23), get_state_if(stateVector, 23), get_channelType_if(channels, 23), get_channelName_if(channels, 24), get_state_if(stateVector, 24), get_channelType_if(channels, 24), get_channelName_if(channels, 25), get_state_if(stateVector, 25), get_channelType_if(channels, 25), get_channelName_if(channels, 26), get_state_if(stateVector, 26), get_channelType_if(channels, 26), get_channelName_if(channels, 27), get_state_if(stateVector, 27), get_channelType_if(channels, 27), get_channelName_if(channels, 28), get_state_if(stateVector, 28), get_channelType_if(channels, 28), get_channelName_if(channels, 29), get_state_if(stateVector, 29), get_channelType_if(channels, 29), get_channelName_if(channels, 30), get_state_if(stateVector, 30), get_channelType_if(channels, 30), get_channelName_if(channels, 31), get_state_if(stateVector, 31), get_channelType_if(channels, 31), get_channelName_if(channels, 32), get_state_if(stateVector, 32), get_channelType_if(channels, 32), get_channelName_if(channels, 33), get_state_if(stateVector, 33), get_channelType_if(channels, 33), get_channelName_if(channels, 34), get_state_if(stateVector, 34), get_channelType_if(channels, 34), get_channelName_if(channels, 35), get_state_if(stateVector, 35), get_channelType_if(channels, 35), get_channelName_if(channels, 36), get_state_if(stateVector, 36), get_channelType_if(channels, 36), get_channelName_if(channels, 37), get_state_if(stateVector, 37), get_channelType_if(channels, 37), get_channelName_if(channels, 38), get_state_if(stateVector, 38), get_channelType_if(channels, 38), get_channelName_if(channels, 39), get_state_if(stateVector, 39), get_channelType_if(channels, 39), get_channelName_if(channels, 40), get_state_if(stateVector, 40), get_channelType_if(channels, 40), get_channelName_if(channels, 41), get_state_if(stateVector, 41), get_channelType_if(channels, 41), get_channelName_if(channels, 42), get_state_if(stateVector, 42), get_channelType_if(channels, 42), get_channelName_if(channels, 43), get_state_if(stateVector, 43), get_channelType_if(channels, 43), get_channelName_if(channels, 44), get_state_if(stateVector, 44), get_channelType_if(channels, 44), get_channelName_if(channels, 45), get_state_if(stateVector, 45), get_channelType_if(channels, 45), get_channelName_if(channels, 46), get_state_if(stateVector, 46), get_channelType_if(channels, 46), get_channelName_if(channels, 47), get_state_if(stateVector, 47), get_channelType_if(channels, 47), get_channelName_if(channels, 48), get_state_if(stateVector, 48), get_channelType_if(channels, 48), get_channelName_if(channels, 49), get_state_if(stateVector, 49), get_channelType_if(channels, 49), get_channelName_if(channels, 50), get_state_if(stateVector, 50), get_channelType_if(channels, 50), get_channelName_if(channels, 51), get_state_if(stateVector, 51), get_channelType_if(channels, 51), get_channelName_if(channels, 52), get_state_if(stateVector, 52), get_channelType_if(channels, 52), get_channelName_if(channels, 53), get_state_if(stateVector, 53), get_channelType_if(channels, 53), get_channelName_if(channels, 54), get_state_if(stateVector, 54), get_channelType_if(channels, 54), get_channelName_if(channels, 55), get_state_if(stateVector, 55), get_channelType_if(channels, 55), get_channelName_if(channels, 56), get_state_if(stateVector, 56), get_channelType_if(channels, 56), get_channelName_if(channels, 57), get_state_if(stateVector, 57), get_channelType_if(channels, 57), get_channelName_if(channels, 58), get_state_if(stateVector, 58), get_channelType_if(channels, 58), get_channelName_if(channels, 59), get_state_if(stateVector, 59), get_channelType_if(channels, 59), get_channelName_if(channels, 60), get_state_if(stateVector, 60), get_channelType_if(channels, 60), get_channelName_if(channels, 61), get_state_if(stateVector, 61), get_channelType_if(channels, 61), get_channelName_if(channels, 62), get_state_if(stateVector, 62), get_channelType_if(channels, 62), get_channelName_if(channels, 63), get_state_if(stateVector, 63), get_channelType_if(channels, 63), get_channelName_if(channels, 64), get_state_if(stateVector, 64), get_channelType_if(channels, 64), get_channelName_if(channels, 65), get_state_if(stateVector, 65), get_channelType_if(channels, 65), get_channelName_if(channels, 66), get_state_if(stateVector, 66), get_channelType_if(channels, 66), get_channelName_if(channels, 67), get_state_if(stateVector, 67), get_channelType_if(channels, 67), get_channelName_if(channels, 68), get_state_if(stateVector, 68), get_channelType_if(channels, 68), get_channelName_if(channels, 69), get_state_if(stateVector, 69), get_channelType_if(channels, 69), get_channelName_if(channels, 70), get_state_if(stateVector, 70), get_channelType_if(channels, 70), get_channelName_if(channels, 71), get_state_if(stateVector, 71), get_channelType_if(channels, 71), get_channelName_if(channels, 72), get_state_if(stateVector, 72), get_channelType_if(channels, 72), get_channelName_if(channels, 73), get_state_if(stateVector, 73), get_channelType_if(channels, 73), get_channelName_if(channels, 74), get_state_if(stateVector, 74), get_channelType_if(channels, 74), get_channelName_if(channels, 75), get_state_if(stateVector, 75), get_channelType_if(channels, 75), get_channelName_if(channels, 76), get_state_if(stateVector, 76), get_channelType_if(channels, 76), get_channelName_if(channels, 77), get_state_if(stateVector, 77), get_channelType_if(channels, 77), get_channelName_if(channels, 78), get_state_if(stateVector, 78), get_channelType_if(channels, 78), get_channelName_if(channels, 79), get_state_if(stateVector, 79), get_channelType_if(channels, 79), get_channelName_if(channels, 80), get_state_if(stateVector, 80), get_channelType_if(channels, 80), get_channelName_if(channels, 81), get_state_if(stateVector, 81), get_channelType_if(channels, 81), get_channelName_if(channels, 82), get_state_if(stateVector, 82), get_channelType_if(channels, 82), get_channelName_if(channels, 83), get_state_if(stateVector, 83), get_channelType_if(channels, 83), get_channelName_if(channels, 84), get_state_if(stateVector, 84), get_channelType_if(channels, 84), get_channelName_if(channels, 85), get_state_if(stateVector, 85), get_channelType_if(channels, 85), get_channelName_if(channels, 86), get_state_if(stateVector, 86), get_channelType_if(channels, 86), get_channelName_if(channels, 87), get_state_if(stateVector, 87), get_channelType_if(channels, 87), get_channelName_if(channels, 88), get_state_if(stateVector, 88), get_channelType_if(channels, 88), get_channelName_if(channels, 89), get_state_if(stateVector, 89), get_channelType_if(channels, 89), get_channelName_if(channels, 90), get_state_if(stateVector, 90), get_channelType_if(channels, 90), get_channelName_if(channels, 91), get_state_if(stateVector, 91), get_channelType_if(channels, 91), get_channelName_if(channels, 92), get_state_if(stateVector, 92), get_channelType_if(channels, 92), get_channelName_if(channels, 93), get_state_if(stateVector, 93), get_channelType_if(channels, 93), get_channelName_if(channels, 94), get_state_if(stateVector, 94), get_channelType_if(channels, 94), get_channelName_if(channels, 95), get_state_if(stateVector, 95), get_channelType_if(channels, 95), get_channelName_if(channels, 96), get_state_if(stateVector, 96), get_channelType_if(channels, 96)); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, 0); + } response->set_status(status); - if (status_ok(status)) { - for (int i = 0; i < stateVector.size(); ++i) { - response->add_power_up_states(stateVector[i]); - } + for (int i = 0; i < stateVector.size(); ++i) { + response->add_power_up_states(stateVector[i]); } return ::grpc::Status::OK; } @@ -7121,9 +7487,11 @@ namespace nidaqmx_grpc { response->mutable_channel_type_array_raw()->Resize(array_size_copy, 0); int32* channel_type_array = reinterpret_cast(response->mutable_channel_type_array_raw()->mutable_data()); auto status = library_->GetAnalogPowerUpStatesWithOutputType(channel_names, state_array, channel_type_array, &array_size_copy); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, 0); + } response->set_status(status); - if (status_ok(status)) { - response->mutable_state_array()->Resize(array_size_copy, 0); + response->mutable_state_array()->Resize(array_size_copy, 0); response->mutable_channel_type_array()->Clear(); response->mutable_channel_type_array()->Reserve(array_size_copy); std::transform( @@ -7133,7 +7501,6 @@ namespace nidaqmx_grpc { [&](auto x) { return static_cast(x); }); - } return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -7153,10 +7520,11 @@ namespace nidaqmx_grpc { TaskHandle task = session_repository_->access_session(task_grpc_session.id(), task_grpc_session.name()); CVIAbsoluteTime data {}; auto status = library_->GetArmStartTrigTimestampVal(task, &data); - response->set_status(status); - if (status_ok(status)) { - convert_to_grpc(data, response->mutable_data()); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); } + response->set_status(status); + convert_to_grpc(data, response->mutable_data()); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -7176,10 +7544,11 @@ namespace nidaqmx_grpc { TaskHandle task = session_repository_->access_session(task_grpc_session.id(), task_grpc_session.name()); CVIAbsoluteTime data {}; auto status = library_->GetArmStartTrigTrigWhen(task, &data); - response->set_status(status); - if (status_ok(status)) { - convert_to_grpc(data, response->mutable_data()); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); } + response->set_status(status); + convert_to_grpc(data, response->mutable_data()); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -7198,9 +7567,8 @@ namespace nidaqmx_grpc { while (true) { auto status = library_->GetAutoConfiguredCDAQSyncConnections(nullptr, 0); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, 0); } uInt32 port_list_size = status; @@ -7213,11 +7581,12 @@ namespace nidaqmx_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_port_list(port_list); - nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_port_list())); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, 0); } + response->set_status(status); + response->set_port_list(port_list); + nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_port_list())); return ::grpc::Status::OK; } } @@ -7257,10 +7626,11 @@ namespace nidaqmx_grpc { uInt32 value {}; auto status = library_->GetBufferAttributeUInt32(task, attribute, &value); - response->set_status(status); - if (status_ok(status)) { - response->set_value(value); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); } + response->set_status(status); + response->set_value(value); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -7299,10 +7669,11 @@ namespace nidaqmx_grpc { auto size = 0U; bool32 value {}; auto status = library_->GetCalInfoAttributeBool(device_name, attribute, &value, size); - response->set_status(status); - if (status_ok(status)) { - response->set_value(value); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, 0); } + response->set_status(status); + response->set_value(value); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -7341,10 +7712,11 @@ namespace nidaqmx_grpc { auto size = 0U; float64 value {}; auto status = library_->GetCalInfoAttributeDouble(device_name, attribute, &value, size); - response->set_status(status); - if (status_ok(status)) { - response->set_value(value); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, 0); } + response->set_status(status); + response->set_value(value); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -7383,9 +7755,8 @@ namespace nidaqmx_grpc { while (true) { auto status = library_->GetCalInfoAttributeString(device_name, attribute, nullptr, 0); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, 0); } uInt32 size = status; @@ -7398,11 +7769,12 @@ namespace nidaqmx_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_value(value); - nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_value())); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, 0); } + response->set_status(status); + response->set_value(value); + nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_value())); return ::grpc::Status::OK; } } @@ -7442,10 +7814,11 @@ namespace nidaqmx_grpc { auto size = 0U; uInt32 value {}; auto status = library_->GetCalInfoAttributeUInt32(device_name, attribute, &value, size); - response->set_status(status); - if (status_ok(status)) { - response->set_value(value); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, 0); } + response->set_status(status); + response->set_value(value); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -7486,10 +7859,11 @@ namespace nidaqmx_grpc { auto size = 0U; bool32 value {}; auto status = library_->GetChanAttributeBool(task, channel, attribute, &value, size); - response->set_status(status); - if (status_ok(status)) { - response->set_value(value); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); } + response->set_status(status); + response->set_value(value); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -7530,10 +7904,11 @@ namespace nidaqmx_grpc { auto size = 0U; float64 value {}; auto status = library_->GetChanAttributeDouble(task, channel, attribute, &value, size); - response->set_status(status); - if (status_ok(status)) { - response->set_value(value); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); } + response->set_status(status); + response->set_value(value); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -7574,9 +7949,8 @@ namespace nidaqmx_grpc { while (true) { auto status = library_->GetChanAttributeDoubleArray(task, channel, attribute, nullptr, 0); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); } uInt32 size = status; @@ -7587,9 +7961,10 @@ namespace nidaqmx_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); } + response->set_status(status); return ::grpc::Status::OK; } } @@ -7631,16 +8006,17 @@ namespace nidaqmx_grpc { auto size = 0U; int32 value {}; auto status = library_->GetChanAttributeInt32(task, channel, attribute, &value, size); - response->set_status(status); - if (status_ok(status)) { - auto checked_convert_value = [](auto raw_value) { - bool raw_value_is_valid = nidaqmx_grpc::ChannelInt32AttributeValues_IsValid(raw_value); - auto valid_enum_value = raw_value_is_valid ? raw_value : 0; - return static_cast(valid_enum_value); - }; - response->set_value(checked_convert_value(value)); - response->set_value_raw(value); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); } + response->set_status(status); + auto checked_convert_value = [](auto raw_value) { + bool raw_value_is_valid = nidaqmx_grpc::ChannelInt32AttributeValues_IsValid(raw_value); + auto valid_enum_value = raw_value_is_valid ? raw_value : 0; + return static_cast(valid_enum_value); + }; + response->set_value(checked_convert_value(value)); + response->set_value_raw(value); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -7681,9 +8057,8 @@ namespace nidaqmx_grpc { while (true) { auto status = library_->GetChanAttributeString(task, channel, attribute, nullptr, 0); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); } uInt32 size = status; @@ -7696,11 +8071,12 @@ namespace nidaqmx_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_value(value); - nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_value())); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); } + response->set_status(status); + response->set_value(value); + nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_value())); return ::grpc::Status::OK; } } @@ -7742,10 +8118,11 @@ namespace nidaqmx_grpc { auto size = 0U; uInt32 value {}; auto status = library_->GetChanAttributeUInt32(task, channel, attribute, &value, size); - response->set_status(status); - if (status_ok(status)) { - response->set_value(value); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); } + response->set_status(status); + response->set_value(value); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -7784,10 +8161,11 @@ namespace nidaqmx_grpc { auto size = 0U; bool32 value {}; auto status = library_->GetDeviceAttributeBool(device_name, attribute, &value, size); - response->set_status(status); - if (status_ok(status)) { - response->set_value(value); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, 0); } + response->set_status(status); + response->set_value(value); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -7826,10 +8204,11 @@ namespace nidaqmx_grpc { auto size = 0U; float64 value {}; auto status = library_->GetDeviceAttributeDouble(device_name, attribute, &value, size); - response->set_status(status); - if (status_ok(status)) { - response->set_value(value); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, 0); } + response->set_status(status); + response->set_value(value); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -7868,9 +8247,8 @@ namespace nidaqmx_grpc { while (true) { auto status = library_->GetDeviceAttributeDoubleArray(device_name, attribute, nullptr, 0); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, 0); } uInt32 size = status; @@ -7881,9 +8259,10 @@ namespace nidaqmx_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, 0); } + response->set_status(status); return ::grpc::Status::OK; } } @@ -7923,16 +8302,17 @@ namespace nidaqmx_grpc { auto size = 0U; int32 value {}; auto status = library_->GetDeviceAttributeInt32(device_name, attribute, &value, size); - response->set_status(status); - if (status_ok(status)) { - auto checked_convert_value = [](auto raw_value) { - bool raw_value_is_valid = nidaqmx_grpc::DeviceInt32AttributeValues_IsValid(raw_value); - auto valid_enum_value = raw_value_is_valid ? raw_value : 0; - return static_cast(valid_enum_value); - }; - response->set_value(checked_convert_value(value)); - response->set_value_raw(value); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, 0); } + response->set_status(status); + auto checked_convert_value = [](auto raw_value) { + bool raw_value_is_valid = nidaqmx_grpc::DeviceInt32AttributeValues_IsValid(raw_value); + auto valid_enum_value = raw_value_is_valid ? raw_value : 0; + return static_cast(valid_enum_value); + }; + response->set_value(checked_convert_value(value)); + response->set_value_raw(value); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -7971,9 +8351,8 @@ namespace nidaqmx_grpc { while (true) { auto status = library_->GetDeviceAttributeInt32Array(device_name, attribute, nullptr, 0); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, 0); } uInt32 size = status; @@ -7984,13 +8363,15 @@ namespace nidaqmx_grpc { // buffer is now too small, try again continue; } + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, 0); + } response->set_status(status); - if (status_ok(status)) { - auto checked_convert_value = [](auto raw_value) { - bool raw_value_is_valid = nidaqmx_grpc::DeviceInt32AttributeValues_IsValid(raw_value); - auto valid_enum_value = raw_value_is_valid ? raw_value : 0; - return static_cast(valid_enum_value); - }; + auto checked_convert_value = [](auto raw_value) { + bool raw_value_is_valid = nidaqmx_grpc::DeviceInt32AttributeValues_IsValid(raw_value); + auto valid_enum_value = raw_value_is_valid ? raw_value : 0; + return static_cast(valid_enum_value); + }; response->mutable_value()->Clear(); response->mutable_value()->Reserve(size); std::transform( @@ -8000,7 +8381,6 @@ namespace nidaqmx_grpc { [&](auto x) { return checked_convert_value(x); }); - } return ::grpc::Status::OK; } } @@ -8040,9 +8420,8 @@ namespace nidaqmx_grpc { while (true) { auto status = library_->GetDeviceAttributeString(device_name, attribute, nullptr, 0); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, 0); } uInt32 size = status; @@ -8055,11 +8434,12 @@ namespace nidaqmx_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_value(value); - nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_value())); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, 0); } + response->set_status(status); + response->set_value(value); + nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_value())); return ::grpc::Status::OK; } } @@ -8099,10 +8479,11 @@ namespace nidaqmx_grpc { auto size = 0U; uInt32 value {}; auto status = library_->GetDeviceAttributeUInt32(device_name, attribute, &value, size); - response->set_status(status); - if (status_ok(status)) { - response->set_value(value); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, 0); } + response->set_status(status); + response->set_value(value); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -8141,9 +8522,8 @@ namespace nidaqmx_grpc { while (true) { auto status = library_->GetDeviceAttributeUInt32Array(device_name, attribute, nullptr, 0); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, 0); } uInt32 size = status; @@ -8154,9 +8534,10 @@ namespace nidaqmx_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, 0); } + response->set_status(status); return ::grpc::Status::OK; } } @@ -8176,10 +8557,11 @@ namespace nidaqmx_grpc { auto device_name = request->device_name().c_str(); int32 logic_family {}; auto status = library_->GetDigitalLogicFamilyPowerUpState(device_name, &logic_family); - response->set_status(status); - if (status_ok(status)) { - response->set_logic_family(logic_family); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, 0); } + response->set_status(status); + response->set_logic_family(logic_family); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -8219,11 +8601,12 @@ namespace nidaqmx_grpc { std::vector stateVector; stateVector.resize(channel_name.size()); auto status = ((NiDAQmxLibrary*)library_)->GetDigitalPowerUpStates(device_name, get_channelName_if(channel_name, 0), get_state_if(stateVector, 0), get_channelName_if(channel_name, 1), get_state_if(stateVector, 1), get_channelName_if(channel_name, 2), get_state_if(stateVector, 2), get_channelName_if(channel_name, 3), get_state_if(stateVector, 3), get_channelName_if(channel_name, 4), get_state_if(stateVector, 4), get_channelName_if(channel_name, 5), get_state_if(stateVector, 5), get_channelName_if(channel_name, 6), get_state_if(stateVector, 6), get_channelName_if(channel_name, 7), get_state_if(stateVector, 7), get_channelName_if(channel_name, 8), get_state_if(stateVector, 8), get_channelName_if(channel_name, 9), get_state_if(stateVector, 9), get_channelName_if(channel_name, 10), get_state_if(stateVector, 10), get_channelName_if(channel_name, 11), get_state_if(stateVector, 11), get_channelName_if(channel_name, 12), get_state_if(stateVector, 12), get_channelName_if(channel_name, 13), get_state_if(stateVector, 13), get_channelName_if(channel_name, 14), get_state_if(stateVector, 14), get_channelName_if(channel_name, 15), get_state_if(stateVector, 15), get_channelName_if(channel_name, 16), get_state_if(stateVector, 16), get_channelName_if(channel_name, 17), get_state_if(stateVector, 17), get_channelName_if(channel_name, 18), get_state_if(stateVector, 18), get_channelName_if(channel_name, 19), get_state_if(stateVector, 19), get_channelName_if(channel_name, 20), get_state_if(stateVector, 20), get_channelName_if(channel_name, 21), get_state_if(stateVector, 21), get_channelName_if(channel_name, 22), get_state_if(stateVector, 22), get_channelName_if(channel_name, 23), get_state_if(stateVector, 23), get_channelName_if(channel_name, 24), get_state_if(stateVector, 24), get_channelName_if(channel_name, 25), get_state_if(stateVector, 25), get_channelName_if(channel_name, 26), get_state_if(stateVector, 26), get_channelName_if(channel_name, 27), get_state_if(stateVector, 27), get_channelName_if(channel_name, 28), get_state_if(stateVector, 28), get_channelName_if(channel_name, 29), get_state_if(stateVector, 29), get_channelName_if(channel_name, 30), get_state_if(stateVector, 30), get_channelName_if(channel_name, 31), get_state_if(stateVector, 31), get_channelName_if(channel_name, 32), get_state_if(stateVector, 32), get_channelName_if(channel_name, 33), get_state_if(stateVector, 33), get_channelName_if(channel_name, 34), get_state_if(stateVector, 34), get_channelName_if(channel_name, 35), get_state_if(stateVector, 35), get_channelName_if(channel_name, 36), get_state_if(stateVector, 36), get_channelName_if(channel_name, 37), get_state_if(stateVector, 37), get_channelName_if(channel_name, 38), get_state_if(stateVector, 38), get_channelName_if(channel_name, 39), get_state_if(stateVector, 39), get_channelName_if(channel_name, 40), get_state_if(stateVector, 40), get_channelName_if(channel_name, 41), get_state_if(stateVector, 41), get_channelName_if(channel_name, 42), get_state_if(stateVector, 42), get_channelName_if(channel_name, 43), get_state_if(stateVector, 43), get_channelName_if(channel_name, 44), get_state_if(stateVector, 44), get_channelName_if(channel_name, 45), get_state_if(stateVector, 45), get_channelName_if(channel_name, 46), get_state_if(stateVector, 46), get_channelName_if(channel_name, 47), get_state_if(stateVector, 47), get_channelName_if(channel_name, 48), get_state_if(stateVector, 48), get_channelName_if(channel_name, 49), get_state_if(stateVector, 49), get_channelName_if(channel_name, 50), get_state_if(stateVector, 50), get_channelName_if(channel_name, 51), get_state_if(stateVector, 51), get_channelName_if(channel_name, 52), get_state_if(stateVector, 52), get_channelName_if(channel_name, 53), get_state_if(stateVector, 53), get_channelName_if(channel_name, 54), get_state_if(stateVector, 54), get_channelName_if(channel_name, 55), get_state_if(stateVector, 55), get_channelName_if(channel_name, 56), get_state_if(stateVector, 56), get_channelName_if(channel_name, 57), get_state_if(stateVector, 57), get_channelName_if(channel_name, 58), get_state_if(stateVector, 58), get_channelName_if(channel_name, 59), get_state_if(stateVector, 59), get_channelName_if(channel_name, 60), get_state_if(stateVector, 60), get_channelName_if(channel_name, 61), get_state_if(stateVector, 61), get_channelName_if(channel_name, 62), get_state_if(stateVector, 62), get_channelName_if(channel_name, 63), get_state_if(stateVector, 63), get_channelName_if(channel_name, 64), get_state_if(stateVector, 64), get_channelName_if(channel_name, 65), get_state_if(stateVector, 65), get_channelName_if(channel_name, 66), get_state_if(stateVector, 66), get_channelName_if(channel_name, 67), get_state_if(stateVector, 67), get_channelName_if(channel_name, 68), get_state_if(stateVector, 68), get_channelName_if(channel_name, 69), get_state_if(stateVector, 69), get_channelName_if(channel_name, 70), get_state_if(stateVector, 70), get_channelName_if(channel_name, 71), get_state_if(stateVector, 71), get_channelName_if(channel_name, 72), get_state_if(stateVector, 72), get_channelName_if(channel_name, 73), get_state_if(stateVector, 73), get_channelName_if(channel_name, 74), get_state_if(stateVector, 74), get_channelName_if(channel_name, 75), get_state_if(stateVector, 75), get_channelName_if(channel_name, 76), get_state_if(stateVector, 76), get_channelName_if(channel_name, 77), get_state_if(stateVector, 77), get_channelName_if(channel_name, 78), get_state_if(stateVector, 78), get_channelName_if(channel_name, 79), get_state_if(stateVector, 79), get_channelName_if(channel_name, 80), get_state_if(stateVector, 80), get_channelName_if(channel_name, 81), get_state_if(stateVector, 81), get_channelName_if(channel_name, 82), get_state_if(stateVector, 82), get_channelName_if(channel_name, 83), get_state_if(stateVector, 83), get_channelName_if(channel_name, 84), get_state_if(stateVector, 84), get_channelName_if(channel_name, 85), get_state_if(stateVector, 85), get_channelName_if(channel_name, 86), get_state_if(stateVector, 86), get_channelName_if(channel_name, 87), get_state_if(stateVector, 87), get_channelName_if(channel_name, 88), get_state_if(stateVector, 88), get_channelName_if(channel_name, 89), get_state_if(stateVector, 89), get_channelName_if(channel_name, 90), get_state_if(stateVector, 90), get_channelName_if(channel_name, 91), get_state_if(stateVector, 91), get_channelName_if(channel_name, 92), get_state_if(stateVector, 92), get_channelName_if(channel_name, 93), get_state_if(stateVector, 93), get_channelName_if(channel_name, 94), get_state_if(stateVector, 94), get_channelName_if(channel_name, 95), get_state_if(stateVector, 95), get_channelName_if(channel_name, 96), get_state_if(stateVector, 96)); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, 0); + } response->set_status(status); - if (status_ok(status)) { - for (int i = 0; i < stateVector.size(); ++i) { - response->add_power_up_states(static_cast(stateVector[i])); - } + for (int i = 0; i < stateVector.size(); ++i) { + response->add_power_up_states(static_cast(stateVector[i])); } return ::grpc::Status::OK; } @@ -8264,11 +8647,12 @@ namespace nidaqmx_grpc { std::vector stateVector; stateVector.resize(channel_name.size()); auto status = ((NiDAQmxLibrary*)library_)->GetDigitalPullUpPullDownStates(device_name, get_channelName_if(channel_name, 0), get_state_if(stateVector, 0), get_channelName_if(channel_name, 1), get_state_if(stateVector, 1), get_channelName_if(channel_name, 2), get_state_if(stateVector, 2), get_channelName_if(channel_name, 3), get_state_if(stateVector, 3), get_channelName_if(channel_name, 4), get_state_if(stateVector, 4), get_channelName_if(channel_name, 5), get_state_if(stateVector, 5), get_channelName_if(channel_name, 6), get_state_if(stateVector, 6), get_channelName_if(channel_name, 7), get_state_if(stateVector, 7), get_channelName_if(channel_name, 8), get_state_if(stateVector, 8), get_channelName_if(channel_name, 9), get_state_if(stateVector, 9), get_channelName_if(channel_name, 10), get_state_if(stateVector, 10), get_channelName_if(channel_name, 11), get_state_if(stateVector, 11), get_channelName_if(channel_name, 12), get_state_if(stateVector, 12), get_channelName_if(channel_name, 13), get_state_if(stateVector, 13), get_channelName_if(channel_name, 14), get_state_if(stateVector, 14), get_channelName_if(channel_name, 15), get_state_if(stateVector, 15), get_channelName_if(channel_name, 16), get_state_if(stateVector, 16), get_channelName_if(channel_name, 17), get_state_if(stateVector, 17), get_channelName_if(channel_name, 18), get_state_if(stateVector, 18), get_channelName_if(channel_name, 19), get_state_if(stateVector, 19), get_channelName_if(channel_name, 20), get_state_if(stateVector, 20), get_channelName_if(channel_name, 21), get_state_if(stateVector, 21), get_channelName_if(channel_name, 22), get_state_if(stateVector, 22), get_channelName_if(channel_name, 23), get_state_if(stateVector, 23), get_channelName_if(channel_name, 24), get_state_if(stateVector, 24), get_channelName_if(channel_name, 25), get_state_if(stateVector, 25), get_channelName_if(channel_name, 26), get_state_if(stateVector, 26), get_channelName_if(channel_name, 27), get_state_if(stateVector, 27), get_channelName_if(channel_name, 28), get_state_if(stateVector, 28), get_channelName_if(channel_name, 29), get_state_if(stateVector, 29), get_channelName_if(channel_name, 30), get_state_if(stateVector, 30), get_channelName_if(channel_name, 31), get_state_if(stateVector, 31), get_channelName_if(channel_name, 32), get_state_if(stateVector, 32), get_channelName_if(channel_name, 33), get_state_if(stateVector, 33), get_channelName_if(channel_name, 34), get_state_if(stateVector, 34), get_channelName_if(channel_name, 35), get_state_if(stateVector, 35), get_channelName_if(channel_name, 36), get_state_if(stateVector, 36), get_channelName_if(channel_name, 37), get_state_if(stateVector, 37), get_channelName_if(channel_name, 38), get_state_if(stateVector, 38), get_channelName_if(channel_name, 39), get_state_if(stateVector, 39), get_channelName_if(channel_name, 40), get_state_if(stateVector, 40), get_channelName_if(channel_name, 41), get_state_if(stateVector, 41), get_channelName_if(channel_name, 42), get_state_if(stateVector, 42), get_channelName_if(channel_name, 43), get_state_if(stateVector, 43), get_channelName_if(channel_name, 44), get_state_if(stateVector, 44), get_channelName_if(channel_name, 45), get_state_if(stateVector, 45), get_channelName_if(channel_name, 46), get_state_if(stateVector, 46), get_channelName_if(channel_name, 47), get_state_if(stateVector, 47), get_channelName_if(channel_name, 48), get_state_if(stateVector, 48), get_channelName_if(channel_name, 49), get_state_if(stateVector, 49), get_channelName_if(channel_name, 50), get_state_if(stateVector, 50), get_channelName_if(channel_name, 51), get_state_if(stateVector, 51), get_channelName_if(channel_name, 52), get_state_if(stateVector, 52), get_channelName_if(channel_name, 53), get_state_if(stateVector, 53), get_channelName_if(channel_name, 54), get_state_if(stateVector, 54), get_channelName_if(channel_name, 55), get_state_if(stateVector, 55), get_channelName_if(channel_name, 56), get_state_if(stateVector, 56), get_channelName_if(channel_name, 57), get_state_if(stateVector, 57), get_channelName_if(channel_name, 58), get_state_if(stateVector, 58), get_channelName_if(channel_name, 59), get_state_if(stateVector, 59), get_channelName_if(channel_name, 60), get_state_if(stateVector, 60), get_channelName_if(channel_name, 61), get_state_if(stateVector, 61), get_channelName_if(channel_name, 62), get_state_if(stateVector, 62), get_channelName_if(channel_name, 63), get_state_if(stateVector, 63), get_channelName_if(channel_name, 64), get_state_if(stateVector, 64), get_channelName_if(channel_name, 65), get_state_if(stateVector, 65), get_channelName_if(channel_name, 66), get_state_if(stateVector, 66), get_channelName_if(channel_name, 67), get_state_if(stateVector, 67), get_channelName_if(channel_name, 68), get_state_if(stateVector, 68), get_channelName_if(channel_name, 69), get_state_if(stateVector, 69), get_channelName_if(channel_name, 70), get_state_if(stateVector, 70), get_channelName_if(channel_name, 71), get_state_if(stateVector, 71), get_channelName_if(channel_name, 72), get_state_if(stateVector, 72), get_channelName_if(channel_name, 73), get_state_if(stateVector, 73), get_channelName_if(channel_name, 74), get_state_if(stateVector, 74), get_channelName_if(channel_name, 75), get_state_if(stateVector, 75), get_channelName_if(channel_name, 76), get_state_if(stateVector, 76), get_channelName_if(channel_name, 77), get_state_if(stateVector, 77), get_channelName_if(channel_name, 78), get_state_if(stateVector, 78), get_channelName_if(channel_name, 79), get_state_if(stateVector, 79), get_channelName_if(channel_name, 80), get_state_if(stateVector, 80), get_channelName_if(channel_name, 81), get_state_if(stateVector, 81), get_channelName_if(channel_name, 82), get_state_if(stateVector, 82), get_channelName_if(channel_name, 83), get_state_if(stateVector, 83), get_channelName_if(channel_name, 84), get_state_if(stateVector, 84), get_channelName_if(channel_name, 85), get_state_if(stateVector, 85), get_channelName_if(channel_name, 86), get_state_if(stateVector, 86), get_channelName_if(channel_name, 87), get_state_if(stateVector, 87), get_channelName_if(channel_name, 88), get_state_if(stateVector, 88), get_channelName_if(channel_name, 89), get_state_if(stateVector, 89), get_channelName_if(channel_name, 90), get_state_if(stateVector, 90), get_channelName_if(channel_name, 91), get_state_if(stateVector, 91), get_channelName_if(channel_name, 92), get_state_if(stateVector, 92), get_channelName_if(channel_name, 93), get_state_if(stateVector, 93), get_channelName_if(channel_name, 94), get_state_if(stateVector, 94), get_channelName_if(channel_name, 95), get_state_if(stateVector, 95), get_channelName_if(channel_name, 96), get_state_if(stateVector, 96)); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, 0); + } response->set_status(status); - if (status_ok(status)) { - for (int i = 0; i < stateVector.size(); ++i) { - response->add_pull_up_pull_down_states(static_cast(stateVector[i])); - } + for (int i = 0; i < stateVector.size(); ++i) { + response->add_pull_up_pull_down_states(static_cast(stateVector[i])); } return ::grpc::Status::OK; } @@ -8288,9 +8672,8 @@ namespace nidaqmx_grpc { while (true) { auto status = library_->GetDisconnectedCDAQSyncPorts(nullptr, 0); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, 0); } uInt32 port_list_size = status; @@ -8303,11 +8686,12 @@ namespace nidaqmx_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_port_list(port_list); - nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_port_list())); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, 0); } + response->set_status(status); + response->set_port_list(port_list); + nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_port_list())); return ::grpc::Status::OK; } } @@ -8328,9 +8712,8 @@ namespace nidaqmx_grpc { while (true) { auto status = library_->GetErrorString(error_code, nullptr, 0); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, 0); } uInt32 buffer_size = status; @@ -8343,11 +8726,12 @@ namespace nidaqmx_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_error_string(error_string); - nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_error_string())); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, 0); } + response->set_status(status); + response->set_error_string(error_string); + nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_error_string())); return ::grpc::Status::OK; } } @@ -8388,10 +8772,11 @@ namespace nidaqmx_grpc { auto size = 0U; bool32 value {}; auto status = library_->GetExportedSignalAttributeBool(task, attribute, &value, size); - response->set_status(status); - if (status_ok(status)) { - response->set_value(value); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); } + response->set_status(status); + response->set_value(value); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -8431,10 +8816,11 @@ namespace nidaqmx_grpc { auto size = 0U; float64 value {}; auto status = library_->GetExportedSignalAttributeDouble(task, attribute, &value, size); - response->set_status(status); - if (status_ok(status)) { - response->set_value(value); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); } + response->set_status(status); + response->set_value(value); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -8474,16 +8860,17 @@ namespace nidaqmx_grpc { auto size = 0U; int32 value {}; auto status = library_->GetExportedSignalAttributeInt32(task, attribute, &value, size); - response->set_status(status); - if (status_ok(status)) { - auto checked_convert_value = [](auto raw_value) { - bool raw_value_is_valid = nidaqmx_grpc::ExportSignalInt32AttributeValues_IsValid(raw_value); - auto valid_enum_value = raw_value_is_valid ? raw_value : 0; - return static_cast(valid_enum_value); - }; - response->set_value(checked_convert_value(value)); - response->set_value_raw(value); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); } + response->set_status(status); + auto checked_convert_value = [](auto raw_value) { + bool raw_value_is_valid = nidaqmx_grpc::ExportSignalInt32AttributeValues_IsValid(raw_value); + auto valid_enum_value = raw_value_is_valid ? raw_value : 0; + return static_cast(valid_enum_value); + }; + response->set_value(checked_convert_value(value)); + response->set_value_raw(value); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -8523,9 +8910,8 @@ namespace nidaqmx_grpc { while (true) { auto status = library_->GetExportedSignalAttributeString(task, attribute, nullptr, 0); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); } uInt32 size = status; @@ -8538,11 +8924,12 @@ namespace nidaqmx_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_value(value); - nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_value())); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); } + response->set_status(status); + response->set_value(value); + nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_value())); return ::grpc::Status::OK; } } @@ -8583,10 +8970,11 @@ namespace nidaqmx_grpc { auto size = 0U; uInt32 value {}; auto status = library_->GetExportedSignalAttributeUInt32(task, attribute, &value, size); - response->set_status(status); - if (status_ok(status)) { - response->set_value(value); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); } + response->set_status(status); + response->set_value(value); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -8605,9 +8993,8 @@ namespace nidaqmx_grpc { while (true) { auto status = library_->GetExtendedErrorInfo(nullptr, 0); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, 0); } uInt32 buffer_size = status; @@ -8620,11 +9007,12 @@ namespace nidaqmx_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_error_string(error_string); - nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_error_string())); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, 0); } + response->set_status(status); + response->set_error_string(error_string); + nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_error_string())); return ::grpc::Status::OK; } } @@ -8645,10 +9033,11 @@ namespace nidaqmx_grpc { TaskHandle task = session_repository_->access_session(task_grpc_session.id(), task_grpc_session.name()); CVIAbsoluteTime data {}; auto status = library_->GetFirstSampClkWhen(task, &data); - response->set_status(status); - if (status_ok(status)) { - convert_to_grpc(data, response->mutable_data()); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); } + response->set_status(status); + convert_to_grpc(data, response->mutable_data()); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -8668,10 +9057,11 @@ namespace nidaqmx_grpc { TaskHandle task = session_repository_->access_session(task_grpc_session.id(), task_grpc_session.name()); CVIAbsoluteTime data {}; auto status = library_->GetFirstSampTimestampVal(task, &data); - response->set_status(status); - if (status_ok(status)) { - convert_to_grpc(data, response->mutable_data()); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); } + response->set_status(status); + convert_to_grpc(data, response->mutable_data()); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -8693,9 +9083,8 @@ namespace nidaqmx_grpc { while (true) { auto status = library_->GetNthTaskChannel(task, index, nullptr, 0); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); } int32 buffer_size = status; @@ -8708,11 +9097,12 @@ namespace nidaqmx_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_buffer(buffer); - nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_buffer())); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); } + response->set_status(status); + response->set_buffer(buffer); + nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_buffer())); return ::grpc::Status::OK; } } @@ -8735,9 +9125,8 @@ namespace nidaqmx_grpc { while (true) { auto status = library_->GetNthTaskDevice(task, index, nullptr, 0); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); } int32 buffer_size = status; @@ -8750,11 +9139,12 @@ namespace nidaqmx_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_buffer(buffer); - nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_buffer())); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); } + response->set_status(status); + response->set_buffer(buffer); + nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_buffer())); return ::grpc::Status::OK; } } @@ -8777,9 +9167,8 @@ namespace nidaqmx_grpc { while (true) { auto status = library_->GetNthTaskReadChannel(task, index, nullptr, 0); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); } int32 buffer_size = status; @@ -8792,11 +9181,12 @@ namespace nidaqmx_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_buffer(buffer); - nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_buffer())); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); } + response->set_status(status); + response->set_buffer(buffer); + nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_buffer())); return ::grpc::Status::OK; } } @@ -8836,10 +9226,11 @@ namespace nidaqmx_grpc { auto size = 0U; bool32 value {}; auto status = library_->GetPersistedChanAttributeBool(channel, attribute, &value, size); - response->set_status(status); - if (status_ok(status)) { - response->set_value(value); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, 0); } + response->set_status(status); + response->set_value(value); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -8878,9 +9269,8 @@ namespace nidaqmx_grpc { while (true) { auto status = library_->GetPersistedChanAttributeString(channel, attribute, nullptr, 0); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, 0); } uInt32 size = status; @@ -8893,11 +9283,12 @@ namespace nidaqmx_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_value(value); - nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_value())); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, 0); } + response->set_status(status); + response->set_value(value); + nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_value())); return ::grpc::Status::OK; } } @@ -8937,10 +9328,11 @@ namespace nidaqmx_grpc { auto size = 0U; bool32 value {}; auto status = library_->GetPersistedScaleAttributeBool(scale_name, attribute, &value, size); - response->set_status(status); - if (status_ok(status)) { - response->set_value(value); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, 0); } + response->set_status(status); + response->set_value(value); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -8979,9 +9371,8 @@ namespace nidaqmx_grpc { while (true) { auto status = library_->GetPersistedScaleAttributeString(scale_name, attribute, nullptr, 0); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, 0); } uInt32 size = status; @@ -8994,11 +9385,12 @@ namespace nidaqmx_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_value(value); - nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_value())); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, 0); } + response->set_status(status); + response->set_value(value); + nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_value())); return ::grpc::Status::OK; } } @@ -9038,10 +9430,11 @@ namespace nidaqmx_grpc { auto size = 0U; bool32 value {}; auto status = library_->GetPersistedTaskAttributeBool(task_name, attribute, &value, size); - response->set_status(status); - if (status_ok(status)) { - response->set_value(value); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, 0); } + response->set_status(status); + response->set_value(value); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -9080,9 +9473,8 @@ namespace nidaqmx_grpc { while (true) { auto status = library_->GetPersistedTaskAttributeString(task_name, attribute, nullptr, 0); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, 0); } uInt32 size = status; @@ -9095,11 +9487,12 @@ namespace nidaqmx_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_value(value); - nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_value())); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, 0); } + response->set_status(status); + response->set_value(value); + nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_value())); return ::grpc::Status::OK; } } @@ -9139,10 +9532,11 @@ namespace nidaqmx_grpc { auto size = 0U; bool32 value {}; auto status = library_->GetPhysicalChanAttributeBool(physical_channel, attribute, &value, size); - response->set_status(status); - if (status_ok(status)) { - response->set_value(value); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, 0); } + response->set_status(status); + response->set_value(value); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -9181,9 +9575,8 @@ namespace nidaqmx_grpc { while (true) { auto status = library_->GetPhysicalChanAttributeBytes(physical_channel, attribute, nullptr, 0); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, 0); } uInt32 size = status; @@ -9193,10 +9586,11 @@ namespace nidaqmx_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_value(value); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, 0); } + response->set_status(status); + response->set_value(value); return ::grpc::Status::OK; } } @@ -9236,10 +9630,11 @@ namespace nidaqmx_grpc { auto size = 0U; float64 value {}; auto status = library_->GetPhysicalChanAttributeDouble(physical_channel, attribute, &value, size); - response->set_status(status); - if (status_ok(status)) { - response->set_value(value); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, 0); } + response->set_status(status); + response->set_value(value); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -9278,9 +9673,8 @@ namespace nidaqmx_grpc { while (true) { auto status = library_->GetPhysicalChanAttributeDoubleArray(physical_channel, attribute, nullptr, 0); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, 0); } uInt32 size = status; @@ -9291,9 +9685,10 @@ namespace nidaqmx_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, 0); } + response->set_status(status); return ::grpc::Status::OK; } } @@ -9333,16 +9728,17 @@ namespace nidaqmx_grpc { auto size = 0U; int32 value {}; auto status = library_->GetPhysicalChanAttributeInt32(physical_channel, attribute, &value, size); - response->set_status(status); - if (status_ok(status)) { - auto checked_convert_value = [](auto raw_value) { - bool raw_value_is_valid = nidaqmx_grpc::PhysicalChannelInt32AttributeValues_IsValid(raw_value); - auto valid_enum_value = raw_value_is_valid ? raw_value : 0; - return static_cast(valid_enum_value); - }; - response->set_value(checked_convert_value(value)); - response->set_value_raw(value); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, 0); } + response->set_status(status); + auto checked_convert_value = [](auto raw_value) { + bool raw_value_is_valid = nidaqmx_grpc::PhysicalChannelInt32AttributeValues_IsValid(raw_value); + auto valid_enum_value = raw_value_is_valid ? raw_value : 0; + return static_cast(valid_enum_value); + }; + response->set_value(checked_convert_value(value)); + response->set_value_raw(value); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -9381,9 +9777,8 @@ namespace nidaqmx_grpc { while (true) { auto status = library_->GetPhysicalChanAttributeInt32Array(physical_channel, attribute, nullptr, 0); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, 0); } uInt32 size = status; @@ -9394,13 +9789,15 @@ namespace nidaqmx_grpc { // buffer is now too small, try again continue; } + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, 0); + } response->set_status(status); - if (status_ok(status)) { - auto checked_convert_value = [](auto raw_value) { - bool raw_value_is_valid = nidaqmx_grpc::PhysicalChannelInt32AttributeValues_IsValid(raw_value); - auto valid_enum_value = raw_value_is_valid ? raw_value : 0; - return static_cast(valid_enum_value); - }; + auto checked_convert_value = [](auto raw_value) { + bool raw_value_is_valid = nidaqmx_grpc::PhysicalChannelInt32AttributeValues_IsValid(raw_value); + auto valid_enum_value = raw_value_is_valid ? raw_value : 0; + return static_cast(valid_enum_value); + }; response->mutable_value()->Clear(); response->mutable_value()->Reserve(size); std::transform( @@ -9410,7 +9807,6 @@ namespace nidaqmx_grpc { [&](auto x) { return checked_convert_value(x); }); - } return ::grpc::Status::OK; } } @@ -9450,9 +9846,8 @@ namespace nidaqmx_grpc { while (true) { auto status = library_->GetPhysicalChanAttributeString(physical_channel, attribute, nullptr, 0); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, 0); } uInt32 size = status; @@ -9465,11 +9860,12 @@ namespace nidaqmx_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_value(value); - nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_value())); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, 0); } + response->set_status(status); + response->set_value(value); + nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_value())); return ::grpc::Status::OK; } } @@ -9509,10 +9905,11 @@ namespace nidaqmx_grpc { auto size = 0U; uInt32 value {}; auto status = library_->GetPhysicalChanAttributeUInt32(physical_channel, attribute, &value, size); - response->set_status(status); - if (status_ok(status)) { - response->set_value(value); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, 0); } + response->set_status(status); + response->set_value(value); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -9551,9 +9948,8 @@ namespace nidaqmx_grpc { while (true) { auto status = library_->GetPhysicalChanAttributeUInt32Array(physical_channel, attribute, nullptr, 0); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, 0); } uInt32 size = status; @@ -9564,9 +9960,10 @@ namespace nidaqmx_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, 0); } + response->set_status(status); return ::grpc::Status::OK; } } @@ -9607,10 +10004,11 @@ namespace nidaqmx_grpc { auto size = 0U; bool32 value {}; auto status = library_->GetReadAttributeBool(task, attribute, &value, size); - response->set_status(status); - if (status_ok(status)) { - response->set_value(value); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); } + response->set_status(status); + response->set_value(value); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -9650,10 +10048,11 @@ namespace nidaqmx_grpc { auto size = 0U; float64 value {}; auto status = library_->GetReadAttributeDouble(task, attribute, &value, size); - response->set_status(status); - if (status_ok(status)) { - response->set_value(value); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); } + response->set_status(status); + response->set_value(value); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -9693,16 +10092,17 @@ namespace nidaqmx_grpc { auto size = 0U; int32 value {}; auto status = library_->GetReadAttributeInt32(task, attribute, &value, size); - response->set_status(status); - if (status_ok(status)) { - auto checked_convert_value = [](auto raw_value) { - bool raw_value_is_valid = nidaqmx_grpc::ReadInt32AttributeValues_IsValid(raw_value); - auto valid_enum_value = raw_value_is_valid ? raw_value : 0; - return static_cast(valid_enum_value); - }; - response->set_value(checked_convert_value(value)); - response->set_value_raw(value); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); } + response->set_status(status); + auto checked_convert_value = [](auto raw_value) { + bool raw_value_is_valid = nidaqmx_grpc::ReadInt32AttributeValues_IsValid(raw_value); + auto valid_enum_value = raw_value_is_valid ? raw_value : 0; + return static_cast(valid_enum_value); + }; + response->set_value(checked_convert_value(value)); + response->set_value_raw(value); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -9742,9 +10142,8 @@ namespace nidaqmx_grpc { while (true) { auto status = library_->GetReadAttributeString(task, attribute, nullptr, 0); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); } uInt32 size = status; @@ -9757,11 +10156,12 @@ namespace nidaqmx_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_value(value); - nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_value())); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); } + response->set_status(status); + response->set_value(value); + nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_value())); return ::grpc::Status::OK; } } @@ -9802,10 +10202,11 @@ namespace nidaqmx_grpc { auto size = 0U; uInt32 value {}; auto status = library_->GetReadAttributeUInt32(task, attribute, &value, size); - response->set_status(status); - if (status_ok(status)) { - response->set_value(value); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); } + response->set_status(status); + response->set_value(value); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -9845,10 +10246,11 @@ namespace nidaqmx_grpc { auto size = 0U; uInt64 value {}; auto status = library_->GetReadAttributeUInt64(task, attribute, &value, size); - response->set_status(status); - if (status_ok(status)) { - response->set_value(value); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); } + response->set_status(status); + response->set_value(value); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -9888,10 +10290,11 @@ namespace nidaqmx_grpc { auto size = 0U; bool32 value {}; auto status = library_->GetRealTimeAttributeBool(task, attribute, &value, size); - response->set_status(status); - if (status_ok(status)) { - response->set_value(value); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); } + response->set_status(status); + response->set_value(value); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -9931,16 +10334,17 @@ namespace nidaqmx_grpc { auto size = 0U; int32 value {}; auto status = library_->GetRealTimeAttributeInt32(task, attribute, &value, size); - response->set_status(status); - if (status_ok(status)) { - auto checked_convert_value = [](auto raw_value) { - bool raw_value_is_valid = nidaqmx_grpc::RealTimeInt32AttributeValues_IsValid(raw_value); - auto valid_enum_value = raw_value_is_valid ? raw_value : 0; - return static_cast(valid_enum_value); - }; - response->set_value(checked_convert_value(value)); - response->set_value_raw(value); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); } + response->set_status(status); + auto checked_convert_value = [](auto raw_value) { + bool raw_value_is_valid = nidaqmx_grpc::RealTimeInt32AttributeValues_IsValid(raw_value); + auto valid_enum_value = raw_value_is_valid ? raw_value : 0; + return static_cast(valid_enum_value); + }; + response->set_value(checked_convert_value(value)); + response->set_value_raw(value); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -9980,10 +10384,11 @@ namespace nidaqmx_grpc { auto size = 0U; uInt32 value {}; auto status = library_->GetRealTimeAttributeUInt32(task, attribute, &value, size); - response->set_status(status); - if (status_ok(status)) { - response->set_value(value); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); } + response->set_status(status); + response->set_value(value); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -10003,10 +10408,11 @@ namespace nidaqmx_grpc { TaskHandle task = session_repository_->access_session(task_grpc_session.id(), task_grpc_session.name()); CVIAbsoluteTime data {}; auto status = library_->GetRefTrigTimestampVal(task, &data); - response->set_status(status); - if (status_ok(status)) { - convert_to_grpc(data, response->mutable_data()); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); } + response->set_status(status); + convert_to_grpc(data, response->mutable_data()); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -10045,10 +10451,11 @@ namespace nidaqmx_grpc { auto size = 0U; float64 value {}; auto status = library_->GetScaleAttributeDouble(scale_name, attribute, &value, size); - response->set_status(status); - if (status_ok(status)) { - response->set_value(value); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, 0); } + response->set_status(status); + response->set_value(value); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -10087,9 +10494,8 @@ namespace nidaqmx_grpc { while (true) { auto status = library_->GetScaleAttributeDoubleArray(scale_name, attribute, nullptr, 0); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, 0); } uInt32 size = status; @@ -10100,9 +10506,10 @@ namespace nidaqmx_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, 0); } + response->set_status(status); return ::grpc::Status::OK; } } @@ -10142,16 +10549,17 @@ namespace nidaqmx_grpc { auto size = 0U; int32 value {}; auto status = library_->GetScaleAttributeInt32(scale_name, attribute, &value, size); - response->set_status(status); - if (status_ok(status)) { - auto checked_convert_value = [](auto raw_value) { - bool raw_value_is_valid = nidaqmx_grpc::ScaleInt32AttributeValues_IsValid(raw_value); - auto valid_enum_value = raw_value_is_valid ? raw_value : 0; - return static_cast(valid_enum_value); - }; - response->set_value(checked_convert_value(value)); - response->set_value_raw(value); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, 0); } + response->set_status(status); + auto checked_convert_value = [](auto raw_value) { + bool raw_value_is_valid = nidaqmx_grpc::ScaleInt32AttributeValues_IsValid(raw_value); + auto valid_enum_value = raw_value_is_valid ? raw_value : 0; + return static_cast(valid_enum_value); + }; + response->set_value(checked_convert_value(value)); + response->set_value_raw(value); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -10190,9 +10598,8 @@ namespace nidaqmx_grpc { while (true) { auto status = library_->GetScaleAttributeString(scale_name, attribute, nullptr, 0); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, 0); } uInt32 size = status; @@ -10205,11 +10612,12 @@ namespace nidaqmx_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_value(value); - nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_value())); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, 0); } + response->set_status(status); + response->set_value(value); + nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_value())); return ::grpc::Status::OK; } } @@ -10233,14 +10641,15 @@ namespace nidaqmx_grpc { uInt32 hour {}; uInt32 minute {}; auto status = library_->GetSelfCalLastDateAndTime(device_name, &year, &month, &day, &hour, &minute); - response->set_status(status); - if (status_ok(status)) { - response->set_year(year); - response->set_month(month); - response->set_day(day); - response->set_hour(hour); - response->set_minute(minute); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, 0); } + response->set_status(status); + response->set_year(year); + response->set_month(month); + response->set_day(day); + response->set_hour(hour); + response->set_minute(minute); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -10260,10 +10669,11 @@ namespace nidaqmx_grpc { TaskHandle task = session_repository_->access_session(task_grpc_session.id(), task_grpc_session.name()); CVIAbsoluteTime data {}; auto status = library_->GetStartTrigTimestampVal(task, &data); - response->set_status(status); - if (status_ok(status)) { - convert_to_grpc(data, response->mutable_data()); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); } + response->set_status(status); + convert_to_grpc(data, response->mutable_data()); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -10283,10 +10693,11 @@ namespace nidaqmx_grpc { TaskHandle task = session_repository_->access_session(task_grpc_session.id(), task_grpc_session.name()); CVIAbsoluteTime data {}; auto status = library_->GetStartTrigTrigWhen(task, &data); - response->set_status(status); - if (status_ok(status)) { - convert_to_grpc(data, response->mutable_data()); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); } + response->set_status(status); + convert_to_grpc(data, response->mutable_data()); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -10306,10 +10717,11 @@ namespace nidaqmx_grpc { TaskHandle task = session_repository_->access_session(task_grpc_session.id(), task_grpc_session.name()); CVIAbsoluteTime data {}; auto status = library_->GetSyncPulseTimeWhen(task, &data); - response->set_status(status); - if (status_ok(status)) { - convert_to_grpc(data, response->mutable_data()); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); } + response->set_status(status); + convert_to_grpc(data, response->mutable_data()); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -10347,9 +10759,8 @@ namespace nidaqmx_grpc { while (true) { auto status = library_->GetSystemInfoAttributeString(attribute, nullptr, 0); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, 0); } uInt32 size = status; @@ -10362,11 +10773,12 @@ namespace nidaqmx_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_value(value); - nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_value())); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, 0); } + response->set_status(status); + response->set_value(value); + nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_value())); return ::grpc::Status::OK; } } @@ -10405,10 +10817,11 @@ namespace nidaqmx_grpc { auto size = 0U; uInt32 value {}; auto status = library_->GetSystemInfoAttributeUInt32(attribute, &value, size); - response->set_status(status); - if (status_ok(status)) { - response->set_value(value); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, 0); } + response->set_status(status); + response->set_value(value); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -10448,10 +10861,11 @@ namespace nidaqmx_grpc { auto size = 0U; bool32 value {}; auto status = library_->GetTaskAttributeBool(task, attribute, &value, size); - response->set_status(status); - if (status_ok(status)) { - response->set_value(value); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); } + response->set_status(status); + response->set_value(value); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -10491,9 +10905,8 @@ namespace nidaqmx_grpc { while (true) { auto status = library_->GetTaskAttributeString(task, attribute, nullptr, 0); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); } uInt32 size = status; @@ -10506,11 +10919,12 @@ namespace nidaqmx_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_value(value); - nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_value())); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); } + response->set_status(status); + response->set_value(value); + nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_value())); return ::grpc::Status::OK; } } @@ -10551,10 +10965,11 @@ namespace nidaqmx_grpc { auto size = 0U; uInt32 value {}; auto status = library_->GetTaskAttributeUInt32(task, attribute, &value, size); - response->set_status(status); - if (status_ok(status)) { - response->set_value(value); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); } + response->set_status(status); + response->set_value(value); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -10594,10 +11009,11 @@ namespace nidaqmx_grpc { auto size = 0U; bool32 value {}; auto status = library_->GetTimingAttributeBool(task, attribute, &value, size); - response->set_status(status); - if (status_ok(status)) { - response->set_value(value); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); } + response->set_status(status); + response->set_value(value); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -10637,10 +11053,11 @@ namespace nidaqmx_grpc { auto size = 0U; float64 value {}; auto status = library_->GetTimingAttributeDouble(task, attribute, &value, size); - response->set_status(status); - if (status_ok(status)) { - response->set_value(value); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); } + response->set_status(status); + response->set_value(value); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -10681,10 +11098,11 @@ namespace nidaqmx_grpc { auto size = 0U; bool32 value {}; auto status = library_->GetTimingAttributeExBool(task, device_names, attribute, &value, size); - response->set_status(status); - if (status_ok(status)) { - response->set_value(value); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); } + response->set_status(status); + response->set_value(value); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -10725,10 +11143,11 @@ namespace nidaqmx_grpc { auto size = 0U; float64 value {}; auto status = library_->GetTimingAttributeExDouble(task, device_names, attribute, &value, size); - response->set_status(status); - if (status_ok(status)) { - response->set_value(value); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); } + response->set_status(status); + response->set_value(value); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -10769,16 +11188,17 @@ namespace nidaqmx_grpc { auto size = 0U; int32 value {}; auto status = library_->GetTimingAttributeExInt32(task, device_names, attribute, &value, size); - response->set_status(status); - if (status_ok(status)) { - auto checked_convert_value = [](auto raw_value) { - bool raw_value_is_valid = nidaqmx_grpc::TimingInt32AttributeValues_IsValid(raw_value); - auto valid_enum_value = raw_value_is_valid ? raw_value : 0; - return static_cast(valid_enum_value); - }; - response->set_value(checked_convert_value(value)); - response->set_value_raw(value); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); } + response->set_status(status); + auto checked_convert_value = [](auto raw_value) { + bool raw_value_is_valid = nidaqmx_grpc::TimingInt32AttributeValues_IsValid(raw_value); + auto valid_enum_value = raw_value_is_valid ? raw_value : 0; + return static_cast(valid_enum_value); + }; + response->set_value(checked_convert_value(value)); + response->set_value_raw(value); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -10819,9 +11239,8 @@ namespace nidaqmx_grpc { while (true) { auto status = library_->GetTimingAttributeExString(task, device_names, attribute, nullptr, 0); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); } uInt32 size = status; @@ -10834,11 +11253,12 @@ namespace nidaqmx_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_value(value); - nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_value())); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); } + response->set_status(status); + response->set_value(value); + nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_value())); return ::grpc::Status::OK; } } @@ -10880,10 +11300,11 @@ namespace nidaqmx_grpc { auto size = 0U; CVIAbsoluteTime value {}; auto status = library_->GetTimingAttributeExTimestamp(task, device_names, attribute, &value, size); - response->set_status(status); - if (status_ok(status)) { - convert_to_grpc(value, response->mutable_value()); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); } + response->set_status(status); + convert_to_grpc(value, response->mutable_value()); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -10924,10 +11345,11 @@ namespace nidaqmx_grpc { auto size = 0U; uInt32 value {}; auto status = library_->GetTimingAttributeExUInt32(task, device_names, attribute, &value, size); - response->set_status(status); - if (status_ok(status)) { - response->set_value(value); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); } + response->set_status(status); + response->set_value(value); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -10968,10 +11390,11 @@ namespace nidaqmx_grpc { auto size = 0U; uInt64 value {}; auto status = library_->GetTimingAttributeExUInt64(task, device_names, attribute, &value, size); - response->set_status(status); - if (status_ok(status)) { - response->set_value(value); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); } + response->set_status(status); + response->set_value(value); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -11011,16 +11434,17 @@ namespace nidaqmx_grpc { auto size = 0U; int32 value {}; auto status = library_->GetTimingAttributeInt32(task, attribute, &value, size); - response->set_status(status); - if (status_ok(status)) { - auto checked_convert_value = [](auto raw_value) { - bool raw_value_is_valid = nidaqmx_grpc::TimingInt32AttributeValues_IsValid(raw_value); - auto valid_enum_value = raw_value_is_valid ? raw_value : 0; - return static_cast(valid_enum_value); - }; - response->set_value(checked_convert_value(value)); - response->set_value_raw(value); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); } + response->set_status(status); + auto checked_convert_value = [](auto raw_value) { + bool raw_value_is_valid = nidaqmx_grpc::TimingInt32AttributeValues_IsValid(raw_value); + auto valid_enum_value = raw_value_is_valid ? raw_value : 0; + return static_cast(valid_enum_value); + }; + response->set_value(checked_convert_value(value)); + response->set_value_raw(value); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -11060,9 +11484,8 @@ namespace nidaqmx_grpc { while (true) { auto status = library_->GetTimingAttributeString(task, attribute, nullptr, 0); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); } uInt32 size = status; @@ -11075,11 +11498,12 @@ namespace nidaqmx_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_value(value); - nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_value())); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); } + response->set_status(status); + response->set_value(value); + nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_value())); return ::grpc::Status::OK; } } @@ -11120,10 +11544,11 @@ namespace nidaqmx_grpc { auto size = 0U; CVIAbsoluteTime value {}; auto status = library_->GetTimingAttributeTimestamp(task, attribute, &value, size); - response->set_status(status); - if (status_ok(status)) { - convert_to_grpc(value, response->mutable_value()); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); } + response->set_status(status); + convert_to_grpc(value, response->mutable_value()); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -11163,10 +11588,11 @@ namespace nidaqmx_grpc { auto size = 0U; uInt32 value {}; auto status = library_->GetTimingAttributeUInt32(task, attribute, &value, size); - response->set_status(status); - if (status_ok(status)) { - response->set_value(value); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); } + response->set_status(status); + response->set_value(value); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -11206,10 +11632,11 @@ namespace nidaqmx_grpc { auto size = 0U; uInt64 value {}; auto status = library_->GetTimingAttributeUInt64(task, attribute, &value, size); - response->set_status(status); - if (status_ok(status)) { - response->set_value(value); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); } + response->set_status(status); + response->set_value(value); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -11249,10 +11676,11 @@ namespace nidaqmx_grpc { auto size = 0U; bool32 value {}; auto status = library_->GetTrigAttributeBool(task, attribute, &value, size); - response->set_status(status); - if (status_ok(status)) { - response->set_value(value); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); } + response->set_status(status); + response->set_value(value); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -11292,10 +11720,11 @@ namespace nidaqmx_grpc { auto size = 0U; float64 value {}; auto status = library_->GetTrigAttributeDouble(task, attribute, &value, size); - response->set_status(status); - if (status_ok(status)) { - response->set_value(value); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); } + response->set_status(status); + response->set_value(value); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -11335,9 +11764,8 @@ namespace nidaqmx_grpc { while (true) { auto status = library_->GetTrigAttributeDoubleArray(task, attribute, nullptr, 0); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); } uInt32 size = status; @@ -11348,9 +11776,10 @@ namespace nidaqmx_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); } + response->set_status(status); return ::grpc::Status::OK; } } @@ -11391,16 +11820,17 @@ namespace nidaqmx_grpc { auto size = 0U; int32 value {}; auto status = library_->GetTrigAttributeInt32(task, attribute, &value, size); - response->set_status(status); - if (status_ok(status)) { - auto checked_convert_value = [](auto raw_value) { - bool raw_value_is_valid = nidaqmx_grpc::TriggerInt32AttributeValues_IsValid(raw_value); - auto valid_enum_value = raw_value_is_valid ? raw_value : 0; - return static_cast(valid_enum_value); - }; - response->set_value(checked_convert_value(value)); - response->set_value_raw(value); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); } + response->set_status(status); + auto checked_convert_value = [](auto raw_value) { + bool raw_value_is_valid = nidaqmx_grpc::TriggerInt32AttributeValues_IsValid(raw_value); + auto valid_enum_value = raw_value_is_valid ? raw_value : 0; + return static_cast(valid_enum_value); + }; + response->set_value(checked_convert_value(value)); + response->set_value_raw(value); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -11440,9 +11870,8 @@ namespace nidaqmx_grpc { while (true) { auto status = library_->GetTrigAttributeInt32Array(task, attribute, nullptr, 0); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); } uInt32 size = status; @@ -11453,13 +11882,15 @@ namespace nidaqmx_grpc { // buffer is now too small, try again continue; } + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); + } response->set_status(status); - if (status_ok(status)) { - auto checked_convert_value = [](auto raw_value) { - bool raw_value_is_valid = nidaqmx_grpc::TriggerInt32AttributeValues_IsValid(raw_value); - auto valid_enum_value = raw_value_is_valid ? raw_value : 0; - return static_cast(valid_enum_value); - }; + auto checked_convert_value = [](auto raw_value) { + bool raw_value_is_valid = nidaqmx_grpc::TriggerInt32AttributeValues_IsValid(raw_value); + auto valid_enum_value = raw_value_is_valid ? raw_value : 0; + return static_cast(valid_enum_value); + }; response->mutable_value()->Clear(); response->mutable_value()->Reserve(size); std::transform( @@ -11469,7 +11900,6 @@ namespace nidaqmx_grpc { [&](auto x) { return checked_convert_value(x); }); - } return ::grpc::Status::OK; } } @@ -11510,9 +11940,8 @@ namespace nidaqmx_grpc { while (true) { auto status = library_->GetTrigAttributeString(task, attribute, nullptr, 0); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); } uInt32 size = status; @@ -11525,11 +11954,12 @@ namespace nidaqmx_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_value(value); - nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_value())); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); } + response->set_status(status); + response->set_value(value); + nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_value())); return ::grpc::Status::OK; } } @@ -11570,10 +12000,11 @@ namespace nidaqmx_grpc { auto size = 0U; CVIAbsoluteTime value {}; auto status = library_->GetTrigAttributeTimestamp(task, attribute, &value, size); - response->set_status(status); - if (status_ok(status)) { - convert_to_grpc(value, response->mutable_value()); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); } + response->set_status(status); + convert_to_grpc(value, response->mutable_value()); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -11613,10 +12044,11 @@ namespace nidaqmx_grpc { auto size = 0U; uInt32 value {}; auto status = library_->GetTrigAttributeUInt32(task, attribute, &value, size); - response->set_status(status); - if (status_ok(status)) { - response->set_value(value); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); } + response->set_status(status); + response->set_value(value); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -11657,10 +12089,11 @@ namespace nidaqmx_grpc { auto size = 0U; bool32 value {}; auto status = library_->GetWatchdogAttributeBool(task, lines, attribute, &value, size); - response->set_status(status); - if (status_ok(status)) { - response->set_value(value); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); } + response->set_status(status); + response->set_value(value); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -11701,10 +12134,11 @@ namespace nidaqmx_grpc { auto size = 0U; float64 value {}; auto status = library_->GetWatchdogAttributeDouble(task, lines, attribute, &value, size); - response->set_status(status); - if (status_ok(status)) { - response->set_value(value); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); } + response->set_status(status); + response->set_value(value); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -11745,16 +12179,17 @@ namespace nidaqmx_grpc { auto size = 0U; int32 value {}; auto status = library_->GetWatchdogAttributeInt32(task, lines, attribute, &value, size); - response->set_status(status); - if (status_ok(status)) { - auto checked_convert_value = [](auto raw_value) { - bool raw_value_is_valid = nidaqmx_grpc::WatchdogInt32AttributeValues_IsValid(raw_value); - auto valid_enum_value = raw_value_is_valid ? raw_value : 0; - return static_cast(valid_enum_value); - }; - response->set_value(checked_convert_value(value)); - response->set_value_raw(value); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); } + response->set_status(status); + auto checked_convert_value = [](auto raw_value) { + bool raw_value_is_valid = nidaqmx_grpc::WatchdogInt32AttributeValues_IsValid(raw_value); + auto valid_enum_value = raw_value_is_valid ? raw_value : 0; + return static_cast(valid_enum_value); + }; + response->set_value(checked_convert_value(value)); + response->set_value_raw(value); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -11795,9 +12230,8 @@ namespace nidaqmx_grpc { while (true) { auto status = library_->GetWatchdogAttributeString(task, lines, attribute, nullptr, 0); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); } uInt32 size = status; @@ -11810,11 +12244,12 @@ namespace nidaqmx_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_value(value); - nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_value())); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); } + response->set_status(status); + response->set_value(value); + nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_value())); return ::grpc::Status::OK; } } @@ -11855,10 +12290,11 @@ namespace nidaqmx_grpc { auto size = 0U; bool32 value {}; auto status = library_->GetWriteAttributeBool(task, attribute, &value, size); - response->set_status(status); - if (status_ok(status)) { - response->set_value(value); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); } + response->set_status(status); + response->set_value(value); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -11898,10 +12334,11 @@ namespace nidaqmx_grpc { auto size = 0U; float64 value {}; auto status = library_->GetWriteAttributeDouble(task, attribute, &value, size); - response->set_status(status); - if (status_ok(status)) { - response->set_value(value); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); } + response->set_status(status); + response->set_value(value); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -11941,16 +12378,17 @@ namespace nidaqmx_grpc { auto size = 0U; int32 value {}; auto status = library_->GetWriteAttributeInt32(task, attribute, &value, size); - response->set_status(status); - if (status_ok(status)) { - auto checked_convert_value = [](auto raw_value) { - bool raw_value_is_valid = nidaqmx_grpc::WriteInt32AttributeValues_IsValid(raw_value); - auto valid_enum_value = raw_value_is_valid ? raw_value : 0; - return static_cast(valid_enum_value); - }; - response->set_value(checked_convert_value(value)); - response->set_value_raw(value); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); } + response->set_status(status); + auto checked_convert_value = [](auto raw_value) { + bool raw_value_is_valid = nidaqmx_grpc::WriteInt32AttributeValues_IsValid(raw_value); + auto valid_enum_value = raw_value_is_valid ? raw_value : 0; + return static_cast(valid_enum_value); + }; + response->set_value(checked_convert_value(value)); + response->set_value_raw(value); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -11990,9 +12428,8 @@ namespace nidaqmx_grpc { while (true) { auto status = library_->GetWriteAttributeString(task, attribute, nullptr, 0); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); } uInt32 size = status; @@ -12005,11 +12442,12 @@ namespace nidaqmx_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_value(value); - nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_value())); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); } + response->set_status(status); + response->set_value(value); + nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_value())); return ::grpc::Status::OK; } } @@ -12050,10 +12488,11 @@ namespace nidaqmx_grpc { auto size = 0U; uInt32 value {}; auto status = library_->GetWriteAttributeUInt32(task, attribute, &value, size); - response->set_status(status); - if (status_ok(status)) { - response->set_value(value); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); } + response->set_status(status); + response->set_value(value); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -12093,10 +12532,11 @@ namespace nidaqmx_grpc { auto size = 0U; uInt64 value {}; auto status = library_->GetWriteAttributeUInt64(task, attribute, &value, size); - response->set_status(status); - if (status_ok(status)) { - response->set_value(value); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); } + response->set_status(status); + response->set_value(value); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -12116,10 +12556,11 @@ namespace nidaqmx_grpc { TaskHandle task = session_repository_->access_session(task_grpc_session.id(), task_grpc_session.name()); bool32 is_task_done {}; auto status = library_->IsTaskDone(task, &is_task_done); - response->set_status(status); - if (status_ok(status)) { - response->set_is_task_done(is_task_done); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); } + response->set_status(status); + response->set_is_task_done(is_task_done); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -12146,10 +12587,11 @@ namespace nidaqmx_grpc { const std::string& grpc_device_session_name = request->session_name(); auto cleanup_lambda = [&] (TaskHandle id) { library_->ClearTask(id); }; int status = session_repository_->add_session(grpc_device_session_name, init_lambda, cleanup_lambda, session_id); - response->set_status(status); - if (status_ok(status)) { - response->mutable_task()->set_id(session_id); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, 0); } + response->set_status(status); + response->mutable_task()->set_id(session_id); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -12194,10 +12636,11 @@ namespace nidaqmx_grpc { float64* read_array = response->mutable_read_array()->mutable_data(); int32 samps_per_chan_read {}; auto status = library_->ReadAnalogF64(task, num_samps_per_chan, timeout, fill_mode, read_array, array_size_in_samps, &samps_per_chan_read, reserved); - response->set_status(status); - if (status_ok(status)) { - response->set_samps_per_chan_read(samps_per_chan_read); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); } + response->set_status(status); + response->set_samps_per_chan_read(samps_per_chan_read); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -12219,10 +12662,11 @@ namespace nidaqmx_grpc { auto reserved = nullptr; float64 value {}; auto status = library_->ReadAnalogScalarF64(task, timeout, &value, reserved); - response->set_status(status); - if (status_ok(status)) { - response->set_value(value); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); } + response->set_status(status); + response->set_value(value); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -12263,8 +12707,10 @@ namespace nidaqmx_grpc { std::vector read_array(array_size_in_samps); int32 samps_per_chan_read {}; auto status = library_->ReadBinaryI16(task, num_samps_per_chan, timeout, fill_mode, read_array.data(), array_size_in_samps, &samps_per_chan_read, reserved); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); + } response->set_status(status); - if (status_ok(status)) { response->mutable_read_array()->Clear(); response->mutable_read_array()->Reserve(array_size_in_samps); std::transform( @@ -12274,8 +12720,7 @@ namespace nidaqmx_grpc { [&](auto x) { return x; }); - response->set_samps_per_chan_read(samps_per_chan_read); - } + response->set_samps_per_chan_read(samps_per_chan_read); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -12317,10 +12762,11 @@ namespace nidaqmx_grpc { int32* read_array = reinterpret_cast(response->mutable_read_array()->mutable_data()); int32 samps_per_chan_read {}; auto status = library_->ReadBinaryI32(task, num_samps_per_chan, timeout, fill_mode, read_array, array_size_in_samps, &samps_per_chan_read, reserved); - response->set_status(status); - if (status_ok(status)) { - response->set_samps_per_chan_read(samps_per_chan_read); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); } + response->set_status(status); + response->set_samps_per_chan_read(samps_per_chan_read); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -12361,8 +12807,10 @@ namespace nidaqmx_grpc { std::vector read_array(array_size_in_samps); int32 samps_per_chan_read {}; auto status = library_->ReadBinaryU16(task, num_samps_per_chan, timeout, fill_mode, read_array.data(), array_size_in_samps, &samps_per_chan_read, reserved); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); + } response->set_status(status); - if (status_ok(status)) { response->mutable_read_array()->Clear(); response->mutable_read_array()->Reserve(array_size_in_samps); std::transform( @@ -12372,8 +12820,7 @@ namespace nidaqmx_grpc { [&](auto x) { return x; }); - response->set_samps_per_chan_read(samps_per_chan_read); - } + response->set_samps_per_chan_read(samps_per_chan_read); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -12415,10 +12862,11 @@ namespace nidaqmx_grpc { uInt32* read_array = reinterpret_cast(response->mutable_read_array()->mutable_data()); int32 samps_per_chan_read {}; auto status = library_->ReadBinaryU32(task, num_samps_per_chan, timeout, fill_mode, read_array, array_size_in_samps, &samps_per_chan_read, reserved); - response->set_status(status); - if (status_ok(status)) { - response->set_samps_per_chan_read(samps_per_chan_read); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); } + response->set_status(status); + response->set_samps_per_chan_read(samps_per_chan_read); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -12444,10 +12892,11 @@ namespace nidaqmx_grpc { float64* read_array = response->mutable_read_array()->mutable_data(); int32 samps_per_chan_read {}; auto status = library_->ReadCounterF64(task, num_samps_per_chan, timeout, read_array, array_size_in_samps, &samps_per_chan_read, reserved); - response->set_status(status); - if (status_ok(status)) { - response->set_samps_per_chan_read(samps_per_chan_read); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); } + response->set_status(status); + response->set_samps_per_chan_read(samps_per_chan_read); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -12489,10 +12938,11 @@ namespace nidaqmx_grpc { float64* read_array = response->mutable_read_array()->mutable_data(); int32 samps_per_chan_read {}; auto status = library_->ReadCounterF64Ex(task, num_samps_per_chan, timeout, fill_mode, read_array, array_size_in_samps, &samps_per_chan_read, reserved); - response->set_status(status); - if (status_ok(status)) { - response->set_samps_per_chan_read(samps_per_chan_read); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); } + response->set_status(status); + response->set_samps_per_chan_read(samps_per_chan_read); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -12514,10 +12964,11 @@ namespace nidaqmx_grpc { auto reserved = nullptr; float64 value {}; auto status = library_->ReadCounterScalarF64(task, timeout, &value, reserved); - response->set_status(status); - if (status_ok(status)) { - response->set_value(value); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); } + response->set_status(status); + response->set_value(value); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -12539,10 +12990,11 @@ namespace nidaqmx_grpc { auto reserved = nullptr; uInt32 value {}; auto status = library_->ReadCounterScalarU32(task, timeout, &value, reserved); - response->set_status(status); - if (status_ok(status)) { - response->set_value(value); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); } + response->set_status(status); + response->set_value(value); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -12568,10 +13020,11 @@ namespace nidaqmx_grpc { uInt32* read_array = reinterpret_cast(response->mutable_read_array()->mutable_data()); int32 samps_per_chan_read {}; auto status = library_->ReadCounterU32(task, num_samps_per_chan, timeout, read_array, array_size_in_samps, &samps_per_chan_read, reserved); - response->set_status(status); - if (status_ok(status)) { - response->set_samps_per_chan_read(samps_per_chan_read); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); } + response->set_status(status); + response->set_samps_per_chan_read(samps_per_chan_read); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -12613,10 +13066,11 @@ namespace nidaqmx_grpc { uInt32* read_array = reinterpret_cast(response->mutable_read_array()->mutable_data()); int32 samps_per_chan_read {}; auto status = library_->ReadCounterU32Ex(task, num_samps_per_chan, timeout, fill_mode, read_array, array_size_in_samps, &samps_per_chan_read, reserved); - response->set_status(status); - if (status_ok(status)) { - response->set_samps_per_chan_read(samps_per_chan_read); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); } + response->set_status(status); + response->set_samps_per_chan_read(samps_per_chan_read); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -12660,10 +13114,11 @@ namespace nidaqmx_grpc { float64* read_array_duty_cycle = response->mutable_read_array_duty_cycle()->mutable_data(); int32 samps_per_chan_read {}; auto status = library_->ReadCtrFreq(task, num_samps_per_chan, timeout, interleaved, read_array_frequency, read_array_duty_cycle, array_size_in_samps, &samps_per_chan_read, reserved); - response->set_status(status); - if (status_ok(status)) { - response->set_samps_per_chan_read(samps_per_chan_read); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); } + response->set_status(status); + response->set_samps_per_chan_read(samps_per_chan_read); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -12686,11 +13141,12 @@ namespace nidaqmx_grpc { float64 frequency {}; float64 duty_cycle {}; auto status = library_->ReadCtrFreqScalar(task, timeout, &frequency, &duty_cycle, reserved); - response->set_status(status); - if (status_ok(status)) { - response->set_frequency(frequency); - response->set_duty_cycle(duty_cycle); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); } + response->set_status(status); + response->set_frequency(frequency); + response->set_duty_cycle(duty_cycle); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -12734,10 +13190,11 @@ namespace nidaqmx_grpc { uInt32* read_array_low_ticks = reinterpret_cast(response->mutable_read_array_low_ticks()->mutable_data()); int32 samps_per_chan_read {}; auto status = library_->ReadCtrTicks(task, num_samps_per_chan, timeout, interleaved, read_array_high_ticks, read_array_low_ticks, array_size_in_samps, &samps_per_chan_read, reserved); - response->set_status(status); - if (status_ok(status)) { - response->set_samps_per_chan_read(samps_per_chan_read); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); } + response->set_status(status); + response->set_samps_per_chan_read(samps_per_chan_read); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -12760,11 +13217,12 @@ namespace nidaqmx_grpc { uInt32 high_ticks {}; uInt32 low_ticks {}; auto status = library_->ReadCtrTicksScalar(task, timeout, &high_ticks, &low_ticks, reserved); - response->set_status(status); - if (status_ok(status)) { - response->set_high_ticks(high_ticks); - response->set_low_ticks(low_ticks); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); } + response->set_status(status); + response->set_high_ticks(high_ticks); + response->set_low_ticks(low_ticks); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -12808,10 +13266,11 @@ namespace nidaqmx_grpc { float64* read_array_low_time = response->mutable_read_array_low_time()->mutable_data(); int32 samps_per_chan_read {}; auto status = library_->ReadCtrTime(task, num_samps_per_chan, timeout, interleaved, read_array_high_time, read_array_low_time, array_size_in_samps, &samps_per_chan_read, reserved); - response->set_status(status); - if (status_ok(status)) { - response->set_samps_per_chan_read(samps_per_chan_read); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); } + response->set_status(status); + response->set_samps_per_chan_read(samps_per_chan_read); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -12834,11 +13293,12 @@ namespace nidaqmx_grpc { float64 high_time {}; float64 low_time {}; auto status = library_->ReadCtrTimeScalar(task, timeout, &high_time, &low_time, reserved); - response->set_status(status); - if (status_ok(status)) { - response->set_high_time(high_time); - response->set_low_time(low_time); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); } + response->set_status(status); + response->set_high_time(high_time); + response->set_low_time(low_time); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -12880,12 +13340,13 @@ namespace nidaqmx_grpc { int32 samps_per_chan_read {}; int32 num_bytes_per_samp {}; auto status = library_->ReadDigitalLines(task, num_samps_per_chan, timeout, fill_mode, (uInt8*)read_array.data(), array_size_in_bytes, &samps_per_chan_read, &num_bytes_per_samp, reserved); - response->set_status(status); - if (status_ok(status)) { - response->set_read_array(read_array); - response->set_samps_per_chan_read(samps_per_chan_read); - response->set_num_bytes_per_samp(num_bytes_per_samp); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); } + response->set_status(status); + response->set_read_array(read_array); + response->set_samps_per_chan_read(samps_per_chan_read); + response->set_num_bytes_per_samp(num_bytes_per_samp); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -12907,10 +13368,11 @@ namespace nidaqmx_grpc { auto reserved = nullptr; uInt32 value {}; auto status = library_->ReadDigitalScalarU32(task, timeout, &value, reserved); - response->set_status(status); - if (status_ok(status)) { - response->set_value(value); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); } + response->set_status(status); + response->set_value(value); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -12951,8 +13413,10 @@ namespace nidaqmx_grpc { std::vector read_array(array_size_in_samps); int32 samps_per_chan_read {}; auto status = library_->ReadDigitalU16(task, num_samps_per_chan, timeout, fill_mode, read_array.data(), array_size_in_samps, &samps_per_chan_read, reserved); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); + } response->set_status(status); - if (status_ok(status)) { response->mutable_read_array()->Clear(); response->mutable_read_array()->Reserve(array_size_in_samps); std::transform( @@ -12962,8 +13426,7 @@ namespace nidaqmx_grpc { [&](auto x) { return x; }); - response->set_samps_per_chan_read(samps_per_chan_read); - } + response->set_samps_per_chan_read(samps_per_chan_read); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -13005,10 +13468,11 @@ namespace nidaqmx_grpc { uInt32* read_array = reinterpret_cast(response->mutable_read_array()->mutable_data()); int32 samps_per_chan_read {}; auto status = library_->ReadDigitalU32(task, num_samps_per_chan, timeout, fill_mode, read_array, array_size_in_samps, &samps_per_chan_read, reserved); - response->set_status(status); - if (status_ok(status)) { - response->set_samps_per_chan_read(samps_per_chan_read); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); } + response->set_status(status); + response->set_samps_per_chan_read(samps_per_chan_read); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -13049,11 +13513,12 @@ namespace nidaqmx_grpc { std::string read_array(array_size_in_samps, '\0'); int32 samps_per_chan_read {}; auto status = library_->ReadDigitalU8(task, num_samps_per_chan, timeout, fill_mode, (uInt8*)read_array.data(), array_size_in_samps, &samps_per_chan_read, reserved); - response->set_status(status); - if (status_ok(status)) { - response->set_read_array(read_array); - response->set_samps_per_chan_read(samps_per_chan_read); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); } + response->set_status(status); + response->set_read_array(read_array); + response->set_samps_per_chan_read(samps_per_chan_read); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -13079,12 +13544,13 @@ namespace nidaqmx_grpc { int32 samps_read {}; int32 num_bytes_per_samp {}; auto status = library_->ReadRaw(task, num_samps_per_chan, timeout, (uInt8*)read_array.data(), array_size_in_bytes, &samps_read, &num_bytes_per_samp, reserved); - response->set_status(status); - if (status_ok(status)) { - response->set_read_array(read_array); - response->set_samps_read(samps_read); - response->set_num_bytes_per_samp(num_bytes_per_samp); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); } + response->set_status(status); + response->set_read_array(read_array); + response->set_samps_read(samps_read); + response->set_num_bytes_per_samp(num_bytes_per_samp); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -13115,7 +13581,7 @@ namespace nidaqmx_grpc { [this](TaskHandle task, int32 status) { RegisterDoneEventResponse callback_response; auto response = &callback_response; - response->set_status(status); + response->set_status(status); queue_write(callback_response); return 0; }); @@ -13171,9 +13637,9 @@ namespace nidaqmx_grpc { [this](TaskHandle task, int32 every_n_samples_event_type, uInt32 n_samples) { RegisterEveryNSamplesEventResponse callback_response; auto response = &callback_response; - response->set_every_n_samples_event_type(static_cast(every_n_samples_event_type)); - response->set_every_n_samples_event_type_raw(every_n_samples_event_type); - response->set_n_samples(n_samples); + response->set_every_n_samples_event_type(static_cast(every_n_samples_event_type)); + response->set_every_n_samples_event_type_raw(every_n_samples_event_type); + response->set_n_samples(n_samples); queue_write(callback_response); return 0; }); @@ -13246,7 +13712,7 @@ namespace nidaqmx_grpc { [this](TaskHandle task, int32 signal_id) { RegisterSignalEventResponse callback_response; auto response = &callback_response; - response->set_signal_id(signal_id); + response->set_signal_id(signal_id); queue_write(callback_response); return 0; }); @@ -13305,6 +13771,9 @@ namespace nidaqmx_grpc { try { auto port_list = request->port_list().c_str(); auto status = library_->RemoveCDAQSyncConnection(port_list); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, 0); + } response->set_status(status); return ::grpc::Status::OK; } @@ -13324,6 +13793,9 @@ namespace nidaqmx_grpc { auto device_name = request->device_name().c_str(); bool32 override_reservation = request->override_reservation(); auto status = library_->ReserveNetworkDevice(device_name, override_reservation); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, 0); + } response->set_status(status); return ::grpc::Status::OK; } @@ -13362,6 +13834,9 @@ namespace nidaqmx_grpc { } auto status = library_->ResetBufferAttribute(task, attribute); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); + } response->set_status(status); return ::grpc::Status::OK; } @@ -13401,6 +13876,9 @@ namespace nidaqmx_grpc { } auto status = library_->ResetChanAttribute(task, channel, attribute); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); + } response->set_status(status); return ::grpc::Status::OK; } @@ -13419,6 +13897,9 @@ namespace nidaqmx_grpc { try { auto device_name = request->device_name().c_str(); auto status = library_->ResetDevice(device_name); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, 0); + } response->set_status(status); return ::grpc::Status::OK; } @@ -13457,6 +13938,9 @@ namespace nidaqmx_grpc { } auto status = library_->ResetExportedSignalAttribute(task, attribute); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); + } response->set_status(status); return ::grpc::Status::OK; } @@ -13495,6 +13979,9 @@ namespace nidaqmx_grpc { } auto status = library_->ResetReadAttribute(task, attribute); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); + } response->set_status(status); return ::grpc::Status::OK; } @@ -13533,6 +14020,9 @@ namespace nidaqmx_grpc { } auto status = library_->ResetRealTimeAttribute(task, attribute); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); + } response->set_status(status); return ::grpc::Status::OK; } @@ -13571,6 +14061,9 @@ namespace nidaqmx_grpc { } auto status = library_->ResetTimingAttribute(task, attribute); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); + } response->set_status(status); return ::grpc::Status::OK; } @@ -13610,6 +14103,9 @@ namespace nidaqmx_grpc { } auto status = library_->ResetTimingAttributeEx(task, device_names, attribute); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); + } response->set_status(status); return ::grpc::Status::OK; } @@ -13648,6 +14144,9 @@ namespace nidaqmx_grpc { } auto status = library_->ResetTrigAttribute(task, attribute); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); + } response->set_status(status); return ::grpc::Status::OK; } @@ -13687,6 +14186,9 @@ namespace nidaqmx_grpc { } auto status = library_->ResetWatchdogAttribute(task, lines, attribute); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); + } response->set_status(status); return ::grpc::Status::OK; } @@ -13725,6 +14227,9 @@ namespace nidaqmx_grpc { } auto status = library_->ResetWriteAttribute(task, attribute); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); + } response->set_status(status); return ::grpc::Status::OK; } @@ -13763,6 +14268,9 @@ namespace nidaqmx_grpc { } auto status = library_->SaveGlobalChan(task, channel_name, save_as, author, options); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); + } response->set_status(status); return ::grpc::Status::OK; } @@ -13799,6 +14307,9 @@ namespace nidaqmx_grpc { } auto status = library_->SaveScale(scale_name, save_as, author, options); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, 0); + } response->set_status(status); return ::grpc::Status::OK; } @@ -13836,6 +14347,9 @@ namespace nidaqmx_grpc { } auto status = library_->SaveTask(task, save_as, author, options); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); + } response->set_status(status); return ::grpc::Status::OK; } @@ -13854,6 +14368,9 @@ namespace nidaqmx_grpc { try { auto device_name = request->device_name().c_str(); auto status = library_->SelfCal(device_name); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, 0); + } response->set_status(status); return ::grpc::Status::OK; } @@ -13872,6 +14389,9 @@ namespace nidaqmx_grpc { try { auto device_name = request->device_name().c_str(); auto status = library_->SelfTestDevice(device_name); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, 0); + } response->set_status(status); return ::grpc::Status::OK; } @@ -13897,6 +14417,9 @@ namespace nidaqmx_grpc { uInt32 hour = request->hour(); uInt32 minute = request->minute(); auto status = library_->SetAIChanCalCalDate(task, channel_name, year, month, day, hour, minute); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); + } response->set_status(status); return ::grpc::Status::OK; } @@ -13922,6 +14445,9 @@ namespace nidaqmx_grpc { uInt32 hour = request->hour(); uInt32 minute = request->minute(); auto status = library_->SetAIChanCalExpDate(task, channel_name, year, month, day, hour, minute); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); + } response->set_status(status); return ::grpc::Status::OK; } @@ -13966,6 +14492,9 @@ namespace nidaqmx_grpc { } auto status = ((NiDAQmxLibrary*)library_)->SetAnalogPowerUpStates(device_name, get_channelNames_if(power_up_states, 0), get_state_if(power_up_states, 0), get_channelType_if(power_up_states, 0), get_channelNames_if(power_up_states, 1), get_state_if(power_up_states, 1), get_channelType_if(power_up_states, 1), get_channelNames_if(power_up_states, 2), get_state_if(power_up_states, 2), get_channelType_if(power_up_states, 2), get_channelNames_if(power_up_states, 3), get_state_if(power_up_states, 3), get_channelType_if(power_up_states, 3), get_channelNames_if(power_up_states, 4), get_state_if(power_up_states, 4), get_channelType_if(power_up_states, 4), get_channelNames_if(power_up_states, 5), get_state_if(power_up_states, 5), get_channelType_if(power_up_states, 5), get_channelNames_if(power_up_states, 6), get_state_if(power_up_states, 6), get_channelType_if(power_up_states, 6), get_channelNames_if(power_up_states, 7), get_state_if(power_up_states, 7), get_channelType_if(power_up_states, 7), get_channelNames_if(power_up_states, 8), get_state_if(power_up_states, 8), get_channelType_if(power_up_states, 8), get_channelNames_if(power_up_states, 9), get_state_if(power_up_states, 9), get_channelType_if(power_up_states, 9), get_channelNames_if(power_up_states, 10), get_state_if(power_up_states, 10), get_channelType_if(power_up_states, 10), get_channelNames_if(power_up_states, 11), get_state_if(power_up_states, 11), get_channelType_if(power_up_states, 11), get_channelNames_if(power_up_states, 12), get_state_if(power_up_states, 12), get_channelType_if(power_up_states, 12), get_channelNames_if(power_up_states, 13), get_state_if(power_up_states, 13), get_channelType_if(power_up_states, 13), get_channelNames_if(power_up_states, 14), get_state_if(power_up_states, 14), get_channelType_if(power_up_states, 14), get_channelNames_if(power_up_states, 15), get_state_if(power_up_states, 15), get_channelType_if(power_up_states, 15), get_channelNames_if(power_up_states, 16), get_state_if(power_up_states, 16), get_channelType_if(power_up_states, 16), get_channelNames_if(power_up_states, 17), get_state_if(power_up_states, 17), get_channelType_if(power_up_states, 17), get_channelNames_if(power_up_states, 18), get_state_if(power_up_states, 18), get_channelType_if(power_up_states, 18), get_channelNames_if(power_up_states, 19), get_state_if(power_up_states, 19), get_channelType_if(power_up_states, 19), get_channelNames_if(power_up_states, 20), get_state_if(power_up_states, 20), get_channelType_if(power_up_states, 20), get_channelNames_if(power_up_states, 21), get_state_if(power_up_states, 21), get_channelType_if(power_up_states, 21), get_channelNames_if(power_up_states, 22), get_state_if(power_up_states, 22), get_channelType_if(power_up_states, 22), get_channelNames_if(power_up_states, 23), get_state_if(power_up_states, 23), get_channelType_if(power_up_states, 23), get_channelNames_if(power_up_states, 24), get_state_if(power_up_states, 24), get_channelType_if(power_up_states, 24), get_channelNames_if(power_up_states, 25), get_state_if(power_up_states, 25), get_channelType_if(power_up_states, 25), get_channelNames_if(power_up_states, 26), get_state_if(power_up_states, 26), get_channelType_if(power_up_states, 26), get_channelNames_if(power_up_states, 27), get_state_if(power_up_states, 27), get_channelType_if(power_up_states, 27), get_channelNames_if(power_up_states, 28), get_state_if(power_up_states, 28), get_channelType_if(power_up_states, 28), get_channelNames_if(power_up_states, 29), get_state_if(power_up_states, 29), get_channelType_if(power_up_states, 29), get_channelNames_if(power_up_states, 30), get_state_if(power_up_states, 30), get_channelType_if(power_up_states, 30), get_channelNames_if(power_up_states, 31), get_state_if(power_up_states, 31), get_channelType_if(power_up_states, 31), get_channelNames_if(power_up_states, 32), get_state_if(power_up_states, 32), get_channelType_if(power_up_states, 32), get_channelNames_if(power_up_states, 33), get_state_if(power_up_states, 33), get_channelType_if(power_up_states, 33), get_channelNames_if(power_up_states, 34), get_state_if(power_up_states, 34), get_channelType_if(power_up_states, 34), get_channelNames_if(power_up_states, 35), get_state_if(power_up_states, 35), get_channelType_if(power_up_states, 35), get_channelNames_if(power_up_states, 36), get_state_if(power_up_states, 36), get_channelType_if(power_up_states, 36), get_channelNames_if(power_up_states, 37), get_state_if(power_up_states, 37), get_channelType_if(power_up_states, 37), get_channelNames_if(power_up_states, 38), get_state_if(power_up_states, 38), get_channelType_if(power_up_states, 38), get_channelNames_if(power_up_states, 39), get_state_if(power_up_states, 39), get_channelType_if(power_up_states, 39), get_channelNames_if(power_up_states, 40), get_state_if(power_up_states, 40), get_channelType_if(power_up_states, 40), get_channelNames_if(power_up_states, 41), get_state_if(power_up_states, 41), get_channelType_if(power_up_states, 41), get_channelNames_if(power_up_states, 42), get_state_if(power_up_states, 42), get_channelType_if(power_up_states, 42), get_channelNames_if(power_up_states, 43), get_state_if(power_up_states, 43), get_channelType_if(power_up_states, 43), get_channelNames_if(power_up_states, 44), get_state_if(power_up_states, 44), get_channelType_if(power_up_states, 44), get_channelNames_if(power_up_states, 45), get_state_if(power_up_states, 45), get_channelType_if(power_up_states, 45), get_channelNames_if(power_up_states, 46), get_state_if(power_up_states, 46), get_channelType_if(power_up_states, 46), get_channelNames_if(power_up_states, 47), get_state_if(power_up_states, 47), get_channelType_if(power_up_states, 47), get_channelNames_if(power_up_states, 48), get_state_if(power_up_states, 48), get_channelType_if(power_up_states, 48), get_channelNames_if(power_up_states, 49), get_state_if(power_up_states, 49), get_channelType_if(power_up_states, 49), get_channelNames_if(power_up_states, 50), get_state_if(power_up_states, 50), get_channelType_if(power_up_states, 50), get_channelNames_if(power_up_states, 51), get_state_if(power_up_states, 51), get_channelType_if(power_up_states, 51), get_channelNames_if(power_up_states, 52), get_state_if(power_up_states, 52), get_channelType_if(power_up_states, 52), get_channelNames_if(power_up_states, 53), get_state_if(power_up_states, 53), get_channelType_if(power_up_states, 53), get_channelNames_if(power_up_states, 54), get_state_if(power_up_states, 54), get_channelType_if(power_up_states, 54), get_channelNames_if(power_up_states, 55), get_state_if(power_up_states, 55), get_channelType_if(power_up_states, 55), get_channelNames_if(power_up_states, 56), get_state_if(power_up_states, 56), get_channelType_if(power_up_states, 56), get_channelNames_if(power_up_states, 57), get_state_if(power_up_states, 57), get_channelType_if(power_up_states, 57), get_channelNames_if(power_up_states, 58), get_state_if(power_up_states, 58), get_channelType_if(power_up_states, 58), get_channelNames_if(power_up_states, 59), get_state_if(power_up_states, 59), get_channelType_if(power_up_states, 59), get_channelNames_if(power_up_states, 60), get_state_if(power_up_states, 60), get_channelType_if(power_up_states, 60), get_channelNames_if(power_up_states, 61), get_state_if(power_up_states, 61), get_channelType_if(power_up_states, 61), get_channelNames_if(power_up_states, 62), get_state_if(power_up_states, 62), get_channelType_if(power_up_states, 62), get_channelNames_if(power_up_states, 63), get_state_if(power_up_states, 63), get_channelType_if(power_up_states, 63), get_channelNames_if(power_up_states, 64), get_state_if(power_up_states, 64), get_channelType_if(power_up_states, 64), get_channelNames_if(power_up_states, 65), get_state_if(power_up_states, 65), get_channelType_if(power_up_states, 65), get_channelNames_if(power_up_states, 66), get_state_if(power_up_states, 66), get_channelType_if(power_up_states, 66), get_channelNames_if(power_up_states, 67), get_state_if(power_up_states, 67), get_channelType_if(power_up_states, 67), get_channelNames_if(power_up_states, 68), get_state_if(power_up_states, 68), get_channelType_if(power_up_states, 68), get_channelNames_if(power_up_states, 69), get_state_if(power_up_states, 69), get_channelType_if(power_up_states, 69), get_channelNames_if(power_up_states, 70), get_state_if(power_up_states, 70), get_channelType_if(power_up_states, 70), get_channelNames_if(power_up_states, 71), get_state_if(power_up_states, 71), get_channelType_if(power_up_states, 71), get_channelNames_if(power_up_states, 72), get_state_if(power_up_states, 72), get_channelType_if(power_up_states, 72), get_channelNames_if(power_up_states, 73), get_state_if(power_up_states, 73), get_channelType_if(power_up_states, 73), get_channelNames_if(power_up_states, 74), get_state_if(power_up_states, 74), get_channelType_if(power_up_states, 74), get_channelNames_if(power_up_states, 75), get_state_if(power_up_states, 75), get_channelType_if(power_up_states, 75), get_channelNames_if(power_up_states, 76), get_state_if(power_up_states, 76), get_channelType_if(power_up_states, 76), get_channelNames_if(power_up_states, 77), get_state_if(power_up_states, 77), get_channelType_if(power_up_states, 77), get_channelNames_if(power_up_states, 78), get_state_if(power_up_states, 78), get_channelType_if(power_up_states, 78), get_channelNames_if(power_up_states, 79), get_state_if(power_up_states, 79), get_channelType_if(power_up_states, 79), get_channelNames_if(power_up_states, 80), get_state_if(power_up_states, 80), get_channelType_if(power_up_states, 80), get_channelNames_if(power_up_states, 81), get_state_if(power_up_states, 81), get_channelType_if(power_up_states, 81), get_channelNames_if(power_up_states, 82), get_state_if(power_up_states, 82), get_channelType_if(power_up_states, 82), get_channelNames_if(power_up_states, 83), get_state_if(power_up_states, 83), get_channelType_if(power_up_states, 83), get_channelNames_if(power_up_states, 84), get_state_if(power_up_states, 84), get_channelType_if(power_up_states, 84), get_channelNames_if(power_up_states, 85), get_state_if(power_up_states, 85), get_channelType_if(power_up_states, 85), get_channelNames_if(power_up_states, 86), get_state_if(power_up_states, 86), get_channelType_if(power_up_states, 86), get_channelNames_if(power_up_states, 87), get_state_if(power_up_states, 87), get_channelType_if(power_up_states, 87), get_channelNames_if(power_up_states, 88), get_state_if(power_up_states, 88), get_channelType_if(power_up_states, 88), get_channelNames_if(power_up_states, 89), get_state_if(power_up_states, 89), get_channelType_if(power_up_states, 89), get_channelNames_if(power_up_states, 90), get_state_if(power_up_states, 90), get_channelType_if(power_up_states, 90), get_channelNames_if(power_up_states, 91), get_state_if(power_up_states, 91), get_channelType_if(power_up_states, 91), get_channelNames_if(power_up_states, 92), get_state_if(power_up_states, 92), get_channelType_if(power_up_states, 92), get_channelNames_if(power_up_states, 93), get_state_if(power_up_states, 93), get_channelType_if(power_up_states, 93), get_channelNames_if(power_up_states, 94), get_state_if(power_up_states, 94), get_channelType_if(power_up_states, 94), get_channelNames_if(power_up_states, 95), get_state_if(power_up_states, 95), get_channelType_if(power_up_states, 95), get_channelNames_if(power_up_states, 96), get_state_if(power_up_states, 96), get_channelType_if(power_up_states, 96)); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, 0); + } response->set_status(status); return ::grpc::Status::OK; } @@ -14006,6 +14535,9 @@ namespace nidaqmx_grpc { auto array_size = array_size_size_calculation.size; auto status = library_->SetAnalogPowerUpStatesWithOutputType(channel_names, state_array, channel_type_array, array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, 0); + } response->set_status(status); return ::grpc::Status::OK; } @@ -14026,6 +14558,9 @@ namespace nidaqmx_grpc { TaskHandle task = session_repository_->access_session(task_grpc_session.id(), task_grpc_session.name()); auto data = convert_from_grpc(request->data()); auto status = library_->SetArmStartTrigTrigWhen(task, data); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); + } response->set_status(status); return ::grpc::Status::OK; } @@ -14065,6 +14600,9 @@ namespace nidaqmx_grpc { uInt32 value = request->value(); auto status = library_->SetBufferAttributeUInt32(task, attribute, value); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); + } response->set_status(status); return ::grpc::Status::OK; } @@ -14104,6 +14642,9 @@ namespace nidaqmx_grpc { bool32 value = request->value(); auto size = 0U; auto status = library_->SetCalInfoAttributeBool(device_name, attribute, value, size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, 0); + } response->set_status(status); return ::grpc::Status::OK; } @@ -14143,6 +14684,9 @@ namespace nidaqmx_grpc { float64 value = request->value(); auto size = 0U; auto status = library_->SetCalInfoAttributeDouble(device_name, attribute, value, size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, 0); + } response->set_status(status); return ::grpc::Status::OK; } @@ -14182,6 +14726,9 @@ namespace nidaqmx_grpc { auto value = request->value().c_str(); auto size = 0U; auto status = library_->SetCalInfoAttributeString(device_name, attribute, value, size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, 0); + } response->set_status(status); return ::grpc::Status::OK; } @@ -14221,6 +14768,9 @@ namespace nidaqmx_grpc { uInt32 value = request->value(); auto size = 0U; auto status = library_->SetCalInfoAttributeUInt32(device_name, attribute, value, size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, 0); + } response->set_status(status); return ::grpc::Status::OK; } @@ -14262,6 +14812,9 @@ namespace nidaqmx_grpc { bool32 value = request->value(); auto size = 0U; auto status = library_->SetChanAttributeBool(task, channel, attribute, value, size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); + } response->set_status(status); return ::grpc::Status::OK; } @@ -14303,6 +14856,9 @@ namespace nidaqmx_grpc { float64 value = request->value(); auto size = 0U; auto status = library_->SetChanAttributeDouble(task, channel, attribute, value, size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); + } response->set_status(status); return ::grpc::Status::OK; } @@ -14344,6 +14900,9 @@ namespace nidaqmx_grpc { auto value = const_cast(request->value().data()); uInt32 size = static_cast(request->value().size()); auto status = library_->SetChanAttributeDoubleArray(task, channel, attribute, value, size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); + } response->set_status(status); return ::grpc::Status::OK; } @@ -14400,6 +14959,9 @@ namespace nidaqmx_grpc { auto size = 0U; auto status = library_->SetChanAttributeInt32(task, channel, attribute, value, size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); + } response->set_status(status); return ::grpc::Status::OK; } @@ -14441,6 +15003,9 @@ namespace nidaqmx_grpc { auto value = request->value().c_str(); auto size = 0U; auto status = library_->SetChanAttributeString(task, channel, attribute, value, size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); + } response->set_status(status); return ::grpc::Status::OK; } @@ -14482,6 +15047,9 @@ namespace nidaqmx_grpc { uInt32 value = request->value(); auto size = 0U; auto status = library_->SetChanAttributeUInt32(task, channel, attribute, value, size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); + } response->set_status(status); return ::grpc::Status::OK; } @@ -14516,6 +15084,9 @@ namespace nidaqmx_grpc { } auto status = library_->SetDigitalLogicFamilyPowerUpState(device_name, logic_family); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, 0); + } response->set_status(status); return ::grpc::Status::OK; } @@ -14554,6 +15125,9 @@ namespace nidaqmx_grpc { } auto status = ((NiDAQmxLibrary*)library_)->SetDigitalPowerUpStates(device_name, get_channelNames_if(power_up_states, 0), get_state_if(power_up_states, 0), get_channelNames_if(power_up_states, 1), get_state_if(power_up_states, 1), get_channelNames_if(power_up_states, 2), get_state_if(power_up_states, 2), get_channelNames_if(power_up_states, 3), get_state_if(power_up_states, 3), get_channelNames_if(power_up_states, 4), get_state_if(power_up_states, 4), get_channelNames_if(power_up_states, 5), get_state_if(power_up_states, 5), get_channelNames_if(power_up_states, 6), get_state_if(power_up_states, 6), get_channelNames_if(power_up_states, 7), get_state_if(power_up_states, 7), get_channelNames_if(power_up_states, 8), get_state_if(power_up_states, 8), get_channelNames_if(power_up_states, 9), get_state_if(power_up_states, 9), get_channelNames_if(power_up_states, 10), get_state_if(power_up_states, 10), get_channelNames_if(power_up_states, 11), get_state_if(power_up_states, 11), get_channelNames_if(power_up_states, 12), get_state_if(power_up_states, 12), get_channelNames_if(power_up_states, 13), get_state_if(power_up_states, 13), get_channelNames_if(power_up_states, 14), get_state_if(power_up_states, 14), get_channelNames_if(power_up_states, 15), get_state_if(power_up_states, 15), get_channelNames_if(power_up_states, 16), get_state_if(power_up_states, 16), get_channelNames_if(power_up_states, 17), get_state_if(power_up_states, 17), get_channelNames_if(power_up_states, 18), get_state_if(power_up_states, 18), get_channelNames_if(power_up_states, 19), get_state_if(power_up_states, 19), get_channelNames_if(power_up_states, 20), get_state_if(power_up_states, 20), get_channelNames_if(power_up_states, 21), get_state_if(power_up_states, 21), get_channelNames_if(power_up_states, 22), get_state_if(power_up_states, 22), get_channelNames_if(power_up_states, 23), get_state_if(power_up_states, 23), get_channelNames_if(power_up_states, 24), get_state_if(power_up_states, 24), get_channelNames_if(power_up_states, 25), get_state_if(power_up_states, 25), get_channelNames_if(power_up_states, 26), get_state_if(power_up_states, 26), get_channelNames_if(power_up_states, 27), get_state_if(power_up_states, 27), get_channelNames_if(power_up_states, 28), get_state_if(power_up_states, 28), get_channelNames_if(power_up_states, 29), get_state_if(power_up_states, 29), get_channelNames_if(power_up_states, 30), get_state_if(power_up_states, 30), get_channelNames_if(power_up_states, 31), get_state_if(power_up_states, 31), get_channelNames_if(power_up_states, 32), get_state_if(power_up_states, 32), get_channelNames_if(power_up_states, 33), get_state_if(power_up_states, 33), get_channelNames_if(power_up_states, 34), get_state_if(power_up_states, 34), get_channelNames_if(power_up_states, 35), get_state_if(power_up_states, 35), get_channelNames_if(power_up_states, 36), get_state_if(power_up_states, 36), get_channelNames_if(power_up_states, 37), get_state_if(power_up_states, 37), get_channelNames_if(power_up_states, 38), get_state_if(power_up_states, 38), get_channelNames_if(power_up_states, 39), get_state_if(power_up_states, 39), get_channelNames_if(power_up_states, 40), get_state_if(power_up_states, 40), get_channelNames_if(power_up_states, 41), get_state_if(power_up_states, 41), get_channelNames_if(power_up_states, 42), get_state_if(power_up_states, 42), get_channelNames_if(power_up_states, 43), get_state_if(power_up_states, 43), get_channelNames_if(power_up_states, 44), get_state_if(power_up_states, 44), get_channelNames_if(power_up_states, 45), get_state_if(power_up_states, 45), get_channelNames_if(power_up_states, 46), get_state_if(power_up_states, 46), get_channelNames_if(power_up_states, 47), get_state_if(power_up_states, 47), get_channelNames_if(power_up_states, 48), get_state_if(power_up_states, 48), get_channelNames_if(power_up_states, 49), get_state_if(power_up_states, 49), get_channelNames_if(power_up_states, 50), get_state_if(power_up_states, 50), get_channelNames_if(power_up_states, 51), get_state_if(power_up_states, 51), get_channelNames_if(power_up_states, 52), get_state_if(power_up_states, 52), get_channelNames_if(power_up_states, 53), get_state_if(power_up_states, 53), get_channelNames_if(power_up_states, 54), get_state_if(power_up_states, 54), get_channelNames_if(power_up_states, 55), get_state_if(power_up_states, 55), get_channelNames_if(power_up_states, 56), get_state_if(power_up_states, 56), get_channelNames_if(power_up_states, 57), get_state_if(power_up_states, 57), get_channelNames_if(power_up_states, 58), get_state_if(power_up_states, 58), get_channelNames_if(power_up_states, 59), get_state_if(power_up_states, 59), get_channelNames_if(power_up_states, 60), get_state_if(power_up_states, 60), get_channelNames_if(power_up_states, 61), get_state_if(power_up_states, 61), get_channelNames_if(power_up_states, 62), get_state_if(power_up_states, 62), get_channelNames_if(power_up_states, 63), get_state_if(power_up_states, 63), get_channelNames_if(power_up_states, 64), get_state_if(power_up_states, 64), get_channelNames_if(power_up_states, 65), get_state_if(power_up_states, 65), get_channelNames_if(power_up_states, 66), get_state_if(power_up_states, 66), get_channelNames_if(power_up_states, 67), get_state_if(power_up_states, 67), get_channelNames_if(power_up_states, 68), get_state_if(power_up_states, 68), get_channelNames_if(power_up_states, 69), get_state_if(power_up_states, 69), get_channelNames_if(power_up_states, 70), get_state_if(power_up_states, 70), get_channelNames_if(power_up_states, 71), get_state_if(power_up_states, 71), get_channelNames_if(power_up_states, 72), get_state_if(power_up_states, 72), get_channelNames_if(power_up_states, 73), get_state_if(power_up_states, 73), get_channelNames_if(power_up_states, 74), get_state_if(power_up_states, 74), get_channelNames_if(power_up_states, 75), get_state_if(power_up_states, 75), get_channelNames_if(power_up_states, 76), get_state_if(power_up_states, 76), get_channelNames_if(power_up_states, 77), get_state_if(power_up_states, 77), get_channelNames_if(power_up_states, 78), get_state_if(power_up_states, 78), get_channelNames_if(power_up_states, 79), get_state_if(power_up_states, 79), get_channelNames_if(power_up_states, 80), get_state_if(power_up_states, 80), get_channelNames_if(power_up_states, 81), get_state_if(power_up_states, 81), get_channelNames_if(power_up_states, 82), get_state_if(power_up_states, 82), get_channelNames_if(power_up_states, 83), get_state_if(power_up_states, 83), get_channelNames_if(power_up_states, 84), get_state_if(power_up_states, 84), get_channelNames_if(power_up_states, 85), get_state_if(power_up_states, 85), get_channelNames_if(power_up_states, 86), get_state_if(power_up_states, 86), get_channelNames_if(power_up_states, 87), get_state_if(power_up_states, 87), get_channelNames_if(power_up_states, 88), get_state_if(power_up_states, 88), get_channelNames_if(power_up_states, 89), get_state_if(power_up_states, 89), get_channelNames_if(power_up_states, 90), get_state_if(power_up_states, 90), get_channelNames_if(power_up_states, 91), get_state_if(power_up_states, 91), get_channelNames_if(power_up_states, 92), get_state_if(power_up_states, 92), get_channelNames_if(power_up_states, 93), get_state_if(power_up_states, 93), get_channelNames_if(power_up_states, 94), get_state_if(power_up_states, 94), get_channelNames_if(power_up_states, 95), get_state_if(power_up_states, 95), get_channelNames_if(power_up_states, 96), get_state_if(power_up_states, 96)); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, 0); + } response->set_status(status); return ::grpc::Status::OK; } @@ -14592,6 +15166,9 @@ namespace nidaqmx_grpc { } auto status = ((NiDAQmxLibrary*)library_)->SetDigitalPullUpPullDownStates(device_name, get_channelNames_if(pull_up_pull_down_states, 0), get_state_if(pull_up_pull_down_states, 0), get_channelNames_if(pull_up_pull_down_states, 1), get_state_if(pull_up_pull_down_states, 1), get_channelNames_if(pull_up_pull_down_states, 2), get_state_if(pull_up_pull_down_states, 2), get_channelNames_if(pull_up_pull_down_states, 3), get_state_if(pull_up_pull_down_states, 3), get_channelNames_if(pull_up_pull_down_states, 4), get_state_if(pull_up_pull_down_states, 4), get_channelNames_if(pull_up_pull_down_states, 5), get_state_if(pull_up_pull_down_states, 5), get_channelNames_if(pull_up_pull_down_states, 6), get_state_if(pull_up_pull_down_states, 6), get_channelNames_if(pull_up_pull_down_states, 7), get_state_if(pull_up_pull_down_states, 7), get_channelNames_if(pull_up_pull_down_states, 8), get_state_if(pull_up_pull_down_states, 8), get_channelNames_if(pull_up_pull_down_states, 9), get_state_if(pull_up_pull_down_states, 9), get_channelNames_if(pull_up_pull_down_states, 10), get_state_if(pull_up_pull_down_states, 10), get_channelNames_if(pull_up_pull_down_states, 11), get_state_if(pull_up_pull_down_states, 11), get_channelNames_if(pull_up_pull_down_states, 12), get_state_if(pull_up_pull_down_states, 12), get_channelNames_if(pull_up_pull_down_states, 13), get_state_if(pull_up_pull_down_states, 13), get_channelNames_if(pull_up_pull_down_states, 14), get_state_if(pull_up_pull_down_states, 14), get_channelNames_if(pull_up_pull_down_states, 15), get_state_if(pull_up_pull_down_states, 15), get_channelNames_if(pull_up_pull_down_states, 16), get_state_if(pull_up_pull_down_states, 16), get_channelNames_if(pull_up_pull_down_states, 17), get_state_if(pull_up_pull_down_states, 17), get_channelNames_if(pull_up_pull_down_states, 18), get_state_if(pull_up_pull_down_states, 18), get_channelNames_if(pull_up_pull_down_states, 19), get_state_if(pull_up_pull_down_states, 19), get_channelNames_if(pull_up_pull_down_states, 20), get_state_if(pull_up_pull_down_states, 20), get_channelNames_if(pull_up_pull_down_states, 21), get_state_if(pull_up_pull_down_states, 21), get_channelNames_if(pull_up_pull_down_states, 22), get_state_if(pull_up_pull_down_states, 22), get_channelNames_if(pull_up_pull_down_states, 23), get_state_if(pull_up_pull_down_states, 23), get_channelNames_if(pull_up_pull_down_states, 24), get_state_if(pull_up_pull_down_states, 24), get_channelNames_if(pull_up_pull_down_states, 25), get_state_if(pull_up_pull_down_states, 25), get_channelNames_if(pull_up_pull_down_states, 26), get_state_if(pull_up_pull_down_states, 26), get_channelNames_if(pull_up_pull_down_states, 27), get_state_if(pull_up_pull_down_states, 27), get_channelNames_if(pull_up_pull_down_states, 28), get_state_if(pull_up_pull_down_states, 28), get_channelNames_if(pull_up_pull_down_states, 29), get_state_if(pull_up_pull_down_states, 29), get_channelNames_if(pull_up_pull_down_states, 30), get_state_if(pull_up_pull_down_states, 30), get_channelNames_if(pull_up_pull_down_states, 31), get_state_if(pull_up_pull_down_states, 31), get_channelNames_if(pull_up_pull_down_states, 32), get_state_if(pull_up_pull_down_states, 32), get_channelNames_if(pull_up_pull_down_states, 33), get_state_if(pull_up_pull_down_states, 33), get_channelNames_if(pull_up_pull_down_states, 34), get_state_if(pull_up_pull_down_states, 34), get_channelNames_if(pull_up_pull_down_states, 35), get_state_if(pull_up_pull_down_states, 35), get_channelNames_if(pull_up_pull_down_states, 36), get_state_if(pull_up_pull_down_states, 36), get_channelNames_if(pull_up_pull_down_states, 37), get_state_if(pull_up_pull_down_states, 37), get_channelNames_if(pull_up_pull_down_states, 38), get_state_if(pull_up_pull_down_states, 38), get_channelNames_if(pull_up_pull_down_states, 39), get_state_if(pull_up_pull_down_states, 39), get_channelNames_if(pull_up_pull_down_states, 40), get_state_if(pull_up_pull_down_states, 40), get_channelNames_if(pull_up_pull_down_states, 41), get_state_if(pull_up_pull_down_states, 41), get_channelNames_if(pull_up_pull_down_states, 42), get_state_if(pull_up_pull_down_states, 42), get_channelNames_if(pull_up_pull_down_states, 43), get_state_if(pull_up_pull_down_states, 43), get_channelNames_if(pull_up_pull_down_states, 44), get_state_if(pull_up_pull_down_states, 44), get_channelNames_if(pull_up_pull_down_states, 45), get_state_if(pull_up_pull_down_states, 45), get_channelNames_if(pull_up_pull_down_states, 46), get_state_if(pull_up_pull_down_states, 46), get_channelNames_if(pull_up_pull_down_states, 47), get_state_if(pull_up_pull_down_states, 47), get_channelNames_if(pull_up_pull_down_states, 48), get_state_if(pull_up_pull_down_states, 48), get_channelNames_if(pull_up_pull_down_states, 49), get_state_if(pull_up_pull_down_states, 49), get_channelNames_if(pull_up_pull_down_states, 50), get_state_if(pull_up_pull_down_states, 50), get_channelNames_if(pull_up_pull_down_states, 51), get_state_if(pull_up_pull_down_states, 51), get_channelNames_if(pull_up_pull_down_states, 52), get_state_if(pull_up_pull_down_states, 52), get_channelNames_if(pull_up_pull_down_states, 53), get_state_if(pull_up_pull_down_states, 53), get_channelNames_if(pull_up_pull_down_states, 54), get_state_if(pull_up_pull_down_states, 54), get_channelNames_if(pull_up_pull_down_states, 55), get_state_if(pull_up_pull_down_states, 55), get_channelNames_if(pull_up_pull_down_states, 56), get_state_if(pull_up_pull_down_states, 56), get_channelNames_if(pull_up_pull_down_states, 57), get_state_if(pull_up_pull_down_states, 57), get_channelNames_if(pull_up_pull_down_states, 58), get_state_if(pull_up_pull_down_states, 58), get_channelNames_if(pull_up_pull_down_states, 59), get_state_if(pull_up_pull_down_states, 59), get_channelNames_if(pull_up_pull_down_states, 60), get_state_if(pull_up_pull_down_states, 60), get_channelNames_if(pull_up_pull_down_states, 61), get_state_if(pull_up_pull_down_states, 61), get_channelNames_if(pull_up_pull_down_states, 62), get_state_if(pull_up_pull_down_states, 62), get_channelNames_if(pull_up_pull_down_states, 63), get_state_if(pull_up_pull_down_states, 63), get_channelNames_if(pull_up_pull_down_states, 64), get_state_if(pull_up_pull_down_states, 64), get_channelNames_if(pull_up_pull_down_states, 65), get_state_if(pull_up_pull_down_states, 65), get_channelNames_if(pull_up_pull_down_states, 66), get_state_if(pull_up_pull_down_states, 66), get_channelNames_if(pull_up_pull_down_states, 67), get_state_if(pull_up_pull_down_states, 67), get_channelNames_if(pull_up_pull_down_states, 68), get_state_if(pull_up_pull_down_states, 68), get_channelNames_if(pull_up_pull_down_states, 69), get_state_if(pull_up_pull_down_states, 69), get_channelNames_if(pull_up_pull_down_states, 70), get_state_if(pull_up_pull_down_states, 70), get_channelNames_if(pull_up_pull_down_states, 71), get_state_if(pull_up_pull_down_states, 71), get_channelNames_if(pull_up_pull_down_states, 72), get_state_if(pull_up_pull_down_states, 72), get_channelNames_if(pull_up_pull_down_states, 73), get_state_if(pull_up_pull_down_states, 73), get_channelNames_if(pull_up_pull_down_states, 74), get_state_if(pull_up_pull_down_states, 74), get_channelNames_if(pull_up_pull_down_states, 75), get_state_if(pull_up_pull_down_states, 75), get_channelNames_if(pull_up_pull_down_states, 76), get_state_if(pull_up_pull_down_states, 76), get_channelNames_if(pull_up_pull_down_states, 77), get_state_if(pull_up_pull_down_states, 77), get_channelNames_if(pull_up_pull_down_states, 78), get_state_if(pull_up_pull_down_states, 78), get_channelNames_if(pull_up_pull_down_states, 79), get_state_if(pull_up_pull_down_states, 79), get_channelNames_if(pull_up_pull_down_states, 80), get_state_if(pull_up_pull_down_states, 80), get_channelNames_if(pull_up_pull_down_states, 81), get_state_if(pull_up_pull_down_states, 81), get_channelNames_if(pull_up_pull_down_states, 82), get_state_if(pull_up_pull_down_states, 82), get_channelNames_if(pull_up_pull_down_states, 83), get_state_if(pull_up_pull_down_states, 83), get_channelNames_if(pull_up_pull_down_states, 84), get_state_if(pull_up_pull_down_states, 84), get_channelNames_if(pull_up_pull_down_states, 85), get_state_if(pull_up_pull_down_states, 85), get_channelNames_if(pull_up_pull_down_states, 86), get_state_if(pull_up_pull_down_states, 86), get_channelNames_if(pull_up_pull_down_states, 87), get_state_if(pull_up_pull_down_states, 87), get_channelNames_if(pull_up_pull_down_states, 88), get_state_if(pull_up_pull_down_states, 88), get_channelNames_if(pull_up_pull_down_states, 89), get_state_if(pull_up_pull_down_states, 89), get_channelNames_if(pull_up_pull_down_states, 90), get_state_if(pull_up_pull_down_states, 90), get_channelNames_if(pull_up_pull_down_states, 91), get_state_if(pull_up_pull_down_states, 91), get_channelNames_if(pull_up_pull_down_states, 92), get_state_if(pull_up_pull_down_states, 92), get_channelNames_if(pull_up_pull_down_states, 93), get_state_if(pull_up_pull_down_states, 93), get_channelNames_if(pull_up_pull_down_states, 94), get_state_if(pull_up_pull_down_states, 94), get_channelNames_if(pull_up_pull_down_states, 95), get_state_if(pull_up_pull_down_states, 95), get_channelNames_if(pull_up_pull_down_states, 96), get_state_if(pull_up_pull_down_states, 96)); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, 0); + } response->set_status(status); return ::grpc::Status::OK; } @@ -14632,6 +15209,9 @@ namespace nidaqmx_grpc { bool32 value = request->value(); auto size = 0U; auto status = library_->SetExportedSignalAttributeBool(task, attribute, value, size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); + } response->set_status(status); return ::grpc::Status::OK; } @@ -14672,6 +15252,9 @@ namespace nidaqmx_grpc { float64 value = request->value(); auto size = 0U; auto status = library_->SetExportedSignalAttributeDouble(task, attribute, value, size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); + } response->set_status(status); return ::grpc::Status::OK; } @@ -14727,6 +15310,9 @@ namespace nidaqmx_grpc { auto size = 0U; auto status = library_->SetExportedSignalAttributeInt32(task, attribute, value, size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); + } response->set_status(status); return ::grpc::Status::OK; } @@ -14767,6 +15353,9 @@ namespace nidaqmx_grpc { auto value = request->value().c_str(); auto size = 0U; auto status = library_->SetExportedSignalAttributeString(task, attribute, value, size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); + } response->set_status(status); return ::grpc::Status::OK; } @@ -14807,6 +15396,9 @@ namespace nidaqmx_grpc { uInt32 value = request->value(); auto size = 0U; auto status = library_->SetExportedSignalAttributeUInt32(task, attribute, value, size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); + } response->set_status(status); return ::grpc::Status::OK; } @@ -14827,6 +15419,9 @@ namespace nidaqmx_grpc { TaskHandle task = session_repository_->access_session(task_grpc_session.id(), task_grpc_session.name()); auto data = convert_from_grpc(request->data()); auto status = library_->SetFirstSampClkWhen(task, data); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); + } response->set_status(status); return ::grpc::Status::OK; } @@ -14867,6 +15462,9 @@ namespace nidaqmx_grpc { bool32 value = request->value(); auto size = 0U; auto status = library_->SetReadAttributeBool(task, attribute, value, size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); + } response->set_status(status); return ::grpc::Status::OK; } @@ -14907,6 +15505,9 @@ namespace nidaqmx_grpc { float64 value = request->value(); auto size = 0U; auto status = library_->SetReadAttributeDouble(task, attribute, value, size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); + } response->set_status(status); return ::grpc::Status::OK; } @@ -14962,6 +15563,9 @@ namespace nidaqmx_grpc { auto size = 0U; auto status = library_->SetReadAttributeInt32(task, attribute, value, size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); + } response->set_status(status); return ::grpc::Status::OK; } @@ -15002,6 +15606,9 @@ namespace nidaqmx_grpc { auto value = request->value().c_str(); auto size = 0U; auto status = library_->SetReadAttributeString(task, attribute, value, size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); + } response->set_status(status); return ::grpc::Status::OK; } @@ -15042,6 +15649,9 @@ namespace nidaqmx_grpc { uInt32 value = request->value(); auto size = 0U; auto status = library_->SetReadAttributeUInt32(task, attribute, value, size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); + } response->set_status(status); return ::grpc::Status::OK; } @@ -15082,6 +15692,9 @@ namespace nidaqmx_grpc { uInt64 value = request->value(); auto size = 0U; auto status = library_->SetReadAttributeUInt64(task, attribute, value, size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); + } response->set_status(status); return ::grpc::Status::OK; } @@ -15122,6 +15735,9 @@ namespace nidaqmx_grpc { bool32 value = request->value(); auto size = 0U; auto status = library_->SetRealTimeAttributeBool(task, attribute, value, size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); + } response->set_status(status); return ::grpc::Status::OK; } @@ -15177,6 +15793,9 @@ namespace nidaqmx_grpc { auto size = 0U; auto status = library_->SetRealTimeAttributeInt32(task, attribute, value, size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); + } response->set_status(status); return ::grpc::Status::OK; } @@ -15217,6 +15836,9 @@ namespace nidaqmx_grpc { uInt32 value = request->value(); auto size = 0U; auto status = library_->SetRealTimeAttributeUInt32(task, attribute, value, size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); + } response->set_status(status); return ::grpc::Status::OK; } @@ -15256,6 +15878,9 @@ namespace nidaqmx_grpc { float64 value = request->value(); auto size = 0U; auto status = library_->SetScaleAttributeDouble(scale_name, attribute, value, size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, 0); + } response->set_status(status); return ::grpc::Status::OK; } @@ -15295,6 +15920,9 @@ namespace nidaqmx_grpc { auto value = const_cast(request->value().data()); uInt32 size = static_cast(request->value().size()); auto status = library_->SetScaleAttributeDoubleArray(scale_name, attribute, value, size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, 0); + } response->set_status(status); return ::grpc::Status::OK; } @@ -15349,6 +15977,9 @@ namespace nidaqmx_grpc { auto size = 0U; auto status = library_->SetScaleAttributeInt32(scale_name, attribute, value, size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, 0); + } response->set_status(status); return ::grpc::Status::OK; } @@ -15388,6 +16019,9 @@ namespace nidaqmx_grpc { auto value = request->value().c_str(); auto size = 0U; auto status = library_->SetScaleAttributeString(scale_name, attribute, value, size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, 0); + } response->set_status(status); return ::grpc::Status::OK; } @@ -15408,6 +16042,9 @@ namespace nidaqmx_grpc { TaskHandle task = session_repository_->access_session(task_grpc_session.id(), task_grpc_session.name()); auto data = convert_from_grpc(request->data()); auto status = library_->SetStartTrigTrigWhen(task, data); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); + } response->set_status(status); return ::grpc::Status::OK; } @@ -15428,6 +16065,9 @@ namespace nidaqmx_grpc { TaskHandle task = session_repository_->access_session(task_grpc_session.id(), task_grpc_session.name()); auto data = convert_from_grpc(request->data()); auto status = library_->SetSyncPulseTimeWhen(task, data); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); + } response->set_status(status); return ::grpc::Status::OK; } @@ -15468,6 +16108,9 @@ namespace nidaqmx_grpc { bool32 value = request->value(); auto size = 0U; auto status = library_->SetTimingAttributeBool(task, attribute, value, size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); + } response->set_status(status); return ::grpc::Status::OK; } @@ -15508,6 +16151,9 @@ namespace nidaqmx_grpc { float64 value = request->value(); auto size = 0U; auto status = library_->SetTimingAttributeDouble(task, attribute, value, size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); + } response->set_status(status); return ::grpc::Status::OK; } @@ -15549,6 +16195,9 @@ namespace nidaqmx_grpc { bool32 value = request->value(); auto size = 0U; auto status = library_->SetTimingAttributeExBool(task, device_names, attribute, value, size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); + } response->set_status(status); return ::grpc::Status::OK; } @@ -15590,6 +16239,9 @@ namespace nidaqmx_grpc { float64 value = request->value(); auto size = 0U; auto status = library_->SetTimingAttributeExDouble(task, device_names, attribute, value, size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); + } response->set_status(status); return ::grpc::Status::OK; } @@ -15646,6 +16298,9 @@ namespace nidaqmx_grpc { auto size = 0U; auto status = library_->SetTimingAttributeExInt32(task, device_names, attribute, value, size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); + } response->set_status(status); return ::grpc::Status::OK; } @@ -15687,6 +16342,9 @@ namespace nidaqmx_grpc { auto value = request->value().c_str(); auto size = 0U; auto status = library_->SetTimingAttributeExString(task, device_names, attribute, value, size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); + } response->set_status(status); return ::grpc::Status::OK; } @@ -15728,6 +16386,9 @@ namespace nidaqmx_grpc { auto value = convert_from_grpc(request->value()); auto size = 0U; auto status = library_->SetTimingAttributeExTimestamp(task, device_names, attribute, value, size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); + } response->set_status(status); return ::grpc::Status::OK; } @@ -15769,6 +16430,9 @@ namespace nidaqmx_grpc { uInt32 value = request->value(); auto size = 0U; auto status = library_->SetTimingAttributeExUInt32(task, device_names, attribute, value, size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); + } response->set_status(status); return ::grpc::Status::OK; } @@ -15810,6 +16474,9 @@ namespace nidaqmx_grpc { uInt64 value = request->value(); auto size = 0U; auto status = library_->SetTimingAttributeExUInt64(task, device_names, attribute, value, size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); + } response->set_status(status); return ::grpc::Status::OK; } @@ -15865,6 +16532,9 @@ namespace nidaqmx_grpc { auto size = 0U; auto status = library_->SetTimingAttributeInt32(task, attribute, value, size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); + } response->set_status(status); return ::grpc::Status::OK; } @@ -15905,6 +16575,9 @@ namespace nidaqmx_grpc { auto value = request->value().c_str(); auto size = 0U; auto status = library_->SetTimingAttributeString(task, attribute, value, size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); + } response->set_status(status); return ::grpc::Status::OK; } @@ -15945,6 +16618,9 @@ namespace nidaqmx_grpc { auto value = convert_from_grpc(request->value()); auto size = 0U; auto status = library_->SetTimingAttributeTimestamp(task, attribute, value, size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); + } response->set_status(status); return ::grpc::Status::OK; } @@ -15985,6 +16661,9 @@ namespace nidaqmx_grpc { uInt32 value = request->value(); auto size = 0U; auto status = library_->SetTimingAttributeUInt32(task, attribute, value, size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); + } response->set_status(status); return ::grpc::Status::OK; } @@ -16025,6 +16704,9 @@ namespace nidaqmx_grpc { uInt64 value = request->value(); auto size = 0U; auto status = library_->SetTimingAttributeUInt64(task, attribute, value, size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); + } response->set_status(status); return ::grpc::Status::OK; } @@ -16065,6 +16747,9 @@ namespace nidaqmx_grpc { bool32 value = request->value(); auto size = 0U; auto status = library_->SetTrigAttributeBool(task, attribute, value, size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); + } response->set_status(status); return ::grpc::Status::OK; } @@ -16105,6 +16790,9 @@ namespace nidaqmx_grpc { float64 value = request->value(); auto size = 0U; auto status = library_->SetTrigAttributeDouble(task, attribute, value, size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); + } response->set_status(status); return ::grpc::Status::OK; } @@ -16145,6 +16833,9 @@ namespace nidaqmx_grpc { auto value = const_cast(request->value().data()); uInt32 size = static_cast(request->value().size()); auto status = library_->SetTrigAttributeDoubleArray(task, attribute, value, size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); + } response->set_status(status); return ::grpc::Status::OK; } @@ -16200,6 +16891,9 @@ namespace nidaqmx_grpc { auto size = 0U; auto status = library_->SetTrigAttributeInt32(task, attribute, value, size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); + } response->set_status(status); return ::grpc::Status::OK; } @@ -16240,6 +16934,9 @@ namespace nidaqmx_grpc { auto value = reinterpret_cast(request->value().data()); uInt32 size = static_cast(request->value().size()); auto status = library_->SetTrigAttributeInt32Array(task, attribute, value, size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); + } response->set_status(status); return ::grpc::Status::OK; } @@ -16280,6 +16977,9 @@ namespace nidaqmx_grpc { auto value = request->value().c_str(); auto size = 0U; auto status = library_->SetTrigAttributeString(task, attribute, value, size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); + } response->set_status(status); return ::grpc::Status::OK; } @@ -16320,6 +17020,9 @@ namespace nidaqmx_grpc { auto value = convert_from_grpc(request->value()); auto size = 0U; auto status = library_->SetTrigAttributeTimestamp(task, attribute, value, size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); + } response->set_status(status); return ::grpc::Status::OK; } @@ -16360,6 +17063,9 @@ namespace nidaqmx_grpc { uInt32 value = request->value(); auto size = 0U; auto status = library_->SetTrigAttributeUInt32(task, attribute, value, size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); + } response->set_status(status); return ::grpc::Status::OK; } @@ -16401,6 +17107,9 @@ namespace nidaqmx_grpc { bool32 value = request->value(); auto size = 0U; auto status = library_->SetWatchdogAttributeBool(task, lines, attribute, value, size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); + } response->set_status(status); return ::grpc::Status::OK; } @@ -16442,6 +17151,9 @@ namespace nidaqmx_grpc { float64 value = request->value(); auto size = 0U; auto status = library_->SetWatchdogAttributeDouble(task, lines, attribute, value, size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); + } response->set_status(status); return ::grpc::Status::OK; } @@ -16498,6 +17210,9 @@ namespace nidaqmx_grpc { auto size = 0U; auto status = library_->SetWatchdogAttributeInt32(task, lines, attribute, value, size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); + } response->set_status(status); return ::grpc::Status::OK; } @@ -16539,6 +17254,9 @@ namespace nidaqmx_grpc { auto value = request->value().c_str(); auto size = 0U; auto status = library_->SetWatchdogAttributeString(task, lines, attribute, value, size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); + } response->set_status(status); return ::grpc::Status::OK; } @@ -16579,6 +17297,9 @@ namespace nidaqmx_grpc { bool32 value = request->value(); auto size = 0U; auto status = library_->SetWriteAttributeBool(task, attribute, value, size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); + } response->set_status(status); return ::grpc::Status::OK; } @@ -16619,6 +17340,9 @@ namespace nidaqmx_grpc { float64 value = request->value(); auto size = 0U; auto status = library_->SetWriteAttributeDouble(task, attribute, value, size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); + } response->set_status(status); return ::grpc::Status::OK; } @@ -16674,6 +17398,9 @@ namespace nidaqmx_grpc { auto size = 0U; auto status = library_->SetWriteAttributeInt32(task, attribute, value, size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); + } response->set_status(status); return ::grpc::Status::OK; } @@ -16714,6 +17441,9 @@ namespace nidaqmx_grpc { auto value = request->value().c_str(); auto size = 0U; auto status = library_->SetWriteAttributeString(task, attribute, value, size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); + } response->set_status(status); return ::grpc::Status::OK; } @@ -16754,6 +17484,9 @@ namespace nidaqmx_grpc { uInt32 value = request->value(); auto size = 0U; auto status = library_->SetWriteAttributeUInt32(task, attribute, value, size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); + } response->set_status(status); return ::grpc::Status::OK; } @@ -16794,6 +17527,9 @@ namespace nidaqmx_grpc { uInt64 value = request->value(); auto size = 0U; auto status = library_->SetWriteAttributeUInt64(task, attribute, value, size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); + } response->set_status(status); return ::grpc::Status::OK; } @@ -16814,6 +17550,9 @@ namespace nidaqmx_grpc { TaskHandle task = session_repository_->access_session(task_grpc_session.id(), task_grpc_session.name()); auto file_path = request->file_path().c_str(); auto status = library_->StartNewFile(task, file_path); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); + } response->set_status(status); return ::grpc::Status::OK; } @@ -16833,6 +17572,9 @@ namespace nidaqmx_grpc { auto task_grpc_session = request->task(); TaskHandle task = session_repository_->access_session(task_grpc_session.id(), task_grpc_session.name()); auto status = library_->StartTask(task); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); + } response->set_status(status); return ::grpc::Status::OK; } @@ -16852,6 +17594,9 @@ namespace nidaqmx_grpc { auto task_grpc_session = request->task(); TaskHandle task = session_repository_->access_session(task_grpc_session.id(), task_grpc_session.name()); auto status = library_->StopTask(task); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); + } response->set_status(status); return ::grpc::Status::OK; } @@ -16887,6 +17632,9 @@ namespace nidaqmx_grpc { } auto status = library_->TaskControl(task, action); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); + } response->set_status(status); return ::grpc::Status::OK; } @@ -16905,6 +17653,9 @@ namespace nidaqmx_grpc { try { auto output_terminal = request->output_terminal().c_str(); auto status = library_->TristateOutputTerm(output_terminal); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, 0); + } response->set_status(status); return ::grpc::Status::OK; } @@ -16923,6 +17674,9 @@ namespace nidaqmx_grpc { try { auto device_name = request->device_name().c_str(); auto status = library_->UnreserveNetworkDevice(device_name); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, 0); + } response->set_status(status); return ::grpc::Status::OK; } @@ -16944,10 +17698,11 @@ namespace nidaqmx_grpc { float64 timeout = request->timeout(); bool32 is_late {}; auto status = library_->WaitForNextSampleClock(task, timeout, &is_late); - response->set_status(status); - if (status_ok(status)) { - response->set_is_late(is_late); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); } + response->set_status(status); + response->set_is_late(is_late); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -16984,10 +17739,11 @@ namespace nidaqmx_grpc { float64 timeout = request->timeout(); CVIAbsoluteTime timestamp {}; auto status = library_->WaitForValidTimestamp(task, timestamp_event, timeout, ×tamp); - response->set_status(status); - if (status_ok(status)) { - convert_to_grpc(timestamp, response->mutable_timestamp()); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); } + response->set_status(status); + convert_to_grpc(timestamp, response->mutable_timestamp()); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -17007,6 +17763,9 @@ namespace nidaqmx_grpc { TaskHandle task = session_repository_->access_session(task_grpc_session.id(), task_grpc_session.name()); float64 time_to_wait = request->time_to_wait(); auto status = library_->WaitUntilTaskDone(task, time_to_wait); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); + } response->set_status(status); return ::grpc::Status::OK; } @@ -17048,10 +17807,11 @@ namespace nidaqmx_grpc { auto reserved = nullptr; int32 samps_per_chan_written {}; auto status = library_->WriteAnalogF64(task, num_samps_per_chan, auto_start, timeout, data_layout, write_array, &samps_per_chan_written, reserved); - response->set_status(status); - if (status_ok(status)) { - response->set_samps_per_chan_written(samps_per_chan_written); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); } + response->set_status(status); + response->set_samps_per_chan_written(samps_per_chan_written); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -17074,6 +17834,9 @@ namespace nidaqmx_grpc { float64 value = request->value(); auto reserved = nullptr; auto status = library_->WriteAnalogScalarF64(task, auto_start, timeout, value, reserved); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); + } response->set_status(status); return ::grpc::Status::OK; } @@ -17132,10 +17895,11 @@ namespace nidaqmx_grpc { auto reserved = nullptr; int32 samps_per_chan_written {}; auto status = library_->WriteBinaryI16(task, num_samps_per_chan, auto_start, timeout, data_layout, write_array.data(), &samps_per_chan_written, reserved); - response->set_status(status); - if (status_ok(status)) { - response->set_samps_per_chan_written(samps_per_chan_written); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); } + response->set_status(status); + response->set_samps_per_chan_written(samps_per_chan_written); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -17179,10 +17943,11 @@ namespace nidaqmx_grpc { auto reserved = nullptr; int32 samps_per_chan_written {}; auto status = library_->WriteBinaryI32(task, num_samps_per_chan, auto_start, timeout, data_layout, write_array, &samps_per_chan_written, reserved); - response->set_status(status); - if (status_ok(status)) { - response->set_samps_per_chan_written(samps_per_chan_written); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); } + response->set_status(status); + response->set_samps_per_chan_written(samps_per_chan_written); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -17240,10 +18005,11 @@ namespace nidaqmx_grpc { auto reserved = nullptr; int32 samps_per_chan_written {}; auto status = library_->WriteBinaryU16(task, num_samps_per_chan, auto_start, timeout, data_layout, write_array.data(), &samps_per_chan_written, reserved); - response->set_status(status); - if (status_ok(status)) { - response->set_samps_per_chan_written(samps_per_chan_written); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); } + response->set_status(status); + response->set_samps_per_chan_written(samps_per_chan_written); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -17287,10 +18053,11 @@ namespace nidaqmx_grpc { auto reserved = nullptr; int32 samps_per_chan_written {}; auto status = library_->WriteBinaryU32(task, num_samps_per_chan, auto_start, timeout, data_layout, write_array, &samps_per_chan_written, reserved); - response->set_status(status); - if (status_ok(status)) { - response->set_samps_per_chan_written(samps_per_chan_written); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); } + response->set_status(status); + response->set_samps_per_chan_written(samps_per_chan_written); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -17332,10 +18099,11 @@ namespace nidaqmx_grpc { auto reserved = nullptr; int32 num_samps_per_chan_written {}; auto status = library_->WriteCtrFreq(task, num_samps_per_chan, auto_start, timeout, data_layout, frequency, duty_cycle, &num_samps_per_chan_written, reserved); - response->set_status(status); - if (status_ok(status)) { - response->set_num_samps_per_chan_written(num_samps_per_chan_written); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); } + response->set_status(status); + response->set_num_samps_per_chan_written(num_samps_per_chan_written); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -17359,6 +18127,9 @@ namespace nidaqmx_grpc { float64 duty_cycle = request->duty_cycle(); auto reserved = nullptr; auto status = library_->WriteCtrFreqScalar(task, auto_start, timeout, frequency, duty_cycle, reserved); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); + } response->set_status(status); return ::grpc::Status::OK; } @@ -17401,10 +18172,11 @@ namespace nidaqmx_grpc { auto reserved = nullptr; int32 num_samps_per_chan_written {}; auto status = library_->WriteCtrTicks(task, num_samps_per_chan, auto_start, timeout, data_layout, high_ticks, low_ticks, &num_samps_per_chan_written, reserved); - response->set_status(status); - if (status_ok(status)) { - response->set_num_samps_per_chan_written(num_samps_per_chan_written); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); } + response->set_status(status); + response->set_num_samps_per_chan_written(num_samps_per_chan_written); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -17428,6 +18200,9 @@ namespace nidaqmx_grpc { uInt32 low_ticks = request->low_ticks(); auto reserved = nullptr; auto status = library_->WriteCtrTicksScalar(task, auto_start, timeout, high_ticks, low_ticks, reserved); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); + } response->set_status(status); return ::grpc::Status::OK; } @@ -17470,10 +18245,11 @@ namespace nidaqmx_grpc { auto reserved = nullptr; int32 num_samps_per_chan_written {}; auto status = library_->WriteCtrTime(task, num_samps_per_chan, auto_start, timeout, data_layout, high_time, low_time, &num_samps_per_chan_written, reserved); - response->set_status(status); - if (status_ok(status)) { - response->set_num_samps_per_chan_written(num_samps_per_chan_written); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); } + response->set_status(status); + response->set_num_samps_per_chan_written(num_samps_per_chan_written); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -17497,6 +18273,9 @@ namespace nidaqmx_grpc { float64 low_time = request->low_time(); auto reserved = nullptr; auto status = library_->WriteCtrTimeScalar(task, auto_start, timeout, high_time, low_time, reserved); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); + } response->set_status(status); return ::grpc::Status::OK; } @@ -17538,10 +18317,11 @@ namespace nidaqmx_grpc { auto reserved = nullptr; int32 samps_per_chan_written {}; auto status = library_->WriteDigitalLines(task, num_samps_per_chan, auto_start, timeout, data_layout, write_array, &samps_per_chan_written, reserved); - response->set_status(status); - if (status_ok(status)) { - response->set_samps_per_chan_written(samps_per_chan_written); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); } + response->set_status(status); + response->set_samps_per_chan_written(samps_per_chan_written); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -17564,6 +18344,9 @@ namespace nidaqmx_grpc { uInt32 value = request->value(); auto reserved = nullptr; auto status = library_->WriteDigitalScalarU32(task, auto_start, timeout, value, reserved); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); + } response->set_status(status); return ::grpc::Status::OK; } @@ -17622,10 +18405,11 @@ namespace nidaqmx_grpc { auto reserved = nullptr; int32 samps_per_chan_written {}; auto status = library_->WriteDigitalU16(task, num_samps_per_chan, auto_start, timeout, data_layout, write_array.data(), &samps_per_chan_written, reserved); - response->set_status(status); - if (status_ok(status)) { - response->set_samps_per_chan_written(samps_per_chan_written); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); } + response->set_status(status); + response->set_samps_per_chan_written(samps_per_chan_written); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -17669,10 +18453,11 @@ namespace nidaqmx_grpc { auto reserved = nullptr; int32 samps_per_chan_written {}; auto status = library_->WriteDigitalU32(task, num_samps_per_chan, auto_start, timeout, data_layout, write_array, &samps_per_chan_written, reserved); - response->set_status(status); - if (status_ok(status)) { - response->set_samps_per_chan_written(samps_per_chan_written); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); } + response->set_status(status); + response->set_samps_per_chan_written(samps_per_chan_written); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -17713,10 +18498,11 @@ namespace nidaqmx_grpc { auto reserved = nullptr; int32 samps_per_chan_written {}; auto status = library_->WriteDigitalU8(task, num_samps_per_chan, auto_start, timeout, data_layout, write_array, &samps_per_chan_written, reserved); - response->set_status(status); - if (status_ok(status)) { - response->set_samps_per_chan_written(samps_per_chan_written); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); } + response->set_status(status); + response->set_samps_per_chan_written(samps_per_chan_written); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -17741,10 +18527,11 @@ namespace nidaqmx_grpc { auto reserved = nullptr; int32 samps_per_chan_written {}; auto status = library_->WriteRaw(task, num_samps, auto_start, timeout, write_array, &samps_per_chan_written, reserved); - response->set_status(status); - if (status_ok(status)) { - response->set_samps_per_chan_written(samps_per_chan_written); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, task); } + response->set_status(status); + response->set_samps_per_chan_written(samps_per_chan_written); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -17780,6 +18567,9 @@ namespace nidaqmx_grpc { } auto status = library_->WriteToTEDSFromArray(physical_channel, bit_stream, array_size, basic_teds_options); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, 0); + } response->set_status(status); return ::grpc::Status::OK; } @@ -17815,6 +18605,9 @@ namespace nidaqmx_grpc { } auto status = library_->WriteToTEDSFromFile(physical_channel, file_path, basic_teds_options); + if (!status_ok(status)) { + return ConvertApiErrorStatusForTaskHandle(status, 0); + } response->set_status(status); return ::grpc::Status::OK; } diff --git a/generated/nidaqmx/nidaqmx_service.h b/generated/nidaqmx/nidaqmx_service.h index a15db7a92..27f8e1303 100644 --- a/generated/nidaqmx/nidaqmx_service.h +++ b/generated/nidaqmx/nidaqmx_service.h @@ -431,6 +431,7 @@ class NiDAQmxService final : public NiDAQmx::WithCallbackMethod_RegisterSignalEv private: NiDAQmxLibraryInterface* library_; ResourceRepositorySharedPtr session_repository_; + ::grpc::Status ConvertApiErrorStatusForTaskHandle(google::protobuf::int32 status, TaskHandle task); NiDAQmxFeatureToggles feature_toggles_; }; diff --git a/generated/nidcpower/nidcpower_service.cpp b/generated/nidcpower/nidcpower_service.cpp index fb82e3742..2f3781329 100644 --- a/generated/nidcpower/nidcpower_service.cpp +++ b/generated/nidcpower/nidcpower_service.cpp @@ -57,6 +57,9 @@ namespace nidcpower_grpc { ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); auto channel_name = request->channel_name().c_str(); auto status = library_->AbortWithChannels(vi, channel_name); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -77,6 +80,9 @@ namespace nidcpower_grpc { ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); auto channel_name = request->channel_name().c_str(); auto status = library_->CommitWithChannels(vi, channel_name); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -114,6 +120,9 @@ namespace nidcpower_grpc { } auto status = library_->ConfigureDigitalEdgeMeasureTriggerWithChannels(vi, channel_name, input_terminal, edge); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -151,6 +160,9 @@ namespace nidcpower_grpc { } auto status = library_->ConfigureDigitalEdgePulseTriggerWithChannels(vi, channel_name, input_terminal, edge); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -188,6 +200,9 @@ namespace nidcpower_grpc { } auto status = library_->ConfigureDigitalEdgeSequenceAdvanceTriggerWithChannels(vi, channel_name, input_terminal, edge); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -225,6 +240,9 @@ namespace nidcpower_grpc { } auto status = library_->ConfigureDigitalEdgeShutdownTriggerWithChannels(vi, channel_name, input_terminal, edge); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -262,6 +280,9 @@ namespace nidcpower_grpc { } auto status = library_->ConfigureDigitalEdgeSourceTriggerWithChannels(vi, channel_name, input_terminal, edge); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -299,6 +320,9 @@ namespace nidcpower_grpc { } auto status = library_->ConfigureDigitalEdgeStartTriggerWithChannels(vi, channel_name, input_terminal, edge); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -321,6 +345,9 @@ namespace nidcpower_grpc { ViBoolean enabled = request->enabled(); ViReal64 limit = request->limit(); auto status = library_->ConfigureOvp(vi, channel_name, enabled, limit); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -341,6 +368,9 @@ namespace nidcpower_grpc { ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); auto channel_name = request->channel_name().c_str(); auto status = library_->ConfigureSoftwareEdgeMeasureTriggerWithChannels(vi, channel_name); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -361,6 +391,9 @@ namespace nidcpower_grpc { ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); auto channel_name = request->channel_name().c_str(); auto status = library_->ConfigureSoftwareEdgePulseTriggerWithChannels(vi, channel_name); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -381,6 +414,9 @@ namespace nidcpower_grpc { ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); auto channel_name = request->channel_name().c_str(); auto status = library_->ConfigureSoftwareEdgeSequenceAdvanceTriggerWithChannels(vi, channel_name); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -401,6 +437,9 @@ namespace nidcpower_grpc { ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); auto channel_name = request->channel_name().c_str(); auto status = library_->ConfigureSoftwareEdgeShutdownTriggerWithChannels(vi, channel_name); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -421,6 +460,9 @@ namespace nidcpower_grpc { ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); auto channel_name = request->channel_name().c_str(); auto status = library_->ConfigureSoftwareEdgeSourceTriggerWithChannels(vi, channel_name); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -441,6 +483,9 @@ namespace nidcpower_grpc { ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); auto channel_name = request->channel_name().c_str(); auto status = library_->ConfigureSoftwareEdgeStartTriggerWithChannels(vi, channel_name); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -477,6 +522,9 @@ namespace nidcpower_grpc { } auto status = library_->ConfigureSourceModeWithChannels(vi, channel_name, source_mode); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -498,6 +546,9 @@ namespace nidcpower_grpc { auto channel_name = request->channel_name().c_str(); ViBoolean set_as_active_step = request->set_as_active_step(); auto status = library_->CreateAdvancedSequenceCommitStepWithChannels(vi, channel_name, set_as_active_step); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -519,6 +570,9 @@ namespace nidcpower_grpc { auto channel_name = request->channel_name().c_str(); ViBoolean set_as_active_step = request->set_as_active_step(); auto status = library_->CreateAdvancedSequenceStepWithChannels(vi, channel_name, set_as_active_step); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -543,6 +597,9 @@ namespace nidcpower_grpc { auto attribute_ids = const_cast(reinterpret_cast(request->attribute_ids().data())); ViBoolean set_as_active_sequence = request->set_as_active_sequence(); auto status = library_->CreateAdvancedSequenceWithChannels(vi, channel_name, sequence_name, attribute_id_count, attribute_ids, set_as_active_sequence); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -566,6 +623,9 @@ namespace nidcpower_grpc { auto attribute_ids = const_cast(reinterpret_cast(request->attribute_ids().data())); ViBoolean set_as_active_sequence = request->set_as_active_sequence(); auto status = library_->CreateAdvancedSequence(vi, sequence_name, attribute_id_count, attribute_ids, set_as_active_sequence); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -587,6 +647,9 @@ namespace nidcpower_grpc { auto channel_name = request->channel_name().c_str(); auto sequence_name = request->sequence_name().c_str(); auto status = library_->DeleteAdvancedSequenceWithChannels(vi, channel_name, sequence_name); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -607,6 +670,9 @@ namespace nidcpower_grpc { ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); auto channel_name = request->channel_name().c_str(); auto status = library_->DisablePulseTriggerWithChannels(vi, channel_name); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -627,6 +693,9 @@ namespace nidcpower_grpc { ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); auto channel_name = request->channel_name().c_str(); auto status = library_->DisableSequenceAdvanceTriggerWithChannels(vi, channel_name); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -647,6 +716,9 @@ namespace nidcpower_grpc { ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); auto channel_name = request->channel_name().c_str(); auto status = library_->DisableShutdownTriggerWithChannels(vi, channel_name); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -667,6 +739,9 @@ namespace nidcpower_grpc { ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); auto channel_name = request->channel_name().c_str(); auto status = library_->DisableSourceTriggerWithChannels(vi, channel_name); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -687,6 +762,9 @@ namespace nidcpower_grpc { ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); auto channel_name = request->channel_name().c_str(); auto status = library_->DisableStartTriggerWithChannels(vi, channel_name); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -708,10 +786,11 @@ namespace nidcpower_grpc { ViChar* error_message = (ViChar*)request->error_message().c_str(); ViInt32 error_code {}; auto status = library_->ErrorQuery(vi, &error_code, error_message); - response->set_status(status); - if (status_ok(status)) { - response->set_error_code(error_code); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_error_code(error_code); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -749,6 +828,9 @@ namespace nidcpower_grpc { auto signal_identifier = request->signal_identifier().c_str(); auto output_terminal = request->output_terminal().c_str(); auto status = library_->ExportSignalWithChannels(vi, channel_name, signal, signal_identifier, output_terminal); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -778,14 +860,11 @@ namespace nidcpower_grpc { const std::string& grpc_device_session_name = request->session_name(); auto cleanup_lambda = [&] (ViSession id) { library_->Close(id); }; int status = session_repository_->add_session(grpc_device_session_name, init_lambda, cleanup_lambda, session_id); - response->set_status(status); - if (status_ok(status)) { - response->mutable_vi()->set_id(session_id); - } - else { - const auto error_message = get_last_error_message(library_); - response->set_error_message(error_message); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, 0); } + response->set_status(status); + response->mutable_vi()->set_id(session_id); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -808,6 +887,9 @@ namespace nidcpower_grpc { ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); auto channel_name = request->channel_name().c_str(); auto status = library_->InitiateWithChannels(vi, channel_name); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -827,6 +909,9 @@ namespace nidcpower_grpc { auto vi_grpc_session = request->vi(); ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); auto status = library_->InvalidateAllAttributes(vi); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -847,6 +932,9 @@ namespace nidcpower_grpc { ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); auto channel_name = request->channel_name().c_str(); auto status = library_->ResetWithChannels(vi, channel_name); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -883,6 +971,9 @@ namespace nidcpower_grpc { } auto status = library_->SendSoftwareEdgeTriggerWithChannels(vi, channel_name, trigger); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -920,6 +1011,9 @@ namespace nidcpower_grpc { ViReal64 timeout = request->timeout(); auto status = library_->WaitForEventWithChannels(vi, channel_name, event_id, timeout); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -939,6 +1033,9 @@ namespace nidcpower_grpc { auto vi_grpc_session = request->vi(); ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); auto status = library_->Abort(vi); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -959,6 +1056,9 @@ namespace nidcpower_grpc { ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); auto channel_name = request->channel_name().c_str(); auto status = library_->CalSelfCalibrate(vi, channel_name); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -978,6 +1078,9 @@ namespace nidcpower_grpc { auto vi_grpc_session = request->vi(); ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); auto status = library_->ClearError(vi); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -997,6 +1100,9 @@ namespace nidcpower_grpc { auto vi_grpc_session = request->vi(); ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); auto status = library_->ClearInterchangeWarnings(vi); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1017,6 +1123,9 @@ namespace nidcpower_grpc { ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); session_repository_->remove_session(vi_grpc_session.id(), vi_grpc_session.name()); auto status = library_->Close(vi); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1036,6 +1145,9 @@ namespace nidcpower_grpc { auto vi_grpc_session = request->vi(); ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); auto status = library_->Commit(vi); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1073,6 +1185,9 @@ namespace nidcpower_grpc { } auto status = library_->ConfigureApertureTime(vi, channel_name, aperture_time, units); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1109,6 +1224,9 @@ namespace nidcpower_grpc { } auto status = library_->ConfigureAutoZero(vi, channel_name, auto_zero); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1130,6 +1248,9 @@ namespace nidcpower_grpc { auto channel_name = request->channel_name().c_str(); ViReal64 level = request->level(); auto status = library_->ConfigureCurrentLevel(vi, channel_name, level); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1151,6 +1272,9 @@ namespace nidcpower_grpc { auto channel_name = request->channel_name().c_str(); ViReal64 range = request->range(); auto status = library_->ConfigureCurrentLevelRange(vi, channel_name, range); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1188,6 +1312,9 @@ namespace nidcpower_grpc { ViReal64 limit = request->limit(); auto status = library_->ConfigureCurrentLimit(vi, channel_name, behavior, limit); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1209,6 +1336,9 @@ namespace nidcpower_grpc { auto channel_name = request->channel_name().c_str(); ViReal64 range = request->range(); auto status = library_->ConfigureCurrentLimitRange(vi, channel_name, range); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1245,6 +1375,9 @@ namespace nidcpower_grpc { } auto status = library_->ConfigureDigitalEdgeMeasureTrigger(vi, input_terminal, edge); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1281,6 +1414,9 @@ namespace nidcpower_grpc { } auto status = library_->ConfigureDigitalEdgePulseTrigger(vi, input_terminal, edge); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1317,6 +1453,9 @@ namespace nidcpower_grpc { } auto status = library_->ConfigureDigitalEdgeSequenceAdvanceTrigger(vi, input_terminal, edge); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1353,6 +1492,9 @@ namespace nidcpower_grpc { } auto status = library_->ConfigureDigitalEdgeSourceTrigger(vi, input_terminal, edge); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1389,6 +1531,9 @@ namespace nidcpower_grpc { } auto status = library_->ConfigureDigitalEdgeStartTrigger(vi, input_terminal, edge); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1410,6 +1555,9 @@ namespace nidcpower_grpc { auto channel_name = request->channel_name().c_str(); ViBoolean enabled = request->enabled(); auto status = library_->ConfigureOutputEnabled(vi, channel_name, enabled); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1446,6 +1594,9 @@ namespace nidcpower_grpc { } auto status = library_->ConfigureOutputFunction(vi, channel_name, function); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1467,6 +1618,9 @@ namespace nidcpower_grpc { auto channel_name = request->channel_name().c_str(); ViReal64 resistance = request->resistance(); auto status = library_->ConfigureOutputResistance(vi, channel_name, resistance); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1502,6 +1656,9 @@ namespace nidcpower_grpc { } auto status = library_->ConfigurePowerLineFrequency(vi, powerline_frequency); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1523,6 +1680,9 @@ namespace nidcpower_grpc { auto channel_name = request->channel_name().c_str(); ViReal64 level = request->level(); auto status = library_->ConfigurePulseBiasCurrentLevel(vi, channel_name, level); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1544,6 +1704,9 @@ namespace nidcpower_grpc { auto channel_name = request->channel_name().c_str(); ViReal64 limit = request->limit(); auto status = library_->ConfigurePulseBiasCurrentLimit(vi, channel_name, limit); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1565,6 +1728,9 @@ namespace nidcpower_grpc { auto channel_name = request->channel_name().c_str(); ViReal64 level = request->level(); auto status = library_->ConfigurePulseBiasVoltageLevel(vi, channel_name, level); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1586,6 +1752,9 @@ namespace nidcpower_grpc { auto channel_name = request->channel_name().c_str(); ViReal64 limit = request->limit(); auto status = library_->ConfigurePulseBiasVoltageLimit(vi, channel_name, limit); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1607,6 +1776,9 @@ namespace nidcpower_grpc { auto channel_name = request->channel_name().c_str(); ViReal64 level = request->level(); auto status = library_->ConfigurePulseCurrentLevel(vi, channel_name, level); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1628,6 +1800,9 @@ namespace nidcpower_grpc { auto channel_name = request->channel_name().c_str(); ViReal64 range = request->range(); auto status = library_->ConfigurePulseCurrentLevelRange(vi, channel_name, range); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1649,6 +1824,9 @@ namespace nidcpower_grpc { auto channel_name = request->channel_name().c_str(); ViReal64 limit = request->limit(); auto status = library_->ConfigurePulseCurrentLimit(vi, channel_name, limit); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1670,6 +1848,9 @@ namespace nidcpower_grpc { auto channel_name = request->channel_name().c_str(); ViReal64 range = request->range(); auto status = library_->ConfigurePulseCurrentLimitRange(vi, channel_name, range); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1691,6 +1872,9 @@ namespace nidcpower_grpc { auto channel_name = request->channel_name().c_str(); ViReal64 level = request->level(); auto status = library_->ConfigurePulseVoltageLevel(vi, channel_name, level); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1712,6 +1896,9 @@ namespace nidcpower_grpc { auto channel_name = request->channel_name().c_str(); ViReal64 range = request->range(); auto status = library_->ConfigurePulseVoltageLevelRange(vi, channel_name, range); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1733,6 +1920,9 @@ namespace nidcpower_grpc { auto channel_name = request->channel_name().c_str(); ViReal64 limit = request->limit(); auto status = library_->ConfigurePulseVoltageLimit(vi, channel_name, limit); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1754,6 +1944,9 @@ namespace nidcpower_grpc { auto channel_name = request->channel_name().c_str(); ViReal64 range = request->range(); auto status = library_->ConfigurePulseVoltageLimitRange(vi, channel_name, range); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1790,6 +1983,9 @@ namespace nidcpower_grpc { } auto status = library_->ConfigureSense(vi, channel_name, sense); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1809,6 +2005,9 @@ namespace nidcpower_grpc { auto vi_grpc_session = request->vi(); ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); auto status = library_->ConfigureSoftwareEdgeMeasureTrigger(vi); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1828,6 +2027,9 @@ namespace nidcpower_grpc { auto vi_grpc_session = request->vi(); ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); auto status = library_->ConfigureSoftwareEdgePulseTrigger(vi); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1847,6 +2049,9 @@ namespace nidcpower_grpc { auto vi_grpc_session = request->vi(); ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); auto status = library_->ConfigureSoftwareEdgeSequenceAdvanceTrigger(vi); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1866,6 +2071,9 @@ namespace nidcpower_grpc { auto vi_grpc_session = request->vi(); ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); auto status = library_->ConfigureSoftwareEdgeSourceTrigger(vi); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1885,6 +2093,9 @@ namespace nidcpower_grpc { auto vi_grpc_session = request->vi(); ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); auto status = library_->ConfigureSoftwareEdgeStartTrigger(vi); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1920,6 +2131,9 @@ namespace nidcpower_grpc { } auto status = library_->ConfigureSourceMode(vi, source_mode); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1941,6 +2155,9 @@ namespace nidcpower_grpc { auto channel_name = request->channel_name().c_str(); ViReal64 level = request->level(); auto status = library_->ConfigureVoltageLevel(vi, channel_name, level); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1962,6 +2179,9 @@ namespace nidcpower_grpc { auto channel_name = request->channel_name().c_str(); ViReal64 range = request->range(); auto status = library_->ConfigureVoltageLevelRange(vi, channel_name, range); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1983,6 +2203,9 @@ namespace nidcpower_grpc { auto channel_name = request->channel_name().c_str(); ViReal64 limit = request->limit(); auto status = library_->ConfigureVoltageLimit(vi, channel_name, limit); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -2004,6 +2227,9 @@ namespace nidcpower_grpc { auto channel_name = request->channel_name().c_str(); ViReal64 range = request->range(); auto status = library_->ConfigureVoltageLimitRange(vi, channel_name, range); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -2024,6 +2250,9 @@ namespace nidcpower_grpc { ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); ViBoolean set_as_active_step = request->set_as_active_step(); auto status = library_->CreateAdvancedSequenceStep(vi, set_as_active_step); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -2044,6 +2273,9 @@ namespace nidcpower_grpc { ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); auto sequence_name = request->sequence_name().c_str(); auto status = library_->DeleteAdvancedSequence(vi, sequence_name); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -2063,6 +2295,9 @@ namespace nidcpower_grpc { auto vi_grpc_session = request->vi(); ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); auto status = library_->Disable(vi); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -2082,6 +2317,9 @@ namespace nidcpower_grpc { auto vi_grpc_session = request->vi(); ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); auto status = library_->DisablePulseTrigger(vi); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -2101,6 +2339,9 @@ namespace nidcpower_grpc { auto vi_grpc_session = request->vi(); ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); auto status = library_->DisableSequenceAdvanceTrigger(vi); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -2120,6 +2361,9 @@ namespace nidcpower_grpc { auto vi_grpc_session = request->vi(); ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); auto status = library_->DisableSourceTrigger(vi); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -2139,6 +2383,9 @@ namespace nidcpower_grpc { auto vi_grpc_session = request->vi(); ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); auto status = library_->DisableStartTrigger(vi); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -2160,11 +2407,12 @@ namespace nidcpower_grpc { ViStatus error_code = request->error_code(); std::string error_message(256 - 1, '\0'); auto status = library_->ErrorMessage(vi, error_code, (ViChar*)error_message.data()); - response->set_status(status); - if (status_ok(status)) { - response->set_error_message(error_message); - nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_error_message())); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_error_message(error_message); + nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_error_message())); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -2185,9 +2433,8 @@ namespace nidcpower_grpc { while (true) { auto status = library_->ExportAttributeConfigurationBuffer(vi, 0, nullptr); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } ViInt32 size = status; @@ -2198,9 +2445,10 @@ namespace nidcpower_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); return ::grpc::Status::OK; } } @@ -2221,6 +2469,9 @@ namespace nidcpower_grpc { ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); auto file_path = request->file_path().c_str(); auto status = library_->ExportAttributeConfigurationFile(vi, file_path); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -2258,6 +2509,9 @@ namespace nidcpower_grpc { auto signal_identifier = request->signal_identifier().c_str(); auto output_terminal = request->output_terminal().c_str(); auto status = library_->ExportSignal(vi, signal, signal_identifier, output_terminal); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -2286,11 +2540,12 @@ namespace nidcpower_grpc { std::vector in_compliance(count, ViBoolean()); ViInt32 actual_count {}; auto status = library_->FetchMultiple(vi, channel_name, timeout, count, voltage_measurements, current_measurements, in_compliance.data(), &actual_count); - response->set_status(status); - if (status_ok(status)) { - convert_to_grpc(in_compliance, response->mutable_in_compliance()); - response->set_actual_count(actual_count); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + convert_to_grpc(in_compliance, response->mutable_in_compliance()); + response->set_actual_count(actual_count); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -2312,10 +2567,11 @@ namespace nidcpower_grpc { ViAttr attribute_id = request->attribute_id(); ViBoolean attribute_value {}; auto status = library_->GetAttributeViBoolean(vi, channel_name, attribute_id, &attribute_value); - response->set_status(status); - if (status_ok(status)) { - response->set_attribute_value(attribute_value); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_attribute_value(attribute_value); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -2337,10 +2593,11 @@ namespace nidcpower_grpc { ViAttr attribute_id = request->attribute_id(); ViInt32 attribute_value {}; auto status = library_->GetAttributeViInt32(vi, channel_name, attribute_id, &attribute_value); - response->set_status(status); - if (status_ok(status)) { - response->set_attribute_value(attribute_value); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_attribute_value(attribute_value); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -2362,10 +2619,11 @@ namespace nidcpower_grpc { ViAttr attribute_id = request->attribute_id(); ViInt64 attribute_value {}; auto status = library_->GetAttributeViInt64(vi, channel_name, attribute_id, &attribute_value); - response->set_status(status); - if (status_ok(status)) { - response->set_attribute_value(attribute_value); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_attribute_value(attribute_value); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -2387,10 +2645,11 @@ namespace nidcpower_grpc { ViAttr attribute_id = request->attribute_id(); ViReal64 attribute_value {}; auto status = library_->GetAttributeViReal64(vi, channel_name, attribute_id, &attribute_value); - response->set_status(status); - if (status_ok(status)) { - response->set_attribute_value(attribute_value); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_attribute_value(attribute_value); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -2412,11 +2671,12 @@ namespace nidcpower_grpc { ViAttr attribute_id = request->attribute_id(); ViSession attribute_value {}; auto status = library_->GetAttributeViSession(vi, channel_name, attribute_id, &attribute_value); - response->set_status(status); - if (status_ok(status)) { - auto session_id = session_repository_->resolve_session_id(attribute_value); - response->mutable_attribute_value()->set_id(session_id); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + auto session_id = session_repository_->resolve_session_id(attribute_value); + response->mutable_attribute_value()->set_id(session_id); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -2439,9 +2699,8 @@ namespace nidcpower_grpc { while (true) { auto status = library_->GetAttributeViString(vi, channel_name, attribute_id, 0, nullptr); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } ViInt32 buffer_size = status; @@ -2454,11 +2713,12 @@ namespace nidcpower_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_attribute_value(attribute_value); - nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_attribute_value())); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_attribute_value(attribute_value); + nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_attribute_value())); return ::grpc::Status::OK; } } @@ -2481,9 +2741,8 @@ namespace nidcpower_grpc { while (true) { auto status = library_->GetChannelName(vi, index, 0, nullptr); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } ViInt32 buffer_size = status; @@ -2496,11 +2755,12 @@ namespace nidcpower_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_channel_name(channel_name); - nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_channel_name())); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_channel_name(channel_name); + nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_channel_name())); return ::grpc::Status::OK; } } @@ -2523,9 +2783,8 @@ namespace nidcpower_grpc { while (true) { auto status = library_->GetChannelNameFromString(vi, index, 0, nullptr); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } ViInt32 buffer_size = status; @@ -2538,11 +2797,12 @@ namespace nidcpower_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_channel_name(channel_name); - nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_channel_name())); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_channel_name(channel_name); + nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_channel_name())); return ::grpc::Status::OK; } } @@ -2564,9 +2824,8 @@ namespace nidcpower_grpc { while (true) { auto status = library_->GetError(vi, nullptr, 0, nullptr); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } ViInt32 buffer_size = status; @@ -2580,12 +2839,13 @@ namespace nidcpower_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_code(code); - response->set_description(description); - nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_description())); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_code(code); + response->set_description(description); + nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_description())); return ::grpc::Status::OK; } } @@ -2610,14 +2870,15 @@ namespace nidcpower_grpc { ViInt32 hour {}; ViInt32 minute {}; auto status = library_->GetExtCalLastDateAndTime(vi, &year, &month, &day, &hour, &minute); - response->set_status(status); - if (status_ok(status)) { - response->set_year(year); - response->set_month(month); - response->set_day(day); - response->set_hour(hour); - response->set_minute(minute); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_year(year); + response->set_month(month); + response->set_day(day); + response->set_hour(hour); + response->set_minute(minute); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -2637,10 +2898,11 @@ namespace nidcpower_grpc { ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); ViReal64 temperature {}; auto status = library_->GetExtCalLastTemp(vi, &temperature); - response->set_status(status); - if (status_ok(status)) { - response->set_temperature(temperature); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_temperature(temperature); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -2660,10 +2922,11 @@ namespace nidcpower_grpc { ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); ViInt32 months {}; auto status = library_->GetExtCalRecommendedInterval(vi, &months); - response->set_status(status); - if (status_ok(status)) { - response->set_months(months); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_months(months); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -2684,9 +2947,8 @@ namespace nidcpower_grpc { while (true) { auto status = library_->GetNextCoercionRecord(vi, 0, nullptr); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } ViInt32 buffer_size = status; @@ -2699,11 +2961,12 @@ namespace nidcpower_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_coercion_record(coercion_record); - nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_coercion_record())); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_coercion_record(coercion_record); + nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_coercion_record())); return ::grpc::Status::OK; } } @@ -2725,9 +2988,8 @@ namespace nidcpower_grpc { while (true) { auto status = library_->GetNextInterchangeWarning(vi, 0, nullptr); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } ViInt32 buffer_size = status; @@ -2740,11 +3002,12 @@ namespace nidcpower_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_interchange_warning(interchange_warning); - nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_interchange_warning())); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_interchange_warning(interchange_warning); + nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_interchange_warning())); return ::grpc::Status::OK; } } @@ -2769,14 +3032,15 @@ namespace nidcpower_grpc { ViInt32 hour {}; ViInt32 minute {}; auto status = library_->GetSelfCalLastDateAndTime(vi, &year, &month, &day, &hour, &minute); - response->set_status(status); - if (status_ok(status)) { - response->set_year(year); - response->set_month(month); - response->set_day(day); - response->set_hour(hour); - response->set_minute(minute); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_year(year); + response->set_month(month); + response->set_day(day); + response->set_hour(hour); + response->set_minute(minute); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -2796,10 +3060,11 @@ namespace nidcpower_grpc { ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); ViReal64 temperature {}; auto status = library_->GetSelfCalLastTemp(vi, &temperature); - response->set_status(status); - if (status_ok(status)) { - response->set_temperature(temperature); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_temperature(temperature); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -2820,6 +3085,9 @@ namespace nidcpower_grpc { ViInt32 size = static_cast(request->configuration().size()); auto configuration = const_cast(reinterpret_cast(request->configuration().data())); auto status = library_->ImportAttributeConfigurationBuffer(vi, size, configuration); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -2840,6 +3108,9 @@ namespace nidcpower_grpc { ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); auto file_path = request->file_path().c_str(); auto status = library_->ImportAttributeConfigurationFile(vi, file_path); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -2870,14 +3141,11 @@ namespace nidcpower_grpc { const std::string& grpc_device_session_name = request->session_name(); auto cleanup_lambda = [&] (ViSession id) { library_->Close(id); }; int status = session_repository_->add_session(grpc_device_session_name, init_lambda, cleanup_lambda, session_id); - response->set_status(status); - if (status_ok(status)) { - response->mutable_vi()->set_id(session_id); - } - else { - const auto error_message = get_last_error_message(library_); - response->set_error_message(error_message); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, 0); } + response->set_status(status); + response->mutable_vi()->set_id(session_id); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -2899,6 +3167,9 @@ namespace nidcpower_grpc { auto vi_grpc_session = request->vi(); ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); auto status = library_->Initiate(vi); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -2936,10 +3207,11 @@ namespace nidcpower_grpc { ViReal64 measurement {}; auto status = library_->Measure(vi, channel_name, measurement_type, &measurement); - response->set_status(status); - if (status_ok(status)) { - response->set_measurement(measurement); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_measurement(measurement); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -2960,10 +3232,11 @@ namespace nidcpower_grpc { auto channel_name = request->channel_name().c_str(); ViBoolean in_compliance {}; auto status = library_->QueryInCompliance(vi, channel_name, &in_compliance); - response->set_status(status); - if (status_ok(status)) { - response->set_in_compliance(in_compliance); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_in_compliance(in_compliance); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -2985,10 +3258,11 @@ namespace nidcpower_grpc { ViReal64 voltage_level = request->voltage_level(); ViReal64 max_current_limit {}; auto status = library_->QueryMaxCurrentLimit(vi, channel_name, voltage_level, &max_current_limit); - response->set_status(status); - if (status_ok(status)) { - response->set_max_current_limit(max_current_limit); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_max_current_limit(max_current_limit); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -3010,10 +3284,11 @@ namespace nidcpower_grpc { ViReal64 current_limit = request->current_limit(); ViReal64 max_voltage_level {}; auto status = library_->QueryMaxVoltageLevel(vi, channel_name, current_limit, &max_voltage_level); - response->set_status(status); - if (status_ok(status)) { - response->set_max_voltage_level(max_voltage_level); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_max_voltage_level(max_voltage_level); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -3035,10 +3310,11 @@ namespace nidcpower_grpc { ViReal64 voltage_level = request->voltage_level(); ViReal64 min_current_limit {}; auto status = library_->QueryMinCurrentLimit(vi, channel_name, voltage_level, &min_current_limit); - response->set_status(status); - if (status_ok(status)) { - response->set_min_current_limit(min_current_limit); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_min_current_limit(min_current_limit); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -3075,10 +3351,11 @@ namespace nidcpower_grpc { ViBoolean in_state {}; auto status = library_->QueryOutputState(vi, channel_name, output_state, &in_state); - response->set_status(status); - if (status_ok(status)) { - response->set_in_state(in_state); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_in_state(in_state); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -3098,10 +3375,11 @@ namespace nidcpower_grpc { ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); ViReal64 temperature {}; auto status = library_->ReadCurrentTemperature(vi, &temperature); - response->set_status(status); - if (status_ok(status)) { - response->set_temperature(temperature); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_temperature(temperature); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -3120,6 +3398,9 @@ namespace nidcpower_grpc { auto vi_grpc_session = request->vi(); ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); auto status = library_->Reset(vi); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -3139,6 +3420,9 @@ namespace nidcpower_grpc { auto vi_grpc_session = request->vi(); ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); auto status = library_->ResetDevice(vi); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -3158,6 +3442,9 @@ namespace nidcpower_grpc { auto vi_grpc_session = request->vi(); ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); auto status = library_->ResetInterchangeCheck(vi); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -3177,6 +3464,9 @@ namespace nidcpower_grpc { auto vi_grpc_session = request->vi(); ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); auto status = library_->ResetWithDefaults(vi); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -3198,13 +3488,14 @@ namespace nidcpower_grpc { std::string instrument_driver_revision(256 - 1, '\0'); std::string firmware_revision(256 - 1, '\0'); auto status = library_->RevisionQuery(vi, (ViChar*)instrument_driver_revision.data(), (ViChar*)firmware_revision.data()); - response->set_status(status); - if (status_ok(status)) { - response->set_instrument_driver_revision(instrument_driver_revision); - nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_instrument_driver_revision())); - response->set_firmware_revision(firmware_revision); - nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_firmware_revision())); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_instrument_driver_revision(instrument_driver_revision); + nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_instrument_driver_revision())); + response->set_firmware_revision(firmware_revision); + nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_firmware_revision())); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -3225,12 +3516,13 @@ namespace nidcpower_grpc { ViInt16 self_test_result {}; std::string self_test_message(256 - 1, '\0'); auto status = library_->SelfTest(vi, &self_test_result, (ViChar*)self_test_message.data()); - response->set_status(status); - if (status_ok(status)) { - response->set_self_test_result(self_test_result); - response->set_self_test_message(self_test_message); - nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_self_test_message())); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_self_test_result(self_test_result); + response->set_self_test_message(self_test_message); + nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_self_test_message())); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -3265,6 +3557,9 @@ namespace nidcpower_grpc { } auto status = library_->SendSoftwareEdgeTrigger(vi, trigger); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -3287,6 +3582,9 @@ namespace nidcpower_grpc { ViAttr attribute_id = request->attribute_id(); ViBoolean attribute_value = request->attribute_value(); auto status = library_->SetAttributeViBoolean(vi, channel_name, attribute_id, attribute_value); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -3324,6 +3622,9 @@ namespace nidcpower_grpc { } auto status = library_->SetAttributeViInt32(vi, channel_name, attribute_id, attribute_value); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -3346,6 +3647,9 @@ namespace nidcpower_grpc { ViAttr attribute_id = request->attribute_id(); ViInt64 attribute_value = request->attribute_value_raw(); auto status = library_->SetAttributeViInt64(vi, channel_name, attribute_id, attribute_value); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -3383,6 +3687,9 @@ namespace nidcpower_grpc { } auto status = library_->SetAttributeViReal64(vi, channel_name, attribute_id, attribute_value); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -3406,6 +3713,9 @@ namespace nidcpower_grpc { auto attribute_value_grpc_session = request->attribute_value(); ViSession attribute_value = session_repository_->access_session(attribute_value_grpc_session.id(), attribute_value_grpc_session.name()); auto status = library_->SetAttributeViSession(vi, channel_name, attribute_id, attribute_value); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -3428,6 +3738,9 @@ namespace nidcpower_grpc { ViAttr attribute_id = request->attribute_id(); auto attribute_value = request->attribute_value_raw().c_str(); auto status = library_->SetAttributeViString(vi, channel_name, attribute_id, attribute_value); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -3462,6 +3775,9 @@ namespace nidcpower_grpc { auto size = size_size_calculation.size; auto status = library_->SetSequence(vi, channel_name, values, source_delays, size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -3498,6 +3814,9 @@ namespace nidcpower_grpc { ViReal64 timeout = request->timeout(); auto status = library_->WaitForEvent(vi, event_id, timeout); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } diff --git a/generated/nidcpower/nidcpower_service.h b/generated/nidcpower/nidcpower_service.h index 47ba4e4a5..a37ada244 100644 --- a/generated/nidcpower/nidcpower_service.h +++ b/generated/nidcpower/nidcpower_service.h @@ -177,6 +177,7 @@ class NiDCPowerService final : public NiDCPower::Service { private: NiDCPowerLibraryInterface* library_; ResourceRepositorySharedPtr session_repository_; + ::grpc::Status ConvertApiErrorStatusForViSession(google::protobuf::int32 status, ViSession vi); void Copy(const std::vector& input, google::protobuf::RepeatedField* output); NiDCPowerFeatureToggles feature_toggles_; diff --git a/generated/nidigitalpattern/nidigitalpattern_service.cpp b/generated/nidigitalpattern/nidigitalpattern_service.cpp index 49cfd1674..6f4ff7fdd 100644 --- a/generated/nidigitalpattern/nidigitalpattern_service.cpp +++ b/generated/nidigitalpattern/nidigitalpattern_service.cpp @@ -65,6 +65,9 @@ namespace nidigitalpattern_grpc { auto vi_grpc_session = request->vi(); ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); auto status = library_->Abort(vi); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -84,6 +87,9 @@ namespace nidigitalpattern_grpc { auto vi_grpc_session = request->vi(); ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); auto status = library_->AbortKeepAlive(vi); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -109,6 +115,9 @@ namespace nidigitalpattern_grpc { auto initial_state_low_pins = request->initial_state_low_pins().c_str(); auto initial_state_tristate_pins = request->initial_state_tristate_pins().c_str(); auto status = library_->ApplyLevelsAndTiming(vi, site_list, levels_sheet, timing_sheet, initial_state_high_pins, initial_state_low_pins, initial_state_tristate_pins); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -131,6 +140,9 @@ namespace nidigitalpattern_grpc { ViInt32 num_offsets = static_cast(request->offsets().size()); auto offsets = const_cast(request->offsets().data()); auto status = library_->ApplyTDROffsets(vi, channel_list, num_offsets, offsets); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -155,6 +167,9 @@ namespace nidigitalpattern_grpc { ViBoolean wait_until_done = request->wait_until_done(); ViReal64 timeout = request->timeout(); auto status = library_->BurstPattern(vi, site_list, start_label, select_digital_function, wait_until_done, timeout); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -185,6 +200,9 @@ namespace nidigitalpattern_grpc { ViBoolean wait_until_done = request->wait_until_done(); ViReal64 timeout = request->timeout(); auto status = library_->BurstPatternSynchronized(session_count, sessions.data(), site_list, start_label, select_digital_function, wait_until_done, timeout); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, 0); + } response->set_status(status); return ::grpc::Status::OK; } @@ -204,6 +222,9 @@ namespace nidigitalpattern_grpc { auto vi_grpc_session = request->vi(); ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); auto status = library_->ClearError(vi); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -224,6 +245,9 @@ namespace nidigitalpattern_grpc { ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); auto channel_list = request->channel_list().c_str(); auto status = library_->ClockGeneratorAbort(vi, channel_list); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -246,6 +270,9 @@ namespace nidigitalpattern_grpc { ViReal64 frequency = request->frequency(); ViBoolean select_digital_function = request->select_digital_function(); auto status = library_->ClockGeneratorGenerateClock(vi, channel_list, frequency, select_digital_function); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -266,6 +293,9 @@ namespace nidigitalpattern_grpc { ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); auto channel_list = request->channel_list().c_str(); auto status = library_->ClockGeneratorInitiate(vi, channel_list); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -286,6 +316,9 @@ namespace nidigitalpattern_grpc { ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); session_repository_->remove_session(vi_grpc_session.id(), vi_grpc_session.name()); auto status = library_->Close(vi); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -305,6 +338,9 @@ namespace nidigitalpattern_grpc { auto vi_grpc_session = request->vi(); ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); auto status = library_->Commit(vi); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -328,6 +364,9 @@ namespace nidigitalpattern_grpc { ViReal64 ioh = request->ioh(); ViReal64 vcom = request->vcom(); auto status = library_->ConfigureActiveLoadLevels(vi, channel_list, iol, ioh, vcom); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -349,6 +388,9 @@ namespace nidigitalpattern_grpc { ViInt64 cycle_number = request->cycle_number(); ViInt32 pretrigger_samples = request->pretrigger_samples(); auto status = library_->ConfigureCycleNumberHistoryRAMTrigger(vi, cycle_number, pretrigger_samples); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -386,6 +428,9 @@ namespace nidigitalpattern_grpc { } auto status = library_->ConfigureDigitalEdgeConditionalJumpTrigger(vi, trigger_identifier, source, edge); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -422,6 +467,9 @@ namespace nidigitalpattern_grpc { } auto status = library_->ConfigureDigitalEdgeStartTrigger(vi, source, edge); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -442,6 +490,9 @@ namespace nidigitalpattern_grpc { ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); ViInt32 pretrigger_samples = request->pretrigger_samples(); auto status = library_->ConfigureFirstFailureHistoryRAMTrigger(vi, pretrigger_samples); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -477,6 +528,9 @@ namespace nidigitalpattern_grpc { } auto status = library_->ConfigureHistoryRAMCyclesToAcquire(vi, cycles_to_acquire); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -497,6 +551,9 @@ namespace nidigitalpattern_grpc { ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); auto site_list = request->site_list().c_str(); auto status = library_->ConfigurePatternBurstSites(vi, site_list); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -520,6 +577,9 @@ namespace nidigitalpattern_grpc { ViInt64 cycle_offset = request->cycle_offset(); ViInt32 pretrigger_samples = request->pretrigger_samples(); auto status = library_->ConfigurePatternLabelHistoryRAMTrigger(vi, label, vector_offset, cycle_offset, pretrigger_samples); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -540,6 +600,9 @@ namespace nidigitalpattern_grpc { ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); auto label = request->label().c_str(); auto status = library_->ConfigureStartLabel(vi, label); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -560,6 +623,9 @@ namespace nidigitalpattern_grpc { ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); auto trigger_identifier = request->trigger_identifier().c_str(); auto status = library_->ConfigureSoftwareEdgeConditionalJumpTrigger(vi, trigger_identifier); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -579,6 +645,9 @@ namespace nidigitalpattern_grpc { auto vi_grpc_session = request->vi(); ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); auto status = library_->ConfigureSoftwareEdgeStartTrigger(vi); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -615,6 +684,9 @@ namespace nidigitalpattern_grpc { } auto status = library_->ConfigureTerminationMode(vi, channel_list, mode); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -637,6 +709,9 @@ namespace nidigitalpattern_grpc { auto time_set_name = request->time_set_name().c_str(); ViReal64 strobe_edge = request->strobe_edge(); auto status = library_->ConfigureTimeSetCompareEdgesStrobe(vi, pin_list, time_set_name, strobe_edge); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -660,6 +735,9 @@ namespace nidigitalpattern_grpc { ViReal64 strobe_edge = request->strobe_edge(); ViReal64 strobe2_edge = request->strobe2_edge(); auto status = library_->ConfigureTimeSetCompareEdgesStrobe2x(vi, pin_list, time_set_name, strobe_edge, strobe2_edge); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -701,6 +779,9 @@ namespace nidigitalpattern_grpc { ViReal64 drive_return_edge = request->drive_return_edge(); ViReal64 drive_off_edge = request->drive_off_edge(); auto status = library_->ConfigureTimeSetDriveEdges(vi, pin_list, time_set_name, format, drive_on_edge, drive_data_edge, drive_return_edge, drive_off_edge); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -744,6 +825,9 @@ namespace nidigitalpattern_grpc { ViReal64 drive_data2_edge = request->drive_data2_edge(); ViReal64 drive_return2_edge = request->drive_return2_edge(); auto status = library_->ConfigureTimeSetDriveEdges2x(vi, pin_list, time_set_name, format, drive_on_edge, drive_data_edge, drive_return_edge, drive_off_edge, drive_data2_edge, drive_return2_edge); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -781,6 +865,9 @@ namespace nidigitalpattern_grpc { } auto status = library_->ConfigureTimeSetDriveFormat(vi, pin_list, time_set_name, drive_format); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -819,6 +906,9 @@ namespace nidigitalpattern_grpc { ViReal64 time = request->time(); auto status = library_->ConfigureTimeSetEdge(vi, pin_list, time_set_name, edge, time); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -841,6 +931,9 @@ namespace nidigitalpattern_grpc { auto time_set_name = request->time_set_name().c_str(); ViInt32 edge_multiplier = request->edge_multiplier(); auto status = library_->ConfigureTimeSetEdgeMultiplier(vi, pin_list, time_set_name, edge_multiplier); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -862,6 +955,9 @@ namespace nidigitalpattern_grpc { auto time_set_name = request->time_set_name().c_str(); ViReal64 period = request->period(); auto status = library_->ConfigureTimeSetPeriod(vi, time_set_name, period); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -887,6 +983,9 @@ namespace nidigitalpattern_grpc { ViReal64 voh = request->voh(); ViReal64 vterm = request->vterm(); auto status = library_->ConfigureVoltageLevels(vi, channel_list, vil, vih, vol, voh, vterm); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -908,6 +1007,9 @@ namespace nidigitalpattern_grpc { auto waveform_name = request->waveform_name().c_str(); auto waveform_file_path = request->waveform_file_path().c_str(); auto status = library_->CreateCaptureWaveformFromFileDigicapture(vi, waveform_name, waveform_file_path); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -929,6 +1031,9 @@ namespace nidigitalpattern_grpc { auto pin_list = request->pin_list().c_str(); auto waveform_name = request->waveform_name().c_str(); auto status = library_->CreateCaptureWaveformParallel(vi, pin_list, waveform_name); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -967,6 +1072,9 @@ namespace nidigitalpattern_grpc { } auto status = library_->CreateCaptureWaveformSerial(vi, pin_list, waveform_name, sample_width, bit_order); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -987,6 +1095,9 @@ namespace nidigitalpattern_grpc { ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); ViInt32 num_sites = request->num_sites(); auto status = library_->CreateChannelMap(vi, num_sites); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1009,6 +1120,9 @@ namespace nidigitalpattern_grpc { auto waveform_file_path = request->waveform_file_path().c_str(); ViBoolean write_waveform_data = request->write_waveform_data(); auto status = library_->CreateSourceWaveformFromFileTDMS(vi, waveform_name, waveform_file_path, write_waveform_data); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1030,6 +1144,9 @@ namespace nidigitalpattern_grpc { auto dut_pin_list = request->dut_pin_list().c_str(); auto system_pin_list = request->system_pin_list().c_str(); auto status = library_->CreatePinMap(vi, dut_pin_list, system_pin_list); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1051,6 +1168,9 @@ namespace nidigitalpattern_grpc { auto pin_group_name = request->pin_group_name().c_str(); auto pin_list = request->pin_list().c_str(); auto status = library_->CreatePinGroup(vi, pin_group_name, pin_list); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1088,6 +1208,9 @@ namespace nidigitalpattern_grpc { } auto status = library_->CreateSourceWaveformParallel(vi, pin_list, waveform_name, data_mapping); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1142,6 +1265,9 @@ namespace nidigitalpattern_grpc { } auto status = library_->CreateSourceWaveformSerial(vi, pin_list, waveform_name, data_mapping, sample_width, bit_order); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1162,6 +1288,9 @@ namespace nidigitalpattern_grpc { ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); auto name = request->name().c_str(); auto status = library_->CreateTimeSet(vi, name); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1181,6 +1310,9 @@ namespace nidigitalpattern_grpc { auto vi_grpc_session = request->vi(); ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); auto status = library_->DeleteAllTimeSets(vi); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1201,6 +1333,9 @@ namespace nidigitalpattern_grpc { ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); auto trigger_identifier = request->trigger_identifier().c_str(); auto status = library_->DisableConditionalJumpTrigger(vi, trigger_identifier); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1221,6 +1356,9 @@ namespace nidigitalpattern_grpc { ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); auto site_list = request->site_list().c_str(); auto status = library_->DisableSites(vi, site_list); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1240,6 +1378,9 @@ namespace nidigitalpattern_grpc { auto vi_grpc_session = request->vi(); ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); auto status = library_->DisableStartTrigger(vi); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1267,6 +1408,9 @@ namespace nidigitalpattern_grpc { auto sync_session_grpc_session = request->sync_session(); ViSession sync_session = session_repository_->access_session(sync_session_grpc_session.id(), sync_session_grpc_session.name()); auto status = library_->EnableMatchFailCombination(session_count, sessions.data(), sync_session); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, sync_session); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1287,6 +1431,9 @@ namespace nidigitalpattern_grpc { ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); auto site_list = request->site_list().c_str(); auto status = library_->EnableSites(vi, site_list); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1306,6 +1453,9 @@ namespace nidigitalpattern_grpc { auto vi_grpc_session = request->vi(); ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); auto status = library_->EndChannelMap(vi); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1327,11 +1477,12 @@ namespace nidigitalpattern_grpc { ViStatus error_code = request->error_code(); std::string error_message(256 - 1, '\0'); auto status = library_->ErrorMessage(vi, error_code, (ViChar*)error_message.data()); - response->set_status(status); - if (status_ok(status)) { - response->set_error_message(error_message); - nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_error_message())); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_error_message(error_message); + nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_error_message())); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -1368,6 +1519,9 @@ namespace nidigitalpattern_grpc { auto signal_identifier = request->signal_identifier().c_str(); auto output_terminal = request->output_terminal().c_str(); auto status = library_->ExportSignal(vi, signal, signal_identifier, output_terminal); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1394,9 +1548,8 @@ namespace nidigitalpattern_grpc { ViInt32 actual_samples_per_waveform {}; while (true) { auto status = library_->FetchCaptureWaveformU32(vi, site_list, waveform_name, samples_to_read, timeout, 0, nullptr, &actual_num_waveforms, &actual_samples_per_waveform); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } response->mutable_data()->Resize(actual_num_waveforms, 0); ViUInt32* data = reinterpret_cast(response->mutable_data()->mutable_data()); @@ -1406,12 +1559,13 @@ namespace nidigitalpattern_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->mutable_data()->Resize(actual_num_waveforms, 0); - response->set_actual_num_waveforms(actual_num_waveforms); - response->set_actual_samples_per_waveform(actual_samples_per_waveform); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->mutable_data()->Resize(actual_num_waveforms, 0); + response->set_actual_num_waveforms(actual_num_waveforms); + response->set_actual_samples_per_waveform(actual_samples_per_waveform); return ::grpc::Status::OK; } } @@ -1438,14 +1592,15 @@ namespace nidigitalpattern_grpc { ViInt64 cycle_number {}; ViInt32 num_dut_cycles {}; auto status = library_->FetchHistoryRAMCycleInformation(vi, site, sample_index, &pattern_index, &time_set_index, &vector_number, &cycle_number, &num_dut_cycles); - response->set_status(status); - if (status_ok(status)) { - response->set_pattern_index(pattern_index); - response->set_time_set_index(time_set_index); - response->set_vector_number(vector_number); - response->set_cycle_number(cycle_number); - response->set_num_dut_cycles(num_dut_cycles); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_pattern_index(pattern_index); + response->set_time_set_index(time_set_index); + response->set_vector_number(vector_number); + response->set_cycle_number(cycle_number); + response->set_num_dut_cycles(num_dut_cycles); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -1470,9 +1625,8 @@ namespace nidigitalpattern_grpc { ViInt32 actual_num_pin_data {}; while (true) { auto status = library_->FetchHistoryRAMCyclePinData(vi, site, pin_list, sample_index, dut_cycle_index, 0, nullptr, nullptr, nullptr, &actual_num_pin_data); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } std::string expected_pin_states(actual_num_pin_data, '\0'); std::string actual_pin_states(actual_num_pin_data, '\0'); @@ -1483,18 +1637,19 @@ namespace nidigitalpattern_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - CopyBytesToEnums(expected_pin_states, response->mutable_expected_pin_states()); - response->set_expected_pin_states_raw(expected_pin_states); - response->mutable_expected_pin_states()->Resize(actual_num_pin_data, 0); - CopyBytesToEnums(actual_pin_states, response->mutable_actual_pin_states()); - response->set_actual_pin_states_raw(actual_pin_states); - response->mutable_actual_pin_states()->Resize(actual_num_pin_data, 0); - convert_to_grpc(per_pin_pass_fail, response->mutable_per_pin_pass_fail()); - response->mutable_per_pin_pass_fail()->Resize(actual_num_pin_data, 0); - response->set_actual_num_pin_data(actual_num_pin_data); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + CopyBytesToEnums(expected_pin_states, response->mutable_expected_pin_states()); + response->set_expected_pin_states_raw(expected_pin_states); + response->mutable_expected_pin_states()->Resize(actual_num_pin_data, 0); + CopyBytesToEnums(actual_pin_states, response->mutable_actual_pin_states()); + response->set_actual_pin_states_raw(actual_pin_states); + response->mutable_actual_pin_states()->Resize(actual_num_pin_data, 0); + convert_to_grpc(per_pin_pass_fail, response->mutable_per_pin_pass_fail()); + response->mutable_per_pin_pass_fail()->Resize(actual_num_pin_data, 0); + response->set_actual_num_pin_data(actual_num_pin_data); return ::grpc::Status::OK; } } @@ -1517,10 +1672,11 @@ namespace nidigitalpattern_grpc { ViInt64 sample_index = request->sample_index(); ViInt64 scan_cycle_number {}; auto status = library_->FetchHistoryRAMScanCycleNumber(vi, site, sample_index, &scan_cycle_number); - response->set_status(status); - if (status_ok(status)) { - response->set_scan_cycle_number(scan_cycle_number); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_scan_cycle_number(scan_cycle_number); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -1555,6 +1711,9 @@ namespace nidigitalpattern_grpc { } auto status = library_->FrequencyCounterConfigureMeasurementMode(vi, measurement_mode); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1576,6 +1735,9 @@ namespace nidigitalpattern_grpc { auto channel_list = request->channel_list().c_str(); ViReal64 measurement_time = request->measurement_time(); auto status = library_->FrequencyCounterConfigureMeasurementTime(vi, channel_list, measurement_time); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1598,9 +1760,8 @@ namespace nidigitalpattern_grpc { ViInt32 actual_num_frequencies {}; while (true) { auto status = library_->FrequencyCounterMeasureFrequency(vi, channel_list, 0, nullptr, &actual_num_frequencies); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } response->mutable_frequencies()->Resize(actual_num_frequencies, 0); ViReal64* frequencies = response->mutable_frequencies()->mutable_data(); @@ -1610,11 +1771,12 @@ namespace nidigitalpattern_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->mutable_frequencies()->Resize(actual_num_frequencies, 0); - response->set_actual_num_frequencies(actual_num_frequencies); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->mutable_frequencies()->Resize(actual_num_frequencies, 0); + response->set_actual_num_frequencies(actual_num_frequencies); return ::grpc::Status::OK; } } @@ -1637,10 +1799,11 @@ namespace nidigitalpattern_grpc { ViAttr attribute = request->attribute(); ViBoolean value {}; auto status = library_->GetAttributeViBoolean(vi, channel_name, attribute, &value); - response->set_status(status); - if (status_ok(status)) { - response->set_value(value); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_value(value); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -1662,10 +1825,11 @@ namespace nidigitalpattern_grpc { ViAttr attribute = request->attribute(); ViInt32 value {}; auto status = library_->GetAttributeViInt32(vi, channel_name, attribute, &value); - response->set_status(status); - if (status_ok(status)) { - response->set_value(value); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_value(value); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -1687,10 +1851,11 @@ namespace nidigitalpattern_grpc { ViAttr attribute = request->attribute(); ViInt64 value {}; auto status = library_->GetAttributeViInt64(vi, channel_name, attribute, &value); - response->set_status(status); - if (status_ok(status)) { - response->set_value(value); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_value(value); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -1712,10 +1877,11 @@ namespace nidigitalpattern_grpc { ViAttr attribute = request->attribute(); ViReal64 value {}; auto status = library_->GetAttributeViReal64(vi, channel_name, attribute, &value); - response->set_status(status); - if (status_ok(status)) { - response->set_value(value); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_value(value); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -1737,11 +1903,12 @@ namespace nidigitalpattern_grpc { ViAttr attribute = request->attribute(); ViSession value {}; auto status = library_->GetAttributeViSession(vi, channel_list, attribute, &value); - response->set_status(status); - if (status_ok(status)) { - auto session_id = session_repository_->resolve_session_id(value); - response->mutable_value()->set_id(session_id); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + auto session_id = session_repository_->resolve_session_id(value); + response->mutable_value()->set_id(session_id); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -1764,9 +1931,8 @@ namespace nidigitalpattern_grpc { while (true) { auto status = library_->GetAttributeViString(vi, channel_name, attribute, 0, nullptr); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } ViInt32 buffer_size = status; @@ -1779,11 +1945,12 @@ namespace nidigitalpattern_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_value(value); - nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_value())); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_value(value); + nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_value())); return ::grpc::Status::OK; } } @@ -1806,9 +1973,8 @@ namespace nidigitalpattern_grpc { while (true) { auto status = library_->GetChannelName(vi, index, 0, nullptr); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } ViInt32 name_buffer_size = status; @@ -1821,11 +1987,12 @@ namespace nidigitalpattern_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_name(name); - nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_name())); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_name(name); + nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_name())); return ::grpc::Status::OK; } } @@ -1848,9 +2015,8 @@ namespace nidigitalpattern_grpc { while (true) { auto status = library_->GetChannelNameFromString(vi, indices, 0, nullptr); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } ViInt32 name_buffer_size = status; @@ -1863,11 +2029,12 @@ namespace nidigitalpattern_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_names(names); - nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_names())); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_names(names); + nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_names())); return ::grpc::Status::OK; } } @@ -1889,9 +2056,8 @@ namespace nidigitalpattern_grpc { while (true) { auto status = library_->GetError(vi, nullptr, 0, nullptr); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } ViInt32 error_description_buffer_size = status; @@ -1905,12 +2071,13 @@ namespace nidigitalpattern_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_error_code(error_code); - response->set_error_description(error_description); - nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_error_description())); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_error_code(error_code); + response->set_error_description(error_description); + nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_error_description())); return ::grpc::Status::OK; } } @@ -1933,9 +2100,8 @@ namespace nidigitalpattern_grpc { ViInt32 actual_num_read {}; while (true) { auto status = library_->GetFailCount(vi, channel_list, 0, nullptr, &actual_num_read); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } response->mutable_failure_count()->Resize(actual_num_read, 0); ViInt64* failure_count = response->mutable_failure_count()->mutable_data(); @@ -1945,11 +2111,12 @@ namespace nidigitalpattern_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->mutable_failure_count()->Resize(actual_num_read, 0); - response->set_actual_num_read(actual_num_read); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->mutable_failure_count()->Resize(actual_num_read, 0); + response->set_actual_num_read(actual_num_read); return ::grpc::Status::OK; } } @@ -1971,10 +2138,11 @@ namespace nidigitalpattern_grpc { auto site = request->site().c_str(); ViInt64 sample_count {}; auto status = library_->GetHistoryRAMSampleCount(vi, site, &sample_count); - response->set_status(status); - if (status_ok(status)) { - response->set_sample_count(sample_count); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_sample_count(sample_count); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -1996,9 +2164,8 @@ namespace nidigitalpattern_grpc { ViInt32 actual_num_pins {}; while (true) { auto status = library_->GetPatternPinIndexes(vi, start_label, 0, nullptr, &actual_num_pins); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } response->mutable_pin_indexes()->Resize(actual_num_pins, 0); ViInt32* pin_indexes = reinterpret_cast(response->mutable_pin_indexes()->mutable_data()); @@ -2008,11 +2175,12 @@ namespace nidigitalpattern_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->mutable_pin_indexes()->Resize(actual_num_pins, 0); - response->set_actual_num_pins(actual_num_pins); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->mutable_pin_indexes()->Resize(actual_num_pins, 0); + response->set_actual_num_pins(actual_num_pins); return ::grpc::Status::OK; } } @@ -2035,9 +2203,8 @@ namespace nidigitalpattern_grpc { while (true) { auto status = library_->GetPatternName(vi, pattern_index, 0, nullptr); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } ViInt32 name_buffer_size = status; @@ -2050,11 +2217,12 @@ namespace nidigitalpattern_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_name(name); - nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_name())); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_name(name); + nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_name())); return ::grpc::Status::OK; } } @@ -2077,9 +2245,8 @@ namespace nidigitalpattern_grpc { while (true) { auto status = library_->GetPatternPinList(vi, start_label, 0, nullptr); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } ViInt32 pin_list_buffer_size = status; @@ -2092,11 +2259,12 @@ namespace nidigitalpattern_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_pin_list(pin_list); - nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_pin_list())); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_pin_list(pin_list); + nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_pin_list())); return ::grpc::Status::OK; } } @@ -2119,9 +2287,8 @@ namespace nidigitalpattern_grpc { while (true) { auto status = library_->GetPinName(vi, pin_index, 0, nullptr); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } ViInt32 name_buffer_size = status; @@ -2134,11 +2301,12 @@ namespace nidigitalpattern_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_name(name); - nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_name())); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_name(name); + nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_name())); return ::grpc::Status::OK; } } @@ -2161,9 +2329,8 @@ namespace nidigitalpattern_grpc { ViInt32 actual_num_values {}; while (true) { auto status = library_->GetPinResultsPinInformation(vi, channel_list, 0, nullptr, nullptr, nullptr, &actual_num_values); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } response->mutable_pin_indexes()->Resize(actual_num_values, 0); ViInt32* pin_indexes = reinterpret_cast(response->mutable_pin_indexes()->mutable_data()); @@ -2177,13 +2344,14 @@ namespace nidigitalpattern_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->mutable_pin_indexes()->Resize(actual_num_values, 0); - response->mutable_site_numbers()->Resize(actual_num_values, 0); - response->mutable_channel_indexes()->Resize(actual_num_values, 0); - response->set_actual_num_values(actual_num_values); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->mutable_pin_indexes()->Resize(actual_num_values, 0); + response->mutable_site_numbers()->Resize(actual_num_values, 0); + response->mutable_channel_indexes()->Resize(actual_num_values, 0); + response->set_actual_num_values(actual_num_values); return ::grpc::Status::OK; } } @@ -2206,9 +2374,8 @@ namespace nidigitalpattern_grpc { ViInt32 actual_num_sites {}; while (true) { auto status = library_->GetSitePassFail(vi, site_list, 0, nullptr, &actual_num_sites); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } std::vector pass_fail(actual_num_sites, ViBoolean()); auto pass_fail_buffer_size = actual_num_sites; @@ -2217,12 +2384,13 @@ namespace nidigitalpattern_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - convert_to_grpc(pass_fail, response->mutable_pass_fail()); - response->mutable_pass_fail()->Resize(actual_num_sites, 0); - response->set_actual_num_sites(actual_num_sites); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + convert_to_grpc(pass_fail, response->mutable_pass_fail()); + response->mutable_pass_fail()->Resize(actual_num_sites, 0); + response->set_actual_num_sites(actual_num_sites); return ::grpc::Status::OK; } } @@ -2261,9 +2429,8 @@ namespace nidigitalpattern_grpc { ViInt32 actual_num_site_numbers {}; while (true) { auto status = library_->GetSiteResultsSiteNumbers(vi, site_list, site_result_type, 0, nullptr, &actual_num_site_numbers); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } response->mutable_site_numbers()->Resize(actual_num_site_numbers, 0); ViInt32* site_numbers = reinterpret_cast(response->mutable_site_numbers()->mutable_data()); @@ -2273,11 +2440,12 @@ namespace nidigitalpattern_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->mutable_site_numbers()->Resize(actual_num_site_numbers, 0); - response->set_actual_num_site_numbers(actual_num_site_numbers); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->mutable_site_numbers()->Resize(actual_num_site_numbers, 0); + response->set_actual_num_site_numbers(actual_num_site_numbers); return ::grpc::Status::OK; } } @@ -2300,11 +2468,12 @@ namespace nidigitalpattern_grpc { auto time_set_name = request->time_set_name().c_str(); ViInt32 format {}; auto status = library_->GetTimeSetDriveFormat(vi, pin, time_set_name, &format); - response->set_status(status); - if (status_ok(status)) { - response->set_format(static_cast(format)); - response->set_format_raw(format); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_format(static_cast(format)); + response->set_format_raw(format); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -2342,10 +2511,11 @@ namespace nidigitalpattern_grpc { ViReal64 time {}; auto status = library_->GetTimeSetEdge(vi, pin, time_set_name, edge, &time); - response->set_status(status); - if (status_ok(status)) { - response->set_time(time); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_time(time); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -2367,10 +2537,11 @@ namespace nidigitalpattern_grpc { auto time_set_name = request->time_set_name().c_str(); ViInt32 edge_multiplier {}; auto status = library_->GetTimeSetEdgeMultiplier(vi, pin, time_set_name, &edge_multiplier); - response->set_status(status); - if (status_ok(status)) { - response->set_edge_multiplier(edge_multiplier); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_edge_multiplier(edge_multiplier); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -2392,9 +2563,8 @@ namespace nidigitalpattern_grpc { while (true) { auto status = library_->GetTimeSetName(vi, time_set_index, 0, nullptr); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } ViInt32 name_buffer_size = status; @@ -2407,11 +2577,12 @@ namespace nidigitalpattern_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_name(name); - nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_name())); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_name(name); + nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_name())); return ::grpc::Status::OK; } } @@ -2433,10 +2604,11 @@ namespace nidigitalpattern_grpc { auto time_set_name = request->time_set_name().c_str(); ViReal64 period {}; auto status = library_->GetTimeSetPeriod(vi, time_set_name, &period); - response->set_status(status); - if (status_ok(status)) { - response->set_period(period); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_period(period); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -2465,14 +2637,11 @@ namespace nidigitalpattern_grpc { const std::string& grpc_device_session_name = request->session_name(); auto cleanup_lambda = [&] (ViSession id) { library_->Close(id); }; int status = session_repository_->add_session(grpc_device_session_name, init_lambda, cleanup_lambda, session_id); - response->set_status(status); - if (status_ok(status)) { - response->mutable_vi()->set_id(session_id); - } - else { - const auto error_message = get_last_error_message(library_); - response->set_error_message(error_message); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, 0); } + response->set_status(status); + response->mutable_vi()->set_id(session_id); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -2505,14 +2674,11 @@ namespace nidigitalpattern_grpc { const std::string& grpc_device_session_name = request->session_name(); auto cleanup_lambda = [&] (ViSession id) { library_->Close(id); }; int status = session_repository_->add_session(grpc_device_session_name, init_lambda, cleanup_lambda, session_id); - response->set_status(status); - if (status_ok(status)) { - response->mutable_vi()->set_id(session_id); - } - else { - const auto error_message = get_last_error_message(library_); - response->set_error_message(error_message); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, 0); } + response->set_status(status); + response->mutable_vi()->set_id(session_id); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -2534,6 +2700,9 @@ namespace nidigitalpattern_grpc { auto vi_grpc_session = request->vi(); ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); auto status = library_->Initiate(vi); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -2554,10 +2723,11 @@ namespace nidigitalpattern_grpc { ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); ViBoolean done {}; auto status = library_->IsDone(vi, &done); - response->set_status(status); - if (status_ok(status)) { - response->set_done(done); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_done(done); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -2578,10 +2748,11 @@ namespace nidigitalpattern_grpc { auto site = request->site().c_str(); ViBoolean enable {}; auto status = library_->IsSiteEnabled(vi, site, &enable); - response->set_status(status); - if (status_ok(status)) { - response->set_enable(enable); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_enable(enable); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -2601,6 +2772,9 @@ namespace nidigitalpattern_grpc { ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); auto file_path = request->file_path().c_str(); auto status = library_->LoadLevels(vi, file_path); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -2621,6 +2795,9 @@ namespace nidigitalpattern_grpc { ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); auto file_path = request->file_path().c_str(); auto status = library_->LoadPattern(vi, file_path); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -2641,6 +2818,9 @@ namespace nidigitalpattern_grpc { ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); auto file_path = request->file_path().c_str(); auto status = library_->LoadPinMap(vi, file_path); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -2661,6 +2841,9 @@ namespace nidigitalpattern_grpc { ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); auto file_path = request->file_path().c_str(); auto status = library_->LoadSpecifications(vi, file_path); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -2681,6 +2864,9 @@ namespace nidigitalpattern_grpc { ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); auto file_path = request->file_path().c_str(); auto status = library_->LoadTiming(vi, file_path); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -2703,6 +2889,9 @@ namespace nidigitalpattern_grpc { ViInt32 site = request->site(); auto channel = request->channel().c_str(); auto status = library_->MapPinToChannel(vi, pin, site, channel); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -2740,6 +2929,9 @@ namespace nidigitalpattern_grpc { } auto status = library_->PPMUConfigureApertureTime(vi, channel_list, aperture_time, units); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -2761,6 +2953,9 @@ namespace nidigitalpattern_grpc { auto channel_list = request->channel_list().c_str(); ViReal64 current_level = request->current_level(); auto status = library_->PPMUConfigureCurrentLevel(vi, channel_list, current_level); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -2782,6 +2977,9 @@ namespace nidigitalpattern_grpc { auto channel_list = request->channel_list().c_str(); ViReal64 range = request->range(); auto status = library_->PPMUConfigureCurrentLevelRange(vi, channel_list, range); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -2819,6 +3017,9 @@ namespace nidigitalpattern_grpc { ViReal64 limit = request->limit(); auto status = library_->PPMUConfigureCurrentLimit(vi, channel_list, behavior, limit); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -2840,6 +3041,9 @@ namespace nidigitalpattern_grpc { auto channel_list = request->channel_list().c_str(); ViReal64 range = request->range(); auto status = library_->PPMUConfigureCurrentLimitRange(vi, channel_list, range); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -2876,6 +3080,9 @@ namespace nidigitalpattern_grpc { } auto status = library_->PPMUConfigureOutputFunction(vi, channel_list, output_function); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -2897,6 +3104,9 @@ namespace nidigitalpattern_grpc { auto channel_list = request->channel_list().c_str(); ViReal64 voltage_level = request->voltage_level(); auto status = library_->PPMUConfigureVoltageLevel(vi, channel_list, voltage_level); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -2919,6 +3129,9 @@ namespace nidigitalpattern_grpc { ViReal64 lower_voltage_limit = request->lower_voltage_limit(); ViReal64 upper_voltage_limit = request->upper_voltage_limit(); auto status = library_->PPMUConfigureVoltageLimits(vi, channel_list, lower_voltage_limit, upper_voltage_limit); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -2957,9 +3170,8 @@ namespace nidigitalpattern_grpc { ViInt32 actual_num_read {}; while (true) { auto status = library_->PPMUMeasure(vi, channel_list, measurement_type, 0, nullptr, &actual_num_read); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } response->mutable_measurements()->Resize(actual_num_read, 0); ViReal64* measurements = response->mutable_measurements()->mutable_data(); @@ -2969,11 +3181,12 @@ namespace nidigitalpattern_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->mutable_measurements()->Resize(actual_num_read, 0); - response->set_actual_num_read(actual_num_read); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->mutable_measurements()->Resize(actual_num_read, 0); + response->set_actual_num_read(actual_num_read); return ::grpc::Status::OK; } } @@ -2994,6 +3207,9 @@ namespace nidigitalpattern_grpc { ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); auto channel_list = request->channel_list().c_str(); auto status = library_->PPMUSource(vi, channel_list); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -3015,10 +3231,11 @@ namespace nidigitalpattern_grpc { auto flag = request->flag().c_str(); ViBoolean value {}; auto status = library_->ReadSequencerFlag(vi, flag, &value); - response->set_status(status); - if (status_ok(status)) { - response->set_value(value); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_value(value); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -3039,10 +3256,11 @@ namespace nidigitalpattern_grpc { auto reg = request->reg().c_str(); ViInt32 value {}; auto status = library_->ReadSequencerRegister(vi, reg, &value); - response->set_status(status); - if (status_ok(status)) { - response->set_value(value); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_value(value); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -3064,9 +3282,8 @@ namespace nidigitalpattern_grpc { ViInt32 actual_num_read {}; while (true) { auto status = library_->ReadStatic(vi, channel_list, 0, nullptr, &actual_num_read); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } std::string data(actual_num_read, '\0'); auto buffer_size = actual_num_read; @@ -3075,13 +3292,14 @@ namespace nidigitalpattern_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - CopyBytesToEnums(data, response->mutable_data()); - response->set_data_raw(data); - response->mutable_data()->Resize(actual_num_read, 0); - response->set_actual_num_read(actual_num_read); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + CopyBytesToEnums(data, response->mutable_data()); + response->set_data_raw(data); + response->mutable_data()->Resize(actual_num_read, 0); + response->set_actual_num_read(actual_num_read); return ::grpc::Status::OK; } } @@ -3101,6 +3319,9 @@ namespace nidigitalpattern_grpc { auto vi_grpc_session = request->vi(); ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); auto status = library_->Reset(vi); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -3122,6 +3343,9 @@ namespace nidigitalpattern_grpc { auto channel_name = request->channel_name().c_str(); ViAttr attribute_id = request->attribute_id(); auto status = library_->ResetAttribute(vi, channel_name, attribute_id); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -3141,6 +3365,9 @@ namespace nidigitalpattern_grpc { auto vi_grpc_session = request->vi(); ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); auto status = library_->ResetDevice(vi); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -3177,6 +3404,9 @@ namespace nidigitalpattern_grpc { } auto status = library_->SelectFunction(vi, channel_list, function); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -3196,6 +3426,9 @@ namespace nidigitalpattern_grpc { auto vi_grpc_session = request->vi(); ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); auto status = library_->SelfCalibrate(vi); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -3217,12 +3450,13 @@ namespace nidigitalpattern_grpc { ViInt16 test_result {}; std::string test_message(2048 - 1, '\0'); auto status = library_->SelfTest(vi, &test_result, (ViChar*)test_message.data()); - response->set_status(status); - if (status_ok(status)) { - response->set_test_result(test_result); - response->set_test_message(test_message); - nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_test_message())); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_test_result(test_result); + response->set_test_message(test_message); + nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_test_message())); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -3258,6 +3492,9 @@ namespace nidigitalpattern_grpc { auto trigger_identifier = request->trigger_identifier().c_str(); auto status = library_->SendSoftwareEdgeTrigger(vi, trigger, trigger_identifier); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -3280,6 +3517,9 @@ namespace nidigitalpattern_grpc { ViAttr attribute = request->attribute(); ViBoolean value = request->value(); auto status = library_->SetAttributeViBoolean(vi, channel_name, attribute, value); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -3317,6 +3557,9 @@ namespace nidigitalpattern_grpc { } auto status = library_->SetAttributeViInt32(vi, channel_name, attribute, value); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -3339,6 +3582,9 @@ namespace nidigitalpattern_grpc { ViAttr attribute = request->attribute(); ViInt64 value = request->value_raw(); auto status = library_->SetAttributeViInt64(vi, channel_name, attribute, value); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -3361,6 +3607,9 @@ namespace nidigitalpattern_grpc { ViAttr attribute = request->attribute(); ViReal64 value = request->value_raw(); auto status = library_->SetAttributeViReal64(vi, channel_name, attribute, value); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -3384,6 +3633,9 @@ namespace nidigitalpattern_grpc { auto value_grpc_session = request->value(); ViSession value = session_repository_->access_session(value_grpc_session.id(), value_grpc_session.name()); auto status = library_->SetAttributeViSession(vi, channel_list, attribute, value); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -3406,6 +3658,9 @@ namespace nidigitalpattern_grpc { ViAttr attribute = request->attribute(); auto value = request->value_raw().c_str(); auto status = library_->SetAttributeViString(vi, channel_name, attribute, value); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -3429,9 +3684,8 @@ namespace nidigitalpattern_grpc { ViInt32 actual_num_offsets {}; while (true) { auto status = library_->TDR(vi, channel_list, apply_offsets, 0, nullptr, &actual_num_offsets); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } response->mutable_offsets()->Resize(actual_num_offsets, 0); ViReal64* offsets = response->mutable_offsets()->mutable_data(); @@ -3441,11 +3695,12 @@ namespace nidigitalpattern_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->mutable_offsets()->Resize(actual_num_offsets, 0); - response->set_actual_num_offsets(actual_num_offsets); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->mutable_offsets()->Resize(actual_num_offsets, 0); + response->set_actual_num_offsets(actual_num_offsets); return ::grpc::Status::OK; } } @@ -3466,6 +3721,9 @@ namespace nidigitalpattern_grpc { ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); ViBoolean unload_keep_alive_pattern = request->unload_keep_alive_pattern(); auto status = library_->UnloadAllPatterns(vi, unload_keep_alive_pattern); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -3486,6 +3744,9 @@ namespace nidigitalpattern_grpc { ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); auto file_path = request->file_path().c_str(); auto status = library_->UnloadSpecifications(vi, file_path); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -3506,6 +3767,9 @@ namespace nidigitalpattern_grpc { ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); ViReal64 timeout = request->timeout(); auto status = library_->WaitUntilDone(vi, timeout); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -3527,6 +3791,9 @@ namespace nidigitalpattern_grpc { auto flag = request->flag().c_str(); ViBoolean value = request->value(); auto status = library_->WriteSequencerFlag(vi, flag, value); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -3554,6 +3821,9 @@ namespace nidigitalpattern_grpc { auto flag = request->flag().c_str(); ViBoolean value = request->value(); auto status = library_->WriteSequencerFlagSynchronized(session_count, sessions.data(), flag, value); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, 0); + } response->set_status(status); return ::grpc::Status::OK; } @@ -3575,6 +3845,9 @@ namespace nidigitalpattern_grpc { auto reg = request->reg().c_str(); ViInt32 value = request->value(); auto status = library_->WriteSequencerRegister(vi, reg, value); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -3597,6 +3870,9 @@ namespace nidigitalpattern_grpc { ViInt32 waveform_size = static_cast(request->waveform_data().size()); auto waveform_data = const_cast(reinterpret_cast(request->waveform_data().data())); auto status = library_->WriteSourceWaveformBroadcastU32(vi, waveform_name, waveform_size, waveform_data); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -3618,6 +3894,9 @@ namespace nidigitalpattern_grpc { auto waveform_name = request->waveform_name().c_str(); auto waveform_file_path = request->waveform_file_path().c_str(); auto status = library_->WriteSourceWaveformDataFromFileTDMS(vi, waveform_name, waveform_file_path); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -3654,6 +3933,9 @@ namespace nidigitalpattern_grpc { } auto status = library_->WriteStatic(vi, channel_list, state); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -3678,6 +3960,9 @@ namespace nidigitalpattern_grpc { ViInt32 samples_per_waveform = request->samples_per_waveform(); auto waveform_data = const_cast(reinterpret_cast(request->waveform_data().data())); auto status = library_->WriteSourceWaveformSiteUniqueU32(vi, site_list, waveform_name, num_waveforms, samples_per_waveform, waveform_data); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } diff --git a/generated/nidigitalpattern/nidigitalpattern_service.h b/generated/nidigitalpattern/nidigitalpattern_service.h index 247368b86..db4887031 100644 --- a/generated/nidigitalpattern/nidigitalpattern_service.h +++ b/generated/nidigitalpattern/nidigitalpattern_service.h @@ -174,6 +174,7 @@ class NiDigitalService final : public NiDigital::Service { private: NiDigitalLibraryInterface* library_; ResourceRepositorySharedPtr session_repository_; + ::grpc::Status ConvertApiErrorStatusForViSession(google::protobuf::int32 status, ViSession vi); void Copy(const std::vector& input, google::protobuf::RepeatedField* output); template void CopyBytesToEnums(const std::string& input, google::protobuf::RepeatedField* output); diff --git a/generated/nidmm/nidmm_service.cpp b/generated/nidmm/nidmm_service.cpp index aa6f5ccc3..ce33a8a24 100644 --- a/generated/nidmm/nidmm_service.cpp +++ b/generated/nidmm/nidmm_service.cpp @@ -71,6 +71,9 @@ namespace nidmm_grpc { } auto status = library_->Control4022(resource_name, configuration); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, 0); + } response->set_status(status); return ::grpc::Status::OK; } @@ -90,6 +93,9 @@ namespace nidmm_grpc { auto vi_grpc_session = request->vi(); ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); auto status = library_->Abort(vi); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -112,6 +118,9 @@ namespace nidmm_grpc { ViAttr attribute_id = request->attribute_id(); ViBoolean attribute_value = request->attribute_value(); auto status = library_->CheckAttributeViBoolean(vi, channel_name, attribute_id, attribute_value); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -149,6 +158,9 @@ namespace nidmm_grpc { } auto status = library_->CheckAttributeViInt32(vi, channel_name, attribute_id, attribute_value); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -186,6 +198,9 @@ namespace nidmm_grpc { } auto status = library_->CheckAttributeViReal64(vi, channel_name, attribute_id, attribute_value); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -209,6 +224,9 @@ namespace nidmm_grpc { auto attribute_value_grpc_session = request->attribute_value(); ViSession attribute_value = session_repository_->access_session(attribute_value_grpc_session.id(), attribute_value_grpc_session.name()); auto status = library_->CheckAttributeViSession(vi, channel_name, attribute_id, attribute_value); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -231,6 +249,9 @@ namespace nidmm_grpc { ViAttr attribute_id = request->attribute_id(); ViString attribute_value = (ViString)request->attribute_value_raw().c_str(); auto status = library_->CheckAttributeViString(vi, channel_name, attribute_id, attribute_value); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -250,6 +271,9 @@ namespace nidmm_grpc { auto vi_grpc_session = request->vi(); ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); auto status = library_->ClearError(vi); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -269,6 +293,9 @@ namespace nidmm_grpc { auto vi_grpc_session = request->vi(); ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); auto status = library_->ClearInterchangeWarnings(vi); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -289,6 +316,9 @@ namespace nidmm_grpc { ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); session_repository_->remove_session(vi_grpc_session.id(), vi_grpc_session.name()); auto status = library_->Close(vi); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -310,6 +340,9 @@ namespace nidmm_grpc { ViReal64 ac_minimum_frequency_hz = request->ac_minimum_frequency_hz(); ViReal64 ac_maximum_frequency_hz = request->ac_maximum_frequency_hz(); auto status = library_->ConfigureACBandwidth(vi, ac_minimum_frequency_hz, ac_maximum_frequency_hz); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -330,6 +363,9 @@ namespace nidmm_grpc { ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); ViInt32 adc_calibration = request->adc_calibration(); auto status = library_->ConfigureADCCalibration(vi, adc_calibration); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -350,6 +386,9 @@ namespace nidmm_grpc { ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); ViInt32 auto_zero_mode = request->auto_zero_mode(); auto status = library_->ConfigureAutoZeroMode(vi, auto_zero_mode); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -370,6 +409,9 @@ namespace nidmm_grpc { ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); ViInt32 cable_comp_type = request->cable_comp_type(); auto status = library_->ConfigureCableCompType(vi, cable_comp_type); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -390,6 +432,9 @@ namespace nidmm_grpc { ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); ViReal64 current_source = request->current_source(); auto status = library_->ConfigureCurrentSource(vi, current_source); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -410,6 +455,9 @@ namespace nidmm_grpc { ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); ViReal64 fixed_reference_junction = request->fixed_reference_junction(); auto status = library_->ConfigureFixedRefJunction(vi, fixed_reference_junction); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -445,6 +493,9 @@ namespace nidmm_grpc { } auto status = library_->ConfigureFrequencyVoltageRange(vi, voltage_range); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -465,6 +516,9 @@ namespace nidmm_grpc { ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); ViInt32 meas_complete_destination = request->meas_complete_destination(); auto status = library_->ConfigureMeasCompleteDest(vi, meas_complete_destination); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -502,6 +556,9 @@ namespace nidmm_grpc { ViReal64 range = request->range(); ViReal64 resolution_absolute = request->resolution_absolute(); auto status = library_->ConfigureMeasurementAbsolute(vi, measurement_function, range, resolution_absolute); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -522,6 +579,9 @@ namespace nidmm_grpc { ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); ViInt32 meas_complete_slope = request->meas_complete_slope(); auto status = library_->ConfigureMeasCompleteSlope(vi, meas_complete_slope); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -559,6 +619,9 @@ namespace nidmm_grpc { ViReal64 range = request->range(); ViReal64 resolution_digits = request->resolution_digits(); auto status = library_->ConfigureMeasurementDigits(vi, measurement_function, range, resolution_digits); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -642,6 +705,9 @@ namespace nidmm_grpc { } auto status = library_->ConfigureMultiPoint(vi, trigger_count, sample_count, sample_trigger, sample_interval); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -677,6 +743,9 @@ namespace nidmm_grpc { } auto status = library_->ConfigureOffsetCompOhms(vi, offset_comp_ohms); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -698,6 +767,9 @@ namespace nidmm_grpc { ViReal64 conductance = request->conductance(); ViReal64 susceptance = request->susceptance(); auto status = library_->ConfigureOpenCableCompValues(vi, conductance, susceptance); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -733,6 +805,9 @@ namespace nidmm_grpc { } auto status = library_->ConfigurePowerLineFrequency(vi, power_line_frequency_hz); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -754,6 +829,9 @@ namespace nidmm_grpc { ViReal64 resistance = request->resistance(); ViReal64 reactance = request->reactance(); auto status = library_->ConfigureShortCableCompValues(vi, resistance, reactance); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -776,6 +854,9 @@ namespace nidmm_grpc { ViReal64 rtd_b = request->rtd_b(); ViReal64 rtd_c = request->rtd_c(); auto status = library_->ConfigureRTDCustom(vi, rtd_a, rtd_b, rtd_c); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -812,6 +893,9 @@ namespace nidmm_grpc { ViReal64 rtd_resistance = request->rtd_resistance(); auto status = library_->ConfigureRTDType(vi, rtd_type, rtd_resistance); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -847,6 +931,9 @@ namespace nidmm_grpc { } auto status = library_->ConfigureSampleTriggerSlope(vi, sample_trigger_slope); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -869,6 +956,9 @@ namespace nidmm_grpc { ViReal64 thermistor_b = request->thermistor_b(); ViReal64 thermistor_c = request->thermistor_c(); auto status = library_->ConfigureThermistorCustom(vi, thermistor_a, thermistor_b, thermistor_c); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -920,6 +1010,9 @@ namespace nidmm_grpc { } auto status = library_->ConfigureThermocouple(vi, thermocouple_type, reference_junction_type); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -940,6 +1033,9 @@ namespace nidmm_grpc { ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); ViInt32 thermistor_type = request->thermistor_type(); auto status = library_->ConfigureThermistorType(vi, thermistor_type); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -960,6 +1056,9 @@ namespace nidmm_grpc { ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); ViInt32 transducer_type = request->transducer_type(); auto status = library_->ConfigureTransducerType(vi, transducer_type); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1011,6 +1110,9 @@ namespace nidmm_grpc { } auto status = library_->ConfigureTrigger(vi, trigger_source, trigger_delay); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1046,6 +1148,9 @@ namespace nidmm_grpc { } auto status = library_->ConfigureTriggerSlope(vi, trigger_slope); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1084,6 +1189,9 @@ namespace nidmm_grpc { ViReal64 rate = request->rate(); ViInt32 waveform_points = request->waveform_points(); auto status = library_->ConfigureWaveformAcquisition(vi, measurement_function, range, rate, waveform_points); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1104,6 +1212,9 @@ namespace nidmm_grpc { ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); ViInt32 waveform_coupling = request->waveform_coupling(); auto status = library_->ConfigureWaveformCoupling(vi, waveform_coupling); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1139,6 +1250,9 @@ namespace nidmm_grpc { } auto status = library_->Control(vi, control_action); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1158,6 +1272,9 @@ namespace nidmm_grpc { auto vi_grpc_session = request->vi(); ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); auto status = library_->Disable(vi); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1179,9 +1296,8 @@ namespace nidmm_grpc { while (true) { auto status = library_->ExportAttributeConfigurationBuffer(vi, 0, nullptr); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } ViInt32 size = status; @@ -1191,10 +1307,11 @@ namespace nidmm_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_configuration(configuration); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_configuration(configuration); return ::grpc::Status::OK; } } @@ -1215,6 +1332,9 @@ namespace nidmm_grpc { ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); auto file_path = request->file_path().c_str(); auto status = library_->ExportAttributeConfigurationFile(vi, file_path); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1251,10 +1371,11 @@ namespace nidmm_grpc { ViReal64 reading {}; auto status = library_->Fetch(vi, maximum_time, &reading); - response->set_status(status); - if (status_ok(status)) { - response->set_reading(reading); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_reading(reading); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -1293,10 +1414,11 @@ namespace nidmm_grpc { ViReal64* reading_array = response->mutable_reading_array()->mutable_data(); ViInt32 actual_number_of_points {}; auto status = library_->FetchMultiPoint(vi, maximum_time, array_size, reading_array, &actual_number_of_points); - response->set_status(status); - if (status_ok(status)) { - response->set_actual_number_of_points(actual_number_of_points); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_actual_number_of_points(actual_number_of_points); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -1335,10 +1457,11 @@ namespace nidmm_grpc { ViReal64* waveform_array = response->mutable_waveform_array()->mutable_data(); ViInt32 actual_number_of_points {}; auto status = library_->FetchWaveform(vi, maximum_time, array_size, waveform_array, &actual_number_of_points); - response->set_status(status); - if (status_ok(status)) { - response->set_actual_number_of_points(actual_number_of_points); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_actual_number_of_points(actual_number_of_points); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -1359,15 +1482,16 @@ namespace nidmm_grpc { ViReal64 aperture_time {}; ViInt32 aperture_time_units {}; auto status = library_->GetApertureTimeInfo(vi, &aperture_time, &aperture_time_units); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); - if (status_ok(status)) { - if(aperture_time == (int)aperture_time) { - response->set_aperture_time(static_cast(static_cast(aperture_time))); - } - response->set_aperture_time_raw(aperture_time); - response->set_aperture_time_units(static_cast(aperture_time_units)); - response->set_aperture_time_units_raw(aperture_time_units); + if(aperture_time == (int)aperture_time) { + response->set_aperture_time(static_cast(static_cast(aperture_time))); } + response->set_aperture_time_raw(aperture_time); + response->set_aperture_time_units(static_cast(aperture_time_units)); + response->set_aperture_time_units_raw(aperture_time_units); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -1389,10 +1513,11 @@ namespace nidmm_grpc { ViAttr attribute_id = request->attribute_id(); ViBoolean attribute_value {}; auto status = library_->GetAttributeViBoolean(vi, channel_name, attribute_id, &attribute_value); - response->set_status(status); - if (status_ok(status)) { - response->set_attribute_value(attribute_value); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_attribute_value(attribute_value); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -1414,10 +1539,11 @@ namespace nidmm_grpc { ViAttr attribute_id = request->attribute_id(); ViInt32 attribute_value {}; auto status = library_->GetAttributeViInt32(vi, channel_name, attribute_id, &attribute_value); - response->set_status(status); - if (status_ok(status)) { - response->set_attribute_value(attribute_value); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_attribute_value(attribute_value); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -1439,10 +1565,11 @@ namespace nidmm_grpc { ViAttr attribute_id = request->attribute_id(); ViReal64 attribute_value {}; auto status = library_->GetAttributeViReal64(vi, channel_name, attribute_id, &attribute_value); - response->set_status(status); - if (status_ok(status)) { - response->set_attribute_value(attribute_value); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_attribute_value(attribute_value); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -1464,11 +1591,12 @@ namespace nidmm_grpc { ViAttr attribute_id = request->attribute_id(); ViSession attribute_value {}; auto status = library_->GetAttributeViSession(vi, channel_name, attribute_id, &attribute_value); - response->set_status(status); - if (status_ok(status)) { - auto session_id = session_repository_->resolve_session_id(attribute_value); - response->mutable_attribute_value()->set_id(session_id); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + auto session_id = session_repository_->resolve_session_id(attribute_value); + response->mutable_attribute_value()->set_id(session_id); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -1491,9 +1619,8 @@ namespace nidmm_grpc { while (true) { auto status = library_->GetAttributeViString(vi, channel_name, attribute_id, 0, nullptr); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } ViInt32 buffer_size = status; @@ -1506,11 +1633,12 @@ namespace nidmm_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_attribute_value(attribute_value); - nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_attribute_value())); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_attribute_value(attribute_value); + nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_attribute_value())); return ::grpc::Status::OK; } } @@ -1531,10 +1659,11 @@ namespace nidmm_grpc { ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); ViReal64 actual_range {}; auto status = library_->GetAutoRangeValue(vi, &actual_range); - response->set_status(status); - if (status_ok(status)) { - response->set_actual_range(actual_range); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_actual_range(actual_range); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -1574,14 +1703,15 @@ namespace nidmm_grpc { ViInt32 hour {}; ViInt32 minute {}; auto status = library_->GetCalDateAndTime(vi, cal_type, &month, &day, &year, &hour, &minute); - response->set_status(status); - if (status_ok(status)) { - response->set_month(month); - response->set_day(day); - response->set_year(year); - response->set_hour(hour); - response->set_minute(minute); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_month(month); + response->set_day(day); + response->set_year(year); + response->set_hour(hour); + response->set_minute(minute); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -1603,9 +1733,8 @@ namespace nidmm_grpc { while (true) { auto status = library_->GetChannelName(vi, index, 0, nullptr); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } ViInt32 buffer_size = status; @@ -1618,11 +1747,12 @@ namespace nidmm_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_channel_string(channel_string); - nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_channel_string())); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_channel_string(channel_string); + nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_channel_string())); return ::grpc::Status::OK; } } @@ -1644,10 +1774,11 @@ namespace nidmm_grpc { ViString options = (ViString)request->options().c_str(); ViReal64 temperature {}; auto status = library_->GetDevTemp(vi, options, &temperature); - response->set_status(status); - if (status_ok(status)) { - response->set_temperature(temperature); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_temperature(temperature); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -1668,9 +1799,8 @@ namespace nidmm_grpc { while (true) { auto status = library_->GetError(vi, nullptr, 0, nullptr); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } ViInt32 buffer_size = status; @@ -1684,12 +1814,13 @@ namespace nidmm_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_error_code(error_code); - response->set_description(description); - nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_description())); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_error_code(error_code); + response->set_description(description); + nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_description())); return ::grpc::Status::OK; } } @@ -1712,9 +1843,8 @@ namespace nidmm_grpc { while (true) { auto status = library_->GetErrorMessage(vi, error_code, 0, nullptr); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } ViInt32 buffer_size = status; @@ -1727,11 +1857,12 @@ namespace nidmm_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_error_message(error_message); - nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_error_message())); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_error_message(error_message); + nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_error_message())); return ::grpc::Status::OK; } } @@ -1752,10 +1883,11 @@ namespace nidmm_grpc { ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); ViInt32 months {}; auto status = library_->GetExtCalRecommendedInterval(vi, &months); - response->set_status(status); - if (status_ok(status)) { - response->set_months(months); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_months(months); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -1791,10 +1923,11 @@ namespace nidmm_grpc { ViReal64 temperature {}; auto status = library_->GetLastCalTemp(vi, cal_type, &temperature); - response->set_status(status); - if (status_ok(status)) { - response->set_temperature(temperature); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_temperature(temperature); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -1814,10 +1947,11 @@ namespace nidmm_grpc { ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); ViReal64 period {}; auto status = library_->GetMeasurementPeriod(vi, &period); - response->set_status(status); - if (status_ok(status)) { - response->set_period(period); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_period(period); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -1838,9 +1972,8 @@ namespace nidmm_grpc { while (true) { auto status = library_->GetNextCoercionRecord(vi, 0, nullptr); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } ViInt32 buffer_size = status; @@ -1853,11 +1986,12 @@ namespace nidmm_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_coercion_record(coercion_record); - nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_coercion_record())); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_coercion_record(coercion_record); + nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_coercion_record())); return ::grpc::Status::OK; } } @@ -1879,9 +2013,8 @@ namespace nidmm_grpc { while (true) { auto status = library_->GetNextInterchangeWarning(vi, 0, nullptr); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } ViInt32 buffer_size = status; @@ -1894,11 +2027,12 @@ namespace nidmm_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_interchange_warning(interchange_warning); - nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_interchange_warning())); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_interchange_warning(interchange_warning); + nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_interchange_warning())); return ::grpc::Status::OK; } } @@ -1919,10 +2053,11 @@ namespace nidmm_grpc { ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); ViBoolean self_cal_supported {}; auto status = library_->GetSelfCalSupported(vi, &self_cal_supported); - response->set_status(status); - if (status_ok(status)) { - response->set_self_cal_supported(self_cal_supported); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_self_cal_supported(self_cal_supported); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -1943,6 +2078,9 @@ namespace nidmm_grpc { ViInt32 size = static_cast(request->configuration().size()); ViInt8* configuration = (ViInt8*)request->configuration().c_str(); auto status = library_->ImportAttributeConfigurationBuffer(vi, size, configuration); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1963,6 +2101,9 @@ namespace nidmm_grpc { ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); auto file_path = request->file_path().c_str(); auto status = library_->ImportAttributeConfigurationFile(vi, file_path); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1992,14 +2133,11 @@ namespace nidmm_grpc { const std::string& grpc_device_session_name = request->session_name(); auto cleanup_lambda = [&] (ViSession id) { library_->Close(id); }; int status = session_repository_->add_session(grpc_device_session_name, init_lambda, cleanup_lambda, session_id); - response->set_status(status); - if (status_ok(status)) { - response->mutable_vi()->set_id(session_id); - } - else { - const auto error_message = get_last_error_message(library_); - response->set_error_message(error_message); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, 0); } + response->set_status(status); + response->mutable_vi()->set_id(session_id); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -2032,14 +2170,11 @@ namespace nidmm_grpc { const std::string& grpc_device_session_name = request->session_name(); auto cleanup_lambda = [&] (ViSession id) { library_->Close(id); }; int status = session_repository_->add_session(grpc_device_session_name, init_lambda, cleanup_lambda, session_id); - response->set_status(status); - if (status_ok(status)) { - response->mutable_vi()->set_id(session_id); - } - else { - const auto error_message = get_last_error_message(library_); - response->set_error_message(error_message); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, 0); } + response->set_status(status); + response->mutable_vi()->set_id(session_id); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -2061,6 +2196,9 @@ namespace nidmm_grpc { auto vi_grpc_session = request->vi(); ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); auto status = library_->Initiate(vi); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -2080,6 +2218,9 @@ namespace nidmm_grpc { auto vi_grpc_session = request->vi(); ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); auto status = library_->InvalidateAllAttributes(vi); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -2101,10 +2242,11 @@ namespace nidmm_grpc { ViReal64 measurement_value = request->measurement_value(); ViBoolean is_over_range {}; auto status = library_->IsOverRange(vi, measurement_value, &is_over_range); - response->set_status(status); - if (status_ok(status)) { - response->set_is_over_range(is_over_range); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_is_over_range(is_over_range); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -2125,10 +2267,11 @@ namespace nidmm_grpc { ViReal64 measurement_value = request->measurement_value(); ViBoolean is_under_range {}; auto status = library_->IsUnderRange(vi, measurement_value, &is_under_range); - response->set_status(status); - if (status_ok(status)) { - response->set_is_under_range(is_under_range); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_is_under_range(is_under_range); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -2149,11 +2292,12 @@ namespace nidmm_grpc { ViReal64 conductance {}; ViReal64 susceptance {}; auto status = library_->PerformOpenCableComp(vi, &conductance, &susceptance); - response->set_status(status); - if (status_ok(status)) { - response->set_conductance(conductance); - response->set_susceptance(susceptance); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_conductance(conductance); + response->set_susceptance(susceptance); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -2174,11 +2318,12 @@ namespace nidmm_grpc { ViReal64 resistance {}; ViReal64 reactance {}; auto status = library_->PerformShortCableComp(vi, &resistance, &reactance); - response->set_status(status); - if (status_ok(status)) { - response->set_resistance(resistance); - response->set_reactance(reactance); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_resistance(resistance); + response->set_reactance(reactance); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -2214,10 +2359,11 @@ namespace nidmm_grpc { ViReal64 reading {}; auto status = library_->Read(vi, maximum_time, &reading); - response->set_status(status); - if (status_ok(status)) { - response->set_reading(reading); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_reading(reading); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -2256,10 +2402,11 @@ namespace nidmm_grpc { ViReal64* reading_array = response->mutable_reading_array()->mutable_data(); ViInt32 actual_number_of_points {}; auto status = library_->ReadMultiPoint(vi, maximum_time, array_size, reading_array, &actual_number_of_points); - response->set_status(status); - if (status_ok(status)) { - response->set_actual_number_of_points(actual_number_of_points); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_actual_number_of_points(actual_number_of_points); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -2280,12 +2427,13 @@ namespace nidmm_grpc { ViInt32 acquisition_backlog {}; ViInt16 acquisition_status {}; auto status = library_->ReadStatus(vi, &acquisition_backlog, &acquisition_status); - response->set_status(status); - if (status_ok(status)) { - response->set_acquisition_backlog(acquisition_backlog); - response->set_acquisition_status(static_cast(acquisition_status)); - response->set_acquisition_status_raw(acquisition_status); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_acquisition_backlog(acquisition_backlog); + response->set_acquisition_status(static_cast(acquisition_status)); + response->set_acquisition_status_raw(acquisition_status); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -2324,10 +2472,11 @@ namespace nidmm_grpc { ViReal64* waveform_array = response->mutable_waveform_array()->mutable_data(); ViInt32 actual_number_of_points {}; auto status = library_->ReadWaveform(vi, maximum_time, array_size, waveform_array, &actual_number_of_points); - response->set_status(status); - if (status_ok(status)) { - response->set_actual_number_of_points(actual_number_of_points); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_actual_number_of_points(actual_number_of_points); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -2346,6 +2495,9 @@ namespace nidmm_grpc { auto vi_grpc_session = request->vi(); ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); auto status = library_->Reset(vi); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -2365,6 +2517,9 @@ namespace nidmm_grpc { auto vi_grpc_session = request->vi(); ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); auto status = library_->ResetInterchangeCheck(vi); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -2384,6 +2539,9 @@ namespace nidmm_grpc { auto vi_grpc_session = request->vi(); ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); auto status = library_->ResetWithDefaults(vi); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -2405,13 +2563,14 @@ namespace nidmm_grpc { std::string instrument_driver_revision(256 - 1, '\0'); std::string firmware_revision(256 - 1, '\0'); auto status = library_->RevisionQuery(vi, (ViChar*)instrument_driver_revision.data(), (ViChar*)firmware_revision.data()); - response->set_status(status); - if (status_ok(status)) { - response->set_instrument_driver_revision(instrument_driver_revision); - nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_instrument_driver_revision())); - response->set_firmware_revision(firmware_revision); - nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_firmware_revision())); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_instrument_driver_revision(instrument_driver_revision); + nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_instrument_driver_revision())); + response->set_firmware_revision(firmware_revision); + nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_firmware_revision())); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -2430,6 +2589,9 @@ namespace nidmm_grpc { auto vi_grpc_session = request->vi(); ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); auto status = library_->SelfCal(vi); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -2451,12 +2613,13 @@ namespace nidmm_grpc { ViInt16 self_test_result {}; std::string self_test_message(256 - 1, '\0'); auto status = library_->SelfTest(vi, &self_test_result, (ViChar*)self_test_message.data()); - response->set_status(status); - if (status_ok(status)) { - response->set_self_test_result(self_test_result); - response->set_self_test_message(self_test_message); - nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_self_test_message())); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_self_test_result(self_test_result); + response->set_self_test_message(self_test_message); + nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_self_test_message())); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -2475,6 +2638,9 @@ namespace nidmm_grpc { auto vi_grpc_session = request->vi(); ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); auto status = library_->SendSoftwareTrigger(vi); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -2497,6 +2663,9 @@ namespace nidmm_grpc { ViAttr attribute_id = request->attribute_id(); ViBoolean attribute_value = request->attribute_value(); auto status = library_->SetAttributeViBoolean(vi, channel_name, attribute_id, attribute_value); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -2534,6 +2703,9 @@ namespace nidmm_grpc { } auto status = library_->SetAttributeViInt32(vi, channel_name, attribute_id, attribute_value); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -2571,6 +2743,9 @@ namespace nidmm_grpc { } auto status = library_->SetAttributeViReal64(vi, channel_name, attribute_id, attribute_value); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -2594,6 +2769,9 @@ namespace nidmm_grpc { auto attribute_value_grpc_session = request->attribute_value(); ViSession attribute_value = session_repository_->access_session(attribute_value_grpc_session.id(), attribute_value_grpc_session.name()); auto status = library_->SetAttributeViSession(vi, channel_name, attribute_id, attribute_value); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -2616,6 +2794,9 @@ namespace nidmm_grpc { ViAttr attribute_id = request->attribute_id(); ViString attribute_value = (ViString)request->attribute_value_raw().c_str(); auto status = library_->SetAttributeViString(vi, channel_name, attribute_id, attribute_value); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } diff --git a/generated/nidmm/nidmm_service.h b/generated/nidmm/nidmm_service.h index 841018fe7..f60997cff 100644 --- a/generated/nidmm/nidmm_service.h +++ b/generated/nidmm/nidmm_service.h @@ -132,6 +132,7 @@ class NiDmmService final : public NiDmm::Service { private: NiDmmLibraryInterface* library_; ResourceRepositorySharedPtr session_repository_; + ::grpc::Status ConvertApiErrorStatusForViSession(google::protobuf::int32 status, ViSession vi); NiDmmFeatureToggles feature_toggles_; }; diff --git a/generated/nifake/nifake_service.cpp b/generated/nifake/nifake_service.cpp index c34cc70fe..2bb49a8f2 100644 --- a/generated/nifake/nifake_service.cpp +++ b/generated/nifake/nifake_service.cpp @@ -65,6 +65,9 @@ namespace nifake_grpc { auto vi_grpc_session = request->vi(); ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); auto status = library_->Abort(vi); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -86,6 +89,9 @@ namespace nifake_grpc { ViInt32 count = static_cast(request->delays().size()); auto delays = const_cast(request->delays().data()); auto status = library_->AcceptListOfDurationsInSeconds(vi, count, delays); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -111,6 +117,9 @@ namespace nifake_grpc { std::back_inserter(session_array), [&](auto session) { return session_repository_->access_session(session.id(), session.name()); }); auto status = library_->AcceptViSessionArray(session_count, session_array.data()); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, 0); + } response->set_status(status); return ::grpc::Status::OK; } @@ -132,6 +141,9 @@ namespace nifake_grpc { ViInt32 array_len = static_cast(request->u_int32_array().size()); auto u_int32_array = const_cast(reinterpret_cast(request->u_int32_array().data())); auto status = library_->AcceptViUInt32Array(vi, array_len, u_int32_array); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -153,10 +165,11 @@ namespace nifake_grpc { ViInt32 number_of_elements = request->number_of_elements(); std::vector an_array(number_of_elements, ViBoolean()); auto status = library_->BoolArrayOutputFunction(vi, number_of_elements, an_array.data()); - response->set_status(status); - if (status_ok(status)) { - convert_to_grpc(an_array, response->mutable_an_array()); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + convert_to_grpc(an_array, response->mutable_an_array()); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -177,6 +190,9 @@ namespace nifake_grpc { ViInt32 number_of_elements = request->number_of_elements(); auto an_array = convert_from_grpc(request->an_array()); auto status = library_->BoolArrayInputFunction(vi, number_of_elements, an_array.data()); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -197,6 +213,9 @@ namespace nifake_grpc { ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); auto reserved = nullptr; auto status = library_->CommandWithReservedParam(vi, reserved); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -216,6 +235,9 @@ namespace nifake_grpc { ViInt32 number_of_list_attributes = static_cast(request->list_attribute_ids().size()); auto list_attribute_ids = const_cast(reinterpret_cast(request->list_attribute_ids().data())); auto status = library_->CreateConfigurationList(number_of_list_attributes, list_attribute_ids); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, 0); + } response->set_status(status); return ::grpc::Status::OK; } @@ -237,6 +259,9 @@ namespace nifake_grpc { ViInt32 number_count = static_cast(request->numbers().size()); auto numbers = const_cast(request->numbers().data()); auto status = library_->DoubleAllTheNums(vi, number_count, numbers); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -287,6 +312,9 @@ namespace nifake_grpc { } auto status = library_->EnumInputFunctionWithDefaults(vi, a_turtle); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -308,9 +336,8 @@ namespace nifake_grpc { while (true) { auto status = library_->ExportAttributeConfigurationBuffer(vi, 0, nullptr); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } ViInt32 size_in_bytes = status; @@ -320,10 +347,11 @@ namespace nifake_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_configuration(configuration); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_configuration(configuration); return ::grpc::Status::OK; } } @@ -347,10 +375,11 @@ namespace nifake_grpc { ViReal64* waveform_data = response->mutable_waveform_data()->mutable_data(); ViInt32 actual_number_of_samples {}; auto status = library_->FetchWaveform(vi, number_of_samples, waveform_data, &actual_number_of_samples); - response->set_status(status); - if (status_ok(status)) { - response->set_actual_number_of_samples(actual_number_of_samples); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_actual_number_of_samples(actual_number_of_samples); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -370,10 +399,11 @@ namespace nifake_grpc { ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); ViBoolean a_boolean {}; auto status = library_->GetABoolean(vi, &a_boolean); - response->set_status(status); - if (status_ok(status)) { - response->set_a_boolean(a_boolean); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_a_boolean(a_boolean); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -393,10 +423,11 @@ namespace nifake_grpc { ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); ViInt16 a_number {}; auto status = library_->GetANumber(vi, &a_number); - response->set_status(status); - if (status_ok(status)) { - response->set_a_number(a_number); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_a_number(a_number); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -416,11 +447,12 @@ namespace nifake_grpc { ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); std::string a_string(256 - 1, '\0'); auto status = library_->GetAStringOfFixedMaximumSize(vi, (ViChar*)a_string.data()); - response->set_status(status); - if (status_ok(status)) { - response->set_a_string(a_string); - nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_a_string())); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_a_string(a_string); + nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_a_string())); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -438,18 +470,19 @@ namespace nifake_grpc { try { ViInt64 flags {}; auto status = library_->GetBitfieldAsEnumArray(&flags); - response->set_status(status); - if (status_ok(status)) { - if (flags & 0x1) - response->add_flags_array(Bitfield::BITFIELD_FLAG_A); - if (flags & 0x2) - response->add_flags_array(Bitfield::BITFIELD_FLAG_B); - if (flags & 0x4) - response->add_flags_array(Bitfield::BITFIELD_FLAG_C); - if (flags & 0x8) - response->add_flags_array(Bitfield::BITFIELD_FLAG_D); - response->set_flags_raw(flags); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, 0); } + response->set_status(status); + if (flags & 0x1) + response->add_flags_array(Bitfield::BITFIELD_FLAG_A); + if (flags & 0x2) + response->add_flags_array(Bitfield::BITFIELD_FLAG_B); + if (flags & 0x4) + response->add_flags_array(Bitfield::BITFIELD_FLAG_C); + if (flags & 0x8) + response->add_flags_array(Bitfield::BITFIELD_FLAG_D); + response->set_flags_raw(flags); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -470,9 +503,8 @@ namespace nifake_grpc { while (true) { auto status = library_->GetAnIviDanceString(vi, 0, nullptr); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } ViInt32 buffer_size = status; @@ -485,11 +517,12 @@ namespace nifake_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_a_string(a_string); - nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_a_string())); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_a_string(a_string); + nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_a_string())); return ::grpc::Status::OK; } } @@ -518,6 +551,9 @@ namespace nifake_grpc { auto array_lengths = const_cast(reinterpret_cast(request->array_lengths().data())); ViInt32 array_size = static_cast(request->array_lengths().size()); auto status = library_->UseATwoDimensionParameter(vi, array, array_lengths, array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -540,9 +576,8 @@ namespace nifake_grpc { ViInt32 actual_size {}; while (true) { auto status = library_->GetAnIviDanceWithATwistArray(vi, a_string, 0, nullptr, &actual_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } response->mutable_array_out()->Resize(actual_size, 0); ViInt32* array_out = reinterpret_cast(response->mutable_array_out()->mutable_data()); @@ -552,11 +587,12 @@ namespace nifake_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->mutable_array_out()->Resize(actual_size, 0); - response->set_actual_size(actual_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->mutable_array_out()->Resize(actual_size, 0); + response->set_actual_size(actual_size); return ::grpc::Status::OK; } } @@ -578,9 +614,8 @@ namespace nifake_grpc { ViInt32 actual_size {}; while (true) { auto status = library_->GetAnIviDanceWithATwistArrayOfCustomType(vi, 0, nullptr, &actual_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } std::vector array_out(actual_size, CustomStruct()); auto buffer_size = actual_size; @@ -589,18 +624,19 @@ namespace nifake_grpc { // buffer is now too small, try again continue; } + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); - if (status_ok(status)) { - convert_to_grpc(array_out, response->mutable_array_out()); - { - auto shrunk_size = actual_size; - auto current_size = response->mutable_array_out()->size(); - if (shrunk_size != current_size) { - response->mutable_array_out()->DeleteSubrange(shrunk_size, current_size - shrunk_size); - } + convert_to_grpc(array_out, response->mutable_array_out()); + { + auto shrunk_size = actual_size; + auto current_size = response->mutable_array_out()->size(); + if (shrunk_size != current_size) { + response->mutable_array_out()->DeleteSubrange(shrunk_size, current_size - shrunk_size); } - response->set_actual_size(actual_size); } + response->set_actual_size(actual_size); return ::grpc::Status::OK; } } @@ -622,9 +658,8 @@ namespace nifake_grpc { ViInt32 actual_size {}; while (true) { auto status = library_->GetAnIviDanceWithATwistArrayWithInputArray(data_in, array_size_in, 0, nullptr, &actual_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, 0); } response->mutable_array_out()->Resize(actual_size, 0); ViInt32* array_out = reinterpret_cast(response->mutable_array_out()->mutable_data()); @@ -634,11 +669,12 @@ namespace nifake_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->mutable_array_out()->Resize(actual_size, 0); - response->set_actual_size(actual_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, 0); } + response->set_status(status); + response->mutable_array_out()->Resize(actual_size, 0); + response->set_actual_size(actual_size); return ::grpc::Status::OK; } } @@ -658,9 +694,8 @@ namespace nifake_grpc { ViInt32 actual_size {}; while (true) { auto status = library_->GetAnIviDanceWithATwistByteArray(0, nullptr, &actual_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, 0); } std::string array_out(actual_size, '\0'); auto buffer_size = actual_size; @@ -669,12 +704,13 @@ namespace nifake_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_array_out(array_out); - response->mutable_array_out()->resize(actual_size); - response->set_actual_size(actual_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, 0); } + response->set_status(status); + response->set_array_out(array_out); + response->mutable_array_out()->resize(actual_size); + response->set_actual_size(actual_size); return ::grpc::Status::OK; } } @@ -694,9 +730,8 @@ namespace nifake_grpc { ViInt32 actual_size {}; while (true) { auto status = library_->GetAnIviDanceWithATwistString(0, nullptr, &actual_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, 0); } std::string array_out; if (actual_size > 0) { @@ -708,12 +743,13 @@ namespace nifake_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_array_out(array_out); - nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_array_out())); - response->set_actual_size(actual_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, 0); } + response->set_status(status); + response->set_array_out(array_out); + nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_array_out())); + response->set_actual_size(actual_size); return ::grpc::Status::OK; } } @@ -733,9 +769,8 @@ namespace nifake_grpc { ViInt32 actual_size {}; while (true) { auto status = library_->GetAnIviDanceWithATwistStringStrlenBug(0, nullptr, &actual_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, 0); } std::string string_out; if (actual_size > 0) { @@ -747,12 +782,13 @@ namespace nifake_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_string_out(string_out); - nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_string_out())); - response->set_actual_size(actual_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, 0); } + response->set_status(status); + response->set_string_out(string_out); + nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_string_out())); + response->set_actual_size(actual_size); return ::grpc::Status::OK; } } @@ -773,10 +809,11 @@ namespace nifake_grpc { ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); ViInt32 size_out {}; auto status = library_->GetArraySizeForCustomCode(vi, &size_out); - response->set_status(status); - if (status_ok(status)) { - response->set_size_out(size_out); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_size_out(size_out); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -797,9 +834,8 @@ namespace nifake_grpc { while (true) { auto status = library_->GetArrayUsingIviDance(vi, 0, nullptr); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } ViInt32 array_size = status; @@ -810,9 +846,10 @@ namespace nifake_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); return ::grpc::Status::OK; } } @@ -834,11 +871,12 @@ namespace nifake_grpc { ViInt32 array_len = request->array_len(); std::string u_int8_enum_array(array_len, '\0'); auto status = library_->GetArrayViUInt8WithEnum(vi, array_len, (ViUInt8*)u_int8_enum_array.data()); - response->set_status(status); - if (status_ok(status)) { - CopyBytesToEnums(u_int8_enum_array, response->mutable_u_int8_enum_array()); - response->set_u_int8_enum_array_raw(u_int8_enum_array); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + CopyBytesToEnums(u_int8_enum_array, response->mutable_u_int8_enum_array()); + response->set_u_int8_enum_array_raw(u_int8_enum_array); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -860,10 +898,11 @@ namespace nifake_grpc { ViAttr attribute_id = request->attribute_id(); ViBoolean attribute_value {}; auto status = library_->GetAttributeViBoolean(vi, channel_name, attribute_id, &attribute_value); - response->set_status(status); - if (status_ok(status)) { - response->set_attribute_value(attribute_value); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_attribute_value(attribute_value); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -885,10 +924,11 @@ namespace nifake_grpc { ViAttr attribute_id = request->attribute_id(); ViInt32 attribute_value {}; auto status = library_->GetAttributeViInt32(vi, channel_name, attribute_id, &attribute_value); - response->set_status(status); - if (status_ok(status)) { - response->set_attribute_value(attribute_value); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_attribute_value(attribute_value); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -910,10 +950,11 @@ namespace nifake_grpc { ViAttr attribute_id = request->attribute_id(); ViInt64 attribute_value {}; auto status = library_->GetAttributeViInt64(vi, channel_name, attribute_id, &attribute_value); - response->set_status(status); - if (status_ok(status)) { - response->set_attribute_value(attribute_value); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_attribute_value(attribute_value); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -935,10 +976,11 @@ namespace nifake_grpc { ViAttr attribute_id = request->attribute_id(); ViReal64 attribute_value {}; auto status = library_->GetAttributeViReal64(vi, channel_name, attribute_id, &attribute_value); - response->set_status(status); - if (status_ok(status)) { - response->set_attribute_value(attribute_value); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_attribute_value(attribute_value); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -959,11 +1001,12 @@ namespace nifake_grpc { ViInt32 attribute_id = request->attribute_id(); ViSession session_out {}; auto status = library_->GetAttributeViSession(vi, attribute_id, &session_out); - response->set_status(status); - if (status_ok(status)) { - auto session_id = session_repository_->resolve_session_id(session_out); - response->mutable_session_out()->set_id(session_id); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + auto session_id = session_repository_->resolve_session_id(session_out); + response->mutable_session_out()->set_id(session_id); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -986,9 +1029,8 @@ namespace nifake_grpc { while (true) { auto status = library_->GetAttributeViString(vi, channel_name, attribute_id, 0, nullptr); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } ViInt32 buffer_size = status; @@ -1001,11 +1043,12 @@ namespace nifake_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_attribute_value(attribute_value); - nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_attribute_value())); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_attribute_value(attribute_value); + nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_attribute_value())); return ::grpc::Status::OK; } } @@ -1031,14 +1074,15 @@ namespace nifake_grpc { ViInt32 hour {}; ViInt32 minute {}; auto status = library_->GetCalDateAndTime(vi, cal_type, &month, &day, &year, &hour, &minute); - response->set_status(status); - if (status_ok(status)) { - response->set_month(month); - response->set_day(day); - response->set_year(year); - response->set_hour(hour); - response->set_minute(minute); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_month(month); + response->set_day(day); + response->set_year(year); + response->set_hour(hour); + response->set_minute(minute); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -1058,10 +1102,11 @@ namespace nifake_grpc { ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); ViInt32 months {}; auto status = library_->GetCalInterval(vi, &months); - response->set_status(status); - if (status_ok(status)) { - response->set_months(months); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_months(months); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -1081,10 +1126,11 @@ namespace nifake_grpc { ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); CustomStruct cs {}; auto status = library_->GetCustomType(vi, &cs); - response->set_status(status); - if (status_ok(status)) { - convert_to_grpc(cs, response->mutable_cs()); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + convert_to_grpc(cs, response->mutable_cs()); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -1105,10 +1151,11 @@ namespace nifake_grpc { ViInt32 number_of_elements = request->number_of_elements(); std::vector cs(number_of_elements, CustomStruct()); auto status = library_->GetCustomTypeArray(vi, number_of_elements, cs.data()); - response->set_status(status); - if (status_ok(status)) { - convert_to_grpc(cs, response->mutable_cs()); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + convert_to_grpc(cs, response->mutable_cs()); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -1129,12 +1176,13 @@ namespace nifake_grpc { ViInt32 a_quantity {}; ViInt16 a_turtle {}; auto status = library_->GetEnumValue(vi, &a_quantity, &a_turtle); - response->set_status(status); - if (status_ok(status)) { - response->set_a_quantity(a_quantity); - response->set_a_turtle(static_cast(a_turtle)); - response->set_a_turtle_raw(a_turtle); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_a_quantity(a_quantity); + response->set_a_turtle(static_cast(a_turtle)); + response->set_a_turtle_raw(a_turtle); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -1154,10 +1202,11 @@ namespace nifake_grpc { ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); ViUInt8 a_uint8_number {}; auto status = library_->GetViUInt8(vi, &a_uint8_number); - response->set_status(status); - if (status_ok(status)) { - response->set_a_uint8_number(a_uint8_number); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_a_uint8_number(a_uint8_number); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -1179,9 +1228,10 @@ namespace nifake_grpc { response->mutable_int32_array()->Resize(array_len, 0); ViInt32* int32_array = reinterpret_cast(response->mutable_int32_array()->mutable_data()); auto status = library_->GetViInt32Array(vi, array_len, int32_array); - response->set_status(status); - if (status_ok(status)) { + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -1203,9 +1253,10 @@ namespace nifake_grpc { response->mutable_u_int32_array()->Resize(array_len, 0); ViUInt32* u_int32_array = reinterpret_cast(response->mutable_u_int32_array()->mutable_data()); auto status = library_->GetViUInt32Array(vi, array_len, u_int32_array); - response->set_status(status); - if (status_ok(status)) { + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -1226,6 +1277,9 @@ namespace nifake_grpc { ViInt32 size_in_bytes = static_cast(request->configuration().size()); ViInt8* configuration = (ViInt8*)request->configuration().c_str(); auto status = library_->ImportAttributeConfigurationBuffer(vi, size_in_bytes, configuration); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1256,10 +1310,11 @@ namespace nifake_grpc { const std::string& grpc_device_session_name = request->session_name(); auto cleanup_lambda = [&] (ViSession id) { library_->close(id); }; int status = session_repository_->add_session(grpc_device_session_name, init_lambda, cleanup_lambda, session_id); - response->set_status(status); - if (status_ok(status)) { - response->mutable_vi()->set_id(session_id); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, 0); } + response->set_status(status); + response->mutable_vi()->set_id(session_id); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -1290,10 +1345,11 @@ namespace nifake_grpc { const std::string& grpc_device_session_name = request->session_name(); auto cleanup_lambda = [&] (ViSession id) { library_->CloseExtCal(id, 0); }; int status = session_repository_->add_session(grpc_device_session_name, init_lambda, cleanup_lambda, session_id); - response->set_status(status); - if (status_ok(status)) { - response->mutable_vi()->set_id(session_id); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, 0); } + response->set_status(status); + response->mutable_vi()->set_id(session_id); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -1343,10 +1399,11 @@ namespace nifake_grpc { const std::string& grpc_device_session_name = request->session_name(); auto cleanup_lambda = [&] (ViSession id) { library_->close(id); }; int status = session_repository_->add_session(grpc_device_session_name, init_lambda, cleanup_lambda, session_id); - response->set_status(status); - if (status_ok(status)) { - response->mutable_vi()->set_id(session_id); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, 0); } + response->set_status(status); + response->mutable_vi()->set_id(session_id); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -1393,9 +1450,10 @@ namespace nifake_grpc { response->mutable_output_array_of_fixed_length()->Resize(3, 0); ViReal64* output_array_of_fixed_length = response->mutable_output_array_of_fixed_length()->mutable_data(); auto status = library_->MultipleArrayTypes(vi, output_array_size, output_array, output_array_of_fixed_length, input_array_sizes, input_array_of_floats, input_array_of_integers.data()); - response->set_status(status); - if (status_ok(status)) { + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -1432,6 +1490,9 @@ namespace nifake_grpc { auto size = size_size_calculation.size; auto status = library_->MultipleArraysSameSize(vi, values1, values2, values3, values4, size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1479,6 +1540,9 @@ namespace nifake_grpc { auto size = size_size_calculation.size; auto status = library_->MultipleArraysSameSizeWithOptional(vi, values1, values2, values3, values4, values5.data(), size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1499,6 +1563,9 @@ namespace nifake_grpc { ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); ViInt32 a_number = request->a_number(); auto status = library_->OneInputFunction(vi, a_number); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1560,6 +1627,9 @@ namespace nifake_grpc { ViInt32 string_size = static_cast(request->a_string().size()); auto a_string = request->a_string().c_str(); auto status = library_->ParametersAreMultipleTypes(vi, a_boolean, an_int32, an_int64, an_int_enum, a_float, a_float_enum, string_size, a_string); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1579,6 +1649,9 @@ namespace nifake_grpc { auto vi_grpc_session = request->vi(); ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); auto status = library_->PoorlyNamedSimpleFunction(vi); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1600,10 +1673,11 @@ namespace nifake_grpc { ViReal64 maximum_time = request->maximum_time(); ViReal64 reading {}; auto status = library_->Read(vi, maximum_time, &reading); - response->set_status(status); - if (status_ok(status)) { - response->set_reading(reading); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_reading(reading); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -1622,9 +1696,8 @@ namespace nifake_grpc { ViInt32 buffer_size {}; while (true) { auto status = library_->ReadDataWithInOutIviTwist(nullptr, &buffer_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, 0); } response->mutable_data()->Resize(buffer_size, 0); ViInt32* data = reinterpret_cast(response->mutable_data()->mutable_data()); @@ -1633,11 +1706,12 @@ namespace nifake_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->mutable_data()->Resize(buffer_size, 0); - response->set_buffer_size(buffer_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, 0); } + response->set_status(status); + response->mutable_data()->Resize(buffer_size, 0); + response->set_buffer_size(buffer_size); return ::grpc::Status::OK; } } @@ -1658,9 +1732,8 @@ namespace nifake_grpc { ViInt32 other_actual_size {}; while (true) { auto status = library_->ReadDataWithMultpleIviTwistParamSets(0, nullptr, &actual_size, 0, nullptr, &other_actual_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, 0); } response->mutable_array_out()->Resize(actual_size, 0); ViInt32* array_out = reinterpret_cast(response->mutable_array_out()->mutable_data()); @@ -1673,13 +1746,14 @@ namespace nifake_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->mutable_array_out()->Resize(actual_size, 0); - response->set_actual_size(actual_size); - response->mutable_other_array_out()->Resize(other_actual_size, 0); - response->set_other_actual_size(other_actual_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, 0); } + response->set_status(status); + response->mutable_array_out()->Resize(actual_size, 0); + response->set_actual_size(actual_size); + response->mutable_other_array_out()->Resize(other_actual_size, 0); + response->set_other_actual_size(other_actual_size); return ::grpc::Status::OK; } } @@ -1702,10 +1776,11 @@ namespace nifake_grpc { ViInt32 maximum_time = request->maximum_time(); ViReal64 reading {}; auto status = library_->ReadFromChannel(vi, channel_name, maximum_time, &reading); - response->set_status(status); - if (status_ok(status)) { - response->set_reading(reading); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_reading(reading); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -1726,12 +1801,13 @@ namespace nifake_grpc { ViInt16 a_number {}; std::string a_string(256 - 1, '\0'); auto status = library_->ReturnANumberAndAString(vi, &a_number, (ViChar*)a_string.data()); - response->set_status(status); - if (status_ok(status)) { - response->set_a_number(a_number); - response->set_a_string(a_string); - nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_a_string())); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_a_number(a_number); + response->set_a_string(a_string); + nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_a_string())); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -1751,10 +1827,11 @@ namespace nifake_grpc { ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); ViReal64 timedelta {}; auto status = library_->ReturnDurationInSeconds(vi, &timedelta); - response->set_status(status); - if (status_ok(status)) { - response->set_timedelta(timedelta); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_timedelta(timedelta); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -1776,9 +1853,10 @@ namespace nifake_grpc { response->mutable_timedeltas()->Resize(number_of_elements, 0); ViReal64* timedeltas = response->mutable_timedeltas()->mutable_data(); auto status = library_->ReturnListOfDurationsInSeconds(vi, number_of_elements, timedeltas); - response->set_status(status); - if (status_ok(status)) { + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -1800,9 +1878,8 @@ namespace nifake_grpc { while (true) { auto status = library_->ReturnMultipleTypes(vi, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, 0, nullptr, 0, nullptr); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } ViInt32 string_size = status; @@ -1823,22 +1900,23 @@ namespace nifake_grpc { // buffer is now too small, try again continue; } + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); - if (status_ok(status)) { - response->set_a_boolean(a_boolean); - response->set_an_int32(an_int32); - response->set_an_int64(an_int64); - response->set_an_int_enum(static_cast(an_int_enum)); - response->set_an_int_enum_raw(an_int_enum); - response->set_a_float(a_float); - auto a_float_enum_omap_it = floatenum_output_map_.find(a_float_enum); - if(a_float_enum_omap_it != floatenum_output_map_.end()) { - response->set_a_float_enum_mapped(static_cast(a_float_enum_omap_it->second)); - } - response->set_a_float_enum_raw(a_float_enum); - response->set_a_string(a_string); - nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_a_string())); + response->set_a_boolean(a_boolean); + response->set_an_int32(an_int32); + response->set_an_int64(an_int64); + response->set_an_int_enum(static_cast(an_int_enum)); + response->set_an_int_enum_raw(an_int_enum); + response->set_a_float(a_float); + auto a_float_enum_omap_it = floatenum_output_map_.find(a_float_enum); + if(a_float_enum_omap_it != floatenum_output_map_.end()) { + response->set_a_float_enum_mapped(static_cast(a_float_enum_omap_it->second)); } + response->set_a_float_enum_raw(a_float_enum); + response->set_a_string(a_string); + nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_a_string())); return ::grpc::Status::OK; } } @@ -1859,6 +1937,9 @@ namespace nifake_grpc { ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); auto cs = convert_from_grpc(request->cs()); auto status = library_->SetCustomType(vi, cs); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1880,6 +1961,9 @@ namespace nifake_grpc { ViInt32 number_of_elements = static_cast(request->cs().size()); auto cs = convert_from_grpc(request->cs()); auto status = library_->SetCustomTypeArray(vi, number_of_elements, cs.data()); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1919,6 +2003,9 @@ namespace nifake_grpc { } auto status = library_->StringValuedEnumInputFunctionWithDefaults(vi, a_mobile_os_name); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1940,6 +2027,9 @@ namespace nifake_grpc { ViReal64 a_number = request->a_number(); ViString a_string = (ViString)request->a_string().c_str(); auto status = library_->TwoInputFunction(vi, a_number, a_string); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1961,10 +2051,11 @@ namespace nifake_grpc { ViInt64 input = request->input(); ViInt64 output {}; auto status = library_->Use64BitNumber(vi, input, &output); - response->set_status(status); - if (status_ok(status)) { - response->set_output(output); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_output(output); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -1985,6 +2076,9 @@ namespace nifake_grpc { ViInt32 number_of_samples = static_cast(request->waveform().size()); auto waveform = const_cast(request->waveform().data()); auto status = library_->WriteWaveform(vi, number_of_samples, waveform); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -2005,6 +2099,9 @@ namespace nifake_grpc { ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); session_repository_->remove_session(vi_grpc_session.id(), vi_grpc_session.name()); auto status = library_->close(vi); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -2026,6 +2123,9 @@ namespace nifake_grpc { ViInt32 action = request->action(); session_repository_->remove_session(vi_grpc_session.id(), vi_grpc_session.name()); auto status = library_->CloseExtCal(vi, action); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -2047,6 +2147,9 @@ namespace nifake_grpc { ViInt32 number_of_elements = request->number_of_elements(); ViUInt8* an_array = (ViUInt8*)request->an_array().c_str(); auto status = library_->ViUInt8ArrayInputFunction(vi, number_of_elements, an_array); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -2068,10 +2171,11 @@ namespace nifake_grpc { ViInt32 number_of_elements = request->number_of_elements(); std::string an_array(number_of_elements, '\0'); auto status = library_->ViUInt8ArrayOutputFunction(vi, number_of_elements, (ViUInt8*)an_array.data()); - response->set_status(status); - if (status_ok(status)) { - response->set_an_array(an_array); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_an_array(an_array); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -2098,6 +2202,9 @@ namespace nifake_grpc { std::back_inserter(an_array), [](auto x) { return (ViInt16)x; }); auto status = library_->ViInt16ArrayInputFunction(vi, number_of_elements, an_array.data()); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } diff --git a/generated/nifake/nifake_service.h b/generated/nifake/nifake_service.h index 25975dffc..7827264a4 100644 --- a/generated/nifake/nifake_service.h +++ b/generated/nifake/nifake_service.h @@ -115,6 +115,7 @@ class NiFakeService final : public NiFake::Service { private: NiFakeLibraryInterface* library_; ResourceRepositorySharedPtr session_repository_; + ::grpc::Status ConvertApiErrorStatusForViSession(google::protobuf::int32 status, ViSession vi); void Copy(const std::vector& input, google::protobuf::RepeatedField* output); template void CopyBytesToEnums(const std::string& input, google::protobuf::RepeatedField* output); diff --git a/generated/nifake_extension/nifake_extension_service.cpp b/generated/nifake_extension/nifake_extension_service.cpp index 3c7692c13..a8e555f2c 100644 --- a/generated/nifake_extension/nifake_extension_service.cpp +++ b/generated/nifake_extension/nifake_extension_service.cpp @@ -53,6 +53,9 @@ namespace nifake_extension_grpc { ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); ViInt32 param = request->param(); auto status = library_->AddCoolFunctionality(vi, param); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } diff --git a/generated/nifake_extension/nifake_extension_service.h b/generated/nifake_extension/nifake_extension_service.h index 56b8da097..42e844625 100644 --- a/generated/nifake_extension/nifake_extension_service.h +++ b/generated/nifake_extension/nifake_extension_service.h @@ -45,6 +45,7 @@ class NiFakeExtensionService final : public NiFakeExtension::Service { private: NiFakeExtensionLibraryInterface* library_; ResourceRepositorySharedPtr session_repository_; + ::grpc::Status ConvertApiErrorStatusForViSession(google::protobuf::int32 status, ViSession vi); NiFakeExtensionFeatureToggles feature_toggles_; }; diff --git a/generated/nifake_non_ivi/nifake_non_ivi_service.cpp b/generated/nifake_non_ivi/nifake_non_ivi_service.cpp index 6fc575c02..a5e375bf8 100644 --- a/generated/nifake_non_ivi/nifake_non_ivi_service.cpp +++ b/generated/nifake_non_ivi/nifake_non_ivi_service.cpp @@ -63,6 +63,9 @@ namespace nifake_non_ivi_grpc { FakeHandle handle = session_repository_->access_session(handle_grpc_session.id(), handle_grpc_session.name()); session_repository_->remove_session(handle_grpc_session.id(), handle_grpc_session.name()); auto status = library_->Close(handle); + if (!status_ok(status)) { + return ConvertApiErrorStatusForFakeHandle(status, handle); + } response->set_status(status); return ::grpc::Status::OK; } @@ -83,6 +86,9 @@ namespace nifake_non_ivi_grpc { SecondarySessionHandle secondary_session_handle = secondary_session_handle_resource_repository_->access_session(secondary_session_handle_grpc_session.id(), secondary_session_handle_grpc_session.name()); secondary_session_handle_resource_repository_->remove_session(secondary_session_handle_grpc_session.id(), secondary_session_handle_grpc_session.name()); auto status = library_->CloseSecondarySession(secondary_session_handle); + if (!status_ok(status)) { + return ConvertApiErrorStatusForSecondarySessionHandle(status, secondary_session_handle); + } response->set_status(status); return ::grpc::Status::OK; } @@ -136,9 +142,8 @@ namespace nifake_non_ivi_grpc { while (true) { auto status = library_->GetLatestErrorMessage(nullptr, 0); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForFakeHandle(status, 0); } uInt32 size = status; @@ -151,11 +156,12 @@ namespace nifake_non_ivi_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_message(message); - nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_message())); + if (!status_ok(status)) { + return ConvertApiErrorStatusForFakeHandle(status, 0); } + response->set_status(status); + response->set_message(message); + nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_message())); return ::grpc::Status::OK; } } @@ -175,11 +181,12 @@ namespace nifake_non_ivi_grpc { std::string buf(512 - 1, '\0'); auto string_out = library_->GetStringAsReturnedValue((char*)buf.data()); auto status = string_out ? 0 : -1; - response->set_status(status); - if (status_ok(status)) { - response->set_string_out(string_out); - nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_string_out())); + if (!status_ok(status)) { + return ConvertApiErrorStatusForFakeHandle(status, 0); } + response->set_status(status); + response->set_string_out(string_out); + nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_string_out())); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -218,10 +225,11 @@ namespace nifake_non_ivi_grpc { double value {}; auto status = library_->GetMarbleAttributeDouble(handle, attribute, &value); - response->set_status(status); - if (status_ok(status)) { - response->set_value(value); + if (!status_ok(status)) { + return ConvertApiErrorStatusForFakeHandle(status, handle); } + response->set_status(status); + response->set_value(value); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -260,16 +268,17 @@ namespace nifake_non_ivi_grpc { int32 value {}; auto status = library_->GetMarbleAttributeInt32(handle, attribute, &value); - response->set_status(status); - if (status_ok(status)) { - auto checked_convert_value = [](auto raw_value) { - bool raw_value_is_valid = nifake_non_ivi_grpc::MarbleInt32AttributeValues_IsValid(raw_value); - auto valid_enum_value = raw_value_is_valid ? raw_value : 0; - return static_cast(valid_enum_value); - }; - response->set_value(checked_convert_value(value)); - response->set_value_raw(value); + if (!status_ok(status)) { + return ConvertApiErrorStatusForFakeHandle(status, handle); } + response->set_status(status); + auto checked_convert_value = [](auto raw_value) { + bool raw_value_is_valid = nifake_non_ivi_grpc::MarbleInt32AttributeValues_IsValid(raw_value); + auto valid_enum_value = raw_value_is_valid ? raw_value : 0; + return static_cast(valid_enum_value); + }; + response->set_value(checked_convert_value(value)); + response->set_value_raw(value); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -309,13 +318,15 @@ namespace nifake_non_ivi_grpc { response->mutable_value_raw()->Resize(10, 0); int32* value = reinterpret_cast(response->mutable_value_raw()->mutable_data()); auto status = library_->GetMarbleAttributeInt32Array(handle, attribute, value); + if (!status_ok(status)) { + return ConvertApiErrorStatusForFakeHandle(status, handle); + } response->set_status(status); - if (status_ok(status)) { - auto checked_convert_value = [](auto raw_value) { - bool raw_value_is_valid = nifake_non_ivi_grpc::MarbleInt32AttributeValues_IsValid(raw_value); - auto valid_enum_value = raw_value_is_valid ? raw_value : 0; - return static_cast(valid_enum_value); - }; + auto checked_convert_value = [](auto raw_value) { + bool raw_value_is_valid = nifake_non_ivi_grpc::MarbleInt32AttributeValues_IsValid(raw_value); + auto valid_enum_value = raw_value_is_valid ? raw_value : 0; + return static_cast(valid_enum_value); + }; response->mutable_value()->Clear(); response->mutable_value()->Reserve(10); std::transform( @@ -325,7 +336,6 @@ namespace nifake_non_ivi_grpc { [&](auto x) { return checked_convert_value(x); }); - } return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -352,14 +362,11 @@ namespace nifake_non_ivi_grpc { const std::string& grpc_device_session_name = request->session_name(); auto cleanup_lambda = [&] (FakeHandle id) { library_->Close(id); }; int status = session_repository_->add_session(grpc_device_session_name, init_lambda, cleanup_lambda, session_id); - response->set_status(status); - if (status_ok(status)) { - response->mutable_handle()->set_id(session_id); - } - else { - const auto error_message = get_last_error(library_); - response->set_error_message(error_message); + if (!status_ok(status)) { + return ConvertApiErrorStatusForFakeHandle(status, 0); } + response->set_status(status); + response->mutable_handle()->set_id(session_id); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -390,10 +397,11 @@ namespace nifake_non_ivi_grpc { const std::string& grpc_device_session_name = request->session_name(); auto cleanup_lambda = [&] (FakeHandle id) { library_->Close(id); }; int status = session_repository_->add_session(grpc_device_session_name, init_lambda, cleanup_lambda, session_id); - response->set_status(status); - if (status_ok(status)) { - response->mutable_handle()->set_id(session_id); + if (!status_ok(status)) { + return ConvertApiErrorStatusForFakeHandle(status, 0); } + response->set_status(status); + response->mutable_handle()->set_id(session_id); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -430,10 +438,11 @@ namespace nifake_non_ivi_grpc { const std::string& grpc_device_session_name = request->session_name(); auto cleanup_lambda = [&] (FakeHandle id) { library_->Close(id); }; int status = session_repository_->add_session(grpc_device_session_name, init_lambda, cleanup_lambda, session_id); - response->set_status(status); - if (status_ok(status)) { - response->mutable_handle()->set_id(session_id); + if (!status_ok(status)) { + return ConvertApiErrorStatusForFakeHandle(status, 0); } + response->set_status(status); + response->mutable_handle()->set_id(session_id); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -462,10 +471,11 @@ namespace nifake_non_ivi_grpc { const std::string& grpc_device_session_name = request->session_name(); auto cleanup_lambda = [&] (SecondarySessionHandle id) { library_->CloseSecondarySession(id); }; int status = secondary_session_handle_resource_repository_->add_session(grpc_device_session_name, init_lambda, cleanup_lambda, session_id); - response->set_status(status); - if (status_ok(status)) { - response->mutable_secondary_session_handle()->set_id(session_id); + if (!status_ok(status)) { + return ConvertApiErrorStatusForFakeHandle(status, 0); } + response->set_status(status); + response->mutable_secondary_session_handle()->set_id(session_id); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -495,10 +505,11 @@ namespace nifake_non_ivi_grpc { const std::string& grpc_device_session_name = request->handle_name(); auto cleanup_lambda = [&] (FakeHandle id) { library_->Close(id); }; int status = session_repository_->add_session(grpc_device_session_name, init_lambda, cleanup_lambda, session_id); - response->set_status(status); - if (status_ok(status)) { - response->mutable_handle()->set_id(session_id); + if (!status_ok(status)) { + return ConvertApiErrorStatusForFakeHandle(status, 0); } + response->set_status(status); + response->mutable_handle()->set_id(session_id); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -528,10 +539,11 @@ namespace nifake_non_ivi_grpc { const std::string& grpc_device_session_name = request->handle_name(); auto cleanup_lambda = [&] (FakeHandle id) { library_->Close(id); }; int status = session_repository_->add_session(grpc_device_session_name, init_lambda, cleanup_lambda, session_id); - response->set_status(status); - if (status_ok(status)) { - response->mutable_handle()->set_id(session_id); + if (!status_ok(status)) { + return ConvertApiErrorStatusForFakeHandle(status, 0); } + response->set_status(status); + response->mutable_handle()->set_id(session_id); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -605,6 +617,9 @@ namespace nifake_non_ivi_grpc { }); auto status = library_->InputArraysWithNarrowIntegerTypes(u16_array.data(), i16_array.data(), i8_array.data()); + if (!status_ok(status)) { + return ConvertApiErrorStatusForFakeHandle(status, 0); + } response->set_status(status); return ::grpc::Status::OK; } @@ -629,9 +644,10 @@ namespace nifake_non_ivi_grpc { response->mutable_data()->Resize((size_one < 0) ? size_two : size_one + 1, 0); int32* data = reinterpret_cast(response->mutable_data()->mutable_data()); auto status = library_->IotaWithCustomSize(size_one, size_two, data); - response->set_status(status); - if (status_ok(status)) { + if (!status_ok(status)) { + return ConvertApiErrorStatusForFakeHandle(status, 0); } + response->set_status(status); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -654,8 +670,10 @@ namespace nifake_non_ivi_grpc { std::vector i16_data(number_of_i16_samples); std::vector i8_data(number_of_i8_samples); auto status = library_->OutputArraysWithNarrowIntegerTypes(number_of_u16_samples, u16_data.data(), number_of_i16_samples, i16_data.data(), number_of_i8_samples, i8_data.data()); + if (!status_ok(status)) { + return ConvertApiErrorStatusForFakeHandle(status, 0); + } response->set_status(status); - if (status_ok(status)) { response->mutable_u16_data()->Clear(); response->mutable_u16_data()->Reserve(number_of_u16_samples); std::transform( @@ -683,7 +701,6 @@ namespace nifake_non_ivi_grpc { [&](auto x) { return x; }); - } return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -701,6 +718,9 @@ namespace nifake_non_ivi_grpc { try { const myUInt8* u8_array = (const myUInt8*)request->u8_array().c_str(); auto status = library_->InputArrayOfBytes(u8_array); + if (!status_ok(status)) { + return ConvertApiErrorStatusForFakeHandle(status, 0); + } response->set_status(status); return ::grpc::Status::OK; } @@ -720,10 +740,11 @@ namespace nifake_non_ivi_grpc { int32 number_of_u8_samples = request->number_of_u8_samples(); std::string u8_data(number_of_u8_samples, '\0'); auto status = library_->OutputArrayOfBytes(number_of_u8_samples, (myUInt8*)u8_data.data()); - response->set_status(status); - if (status_ok(status)) { - response->set_u8_data(u8_data); + if (!status_ok(status)) { + return ConvertApiErrorStatusForFakeHandle(status, 0); } + response->set_status(status); + response->set_u8_data(u8_data); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -744,9 +765,11 @@ namespace nifake_non_ivi_grpc { int32* i32_data = reinterpret_cast(response->mutable_i32_data()->mutable_data()); std::vector u16_data(array_size_copy); auto status = library_->OutputArraysWithPassedInByPtrMechanism(i32_data, u16_data.data(), &array_size_copy); + if (!status_ok(status)) { + return ConvertApiErrorStatusForFakeHandle(status, 0); + } response->set_status(status); - if (status_ok(status)) { - response->mutable_i32_data()->Resize(array_size_copy, 0); + response->mutable_i32_data()->Resize(array_size_copy, 0); response->mutable_u16_data()->Clear(); response->mutable_u16_data()->Reserve(array_size_copy); std::transform( @@ -756,7 +779,6 @@ namespace nifake_non_ivi_grpc { [&](auto x) { return x; }); - } return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -787,7 +809,7 @@ namespace nifake_non_ivi_grpc { [this](myInt16 data_out) { RegisterCallbackResponse callback_response; auto response = &callback_response; - response->set_data_out(data_out); + response->set_data_out(data_out); queue_write(callback_response); return 0; }); @@ -828,6 +850,9 @@ namespace nifake_non_ivi_grpc { try { auto when = convert_from_grpc(request->when()); auto status = library_->InputTimestamp(when); + if (!status_ok(status)) { + return ConvertApiErrorStatusForFakeHandle(status, 0); + } response->set_status(status); return ::grpc::Status::OK; } @@ -846,10 +871,11 @@ namespace nifake_non_ivi_grpc { try { CVIAbsoluteTime when {}; auto status = library_->OutputTimestamp(&when); - response->set_status(status); - if (status_ok(status)) { - convert_to_grpc(when, response->mutable_when()); + if (!status_ok(status)) { + return ConvertApiErrorStatusForFakeHandle(status, 0); } + response->set_status(status); + convert_to_grpc(when, response->mutable_when()); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -893,6 +919,9 @@ namespace nifake_non_ivi_grpc { } auto status = library_->InputVarArgs(input_name, get_channelName_if(string_and_enums, 0), get_color_if(string_and_enums, 0), get_powerUpState_if(string_and_enums, 0), get_channelName_if(string_and_enums, 1), get_color_if(string_and_enums, 1), get_powerUpState_if(string_and_enums, 1), get_channelName_if(string_and_enums, 2), get_color_if(string_and_enums, 2), get_powerUpState_if(string_and_enums, 2), get_channelName_if(string_and_enums, 3), get_color_if(string_and_enums, 3), get_powerUpState_if(string_and_enums, 3)); + if (!status_ok(status)) { + return ConvertApiErrorStatusForFakeHandle(status, 0); + } response->set_status(status); return ::grpc::Status::OK; } @@ -933,11 +962,12 @@ namespace nifake_non_ivi_grpc { std::vector colorVector; colorVector.resize(channel_names.size()); auto status = library_->OutputVarArgs(input_name, get_channelName_if(channel_names, 0), get_color_if(colorVector, 0), get_channelName_if(channel_names, 1), get_color_if(colorVector, 1), get_channelName_if(channel_names, 2), get_color_if(colorVector, 2), get_channelName_if(channel_names, 3), get_color_if(colorVector, 3)); + if (!status_ok(status)) { + return ConvertApiErrorStatusForFakeHandle(status, 0); + } response->set_status(status); - if (status_ok(status)) { - for (int i = 0; i < colorVector.size(); ++i) { - response->add_colors(static_cast(colorVector[i])); - } + for (int i = 0; i < colorVector.size(); ++i) { + response->add_colors(static_cast(colorVector[i])); } return ::grpc::Status::OK; } @@ -976,6 +1006,9 @@ namespace nifake_non_ivi_grpc { } auto status = library_->ResetMarbleAttribute(handle, attribute); + if (!status_ok(status)) { + return ConvertApiErrorStatusForFakeHandle(status, handle); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1023,6 +1056,9 @@ namespace nifake_non_ivi_grpc { auto i8 = static_cast(i8_raw); auto status = library_->ScalarsWithNarrowIntegerTypes(u16, i16, i8); + if (!status_ok(status)) { + return ConvertApiErrorStatusForFakeHandle(status, 0); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1065,6 +1101,9 @@ namespace nifake_non_ivi_grpc { double value = request->value(); auto status = library_->SetMarbleAttributeDouble(handle, attribute, value); + if (!status_ok(status)) { + return ConvertApiErrorStatusForFakeHandle(status, handle); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1119,6 +1158,9 @@ namespace nifake_non_ivi_grpc { } auto status = library_->SetMarbleAttributeInt32(handle, attribute, value); + if (!status_ok(status)) { + return ConvertApiErrorStatusForFakeHandle(status, handle); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1146,6 +1188,9 @@ namespace nifake_non_ivi_grpc { int32 size = request->size(); auto status = library_->SetColors(colors, size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForFakeHandle(status, 0); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1165,10 +1210,11 @@ namespace nifake_non_ivi_grpc { int32 number_of_structs = request->number_of_structs(); std::vector structs(number_of_structs, StructWithCoercion_struct()); auto status = library_->GetStructsWithCoercion(number_of_structs, structs.data()); - response->set_status(status); - if (status_ok(status)) { - convert_to_grpc(structs, response->mutable_structs()); + if (!status_ok(status)) { + return ConvertApiErrorStatusForFakeHandle(status, 0); } + response->set_status(status); + convert_to_grpc(structs, response->mutable_structs()); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -1186,6 +1232,9 @@ namespace nifake_non_ivi_grpc { try { auto structs = convert_from_grpc(request->structs()); auto status = library_->SetStructsWithCoercion(structs.data()); + if (!status_ok(status)) { + return ConvertApiErrorStatusForFakeHandle(status, 0); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1226,6 +1275,9 @@ namespace nifake_non_ivi_grpc { } auto status = library_->InputStringValuedEnum(a_name); + if (!status_ok(status)) { + return ConvertApiErrorStatusForFakeHandle(status, 0); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1245,6 +1297,9 @@ namespace nifake_non_ivi_grpc { auto bools = convert_from_grpc(request->bools()); int32 size = static_cast(request->bools().size()); auto status = library_->WriteBooleanArray(bools.data(), size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForFakeHandle(status, 0); + } response->set_status(status); return ::grpc::Status::OK; } diff --git a/generated/nifake_non_ivi/nifake_non_ivi_service.h b/generated/nifake_non_ivi/nifake_non_ivi_service.h index 2f490d4ac..8b51bbf6e 100644 --- a/generated/nifake_non_ivi/nifake_non_ivi_service.h +++ b/generated/nifake_non_ivi/nifake_non_ivi_service.h @@ -86,6 +86,8 @@ class NiFakeNonIviService final : public NiFakeNonIvi::WithCallbackMethod_ReadSt ResourceRepositorySharedPtr session_repository_; SecondarySessionHandleResourceRepositorySharedPtr secondary_session_handle_resource_repository_; FakeCrossDriverHandleResourceRepositorySharedPtr fake_cross_driver_handle_resource_repository_; + ::grpc::Status ConvertApiErrorStatusForFakeHandle(google::protobuf::int32 status, FakeHandle handle); + ::grpc::Status ConvertApiErrorStatusForSecondarySessionHandle(google::protobuf::int32 status, SecondarySessionHandle handle); std::map mobileosnames_input_map_ { {1, "Android"},{2, "iOS"},{3, "None"}, }; std::map mobileosnames_output_map_ { {"Android", 1},{"iOS", 2},{"None", 3}, }; diff --git a/generated/nifgen/nifgen_service.cpp b/generated/nifgen/nifgen_service.cpp index 9cf79c333..a75dc5fe8 100644 --- a/generated/nifgen/nifgen_service.cpp +++ b/generated/nifgen/nifgen_service.cpp @@ -56,6 +56,9 @@ namespace nifgen_grpc { auto vi_grpc_session = request->vi(); ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); auto status = library_->AbortGeneration(vi); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -76,6 +79,9 @@ namespace nifgen_grpc { ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); ViReal64 adjustment_time = request->adjustment_time(); auto status = library_->AdjustSampleClockRelativeDelay(vi, adjustment_time); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -98,6 +104,9 @@ namespace nifgen_grpc { auto waveform_name = request->waveform_name().c_str(); ViInt32 waveform_size = request->waveform_size(); auto status = library_->AllocateNamedWaveform(vi, channel_name, waveform_name, waveform_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -120,10 +129,11 @@ namespace nifgen_grpc { ViInt32 waveform_size = request->waveform_size(); ViInt32 waveform_handle {}; auto status = library_->AllocateWaveform(vi, channel_name, waveform_size, &waveform_handle); - response->set_status(status); - if (status_ok(status)) { - response->set_waveform_handle(waveform_handle); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_waveform_handle(waveform_handle); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -145,6 +155,9 @@ namespace nifgen_grpc { ViAttr attribute_id = request->attribute_id(); ViBoolean attribute_value = request->attribute_value(); auto status = library_->CheckAttributeViBoolean(vi, channel_name, attribute_id, attribute_value); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -182,6 +195,9 @@ namespace nifgen_grpc { } auto status = library_->CheckAttributeViInt32(vi, channel_name, attribute_id, attribute_value); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -204,6 +220,9 @@ namespace nifgen_grpc { ViAttr attribute_id = request->attribute_id(); ViInt64 attribute_value = request->attribute_value_raw(); auto status = library_->CheckAttributeViInt64(vi, channel_name, attribute_id, attribute_value); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -241,6 +260,9 @@ namespace nifgen_grpc { } auto status = library_->CheckAttributeViReal64(vi, channel_name, attribute_id, attribute_value); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -264,6 +286,9 @@ namespace nifgen_grpc { auto attribute_value_grpc_session = request->attribute_value(); ViSession attribute_value = session_repository_->access_session(attribute_value_grpc_session.id(), attribute_value_grpc_session.name()); auto status = library_->CheckAttributeViSession(vi, channel_name, attribute_id, attribute_value); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -286,6 +311,9 @@ namespace nifgen_grpc { ViAttr attribute_id = request->attribute_id(); auto attribute_value = request->attribute_value_raw().c_str(); auto status = library_->CheckAttributeViString(vi, channel_name, attribute_id, attribute_value); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -305,6 +333,9 @@ namespace nifgen_grpc { auto vi_grpc_session = request->vi(); ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); auto status = library_->ClearArbMemory(vi); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -340,6 +371,9 @@ namespace nifgen_grpc { } auto status = library_->ClearArbSequence(vi, sequence_handle); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -375,6 +409,9 @@ namespace nifgen_grpc { } auto status = library_->ClearArbWaveform(vi, waveform_handle); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -394,6 +431,9 @@ namespace nifgen_grpc { auto vi_grpc_session = request->vi(); ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); auto status = library_->ClearError(vi); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -429,6 +469,9 @@ namespace nifgen_grpc { } auto status = library_->ClearFreqList(vi, frequency_list_handle); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -448,6 +491,9 @@ namespace nifgen_grpc { auto vi_grpc_session = request->vi(); ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); auto status = library_->ClearInterchangeWarnings(vi); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -468,6 +514,9 @@ namespace nifgen_grpc { ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); auto channel_name = request->channel_name().c_str(); auto status = library_->ClearUserStandardWaveform(vi, channel_name); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -488,6 +537,9 @@ namespace nifgen_grpc { ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); session_repository_->remove_session(vi_grpc_session.id(), vi_grpc_session.name()); auto status = library_->Close(vi); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -507,6 +559,9 @@ namespace nifgen_grpc { auto vi_grpc_session = request->vi(); ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); auto status = library_->Commit(vi); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -528,6 +583,9 @@ namespace nifgen_grpc { auto channel_name = request->channel_name().c_str(); ViReal64 amplitude = request->amplitude(); auto status = library_->ConfigureAmplitude(vi, channel_name, amplitude); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -551,6 +609,9 @@ namespace nifgen_grpc { ViReal64 gain = request->gain(); ViReal64 offset = request->offset(); auto status = library_->ConfigureArbSequence(vi, channel_name, sequence_handle, gain, offset); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -574,6 +635,9 @@ namespace nifgen_grpc { ViReal64 gain = request->gain(); ViReal64 offset = request->offset(); auto status = library_->ConfigureArbWaveform(vi, channel_name, waveform_handle, gain, offset); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -594,6 +658,9 @@ namespace nifgen_grpc { ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); auto channels = request->channels().c_str(); auto status = library_->ConfigureChannels(vi, channels); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -629,6 +696,9 @@ namespace nifgen_grpc { } auto status = library_->ConfigureClockMode(vi, clock_mode); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -651,6 +721,9 @@ namespace nifgen_grpc { ViInt32 number_of_coefficients = static_cast(request->coefficients_array().size()); auto coefficients_array = const_cast(request->coefficients_array().data()); auto status = library_->ConfigureCustomFIRFilterCoefficients(vi, channel_name, number_of_coefficients, coefficients_array); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -673,6 +746,9 @@ namespace nifgen_grpc { auto source = request->source().c_str(); ViInt32 edge = request->edge(); auto status = library_->ConfigureDigitalEdgeScriptTrigger(vi, trigger_id, source, edge); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -694,6 +770,9 @@ namespace nifgen_grpc { auto source = request->source().c_str(); ViInt32 edge = request->edge(); auto status = library_->ConfigureDigitalEdgeStartTrigger(vi, source, edge); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -731,6 +810,9 @@ namespace nifgen_grpc { } auto status = library_->ConfigureDigitalLevelScriptTrigger(vi, trigger_id, source, trigger_when); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -755,6 +837,9 @@ namespace nifgen_grpc { ViReal64 dc_offset = request->dc_offset(); ViReal64 start_phase = request->start_phase(); auto status = library_->ConfigureFreqList(vi, channel_name, frequency_list_handle, amplitude, dc_offset, start_phase); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -776,6 +861,9 @@ namespace nifgen_grpc { auto channel_name = request->channel_name().c_str(); ViReal64 frequency = request->frequency(); auto status = library_->ConfigureFrequency(vi, channel_name, frequency); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -797,6 +885,9 @@ namespace nifgen_grpc { auto channel_name = request->channel_name().c_str(); ViInt32 operation_mode = request->operation_mode(); auto status = library_->ConfigureOperationMode(vi, channel_name, operation_mode); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -818,6 +909,9 @@ namespace nifgen_grpc { auto channel_name = request->channel_name().c_str(); ViBoolean enabled = request->enabled(); auto status = library_->ConfigureOutputEnabled(vi, channel_name, enabled); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -839,6 +933,9 @@ namespace nifgen_grpc { auto channel_name = request->channel_name().c_str(); ViReal64 impedance = request->impedance(); auto status = library_->ConfigureOutputImpedance(vi, channel_name, impedance); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -874,6 +971,9 @@ namespace nifgen_grpc { } auto status = library_->ConfigureOutputMode(vi, output_mode); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -894,6 +994,9 @@ namespace nifgen_grpc { ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); ViInt32 p2p_endpoint_fullness_level = request->p2p_endpoint_fullness_level(); auto status = library_->ConfigureP2PEndpointFullnessStartTrigger(vi, p2p_endpoint_fullness_level); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -915,6 +1018,9 @@ namespace nifgen_grpc { auto reference_clock_source = request->reference_clock_source().c_str(); ViReal64 reference_clock_frequency = request->reference_clock_frequency(); auto status = library_->ConfigureReferenceClock(vi, reference_clock_source, reference_clock_frequency); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -935,6 +1041,9 @@ namespace nifgen_grpc { ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); auto sample_clock_source = request->sample_clock_source().c_str(); auto status = library_->ConfigureSampleClockSource(vi, sample_clock_source); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -955,6 +1064,9 @@ namespace nifgen_grpc { ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); ViReal64 sample_rate = request->sample_rate(); auto status = library_->ConfigureSampleRate(vi, sample_rate); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -975,6 +1087,9 @@ namespace nifgen_grpc { ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); auto trigger_id = request->trigger_id().c_str(); auto status = library_->ConfigureSoftwareEdgeScriptTrigger(vi, trigger_id); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -994,6 +1109,9 @@ namespace nifgen_grpc { auto vi_grpc_session = request->vi(); ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); auto status = library_->ConfigureSoftwareEdgeStartTrigger(vi); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1034,6 +1152,9 @@ namespace nifgen_grpc { ViReal64 frequency = request->frequency(); ViReal64 start_phase = request->start_phase(); auto status = library_->ConfigureStandardWaveform(vi, channel_name, waveform, amplitude, dc_offset, frequency, start_phase); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1055,6 +1176,9 @@ namespace nifgen_grpc { auto channel_name = request->channel_name().c_str(); ViInt32 synchronization_source = request->synchronization_source(); auto status = library_->ConfigureSynchronization(vi, channel_name, synchronization_source); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1091,6 +1215,9 @@ namespace nifgen_grpc { } auto status = library_->ConfigureTriggerMode(vi, channel_name, trigger_mode); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1125,10 +1252,11 @@ namespace nifgen_grpc { auto loop_counts_array = const_cast(reinterpret_cast(request->loop_counts_array().data())); ViInt32 sequence_handle {}; auto status = library_->CreateArbSequence(vi, sequence_length, waveform_handles_array, loop_counts_array, &sequence_handle); - response->set_status(status); - if (status_ok(status)) { - response->set_sequence_handle(sequence_handle); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_sequence_handle(sequence_handle); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -1178,10 +1306,11 @@ namespace nifgen_grpc { auto duration_array = const_cast(request->duration_array().data()); ViInt32 frequency_list_handle {}; auto status = library_->CreateFreqList(vi, waveform, frequency_list_length, frequency_array, duration_array, &frequency_list_handle); - response->set_status(status); - if (status_ok(status)) { - response->set_frequency_list_handle(frequency_list_handle); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_frequency_list_handle(frequency_list_handle); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -1204,10 +1333,11 @@ namespace nifgen_grpc { auto waveform_data_array = convert_from_grpc(request->waveform_data_array()); ViInt32 waveform_handle {}; auto status = library_->CreateWaveformComplexF64(vi, channel_name, number_of_samples, waveform_data_array.data(), &waveform_handle); - response->set_status(status); - if (status_ok(status)) { - response->set_waveform_handle(waveform_handle); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_waveform_handle(waveform_handle); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -1230,10 +1360,11 @@ namespace nifgen_grpc { auto waveform_data_array = const_cast(request->waveform_data_array().data()); ViInt32 waveform_handle {}; auto status = library_->CreateWaveformF64(vi, channel_name, waveform_size, waveform_data_array, &waveform_handle); - response->set_status(status); - if (status_ok(status)) { - response->set_waveform_handle(waveform_handle); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_waveform_handle(waveform_handle); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -1271,10 +1402,11 @@ namespace nifgen_grpc { ViInt32 waveform_handle {}; auto status = library_->CreateWaveformFromFileF64(vi, channel_name, file_name, byte_order, &waveform_handle); - response->set_status(status); - if (status_ok(status)) { - response->set_waveform_handle(waveform_handle); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_waveform_handle(waveform_handle); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -1298,10 +1430,11 @@ namespace nifgen_grpc { ViBoolean use_gain_and_offset_from_waveform = request->use_gain_and_offset_from_waveform(); ViInt32 waveform_handle {}; auto status = library_->CreateWaveformFromFileHWS(vi, channel_name, file_name, use_rate_from_waveform, use_gain_and_offset_from_waveform, &waveform_handle); - response->set_status(status); - if (status_ok(status)) { - response->set_waveform_handle(waveform_handle); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_waveform_handle(waveform_handle); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -1330,10 +1463,11 @@ namespace nifgen_grpc { [](auto x) { return (ViInt16)x; }); ViInt32 waveform_handle {}; auto status = library_->CreateWaveformI16(vi, channel_name, waveform_size, waveform_data_array.data(), &waveform_handle); - response->set_status(status); - if (status_ok(status)) { - response->set_waveform_handle(waveform_handle); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_waveform_handle(waveform_handle); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -1371,10 +1505,11 @@ namespace nifgen_grpc { ViInt32 waveform_handle {}; auto status = library_->CreateWaveformFromFileI16(vi, channel_name, file_name, byte_order, &waveform_handle); - response->set_status(status); - if (status_ok(status)) { - response->set_waveform_handle(waveform_handle); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_waveform_handle(waveform_handle); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -1396,6 +1531,9 @@ namespace nifgen_grpc { ViInt32 waveform_size = static_cast(request->waveform_data_array().size()); auto waveform_data_array = const_cast(request->waveform_data_array().data()); auto status = library_->DefineUserStandardWaveform(vi, channel_name, waveform_size, waveform_data_array); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1417,6 +1555,9 @@ namespace nifgen_grpc { auto channel_name = request->channel_name().c_str(); auto waveform_name = request->waveform_name().c_str(); auto status = library_->DeleteNamedWaveform(vi, channel_name, waveform_name); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1438,6 +1579,9 @@ namespace nifgen_grpc { auto channel_name = request->channel_name().c_str(); auto script_name = request->script_name().c_str(); auto status = library_->DeleteScript(vi, channel_name, script_name); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1457,6 +1601,9 @@ namespace nifgen_grpc { auto vi_grpc_session = request->vi(); ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); auto status = library_->Disable(vi); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1477,6 +1624,9 @@ namespace nifgen_grpc { ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); auto channel_name = request->channel_name().c_str(); auto status = library_->DisableAnalogFilter(vi, channel_name); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1497,6 +1647,9 @@ namespace nifgen_grpc { ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); auto channel_name = request->channel_name().c_str(); auto status = library_->DisableDigitalFilter(vi, channel_name); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1517,6 +1670,9 @@ namespace nifgen_grpc { ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); auto channel_name = request->channel_name().c_str(); auto status = library_->DisableDigitalPatterning(vi, channel_name); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1537,6 +1693,9 @@ namespace nifgen_grpc { ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); auto trigger_id = request->trigger_id().c_str(); auto status = library_->DisableScriptTrigger(vi, trigger_id); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1556,6 +1715,9 @@ namespace nifgen_grpc { auto vi_grpc_session = request->vi(); ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); auto status = library_->DisableStartTrigger(vi); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1577,6 +1739,9 @@ namespace nifgen_grpc { auto channel_name = request->channel_name().c_str(); ViReal64 filter_correction_frequency = request->filter_correction_frequency(); auto status = library_->EnableAnalogFilter(vi, channel_name, filter_correction_frequency); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1597,6 +1762,9 @@ namespace nifgen_grpc { ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); auto channel_name = request->channel_name().c_str(); auto status = library_->EnableDigitalFilter(vi, channel_name); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1617,6 +1785,9 @@ namespace nifgen_grpc { ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); auto channel_name = request->channel_name().c_str(); auto status = library_->EnableDigitalPatterning(vi, channel_name); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1638,11 +1809,12 @@ namespace nifgen_grpc { ViStatus error_code = request->error_code(); std::string error_message(256 - 1, '\0'); auto status = library_->ErrorHandler(vi, error_code, (ViChar*)error_message.data()); - response->set_status(status); - if (status_ok(status)) { - response->set_error_message(error_message); - nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_error_message())); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_error_message(error_message); + nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_error_message())); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -1663,11 +1835,12 @@ namespace nifgen_grpc { ViStatus error_code = request->error_code(); std::string error_message(256 - 1, '\0'); auto status = library_->ErrorMessage(vi, error_code, (ViChar*)error_message.data()); - response->set_status(status); - if (status_ok(status)) { - response->set_error_message(error_message); - nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_error_message())); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_error_message(error_message); + nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_error_message())); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -1688,12 +1861,13 @@ namespace nifgen_grpc { ViInt32 error_code {}; std::string error_message(256 - 1, '\0'); auto status = library_->ErrorQuery(vi, &error_code, (ViChar*)error_message.data()); - response->set_status(status); - if (status_ok(status)) { - response->set_error_code(error_code); - response->set_error_message(error_message); - nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_error_message())); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_error_code(error_code); + response->set_error_message(error_message); + nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_error_message())); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -1714,9 +1888,8 @@ namespace nifgen_grpc { while (true) { auto status = library_->ExportAttributeConfigurationBuffer(vi, 0, nullptr); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } ViInt32 size_in_bytes = status; @@ -1727,9 +1900,10 @@ namespace nifgen_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); return ::grpc::Status::OK; } } @@ -1750,6 +1924,9 @@ namespace nifgen_grpc { ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); auto file_path = request->file_path().c_str(); auto status = library_->ExportAttributeConfigurationFile(vi, file_path); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1787,6 +1964,9 @@ namespace nifgen_grpc { auto signal_identifier = request->signal_identifier().c_str(); auto output_terminal = request->output_terminal().c_str(); auto status = library_->ExportSignal(vi, signal, signal_identifier, output_terminal); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1809,10 +1989,11 @@ namespace nifgen_grpc { ViAttr attribute_id = request->attribute_id(); ViBoolean attribute_value {}; auto status = library_->GetAttributeViBoolean(vi, channel_name, attribute_id, &attribute_value); - response->set_status(status); - if (status_ok(status)) { - response->set_attribute_value(attribute_value); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_attribute_value(attribute_value); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -1834,10 +2015,11 @@ namespace nifgen_grpc { ViAttr attribute_id = request->attribute_id(); ViInt32 attribute_value {}; auto status = library_->GetAttributeViInt32(vi, channel_name, attribute_id, &attribute_value); - response->set_status(status); - if (status_ok(status)) { - response->set_attribute_value(attribute_value); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_attribute_value(attribute_value); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -1859,10 +2041,11 @@ namespace nifgen_grpc { ViAttr attribute_id = request->attribute_id(); ViInt64 attribute_value {}; auto status = library_->GetAttributeViInt64(vi, channel_name, attribute_id, &attribute_value); - response->set_status(status); - if (status_ok(status)) { - response->set_attribute_value(attribute_value); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_attribute_value(attribute_value); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -1884,10 +2067,11 @@ namespace nifgen_grpc { ViAttr attribute_id = request->attribute_id(); ViReal64 attribute_value {}; auto status = library_->GetAttributeViReal64(vi, channel_name, attribute_id, &attribute_value); - response->set_status(status); - if (status_ok(status)) { - response->set_attribute_value(attribute_value); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_attribute_value(attribute_value); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -1909,11 +2093,12 @@ namespace nifgen_grpc { ViAttr attribute_id = request->attribute_id(); ViSession attribute_value {}; auto status = library_->GetAttributeViSession(vi, channel_name, attribute_id, &attribute_value); - response->set_status(status); - if (status_ok(status)) { - auto session_id = session_repository_->resolve_session_id(attribute_value); - response->mutable_attribute_value()->set_id(session_id); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + auto session_id = session_repository_->resolve_session_id(attribute_value); + response->mutable_attribute_value()->set_id(session_id); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -1936,9 +2121,8 @@ namespace nifgen_grpc { while (true) { auto status = library_->GetAttributeViString(vi, channel_name, attribute_id, 0, nullptr); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } ViInt32 array_size = status; @@ -1951,11 +2135,12 @@ namespace nifgen_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_attribute_value(attribute_value); - nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_attribute_value())); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_attribute_value(attribute_value); + nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_attribute_value())); return ::grpc::Status::OK; } } @@ -1978,9 +2163,8 @@ namespace nifgen_grpc { while (true) { auto status = library_->GetChannelName(vi, index, 0, nullptr); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } ViInt32 buffer_size = status; @@ -1993,11 +2177,12 @@ namespace nifgen_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_channel_string(channel_string); - nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_channel_string())); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_channel_string(channel_string); + nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_channel_string())); return ::grpc::Status::OK; } } @@ -2019,9 +2204,8 @@ namespace nifgen_grpc { while (true) { auto status = library_->GetError(vi, nullptr, 0, nullptr); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } ViInt32 error_description_buffer_size = status; @@ -2035,12 +2219,13 @@ namespace nifgen_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_error_code(error_code); - response->set_error_description(error_description); - nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_error_description())); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_error_code(error_code); + response->set_error_description(error_description); + nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_error_description())); return ::grpc::Status::OK; } } @@ -2065,14 +2250,15 @@ namespace nifgen_grpc { ViInt32 hour {}; ViInt32 minute {}; auto status = library_->GetExtCalLastDateAndTime(vi, &year, &month, &day, &hour, &minute); - response->set_status(status); - if (status_ok(status)) { - response->set_year(year); - response->set_month(month); - response->set_day(day); - response->set_hour(hour); - response->set_minute(minute); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_year(year); + response->set_month(month); + response->set_day(day); + response->set_hour(hour); + response->set_minute(minute); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -2092,10 +2278,11 @@ namespace nifgen_grpc { ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); ViReal64 temperature {}; auto status = library_->GetExtCalLastTemp(vi, &temperature); - response->set_status(status); - if (status_ok(status)) { - response->set_temperature(temperature); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_temperature(temperature); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -2115,10 +2302,11 @@ namespace nifgen_grpc { ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); ViInt32 months {}; auto status = library_->GetExtCalRecommendedInterval(vi, &months); - response->set_status(status); - if (status_ok(status)) { - response->set_months(months); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_months(months); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -2140,9 +2328,8 @@ namespace nifgen_grpc { ViInt32 number_of_coefficients_read {}; while (true) { auto status = library_->GetFIRFilterCoefficients(vi, channel_name, 0, nullptr, &number_of_coefficients_read); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } response->mutable_coefficients_array()->Resize(number_of_coefficients_read, 0); ViReal64* coefficients_array = response->mutable_coefficients_array()->mutable_data(); @@ -2152,11 +2339,12 @@ namespace nifgen_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->mutable_coefficients_array()->Resize(number_of_coefficients_read, 0); - response->set_number_of_coefficients_read(number_of_coefficients_read); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->mutable_coefficients_array()->Resize(number_of_coefficients_read, 0); + response->set_number_of_coefficients_read(number_of_coefficients_read); return ::grpc::Status::OK; } } @@ -2177,11 +2365,12 @@ namespace nifgen_grpc { ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); ViInt32 state {}; auto status = library_->GetHardwareState(vi, &state); - response->set_status(status); - if (status_ok(status)) { - response->set_state(static_cast(state)); - response->set_state_raw(state); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_state(static_cast(state)); + response->set_state_raw(state); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -2202,9 +2391,8 @@ namespace nifgen_grpc { while (true) { auto status = library_->GetNextCoercionRecord(vi, 0, nullptr); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } ViInt32 buffer_size = status; @@ -2217,11 +2405,12 @@ namespace nifgen_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_coercion_record(coercion_record); - nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_coercion_record())); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_coercion_record(coercion_record); + nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_coercion_record())); return ::grpc::Status::OK; } } @@ -2243,9 +2432,8 @@ namespace nifgen_grpc { while (true) { auto status = library_->GetNextInterchangeWarning(vi, 0, nullptr); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } ViInt32 buffer_size = status; @@ -2258,11 +2446,12 @@ namespace nifgen_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_interchange_warning(interchange_warning); - nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_interchange_warning())); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_interchange_warning(interchange_warning); + nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_interchange_warning())); return ::grpc::Status::OK; } } @@ -2287,14 +2476,15 @@ namespace nifgen_grpc { ViInt32 hour {}; ViInt32 minute {}; auto status = library_->GetSelfCalLastDateAndTime(vi, &year, &month, &day, &hour, &minute); - response->set_status(status); - if (status_ok(status)) { - response->set_year(year); - response->set_month(month); - response->set_day(day); - response->set_hour(hour); - response->set_minute(minute); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_year(year); + response->set_month(month); + response->set_day(day); + response->set_hour(hour); + response->set_minute(minute); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -2314,10 +2504,11 @@ namespace nifgen_grpc { ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); ViReal64 temperature {}; auto status = library_->GetSelfCalLastTemp(vi, &temperature); - response->set_status(status); - if (status_ok(status)) { - response->set_temperature(temperature); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_temperature(temperature); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -2337,10 +2528,11 @@ namespace nifgen_grpc { ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); ViBoolean self_cal_supported {}; auto status = library_->GetSelfCalSupported(vi, &self_cal_supported); - response->set_status(status); - if (status_ok(status)) { - response->set_self_cal_supported(self_cal_supported); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_self_cal_supported(self_cal_supported); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -2361,10 +2553,11 @@ namespace nifgen_grpc { auto stream_endpoint = request->stream_endpoint().c_str(); ViUInt32 reader_handle {}; auto status = library_->GetStreamEndpointHandle(vi, stream_endpoint, &reader_handle); - response->set_status(status); - if (status_ok(status)) { - response->set_reader_handle(reader_handle); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_reader_handle(reader_handle); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -2385,6 +2578,9 @@ namespace nifgen_grpc { ViInt32 size_in_bytes = static_cast(request->configuration().size()); auto configuration = const_cast(reinterpret_cast(request->configuration().data())); auto status = library_->ImportAttributeConfigurationBuffer(vi, size_in_bytes, configuration); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -2405,6 +2601,9 @@ namespace nifgen_grpc { ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); auto file_path = request->file_path().c_str(); auto status = library_->ImportAttributeConfigurationFile(vi, file_path); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -2434,14 +2633,11 @@ namespace nifgen_grpc { const std::string& grpc_device_session_name = request->session_name(); auto cleanup_lambda = [&] (ViSession id) { library_->Close(id); }; int status = session_repository_->add_session(grpc_device_session_name, init_lambda, cleanup_lambda, session_id); - response->set_status(status); - if (status_ok(status)) { - response->mutable_vi()->set_id(session_id); - } - else { - const auto error_message = get_last_error_message(library_); - response->set_error_message(error_message); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, 0); } + response->set_status(status); + response->mutable_vi()->set_id(session_id); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -2474,14 +2670,11 @@ namespace nifgen_grpc { const std::string& grpc_device_session_name = request->session_name(); auto cleanup_lambda = [&] (ViSession id) { library_->Close(id); }; int status = session_repository_->add_session(grpc_device_session_name, init_lambda, cleanup_lambda, session_id); - response->set_status(status); - if (status_ok(status)) { - response->mutable_vi()->set_id(session_id); - } - else { - const auto error_message = get_last_error_message(library_); - response->set_error_message(error_message); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, 0); } + response->set_status(status); + response->mutable_vi()->set_id(session_id); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -2514,14 +2707,11 @@ namespace nifgen_grpc { const std::string& grpc_device_session_name = request->session_name(); auto cleanup_lambda = [&] (ViSession id) { library_->Close(id); }; int status = session_repository_->add_session(grpc_device_session_name, init_lambda, cleanup_lambda, session_id); - response->set_status(status); - if (status_ok(status)) { - response->mutable_vi()->set_id(session_id); - } - else { - const auto error_message = get_last_error_message(library_); - response->set_error_message(error_message); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, 0); } + response->set_status(status); + response->mutable_vi()->set_id(session_id); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -2543,6 +2733,9 @@ namespace nifgen_grpc { auto vi_grpc_session = request->vi(); ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); auto status = library_->InitiateGeneration(vi); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -2562,6 +2755,9 @@ namespace nifgen_grpc { auto vi_grpc_session = request->vi(); ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); auto status = library_->InvalidateAllAttributes(vi); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -2582,10 +2778,11 @@ namespace nifgen_grpc { ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); ViBoolean done {}; auto status = library_->IsDone(vi, &done); - response->set_status(status); - if (status_ok(status)) { - response->set_done(done); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_done(done); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -2605,6 +2802,9 @@ namespace nifgen_grpc { ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); auto endpoint_name = request->endpoint_name().c_str(); auto status = library_->ManualEnableP2PStream(vi, endpoint_name); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -2628,13 +2828,14 @@ namespace nifgen_grpc { ViInt32 maximum_sequence_length {}; ViInt32 maximum_loop_count {}; auto status = library_->QueryArbSeqCapabilities(vi, &maximum_number_of_sequences, &minimum_sequence_length, &maximum_sequence_length, &maximum_loop_count); - response->set_status(status); - if (status_ok(status)) { - response->set_maximum_number_of_sequences(maximum_number_of_sequences); - response->set_minimum_sequence_length(minimum_sequence_length); - response->set_maximum_sequence_length(maximum_sequence_length); - response->set_maximum_loop_count(maximum_loop_count); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_maximum_number_of_sequences(maximum_number_of_sequences); + response->set_minimum_sequence_length(minimum_sequence_length); + response->set_maximum_sequence_length(maximum_sequence_length); + response->set_maximum_loop_count(maximum_loop_count); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -2657,13 +2858,14 @@ namespace nifgen_grpc { ViInt32 minimum_waveform_size {}; ViInt32 maximum_waveform_size {}; auto status = library_->QueryArbWfmCapabilities(vi, &maximum_number_of_waveforms, &waveform_quantum, &minimum_waveform_size, &maximum_waveform_size); - response->set_status(status); - if (status_ok(status)) { - response->set_maximum_number_of_waveforms(maximum_number_of_waveforms); - response->set_waveform_quantum(waveform_quantum); - response->set_minimum_waveform_size(minimum_waveform_size); - response->set_maximum_waveform_size(maximum_waveform_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_maximum_number_of_waveforms(maximum_number_of_waveforms); + response->set_waveform_quantum(waveform_quantum); + response->set_minimum_waveform_size(minimum_waveform_size); + response->set_maximum_waveform_size(maximum_waveform_size); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -2688,15 +2890,16 @@ namespace nifgen_grpc { ViReal64 maximum_frequency_list_duration {}; ViReal64 frequency_list_duration_quantum {}; auto status = library_->QueryFreqListCapabilities(vi, &maximum_number_of_freq_lists, &minimum_frequency_list_length, &maximum_frequency_list_length, &minimum_frequency_list_duration, &maximum_frequency_list_duration, &frequency_list_duration_quantum); - response->set_status(status); - if (status_ok(status)) { - response->set_maximum_number_of_freq_lists(maximum_number_of_freq_lists); - response->set_minimum_frequency_list_length(minimum_frequency_list_length); - response->set_maximum_frequency_list_length(maximum_frequency_list_length); - response->set_minimum_frequency_list_duration(minimum_frequency_list_duration); - response->set_maximum_frequency_list_duration(maximum_frequency_list_duration); - response->set_frequency_list_duration_quantum(frequency_list_duration_quantum); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_maximum_number_of_freq_lists(maximum_number_of_freq_lists); + response->set_minimum_frequency_list_length(minimum_frequency_list_length); + response->set_maximum_frequency_list_length(maximum_frequency_list_length); + response->set_minimum_frequency_list_duration(minimum_frequency_list_duration); + response->set_maximum_frequency_list_duration(maximum_frequency_list_duration); + response->set_frequency_list_duration_quantum(frequency_list_duration_quantum); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -2716,10 +2919,11 @@ namespace nifgen_grpc { ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); ViReal64 temperature {}; auto status = library_->ReadCurrentTemperature(vi, &temperature); - response->set_status(status); - if (status_ok(status)) { - response->set_temperature(temperature); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_temperature(temperature); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -2738,6 +2942,9 @@ namespace nifgen_grpc { auto vi_grpc_session = request->vi(); ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); auto status = library_->Reset(vi); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -2759,6 +2966,9 @@ namespace nifgen_grpc { auto channel_name = request->channel_name().c_str(); ViAttr attribute_id = request->attribute_id(); auto status = library_->ResetAttribute(vi, channel_name, attribute_id); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -2778,6 +2988,9 @@ namespace nifgen_grpc { auto vi_grpc_session = request->vi(); ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); auto status = library_->ResetDevice(vi); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -2797,6 +3010,9 @@ namespace nifgen_grpc { auto vi_grpc_session = request->vi(); ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); auto status = library_->ResetInterchangeCheck(vi); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -2816,6 +3032,9 @@ namespace nifgen_grpc { auto vi_grpc_session = request->vi(); ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); auto status = library_->ResetWithDefaults(vi); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -2837,13 +3056,14 @@ namespace nifgen_grpc { std::string instrument_driver_revision(256 - 1, '\0'); std::string firmware_revision(256 - 1, '\0'); auto status = library_->RevisionQuery(vi, (ViChar*)instrument_driver_revision.data(), (ViChar*)firmware_revision.data()); - response->set_status(status); - if (status_ok(status)) { - response->set_instrument_driver_revision(instrument_driver_revision); - nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_instrument_driver_revision())); - response->set_firmware_revision(firmware_revision); - nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_firmware_revision())); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_instrument_driver_revision(instrument_driver_revision); + nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_instrument_driver_revision())); + response->set_firmware_revision(firmware_revision); + nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_firmware_revision())); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -2895,6 +3115,9 @@ namespace nifgen_grpc { } auto status = library_->RouteSignalOut(vi, channel_name, route_signal_from, route_signal_to); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -2914,6 +3137,9 @@ namespace nifgen_grpc { auto vi_grpc_session = request->vi(); ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); auto status = library_->SelfCal(vi); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -2935,12 +3161,13 @@ namespace nifgen_grpc { ViInt16 self_test_result {}; std::string self_test_message(256 - 1, '\0'); auto status = library_->SelfTest(vi, &self_test_result, (ViChar*)self_test_message.data()); - response->set_status(status); - if (status_ok(status)) { - response->set_self_test_result(self_test_result); - response->set_self_test_message(self_test_message); - nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_self_test_message())); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_self_test_result(self_test_result); + response->set_self_test_message(self_test_message); + nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_self_test_message())); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -2976,6 +3203,9 @@ namespace nifgen_grpc { ViString trigger_id = (ViString)request->trigger_id().c_str(); auto status = library_->SendSoftwareEdgeTrigger(vi, trigger, trigger_id); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -2998,6 +3228,9 @@ namespace nifgen_grpc { ViAttr attribute_id = request->attribute_id(); ViBoolean attribute_value = request->attribute_value(); auto status = library_->SetAttributeViBoolean(vi, channel_name, attribute_id, attribute_value); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -3035,6 +3268,9 @@ namespace nifgen_grpc { } auto status = library_->SetAttributeViInt32(vi, channel_name, attribute_id, attribute_value); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -3057,6 +3293,9 @@ namespace nifgen_grpc { ViAttr attribute_id = request->attribute_id(); ViInt64 attribute_value = request->attribute_value_raw(); auto status = library_->SetAttributeViInt64(vi, channel_name, attribute_id, attribute_value); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -3094,6 +3333,9 @@ namespace nifgen_grpc { } auto status = library_->SetAttributeViReal64(vi, channel_name, attribute_id, attribute_value); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -3117,6 +3359,9 @@ namespace nifgen_grpc { auto attribute_value_grpc_session = request->attribute_value(); ViSession attribute_value = session_repository_->access_session(attribute_value_grpc_session.id(), attribute_value_grpc_session.name()); auto status = library_->SetAttributeViSession(vi, channel_name, attribute_id, attribute_value); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -3139,6 +3384,9 @@ namespace nifgen_grpc { ViAttr attribute_id = request->attribute_id(); auto attribute_value = request->attribute_value_raw().c_str(); auto status = library_->SetAttributeViString(vi, channel_name, attribute_id, attribute_value); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -3177,6 +3425,9 @@ namespace nifgen_grpc { ViInt32 offset = request->offset(); auto status = library_->SetNamedWaveformNextWritePosition(vi, channel_name, waveform_name, relative_to, offset); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -3215,6 +3466,9 @@ namespace nifgen_grpc { ViInt32 offset = request->offset(); auto status = library_->SetWaveformNextWritePosition(vi, channel_name, waveform_handle, relative_to, offset); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -3235,6 +3489,9 @@ namespace nifgen_grpc { ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); ViInt32 max_time = request->max_time(); auto status = library_->WaitUntilDone(vi, max_time); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -3264,6 +3521,9 @@ namespace nifgen_grpc { std::back_inserter(data), [](auto x) { return (ViInt16)x; }); auto status = library_->WriteBinary16Waveform(vi, channel_name, waveform_handle, size, data.data()); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -3287,6 +3547,9 @@ namespace nifgen_grpc { ViInt32 size = static_cast(request->data().size()); auto data = convert_from_grpc(request->data()); auto status = library_->WriteComplexBinary16Waveform(vi, channel_name, waveform_handle, size, data.data()); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -3310,6 +3573,9 @@ namespace nifgen_grpc { ViInt32 size = static_cast(request->data().size()); auto data = const_cast(request->data().data()); auto status = library_->WriteNamedWaveformF64(vi, channel_name, waveform_name, size, data); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -3339,6 +3605,9 @@ namespace nifgen_grpc { std::back_inserter(data), [](auto x) { return (ViInt16)x; }); auto status = library_->WriteNamedWaveformI16(vi, channel_name, waveform_name, size, data.data()); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -3367,6 +3636,9 @@ namespace nifgen_grpc { std::back_inserter(endpoint_data), [](auto x) { return (ViInt16)x; }); auto status = library_->WriteP2PEndpointI16(vi, endpoint_name, number_of_samples, endpoint_data.data()); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -3388,6 +3660,9 @@ namespace nifgen_grpc { auto channel_name = request->channel_name().c_str(); auto script = request->script().c_str(); auto status = library_->WriteScript(vi, channel_name, script); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -3411,6 +3686,9 @@ namespace nifgen_grpc { ViInt32 size = static_cast(request->data().size()); auto data = const_cast(request->data().data()); auto status = library_->WriteWaveform(vi, channel_name, waveform_handle, size, data); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -3434,6 +3712,9 @@ namespace nifgen_grpc { auto data = convert_from_grpc(request->data()); ViInt32 waveform_handle = request->waveform_handle(); auto status = library_->WriteWaveformComplexF64(vi, channel_name, number_of_samples, data.data(), waveform_handle); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -3457,6 +3738,9 @@ namespace nifgen_grpc { ViInt32 size = static_cast(request->data().size()); auto data = convert_from_grpc(request->data()); auto status = library_->WriteNamedWaveformComplexF64(vi, channel_name, waveform_name, size, data.data()); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -3480,6 +3764,9 @@ namespace nifgen_grpc { ViInt32 size = static_cast(request->data().size()); auto data = convert_from_grpc(request->data()); auto status = library_->WriteNamedWaveformComplexI16(vi, channel_name, waveform_name, size, data.data()); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } diff --git a/generated/nifgen/nifgen_service.h b/generated/nifgen/nifgen_service.h index aaea23d94..e063f7d14 100644 --- a/generated/nifgen/nifgen_service.h +++ b/generated/nifgen/nifgen_service.h @@ -175,6 +175,7 @@ class NiFgenService final : public NiFgen::Service { private: NiFgenLibraryInterface* library_; ResourceRepositorySharedPtr session_repository_; + ::grpc::Status ConvertApiErrorStatusForViSession(google::protobuf::int32 status, ViSession vi); NiFgenFeatureToggles feature_toggles_; }; diff --git a/generated/nirfmxbluetooth/nirfmxbluetooth_service.cpp b/generated/nirfmxbluetooth/nirfmxbluetooth_service.cpp index 83544292b..87a7f6ad2 100644 --- a/generated/nirfmxbluetooth/nirfmxbluetooth_service.cpp +++ b/generated/nirfmxbluetooth/nirfmxbluetooth_service.cpp @@ -76,6 +76,9 @@ namespace nirfmxbluetooth_grpc { int32 averaging_count = request->averaging_count(); auto status = library_->ACPCfgAveraging(instrument, selector_string, averaging_enabled, averaging_count); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -112,6 +115,9 @@ namespace nirfmxbluetooth_grpc { } auto status = library_->ACPCfgBurstSynchronizationType(instrument, selector_string, burst_synchronization_type); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -133,6 +139,9 @@ namespace nirfmxbluetooth_grpc { char* selector_string = (char*)request->selector_string().c_str(); int32 number_of_offsets = request->number_of_offsets(); auto status = library_->ACPCfgNumberOfOffsets(instrument, selector_string, number_of_offsets); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -169,6 +178,9 @@ namespace nirfmxbluetooth_grpc { } auto status = library_->ACPCfgOffsetChannelMode(instrument, selector_string, offset_channel_mode); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -194,9 +206,8 @@ namespace nirfmxbluetooth_grpc { int32 actual_array_size {}; while (true) { auto status = library_->ACPFetchAbsolutePowerTrace(instrument, selector_string, timeout, &x0, &dx, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_absolute_power()->Resize(actual_array_size, 0); float32* absolute_power = response->mutable_absolute_power()->mutable_data(); @@ -206,13 +217,14 @@ namespace nirfmxbluetooth_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_x0(x0); - response->set_dx(dx); - response->mutable_absolute_power()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_x0(x0); + response->set_dx(dx); + response->mutable_absolute_power()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -238,9 +250,8 @@ namespace nirfmxbluetooth_grpc { int32 actual_array_size {}; while (true) { auto status = library_->ACPFetchMaskTrace(instrument, selector_string, timeout, &x0, &dx, nullptr, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_limit_with_exception_mask()->Resize(actual_array_size, 0); float32* limit_with_exception_mask = response->mutable_limit_with_exception_mask()->mutable_data(); @@ -252,14 +263,15 @@ namespace nirfmxbluetooth_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_x0(x0); - response->set_dx(dx); - response->mutable_limit_with_exception_mask()->Resize(actual_array_size, 0); - response->mutable_limit_without_exception_mask()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_x0(x0); + response->set_dx(dx); + response->mutable_limit_with_exception_mask()->Resize(actual_array_size, 0); + response->mutable_limit_without_exception_mask()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -282,11 +294,12 @@ namespace nirfmxbluetooth_grpc { float64 timeout = request->timeout(); int32 measurement_status {}; auto status = library_->ACPFetchMeasurementStatus(instrument, selector_string, timeout, &measurement_status); - response->set_status(status); - if (status_ok(status)) { - response->set_measurement_status(static_cast(measurement_status)); - response->set_measurement_status_raw(measurement_status); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_measurement_status(static_cast(measurement_status)); + response->set_measurement_status_raw(measurement_status); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -313,15 +326,16 @@ namespace nirfmxbluetooth_grpc { float64 lower_margin {}; float64 upper_margin {}; auto status = library_->ACPFetchOffsetMeasurement(instrument, selector_string, timeout, &lower_absolute_power, &upper_absolute_power, &lower_relative_power, &upper_relative_power, &lower_margin, &upper_margin); - response->set_status(status); - if (status_ok(status)) { - response->set_lower_absolute_power(lower_absolute_power); - response->set_upper_absolute_power(upper_absolute_power); - response->set_lower_relative_power(lower_relative_power); - response->set_upper_relative_power(upper_relative_power); - response->set_lower_margin(lower_margin); - response->set_upper_margin(upper_margin); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_lower_absolute_power(lower_absolute_power); + response->set_upper_absolute_power(upper_absolute_power); + response->set_lower_relative_power(lower_relative_power); + response->set_upper_relative_power(upper_relative_power); + response->set_lower_margin(lower_margin); + response->set_upper_margin(upper_margin); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -344,9 +358,8 @@ namespace nirfmxbluetooth_grpc { int32 actual_array_size {}; while (true) { auto status = library_->ACPFetchOffsetMeasurementArray(instrument, selector_string, timeout, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_lower_absolute_power()->Resize(actual_array_size, 0); float64* lower_absolute_power = response->mutable_lower_absolute_power()->mutable_data(); @@ -366,16 +379,17 @@ namespace nirfmxbluetooth_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->mutable_lower_absolute_power()->Resize(actual_array_size, 0); - response->mutable_upper_absolute_power()->Resize(actual_array_size, 0); - response->mutable_lower_relative_power()->Resize(actual_array_size, 0); - response->mutable_upper_relative_power()->Resize(actual_array_size, 0); - response->mutable_lower_margin()->Resize(actual_array_size, 0); - response->mutable_upper_margin()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->mutable_lower_absolute_power()->Resize(actual_array_size, 0); + response->mutable_upper_absolute_power()->Resize(actual_array_size, 0); + response->mutable_lower_relative_power()->Resize(actual_array_size, 0); + response->mutable_upper_relative_power()->Resize(actual_array_size, 0); + response->mutable_lower_margin()->Resize(actual_array_size, 0); + response->mutable_upper_margin()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -398,10 +412,11 @@ namespace nirfmxbluetooth_grpc { float64 timeout = request->timeout(); float64 reference_channel_power {}; auto status = library_->ACPFetchReferenceChannelPower(instrument, selector_string, timeout, &reference_channel_power); - response->set_status(status); - if (status_ok(status)) { - response->set_reference_channel_power(reference_channel_power); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_reference_channel_power(reference_channel_power); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -426,9 +441,8 @@ namespace nirfmxbluetooth_grpc { int32 actual_array_size {}; while (true) { auto status = library_->ACPFetchSpectrum(instrument, selector_string, timeout, &x0, &dx, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_spectrum()->Resize(actual_array_size, 0); float32* spectrum = response->mutable_spectrum()->mutable_data(); @@ -438,13 +452,14 @@ namespace nirfmxbluetooth_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_x0(x0); - response->set_dx(dx); - response->mutable_spectrum()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_x0(x0); + response->set_dx(dx); + response->mutable_spectrum()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -465,6 +480,9 @@ namespace nirfmxbluetooth_grpc { niRFmxInstrHandle instrument = session_repository_->access_session(instrument_grpc_session.id(), instrument_grpc_session.name()); char* selector_string = (char*)request->selector_string().c_str(); auto status = library_->AbortMeasurements(instrument, selector_string); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -492,6 +510,9 @@ namespace nirfmxbluetooth_grpc { int32 reset = request->reset(); auto reserved = 0; auto status = library_->AnalyzeIQ1Waveform(instrument, selector_string, result_name, x0, dx, iq.data(), array_size, reset, reserved); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -513,6 +534,9 @@ namespace nirfmxbluetooth_grpc { char* selector_string = (char*)request->selector_string().c_str(); float64 timeout = request->timeout(); auto status = library_->AutoDetectSignal(instrument, selector_string, timeout); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -535,10 +559,11 @@ namespace nirfmxbluetooth_grpc { float64 measurement_interval = request->measurement_interval(); float64 reference_level {}; auto status = library_->AutoLevel(instrument, selector_string, measurement_interval, &reference_level); - response->set_status(status); - if (status_ok(status)) { - response->set_reference_level(reference_level); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_reference_level(reference_level); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -559,9 +584,8 @@ namespace nirfmxbluetooth_grpc { while (true) { auto status = library_->BuildOffsetString(selector_string, offset_number, 0, nullptr); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, 0); } int32 selector_string_out_length = status; @@ -574,11 +598,12 @@ namespace nirfmxbluetooth_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_selector_string_out(selector_string_out); - nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_selector_string_out())); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, 0); } + response->set_status(status); + response->set_selector_string_out(selector_string_out); + nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_selector_string_out())); return ::grpc::Status::OK; } } @@ -600,9 +625,8 @@ namespace nirfmxbluetooth_grpc { while (true) { auto status = library_->BuildSignalString(signal_name, result_name, 0, nullptr); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, 0); } int32 selector_string_length = status; @@ -615,11 +639,12 @@ namespace nirfmxbluetooth_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_selector_string(selector_string); - nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_selector_string())); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, 0); } + response->set_status(status); + response->set_selector_string(selector_string); + nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_selector_string())); return ::grpc::Status::OK; } } @@ -641,9 +666,8 @@ namespace nirfmxbluetooth_grpc { while (true) { auto status = library_->BuildSlotString(selector_string, slot_number, 0, nullptr); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, 0); } int32 selector_string_out_length = status; @@ -656,11 +680,12 @@ namespace nirfmxbluetooth_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_selector_string_out(selector_string_out); - nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_selector_string_out())); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, 0); } + response->set_status(status); + response->set_selector_string_out(selector_string_out); + nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_selector_string_out())); return ::grpc::Status::OK; } } @@ -682,6 +707,9 @@ namespace nirfmxbluetooth_grpc { char* selector_string = (char*)request->selector_string().c_str(); int32 channel_number = request->channel_number(); auto status = library_->CfgChannelNumber(instrument, selector_string, channel_number); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -703,6 +731,9 @@ namespace nirfmxbluetooth_grpc { char* selector_string = (char*)request->selector_string().c_str(); int32 data_rate = request->data_rate(); auto status = library_->CfgDataRate(instrument, selector_string, data_rate); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -742,6 +773,9 @@ namespace nirfmxbluetooth_grpc { float64 trigger_delay = request->trigger_delay(); int32 enable_trigger = request->enable_trigger(); auto status = library_->CfgDigitalEdgeTrigger(instrument, selector_string, digital_edge_source, digital_edge, trigger_delay, enable_trigger); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -763,6 +797,9 @@ namespace nirfmxbluetooth_grpc { char* selector_string = (char*)request->selector_string().c_str(); float64 external_attenuation = request->external_attenuation(); auto status = library_->CfgExternalAttenuation(instrument, selector_string, external_attenuation); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -784,6 +821,9 @@ namespace nirfmxbluetooth_grpc { char* selector_string = (char*)request->selector_string().c_str(); float64 center_frequency = request->center_frequency(); auto status = library_->CfgFrequency(instrument, selector_string, center_frequency); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -821,6 +861,9 @@ namespace nirfmxbluetooth_grpc { int32 channel_number = request->channel_number(); auto status = library_->CfgFrequencyChannelNumber(instrument, selector_string, standard, channel_number); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -862,6 +905,9 @@ namespace nirfmxbluetooth_grpc { float64 frequency_reference_frequency = request->frequency_reference_frequency(); auto status = library_->CfgFrequencyReference(instrument, channel_name, frequency_reference_source, frequency_reference_frequency); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -935,6 +981,9 @@ namespace nirfmxbluetooth_grpc { int32 enable_trigger = request->enable_trigger(); auto status = library_->CfgIQPowerEdgeTrigger(instrument, selector_string, iq_power_edge_source, iq_power_edge_slope, iq_power_edge_level, trigger_delay, trigger_min_quiet_time_mode, trigger_min_quiet_time_duration, iq_power_edge_level_type, enable_trigger); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -973,6 +1022,9 @@ namespace nirfmxbluetooth_grpc { float64 cte_length = request->cte_length(); float64 cte_slot_duration = request->cte_slot_duration(); auto status = library_->CfgLEDirectionFinding(instrument, selector_string, direction_finding_mode, cte_length, cte_slot_duration); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1010,6 +1062,9 @@ namespace nirfmxbluetooth_grpc { float64 mechanical_attenuation_value = request->mechanical_attenuation_value(); auto status = library_->CfgMechanicalAttenuation(instrument, channel_name, mechanical_attenuation_auto, mechanical_attenuation_value); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1046,6 +1101,9 @@ namespace nirfmxbluetooth_grpc { } auto status = library_->CfgPacketType(instrument, selector_string, packet_type); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1082,6 +1140,9 @@ namespace nirfmxbluetooth_grpc { } auto status = library_->CfgPayloadBitPattern(instrument, selector_string, payload_bit_pattern); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1119,6 +1180,9 @@ namespace nirfmxbluetooth_grpc { int32 payload_length = request->payload_length(); auto status = library_->CfgPayloadLength(instrument, selector_string, payload_length_mode, payload_length); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1142,6 +1206,9 @@ namespace nirfmxbluetooth_grpc { float64 reference_level = request->reference_level(); float64 external_attenuation = request->external_attenuation(); auto status = library_->CfgRF(instrument, selector_string, center_frequency, reference_level, external_attenuation); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1179,6 +1246,9 @@ namespace nirfmxbluetooth_grpc { float64 rf_attenuation_value = request->rf_attenuation_value(); auto status = library_->CfgRFAttenuation(instrument, channel_name, rf_attenuation_auto, rf_attenuation_value); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1200,6 +1270,9 @@ namespace nirfmxbluetooth_grpc { char* selector_string = (char*)request->selector_string().c_str(); float64 reference_level = request->reference_level(); auto status = library_->CfgReferenceLevel(instrument, selector_string, reference_level); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1222,6 +1295,9 @@ namespace nirfmxbluetooth_grpc { float64 trigger_delay = request->trigger_delay(); int32 enable_trigger = request->enable_trigger(); auto status = library_->CfgSoftwareEdgeTrigger(instrument, selector_string, trigger_delay, enable_trigger); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1243,10 +1319,11 @@ namespace nirfmxbluetooth_grpc { char* selector_string = (char*)request->selector_string().c_str(); int32 is_done {}; auto status = library_->CheckMeasurementStatus(instrument, selector_string, &is_done); - response->set_status(status); - if (status_ok(status)) { - response->set_is_done(is_done); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_is_done(is_done); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -1266,6 +1343,9 @@ namespace nirfmxbluetooth_grpc { niRFmxInstrHandle instrument = session_repository_->access_session(instrument_grpc_session.id(), instrument_grpc_session.name()); char* selector_string = (char*)request->selector_string().c_str(); auto status = library_->ClearAllNamedResults(instrument, selector_string); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1286,6 +1366,9 @@ namespace nirfmxbluetooth_grpc { niRFmxInstrHandle instrument = session_repository_->access_session(instrument_grpc_session.id(), instrument_grpc_session.name()); char* selector_string = (char*)request->selector_string().c_str(); auto status = library_->ClearNamedResult(instrument, selector_string); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1307,6 +1390,9 @@ namespace nirfmxbluetooth_grpc { char* old_signal_name = (char*)request->old_signal_name().c_str(); char* new_signal_name = (char*)request->new_signal_name().c_str(); auto status = library_->CloneSignalConfiguration(instrument, old_signal_name, new_signal_name); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1328,6 +1414,9 @@ namespace nirfmxbluetooth_grpc { int32 force_destroy = request->force_destroy(); session_repository_->remove_session(instrument_grpc_session.id(), instrument_grpc_session.name()); auto status = library_->Close(instrument, force_destroy); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1348,6 +1437,9 @@ namespace nirfmxbluetooth_grpc { niRFmxInstrHandle instrument = session_repository_->access_session(instrument_grpc_session.id(), instrument_grpc_session.name()); char* selector_string = (char*)request->selector_string().c_str(); auto status = library_->Commit(instrument, selector_string); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1368,6 +1460,9 @@ namespace nirfmxbluetooth_grpc { niRFmxInstrHandle instrument = session_repository_->access_session(instrument_grpc_session.id(), instrument_grpc_session.name()); char* signal_name = (char*)request->signal_name().c_str(); auto status = library_->CreateSignalConfiguration(instrument, signal_name); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1388,6 +1483,9 @@ namespace nirfmxbluetooth_grpc { niRFmxInstrHandle instrument = session_repository_->access_session(instrument_grpc_session.id(), instrument_grpc_session.name()); char* signal_name = (char*)request->signal_name().c_str(); auto status = library_->DeleteSignalConfiguration(instrument, signal_name); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1408,6 +1506,9 @@ namespace nirfmxbluetooth_grpc { niRFmxInstrHandle instrument = session_repository_->access_session(instrument_grpc_session.id(), instrument_grpc_session.name()); char* selector_string = (char*)request->selector_string().c_str(); auto status = library_->DisableTrigger(instrument, selector_string); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1445,6 +1546,9 @@ namespace nirfmxbluetooth_grpc { int32 averaging_count = request->averaging_count(); auto status = library_->FrequencyRangeCfgAveraging(instrument, selector_string, averaging_enabled, averaging_count); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1466,6 +1570,9 @@ namespace nirfmxbluetooth_grpc { char* selector_string = (char*)request->selector_string().c_str(); float64 span = request->span(); auto status = library_->FrequencyRangeCfgSpan(instrument, selector_string, span); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1489,11 +1596,12 @@ namespace nirfmxbluetooth_grpc { float64 high_frequency {}; float64 low_frequency {}; auto status = library_->FrequencyRangeFetchMeasurement(instrument, selector_string, timeout, &high_frequency, &low_frequency); - response->set_status(status); - if (status_ok(status)) { - response->set_high_frequency(high_frequency); - response->set_low_frequency(low_frequency); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_high_frequency(high_frequency); + response->set_low_frequency(low_frequency); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -1518,9 +1626,8 @@ namespace nirfmxbluetooth_grpc { int32 actual_array_size {}; while (true) { auto status = library_->FrequencyRangeFetchSpectrum(instrument, selector_string, timeout, &x0, &dx, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_spectrum()->Resize(actual_array_size, 0); float32* spectrum = response->mutable_spectrum()->mutable_data(); @@ -1530,13 +1637,14 @@ namespace nirfmxbluetooth_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_x0(x0); - response->set_dx(dx); - response->mutable_spectrum()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_x0(x0); + response->set_dx(dx); + response->mutable_spectrum()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -1560,9 +1668,8 @@ namespace nirfmxbluetooth_grpc { int32 default_result_exists {}; while (true) { auto status = library_->GetAllNamedResultNames(instrument, selector_string, nullptr, 0, &actual_result_names_size, &default_result_exists); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } std::string result_names; if (actual_result_names_size > 0) { @@ -1574,13 +1681,14 @@ namespace nirfmxbluetooth_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_result_names(result_names); - nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_result_names())); - response->set_actual_result_names_size(actual_result_names_size); - response->set_default_result_exists(default_result_exists); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_result_names(result_names); + nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_result_names())); + response->set_actual_result_names_size(actual_result_names_size); + response->set_default_result_exists(default_result_exists); return ::grpc::Status::OK; } } @@ -1603,10 +1711,11 @@ namespace nirfmxbluetooth_grpc { int32 attribute_id = request->attribute_id(); float32 attr_val {}; auto status = library_->GetAttributeF32(instrument, selector_string, attribute_id, &attr_val); - response->set_status(status); - if (status_ok(status)) { - response->set_attr_val(attr_val); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_attr_val(attr_val); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -1629,9 +1738,8 @@ namespace nirfmxbluetooth_grpc { int32 actual_array_size {}; while (true) { auto status = library_->GetAttributeF32Array(instrument, selector_string, attribute_id, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_attr_val()->Resize(actual_array_size, 0); float32* attr_val = response->mutable_attr_val()->mutable_data(); @@ -1641,11 +1749,12 @@ namespace nirfmxbluetooth_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->mutable_attr_val()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->mutable_attr_val()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -1668,10 +1777,11 @@ namespace nirfmxbluetooth_grpc { int32 attribute_id = request->attribute_id(); float64 attr_val {}; auto status = library_->GetAttributeF64(instrument, selector_string, attribute_id, &attr_val); - response->set_status(status); - if (status_ok(status)) { - response->set_attr_val(attr_val); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_attr_val(attr_val); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -1694,9 +1804,8 @@ namespace nirfmxbluetooth_grpc { int32 actual_array_size {}; while (true) { auto status = library_->GetAttributeF64Array(instrument, selector_string, attribute_id, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_attr_val()->Resize(actual_array_size, 0); float64* attr_val = response->mutable_attr_val()->mutable_data(); @@ -1706,11 +1815,12 @@ namespace nirfmxbluetooth_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->mutable_attr_val()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->mutable_attr_val()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -1733,10 +1843,11 @@ namespace nirfmxbluetooth_grpc { int32 attribute_id = request->attribute_id(); int16 attr_val {}; auto status = library_->GetAttributeI16(instrument, selector_string, attribute_id, &attr_val); - response->set_status(status); - if (status_ok(status)) { - response->set_attr_val(attr_val); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_attr_val(attr_val); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -1758,16 +1869,17 @@ namespace nirfmxbluetooth_grpc { int32 attribute_id = request->attribute_id(); int32 attr_val {}; auto status = library_->GetAttributeI32(instrument, selector_string, attribute_id, &attr_val); - response->set_status(status); - if (status_ok(status)) { - auto checked_convert_attr_val = [](auto raw_value) { - bool raw_value_is_valid = nirfmxbluetooth_grpc::NiRFmxBluetoothInt32AttributeValues_IsValid(raw_value); - auto valid_enum_value = raw_value_is_valid ? raw_value : 0; - return static_cast(valid_enum_value); - }; - response->set_attr_val(checked_convert_attr_val(attr_val)); - response->set_attr_val_raw(attr_val); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + auto checked_convert_attr_val = [](auto raw_value) { + bool raw_value_is_valid = nirfmxbluetooth_grpc::NiRFmxBluetoothInt32AttributeValues_IsValid(raw_value); + auto valid_enum_value = raw_value_is_valid ? raw_value : 0; + return static_cast(valid_enum_value); + }; + response->set_attr_val(checked_convert_attr_val(attr_val)); + response->set_attr_val_raw(attr_val); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -1790,9 +1902,8 @@ namespace nirfmxbluetooth_grpc { int32 actual_array_size {}; while (true) { auto status = library_->GetAttributeI32Array(instrument, selector_string, attribute_id, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_attr_val_raw()->Resize(actual_array_size, 0); int32* attr_val = reinterpret_cast(response->mutable_attr_val_raw()->mutable_data()); @@ -1802,13 +1913,15 @@ namespace nirfmxbluetooth_grpc { // buffer is now too small, try again continue; } + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); - if (status_ok(status)) { - auto checked_convert_attr_val = [](auto raw_value) { - bool raw_value_is_valid = nirfmxbluetooth_grpc::NiRFmxBluetoothInt32AttributeValues_IsValid(raw_value); - auto valid_enum_value = raw_value_is_valid ? raw_value : 0; - return static_cast(valid_enum_value); - }; + auto checked_convert_attr_val = [](auto raw_value) { + bool raw_value_is_valid = nirfmxbluetooth_grpc::NiRFmxBluetoothInt32AttributeValues_IsValid(raw_value); + auto valid_enum_value = raw_value_is_valid ? raw_value : 0; + return static_cast(valid_enum_value); + }; response->mutable_attr_val()->Clear(); response->mutable_attr_val()->Reserve(actual_array_size); std::transform( @@ -1818,9 +1931,8 @@ namespace nirfmxbluetooth_grpc { [&](auto x) { return checked_convert_attr_val(x); }); - response->mutable_attr_val()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); - } + response->mutable_attr_val()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -1843,10 +1955,11 @@ namespace nirfmxbluetooth_grpc { int32 attribute_id = request->attribute_id(); int64 attr_val {}; auto status = library_->GetAttributeI64(instrument, selector_string, attribute_id, &attr_val); - response->set_status(status); - if (status_ok(status)) { - response->set_attr_val(attr_val); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_attr_val(attr_val); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -1869,9 +1982,8 @@ namespace nirfmxbluetooth_grpc { int32 actual_array_size {}; while (true) { auto status = library_->GetAttributeI64Array(instrument, selector_string, attribute_id, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_attr_val()->Resize(actual_array_size, 0); int64* attr_val = reinterpret_cast(response->mutable_attr_val()->mutable_data()); @@ -1881,11 +1993,12 @@ namespace nirfmxbluetooth_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->mutable_attr_val()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->mutable_attr_val()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -1908,10 +2021,11 @@ namespace nirfmxbluetooth_grpc { int32 attribute_id = request->attribute_id(); int8 attr_val {}; auto status = library_->GetAttributeI8(instrument, selector_string, attribute_id, &attr_val); - response->set_status(status); - if (status_ok(status)) { - response->set_attr_val(attr_val); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_attr_val(attr_val); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -1934,9 +2048,8 @@ namespace nirfmxbluetooth_grpc { int32 actual_array_size {}; while (true) { auto status = library_->GetAttributeI8Array(instrument, selector_string, attribute_id, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } std::vector attr_val(actual_array_size); auto array_size = actual_array_size; @@ -1945,8 +2058,10 @@ namespace nirfmxbluetooth_grpc { // buffer is now too small, try again continue; } + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); - if (status_ok(status)) { response->mutable_attr_val()->Clear(); response->mutable_attr_val()->Reserve(actual_array_size); std::transform( @@ -1956,9 +2071,8 @@ namespace nirfmxbluetooth_grpc { [&](auto x) { return x; }); - response->mutable_attr_val()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); - } + response->mutable_attr_val()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -1982,9 +2096,8 @@ namespace nirfmxbluetooth_grpc { int32 actual_array_size {}; while (true) { auto status = library_->GetAttributeNIComplexDoubleArray(instrument, selector_string, attribute_id, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } std::vector attr_val(actual_array_size, NIComplexDouble()); auto array_size = actual_array_size; @@ -1993,18 +2106,19 @@ namespace nirfmxbluetooth_grpc { // buffer is now too small, try again continue; } + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); - if (status_ok(status)) { - convert_to_grpc(attr_val, response->mutable_attr_val()); - { - auto shrunk_size = actual_array_size; - auto current_size = response->mutable_attr_val()->size(); - if (shrunk_size != current_size) { - response->mutable_attr_val()->DeleteSubrange(shrunk_size, current_size - shrunk_size); - } + convert_to_grpc(attr_val, response->mutable_attr_val()); + { + auto shrunk_size = actual_array_size; + auto current_size = response->mutable_attr_val()->size(); + if (shrunk_size != current_size) { + response->mutable_attr_val()->DeleteSubrange(shrunk_size, current_size - shrunk_size); } - response->set_actual_array_size(actual_array_size); } + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -2028,9 +2142,8 @@ namespace nirfmxbluetooth_grpc { int32 actual_array_size {}; while (true) { auto status = library_->GetAttributeNIComplexSingleArray(instrument, selector_string, attribute_id, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } std::vector attr_val(actual_array_size, NIComplexSingle()); auto array_size = actual_array_size; @@ -2039,18 +2152,19 @@ namespace nirfmxbluetooth_grpc { // buffer is now too small, try again continue; } + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); - if (status_ok(status)) { - convert_to_grpc(attr_val, response->mutable_attr_val()); - { - auto shrunk_size = actual_array_size; - auto current_size = response->mutable_attr_val()->size(); - if (shrunk_size != current_size) { - response->mutable_attr_val()->DeleteSubrange(shrunk_size, current_size - shrunk_size); - } + convert_to_grpc(attr_val, response->mutable_attr_val()); + { + auto shrunk_size = actual_array_size; + auto current_size = response->mutable_attr_val()->size(); + if (shrunk_size != current_size) { + response->mutable_attr_val()->DeleteSubrange(shrunk_size, current_size - shrunk_size); } - response->set_actual_array_size(actual_array_size); } + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -2074,9 +2188,8 @@ namespace nirfmxbluetooth_grpc { while (true) { auto status = library_->GetAttributeString(instrument, selector_string, attribute_id, 0, nullptr); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } int32 array_size = status; @@ -2089,11 +2202,12 @@ namespace nirfmxbluetooth_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_attr_val(attr_val); - nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_attr_val())); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_attr_val(attr_val); + nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_attr_val())); return ::grpc::Status::OK; } } @@ -2116,10 +2230,11 @@ namespace nirfmxbluetooth_grpc { int32 attribute_id = request->attribute_id(); uInt16 attr_val {}; auto status = library_->GetAttributeU16(instrument, selector_string, attribute_id, &attr_val); - response->set_status(status); - if (status_ok(status)) { - response->set_attr_val(attr_val); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_attr_val(attr_val); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -2141,10 +2256,11 @@ namespace nirfmxbluetooth_grpc { int32 attribute_id = request->attribute_id(); uInt32 attr_val {}; auto status = library_->GetAttributeU32(instrument, selector_string, attribute_id, &attr_val); - response->set_status(status); - if (status_ok(status)) { - response->set_attr_val(attr_val); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_attr_val(attr_val); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -2167,9 +2283,8 @@ namespace nirfmxbluetooth_grpc { int32 actual_array_size {}; while (true) { auto status = library_->GetAttributeU32Array(instrument, selector_string, attribute_id, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_attr_val()->Resize(actual_array_size, 0); uInt32* attr_val = reinterpret_cast(response->mutable_attr_val()->mutable_data()); @@ -2179,11 +2294,12 @@ namespace nirfmxbluetooth_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->mutable_attr_val()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->mutable_attr_val()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -2207,9 +2323,8 @@ namespace nirfmxbluetooth_grpc { int32 actual_array_size {}; while (true) { auto status = library_->GetAttributeU64Array(instrument, selector_string, attribute_id, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_attr_val()->Resize(actual_array_size, 0); uInt64* attr_val = reinterpret_cast(response->mutable_attr_val()->mutable_data()); @@ -2219,11 +2334,12 @@ namespace nirfmxbluetooth_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->mutable_attr_val()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->mutable_attr_val()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -2246,10 +2362,11 @@ namespace nirfmxbluetooth_grpc { int32 attribute_id = request->attribute_id(); uInt8 attr_val {}; auto status = library_->GetAttributeU8(instrument, selector_string, attribute_id, &attr_val); - response->set_status(status); - if (status_ok(status)) { - response->set_attr_val(attr_val); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_attr_val(attr_val); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -2272,9 +2389,8 @@ namespace nirfmxbluetooth_grpc { int32 actual_array_size {}; while (true) { auto status = library_->GetAttributeU8Array(instrument, selector_string, attribute_id, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } std::string attr_val(actual_array_size, '\0'); auto array_size = actual_array_size; @@ -2283,12 +2399,13 @@ namespace nirfmxbluetooth_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_attr_val(attr_val); - response->mutable_attr_val()->resize(actual_array_size); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_attr_val(attr_val); + response->mutable_attr_val()->resize(actual_array_size); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -2310,9 +2427,8 @@ namespace nirfmxbluetooth_grpc { while (true) { auto status = library_->GetError(instrument, nullptr, 0, nullptr); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } int32 error_description_buffer_size = status; @@ -2326,12 +2442,13 @@ namespace nirfmxbluetooth_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_error_code(error_code); - response->set_error_description(error_description); - nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_error_description())); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_error_code(error_code); + response->set_error_description(error_description); + nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_error_description())); return ::grpc::Status::OK; } } @@ -2354,9 +2471,8 @@ namespace nirfmxbluetooth_grpc { while (true) { auto status = library_->GetErrorString(instrument, error_code, 0, nullptr); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } int32 error_description_buffer_size = status; @@ -2369,11 +2485,12 @@ namespace nirfmxbluetooth_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_error_description(error_description); - nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_error_description())); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_error_description(error_description); + nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_error_description())); return ::grpc::Status::OK; } } @@ -2403,15 +2520,12 @@ namespace nirfmxbluetooth_grpc { const std::string& grpc_device_session_name = request->session_name(); auto cleanup_lambda = [&] (niRFmxInstrHandle id) { library_->Close(id, RFMXBT_VAL_FALSE); }; int status = session_repository_->add_session(grpc_device_session_name, init_lambda, cleanup_lambda, session_id); - response->set_status(status); - if (status_ok(status)) { - response->mutable_instrument()->set_id(session_id); - response->set_is_new_session(is_new_session); - } - else { - const auto error_message = get_last_error_message(library_); - response->set_error_message(error_message); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, 0); } + response->set_status(status); + response->mutable_instrument()->set_id(session_id); + response->set_is_new_session(is_new_session); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -2442,14 +2556,11 @@ namespace nirfmxbluetooth_grpc { const std::string& grpc_device_session_name = request->session_name(); auto cleanup_lambda = [&] (niRFmxInstrHandle id) { library_->Close(id, RFMXBT_VAL_FALSE); }; int status = session_repository_->add_session(grpc_device_session_name, init_lambda, cleanup_lambda, session_id); - response->set_status(status); - if (status_ok(status)) { - response->mutable_instrument()->set_id(session_id); - } - else { - const auto error_message = get_last_error_message(library_); - response->set_error_message(error_message); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, 0); } + response->set_status(status); + response->mutable_instrument()->set_id(session_id); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -2473,6 +2584,9 @@ namespace nirfmxbluetooth_grpc { char* selector_string = (char*)request->selector_string().c_str(); char* result_name = (char*)request->result_name().c_str(); auto status = library_->Initiate(instrument, selector_string, result_name); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -2510,6 +2624,9 @@ namespace nirfmxbluetooth_grpc { int32 averaging_count = request->averaging_count(); auto status = library_->ModAccCfgAveraging(instrument, selector_string, averaging_enabled, averaging_count); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -2546,6 +2663,9 @@ namespace nirfmxbluetooth_grpc { } auto status = library_->ModAccCfgBurstSynchronizationType(instrument, selector_string, burst_synchronization_type); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -2569,9 +2689,8 @@ namespace nirfmxbluetooth_grpc { int32 actual_array_size {}; while (true) { auto status = library_->ModAccFetchConstellationTrace(instrument, selector_string, timeout, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } std::vector constellation(actual_array_size, NIComplexSingle()); auto array_size = actual_array_size; @@ -2580,18 +2699,19 @@ namespace nirfmxbluetooth_grpc { // buffer is now too small, try again continue; } + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); - if (status_ok(status)) { - convert_to_grpc(constellation, response->mutable_constellation()); - { - auto shrunk_size = actual_array_size; - auto current_size = response->mutable_constellation()->size(); - if (shrunk_size != current_size) { - response->mutable_constellation()->DeleteSubrange(shrunk_size, current_size - shrunk_size); - } + convert_to_grpc(constellation, response->mutable_constellation()); + { + auto shrunk_size = actual_array_size; + auto current_size = response->mutable_constellation()->size(); + if (shrunk_size != current_size) { + response->mutable_constellation()->DeleteSubrange(shrunk_size, current_size - shrunk_size); } - response->set_actual_array_size(actual_array_size); } + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -2616,12 +2736,13 @@ namespace nirfmxbluetooth_grpc { float64 peak_devm_maximum {}; float64 ninetynine_percent_devm {}; auto status = library_->ModAccFetchDEVM(instrument, selector_string, timeout, &peak_rms_devm_maximum, &peak_devm_maximum, &ninetynine_percent_devm); - response->set_status(status); - if (status_ok(status)) { - response->set_peak_rms_devm_maximum(peak_rms_devm_maximum); - response->set_peak_devm_maximum(peak_devm_maximum); - response->set_ninetynine_percent_devm(ninetynine_percent_devm); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_peak_rms_devm_maximum(peak_rms_devm_maximum); + response->set_peak_devm_maximum(peak_devm_maximum); + response->set_ninetynine_percent_devm(ninetynine_percent_devm); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -2644,11 +2765,12 @@ namespace nirfmxbluetooth_grpc { float64 average_rms_magnitude_error_mean {}; float64 peak_rms_magnitude_error_maximum {}; auto status = library_->ModAccFetchDEVMMagnitudeError(instrument, selector_string, timeout, &average_rms_magnitude_error_mean, &peak_rms_magnitude_error_maximum); - response->set_status(status); - if (status_ok(status)) { - response->set_average_rms_magnitude_error_mean(average_rms_magnitude_error_mean); - response->set_peak_rms_magnitude_error_maximum(peak_rms_magnitude_error_maximum); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_average_rms_magnitude_error_mean(average_rms_magnitude_error_mean); + response->set_peak_rms_magnitude_error_maximum(peak_rms_magnitude_error_maximum); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -2671,9 +2793,8 @@ namespace nirfmxbluetooth_grpc { int32 actual_array_size {}; while (true) { auto status = library_->ModAccFetchDEVMPerSymbolTrace(instrument, selector_string, timeout, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_devm_per_symbol()->Resize(actual_array_size, 0); float32* devm_per_symbol = response->mutable_devm_per_symbol()->mutable_data(); @@ -2683,11 +2804,12 @@ namespace nirfmxbluetooth_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->mutable_devm_per_symbol()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->mutable_devm_per_symbol()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -2711,11 +2833,12 @@ namespace nirfmxbluetooth_grpc { float64 average_rms_phase_error_mean {}; float64 peak_rms_phase_error_maximum {}; auto status = library_->ModAccFetchDEVMPhaseError(instrument, selector_string, timeout, &average_rms_phase_error_mean, &peak_rms_phase_error_maximum); - response->set_status(status); - if (status_ok(status)) { - response->set_average_rms_phase_error_mean(average_rms_phase_error_mean); - response->set_peak_rms_phase_error_maximum(peak_rms_phase_error_maximum); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_average_rms_phase_error_mean(average_rms_phase_error_mean); + response->set_peak_rms_phase_error_maximum(peak_rms_phase_error_maximum); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -2738,9 +2861,8 @@ namespace nirfmxbluetooth_grpc { int32 actual_array_size {}; while (true) { auto status = library_->ModAccFetchDemodulatedBitTrace(instrument, selector_string, timeout, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } std::vector demodulated_bits(actual_array_size); auto array_size = actual_array_size; @@ -2749,8 +2871,10 @@ namespace nirfmxbluetooth_grpc { // buffer is now too small, try again continue; } + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); - if (status_ok(status)) { response->mutable_demodulated_bits()->Clear(); response->mutable_demodulated_bits()->Reserve(actual_array_size); std::transform( @@ -2760,9 +2884,8 @@ namespace nirfmxbluetooth_grpc { [&](auto x) { return x; }); - response->mutable_demodulated_bits()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); - } + response->mutable_demodulated_bits()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -2786,11 +2909,12 @@ namespace nirfmxbluetooth_grpc { float64 df1avg_maximum {}; float64 df1avg_minimum {}; auto status = library_->ModAccFetchDf1(instrument, selector_string, timeout, &df1avg_maximum, &df1avg_minimum); - response->set_status(status); - if (status_ok(status)) { - response->set_df1avg_maximum(df1avg_maximum); - response->set_df1avg_minimum(df1avg_minimum); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_df1avg_maximum(df1avg_maximum); + response->set_df1avg_minimum(df1avg_minimum); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -2813,9 +2937,8 @@ namespace nirfmxbluetooth_grpc { int32 actual_array_size {}; while (true) { auto status = library_->ModAccFetchDf1maxTrace(instrument, selector_string, timeout, nullptr, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_time()->Resize(actual_array_size, 0); float32* time = response->mutable_time()->mutable_data(); @@ -2827,12 +2950,13 @@ namespace nirfmxbluetooth_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->mutable_time()->Resize(actual_array_size, 0); - response->mutable_df1max()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->mutable_time()->Resize(actual_array_size, 0); + response->mutable_df1max()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -2856,11 +2980,12 @@ namespace nirfmxbluetooth_grpc { float64 df2avg_minimum {}; float64 percentage_of_symbols_above_df2max_threshold {}; auto status = library_->ModAccFetchDf2(instrument, selector_string, timeout, &df2avg_minimum, &percentage_of_symbols_above_df2max_threshold); - response->set_status(status); - if (status_ok(status)) { - response->set_df2avg_minimum(df2avg_minimum); - response->set_percentage_of_symbols_above_df2max_threshold(percentage_of_symbols_above_df2max_threshold); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_df2avg_minimum(df2avg_minimum); + response->set_percentage_of_symbols_above_df2max_threshold(percentage_of_symbols_above_df2max_threshold); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -2883,9 +3008,8 @@ namespace nirfmxbluetooth_grpc { int32 actual_array_size {}; while (true) { auto status = library_->ModAccFetchDf2maxTrace(instrument, selector_string, timeout, nullptr, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_time()->Resize(actual_array_size, 0); float32* time = response->mutable_time()->mutable_data(); @@ -2897,12 +3021,13 @@ namespace nirfmxbluetooth_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->mutable_time()->Resize(actual_array_size, 0); - response->mutable_df2max()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->mutable_time()->Resize(actual_array_size, 0); + response->mutable_df2max()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -2927,12 +3052,13 @@ namespace nirfmxbluetooth_grpc { float64 peak_frequency_drift_maximum {}; float64 peak_frequency_drift_rate_maximum {}; auto status = library_->ModAccFetchFrequencyErrorBR(instrument, selector_string, timeout, &initial_frequency_error_maximum, &peak_frequency_drift_maximum, &peak_frequency_drift_rate_maximum); - response->set_status(status); - if (status_ok(status)) { - response->set_initial_frequency_error_maximum(initial_frequency_error_maximum); - response->set_peak_frequency_drift_maximum(peak_frequency_drift_maximum); - response->set_peak_frequency_drift_rate_maximum(peak_frequency_drift_rate_maximum); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_initial_frequency_error_maximum(initial_frequency_error_maximum); + response->set_peak_frequency_drift_maximum(peak_frequency_drift_maximum); + response->set_peak_frequency_drift_rate_maximum(peak_frequency_drift_rate_maximum); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -2956,12 +3082,13 @@ namespace nirfmxbluetooth_grpc { float64 peak_frequency_error_wi_plus_w0_maximum {}; float64 peak_frequency_error_w0_maximum {}; auto status = library_->ModAccFetchFrequencyErrorEDR(instrument, selector_string, timeout, &header_frequency_error_wi_maximum, &peak_frequency_error_wi_plus_w0_maximum, &peak_frequency_error_w0_maximum); - response->set_status(status); - if (status_ok(status)) { - response->set_header_frequency_error_wi_maximum(header_frequency_error_wi_maximum); - response->set_peak_frequency_error_wi_plus_w0_maximum(peak_frequency_error_wi_plus_w0_maximum); - response->set_peak_frequency_error_w0_maximum(peak_frequency_error_w0_maximum); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_header_frequency_error_wi_maximum(header_frequency_error_wi_maximum); + response->set_peak_frequency_error_wi_plus_w0_maximum(peak_frequency_error_wi_plus_w0_maximum); + response->set_peak_frequency_error_w0_maximum(peak_frequency_error_w0_maximum); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -2986,13 +3113,14 @@ namespace nirfmxbluetooth_grpc { float64 peak_frequency_drift_maximum {}; float64 peak_frequency_drift_rate_maximum {}; auto status = library_->ModAccFetchFrequencyErrorLE(instrument, selector_string, timeout, &peak_frequency_error_maximum, &initial_frequency_drift_maximum, &peak_frequency_drift_maximum, &peak_frequency_drift_rate_maximum); - response->set_status(status); - if (status_ok(status)) { - response->set_peak_frequency_error_maximum(peak_frequency_error_maximum); - response->set_initial_frequency_drift_maximum(initial_frequency_drift_maximum); - response->set_peak_frequency_drift_maximum(peak_frequency_drift_maximum); - response->set_peak_frequency_drift_rate_maximum(peak_frequency_drift_rate_maximum); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_peak_frequency_error_maximum(peak_frequency_error_maximum); + response->set_initial_frequency_drift_maximum(initial_frequency_drift_maximum); + response->set_peak_frequency_drift_maximum(peak_frequency_drift_maximum); + response->set_peak_frequency_drift_rate_maximum(peak_frequency_drift_rate_maximum); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -3015,9 +3143,8 @@ namespace nirfmxbluetooth_grpc { int32 actual_array_size {}; while (true) { auto status = library_->ModAccFetchFrequencyErrorTraceBR(instrument, selector_string, timeout, nullptr, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_time()->Resize(actual_array_size, 0); float32* time = response->mutable_time()->mutable_data(); @@ -3029,12 +3156,13 @@ namespace nirfmxbluetooth_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->mutable_time()->Resize(actual_array_size, 0); - response->mutable_frequency_error()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->mutable_time()->Resize(actual_array_size, 0); + response->mutable_frequency_error()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -3058,9 +3186,8 @@ namespace nirfmxbluetooth_grpc { int32 actual_array_size {}; while (true) { auto status = library_->ModAccFetchFrequencyErrorTraceLE(instrument, selector_string, timeout, nullptr, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_time()->Resize(actual_array_size, 0); float32* time = response->mutable_time()->mutable_data(); @@ -3072,12 +3199,13 @@ namespace nirfmxbluetooth_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->mutable_time()->Resize(actual_array_size, 0); - response->mutable_frequency_error()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->mutable_time()->Resize(actual_array_size, 0); + response->mutable_frequency_error()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -3101,9 +3229,8 @@ namespace nirfmxbluetooth_grpc { int32 actual_array_size {}; while (true) { auto status = library_->ModAccFetchFrequencyErrorWiPlusW0TraceEDR(instrument, selector_string, timeout, nullptr, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_time()->Resize(actual_array_size, 0); float32* time = response->mutable_time()->mutable_data(); @@ -3115,12 +3242,13 @@ namespace nirfmxbluetooth_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->mutable_time()->Resize(actual_array_size, 0); - response->mutable_frequency_error_wi_plus_w0()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->mutable_time()->Resize(actual_array_size, 0); + response->mutable_frequency_error_wi_plus_w0()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -3146,9 +3274,8 @@ namespace nirfmxbluetooth_grpc { int32 actual_array_size {}; while (true) { auto status = library_->ModAccFetchFrequencyTrace(instrument, selector_string, timeout, &x0, &dx, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_frequency()->Resize(actual_array_size, 0); float32* frequency = response->mutable_frequency()->mutable_data(); @@ -3158,13 +3285,14 @@ namespace nirfmxbluetooth_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_x0(x0); - response->set_dx(dx); - response->mutable_frequency()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_x0(x0); + response->set_dx(dx); + response->mutable_frequency()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -3188,9 +3316,8 @@ namespace nirfmxbluetooth_grpc { int32 actual_array_size {}; while (true) { auto status = library_->ModAccFetchRMSDEVMTrace(instrument, selector_string, timeout, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_rms_devm()->Resize(actual_array_size, 0); float32* rms_devm = response->mutable_rms_devm()->mutable_data(); @@ -3200,11 +3327,12 @@ namespace nirfmxbluetooth_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->mutable_rms_devm()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->mutable_rms_devm()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -3226,6 +3354,9 @@ namespace nirfmxbluetooth_grpc { char* selector_string = (char*)request->selector_string().c_str(); int32 attribute_id = request->attribute_id(); auto status = library_->ResetAttribute(instrument, selector_string, attribute_id); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -3246,6 +3377,9 @@ namespace nirfmxbluetooth_grpc { niRFmxInstrHandle instrument = session_repository_->access_session(instrument_grpc_session.id(), instrument_grpc_session.name()); char* selector_string = (char*)request->selector_string().c_str(); auto status = library_->ResetToDefault(instrument, selector_string); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -3283,6 +3417,9 @@ namespace nirfmxbluetooth_grpc { int32 enable_all_traces = request->enable_all_traces(); auto status = library_->SelectMeasurements(instrument, selector_string, measurements, enable_all_traces); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -3302,6 +3439,9 @@ namespace nirfmxbluetooth_grpc { auto instrument_grpc_session = request->instrument(); niRFmxInstrHandle instrument = session_repository_->access_session(instrument_grpc_session.id(), instrument_grpc_session.name()); auto status = library_->SendSoftwareEdgeTrigger(instrument); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -3324,6 +3464,9 @@ namespace nirfmxbluetooth_grpc { int32 attribute_id = request->attribute_id(); float32 attr_val = request->attr_val(); auto status = library_->SetAttributeF32(instrument, selector_string, attribute_id, attr_val); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -3347,6 +3490,9 @@ namespace nirfmxbluetooth_grpc { auto attr_val = const_cast(request->attr_val().data()); int32 array_size = static_cast(request->attr_val().size()); auto status = library_->SetAttributeF32Array(instrument, selector_string, attribute_id, attr_val, array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -3369,6 +3515,9 @@ namespace nirfmxbluetooth_grpc { int32 attribute_id = request->attribute_id(); float64 attr_val = request->attr_val(); auto status = library_->SetAttributeF64(instrument, selector_string, attribute_id, attr_val); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -3392,6 +3541,9 @@ namespace nirfmxbluetooth_grpc { auto attr_val = const_cast(request->attr_val().data()); int32 array_size = static_cast(request->attr_val().size()); auto status = library_->SetAttributeF64Array(instrument, selector_string, attribute_id, attr_val, array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -3423,6 +3575,9 @@ namespace nirfmxbluetooth_grpc { auto attr_val = static_cast(attr_val_raw); auto status = library_->SetAttributeI16(instrument, selector_string, attribute_id, attr_val); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -3463,6 +3618,9 @@ namespace nirfmxbluetooth_grpc { } auto status = library_->SetAttributeI32(instrument, selector_string, attribute_id, attr_val); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -3494,6 +3652,9 @@ namespace nirfmxbluetooth_grpc { int32 array_size = static_cast(request->attr_val().size()); auto status = library_->SetAttributeI32Array(instrument, selector_string, attribute_id, attr_val, array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -3516,6 +3677,9 @@ namespace nirfmxbluetooth_grpc { int32 attribute_id = request->attribute_id(); int64 attr_val = request->attr_val(); auto status = library_->SetAttributeI64(instrument, selector_string, attribute_id, attr_val); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -3539,6 +3703,9 @@ namespace nirfmxbluetooth_grpc { auto attr_val = const_cast(reinterpret_cast(request->attr_val().data())); int32 array_size = static_cast(request->attr_val().size()); auto status = library_->SetAttributeI64Array(instrument, selector_string, attribute_id, attr_val, array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -3570,6 +3737,9 @@ namespace nirfmxbluetooth_grpc { auto attr_val = static_cast(attr_val_raw); auto status = library_->SetAttributeI8(instrument, selector_string, attribute_id, attr_val); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -3613,6 +3783,9 @@ namespace nirfmxbluetooth_grpc { int32 array_size = static_cast(request->attr_val().size()); auto status = library_->SetAttributeI8Array(instrument, selector_string, attribute_id, attr_val.data(), array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -3639,6 +3812,9 @@ namespace nirfmxbluetooth_grpc { auto attr_val = convert_from_grpc(request->attr_val()); int32 array_size = static_cast(request->attr_val().size()); auto status = library_->SetAttributeNIComplexDoubleArray(instrument, selector_string, attribute_id, attr_val.data(), array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -3662,6 +3838,9 @@ namespace nirfmxbluetooth_grpc { auto attr_val = convert_from_grpc(request->attr_val()); int32 array_size = static_cast(request->attr_val().size()); auto status = library_->SetAttributeNIComplexSingleArray(instrument, selector_string, attribute_id, attr_val.data(), array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -3703,6 +3882,9 @@ namespace nirfmxbluetooth_grpc { } auto status = library_->SetAttributeString(instrument, selector_string, attribute_id, attr_val); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -3734,6 +3916,9 @@ namespace nirfmxbluetooth_grpc { auto attr_val = static_cast(attr_val_raw); auto status = library_->SetAttributeU16(instrument, selector_string, attribute_id, attr_val); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -3759,6 +3944,9 @@ namespace nirfmxbluetooth_grpc { int32 attribute_id = request->attribute_id(); uInt32 attr_val = request->attr_val(); auto status = library_->SetAttributeU32(instrument, selector_string, attribute_id, attr_val); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -3782,6 +3970,9 @@ namespace nirfmxbluetooth_grpc { auto attr_val = const_cast(reinterpret_cast(request->attr_val().data())); int32 array_size = static_cast(request->attr_val().size()); auto status = library_->SetAttributeU32Array(instrument, selector_string, attribute_id, attr_val, array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -3805,6 +3996,9 @@ namespace nirfmxbluetooth_grpc { auto attr_val = const_cast(reinterpret_cast(request->attr_val().data())); int32 array_size = static_cast(request->attr_val().size()); auto status = library_->SetAttributeU64Array(instrument, selector_string, attribute_id, attr_val, array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -3827,6 +4021,9 @@ namespace nirfmxbluetooth_grpc { int32 attribute_id = request->attribute_id(); uInt8 attr_val = request->attr_val(); auto status = library_->SetAttributeU8(instrument, selector_string, attribute_id, attr_val); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -3850,6 +4047,9 @@ namespace nirfmxbluetooth_grpc { uInt8* attr_val = (uInt8*)request->attr_val().c_str(); int32 array_size = static_cast(request->attr_val().size()); auto status = library_->SetAttributeU8Array(instrument, selector_string, attribute_id, attr_val, array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -3887,6 +4087,9 @@ namespace nirfmxbluetooth_grpc { int32 averaging_count = request->averaging_count(); auto status = library_->TXPCfgAveraging(instrument, selector_string, averaging_enabled, averaging_count); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -3923,6 +4126,9 @@ namespace nirfmxbluetooth_grpc { } auto status = library_->TXPCfgBurstSynchronizationType(instrument, selector_string, burst_synchronization_type); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -3947,12 +4153,13 @@ namespace nirfmxbluetooth_grpc { float64 edr_dpsk_average_power_mean {}; float64 edr_dpsk_gfsk_average_power_ratio_mean {}; auto status = library_->TXPFetchEDRPowers(instrument, selector_string, timeout, &edr_gfsk_average_power_mean, &edr_dpsk_average_power_mean, &edr_dpsk_gfsk_average_power_ratio_mean); - response->set_status(status); - if (status_ok(status)) { - response->set_edr_gfsk_average_power_mean(edr_gfsk_average_power_mean); - response->set_edr_dpsk_average_power_mean(edr_dpsk_average_power_mean); - response->set_edr_dpsk_gfsk_average_power_ratio_mean(edr_dpsk_gfsk_average_power_ratio_mean); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_edr_gfsk_average_power_mean(edr_gfsk_average_power_mean); + response->set_edr_dpsk_average_power_mean(edr_dpsk_average_power_mean); + response->set_edr_dpsk_gfsk_average_power_ratio_mean(edr_dpsk_gfsk_average_power_ratio_mean); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -3975,11 +4182,12 @@ namespace nirfmxbluetooth_grpc { float64 reference_period_average_power_mean {}; float64 reference_period_peak_absolute_power_deviation_maximum {}; auto status = library_->TXPFetchLECTEReferencePeriodPowers(instrument, selector_string, timeout, &reference_period_average_power_mean, &reference_period_peak_absolute_power_deviation_maximum); - response->set_status(status); - if (status_ok(status)) { - response->set_reference_period_average_power_mean(reference_period_average_power_mean); - response->set_reference_period_peak_absolute_power_deviation_maximum(reference_period_peak_absolute_power_deviation_maximum); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_reference_period_average_power_mean(reference_period_average_power_mean); + response->set_reference_period_peak_absolute_power_deviation_maximum(reference_period_peak_absolute_power_deviation_maximum); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -4002,11 +4210,12 @@ namespace nirfmxbluetooth_grpc { float64 transmit_slot_average_power_mean {}; float64 transmit_slot_peak_absolute_power_deviation_maximum {}; auto status = library_->TXPFetchLECTETransmitSlotPowers(instrument, selector_string, timeout, &transmit_slot_average_power_mean, &transmit_slot_peak_absolute_power_deviation_maximum); - response->set_status(status); - if (status_ok(status)) { - response->set_transmit_slot_average_power_mean(transmit_slot_average_power_mean); - response->set_transmit_slot_peak_absolute_power_deviation_maximum(transmit_slot_peak_absolute_power_deviation_maximum); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_transmit_slot_average_power_mean(transmit_slot_average_power_mean); + response->set_transmit_slot_peak_absolute_power_deviation_maximum(transmit_slot_peak_absolute_power_deviation_maximum); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -4029,9 +4238,8 @@ namespace nirfmxbluetooth_grpc { int32 actual_array_size {}; while (true) { auto status = library_->TXPFetchLECTETransmitSlotPowersArray(instrument, selector_string, timeout, nullptr, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_transmit_slot_average_power_mean()->Resize(actual_array_size, 0); float64* transmit_slot_average_power_mean = response->mutable_transmit_slot_average_power_mean()->mutable_data(); @@ -4043,12 +4251,13 @@ namespace nirfmxbluetooth_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->mutable_transmit_slot_average_power_mean()->Resize(actual_array_size, 0); - response->mutable_transmit_slot_peak_absolute_power_deviation_maximum()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->mutable_transmit_slot_average_power_mean()->Resize(actual_array_size, 0); + response->mutable_transmit_slot_peak_absolute_power_deviation_maximum()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -4074,9 +4283,8 @@ namespace nirfmxbluetooth_grpc { int32 actual_array_size {}; while (true) { auto status = library_->TXPFetchPowerTrace(instrument, selector_string, timeout, &x0, &dx, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_power()->Resize(actual_array_size, 0); float32* power = response->mutable_power()->mutable_data(); @@ -4086,13 +4294,14 @@ namespace nirfmxbluetooth_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_x0(x0); - response->set_dx(dx); - response->mutable_power()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_x0(x0); + response->set_dx(dx); + response->mutable_power()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -4118,13 +4327,14 @@ namespace nirfmxbluetooth_grpc { float64 average_power_minimum {}; float64 peak_to_average_power_ratio_maximum {}; auto status = library_->TXPFetchPowers(instrument, selector_string, timeout, &average_power_mean, &average_power_maximum, &average_power_minimum, &peak_to_average_power_ratio_maximum); - response->set_status(status); - if (status_ok(status)) { - response->set_average_power_mean(average_power_mean); - response->set_average_power_maximum(average_power_maximum); - response->set_average_power_minimum(average_power_minimum); - response->set_peak_to_average_power_ratio_maximum(peak_to_average_power_ratio_maximum); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_average_power_mean(average_power_mean); + response->set_average_power_maximum(average_power_maximum); + response->set_average_power_minimum(average_power_minimum); + response->set_peak_to_average_power_ratio_maximum(peak_to_average_power_ratio_maximum); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -4161,6 +4371,9 @@ namespace nirfmxbluetooth_grpc { int32 averaging_count = request->averaging_count(); auto status = library_->TwentydBBandwidthCfgAveraging(instrument, selector_string, averaging_enabled, averaging_count); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -4186,13 +4399,14 @@ namespace nirfmxbluetooth_grpc { float64 high_frequency {}; float64 low_frequency {}; auto status = library_->TwentydBBandwidthFetchMeasurement(instrument, selector_string, timeout, &peak_power, &bandwidth, &high_frequency, &low_frequency); - response->set_status(status); - if (status_ok(status)) { - response->set_peak_power(peak_power); - response->set_bandwidth(bandwidth); - response->set_high_frequency(high_frequency); - response->set_low_frequency(low_frequency); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_peak_power(peak_power); + response->set_bandwidth(bandwidth); + response->set_high_frequency(high_frequency); + response->set_low_frequency(low_frequency); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -4217,9 +4431,8 @@ namespace nirfmxbluetooth_grpc { int32 actual_array_size {}; while (true) { auto status = library_->TwentydBBandwidthFetchSpectrum(instrument, selector_string, timeout, &x0, &dx, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_spectrum()->Resize(actual_array_size, 0); float32* spectrum = response->mutable_spectrum()->mutable_data(); @@ -4229,13 +4442,14 @@ namespace nirfmxbluetooth_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_x0(x0); - response->set_dx(dx); - response->mutable_spectrum()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_x0(x0); + response->set_dx(dx); + response->mutable_spectrum()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -4256,6 +4470,9 @@ namespace nirfmxbluetooth_grpc { niRFmxInstrHandle instrument = session_repository_->access_session(instrument_grpc_session.id(), instrument_grpc_session.name()); float64 timeout = request->timeout(); auto status = library_->WaitForAcquisitionComplete(instrument, timeout); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -4277,6 +4494,9 @@ namespace nirfmxbluetooth_grpc { char* selector_string = (char*)request->selector_string().c_str(); float64 timeout = request->timeout(); auto status = library_->WaitForMeasurementComplete(instrument, selector_string, timeout); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } diff --git a/generated/nirfmxbluetooth/nirfmxbluetooth_service.h b/generated/nirfmxbluetooth/nirfmxbluetooth_service.h index 86e375a2c..79f990cf0 100644 --- a/generated/nirfmxbluetooth/nirfmxbluetooth_service.h +++ b/generated/nirfmxbluetooth/nirfmxbluetooth_service.h @@ -178,6 +178,7 @@ class NiRFmxBluetoothService final : public NiRFmxBluetooth::Service { NiRFmxBluetoothLibraryInterface* library_; ResourceRepositorySharedPtr session_repository_; ViSessionResourceRepositorySharedPtr vi_session_resource_repository_; + ::grpc::Status ConvertApiErrorStatusForNiRFmxInstrHandle(google::protobuf::int32 status, niRFmxInstrHandle instrumentHandle); std::map frequencyreferencesource_input_map_ { {1, "OnboardClock"},{2, "RefIn"},{3, "PXI_Clk"},{4, "ClkIn"}, }; std::map frequencyreferencesource_output_map_ { {"OnboardClock", 1},{"RefIn", 2},{"PXI_Clk", 3},{"ClkIn", 4}, }; std::map nirfmxbluetoothstringattributevaluesmapped_input_map_ { {1, "PFI0"},{2, "PFI1"},{3, "PXI_Trig0"},{4, "PXI_Trig1"},{5, "PXI_Trig2"},{6, "PXI_Trig3"},{7, "PXI_Trig4"},{8, "PXI_Trig5"},{9, "PXI_Trig6"},{10, "PXI_Trig7"},{11, "PXI_STAR"},{12, "PXIe_DStarB"},{13, "TimerEvent"}, }; diff --git a/generated/nirfmxinstr/nirfmxinstr_service.cpp b/generated/nirfmxinstr/nirfmxinstr_service.cpp index 989d5e84b..c3bb6bbd2 100644 --- a/generated/nirfmxinstr/nirfmxinstr_service.cpp +++ b/generated/nirfmxinstr/nirfmxinstr_service.cpp @@ -59,9 +59,8 @@ namespace nirfmxinstr_grpc { while (true) { auto status = library_->BuildCalibrationPlaneString(calibration_plane_name, 0, nullptr); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, 0); } int32 selector_string_length = status; @@ -74,11 +73,12 @@ namespace nirfmxinstr_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_selector_string(selector_string); - nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_selector_string())); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, 0); } + response->set_status(status); + response->set_selector_string(selector_string); + nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_selector_string())); return ::grpc::Status::OK; } } @@ -100,9 +100,8 @@ namespace nirfmxinstr_grpc { while (true) { auto status = library_->BuildInstrumentString(selector_string, instrument_number, 0, nullptr); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, 0); } int32 selector_string_out_length = status; @@ -115,11 +114,12 @@ namespace nirfmxinstr_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_selector_string_out(selector_string_out); - nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_selector_string_out())); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, 0); } + response->set_status(status); + response->set_selector_string_out(selector_string_out); + nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_selector_string_out())); return ::grpc::Status::OK; } } @@ -141,9 +141,8 @@ namespace nirfmxinstr_grpc { while (true) { auto status = library_->BuildLOString(selector_string, lo_index, 0, nullptr); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, 0); } int32 selector_string_out_length = status; @@ -156,11 +155,12 @@ namespace nirfmxinstr_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_selector_string_out(selector_string_out); - nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_selector_string_out())); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, 0); } + response->set_status(status); + response->set_selector_string_out(selector_string_out); + nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_selector_string_out())); return ::grpc::Status::OK; } } @@ -182,9 +182,8 @@ namespace nirfmxinstr_grpc { while (true) { auto status = library_->BuildModuleString(selector_string, module_name, 0, nullptr); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, 0); } int32 selector_string_out_length = status; @@ -197,11 +196,12 @@ namespace nirfmxinstr_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_selector_string_out(selector_string_out); - nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_selector_string_out())); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, 0); } + response->set_status(status); + response->set_selector_string_out(selector_string_out); + nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_selector_string_out())); return ::grpc::Status::OK; } } @@ -239,6 +239,9 @@ namespace nirfmxinstr_grpc { } auto status = library_->CfgExternalAttenuationInterpolationLinear(instrument, selector_string, table_name, format); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -260,6 +263,9 @@ namespace nirfmxinstr_grpc { char* selector_string = (char*)request->selector_string().c_str(); char* table_name = (char*)request->table_name().c_str(); auto status = library_->CfgExternalAttenuationInterpolationNearest(instrument, selector_string, table_name); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -281,6 +287,9 @@ namespace nirfmxinstr_grpc { char* selector_string = (char*)request->selector_string().c_str(); char* table_name = (char*)request->table_name().c_str(); auto status = library_->CfgExternalAttenuationInterpolationSpline(instrument, selector_string, table_name); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -321,6 +330,9 @@ namespace nirfmxinstr_grpc { auto array_size = array_size_size_calculation.size; auto status = library_->CfgExternalAttenuationTable(instrument, selector_string, table_name, frequency, external_attenuation, array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -362,6 +374,9 @@ namespace nirfmxinstr_grpc { float64 frequency_reference_frequency = request->frequency_reference_frequency(); auto status = library_->CfgFrequencyReference(instrument, channel_name, frequency_reference_source, frequency_reference_frequency); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -399,6 +414,9 @@ namespace nirfmxinstr_grpc { float64 mechanical_attenuation_value = request->mechanical_attenuation_value(); auto status = library_->CfgMechanicalAttenuation(instrument, channel_name, mechanical_attenuation_auto, mechanical_attenuation_value); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -436,6 +454,9 @@ namespace nirfmxinstr_grpc { float64 rf_attenuation_value = request->rf_attenuation_value(); auto status = library_->CfgRFAttenuation(instrument, channel_name, rf_attenuation_auto, rf_attenuation_value); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -478,6 +499,9 @@ namespace nirfmxinstr_grpc { } auto status = library_->CfgSParameterExternalAttenuationTable(instrument, selector_string, table_name, frequency, frequency_array_size, s_parameters.data(), s_parameter_table_size, number_of_ports, s_parameter_orientation); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -514,6 +538,9 @@ namespace nirfmxinstr_grpc { } auto status = library_->CfgSParameterExternalAttenuationType(instrument, selector_string, s_parameter_type); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -534,10 +561,11 @@ namespace nirfmxinstr_grpc { niRFmxInstrHandle instrument = session_repository_->access_session(instrument_grpc_session.id(), instrument_grpc_session.name()); int32 acquisition_done {}; auto status = library_->CheckAcquisitionStatus(instrument, &acquisition_done); - response->set_status(status); - if (status_ok(status)) { - response->set_acquisition_done(acquisition_done); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_acquisition_done(acquisition_done); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -559,12 +587,13 @@ namespace nirfmxinstr_grpc { int32 list_exists {}; int32 personality {}; auto status = library_->CheckIfListExists(instrument, list_name, &list_exists, &personality); - response->set_status(status); - if (status_ok(status)) { - response->set_list_exists(list_exists); - response->set_personality(static_cast(personality)); - response->set_personality_raw(personality); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_list_exists(list_exists); + response->set_personality(static_cast(personality)); + response->set_personality_raw(personality); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -586,12 +615,13 @@ namespace nirfmxinstr_grpc { int32 signal_configuration_exists {}; int32 personality {}; auto status = library_->CheckIfSignalConfigurationExists(instrument, signal_name, &signal_configuration_exists, &personality); - response->set_status(status); - if (status_ok(status)) { - response->set_signal_configuration_exists(signal_configuration_exists); - response->set_personality(static_cast(personality)); - response->set_personality_raw(personality); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_signal_configuration_exists(signal_configuration_exists); + response->set_personality(static_cast(personality)); + response->set_personality_raw(personality); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -612,6 +642,9 @@ namespace nirfmxinstr_grpc { int32 force_destroy = request->force_destroy(); session_repository_->remove_session(instrument_grpc_session.id(), instrument_grpc_session.name()); auto status = library_->Close(instrument, force_destroy); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -632,6 +665,9 @@ namespace nirfmxinstr_grpc { niRFmxInstrHandle instrument = session_repository_->access_session(instrument_grpc_session.id(), instrument_grpc_session.name()); char* selector_string = (char*)request->selector_string().c_str(); auto status = library_->DeleteAllExternalAttenuationTables(instrument, selector_string); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -653,6 +689,9 @@ namespace nirfmxinstr_grpc { char* selector_string = (char*)request->selector_string().c_str(); char* table_name = (char*)request->table_name().c_str(); auto status = library_->DeleteExternalAttenuationTable(instrument, selector_string, table_name); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -673,6 +712,9 @@ namespace nirfmxinstr_grpc { niRFmxInstrHandle instrument = session_repository_->access_session(instrument_grpc_session.id(), instrument_grpc_session.name()); char* selector_string = (char*)request->selector_string().c_str(); auto status = library_->DisableCalibrationPlane(instrument, selector_string); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -693,6 +735,9 @@ namespace nirfmxinstr_grpc { niRFmxInstrHandle instrument = session_repository_->access_session(instrument_grpc_session.id(), instrument_grpc_session.name()); char* selector_string = (char*)request->selector_string().c_str(); auto status = library_->EnableCalibrationPlane(instrument, selector_string); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -748,6 +793,9 @@ namespace nirfmxinstr_grpc { } auto status = library_->ExportSignal(instrument, export_signal_source, export_signal_output_terminal); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -770,10 +818,11 @@ namespace nirfmxinstr_grpc { int32 attribute_id = request->attribute_id(); float32 attr_val {}; auto status = library_->GetAttributeF32(instrument, channel_name, attribute_id, &attr_val); - response->set_status(status); - if (status_ok(status)) { - response->set_attr_val(attr_val); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_attr_val(attr_val); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -796,9 +845,8 @@ namespace nirfmxinstr_grpc { int32 actual_array_size {}; while (true) { auto status = library_->GetAttributeF32Array(instrument, channel_name, attribute_id, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_attr_val()->Resize(actual_array_size, 0); float32* attr_val = response->mutable_attr_val()->mutable_data(); @@ -808,11 +856,12 @@ namespace nirfmxinstr_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->mutable_attr_val()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->mutable_attr_val()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -835,10 +884,11 @@ namespace nirfmxinstr_grpc { int32 attribute_id = request->attribute_id(); float64 attr_val {}; auto status = library_->GetAttributeF64(instrument, channel_name, attribute_id, &attr_val); - response->set_status(status); - if (status_ok(status)) { - response->set_attr_val(attr_val); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_attr_val(attr_val); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -861,9 +911,8 @@ namespace nirfmxinstr_grpc { int32 actual_array_size {}; while (true) { auto status = library_->GetAttributeF64Array(instrument, channel_name, attribute_id, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_attr_val()->Resize(actual_array_size, 0); float64* attr_val = response->mutable_attr_val()->mutable_data(); @@ -873,11 +922,12 @@ namespace nirfmxinstr_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->mutable_attr_val()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->mutable_attr_val()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -900,10 +950,11 @@ namespace nirfmxinstr_grpc { int32 attribute_id = request->attribute_id(); int16 attr_val {}; auto status = library_->GetAttributeI16(instrument, channel_name, attribute_id, &attr_val); - response->set_status(status); - if (status_ok(status)) { - response->set_attr_val(attr_val); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_attr_val(attr_val); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -925,16 +976,17 @@ namespace nirfmxinstr_grpc { int32 attribute_id = request->attribute_id(); int32 attr_val {}; auto status = library_->GetAttributeI32(instrument, channel_name, attribute_id, &attr_val); - response->set_status(status); - if (status_ok(status)) { - auto checked_convert_attr_val = [](auto raw_value) { - bool raw_value_is_valid = nirfmxinstr_grpc::NiRFmxInstrInt32AttributeValues_IsValid(raw_value); - auto valid_enum_value = raw_value_is_valid ? raw_value : 0; - return static_cast(valid_enum_value); - }; - response->set_attr_val(checked_convert_attr_val(attr_val)); - response->set_attr_val_raw(attr_val); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + auto checked_convert_attr_val = [](auto raw_value) { + bool raw_value_is_valid = nirfmxinstr_grpc::NiRFmxInstrInt32AttributeValues_IsValid(raw_value); + auto valid_enum_value = raw_value_is_valid ? raw_value : 0; + return static_cast(valid_enum_value); + }; + response->set_attr_val(checked_convert_attr_val(attr_val)); + response->set_attr_val_raw(attr_val); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -957,9 +1009,8 @@ namespace nirfmxinstr_grpc { int32 actual_array_size {}; while (true) { auto status = library_->GetAttributeI32Array(instrument, channel_name, attribute_id, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_attr_val_raw()->Resize(actual_array_size, 0); int32* attr_val = reinterpret_cast(response->mutable_attr_val_raw()->mutable_data()); @@ -969,13 +1020,15 @@ namespace nirfmxinstr_grpc { // buffer is now too small, try again continue; } + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); - if (status_ok(status)) { - auto checked_convert_attr_val = [](auto raw_value) { - bool raw_value_is_valid = nirfmxinstr_grpc::NiRFmxInstrInt32AttributeValues_IsValid(raw_value); - auto valid_enum_value = raw_value_is_valid ? raw_value : 0; - return static_cast(valid_enum_value); - }; + auto checked_convert_attr_val = [](auto raw_value) { + bool raw_value_is_valid = nirfmxinstr_grpc::NiRFmxInstrInt32AttributeValues_IsValid(raw_value); + auto valid_enum_value = raw_value_is_valid ? raw_value : 0; + return static_cast(valid_enum_value); + }; response->mutable_attr_val()->Clear(); response->mutable_attr_val()->Reserve(actual_array_size); std::transform( @@ -985,9 +1038,8 @@ namespace nirfmxinstr_grpc { [&](auto x) { return checked_convert_attr_val(x); }); - response->mutable_attr_val()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); - } + response->mutable_attr_val()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -1010,10 +1062,11 @@ namespace nirfmxinstr_grpc { int32 attribute_id = request->attribute_id(); int64 attr_val {}; auto status = library_->GetAttributeI64(instrument, channel_name, attribute_id, &attr_val); - response->set_status(status); - if (status_ok(status)) { - response->set_attr_val(attr_val); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_attr_val(attr_val); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -1036,9 +1089,8 @@ namespace nirfmxinstr_grpc { int32 actual_array_size {}; while (true) { auto status = library_->GetAttributeI64Array(instrument, channel_name, attribute_id, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_attr_val()->Resize(actual_array_size, 0); int64* attr_val = reinterpret_cast(response->mutable_attr_val()->mutable_data()); @@ -1048,11 +1100,12 @@ namespace nirfmxinstr_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->mutable_attr_val()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->mutable_attr_val()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -1075,10 +1128,11 @@ namespace nirfmxinstr_grpc { int32 attribute_id = request->attribute_id(); int8 attr_val {}; auto status = library_->GetAttributeI8(instrument, channel_name, attribute_id, &attr_val); - response->set_status(status); - if (status_ok(status)) { - response->set_attr_val(attr_val); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_attr_val(attr_val); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -1101,9 +1155,8 @@ namespace nirfmxinstr_grpc { int32 actual_array_size {}; while (true) { auto status = library_->GetAttributeI8Array(instrument, channel_name, attribute_id, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } std::vector attr_val(actual_array_size); auto array_size = actual_array_size; @@ -1112,8 +1165,10 @@ namespace nirfmxinstr_grpc { // buffer is now too small, try again continue; } + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); - if (status_ok(status)) { response->mutable_attr_val()->Clear(); response->mutable_attr_val()->Reserve(actual_array_size); std::transform( @@ -1123,9 +1178,8 @@ namespace nirfmxinstr_grpc { [&](auto x) { return x; }); - response->mutable_attr_val()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); - } + response->mutable_attr_val()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -1149,9 +1203,8 @@ namespace nirfmxinstr_grpc { int32 actual_array_size {}; while (true) { auto status = library_->GetAttributeNIComplexDoubleArray(instrument, channel_name, attribute_id, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } std::vector attr_val(actual_array_size, NIComplexDouble()); auto array_size = actual_array_size; @@ -1160,18 +1213,19 @@ namespace nirfmxinstr_grpc { // buffer is now too small, try again continue; } + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); - if (status_ok(status)) { - convert_to_grpc(attr_val, response->mutable_attr_val()); - { - auto shrunk_size = actual_array_size; - auto current_size = response->mutable_attr_val()->size(); - if (shrunk_size != current_size) { - response->mutable_attr_val()->DeleteSubrange(shrunk_size, current_size - shrunk_size); - } + convert_to_grpc(attr_val, response->mutable_attr_val()); + { + auto shrunk_size = actual_array_size; + auto current_size = response->mutable_attr_val()->size(); + if (shrunk_size != current_size) { + response->mutable_attr_val()->DeleteSubrange(shrunk_size, current_size - shrunk_size); } - response->set_actual_array_size(actual_array_size); } + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -1195,9 +1249,8 @@ namespace nirfmxinstr_grpc { int32 actual_array_size {}; while (true) { auto status = library_->GetAttributeNIComplexSingleArray(instrument, channel_name, attribute_id, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } std::vector attr_val(actual_array_size, NIComplexSingle()); auto array_size = actual_array_size; @@ -1206,18 +1259,19 @@ namespace nirfmxinstr_grpc { // buffer is now too small, try again continue; } + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); - if (status_ok(status)) { - convert_to_grpc(attr_val, response->mutable_attr_val()); - { - auto shrunk_size = actual_array_size; - auto current_size = response->mutable_attr_val()->size(); - if (shrunk_size != current_size) { - response->mutable_attr_val()->DeleteSubrange(shrunk_size, current_size - shrunk_size); - } + convert_to_grpc(attr_val, response->mutable_attr_val()); + { + auto shrunk_size = actual_array_size; + auto current_size = response->mutable_attr_val()->size(); + if (shrunk_size != current_size) { + response->mutable_attr_val()->DeleteSubrange(shrunk_size, current_size - shrunk_size); } - response->set_actual_array_size(actual_array_size); } + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -1241,9 +1295,8 @@ namespace nirfmxinstr_grpc { while (true) { auto status = library_->GetAttributeString(instrument, channel_name, attribute_id, 0, nullptr); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } int32 array_size = status; @@ -1256,11 +1309,12 @@ namespace nirfmxinstr_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_attr_val(attr_val); - nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_attr_val())); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_attr_val(attr_val); + nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_attr_val())); return ::grpc::Status::OK; } } @@ -1283,10 +1337,11 @@ namespace nirfmxinstr_grpc { int32 attribute_id = request->attribute_id(); uInt16 attr_val {}; auto status = library_->GetAttributeU16(instrument, channel_name, attribute_id, &attr_val); - response->set_status(status); - if (status_ok(status)) { - response->set_attr_val(attr_val); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_attr_val(attr_val); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -1308,10 +1363,11 @@ namespace nirfmxinstr_grpc { int32 attribute_id = request->attribute_id(); uInt32 attr_val {}; auto status = library_->GetAttributeU32(instrument, channel_name, attribute_id, &attr_val); - response->set_status(status); - if (status_ok(status)) { - response->set_attr_val(attr_val); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_attr_val(attr_val); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -1334,9 +1390,8 @@ namespace nirfmxinstr_grpc { int32 actual_array_size {}; while (true) { auto status = library_->GetAttributeU32Array(instrument, channel_name, attribute_id, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_attr_val()->Resize(actual_array_size, 0); uInt32* attr_val = reinterpret_cast(response->mutable_attr_val()->mutable_data()); @@ -1346,11 +1401,12 @@ namespace nirfmxinstr_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->mutable_attr_val()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->mutable_attr_val()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -1374,9 +1430,8 @@ namespace nirfmxinstr_grpc { int32 actual_array_size {}; while (true) { auto status = library_->GetAttributeU64Array(instrument, channel_name, attribute_id, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_attr_val()->Resize(actual_array_size, 0); uInt64* attr_val = reinterpret_cast(response->mutable_attr_val()->mutable_data()); @@ -1386,11 +1441,12 @@ namespace nirfmxinstr_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->mutable_attr_val()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->mutable_attr_val()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -1413,10 +1469,11 @@ namespace nirfmxinstr_grpc { int32 attribute_id = request->attribute_id(); uInt8 attr_val {}; auto status = library_->GetAttributeU8(instrument, channel_name, attribute_id, &attr_val); - response->set_status(status); - if (status_ok(status)) { - response->set_attr_val(attr_val); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_attr_val(attr_val); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -1439,9 +1496,8 @@ namespace nirfmxinstr_grpc { int32 actual_array_size {}; while (true) { auto status = library_->GetAttributeU8Array(instrument, channel_name, attribute_id, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } std::string attr_val(actual_array_size, '\0'); auto array_size = actual_array_size; @@ -1450,12 +1506,13 @@ namespace nirfmxinstr_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_attr_val(attr_val); - response->mutable_attr_val()->resize(actual_array_size); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_attr_val(attr_val); + response->mutable_attr_val()->resize(actual_array_size); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -1478,9 +1535,8 @@ namespace nirfmxinstr_grpc { while (true) { auto status = library_->GetAvailablePorts(instrument, selector_string, 0, nullptr); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } int32 array_size = status; @@ -1493,11 +1549,12 @@ namespace nirfmxinstr_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_available_ports(available_ports); - nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_available_ports())); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_available_ports(available_ports); + nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_available_ports())); return ::grpc::Status::OK; } } @@ -1519,9 +1576,8 @@ namespace nirfmxinstr_grpc { while (true) { auto status = library_->GetError(instrument, nullptr, 0, nullptr); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } int32 error_description_buffer_size = status; @@ -1535,12 +1591,13 @@ namespace nirfmxinstr_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_error_code(error_code); - response->set_error_description(error_description); - nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_error_description())); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_error_code(error_code); + response->set_error_description(error_description); + nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_error_description())); return ::grpc::Status::OK; } } @@ -1563,9 +1620,8 @@ namespace nirfmxinstr_grpc { while (true) { auto status = library_->GetErrorString(instrument, error_code, 0, nullptr); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } int32 error_description_buffer_size = status; @@ -1578,11 +1634,12 @@ namespace nirfmxinstr_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_error_description(error_description); - nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_error_description())); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_error_description(error_description); + nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_error_description())); return ::grpc::Status::OK; } } @@ -1604,10 +1661,11 @@ namespace nirfmxinstr_grpc { char* selector_string = (char*)request->selector_string().c_str(); float64 external_attenuation {}; auto status = library_->GetExternalAttenuationTableActualValue(instrument, selector_string, &external_attenuation); - response->set_status(status); - if (status_ok(status)) { - response->set_external_attenuation(external_attenuation); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_external_attenuation(external_attenuation); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -1646,9 +1704,8 @@ namespace nirfmxinstr_grpc { int32 actual_personality_array_size {}; while (true) { auto status = library_->GetListNames(instrument, selector_string, personality_filter, nullptr, 0, &actual_list_names_size, nullptr, 0, &actual_personality_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } std::string list_names; if (actual_list_names_size > 0) { @@ -1663,11 +1720,13 @@ namespace nirfmxinstr_grpc { // buffer is now too small, try again continue; } + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); - if (status_ok(status)) { - response->set_list_names(list_names); - nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_list_names())); - response->set_actual_list_names_size(actual_list_names_size); + response->set_list_names(list_names); + nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_list_names())); + response->set_actual_list_names_size(actual_list_names_size); response->mutable_personality()->Clear(); response->mutable_personality()->Reserve(actual_personality_array_size); std::transform( @@ -1677,9 +1736,8 @@ namespace nirfmxinstr_grpc { [&](auto x) { return static_cast(x); }); - response->mutable_personality()->Resize(actual_personality_array_size, 0); - response->set_actual_personality_array_size(actual_personality_array_size); - } + response->mutable_personality()->Resize(actual_personality_array_size, 0); + response->set_actual_personality_array_size(actual_personality_array_size); return ::grpc::Status::OK; } } @@ -1735,11 +1793,12 @@ namespace nirfmxinstr_grpc { char* selector_string = (char*)request->selector_string().c_str(); int32 s_parameter_type {}; auto status = library_->GetSParameterExternalAttenuationType(instrument, selector_string, &s_parameter_type); - response->set_status(status); - if (status_ok(status)) { - response->set_s_parameter_type(static_cast(s_parameter_type)); - response->set_s_parameter_type_raw(s_parameter_type); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_s_parameter_type(static_cast(s_parameter_type)); + response->set_s_parameter_type_raw(s_parameter_type); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -1776,10 +1835,11 @@ namespace nirfmxinstr_grpc { CVIAbsoluteTime timestamp {}; auto status = library_->GetSelfCalibrateLastDateAndTime(instrument, selector_string, self_calibrate_step, ×tamp); - response->set_status(status); - if (status_ok(status)) { - convert_to_grpc(timestamp, response->mutable_timestamp()); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + convert_to_grpc(timestamp, response->mutable_timestamp()); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -1816,10 +1876,11 @@ namespace nirfmxinstr_grpc { float64 temperature {}; auto status = library_->GetSelfCalibrateLastTemperature(instrument, selector_string, self_calibrate_step, &temperature); - response->set_status(status); - if (status_ok(status)) { - response->set_temperature(temperature); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_temperature(temperature); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -1858,9 +1919,8 @@ namespace nirfmxinstr_grpc { int32 actual_personality_array_size {}; while (true) { auto status = library_->GetSignalConfigurationNames(instrument, selector_string, personality_filter, nullptr, 0, &actual_signal_names_size, nullptr, 0, &actual_personality_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } std::string signal_names; if (actual_signal_names_size > 0) { @@ -1875,14 +1935,15 @@ namespace nirfmxinstr_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_signal_names(signal_names); - nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_signal_names())); - response->set_actual_signal_names_size(actual_signal_names_size); - response->mutable_personality()->Resize(actual_personality_array_size, 0); - response->set_actual_personality_array_size(actual_personality_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_signal_names(signal_names); + nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_signal_names())); + response->set_actual_signal_names_size(actual_signal_names_size); + response->mutable_personality()->Resize(actual_personality_array_size, 0); + response->set_actual_personality_array_size(actual_personality_array_size); return ::grpc::Status::OK; } } @@ -1912,15 +1973,12 @@ namespace nirfmxinstr_grpc { const std::string& grpc_device_session_name = request->session_name(); auto cleanup_lambda = [&] (niRFmxInstrHandle id) { library_->Close(id, RFMXINSTR_VAL_FALSE); }; int status = session_repository_->add_session(grpc_device_session_name, init_lambda, cleanup_lambda, session_id); - response->set_status(status); - if (status_ok(status)) { - response->mutable_instrument()->set_id(session_id); - response->set_is_new_session(is_new_session); - } - else { - const auto error_message = get_last_error_message(library_); - response->set_error_message(error_message); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, 0); } + response->set_status(status); + response->mutable_instrument()->set_id(session_id); + response->set_is_new_session(is_new_session); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -1951,14 +2009,11 @@ namespace nirfmxinstr_grpc { const std::string& grpc_device_session_name = request->session_name(); auto cleanup_lambda = [&] (niRFmxInstrHandle id) { library_->Close(id, RFMXINSTR_VAL_FALSE); }; int status = session_repository_->add_session(grpc_device_session_name, init_lambda, cleanup_lambda, session_id); - response->set_status(status); - if (status_ok(status)) { - response->mutable_instrument()->set_id(session_id); - } - else { - const auto error_message = get_last_error_message(library_); - response->set_error_message(error_message); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, 0); } + response->set_status(status); + response->mutable_instrument()->set_id(session_id); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -1995,14 +2050,11 @@ namespace nirfmxinstr_grpc { const std::string& grpc_device_session_name = request->session_name(); auto cleanup_lambda = [&] (niRFmxInstrHandle id) { library_->Close(id, RFMXINSTR_VAL_FALSE); }; int status = session_repository_->add_session(grpc_device_session_name, init_lambda, cleanup_lambda, session_id); - response->set_status(status); - if (status_ok(status)) { - response->mutable_instrument()->set_id(session_id); - } - else { - const auto error_message = get_last_error_message(library_); - response->set_error_message(error_message); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, 0); } + response->set_status(status); + response->mutable_instrument()->set_id(session_id); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -2027,31 +2079,32 @@ namespace nirfmxinstr_grpc { int32 self_calibrate_valid {}; int32 valid_steps {}; auto status = library_->IsSelfCalibrateValid(instrument, selector_string, &self_calibrate_valid, &valid_steps); - response->set_status(status); - if (status_ok(status)) { - response->set_self_calibrate_valid(self_calibrate_valid); - if (valid_steps & 0x20) - response->add_valid_steps_array(SelfCalStep::SELF_CAL_STEP_AMPLITUDE_ACCURACY); - if (valid_steps & 0x200) - response->add_valid_steps_array(SelfCalStep::SELF_CAL_STEP_DC_OFFSET); - if (valid_steps & 0x8) - response->add_valid_steps_array(SelfCalStep::SELF_CAL_STEP_DIGITIZER_SELF_CAL); - if (valid_steps & 0x2) - response->add_valid_steps_array(SelfCalStep::SELF_CAL_STEP_GAIN_REFERENCE); - if (valid_steps & 0x4) - response->add_valid_steps_array(SelfCalStep::SELF_CAL_STEP_IF_FLATNESS); - if (valid_steps & 0x80) - response->add_valid_steps_array(SelfCalStep::SELF_CAL_STEP_IMAGE_SUPPRESSION); - if (valid_steps & 0x10) - response->add_valid_steps_array(SelfCalStep::SELF_CAL_STEP_LO_SELF_CAL); - if (valid_steps & 0x1) - response->add_valid_steps_array(SelfCalStep::SELF_CAL_STEP_PRESELECTOR_ALIGNMENT); - if (valid_steps & 0x40) - response->add_valid_steps_array(SelfCalStep::SELF_CAL_STEP_RESIDUAL_LO_POWER); - if (valid_steps & 0x100) - response->add_valid_steps_array(SelfCalStep::SELF_CAL_STEP_SYNTHESIZER_ALIGNMENT); - response->set_valid_steps_raw(valid_steps); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_self_calibrate_valid(self_calibrate_valid); + if (valid_steps & 0x20) + response->add_valid_steps_array(SelfCalStep::SELF_CAL_STEP_AMPLITUDE_ACCURACY); + if (valid_steps & 0x200) + response->add_valid_steps_array(SelfCalStep::SELF_CAL_STEP_DC_OFFSET); + if (valid_steps & 0x8) + response->add_valid_steps_array(SelfCalStep::SELF_CAL_STEP_DIGITIZER_SELF_CAL); + if (valid_steps & 0x2) + response->add_valid_steps_array(SelfCalStep::SELF_CAL_STEP_GAIN_REFERENCE); + if (valid_steps & 0x4) + response->add_valid_steps_array(SelfCalStep::SELF_CAL_STEP_IF_FLATNESS); + if (valid_steps & 0x80) + response->add_valid_steps_array(SelfCalStep::SELF_CAL_STEP_IMAGE_SUPPRESSION); + if (valid_steps & 0x10) + response->add_valid_steps_array(SelfCalStep::SELF_CAL_STEP_LO_SELF_CAL); + if (valid_steps & 0x1) + response->add_valid_steps_array(SelfCalStep::SELF_CAL_STEP_PRESELECTOR_ALIGNMENT); + if (valid_steps & 0x40) + response->add_valid_steps_array(SelfCalStep::SELF_CAL_STEP_RESIDUAL_LO_POWER); + if (valid_steps & 0x100) + response->add_valid_steps_array(SelfCalStep::SELF_CAL_STEP_SYNTHESIZER_ALIGNMENT); + response->set_valid_steps_raw(valid_steps); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -2072,6 +2125,9 @@ namespace nirfmxinstr_grpc { char* file_path = (char*)request->file_path().c_str(); int32 load_rf_instr_configuration = request->load_rf_instr_configuration(); auto status = library_->LoadAllConfigurations(instrument, file_path, load_rf_instr_configuration); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -2110,6 +2166,9 @@ namespace nirfmxinstr_grpc { } auto status = library_->LoadSParameterExternalAttenuationTableFromS2PFile(instrument, selector_string, table_name, s2p_file_path, s_parameter_orientation); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -2131,6 +2190,9 @@ namespace nirfmxinstr_grpc { char* channel_name = (char*)request->channel_name().c_str(); int32 attribute_id = request->attribute_id(); auto status = library_->ResetAttribute(instrument, channel_name, attribute_id); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -2150,6 +2212,9 @@ namespace nirfmxinstr_grpc { auto instrument_grpc_session = request->instrument(); niRFmxInstrHandle instrument = session_repository_->access_session(instrument_grpc_session.id(), instrument_grpc_session.name()); auto status = library_->ResetDriver(instrument); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -2169,6 +2234,9 @@ namespace nirfmxinstr_grpc { auto instrument_grpc_session = request->instrument(); niRFmxInstrHandle instrument = session_repository_->access_session(instrument_grpc_session.id(), instrument_grpc_session.name()); auto status = library_->ResetEntireSession(instrument); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -2188,6 +2256,9 @@ namespace nirfmxinstr_grpc { auto instrument_grpc_session = request->instrument(); niRFmxInstrHandle instrument = session_repository_->access_session(instrument_grpc_session.id(), instrument_grpc_session.name()); auto status = library_->ResetToDefault(instrument); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -2208,6 +2279,9 @@ namespace nirfmxinstr_grpc { niRFmxInstrHandle instrument = session_repository_->access_session(instrument_grpc_session.id(), instrument_grpc_session.name()); char* file_path = (char*)request->file_path().c_str(); auto status = library_->SaveAllConfigurations(instrument, file_path); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -2229,6 +2303,9 @@ namespace nirfmxinstr_grpc { char* selector_string = (char*)request->selector_string().c_str(); char* table_name = (char*)request->table_name().c_str(); auto status = library_->SelectActiveExternalAttenuationTable(instrument, selector_string, table_name); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -2265,6 +2342,9 @@ namespace nirfmxinstr_grpc { } auto status = library_->SelfCalibrate(instrument, selector_string, steps_to_omit); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -2305,6 +2385,9 @@ namespace nirfmxinstr_grpc { float64 minimum_reference_level = request->minimum_reference_level(); float64 maximum_reference_level = request->maximum_reference_level(); auto status = library_->SelfCalibrateRange(instrument, selector_string, steps_to_omit, minimum_frequency, maximum_frequency, minimum_reference_level, maximum_reference_level); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -2324,6 +2407,9 @@ namespace nirfmxinstr_grpc { auto instrument_grpc_session = request->instrument(); niRFmxInstrHandle instrument = session_repository_->access_session(instrument_grpc_session.id(), instrument_grpc_session.name()); auto status = library_->SendSoftwareEdgeAdvanceTrigger(instrument); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -2343,6 +2429,9 @@ namespace nirfmxinstr_grpc { auto instrument_grpc_session = request->instrument(); niRFmxInstrHandle instrument = session_repository_->access_session(instrument_grpc_session.id(), instrument_grpc_session.name()); auto status = library_->SendSoftwareEdgeStartTrigger(instrument); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -2365,6 +2454,9 @@ namespace nirfmxinstr_grpc { int32 attribute_id = request->attribute_id(); float32 attr_val = request->attr_val(); auto status = library_->SetAttributeF32(instrument, channel_name, attribute_id, attr_val); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -2388,6 +2480,9 @@ namespace nirfmxinstr_grpc { auto attr_val = const_cast(request->attr_val().data()); int32 array_size = static_cast(request->attr_val().size()); auto status = library_->SetAttributeF32Array(instrument, channel_name, attribute_id, attr_val, array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -2410,6 +2505,9 @@ namespace nirfmxinstr_grpc { int32 attribute_id = request->attribute_id(); float64 attr_val = request->attr_val(); auto status = library_->SetAttributeF64(instrument, channel_name, attribute_id, attr_val); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -2433,6 +2531,9 @@ namespace nirfmxinstr_grpc { auto attr_val = const_cast(request->attr_val().data()); int32 array_size = static_cast(request->attr_val().size()); auto status = library_->SetAttributeF64Array(instrument, channel_name, attribute_id, attr_val, array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -2464,6 +2565,9 @@ namespace nirfmxinstr_grpc { auto attr_val = static_cast(attr_val_raw); auto status = library_->SetAttributeI16(instrument, channel_name, attribute_id, attr_val); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -2504,6 +2608,9 @@ namespace nirfmxinstr_grpc { } auto status = library_->SetAttributeI32(instrument, channel_name, attribute_id, attr_val); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -2535,6 +2642,9 @@ namespace nirfmxinstr_grpc { int32 array_size = static_cast(request->attr_val().size()); auto status = library_->SetAttributeI32Array(instrument, channel_name, attribute_id, attr_val, array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -2557,6 +2667,9 @@ namespace nirfmxinstr_grpc { int32 attribute_id = request->attribute_id(); int64 attr_val = request->attr_val(); auto status = library_->SetAttributeI64(instrument, channel_name, attribute_id, attr_val); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -2580,6 +2693,9 @@ namespace nirfmxinstr_grpc { auto attr_val = const_cast(reinterpret_cast(request->attr_val().data())); int32 array_size = static_cast(request->attr_val().size()); auto status = library_->SetAttributeI64Array(instrument, channel_name, attribute_id, attr_val, array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -2611,6 +2727,9 @@ namespace nirfmxinstr_grpc { auto attr_val = static_cast(attr_val_raw); auto status = library_->SetAttributeI8(instrument, channel_name, attribute_id, attr_val); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -2654,6 +2773,9 @@ namespace nirfmxinstr_grpc { int32 array_size = static_cast(request->attr_val().size()); auto status = library_->SetAttributeI8Array(instrument, channel_name, attribute_id, attr_val.data(), array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -2680,6 +2802,9 @@ namespace nirfmxinstr_grpc { auto attr_val = convert_from_grpc(request->attr_val()); int32 array_size = static_cast(request->attr_val().size()); auto status = library_->SetAttributeNIComplexDoubleArray(instrument, channel_name, attribute_id, attr_val.data(), array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -2703,6 +2828,9 @@ namespace nirfmxinstr_grpc { auto attr_val = convert_from_grpc(request->attr_val()); int32 array_size = static_cast(request->attr_val().size()); auto status = library_->SetAttributeNIComplexSingleArray(instrument, channel_name, attribute_id, attr_val.data(), array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -2744,6 +2872,9 @@ namespace nirfmxinstr_grpc { } auto status = library_->SetAttributeString(instrument, channel_name, attribute_id, attr_val); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -2775,6 +2906,9 @@ namespace nirfmxinstr_grpc { auto attr_val = static_cast(attr_val_raw); auto status = library_->SetAttributeU16(instrument, channel_name, attribute_id, attr_val); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -2800,6 +2934,9 @@ namespace nirfmxinstr_grpc { int32 attribute_id = request->attribute_id(); uInt32 attr_val = request->attr_val(); auto status = library_->SetAttributeU32(instrument, channel_name, attribute_id, attr_val); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -2823,6 +2960,9 @@ namespace nirfmxinstr_grpc { auto attr_val = const_cast(reinterpret_cast(request->attr_val().data())); int32 array_size = static_cast(request->attr_val().size()); auto status = library_->SetAttributeU32Array(instrument, channel_name, attribute_id, attr_val, array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -2846,6 +2986,9 @@ namespace nirfmxinstr_grpc { auto attr_val = const_cast(reinterpret_cast(request->attr_val().data())); int32 array_size = static_cast(request->attr_val().size()); auto status = library_->SetAttributeU64Array(instrument, channel_name, attribute_id, attr_val, array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -2868,6 +3011,9 @@ namespace nirfmxinstr_grpc { int32 attribute_id = request->attribute_id(); uInt8 attr_val = request->attr_val(); auto status = library_->SetAttributeU8(instrument, channel_name, attribute_id, attr_val); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -2891,6 +3037,9 @@ namespace nirfmxinstr_grpc { uInt8* attr_val = (uInt8*)request->attr_val().c_str(); int32 array_size = static_cast(request->attr_val().size()); auto status = library_->SetAttributeU8Array(instrument, channel_name, attribute_id, attr_val, array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -2911,10 +3060,11 @@ namespace nirfmxinstr_grpc { float64 fractional_seconds = request->fractional_seconds(); CVIAbsoluteTime timestamp {}; auto status = library_->TimestampFromValues(seconds_since_1970, fractional_seconds, ×tamp); - response->set_status(status); - if (status_ok(status)) { - convert_to_grpc(timestamp, response->mutable_timestamp()); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, 0); } + response->set_status(status); + convert_to_grpc(timestamp, response->mutable_timestamp()); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -2934,11 +3084,12 @@ namespace nirfmxinstr_grpc { int64 seconds_since_1970 {}; float64 fractional_seconds {}; auto status = library_->ValuesFromTimestamp(timestamp, &seconds_since_1970, &fractional_seconds); - response->set_status(status); - if (status_ok(status)) { - response->set_seconds_since_1970(seconds_since_1970); - response->set_fractional_seconds(fractional_seconds); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, 0); } + response->set_status(status); + response->set_seconds_since_1970(seconds_since_1970); + response->set_fractional_seconds(fractional_seconds); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -2958,6 +3109,9 @@ namespace nirfmxinstr_grpc { niRFmxInstrHandle instrument = session_repository_->access_session(instrument_grpc_session.id(), instrument_grpc_session.name()); float64 timeout = request->timeout(); auto status = library_->WaitForAcquisitionComplete(instrument, timeout); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } diff --git a/generated/nirfmxinstr/nirfmxinstr_service.h b/generated/nirfmxinstr/nirfmxinstr_service.h index 499658b3a..37737ada3 100644 --- a/generated/nirfmxinstr/nirfmxinstr_service.h +++ b/generated/nirfmxinstr/nirfmxinstr_service.h @@ -140,6 +140,7 @@ class NiRFmxInstrService final : public NiRFmxInstr::Service { NiRFmxInstrLibraryInterface* library_; ResourceRepositorySharedPtr session_repository_; ViSessionResourceRepositorySharedPtr vi_session_resource_repository_; + ::grpc::Status ConvertApiErrorStatusForNiRFmxInstrHandle(google::protobuf::int32 status, niRFmxInstrHandle instrumentHandle); std::map frequencyreferencesource_input_map_ { {1, "OnboardClock"},{2, "RefIn"},{3, "PXI_Clk"},{4, "ClkIn"},{5, "RefIn2"},{6, "PXI_ClkMaster"}, }; std::map frequencyreferencesource_output_map_ { {"OnboardClock", 1},{"RefIn", 2},{"PXI_Clk", 3},{"ClkIn", 4},{"RefIn2", 5},{"PXI_ClkMaster", 6}, }; std::map nirfmxinstrstringattributevaluesmapped_input_map_ { {1, "PFI0"},{2, "PFI1"},{3, "PXI_Trig0"},{4, "PXI_Trig1"},{5, "PXI_Trig2"},{6, "PXI_Trig3"},{7, "PXI_Trig4"},{8, "PXI_Trig5"},{9, "PXI_Trig6"},{10, "PXI_Trig7"},{11, "PXI_STAR"},{12, "PXIe_DStarB"},{13, "TimerEvent"},{14, ""},{15, "RefOut"},{16, "RefOut2"},{17, "ClkOut"},{18, ""},{19, "OnboardClock"},{20, "RefIn"},{21, "PXI_Clk"},{22, "ClkIn"},{23, "RefIn2"},{24, "PXI_ClkMaster"},{25, "Automatic_SG_SA_Shared"},{26, "LO_In"},{27, "None"},{28, "Onboard"},{29, "Secondary"},{30, "SG_SA_Shared"},{31, "PFI0"},{32, "PFI1"},{33, "PXI_Trig0"},{34, "PXI_Trig1"},{35, "PXI_Trig2"},{36, "PXI_Trig3"},{37, "PXI_Trig4"},{38, "PXI_Trig5"},{39, "PXI_Trig6"},{40, "PXI_Trig7"},{41, "PXI_STAR"},{42, "PXIe_DStarC"},{43, "PXIe_DStarB"},{44, "TimerEvent"}, }; diff --git a/generated/nirfmxinstr_restricted/nirfmxinstr_restricted_service.cpp b/generated/nirfmxinstr_restricted/nirfmxinstr_restricted_service.cpp index 2dce0cee7..2e5572009 100644 --- a/generated/nirfmxinstr_restricted/nirfmxinstr_restricted_service.cpp +++ b/generated/nirfmxinstr_restricted/nirfmxinstr_restricted_service.cpp @@ -54,6 +54,9 @@ namespace nirfmxinstr_restricted_grpc { try { char* resource_name = (char*)request->resource_name().c_str(); auto status = library_->RegisterSpecialClientSnapshotInterest(resource_name); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, 0); + } response->set_status(status); return ::grpc::Status::OK; } @@ -74,9 +77,8 @@ namespace nirfmxinstr_restricted_grpc { while (true) { auto status = library_->GetOpenSessionsInformation(resource_name, 0, nullptr); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, 0); } int32 info_json_size = status; @@ -89,11 +91,12 @@ namespace nirfmxinstr_restricted_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_info_json(info_json); - nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_info_json())); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, 0); } + response->set_status(status); + response->set_info_json(info_json); + nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_info_json())); return ::grpc::Status::OK; } } @@ -115,9 +118,8 @@ namespace nirfmxinstr_restricted_grpc { while (true) { auto status = library_->GetRFmxVersion(instrument, 0, nullptr); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } int32 array_size = status; @@ -130,11 +132,12 @@ namespace nirfmxinstr_restricted_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_version(version); - nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_version())); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_version(version); + nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_version())); return ::grpc::Status::OK; } } @@ -156,10 +159,11 @@ namespace nirfmxinstr_restricted_grpc { char* selector_string = (char*)request->selector_string().c_str(); int32 all_traces_enabled {}; auto status = library_->GetTracesInfoForMonitorSnapshot(instrument, selector_string, &all_traces_enabled); - response->set_status(status); - if (status_ok(status)) { - response->set_all_traces_enabled(all_traces_enabled); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_all_traces_enabled(all_traces_enabled); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -180,10 +184,11 @@ namespace nirfmxinstr_restricted_grpc { char* channel_name = (char*)request->channel_name().c_str(); int32 attr_val {}; auto status = library_->GetForceAllTracesEnabled(instrument, channel_name, &attr_val); - response->set_status(status); - if (status_ok(status)) { - response->set_attr_val(attr_val); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_attr_val(attr_val); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -204,6 +209,9 @@ namespace nirfmxinstr_restricted_grpc { char* channel_name = (char*)request->channel_name().c_str(); int32 attr_val = request->attr_val(); auto status = library_->SetForceAllTracesEnabled(instrument, channel_name, attr_val); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -226,9 +234,8 @@ namespace nirfmxinstr_restricted_grpc { int32 actual_array_size {}; while (true) { auto status = library_->SaveConfigurationsToJSON(instrument, signal_names, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } std::string json_string_out; if (actual_array_size > 0) { @@ -240,12 +247,13 @@ namespace nirfmxinstr_restricted_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_json_string_out(json_string_out); - nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_json_string_out())); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_json_string_out(json_string_out); + nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_json_string_out())); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -267,6 +275,9 @@ namespace nirfmxinstr_restricted_grpc { char* json_string = (char*)request->json_string().c_str(); int32 array_size = request->array_size(); auto status = library_->LoadConfigurationsFromJSON(instrument, json_string, array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -289,10 +300,11 @@ namespace nirfmxinstr_restricted_grpc { int32 attribute_id = request->attribute_id(); float64 attr_val {}; auto status = library_->GetAttributeDesiredF64(instrument, channel_name, attribute_id, &attr_val); - response->set_status(status); - if (status_ok(status)) { - response->set_attr_val(attr_val); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_attr_val(attr_val); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -314,10 +326,11 @@ namespace nirfmxinstr_restricted_grpc { int32 attribute_id = request->attribute_id(); int32 attr_val {}; auto status = library_->GetAttributeDesiredI32(instrument, channel_name, attribute_id, &attr_val); - response->set_status(status); - if (status_ok(status)) { - response->set_attr_val(attr_val); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_attr_val(attr_val); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -339,10 +352,11 @@ namespace nirfmxinstr_restricted_grpc { int32 attribute_id = request->attribute_id(); int64 attr_val {}; auto status = library_->GetAttributeDesiredI64(instrument, channel_name, attribute_id, &attr_val); - response->set_status(status); - if (status_ok(status)) { - response->set_attr_val(attr_val); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_attr_val(attr_val); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -365,9 +379,8 @@ namespace nirfmxinstr_restricted_grpc { while (true) { auto status = library_->GetAttributeDesiredString(instrument, channel_name, attribute_id, 0, nullptr); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } int32 array_size = status; @@ -380,11 +393,12 @@ namespace nirfmxinstr_restricted_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_attr_val(attr_val); - nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_attr_val())); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_attr_val(attr_val); + nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_attr_val())); return ::grpc::Status::OK; } } @@ -408,9 +422,8 @@ namespace nirfmxinstr_restricted_grpc { int32 actual_array_size {}; while (true) { auto status = library_->GetAttributeDesiredF64Array(instrument, channel_name, attribute_id, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_attr_val()->Resize(actual_array_size, 0); float64* attr_val = response->mutable_attr_val()->mutable_data(); @@ -420,11 +433,12 @@ namespace nirfmxinstr_restricted_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->mutable_attr_val()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->mutable_attr_val()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -448,9 +462,8 @@ namespace nirfmxinstr_restricted_grpc { int32 actual_array_size {}; while (true) { auto status = library_->GetAttributeDesiredF32Array(instrument, channel_name, attribute_id, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_attr_val()->Resize(actual_array_size, 0); float32* attr_val = response->mutable_attr_val()->mutable_data(); @@ -460,11 +473,12 @@ namespace nirfmxinstr_restricted_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->mutable_attr_val()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->mutable_attr_val()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -487,10 +501,11 @@ namespace nirfmxinstr_restricted_grpc { int32 attribute_id = request->attribute_id(); float32 attr_val {}; auto status = library_->GetAttributeDesiredF32(instrument, channel_name, attribute_id, &attr_val); - response->set_status(status); - if (status_ok(status)) { - response->set_attr_val(attr_val); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_attr_val(attr_val); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -512,10 +527,11 @@ namespace nirfmxinstr_restricted_grpc { int32 attribute_id = request->attribute_id(); int32 attr_val {}; auto status = library_->GetAttributeAuthor(instrument, selector_string, attribute_id, &attr_val); - response->set_status(status); - if (status_ok(status)) { - response->set_attr_val(attr_val); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_attr_val(attr_val); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -536,11 +552,12 @@ namespace nirfmxinstr_restricted_grpc { int32 is_connection_alive {}; int32 privilege_level {}; auto status = library_->GetPrivilegeLevel(instrument, &is_connection_alive, &privilege_level); - response->set_status(status); - if (status_ok(status)) { - response->set_is_connection_alive(is_connection_alive); - response->set_privilege_level(privilege_level); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_is_connection_alive(is_connection_alive); + response->set_privilege_level(privilege_level); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -560,6 +577,9 @@ namespace nirfmxinstr_restricted_grpc { niRFmxInstrHandle instrument = session_repository_->access_session(instrument_grpc_session.id(), instrument_grpc_session.name()); int32 privilege_level = request->privilege_level(); auto status = library_->RequestPrivilege(instrument, privilege_level); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -580,6 +600,9 @@ namespace nirfmxinstr_restricted_grpc { niRFmxInstrHandle instrument = session_repository_->access_session(instrument_grpc_session.id(), instrument_grpc_session.name()); char* file_path = (char*)request->file_path().c_str(); auto status = library_->SaveAllForRevert(instrument, file_path); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -600,6 +623,9 @@ namespace nirfmxinstr_restricted_grpc { niRFmxInstrHandle instrument = session_repository_->access_session(instrument_grpc_session.id(), instrument_grpc_session.name()); char* file_path = (char*)request->file_path().c_str(); auto status = library_->LoadAllForRevert(instrument, file_path); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -626,9 +652,8 @@ namespace nirfmxinstr_restricted_grpc { int32 snapshot_timestamp_array_actual_size {}; while (true) { auto status = library_->GetInitiaitedSnapshotStrings(instrument, &snapshot_info_cache_index, nullptr, 0, &personality_id_array_actual_size, nullptr, 0, &signal_names_actual_size, nullptr, 0, &result_names_actual_size, nullptr, 0, &snapshot_identifiers_actual_size, nullptr, 0, &snapshot_timestamp_array_actual_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_personality_id_array()->Resize(personality_id_array_actual_size, 0); int32* personality_id_array = reinterpret_cast(response->mutable_personality_id_array()->mutable_data()); @@ -656,23 +681,24 @@ namespace nirfmxinstr_restricted_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_snapshot_info_cache_index(snapshot_info_cache_index); - response->mutable_personality_id_array()->Resize(personality_id_array_actual_size, 0); - response->set_personality_id_array_actual_size(personality_id_array_actual_size); - response->set_signal_names(signal_names); - nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_signal_names())); - response->set_signal_names_actual_size(signal_names_actual_size); - response->set_result_names(result_names); - nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_result_names())); - response->set_result_names_actual_size(result_names_actual_size); - response->set_snapshot_identifiers(snapshot_identifiers); - nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_snapshot_identifiers())); - response->set_snapshot_identifiers_actual_size(snapshot_identifiers_actual_size); - response->mutable_snapshot_timestamp_array()->Resize(snapshot_timestamp_array_actual_size, 0); - response->set_snapshot_timestamp_array_actual_size(snapshot_timestamp_array_actual_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_snapshot_info_cache_index(snapshot_info_cache_index); + response->mutable_personality_id_array()->Resize(personality_id_array_actual_size, 0); + response->set_personality_id_array_actual_size(personality_id_array_actual_size); + response->set_signal_names(signal_names); + nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_signal_names())); + response->set_signal_names_actual_size(signal_names_actual_size); + response->set_result_names(result_names); + nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_result_names())); + response->set_result_names_actual_size(result_names_actual_size); + response->set_snapshot_identifiers(snapshot_identifiers); + nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_snapshot_identifiers())); + response->set_snapshot_identifiers_actual_size(snapshot_identifiers_actual_size); + response->mutable_snapshot_timestamp_array()->Resize(snapshot_timestamp_array_actual_size, 0); + response->set_snapshot_timestamp_array_actual_size(snapshot_timestamp_array_actual_size); return ::grpc::Status::OK; } } @@ -699,9 +725,8 @@ namespace nirfmxinstr_restricted_grpc { int32 snapshot_timestamp_array_actual_size {}; while (true) { auto status = library_->GetSnapshotInfoFromCache(instrument, snapshot_info_cache_index, nullptr, 0, &personality_id_array_actual_size, nullptr, 0, &signal_names_actual_size, nullptr, 0, &result_names_actual_size, nullptr, 0, &snapshot_identifiers_actual_size, nullptr, 0, &snapshot_timestamp_array_actual_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_personality_id_array()->Resize(personality_id_array_actual_size, 0); int32* personality_id_array = reinterpret_cast(response->mutable_personality_id_array()->mutable_data()); @@ -729,22 +754,23 @@ namespace nirfmxinstr_restricted_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->mutable_personality_id_array()->Resize(personality_id_array_actual_size, 0); - response->set_personality_id_array_actual_size(personality_id_array_actual_size); - response->set_signal_names(signal_names); - nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_signal_names())); - response->set_signal_names_actual_size(signal_names_actual_size); - response->set_result_names(result_names); - nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_result_names())); - response->set_result_names_actual_size(result_names_actual_size); - response->set_snapshot_identifiers(snapshot_identifiers); - nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_snapshot_identifiers())); - response->set_snapshot_identifiers_actual_size(snapshot_identifiers_actual_size); - response->mutable_snapshot_timestamp_array()->Resize(snapshot_timestamp_array_actual_size, 0); - response->set_snapshot_timestamp_array_actual_size(snapshot_timestamp_array_actual_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->mutable_personality_id_array()->Resize(personality_id_array_actual_size, 0); + response->set_personality_id_array_actual_size(personality_id_array_actual_size); + response->set_signal_names(signal_names); + nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_signal_names())); + response->set_signal_names_actual_size(signal_names_actual_size); + response->set_result_names(result_names); + nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_result_names())); + response->set_result_names_actual_size(result_names_actual_size); + response->set_snapshot_identifiers(snapshot_identifiers); + nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_snapshot_identifiers())); + response->set_snapshot_identifiers_actual_size(snapshot_identifiers_actual_size); + response->mutable_snapshot_timestamp_array()->Resize(snapshot_timestamp_array_actual_size, 0); + response->set_snapshot_timestamp_array_actual_size(snapshot_timestamp_array_actual_size); return ::grpc::Status::OK; } } @@ -771,9 +797,8 @@ namespace nirfmxinstr_restricted_grpc { uInt64 signal_timestamp {}; while (true) { auto status = library_->GetLatestConfigurationSnapshot(instrument, &snapshot_info_cache_index, &personality_id, nullptr, 0, &signal_name_actual_size, nullptr, 0, &snapshot_identifier_actual_size, &signal_configuration_state, &signal_timestamp); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } std::string signal_name; if (signal_name_actual_size > 0) { @@ -790,19 +815,20 @@ namespace nirfmxinstr_restricted_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_snapshot_info_cache_index(snapshot_info_cache_index); - response->set_personality_id(personality_id); - response->set_signal_name(signal_name); - nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_signal_name())); - response->set_signal_name_actual_size(signal_name_actual_size); - response->set_snapshot_identifier(snapshot_identifier); - nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_snapshot_identifier())); - response->set_snapshot_identifier_actual_size(snapshot_identifier_actual_size); - response->set_signal_configuration_state(signal_configuration_state); - response->set_signal_timestamp(signal_timestamp); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_snapshot_info_cache_index(snapshot_info_cache_index); + response->set_personality_id(personality_id); + response->set_signal_name(signal_name); + nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_signal_name())); + response->set_signal_name_actual_size(signal_name_actual_size); + response->set_snapshot_identifier(snapshot_identifier); + nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_snapshot_identifier())); + response->set_snapshot_identifier_actual_size(snapshot_identifier_actual_size); + response->set_signal_configuration_state(signal_configuration_state); + response->set_signal_timestamp(signal_timestamp); return ::grpc::Status::OK; } } @@ -825,10 +851,11 @@ namespace nirfmxinstr_restricted_grpc { char* selector_string = (char*)request->selector_string().c_str(); int32 snapshot_state {}; auto status = library_->GetSnapshotState(instrument, personality, selector_string, &snapshot_state); - response->set_status(status); - if (status_ok(status)) { - response->set_snapshot_state(snapshot_state); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_snapshot_state(snapshot_state); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -849,6 +876,9 @@ namespace nirfmxinstr_restricted_grpc { int32 personality = request->personality(); char* selector_string = (char*)request->selector_string().c_str(); auto status = library_->DeleteSnapshot(instrument, personality, selector_string); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -874,10 +904,11 @@ namespace nirfmxinstr_restricted_grpc { float64 bandwidth = request->bandwidth(); float64 reference_or_trigger_level_out {}; auto status = library_->ConvertForPowerUnitsUtility(instrument, reference_or_trigger_level_in, input_power_units, output_power_units, terminal_configuration, bandwidth, &reference_or_trigger_level_out); - response->set_status(status); - if (status_ok(status)) { - response->set_reference_or_trigger_level_out(reference_or_trigger_level_out); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_reference_or_trigger_level_out(reference_or_trigger_level_out); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -895,6 +926,9 @@ namespace nirfmxinstr_restricted_grpc { try { char* resource_name = (char*)request->resource_name().c_str(); auto status = library_->UnregisterSpecialClientSnapshotInterest(resource_name); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, 0); + } response->set_status(status); return ::grpc::Status::OK; } @@ -917,9 +951,8 @@ namespace nirfmxinstr_restricted_grpc { while (true) { auto status = library_->GetCalibrationPlaneNames(instrument, selector_string, 0, nullptr); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } int32 array_size = status; @@ -932,11 +965,12 @@ namespace nirfmxinstr_restricted_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_calibration_plane_names(calibration_plane_names); - nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_calibration_plane_names())); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_calibration_plane_names(calibration_plane_names); + nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_calibration_plane_names())); return ::grpc::Status::OK; } } @@ -958,10 +992,11 @@ namespace nirfmxinstr_restricted_grpc { char* selector_string = (char*)request->selector_string().c_str(); int32 calibration_plane_enabled {}; auto status = library_->GetCalibrationPlaneEnabled(instrument, selector_string, &calibration_plane_enabled); - response->set_status(status); - if (status_ok(status)) { - response->set_calibration_plane_enabled(calibration_plane_enabled); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_calibration_plane_enabled(calibration_plane_enabled); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -983,9 +1018,8 @@ namespace nirfmxinstr_restricted_grpc { while (true) { auto status = library_->GetExternalAttenuationTableNames(instrument, selector_string, 0, nullptr); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } int32 array_size = status; @@ -998,11 +1032,12 @@ namespace nirfmxinstr_restricted_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_external_attenuation_table_names(external_attenuation_table_names); - nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_external_attenuation_table_names())); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_external_attenuation_table_names(external_attenuation_table_names); + nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_external_attenuation_table_names())); return ::grpc::Status::OK; } } @@ -1025,9 +1060,8 @@ namespace nirfmxinstr_restricted_grpc { while (true) { auto status = library_->GetActiveTableName(instrument, selector_string, 0, nullptr); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } int32 array_size = status; @@ -1040,11 +1074,12 @@ namespace nirfmxinstr_restricted_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_active_table_name(active_table_name); - nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_active_table_name())); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_active_table_name(active_table_name); + nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_active_table_name())); return ::grpc::Status::OK; } } @@ -1068,11 +1103,12 @@ namespace nirfmxinstr_restricted_grpc { int32 signal_state {}; uInt64 time_stamp {}; auto status = library_->GetSignalConfigurationState64(instrument, signal_name, signal_type, &signal_state, &time_stamp); - response->set_status(status); - if (status_ok(status)) { - response->set_signal_state(signal_state); - response->set_time_stamp(time_stamp); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_signal_state(signal_state); + response->set_time_stamp(time_stamp); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -1092,6 +1128,9 @@ namespace nirfmxinstr_restricted_grpc { niRFmxInstrHandle instrument = session_repository_->access_session(instrument_grpc_session.id(), instrument_grpc_session.name()); int32 io_trace_status = request->io_trace_status(); auto status = library_->SetIOTraceStatus(instrument, io_trace_status); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1116,9 +1155,8 @@ namespace nirfmxinstr_restricted_grpc { int32 result_state {}; while (true) { auto status = library_->GetActiveResultName(instrument, signal_name, signal_type, 0, nullptr, &actual_result_size, &result_state); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } std::string result_name; if (actual_result_size > 0) { @@ -1130,13 +1168,14 @@ namespace nirfmxinstr_restricted_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_result_name(result_name); - nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_result_name())); - response->set_actual_result_size(actual_result_size); - response->set_result_state(result_state); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_result_name(result_name); + nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_result_name())); + response->set_actual_result_size(actual_result_size); + response->set_result_state(result_state); return ::grpc::Status::OK; } } diff --git a/generated/nirfmxinstr_restricted/nirfmxinstr_restricted_service.h b/generated/nirfmxinstr_restricted/nirfmxinstr_restricted_service.h index 09d156cd8..663c03147 100644 --- a/generated/nirfmxinstr_restricted/nirfmxinstr_restricted_service.h +++ b/generated/nirfmxinstr_restricted/nirfmxinstr_restricted_service.h @@ -78,6 +78,7 @@ class NiRFmxInstrRestrictedService final : public NiRFmxInstrRestricted::Service private: NiRFmxInstrRestrictedLibraryInterface* library_; ResourceRepositorySharedPtr session_repository_; + ::grpc::Status ConvertApiErrorStatusForNiRFmxInstrHandle(google::protobuf::int32 status, niRFmxInstrHandle instrument); NiRFmxInstrRestrictedFeatureToggles feature_toggles_; }; diff --git a/generated/nirfmxlte/nirfmxlte_service.cpp b/generated/nirfmxlte/nirfmxlte_service.cpp index 792e6a2d7..42b80ac35 100644 --- a/generated/nirfmxlte/nirfmxlte_service.cpp +++ b/generated/nirfmxlte/nirfmxlte_service.cpp @@ -92,6 +92,9 @@ namespace nirfmxlte_grpc { } auto status = library_->ACPCfgAveraging(instrument, selector_string, averaging_enabled, averaging_count, averaging_type); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -128,6 +131,9 @@ namespace nirfmxlte_grpc { } auto status = library_->ACPCfgConfigurableNumberOfOffsetsEnabled(instrument, selector_string, configurable_number_of_offsets_enabled); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -164,6 +170,9 @@ namespace nirfmxlte_grpc { } auto status = library_->ACPCfgMeasurementMethod(instrument, selector_string, measurement_method); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -200,6 +209,9 @@ namespace nirfmxlte_grpc { } auto status = library_->ACPCfgNoiseCompensationEnabled(instrument, selector_string, noise_compensation_enabled); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -221,6 +233,9 @@ namespace nirfmxlte_grpc { char* selector_string = (char*)request->selector_string().c_str(); int32 number_of_eutra_offsets = request->number_of_eutra_offsets(); auto status = library_->ACPCfgNumberOfEUTRAOffsets(instrument, selector_string, number_of_eutra_offsets); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -242,6 +257,9 @@ namespace nirfmxlte_grpc { char* selector_string = (char*)request->selector_string().c_str(); int32 number_of_gsm_offsets = request->number_of_gsm_offsets(); auto status = library_->ACPCfgNumberOfGSMOffsets(instrument, selector_string, number_of_gsm_offsets); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -263,6 +281,9 @@ namespace nirfmxlte_grpc { char* selector_string = (char*)request->selector_string().c_str(); int32 number_of_utra_offsets = request->number_of_utra_offsets(); auto status = library_->ACPCfgNumberOfUTRAOffsets(instrument, selector_string, number_of_utra_offsets); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -299,6 +320,9 @@ namespace nirfmxlte_grpc { } auto status = library_->ACPCfgPowerUnits(instrument, selector_string, power_units); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -352,6 +376,9 @@ namespace nirfmxlte_grpc { } auto status = library_->ACPCfgRBWFilter(instrument, selector_string, rbw_auto, rbw, rbw_filter_type); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -389,6 +416,9 @@ namespace nirfmxlte_grpc { float64 sweep_time_interval = request->sweep_time_interval(); auto status = library_->ACPCfgSweepTime(instrument, selector_string, sweep_time_auto, sweep_time_interval); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -411,6 +441,9 @@ namespace nirfmxlte_grpc { int32 number_of_utra_offsets = request->number_of_utra_offsets(); int32 number_of_eutra_offsets = request->number_of_eutra_offsets(); auto status = library_->ACPCfgUTRAAndEUTRAOffsets(instrument, selector_string, number_of_utra_offsets, number_of_eutra_offsets); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -437,9 +470,8 @@ namespace nirfmxlte_grpc { int32 actual_array_size {}; while (true) { auto status = library_->ACPFetchAbsolutePowersTrace(instrument, selector_string, timeout, trace_index, &x0, &dx, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_absolute_powers_trace()->Resize(actual_array_size, 0); float32* absolute_powers_trace = response->mutable_absolute_powers_trace()->mutable_data(); @@ -449,13 +481,14 @@ namespace nirfmxlte_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_x0(x0); - response->set_dx(dx); - response->mutable_absolute_powers_trace()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_x0(x0); + response->set_dx(dx); + response->mutable_absolute_powers_trace()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -479,11 +512,12 @@ namespace nirfmxlte_grpc { float64 absolute_power {}; float64 relative_power {}; auto status = library_->ACPFetchComponentCarrierMeasurement(instrument, selector_string, timeout, &absolute_power, &relative_power); - response->set_status(status); - if (status_ok(status)) { - response->set_absolute_power(absolute_power); - response->set_relative_power(relative_power); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_absolute_power(absolute_power); + response->set_relative_power(relative_power); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -506,9 +540,8 @@ namespace nirfmxlte_grpc { int32 actual_array_size {}; while (true) { auto status = library_->ACPFetchComponentCarrierMeasurementArray(instrument, selector_string, timeout, nullptr, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_absolute_power()->Resize(actual_array_size, 0); float64* absolute_power = response->mutable_absolute_power()->mutable_data(); @@ -520,12 +553,13 @@ namespace nirfmxlte_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->mutable_absolute_power()->Resize(actual_array_size, 0); - response->mutable_relative_power()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->mutable_absolute_power()->Resize(actual_array_size, 0); + response->mutable_relative_power()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -551,13 +585,14 @@ namespace nirfmxlte_grpc { float64 lower_absolute_power {}; float64 upper_absolute_power {}; auto status = library_->ACPFetchOffsetMeasurement(instrument, selector_string, timeout, &lower_relative_power, &upper_relative_power, &lower_absolute_power, &upper_absolute_power); - response->set_status(status); - if (status_ok(status)) { - response->set_lower_relative_power(lower_relative_power); - response->set_upper_relative_power(upper_relative_power); - response->set_lower_absolute_power(lower_absolute_power); - response->set_upper_absolute_power(upper_absolute_power); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_lower_relative_power(lower_relative_power); + response->set_upper_relative_power(upper_relative_power); + response->set_lower_absolute_power(lower_absolute_power); + response->set_upper_absolute_power(upper_absolute_power); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -580,9 +615,8 @@ namespace nirfmxlte_grpc { int32 actual_array_size {}; while (true) { auto status = library_->ACPFetchOffsetMeasurementArray(instrument, selector_string, timeout, nullptr, nullptr, nullptr, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_lower_relative_power()->Resize(actual_array_size, 0); float64* lower_relative_power = response->mutable_lower_relative_power()->mutable_data(); @@ -598,14 +632,15 @@ namespace nirfmxlte_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->mutable_lower_relative_power()->Resize(actual_array_size, 0); - response->mutable_upper_relative_power()->Resize(actual_array_size, 0); - response->mutable_lower_absolute_power()->Resize(actual_array_size, 0); - response->mutable_upper_absolute_power()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->mutable_lower_relative_power()->Resize(actual_array_size, 0); + response->mutable_upper_relative_power()->Resize(actual_array_size, 0); + response->mutable_lower_absolute_power()->Resize(actual_array_size, 0); + response->mutable_upper_absolute_power()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -632,9 +667,8 @@ namespace nirfmxlte_grpc { int32 actual_array_size {}; while (true) { auto status = library_->ACPFetchRelativePowersTrace(instrument, selector_string, timeout, trace_index, &x0, &dx, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_relative_powers_trace()->Resize(actual_array_size, 0); float32* relative_powers_trace = response->mutable_relative_powers_trace()->mutable_data(); @@ -644,13 +678,14 @@ namespace nirfmxlte_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_x0(x0); - response->set_dx(dx); - response->mutable_relative_powers_trace()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_x0(x0); + response->set_dx(dx); + response->mutable_relative_powers_trace()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -676,9 +711,8 @@ namespace nirfmxlte_grpc { int32 actual_array_size {}; while (true) { auto status = library_->ACPFetchSpectrum(instrument, selector_string, timeout, &x0, &dx, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_spectrum()->Resize(actual_array_size, 0); float32* spectrum = response->mutable_spectrum()->mutable_data(); @@ -688,13 +722,14 @@ namespace nirfmxlte_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_x0(x0); - response->set_dx(dx); - response->mutable_spectrum()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_x0(x0); + response->set_dx(dx); + response->mutable_spectrum()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -719,12 +754,13 @@ namespace nirfmxlte_grpc { float64 integration_bandwidth {}; float64 frequency {}; auto status = library_->ACPFetchSubblockMeasurement(instrument, selector_string, timeout, &subblock_power, &integration_bandwidth, &frequency); - response->set_status(status); - if (status_ok(status)) { - response->set_subblock_power(subblock_power); - response->set_integration_bandwidth(integration_bandwidth); - response->set_frequency(frequency); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_subblock_power(subblock_power); + response->set_integration_bandwidth(integration_bandwidth); + response->set_frequency(frequency); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -746,10 +782,11 @@ namespace nirfmxlte_grpc { float64 timeout = request->timeout(); float64 total_aggregated_power {}; auto status = library_->ACPFetchTotalAggregatedPower(instrument, selector_string, timeout, &total_aggregated_power); - response->set_status(status); - if (status_ok(status)) { - response->set_total_aggregated_power(total_aggregated_power); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_total_aggregated_power(total_aggregated_power); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -770,11 +807,12 @@ namespace nirfmxlte_grpc { char* selector_string = (char*)request->selector_string().c_str(); int32 noise_calibration_data_valid {}; auto status = library_->ACPValidateNoiseCalibrationData(instrument, selector_string, &noise_calibration_data_valid); - response->set_status(status); - if (status_ok(status)) { - response->set_noise_calibration_data_valid(static_cast(noise_calibration_data_valid)); - response->set_noise_calibration_data_valid_raw(noise_calibration_data_valid); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_noise_calibration_data_valid(static_cast(noise_calibration_data_valid)); + response->set_noise_calibration_data_valid_raw(noise_calibration_data_valid); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -794,6 +832,9 @@ namespace nirfmxlte_grpc { niRFmxInstrHandle instrument = session_repository_->access_session(instrument_grpc_session.id(), instrument_grpc_session.name()); char* selector_string = (char*)request->selector_string().c_str(); auto status = library_->AbortMeasurements(instrument, selector_string); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -821,6 +862,9 @@ namespace nirfmxlte_grpc { int32 reset = request->reset(); auto reserved = 0; auto status = library_->AnalyzeIQ1Waveform(instrument, selector_string, result_name, x0, dx, iq.data(), array_size, reset, reserved); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -848,6 +892,9 @@ namespace nirfmxlte_grpc { int32 reset = request->reset(); auto reserved = 0; auto status = library_->AnalyzeSpectrum1Waveform(instrument, selector_string, result_name, x0, dx, spectrum, array_size, reset, reserved); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -870,10 +917,11 @@ namespace nirfmxlte_grpc { float64 measurement_interval = request->measurement_interval(); float64 reference_level {}; auto status = library_->AutoLevel(instrument, selector_string, measurement_interval, &reference_level); - response->set_status(status); - if (status_ok(status)) { - response->set_reference_level(reference_level); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_reference_level(reference_level); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -894,9 +942,8 @@ namespace nirfmxlte_grpc { while (true) { auto status = library_->BuildCarrierString(selector_string, carrier_number, 0, nullptr); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, 0); } int32 selector_string_out_length = status; @@ -909,11 +956,12 @@ namespace nirfmxlte_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_selector_string_out(selector_string_out); - nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_selector_string_out())); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, 0); } + response->set_status(status); + response->set_selector_string_out(selector_string_out); + nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_selector_string_out())); return ::grpc::Status::OK; } } @@ -935,9 +983,8 @@ namespace nirfmxlte_grpc { while (true) { auto status = library_->BuildClusterString(selector_string, cluster_number, 0, nullptr); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, 0); } int32 selector_string_out_length = status; @@ -950,11 +997,12 @@ namespace nirfmxlte_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_selector_string_out(selector_string_out); - nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_selector_string_out())); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, 0); } + response->set_status(status); + response->set_selector_string_out(selector_string_out); + nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_selector_string_out())); return ::grpc::Status::OK; } } @@ -976,9 +1024,8 @@ namespace nirfmxlte_grpc { while (true) { auto status = library_->BuildOffsetString(selector_string, offset_number, 0, nullptr); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, 0); } int32 selector_string_out_length = status; @@ -991,11 +1038,12 @@ namespace nirfmxlte_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_selector_string_out(selector_string_out); - nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_selector_string_out())); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, 0); } + response->set_status(status); + response->set_selector_string_out(selector_string_out); + nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_selector_string_out())); return ::grpc::Status::OK; } } @@ -1017,9 +1065,8 @@ namespace nirfmxlte_grpc { while (true) { auto status = library_->BuildPDSCHString(selector_string, pdsch_number, 0, nullptr); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, 0); } int32 selector_string_out_length = status; @@ -1032,11 +1079,12 @@ namespace nirfmxlte_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_selector_string_out(selector_string_out); - nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_selector_string_out())); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, 0); } + response->set_status(status); + response->set_selector_string_out(selector_string_out); + nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_selector_string_out())); return ::grpc::Status::OK; } } @@ -1058,9 +1106,8 @@ namespace nirfmxlte_grpc { while (true) { auto status = library_->BuildSignalString(signal_name, result_name, 0, nullptr); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, 0); } int32 selector_string_length = status; @@ -1073,11 +1120,12 @@ namespace nirfmxlte_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_selector_string(selector_string); - nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_selector_string())); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, 0); } + response->set_status(status); + response->set_selector_string(selector_string); + nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_selector_string())); return ::grpc::Status::OK; } } @@ -1099,9 +1147,8 @@ namespace nirfmxlte_grpc { while (true) { auto status = library_->BuildSubblockString(selector_string, subblock_number, 0, nullptr); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, 0); } int32 selector_string_out_length = status; @@ -1114,11 +1161,12 @@ namespace nirfmxlte_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_selector_string_out(selector_string_out); - nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_selector_string_out())); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, 0); } + response->set_status(status); + response->set_selector_string_out(selector_string_out); + nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_selector_string_out())); return ::grpc::Status::OK; } } @@ -1140,9 +1188,8 @@ namespace nirfmxlte_grpc { while (true) { auto status = library_->BuildSubframeString(selector_string, subframe_number, 0, nullptr); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, 0); } int32 selector_string_out_length = status; @@ -1155,11 +1202,12 @@ namespace nirfmxlte_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_selector_string_out(selector_string_out); - nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_selector_string_out())); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, 0); } + response->set_status(status); + response->set_selector_string_out(selector_string_out); + nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_selector_string_out())); return ::grpc::Status::OK; } } @@ -1213,6 +1261,9 @@ namespace nirfmxlte_grpc { } auto status = library_->CHPCfgAveraging(instrument, selector_string, averaging_enabled, averaging_count, averaging_type); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1249,6 +1300,9 @@ namespace nirfmxlte_grpc { } auto status = library_->CHPCfgIntegrationBandwidthType(instrument, selector_string, integration_bandwidth_type); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1302,6 +1356,9 @@ namespace nirfmxlte_grpc { } auto status = library_->CHPCfgRBWFilter(instrument, selector_string, rbw_auto, rbw, rbw_filter_type); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1339,6 +1396,9 @@ namespace nirfmxlte_grpc { float64 sweep_time_interval = request->sweep_time_interval(); auto status = library_->CHPCfgSweepTime(instrument, selector_string, sweep_time_auto, sweep_time_interval); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1362,11 +1422,12 @@ namespace nirfmxlte_grpc { float64 absolute_power {}; float64 relative_power {}; auto status = library_->CHPFetchComponentCarrierMeasurement(instrument, selector_string, timeout, &absolute_power, &relative_power); - response->set_status(status); - if (status_ok(status)) { - response->set_absolute_power(absolute_power); - response->set_relative_power(relative_power); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_absolute_power(absolute_power); + response->set_relative_power(relative_power); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -1389,9 +1450,8 @@ namespace nirfmxlte_grpc { int32 actual_array_size {}; while (true) { auto status = library_->CHPFetchComponentCarrierMeasurementArray(instrument, selector_string, timeout, nullptr, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_absolute_power()->Resize(actual_array_size, 0); float64* absolute_power = response->mutable_absolute_power()->mutable_data(); @@ -1403,12 +1463,13 @@ namespace nirfmxlte_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->mutable_absolute_power()->Resize(actual_array_size, 0); - response->mutable_relative_power()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->mutable_absolute_power()->Resize(actual_array_size, 0); + response->mutable_relative_power()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -1434,9 +1495,8 @@ namespace nirfmxlte_grpc { int32 actual_array_size {}; while (true) { auto status = library_->CHPFetchSpectrum(instrument, selector_string, timeout, &x0, &dx, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_spectrum()->Resize(actual_array_size, 0); float32* spectrum = response->mutable_spectrum()->mutable_data(); @@ -1446,13 +1506,14 @@ namespace nirfmxlte_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_x0(x0); - response->set_dx(dx); - response->mutable_spectrum()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_x0(x0); + response->set_dx(dx); + response->mutable_spectrum()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -1477,12 +1538,13 @@ namespace nirfmxlte_grpc { float64 integration_bandwidth {}; float64 frequency {}; auto status = library_->CHPFetchSubblockMeasurement(instrument, selector_string, timeout, &subblock_power, &integration_bandwidth, &frequency); - response->set_status(status); - if (status_ok(status)) { - response->set_subblock_power(subblock_power); - response->set_integration_bandwidth(integration_bandwidth); - response->set_frequency(frequency); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_subblock_power(subblock_power); + response->set_integration_bandwidth(integration_bandwidth); + response->set_frequency(frequency); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -1504,10 +1566,11 @@ namespace nirfmxlte_grpc { float64 timeout = request->timeout(); float64 total_aggregated_power {}; auto status = library_->CHPFetchTotalAggregatedPower(instrument, selector_string, timeout, &total_aggregated_power); - response->set_status(status); - if (status_ok(status)) { - response->set_total_aggregated_power(total_aggregated_power); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_total_aggregated_power(total_aggregated_power); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -1528,11 +1591,12 @@ namespace nirfmxlte_grpc { char* selector_string = (char*)request->selector_string().c_str(); int32 noise_calibration_data_valid {}; auto status = library_->CHPValidateNoiseCalibrationData(instrument, selector_string, &noise_calibration_data_valid); - response->set_status(status); - if (status_ok(status)) { - response->set_noise_calibration_data_valid(static_cast(noise_calibration_data_valid)); - response->set_noise_calibration_data_valid_raw(noise_calibration_data_valid); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_noise_calibration_data_valid(static_cast(noise_calibration_data_valid)); + response->set_noise_calibration_data_valid_raw(noise_calibration_data_valid); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -1568,6 +1632,9 @@ namespace nirfmxlte_grpc { } auto status = library_->CfgAutoDMRSDetectionEnabled(instrument, selector_string, auto_dmrs_detection_enabled); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1604,6 +1671,9 @@ namespace nirfmxlte_grpc { } auto status = library_->CfgAutoNPUSCHChannelDetectionEnabled(instrument, selector_string, auto_npusch_channel_detection_enabled); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1640,6 +1710,9 @@ namespace nirfmxlte_grpc { } auto status = library_->CfgAutoResourceBlockDetectionEnabled(instrument, selector_string, auto_resource_block_detection_enabled); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1661,6 +1734,9 @@ namespace nirfmxlte_grpc { char* selector_string = (char*)request->selector_string().c_str(); int32 band = request->band(); auto status = library_->CfgBand(instrument, selector_string, band); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1697,6 +1773,9 @@ namespace nirfmxlte_grpc { } auto status = library_->CfgCellSpecificRatio(instrument, selector_string, cell_specific_ratio); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1720,6 +1799,9 @@ namespace nirfmxlte_grpc { float64 component_carrier_frequency = request->component_carrier_frequency(); int32 cell_id = request->cell_id(); auto status = library_->CfgComponentCarrier(instrument, selector_string, component_carrier_bandwidth, component_carrier_frequency, cell_id); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1762,6 +1844,9 @@ namespace nirfmxlte_grpc { auto number_of_elements = number_of_elements_size_calculation.size; auto status = library_->CfgComponentCarrierArray(instrument, selector_string, component_carrier_bandwidth, component_carrier_frequency, cell_id, number_of_elements); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1799,6 +1884,9 @@ namespace nirfmxlte_grpc { int32 component_carrier_at_center_frequency = request->component_carrier_at_center_frequency(); auto status = library_->CfgComponentCarrierSpacing(instrument, selector_string, component_carrier_spacing_type, component_carrier_at_center_frequency); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1857,6 +1945,9 @@ namespace nirfmxlte_grpc { float64 trigger_delay = request->trigger_delay(); int32 enable_trigger = request->enable_trigger(); auto status = library_->CfgDigitalEdgeTrigger(instrument, selector_string, digital_edge_source, digital_edge, trigger_delay, enable_trigger); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1893,6 +1984,9 @@ namespace nirfmxlte_grpc { } auto status = library_->CfgDownlinkAutoCellIDDetectionEnabled(instrument, selector_string, auto_cell_id_detection_enabled); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1962,6 +2056,9 @@ namespace nirfmxlte_grpc { auto reserved = 0; auto status = library_->CfgDownlinkAutoChannelDetection(instrument, selector_string, auto_pdsch_channel_detection_enabled, auto_control_channel_power_detection_enabled, auto_pcfich_cfi_detection_enabled, reserved); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1998,6 +2095,9 @@ namespace nirfmxlte_grpc { } auto status = library_->CfgDownlinkChannelConfigurationMode(instrument, selector_string, channel_configuration_mode); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -2019,6 +2119,9 @@ namespace nirfmxlte_grpc { char* selector_string = (char*)request->selector_string().c_str(); int32 number_of_subframes = request->number_of_subframes(); auto status = library_->CfgDownlinkNumberOfSubframes(instrument, selector_string, number_of_subframes); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -2041,6 +2144,9 @@ namespace nirfmxlte_grpc { float64 pss_power = request->pss_power(); float64 sss_power = request->sss_power(); auto status = library_->CfgDownlinkSynchronizationSignal(instrument, selector_string, pss_power, sss_power); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -2077,6 +2183,9 @@ namespace nirfmxlte_grpc { } auto status = library_->CfgDownlinkTestModel(instrument, selector_string, downlink_test_model); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -2107,6 +2216,9 @@ namespace nirfmxlte_grpc { int32 number_of_elements = static_cast(request->downlink_test_model().size()); auto status = library_->CfgDownlinkTestModelArray(instrument, selector_string, downlink_test_model, number_of_elements); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -2159,6 +2271,9 @@ namespace nirfmxlte_grpc { } auto status = library_->CfgDuplexScheme(instrument, selector_string, duplex_scheme, uplink_downlink_configuration); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -2195,6 +2310,9 @@ namespace nirfmxlte_grpc { } auto status = library_->CfgEMTCAnalysisEnabled(instrument, selector_string, emtc_analysis_enabled); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -2216,6 +2334,9 @@ namespace nirfmxlte_grpc { char* selector_string = (char*)request->selector_string().c_str(); float64 external_attenuation = request->external_attenuation(); auto status = library_->CfgExternalAttenuation(instrument, selector_string, external_attenuation); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -2237,6 +2358,9 @@ namespace nirfmxlte_grpc { char* selector_string = (char*)request->selector_string().c_str(); float64 center_frequency = request->center_frequency(); auto status = library_->CfgFrequency(instrument, selector_string, center_frequency); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -2275,6 +2399,9 @@ namespace nirfmxlte_grpc { int32 band = request->band(); int32 earfcn = request->earfcn(); auto status = library_->CfgFrequencyEARFCN(instrument, selector_string, link_direction, band, earfcn); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -2316,6 +2443,9 @@ namespace nirfmxlte_grpc { float64 frequency_reference_frequency = request->frequency_reference_frequency(); auto status = library_->CfgFrequencyReference(instrument, channel_name, frequency_reference_source, frequency_reference_frequency); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -2389,6 +2519,9 @@ namespace nirfmxlte_grpc { int32 enable_trigger = request->enable_trigger(); auto status = library_->CfgIQPowerEdgeTrigger(instrument, selector_string, iq_power_edge_source, iq_power_edge_slope, iq_power_edge_level, trigger_delay, trigger_min_quiet_time_mode, trigger_min_quiet_time_duration, iq_power_edge_level_type, enable_trigger); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -2425,6 +2558,9 @@ namespace nirfmxlte_grpc { } auto status = library_->CfgLinkDirection(instrument, selector_string, link_direction); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -2462,6 +2598,9 @@ namespace nirfmxlte_grpc { float64 mechanical_attenuation_value = request->mechanical_attenuation_value(); auto status = library_->CfgMechanicalAttenuation(instrument, channel_name, mechanical_attenuation_auto, mechanical_attenuation_value); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -2499,6 +2638,9 @@ namespace nirfmxlte_grpc { } auto status = library_->CfgNBIoTComponentCarrier(instrument, selector_string, n_cell_id, uplink_subcarrier_spacing); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -2554,6 +2696,9 @@ namespace nirfmxlte_grpc { int32 npusch_dmrs_delta_ss = request->npusch_dmrs_delta_ss(); auto status = library_->CfgNPUSCHDMRS(instrument, selector_string, npusch_dmrs_base_sequence_mode, npusch_dmrs_base_sequence_index, npusch_dmrs_cyclic_shift, npusch_dmrs_group_hopping_enabled, npusch_dmrs_delta_ss); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -2575,6 +2720,9 @@ namespace nirfmxlte_grpc { char* selector_string = (char*)request->selector_string().c_str(); int32 format = request->format(); auto status = library_->CfgNPUSCHFormat(instrument, selector_string, format); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -2596,6 +2744,9 @@ namespace nirfmxlte_grpc { char* selector_string = (char*)request->selector_string().c_str(); int32 starting_slot = request->starting_slot(); auto status = library_->CfgNPUSCHStartingSlot(instrument, selector_string, starting_slot); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -2634,6 +2785,9 @@ namespace nirfmxlte_grpc { } auto status = library_->CfgNPUSCHTones(instrument, selector_string, tone_offset, number_of_tones, modulation_type); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -2655,6 +2809,9 @@ namespace nirfmxlte_grpc { char* selector_string = (char*)request->selector_string().c_str(); int32 number_of_component_carriers = request->number_of_component_carriers(); auto status = library_->CfgNumberOfComponentCarriers(instrument, selector_string, number_of_component_carriers); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -2676,6 +2833,9 @@ namespace nirfmxlte_grpc { char* selector_string = (char*)request->selector_string().c_str(); int32 number_of_dut_antennas = request->number_of_dut_antennas(); auto status = library_->CfgNumberOfDUTAntennas(instrument, selector_string, number_of_dut_antennas); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -2697,6 +2857,9 @@ namespace nirfmxlte_grpc { char* selector_string = (char*)request->selector_string().c_str(); int32 number_of_pdsch_channels = request->number_of_pdsch_channels(); auto status = library_->CfgNumberOfPDSCHChannels(instrument, selector_string, number_of_pdsch_channels); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -2718,6 +2881,9 @@ namespace nirfmxlte_grpc { char* selector_string = (char*)request->selector_string().c_str(); int32 number_of_resource_block_clusters = request->number_of_resource_block_clusters(); auto status = library_->CfgNumberOfPUSCHResourceBlockClusters(instrument, selector_string, number_of_resource_block_clusters); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -2739,6 +2905,9 @@ namespace nirfmxlte_grpc { char* selector_string = (char*)request->selector_string().c_str(); int32 number_of_subblocks = request->number_of_subblocks(); auto status = library_->CfgNumberOfSubblocks(instrument, selector_string, number_of_subblocks); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -2760,6 +2929,9 @@ namespace nirfmxlte_grpc { char* selector_string = (char*)request->selector_string().c_str(); float64 pbch_power = request->pbch_power(); auto status = library_->CfgPBCH(instrument, selector_string, pbch_power); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -2782,6 +2954,9 @@ namespace nirfmxlte_grpc { int32 cfi = request->cfi(); float64 power = request->power(); auto status = library_->CfgPCFICH(instrument, selector_string, cfi, power); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -2803,6 +2978,9 @@ namespace nirfmxlte_grpc { char* selector_string = (char*)request->selector_string().c_str(); float64 pdcch_power = request->pdcch_power(); auto status = library_->CfgPDCCH(instrument, selector_string, pdcch_power); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -2841,6 +3019,9 @@ namespace nirfmxlte_grpc { char* resource_block_allocation = (char*)request->resource_block_allocation().c_str(); float64 power = request->power(); auto status = library_->CfgPDSCH(instrument, selector_string, cw0_modulation_type, resource_block_allocation, power); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -2894,6 +3075,9 @@ namespace nirfmxlte_grpc { float64 power = request->power(); auto status = library_->CfgPHICH(instrument, selector_string, resource, duration, power); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -2915,6 +3099,9 @@ namespace nirfmxlte_grpc { char* selector_string = (char*)request->selector_string().c_str(); int32 modulation_type = request->modulation_type(); auto status = library_->CfgPSSCHModulationType(instrument, selector_string, modulation_type); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -2937,6 +3124,9 @@ namespace nirfmxlte_grpc { int32 resource_block_offset = request->resource_block_offset(); int32 number_of_resource_blocks = request->number_of_resource_blocks(); auto status = library_->CfgPSSCHResourceBlocks(instrument, selector_string, resource_block_offset, number_of_resource_blocks); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -2973,6 +3163,9 @@ namespace nirfmxlte_grpc { } auto status = library_->CfgPUSCHModulationType(instrument, selector_string, modulation_type); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -2995,6 +3188,9 @@ namespace nirfmxlte_grpc { int32 resource_block_offset = request->resource_block_offset(); int32 number_of_resource_blocks = request->number_of_resource_blocks(); auto status = library_->CfgPUSCHResourceBlocks(instrument, selector_string, resource_block_offset, number_of_resource_blocks); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -3018,6 +3214,9 @@ namespace nirfmxlte_grpc { float64 reference_level = request->reference_level(); float64 external_attenuation = request->external_attenuation(); auto status = library_->CfgRF(instrument, selector_string, center_frequency, reference_level, external_attenuation); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -3055,6 +3254,9 @@ namespace nirfmxlte_grpc { float64 rf_attenuation_value = request->rf_attenuation_value(); auto status = library_->CfgRFAttenuation(instrument, channel_name, rf_attenuation_auto, rf_attenuation_value); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -3076,6 +3278,9 @@ namespace nirfmxlte_grpc { char* selector_string = (char*)request->selector_string().c_str(); float64 reference_level = request->reference_level(); auto status = library_->CfgReferenceLevel(instrument, selector_string, reference_level); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -3098,6 +3303,9 @@ namespace nirfmxlte_grpc { float64 trigger_delay = request->trigger_delay(); int32 enable_trigger = request->enable_trigger(); auto status = library_->CfgSoftwareEdgeTrigger(instrument, selector_string, trigger_delay, enable_trigger); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -3119,6 +3327,9 @@ namespace nirfmxlte_grpc { char* selector_string = (char*)request->selector_string().c_str(); int32 transmit_antenna_to_analyze = request->transmit_antenna_to_analyze(); auto status = library_->CfgTransmitAntennaToAnalyze(instrument, selector_string, transmit_antenna_to_analyze); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -3155,6 +3366,9 @@ namespace nirfmxlte_grpc { } auto status = library_->CfgeNodeBCategory(instrument, selector_string, enodeb_category); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -3176,10 +3390,11 @@ namespace nirfmxlte_grpc { char* selector_string = (char*)request->selector_string().c_str(); int32 is_done {}; auto status = library_->CheckMeasurementStatus(instrument, selector_string, &is_done); - response->set_status(status); - if (status_ok(status)) { - response->set_is_done(is_done); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_is_done(is_done); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -3199,6 +3414,9 @@ namespace nirfmxlte_grpc { niRFmxInstrHandle instrument = session_repository_->access_session(instrument_grpc_session.id(), instrument_grpc_session.name()); char* selector_string = (char*)request->selector_string().c_str(); auto status = library_->ClearAllNamedResults(instrument, selector_string); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -3219,6 +3437,9 @@ namespace nirfmxlte_grpc { niRFmxInstrHandle instrument = session_repository_->access_session(instrument_grpc_session.id(), instrument_grpc_session.name()); char* selector_string = (char*)request->selector_string().c_str(); auto status = library_->ClearNamedResult(instrument, selector_string); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -3239,6 +3460,9 @@ namespace nirfmxlte_grpc { niRFmxInstrHandle instrument = session_repository_->access_session(instrument_grpc_session.id(), instrument_grpc_session.name()); char* selector_string = (char*)request->selector_string().c_str(); auto status = library_->ClearNoiseCalibrationDatabase(instrument, selector_string); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -3260,6 +3484,9 @@ namespace nirfmxlte_grpc { char* old_signal_name = (char*)request->old_signal_name().c_str(); char* new_signal_name = (char*)request->new_signal_name().c_str(); auto status = library_->CloneSignalConfiguration(instrument, old_signal_name, new_signal_name); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -3281,6 +3508,9 @@ namespace nirfmxlte_grpc { int32 force_destroy = request->force_destroy(); session_repository_->remove_session(instrument_grpc_session.id(), instrument_grpc_session.name()); auto status = library_->Close(instrument, force_destroy); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -3301,6 +3531,9 @@ namespace nirfmxlte_grpc { niRFmxInstrHandle instrument = session_repository_->access_session(instrument_grpc_session.id(), instrument_grpc_session.name()); char* selector_string = (char*)request->selector_string().c_str(); auto status = library_->Commit(instrument, selector_string); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -3321,6 +3554,9 @@ namespace nirfmxlte_grpc { niRFmxInstrHandle instrument = session_repository_->access_session(instrument_grpc_session.id(), instrument_grpc_session.name()); char* signal_name = (char*)request->signal_name().c_str(); auto status = library_->CreateSignalConfiguration(instrument, signal_name); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -3341,6 +3577,9 @@ namespace nirfmxlte_grpc { niRFmxInstrHandle instrument = session_repository_->access_session(instrument_grpc_session.id(), instrument_grpc_session.name()); char* signal_name = (char*)request->signal_name().c_str(); auto status = library_->DeleteSignalConfiguration(instrument, signal_name); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -3361,6 +3600,9 @@ namespace nirfmxlte_grpc { niRFmxInstrHandle instrument = session_repository_->access_session(instrument_grpc_session.id(), instrument_grpc_session.name()); char* selector_string = (char*)request->selector_string().c_str(); auto status = library_->DisableTrigger(instrument, selector_string); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -3384,9 +3626,8 @@ namespace nirfmxlte_grpc { int32 default_result_exists {}; while (true) { auto status = library_->GetAllNamedResultNames(instrument, selector_string, nullptr, 0, &actual_result_names_size, &default_result_exists); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } std::string result_names; if (actual_result_names_size > 0) { @@ -3398,13 +3639,14 @@ namespace nirfmxlte_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_result_names(result_names); - nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_result_names())); - response->set_actual_result_names_size(actual_result_names_size); - response->set_default_result_exists(default_result_exists); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_result_names(result_names); + nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_result_names())); + response->set_actual_result_names_size(actual_result_names_size); + response->set_default_result_exists(default_result_exists); return ::grpc::Status::OK; } } @@ -3427,10 +3669,11 @@ namespace nirfmxlte_grpc { int32 attribute_id = request->attribute_id(); float32 attr_val {}; auto status = library_->GetAttributeF32(instrument, selector_string, attribute_id, &attr_val); - response->set_status(status); - if (status_ok(status)) { - response->set_attr_val(attr_val); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_attr_val(attr_val); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -3453,9 +3696,8 @@ namespace nirfmxlte_grpc { int32 actual_array_size {}; while (true) { auto status = library_->GetAttributeF32Array(instrument, selector_string, attribute_id, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_attr_val()->Resize(actual_array_size, 0); float32* attr_val = response->mutable_attr_val()->mutable_data(); @@ -3465,11 +3707,12 @@ namespace nirfmxlte_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->mutable_attr_val()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->mutable_attr_val()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -3492,10 +3735,11 @@ namespace nirfmxlte_grpc { int32 attribute_id = request->attribute_id(); float64 attr_val {}; auto status = library_->GetAttributeF64(instrument, selector_string, attribute_id, &attr_val); - response->set_status(status); - if (status_ok(status)) { - response->set_attr_val(attr_val); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_attr_val(attr_val); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -3518,9 +3762,8 @@ namespace nirfmxlte_grpc { int32 actual_array_size {}; while (true) { auto status = library_->GetAttributeF64Array(instrument, selector_string, attribute_id, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_attr_val()->Resize(actual_array_size, 0); float64* attr_val = response->mutable_attr_val()->mutable_data(); @@ -3530,11 +3773,12 @@ namespace nirfmxlte_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->mutable_attr_val()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->mutable_attr_val()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -3557,10 +3801,11 @@ namespace nirfmxlte_grpc { int32 attribute_id = request->attribute_id(); int16 attr_val {}; auto status = library_->GetAttributeI16(instrument, selector_string, attribute_id, &attr_val); - response->set_status(status); - if (status_ok(status)) { - response->set_attr_val(attr_val); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_attr_val(attr_val); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -3582,16 +3827,17 @@ namespace nirfmxlte_grpc { int32 attribute_id = request->attribute_id(); int32 attr_val {}; auto status = library_->GetAttributeI32(instrument, selector_string, attribute_id, &attr_val); - response->set_status(status); - if (status_ok(status)) { - auto checked_convert_attr_val = [](auto raw_value) { - bool raw_value_is_valid = nirfmxlte_grpc::NiRFmxLTEInt32AttributeValues_IsValid(raw_value); - auto valid_enum_value = raw_value_is_valid ? raw_value : 0; - return static_cast(valid_enum_value); - }; - response->set_attr_val(checked_convert_attr_val(attr_val)); - response->set_attr_val_raw(attr_val); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + auto checked_convert_attr_val = [](auto raw_value) { + bool raw_value_is_valid = nirfmxlte_grpc::NiRFmxLTEInt32AttributeValues_IsValid(raw_value); + auto valid_enum_value = raw_value_is_valid ? raw_value : 0; + return static_cast(valid_enum_value); + }; + response->set_attr_val(checked_convert_attr_val(attr_val)); + response->set_attr_val_raw(attr_val); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -3614,9 +3860,8 @@ namespace nirfmxlte_grpc { int32 actual_array_size {}; while (true) { auto status = library_->GetAttributeI32Array(instrument, selector_string, attribute_id, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_attr_val_raw()->Resize(actual_array_size, 0); int32* attr_val = reinterpret_cast(response->mutable_attr_val_raw()->mutable_data()); @@ -3626,13 +3871,15 @@ namespace nirfmxlte_grpc { // buffer is now too small, try again continue; } + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); - if (status_ok(status)) { - auto checked_convert_attr_val = [](auto raw_value) { - bool raw_value_is_valid = nirfmxlte_grpc::NiRFmxLTEInt32AttributeValues_IsValid(raw_value); - auto valid_enum_value = raw_value_is_valid ? raw_value : 0; - return static_cast(valid_enum_value); - }; + auto checked_convert_attr_val = [](auto raw_value) { + bool raw_value_is_valid = nirfmxlte_grpc::NiRFmxLTEInt32AttributeValues_IsValid(raw_value); + auto valid_enum_value = raw_value_is_valid ? raw_value : 0; + return static_cast(valid_enum_value); + }; response->mutable_attr_val()->Clear(); response->mutable_attr_val()->Reserve(actual_array_size); std::transform( @@ -3642,9 +3889,8 @@ namespace nirfmxlte_grpc { [&](auto x) { return checked_convert_attr_val(x); }); - response->mutable_attr_val()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); - } + response->mutable_attr_val()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -3667,10 +3913,11 @@ namespace nirfmxlte_grpc { int32 attribute_id = request->attribute_id(); int64 attr_val {}; auto status = library_->GetAttributeI64(instrument, selector_string, attribute_id, &attr_val); - response->set_status(status); - if (status_ok(status)) { - response->set_attr_val(attr_val); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_attr_val(attr_val); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -3693,9 +3940,8 @@ namespace nirfmxlte_grpc { int32 actual_array_size {}; while (true) { auto status = library_->GetAttributeI64Array(instrument, selector_string, attribute_id, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_attr_val()->Resize(actual_array_size, 0); int64* attr_val = reinterpret_cast(response->mutable_attr_val()->mutable_data()); @@ -3705,11 +3951,12 @@ namespace nirfmxlte_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->mutable_attr_val()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->mutable_attr_val()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -3732,10 +3979,11 @@ namespace nirfmxlte_grpc { int32 attribute_id = request->attribute_id(); int8 attr_val {}; auto status = library_->GetAttributeI8(instrument, selector_string, attribute_id, &attr_val); - response->set_status(status); - if (status_ok(status)) { - response->set_attr_val(attr_val); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_attr_val(attr_val); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -3758,9 +4006,8 @@ namespace nirfmxlte_grpc { int32 actual_array_size {}; while (true) { auto status = library_->GetAttributeI8Array(instrument, selector_string, attribute_id, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } std::vector attr_val(actual_array_size); auto array_size = actual_array_size; @@ -3769,8 +4016,10 @@ namespace nirfmxlte_grpc { // buffer is now too small, try again continue; } + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); - if (status_ok(status)) { response->mutable_attr_val()->Clear(); response->mutable_attr_val()->Reserve(actual_array_size); std::transform( @@ -3780,9 +4029,8 @@ namespace nirfmxlte_grpc { [&](auto x) { return x; }); - response->mutable_attr_val()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); - } + response->mutable_attr_val()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -3806,9 +4054,8 @@ namespace nirfmxlte_grpc { int32 actual_array_size {}; while (true) { auto status = library_->GetAttributeNIComplexDoubleArray(instrument, selector_string, attribute_id, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } std::vector attr_val(actual_array_size, NIComplexDouble()); auto array_size = actual_array_size; @@ -3817,18 +4064,19 @@ namespace nirfmxlte_grpc { // buffer is now too small, try again continue; } + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); - if (status_ok(status)) { - convert_to_grpc(attr_val, response->mutable_attr_val()); - { - auto shrunk_size = actual_array_size; - auto current_size = response->mutable_attr_val()->size(); - if (shrunk_size != current_size) { - response->mutable_attr_val()->DeleteSubrange(shrunk_size, current_size - shrunk_size); - } + convert_to_grpc(attr_val, response->mutable_attr_val()); + { + auto shrunk_size = actual_array_size; + auto current_size = response->mutable_attr_val()->size(); + if (shrunk_size != current_size) { + response->mutable_attr_val()->DeleteSubrange(shrunk_size, current_size - shrunk_size); } - response->set_actual_array_size(actual_array_size); } + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -3852,9 +4100,8 @@ namespace nirfmxlte_grpc { int32 actual_array_size {}; while (true) { auto status = library_->GetAttributeNIComplexSingleArray(instrument, selector_string, attribute_id, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } std::vector attr_val(actual_array_size, NIComplexSingle()); auto array_size = actual_array_size; @@ -3863,18 +4110,19 @@ namespace nirfmxlte_grpc { // buffer is now too small, try again continue; } + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); - if (status_ok(status)) { - convert_to_grpc(attr_val, response->mutable_attr_val()); - { - auto shrunk_size = actual_array_size; - auto current_size = response->mutable_attr_val()->size(); - if (shrunk_size != current_size) { - response->mutable_attr_val()->DeleteSubrange(shrunk_size, current_size - shrunk_size); - } + convert_to_grpc(attr_val, response->mutable_attr_val()); + { + auto shrunk_size = actual_array_size; + auto current_size = response->mutable_attr_val()->size(); + if (shrunk_size != current_size) { + response->mutable_attr_val()->DeleteSubrange(shrunk_size, current_size - shrunk_size); } - response->set_actual_array_size(actual_array_size); } + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -3898,9 +4146,8 @@ namespace nirfmxlte_grpc { while (true) { auto status = library_->GetAttributeString(instrument, selector_string, attribute_id, 0, nullptr); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } int32 array_size = status; @@ -3913,11 +4160,12 @@ namespace nirfmxlte_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_attr_val(attr_val); - nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_attr_val())); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_attr_val(attr_val); + nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_attr_val())); return ::grpc::Status::OK; } } @@ -3940,10 +4188,11 @@ namespace nirfmxlte_grpc { int32 attribute_id = request->attribute_id(); uInt16 attr_val {}; auto status = library_->GetAttributeU16(instrument, selector_string, attribute_id, &attr_val); - response->set_status(status); - if (status_ok(status)) { - response->set_attr_val(attr_val); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_attr_val(attr_val); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -3965,10 +4214,11 @@ namespace nirfmxlte_grpc { int32 attribute_id = request->attribute_id(); uInt32 attr_val {}; auto status = library_->GetAttributeU32(instrument, selector_string, attribute_id, &attr_val); - response->set_status(status); - if (status_ok(status)) { - response->set_attr_val(attr_val); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_attr_val(attr_val); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -3991,9 +4241,8 @@ namespace nirfmxlte_grpc { int32 actual_array_size {}; while (true) { auto status = library_->GetAttributeU32Array(instrument, selector_string, attribute_id, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_attr_val()->Resize(actual_array_size, 0); uInt32* attr_val = reinterpret_cast(response->mutable_attr_val()->mutable_data()); @@ -4003,11 +4252,12 @@ namespace nirfmxlte_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->mutable_attr_val()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->mutable_attr_val()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -4031,9 +4281,8 @@ namespace nirfmxlte_grpc { int32 actual_array_size {}; while (true) { auto status = library_->GetAttributeU64Array(instrument, selector_string, attribute_id, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_attr_val()->Resize(actual_array_size, 0); uInt64* attr_val = reinterpret_cast(response->mutable_attr_val()->mutable_data()); @@ -4043,11 +4292,12 @@ namespace nirfmxlte_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->mutable_attr_val()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->mutable_attr_val()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -4070,10 +4320,11 @@ namespace nirfmxlte_grpc { int32 attribute_id = request->attribute_id(); uInt8 attr_val {}; auto status = library_->GetAttributeU8(instrument, selector_string, attribute_id, &attr_val); - response->set_status(status); - if (status_ok(status)) { - response->set_attr_val(attr_val); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_attr_val(attr_val); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -4096,9 +4347,8 @@ namespace nirfmxlte_grpc { int32 actual_array_size {}; while (true) { auto status = library_->GetAttributeU8Array(instrument, selector_string, attribute_id, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } std::string attr_val(actual_array_size, '\0'); auto array_size = actual_array_size; @@ -4107,12 +4357,13 @@ namespace nirfmxlte_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_attr_val(attr_val); - response->mutable_attr_val()->resize(actual_array_size); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_attr_val(attr_val); + response->mutable_attr_val()->resize(actual_array_size); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -4134,9 +4385,8 @@ namespace nirfmxlte_grpc { while (true) { auto status = library_->GetError(instrument, nullptr, 0, nullptr); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } int32 error_description_buffer_size = status; @@ -4150,12 +4400,13 @@ namespace nirfmxlte_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_error_code(error_code); - response->set_error_description(error_description); - nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_error_description())); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_error_code(error_code); + response->set_error_description(error_description); + nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_error_description())); return ::grpc::Status::OK; } } @@ -4178,9 +4429,8 @@ namespace nirfmxlte_grpc { while (true) { auto status = library_->GetErrorString(instrument, error_code, 0, nullptr); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } int32 error_description_buffer_size = status; @@ -4193,11 +4443,12 @@ namespace nirfmxlte_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_error_description(error_description); - nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_error_description())); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_error_description(error_description); + nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_error_description())); return ::grpc::Status::OK; } } @@ -4227,15 +4478,12 @@ namespace nirfmxlte_grpc { const std::string& grpc_device_session_name = request->session_name(); auto cleanup_lambda = [&] (niRFmxInstrHandle id) { library_->Close(id, RFMXLTE_VAL_FALSE); }; int status = session_repository_->add_session(grpc_device_session_name, init_lambda, cleanup_lambda, session_id); - response->set_status(status); - if (status_ok(status)) { - response->mutable_instrument()->set_id(session_id); - response->set_is_new_session(is_new_session); - } - else { - const auto error_message = get_last_error_message(library_); - response->set_error_message(error_message); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, 0); } + response->set_status(status); + response->mutable_instrument()->set_id(session_id); + response->set_is_new_session(is_new_session); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -4266,14 +4514,11 @@ namespace nirfmxlte_grpc { const std::string& grpc_device_session_name = request->session_name(); auto cleanup_lambda = [&] (niRFmxInstrHandle id) { library_->Close(id, RFMXLTE_VAL_FALSE); }; int status = session_repository_->add_session(grpc_device_session_name, init_lambda, cleanup_lambda, session_id); - response->set_status(status); - if (status_ok(status)) { - response->mutable_instrument()->set_id(session_id); - } - else { - const auto error_message = get_last_error_message(library_); - response->set_error_message(error_message); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, 0); } + response->set_status(status); + response->mutable_instrument()->set_id(session_id); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -4297,6 +4542,9 @@ namespace nirfmxlte_grpc { char* selector_string = (char*)request->selector_string().c_str(); char* result_name = (char*)request->result_name().c_str(); auto status = library_->Initiate(instrument, selector_string, result_name); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -4334,6 +4582,9 @@ namespace nirfmxlte_grpc { int32 averaging_count = request->averaging_count(); auto status = library_->ModAccCfgAveraging(instrument, selector_string, averaging_enabled, averaging_count); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -4370,6 +4621,9 @@ namespace nirfmxlte_grpc { } auto status = library_->ModAccCfgCommonClockSourceEnabled(instrument, selector_string, common_clock_source_enabled); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -4406,6 +4660,9 @@ namespace nirfmxlte_grpc { } auto status = library_->ModAccCfgEVMUnit(instrument, selector_string, evm_unit); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -4427,6 +4684,9 @@ namespace nirfmxlte_grpc { char* selector_string = (char*)request->selector_string().c_str(); float64 fft_window_offset = request->fft_window_offset(); auto status = library_->ModAccCfgFFTWindowOffset(instrument, selector_string, fft_window_offset); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -4465,6 +4725,9 @@ namespace nirfmxlte_grpc { float64 fft_window_offset = request->fft_window_offset(); float64 fft_window_length = request->fft_window_length(); auto status = library_->ModAccCfgFFTWindowPosition(instrument, selector_string, fft_window_type, fft_window_offset, fft_window_length); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -4501,6 +4764,9 @@ namespace nirfmxlte_grpc { } auto status = library_->ModAccCfgInBandEmissionMaskType(instrument, selector_string, in_band_emission_mask_type); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -4539,6 +4805,9 @@ namespace nirfmxlte_grpc { int32 measurement_offset = request->measurement_offset(); int32 measurement_length = request->measurement_length(); auto status = library_->ModAccCfgSynchronizationModeAndInterval(instrument, selector_string, synchronization_mode, measurement_offset, measurement_length); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -4562,9 +4831,8 @@ namespace nirfmxlte_grpc { int32 actual_array_size {}; while (true) { auto status = library_->ModAccFetchCSRSConstellation(instrument, selector_string, timeout, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } std::vector csrs_constellation(actual_array_size, NIComplexSingle()); auto array_size = actual_array_size; @@ -4573,18 +4841,19 @@ namespace nirfmxlte_grpc { // buffer is now too small, try again continue; } + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); - if (status_ok(status)) { - convert_to_grpc(csrs_constellation, response->mutable_csrs_constellation()); - { - auto shrunk_size = actual_array_size; - auto current_size = response->mutable_csrs_constellation()->size(); - if (shrunk_size != current_size) { - response->mutable_csrs_constellation()->DeleteSubrange(shrunk_size, current_size - shrunk_size); - } + convert_to_grpc(csrs_constellation, response->mutable_csrs_constellation()); + { + auto shrunk_size = actual_array_size; + auto current_size = response->mutable_csrs_constellation()->size(); + if (shrunk_size != current_size) { + response->mutable_csrs_constellation()->DeleteSubrange(shrunk_size, current_size - shrunk_size); } - response->set_actual_array_size(actual_array_size); } + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -4607,10 +4876,11 @@ namespace nirfmxlte_grpc { float64 timeout = request->timeout(); float64 mean_rms_csrs_evm {}; auto status = library_->ModAccFetchCSRSEVM(instrument, selector_string, timeout, &mean_rms_csrs_evm); - response->set_status(status); - if (status_ok(status)) { - response->set_mean_rms_csrs_evm(mean_rms_csrs_evm); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_mean_rms_csrs_evm(mean_rms_csrs_evm); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -4633,9 +4903,8 @@ namespace nirfmxlte_grpc { int32 actual_array_size {}; while (true) { auto status = library_->ModAccFetchCSRSEVMArray(instrument, selector_string, timeout, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_mean_rms_csrs_evm()->Resize(actual_array_size, 0); float64* mean_rms_csrs_evm = response->mutable_mean_rms_csrs_evm()->mutable_data(); @@ -4645,11 +4914,12 @@ namespace nirfmxlte_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->mutable_mean_rms_csrs_evm()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->mutable_mean_rms_csrs_evm()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -4677,15 +4947,16 @@ namespace nirfmxlte_grpc { int32 peak_composite_evm_subcarrier_index {}; int32 peak_composite_evm_slot_index {}; auto status = library_->ModAccFetchCompositeEVM(instrument, selector_string, timeout, &mean_rms_composite_evm, &maximum_peak_composite_evm, &mean_frequency_error, &peak_composite_evm_symbol_index, &peak_composite_evm_subcarrier_index, &peak_composite_evm_slot_index); - response->set_status(status); - if (status_ok(status)) { - response->set_mean_rms_composite_evm(mean_rms_composite_evm); - response->set_maximum_peak_composite_evm(maximum_peak_composite_evm); - response->set_mean_frequency_error(mean_frequency_error); - response->set_peak_composite_evm_symbol_index(peak_composite_evm_symbol_index); - response->set_peak_composite_evm_subcarrier_index(peak_composite_evm_subcarrier_index); - response->set_peak_composite_evm_slot_index(peak_composite_evm_slot_index); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_mean_rms_composite_evm(mean_rms_composite_evm); + response->set_maximum_peak_composite_evm(maximum_peak_composite_evm); + response->set_mean_frequency_error(mean_frequency_error); + response->set_peak_composite_evm_symbol_index(peak_composite_evm_symbol_index); + response->set_peak_composite_evm_subcarrier_index(peak_composite_evm_subcarrier_index); + response->set_peak_composite_evm_slot_index(peak_composite_evm_slot_index); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -4708,9 +4979,8 @@ namespace nirfmxlte_grpc { int32 actual_array_size {}; while (true) { auto status = library_->ModAccFetchCompositeEVMArray(instrument, selector_string, timeout, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_mean_rms_composite_evm()->Resize(actual_array_size, 0); float64* mean_rms_composite_evm = response->mutable_mean_rms_composite_evm()->mutable_data(); @@ -4730,16 +5000,17 @@ namespace nirfmxlte_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->mutable_mean_rms_composite_evm()->Resize(actual_array_size, 0); - response->mutable_maximum_peak_composite_evm()->Resize(actual_array_size, 0); - response->mutable_mean_frequency_error()->Resize(actual_array_size, 0); - response->mutable_peak_composite_evm_symbol_index()->Resize(actual_array_size, 0); - response->mutable_peak_composite_evm_subcarrier_index()->Resize(actual_array_size, 0); - response->mutable_peak_composite_evm_slot_index()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->mutable_mean_rms_composite_evm()->Resize(actual_array_size, 0); + response->mutable_maximum_peak_composite_evm()->Resize(actual_array_size, 0); + response->mutable_mean_frequency_error()->Resize(actual_array_size, 0); + response->mutable_peak_composite_evm_symbol_index()->Resize(actual_array_size, 0); + response->mutable_peak_composite_evm_subcarrier_index()->Resize(actual_array_size, 0); + response->mutable_peak_composite_evm_slot_index()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -4765,13 +5036,14 @@ namespace nirfmxlte_grpc { float64 mean_rms_composite_phase_error {}; float64 max_peak_composite_phase_error {}; auto status = library_->ModAccFetchCompositeMagnitudeAndPhaseError(instrument, selector_string, timeout, &mean_rms_composite_magnitude_error, &max_peak_composite_magnitude_error, &mean_rms_composite_phase_error, &max_peak_composite_phase_error); - response->set_status(status); - if (status_ok(status)) { - response->set_mean_rms_composite_magnitude_error(mean_rms_composite_magnitude_error); - response->set_max_peak_composite_magnitude_error(max_peak_composite_magnitude_error); - response->set_mean_rms_composite_phase_error(mean_rms_composite_phase_error); - response->set_max_peak_composite_phase_error(max_peak_composite_phase_error); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_mean_rms_composite_magnitude_error(mean_rms_composite_magnitude_error); + response->set_max_peak_composite_magnitude_error(max_peak_composite_magnitude_error); + response->set_mean_rms_composite_phase_error(mean_rms_composite_phase_error); + response->set_max_peak_composite_phase_error(max_peak_composite_phase_error); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -4794,9 +5066,8 @@ namespace nirfmxlte_grpc { int32 actual_array_size {}; while (true) { auto status = library_->ModAccFetchCompositeMagnitudeAndPhaseErrorArray(instrument, selector_string, timeout, nullptr, nullptr, nullptr, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_mean_rms_composite_magnitude_error()->Resize(actual_array_size, 0); float64* mean_rms_composite_magnitude_error = response->mutable_mean_rms_composite_magnitude_error()->mutable_data(); @@ -4812,14 +5083,15 @@ namespace nirfmxlte_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->mutable_mean_rms_composite_magnitude_error()->Resize(actual_array_size, 0); - response->mutable_maximum_peak_composite_magnitude_error()->Resize(actual_array_size, 0); - response->mutable_mean_rms_composite_phase_error()->Resize(actual_array_size, 0); - response->mutable_maximum_peak_composite_phase_error()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->mutable_mean_rms_composite_magnitude_error()->Resize(actual_array_size, 0); + response->mutable_maximum_peak_composite_magnitude_error()->Resize(actual_array_size, 0); + response->mutable_mean_rms_composite_phase_error()->Resize(actual_array_size, 0); + response->mutable_maximum_peak_composite_phase_error()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -4842,10 +5114,11 @@ namespace nirfmxlte_grpc { float64 timeout = request->timeout(); int32 detected_cell_id {}; auto status = library_->ModAccFetchDownlinkDetectedCellID(instrument, selector_string, timeout, &detected_cell_id); - response->set_status(status); - if (status_ok(status)) { - response->set_detected_cell_id(detected_cell_id); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_detected_cell_id(detected_cell_id); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -4868,9 +5141,8 @@ namespace nirfmxlte_grpc { int32 actual_array_size {}; while (true) { auto status = library_->ModAccFetchDownlinkDetectedCellIDArray(instrument, selector_string, timeout, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_detected_cell_id()->Resize(actual_array_size, 0); int32* detected_cell_id = reinterpret_cast(response->mutable_detected_cell_id()->mutable_data()); @@ -4880,11 +5152,12 @@ namespace nirfmxlte_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->mutable_detected_cell_id()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->mutable_detected_cell_id()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -4908,9 +5181,8 @@ namespace nirfmxlte_grpc { int32 actual_array_size {}; while (true) { auto status = library_->ModAccFetchDownlinkPBCHConstellation(instrument, selector_string, timeout, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } std::vector pbch_constellation(actual_array_size, NIComplexSingle()); auto array_size = actual_array_size; @@ -4919,18 +5191,19 @@ namespace nirfmxlte_grpc { // buffer is now too small, try again continue; } + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); - if (status_ok(status)) { - convert_to_grpc(pbch_constellation, response->mutable_pbch_constellation()); - { - auto shrunk_size = actual_array_size; - auto current_size = response->mutable_pbch_constellation()->size(); - if (shrunk_size != current_size) { - response->mutable_pbch_constellation()->DeleteSubrange(shrunk_size, current_size - shrunk_size); - } + convert_to_grpc(pbch_constellation, response->mutable_pbch_constellation()); + { + auto shrunk_size = actual_array_size; + auto current_size = response->mutable_pbch_constellation()->size(); + if (shrunk_size != current_size) { + response->mutable_pbch_constellation()->DeleteSubrange(shrunk_size, current_size - shrunk_size); } - response->set_actual_array_size(actual_array_size); } + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -4954,9 +5227,8 @@ namespace nirfmxlte_grpc { int32 actual_array_size {}; while (true) { auto status = library_->ModAccFetchDownlinkPCFICHConstellation(instrument, selector_string, timeout, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } std::vector pcfich_constellation(actual_array_size, NIComplexSingle()); auto array_size = actual_array_size; @@ -4965,18 +5237,19 @@ namespace nirfmxlte_grpc { // buffer is now too small, try again continue; } + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); - if (status_ok(status)) { - convert_to_grpc(pcfich_constellation, response->mutable_pcfich_constellation()); - { - auto shrunk_size = actual_array_size; - auto current_size = response->mutable_pcfich_constellation()->size(); - if (shrunk_size != current_size) { - response->mutable_pcfich_constellation()->DeleteSubrange(shrunk_size, current_size - shrunk_size); - } + convert_to_grpc(pcfich_constellation, response->mutable_pcfich_constellation()); + { + auto shrunk_size = actual_array_size; + auto current_size = response->mutable_pcfich_constellation()->size(); + if (shrunk_size != current_size) { + response->mutable_pcfich_constellation()->DeleteSubrange(shrunk_size, current_size - shrunk_size); } - response->set_actual_array_size(actual_array_size); } + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -5000,9 +5273,8 @@ namespace nirfmxlte_grpc { int32 actual_array_size {}; while (true) { auto status = library_->ModAccFetchDownlinkPDCCHConstellation(instrument, selector_string, timeout, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } std::vector pdcch_constellation(actual_array_size, NIComplexSingle()); auto array_size = actual_array_size; @@ -5011,18 +5283,19 @@ namespace nirfmxlte_grpc { // buffer is now too small, try again continue; } + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); - if (status_ok(status)) { - convert_to_grpc(pdcch_constellation, response->mutable_pdcch_constellation()); - { - auto shrunk_size = actual_array_size; - auto current_size = response->mutable_pdcch_constellation()->size(); - if (shrunk_size != current_size) { - response->mutable_pdcch_constellation()->DeleteSubrange(shrunk_size, current_size - shrunk_size); - } + convert_to_grpc(pdcch_constellation, response->mutable_pdcch_constellation()); + { + auto shrunk_size = actual_array_size; + auto current_size = response->mutable_pdcch_constellation()->size(); + if (shrunk_size != current_size) { + response->mutable_pdcch_constellation()->DeleteSubrange(shrunk_size, current_size - shrunk_size); } - response->set_actual_array_size(actual_array_size); } + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -5046,9 +5319,8 @@ namespace nirfmxlte_grpc { int32 actual_array_size {}; while (true) { auto status = library_->ModAccFetchDownlinkPHICHConstellation(instrument, selector_string, timeout, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } std::vector phich_constellation(actual_array_size, NIComplexSingle()); auto array_size = actual_array_size; @@ -5057,18 +5329,19 @@ namespace nirfmxlte_grpc { // buffer is now too small, try again continue; } + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); - if (status_ok(status)) { - convert_to_grpc(phich_constellation, response->mutable_phich_constellation()); - { - auto shrunk_size = actual_array_size; - auto current_size = response->mutable_phich_constellation()->size(); - if (shrunk_size != current_size) { - response->mutable_phich_constellation()->DeleteSubrange(shrunk_size, current_size - shrunk_size); - } + convert_to_grpc(phich_constellation, response->mutable_phich_constellation()); + { + auto shrunk_size = actual_array_size; + auto current_size = response->mutable_phich_constellation()->size(); + if (shrunk_size != current_size) { + response->mutable_phich_constellation()->DeleteSubrange(shrunk_size, current_size - shrunk_size); } - response->set_actual_array_size(actual_array_size); } + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -5094,11 +5367,12 @@ namespace nirfmxlte_grpc { float64 rs_transmit_power {}; float64 ofdm_symbol_transmit_power {}; auto status = library_->ModAccFetchDownlinkTransmitPower(instrument, selector_string, timeout, &rs_transmit_power, &ofdm_symbol_transmit_power, reserved1, reserved2); - response->set_status(status); - if (status_ok(status)) { - response->set_rs_transmit_power(rs_transmit_power); - response->set_ofdm_symbol_transmit_power(ofdm_symbol_transmit_power); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_rs_transmit_power(rs_transmit_power); + response->set_ofdm_symbol_transmit_power(ofdm_symbol_transmit_power); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -5123,9 +5397,8 @@ namespace nirfmxlte_grpc { int32 actual_array_size {}; while (true) { auto status = library_->ModAccFetchDownlinkTransmitPowerArray(instrument, selector_string, timeout, nullptr, nullptr, reserved1, reserved2, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_rs_transmit_power()->Resize(actual_array_size, 0); float64* rs_transmit_power = response->mutable_rs_transmit_power()->mutable_data(); @@ -5137,12 +5410,13 @@ namespace nirfmxlte_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->mutable_rs_transmit_power()->Resize(actual_array_size, 0); - response->mutable_ofdm_symbol_transmit_power()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->mutable_rs_transmit_power()->Resize(actual_array_size, 0); + response->mutable_ofdm_symbol_transmit_power()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -5168,9 +5442,8 @@ namespace nirfmxlte_grpc { int32 actual_array_size {}; while (true) { auto status = library_->ModAccFetchEVMHighPerSymbolTrace(instrument, selector_string, timeout, &x0, &dx, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_evm_high_per_symbol()->Resize(actual_array_size, 0); float32* evm_high_per_symbol = response->mutable_evm_high_per_symbol()->mutable_data(); @@ -5180,13 +5453,14 @@ namespace nirfmxlte_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_x0(x0); - response->set_dx(dx); - response->mutable_evm_high_per_symbol()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_x0(x0); + response->set_dx(dx); + response->mutable_evm_high_per_symbol()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -5212,9 +5486,8 @@ namespace nirfmxlte_grpc { int32 actual_array_size {}; while (true) { auto status = library_->ModAccFetchEVMLowPerSymbolTrace(instrument, selector_string, timeout, &x0, &dx, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_evm_low_per_symbol()->Resize(actual_array_size, 0); float32* evm_low_per_symbol = response->mutable_evm_low_per_symbol()->mutable_data(); @@ -5224,13 +5497,14 @@ namespace nirfmxlte_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_x0(x0); - response->set_dx(dx); - response->mutable_evm_low_per_symbol()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_x0(x0); + response->set_dx(dx); + response->mutable_evm_low_per_symbol()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -5256,9 +5530,8 @@ namespace nirfmxlte_grpc { int32 actual_array_size {}; while (true) { auto status = library_->ModAccFetchEVMPerSlotTrace(instrument, selector_string, timeout, &x0, &dx, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_rms_evm_per_slot()->Resize(actual_array_size, 0); float32* rms_evm_per_slot = response->mutable_rms_evm_per_slot()->mutable_data(); @@ -5268,13 +5541,14 @@ namespace nirfmxlte_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_x0(x0); - response->set_dx(dx); - response->mutable_rms_evm_per_slot()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_x0(x0); + response->set_dx(dx); + response->mutable_rms_evm_per_slot()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -5300,9 +5574,8 @@ namespace nirfmxlte_grpc { int32 actual_array_size {}; while (true) { auto status = library_->ModAccFetchEVMPerSubcarrierTrace(instrument, selector_string, timeout, &x0, &dx, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_mean_rms_evm_per_subcarrier()->Resize(actual_array_size, 0); float32* mean_rms_evm_per_subcarrier = response->mutable_mean_rms_evm_per_subcarrier()->mutable_data(); @@ -5312,13 +5585,14 @@ namespace nirfmxlte_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_x0(x0); - response->set_dx(dx); - response->mutable_mean_rms_evm_per_subcarrier()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_x0(x0); + response->set_dx(dx); + response->mutable_mean_rms_evm_per_subcarrier()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -5344,9 +5618,8 @@ namespace nirfmxlte_grpc { int32 actual_array_size {}; while (true) { auto status = library_->ModAccFetchEVMPerSymbolTrace(instrument, selector_string, timeout, &x0, &dx, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_rms_evm_per_symbol()->Resize(actual_array_size, 0); float32* rms_evm_per_symbol = response->mutable_rms_evm_per_symbol()->mutable_data(); @@ -5356,13 +5629,14 @@ namespace nirfmxlte_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_x0(x0); - response->set_dx(dx); - response->mutable_rms_evm_per_symbol()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_x0(x0); + response->set_dx(dx); + response->mutable_rms_evm_per_symbol()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -5387,12 +5661,13 @@ namespace nirfmxlte_grpc { float64 mean_iq_gain_imbalance {}; float64 mean_iq_quadrature_error {}; auto status = library_->ModAccFetchIQImpairments(instrument, selector_string, timeout, &mean_iq_origin_offset, &mean_iq_gain_imbalance, &mean_iq_quadrature_error); - response->set_status(status); - if (status_ok(status)) { - response->set_mean_iq_origin_offset(mean_iq_origin_offset); - response->set_mean_iq_gain_imbalance(mean_iq_gain_imbalance); - response->set_mean_iq_quadrature_error(mean_iq_quadrature_error); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_mean_iq_origin_offset(mean_iq_origin_offset); + response->set_mean_iq_gain_imbalance(mean_iq_gain_imbalance); + response->set_mean_iq_quadrature_error(mean_iq_quadrature_error); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -5415,9 +5690,8 @@ namespace nirfmxlte_grpc { int32 actual_array_size {}; while (true) { auto status = library_->ModAccFetchIQImpairmentsArray(instrument, selector_string, timeout, nullptr, nullptr, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_mean_iq_origin_offset()->Resize(actual_array_size, 0); float64* mean_iq_origin_offset = response->mutable_mean_iq_origin_offset()->mutable_data(); @@ -5431,13 +5705,14 @@ namespace nirfmxlte_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->mutable_mean_iq_origin_offset()->Resize(actual_array_size, 0); - response->mutable_mean_iq_gain_imbalance()->Resize(actual_array_size, 0); - response->mutable_mean_iq_quadrature_error()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->mutable_mean_iq_origin_offset()->Resize(actual_array_size, 0); + response->mutable_mean_iq_gain_imbalance()->Resize(actual_array_size, 0); + response->mutable_mean_iq_quadrature_error()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -5460,10 +5735,11 @@ namespace nirfmxlte_grpc { float64 timeout = request->timeout(); float64 in_band_emission_margin {}; auto status = library_->ModAccFetchInBandEmissionMargin(instrument, selector_string, timeout, &in_band_emission_margin); - response->set_status(status); - if (status_ok(status)) { - response->set_in_band_emission_margin(in_band_emission_margin); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_in_band_emission_margin(in_band_emission_margin); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -5486,9 +5762,8 @@ namespace nirfmxlte_grpc { int32 actual_array_size {}; while (true) { auto status = library_->ModAccFetchInBandEmissionMarginArray(instrument, selector_string, timeout, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_in_band_emission_margin()->Resize(actual_array_size, 0); float64* in_band_emission_margin = response->mutable_in_band_emission_margin()->mutable_data(); @@ -5498,11 +5773,12 @@ namespace nirfmxlte_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->mutable_in_band_emission_margin()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->mutable_in_band_emission_margin()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -5528,9 +5804,8 @@ namespace nirfmxlte_grpc { int32 actual_array_size {}; while (true) { auto status = library_->ModAccFetchInBandEmissionTrace(instrument, selector_string, timeout, &x0, &dx, nullptr, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_in_band_emission()->Resize(actual_array_size, 0); float32* in_band_emission = response->mutable_in_band_emission()->mutable_data(); @@ -5542,14 +5817,15 @@ namespace nirfmxlte_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_x0(x0); - response->set_dx(dx); - response->mutable_in_band_emission()->Resize(actual_array_size, 0); - response->mutable_in_band_emission_mask()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_x0(x0); + response->set_dx(dx); + response->mutable_in_band_emission()->Resize(actual_array_size, 0); + response->mutable_in_band_emission_mask()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -5575,9 +5851,8 @@ namespace nirfmxlte_grpc { int32 actual_array_size {}; while (true) { auto status = library_->ModAccFetchMaximumEVMPerSlotTrace(instrument, selector_string, timeout, &x0, &dx, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_maximum_evm_per_slot()->Resize(actual_array_size, 0); float32* maximum_evm_per_slot = response->mutable_maximum_evm_per_slot()->mutable_data(); @@ -5587,13 +5862,14 @@ namespace nirfmxlte_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_x0(x0); - response->set_dx(dx); - response->mutable_maximum_evm_per_slot()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_x0(x0); + response->set_dx(dx); + response->mutable_maximum_evm_per_slot()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -5619,9 +5895,8 @@ namespace nirfmxlte_grpc { int32 actual_array_size {}; while (true) { auto status = library_->ModAccFetchMaximumEVMPerSubcarrierTrace(instrument, selector_string, timeout, &x0, &dx, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_maximum_evm_per_subcarrier()->Resize(actual_array_size, 0); float32* maximum_evm_per_subcarrier = response->mutable_maximum_evm_per_subcarrier()->mutable_data(); @@ -5631,13 +5906,14 @@ namespace nirfmxlte_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_x0(x0); - response->set_dx(dx); - response->mutable_maximum_evm_per_subcarrier()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_x0(x0); + response->set_dx(dx); + response->mutable_maximum_evm_per_subcarrier()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -5663,9 +5939,8 @@ namespace nirfmxlte_grpc { int32 actual_array_size {}; while (true) { auto status = library_->ModAccFetchMaximumEVMPerSymbolTrace(instrument, selector_string, timeout, &x0, &dx, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_maximum_evm_per_symbol()->Resize(actual_array_size, 0); float32* maximum_evm_per_symbol = response->mutable_maximum_evm_per_symbol()->mutable_data(); @@ -5675,13 +5950,14 @@ namespace nirfmxlte_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_x0(x0); - response->set_dx(dx); - response->mutable_maximum_evm_per_symbol()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_x0(x0); + response->set_dx(dx); + response->mutable_maximum_evm_per_symbol()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -5707,9 +5983,8 @@ namespace nirfmxlte_grpc { int32 actual_array_size {}; while (true) { auto status = library_->ModAccFetchMaximumMagnitudeErrorPerSymbolTrace(instrument, selector_string, timeout, &x0, &dx, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_maximum_magnitude_error_per_symbol()->Resize(actual_array_size, 0); float32* maximum_magnitude_error_per_symbol = response->mutable_maximum_magnitude_error_per_symbol()->mutable_data(); @@ -5719,13 +5994,14 @@ namespace nirfmxlte_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_x0(x0); - response->set_dx(dx); - response->mutable_maximum_magnitude_error_per_symbol()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_x0(x0); + response->set_dx(dx); + response->mutable_maximum_magnitude_error_per_symbol()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -5751,9 +6027,8 @@ namespace nirfmxlte_grpc { int32 actual_array_size {}; while (true) { auto status = library_->ModAccFetchMaximumPhaseErrorPerSymbolTrace(instrument, selector_string, timeout, &x0, &dx, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_maximum_phase_error_per_symbol()->Resize(actual_array_size, 0); float32* maximum_phase_error_per_symbol = response->mutable_maximum_phase_error_per_symbol()->mutable_data(); @@ -5763,13 +6038,14 @@ namespace nirfmxlte_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_x0(x0); - response->set_dx(dx); - response->mutable_maximum_phase_error_per_symbol()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_x0(x0); + response->set_dx(dx); + response->mutable_maximum_phase_error_per_symbol()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -5794,9 +6070,8 @@ namespace nirfmxlte_grpc { int32 dmrs_constellation_actual_array_size {}; while (true) { auto status = library_->ModAccFetchNPUSCHConstellationTrace(instrument, selector_string, timeout, nullptr, 0, &data_constellation_actual_array_size, nullptr, 0, &dmrs_constellation_actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } std::vector data_constellation(data_constellation_actual_array_size, NIComplexSingle()); std::vector dmrs_constellation(dmrs_constellation_actual_array_size, NIComplexSingle()); @@ -5807,27 +6082,28 @@ namespace nirfmxlte_grpc { // buffer is now too small, try again continue; } + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); - if (status_ok(status)) { - convert_to_grpc(data_constellation, response->mutable_data_constellation()); - { - auto shrunk_size = data_constellation_actual_array_size; - auto current_size = response->mutable_data_constellation()->size(); - if (shrunk_size != current_size) { - response->mutable_data_constellation()->DeleteSubrange(shrunk_size, current_size - shrunk_size); - } + convert_to_grpc(data_constellation, response->mutable_data_constellation()); + { + auto shrunk_size = data_constellation_actual_array_size; + auto current_size = response->mutable_data_constellation()->size(); + if (shrunk_size != current_size) { + response->mutable_data_constellation()->DeleteSubrange(shrunk_size, current_size - shrunk_size); } - response->set_data_constellation_actual_array_size(data_constellation_actual_array_size); - convert_to_grpc(dmrs_constellation, response->mutable_dmrs_constellation()); - { - auto shrunk_size = dmrs_constellation_actual_array_size; - auto current_size = response->mutable_dmrs_constellation()->size(); - if (shrunk_size != current_size) { - response->mutable_dmrs_constellation()->DeleteSubrange(shrunk_size, current_size - shrunk_size); - } + } + response->set_data_constellation_actual_array_size(data_constellation_actual_array_size); + convert_to_grpc(dmrs_constellation, response->mutable_dmrs_constellation()); + { + auto shrunk_size = dmrs_constellation_actual_array_size; + auto current_size = response->mutable_dmrs_constellation()->size(); + if (shrunk_size != current_size) { + response->mutable_dmrs_constellation()->DeleteSubrange(shrunk_size, current_size - shrunk_size); } - response->set_dmrs_constellation_actual_array_size(dmrs_constellation_actual_array_size); } + response->set_dmrs_constellation_actual_array_size(dmrs_constellation_actual_array_size); return ::grpc::Status::OK; } } @@ -5851,11 +6127,12 @@ namespace nirfmxlte_grpc { float64 npusch_mean_rms_dmrs_evm {}; float64 npusch_maximum_peak_dmrs_evm {}; auto status = library_->ModAccFetchNPUSCHDMRSEVM(instrument, selector_string, timeout, &npusch_mean_rms_dmrs_evm, &npusch_maximum_peak_dmrs_evm); - response->set_status(status); - if (status_ok(status)) { - response->set_npusch_mean_rms_dmrs_evm(npusch_mean_rms_dmrs_evm); - response->set_npusch_maximum_peak_dmrs_evm(npusch_maximum_peak_dmrs_evm); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_npusch_mean_rms_dmrs_evm(npusch_mean_rms_dmrs_evm); + response->set_npusch_maximum_peak_dmrs_evm(npusch_maximum_peak_dmrs_evm); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -5878,11 +6155,12 @@ namespace nirfmxlte_grpc { float64 npusch_mean_rms_data_evm {}; float64 npusch_maximum_peak_data_evm {}; auto status = library_->ModAccFetchNPUSCHDataEVM(instrument, selector_string, timeout, &npusch_mean_rms_data_evm, &npusch_maximum_peak_data_evm); - response->set_status(status); - if (status_ok(status)) { - response->set_npusch_mean_rms_data_evm(npusch_mean_rms_data_evm); - response->set_npusch_maximum_peak_data_evm(npusch_maximum_peak_data_evm); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_npusch_mean_rms_data_evm(npusch_mean_rms_data_evm); + response->set_npusch_maximum_peak_data_evm(npusch_maximum_peak_data_evm); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -5905,11 +6183,12 @@ namespace nirfmxlte_grpc { float64 npusch_mean_data_power {}; float64 npusch_mean_dmrs_power {}; auto status = library_->ModAccFetchNPUSCHSymbolPower(instrument, selector_string, timeout, &npusch_mean_data_power, &npusch_mean_dmrs_power); - response->set_status(status); - if (status_ok(status)) { - response->set_npusch_mean_data_power(npusch_mean_data_power); - response->set_npusch_mean_dmrs_power(npusch_mean_dmrs_power); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_npusch_mean_data_power(npusch_mean_data_power); + response->set_npusch_mean_dmrs_power(npusch_mean_dmrs_power); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -5932,9 +6211,8 @@ namespace nirfmxlte_grpc { int32 actual_array_size {}; while (true) { auto status = library_->ModAccFetchPDSCH1024QAMConstellation(instrument, selector_string, timeout, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } std::vector qam1024_constellation(actual_array_size, NIComplexSingle()); auto array_size = actual_array_size; @@ -5943,18 +6221,19 @@ namespace nirfmxlte_grpc { // buffer is now too small, try again continue; } + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); - if (status_ok(status)) { - convert_to_grpc(qam1024_constellation, response->mutable_qam1024_constellation()); - { - auto shrunk_size = actual_array_size; - auto current_size = response->mutable_qam1024_constellation()->size(); - if (shrunk_size != current_size) { - response->mutable_qam1024_constellation()->DeleteSubrange(shrunk_size, current_size - shrunk_size); - } + convert_to_grpc(qam1024_constellation, response->mutable_qam1024_constellation()); + { + auto shrunk_size = actual_array_size; + auto current_size = response->mutable_qam1024_constellation()->size(); + if (shrunk_size != current_size) { + response->mutable_qam1024_constellation()->DeleteSubrange(shrunk_size, current_size - shrunk_size); } - response->set_actual_array_size(actual_array_size); } + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -5977,10 +6256,11 @@ namespace nirfmxlte_grpc { float64 timeout = request->timeout(); float64 mean_rms_1024qam_evm {}; auto status = library_->ModAccFetchPDSCH1024QAMEVM(instrument, selector_string, timeout, &mean_rms_1024qam_evm); - response->set_status(status); - if (status_ok(status)) { - response->set_mean_rms_1024qam_evm(mean_rms_1024qam_evm); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_mean_rms_1024qam_evm(mean_rms_1024qam_evm); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -6003,9 +6283,8 @@ namespace nirfmxlte_grpc { int32 actual_array_size {}; while (true) { auto status = library_->ModAccFetchPDSCH1024QAMEVMArray(instrument, selector_string, timeout, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_mean_rms_1024qam_evm()->Resize(actual_array_size, 0); float64* mean_rms_1024qam_evm = response->mutable_mean_rms_1024qam_evm()->mutable_data(); @@ -6015,11 +6294,12 @@ namespace nirfmxlte_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->mutable_mean_rms_1024qam_evm()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->mutable_mean_rms_1024qam_evm()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -6043,9 +6323,8 @@ namespace nirfmxlte_grpc { int32 actual_array_size {}; while (true) { auto status = library_->ModAccFetchPDSCH16QAMConstellation(instrument, selector_string, timeout, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } std::vector qam16_constellation(actual_array_size, NIComplexSingle()); auto array_size = actual_array_size; @@ -6054,18 +6333,19 @@ namespace nirfmxlte_grpc { // buffer is now too small, try again continue; } + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); - if (status_ok(status)) { - convert_to_grpc(qam16_constellation, response->mutable_qam16_constellation()); - { - auto shrunk_size = actual_array_size; - auto current_size = response->mutable_qam16_constellation()->size(); - if (shrunk_size != current_size) { - response->mutable_qam16_constellation()->DeleteSubrange(shrunk_size, current_size - shrunk_size); - } + convert_to_grpc(qam16_constellation, response->mutable_qam16_constellation()); + { + auto shrunk_size = actual_array_size; + auto current_size = response->mutable_qam16_constellation()->size(); + if (shrunk_size != current_size) { + response->mutable_qam16_constellation()->DeleteSubrange(shrunk_size, current_size - shrunk_size); } - response->set_actual_array_size(actual_array_size); } + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -6089,9 +6369,8 @@ namespace nirfmxlte_grpc { int32 actual_array_size {}; while (true) { auto status = library_->ModAccFetchPDSCH256QAMConstellation(instrument, selector_string, timeout, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } std::vector qam256_constellation(actual_array_size, NIComplexSingle()); auto array_size = actual_array_size; @@ -6100,18 +6379,19 @@ namespace nirfmxlte_grpc { // buffer is now too small, try again continue; } + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); - if (status_ok(status)) { - convert_to_grpc(qam256_constellation, response->mutable_qam256_constellation()); - { - auto shrunk_size = actual_array_size; - auto current_size = response->mutable_qam256_constellation()->size(); - if (shrunk_size != current_size) { - response->mutable_qam256_constellation()->DeleteSubrange(shrunk_size, current_size - shrunk_size); - } + convert_to_grpc(qam256_constellation, response->mutable_qam256_constellation()); + { + auto shrunk_size = actual_array_size; + auto current_size = response->mutable_qam256_constellation()->size(); + if (shrunk_size != current_size) { + response->mutable_qam256_constellation()->DeleteSubrange(shrunk_size, current_size - shrunk_size); } - response->set_actual_array_size(actual_array_size); } + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -6135,9 +6415,8 @@ namespace nirfmxlte_grpc { int32 actual_array_size {}; while (true) { auto status = library_->ModAccFetchPDSCH64QAMConstellation(instrument, selector_string, timeout, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } std::vector qam64_constellation(actual_array_size, NIComplexSingle()); auto array_size = actual_array_size; @@ -6146,18 +6425,19 @@ namespace nirfmxlte_grpc { // buffer is now too small, try again continue; } + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); - if (status_ok(status)) { - convert_to_grpc(qam64_constellation, response->mutable_qam64_constellation()); - { - auto shrunk_size = actual_array_size; - auto current_size = response->mutable_qam64_constellation()->size(); - if (shrunk_size != current_size) { - response->mutable_qam64_constellation()->DeleteSubrange(shrunk_size, current_size - shrunk_size); - } + convert_to_grpc(qam64_constellation, response->mutable_qam64_constellation()); + { + auto shrunk_size = actual_array_size; + auto current_size = response->mutable_qam64_constellation()->size(); + if (shrunk_size != current_size) { + response->mutable_qam64_constellation()->DeleteSubrange(shrunk_size, current_size - shrunk_size); } - response->set_actual_array_size(actual_array_size); } + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -6184,14 +6464,15 @@ namespace nirfmxlte_grpc { float64 mean_rms_64qam_evm {}; float64 mean_rms_256qam_evm {}; auto status = library_->ModAccFetchPDSCHEVM(instrument, selector_string, timeout, &mean_rms_evm, &mean_rms_qpsk_evm, &mean_rms_16qam_evm, &mean_rms_64qam_evm, &mean_rms_256qam_evm); - response->set_status(status); - if (status_ok(status)) { - response->set_mean_rms_evm(mean_rms_evm); - response->set_mean_rms_qpsk_evm(mean_rms_qpsk_evm); - response->set_mean_rms_16qam_evm(mean_rms_16qam_evm); - response->set_mean_rms_64qam_evm(mean_rms_64qam_evm); - response->set_mean_rms_256qam_evm(mean_rms_256qam_evm); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_mean_rms_evm(mean_rms_evm); + response->set_mean_rms_qpsk_evm(mean_rms_qpsk_evm); + response->set_mean_rms_16qam_evm(mean_rms_16qam_evm); + response->set_mean_rms_64qam_evm(mean_rms_64qam_evm); + response->set_mean_rms_256qam_evm(mean_rms_256qam_evm); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -6214,9 +6495,8 @@ namespace nirfmxlte_grpc { int32 actual_array_size {}; while (true) { auto status = library_->ModAccFetchPDSCHEVMArray(instrument, selector_string, timeout, nullptr, nullptr, nullptr, nullptr, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_mean_rms_evm()->Resize(actual_array_size, 0); float64* mean_rms_evm = response->mutable_mean_rms_evm()->mutable_data(); @@ -6234,15 +6514,16 @@ namespace nirfmxlte_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->mutable_mean_rms_evm()->Resize(actual_array_size, 0); - response->mutable_mean_rms_qpsk_evm()->Resize(actual_array_size, 0); - response->mutable_mean_rms_16qam_evm()->Resize(actual_array_size, 0); - response->mutable_mean_rms_64qam_evm()->Resize(actual_array_size, 0); - response->mutable_mean_rms_256qam_evm()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->mutable_mean_rms_evm()->Resize(actual_array_size, 0); + response->mutable_mean_rms_qpsk_evm()->Resize(actual_array_size, 0); + response->mutable_mean_rms_16qam_evm()->Resize(actual_array_size, 0); + response->mutable_mean_rms_64qam_evm()->Resize(actual_array_size, 0); + response->mutable_mean_rms_256qam_evm()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -6266,9 +6547,8 @@ namespace nirfmxlte_grpc { int32 actual_array_size {}; while (true) { auto status = library_->ModAccFetchPDSCHQPSKConstellation(instrument, selector_string, timeout, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } std::vector qpsk_constellation(actual_array_size, NIComplexSingle()); auto array_size = actual_array_size; @@ -6277,18 +6557,19 @@ namespace nirfmxlte_grpc { // buffer is now too small, try again continue; } + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); - if (status_ok(status)) { - convert_to_grpc(qpsk_constellation, response->mutable_qpsk_constellation()); - { - auto shrunk_size = actual_array_size; - auto current_size = response->mutable_qpsk_constellation()->size(); - if (shrunk_size != current_size) { - response->mutable_qpsk_constellation()->DeleteSubrange(shrunk_size, current_size - shrunk_size); - } + convert_to_grpc(qpsk_constellation, response->mutable_qpsk_constellation()); + { + auto shrunk_size = actual_array_size; + auto current_size = response->mutable_qpsk_constellation()->size(); + if (shrunk_size != current_size) { + response->mutable_qpsk_constellation()->DeleteSubrange(shrunk_size, current_size - shrunk_size); } - response->set_actual_array_size(actual_array_size); } + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -6313,9 +6594,8 @@ namespace nirfmxlte_grpc { int32 dmrs_constellation_actual_array_size {}; while (true) { auto status = library_->ModAccFetchPSSCHConstellationTrace(instrument, selector_string, timeout, nullptr, 0, &data_constellation_actual_array_size, nullptr, 0, &dmrs_constellation_actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } std::vector data_constellation(data_constellation_actual_array_size, NIComplexSingle()); std::vector dmrs_constellation(dmrs_constellation_actual_array_size, NIComplexSingle()); @@ -6326,27 +6606,28 @@ namespace nirfmxlte_grpc { // buffer is now too small, try again continue; } + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); - if (status_ok(status)) { - convert_to_grpc(data_constellation, response->mutable_data_constellation()); - { - auto shrunk_size = data_constellation_actual_array_size; - auto current_size = response->mutable_data_constellation()->size(); - if (shrunk_size != current_size) { - response->mutable_data_constellation()->DeleteSubrange(shrunk_size, current_size - shrunk_size); - } + convert_to_grpc(data_constellation, response->mutable_data_constellation()); + { + auto shrunk_size = data_constellation_actual_array_size; + auto current_size = response->mutable_data_constellation()->size(); + if (shrunk_size != current_size) { + response->mutable_data_constellation()->DeleteSubrange(shrunk_size, current_size - shrunk_size); } - response->set_data_constellation_actual_array_size(data_constellation_actual_array_size); - convert_to_grpc(dmrs_constellation, response->mutable_dmrs_constellation()); - { - auto shrunk_size = dmrs_constellation_actual_array_size; - auto current_size = response->mutable_dmrs_constellation()->size(); - if (shrunk_size != current_size) { - response->mutable_dmrs_constellation()->DeleteSubrange(shrunk_size, current_size - shrunk_size); - } + } + response->set_data_constellation_actual_array_size(data_constellation_actual_array_size); + convert_to_grpc(dmrs_constellation, response->mutable_dmrs_constellation()); + { + auto shrunk_size = dmrs_constellation_actual_array_size; + auto current_size = response->mutable_dmrs_constellation()->size(); + if (shrunk_size != current_size) { + response->mutable_dmrs_constellation()->DeleteSubrange(shrunk_size, current_size - shrunk_size); } - response->set_dmrs_constellation_actual_array_size(dmrs_constellation_actual_array_size); } + response->set_dmrs_constellation_actual_array_size(dmrs_constellation_actual_array_size); return ::grpc::Status::OK; } } @@ -6370,11 +6651,12 @@ namespace nirfmxlte_grpc { float64 pssch_mean_rms_dmrs_evm {}; float64 pssch_maximum_peak_dmrs_evm {}; auto status = library_->ModAccFetchPSSCHDMRSEVM(instrument, selector_string, timeout, &pssch_mean_rms_dmrs_evm, &pssch_maximum_peak_dmrs_evm); - response->set_status(status); - if (status_ok(status)) { - response->set_pssch_mean_rms_dmrs_evm(pssch_mean_rms_dmrs_evm); - response->set_pssch_maximum_peak_dmrs_evm(pssch_maximum_peak_dmrs_evm); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_pssch_mean_rms_dmrs_evm(pssch_mean_rms_dmrs_evm); + response->set_pssch_maximum_peak_dmrs_evm(pssch_maximum_peak_dmrs_evm); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -6397,9 +6679,8 @@ namespace nirfmxlte_grpc { int32 actual_array_size {}; while (true) { auto status = library_->ModAccFetchPSSCHDMRSEVMArray(instrument, selector_string, timeout, nullptr, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_pssch_mean_rms_dmrs_evm()->Resize(actual_array_size, 0); float64* pssch_mean_rms_dmrs_evm = response->mutable_pssch_mean_rms_dmrs_evm()->mutable_data(); @@ -6411,12 +6692,13 @@ namespace nirfmxlte_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->mutable_pssch_mean_rms_dmrs_evm()->Resize(actual_array_size, 0); - response->mutable_pssch_maximum_peak_dmrs_evm()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->mutable_pssch_mean_rms_dmrs_evm()->Resize(actual_array_size, 0); + response->mutable_pssch_maximum_peak_dmrs_evm()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -6440,11 +6722,12 @@ namespace nirfmxlte_grpc { float64 pssch_mean_rms_data_evm {}; float64 pssch_maximum_peak_data_evm {}; auto status = library_->ModAccFetchPSSCHDataEVM(instrument, selector_string, timeout, &pssch_mean_rms_data_evm, &pssch_maximum_peak_data_evm); - response->set_status(status); - if (status_ok(status)) { - response->set_pssch_mean_rms_data_evm(pssch_mean_rms_data_evm); - response->set_pssch_maximum_peak_data_evm(pssch_maximum_peak_data_evm); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_pssch_mean_rms_data_evm(pssch_mean_rms_data_evm); + response->set_pssch_maximum_peak_data_evm(pssch_maximum_peak_data_evm); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -6467,9 +6750,8 @@ namespace nirfmxlte_grpc { int32 actual_array_size {}; while (true) { auto status = library_->ModAccFetchPSSCHDataEVMArray(instrument, selector_string, timeout, nullptr, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_pssch_mean_rms_data_evm()->Resize(actual_array_size, 0); float64* pssch_mean_rms_data_evm = response->mutable_pssch_mean_rms_data_evm()->mutable_data(); @@ -6481,12 +6763,13 @@ namespace nirfmxlte_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->mutable_pssch_mean_rms_data_evm()->Resize(actual_array_size, 0); - response->mutable_pssch_maximum_peak_data_evm()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->mutable_pssch_mean_rms_data_evm()->Resize(actual_array_size, 0); + response->mutable_pssch_maximum_peak_data_evm()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -6510,11 +6793,12 @@ namespace nirfmxlte_grpc { float64 pssch_mean_data_power {}; float64 pssch_mean_dmrs_power {}; auto status = library_->ModAccFetchPSSCHSymbolPower(instrument, selector_string, timeout, &pssch_mean_data_power, &pssch_mean_dmrs_power); - response->set_status(status); - if (status_ok(status)) { - response->set_pssch_mean_data_power(pssch_mean_data_power); - response->set_pssch_mean_dmrs_power(pssch_mean_dmrs_power); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_pssch_mean_data_power(pssch_mean_data_power); + response->set_pssch_mean_dmrs_power(pssch_mean_dmrs_power); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -6537,9 +6821,8 @@ namespace nirfmxlte_grpc { int32 actual_array_size {}; while (true) { auto status = library_->ModAccFetchPSSCHSymbolPowerArray(instrument, selector_string, timeout, nullptr, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_pssch_mean_data_power()->Resize(actual_array_size, 0); float64* pssch_mean_data_power = response->mutable_pssch_mean_data_power()->mutable_data(); @@ -6551,12 +6834,13 @@ namespace nirfmxlte_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->mutable_pssch_mean_data_power()->Resize(actual_array_size, 0); - response->mutable_pssch_mean_dmrs_power()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->mutable_pssch_mean_data_power()->Resize(actual_array_size, 0); + response->mutable_pssch_mean_dmrs_power()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -6581,9 +6865,8 @@ namespace nirfmxlte_grpc { int32 dmrs_constellation_actual_array_size {}; while (true) { auto status = library_->ModAccFetchPUSCHConstellationTrace(instrument, selector_string, timeout, nullptr, 0, &data_constellation_actual_array_size, nullptr, 0, &dmrs_constellation_actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } std::vector data_constellation(data_constellation_actual_array_size, NIComplexSingle()); std::vector dmrs_constellation(dmrs_constellation_actual_array_size, NIComplexSingle()); @@ -6594,27 +6877,28 @@ namespace nirfmxlte_grpc { // buffer is now too small, try again continue; } + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); - if (status_ok(status)) { - convert_to_grpc(data_constellation, response->mutable_data_constellation()); - { - auto shrunk_size = data_constellation_actual_array_size; - auto current_size = response->mutable_data_constellation()->size(); - if (shrunk_size != current_size) { - response->mutable_data_constellation()->DeleteSubrange(shrunk_size, current_size - shrunk_size); - } + convert_to_grpc(data_constellation, response->mutable_data_constellation()); + { + auto shrunk_size = data_constellation_actual_array_size; + auto current_size = response->mutable_data_constellation()->size(); + if (shrunk_size != current_size) { + response->mutable_data_constellation()->DeleteSubrange(shrunk_size, current_size - shrunk_size); } - response->set_data_constellation_actual_array_size(data_constellation_actual_array_size); - convert_to_grpc(dmrs_constellation, response->mutable_dmrs_constellation()); - { - auto shrunk_size = dmrs_constellation_actual_array_size; - auto current_size = response->mutable_dmrs_constellation()->size(); - if (shrunk_size != current_size) { - response->mutable_dmrs_constellation()->DeleteSubrange(shrunk_size, current_size - shrunk_size); - } + } + response->set_data_constellation_actual_array_size(data_constellation_actual_array_size); + convert_to_grpc(dmrs_constellation, response->mutable_dmrs_constellation()); + { + auto shrunk_size = dmrs_constellation_actual_array_size; + auto current_size = response->mutable_dmrs_constellation()->size(); + if (shrunk_size != current_size) { + response->mutable_dmrs_constellation()->DeleteSubrange(shrunk_size, current_size - shrunk_size); } - response->set_dmrs_constellation_actual_array_size(dmrs_constellation_actual_array_size); } + response->set_dmrs_constellation_actual_array_size(dmrs_constellation_actual_array_size); return ::grpc::Status::OK; } } @@ -6638,11 +6922,12 @@ namespace nirfmxlte_grpc { float64 mean_rms_dmrs_evm {}; float64 maximum_peak_dmrs_evm {}; auto status = library_->ModAccFetchPUSCHDMRSEVM(instrument, selector_string, timeout, &mean_rms_dmrs_evm, &maximum_peak_dmrs_evm); - response->set_status(status); - if (status_ok(status)) { - response->set_mean_rms_dmrs_evm(mean_rms_dmrs_evm); - response->set_maximum_peak_dmrs_evm(maximum_peak_dmrs_evm); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_mean_rms_dmrs_evm(mean_rms_dmrs_evm); + response->set_maximum_peak_dmrs_evm(maximum_peak_dmrs_evm); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -6665,9 +6950,8 @@ namespace nirfmxlte_grpc { int32 actual_array_size {}; while (true) { auto status = library_->ModAccFetchPUSCHDMRSEVMArray(instrument, selector_string, timeout, nullptr, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_mean_rms_dmrs_evm()->Resize(actual_array_size, 0); float64* mean_rms_dmrs_evm = response->mutable_mean_rms_dmrs_evm()->mutable_data(); @@ -6679,12 +6963,13 @@ namespace nirfmxlte_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->mutable_mean_rms_dmrs_evm()->Resize(actual_array_size, 0); - response->mutable_maximum_peak_dmrs_evm()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->mutable_mean_rms_dmrs_evm()->Resize(actual_array_size, 0); + response->mutable_maximum_peak_dmrs_evm()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -6708,11 +6993,12 @@ namespace nirfmxlte_grpc { float64 mean_rms_data_evm {}; float64 maximum_peak_data_evm {}; auto status = library_->ModAccFetchPUSCHDataEVM(instrument, selector_string, timeout, &mean_rms_data_evm, &maximum_peak_data_evm); - response->set_status(status); - if (status_ok(status)) { - response->set_mean_rms_data_evm(mean_rms_data_evm); - response->set_maximum_peak_data_evm(maximum_peak_data_evm); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_mean_rms_data_evm(mean_rms_data_evm); + response->set_maximum_peak_data_evm(maximum_peak_data_evm); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -6735,9 +7021,8 @@ namespace nirfmxlte_grpc { int32 actual_array_size {}; while (true) { auto status = library_->ModAccFetchPUSCHDataEVMArray(instrument, selector_string, timeout, nullptr, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_mean_rms_data_evm()->Resize(actual_array_size, 0); float64* mean_rms_data_evm = response->mutable_mean_rms_data_evm()->mutable_data(); @@ -6749,12 +7034,13 @@ namespace nirfmxlte_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->mutable_mean_rms_data_evm()->Resize(actual_array_size, 0); - response->mutable_maximum_peak_data_evm()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->mutable_mean_rms_data_evm()->Resize(actual_array_size, 0); + response->mutable_maximum_peak_data_evm()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -6778,9 +7064,8 @@ namespace nirfmxlte_grpc { int32 actual_array_size {}; while (true) { auto status = library_->ModAccFetchPUSCHDemodulatedBits(instrument, selector_string, timeout, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } std::vector bits(actual_array_size); auto array_size = actual_array_size; @@ -6789,8 +7074,10 @@ namespace nirfmxlte_grpc { // buffer is now too small, try again continue; } + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); - if (status_ok(status)) { response->mutable_bits()->Clear(); response->mutable_bits()->Reserve(actual_array_size); std::transform( @@ -6800,9 +7087,8 @@ namespace nirfmxlte_grpc { [&](auto x) { return x; }); - response->mutable_bits()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); - } + response->mutable_bits()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -6826,11 +7112,12 @@ namespace nirfmxlte_grpc { float64 pusch_mean_data_power {}; float64 pusch_mean_dmrs_power {}; auto status = library_->ModAccFetchPUSCHSymbolPower(instrument, selector_string, timeout, &pusch_mean_data_power, &pusch_mean_dmrs_power); - response->set_status(status); - if (status_ok(status)) { - response->set_pusch_mean_data_power(pusch_mean_data_power); - response->set_pusch_mean_dmrs_power(pusch_mean_dmrs_power); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_pusch_mean_data_power(pusch_mean_data_power); + response->set_pusch_mean_dmrs_power(pusch_mean_dmrs_power); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -6853,9 +7140,8 @@ namespace nirfmxlte_grpc { int32 actual_array_size {}; while (true) { auto status = library_->ModAccFetchPUSCHSymbolPowerArray(instrument, selector_string, timeout, nullptr, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_pusch_mean_data_power()->Resize(actual_array_size, 0); float64* pusch_mean_data_power = response->mutable_pusch_mean_data_power()->mutable_data(); @@ -6867,12 +7153,13 @@ namespace nirfmxlte_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->mutable_pusch_mean_data_power()->Resize(actual_array_size, 0); - response->mutable_pusch_mean_dmrs_power()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->mutable_pusch_mean_data_power()->Resize(actual_array_size, 0); + response->mutable_pusch_mean_dmrs_power()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -6898,9 +7185,8 @@ namespace nirfmxlte_grpc { int32 actual_array_size {}; while (true) { auto status = library_->ModAccFetchRMSMagnitudeErrorPerSymbolTrace(instrument, selector_string, timeout, &x0, &dx, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_rms_magnitude_error_per_symbol()->Resize(actual_array_size, 0); float32* rms_magnitude_error_per_symbol = response->mutable_rms_magnitude_error_per_symbol()->mutable_data(); @@ -6910,13 +7196,14 @@ namespace nirfmxlte_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_x0(x0); - response->set_dx(dx); - response->mutable_rms_magnitude_error_per_symbol()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_x0(x0); + response->set_dx(dx); + response->mutable_rms_magnitude_error_per_symbol()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -6942,9 +7229,8 @@ namespace nirfmxlte_grpc { int32 actual_array_size {}; while (true) { auto status = library_->ModAccFetchRMSPhaseErrorPerSymbolTrace(instrument, selector_string, timeout, &x0, &dx, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_rms_phase_error_per_symbol()->Resize(actual_array_size, 0); float32* rms_phase_error_per_symbol = response->mutable_rms_phase_error_per_symbol()->mutable_data(); @@ -6954,13 +7240,14 @@ namespace nirfmxlte_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_x0(x0); - response->set_dx(dx); - response->mutable_rms_phase_error_per_symbol()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_x0(x0); + response->set_dx(dx); + response->mutable_rms_phase_error_per_symbol()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -6984,9 +7271,8 @@ namespace nirfmxlte_grpc { int32 actual_array_size {}; while (true) { auto status = library_->ModAccFetchSRSConstellation(instrument, selector_string, timeout, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } std::vector srs_constellation(actual_array_size, NIComplexSingle()); auto array_size = actual_array_size; @@ -6995,18 +7281,19 @@ namespace nirfmxlte_grpc { // buffer is now too small, try again continue; } + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); - if (status_ok(status)) { - convert_to_grpc(srs_constellation, response->mutable_srs_constellation()); - { - auto shrunk_size = actual_array_size; - auto current_size = response->mutable_srs_constellation()->size(); - if (shrunk_size != current_size) { - response->mutable_srs_constellation()->DeleteSubrange(shrunk_size, current_size - shrunk_size); - } + convert_to_grpc(srs_constellation, response->mutable_srs_constellation()); + { + auto shrunk_size = actual_array_size; + auto current_size = response->mutable_srs_constellation()->size(); + if (shrunk_size != current_size) { + response->mutable_srs_constellation()->DeleteSubrange(shrunk_size, current_size - shrunk_size); } - response->set_actual_array_size(actual_array_size); } + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -7030,11 +7317,12 @@ namespace nirfmxlte_grpc { float64 mean_rms_srs_evm {}; float64 mean_srs_power {}; auto status = library_->ModAccFetchSRSEVM(instrument, selector_string, timeout, &mean_rms_srs_evm, &mean_srs_power); - response->set_status(status); - if (status_ok(status)) { - response->set_mean_rms_srs_evm(mean_rms_srs_evm); - response->set_mean_srs_power(mean_srs_power); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_mean_rms_srs_evm(mean_rms_srs_evm); + response->set_mean_srs_power(mean_srs_power); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -7057,9 +7345,8 @@ namespace nirfmxlte_grpc { int32 actual_array_size {}; while (true) { auto status = library_->ModAccFetchSRSEVMArray(instrument, selector_string, timeout, nullptr, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_mean_rms_srs_evm()->Resize(actual_array_size, 0); float64* mean_rms_srs_evm = response->mutable_mean_rms_srs_evm()->mutable_data(); @@ -7071,12 +7358,13 @@ namespace nirfmxlte_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->mutable_mean_rms_srs_evm()->Resize(actual_array_size, 0); - response->mutable_mean_srs_power()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->mutable_mean_rms_srs_evm()->Resize(actual_array_size, 0); + response->mutable_mean_srs_power()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -7102,13 +7390,14 @@ namespace nirfmxlte_grpc { float64 range1_maximum_to_range2_minimum {}; float64 range2_maximum_to_range1_minimum {}; auto status = library_->ModAccFetchSpectralFlatness(instrument, selector_string, timeout, &range1_maximum_to_range1_minimum, &range2_maximum_to_range2_minimum, &range1_maximum_to_range2_minimum, &range2_maximum_to_range1_minimum); - response->set_status(status); - if (status_ok(status)) { - response->set_range1_maximum_to_range1_minimum(range1_maximum_to_range1_minimum); - response->set_range2_maximum_to_range2_minimum(range2_maximum_to_range2_minimum); - response->set_range1_maximum_to_range2_minimum(range1_maximum_to_range2_minimum); - response->set_range2_maximum_to_range1_minimum(range2_maximum_to_range1_minimum); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_range1_maximum_to_range1_minimum(range1_maximum_to_range1_minimum); + response->set_range2_maximum_to_range2_minimum(range2_maximum_to_range2_minimum); + response->set_range1_maximum_to_range2_minimum(range1_maximum_to_range2_minimum); + response->set_range2_maximum_to_range1_minimum(range2_maximum_to_range1_minimum); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -7131,9 +7420,8 @@ namespace nirfmxlte_grpc { int32 actual_array_size {}; while (true) { auto status = library_->ModAccFetchSpectralFlatnessArray(instrument, selector_string, timeout, nullptr, nullptr, nullptr, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_range1_maximum_to_range1_minimum()->Resize(actual_array_size, 0); float64* range1_maximum_to_range1_minimum = response->mutable_range1_maximum_to_range1_minimum()->mutable_data(); @@ -7149,14 +7437,15 @@ namespace nirfmxlte_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->mutable_range1_maximum_to_range1_minimum()->Resize(actual_array_size, 0); - response->mutable_range2_maximum_to_range2_minimum()->Resize(actual_array_size, 0); - response->mutable_range1_maximum_to_range2_minimum()->Resize(actual_array_size, 0); - response->mutable_range2_maximum_to_range1_minimum()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->mutable_range1_maximum_to_range1_minimum()->Resize(actual_array_size, 0); + response->mutable_range2_maximum_to_range2_minimum()->Resize(actual_array_size, 0); + response->mutable_range1_maximum_to_range2_minimum()->Resize(actual_array_size, 0); + response->mutable_range2_maximum_to_range1_minimum()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -7182,9 +7471,8 @@ namespace nirfmxlte_grpc { int32 actual_array_size {}; while (true) { auto status = library_->ModAccFetchSpectralFlatnessTrace(instrument, selector_string, timeout, &x0, &dx, nullptr, nullptr, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_spectral_flatness()->Resize(actual_array_size, 0); float32* spectral_flatness = response->mutable_spectral_flatness()->mutable_data(); @@ -7198,15 +7486,16 @@ namespace nirfmxlte_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_x0(x0); - response->set_dx(dx); - response->mutable_spectral_flatness()->Resize(actual_array_size, 0); - response->mutable_spectral_flatness_lower_mask()->Resize(actual_array_size, 0); - response->mutable_spectral_flatness_upper_mask()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_x0(x0); + response->set_dx(dx); + response->mutable_spectral_flatness()->Resize(actual_array_size, 0); + response->mutable_spectral_flatness_lower_mask()->Resize(actual_array_size, 0); + response->mutable_spectral_flatness_upper_mask()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -7231,12 +7520,13 @@ namespace nirfmxlte_grpc { float64 subblock_mean_iq_gain_imbalance {}; float64 subblock_mean_iq_quadrature_error {}; auto status = library_->ModAccFetchSubblockIQImpairments(instrument, selector_string, timeout, &subblock_mean_iq_origin_offset, &subblock_mean_iq_gain_imbalance, &subblock_mean_iq_quadrature_error); - response->set_status(status); - if (status_ok(status)) { - response->set_subblock_mean_iq_origin_offset(subblock_mean_iq_origin_offset); - response->set_subblock_mean_iq_gain_imbalance(subblock_mean_iq_gain_imbalance); - response->set_subblock_mean_iq_quadrature_error(subblock_mean_iq_quadrature_error); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_subblock_mean_iq_origin_offset(subblock_mean_iq_origin_offset); + response->set_subblock_mean_iq_gain_imbalance(subblock_mean_iq_gain_imbalance); + response->set_subblock_mean_iq_quadrature_error(subblock_mean_iq_quadrature_error); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -7258,10 +7548,11 @@ namespace nirfmxlte_grpc { float64 timeout = request->timeout(); float64 subblock_in_band_emission_margin {}; auto status = library_->ModAccFetchSubblockInBandEmissionMargin(instrument, selector_string, timeout, &subblock_in_band_emission_margin); - response->set_status(status); - if (status_ok(status)) { - response->set_subblock_in_band_emission_margin(subblock_in_band_emission_margin); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_subblock_in_band_emission_margin(subblock_in_band_emission_margin); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -7284,9 +7575,8 @@ namespace nirfmxlte_grpc { int32 actual_array_size {}; while (true) { auto status = library_->ModAccFetchSubblockInBandEmissionTrace(instrument, selector_string, timeout, nullptr, nullptr, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_subblock_in_band_emission()->Resize(actual_array_size, 0); float64* subblock_in_band_emission = response->mutable_subblock_in_band_emission()->mutable_data(); @@ -7300,13 +7590,14 @@ namespace nirfmxlte_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->mutable_subblock_in_band_emission()->Resize(actual_array_size, 0); - response->mutable_subblock_in_band_emission_mask()->Resize(actual_array_size, 0); - response->mutable_subblock_in_band_emission_rb_indices()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->mutable_subblock_in_band_emission()->Resize(actual_array_size, 0); + response->mutable_subblock_in_band_emission_mask()->Resize(actual_array_size, 0); + response->mutable_subblock_in_band_emission_rb_indices()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -7330,9 +7621,8 @@ namespace nirfmxlte_grpc { int32 actual_array_size {}; while (true) { auto status = library_->ModAccFetchSynchronizationSignalConstellation(instrument, selector_string, timeout, nullptr, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } std::vector sss_constellation(actual_array_size, NIComplexSingle()); std::vector pss_constellation(actual_array_size, NIComplexSingle()); @@ -7342,26 +7632,27 @@ namespace nirfmxlte_grpc { // buffer is now too small, try again continue; } + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); - if (status_ok(status)) { - convert_to_grpc(sss_constellation, response->mutable_sss_constellation()); - { - auto shrunk_size = actual_array_size; - auto current_size = response->mutable_sss_constellation()->size(); - if (shrunk_size != current_size) { - response->mutable_sss_constellation()->DeleteSubrange(shrunk_size, current_size - shrunk_size); - } + convert_to_grpc(sss_constellation, response->mutable_sss_constellation()); + { + auto shrunk_size = actual_array_size; + auto current_size = response->mutable_sss_constellation()->size(); + if (shrunk_size != current_size) { + response->mutable_sss_constellation()->DeleteSubrange(shrunk_size, current_size - shrunk_size); } - convert_to_grpc(pss_constellation, response->mutable_pss_constellation()); - { - auto shrunk_size = actual_array_size; - auto current_size = response->mutable_pss_constellation()->size(); - if (shrunk_size != current_size) { - response->mutable_pss_constellation()->DeleteSubrange(shrunk_size, current_size - shrunk_size); - } + } + convert_to_grpc(pss_constellation, response->mutable_pss_constellation()); + { + auto shrunk_size = actual_array_size; + auto current_size = response->mutable_pss_constellation()->size(); + if (shrunk_size != current_size) { + response->mutable_pss_constellation()->DeleteSubrange(shrunk_size, current_size - shrunk_size); } - response->set_actual_array_size(actual_array_size); } + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -7385,11 +7676,12 @@ namespace nirfmxlte_grpc { float64 mean_rms_pss_evm {}; float64 mean_rms_sss_evm {}; auto status = library_->ModAccFetchSynchronizationSignalEVM(instrument, selector_string, timeout, &mean_rms_pss_evm, &mean_rms_sss_evm); - response->set_status(status); - if (status_ok(status)) { - response->set_mean_rms_pss_evm(mean_rms_pss_evm); - response->set_mean_rms_sss_evm(mean_rms_sss_evm); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_mean_rms_pss_evm(mean_rms_pss_evm); + response->set_mean_rms_sss_evm(mean_rms_sss_evm); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -7412,9 +7704,8 @@ namespace nirfmxlte_grpc { int32 actual_array_size {}; while (true) { auto status = library_->ModAccFetchSynchronizationSignalEVMArray(instrument, selector_string, timeout, nullptr, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_mean_rms_pss_evm()->Resize(actual_array_size, 0); float64* mean_rms_pss_evm = response->mutable_mean_rms_pss_evm()->mutable_data(); @@ -7426,12 +7717,13 @@ namespace nirfmxlte_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->mutable_mean_rms_pss_evm()->Resize(actual_array_size, 0); - response->mutable_mean_rms_sss_evm()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->mutable_mean_rms_pss_evm()->Resize(actual_array_size, 0); + response->mutable_mean_rms_sss_evm()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -7485,6 +7777,9 @@ namespace nirfmxlte_grpc { } auto status = library_->OBWCfgAveraging(instrument, selector_string, averaging_enabled, averaging_count, averaging_type); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -7538,6 +7833,9 @@ namespace nirfmxlte_grpc { } auto status = library_->OBWCfgRBWFilter(instrument, selector_string, rbw_auto, rbw, rbw_filter_type); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -7575,6 +7873,9 @@ namespace nirfmxlte_grpc { float64 sweep_time_interval = request->sweep_time_interval(); auto status = library_->OBWCfgSweepTime(instrument, selector_string, sweep_time_auto, sweep_time_interval); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -7600,13 +7901,14 @@ namespace nirfmxlte_grpc { float64 start_frequency {}; float64 stop_frequency {}; auto status = library_->OBWFetchMeasurement(instrument, selector_string, timeout, &occupied_bandwidth, &absolute_power, &start_frequency, &stop_frequency); - response->set_status(status); - if (status_ok(status)) { - response->set_occupied_bandwidth(occupied_bandwidth); - response->set_absolute_power(absolute_power); - response->set_start_frequency(start_frequency); - response->set_stop_frequency(stop_frequency); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_occupied_bandwidth(occupied_bandwidth); + response->set_absolute_power(absolute_power); + response->set_start_frequency(start_frequency); + response->set_stop_frequency(stop_frequency); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -7631,9 +7933,8 @@ namespace nirfmxlte_grpc { int32 actual_array_size {}; while (true) { auto status = library_->OBWFetchSpectrum(instrument, selector_string, timeout, &x0, &dx, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_spectrum()->Resize(actual_array_size, 0); float32* spectrum = response->mutable_spectrum()->mutable_data(); @@ -7643,13 +7944,14 @@ namespace nirfmxlte_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_x0(x0); - response->set_dx(dx); - response->mutable_spectrum()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_x0(x0); + response->set_dx(dx); + response->mutable_spectrum()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -7703,6 +8005,9 @@ namespace nirfmxlte_grpc { } auto status = library_->PVTCfgAveraging(instrument, selector_string, averaging_enabled, averaging_count, averaging_type); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -7739,6 +8044,9 @@ namespace nirfmxlte_grpc { } auto status = library_->PVTCfgMeasurementMethod(instrument, selector_string, measurement_method); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -7761,6 +8069,9 @@ namespace nirfmxlte_grpc { float64 off_power_exclusion_before = request->off_power_exclusion_before(); float64 off_power_exclusion_after = request->off_power_exclusion_after(); auto status = library_->PVTCfgOFFPowerExclusionPeriods(instrument, selector_string, off_power_exclusion_before, off_power_exclusion_after); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -7787,15 +8098,16 @@ namespace nirfmxlte_grpc { float64 mean_absolute_on_power {}; float64 burst_width {}; auto status = library_->PVTFetchMeasurement(instrument, selector_string, timeout, &measurement_status, &mean_absolute_off_power_before, &mean_absolute_off_power_after, &mean_absolute_on_power, &burst_width); - response->set_status(status); - if (status_ok(status)) { - response->set_measurement_status(static_cast(measurement_status)); - response->set_measurement_status_raw(measurement_status); - response->set_mean_absolute_off_power_before(mean_absolute_off_power_before); - response->set_mean_absolute_off_power_after(mean_absolute_off_power_after); - response->set_mean_absolute_on_power(mean_absolute_on_power); - response->set_burst_width(burst_width); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_measurement_status(static_cast(measurement_status)); + response->set_measurement_status_raw(measurement_status); + response->set_mean_absolute_off_power_before(mean_absolute_off_power_before); + response->set_mean_absolute_off_power_after(mean_absolute_off_power_after); + response->set_mean_absolute_on_power(mean_absolute_on_power); + response->set_burst_width(burst_width); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -7818,9 +8130,8 @@ namespace nirfmxlte_grpc { int32 actual_array_size {}; while (true) { auto status = library_->PVTFetchMeasurementArray(instrument, selector_string, timeout, nullptr, nullptr, nullptr, nullptr, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_measurement_status_raw()->Resize(actual_array_size, 0); int32* measurement_status = reinterpret_cast(response->mutable_measurement_status_raw()->mutable_data()); @@ -7838,8 +8149,10 @@ namespace nirfmxlte_grpc { // buffer is now too small, try again continue; } + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); - if (status_ok(status)) { response->mutable_measurement_status()->Clear(); response->mutable_measurement_status()->Reserve(actual_array_size); std::transform( @@ -7849,13 +8162,12 @@ namespace nirfmxlte_grpc { [&](auto x) { return static_cast(x); }); - response->mutable_measurement_status()->Resize(actual_array_size, 0); - response->mutable_mean_absolute_off_power_before()->Resize(actual_array_size, 0); - response->mutable_mean_absolute_off_power_after()->Resize(actual_array_size, 0); - response->mutable_mean_absolute_on_power()->Resize(actual_array_size, 0); - response->mutable_burst_width()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); - } + response->mutable_measurement_status()->Resize(actual_array_size, 0); + response->mutable_mean_absolute_off_power_before()->Resize(actual_array_size, 0); + response->mutable_mean_absolute_off_power_after()->Resize(actual_array_size, 0); + response->mutable_mean_absolute_on_power()->Resize(actual_array_size, 0); + response->mutable_burst_width()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -7881,9 +8193,8 @@ namespace nirfmxlte_grpc { int32 actual_array_size {}; while (true) { auto status = library_->PVTFetchSignalPowerTrace(instrument, selector_string, timeout, &x0, &dx, nullptr, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_signal_power()->Resize(actual_array_size, 0); float32* signal_power = response->mutable_signal_power()->mutable_data(); @@ -7895,14 +8206,15 @@ namespace nirfmxlte_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_x0(x0); - response->set_dx(dx); - response->mutable_signal_power()->Resize(actual_array_size, 0); - response->mutable_absolute_limit()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_x0(x0); + response->set_dx(dx); + response->mutable_signal_power()->Resize(actual_array_size, 0); + response->mutable_absolute_limit()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -7924,6 +8236,9 @@ namespace nirfmxlte_grpc { char* selector_string = (char*)request->selector_string().c_str(); int32 attribute_id = request->attribute_id(); auto status = library_->ResetAttribute(instrument, selector_string, attribute_id); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -7944,6 +8259,9 @@ namespace nirfmxlte_grpc { niRFmxInstrHandle instrument = session_repository_->access_session(instrument_grpc_session.id(), instrument_grpc_session.name()); char* selector_string = (char*)request->selector_string().c_str(); auto status = library_->ResetToDefault(instrument, selector_string); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -7997,6 +8315,9 @@ namespace nirfmxlte_grpc { } auto status = library_->SEMCfgAveraging(instrument, selector_string, averaging_enabled, averaging_count, averaging_type); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -8018,6 +8339,9 @@ namespace nirfmxlte_grpc { char* selector_string = (char*)request->selector_string().c_str(); float64 component_carrier_maximum_output_power = request->component_carrier_maximum_output_power(); auto status = library_->SEMCfgComponentCarrierMaximumOutputPower(instrument, selector_string, component_carrier_maximum_output_power); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -8040,6 +8364,9 @@ namespace nirfmxlte_grpc { auto component_carrier_maximum_output_power = const_cast(request->component_carrier_maximum_output_power().data()); int32 number_of_elements = static_cast(request->component_carrier_maximum_output_power().size()); auto status = library_->SEMCfgComponentCarrierMaximumOutputPowerArray(instrument, selector_string, component_carrier_maximum_output_power, number_of_elements); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -8078,6 +8405,9 @@ namespace nirfmxlte_grpc { float64 delta_f_maximum = request->delta_f_maximum(); float64 aggregated_maximum_power = request->aggregated_maximum_power(); auto status = library_->SEMCfgDownlinkMask(instrument, selector_string, downlink_mask_type, delta_f_maximum, aggregated_maximum_power); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -8099,6 +8429,9 @@ namespace nirfmxlte_grpc { char* selector_string = (char*)request->selector_string().c_str(); int32 number_of_offsets = request->number_of_offsets(); auto status = library_->SEMCfgNumberOfOffsets(instrument, selector_string, number_of_offsets); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -8121,6 +8454,9 @@ namespace nirfmxlte_grpc { float64 offset_absolute_limit_start = request->offset_absolute_limit_start(); float64 offset_absolute_limit_stop = request->offset_absolute_limit_stop(); auto status = library_->SEMCfgOffsetAbsoluteLimit(instrument, selector_string, offset_absolute_limit_start, offset_absolute_limit_stop); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -8160,6 +8496,9 @@ namespace nirfmxlte_grpc { auto number_of_elements = number_of_elements_size_calculation.size; auto status = library_->SEMCfgOffsetAbsoluteLimitArray(instrument, selector_string, offset_absolute_limit_start, offset_absolute_limit_stop, number_of_elements); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -8181,6 +8520,9 @@ namespace nirfmxlte_grpc { char* selector_string = (char*)request->selector_string().c_str(); int32 offset_bandwidth_integral = request->offset_bandwidth_integral(); auto status = library_->SEMCfgOffsetBandwidthIntegral(instrument, selector_string, offset_bandwidth_integral); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -8203,6 +8545,9 @@ namespace nirfmxlte_grpc { auto offset_bandwidth_integral = const_cast(reinterpret_cast(request->offset_bandwidth_integral().data())); int32 number_of_elements = static_cast(request->offset_bandwidth_integral().size()); auto status = library_->SEMCfgOffsetBandwidthIntegralArray(instrument, selector_string, offset_bandwidth_integral, number_of_elements); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -8241,6 +8586,9 @@ namespace nirfmxlte_grpc { } auto status = library_->SEMCfgOffsetFrequency(instrument, selector_string, offset_start_frequency, offset_stop_frequency, offset_sideband); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -8291,6 +8639,9 @@ namespace nirfmxlte_grpc { auto number_of_elements = number_of_elements_size_calculation.size; auto status = library_->SEMCfgOffsetFrequencyArray(instrument, selector_string, offset_start_frequency, offset_stop_frequency, offset_sideband, number_of_elements); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -8327,6 +8678,9 @@ namespace nirfmxlte_grpc { } auto status = library_->SEMCfgOffsetLimitFailMask(instrument, selector_string, limit_fail_mask); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -8357,6 +8711,9 @@ namespace nirfmxlte_grpc { int32 number_of_elements = static_cast(request->limit_fail_mask().size()); auto status = library_->SEMCfgOffsetLimitFailMaskArray(instrument, selector_string, limit_fail_mask, number_of_elements); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -8394,6 +8751,9 @@ namespace nirfmxlte_grpc { } auto status = library_->SEMCfgOffsetRBWFilter(instrument, selector_string, offset_rbw, offset_rbw_filter_type); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -8441,6 +8801,9 @@ namespace nirfmxlte_grpc { auto number_of_elements = number_of_elements_size_calculation.size; auto status = library_->SEMCfgOffsetRBWFilterArray(instrument, selector_string, offset_rbw, offset_rbw_filter_type, number_of_elements); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -8463,6 +8826,9 @@ namespace nirfmxlte_grpc { float64 relative_limit_start = request->relative_limit_start(); float64 relative_limit_stop = request->relative_limit_stop(); auto status = library_->SEMCfgOffsetRelativeLimit(instrument, selector_string, relative_limit_start, relative_limit_stop); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -8502,6 +8868,9 @@ namespace nirfmxlte_grpc { auto number_of_elements = number_of_elements_size_calculation.size; auto status = library_->SEMCfgOffsetRelativeLimitArray(instrument, selector_string, relative_limit_start, relative_limit_stop, number_of_elements); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -8539,6 +8908,9 @@ namespace nirfmxlte_grpc { float64 sweep_time_interval = request->sweep_time_interval(); auto status = library_->SEMCfgSweepTime(instrument, selector_string, sweep_time_auto, sweep_time_interval); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -8575,6 +8947,9 @@ namespace nirfmxlte_grpc { } auto status = library_->SEMCfgUplinkMaskType(instrument, selector_string, uplink_mask_type); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -8598,11 +8973,12 @@ namespace nirfmxlte_grpc { float64 absolute_integrated_power {}; float64 relative_integrated_power {}; auto status = library_->SEMFetchComponentCarrierMeasurement(instrument, selector_string, timeout, &absolute_integrated_power, &relative_integrated_power); - response->set_status(status); - if (status_ok(status)) { - response->set_absolute_integrated_power(absolute_integrated_power); - response->set_relative_integrated_power(relative_integrated_power); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_absolute_integrated_power(absolute_integrated_power); + response->set_relative_integrated_power(relative_integrated_power); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -8625,9 +9001,8 @@ namespace nirfmxlte_grpc { int32 actual_array_size {}; while (true) { auto status = library_->SEMFetchComponentCarrierMeasurementArray(instrument, selector_string, timeout, nullptr, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_absolute_integrated_power()->Resize(actual_array_size, 0); float64* absolute_integrated_power = response->mutable_absolute_integrated_power()->mutable_data(); @@ -8639,12 +9014,13 @@ namespace nirfmxlte_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->mutable_absolute_integrated_power()->Resize(actual_array_size, 0); - response->mutable_relative_integrated_power()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->mutable_absolute_integrated_power()->Resize(actual_array_size, 0); + response->mutable_relative_integrated_power()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -8671,15 +9047,16 @@ namespace nirfmxlte_grpc { float64 margin_absolute_power {}; float64 margin_relative_power {}; auto status = library_->SEMFetchLowerOffsetMargin(instrument, selector_string, timeout, &measurement_status, &margin, &margin_frequency, &margin_absolute_power, &margin_relative_power); - response->set_status(status); - if (status_ok(status)) { - response->set_measurement_status(static_cast(measurement_status)); - response->set_measurement_status_raw(measurement_status); - response->set_margin(margin); - response->set_margin_frequency(margin_frequency); - response->set_margin_absolute_power(margin_absolute_power); - response->set_margin_relative_power(margin_relative_power); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_measurement_status(static_cast(measurement_status)); + response->set_measurement_status_raw(measurement_status); + response->set_margin(margin); + response->set_margin_frequency(margin_frequency); + response->set_margin_absolute_power(margin_absolute_power); + response->set_margin_relative_power(margin_relative_power); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -8702,9 +9079,8 @@ namespace nirfmxlte_grpc { int32 actual_array_size {}; while (true) { auto status = library_->SEMFetchLowerOffsetMarginArray(instrument, selector_string, timeout, nullptr, nullptr, nullptr, nullptr, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_measurement_status_raw()->Resize(actual_array_size, 0); int32* measurement_status = reinterpret_cast(response->mutable_measurement_status_raw()->mutable_data()); @@ -8722,8 +9098,10 @@ namespace nirfmxlte_grpc { // buffer is now too small, try again continue; } + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); - if (status_ok(status)) { response->mutable_measurement_status()->Clear(); response->mutable_measurement_status()->Reserve(actual_array_size); std::transform( @@ -8733,13 +9111,12 @@ namespace nirfmxlte_grpc { [&](auto x) { return static_cast(x); }); - response->mutable_measurement_status()->Resize(actual_array_size, 0); - response->mutable_margin()->Resize(actual_array_size, 0); - response->mutable_margin_frequency()->Resize(actual_array_size, 0); - response->mutable_margin_absolute_power()->Resize(actual_array_size, 0); - response->mutable_margin_relative_power()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); - } + response->mutable_measurement_status()->Resize(actual_array_size, 0); + response->mutable_margin()->Resize(actual_array_size, 0); + response->mutable_margin_frequency()->Resize(actual_array_size, 0); + response->mutable_margin_absolute_power()->Resize(actual_array_size, 0); + response->mutable_margin_relative_power()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -8766,14 +9143,15 @@ namespace nirfmxlte_grpc { float64 peak_frequency {}; float64 relative_peak_power {}; auto status = library_->SEMFetchLowerOffsetPower(instrument, selector_string, timeout, &absolute_integrated_power, &relative_integrated_power, &absolute_peak_power, &peak_frequency, &relative_peak_power); - response->set_status(status); - if (status_ok(status)) { - response->set_absolute_integrated_power(absolute_integrated_power); - response->set_relative_integrated_power(relative_integrated_power); - response->set_absolute_peak_power(absolute_peak_power); - response->set_peak_frequency(peak_frequency); - response->set_relative_peak_power(relative_peak_power); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_absolute_integrated_power(absolute_integrated_power); + response->set_relative_integrated_power(relative_integrated_power); + response->set_absolute_peak_power(absolute_peak_power); + response->set_peak_frequency(peak_frequency); + response->set_relative_peak_power(relative_peak_power); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -8796,9 +9174,8 @@ namespace nirfmxlte_grpc { int32 actual_array_size {}; while (true) { auto status = library_->SEMFetchLowerOffsetPowerArray(instrument, selector_string, timeout, nullptr, nullptr, nullptr, nullptr, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_absolute_integrated_power()->Resize(actual_array_size, 0); float64* absolute_integrated_power = response->mutable_absolute_integrated_power()->mutable_data(); @@ -8816,15 +9193,16 @@ namespace nirfmxlte_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->mutable_absolute_integrated_power()->Resize(actual_array_size, 0); - response->mutable_relative_integrated_power()->Resize(actual_array_size, 0); - response->mutable_absolute_peak_power()->Resize(actual_array_size, 0); - response->mutable_peak_frequency()->Resize(actual_array_size, 0); - response->mutable_relative_peak_power()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->mutable_absolute_integrated_power()->Resize(actual_array_size, 0); + response->mutable_relative_integrated_power()->Resize(actual_array_size, 0); + response->mutable_absolute_peak_power()->Resize(actual_array_size, 0); + response->mutable_peak_frequency()->Resize(actual_array_size, 0); + response->mutable_relative_peak_power()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -8847,11 +9225,12 @@ namespace nirfmxlte_grpc { float64 timeout = request->timeout(); int32 measurement_status {}; auto status = library_->SEMFetchMeasurementStatus(instrument, selector_string, timeout, &measurement_status); - response->set_status(status); - if (status_ok(status)) { - response->set_measurement_status(static_cast(measurement_status)); - response->set_measurement_status_raw(measurement_status); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_measurement_status(static_cast(measurement_status)); + response->set_measurement_status_raw(measurement_status); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -8876,9 +9255,8 @@ namespace nirfmxlte_grpc { int32 actual_array_size {}; while (true) { auto status = library_->SEMFetchSpectrum(instrument, selector_string, timeout, &x0, &dx, nullptr, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_spectrum()->Resize(actual_array_size, 0); float32* spectrum = response->mutable_spectrum()->mutable_data(); @@ -8890,14 +9268,15 @@ namespace nirfmxlte_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_x0(x0); - response->set_dx(dx); - response->mutable_spectrum()->Resize(actual_array_size, 0); - response->mutable_composite_mask()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_x0(x0); + response->set_dx(dx); + response->mutable_spectrum()->Resize(actual_array_size, 0); + response->mutable_composite_mask()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -8922,12 +9301,13 @@ namespace nirfmxlte_grpc { float64 integration_bandwidth {}; float64 frequency {}; auto status = library_->SEMFetchSubblockMeasurement(instrument, selector_string, timeout, &subblock_power, &integration_bandwidth, &frequency); - response->set_status(status); - if (status_ok(status)) { - response->set_subblock_power(subblock_power); - response->set_integration_bandwidth(integration_bandwidth); - response->set_frequency(frequency); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_subblock_power(subblock_power); + response->set_integration_bandwidth(integration_bandwidth); + response->set_frequency(frequency); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -8949,10 +9329,11 @@ namespace nirfmxlte_grpc { float64 timeout = request->timeout(); float64 total_aggregated_power {}; auto status = library_->SEMFetchTotalAggregatedPower(instrument, selector_string, timeout, &total_aggregated_power); - response->set_status(status); - if (status_ok(status)) { - response->set_total_aggregated_power(total_aggregated_power); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_total_aggregated_power(total_aggregated_power); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -8978,15 +9359,16 @@ namespace nirfmxlte_grpc { float64 margin_absolute_power {}; float64 margin_relative_power {}; auto status = library_->SEMFetchUpperOffsetMargin(instrument, selector_string, timeout, &measurement_status, &margin, &margin_frequency, &margin_absolute_power, &margin_relative_power); - response->set_status(status); - if (status_ok(status)) { - response->set_measurement_status(static_cast(measurement_status)); - response->set_measurement_status_raw(measurement_status); - response->set_margin(margin); - response->set_margin_frequency(margin_frequency); - response->set_margin_absolute_power(margin_absolute_power); - response->set_margin_relative_power(margin_relative_power); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_measurement_status(static_cast(measurement_status)); + response->set_measurement_status_raw(measurement_status); + response->set_margin(margin); + response->set_margin_frequency(margin_frequency); + response->set_margin_absolute_power(margin_absolute_power); + response->set_margin_relative_power(margin_relative_power); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -9009,9 +9391,8 @@ namespace nirfmxlte_grpc { int32 actual_array_size {}; while (true) { auto status = library_->SEMFetchUpperOffsetMarginArray(instrument, selector_string, timeout, nullptr, nullptr, nullptr, nullptr, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_measurement_status_raw()->Resize(actual_array_size, 0); int32* measurement_status = reinterpret_cast(response->mutable_measurement_status_raw()->mutable_data()); @@ -9029,8 +9410,10 @@ namespace nirfmxlte_grpc { // buffer is now too small, try again continue; } + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); - if (status_ok(status)) { response->mutable_measurement_status()->Clear(); response->mutable_measurement_status()->Reserve(actual_array_size); std::transform( @@ -9040,13 +9423,12 @@ namespace nirfmxlte_grpc { [&](auto x) { return static_cast(x); }); - response->mutable_measurement_status()->Resize(actual_array_size, 0); - response->mutable_margin()->Resize(actual_array_size, 0); - response->mutable_margin_frequency()->Resize(actual_array_size, 0); - response->mutable_margin_absolute_power()->Resize(actual_array_size, 0); - response->mutable_margin_relative_power()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); - } + response->mutable_measurement_status()->Resize(actual_array_size, 0); + response->mutable_margin()->Resize(actual_array_size, 0); + response->mutable_margin_frequency()->Resize(actual_array_size, 0); + response->mutable_margin_absolute_power()->Resize(actual_array_size, 0); + response->mutable_margin_relative_power()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -9073,14 +9455,15 @@ namespace nirfmxlte_grpc { float64 peak_frequency {}; float64 relative_peak_power {}; auto status = library_->SEMFetchUpperOffsetPower(instrument, selector_string, timeout, &absolute_integrated_power, &relative_integrated_power, &absolute_peak_power, &peak_frequency, &relative_peak_power); - response->set_status(status); - if (status_ok(status)) { - response->set_absolute_integrated_power(absolute_integrated_power); - response->set_relative_integrated_power(relative_integrated_power); - response->set_absolute_peak_power(absolute_peak_power); - response->set_peak_frequency(peak_frequency); - response->set_relative_peak_power(relative_peak_power); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_absolute_integrated_power(absolute_integrated_power); + response->set_relative_integrated_power(relative_integrated_power); + response->set_absolute_peak_power(absolute_peak_power); + response->set_peak_frequency(peak_frequency); + response->set_relative_peak_power(relative_peak_power); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -9103,9 +9486,8 @@ namespace nirfmxlte_grpc { int32 actual_array_size {}; while (true) { auto status = library_->SEMFetchUpperOffsetPowerArray(instrument, selector_string, timeout, nullptr, nullptr, nullptr, nullptr, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_absolute_integrated_power()->Resize(actual_array_size, 0); float64* absolute_integrated_power = response->mutable_absolute_integrated_power()->mutable_data(); @@ -9123,15 +9505,16 @@ namespace nirfmxlte_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->mutable_absolute_integrated_power()->Resize(actual_array_size, 0); - response->mutable_relative_integrated_power()->Resize(actual_array_size, 0); - response->mutable_absolute_peak_power()->Resize(actual_array_size, 0); - response->mutable_peak_frequency()->Resize(actual_array_size, 0); - response->mutable_relative_peak_power()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->mutable_absolute_integrated_power()->Resize(actual_array_size, 0); + response->mutable_relative_integrated_power()->Resize(actual_array_size, 0); + response->mutable_absolute_peak_power()->Resize(actual_array_size, 0); + response->mutable_peak_frequency()->Resize(actual_array_size, 0); + response->mutable_relative_peak_power()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -9169,6 +9552,9 @@ namespace nirfmxlte_grpc { int32 enable_all_traces = request->enable_all_traces(); auto status = library_->SelectMeasurements(instrument, selector_string, measurements, enable_all_traces); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -9188,6 +9574,9 @@ namespace nirfmxlte_grpc { auto instrument_grpc_session = request->instrument(); niRFmxInstrHandle instrument = session_repository_->access_session(instrument_grpc_session.id(), instrument_grpc_session.name()); auto status = library_->SendSoftwareEdgeTrigger(instrument); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -9210,6 +9599,9 @@ namespace nirfmxlte_grpc { int32 attribute_id = request->attribute_id(); float32 attr_val = request->attr_val(); auto status = library_->SetAttributeF32(instrument, selector_string, attribute_id, attr_val); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -9233,6 +9625,9 @@ namespace nirfmxlte_grpc { auto attr_val = const_cast(request->attr_val().data()); int32 array_size = static_cast(request->attr_val().size()); auto status = library_->SetAttributeF32Array(instrument, selector_string, attribute_id, attr_val, array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -9255,6 +9650,9 @@ namespace nirfmxlte_grpc { int32 attribute_id = request->attribute_id(); float64 attr_val = request->attr_val(); auto status = library_->SetAttributeF64(instrument, selector_string, attribute_id, attr_val); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -9278,6 +9676,9 @@ namespace nirfmxlte_grpc { auto attr_val = const_cast(request->attr_val().data()); int32 array_size = static_cast(request->attr_val().size()); auto status = library_->SetAttributeF64Array(instrument, selector_string, attribute_id, attr_val, array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -9309,6 +9710,9 @@ namespace nirfmxlte_grpc { auto attr_val = static_cast(attr_val_raw); auto status = library_->SetAttributeI16(instrument, selector_string, attribute_id, attr_val); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -9349,6 +9753,9 @@ namespace nirfmxlte_grpc { } auto status = library_->SetAttributeI32(instrument, selector_string, attribute_id, attr_val); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -9380,6 +9787,9 @@ namespace nirfmxlte_grpc { int32 array_size = static_cast(request->attr_val().size()); auto status = library_->SetAttributeI32Array(instrument, selector_string, attribute_id, attr_val, array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -9402,6 +9812,9 @@ namespace nirfmxlte_grpc { int32 attribute_id = request->attribute_id(); int64 attr_val = request->attr_val(); auto status = library_->SetAttributeI64(instrument, selector_string, attribute_id, attr_val); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -9425,6 +9838,9 @@ namespace nirfmxlte_grpc { auto attr_val = const_cast(reinterpret_cast(request->attr_val().data())); int32 array_size = static_cast(request->attr_val().size()); auto status = library_->SetAttributeI64Array(instrument, selector_string, attribute_id, attr_val, array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -9456,6 +9872,9 @@ namespace nirfmxlte_grpc { auto attr_val = static_cast(attr_val_raw); auto status = library_->SetAttributeI8(instrument, selector_string, attribute_id, attr_val); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -9499,6 +9918,9 @@ namespace nirfmxlte_grpc { int32 array_size = static_cast(request->attr_val().size()); auto status = library_->SetAttributeI8Array(instrument, selector_string, attribute_id, attr_val.data(), array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -9525,6 +9947,9 @@ namespace nirfmxlte_grpc { auto attr_val = convert_from_grpc(request->attr_val()); int32 array_size = static_cast(request->attr_val().size()); auto status = library_->SetAttributeNIComplexDoubleArray(instrument, selector_string, attribute_id, attr_val.data(), array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -9548,6 +9973,9 @@ namespace nirfmxlte_grpc { auto attr_val = convert_from_grpc(request->attr_val()); int32 array_size = static_cast(request->attr_val().size()); auto status = library_->SetAttributeNIComplexSingleArray(instrument, selector_string, attribute_id, attr_val.data(), array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -9589,6 +10017,9 @@ namespace nirfmxlte_grpc { } auto status = library_->SetAttributeString(instrument, selector_string, attribute_id, attr_val); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -9620,6 +10051,9 @@ namespace nirfmxlte_grpc { auto attr_val = static_cast(attr_val_raw); auto status = library_->SetAttributeU16(instrument, selector_string, attribute_id, attr_val); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -9645,6 +10079,9 @@ namespace nirfmxlte_grpc { int32 attribute_id = request->attribute_id(); uInt32 attr_val = request->attr_val(); auto status = library_->SetAttributeU32(instrument, selector_string, attribute_id, attr_val); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -9668,6 +10105,9 @@ namespace nirfmxlte_grpc { auto attr_val = const_cast(reinterpret_cast(request->attr_val().data())); int32 array_size = static_cast(request->attr_val().size()); auto status = library_->SetAttributeU32Array(instrument, selector_string, attribute_id, attr_val, array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -9691,6 +10131,9 @@ namespace nirfmxlte_grpc { auto attr_val = const_cast(reinterpret_cast(request->attr_val().data())); int32 array_size = static_cast(request->attr_val().size()); auto status = library_->SetAttributeU64Array(instrument, selector_string, attribute_id, attr_val, array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -9713,6 +10156,9 @@ namespace nirfmxlte_grpc { int32 attribute_id = request->attribute_id(); uInt8 attr_val = request->attr_val(); auto status = library_->SetAttributeU8(instrument, selector_string, attribute_id, attr_val); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -9736,6 +10182,9 @@ namespace nirfmxlte_grpc { uInt8* attr_val = (uInt8*)request->attr_val().c_str(); int32 array_size = static_cast(request->attr_val().size()); auto status = library_->SetAttributeU8Array(instrument, selector_string, attribute_id, attr_val, array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -9774,6 +10223,9 @@ namespace nirfmxlte_grpc { int32 measurement_offset = request->measurement_offset(); int32 measurement_length = request->measurement_length(); auto status = library_->SlotPhaseCfgSynchronizationModeAndInterval(instrument, selector_string, synchronization_mode, measurement_offset, measurement_length); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -9796,10 +10248,11 @@ namespace nirfmxlte_grpc { float64 timeout = request->timeout(); float64 maximum_phase_discontinuity {}; auto status = library_->SlotPhaseFetchMaximumPhaseDiscontinuity(instrument, selector_string, timeout, &maximum_phase_discontinuity); - response->set_status(status); - if (status_ok(status)) { - response->set_maximum_phase_discontinuity(maximum_phase_discontinuity); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_maximum_phase_discontinuity(maximum_phase_discontinuity); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -9822,9 +10275,8 @@ namespace nirfmxlte_grpc { int32 actual_array_size {}; while (true) { auto status = library_->SlotPhaseFetchMaximumPhaseDiscontinuityArray(instrument, selector_string, timeout, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_maximum_phase_discontinuity()->Resize(actual_array_size, 0); float64* maximum_phase_discontinuity = response->mutable_maximum_phase_discontinuity()->mutable_data(); @@ -9834,11 +10286,12 @@ namespace nirfmxlte_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->mutable_maximum_phase_discontinuity()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->mutable_maximum_phase_discontinuity()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -9862,9 +10315,8 @@ namespace nirfmxlte_grpc { int32 actual_array_size {}; while (true) { auto status = library_->SlotPhaseFetchPhaseDiscontinuities(instrument, selector_string, timeout, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_slot_phase_discontinuity()->Resize(actual_array_size, 0); float64* slot_phase_discontinuity = response->mutable_slot_phase_discontinuity()->mutable_data(); @@ -9874,11 +10326,12 @@ namespace nirfmxlte_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->mutable_slot_phase_discontinuity()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->mutable_slot_phase_discontinuity()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -9904,9 +10357,8 @@ namespace nirfmxlte_grpc { int32 actual_array_size {}; while (true) { auto status = library_->SlotPhaseFetchSamplePhaseError(instrument, selector_string, timeout, &x0, &dx, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_sample_phase_error()->Resize(actual_array_size, 0); float32* sample_phase_error = response->mutable_sample_phase_error()->mutable_data(); @@ -9916,13 +10368,14 @@ namespace nirfmxlte_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_x0(x0); - response->set_dx(dx); - response->mutable_sample_phase_error()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_x0(x0); + response->set_dx(dx); + response->mutable_sample_phase_error()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -9948,9 +10401,8 @@ namespace nirfmxlte_grpc { int32 actual_array_size {}; while (true) { auto status = library_->SlotPhaseFetchSamplePhaseErrorLinearFitTrace(instrument, selector_string, timeout, &x0, &dx, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_sample_phase_error_linear_fit()->Resize(actual_array_size, 0); float32* sample_phase_error_linear_fit = response->mutable_sample_phase_error_linear_fit()->mutable_data(); @@ -9960,13 +10412,14 @@ namespace nirfmxlte_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_x0(x0); - response->set_dx(dx); - response->mutable_sample_phase_error_linear_fit()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_x0(x0); + response->set_dx(dx); + response->mutable_sample_phase_error_linear_fit()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -9989,6 +10442,9 @@ namespace nirfmxlte_grpc { int32 measurement_offset = request->measurement_offset(); int32 measurement_length = request->measurement_length(); auto status = library_->SlotPowerCfgMeasurementInterval(instrument, selector_string, measurement_offset, measurement_length); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -10012,9 +10468,8 @@ namespace nirfmxlte_grpc { int32 actual_array_size {}; while (true) { auto status = library_->SlotPowerFetchPowers(instrument, selector_string, timeout, nullptr, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_subframe_power()->Resize(actual_array_size, 0); float64* subframe_power = response->mutable_subframe_power()->mutable_data(); @@ -10026,12 +10481,13 @@ namespace nirfmxlte_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->mutable_subframe_power()->Resize(actual_array_size, 0); - response->mutable_subframe_power_delta()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->mutable_subframe_power()->Resize(actual_array_size, 0); + response->mutable_subframe_power_delta()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -10052,6 +10508,9 @@ namespace nirfmxlte_grpc { niRFmxInstrHandle instrument = session_repository_->access_session(instrument_grpc_session.id(), instrument_grpc_session.name()); float64 timeout = request->timeout(); auto status = library_->WaitForAcquisitionComplete(instrument, timeout); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -10073,6 +10532,9 @@ namespace nirfmxlte_grpc { char* selector_string = (char*)request->selector_string().c_str(); float64 timeout = request->timeout(); auto status = library_->WaitForMeasurementComplete(instrument, selector_string, timeout); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } diff --git a/generated/nirfmxlte/nirfmxlte_service.h b/generated/nirfmxlte/nirfmxlte_service.h index 00a5ba968..c2e726c87 100644 --- a/generated/nirfmxlte/nirfmxlte_service.h +++ b/generated/nirfmxlte/nirfmxlte_service.h @@ -332,6 +332,7 @@ class NiRFmxLTEService final : public NiRFmxLTE::Service { NiRFmxLTELibraryInterface* library_; ResourceRepositorySharedPtr session_repository_; ViSessionResourceRepositorySharedPtr vi_session_resource_repository_; + ::grpc::Status ConvertApiErrorStatusForNiRFmxInstrHandle(google::protobuf::int32 status, niRFmxInstrHandle instrumentHandle); std::map digitaledgetriggersource_input_map_ { {1, "PFI0"},{2, "PFI1"},{3, "PXI_Trig0"},{4, "PXI_Trig1"},{5, "PXI_Trig2"},{6, "PXI_Trig3"},{7, "PXI_Trig4"},{8, "PXI_Trig5"},{9, "PXI_Trig6"},{10, "PXI_Trig7"},{11, "PXI_STAR"},{12, "PXIe_DStarB"},{13, "TimerEvent"}, }; std::map digitaledgetriggersource_output_map_ { {"PFI0", 1},{"PFI1", 2},{"PXI_Trig0", 3},{"PXI_Trig1", 4},{"PXI_Trig2", 5},{"PXI_Trig3", 6},{"PXI_Trig4", 7},{"PXI_Trig5", 8},{"PXI_Trig6", 9},{"PXI_Trig7", 10},{"PXI_STAR", 11},{"PXIe_DStarB", 12},{"TimerEvent", 13}, }; std::map frequencyreferencesource_input_map_ { {1, "OnboardClock"},{2, "RefIn"},{3, "PXI_Clk"},{4, "ClkIn"}, }; diff --git a/generated/nirfmxnr/nirfmxnr_service.cpp b/generated/nirfmxnr/nirfmxnr_service.cpp index b12d3243b..49bc2331a 100644 --- a/generated/nirfmxnr/nirfmxnr_service.cpp +++ b/generated/nirfmxnr/nirfmxnr_service.cpp @@ -92,6 +92,9 @@ namespace nirfmxnr_grpc { } auto status = library_->ACPCfgAveraging(instrument, selector_string, averaging_enabled, averaging_count, averaging_type); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -128,6 +131,9 @@ namespace nirfmxnr_grpc { } auto status = library_->ACPCfgMeasurementMethod(instrument, selector_string, measurement_method); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -164,6 +170,9 @@ namespace nirfmxnr_grpc { } auto status = library_->ACPCfgNoiseCompensationEnabled(instrument, selector_string, noise_compensation_enabled); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -185,6 +194,9 @@ namespace nirfmxnr_grpc { char* selector_string = (char*)request->selector_string().c_str(); int32 number_of_endc_offsets = request->number_of_endc_offsets(); auto status = library_->ACPCfgNumberOfENDCOffsets(instrument, selector_string, number_of_endc_offsets); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -206,6 +218,9 @@ namespace nirfmxnr_grpc { char* selector_string = (char*)request->selector_string().c_str(); int32 number_of_eutra_offsets = request->number_of_eutra_offsets(); auto status = library_->ACPCfgNumberOfEUTRAOffsets(instrument, selector_string, number_of_eutra_offsets); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -227,6 +242,9 @@ namespace nirfmxnr_grpc { char* selector_string = (char*)request->selector_string().c_str(); int32 number_of_nr_offsets = request->number_of_nr_offsets(); auto status = library_->ACPCfgNumberOfNROffsets(instrument, selector_string, number_of_nr_offsets); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -248,6 +266,9 @@ namespace nirfmxnr_grpc { char* selector_string = (char*)request->selector_string().c_str(); int32 number_of_utra_offsets = request->number_of_utra_offsets(); auto status = library_->ACPCfgNumberOfUTRAOffsets(instrument, selector_string, number_of_utra_offsets); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -284,6 +305,9 @@ namespace nirfmxnr_grpc { } auto status = library_->ACPCfgPowerUnits(instrument, selector_string, power_units); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -337,6 +361,9 @@ namespace nirfmxnr_grpc { } auto status = library_->ACPCfgRBWFilter(instrument, selector_string, rbw_auto, rbw, rbw_filter_type); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -374,6 +401,9 @@ namespace nirfmxnr_grpc { float64 sweep_time_interval = request->sweep_time_interval(); auto status = library_->ACPCfgSweepTime(instrument, selector_string, sweep_time_auto, sweep_time_interval); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -400,9 +430,8 @@ namespace nirfmxnr_grpc { int32 actual_array_size {}; while (true) { auto status = library_->ACPFetchAbsolutePowersTrace(instrument, selector_string, timeout, trace_index, &x0, &dx, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_absolute_powers_trace()->Resize(actual_array_size, 0); float32* absolute_powers_trace = response->mutable_absolute_powers_trace()->mutable_data(); @@ -412,13 +441,14 @@ namespace nirfmxnr_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_x0(x0); - response->set_dx(dx); - response->mutable_absolute_powers_trace()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_x0(x0); + response->set_dx(dx); + response->mutable_absolute_powers_trace()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -442,11 +472,12 @@ namespace nirfmxnr_grpc { float64 absolute_power {}; float64 relative_power {}; auto status = library_->ACPFetchComponentCarrierMeasurement(instrument, selector_string, timeout, &absolute_power, &relative_power); - response->set_status(status); - if (status_ok(status)) { - response->set_absolute_power(absolute_power); - response->set_relative_power(relative_power); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_absolute_power(absolute_power); + response->set_relative_power(relative_power); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -469,9 +500,8 @@ namespace nirfmxnr_grpc { int32 actual_array_size {}; while (true) { auto status = library_->ACPFetchComponentCarrierMeasurementArray(instrument, selector_string, timeout, nullptr, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_absolute_power()->Resize(actual_array_size, 0); float64* absolute_power = response->mutable_absolute_power()->mutable_data(); @@ -483,12 +513,13 @@ namespace nirfmxnr_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->mutable_absolute_power()->Resize(actual_array_size, 0); - response->mutable_relative_power()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->mutable_absolute_power()->Resize(actual_array_size, 0); + response->mutable_relative_power()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -514,13 +545,14 @@ namespace nirfmxnr_grpc { float64 lower_absolute_power {}; float64 upper_absolute_power {}; auto status = library_->ACPFetchOffsetMeasurement(instrument, selector_string, timeout, &lower_relative_power, &upper_relative_power, &lower_absolute_power, &upper_absolute_power); - response->set_status(status); - if (status_ok(status)) { - response->set_lower_relative_power(lower_relative_power); - response->set_upper_relative_power(upper_relative_power); - response->set_lower_absolute_power(lower_absolute_power); - response->set_upper_absolute_power(upper_absolute_power); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_lower_relative_power(lower_relative_power); + response->set_upper_relative_power(upper_relative_power); + response->set_lower_absolute_power(lower_absolute_power); + response->set_upper_absolute_power(upper_absolute_power); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -543,9 +575,8 @@ namespace nirfmxnr_grpc { int32 actual_array_size {}; while (true) { auto status = library_->ACPFetchOffsetMeasurementArray(instrument, selector_string, timeout, nullptr, nullptr, nullptr, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_lower_relative_power()->Resize(actual_array_size, 0); float64* lower_relative_power = response->mutable_lower_relative_power()->mutable_data(); @@ -561,14 +592,15 @@ namespace nirfmxnr_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->mutable_lower_relative_power()->Resize(actual_array_size, 0); - response->mutable_upper_relative_power()->Resize(actual_array_size, 0); - response->mutable_lower_absolute_power()->Resize(actual_array_size, 0); - response->mutable_upper_absolute_power()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->mutable_lower_relative_power()->Resize(actual_array_size, 0); + response->mutable_upper_relative_power()->Resize(actual_array_size, 0); + response->mutable_lower_absolute_power()->Resize(actual_array_size, 0); + response->mutable_upper_absolute_power()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -595,9 +627,8 @@ namespace nirfmxnr_grpc { int32 actual_array_size {}; while (true) { auto status = library_->ACPFetchRelativePowersTrace(instrument, selector_string, timeout, trace_index, &x0, &dx, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_relative_powers_trace()->Resize(actual_array_size, 0); float32* relative_powers_trace = response->mutable_relative_powers_trace()->mutable_data(); @@ -607,13 +638,14 @@ namespace nirfmxnr_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_x0(x0); - response->set_dx(dx); - response->mutable_relative_powers_trace()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_x0(x0); + response->set_dx(dx); + response->mutable_relative_powers_trace()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -639,9 +671,8 @@ namespace nirfmxnr_grpc { int32 actual_array_size {}; while (true) { auto status = library_->ACPFetchSpectrum(instrument, selector_string, timeout, &x0, &dx, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_spectrum()->Resize(actual_array_size, 0); float32* spectrum = response->mutable_spectrum()->mutable_data(); @@ -651,13 +682,14 @@ namespace nirfmxnr_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_x0(x0); - response->set_dx(dx); - response->mutable_spectrum()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_x0(x0); + response->set_dx(dx); + response->mutable_spectrum()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -682,12 +714,13 @@ namespace nirfmxnr_grpc { float64 integration_bandwidth {}; float64 frequency {}; auto status = library_->ACPFetchSubblockMeasurement(instrument, selector_string, timeout, &subblock_power, &integration_bandwidth, &frequency); - response->set_status(status); - if (status_ok(status)) { - response->set_subblock_power(subblock_power); - response->set_integration_bandwidth(integration_bandwidth); - response->set_frequency(frequency); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_subblock_power(subblock_power); + response->set_integration_bandwidth(integration_bandwidth); + response->set_frequency(frequency); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -709,10 +742,11 @@ namespace nirfmxnr_grpc { float64 timeout = request->timeout(); float64 total_aggregated_power {}; auto status = library_->ACPFetchTotalAggregatedPower(instrument, selector_string, timeout, &total_aggregated_power); - response->set_status(status); - if (status_ok(status)) { - response->set_total_aggregated_power(total_aggregated_power); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_total_aggregated_power(total_aggregated_power); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -733,11 +767,12 @@ namespace nirfmxnr_grpc { char* selector_string = (char*)request->selector_string().c_str(); int32 noise_calibration_data_valid {}; auto status = library_->ACPValidateNoiseCalibrationData(instrument, selector_string, &noise_calibration_data_valid); - response->set_status(status); - if (status_ok(status)) { - response->set_noise_calibration_data_valid(static_cast(noise_calibration_data_valid)); - response->set_noise_calibration_data_valid_raw(noise_calibration_data_valid); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_noise_calibration_data_valid(static_cast(noise_calibration_data_valid)); + response->set_noise_calibration_data_valid_raw(noise_calibration_data_valid); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -757,6 +792,9 @@ namespace nirfmxnr_grpc { niRFmxInstrHandle instrument = session_repository_->access_session(instrument_grpc_session.id(), instrument_grpc_session.name()); char* selector_string = (char*)request->selector_string().c_str(); auto status = library_->AbortMeasurements(instrument, selector_string); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -784,6 +822,9 @@ namespace nirfmxnr_grpc { int32 reset = request->reset(); auto reserved = 0; auto status = library_->AnalyzeIQ1Waveform(instrument, selector_string, result_name, x0, dx, iq.data(), array_size, reset, reserved); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -811,6 +852,9 @@ namespace nirfmxnr_grpc { int32 reset = request->reset(); auto reserved = 0; auto status = library_->AnalyzeSpectrum1Waveform(instrument, selector_string, result_name, x0, dx, spectrum, array_size, reset, reserved); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -833,10 +877,11 @@ namespace nirfmxnr_grpc { float64 measurement_interval = request->measurement_interval(); float64 reference_level {}; auto status = library_->AutoLevel(instrument, selector_string, measurement_interval, &reference_level); - response->set_status(status); - if (status_ok(status)) { - response->set_reference_level(reference_level); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_reference_level(reference_level); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -857,9 +902,8 @@ namespace nirfmxnr_grpc { while (true) { auto status = library_->BuildBandwidthPartString(selector_string, bandwidth_part_number, 0, nullptr); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, 0); } int32 selector_string_out_length = status; @@ -872,11 +916,12 @@ namespace nirfmxnr_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_selector_string_out(selector_string_out); - nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_selector_string_out())); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, 0); } + response->set_status(status); + response->set_selector_string_out(selector_string_out); + nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_selector_string_out())); return ::grpc::Status::OK; } } @@ -898,9 +943,8 @@ namespace nirfmxnr_grpc { while (true) { auto status = library_->BuildCORESETClusterString(selector_string, coreset_cluster_number, 0, nullptr); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, 0); } int32 selector_string_out_length = status; @@ -913,11 +957,12 @@ namespace nirfmxnr_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_selector_string_out(selector_string_out); - nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_selector_string_out())); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, 0); } + response->set_status(status); + response->set_selector_string_out(selector_string_out); + nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_selector_string_out())); return ::grpc::Status::OK; } } @@ -939,9 +984,8 @@ namespace nirfmxnr_grpc { while (true) { auto status = library_->BuildCORESETString(selector_string, coreset_number, 0, nullptr); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, 0); } int32 selector_string_out_length = status; @@ -954,11 +998,12 @@ namespace nirfmxnr_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_selector_string_out(selector_string_out); - nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_selector_string_out())); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, 0); } + response->set_status(status); + response->set_selector_string_out(selector_string_out); + nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_selector_string_out())); return ::grpc::Status::OK; } } @@ -980,9 +1025,8 @@ namespace nirfmxnr_grpc { while (true) { auto status = library_->BuildCarrierString(selector_string, carrier_number, 0, nullptr); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, 0); } int32 selector_string_out_length = status; @@ -995,11 +1039,12 @@ namespace nirfmxnr_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_selector_string_out(selector_string_out); - nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_selector_string_out())); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, 0); } + response->set_status(status); + response->set_selector_string_out(selector_string_out); + nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_selector_string_out())); return ::grpc::Status::OK; } } @@ -1022,9 +1067,8 @@ namespace nirfmxnr_grpc { while (true) { auto status = library_->BuildListStepString(list_name, result_name, step_number, 0, nullptr); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, 0); } int32 selector_string_length = status; @@ -1037,11 +1081,12 @@ namespace nirfmxnr_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_selector_string(selector_string); - nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_selector_string())); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, 0); } + response->set_status(status); + response->set_selector_string(selector_string); + nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_selector_string())); return ::grpc::Status::OK; } } @@ -1063,9 +1108,8 @@ namespace nirfmxnr_grpc { while (true) { auto status = library_->BuildListString(list_name, result_name, 0, nullptr); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, 0); } int32 selector_string_length = status; @@ -1078,11 +1122,12 @@ namespace nirfmxnr_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_selector_string(selector_string); - nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_selector_string())); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, 0); } + response->set_status(status); + response->set_selector_string(selector_string); + nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_selector_string())); return ::grpc::Status::OK; } } @@ -1104,9 +1149,8 @@ namespace nirfmxnr_grpc { while (true) { auto status = library_->BuildOffsetString(selector_string, offset_number, 0, nullptr); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, 0); } int32 selector_string_out_length = status; @@ -1119,11 +1163,12 @@ namespace nirfmxnr_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_selector_string_out(selector_string_out); - nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_selector_string_out())); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, 0); } + response->set_status(status); + response->set_selector_string_out(selector_string_out); + nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_selector_string_out())); return ::grpc::Status::OK; } } @@ -1145,9 +1190,8 @@ namespace nirfmxnr_grpc { while (true) { auto status = library_->BuildPDCCHString(selector_string, pdcch_number, 0, nullptr); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, 0); } int32 selector_string_out_length = status; @@ -1160,11 +1204,12 @@ namespace nirfmxnr_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_selector_string_out(selector_string_out); - nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_selector_string_out())); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, 0); } + response->set_status(status); + response->set_selector_string_out(selector_string_out); + nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_selector_string_out())); return ::grpc::Status::OK; } } @@ -1186,9 +1231,8 @@ namespace nirfmxnr_grpc { while (true) { auto status = library_->BuildPDSCHClusterString(selector_string, pdsch_cluster_number, 0, nullptr); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, 0); } int32 selector_string_out_length = status; @@ -1201,11 +1245,12 @@ namespace nirfmxnr_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_selector_string_out(selector_string_out); - nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_selector_string_out())); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, 0); } + response->set_status(status); + response->set_selector_string_out(selector_string_out); + nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_selector_string_out())); return ::grpc::Status::OK; } } @@ -1227,9 +1272,8 @@ namespace nirfmxnr_grpc { while (true) { auto status = library_->BuildPDSCHString(selector_string, pdsch_number, 0, nullptr); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, 0); } int32 selector_string_out_length = status; @@ -1242,11 +1286,12 @@ namespace nirfmxnr_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_selector_string_out(selector_string_out); - nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_selector_string_out())); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, 0); } + response->set_status(status); + response->set_selector_string_out(selector_string_out); + nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_selector_string_out())); return ::grpc::Status::OK; } } @@ -1268,9 +1313,8 @@ namespace nirfmxnr_grpc { while (true) { auto status = library_->BuildPUSCHClusterString(selector_string, pusch_cluster_number, 0, nullptr); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, 0); } int32 selector_string_out_length = status; @@ -1283,11 +1327,12 @@ namespace nirfmxnr_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_selector_string_out(selector_string_out); - nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_selector_string_out())); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, 0); } + response->set_status(status); + response->set_selector_string_out(selector_string_out); + nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_selector_string_out())); return ::grpc::Status::OK; } } @@ -1309,9 +1354,8 @@ namespace nirfmxnr_grpc { while (true) { auto status = library_->BuildPUSCHString(selector_string, pusch_number, 0, nullptr); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, 0); } int32 selector_string_out_length = status; @@ -1324,11 +1368,12 @@ namespace nirfmxnr_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_selector_string_out(selector_string_out); - nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_selector_string_out())); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, 0); } + response->set_status(status); + response->set_selector_string_out(selector_string_out); + nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_selector_string_out())); return ::grpc::Status::OK; } } @@ -1350,9 +1395,8 @@ namespace nirfmxnr_grpc { while (true) { auto status = library_->BuildSignalString(signal_name, result_name, 0, nullptr); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, 0); } int32 selector_string_length = status; @@ -1365,11 +1409,12 @@ namespace nirfmxnr_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_selector_string(selector_string); - nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_selector_string())); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, 0); } + response->set_status(status); + response->set_selector_string(selector_string); + nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_selector_string())); return ::grpc::Status::OK; } } @@ -1391,9 +1436,8 @@ namespace nirfmxnr_grpc { while (true) { auto status = library_->BuildSubblockString(selector_string, subblock_number, 0, nullptr); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, 0); } int32 selector_string_out_length = status; @@ -1406,11 +1450,12 @@ namespace nirfmxnr_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_selector_string_out(selector_string_out); - nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_selector_string_out())); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, 0); } + response->set_status(status); + response->set_selector_string_out(selector_string_out); + nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_selector_string_out())); return ::grpc::Status::OK; } } @@ -1432,9 +1477,8 @@ namespace nirfmxnr_grpc { while (true) { auto status = library_->BuildUserString(selector_string, user_number, 0, nullptr); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, 0); } int32 selector_string_out_length = status; @@ -1447,11 +1491,12 @@ namespace nirfmxnr_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_selector_string_out(selector_string_out); - nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_selector_string_out())); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, 0); } + response->set_status(status); + response->set_selector_string_out(selector_string_out); + nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_selector_string_out())); return ::grpc::Status::OK; } } @@ -1505,6 +1550,9 @@ namespace nirfmxnr_grpc { } auto status = library_->CHPCfgAveraging(instrument, selector_string, averaging_enabled, averaging_count, averaging_type); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1558,6 +1606,9 @@ namespace nirfmxnr_grpc { } auto status = library_->CHPCfgRBWFilter(instrument, selector_string, rbw_auto, rbw, rbw_filter_type); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1595,6 +1646,9 @@ namespace nirfmxnr_grpc { float64 sweep_time_interval = request->sweep_time_interval(); auto status = library_->CHPCfgSweepTime(instrument, selector_string, sweep_time_auto, sweep_time_interval); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1618,11 +1672,12 @@ namespace nirfmxnr_grpc { float64 absolute_power {}; float64 relative_power {}; auto status = library_->CHPFetchComponentCarrierMeasurement(instrument, selector_string, timeout, &absolute_power, &relative_power); - response->set_status(status); - if (status_ok(status)) { - response->set_absolute_power(absolute_power); - response->set_relative_power(relative_power); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_absolute_power(absolute_power); + response->set_relative_power(relative_power); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -1645,9 +1700,8 @@ namespace nirfmxnr_grpc { int32 actual_array_size {}; while (true) { auto status = library_->CHPFetchComponentCarrierMeasurementArray(instrument, selector_string, timeout, nullptr, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_absolute_power()->Resize(actual_array_size, 0); float64* absolute_power = response->mutable_absolute_power()->mutable_data(); @@ -1659,12 +1713,13 @@ namespace nirfmxnr_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->mutable_absolute_power()->Resize(actual_array_size, 0); - response->mutable_relative_power()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->mutable_absolute_power()->Resize(actual_array_size, 0); + response->mutable_relative_power()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -1690,9 +1745,8 @@ namespace nirfmxnr_grpc { int32 actual_array_size {}; while (true) { auto status = library_->CHPFetchSpectrum(instrument, selector_string, timeout, &x0, &dx, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_spectrum()->Resize(actual_array_size, 0); float32* spectrum = response->mutable_spectrum()->mutable_data(); @@ -1702,13 +1756,14 @@ namespace nirfmxnr_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_x0(x0); - response->set_dx(dx); - response->mutable_spectrum()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_x0(x0); + response->set_dx(dx); + response->mutable_spectrum()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -1731,10 +1786,11 @@ namespace nirfmxnr_grpc { float64 timeout = request->timeout(); float64 subblock_power {}; auto status = library_->CHPFetchSubblockPower(instrument, selector_string, timeout, &subblock_power); - response->set_status(status); - if (status_ok(status)) { - response->set_subblock_power(subblock_power); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_subblock_power(subblock_power); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -1756,10 +1812,11 @@ namespace nirfmxnr_grpc { float64 timeout = request->timeout(); float64 total_aggregated_power {}; auto status = library_->CHPFetchTotalAggregatedPower(instrument, selector_string, timeout, &total_aggregated_power); - response->set_status(status); - if (status_ok(status)) { - response->set_total_aggregated_power(total_aggregated_power); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_total_aggregated_power(total_aggregated_power); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -1780,11 +1837,12 @@ namespace nirfmxnr_grpc { char* selector_string = (char*)request->selector_string().c_str(); int32 noise_calibration_data_valid {}; auto status = library_->CHPValidateNoiseCalibrationData(instrument, selector_string, &noise_calibration_data_valid); - response->set_status(status); - if (status_ok(status)) { - response->set_noise_calibration_data_valid(static_cast(noise_calibration_data_valid)); - response->set_noise_calibration_data_valid_raw(noise_calibration_data_valid); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_noise_calibration_data_valid(static_cast(noise_calibration_data_valid)); + response->set_noise_calibration_data_valid_raw(noise_calibration_data_valid); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -1842,6 +1900,9 @@ namespace nirfmxnr_grpc { float64 trigger_delay = request->trigger_delay(); int32 enable_trigger = request->enable_trigger(); auto status = library_->CfgDigitalEdgeTrigger(instrument, selector_string, digital_edge_source, digital_edge, trigger_delay, enable_trigger); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1863,6 +1924,9 @@ namespace nirfmxnr_grpc { char* selector_string = (char*)request->selector_string().c_str(); float64 external_attenuation = request->external_attenuation(); auto status = library_->CfgExternalAttenuation(instrument, selector_string, external_attenuation); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1884,6 +1948,9 @@ namespace nirfmxnr_grpc { char* selector_string = (char*)request->selector_string().c_str(); float64 center_frequency = request->center_frequency(); auto status = library_->CfgFrequency(instrument, selector_string, center_frequency); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1925,6 +1992,9 @@ namespace nirfmxnr_grpc { float64 frequency_reference_frequency = request->frequency_reference_frequency(); auto status = library_->CfgFrequencyReference(instrument, channel_name, frequency_reference_source, frequency_reference_frequency); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1998,6 +2068,9 @@ namespace nirfmxnr_grpc { int32 enable_trigger = request->enable_trigger(); auto status = library_->CfgIQPowerEdgeTrigger(instrument, selector_string, iq_power_edge_source, iq_power_edge_slope, iq_power_edge_level, trigger_delay, trigger_min_quiet_time_mode, trigger_min_quiet_time_duration, iq_power_edge_level_type, enable_trigger); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -2035,6 +2108,9 @@ namespace nirfmxnr_grpc { float64 mechanical_attenuation_value = request->mechanical_attenuation_value(); auto status = library_->CfgMechanicalAttenuation(instrument, channel_name, mechanical_attenuation_auto, mechanical_attenuation_value); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -2058,6 +2134,9 @@ namespace nirfmxnr_grpc { float64 reference_level = request->reference_level(); float64 external_attenuation = request->external_attenuation(); auto status = library_->CfgRF(instrument, selector_string, center_frequency, reference_level, external_attenuation); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -2095,6 +2174,9 @@ namespace nirfmxnr_grpc { float64 rf_attenuation_value = request->rf_attenuation_value(); auto status = library_->CfgRFAttenuation(instrument, channel_name, rf_attenuation_auto, rf_attenuation_value); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -2116,6 +2198,9 @@ namespace nirfmxnr_grpc { char* selector_string = (char*)request->selector_string().c_str(); float64 reference_level = request->reference_level(); auto status = library_->CfgReferenceLevel(instrument, selector_string, reference_level); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -2138,6 +2223,9 @@ namespace nirfmxnr_grpc { float64 trigger_delay = request->trigger_delay(); int32 enable_trigger = request->enable_trigger(); auto status = library_->CfgSoftwareEdgeTrigger(instrument, selector_string, trigger_delay, enable_trigger); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -2174,6 +2262,9 @@ namespace nirfmxnr_grpc { } auto status = library_->CfggNodeBCategory(instrument, selector_string, gnodeb_category); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -2195,10 +2286,11 @@ namespace nirfmxnr_grpc { char* selector_string = (char*)request->selector_string().c_str(); int32 is_done {}; auto status = library_->CheckMeasurementStatus(instrument, selector_string, &is_done); - response->set_status(status); - if (status_ok(status)) { - response->set_is_done(is_done); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_is_done(is_done); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -2218,6 +2310,9 @@ namespace nirfmxnr_grpc { niRFmxInstrHandle instrument = session_repository_->access_session(instrument_grpc_session.id(), instrument_grpc_session.name()); char* selector_string = (char*)request->selector_string().c_str(); auto status = library_->ClearAllNamedResults(instrument, selector_string); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -2238,6 +2333,9 @@ namespace nirfmxnr_grpc { niRFmxInstrHandle instrument = session_repository_->access_session(instrument_grpc_session.id(), instrument_grpc_session.name()); char* selector_string = (char*)request->selector_string().c_str(); auto status = library_->ClearNamedResult(instrument, selector_string); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -2258,6 +2356,9 @@ namespace nirfmxnr_grpc { niRFmxInstrHandle instrument = session_repository_->access_session(instrument_grpc_session.id(), instrument_grpc_session.name()); char* selector_string = (char*)request->selector_string().c_str(); auto status = library_->ClearNoiseCalibrationDatabase(instrument, selector_string); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -2279,6 +2380,9 @@ namespace nirfmxnr_grpc { char* old_signal_name = (char*)request->old_signal_name().c_str(); char* new_signal_name = (char*)request->new_signal_name().c_str(); auto status = library_->CloneSignalConfiguration(instrument, old_signal_name, new_signal_name); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -2300,6 +2404,9 @@ namespace nirfmxnr_grpc { int32 force_destroy = request->force_destroy(); session_repository_->remove_session(instrument_grpc_session.id(), instrument_grpc_session.name()); auto status = library_->Close(instrument, force_destroy); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -2320,6 +2427,9 @@ namespace nirfmxnr_grpc { niRFmxInstrHandle instrument = session_repository_->access_session(instrument_grpc_session.id(), instrument_grpc_session.name()); char* selector_string = (char*)request->selector_string().c_str(); auto status = library_->Commit(instrument, selector_string); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -2340,6 +2450,9 @@ namespace nirfmxnr_grpc { niRFmxInstrHandle instrument = session_repository_->access_session(instrument_grpc_session.id(), instrument_grpc_session.name()); char* list_name = (char*)request->list_name().c_str(); auto status = library_->CreateList(instrument, list_name); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -2361,10 +2474,11 @@ namespace nirfmxnr_grpc { char* selector_string = (char*)request->selector_string().c_str(); int32 created_step_index {}; auto status = library_->CreateListStep(instrument, selector_string, &created_step_index); - response->set_status(status); - if (status_ok(status)) { - response->set_created_step_index(created_step_index); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_created_step_index(created_step_index); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -2384,6 +2498,9 @@ namespace nirfmxnr_grpc { niRFmxInstrHandle instrument = session_repository_->access_session(instrument_grpc_session.id(), instrument_grpc_session.name()); char* signal_name = (char*)request->signal_name().c_str(); auto status = library_->CreateSignalConfiguration(instrument, signal_name); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -2404,6 +2521,9 @@ namespace nirfmxnr_grpc { niRFmxInstrHandle instrument = session_repository_->access_session(instrument_grpc_session.id(), instrument_grpc_session.name()); char* list_name = (char*)request->list_name().c_str(); auto status = library_->DeleteList(instrument, list_name); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -2424,6 +2544,9 @@ namespace nirfmxnr_grpc { niRFmxInstrHandle instrument = session_repository_->access_session(instrument_grpc_session.id(), instrument_grpc_session.name()); char* signal_name = (char*)request->signal_name().c_str(); auto status = library_->DeleteSignalConfiguration(instrument, signal_name); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -2444,6 +2567,9 @@ namespace nirfmxnr_grpc { niRFmxInstrHandle instrument = session_repository_->access_session(instrument_grpc_session.id(), instrument_grpc_session.name()); char* selector_string = (char*)request->selector_string().c_str(); auto status = library_->DisableTrigger(instrument, selector_string); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -2467,9 +2593,8 @@ namespace nirfmxnr_grpc { int32 default_result_exists {}; while (true) { auto status = library_->GetAllNamedResultNames(instrument, selector_string, nullptr, 0, &actual_result_names_size, &default_result_exists); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } std::string result_names; if (actual_result_names_size > 0) { @@ -2481,13 +2606,14 @@ namespace nirfmxnr_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_result_names(result_names); - nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_result_names())); - response->set_actual_result_names_size(actual_result_names_size); - response->set_default_result_exists(default_result_exists); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_result_names(result_names); + nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_result_names())); + response->set_actual_result_names_size(actual_result_names_size); + response->set_default_result_exists(default_result_exists); return ::grpc::Status::OK; } } @@ -2510,10 +2636,11 @@ namespace nirfmxnr_grpc { int32 attribute_id = request->attribute_id(); float32 attr_val {}; auto status = library_->GetAttributeF32(instrument, selector_string, attribute_id, &attr_val); - response->set_status(status); - if (status_ok(status)) { - response->set_attr_val(attr_val); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_attr_val(attr_val); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -2536,9 +2663,8 @@ namespace nirfmxnr_grpc { int32 actual_array_size {}; while (true) { auto status = library_->GetAttributeF32Array(instrument, selector_string, attribute_id, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_attr_val()->Resize(actual_array_size, 0); float32* attr_val = response->mutable_attr_val()->mutable_data(); @@ -2548,11 +2674,12 @@ namespace nirfmxnr_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->mutable_attr_val()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->mutable_attr_val()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -2575,10 +2702,11 @@ namespace nirfmxnr_grpc { int32 attribute_id = request->attribute_id(); float64 attr_val {}; auto status = library_->GetAttributeF64(instrument, selector_string, attribute_id, &attr_val); - response->set_status(status); - if (status_ok(status)) { - response->set_attr_val(attr_val); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_attr_val(attr_val); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -2601,9 +2729,8 @@ namespace nirfmxnr_grpc { int32 actual_array_size {}; while (true) { auto status = library_->GetAttributeF64Array(instrument, selector_string, attribute_id, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_attr_val()->Resize(actual_array_size, 0); float64* attr_val = response->mutable_attr_val()->mutable_data(); @@ -2613,11 +2740,12 @@ namespace nirfmxnr_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->mutable_attr_val()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->mutable_attr_val()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -2640,10 +2768,11 @@ namespace nirfmxnr_grpc { int32 attribute_id = request->attribute_id(); int16 attr_val {}; auto status = library_->GetAttributeI16(instrument, selector_string, attribute_id, &attr_val); - response->set_status(status); - if (status_ok(status)) { - response->set_attr_val(attr_val); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_attr_val(attr_val); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -2665,16 +2794,17 @@ namespace nirfmxnr_grpc { int32 attribute_id = request->attribute_id(); int32 attr_val {}; auto status = library_->GetAttributeI32(instrument, selector_string, attribute_id, &attr_val); - response->set_status(status); - if (status_ok(status)) { - auto checked_convert_attr_val = [](auto raw_value) { - bool raw_value_is_valid = nirfmxnr_grpc::NiRFmxNRInt32AttributeValues_IsValid(raw_value); - auto valid_enum_value = raw_value_is_valid ? raw_value : 0; - return static_cast(valid_enum_value); - }; - response->set_attr_val(checked_convert_attr_val(attr_val)); - response->set_attr_val_raw(attr_val); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + auto checked_convert_attr_val = [](auto raw_value) { + bool raw_value_is_valid = nirfmxnr_grpc::NiRFmxNRInt32AttributeValues_IsValid(raw_value); + auto valid_enum_value = raw_value_is_valid ? raw_value : 0; + return static_cast(valid_enum_value); + }; + response->set_attr_val(checked_convert_attr_val(attr_val)); + response->set_attr_val_raw(attr_val); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -2697,9 +2827,8 @@ namespace nirfmxnr_grpc { int32 actual_array_size {}; while (true) { auto status = library_->GetAttributeI32Array(instrument, selector_string, attribute_id, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_attr_val_raw()->Resize(actual_array_size, 0); int32* attr_val = reinterpret_cast(response->mutable_attr_val_raw()->mutable_data()); @@ -2709,13 +2838,15 @@ namespace nirfmxnr_grpc { // buffer is now too small, try again continue; } + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); - if (status_ok(status)) { - auto checked_convert_attr_val = [](auto raw_value) { - bool raw_value_is_valid = nirfmxnr_grpc::NiRFmxNRInt32AttributeValues_IsValid(raw_value); - auto valid_enum_value = raw_value_is_valid ? raw_value : 0; - return static_cast(valid_enum_value); - }; + auto checked_convert_attr_val = [](auto raw_value) { + bool raw_value_is_valid = nirfmxnr_grpc::NiRFmxNRInt32AttributeValues_IsValid(raw_value); + auto valid_enum_value = raw_value_is_valid ? raw_value : 0; + return static_cast(valid_enum_value); + }; response->mutable_attr_val()->Clear(); response->mutable_attr_val()->Reserve(actual_array_size); std::transform( @@ -2725,9 +2856,8 @@ namespace nirfmxnr_grpc { [&](auto x) { return checked_convert_attr_val(x); }); - response->mutable_attr_val()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); - } + response->mutable_attr_val()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -2750,10 +2880,11 @@ namespace nirfmxnr_grpc { int32 attribute_id = request->attribute_id(); int64 attr_val {}; auto status = library_->GetAttributeI64(instrument, selector_string, attribute_id, &attr_val); - response->set_status(status); - if (status_ok(status)) { - response->set_attr_val(attr_val); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_attr_val(attr_val); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -2776,9 +2907,8 @@ namespace nirfmxnr_grpc { int32 actual_array_size {}; while (true) { auto status = library_->GetAttributeI64Array(instrument, selector_string, attribute_id, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_attr_val()->Resize(actual_array_size, 0); int64* attr_val = reinterpret_cast(response->mutable_attr_val()->mutable_data()); @@ -2788,11 +2918,12 @@ namespace nirfmxnr_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->mutable_attr_val()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->mutable_attr_val()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -2815,10 +2946,11 @@ namespace nirfmxnr_grpc { int32 attribute_id = request->attribute_id(); int8 attr_val {}; auto status = library_->GetAttributeI8(instrument, selector_string, attribute_id, &attr_val); - response->set_status(status); - if (status_ok(status)) { - response->set_attr_val(attr_val); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_attr_val(attr_val); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -2841,9 +2973,8 @@ namespace nirfmxnr_grpc { int32 actual_array_size {}; while (true) { auto status = library_->GetAttributeI8Array(instrument, selector_string, attribute_id, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } std::vector attr_val(actual_array_size); auto array_size = actual_array_size; @@ -2852,8 +2983,10 @@ namespace nirfmxnr_grpc { // buffer is now too small, try again continue; } + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); - if (status_ok(status)) { response->mutable_attr_val()->Clear(); response->mutable_attr_val()->Reserve(actual_array_size); std::transform( @@ -2863,9 +2996,8 @@ namespace nirfmxnr_grpc { [&](auto x) { return x; }); - response->mutable_attr_val()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); - } + response->mutable_attr_val()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -2889,9 +3021,8 @@ namespace nirfmxnr_grpc { int32 actual_array_size {}; while (true) { auto status = library_->GetAttributeNIComplexDoubleArray(instrument, selector_string, attribute_id, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } std::vector attr_val(actual_array_size, NIComplexDouble()); auto array_size = actual_array_size; @@ -2900,18 +3031,19 @@ namespace nirfmxnr_grpc { // buffer is now too small, try again continue; } + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); - if (status_ok(status)) { - convert_to_grpc(attr_val, response->mutable_attr_val()); - { - auto shrunk_size = actual_array_size; - auto current_size = response->mutable_attr_val()->size(); - if (shrunk_size != current_size) { - response->mutable_attr_val()->DeleteSubrange(shrunk_size, current_size - shrunk_size); - } + convert_to_grpc(attr_val, response->mutable_attr_val()); + { + auto shrunk_size = actual_array_size; + auto current_size = response->mutable_attr_val()->size(); + if (shrunk_size != current_size) { + response->mutable_attr_val()->DeleteSubrange(shrunk_size, current_size - shrunk_size); } - response->set_actual_array_size(actual_array_size); } + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -2935,9 +3067,8 @@ namespace nirfmxnr_grpc { int32 actual_array_size {}; while (true) { auto status = library_->GetAttributeNIComplexSingleArray(instrument, selector_string, attribute_id, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } std::vector attr_val(actual_array_size, NIComplexSingle()); auto array_size = actual_array_size; @@ -2946,18 +3077,19 @@ namespace nirfmxnr_grpc { // buffer is now too small, try again continue; } + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); - if (status_ok(status)) { - convert_to_grpc(attr_val, response->mutable_attr_val()); - { - auto shrunk_size = actual_array_size; - auto current_size = response->mutable_attr_val()->size(); - if (shrunk_size != current_size) { - response->mutable_attr_val()->DeleteSubrange(shrunk_size, current_size - shrunk_size); - } + convert_to_grpc(attr_val, response->mutable_attr_val()); + { + auto shrunk_size = actual_array_size; + auto current_size = response->mutable_attr_val()->size(); + if (shrunk_size != current_size) { + response->mutable_attr_val()->DeleteSubrange(shrunk_size, current_size - shrunk_size); } - response->set_actual_array_size(actual_array_size); } + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -2981,9 +3113,8 @@ namespace nirfmxnr_grpc { while (true) { auto status = library_->GetAttributeString(instrument, selector_string, attribute_id, 0, nullptr); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } int32 array_size = status; @@ -2996,11 +3127,12 @@ namespace nirfmxnr_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_attr_val(attr_val); - nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_attr_val())); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_attr_val(attr_val); + nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_attr_val())); return ::grpc::Status::OK; } } @@ -3023,10 +3155,11 @@ namespace nirfmxnr_grpc { int32 attribute_id = request->attribute_id(); uInt16 attr_val {}; auto status = library_->GetAttributeU16(instrument, selector_string, attribute_id, &attr_val); - response->set_status(status); - if (status_ok(status)) { - response->set_attr_val(attr_val); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_attr_val(attr_val); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -3048,10 +3181,11 @@ namespace nirfmxnr_grpc { int32 attribute_id = request->attribute_id(); uInt32 attr_val {}; auto status = library_->GetAttributeU32(instrument, selector_string, attribute_id, &attr_val); - response->set_status(status); - if (status_ok(status)) { - response->set_attr_val(attr_val); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_attr_val(attr_val); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -3074,9 +3208,8 @@ namespace nirfmxnr_grpc { int32 actual_array_size {}; while (true) { auto status = library_->GetAttributeU32Array(instrument, selector_string, attribute_id, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_attr_val()->Resize(actual_array_size, 0); uInt32* attr_val = reinterpret_cast(response->mutable_attr_val()->mutable_data()); @@ -3086,11 +3219,12 @@ namespace nirfmxnr_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->mutable_attr_val()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->mutable_attr_val()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -3114,9 +3248,8 @@ namespace nirfmxnr_grpc { int32 actual_array_size {}; while (true) { auto status = library_->GetAttributeU64Array(instrument, selector_string, attribute_id, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_attr_val()->Resize(actual_array_size, 0); uInt64* attr_val = reinterpret_cast(response->mutable_attr_val()->mutable_data()); @@ -3126,11 +3259,12 @@ namespace nirfmxnr_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->mutable_attr_val()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->mutable_attr_val()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -3153,10 +3287,11 @@ namespace nirfmxnr_grpc { int32 attribute_id = request->attribute_id(); uInt8 attr_val {}; auto status = library_->GetAttributeU8(instrument, selector_string, attribute_id, &attr_val); - response->set_status(status); - if (status_ok(status)) { - response->set_attr_val(attr_val); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_attr_val(attr_val); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -3179,9 +3314,8 @@ namespace nirfmxnr_grpc { int32 actual_array_size {}; while (true) { auto status = library_->GetAttributeU8Array(instrument, selector_string, attribute_id, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } std::string attr_val(actual_array_size, '\0'); auto array_size = actual_array_size; @@ -3190,12 +3324,13 @@ namespace nirfmxnr_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_attr_val(attr_val); - response->mutable_attr_val()->resize(actual_array_size); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_attr_val(attr_val); + response->mutable_attr_val()->resize(actual_array_size); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -3217,9 +3352,8 @@ namespace nirfmxnr_grpc { while (true) { auto status = library_->GetError(instrument, nullptr, 0, nullptr); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } int32 error_description_buffer_size = status; @@ -3233,12 +3367,13 @@ namespace nirfmxnr_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_error_code(error_code); - response->set_error_description(error_description); - nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_error_description())); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_error_code(error_code); + response->set_error_description(error_description); + nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_error_description())); return ::grpc::Status::OK; } } @@ -3261,9 +3396,8 @@ namespace nirfmxnr_grpc { while (true) { auto status = library_->GetErrorString(instrument, error_code, 0, nullptr); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } int32 error_description_buffer_size = status; @@ -3276,11 +3410,12 @@ namespace nirfmxnr_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_error_description(error_description); - nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_error_description())); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_error_description(error_description); + nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_error_description())); return ::grpc::Status::OK; } } @@ -3310,15 +3445,12 @@ namespace nirfmxnr_grpc { const std::string& grpc_device_session_name = request->session_name(); auto cleanup_lambda = [&] (niRFmxInstrHandle id) { library_->Close(id, RFMXNR_VAL_FALSE); }; int status = session_repository_->add_session(grpc_device_session_name, init_lambda, cleanup_lambda, session_id); - response->set_status(status); - if (status_ok(status)) { - response->mutable_instrument()->set_id(session_id); - response->set_is_new_session(is_new_session); - } - else { - const auto error_message = get_last_error_message(library_); - response->set_error_message(error_message); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, 0); } + response->set_status(status); + response->mutable_instrument()->set_id(session_id); + response->set_is_new_session(is_new_session); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -3349,14 +3481,11 @@ namespace nirfmxnr_grpc { const std::string& grpc_device_session_name = request->session_name(); auto cleanup_lambda = [&] (niRFmxInstrHandle id) { library_->Close(id, RFMXNR_VAL_FALSE); }; int status = session_repository_->add_session(grpc_device_session_name, init_lambda, cleanup_lambda, session_id); - response->set_status(status); - if (status_ok(status)) { - response->mutable_instrument()->set_id(session_id); - } - else { - const auto error_message = get_last_error_message(library_); - response->set_error_message(error_message); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, 0); } + response->set_status(status); + response->mutable_instrument()->set_id(session_id); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -3380,6 +3509,9 @@ namespace nirfmxnr_grpc { char* selector_string = (char*)request->selector_string().c_str(); char* result_name = (char*)request->result_name().c_str(); auto status = library_->Initiate(instrument, selector_string, result_name); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -3401,6 +3533,9 @@ namespace nirfmxnr_grpc { char* selector_string = (char*)request->selector_string().c_str(); float64 timeout = request->timeout(); auto status = library_->ModAccAutoLevel(instrument, selector_string, timeout); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -3437,6 +3572,9 @@ namespace nirfmxnr_grpc { } auto status = library_->ModAccCfgMeasurementMode(instrument, selector_string, measurement_mode); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -3473,6 +3611,9 @@ namespace nirfmxnr_grpc { } auto status = library_->ModAccCfgNoiseCompensationEnabled(instrument, selector_string, noise_compensation_enabled); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -3497,6 +3638,9 @@ namespace nirfmxnr_grpc { auto reference_waveform = convert_from_grpc(request->reference_waveform()); int32 array_size = static_cast(request->reference_waveform().size()); auto status = library_->ModAccCfgReferenceWaveform(instrument, selector_string, x0, dx, reference_waveform.data(), array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -3516,6 +3660,9 @@ namespace nirfmxnr_grpc { auto instrument_grpc_session = request->instrument(); niRFmxInstrHandle instrument = session_repository_->access_session(instrument_grpc_session.id(), instrument_grpc_session.name()); auto status = library_->ModAccClearNoiseCalibrationDatabase(instrument); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -3539,11 +3686,12 @@ namespace nirfmxnr_grpc { float64 composite_rms_evm_mean {}; float64 composite_peak_evm_maximum {}; auto status = library_->ModAccFetchCompositeEVM(instrument, selector_string, timeout, &composite_rms_evm_mean, &composite_peak_evm_maximum); - response->set_status(status); - if (status_ok(status)) { - response->set_composite_rms_evm_mean(composite_rms_evm_mean); - response->set_composite_peak_evm_maximum(composite_peak_evm_maximum); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_composite_rms_evm_mean(composite_rms_evm_mean); + response->set_composite_peak_evm_maximum(composite_peak_evm_maximum); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -3565,10 +3713,11 @@ namespace nirfmxnr_grpc { float64 timeout = request->timeout(); float64 frequency_error_mean {}; auto status = library_->ModAccFetchFrequencyErrorMean(instrument, selector_string, timeout, &frequency_error_mean); - response->set_status(status); - if (status_ok(status)) { - response->set_frequency_error_mean(frequency_error_mean); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_frequency_error_mean(frequency_error_mean); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -3593,9 +3742,8 @@ namespace nirfmxnr_grpc { int32 actual_array_size {}; while (true) { auto status = library_->ModAccFetchIQGainImbalancePerSubcarrierMeanTrace(instrument, selector_string, timeout, &x0, &dx, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_iq_gain_imbalance_per_subcarrier_mean()->Resize(actual_array_size, 0); float32* iq_gain_imbalance_per_subcarrier_mean = response->mutable_iq_gain_imbalance_per_subcarrier_mean()->mutable_data(); @@ -3605,13 +3753,14 @@ namespace nirfmxnr_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_x0(x0); - response->set_dx(dx); - response->mutable_iq_gain_imbalance_per_subcarrier_mean()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_x0(x0); + response->set_dx(dx); + response->mutable_iq_gain_imbalance_per_subcarrier_mean()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -3637,9 +3786,8 @@ namespace nirfmxnr_grpc { int32 actual_array_size {}; while (true) { auto status = library_->ModAccFetchIQQuadratureErrorPerSubcarrierMeanTrace(instrument, selector_string, timeout, &x0, &dx, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_iq_quadrature_error_per_subcarrier_mean()->Resize(actual_array_size, 0); float32* iq_quadrature_error_per_subcarrier_mean = response->mutable_iq_quadrature_error_per_subcarrier_mean()->mutable_data(); @@ -3649,13 +3797,14 @@ namespace nirfmxnr_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_x0(x0); - response->set_dx(dx); - response->mutable_iq_quadrature_error_per_subcarrier_mean()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_x0(x0); + response->set_dx(dx); + response->mutable_iq_quadrature_error_per_subcarrier_mean()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -3681,9 +3830,8 @@ namespace nirfmxnr_grpc { int32 actual_array_size {}; while (true) { auto status = library_->ModAccFetchInBandEmissionTrace(instrument, selector_string, timeout, &x0, &dx, nullptr, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_in_band_emission()->Resize(actual_array_size, 0); float32* in_band_emission = response->mutable_in_band_emission()->mutable_data(); @@ -3695,14 +3843,15 @@ namespace nirfmxnr_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_x0(x0); - response->set_dx(dx); - response->mutable_in_band_emission()->Resize(actual_array_size, 0); - response->mutable_in_band_emission_mask()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_x0(x0); + response->set_dx(dx); + response->mutable_in_band_emission()->Resize(actual_array_size, 0); + response->mutable_in_band_emission_mask()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -3726,9 +3875,8 @@ namespace nirfmxnr_grpc { int32 actual_array_size {}; while (true) { auto status = library_->ModAccFetchPBCHDMRSConstellationTrace(instrument, selector_string, timeout, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } std::vector pbch_dmrs_constellation(actual_array_size, NIComplexSingle()); auto array_size = actual_array_size; @@ -3737,18 +3885,19 @@ namespace nirfmxnr_grpc { // buffer is now too small, try again continue; } + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); - if (status_ok(status)) { - convert_to_grpc(pbch_dmrs_constellation, response->mutable_pbch_dmrs_constellation()); - { - auto shrunk_size = actual_array_size; - auto current_size = response->mutable_pbch_dmrs_constellation()->size(); - if (shrunk_size != current_size) { - response->mutable_pbch_dmrs_constellation()->DeleteSubrange(shrunk_size, current_size - shrunk_size); - } + convert_to_grpc(pbch_dmrs_constellation, response->mutable_pbch_dmrs_constellation()); + { + auto shrunk_size = actual_array_size; + auto current_size = response->mutable_pbch_dmrs_constellation()->size(); + if (shrunk_size != current_size) { + response->mutable_pbch_dmrs_constellation()->DeleteSubrange(shrunk_size, current_size - shrunk_size); } - response->set_actual_array_size(actual_array_size); } + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -3774,9 +3923,8 @@ namespace nirfmxnr_grpc { int32 actual_array_size {}; while (true) { auto status = library_->ModAccFetchPBCHDMRSRMSEVMPerSubcarrierMeanTrace(instrument, selector_string, timeout, &x0, &dx, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_pbch_dmrs_rms_evm_per_subcarrier_mean()->Resize(actual_array_size, 0); float32* pbch_dmrs_rms_evm_per_subcarrier_mean = response->mutable_pbch_dmrs_rms_evm_per_subcarrier_mean()->mutable_data(); @@ -3786,13 +3934,14 @@ namespace nirfmxnr_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_x0(x0); - response->set_dx(dx); - response->mutable_pbch_dmrs_rms_evm_per_subcarrier_mean()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_x0(x0); + response->set_dx(dx); + response->mutable_pbch_dmrs_rms_evm_per_subcarrier_mean()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -3818,9 +3967,8 @@ namespace nirfmxnr_grpc { int32 actual_array_size {}; while (true) { auto status = library_->ModAccFetchPBCHDMRSRMSEVMPerSymbolMeanTrace(instrument, selector_string, timeout, &x0, &dx, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_pbch_dmrs_rms_evm_per_symbol_mean()->Resize(actual_array_size, 0); float32* pbch_dmrs_rms_evm_per_symbol_mean = response->mutable_pbch_dmrs_rms_evm_per_symbol_mean()->mutable_data(); @@ -3830,13 +3978,14 @@ namespace nirfmxnr_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_x0(x0); - response->set_dx(dx); - response->mutable_pbch_dmrs_rms_evm_per_symbol_mean()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_x0(x0); + response->set_dx(dx); + response->mutable_pbch_dmrs_rms_evm_per_symbol_mean()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -3860,9 +4009,8 @@ namespace nirfmxnr_grpc { int32 actual_array_size {}; while (true) { auto status = library_->ModAccFetchPBCHDataConstellationTrace(instrument, selector_string, timeout, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } std::vector pbch_data_constellation(actual_array_size, NIComplexSingle()); auto array_size = actual_array_size; @@ -3871,18 +4019,19 @@ namespace nirfmxnr_grpc { // buffer is now too small, try again continue; } + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); - if (status_ok(status)) { - convert_to_grpc(pbch_data_constellation, response->mutable_pbch_data_constellation()); - { - auto shrunk_size = actual_array_size; - auto current_size = response->mutable_pbch_data_constellation()->size(); - if (shrunk_size != current_size) { - response->mutable_pbch_data_constellation()->DeleteSubrange(shrunk_size, current_size - shrunk_size); - } + convert_to_grpc(pbch_data_constellation, response->mutable_pbch_data_constellation()); + { + auto shrunk_size = actual_array_size; + auto current_size = response->mutable_pbch_data_constellation()->size(); + if (shrunk_size != current_size) { + response->mutable_pbch_data_constellation()->DeleteSubrange(shrunk_size, current_size - shrunk_size); } - response->set_actual_array_size(actual_array_size); } + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -3908,9 +4057,8 @@ namespace nirfmxnr_grpc { int32 actual_array_size {}; while (true) { auto status = library_->ModAccFetchPBCHDataRMSEVMPerSubcarrierMeanTrace(instrument, selector_string, timeout, &x0, &dx, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_pbch_data_rms_evm_per_subcarrier_mean()->Resize(actual_array_size, 0); float32* pbch_data_rms_evm_per_subcarrier_mean = response->mutable_pbch_data_rms_evm_per_subcarrier_mean()->mutable_data(); @@ -3920,13 +4068,14 @@ namespace nirfmxnr_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_x0(x0); - response->set_dx(dx); - response->mutable_pbch_data_rms_evm_per_subcarrier_mean()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_x0(x0); + response->set_dx(dx); + response->mutable_pbch_data_rms_evm_per_subcarrier_mean()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -3952,9 +4101,8 @@ namespace nirfmxnr_grpc { int32 actual_array_size {}; while (true) { auto status = library_->ModAccFetchPBCHDataRMSEVMPerSymbolMeanTrace(instrument, selector_string, timeout, &x0, &dx, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_pbch_data_rms_evm_per_symbol_mean()->Resize(actual_array_size, 0); float32* pbch_data_rms_evm_per_symbol_mean = response->mutable_pbch_data_rms_evm_per_symbol_mean()->mutable_data(); @@ -3964,13 +4112,14 @@ namespace nirfmxnr_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_x0(x0); - response->set_dx(dx); - response->mutable_pbch_data_rms_evm_per_symbol_mean()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_x0(x0); + response->set_dx(dx); + response->mutable_pbch_data_rms_evm_per_symbol_mean()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -3994,9 +4143,8 @@ namespace nirfmxnr_grpc { int32 actual_array_size {}; while (true) { auto status = library_->ModAccFetchPDSCH1024QAMConstellationTrace(instrument, selector_string, timeout, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } std::vector qam1024_constellation(actual_array_size, NIComplexSingle()); auto array_size = actual_array_size; @@ -4005,18 +4153,19 @@ namespace nirfmxnr_grpc { // buffer is now too small, try again continue; } + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); - if (status_ok(status)) { - convert_to_grpc(qam1024_constellation, response->mutable_qam1024_constellation()); - { - auto shrunk_size = actual_array_size; - auto current_size = response->mutable_qam1024_constellation()->size(); - if (shrunk_size != current_size) { - response->mutable_qam1024_constellation()->DeleteSubrange(shrunk_size, current_size - shrunk_size); - } + convert_to_grpc(qam1024_constellation, response->mutable_qam1024_constellation()); + { + auto shrunk_size = actual_array_size; + auto current_size = response->mutable_qam1024_constellation()->size(); + if (shrunk_size != current_size) { + response->mutable_qam1024_constellation()->DeleteSubrange(shrunk_size, current_size - shrunk_size); } - response->set_actual_array_size(actual_array_size); } + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -4040,9 +4189,8 @@ namespace nirfmxnr_grpc { int32 actual_array_size {}; while (true) { auto status = library_->ModAccFetchPDSCH16QAMConstellationTrace(instrument, selector_string, timeout, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } std::vector qam16_constellation(actual_array_size, NIComplexSingle()); auto array_size = actual_array_size; @@ -4051,18 +4199,19 @@ namespace nirfmxnr_grpc { // buffer is now too small, try again continue; } + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); - if (status_ok(status)) { - convert_to_grpc(qam16_constellation, response->mutable_qam16_constellation()); - { - auto shrunk_size = actual_array_size; - auto current_size = response->mutable_qam16_constellation()->size(); - if (shrunk_size != current_size) { - response->mutable_qam16_constellation()->DeleteSubrange(shrunk_size, current_size - shrunk_size); - } + convert_to_grpc(qam16_constellation, response->mutable_qam16_constellation()); + { + auto shrunk_size = actual_array_size; + auto current_size = response->mutable_qam16_constellation()->size(); + if (shrunk_size != current_size) { + response->mutable_qam16_constellation()->DeleteSubrange(shrunk_size, current_size - shrunk_size); } - response->set_actual_array_size(actual_array_size); } + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -4086,9 +4235,8 @@ namespace nirfmxnr_grpc { int32 actual_array_size {}; while (true) { auto status = library_->ModAccFetchPDSCH256QAMConstellationTrace(instrument, selector_string, timeout, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } std::vector qam256_constellation(actual_array_size, NIComplexSingle()); auto array_size = actual_array_size; @@ -4097,18 +4245,19 @@ namespace nirfmxnr_grpc { // buffer is now too small, try again continue; } + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); - if (status_ok(status)) { - convert_to_grpc(qam256_constellation, response->mutable_qam256_constellation()); - { - auto shrunk_size = actual_array_size; - auto current_size = response->mutable_qam256_constellation()->size(); - if (shrunk_size != current_size) { - response->mutable_qam256_constellation()->DeleteSubrange(shrunk_size, current_size - shrunk_size); - } + convert_to_grpc(qam256_constellation, response->mutable_qam256_constellation()); + { + auto shrunk_size = actual_array_size; + auto current_size = response->mutable_qam256_constellation()->size(); + if (shrunk_size != current_size) { + response->mutable_qam256_constellation()->DeleteSubrange(shrunk_size, current_size - shrunk_size); } - response->set_actual_array_size(actual_array_size); } + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -4132,9 +4281,8 @@ namespace nirfmxnr_grpc { int32 actual_array_size {}; while (true) { auto status = library_->ModAccFetchPDSCH64QAMConstellationTrace(instrument, selector_string, timeout, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } std::vector qam64_constellation(actual_array_size, NIComplexSingle()); auto array_size = actual_array_size; @@ -4143,18 +4291,19 @@ namespace nirfmxnr_grpc { // buffer is now too small, try again continue; } + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); - if (status_ok(status)) { - convert_to_grpc(qam64_constellation, response->mutable_qam64_constellation()); - { - auto shrunk_size = actual_array_size; - auto current_size = response->mutable_qam64_constellation()->size(); - if (shrunk_size != current_size) { - response->mutable_qam64_constellation()->DeleteSubrange(shrunk_size, current_size - shrunk_size); - } + convert_to_grpc(qam64_constellation, response->mutable_qam64_constellation()); + { + auto shrunk_size = actual_array_size; + auto current_size = response->mutable_qam64_constellation()->size(); + if (shrunk_size != current_size) { + response->mutable_qam64_constellation()->DeleteSubrange(shrunk_size, current_size - shrunk_size); } - response->set_actual_array_size(actual_array_size); } + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -4178,9 +4327,8 @@ namespace nirfmxnr_grpc { int32 actual_array_size {}; while (true) { auto status = library_->ModAccFetchPDSCH8PSKConstellationTrace(instrument, selector_string, timeout, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } std::vector psk8_constellation(actual_array_size, NIComplexSingle()); auto array_size = actual_array_size; @@ -4189,18 +4337,19 @@ namespace nirfmxnr_grpc { // buffer is now too small, try again continue; } + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); - if (status_ok(status)) { - convert_to_grpc(psk8_constellation, response->mutable_psk8_constellation()); - { - auto shrunk_size = actual_array_size; - auto current_size = response->mutable_psk8_constellation()->size(); - if (shrunk_size != current_size) { - response->mutable_psk8_constellation()->DeleteSubrange(shrunk_size, current_size - shrunk_size); - } + convert_to_grpc(psk8_constellation, response->mutable_psk8_constellation()); + { + auto shrunk_size = actual_array_size; + auto current_size = response->mutable_psk8_constellation()->size(); + if (shrunk_size != current_size) { + response->mutable_psk8_constellation()->DeleteSubrange(shrunk_size, current_size - shrunk_size); } - response->set_actual_array_size(actual_array_size); } + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -4224,9 +4373,8 @@ namespace nirfmxnr_grpc { int32 actual_array_size {}; while (true) { auto status = library_->ModAccFetchPDSCHDMRSConstellationTrace(instrument, selector_string, timeout, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } std::vector pdsch_dmrs_constellation(actual_array_size, NIComplexSingle()); auto array_size = actual_array_size; @@ -4235,18 +4383,19 @@ namespace nirfmxnr_grpc { // buffer is now too small, try again continue; } + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); - if (status_ok(status)) { - convert_to_grpc(pdsch_dmrs_constellation, response->mutable_pdsch_dmrs_constellation()); - { - auto shrunk_size = actual_array_size; - auto current_size = response->mutable_pdsch_dmrs_constellation()->size(); - if (shrunk_size != current_size) { - response->mutable_pdsch_dmrs_constellation()->DeleteSubrange(shrunk_size, current_size - shrunk_size); - } + convert_to_grpc(pdsch_dmrs_constellation, response->mutable_pdsch_dmrs_constellation()); + { + auto shrunk_size = actual_array_size; + auto current_size = response->mutable_pdsch_dmrs_constellation()->size(); + if (shrunk_size != current_size) { + response->mutable_pdsch_dmrs_constellation()->DeleteSubrange(shrunk_size, current_size - shrunk_size); } - response->set_actual_array_size(actual_array_size); } + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -4270,9 +4419,8 @@ namespace nirfmxnr_grpc { int32 actual_array_size {}; while (true) { auto status = library_->ModAccFetchPDSCHDataConstellationTrace(instrument, selector_string, timeout, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } std::vector pdsch_data_constellation(actual_array_size, NIComplexSingle()); auto array_size = actual_array_size; @@ -4281,18 +4429,19 @@ namespace nirfmxnr_grpc { // buffer is now too small, try again continue; } + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); - if (status_ok(status)) { - convert_to_grpc(pdsch_data_constellation, response->mutable_pdsch_data_constellation()); - { - auto shrunk_size = actual_array_size; - auto current_size = response->mutable_pdsch_data_constellation()->size(); - if (shrunk_size != current_size) { - response->mutable_pdsch_data_constellation()->DeleteSubrange(shrunk_size, current_size - shrunk_size); - } + convert_to_grpc(pdsch_data_constellation, response->mutable_pdsch_data_constellation()); + { + auto shrunk_size = actual_array_size; + auto current_size = response->mutable_pdsch_data_constellation()->size(); + if (shrunk_size != current_size) { + response->mutable_pdsch_data_constellation()->DeleteSubrange(shrunk_size, current_size - shrunk_size); } - response->set_actual_array_size(actual_array_size); } + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -4316,9 +4465,8 @@ namespace nirfmxnr_grpc { int32 actual_array_size {}; while (true) { auto status = library_->ModAccFetchPDSCHDemodulatedBits(instrument, selector_string, timeout, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } std::vector bits(actual_array_size); auto array_size = actual_array_size; @@ -4327,8 +4475,10 @@ namespace nirfmxnr_grpc { // buffer is now too small, try again continue; } + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); - if (status_ok(status)) { response->mutable_bits()->Clear(); response->mutable_bits()->Reserve(actual_array_size); std::transform( @@ -4338,9 +4488,8 @@ namespace nirfmxnr_grpc { [&](auto x) { return x; }); - response->mutable_bits()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); - } + response->mutable_bits()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -4364,9 +4513,8 @@ namespace nirfmxnr_grpc { int32 actual_array_size {}; while (true) { auto status = library_->ModAccFetchPDSCHPTRSConstellationTrace(instrument, selector_string, timeout, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } std::vector pdsch_ptrs_constellation(actual_array_size, NIComplexSingle()); auto array_size = actual_array_size; @@ -4375,18 +4523,19 @@ namespace nirfmxnr_grpc { // buffer is now too small, try again continue; } + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); - if (status_ok(status)) { - convert_to_grpc(pdsch_ptrs_constellation, response->mutable_pdsch_ptrs_constellation()); - { - auto shrunk_size = actual_array_size; - auto current_size = response->mutable_pdsch_ptrs_constellation()->size(); - if (shrunk_size != current_size) { - response->mutable_pdsch_ptrs_constellation()->DeleteSubrange(shrunk_size, current_size - shrunk_size); - } + convert_to_grpc(pdsch_ptrs_constellation, response->mutable_pdsch_ptrs_constellation()); + { + auto shrunk_size = actual_array_size; + auto current_size = response->mutable_pdsch_ptrs_constellation()->size(); + if (shrunk_size != current_size) { + response->mutable_pdsch_ptrs_constellation()->DeleteSubrange(shrunk_size, current_size - shrunk_size); } - response->set_actual_array_size(actual_array_size); } + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -4410,9 +4559,8 @@ namespace nirfmxnr_grpc { int32 actual_array_size {}; while (true) { auto status = library_->ModAccFetchPDSCHQPSKConstellationTrace(instrument, selector_string, timeout, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } std::vector qpsk_constellation(actual_array_size, NIComplexSingle()); auto array_size = actual_array_size; @@ -4421,18 +4569,19 @@ namespace nirfmxnr_grpc { // buffer is now too small, try again continue; } + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); - if (status_ok(status)) { - convert_to_grpc(qpsk_constellation, response->mutable_qpsk_constellation()); - { - auto shrunk_size = actual_array_size; - auto current_size = response->mutable_qpsk_constellation()->size(); - if (shrunk_size != current_size) { - response->mutable_qpsk_constellation()->DeleteSubrange(shrunk_size, current_size - shrunk_size); - } + convert_to_grpc(qpsk_constellation, response->mutable_qpsk_constellation()); + { + auto shrunk_size = actual_array_size; + auto current_size = response->mutable_qpsk_constellation()->size(); + if (shrunk_size != current_size) { + response->mutable_qpsk_constellation()->DeleteSubrange(shrunk_size, current_size - shrunk_size); } - response->set_actual_array_size(actual_array_size); } + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -4456,9 +4605,8 @@ namespace nirfmxnr_grpc { int32 actual_array_size {}; while (true) { auto status = library_->ModAccFetchPSSConstellationTrace(instrument, selector_string, timeout, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } std::vector pss_constellation(actual_array_size, NIComplexSingle()); auto array_size = actual_array_size; @@ -4467,18 +4615,19 @@ namespace nirfmxnr_grpc { // buffer is now too small, try again continue; } + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); - if (status_ok(status)) { - convert_to_grpc(pss_constellation, response->mutable_pss_constellation()); - { - auto shrunk_size = actual_array_size; - auto current_size = response->mutable_pss_constellation()->size(); - if (shrunk_size != current_size) { - response->mutable_pss_constellation()->DeleteSubrange(shrunk_size, current_size - shrunk_size); - } + convert_to_grpc(pss_constellation, response->mutable_pss_constellation()); + { + auto shrunk_size = actual_array_size; + auto current_size = response->mutable_pss_constellation()->size(); + if (shrunk_size != current_size) { + response->mutable_pss_constellation()->DeleteSubrange(shrunk_size, current_size - shrunk_size); } - response->set_actual_array_size(actual_array_size); } + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -4504,9 +4653,8 @@ namespace nirfmxnr_grpc { int32 actual_array_size {}; while (true) { auto status = library_->ModAccFetchPSSRMSEVMPerSubcarrierMeanTrace(instrument, selector_string, timeout, &x0, &dx, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_pss_rms_evm_per_subcarrier_mean()->Resize(actual_array_size, 0); float32* pss_rms_evm_per_subcarrier_mean = response->mutable_pss_rms_evm_per_subcarrier_mean()->mutable_data(); @@ -4516,13 +4664,14 @@ namespace nirfmxnr_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_x0(x0); - response->set_dx(dx); - response->mutable_pss_rms_evm_per_subcarrier_mean()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_x0(x0); + response->set_dx(dx); + response->mutable_pss_rms_evm_per_subcarrier_mean()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -4548,9 +4697,8 @@ namespace nirfmxnr_grpc { int32 actual_array_size {}; while (true) { auto status = library_->ModAccFetchPSSRMSEVMPerSymbolMeanTrace(instrument, selector_string, timeout, &x0, &dx, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_pss_rms_evm_per_symbol_mean()->Resize(actual_array_size, 0); float32* pss_rms_evm_per_symbol_mean = response->mutable_pss_rms_evm_per_symbol_mean()->mutable_data(); @@ -4560,13 +4708,14 @@ namespace nirfmxnr_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_x0(x0); - response->set_dx(dx); - response->mutable_pss_rms_evm_per_symbol_mean()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_x0(x0); + response->set_dx(dx); + response->mutable_pss_rms_evm_per_symbol_mean()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -4590,9 +4739,8 @@ namespace nirfmxnr_grpc { int32 actual_array_size {}; while (true) { auto status = library_->ModAccFetchPUSCHDMRSConstellationTrace(instrument, selector_string, timeout, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } std::vector pusch_dmrs_constellation(actual_array_size, NIComplexSingle()); auto array_size = actual_array_size; @@ -4601,18 +4749,19 @@ namespace nirfmxnr_grpc { // buffer is now too small, try again continue; } + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); - if (status_ok(status)) { - convert_to_grpc(pusch_dmrs_constellation, response->mutable_pusch_dmrs_constellation()); - { - auto shrunk_size = actual_array_size; - auto current_size = response->mutable_pusch_dmrs_constellation()->size(); - if (shrunk_size != current_size) { - response->mutable_pusch_dmrs_constellation()->DeleteSubrange(shrunk_size, current_size - shrunk_size); - } + convert_to_grpc(pusch_dmrs_constellation, response->mutable_pusch_dmrs_constellation()); + { + auto shrunk_size = actual_array_size; + auto current_size = response->mutable_pusch_dmrs_constellation()->size(); + if (shrunk_size != current_size) { + response->mutable_pusch_dmrs_constellation()->DeleteSubrange(shrunk_size, current_size - shrunk_size); } - response->set_actual_array_size(actual_array_size); } + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -4636,9 +4785,8 @@ namespace nirfmxnr_grpc { int32 actual_array_size {}; while (true) { auto status = library_->ModAccFetchPUSCHDataConstellationTrace(instrument, selector_string, timeout, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } std::vector pusch_data_constellation(actual_array_size, NIComplexSingle()); auto array_size = actual_array_size; @@ -4647,18 +4795,19 @@ namespace nirfmxnr_grpc { // buffer is now too small, try again continue; } + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); - if (status_ok(status)) { - convert_to_grpc(pusch_data_constellation, response->mutable_pusch_data_constellation()); - { - auto shrunk_size = actual_array_size; - auto current_size = response->mutable_pusch_data_constellation()->size(); - if (shrunk_size != current_size) { - response->mutable_pusch_data_constellation()->DeleteSubrange(shrunk_size, current_size - shrunk_size); - } + convert_to_grpc(pusch_data_constellation, response->mutable_pusch_data_constellation()); + { + auto shrunk_size = actual_array_size; + auto current_size = response->mutable_pusch_data_constellation()->size(); + if (shrunk_size != current_size) { + response->mutable_pusch_data_constellation()->DeleteSubrange(shrunk_size, current_size - shrunk_size); } - response->set_actual_array_size(actual_array_size); } + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -4682,9 +4831,8 @@ namespace nirfmxnr_grpc { int32 actual_array_size {}; while (true) { auto status = library_->ModAccFetchPUSCHDemodulatedBits(instrument, selector_string, timeout, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } std::vector bits(actual_array_size); auto array_size = actual_array_size; @@ -4693,8 +4841,10 @@ namespace nirfmxnr_grpc { // buffer is now too small, try again continue; } + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); - if (status_ok(status)) { response->mutable_bits()->Clear(); response->mutable_bits()->Reserve(actual_array_size); std::transform( @@ -4704,9 +4854,8 @@ namespace nirfmxnr_grpc { [&](auto x) { return x; }); - response->mutable_bits()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); - } + response->mutable_bits()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -4730,9 +4879,8 @@ namespace nirfmxnr_grpc { int32 actual_array_size {}; while (true) { auto status = library_->ModAccFetchPUSCHPTRSConstellationTrace(instrument, selector_string, timeout, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } std::vector pusch_ptrs_constellation(actual_array_size, NIComplexSingle()); auto array_size = actual_array_size; @@ -4741,18 +4889,19 @@ namespace nirfmxnr_grpc { // buffer is now too small, try again continue; } + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); - if (status_ok(status)) { - convert_to_grpc(pusch_ptrs_constellation, response->mutable_pusch_ptrs_constellation()); - { - auto shrunk_size = actual_array_size; - auto current_size = response->mutable_pusch_ptrs_constellation()->size(); - if (shrunk_size != current_size) { - response->mutable_pusch_ptrs_constellation()->DeleteSubrange(shrunk_size, current_size - shrunk_size); - } + convert_to_grpc(pusch_ptrs_constellation, response->mutable_pusch_ptrs_constellation()); + { + auto shrunk_size = actual_array_size; + auto current_size = response->mutable_pusch_ptrs_constellation()->size(); + if (shrunk_size != current_size) { + response->mutable_pusch_ptrs_constellation()->DeleteSubrange(shrunk_size, current_size - shrunk_size); } - response->set_actual_array_size(actual_array_size); } + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -4778,9 +4927,8 @@ namespace nirfmxnr_grpc { int32 actual_array_size {}; while (true) { auto status = library_->ModAccFetchPeakEVMPerSlotMaximumTrace(instrument, selector_string, timeout, &x0, &dx, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_peak_evm_per_slot_maximum()->Resize(actual_array_size, 0); float32* peak_evm_per_slot_maximum = response->mutable_peak_evm_per_slot_maximum()->mutable_data(); @@ -4790,13 +4938,14 @@ namespace nirfmxnr_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_x0(x0); - response->set_dx(dx); - response->mutable_peak_evm_per_slot_maximum()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_x0(x0); + response->set_dx(dx); + response->mutable_peak_evm_per_slot_maximum()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -4822,9 +4971,8 @@ namespace nirfmxnr_grpc { int32 actual_array_size {}; while (true) { auto status = library_->ModAccFetchPeakEVMPerSubcarrierMaximumTrace(instrument, selector_string, timeout, &x0, &dx, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_peak_evm_per_subcarrier_maximum()->Resize(actual_array_size, 0); float32* peak_evm_per_subcarrier_maximum = response->mutable_peak_evm_per_subcarrier_maximum()->mutable_data(); @@ -4834,13 +4982,14 @@ namespace nirfmxnr_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_x0(x0); - response->set_dx(dx); - response->mutable_peak_evm_per_subcarrier_maximum()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_x0(x0); + response->set_dx(dx); + response->mutable_peak_evm_per_subcarrier_maximum()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -4866,9 +5015,8 @@ namespace nirfmxnr_grpc { int32 actual_array_size {}; while (true) { auto status = library_->ModAccFetchPeakEVMPerSymbolMaximumTrace(instrument, selector_string, timeout, &x0, &dx, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_peak_evm_per_symbol_maximum()->Resize(actual_array_size, 0); float32* peak_evm_per_symbol_maximum = response->mutable_peak_evm_per_symbol_maximum()->mutable_data(); @@ -4878,13 +5026,14 @@ namespace nirfmxnr_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_x0(x0); - response->set_dx(dx); - response->mutable_peak_evm_per_symbol_maximum()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_x0(x0); + response->set_dx(dx); + response->mutable_peak_evm_per_symbol_maximum()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -4910,9 +5059,8 @@ namespace nirfmxnr_grpc { int32 actual_array_size {}; while (true) { auto status = library_->ModAccFetchRMSEVMHighPerSymbolMeanTrace(instrument, selector_string, timeout, &x0, &dx, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_rms_evm_high_per_symbol_mean()->Resize(actual_array_size, 0); float32* rms_evm_high_per_symbol_mean = response->mutable_rms_evm_high_per_symbol_mean()->mutable_data(); @@ -4922,13 +5070,14 @@ namespace nirfmxnr_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_x0(x0); - response->set_dx(dx); - response->mutable_rms_evm_high_per_symbol_mean()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_x0(x0); + response->set_dx(dx); + response->mutable_rms_evm_high_per_symbol_mean()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -4954,9 +5103,8 @@ namespace nirfmxnr_grpc { int32 actual_array_size {}; while (true) { auto status = library_->ModAccFetchRMSEVMLowPerSymbolMeanTrace(instrument, selector_string, timeout, &x0, &dx, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_rms_evm_low_per_symbol_mean()->Resize(actual_array_size, 0); float32* rms_evm_low_per_symbol_mean = response->mutable_rms_evm_low_per_symbol_mean()->mutable_data(); @@ -4966,13 +5114,14 @@ namespace nirfmxnr_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_x0(x0); - response->set_dx(dx); - response->mutable_rms_evm_low_per_symbol_mean()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_x0(x0); + response->set_dx(dx); + response->mutable_rms_evm_low_per_symbol_mean()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -4998,9 +5147,8 @@ namespace nirfmxnr_grpc { int32 actual_array_size {}; while (true) { auto status = library_->ModAccFetchRMSEVMPerSlotMeanTrace(instrument, selector_string, timeout, &x0, &dx, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_rms_evm_per_slot_mean()->Resize(actual_array_size, 0); float32* rms_evm_per_slot_mean = response->mutable_rms_evm_per_slot_mean()->mutable_data(); @@ -5010,13 +5158,14 @@ namespace nirfmxnr_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_x0(x0); - response->set_dx(dx); - response->mutable_rms_evm_per_slot_mean()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_x0(x0); + response->set_dx(dx); + response->mutable_rms_evm_per_slot_mean()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -5042,9 +5191,8 @@ namespace nirfmxnr_grpc { int32 actual_array_size {}; while (true) { auto status = library_->ModAccFetchRMSEVMPerSubcarrierMeanTrace(instrument, selector_string, timeout, &x0, &dx, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_rms_evm_per_subcarrier_mean()->Resize(actual_array_size, 0); float32* rms_evm_per_subcarrier_mean = response->mutable_rms_evm_per_subcarrier_mean()->mutable_data(); @@ -5054,13 +5202,14 @@ namespace nirfmxnr_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_x0(x0); - response->set_dx(dx); - response->mutable_rms_evm_per_subcarrier_mean()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_x0(x0); + response->set_dx(dx); + response->mutable_rms_evm_per_subcarrier_mean()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -5086,9 +5235,8 @@ namespace nirfmxnr_grpc { int32 actual_array_size {}; while (true) { auto status = library_->ModAccFetchRMSEVMPerSymbolMeanTrace(instrument, selector_string, timeout, &x0, &dx, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_rms_evm_per_symbol_mean()->Resize(actual_array_size, 0); float32* rms_evm_per_symbol_mean = response->mutable_rms_evm_per_symbol_mean()->mutable_data(); @@ -5098,13 +5246,14 @@ namespace nirfmxnr_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_x0(x0); - response->set_dx(dx); - response->mutable_rms_evm_per_symbol_mean()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_x0(x0); + response->set_dx(dx); + response->mutable_rms_evm_per_symbol_mean()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -5128,9 +5277,8 @@ namespace nirfmxnr_grpc { int32 actual_array_size {}; while (true) { auto status = library_->ModAccFetchSSSConstellationTrace(instrument, selector_string, timeout, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } std::vector sss_constellation(actual_array_size, NIComplexSingle()); auto array_size = actual_array_size; @@ -5139,18 +5287,19 @@ namespace nirfmxnr_grpc { // buffer is now too small, try again continue; } + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); - if (status_ok(status)) { - convert_to_grpc(sss_constellation, response->mutable_sss_constellation()); - { - auto shrunk_size = actual_array_size; - auto current_size = response->mutable_sss_constellation()->size(); - if (shrunk_size != current_size) { - response->mutable_sss_constellation()->DeleteSubrange(shrunk_size, current_size - shrunk_size); - } + convert_to_grpc(sss_constellation, response->mutable_sss_constellation()); + { + auto shrunk_size = actual_array_size; + auto current_size = response->mutable_sss_constellation()->size(); + if (shrunk_size != current_size) { + response->mutable_sss_constellation()->DeleteSubrange(shrunk_size, current_size - shrunk_size); } - response->set_actual_array_size(actual_array_size); } + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -5176,9 +5325,8 @@ namespace nirfmxnr_grpc { int32 actual_array_size {}; while (true) { auto status = library_->ModAccFetchSSSRMSEVMPerSubcarrierMeanTrace(instrument, selector_string, timeout, &x0, &dx, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_sss_rms_evm_per_subcarrier_mean()->Resize(actual_array_size, 0); float32* sss_rms_evm_per_subcarrier_mean = response->mutable_sss_rms_evm_per_subcarrier_mean()->mutable_data(); @@ -5188,13 +5336,14 @@ namespace nirfmxnr_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_x0(x0); - response->set_dx(dx); - response->mutable_sss_rms_evm_per_subcarrier_mean()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_x0(x0); + response->set_dx(dx); + response->mutable_sss_rms_evm_per_subcarrier_mean()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -5220,9 +5369,8 @@ namespace nirfmxnr_grpc { int32 actual_array_size {}; while (true) { auto status = library_->ModAccFetchSSSRMSEVMPerSymbolMeanTrace(instrument, selector_string, timeout, &x0, &dx, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_sss_rms_evm_per_symbol_mean()->Resize(actual_array_size, 0); float32* sss_rms_evm_per_symbol_mean = response->mutable_sss_rms_evm_per_symbol_mean()->mutable_data(); @@ -5232,13 +5380,14 @@ namespace nirfmxnr_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_x0(x0); - response->set_dx(dx); - response->mutable_sss_rms_evm_per_symbol_mean()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_x0(x0); + response->set_dx(dx); + response->mutable_sss_rms_evm_per_symbol_mean()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -5264,9 +5413,8 @@ namespace nirfmxnr_grpc { int32 actual_array_size {}; while (true) { auto status = library_->ModAccFetchSpectralFlatnessTrace(instrument, selector_string, timeout, &x0, &dx, nullptr, nullptr, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_spectral_flatness()->Resize(actual_array_size, 0); float32* spectral_flatness = response->mutable_spectral_flatness()->mutable_data(); @@ -5280,15 +5428,16 @@ namespace nirfmxnr_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_x0(x0); - response->set_dx(dx); - response->mutable_spectral_flatness()->Resize(actual_array_size, 0); - response->mutable_spectral_flatness_lower_mask()->Resize(actual_array_size, 0); - response->mutable_spectral_flatness_upper_mask()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_x0(x0); + response->set_dx(dx); + response->mutable_spectral_flatness()->Resize(actual_array_size, 0); + response->mutable_spectral_flatness_lower_mask()->Resize(actual_array_size, 0); + response->mutable_spectral_flatness_upper_mask()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -5312,9 +5461,8 @@ namespace nirfmxnr_grpc { int32 actual_array_size {}; while (true) { auto status = library_->ModAccFetchSubblockInBandEmissionTrace(instrument, selector_string, timeout, nullptr, nullptr, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_subblock_in_band_emission()->Resize(actual_array_size, 0); float64* subblock_in_band_emission = response->mutable_subblock_in_band_emission()->mutable_data(); @@ -5328,13 +5476,14 @@ namespace nirfmxnr_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->mutable_subblock_in_band_emission()->Resize(actual_array_size, 0); - response->mutable_subblock_in_band_emission_mask()->Resize(actual_array_size, 0); - response->mutable_subblock_in_band_emission_rb_indices()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->mutable_subblock_in_band_emission()->Resize(actual_array_size, 0); + response->mutable_subblock_in_band_emission_mask()->Resize(actual_array_size, 0); + response->mutable_subblock_in_band_emission_rb_indices()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -5356,11 +5505,12 @@ namespace nirfmxnr_grpc { char* selector_string = (char*)request->selector_string().c_str(); int32 calibration_data_valid {}; auto status = library_->ModAccValidateCalibrationData(instrument, selector_string, &calibration_data_valid); - response->set_status(status); - if (status_ok(status)) { - response->set_calibration_data_valid(static_cast(calibration_data_valid)); - response->set_calibration_data_valid_raw(calibration_data_valid); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_calibration_data_valid(static_cast(calibration_data_valid)); + response->set_calibration_data_valid_raw(calibration_data_valid); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -5413,6 +5563,9 @@ namespace nirfmxnr_grpc { } auto status = library_->OBWCfgAveraging(instrument, selector_string, averaging_enabled, averaging_count, averaging_type); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -5466,6 +5619,9 @@ namespace nirfmxnr_grpc { } auto status = library_->OBWCfgRBWFilter(instrument, selector_string, rbw_auto, rbw, rbw_filter_type); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -5503,6 +5659,9 @@ namespace nirfmxnr_grpc { float64 sweep_time_interval = request->sweep_time_interval(); auto status = library_->OBWCfgSweepTime(instrument, selector_string, sweep_time_auto, sweep_time_interval); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -5528,13 +5687,14 @@ namespace nirfmxnr_grpc { float64 start_frequency {}; float64 stop_frequency {}; auto status = library_->OBWFetchMeasurement(instrument, selector_string, timeout, &occupied_bandwidth, &absolute_power, &start_frequency, &stop_frequency); - response->set_status(status); - if (status_ok(status)) { - response->set_occupied_bandwidth(occupied_bandwidth); - response->set_absolute_power(absolute_power); - response->set_start_frequency(start_frequency); - response->set_stop_frequency(stop_frequency); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_occupied_bandwidth(occupied_bandwidth); + response->set_absolute_power(absolute_power); + response->set_start_frequency(start_frequency); + response->set_stop_frequency(stop_frequency); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -5559,9 +5719,8 @@ namespace nirfmxnr_grpc { int32 actual_array_size {}; while (true) { auto status = library_->OBWFetchSpectrum(instrument, selector_string, timeout, &x0, &dx, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_spectrum()->Resize(actual_array_size, 0); float32* spectrum = response->mutable_spectrum()->mutable_data(); @@ -5571,13 +5730,14 @@ namespace nirfmxnr_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_x0(x0); - response->set_dx(dx); - response->mutable_spectrum()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_x0(x0); + response->set_dx(dx); + response->mutable_spectrum()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -5631,6 +5791,9 @@ namespace nirfmxnr_grpc { } auto status = library_->PVTCfgAveraging(instrument, selector_string, averaging_enabled, averaging_count, averaging_type); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -5667,6 +5830,9 @@ namespace nirfmxnr_grpc { } auto status = library_->PVTCfgMeasurementMethod(instrument, selector_string, measurement_method); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -5689,6 +5855,9 @@ namespace nirfmxnr_grpc { float64 off_power_exclusion_before = request->off_power_exclusion_before(); float64 off_power_exclusion_after = request->off_power_exclusion_after(); auto status = library_->PVTCfgOFFPowerExclusionPeriods(instrument, selector_string, off_power_exclusion_before, off_power_exclusion_after); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -5715,15 +5884,16 @@ namespace nirfmxnr_grpc { float64 absolute_on_power {}; float64 burst_width {}; auto status = library_->PVTFetchMeasurement(instrument, selector_string, timeout, &measurement_status, &absolute_off_power_before, &absolute_off_power_after, &absolute_on_power, &burst_width); - response->set_status(status); - if (status_ok(status)) { - response->set_measurement_status(static_cast(measurement_status)); - response->set_measurement_status_raw(measurement_status); - response->set_absolute_off_power_before(absolute_off_power_before); - response->set_absolute_off_power_after(absolute_off_power_after); - response->set_absolute_on_power(absolute_on_power); - response->set_burst_width(burst_width); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_measurement_status(static_cast(measurement_status)); + response->set_measurement_status_raw(measurement_status); + response->set_absolute_off_power_before(absolute_off_power_before); + response->set_absolute_off_power_after(absolute_off_power_after); + response->set_absolute_on_power(absolute_on_power); + response->set_burst_width(burst_width); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -5746,9 +5916,8 @@ namespace nirfmxnr_grpc { int32 actual_array_size {}; while (true) { auto status = library_->PVTFetchMeasurementArray(instrument, selector_string, timeout, nullptr, nullptr, nullptr, nullptr, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_measurement_status_raw()->Resize(actual_array_size, 0); int32* measurement_status = reinterpret_cast(response->mutable_measurement_status_raw()->mutable_data()); @@ -5766,8 +5935,10 @@ namespace nirfmxnr_grpc { // buffer is now too small, try again continue; } + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); - if (status_ok(status)) { response->mutable_measurement_status()->Clear(); response->mutable_measurement_status()->Reserve(actual_array_size); std::transform( @@ -5777,13 +5948,12 @@ namespace nirfmxnr_grpc { [&](auto x) { return static_cast(x); }); - response->mutable_measurement_status()->Resize(actual_array_size, 0); - response->mutable_absolute_off_power_before()->Resize(actual_array_size, 0); - response->mutable_absolute_off_power_after()->Resize(actual_array_size, 0); - response->mutable_absolute_on_power()->Resize(actual_array_size, 0); - response->mutable_burst_width()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); - } + response->mutable_measurement_status()->Resize(actual_array_size, 0); + response->mutable_absolute_off_power_before()->Resize(actual_array_size, 0); + response->mutable_absolute_off_power_after()->Resize(actual_array_size, 0); + response->mutable_absolute_on_power()->Resize(actual_array_size, 0); + response->mutable_burst_width()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -5809,9 +5979,8 @@ namespace nirfmxnr_grpc { int32 actual_array_size {}; while (true) { auto status = library_->PVTFetchSignalPowerTrace(instrument, selector_string, timeout, &x0, &dx, nullptr, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_signal_power()->Resize(actual_array_size, 0); float32* signal_power = response->mutable_signal_power()->mutable_data(); @@ -5823,14 +5992,15 @@ namespace nirfmxnr_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_x0(x0); - response->set_dx(dx); - response->mutable_signal_power()->Resize(actual_array_size, 0); - response->mutable_absolute_limit()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_x0(x0); + response->set_dx(dx); + response->mutable_signal_power()->Resize(actual_array_size, 0); + response->mutable_absolute_limit()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -5856,9 +6026,8 @@ namespace nirfmxnr_grpc { int32 actual_array_size {}; while (true) { auto status = library_->PVTFetchWindowedSignalPowerTrace(instrument, selector_string, timeout, &x0, &dx, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_windowed_signal_power()->Resize(actual_array_size, 0); float32* windowed_signal_power = response->mutable_windowed_signal_power()->mutable_data(); @@ -5868,13 +6037,14 @@ namespace nirfmxnr_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_x0(x0); - response->set_dx(dx); - response->mutable_windowed_signal_power()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_x0(x0); + response->set_dx(dx); + response->mutable_windowed_signal_power()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -5896,6 +6066,9 @@ namespace nirfmxnr_grpc { char* selector_string = (char*)request->selector_string().c_str(); int32 attribute_id = request->attribute_id(); auto status = library_->ResetAttribute(instrument, selector_string, attribute_id); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -5916,6 +6089,9 @@ namespace nirfmxnr_grpc { niRFmxInstrHandle instrument = session_repository_->access_session(instrument_grpc_session.id(), instrument_grpc_session.name()); char* selector_string = (char*)request->selector_string().c_str(); auto status = library_->ResetToDefault(instrument, selector_string); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -5969,6 +6145,9 @@ namespace nirfmxnr_grpc { } auto status = library_->SEMCfgAveraging(instrument, selector_string, averaging_enabled, averaging_count, averaging_type); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -5990,6 +6169,9 @@ namespace nirfmxnr_grpc { char* selector_string = (char*)request->selector_string().c_str(); float64 component_carrier_rated_output_power = request->component_carrier_rated_output_power(); auto status = library_->SEMCfgComponentCarrierRatedOutputPower(instrument, selector_string, component_carrier_rated_output_power); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -6012,6 +6194,9 @@ namespace nirfmxnr_grpc { auto component_carrier_rated_output_power = const_cast(request->component_carrier_rated_output_power().data()); int32 number_of_elements = static_cast(request->component_carrier_rated_output_power().size()); auto status = library_->SEMCfgComponentCarrierRatedOutputPowerArray(instrument, selector_string, component_carrier_rated_output_power, number_of_elements); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -6033,6 +6218,9 @@ namespace nirfmxnr_grpc { char* selector_string = (char*)request->selector_string().c_str(); int32 number_of_offsets = request->number_of_offsets(); auto status = library_->SEMCfgNumberOfOffsets(instrument, selector_string, number_of_offsets); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -6055,6 +6243,9 @@ namespace nirfmxnr_grpc { float64 absolute_limit_start = request->absolute_limit_start(); float64 absolute_limit_stop = request->absolute_limit_stop(); auto status = library_->SEMCfgOffsetAbsoluteLimit(instrument, selector_string, absolute_limit_start, absolute_limit_stop); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -6094,6 +6285,9 @@ namespace nirfmxnr_grpc { auto number_of_elements = number_of_elements_size_calculation.size; auto status = library_->SEMCfgOffsetAbsoluteLimitArray(instrument, selector_string, absolute_limit_start, absolute_limit_stop, number_of_elements); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -6115,6 +6309,9 @@ namespace nirfmxnr_grpc { char* selector_string = (char*)request->selector_string().c_str(); int32 bandwidth_integral = request->bandwidth_integral(); auto status = library_->SEMCfgOffsetBandwidthIntegral(instrument, selector_string, bandwidth_integral); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -6137,6 +6334,9 @@ namespace nirfmxnr_grpc { auto bandwidth_integral = const_cast(reinterpret_cast(request->bandwidth_integral().data())); int32 number_of_elements = static_cast(request->bandwidth_integral().size()); auto status = library_->SEMCfgOffsetBandwidthIntegralArray(instrument, selector_string, bandwidth_integral, number_of_elements); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -6175,6 +6375,9 @@ namespace nirfmxnr_grpc { } auto status = library_->SEMCfgOffsetFrequency(instrument, selector_string, offset_start_frequency, offset_stop_frequency, offset_sideband); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -6225,6 +6428,9 @@ namespace nirfmxnr_grpc { auto number_of_elements = number_of_elements_size_calculation.size; auto status = library_->SEMCfgOffsetFrequencyArray(instrument, selector_string, offset_start_frequency, offset_stop_frequency, offset_sideband, number_of_elements); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -6261,6 +6467,9 @@ namespace nirfmxnr_grpc { } auto status = library_->SEMCfgOffsetLimitFailMask(instrument, selector_string, limit_fail_mask); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -6291,6 +6500,9 @@ namespace nirfmxnr_grpc { int32 number_of_elements = static_cast(request->limit_fail_mask().size()); auto status = library_->SEMCfgOffsetLimitFailMaskArray(instrument, selector_string, limit_fail_mask, number_of_elements); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -6328,6 +6540,9 @@ namespace nirfmxnr_grpc { } auto status = library_->SEMCfgOffsetRBWFilter(instrument, selector_string, offset_rbw, offset_rbw_filter_type); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -6375,6 +6590,9 @@ namespace nirfmxnr_grpc { auto number_of_elements = number_of_elements_size_calculation.size; auto status = library_->SEMCfgOffsetRBWFilterArray(instrument, selector_string, offset_rbw, offset_rbw_filter_type, number_of_elements); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -6397,6 +6615,9 @@ namespace nirfmxnr_grpc { float64 relative_limit_start = request->relative_limit_start(); float64 relative_limit_stop = request->relative_limit_stop(); auto status = library_->SEMCfgOffsetRelativeLimit(instrument, selector_string, relative_limit_start, relative_limit_stop); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -6436,6 +6657,9 @@ namespace nirfmxnr_grpc { auto number_of_elements = number_of_elements_size_calculation.size; auto status = library_->SEMCfgOffsetRelativeLimitArray(instrument, selector_string, relative_limit_start, relative_limit_stop, number_of_elements); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -6473,6 +6697,9 @@ namespace nirfmxnr_grpc { float64 sweep_time_interval = request->sweep_time_interval(); auto status = library_->SEMCfgSweepTime(instrument, selector_string, sweep_time_auto, sweep_time_interval); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -6509,6 +6736,9 @@ namespace nirfmxnr_grpc { } auto status = library_->SEMCfgUplinkMaskType(instrument, selector_string, uplink_mask_type); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -6534,13 +6764,14 @@ namespace nirfmxnr_grpc { float64 peak_frequency {}; float64 relative_power {}; auto status = library_->SEMFetchComponentCarrierMeasurement(instrument, selector_string, timeout, &absolute_power, &peak_absolute_power, &peak_frequency, &relative_power); - response->set_status(status); - if (status_ok(status)) { - response->set_absolute_power(absolute_power); - response->set_peak_absolute_power(peak_absolute_power); - response->set_peak_frequency(peak_frequency); - response->set_relative_power(relative_power); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_absolute_power(absolute_power); + response->set_peak_absolute_power(peak_absolute_power); + response->set_peak_frequency(peak_frequency); + response->set_relative_power(relative_power); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -6563,9 +6794,8 @@ namespace nirfmxnr_grpc { int32 actual_array_size {}; while (true) { auto status = library_->SEMFetchComponentCarrierMeasurementArray(instrument, selector_string, timeout, nullptr, nullptr, nullptr, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_absolute_power()->Resize(actual_array_size, 0); float64* absolute_power = response->mutable_absolute_power()->mutable_data(); @@ -6581,14 +6811,15 @@ namespace nirfmxnr_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->mutable_absolute_power()->Resize(actual_array_size, 0); - response->mutable_peak_absolute_power()->Resize(actual_array_size, 0); - response->mutable_peak_frequency()->Resize(actual_array_size, 0); - response->mutable_relative_power()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->mutable_absolute_power()->Resize(actual_array_size, 0); + response->mutable_peak_absolute_power()->Resize(actual_array_size, 0); + response->mutable_peak_frequency()->Resize(actual_array_size, 0); + response->mutable_relative_power()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -6615,15 +6846,16 @@ namespace nirfmxnr_grpc { float64 margin_absolute_power {}; float64 margin_relative_power {}; auto status = library_->SEMFetchLowerOffsetMargin(instrument, selector_string, timeout, &measurement_status, &margin, &margin_frequency, &margin_absolute_power, &margin_relative_power); - response->set_status(status); - if (status_ok(status)) { - response->set_measurement_status(static_cast(measurement_status)); - response->set_measurement_status_raw(measurement_status); - response->set_margin(margin); - response->set_margin_frequency(margin_frequency); - response->set_margin_absolute_power(margin_absolute_power); - response->set_margin_relative_power(margin_relative_power); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_measurement_status(static_cast(measurement_status)); + response->set_measurement_status_raw(measurement_status); + response->set_margin(margin); + response->set_margin_frequency(margin_frequency); + response->set_margin_absolute_power(margin_absolute_power); + response->set_margin_relative_power(margin_relative_power); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -6646,9 +6878,8 @@ namespace nirfmxnr_grpc { int32 actual_array_size {}; while (true) { auto status = library_->SEMFetchLowerOffsetMarginArray(instrument, selector_string, timeout, nullptr, nullptr, nullptr, nullptr, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_measurement_status_raw()->Resize(actual_array_size, 0); int32* measurement_status = reinterpret_cast(response->mutable_measurement_status_raw()->mutable_data()); @@ -6666,8 +6897,10 @@ namespace nirfmxnr_grpc { // buffer is now too small, try again continue; } + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); - if (status_ok(status)) { response->mutable_measurement_status()->Clear(); response->mutable_measurement_status()->Reserve(actual_array_size); std::transform( @@ -6677,13 +6910,12 @@ namespace nirfmxnr_grpc { [&](auto x) { return static_cast(x); }); - response->mutable_measurement_status()->Resize(actual_array_size, 0); - response->mutable_margin()->Resize(actual_array_size, 0); - response->mutable_margin_frequency()->Resize(actual_array_size, 0); - response->mutable_margin_absolute_power()->Resize(actual_array_size, 0); - response->mutable_margin_relative_power()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); - } + response->mutable_measurement_status()->Resize(actual_array_size, 0); + response->mutable_margin()->Resize(actual_array_size, 0); + response->mutable_margin_frequency()->Resize(actual_array_size, 0); + response->mutable_margin_absolute_power()->Resize(actual_array_size, 0); + response->mutable_margin_relative_power()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -6710,14 +6942,15 @@ namespace nirfmxnr_grpc { float64 peak_frequency {}; float64 peak_relative_power {}; auto status = library_->SEMFetchLowerOffsetPower(instrument, selector_string, timeout, &total_absolute_power, &total_relative_power, &peak_absolute_power, &peak_frequency, &peak_relative_power); - response->set_status(status); - if (status_ok(status)) { - response->set_total_absolute_power(total_absolute_power); - response->set_total_relative_power(total_relative_power); - response->set_peak_absolute_power(peak_absolute_power); - response->set_peak_frequency(peak_frequency); - response->set_peak_relative_power(peak_relative_power); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_total_absolute_power(total_absolute_power); + response->set_total_relative_power(total_relative_power); + response->set_peak_absolute_power(peak_absolute_power); + response->set_peak_frequency(peak_frequency); + response->set_peak_relative_power(peak_relative_power); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -6740,9 +6973,8 @@ namespace nirfmxnr_grpc { int32 actual_array_size {}; while (true) { auto status = library_->SEMFetchLowerOffsetPowerArray(instrument, selector_string, timeout, nullptr, nullptr, nullptr, nullptr, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_total_absolute_power()->Resize(actual_array_size, 0); float64* total_absolute_power = response->mutable_total_absolute_power()->mutable_data(); @@ -6760,15 +6992,16 @@ namespace nirfmxnr_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->mutable_total_absolute_power()->Resize(actual_array_size, 0); - response->mutable_total_relative_power()->Resize(actual_array_size, 0); - response->mutable_peak_absolute_power()->Resize(actual_array_size, 0); - response->mutable_peak_frequency()->Resize(actual_array_size, 0); - response->mutable_peak_relative_power()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->mutable_total_absolute_power()->Resize(actual_array_size, 0); + response->mutable_total_relative_power()->Resize(actual_array_size, 0); + response->mutable_peak_absolute_power()->Resize(actual_array_size, 0); + response->mutable_peak_frequency()->Resize(actual_array_size, 0); + response->mutable_peak_relative_power()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -6791,11 +7024,12 @@ namespace nirfmxnr_grpc { float64 timeout = request->timeout(); int32 measurement_status {}; auto status = library_->SEMFetchMeasurementStatus(instrument, selector_string, timeout, &measurement_status); - response->set_status(status); - if (status_ok(status)) { - response->set_measurement_status(static_cast(measurement_status)); - response->set_measurement_status_raw(measurement_status); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_measurement_status(static_cast(measurement_status)); + response->set_measurement_status_raw(measurement_status); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -6820,9 +7054,8 @@ namespace nirfmxnr_grpc { int32 actual_array_size {}; while (true) { auto status = library_->SEMFetchSpectrum(instrument, selector_string, timeout, &x0, &dx, nullptr, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_spectrum()->Resize(actual_array_size, 0); float32* spectrum = response->mutable_spectrum()->mutable_data(); @@ -6834,14 +7067,15 @@ namespace nirfmxnr_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_x0(x0); - response->set_dx(dx); - response->mutable_spectrum()->Resize(actual_array_size, 0); - response->mutable_composite_mask()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_x0(x0); + response->set_dx(dx); + response->mutable_spectrum()->Resize(actual_array_size, 0); + response->mutable_composite_mask()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -6866,12 +7100,13 @@ namespace nirfmxnr_grpc { float64 integration_bandwidth {}; float64 frequency {}; auto status = library_->SEMFetchSubblockMeasurement(instrument, selector_string, timeout, &subblock_power, &integration_bandwidth, &frequency); - response->set_status(status); - if (status_ok(status)) { - response->set_subblock_power(subblock_power); - response->set_integration_bandwidth(integration_bandwidth); - response->set_frequency(frequency); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_subblock_power(subblock_power); + response->set_integration_bandwidth(integration_bandwidth); + response->set_frequency(frequency); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -6893,10 +7128,11 @@ namespace nirfmxnr_grpc { float64 timeout = request->timeout(); float64 total_aggregated_power {}; auto status = library_->SEMFetchTotalAggregatedPower(instrument, selector_string, timeout, &total_aggregated_power); - response->set_status(status); - if (status_ok(status)) { - response->set_total_aggregated_power(total_aggregated_power); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_total_aggregated_power(total_aggregated_power); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -6922,15 +7158,16 @@ namespace nirfmxnr_grpc { float64 margin_absolute_power {}; float64 margin_relative_power {}; auto status = library_->SEMFetchUpperOffsetMargin(instrument, selector_string, timeout, &measurement_status, &margin, &margin_frequency, &margin_absolute_power, &margin_relative_power); - response->set_status(status); - if (status_ok(status)) { - response->set_measurement_status(static_cast(measurement_status)); - response->set_measurement_status_raw(measurement_status); - response->set_margin(margin); - response->set_margin_frequency(margin_frequency); - response->set_margin_absolute_power(margin_absolute_power); - response->set_margin_relative_power(margin_relative_power); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_measurement_status(static_cast(measurement_status)); + response->set_measurement_status_raw(measurement_status); + response->set_margin(margin); + response->set_margin_frequency(margin_frequency); + response->set_margin_absolute_power(margin_absolute_power); + response->set_margin_relative_power(margin_relative_power); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -6953,9 +7190,8 @@ namespace nirfmxnr_grpc { int32 actual_array_size {}; while (true) { auto status = library_->SEMFetchUpperOffsetMarginArray(instrument, selector_string, timeout, nullptr, nullptr, nullptr, nullptr, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_measurement_status_raw()->Resize(actual_array_size, 0); int32* measurement_status = reinterpret_cast(response->mutable_measurement_status_raw()->mutable_data()); @@ -6973,8 +7209,10 @@ namespace nirfmxnr_grpc { // buffer is now too small, try again continue; } + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); - if (status_ok(status)) { response->mutable_measurement_status()->Clear(); response->mutable_measurement_status()->Reserve(actual_array_size); std::transform( @@ -6984,13 +7222,12 @@ namespace nirfmxnr_grpc { [&](auto x) { return static_cast(x); }); - response->mutable_measurement_status()->Resize(actual_array_size, 0); - response->mutable_margin()->Resize(actual_array_size, 0); - response->mutable_margin_frequency()->Resize(actual_array_size, 0); - response->mutable_margin_absolute_power()->Resize(actual_array_size, 0); - response->mutable_margin_relative_power()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); - } + response->mutable_measurement_status()->Resize(actual_array_size, 0); + response->mutable_margin()->Resize(actual_array_size, 0); + response->mutable_margin_frequency()->Resize(actual_array_size, 0); + response->mutable_margin_absolute_power()->Resize(actual_array_size, 0); + response->mutable_margin_relative_power()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -7017,14 +7254,15 @@ namespace nirfmxnr_grpc { float64 peak_frequency {}; float64 peak_relative_power {}; auto status = library_->SEMFetchUpperOffsetPower(instrument, selector_string, timeout, &total_absolute_power, &total_relative_power, &peak_absolute_power, &peak_frequency, &peak_relative_power); - response->set_status(status); - if (status_ok(status)) { - response->set_total_absolute_power(total_absolute_power); - response->set_total_relative_power(total_relative_power); - response->set_peak_absolute_power(peak_absolute_power); - response->set_peak_frequency(peak_frequency); - response->set_peak_relative_power(peak_relative_power); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_total_absolute_power(total_absolute_power); + response->set_total_relative_power(total_relative_power); + response->set_peak_absolute_power(peak_absolute_power); + response->set_peak_frequency(peak_frequency); + response->set_peak_relative_power(peak_relative_power); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -7047,9 +7285,8 @@ namespace nirfmxnr_grpc { int32 actual_array_size {}; while (true) { auto status = library_->SEMFetchUpperOffsetPowerArray(instrument, selector_string, timeout, nullptr, nullptr, nullptr, nullptr, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_total_absolute_power()->Resize(actual_array_size, 0); float64* total_absolute_power = response->mutable_total_absolute_power()->mutable_data(); @@ -7067,15 +7304,16 @@ namespace nirfmxnr_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->mutable_total_absolute_power()->Resize(actual_array_size, 0); - response->mutable_total_relative_power()->Resize(actual_array_size, 0); - response->mutable_peak_absolute_power()->Resize(actual_array_size, 0); - response->mutable_peak_frequency()->Resize(actual_array_size, 0); - response->mutable_peak_relative_power()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->mutable_total_absolute_power()->Resize(actual_array_size, 0); + response->mutable_total_relative_power()->Resize(actual_array_size, 0); + response->mutable_peak_absolute_power()->Resize(actual_array_size, 0); + response->mutable_peak_frequency()->Resize(actual_array_size, 0); + response->mutable_peak_relative_power()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -7113,6 +7351,9 @@ namespace nirfmxnr_grpc { int32 enable_all_traces = request->enable_all_traces(); auto status = library_->SelectMeasurements(instrument, selector_string, measurements, enable_all_traces); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -7132,6 +7373,9 @@ namespace nirfmxnr_grpc { auto instrument_grpc_session = request->instrument(); niRFmxInstrHandle instrument = session_repository_->access_session(instrument_grpc_session.id(), instrument_grpc_session.name()); auto status = library_->SendSoftwareEdgeTrigger(instrument); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -7154,6 +7398,9 @@ namespace nirfmxnr_grpc { int32 attribute_id = request->attribute_id(); float32 attr_val = request->attr_val(); auto status = library_->SetAttributeF32(instrument, selector_string, attribute_id, attr_val); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -7177,6 +7424,9 @@ namespace nirfmxnr_grpc { auto attr_val = const_cast(request->attr_val().data()); int32 array_size = static_cast(request->attr_val().size()); auto status = library_->SetAttributeF32Array(instrument, selector_string, attribute_id, attr_val, array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -7199,6 +7449,9 @@ namespace nirfmxnr_grpc { int32 attribute_id = request->attribute_id(); float64 attr_val = request->attr_val(); auto status = library_->SetAttributeF64(instrument, selector_string, attribute_id, attr_val); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -7222,6 +7475,9 @@ namespace nirfmxnr_grpc { auto attr_val = const_cast(request->attr_val().data()); int32 array_size = static_cast(request->attr_val().size()); auto status = library_->SetAttributeF64Array(instrument, selector_string, attribute_id, attr_val, array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -7253,6 +7509,9 @@ namespace nirfmxnr_grpc { auto attr_val = static_cast(attr_val_raw); auto status = library_->SetAttributeI16(instrument, selector_string, attribute_id, attr_val); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -7293,6 +7552,9 @@ namespace nirfmxnr_grpc { } auto status = library_->SetAttributeI32(instrument, selector_string, attribute_id, attr_val); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -7324,6 +7586,9 @@ namespace nirfmxnr_grpc { int32 array_size = static_cast(request->attr_val().size()); auto status = library_->SetAttributeI32Array(instrument, selector_string, attribute_id, attr_val, array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -7346,6 +7611,9 @@ namespace nirfmxnr_grpc { int32 attribute_id = request->attribute_id(); int64 attr_val = request->attr_val(); auto status = library_->SetAttributeI64(instrument, selector_string, attribute_id, attr_val); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -7369,6 +7637,9 @@ namespace nirfmxnr_grpc { auto attr_val = const_cast(reinterpret_cast(request->attr_val().data())); int32 array_size = static_cast(request->attr_val().size()); auto status = library_->SetAttributeI64Array(instrument, selector_string, attribute_id, attr_val, array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -7400,6 +7671,9 @@ namespace nirfmxnr_grpc { auto attr_val = static_cast(attr_val_raw); auto status = library_->SetAttributeI8(instrument, selector_string, attribute_id, attr_val); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -7443,6 +7717,9 @@ namespace nirfmxnr_grpc { int32 array_size = static_cast(request->attr_val().size()); auto status = library_->SetAttributeI8Array(instrument, selector_string, attribute_id, attr_val.data(), array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -7469,6 +7746,9 @@ namespace nirfmxnr_grpc { auto attr_val = convert_from_grpc(request->attr_val()); int32 array_size = static_cast(request->attr_val().size()); auto status = library_->SetAttributeNIComplexDoubleArray(instrument, selector_string, attribute_id, attr_val.data(), array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -7492,6 +7772,9 @@ namespace nirfmxnr_grpc { auto attr_val = convert_from_grpc(request->attr_val()); int32 array_size = static_cast(request->attr_val().size()); auto status = library_->SetAttributeNIComplexSingleArray(instrument, selector_string, attribute_id, attr_val.data(), array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -7533,6 +7816,9 @@ namespace nirfmxnr_grpc { } auto status = library_->SetAttributeString(instrument, selector_string, attribute_id, attr_val); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -7564,6 +7850,9 @@ namespace nirfmxnr_grpc { auto attr_val = static_cast(attr_val_raw); auto status = library_->SetAttributeU16(instrument, selector_string, attribute_id, attr_val); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -7589,6 +7878,9 @@ namespace nirfmxnr_grpc { int32 attribute_id = request->attribute_id(); uInt32 attr_val = request->attr_val(); auto status = library_->SetAttributeU32(instrument, selector_string, attribute_id, attr_val); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -7612,6 +7904,9 @@ namespace nirfmxnr_grpc { auto attr_val = const_cast(reinterpret_cast(request->attr_val().data())); int32 array_size = static_cast(request->attr_val().size()); auto status = library_->SetAttributeU32Array(instrument, selector_string, attribute_id, attr_val, array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -7635,6 +7930,9 @@ namespace nirfmxnr_grpc { auto attr_val = const_cast(reinterpret_cast(request->attr_val().data())); int32 array_size = static_cast(request->attr_val().size()); auto status = library_->SetAttributeU64Array(instrument, selector_string, attribute_id, attr_val, array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -7657,6 +7955,9 @@ namespace nirfmxnr_grpc { int32 attribute_id = request->attribute_id(); uInt8 attr_val = request->attr_val(); auto status = library_->SetAttributeU8(instrument, selector_string, attribute_id, attr_val); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -7680,6 +7981,9 @@ namespace nirfmxnr_grpc { uInt8* attr_val = (uInt8*)request->attr_val().c_str(); int32 array_size = static_cast(request->attr_val().size()); auto status = library_->SetAttributeU8Array(instrument, selector_string, attribute_id, attr_val, array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -7703,11 +8007,12 @@ namespace nirfmxnr_grpc { float64 average_power_mean {}; float64 peak_power_maximum {}; auto status = library_->TXPFetchMeasurement(instrument, selector_string, timeout, &average_power_mean, &peak_power_maximum); - response->set_status(status); - if (status_ok(status)) { - response->set_average_power_mean(average_power_mean); - response->set_peak_power_maximum(peak_power_maximum); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_average_power_mean(average_power_mean); + response->set_peak_power_maximum(peak_power_maximum); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -7732,9 +8037,8 @@ namespace nirfmxnr_grpc { int32 actual_array_size {}; while (true) { auto status = library_->TXPFetchPowerTrace(instrument, selector_string, timeout, &x0, &dx, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_power()->Resize(actual_array_size, 0); float32* power = response->mutable_power()->mutable_data(); @@ -7744,13 +8048,14 @@ namespace nirfmxnr_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_x0(x0); - response->set_dx(dx); - response->mutable_power()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_x0(x0); + response->set_dx(dx); + response->mutable_power()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -7771,6 +8076,9 @@ namespace nirfmxnr_grpc { niRFmxInstrHandle instrument = session_repository_->access_session(instrument_grpc_session.id(), instrument_grpc_session.name()); float64 timeout = request->timeout(); auto status = library_->WaitForAcquisitionComplete(instrument, timeout); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -7792,6 +8100,9 @@ namespace nirfmxnr_grpc { char* selector_string = (char*)request->selector_string().c_str(); float64 timeout = request->timeout(); auto status = library_->WaitForMeasurementComplete(instrument, selector_string, timeout); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } diff --git a/generated/nirfmxnr/nirfmxnr_service.h b/generated/nirfmxnr/nirfmxnr_service.h index 8a2d938ee..feac307dc 100644 --- a/generated/nirfmxnr/nirfmxnr_service.h +++ b/generated/nirfmxnr/nirfmxnr_service.h @@ -264,6 +264,7 @@ class NiRFmxNRService final : public NiRFmxNR::Service { NiRFmxNRLibraryInterface* library_; ResourceRepositorySharedPtr session_repository_; ViSessionResourceRepositorySharedPtr vi_session_resource_repository_; + ::grpc::Status ConvertApiErrorStatusForNiRFmxInstrHandle(google::protobuf::int32 status, niRFmxInstrHandle instrumentHandle); std::map digitaledgetriggersource_input_map_ { {1, "PFI0"},{2, "PFI1"},{3, "PXI_Trig0"},{4, "PXI_Trig1"},{5, "PXI_Trig2"},{6, "PXI_Trig3"},{7, "PXI_Trig4"},{8, "PXI_Trig5"},{9, "PXI_Trig6"},{10, "PXI_Trig7"},{11, "PXI_STAR"},{12, "PXIe_DStarB"},{13, "TimerEvent"}, }; std::map digitaledgetriggersource_output_map_ { {"PFI0", 1},{"PFI1", 2},{"PXI_Trig0", 3},{"PXI_Trig1", 4},{"PXI_Trig2", 5},{"PXI_Trig3", 6},{"PXI_Trig4", 7},{"PXI_Trig5", 8},{"PXI_Trig6", 9},{"PXI_Trig7", 10},{"PXI_STAR", 11},{"PXIe_DStarB", 12},{"TimerEvent", 13}, }; std::map frequencyreferencesource_input_map_ { {1, "OnboardClock"},{2, "RefIn"},{3, "PXI_Clk"},{4, "ClkIn"},{5, "RefIn2"},{6, "PXI_Clk_Master"}, }; diff --git a/generated/nirfmxspecan/nirfmxspecan_service.cpp b/generated/nirfmxspecan/nirfmxspecan_service.cpp index 80c385f49..081035f2a 100644 --- a/generated/nirfmxspecan/nirfmxspecan_service.cpp +++ b/generated/nirfmxspecan/nirfmxspecan_service.cpp @@ -92,6 +92,9 @@ namespace nirfmxspecan_grpc { } auto status = library_->ACPCfgAveraging(instrument, selector_string, averaging_enabled, averaging_count, averaging_type); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -115,6 +118,9 @@ namespace nirfmxspecan_grpc { int32 number_of_offsets = request->number_of_offsets(); float64 channel_spacing = request->channel_spacing(); auto status = library_->ACPCfgCarrierAndOffsets(instrument, selector_string, integration_bandwidth, number_of_offsets, channel_spacing); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -136,6 +142,9 @@ namespace nirfmxspecan_grpc { char* selector_string = (char*)request->selector_string().c_str(); float64 carrier_frequency = request->carrier_frequency(); auto status = library_->ACPCfgCarrierFrequency(instrument, selector_string, carrier_frequency); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -157,6 +166,9 @@ namespace nirfmxspecan_grpc { char* selector_string = (char*)request->selector_string().c_str(); float64 integration_bandwidth = request->integration_bandwidth(); auto status = library_->ACPCfgCarrierIntegrationBandwidth(instrument, selector_string, integration_bandwidth); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -193,6 +205,9 @@ namespace nirfmxspecan_grpc { } auto status = library_->ACPCfgCarrierMode(instrument, selector_string, carrier_mode); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -230,6 +245,9 @@ namespace nirfmxspecan_grpc { float64 rrc_alpha = request->rrc_alpha(); auto status = library_->ACPCfgCarrierRRCFilter(instrument, selector_string, rrc_filter_enabled, rrc_alpha); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -267,6 +285,9 @@ namespace nirfmxspecan_grpc { float64 fft_padding = request->fft_padding(); auto status = library_->ACPCfgFFT(instrument, selector_string, fft_window, fft_padding); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -303,6 +324,9 @@ namespace nirfmxspecan_grpc { } auto status = library_->ACPCfgMeasurementMethod(instrument, selector_string, measurement_method); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -339,6 +363,9 @@ namespace nirfmxspecan_grpc { } auto status = library_->ACPCfgNoiseCompensationEnabled(instrument, selector_string, noise_compensation_enabled); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -360,6 +387,9 @@ namespace nirfmxspecan_grpc { char* selector_string = (char*)request->selector_string().c_str(); int32 number_of_carriers = request->number_of_carriers(); auto status = library_->ACPCfgNumberOfCarriers(instrument, selector_string, number_of_carriers); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -381,6 +411,9 @@ namespace nirfmxspecan_grpc { char* selector_string = (char*)request->selector_string().c_str(); int32 number_of_offsets = request->number_of_offsets(); auto status = library_->ACPCfgNumberOfOffsets(instrument, selector_string, number_of_offsets); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -434,6 +467,9 @@ namespace nirfmxspecan_grpc { } auto status = library_->ACPCfgOffset(instrument, selector_string, offset_frequency, offset_sideband, offset_enabled); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -492,6 +528,9 @@ namespace nirfmxspecan_grpc { auto number_of_elements = number_of_elements_size_calculation.size; auto status = library_->ACPCfgOffsetArray(instrument, selector_string, offset_frequency, offset_sideband, offset_enabled, number_of_elements); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -528,6 +567,9 @@ namespace nirfmxspecan_grpc { } auto status = library_->ACPCfgOffsetFrequencyDefinition(instrument, selector_string, offset_frequency_definition); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -549,6 +591,9 @@ namespace nirfmxspecan_grpc { char* selector_string = (char*)request->selector_string().c_str(); float64 integration_bandwidth = request->integration_bandwidth(); auto status = library_->ACPCfgOffsetIntegrationBandwidth(instrument, selector_string, integration_bandwidth); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -571,6 +616,9 @@ namespace nirfmxspecan_grpc { auto integration_bandwidth = const_cast(request->integration_bandwidth().data()); int32 number_of_elements = static_cast(request->integration_bandwidth().size()); auto status = library_->ACPCfgOffsetIntegrationBandwidthArray(instrument, selector_string, integration_bandwidth, number_of_elements); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -608,6 +656,9 @@ namespace nirfmxspecan_grpc { int32 offset_reference_specific = request->offset_reference_specific(); auto status = library_->ACPCfgOffsetPowerReference(instrument, selector_string, offset_reference_carrier, offset_reference_specific); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -655,6 +706,9 @@ namespace nirfmxspecan_grpc { auto number_of_elements = number_of_elements_size_calculation.size; auto status = library_->ACPCfgOffsetPowerReferenceArray(instrument, selector_string, offset_power_reference_carrier, offset_power_reference_specific, number_of_elements); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -692,6 +746,9 @@ namespace nirfmxspecan_grpc { float64 rrc_alpha = request->rrc_alpha(); auto status = library_->ACPCfgOffsetRRCFilter(instrument, selector_string, rrc_filter_enabled, rrc_alpha); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -739,6 +796,9 @@ namespace nirfmxspecan_grpc { auto number_of_elements = number_of_elements_size_calculation.size; auto status = library_->ACPCfgOffsetRRCFilterArray(instrument, selector_string, rrc_filter_enabled, rrc_alpha, number_of_elements); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -760,6 +820,9 @@ namespace nirfmxspecan_grpc { char* selector_string = (char*)request->selector_string().c_str(); float64 relative_attenuation = request->relative_attenuation(); auto status = library_->ACPCfgOffsetRelativeAttenuation(instrument, selector_string, relative_attenuation); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -782,6 +845,9 @@ namespace nirfmxspecan_grpc { auto relative_attenuation = const_cast(request->relative_attenuation().data()); int32 number_of_elements = static_cast(request->relative_attenuation().size()); auto status = library_->ACPCfgOffsetRelativeAttenuationArray(instrument, selector_string, relative_attenuation, number_of_elements); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -818,6 +884,9 @@ namespace nirfmxspecan_grpc { } auto status = library_->ACPCfgPowerUnits(instrument, selector_string, power_units); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -871,6 +940,9 @@ namespace nirfmxspecan_grpc { } auto status = library_->ACPCfgRBWFilter(instrument, selector_string, rbw_auto, rbw, rbw_filter_type); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -908,6 +980,9 @@ namespace nirfmxspecan_grpc { float64 sweep_time_interval = request->sweep_time_interval(); auto status = library_->ACPCfgSweepTime(instrument, selector_string, sweep_time_auto, sweep_time_interval); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -934,9 +1009,8 @@ namespace nirfmxspecan_grpc { int32 actual_array_size {}; while (true) { auto status = library_->ACPFetchAbsolutePowersTrace(instrument, selector_string, timeout, trace_index, &x0, &dx, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_absolute_powers_trace()->Resize(actual_array_size, 0); float32* absolute_powers_trace = response->mutable_absolute_powers_trace()->mutable_data(); @@ -946,13 +1020,14 @@ namespace nirfmxspecan_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_x0(x0); - response->set_dx(dx); - response->mutable_absolute_powers_trace()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_x0(x0); + response->set_dx(dx); + response->mutable_absolute_powers_trace()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -978,13 +1053,14 @@ namespace nirfmxspecan_grpc { float64 carrier_offset {}; float64 integration_bandwidth {}; auto status = library_->ACPFetchCarrierMeasurement(instrument, selector_string, timeout, &absolute_power, &total_relative_power, &carrier_offset, &integration_bandwidth); - response->set_status(status); - if (status_ok(status)) { - response->set_absolute_power(absolute_power); - response->set_total_relative_power(total_relative_power); - response->set_carrier_offset(carrier_offset); - response->set_integration_bandwidth(integration_bandwidth); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_absolute_power(absolute_power); + response->set_total_relative_power(total_relative_power); + response->set_carrier_offset(carrier_offset); + response->set_integration_bandwidth(integration_bandwidth); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -1006,10 +1082,11 @@ namespace nirfmxspecan_grpc { float64 timeout = request->timeout(); float64 frequency_resolution {}; auto status = library_->ACPFetchFrequencyResolution(instrument, selector_string, timeout, &frequency_resolution); - response->set_status(status); - if (status_ok(status)) { - response->set_frequency_resolution(frequency_resolution); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_frequency_resolution(frequency_resolution); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -1034,13 +1111,14 @@ namespace nirfmxspecan_grpc { float64 lower_absolute_power {}; float64 upper_absolute_power {}; auto status = library_->ACPFetchOffsetMeasurement(instrument, selector_string, timeout, &lower_relative_power, &upper_relative_power, &lower_absolute_power, &upper_absolute_power); - response->set_status(status); - if (status_ok(status)) { - response->set_lower_relative_power(lower_relative_power); - response->set_upper_relative_power(upper_relative_power); - response->set_lower_absolute_power(lower_absolute_power); - response->set_upper_absolute_power(upper_absolute_power); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_lower_relative_power(lower_relative_power); + response->set_upper_relative_power(upper_relative_power); + response->set_lower_absolute_power(lower_absolute_power); + response->set_upper_absolute_power(upper_absolute_power); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -1063,9 +1141,8 @@ namespace nirfmxspecan_grpc { int32 actual_array_size {}; while (true) { auto status = library_->ACPFetchOffsetMeasurementArray(instrument, selector_string, timeout, nullptr, nullptr, nullptr, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_lower_relative_power()->Resize(actual_array_size, 0); float64* lower_relative_power = response->mutable_lower_relative_power()->mutable_data(); @@ -1081,14 +1158,15 @@ namespace nirfmxspecan_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->mutable_lower_relative_power()->Resize(actual_array_size, 0); - response->mutable_upper_relative_power()->Resize(actual_array_size, 0); - response->mutable_lower_absolute_power()->Resize(actual_array_size, 0); - response->mutable_upper_absolute_power()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->mutable_lower_relative_power()->Resize(actual_array_size, 0); + response->mutable_upper_relative_power()->Resize(actual_array_size, 0); + response->mutable_lower_absolute_power()->Resize(actual_array_size, 0); + response->mutable_upper_absolute_power()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -1115,9 +1193,8 @@ namespace nirfmxspecan_grpc { int32 actual_array_size {}; while (true) { auto status = library_->ACPFetchRelativePowersTrace(instrument, selector_string, timeout, trace_index, &x0, &dx, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_relative_powers_trace()->Resize(actual_array_size, 0); float32* relative_powers_trace = response->mutable_relative_powers_trace()->mutable_data(); @@ -1127,13 +1204,14 @@ namespace nirfmxspecan_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_x0(x0); - response->set_dx(dx); - response->mutable_relative_powers_trace()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_x0(x0); + response->set_dx(dx); + response->mutable_relative_powers_trace()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -1159,9 +1237,8 @@ namespace nirfmxspecan_grpc { int32 actual_array_size {}; while (true) { auto status = library_->ACPFetchSpectrum(instrument, selector_string, timeout, &x0, &dx, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_spectrum()->Resize(actual_array_size, 0); float32* spectrum = response->mutable_spectrum()->mutable_data(); @@ -1171,13 +1248,14 @@ namespace nirfmxspecan_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_x0(x0); - response->set_dx(dx); - response->mutable_spectrum()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_x0(x0); + response->set_dx(dx); + response->mutable_spectrum()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -1200,10 +1278,11 @@ namespace nirfmxspecan_grpc { float64 timeout = request->timeout(); float64 total_carrier_power {}; auto status = library_->ACPFetchTotalCarrierPower(instrument, selector_string, timeout, &total_carrier_power); - response->set_status(status); - if (status_ok(status)) { - response->set_total_carrier_power(total_carrier_power); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_total_carrier_power(total_carrier_power); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -1229,14 +1308,15 @@ namespace nirfmxspecan_grpc { float64 offset_ch1_lower_relative_power {}; float64 offset_ch1_upper_relative_power {}; auto status = library_->ACPRead(instrument, selector_string, timeout, &carrier_absolute_power, &offset_ch0_lower_relative_power, &offset_ch0_upper_relative_power, &offset_ch1_lower_relative_power, &offset_ch1_upper_relative_power); - response->set_status(status); - if (status_ok(status)) { - response->set_carrier_absolute_power(carrier_absolute_power); - response->set_offset_ch0_lower_relative_power(offset_ch0_lower_relative_power); - response->set_offset_ch0_upper_relative_power(offset_ch0_upper_relative_power); - response->set_offset_ch1_lower_relative_power(offset_ch1_lower_relative_power); - response->set_offset_ch1_upper_relative_power(offset_ch1_upper_relative_power); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_carrier_absolute_power(carrier_absolute_power); + response->set_offset_ch0_lower_relative_power(offset_ch0_lower_relative_power); + response->set_offset_ch0_upper_relative_power(offset_ch0_upper_relative_power); + response->set_offset_ch1_lower_relative_power(offset_ch1_lower_relative_power); + response->set_offset_ch1_upper_relative_power(offset_ch1_upper_relative_power); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -1257,11 +1337,12 @@ namespace nirfmxspecan_grpc { char* selector_string = (char*)request->selector_string().c_str(); int32 noise_calibration_data_valid {}; auto status = library_->ACPValidateNoiseCalibrationData(instrument, selector_string, &noise_calibration_data_valid); - response->set_status(status); - if (status_ok(status)) { - response->set_noise_calibration_data_valid(static_cast(noise_calibration_data_valid)); - response->set_noise_calibration_data_valid_raw(noise_calibration_data_valid); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_noise_calibration_data_valid(static_cast(noise_calibration_data_valid)); + response->set_noise_calibration_data_valid_raw(noise_calibration_data_valid); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -1298,6 +1379,9 @@ namespace nirfmxspecan_grpc { } auto status = library_->AMPMCfgAMToAMCurveFit(instrument, selector_string, am_to_am_curve_fit_order, am_to_am_curve_fit_type); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1335,6 +1419,9 @@ namespace nirfmxspecan_grpc { } auto status = library_->AMPMCfgAMToPMCurveFit(instrument, selector_string, am_to_pm_curve_fit_order, am_to_pm_curve_fit_type); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1372,6 +1459,9 @@ namespace nirfmxspecan_grpc { int32 averaging_count = request->averaging_count(); auto status = library_->AMPMCfgAveraging(instrument, selector_string, averaging_enabled, averaging_count); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1410,6 +1500,9 @@ namespace nirfmxspecan_grpc { auto compression_level = const_cast(request->compression_level().data()); int32 array_size = static_cast(request->compression_level().size()); auto status = library_->AMPMCfgCompressionPoints(instrument, selector_string, compression_point_enabled, compression_level, array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1431,6 +1524,9 @@ namespace nirfmxspecan_grpc { char* selector_string = (char*)request->selector_string().c_str(); float64 dut_average_input_power = request->dut_average_input_power(); auto status = library_->AMPMCfgDUTAverageInputPower(instrument, selector_string, dut_average_input_power); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1452,6 +1548,9 @@ namespace nirfmxspecan_grpc { char* selector_string = (char*)request->selector_string().c_str(); float64 measurement_interval = request->measurement_interval(); auto status = library_->AMPMCfgMeasurementInterval(instrument, selector_string, measurement_interval); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1489,6 +1588,9 @@ namespace nirfmxspecan_grpc { float64 sample_rate = request->sample_rate(); auto status = library_->AMPMCfgMeasurementSampleRate(instrument, selector_string, sample_rate_mode, sample_rate); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1525,6 +1627,9 @@ namespace nirfmxspecan_grpc { } auto status = library_->AMPMCfgReferencePowerType(instrument, selector_string, reference_power_type); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1581,6 +1686,9 @@ namespace nirfmxspecan_grpc { } auto status = library_->AMPMCfgReferenceWaveform(instrument, selector_string, x0, dx, reference_waveform.data(), array_size, idle_duration_present, signal_type); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1617,6 +1725,9 @@ namespace nirfmxspecan_grpc { } auto status = library_->AMPMCfgSynchronizationMethod(instrument, selector_string, synchronization_method); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1670,6 +1781,9 @@ namespace nirfmxspecan_grpc { } auto status = library_->AMPMCfgThreshold(instrument, selector_string, threshold_enabled, threshold_level, threshold_type); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1693,9 +1807,8 @@ namespace nirfmxspecan_grpc { int32 actual_array_size {}; while (true) { auto status = library_->AMPMFetchAMToAMTrace(instrument, selector_string, timeout, nullptr, nullptr, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_reference_powers()->Resize(actual_array_size, 0); float32* reference_powers = response->mutable_reference_powers()->mutable_data(); @@ -1709,13 +1822,14 @@ namespace nirfmxspecan_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->mutable_reference_powers()->Resize(actual_array_size, 0); - response->mutable_measured_am_to_am()->Resize(actual_array_size, 0); - response->mutable_curve_fit_am_to_am()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->mutable_reference_powers()->Resize(actual_array_size, 0); + response->mutable_measured_am_to_am()->Resize(actual_array_size, 0); + response->mutable_curve_fit_am_to_am()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -1739,9 +1853,8 @@ namespace nirfmxspecan_grpc { int32 actual_array_size {}; while (true) { auto status = library_->AMPMFetchAMToPMTrace(instrument, selector_string, timeout, nullptr, nullptr, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_reference_powers()->Resize(actual_array_size, 0); float32* reference_powers = response->mutable_reference_powers()->mutable_data(); @@ -1755,13 +1868,14 @@ namespace nirfmxspecan_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->mutable_reference_powers()->Resize(actual_array_size, 0); - response->mutable_measured_am_to_pm()->Resize(actual_array_size, 0); - response->mutable_curve_fit_am_to_pm()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->mutable_reference_powers()->Resize(actual_array_size, 0); + response->mutable_measured_am_to_pm()->Resize(actual_array_size, 0); + response->mutable_curve_fit_am_to_pm()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -1785,9 +1899,8 @@ namespace nirfmxspecan_grpc { int32 actual_array_size {}; while (true) { auto status = library_->AMPMFetchCompressionPoints(instrument, selector_string, timeout, nullptr, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_input_compression_point()->Resize(actual_array_size, 0); float64* input_compression_point = response->mutable_input_compression_point()->mutable_data(); @@ -1799,12 +1912,13 @@ namespace nirfmxspecan_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->mutable_input_compression_point()->Resize(actual_array_size, 0); - response->mutable_output_compression_point()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->mutable_input_compression_point()->Resize(actual_array_size, 0); + response->mutable_output_compression_point()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -1828,9 +1942,8 @@ namespace nirfmxspecan_grpc { int32 actual_array_size {}; while (true) { auto status = library_->AMPMFetchCurveFitCoefficients(instrument, selector_string, timeout, nullptr, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_am_to_am_coefficients()->Resize(actual_array_size, 0); float32* am_to_am_coefficients = response->mutable_am_to_am_coefficients()->mutable_data(); @@ -1842,12 +1955,13 @@ namespace nirfmxspecan_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->mutable_am_to_am_coefficients()->Resize(actual_array_size, 0); - response->mutable_am_to_pm_coefficients()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->mutable_am_to_am_coefficients()->Resize(actual_array_size, 0); + response->mutable_am_to_pm_coefficients()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -1871,11 +1985,12 @@ namespace nirfmxspecan_grpc { float64 am_to_am_residual {}; float64 am_to_pm_residual {}; auto status = library_->AMPMFetchCurveFitResidual(instrument, selector_string, timeout, &am_to_am_residual, &am_to_pm_residual); - response->set_status(status); - if (status_ok(status)) { - response->set_am_to_am_residual(am_to_am_residual); - response->set_am_to_pm_residual(am_to_pm_residual); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_am_to_am_residual(am_to_am_residual); + response->set_am_to_pm_residual(am_to_pm_residual); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -1899,12 +2014,13 @@ namespace nirfmxspecan_grpc { float64 one_db_compression_point {}; float64 mean_rms_evm {}; auto status = library_->AMPMFetchDUTCharacteristics(instrument, selector_string, timeout, &mean_linear_gain, &one_db_compression_point, &mean_rms_evm); - response->set_status(status); - if (status_ok(status)) { - response->set_mean_linear_gain(mean_linear_gain); - response->set_one_db_compression_point(one_db_compression_point); - response->set_mean_rms_evm(mean_rms_evm); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_mean_linear_gain(mean_linear_gain); + response->set_one_db_compression_point(one_db_compression_point); + response->set_mean_rms_evm(mean_rms_evm); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -1928,12 +2044,13 @@ namespace nirfmxspecan_grpc { float64 phase_error_range {}; float64 mean_phase_error {}; auto status = library_->AMPMFetchError(instrument, selector_string, timeout, &gain_error_range, &phase_error_range, &mean_phase_error); - response->set_status(status); - if (status_ok(status)) { - response->set_gain_error_range(gain_error_range); - response->set_phase_error_range(phase_error_range); - response->set_mean_phase_error(mean_phase_error); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_gain_error_range(gain_error_range); + response->set_phase_error_range(phase_error_range); + response->set_mean_phase_error(mean_phase_error); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -1958,9 +2075,8 @@ namespace nirfmxspecan_grpc { int32 actual_array_size {}; while (true) { auto status = library_->AMPMFetchProcessedMeanAcquiredWaveform(instrument, selector_string, timeout, &x0, &dx, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } std::vector processed_mean_acquired_waveform(actual_array_size, NIComplexSingle()); auto array_size = actual_array_size; @@ -1969,20 +2085,21 @@ namespace nirfmxspecan_grpc { // buffer is now too small, try again continue; } + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); - if (status_ok(status)) { - response->set_x0(x0); - response->set_dx(dx); - convert_to_grpc(processed_mean_acquired_waveform, response->mutable_processed_mean_acquired_waveform()); - { - auto shrunk_size = actual_array_size; - auto current_size = response->mutable_processed_mean_acquired_waveform()->size(); - if (shrunk_size != current_size) { - response->mutable_processed_mean_acquired_waveform()->DeleteSubrange(shrunk_size, current_size - shrunk_size); - } + response->set_x0(x0); + response->set_dx(dx); + convert_to_grpc(processed_mean_acquired_waveform, response->mutable_processed_mean_acquired_waveform()); + { + auto shrunk_size = actual_array_size; + auto current_size = response->mutable_processed_mean_acquired_waveform()->size(); + if (shrunk_size != current_size) { + response->mutable_processed_mean_acquired_waveform()->DeleteSubrange(shrunk_size, current_size - shrunk_size); } - response->set_actual_array_size(actual_array_size); } + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -2008,9 +2125,8 @@ namespace nirfmxspecan_grpc { int32 actual_array_size {}; while (true) { auto status = library_->AMPMFetchProcessedReferenceWaveform(instrument, selector_string, timeout, &x0, &dx, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } std::vector processed_reference_waveform(actual_array_size, NIComplexSingle()); auto array_size = actual_array_size; @@ -2019,20 +2135,21 @@ namespace nirfmxspecan_grpc { // buffer is now too small, try again continue; } + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); - if (status_ok(status)) { - response->set_x0(x0); - response->set_dx(dx); - convert_to_grpc(processed_reference_waveform, response->mutable_processed_reference_waveform()); - { - auto shrunk_size = actual_array_size; - auto current_size = response->mutable_processed_reference_waveform()->size(); - if (shrunk_size != current_size) { - response->mutable_processed_reference_waveform()->DeleteSubrange(shrunk_size, current_size - shrunk_size); - } + response->set_x0(x0); + response->set_dx(dx); + convert_to_grpc(processed_reference_waveform, response->mutable_processed_reference_waveform()); + { + auto shrunk_size = actual_array_size; + auto current_size = response->mutable_processed_reference_waveform()->size(); + if (shrunk_size != current_size) { + response->mutable_processed_reference_waveform()->DeleteSubrange(shrunk_size, current_size - shrunk_size); } - response->set_actual_array_size(actual_array_size); } + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -2058,9 +2175,8 @@ namespace nirfmxspecan_grpc { int32 actual_array_size {}; while (true) { auto status = library_->AMPMFetchRelativePhaseTrace(instrument, selector_string, timeout, &x0, &dx, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_relative_phase()->Resize(actual_array_size, 0); float32* relative_phase = response->mutable_relative_phase()->mutable_data(); @@ -2070,13 +2186,14 @@ namespace nirfmxspecan_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_x0(x0); - response->set_dx(dx); - response->mutable_relative_phase()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_x0(x0); + response->set_dx(dx); + response->mutable_relative_phase()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -2102,9 +2219,8 @@ namespace nirfmxspecan_grpc { int32 actual_array_size {}; while (true) { auto status = library_->AMPMFetchRelativePowerTrace(instrument, selector_string, timeout, &x0, &dx, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_relative_power()->Resize(actual_array_size, 0); float32* relative_power = response->mutable_relative_power()->mutable_data(); @@ -2114,13 +2230,14 @@ namespace nirfmxspecan_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_x0(x0); - response->set_dx(dx); - response->mutable_relative_power()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_x0(x0); + response->set_dx(dx); + response->mutable_relative_power()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -2141,6 +2258,9 @@ namespace nirfmxspecan_grpc { niRFmxInstrHandle instrument = session_repository_->access_session(instrument_grpc_session.id(), instrument_grpc_session.name()); char* selector_string = (char*)request->selector_string().c_str(); auto status = library_->AbortMeasurements(instrument, selector_string); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -2168,6 +2288,9 @@ namespace nirfmxspecan_grpc { int32 reset = request->reset(); auto reserved = 0; auto status = library_->AnalyzeIQ1Waveform(instrument, selector_string, result_name, x0, dx, iq.data(), array_size, reset, reserved); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -2195,6 +2318,9 @@ namespace nirfmxspecan_grpc { int32 reset = request->reset(); auto reserved = 0; auto status = library_->AnalyzeSpectrum1Waveform(instrument, selector_string, result_name, x0, dx, spectrum, array_size, reset, reserved); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -2218,10 +2344,11 @@ namespace nirfmxspecan_grpc { float64 measurement_interval = request->measurement_interval(); float64 reference_level {}; auto status = library_->AutoLevel(instrument, selector_string, bandwidth, measurement_interval, &reference_level); - response->set_status(status); - if (status_ok(status)) { - response->set_reference_level(reference_level); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_reference_level(reference_level); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -2242,9 +2369,8 @@ namespace nirfmxspecan_grpc { while (true) { auto status = library_->BuildCarrierString(selector_string, carrier_number, 0, nullptr); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, 0); } int32 selector_string_out_length = status; @@ -2257,11 +2383,12 @@ namespace nirfmxspecan_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_selector_string_out(selector_string_out); - nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_selector_string_out())); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, 0); } + response->set_status(status); + response->set_selector_string_out(selector_string_out); + nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_selector_string_out())); return ::grpc::Status::OK; } } @@ -2283,9 +2410,8 @@ namespace nirfmxspecan_grpc { while (true) { auto status = library_->BuildHarmonicString(selector_string, harmonic_number, 0, nullptr); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, 0); } int32 selector_string_out_length = status; @@ -2298,11 +2424,12 @@ namespace nirfmxspecan_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_selector_string_out(selector_string_out); - nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_selector_string_out())); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, 0); } + response->set_status(status); + response->set_selector_string_out(selector_string_out); + nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_selector_string_out())); return ::grpc::Status::OK; } } @@ -2324,9 +2451,8 @@ namespace nirfmxspecan_grpc { while (true) { auto status = library_->BuildIntermodString(selector_string, intermod_number, 0, nullptr); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, 0); } int32 selector_string_out_length = status; @@ -2339,11 +2465,12 @@ namespace nirfmxspecan_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_selector_string_out(selector_string_out); - nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_selector_string_out())); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, 0); } + response->set_status(status); + response->set_selector_string_out(selector_string_out); + nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_selector_string_out())); return ::grpc::Status::OK; } } @@ -2366,9 +2493,8 @@ namespace nirfmxspecan_grpc { while (true) { auto status = library_->BuildListStepString(list_name, result_name, step_number, 0, nullptr); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, 0); } int32 selector_string_length = status; @@ -2381,11 +2507,12 @@ namespace nirfmxspecan_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_selector_string(selector_string); - nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_selector_string())); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, 0); } + response->set_status(status); + response->set_selector_string(selector_string); + nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_selector_string())); return ::grpc::Status::OK; } } @@ -2407,9 +2534,8 @@ namespace nirfmxspecan_grpc { while (true) { auto status = library_->BuildListString(list_name, result_name, 0, nullptr); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, 0); } int32 selector_string_length = status; @@ -2422,11 +2548,12 @@ namespace nirfmxspecan_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_selector_string(selector_string); - nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_selector_string())); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, 0); } + response->set_status(status); + response->set_selector_string(selector_string); + nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_selector_string())); return ::grpc::Status::OK; } } @@ -2448,9 +2575,8 @@ namespace nirfmxspecan_grpc { while (true) { auto status = library_->BuildMarkerString(selector_string, marker_number, 0, nullptr); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, 0); } int32 selector_string_out_length = status; @@ -2463,11 +2589,12 @@ namespace nirfmxspecan_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_selector_string_out(selector_string_out); - nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_selector_string_out())); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, 0); } + response->set_status(status); + response->set_selector_string_out(selector_string_out); + nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_selector_string_out())); return ::grpc::Status::OK; } } @@ -2489,9 +2616,8 @@ namespace nirfmxspecan_grpc { while (true) { auto status = library_->BuildOffsetString(selector_string, offset_number, 0, nullptr); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, 0); } int32 selector_string_out_length = status; @@ -2504,11 +2630,12 @@ namespace nirfmxspecan_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_selector_string_out(selector_string_out); - nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_selector_string_out())); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, 0); } + response->set_status(status); + response->set_selector_string_out(selector_string_out); + nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_selector_string_out())); return ::grpc::Status::OK; } } @@ -2532,9 +2659,8 @@ namespace nirfmxspecan_grpc { while (true) { auto status = library_->BuildRangeSpurString(signal_name, result_name, range_number, spur_number, 0, nullptr); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, 0); } int32 selector_string_length = status; @@ -2547,11 +2673,12 @@ namespace nirfmxspecan_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_selector_string(selector_string); - nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_selector_string())); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, 0); } + response->set_status(status); + response->set_selector_string(selector_string); + nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_selector_string())); return ::grpc::Status::OK; } } @@ -2573,9 +2700,8 @@ namespace nirfmxspecan_grpc { while (true) { auto status = library_->BuildRangeString(selector_string, range_number, 0, nullptr); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, 0); } int32 selector_string_out_length = status; @@ -2588,11 +2714,12 @@ namespace nirfmxspecan_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_selector_string_out(selector_string_out); - nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_selector_string_out())); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, 0); } + response->set_status(status); + response->set_selector_string_out(selector_string_out); + nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_selector_string_out())); return ::grpc::Status::OK; } } @@ -2614,9 +2741,8 @@ namespace nirfmxspecan_grpc { while (true) { auto status = library_->BuildSegmentString(selector_string, segment_number, 0, nullptr); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, 0); } int32 selector_string_out_length = status; @@ -2629,11 +2755,12 @@ namespace nirfmxspecan_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_selector_string_out(selector_string_out); - nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_selector_string_out())); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, 0); } + response->set_status(status); + response->set_selector_string_out(selector_string_out); + nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_selector_string_out())); return ::grpc::Status::OK; } } @@ -2655,9 +2782,8 @@ namespace nirfmxspecan_grpc { while (true) { auto status = library_->BuildSignalString(signal_name, result_name, 0, nullptr); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, 0); } int32 selector_string_length = status; @@ -2670,11 +2796,12 @@ namespace nirfmxspecan_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_selector_string(selector_string); - nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_selector_string())); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, 0); } + response->set_status(status); + response->set_selector_string(selector_string); + nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_selector_string())); return ::grpc::Status::OK; } } @@ -2696,9 +2823,8 @@ namespace nirfmxspecan_grpc { while (true) { auto status = library_->BuildSpurString(selector_string, spur_number, 0, nullptr); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, 0); } int32 selector_string_out_length = status; @@ -2711,11 +2837,12 @@ namespace nirfmxspecan_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_selector_string_out(selector_string_out); - nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_selector_string_out())); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, 0); } + response->set_status(status); + response->set_selector_string_out(selector_string_out); + nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_selector_string_out())); return ::grpc::Status::OK; } } @@ -2737,6 +2864,9 @@ namespace nirfmxspecan_grpc { char* selector_string = (char*)request->selector_string().c_str(); float64 measurement_interval = request->measurement_interval(); auto status = library_->CCDFCfgMeasurementInterval(instrument, selector_string, measurement_interval); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -2758,6 +2888,9 @@ namespace nirfmxspecan_grpc { char* selector_string = (char*)request->selector_string().c_str(); int32 number_of_records = request->number_of_records(); auto status = library_->CCDFCfgNumberOfRecords(instrument, selector_string, number_of_records); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -2796,6 +2929,9 @@ namespace nirfmxspecan_grpc { float64 rrc_alpha = request->rrc_alpha(); auto status = library_->CCDFCfgRBWFilter(instrument, selector_string, rbw, rbw_filter_type, rrc_alpha); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -2849,6 +2985,9 @@ namespace nirfmxspecan_grpc { } auto status = library_->CCDFCfgThreshold(instrument, selector_string, threshold_enabled, threshold_level, threshold_type); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -2876,15 +3015,16 @@ namespace nirfmxspecan_grpc { float64 one_thousandth_percent_power {}; float64 one_ten_thousandth_percent_power {}; auto status = library_->CCDFFetchBasicPowerProbabilities(instrument, selector_string, timeout, &ten_percent_power, &one_percent_power, &one_tenth_percent_power, &one_hundredth_percent_power, &one_thousandth_percent_power, &one_ten_thousandth_percent_power); - response->set_status(status); - if (status_ok(status)) { - response->set_ten_percent_power(ten_percent_power); - response->set_one_percent_power(one_percent_power); - response->set_one_tenth_percent_power(one_tenth_percent_power); - response->set_one_hundredth_percent_power(one_hundredth_percent_power); - response->set_one_thousandth_percent_power(one_thousandth_percent_power); - response->set_one_ten_thousandth_percent_power(one_ten_thousandth_percent_power); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_ten_percent_power(ten_percent_power); + response->set_one_percent_power(one_percent_power); + response->set_one_tenth_percent_power(one_tenth_percent_power); + response->set_one_hundredth_percent_power(one_hundredth_percent_power); + response->set_one_thousandth_percent_power(one_thousandth_percent_power); + response->set_one_ten_thousandth_percent_power(one_ten_thousandth_percent_power); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -2909,9 +3049,8 @@ namespace nirfmxspecan_grpc { int32 actual_array_size {}; while (true) { auto status = library_->CCDFFetchGaussianProbabilitiesTrace(instrument, selector_string, timeout, &x0, &dx, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_gaussian_probabilities()->Resize(actual_array_size, 0); float32* gaussian_probabilities = response->mutable_gaussian_probabilities()->mutable_data(); @@ -2921,13 +3060,14 @@ namespace nirfmxspecan_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_x0(x0); - response->set_dx(dx); - response->mutable_gaussian_probabilities()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_x0(x0); + response->set_dx(dx); + response->mutable_gaussian_probabilities()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -2953,13 +3093,14 @@ namespace nirfmxspecan_grpc { float64 peak_power {}; int32 measured_samples_count {}; auto status = library_->CCDFFetchPower(instrument, selector_string, timeout, &mean_power, &mean_power_percentile, &peak_power, &measured_samples_count); - response->set_status(status); - if (status_ok(status)) { - response->set_mean_power(mean_power); - response->set_mean_power_percentile(mean_power_percentile); - response->set_peak_power(peak_power); - response->set_measured_samples_count(measured_samples_count); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_mean_power(mean_power); + response->set_mean_power_percentile(mean_power_percentile); + response->set_peak_power(peak_power); + response->set_measured_samples_count(measured_samples_count); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -2984,9 +3125,8 @@ namespace nirfmxspecan_grpc { int32 actual_array_size {}; while (true) { auto status = library_->CCDFFetchProbabilitiesTrace(instrument, selector_string, timeout, &x0, &dx, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_probabilities()->Resize(actual_array_size, 0); float32* probabilities = response->mutable_probabilities()->mutable_data(); @@ -2996,13 +3136,14 @@ namespace nirfmxspecan_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_x0(x0); - response->set_dx(dx); - response->mutable_probabilities()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_x0(x0); + response->set_dx(dx); + response->mutable_probabilities()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -3028,13 +3169,14 @@ namespace nirfmxspecan_grpc { float64 peak_power {}; int32 measured_samples_count {}; auto status = library_->CCDFRead(instrument, selector_string, timeout, &mean_power, &mean_power_percentile, &peak_power, &measured_samples_count); - response->set_status(status); - if (status_ok(status)) { - response->set_mean_power(mean_power); - response->set_mean_power_percentile(mean_power_percentile); - response->set_peak_power(peak_power); - response->set_measured_samples_count(measured_samples_count); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_mean_power(mean_power); + response->set_mean_power_percentile(mean_power_percentile); + response->set_peak_power(peak_power); + response->set_measured_samples_count(measured_samples_count); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -3087,6 +3229,9 @@ namespace nirfmxspecan_grpc { } auto status = library_->CHPCfgAveraging(instrument, selector_string, averaging_enabled, averaging_count, averaging_type); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -3108,6 +3253,9 @@ namespace nirfmxspecan_grpc { char* selector_string = (char*)request->selector_string().c_str(); float64 carrier_frequency = request->carrier_frequency(); auto status = library_->CHPCfgCarrierOffset(instrument, selector_string, carrier_frequency); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -3145,6 +3293,9 @@ namespace nirfmxspecan_grpc { float64 fft_padding = request->fft_padding(); auto status = library_->CHPCfgFFT(instrument, selector_string, fft_window, fft_padding); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -3166,6 +3317,9 @@ namespace nirfmxspecan_grpc { char* selector_string = (char*)request->selector_string().c_str(); float64 integration_bandwidth = request->integration_bandwidth(); auto status = library_->CHPCfgIntegrationBandwidth(instrument, selector_string, integration_bandwidth); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -3187,6 +3341,9 @@ namespace nirfmxspecan_grpc { char* selector_string = (char*)request->selector_string().c_str(); int32 number_of_carriers = request->number_of_carriers(); auto status = library_->CHPCfgNumberOfCarriers(instrument, selector_string, number_of_carriers); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -3240,6 +3397,9 @@ namespace nirfmxspecan_grpc { } auto status = library_->CHPCfgRBWFilter(instrument, selector_string, rbw_auto, rbw, rbw_filter_type); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -3277,6 +3437,9 @@ namespace nirfmxspecan_grpc { float64 rrc_alpha = request->rrc_alpha(); auto status = library_->CHPCfgRRCFilter(instrument, selector_string, rrc_filter_enabled, rrc_alpha); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -3298,6 +3461,9 @@ namespace nirfmxspecan_grpc { char* selector_string = (char*)request->selector_string().c_str(); float64 span = request->span(); auto status = library_->CHPCfgSpan(instrument, selector_string, span); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -3335,6 +3501,9 @@ namespace nirfmxspecan_grpc { float64 sweep_time_interval = request->sweep_time_interval(); auto status = library_->CHPCfgSweepTime(instrument, selector_string, sweep_time_auto, sweep_time_interval); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -3359,12 +3528,13 @@ namespace nirfmxspecan_grpc { float64 psd {}; float64 relative_power {}; auto status = library_->CHPFetchCarrierMeasurement(instrument, selector_string, timeout, &absolute_power, &psd, &relative_power); - response->set_status(status); - if (status_ok(status)) { - response->set_absolute_power(absolute_power); - response->set_psd(psd); - response->set_relative_power(relative_power); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_absolute_power(absolute_power); + response->set_psd(psd); + response->set_relative_power(relative_power); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -3389,9 +3559,8 @@ namespace nirfmxspecan_grpc { int32 actual_array_size {}; while (true) { auto status = library_->CHPFetchSpectrum(instrument, selector_string, timeout, &x0, &dx, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_spectrum()->Resize(actual_array_size, 0); float32* spectrum = response->mutable_spectrum()->mutable_data(); @@ -3401,13 +3570,14 @@ namespace nirfmxspecan_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_x0(x0); - response->set_dx(dx); - response->mutable_spectrum()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_x0(x0); + response->set_dx(dx); + response->mutable_spectrum()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -3430,10 +3600,11 @@ namespace nirfmxspecan_grpc { float64 timeout = request->timeout(); float64 total_carrier_power {}; auto status = library_->CHPFetchTotalCarrierPower(instrument, selector_string, timeout, &total_carrier_power); - response->set_status(status); - if (status_ok(status)) { - response->set_total_carrier_power(total_carrier_power); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_total_carrier_power(total_carrier_power); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -3456,11 +3627,12 @@ namespace nirfmxspecan_grpc { float64 absolute_power {}; float64 psd {}; auto status = library_->CHPRead(instrument, selector_string, timeout, &absolute_power, &psd); - response->set_status(status); - if (status_ok(status)) { - response->set_absolute_power(absolute_power); - response->set_psd(psd); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_absolute_power(absolute_power); + response->set_psd(psd); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -3481,11 +3653,12 @@ namespace nirfmxspecan_grpc { char* selector_string = (char*)request->selector_string().c_str(); int32 noise_calibration_data_valid {}; auto status = library_->CHPValidateNoiseCalibrationData(instrument, selector_string, &noise_calibration_data_valid); - response->set_status(status); - if (status_ok(status)) { - response->set_noise_calibration_data_valid(static_cast(noise_calibration_data_valid)); - response->set_noise_calibration_data_valid_raw(noise_calibration_data_valid); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_noise_calibration_data_valid(static_cast(noise_calibration_data_valid)); + response->set_noise_calibration_data_valid_raw(noise_calibration_data_valid); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -3543,6 +3716,9 @@ namespace nirfmxspecan_grpc { float64 trigger_delay = request->trigger_delay(); int32 enable_trigger = request->enable_trigger(); auto status = library_->CfgDigitalEdgeTrigger(instrument, selector_string, digital_edge_source, digital_edge, trigger_delay, enable_trigger); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -3564,6 +3740,9 @@ namespace nirfmxspecan_grpc { char* selector_string = (char*)request->selector_string().c_str(); float64 external_attenuation = request->external_attenuation(); auto status = library_->CfgExternalAttenuation(instrument, selector_string, external_attenuation); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -3585,6 +3764,9 @@ namespace nirfmxspecan_grpc { char* selector_string = (char*)request->selector_string().c_str(); float64 center_frequency = request->center_frequency(); auto status = library_->CfgFrequency(instrument, selector_string, center_frequency); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -3626,6 +3808,9 @@ namespace nirfmxspecan_grpc { float64 frequency_reference_frequency = request->frequency_reference_frequency(); auto status = library_->CfgFrequencyReference(instrument, channel_name, frequency_reference_source, frequency_reference_frequency); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -3683,6 +3868,9 @@ namespace nirfmxspecan_grpc { float64 trigger_min_quiet_time_duration = request->trigger_min_quiet_time_duration(); int32 enable_trigger = request->enable_trigger(); auto status = library_->CfgIQPowerEdgeTrigger(instrument, selector_string, iq_power_edge_source, iq_power_edge_level, iq_power_edge_slope, trigger_delay, trigger_min_quiet_time_mode, trigger_min_quiet_time_duration, enable_trigger); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -3720,6 +3908,9 @@ namespace nirfmxspecan_grpc { float64 mechanical_attenuation_value = request->mechanical_attenuation_value(); auto status = library_->CfgMechanicalAttenuation(instrument, channel_name, mechanical_attenuation_auto, mechanical_attenuation_value); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -3743,6 +3934,9 @@ namespace nirfmxspecan_grpc { float64 reference_level = request->reference_level(); float64 external_attenuation = request->external_attenuation(); auto status = library_->CfgRF(instrument, selector_string, center_frequency, reference_level, external_attenuation); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -3780,6 +3974,9 @@ namespace nirfmxspecan_grpc { float64 rf_attenuation_value = request->rf_attenuation_value(); auto status = library_->CfgRFAttenuation(instrument, channel_name, rf_attenuation_auto, rf_attenuation_value); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -3801,6 +3998,9 @@ namespace nirfmxspecan_grpc { char* selector_string = (char*)request->selector_string().c_str(); float64 reference_level = request->reference_level(); auto status = library_->CfgReferenceLevel(instrument, selector_string, reference_level); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -3823,6 +4023,9 @@ namespace nirfmxspecan_grpc { float64 trigger_delay = request->trigger_delay(); int32 enable_trigger = request->enable_trigger(); auto status = library_->CfgSoftwareEdgeTrigger(instrument, selector_string, trigger_delay, enable_trigger); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -3844,10 +4047,11 @@ namespace nirfmxspecan_grpc { char* selector_string = (char*)request->selector_string().c_str(); int32 is_done {}; auto status = library_->CheckMeasurementStatus(instrument, selector_string, &is_done); - response->set_status(status); - if (status_ok(status)) { - response->set_is_done(is_done); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_is_done(is_done); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -3867,6 +4071,9 @@ namespace nirfmxspecan_grpc { niRFmxInstrHandle instrument = session_repository_->access_session(instrument_grpc_session.id(), instrument_grpc_session.name()); char* selector_string = (char*)request->selector_string().c_str(); auto status = library_->ClearAllNamedResults(instrument, selector_string); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -3887,6 +4094,9 @@ namespace nirfmxspecan_grpc { niRFmxInstrHandle instrument = session_repository_->access_session(instrument_grpc_session.id(), instrument_grpc_session.name()); char* selector_string = (char*)request->selector_string().c_str(); auto status = library_->ClearNamedResult(instrument, selector_string); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -3907,6 +4117,9 @@ namespace nirfmxspecan_grpc { niRFmxInstrHandle instrument = session_repository_->access_session(instrument_grpc_session.id(), instrument_grpc_session.name()); char* selector_string = (char*)request->selector_string().c_str(); auto status = library_->ClearNoiseCalibrationDatabase(instrument, selector_string); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -3928,6 +4141,9 @@ namespace nirfmxspecan_grpc { char* old_signal_name = (char*)request->old_signal_name().c_str(); char* new_signal_name = (char*)request->new_signal_name().c_str(); auto status = library_->CloneSignalConfiguration(instrument, old_signal_name, new_signal_name); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -3949,6 +4165,9 @@ namespace nirfmxspecan_grpc { int32 force_destroy = request->force_destroy(); session_repository_->remove_session(instrument_grpc_session.id(), instrument_grpc_session.name()); auto status = library_->Close(instrument, force_destroy); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -3969,6 +4188,9 @@ namespace nirfmxspecan_grpc { niRFmxInstrHandle instrument = session_repository_->access_session(instrument_grpc_session.id(), instrument_grpc_session.name()); char* selector_string = (char*)request->selector_string().c_str(); auto status = library_->Commit(instrument, selector_string); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -3989,6 +4211,9 @@ namespace nirfmxspecan_grpc { niRFmxInstrHandle instrument = session_repository_->access_session(instrument_grpc_session.id(), instrument_grpc_session.name()); char* list_name = (char*)request->list_name().c_str(); auto status = library_->CreateList(instrument, list_name); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -4010,10 +4235,11 @@ namespace nirfmxspecan_grpc { char* selector_string = (char*)request->selector_string().c_str(); int32 created_step_index {}; auto status = library_->CreateListStep(instrument, selector_string, &created_step_index); - response->set_status(status); - if (status_ok(status)) { - response->set_created_step_index(created_step_index); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_created_step_index(created_step_index); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -4033,6 +4259,9 @@ namespace nirfmxspecan_grpc { niRFmxInstrHandle instrument = session_repository_->access_session(instrument_grpc_session.id(), instrument_grpc_session.name()); char* signal_name = (char*)request->signal_name().c_str(); auto status = library_->CreateSignalConfiguration(instrument, signal_name); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -4080,9 +4309,8 @@ namespace nirfmxspecan_grpc { float64 power_offset {}; while (true) { auto status = library_->DPDApplyDigitalPredistortion(instrument, selector_string, x0_in, dx_in, waveform_in.data(), array_size_in, idle_duration_present, measurement_timeout, &x0_out, &dx_out, nullptr, 0, &actual_array_size, &papr, &power_offset); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } std::vector waveform_out(actual_array_size, NIComplexSingle()); auto array_size_out = actual_array_size; @@ -4091,22 +4319,23 @@ namespace nirfmxspecan_grpc { // buffer is now too small, try again continue; } + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); - if (status_ok(status)) { - response->set_x0_out(x0_out); - response->set_dx_out(dx_out); - convert_to_grpc(waveform_out, response->mutable_waveform_out()); - { - auto shrunk_size = actual_array_size; - auto current_size = response->mutable_waveform_out()->size(); - if (shrunk_size != current_size) { - response->mutable_waveform_out()->DeleteSubrange(shrunk_size, current_size - shrunk_size); - } + response->set_x0_out(x0_out); + response->set_dx_out(dx_out); + convert_to_grpc(waveform_out, response->mutable_waveform_out()); + { + auto shrunk_size = actual_array_size; + auto current_size = response->mutable_waveform_out()->size(); + if (shrunk_size != current_size) { + response->mutable_waveform_out()->DeleteSubrange(shrunk_size, current_size - shrunk_size); } - response->set_actual_array_size(actual_array_size); - response->set_papr(papr); - response->set_power_offset(power_offset); } + response->set_actual_array_size(actual_array_size); + response->set_papr(papr); + response->set_power_offset(power_offset); return ::grpc::Status::OK; } } @@ -4152,9 +4381,8 @@ namespace nirfmxspecan_grpc { float64 papr {}; while (true) { auto status = library_->DPDApplyPreDPDSignalConditioning(instrument, selector_string, x0_in, dx_in, waveform_in.data(), array_size_in, idle_duration_present, &x0_out, &dx_out, nullptr, 0, &actual_array_size, &papr); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } std::vector waveform_out(actual_array_size, NIComplexSingle()); auto array_size_out = actual_array_size; @@ -4163,21 +4391,22 @@ namespace nirfmxspecan_grpc { // buffer is now too small, try again continue; } + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); - if (status_ok(status)) { - response->set_x0_out(x0_out); - response->set_dx_out(dx_out); - convert_to_grpc(waveform_out, response->mutable_waveform_out()); - { - auto shrunk_size = actual_array_size; - auto current_size = response->mutable_waveform_out()->size(); - if (shrunk_size != current_size) { - response->mutable_waveform_out()->DeleteSubrange(shrunk_size, current_size - shrunk_size); - } + response->set_x0_out(x0_out); + response->set_dx_out(dx_out); + convert_to_grpc(waveform_out, response->mutable_waveform_out()); + { + auto shrunk_size = actual_array_size; + auto current_size = response->mutable_waveform_out()->size(); + if (shrunk_size != current_size) { + response->mutable_waveform_out()->DeleteSubrange(shrunk_size, current_size - shrunk_size); } - response->set_actual_array_size(actual_array_size); - response->set_papr(papr); } + response->set_actual_array_size(actual_array_size); + response->set_papr(papr); return ::grpc::Status::OK; } } @@ -4214,6 +4443,9 @@ namespace nirfmxspecan_grpc { } auto status = library_->DPDCfgApplyDPDConfigurationInput(instrument, selector_string, configuration_input); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -4250,6 +4482,9 @@ namespace nirfmxspecan_grpc { } auto status = library_->DPDCfgApplyDPDLookupTableCorrectionType(instrument, selector_string, lut_correction_type); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -4286,6 +4521,9 @@ namespace nirfmxspecan_grpc { } auto status = library_->DPDCfgApplyDPDMemoryModelCorrectionType(instrument, selector_string, memory_model_correction_type); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -4308,6 +4546,9 @@ namespace nirfmxspecan_grpc { auto dpd_polynomial = convert_from_grpc(request->dpd_polynomial()); int32 array_size = static_cast(request->dpd_polynomial().size()); auto status = library_->DPDCfgApplyDPDUserDPDPolynomial(instrument, selector_string, dpd_polynomial.data(), array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -4347,6 +4588,9 @@ namespace nirfmxspecan_grpc { auto array_size = array_size_size_calculation.size; auto status = library_->DPDCfgApplyDPDUserLookupTable(instrument, selector_string, lut_input_powers, lut_complex_gains.data(), array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -4384,6 +4628,9 @@ namespace nirfmxspecan_grpc { int32 averaging_count = request->averaging_count(); auto status = library_->DPDCfgAveraging(instrument, selector_string, averaging_enabled, averaging_count); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -4420,6 +4667,9 @@ namespace nirfmxspecan_grpc { } auto status = library_->DPDCfgDPDModel(instrument, selector_string, dpd_model); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -4441,6 +4691,9 @@ namespace nirfmxspecan_grpc { char* selector_string = (char*)request->selector_string().c_str(); float64 dut_average_input_power = request->dut_average_input_power(); auto status = library_->DPDCfgDUTAverageInputPower(instrument, selector_string, dut_average_input_power); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -4467,6 +4720,9 @@ namespace nirfmxspecan_grpc { int32 memory_polynomial_maximum_lead = request->memory_polynomial_maximum_lead(); int32 memory_polynomial_maximum_lag = request->memory_polynomial_maximum_lag(); auto status = library_->DPDCfgGeneralizedMemoryPolynomialCrossTerms(instrument, selector_string, memory_polynomial_lead_order, memory_polynomial_lag_order, memory_polynomial_lead_memory_depth, memory_polynomial_lag_memory_depth, memory_polynomial_maximum_lead, memory_polynomial_maximum_lag); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -4503,6 +4759,9 @@ namespace nirfmxspecan_grpc { } auto status = library_->DPDCfgIterativeDPDEnabled(instrument, selector_string, iterative_dpd_enabled); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -4540,6 +4799,9 @@ namespace nirfmxspecan_grpc { } auto status = library_->DPDCfgLookupTableAMToAMCurveFit(instrument, selector_string, am_to_am_curve_fit_order, am_to_am_curve_fit_type); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -4577,6 +4839,9 @@ namespace nirfmxspecan_grpc { } auto status = library_->DPDCfgLookupTableAMToPMCurveFit(instrument, selector_string, am_to_pm_curve_fit_order, am_to_pm_curve_fit_type); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -4598,6 +4863,9 @@ namespace nirfmxspecan_grpc { char* selector_string = (char*)request->selector_string().c_str(); float64 step_size = request->step_size(); auto status = library_->DPDCfgLookupTableStepSize(instrument, selector_string, step_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -4651,6 +4919,9 @@ namespace nirfmxspecan_grpc { } auto status = library_->DPDCfgLookupTableThreshold(instrument, selector_string, threshold_enabled, threshold_level, threshold_type); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -4687,6 +4958,9 @@ namespace nirfmxspecan_grpc { } auto status = library_->DPDCfgLookupTableType(instrument, selector_string, lookup_table_type); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -4708,6 +4982,9 @@ namespace nirfmxspecan_grpc { char* selector_string = (char*)request->selector_string().c_str(); float64 measurement_interval = request->measurement_interval(); auto status = library_->DPDCfgMeasurementInterval(instrument, selector_string, measurement_interval); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -4745,6 +5022,9 @@ namespace nirfmxspecan_grpc { float64 sample_rate = request->sample_rate(); auto status = library_->DPDCfgMeasurementSampleRate(instrument, selector_string, sample_rate_mode, sample_rate); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -4767,6 +5047,9 @@ namespace nirfmxspecan_grpc { int32 memory_polynomial_order = request->memory_polynomial_order(); int32 memory_polynomial_memory_depth = request->memory_polynomial_memory_depth(); auto status = library_->DPDCfgMemoryPolynomial(instrument, selector_string, memory_polynomial_order, memory_polynomial_memory_depth); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -4789,6 +5072,9 @@ namespace nirfmxspecan_grpc { auto previous_dpd_polynomial = convert_from_grpc(request->previous_dpd_polynomial()); int32 array_size = static_cast(request->previous_dpd_polynomial().size()); auto status = library_->DPDCfgPreviousDPDPolynomial(instrument, selector_string, previous_dpd_polynomial.data(), array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -4845,6 +5131,9 @@ namespace nirfmxspecan_grpc { } auto status = library_->DPDCfgReferenceWaveform(instrument, selector_string, x0, dx, reference_waveform.data(), array_size, idle_duration_present, signal_type); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -4881,6 +5170,9 @@ namespace nirfmxspecan_grpc { } auto status = library_->DPDCfgSynchronizationMethod(instrument, selector_string, synchronization_method); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -4903,10 +5195,11 @@ namespace nirfmxspecan_grpc { float64 timeout = request->timeout(); float64 pre_cfr_papr {}; auto status = library_->DPDFetchApplyDPDPreCFRPAPR(instrument, selector_string, timeout, &pre_cfr_papr); - response->set_status(status); - if (status_ok(status)) { - response->set_pre_cfr_papr(pre_cfr_papr); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_pre_cfr_papr(pre_cfr_papr); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -4928,10 +5221,11 @@ namespace nirfmxspecan_grpc { float64 timeout = request->timeout(); float64 average_gain {}; auto status = library_->DPDFetchAverageGain(instrument, selector_string, timeout, &average_gain); - response->set_status(status); - if (status_ok(status)) { - response->set_average_gain(average_gain); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_average_gain(average_gain); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -4954,9 +5248,8 @@ namespace nirfmxspecan_grpc { int32 actual_array_size {}; while (true) { auto status = library_->DPDFetchDPDPolynomial(instrument, selector_string, timeout, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } std::vector dpd_polynomial(actual_array_size, NIComplexSingle()); auto array_size = actual_array_size; @@ -4965,18 +5258,19 @@ namespace nirfmxspecan_grpc { // buffer is now too small, try again continue; } + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); - if (status_ok(status)) { - convert_to_grpc(dpd_polynomial, response->mutable_dpd_polynomial()); - { - auto shrunk_size = actual_array_size; - auto current_size = response->mutable_dpd_polynomial()->size(); - if (shrunk_size != current_size) { - response->mutable_dpd_polynomial()->DeleteSubrange(shrunk_size, current_size - shrunk_size); - } + convert_to_grpc(dpd_polynomial, response->mutable_dpd_polynomial()); + { + auto shrunk_size = actual_array_size; + auto current_size = response->mutable_dpd_polynomial()->size(); + if (shrunk_size != current_size) { + response->mutable_dpd_polynomial()->DeleteSubrange(shrunk_size, current_size - shrunk_size); } - response->set_actual_array_size(actual_array_size); } + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -5000,9 +5294,8 @@ namespace nirfmxspecan_grpc { int32 actual_array_size {}; while (true) { auto status = library_->DPDFetchLookupTable(instrument, selector_string, timeout, nullptr, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_input_powers()->Resize(actual_array_size, 0); float32* input_powers = response->mutable_input_powers()->mutable_data(); @@ -5013,19 +5306,20 @@ namespace nirfmxspecan_grpc { // buffer is now too small, try again continue; } + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); - if (status_ok(status)) { - response->mutable_input_powers()->Resize(actual_array_size, 0); - convert_to_grpc(complex_gains, response->mutable_complex_gains()); - { - auto shrunk_size = actual_array_size; - auto current_size = response->mutable_complex_gains()->size(); - if (shrunk_size != current_size) { - response->mutable_complex_gains()->DeleteSubrange(shrunk_size, current_size - shrunk_size); - } + response->mutable_input_powers()->Resize(actual_array_size, 0); + convert_to_grpc(complex_gains, response->mutable_complex_gains()); + { + auto shrunk_size = actual_array_size; + auto current_size = response->mutable_complex_gains()->size(); + if (shrunk_size != current_size) { + response->mutable_complex_gains()->DeleteSubrange(shrunk_size, current_size - shrunk_size); } - response->set_actual_array_size(actual_array_size); } + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -5048,10 +5342,11 @@ namespace nirfmxspecan_grpc { float64 timeout = request->timeout(); float64 nmse {}; auto status = library_->DPDFetchNMSE(instrument, selector_string, timeout, &nmse); - response->set_status(status); - if (status_ok(status)) { - response->set_nmse(nmse); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_nmse(nmse); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -5076,9 +5371,8 @@ namespace nirfmxspecan_grpc { int32 actual_array_size {}; while (true) { auto status = library_->DPDFetchProcessedMeanAcquiredWaveform(instrument, selector_string, timeout, &x0, &dx, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } std::vector processed_mean_acquired_waveform(actual_array_size, NIComplexSingle()); auto array_size = actual_array_size; @@ -5087,20 +5381,21 @@ namespace nirfmxspecan_grpc { // buffer is now too small, try again continue; } + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); - if (status_ok(status)) { - response->set_x0(x0); - response->set_dx(dx); - convert_to_grpc(processed_mean_acquired_waveform, response->mutable_processed_mean_acquired_waveform()); - { - auto shrunk_size = actual_array_size; - auto current_size = response->mutable_processed_mean_acquired_waveform()->size(); - if (shrunk_size != current_size) { - response->mutable_processed_mean_acquired_waveform()->DeleteSubrange(shrunk_size, current_size - shrunk_size); - } + response->set_x0(x0); + response->set_dx(dx); + convert_to_grpc(processed_mean_acquired_waveform, response->mutable_processed_mean_acquired_waveform()); + { + auto shrunk_size = actual_array_size; + auto current_size = response->mutable_processed_mean_acquired_waveform()->size(); + if (shrunk_size != current_size) { + response->mutable_processed_mean_acquired_waveform()->DeleteSubrange(shrunk_size, current_size - shrunk_size); } - response->set_actual_array_size(actual_array_size); } + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -5126,9 +5421,8 @@ namespace nirfmxspecan_grpc { int32 actual_array_size {}; while (true) { auto status = library_->DPDFetchProcessedReferenceWaveform(instrument, selector_string, timeout, &x0, &dx, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } std::vector processed_reference_waveform(actual_array_size, NIComplexSingle()); auto array_size = actual_array_size; @@ -5137,20 +5431,21 @@ namespace nirfmxspecan_grpc { // buffer is now too small, try again continue; } + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); - if (status_ok(status)) { - response->set_x0(x0); - response->set_dx(dx); - convert_to_grpc(processed_reference_waveform, response->mutable_processed_reference_waveform()); - { - auto shrunk_size = actual_array_size; - auto current_size = response->mutable_processed_reference_waveform()->size(); - if (shrunk_size != current_size) { - response->mutable_processed_reference_waveform()->DeleteSubrange(shrunk_size, current_size - shrunk_size); - } + response->set_x0(x0); + response->set_dx(dx); + convert_to_grpc(processed_reference_waveform, response->mutable_processed_reference_waveform()); + { + auto shrunk_size = actual_array_size; + auto current_size = response->mutable_processed_reference_waveform()->size(); + if (shrunk_size != current_size) { + response->mutable_processed_reference_waveform()->DeleteSubrange(shrunk_size, current_size - shrunk_size); } - response->set_actual_array_size(actual_array_size); } + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -5171,6 +5466,9 @@ namespace nirfmxspecan_grpc { niRFmxInstrHandle instrument = session_repository_->access_session(instrument_grpc_session.id(), instrument_grpc_session.name()); char* list_name = (char*)request->list_name().c_str(); auto status = library_->DeleteList(instrument, list_name); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -5191,6 +5489,9 @@ namespace nirfmxspecan_grpc { niRFmxInstrHandle instrument = session_repository_->access_session(instrument_grpc_session.id(), instrument_grpc_session.name()); char* signal_name = (char*)request->signal_name().c_str(); auto status = library_->DeleteSignalConfiguration(instrument, signal_name); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -5211,6 +5512,9 @@ namespace nirfmxspecan_grpc { niRFmxInstrHandle instrument = session_repository_->access_session(instrument_grpc_session.id(), instrument_grpc_session.name()); char* selector_string = (char*)request->selector_string().c_str(); auto status = library_->DisableTrigger(instrument, selector_string); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -5264,6 +5568,9 @@ namespace nirfmxspecan_grpc { } auto status = library_->FCntCfgAveraging(instrument, selector_string, averaging_enabled, averaging_count, averaging_type); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -5285,6 +5592,9 @@ namespace nirfmxspecan_grpc { char* selector_string = (char*)request->selector_string().c_str(); float64 measurement_interval = request->measurement_interval(); auto status = library_->FCntCfgMeasurementInterval(instrument, selector_string, measurement_interval); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -5323,6 +5633,9 @@ namespace nirfmxspecan_grpc { float64 rrc_alpha = request->rrc_alpha(); auto status = library_->FCntCfgRBWFilter(instrument, selector_string, rbw, rbw_filter_type, rrc_alpha); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -5376,6 +5689,9 @@ namespace nirfmxspecan_grpc { } auto status = library_->FCntCfgThreshold(instrument, selector_string, threshold_enabled, threshold_level, threshold_type); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -5398,10 +5714,11 @@ namespace nirfmxspecan_grpc { float64 timeout = request->timeout(); float64 allan_deviation {}; auto status = library_->FCntFetchAllanDeviation(instrument, selector_string, timeout, &allan_deviation); - response->set_status(status); - if (status_ok(status)) { - response->set_allan_deviation(allan_deviation); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_allan_deviation(allan_deviation); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -5426,9 +5743,8 @@ namespace nirfmxspecan_grpc { int32 actual_array_size {}; while (true) { auto status = library_->FCntFetchFrequencyTrace(instrument, selector_string, timeout, &x0, &dx, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_frequency_trace()->Resize(actual_array_size, 0); float32* frequency_trace = response->mutable_frequency_trace()->mutable_data(); @@ -5438,13 +5754,14 @@ namespace nirfmxspecan_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_x0(x0); - response->set_dx(dx); - response->mutable_frequency_trace()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_x0(x0); + response->set_dx(dx); + response->mutable_frequency_trace()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -5469,12 +5786,13 @@ namespace nirfmxspecan_grpc { float64 average_absolute_frequency {}; float64 mean_phase {}; auto status = library_->FCntFetchMeasurement(instrument, selector_string, timeout, &average_relative_frequency, &average_absolute_frequency, &mean_phase); - response->set_status(status); - if (status_ok(status)) { - response->set_average_relative_frequency(average_relative_frequency); - response->set_average_absolute_frequency(average_absolute_frequency); - response->set_mean_phase(mean_phase); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_average_relative_frequency(average_relative_frequency); + response->set_average_absolute_frequency(average_absolute_frequency); + response->set_mean_phase(mean_phase); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -5499,9 +5817,8 @@ namespace nirfmxspecan_grpc { int32 actual_array_size {}; while (true) { auto status = library_->FCntFetchPhaseTrace(instrument, selector_string, timeout, &x0, &dx, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_phase_trace()->Resize(actual_array_size, 0); float32* phase_trace = response->mutable_phase_trace()->mutable_data(); @@ -5511,13 +5828,14 @@ namespace nirfmxspecan_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_x0(x0); - response->set_dx(dx); - response->mutable_phase_trace()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_x0(x0); + response->set_dx(dx); + response->mutable_phase_trace()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -5543,9 +5861,8 @@ namespace nirfmxspecan_grpc { int32 actual_array_size {}; while (true) { auto status = library_->FCntFetchPowerTrace(instrument, selector_string, timeout, &x0, &dx, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_power_trace()->Resize(actual_array_size, 0); float32* power_trace = response->mutable_power_trace()->mutable_data(); @@ -5555,13 +5872,14 @@ namespace nirfmxspecan_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_x0(x0); - response->set_dx(dx); - response->mutable_power_trace()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_x0(x0); + response->set_dx(dx); + response->mutable_power_trace()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -5586,12 +5904,13 @@ namespace nirfmxspecan_grpc { float64 average_absolute_frequency {}; float64 mean_phase {}; auto status = library_->FCntRead(instrument, selector_string, timeout, &average_relative_frequency, &average_absolute_frequency, &mean_phase); - response->set_status(status); - if (status_ok(status)) { - response->set_average_relative_frequency(average_relative_frequency); - response->set_average_absolute_frequency(average_absolute_frequency); - response->set_mean_phase(mean_phase); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_average_relative_frequency(average_relative_frequency); + response->set_average_absolute_frequency(average_absolute_frequency); + response->set_mean_phase(mean_phase); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -5614,9 +5933,8 @@ namespace nirfmxspecan_grpc { int32 default_result_exists {}; while (true) { auto status = library_->GetAllNamedResultNames(instrument, selector_string, nullptr, 0, &actual_result_names_size, &default_result_exists); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } std::string result_names; if (actual_result_names_size > 0) { @@ -5628,13 +5946,14 @@ namespace nirfmxspecan_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_result_names(result_names); - nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_result_names())); - response->set_actual_result_names_size(actual_result_names_size); - response->set_default_result_exists(default_result_exists); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_result_names(result_names); + nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_result_names())); + response->set_actual_result_names_size(actual_result_names_size); + response->set_default_result_exists(default_result_exists); return ::grpc::Status::OK; } } @@ -5657,10 +5976,11 @@ namespace nirfmxspecan_grpc { int32 attribute_id = request->attribute_id(); float32 attr_val {}; auto status = library_->GetAttributeF32(instrument, selector_string, attribute_id, &attr_val); - response->set_status(status); - if (status_ok(status)) { - response->set_attr_val(attr_val); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_attr_val(attr_val); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -5683,9 +6003,8 @@ namespace nirfmxspecan_grpc { int32 actual_array_size {}; while (true) { auto status = library_->GetAttributeF32Array(instrument, selector_string, attribute_id, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_attr_val()->Resize(actual_array_size, 0); float32* attr_val = response->mutable_attr_val()->mutable_data(); @@ -5695,11 +6014,12 @@ namespace nirfmxspecan_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->mutable_attr_val()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->mutable_attr_val()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -5722,10 +6042,11 @@ namespace nirfmxspecan_grpc { int32 attribute_id = request->attribute_id(); float64 attr_val {}; auto status = library_->GetAttributeF64(instrument, selector_string, attribute_id, &attr_val); - response->set_status(status); - if (status_ok(status)) { - response->set_attr_val(attr_val); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_attr_val(attr_val); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -5748,9 +6069,8 @@ namespace nirfmxspecan_grpc { int32 actual_array_size {}; while (true) { auto status = library_->GetAttributeF64Array(instrument, selector_string, attribute_id, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_attr_val()->Resize(actual_array_size, 0); float64* attr_val = response->mutable_attr_val()->mutable_data(); @@ -5760,11 +6080,12 @@ namespace nirfmxspecan_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->mutable_attr_val()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->mutable_attr_val()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -5787,10 +6108,11 @@ namespace nirfmxspecan_grpc { int32 attribute_id = request->attribute_id(); int16 attr_val {}; auto status = library_->GetAttributeI16(instrument, selector_string, attribute_id, &attr_val); - response->set_status(status); - if (status_ok(status)) { - response->set_attr_val(attr_val); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_attr_val(attr_val); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -5812,16 +6134,17 @@ namespace nirfmxspecan_grpc { int32 attribute_id = request->attribute_id(); int32 attr_val {}; auto status = library_->GetAttributeI32(instrument, selector_string, attribute_id, &attr_val); - response->set_status(status); - if (status_ok(status)) { - auto checked_convert_attr_val = [](auto raw_value) { - bool raw_value_is_valid = nirfmxspecan_grpc::NiRFmxSpecAnInt32AttributeValues_IsValid(raw_value); - auto valid_enum_value = raw_value_is_valid ? raw_value : 0; - return static_cast(valid_enum_value); - }; - response->set_attr_val(checked_convert_attr_val(attr_val)); - response->set_attr_val_raw(attr_val); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + auto checked_convert_attr_val = [](auto raw_value) { + bool raw_value_is_valid = nirfmxspecan_grpc::NiRFmxSpecAnInt32AttributeValues_IsValid(raw_value); + auto valid_enum_value = raw_value_is_valid ? raw_value : 0; + return static_cast(valid_enum_value); + }; + response->set_attr_val(checked_convert_attr_val(attr_val)); + response->set_attr_val_raw(attr_val); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -5844,9 +6167,8 @@ namespace nirfmxspecan_grpc { int32 actual_array_size {}; while (true) { auto status = library_->GetAttributeI32Array(instrument, selector_string, attribute_id, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_attr_val_raw()->Resize(actual_array_size, 0); int32* attr_val = reinterpret_cast(response->mutable_attr_val_raw()->mutable_data()); @@ -5856,13 +6178,15 @@ namespace nirfmxspecan_grpc { // buffer is now too small, try again continue; } + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); - if (status_ok(status)) { - auto checked_convert_attr_val = [](auto raw_value) { - bool raw_value_is_valid = nirfmxspecan_grpc::NiRFmxSpecAnInt32AttributeValues_IsValid(raw_value); - auto valid_enum_value = raw_value_is_valid ? raw_value : 0; - return static_cast(valid_enum_value); - }; + auto checked_convert_attr_val = [](auto raw_value) { + bool raw_value_is_valid = nirfmxspecan_grpc::NiRFmxSpecAnInt32AttributeValues_IsValid(raw_value); + auto valid_enum_value = raw_value_is_valid ? raw_value : 0; + return static_cast(valid_enum_value); + }; response->mutable_attr_val()->Clear(); response->mutable_attr_val()->Reserve(actual_array_size); std::transform( @@ -5872,9 +6196,8 @@ namespace nirfmxspecan_grpc { [&](auto x) { return checked_convert_attr_val(x); }); - response->mutable_attr_val()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); - } + response->mutable_attr_val()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -5897,10 +6220,11 @@ namespace nirfmxspecan_grpc { int32 attribute_id = request->attribute_id(); int64 attr_val {}; auto status = library_->GetAttributeI64(instrument, selector_string, attribute_id, &attr_val); - response->set_status(status); - if (status_ok(status)) { - response->set_attr_val(attr_val); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_attr_val(attr_val); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -5923,9 +6247,8 @@ namespace nirfmxspecan_grpc { int32 actual_array_size {}; while (true) { auto status = library_->GetAttributeI64Array(instrument, selector_string, attribute_id, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_attr_val()->Resize(actual_array_size, 0); int64* attr_val = reinterpret_cast(response->mutable_attr_val()->mutable_data()); @@ -5935,11 +6258,12 @@ namespace nirfmxspecan_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->mutable_attr_val()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->mutable_attr_val()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -5962,10 +6286,11 @@ namespace nirfmxspecan_grpc { int32 attribute_id = request->attribute_id(); int8 attr_val {}; auto status = library_->GetAttributeI8(instrument, selector_string, attribute_id, &attr_val); - response->set_status(status); - if (status_ok(status)) { - response->set_attr_val(attr_val); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_attr_val(attr_val); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -5988,9 +6313,8 @@ namespace nirfmxspecan_grpc { int32 actual_array_size {}; while (true) { auto status = library_->GetAttributeI8Array(instrument, selector_string, attribute_id, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } std::vector attr_val(actual_array_size); auto array_size = actual_array_size; @@ -5999,8 +6323,10 @@ namespace nirfmxspecan_grpc { // buffer is now too small, try again continue; } + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); - if (status_ok(status)) { response->mutable_attr_val()->Clear(); response->mutable_attr_val()->Reserve(actual_array_size); std::transform( @@ -6010,9 +6336,8 @@ namespace nirfmxspecan_grpc { [&](auto x) { return x; }); - response->mutable_attr_val()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); - } + response->mutable_attr_val()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -6036,9 +6361,8 @@ namespace nirfmxspecan_grpc { int32 actual_array_size {}; while (true) { auto status = library_->GetAttributeNIComplexDoubleArray(instrument, selector_string, attribute_id, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } std::vector attr_val(actual_array_size, NIComplexDouble()); auto array_size = actual_array_size; @@ -6047,18 +6371,19 @@ namespace nirfmxspecan_grpc { // buffer is now too small, try again continue; } + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); - if (status_ok(status)) { - convert_to_grpc(attr_val, response->mutable_attr_val()); - { - auto shrunk_size = actual_array_size; - auto current_size = response->mutable_attr_val()->size(); - if (shrunk_size != current_size) { - response->mutable_attr_val()->DeleteSubrange(shrunk_size, current_size - shrunk_size); - } + convert_to_grpc(attr_val, response->mutable_attr_val()); + { + auto shrunk_size = actual_array_size; + auto current_size = response->mutable_attr_val()->size(); + if (shrunk_size != current_size) { + response->mutable_attr_val()->DeleteSubrange(shrunk_size, current_size - shrunk_size); } - response->set_actual_array_size(actual_array_size); } + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -6082,9 +6407,8 @@ namespace nirfmxspecan_grpc { int32 actual_array_size {}; while (true) { auto status = library_->GetAttributeNIComplexSingleArray(instrument, selector_string, attribute_id, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } std::vector attr_val(actual_array_size, NIComplexSingle()); auto array_size = actual_array_size; @@ -6093,18 +6417,19 @@ namespace nirfmxspecan_grpc { // buffer is now too small, try again continue; } + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); - if (status_ok(status)) { - convert_to_grpc(attr_val, response->mutable_attr_val()); - { - auto shrunk_size = actual_array_size; - auto current_size = response->mutable_attr_val()->size(); - if (shrunk_size != current_size) { - response->mutable_attr_val()->DeleteSubrange(shrunk_size, current_size - shrunk_size); - } + convert_to_grpc(attr_val, response->mutable_attr_val()); + { + auto shrunk_size = actual_array_size; + auto current_size = response->mutable_attr_val()->size(); + if (shrunk_size != current_size) { + response->mutable_attr_val()->DeleteSubrange(shrunk_size, current_size - shrunk_size); } - response->set_actual_array_size(actual_array_size); } + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -6128,9 +6453,8 @@ namespace nirfmxspecan_grpc { while (true) { auto status = library_->GetAttributeString(instrument, selector_string, attribute_id, 0, nullptr); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } int32 array_size = status; @@ -6143,11 +6467,12 @@ namespace nirfmxspecan_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_attr_val(attr_val); - nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_attr_val())); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_attr_val(attr_val); + nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_attr_val())); return ::grpc::Status::OK; } } @@ -6170,10 +6495,11 @@ namespace nirfmxspecan_grpc { int32 attribute_id = request->attribute_id(); uInt16 attr_val {}; auto status = library_->GetAttributeU16(instrument, selector_string, attribute_id, &attr_val); - response->set_status(status); - if (status_ok(status)) { - response->set_attr_val(attr_val); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_attr_val(attr_val); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -6195,10 +6521,11 @@ namespace nirfmxspecan_grpc { int32 attribute_id = request->attribute_id(); uInt32 attr_val {}; auto status = library_->GetAttributeU32(instrument, selector_string, attribute_id, &attr_val); - response->set_status(status); - if (status_ok(status)) { - response->set_attr_val(attr_val); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_attr_val(attr_val); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -6221,9 +6548,8 @@ namespace nirfmxspecan_grpc { int32 actual_array_size {}; while (true) { auto status = library_->GetAttributeU32Array(instrument, selector_string, attribute_id, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_attr_val()->Resize(actual_array_size, 0); uInt32* attr_val = reinterpret_cast(response->mutable_attr_val()->mutable_data()); @@ -6233,11 +6559,12 @@ namespace nirfmxspecan_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->mutable_attr_val()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->mutable_attr_val()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -6261,9 +6588,8 @@ namespace nirfmxspecan_grpc { int32 actual_array_size {}; while (true) { auto status = library_->GetAttributeU64Array(instrument, selector_string, attribute_id, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_attr_val()->Resize(actual_array_size, 0); uInt64* attr_val = reinterpret_cast(response->mutable_attr_val()->mutable_data()); @@ -6273,11 +6599,12 @@ namespace nirfmxspecan_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->mutable_attr_val()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->mutable_attr_val()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -6300,10 +6627,11 @@ namespace nirfmxspecan_grpc { int32 attribute_id = request->attribute_id(); uInt8 attr_val {}; auto status = library_->GetAttributeU8(instrument, selector_string, attribute_id, &attr_val); - response->set_status(status); - if (status_ok(status)) { - response->set_attr_val(attr_val); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_attr_val(attr_val); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -6326,9 +6654,8 @@ namespace nirfmxspecan_grpc { int32 actual_array_size {}; while (true) { auto status = library_->GetAttributeU8Array(instrument, selector_string, attribute_id, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } std::string attr_val(actual_array_size, '\0'); auto array_size = actual_array_size; @@ -6337,12 +6664,13 @@ namespace nirfmxspecan_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_attr_val(attr_val); - response->mutable_attr_val()->resize(actual_array_size); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_attr_val(attr_val); + response->mutable_attr_val()->resize(actual_array_size); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -6364,9 +6692,8 @@ namespace nirfmxspecan_grpc { while (true) { auto status = library_->GetError(instrument, nullptr, 0, nullptr); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } int32 error_description_buffer_size = status; @@ -6380,12 +6707,13 @@ namespace nirfmxspecan_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_error_code(error_code); - response->set_error_description(error_description); - nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_error_description())); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_error_code(error_code); + response->set_error_description(error_description); + nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_error_description())); return ::grpc::Status::OK; } } @@ -6408,9 +6736,8 @@ namespace nirfmxspecan_grpc { while (true) { auto status = library_->GetErrorString(instrument, error_code, 0, nullptr); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } int32 error_description_buffer_size = status; @@ -6423,11 +6750,12 @@ namespace nirfmxspecan_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_error_description(error_description); - nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_error_description())); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_error_description(error_description); + nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_error_description())); return ::grpc::Status::OK; } } @@ -6464,6 +6792,9 @@ namespace nirfmxspecan_grpc { } auto status = library_->HarmCfgAutoHarmonics(instrument, selector_string, auto_harmonics_setup_enabled); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -6517,6 +6848,9 @@ namespace nirfmxspecan_grpc { } auto status = library_->HarmCfgAveraging(instrument, selector_string, averaging_enabled, averaging_count, averaging_type); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -6538,6 +6872,9 @@ namespace nirfmxspecan_grpc { char* selector_string = (char*)request->selector_string().c_str(); float64 measurement_interval = request->measurement_interval(); auto status = library_->HarmCfgFundamentalMeasurementInterval(instrument, selector_string, measurement_interval); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -6576,6 +6913,9 @@ namespace nirfmxspecan_grpc { float64 rrc_alpha = request->rrc_alpha(); auto status = library_->HarmCfgFundamentalRBW(instrument, selector_string, rbw, rbw_filter_type, rrc_alpha); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -6615,6 +6955,9 @@ namespace nirfmxspecan_grpc { float64 harmonic_measurement_interval = request->harmonic_measurement_interval(); auto status = library_->HarmCfgHarmonic(instrument, selector_string, harmonic_order, harmonic_bandwidth, harmonic_enabled, harmonic_measurement_interval); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -6668,6 +7011,9 @@ namespace nirfmxspecan_grpc { auto number_of_elements = number_of_elements_size_calculation.size; auto status = library_->HarmCfgHarmonicArray(instrument, selector_string, harmonic_order, harmonic_bandwidth, harmonic_enabled, harmonic_measurement_interval, number_of_elements); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -6689,6 +7035,9 @@ namespace nirfmxspecan_grpc { char* selector_string = (char*)request->selector_string().c_str(); int32 number_of_harmonics = request->number_of_harmonics(); auto status = library_->HarmCfgNumberOfHarmonics(instrument, selector_string, number_of_harmonics); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -6714,13 +7063,14 @@ namespace nirfmxspecan_grpc { float64 rbw {}; float64 frequency {}; auto status = library_->HarmFetchHarmonicMeasurement(instrument, selector_string, timeout, &average_relative_power, &average_absolute_power, &rbw, &frequency); - response->set_status(status); - if (status_ok(status)) { - response->set_average_relative_power(average_relative_power); - response->set_average_absolute_power(average_absolute_power); - response->set_rbw(rbw); - response->set_frequency(frequency); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_average_relative_power(average_relative_power); + response->set_average_absolute_power(average_absolute_power); + response->set_rbw(rbw); + response->set_frequency(frequency); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -6743,9 +7093,8 @@ namespace nirfmxspecan_grpc { int32 actual_array_size {}; while (true) { auto status = library_->HarmFetchHarmonicMeasurementArray(instrument, selector_string, timeout, nullptr, nullptr, nullptr, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_average_relative_power()->Resize(actual_array_size, 0); float64* average_relative_power = response->mutable_average_relative_power()->mutable_data(); @@ -6761,14 +7110,15 @@ namespace nirfmxspecan_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->mutable_average_relative_power()->Resize(actual_array_size, 0); - response->mutable_average_absolute_power()->Resize(actual_array_size, 0); - response->mutable_rbw()->Resize(actual_array_size, 0); - response->mutable_frequency()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->mutable_average_relative_power()->Resize(actual_array_size, 0); + response->mutable_average_absolute_power()->Resize(actual_array_size, 0); + response->mutable_rbw()->Resize(actual_array_size, 0); + response->mutable_frequency()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -6794,9 +7144,8 @@ namespace nirfmxspecan_grpc { int32 actual_array_size {}; while (true) { auto status = library_->HarmFetchHarmonicPowerTrace(instrument, selector_string, timeout, &x0, &dx, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_power()->Resize(actual_array_size, 0); float32* power = response->mutable_power()->mutable_data(); @@ -6806,13 +7155,14 @@ namespace nirfmxspecan_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_x0(x0); - response->set_dx(dx); - response->mutable_power()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_x0(x0); + response->set_dx(dx); + response->mutable_power()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -6837,12 +7187,13 @@ namespace nirfmxspecan_grpc { float64 average_fundamental_power {}; float64 fundamental_frequency {}; auto status = library_->HarmFetchTHD(instrument, selector_string, timeout, &total_harmonic_distortion, &average_fundamental_power, &fundamental_frequency); - response->set_status(status); - if (status_ok(status)) { - response->set_total_harmonic_distortion(total_harmonic_distortion); - response->set_average_fundamental_power(average_fundamental_power); - response->set_fundamental_frequency(fundamental_frequency); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_total_harmonic_distortion(total_harmonic_distortion); + response->set_average_fundamental_power(average_fundamental_power); + response->set_fundamental_frequency(fundamental_frequency); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -6865,11 +7216,12 @@ namespace nirfmxspecan_grpc { float64 total_harmonic_distortion {}; float64 average_fundamental_power {}; auto status = library_->HarmRead(instrument, selector_string, timeout, &total_harmonic_distortion, &average_fundamental_power); - response->set_status(status); - if (status_ok(status)) { - response->set_total_harmonic_distortion(total_harmonic_distortion); - response->set_average_fundamental_power(average_fundamental_power); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_total_harmonic_distortion(total_harmonic_distortion); + response->set_average_fundamental_power(average_fundamental_power); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -6906,6 +7258,9 @@ namespace nirfmxspecan_grpc { int32 maximum_intermod_order = request->maximum_intermod_order(); auto status = library_->IMCfgAutoIntermodsSetup(instrument, selector_string, auto_intermods_setup_enabled, maximum_intermod_order); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -6959,6 +7314,9 @@ namespace nirfmxspecan_grpc { } auto status = library_->IMCfgAveraging(instrument, selector_string, averaging_enabled, averaging_count, averaging_type); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -6996,6 +7354,9 @@ namespace nirfmxspecan_grpc { float64 fft_padding = request->fft_padding(); auto status = library_->IMCfgFFT(instrument, selector_string, fft_window, fft_padding); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -7032,6 +7393,9 @@ namespace nirfmxspecan_grpc { } auto status = library_->IMCfgFrequencyDefinition(instrument, selector_string, frequency_definition); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -7054,6 +7418,9 @@ namespace nirfmxspecan_grpc { float64 lower_tone_frequency = request->lower_tone_frequency(); float64 upper_tone_frequency = request->upper_tone_frequency(); auto status = library_->IMCfgFundamentalTones(instrument, selector_string, lower_tone_frequency, upper_tone_frequency); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -7109,6 +7476,9 @@ namespace nirfmxspecan_grpc { } auto status = library_->IMCfgIntermod(instrument, selector_string, intermod_order, lower_intermod_frequency, upper_intermod_frequency, intermod_side, intermod_enabled); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -7173,6 +7543,9 @@ namespace nirfmxspecan_grpc { auto number_of_elements = number_of_elements_size_calculation.size; auto status = library_->IMCfgIntermodArray(instrument, selector_string, intermod_order, lower_intermod_frequency, upper_intermod_frequency, intermod_side, intermod_enabled, number_of_elements); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -7209,6 +7582,9 @@ namespace nirfmxspecan_grpc { } auto status = library_->IMCfgMeasurementMethod(instrument, selector_string, measurement_method); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -7230,6 +7606,9 @@ namespace nirfmxspecan_grpc { char* selector_string = (char*)request->selector_string().c_str(); int32 number_of_intermods = request->number_of_intermods(); auto status = library_->IMCfgNumberOfIntermods(instrument, selector_string, number_of_intermods); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -7283,6 +7662,9 @@ namespace nirfmxspecan_grpc { } auto status = library_->IMCfgRBWFilter(instrument, selector_string, rbw_auto, rbw, rbw_filter_type); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -7320,6 +7702,9 @@ namespace nirfmxspecan_grpc { float64 sweep_time_interval = request->sweep_time_interval(); auto status = library_->IMCfgSweepTime(instrument, selector_string, sweep_time_auto, sweep_time_interval); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -7343,11 +7728,12 @@ namespace nirfmxspecan_grpc { float64 lower_tone_power {}; float64 upper_tone_power {}; auto status = library_->IMFetchFundamentalMeasurement(instrument, selector_string, timeout, &lower_tone_power, &upper_tone_power); - response->set_status(status); - if (status_ok(status)) { - response->set_lower_tone_power(lower_tone_power); - response->set_upper_tone_power(upper_tone_power); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_lower_tone_power(lower_tone_power); + response->set_upper_tone_power(upper_tone_power); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -7372,13 +7758,14 @@ namespace nirfmxspecan_grpc { float64 lower_output_intercept_power {}; float64 upper_output_intercept_power {}; auto status = library_->IMFetchInterceptPower(instrument, selector_string, timeout, &intermod_order, &worst_case_output_intercept_power, &lower_output_intercept_power, &upper_output_intercept_power); - response->set_status(status); - if (status_ok(status)) { - response->set_intermod_order(intermod_order); - response->set_worst_case_output_intercept_power(worst_case_output_intercept_power); - response->set_lower_output_intercept_power(lower_output_intercept_power); - response->set_upper_output_intercept_power(upper_output_intercept_power); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_intermod_order(intermod_order); + response->set_worst_case_output_intercept_power(worst_case_output_intercept_power); + response->set_lower_output_intercept_power(lower_output_intercept_power); + response->set_upper_output_intercept_power(upper_output_intercept_power); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -7401,9 +7788,8 @@ namespace nirfmxspecan_grpc { int32 actual_array_size {}; while (true) { auto status = library_->IMFetchInterceptPowerArray(instrument, selector_string, timeout, nullptr, nullptr, nullptr, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_intermod_order()->Resize(actual_array_size, 0); int32* intermod_order = reinterpret_cast(response->mutable_intermod_order()->mutable_data()); @@ -7419,14 +7805,15 @@ namespace nirfmxspecan_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->mutable_intermod_order()->Resize(actual_array_size, 0); - response->mutable_worst_case_output_intercept_power()->Resize(actual_array_size, 0); - response->mutable_lower_output_intercept_power()->Resize(actual_array_size, 0); - response->mutable_upper_output_intercept_power()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->mutable_intermod_order()->Resize(actual_array_size, 0); + response->mutable_worst_case_output_intercept_power()->Resize(actual_array_size, 0); + response->mutable_lower_output_intercept_power()->Resize(actual_array_size, 0); + response->mutable_upper_output_intercept_power()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -7451,12 +7838,13 @@ namespace nirfmxspecan_grpc { float64 lower_intermod_power {}; float64 upper_intermod_power {}; auto status = library_->IMFetchIntermodMeasurement(instrument, selector_string, timeout, &intermod_order, &lower_intermod_power, &upper_intermod_power); - response->set_status(status); - if (status_ok(status)) { - response->set_intermod_order(intermod_order); - response->set_lower_intermod_power(lower_intermod_power); - response->set_upper_intermod_power(upper_intermod_power); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_intermod_order(intermod_order); + response->set_lower_intermod_power(lower_intermod_power); + response->set_upper_intermod_power(upper_intermod_power); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -7479,9 +7867,8 @@ namespace nirfmxspecan_grpc { int32 actual_array_size {}; while (true) { auto status = library_->IMFetchIntermodMeasurementArray(instrument, selector_string, timeout, nullptr, nullptr, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_intermod_order()->Resize(actual_array_size, 0); int32* intermod_order = reinterpret_cast(response->mutable_intermod_order()->mutable_data()); @@ -7495,13 +7882,14 @@ namespace nirfmxspecan_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->mutable_intermod_order()->Resize(actual_array_size, 0); - response->mutable_lower_intermod_power()->Resize(actual_array_size, 0); - response->mutable_upper_intermod_power()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->mutable_intermod_order()->Resize(actual_array_size, 0); + response->mutable_lower_intermod_power()->Resize(actual_array_size, 0); + response->mutable_upper_intermod_power()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -7528,9 +7916,8 @@ namespace nirfmxspecan_grpc { int32 actual_array_size {}; while (true) { auto status = library_->IMFetchSpectrum(instrument, selector_string, timeout, spectrum_index, &x0, &dx, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_spectrum()->Resize(actual_array_size, 0); float32* spectrum = response->mutable_spectrum()->mutable_data(); @@ -7540,13 +7927,14 @@ namespace nirfmxspecan_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_x0(x0); - response->set_dx(dx); - response->mutable_spectrum()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_x0(x0); + response->set_dx(dx); + response->mutable_spectrum()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -7571,6 +7959,9 @@ namespace nirfmxspecan_grpc { float64 acquisition_time = request->acquisition_time(); float64 pretrigger_time = request->pretrigger_time(); auto status = library_->IQCfgAcquisition(instrument, selector_string, sample_rate, number_of_records, acquisition_time, pretrigger_time); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -7608,6 +7999,9 @@ namespace nirfmxspecan_grpc { float64 bandwidth = request->bandwidth(); auto status = library_->IQCfgBandwidth(instrument, selector_string, bandwidth_auto, bandwidth); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -7635,9 +8029,8 @@ namespace nirfmxspecan_grpc { int32 actual_array_size {}; while (true) { auto status = library_->IQFetchData(instrument, selector_string, timeout, record_to_fetch, samples_to_read, &t0, &dt, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } std::vector data(actual_array_size, NIComplexSingle()); auto array_size = actual_array_size; @@ -7646,20 +8039,21 @@ namespace nirfmxspecan_grpc { // buffer is now too small, try again continue; } + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); - if (status_ok(status)) { - response->set_t0(t0); - response->set_dt(dt); - convert_to_grpc(data, response->mutable_data()); - { - auto shrunk_size = actual_array_size; - auto current_size = response->mutable_data()->size(); - if (shrunk_size != current_size) { - response->mutable_data()->DeleteSubrange(shrunk_size, current_size - shrunk_size); - } + response->set_t0(t0); + response->set_dt(dt); + convert_to_grpc(data, response->mutable_data()); + { + auto shrunk_size = actual_array_size; + auto current_size = response->mutable_data()->size(); + if (shrunk_size != current_size) { + response->mutable_data()->DeleteSubrange(shrunk_size, current_size - shrunk_size); } - response->set_actual_array_size(actual_array_size); } + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -7681,10 +8075,11 @@ namespace nirfmxspecan_grpc { char* selector_string = (char*)request->selector_string().c_str(); int32 records_done {}; auto status = library_->IQGetRecordsDone(instrument, selector_string, &records_done); - response->set_status(status); - if (status_ok(status)) { - response->set_records_done(records_done); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_records_done(records_done); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -7713,15 +8108,12 @@ namespace nirfmxspecan_grpc { const std::string& grpc_device_session_name = request->session_name(); auto cleanup_lambda = [&] (niRFmxInstrHandle id) { library_->Close(id, RFMXSPECAN_VAL_FALSE); }; int status = session_repository_->add_session(grpc_device_session_name, init_lambda, cleanup_lambda, session_id); - response->set_status(status); - if (status_ok(status)) { - response->mutable_instrument()->set_id(session_id); - response->set_is_new_session(is_new_session); - } - else { - const auto error_message = get_last_error_message(library_); - response->set_error_message(error_message); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, 0); } + response->set_status(status); + response->mutable_instrument()->set_id(session_id); + response->set_is_new_session(is_new_session); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -7752,14 +8144,11 @@ namespace nirfmxspecan_grpc { const std::string& grpc_device_session_name = request->session_name(); auto cleanup_lambda = [&] (niRFmxInstrHandle id) { library_->Close(id, RFMXSPECAN_VAL_FALSE); }; int status = session_repository_->add_session(grpc_device_session_name, init_lambda, cleanup_lambda, session_id); - response->set_status(status); - if (status_ok(status)) { - response->mutable_instrument()->set_id(session_id); - } - else { - const auto error_message = get_last_error_message(library_); - response->set_error_message(error_message); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, 0); } + response->set_status(status); + response->mutable_instrument()->set_id(session_id); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -7783,6 +8172,9 @@ namespace nirfmxspecan_grpc { char* selector_string = (char*)request->selector_string().c_str(); char* result_name = (char*)request->result_name().c_str(); auto status = library_->Initiate(instrument, selector_string, result_name); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -7804,6 +8196,9 @@ namespace nirfmxspecan_grpc { char* selector_string = (char*)request->selector_string().c_str(); int32 number_of_markers = request->number_of_markers(); auto status = library_->MarkerCfgNumberOfMarkers(instrument, selector_string, number_of_markers); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -7841,6 +8236,9 @@ namespace nirfmxspecan_grpc { float64 peak_excursion = request->peak_excursion(); auto status = library_->MarkerCfgPeakExcursion(instrument, selector_string, peak_excursion_enabled, peak_excursion); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -7862,6 +8260,9 @@ namespace nirfmxspecan_grpc { char* selector_string = (char*)request->selector_string().c_str(); int32 reference_marker = request->reference_marker(); auto status = library_->MarkerCfgReferenceMarker(instrument, selector_string, reference_marker); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -7899,6 +8300,9 @@ namespace nirfmxspecan_grpc { float64 threshold = request->threshold(); auto status = library_->MarkerCfgThreshold(instrument, selector_string, threshold_enabled, threshold); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -7935,6 +8339,9 @@ namespace nirfmxspecan_grpc { } auto status = library_->MarkerCfgTrace(instrument, selector_string, trace); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -7971,6 +8378,9 @@ namespace nirfmxspecan_grpc { } auto status = library_->MarkerCfgType(instrument, selector_string, marker_type); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -7992,6 +8402,9 @@ namespace nirfmxspecan_grpc { char* selector_string = (char*)request->selector_string().c_str(); float64 marker_x_location = request->marker_x_location(); auto status = library_->MarkerCfgXLocation(instrument, selector_string, marker_x_location); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -8014,11 +8427,12 @@ namespace nirfmxspecan_grpc { float64 marker_x_location {}; float64 marker_y_location {}; auto status = library_->MarkerFetchXY(instrument, selector_string, &marker_x_location, &marker_y_location); - response->set_status(status); - if (status_ok(status)) { - response->set_marker_x_location(marker_x_location); - response->set_marker_y_location(marker_y_location); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_marker_x_location(marker_x_location); + response->set_marker_y_location(marker_y_location); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -8055,10 +8469,11 @@ namespace nirfmxspecan_grpc { int32 next_peak_found {}; auto status = library_->MarkerNextPeak(instrument, selector_string, next_peak, &next_peak_found); - response->set_status(status); - if (status_ok(status)) { - response->set_next_peak_found(next_peak_found); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_next_peak_found(next_peak_found); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -8079,10 +8494,11 @@ namespace nirfmxspecan_grpc { char* selector_string = (char*)request->selector_string().c_str(); int32 number_of_peaks {}; auto status = library_->MarkerPeakSearch(instrument, selector_string, &number_of_peaks); - response->set_status(status); - if (status_ok(status)) { - response->set_number_of_peaks(number_of_peaks); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_number_of_peaks(number_of_peaks); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -8119,6 +8535,9 @@ namespace nirfmxspecan_grpc { int32 averaging_count = request->averaging_count(); auto status = library_->NFCfgAveraging(instrument, selector_string, averaging_enabled, averaging_count); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -8175,6 +8594,9 @@ namespace nirfmxspecan_grpc { auto array_size = array_size_size_calculation.size; auto status = library_->NFCfgCalibrationLoss(instrument, selector_string, calibration_loss_compensation_enabled, calibration_loss_frequency, calibration_loss, calibration_loss_temperature, array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -8223,6 +8645,9 @@ namespace nirfmxspecan_grpc { auto array_size = array_size_size_calculation.size; auto status = library_->NFCfgColdSourceDUTSParameters(instrument, selector_string, dut_s_parameters_frequency, dut_s21, dut_s12, dut_s11, dut_s22, array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -8263,6 +8688,9 @@ namespace nirfmxspecan_grpc { auto array_size = array_size_size_calculation.size; auto status = library_->NFCfgColdSourceInputTermination(instrument, selector_string, termination_vswr, termination_vswr_frequency, termination_temperature, array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -8299,6 +8727,9 @@ namespace nirfmxspecan_grpc { } auto status = library_->NFCfgColdSourceMode(instrument, selector_string, cold_source_mode); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -8355,6 +8786,9 @@ namespace nirfmxspecan_grpc { auto array_size = array_size_size_calculation.size; auto status = library_->NFCfgDUTInputLoss(instrument, selector_string, dut_input_loss_compensation_enabled, dut_input_loss_frequency, dut_input_loss, dut_input_loss_temperature, array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -8411,6 +8845,9 @@ namespace nirfmxspecan_grpc { auto array_size = array_size_size_calculation.size; auto status = library_->NFCfgDUTOutputLoss(instrument, selector_string, dut_output_loss_compensation_enabled, dut_output_loss_frequency, dut_output_loss, dut_output_loss_temperature, array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -8433,6 +8870,9 @@ namespace nirfmxspecan_grpc { auto frequency_list = const_cast(request->frequency_list().data()); int32 array_size = static_cast(request->frequency_list().size()); auto status = library_->NFCfgFrequencyList(instrument, selector_string, frequency_list, array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -8456,6 +8896,9 @@ namespace nirfmxspecan_grpc { float64 stop_frequency = request->stop_frequency(); int32 number_of_points = request->number_of_points(); auto status = library_->NFCfgFrequencyListStartStopPoints(instrument, selector_string, start_frequency, stop_frequency, number_of_points); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -8479,6 +8922,9 @@ namespace nirfmxspecan_grpc { float64 stop_frequency = request->stop_frequency(); float64 step_size = request->step_size(); auto status = library_->NFCfgFrequencyListStartStopStep(instrument, selector_string, start_frequency, stop_frequency, step_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -8500,6 +8946,9 @@ namespace nirfmxspecan_grpc { char* selector_string = (char*)request->selector_string().c_str(); float64 measurement_bandwidth = request->measurement_bandwidth(); auto status = library_->NFCfgMeasurementBandwidth(instrument, selector_string, measurement_bandwidth); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -8521,6 +8970,9 @@ namespace nirfmxspecan_grpc { char* selector_string = (char*)request->selector_string().c_str(); float64 measurement_interval = request->measurement_interval(); auto status = library_->NFCfgMeasurementInterval(instrument, selector_string, measurement_interval); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -8557,6 +9009,9 @@ namespace nirfmxspecan_grpc { } auto status = library_->NFCfgMeasurementMethod(instrument, selector_string, measurement_method); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -8593,6 +9048,9 @@ namespace nirfmxspecan_grpc { } auto status = library_->NFCfgYFactorMode(instrument, selector_string, y_factor_mode); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -8634,6 +9092,9 @@ namespace nirfmxspecan_grpc { auto array_size = array_size_size_calculation.size; auto status = library_->NFCfgYFactorNoiseSourceENR(instrument, selector_string, enr_frequency, enr, cold_temperature, off_temperature, array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -8690,6 +9151,9 @@ namespace nirfmxspecan_grpc { auto array_size = array_size_size_calculation.size; auto status = library_->NFCfgYFactorNoiseSourceLoss(instrument, selector_string, noise_source_loss_compensation_enabled, noise_source_loss_frequency, noise_source_loss, noise_source_loss_temperature, array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -8711,6 +9175,9 @@ namespace nirfmxspecan_grpc { char* selector_string = (char*)request->selector_string().c_str(); float64 settling_time = request->settling_time(); auto status = library_->NFCfgYFactorNoiseSourceSettlingTime(instrument, selector_string, settling_time); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -8731,6 +9198,9 @@ namespace nirfmxspecan_grpc { niRFmxInstrHandle instrument = session_repository_->access_session(instrument_grpc_session.id(), instrument_grpc_session.name()); char* calibration_setup_id = (char*)request->calibration_setup_id().c_str(); auto status = library_->NFClearCalibrationDatabase(instrument, calibration_setup_id); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -8754,9 +9224,8 @@ namespace nirfmxspecan_grpc { int32 actual_array_size {}; while (true) { auto status = library_->NFFetchAnalyzerNoiseFigure(instrument, selector_string, timeout, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_analyzer_noise_figure()->Resize(actual_array_size, 0); float64* analyzer_noise_figure = response->mutable_analyzer_noise_figure()->mutable_data(); @@ -8766,11 +9235,12 @@ namespace nirfmxspecan_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->mutable_analyzer_noise_figure()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->mutable_analyzer_noise_figure()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -8794,9 +9264,8 @@ namespace nirfmxspecan_grpc { int32 actual_array_size {}; while (true) { auto status = library_->NFFetchColdSourcePower(instrument, selector_string, timeout, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_cold_source_power()->Resize(actual_array_size, 0); float64* cold_source_power = response->mutable_cold_source_power()->mutable_data(); @@ -8806,11 +9275,12 @@ namespace nirfmxspecan_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->mutable_cold_source_power()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->mutable_cold_source_power()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -8834,9 +9304,8 @@ namespace nirfmxspecan_grpc { int32 actual_array_size {}; while (true) { auto status = library_->NFFetchDUTNoiseFigureAndGain(instrument, selector_string, timeout, nullptr, nullptr, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_dut_noise_figure()->Resize(actual_array_size, 0); float64* dut_noise_figure = response->mutable_dut_noise_figure()->mutable_data(); @@ -8850,13 +9319,14 @@ namespace nirfmxspecan_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->mutable_dut_noise_figure()->Resize(actual_array_size, 0); - response->mutable_dut_noise_temperature()->Resize(actual_array_size, 0); - response->mutable_dut_gain()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->mutable_dut_noise_figure()->Resize(actual_array_size, 0); + response->mutable_dut_noise_temperature()->Resize(actual_array_size, 0); + response->mutable_dut_gain()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -8880,9 +9350,8 @@ namespace nirfmxspecan_grpc { int32 actual_array_size {}; while (true) { auto status = library_->NFFetchYFactorPowers(instrument, selector_string, timeout, nullptr, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_hot_power()->Resize(actual_array_size, 0); float64* hot_power = response->mutable_hot_power()->mutable_data(); @@ -8894,12 +9363,13 @@ namespace nirfmxspecan_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->mutable_hot_power()->Resize(actual_array_size, 0); - response->mutable_cold_power()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->mutable_hot_power()->Resize(actual_array_size, 0); + response->mutable_cold_power()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -8923,9 +9393,8 @@ namespace nirfmxspecan_grpc { int32 actual_array_size {}; while (true) { auto status = library_->NFFetchYFactors(instrument, selector_string, timeout, nullptr, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_measurement_y_factor()->Resize(actual_array_size, 0); float64* measurement_y_factor = response->mutable_measurement_y_factor()->mutable_data(); @@ -8937,12 +9406,13 @@ namespace nirfmxspecan_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->mutable_measurement_y_factor()->Resize(actual_array_size, 0); - response->mutable_calibration_y_factor()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->mutable_measurement_y_factor()->Resize(actual_array_size, 0); + response->mutable_calibration_y_factor()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -8966,10 +9436,11 @@ namespace nirfmxspecan_grpc { float64 dut_max_noise_figure = request->dut_max_noise_figure(); float64 reference_level {}; auto status = library_->NFRecommendReferenceLevel(instrument, selector_string, dut_max_gain, dut_max_noise_figure, &reference_level); - response->set_status(status); - if (status_ok(status)) { - response->set_reference_level(reference_level); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_reference_level(reference_level); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -8990,11 +9461,12 @@ namespace nirfmxspecan_grpc { char* selector_string = (char*)request->selector_string().c_str(); int32 calibration_data_valid {}; auto status = library_->NFValidateCalibrationData(instrument, selector_string, &calibration_data_valid); - response->set_status(status); - if (status_ok(status)) { - response->set_calibration_data_valid(static_cast(calibration_data_valid)); - response->set_calibration_data_valid_raw(calibration_data_valid); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_calibration_data_valid(static_cast(calibration_data_valid)); + response->set_calibration_data_valid_raw(calibration_data_valid); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -9047,6 +9519,9 @@ namespace nirfmxspecan_grpc { } auto status = library_->OBWCfgAveraging(instrument, selector_string, averaging_enabled, averaging_count, averaging_type); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -9068,6 +9543,9 @@ namespace nirfmxspecan_grpc { char* selector_string = (char*)request->selector_string().c_str(); float64 bandwidth_percentage = request->bandwidth_percentage(); auto status = library_->OBWCfgBandwidthPercentage(instrument, selector_string, bandwidth_percentage); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -9105,6 +9583,9 @@ namespace nirfmxspecan_grpc { float64 fft_padding = request->fft_padding(); auto status = library_->OBWCfgFFT(instrument, selector_string, fft_window, fft_padding); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -9141,6 +9622,9 @@ namespace nirfmxspecan_grpc { } auto status = library_->OBWCfgPowerUnits(instrument, selector_string, power_units); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -9194,6 +9678,9 @@ namespace nirfmxspecan_grpc { } auto status = library_->OBWCfgRBWFilter(instrument, selector_string, rbw_auto, rbw, rbw_filter_type); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -9215,6 +9702,9 @@ namespace nirfmxspecan_grpc { char* selector_string = (char*)request->selector_string().c_str(); float64 span = request->span(); auto status = library_->OBWCfgSpan(instrument, selector_string, span); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -9252,6 +9742,9 @@ namespace nirfmxspecan_grpc { float64 sweep_time_interval = request->sweep_time_interval(); auto status = library_->OBWCfgSweepTime(instrument, selector_string, sweep_time_auto, sweep_time_interval); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -9278,14 +9771,15 @@ namespace nirfmxspecan_grpc { float64 start_frequency {}; float64 stop_frequency {}; auto status = library_->OBWFetchMeasurement(instrument, selector_string, timeout, &occupied_bandwidth, &average_power, &frequency_resolution, &start_frequency, &stop_frequency); - response->set_status(status); - if (status_ok(status)) { - response->set_occupied_bandwidth(occupied_bandwidth); - response->set_average_power(average_power); - response->set_frequency_resolution(frequency_resolution); - response->set_start_frequency(start_frequency); - response->set_stop_frequency(stop_frequency); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_occupied_bandwidth(occupied_bandwidth); + response->set_average_power(average_power); + response->set_frequency_resolution(frequency_resolution); + response->set_start_frequency(start_frequency); + response->set_stop_frequency(stop_frequency); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -9310,9 +9804,8 @@ namespace nirfmxspecan_grpc { int32 actual_array_size {}; while (true) { auto status = library_->OBWFetchSpectrumTrace(instrument, selector_string, timeout, &x0, &dx, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_spectrum()->Resize(actual_array_size, 0); float32* spectrum = response->mutable_spectrum()->mutable_data(); @@ -9322,13 +9815,14 @@ namespace nirfmxspecan_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_x0(x0); - response->set_dx(dx); - response->mutable_spectrum()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_x0(x0); + response->set_dx(dx); + response->mutable_spectrum()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -9355,14 +9849,15 @@ namespace nirfmxspecan_grpc { float64 start_frequency {}; float64 stop_frequency {}; auto status = library_->OBWRead(instrument, selector_string, timeout, &occupied_bandwidth, &average_power, &frequency_resolution, &start_frequency, &stop_frequency); - response->set_status(status); - if (status_ok(status)) { - response->set_occupied_bandwidth(occupied_bandwidth); - response->set_average_power(average_power); - response->set_frequency_resolution(frequency_resolution); - response->set_start_frequency(start_frequency); - response->set_stop_frequency(stop_frequency); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_occupied_bandwidth(occupied_bandwidth); + response->set_average_power(average_power); + response->set_frequency_resolution(frequency_resolution); + response->set_start_frequency(start_frequency); + response->set_stop_frequency(stop_frequency); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -9383,6 +9878,9 @@ namespace nirfmxspecan_grpc { char* selector_string = (char*)request->selector_string().c_str(); float64 measurement_bandwidth = request->measurement_bandwidth(); auto status = library_->PAVTCfgMeasurementBandwidth(instrument, selector_string, measurement_bandwidth); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -9405,6 +9903,9 @@ namespace nirfmxspecan_grpc { float64 measurement_offset = request->measurement_offset(); float64 measurement_length = request->measurement_length(); auto status = library_->PAVTCfgMeasurementInterval(instrument, selector_string, measurement_offset, measurement_length); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -9441,6 +9942,9 @@ namespace nirfmxspecan_grpc { } auto status = library_->PAVTCfgMeasurementIntervalMode(instrument, selector_string, measurement_interval_mode); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -9477,6 +9981,9 @@ namespace nirfmxspecan_grpc { } auto status = library_->PAVTCfgMeasurementLocationType(instrument, selector_string, measurement_location_type); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -9498,6 +10005,9 @@ namespace nirfmxspecan_grpc { char* selector_string = (char*)request->selector_string().c_str(); int32 number_of_segments = request->number_of_segments(); auto status = library_->PAVTCfgNumberOfSegments(instrument, selector_string, number_of_segments); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -9520,6 +10030,9 @@ namespace nirfmxspecan_grpc { float64 segment_measurement_offset = request->segment_measurement_offset(); float64 segment_measurement_length = request->segment_measurement_length(); auto status = library_->PAVTCfgSegmentMeasurementInterval(instrument, selector_string, segment_measurement_offset, segment_measurement_length); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -9559,6 +10072,9 @@ namespace nirfmxspecan_grpc { auto number_of_elements = number_of_elements_size_calculation.size; auto status = library_->PAVTCfgSegmentMeasurementIntervalArray(instrument, selector_string, segment_measurement_offset, segment_measurement_length, number_of_elements); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -9581,6 +10097,9 @@ namespace nirfmxspecan_grpc { auto segment_start_time = const_cast(request->segment_start_time().data()); int32 number_of_elements = static_cast(request->segment_start_time().size()); auto status = library_->PAVTCfgSegmentStartTimeList(instrument, selector_string, segment_start_time, number_of_elements); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -9604,6 +10123,9 @@ namespace nirfmxspecan_grpc { float64 segment0_start_time = request->segment0_start_time(); float64 segment_interval = request->segment_interval(); auto status = library_->PAVTCfgSegmentStartTimeStep(instrument, selector_string, number_of_segments, segment0_start_time, segment_interval); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -9640,6 +10162,9 @@ namespace nirfmxspecan_grpc { } auto status = library_->PAVTCfgSegmentType(instrument, selector_string, segment_type); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -9670,6 +10195,9 @@ namespace nirfmxspecan_grpc { int32 number_of_elements = static_cast(request->segment_type().size()); auto status = library_->PAVTCfgSegmentTypeArray(instrument, selector_string, segment_type, number_of_elements); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -9696,9 +10224,8 @@ namespace nirfmxspecan_grpc { int32 actual_array_size {}; while (true) { auto status = library_->PAVTFetchAmplitudeTrace(instrument, selector_string, timeout, trace_index, &x0, &dx, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_amplitude()->Resize(actual_array_size, 0); float32* amplitude = response->mutable_amplitude()->mutable_data(); @@ -9708,13 +10235,14 @@ namespace nirfmxspecan_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_x0(x0); - response->set_dx(dx); - response->mutable_amplitude()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_x0(x0); + response->set_dx(dx); + response->mutable_amplitude()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -9740,13 +10268,14 @@ namespace nirfmxspecan_grpc { float64 mean_absolute_phase {}; float64 mean_absolute_amplitude {}; auto status = library_->PAVTFetchPhaseAndAmplitude(instrument, selector_string, timeout, &mean_relative_phase, &mean_relative_amplitude, &mean_absolute_phase, &mean_absolute_amplitude); - response->set_status(status); - if (status_ok(status)) { - response->set_mean_relative_phase(mean_relative_phase); - response->set_mean_relative_amplitude(mean_relative_amplitude); - response->set_mean_absolute_phase(mean_absolute_phase); - response->set_mean_absolute_amplitude(mean_absolute_amplitude); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_mean_relative_phase(mean_relative_phase); + response->set_mean_relative_amplitude(mean_relative_amplitude); + response->set_mean_absolute_phase(mean_absolute_phase); + response->set_mean_absolute_amplitude(mean_absolute_amplitude); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -9769,9 +10298,8 @@ namespace nirfmxspecan_grpc { int32 actual_array_size {}; while (true) { auto status = library_->PAVTFetchPhaseAndAmplitudeArray(instrument, selector_string, timeout, nullptr, nullptr, nullptr, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_mean_relative_phase()->Resize(actual_array_size, 0); float64* mean_relative_phase = response->mutable_mean_relative_phase()->mutable_data(); @@ -9787,14 +10315,15 @@ namespace nirfmxspecan_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->mutable_mean_relative_phase()->Resize(actual_array_size, 0); - response->mutable_mean_relative_amplitude()->Resize(actual_array_size, 0); - response->mutable_mean_absolute_phase()->Resize(actual_array_size, 0); - response->mutable_mean_absolute_amplitude()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->mutable_mean_relative_phase()->Resize(actual_array_size, 0); + response->mutable_mean_relative_amplitude()->Resize(actual_array_size, 0); + response->mutable_mean_absolute_phase()->Resize(actual_array_size, 0); + response->mutable_mean_absolute_amplitude()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -9821,9 +10350,8 @@ namespace nirfmxspecan_grpc { int32 actual_array_size {}; while (true) { auto status = library_->PAVTFetchPhaseTrace(instrument, selector_string, timeout, trace_index, &x0, &dx, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_phase()->Resize(actual_array_size, 0); float32* phase = response->mutable_phase()->mutable_data(); @@ -9833,13 +10361,14 @@ namespace nirfmxspecan_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_x0(x0); - response->set_dx(dx); - response->mutable_phase()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_x0(x0); + response->set_dx(dx); + response->mutable_phase()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -9863,6 +10392,9 @@ namespace nirfmxspecan_grpc { float64 stop_frequency = request->stop_frequency(); float64 rbw_percentage = request->rbw_percentage(); auto status = library_->PhaseNoiseCfgAutoRange(instrument, selector_string, start_frequency, stop_frequency, rbw_percentage); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -9884,6 +10416,9 @@ namespace nirfmxspecan_grpc { char* selector_string = (char*)request->selector_string().c_str(); int32 averaging_multiplier = request->averaging_multiplier(); auto status = library_->PhaseNoiseCfgAveragingMultiplier(instrument, selector_string, averaging_multiplier); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -9940,6 +10475,9 @@ namespace nirfmxspecan_grpc { auto array_size = array_size_size_calculation.size; auto status = library_->PhaseNoiseCfgCancellation(instrument, selector_string, cancellation_enabled, cancellation_threshold, frequency, reference_phase_noise, array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -9995,6 +10533,9 @@ namespace nirfmxspecan_grpc { auto array_size = array_size_size_calculation.size; auto status = library_->PhaseNoiseCfgIntegratedNoise(instrument, selector_string, integrated_noise_range_definition, integrated_noise_start_frequency, integrated_noise_stop_frequency, array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -10016,6 +10557,9 @@ namespace nirfmxspecan_grpc { char* selector_string = (char*)request->selector_string().c_str(); int32 number_of_ranges = request->number_of_ranges(); auto status = library_->PhaseNoiseCfgNumberOfRanges(instrument, selector_string, number_of_ranges); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -10061,6 +10605,9 @@ namespace nirfmxspecan_grpc { auto number_of_elements = number_of_elements_size_calculation.size; auto status = library_->PhaseNoiseCfgRangeArray(instrument, selector_string, range_start_frequency, range_stop_frequency, range_rbw_percentage, range_averaging_count, number_of_elements); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -10097,6 +10644,9 @@ namespace nirfmxspecan_grpc { } auto status = library_->PhaseNoiseCfgRangeDefinition(instrument, selector_string, range_definition); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -10134,6 +10684,9 @@ namespace nirfmxspecan_grpc { float64 smoothing_percentage = request->smoothing_percentage(); auto status = library_->PhaseNoiseCfgSmoothing(instrument, selector_string, smoothing_type, smoothing_percentage); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -10156,6 +10709,9 @@ namespace nirfmxspecan_grpc { auto frequency_list = const_cast(request->frequency_list().data()); int32 array_size = static_cast(request->frequency_list().size()); auto status = library_->PhaseNoiseCfgSpotNoiseFrequencyList(instrument, selector_string, frequency_list, array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -10193,6 +10749,9 @@ namespace nirfmxspecan_grpc { float64 peak_excursion = request->peak_excursion(); auto status = library_->PhaseNoiseCfgSpurRemoval(instrument, selector_string, spur_removal_enabled, peak_excursion); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -10216,11 +10775,12 @@ namespace nirfmxspecan_grpc { float64 carrier_frequency {}; float64 carrier_power {}; auto status = library_->PhaseNoiseFetchCarrierMeasurement(instrument, selector_string, timeout, &carrier_frequency, &carrier_power); - response->set_status(status); - if (status_ok(status)) { - response->set_carrier_frequency(carrier_frequency); - response->set_carrier_power(carrier_power); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_carrier_frequency(carrier_frequency); + response->set_carrier_power(carrier_power); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -10243,9 +10803,8 @@ namespace nirfmxspecan_grpc { int32 actual_array_size {}; while (true) { auto status = library_->PhaseNoiseFetchIntegratedNoise(instrument, selector_string, timeout, nullptr, nullptr, nullptr, nullptr, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_integrated_phase_noise()->Resize(actual_array_size, 0); float64* integrated_phase_noise = response->mutable_integrated_phase_noise()->mutable_data(); @@ -10263,15 +10822,16 @@ namespace nirfmxspecan_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->mutable_integrated_phase_noise()->Resize(actual_array_size, 0); - response->mutable_residual_pm_in_radian()->Resize(actual_array_size, 0); - response->mutable_residual_pm_in_degree()->Resize(actual_array_size, 0); - response->mutable_residual_fm()->Resize(actual_array_size, 0); - response->mutable_jitter()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->mutable_integrated_phase_noise()->Resize(actual_array_size, 0); + response->mutable_residual_pm_in_radian()->Resize(actual_array_size, 0); + response->mutable_residual_pm_in_degree()->Resize(actual_array_size, 0); + response->mutable_residual_fm()->Resize(actual_array_size, 0); + response->mutable_jitter()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -10295,9 +10855,8 @@ namespace nirfmxspecan_grpc { int32 actual_array_size {}; while (true) { auto status = library_->PhaseNoiseFetchMeasuredLogPlotTrace(instrument, selector_string, timeout, nullptr, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_frequency()->Resize(actual_array_size, 0); float32* frequency = response->mutable_frequency()->mutable_data(); @@ -10309,12 +10868,13 @@ namespace nirfmxspecan_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->mutable_frequency()->Resize(actual_array_size, 0); - response->mutable_measured_phase_noise()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->mutable_frequency()->Resize(actual_array_size, 0); + response->mutable_measured_phase_noise()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -10338,9 +10898,8 @@ namespace nirfmxspecan_grpc { int32 actual_array_size {}; while (true) { auto status = library_->PhaseNoiseFetchSmoothedLogPlotTrace(instrument, selector_string, timeout, nullptr, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_frequency()->Resize(actual_array_size, 0); float32* frequency = response->mutable_frequency()->mutable_data(); @@ -10352,12 +10911,13 @@ namespace nirfmxspecan_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->mutable_frequency()->Resize(actual_array_size, 0); - response->mutable_smoothed_phase_noise()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->mutable_frequency()->Resize(actual_array_size, 0); + response->mutable_smoothed_phase_noise()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -10381,9 +10941,8 @@ namespace nirfmxspecan_grpc { int32 actual_array_size {}; while (true) { auto status = library_->PhaseNoiseFetchSpotNoise(instrument, selector_string, timeout, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_spot_phase_noise()->Resize(actual_array_size, 0); float64* spot_phase_noise = response->mutable_spot_phase_noise()->mutable_data(); @@ -10393,11 +10952,12 @@ namespace nirfmxspecan_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->mutable_spot_phase_noise()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->mutable_spot_phase_noise()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -10419,6 +10979,9 @@ namespace nirfmxspecan_grpc { char* selector_string = (char*)request->selector_string().c_str(); int32 attribute_id = request->attribute_id(); auto status = library_->ResetAttribute(instrument, selector_string, attribute_id); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -10439,6 +11002,9 @@ namespace nirfmxspecan_grpc { niRFmxInstrHandle instrument = session_repository_->access_session(instrument_grpc_session.id(), instrument_grpc_session.name()); char* selector_string = (char*)request->selector_string().c_str(); auto status = library_->ResetToDefault(instrument, selector_string); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -10492,6 +11058,9 @@ namespace nirfmxspecan_grpc { } auto status = library_->SEMCfgAveraging(instrument, selector_string, averaging_enabled, averaging_count, averaging_type); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -10513,6 +11082,9 @@ namespace nirfmxspecan_grpc { char* selector_string = (char*)request->selector_string().c_str(); float64 carrier_channel_bandwidth = request->carrier_channel_bandwidth(); auto status = library_->SEMCfgCarrierChannelBandwidth(instrument, selector_string, carrier_channel_bandwidth); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -10549,6 +11121,9 @@ namespace nirfmxspecan_grpc { } auto status = library_->SEMCfgCarrierEnabled(instrument, selector_string, carrier_enabled); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -10570,6 +11145,9 @@ namespace nirfmxspecan_grpc { char* selector_string = (char*)request->selector_string().c_str(); float64 carrier_frequency = request->carrier_frequency(); auto status = library_->SEMCfgCarrierFrequency(instrument, selector_string, carrier_frequency); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -10591,6 +11169,9 @@ namespace nirfmxspecan_grpc { char* selector_string = (char*)request->selector_string().c_str(); float64 integration_bandwidth = request->integration_bandwidth(); auto status = library_->SEMCfgCarrierIntegrationBandwidth(instrument, selector_string, integration_bandwidth); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -10644,6 +11225,9 @@ namespace nirfmxspecan_grpc { } auto status = library_->SEMCfgCarrierRBWFilter(instrument, selector_string, rbw_auto, rbw, rbw_filter_type); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -10681,6 +11265,9 @@ namespace nirfmxspecan_grpc { float64 rrc_alpha = request->rrc_alpha(); auto status = library_->SEMCfgCarrierRRCFilter(instrument, selector_string, rrc_filter_enabled, rrc_alpha); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -10718,6 +11305,9 @@ namespace nirfmxspecan_grpc { float64 fft_padding = request->fft_padding(); auto status = library_->SEMCfgFFT(instrument, selector_string, fft_window, fft_padding); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -10739,6 +11329,9 @@ namespace nirfmxspecan_grpc { char* selector_string = (char*)request->selector_string().c_str(); int32 number_of_carriers = request->number_of_carriers(); auto status = library_->SEMCfgNumberOfCarriers(instrument, selector_string, number_of_carriers); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -10760,6 +11353,9 @@ namespace nirfmxspecan_grpc { char* selector_string = (char*)request->selector_string().c_str(); int32 number_of_offsets = request->number_of_offsets(); auto status = library_->SEMCfgNumberOfOffsets(instrument, selector_string, number_of_offsets); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -10798,6 +11394,9 @@ namespace nirfmxspecan_grpc { float64 absolute_limit_start = request->absolute_limit_start(); float64 absolute_limit_stop = request->absolute_limit_stop(); auto status = library_->SEMCfgOffsetAbsoluteLimit(instrument, selector_string, absolute_limit_mode, absolute_limit_start, absolute_limit_stop); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -10848,6 +11447,9 @@ namespace nirfmxspecan_grpc { auto number_of_elements = number_of_elements_size_calculation.size; auto status = library_->SEMCfgOffsetAbsoluteLimitArray(instrument, selector_string, absolute_limit_mode, absolute_limit_start, absolute_limit_stop, number_of_elements); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -10869,6 +11471,9 @@ namespace nirfmxspecan_grpc { char* selector_string = (char*)request->selector_string().c_str(); int32 bandwidth_integral = request->bandwidth_integral(); auto status = library_->SEMCfgOffsetBandwidthIntegral(instrument, selector_string, bandwidth_integral); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -10923,6 +11528,9 @@ namespace nirfmxspecan_grpc { } auto status = library_->SEMCfgOffsetFrequency(instrument, selector_string, offset_start_frequency, offset_stop_frequency, offset_enabled, offset_sideband); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -10984,6 +11592,9 @@ namespace nirfmxspecan_grpc { auto number_of_elements = number_of_elements_size_calculation.size; auto status = library_->SEMCfgOffsetFrequencyArray(instrument, selector_string, offset_start_frequency, offset_stop_frequency, offset_enabled, offset_sideband, number_of_elements); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -11020,6 +11631,9 @@ namespace nirfmxspecan_grpc { } auto status = library_->SEMCfgOffsetFrequencyDefinition(instrument, selector_string, offset_frequency_definition); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -11056,6 +11670,9 @@ namespace nirfmxspecan_grpc { } auto status = library_->SEMCfgOffsetLimitFailMask(instrument, selector_string, limit_fail_mask); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -11109,6 +11726,9 @@ namespace nirfmxspecan_grpc { } auto status = library_->SEMCfgOffsetRBWFilter(instrument, selector_string, rbw_auto, rbw, rbw_filter_type); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -11167,6 +11787,9 @@ namespace nirfmxspecan_grpc { auto number_of_elements = number_of_elements_size_calculation.size; auto status = library_->SEMCfgOffsetRBWFilterArray(instrument, selector_string, rbw_auto, rbw, rbw_filter_type, number_of_elements); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -11188,6 +11811,9 @@ namespace nirfmxspecan_grpc { char* selector_string = (char*)request->selector_string().c_str(); float64 relative_attenuation = request->relative_attenuation(); auto status = library_->SEMCfgOffsetRelativeAttenuation(instrument, selector_string, relative_attenuation); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -11210,6 +11836,9 @@ namespace nirfmxspecan_grpc { auto relative_attenuation = const_cast(request->relative_attenuation().data()); int32 number_of_elements = static_cast(request->relative_attenuation().size()); auto status = library_->SEMCfgOffsetRelativeAttenuationArray(instrument, selector_string, relative_attenuation, number_of_elements); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -11248,6 +11877,9 @@ namespace nirfmxspecan_grpc { float64 relative_limit_start = request->relative_limit_start(); float64 relative_limit_stop = request->relative_limit_stop(); auto status = library_->SEMCfgOffsetRelativeLimit(instrument, selector_string, relative_limit_mode, relative_limit_start, relative_limit_stop); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -11298,6 +11930,9 @@ namespace nirfmxspecan_grpc { auto number_of_elements = number_of_elements_size_calculation.size; auto status = library_->SEMCfgOffsetRelativeLimitArray(instrument, selector_string, relative_limit_mode, relative_limit_start, relative_limit_stop, number_of_elements); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -11334,6 +11969,9 @@ namespace nirfmxspecan_grpc { } auto status = library_->SEMCfgPowerUnits(instrument, selector_string, power_units); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -11370,6 +12008,9 @@ namespace nirfmxspecan_grpc { } auto status = library_->SEMCfgReferenceType(instrument, selector_string, reference_type); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -11407,6 +12048,9 @@ namespace nirfmxspecan_grpc { float64 sweep_time_interval = request->sweep_time_interval(); auto status = library_->SEMCfgSweepTime(instrument, selector_string, sweep_time_auto, sweep_time_interval); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -11432,9 +12076,8 @@ namespace nirfmxspecan_grpc { int32 actual_array_size {}; while (true) { auto status = library_->SEMFetchAbsoluteMaskTrace(instrument, selector_string, timeout, &x0, &dx, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_absolute_mask()->Resize(actual_array_size, 0); float32* absolute_mask = response->mutable_absolute_mask()->mutable_data(); @@ -11444,13 +12087,14 @@ namespace nirfmxspecan_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_x0(x0); - response->set_dx(dx); - response->mutable_absolute_mask()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_x0(x0); + response->set_dx(dx); + response->mutable_absolute_mask()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -11476,13 +12120,14 @@ namespace nirfmxspecan_grpc { float64 peak_frequency {}; float64 total_relative_power {}; auto status = library_->SEMFetchCarrierMeasurement(instrument, selector_string, timeout, &absolute_power, &peak_absolute_power, &peak_frequency, &total_relative_power); - response->set_status(status); - if (status_ok(status)) { - response->set_absolute_power(absolute_power); - response->set_peak_absolute_power(peak_absolute_power); - response->set_peak_frequency(peak_frequency); - response->set_total_relative_power(total_relative_power); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_absolute_power(absolute_power); + response->set_peak_absolute_power(peak_absolute_power); + response->set_peak_frequency(peak_frequency); + response->set_total_relative_power(total_relative_power); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -11504,11 +12149,12 @@ namespace nirfmxspecan_grpc { float64 timeout = request->timeout(); int32 composite_measurement_status {}; auto status = library_->SEMFetchCompositeMeasurementStatus(instrument, selector_string, timeout, &composite_measurement_status); - response->set_status(status); - if (status_ok(status)) { - response->set_composite_measurement_status(static_cast(composite_measurement_status)); - response->set_composite_measurement_status_raw(composite_measurement_status); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_composite_measurement_status(static_cast(composite_measurement_status)); + response->set_composite_measurement_status_raw(composite_measurement_status); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -11530,10 +12176,11 @@ namespace nirfmxspecan_grpc { float64 timeout = request->timeout(); float64 frequency_resolution {}; auto status = library_->SEMFetchFrequencyResolution(instrument, selector_string, timeout, &frequency_resolution); - response->set_status(status); - if (status_ok(status)) { - response->set_frequency_resolution(frequency_resolution); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_frequency_resolution(frequency_resolution); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -11559,15 +12206,16 @@ namespace nirfmxspecan_grpc { float64 margin_absolute_power {}; float64 margin_relative_power {}; auto status = library_->SEMFetchLowerOffsetMargin(instrument, selector_string, timeout, &measurement_status, &margin, &margin_frequency, &margin_absolute_power, &margin_relative_power); - response->set_status(status); - if (status_ok(status)) { - response->set_measurement_status(static_cast(measurement_status)); - response->set_measurement_status_raw(measurement_status); - response->set_margin(margin); - response->set_margin_frequency(margin_frequency); - response->set_margin_absolute_power(margin_absolute_power); - response->set_margin_relative_power(margin_relative_power); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_measurement_status(static_cast(measurement_status)); + response->set_measurement_status_raw(measurement_status); + response->set_margin(margin); + response->set_margin_frequency(margin_frequency); + response->set_margin_absolute_power(margin_absolute_power); + response->set_margin_relative_power(margin_relative_power); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -11590,9 +12238,8 @@ namespace nirfmxspecan_grpc { int32 actual_array_size {}; while (true) { auto status = library_->SEMFetchLowerOffsetMarginArray(instrument, selector_string, timeout, nullptr, nullptr, nullptr, nullptr, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_measurement_status_raw()->Resize(actual_array_size, 0); int32* measurement_status = reinterpret_cast(response->mutable_measurement_status_raw()->mutable_data()); @@ -11610,8 +12257,10 @@ namespace nirfmxspecan_grpc { // buffer is now too small, try again continue; } + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); - if (status_ok(status)) { response->mutable_measurement_status()->Clear(); response->mutable_measurement_status()->Reserve(actual_array_size); std::transform( @@ -11621,13 +12270,12 @@ namespace nirfmxspecan_grpc { [&](auto x) { return static_cast(x); }); - response->mutable_measurement_status()->Resize(actual_array_size, 0); - response->mutable_margin()->Resize(actual_array_size, 0); - response->mutable_margin_frequency()->Resize(actual_array_size, 0); - response->mutable_margin_absolute_power()->Resize(actual_array_size, 0); - response->mutable_margin_relative_power()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); - } + response->mutable_measurement_status()->Resize(actual_array_size, 0); + response->mutable_margin()->Resize(actual_array_size, 0); + response->mutable_margin_frequency()->Resize(actual_array_size, 0); + response->mutable_margin_absolute_power()->Resize(actual_array_size, 0); + response->mutable_margin_relative_power()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -11654,14 +12302,15 @@ namespace nirfmxspecan_grpc { float64 peak_frequency {}; float64 peak_relative_power {}; auto status = library_->SEMFetchLowerOffsetPower(instrument, selector_string, timeout, &total_absolute_power, &total_relative_power, &peak_absolute_power, &peak_frequency, &peak_relative_power); - response->set_status(status); - if (status_ok(status)) { - response->set_total_absolute_power(total_absolute_power); - response->set_total_relative_power(total_relative_power); - response->set_peak_absolute_power(peak_absolute_power); - response->set_peak_frequency(peak_frequency); - response->set_peak_relative_power(peak_relative_power); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_total_absolute_power(total_absolute_power); + response->set_total_relative_power(total_relative_power); + response->set_peak_absolute_power(peak_absolute_power); + response->set_peak_frequency(peak_frequency); + response->set_peak_relative_power(peak_relative_power); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -11684,9 +12333,8 @@ namespace nirfmxspecan_grpc { int32 actual_array_size {}; while (true) { auto status = library_->SEMFetchLowerOffsetPowerArray(instrument, selector_string, timeout, nullptr, nullptr, nullptr, nullptr, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_total_absolute_power()->Resize(actual_array_size, 0); float64* total_absolute_power = response->mutable_total_absolute_power()->mutable_data(); @@ -11704,15 +12352,16 @@ namespace nirfmxspecan_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->mutable_total_absolute_power()->Resize(actual_array_size, 0); - response->mutable_total_relative_power()->Resize(actual_array_size, 0); - response->mutable_peak_absolute_power()->Resize(actual_array_size, 0); - response->mutable_peak_frequency()->Resize(actual_array_size, 0); - response->mutable_peak_relative_power()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->mutable_total_absolute_power()->Resize(actual_array_size, 0); + response->mutable_total_relative_power()->Resize(actual_array_size, 0); + response->mutable_peak_absolute_power()->Resize(actual_array_size, 0); + response->mutable_peak_frequency()->Resize(actual_array_size, 0); + response->mutable_peak_relative_power()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -11738,9 +12387,8 @@ namespace nirfmxspecan_grpc { int32 actual_array_size {}; while (true) { auto status = library_->SEMFetchRelativeMaskTrace(instrument, selector_string, timeout, &x0, &dx, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_relative_mask()->Resize(actual_array_size, 0); float32* relative_mask = response->mutable_relative_mask()->mutable_data(); @@ -11750,13 +12398,14 @@ namespace nirfmxspecan_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_x0(x0); - response->set_dx(dx); - response->mutable_relative_mask()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_x0(x0); + response->set_dx(dx); + response->mutable_relative_mask()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -11782,9 +12431,8 @@ namespace nirfmxspecan_grpc { int32 actual_array_size {}; while (true) { auto status = library_->SEMFetchSpectrum(instrument, selector_string, timeout, &x0, &dx, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_spectrum()->Resize(actual_array_size, 0); float32* spectrum = response->mutable_spectrum()->mutable_data(); @@ -11794,13 +12442,14 @@ namespace nirfmxspecan_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_x0(x0); - response->set_dx(dx); - response->mutable_spectrum()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_x0(x0); + response->set_dx(dx); + response->mutable_spectrum()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -11823,10 +12472,11 @@ namespace nirfmxspecan_grpc { float64 timeout = request->timeout(); float64 total_carrier_power {}; auto status = library_->SEMFetchTotalCarrierPower(instrument, selector_string, timeout, &total_carrier_power); - response->set_status(status); - if (status_ok(status)) { - response->set_total_carrier_power(total_carrier_power); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_total_carrier_power(total_carrier_power); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -11852,15 +12502,16 @@ namespace nirfmxspecan_grpc { float64 margin_absolute_power {}; float64 margin_relative_power {}; auto status = library_->SEMFetchUpperOffsetMargin(instrument, selector_string, timeout, &measurement_status, &margin, &margin_frequency, &margin_absolute_power, &margin_relative_power); - response->set_status(status); - if (status_ok(status)) { - response->set_measurement_status(static_cast(measurement_status)); - response->set_measurement_status_raw(measurement_status); - response->set_margin(margin); - response->set_margin_frequency(margin_frequency); - response->set_margin_absolute_power(margin_absolute_power); - response->set_margin_relative_power(margin_relative_power); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_measurement_status(static_cast(measurement_status)); + response->set_measurement_status_raw(measurement_status); + response->set_margin(margin); + response->set_margin_frequency(margin_frequency); + response->set_margin_absolute_power(margin_absolute_power); + response->set_margin_relative_power(margin_relative_power); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -11883,9 +12534,8 @@ namespace nirfmxspecan_grpc { int32 actual_array_size {}; while (true) { auto status = library_->SEMFetchUpperOffsetMarginArray(instrument, selector_string, timeout, nullptr, nullptr, nullptr, nullptr, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_measurement_status_raw()->Resize(actual_array_size, 0); int32* measurement_status = reinterpret_cast(response->mutable_measurement_status_raw()->mutable_data()); @@ -11903,8 +12553,10 @@ namespace nirfmxspecan_grpc { // buffer is now too small, try again continue; } + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); - if (status_ok(status)) { response->mutable_measurement_status()->Clear(); response->mutable_measurement_status()->Reserve(actual_array_size); std::transform( @@ -11914,13 +12566,12 @@ namespace nirfmxspecan_grpc { [&](auto x) { return static_cast(x); }); - response->mutable_measurement_status()->Resize(actual_array_size, 0); - response->mutable_margin()->Resize(actual_array_size, 0); - response->mutable_margin_frequency()->Resize(actual_array_size, 0); - response->mutable_margin_absolute_power()->Resize(actual_array_size, 0); - response->mutable_margin_relative_power()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); - } + response->mutable_measurement_status()->Resize(actual_array_size, 0); + response->mutable_margin()->Resize(actual_array_size, 0); + response->mutable_margin_frequency()->Resize(actual_array_size, 0); + response->mutable_margin_absolute_power()->Resize(actual_array_size, 0); + response->mutable_margin_relative_power()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -11947,14 +12598,15 @@ namespace nirfmxspecan_grpc { float64 peak_frequency {}; float64 peak_relative_power {}; auto status = library_->SEMFetchUpperOffsetPower(instrument, selector_string, timeout, &total_absolute_power, &total_relative_power, &peak_absolute_power, &peak_frequency, &peak_relative_power); - response->set_status(status); - if (status_ok(status)) { - response->set_total_absolute_power(total_absolute_power); - response->set_total_relative_power(total_relative_power); - response->set_peak_absolute_power(peak_absolute_power); - response->set_peak_frequency(peak_frequency); - response->set_peak_relative_power(peak_relative_power); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_total_absolute_power(total_absolute_power); + response->set_total_relative_power(total_relative_power); + response->set_peak_absolute_power(peak_absolute_power); + response->set_peak_frequency(peak_frequency); + response->set_peak_relative_power(peak_relative_power); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -11977,9 +12629,8 @@ namespace nirfmxspecan_grpc { int32 actual_array_size {}; while (true) { auto status = library_->SEMFetchUpperOffsetPowerArray(instrument, selector_string, timeout, nullptr, nullptr, nullptr, nullptr, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_total_absolute_power()->Resize(actual_array_size, 0); float64* total_absolute_power = response->mutable_total_absolute_power()->mutable_data(); @@ -11997,15 +12648,16 @@ namespace nirfmxspecan_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->mutable_total_absolute_power()->Resize(actual_array_size, 0); - response->mutable_total_relative_power()->Resize(actual_array_size, 0); - response->mutable_peak_absolute_power()->Resize(actual_array_size, 0); - response->mutable_peak_frequency()->Resize(actual_array_size, 0); - response->mutable_peak_relative_power()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->mutable_total_absolute_power()->Resize(actual_array_size, 0); + response->mutable_total_relative_power()->Resize(actual_array_size, 0); + response->mutable_peak_absolute_power()->Resize(actual_array_size, 0); + response->mutable_peak_frequency()->Resize(actual_array_size, 0); + response->mutable_peak_relative_power()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -12043,6 +12695,9 @@ namespace nirfmxspecan_grpc { int32 enable_all_traces = request->enable_all_traces(); auto status = library_->SelectMeasurements(instrument, selector_string, measurements, enable_all_traces); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -12062,6 +12717,9 @@ namespace nirfmxspecan_grpc { auto instrument_grpc_session = request->instrument(); niRFmxInstrHandle instrument = session_repository_->access_session(instrument_grpc_session.id(), instrument_grpc_session.name()); auto status = library_->SendSoftwareEdgeTrigger(instrument); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -12084,6 +12742,9 @@ namespace nirfmxspecan_grpc { int32 attribute_id = request->attribute_id(); float32 attr_val = request->attr_val(); auto status = library_->SetAttributeF32(instrument, selector_string, attribute_id, attr_val); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -12107,6 +12768,9 @@ namespace nirfmxspecan_grpc { auto attr_val = const_cast(request->attr_val().data()); int32 array_size = static_cast(request->attr_val().size()); auto status = library_->SetAttributeF32Array(instrument, selector_string, attribute_id, attr_val, array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -12129,6 +12793,9 @@ namespace nirfmxspecan_grpc { int32 attribute_id = request->attribute_id(); float64 attr_val = request->attr_val(); auto status = library_->SetAttributeF64(instrument, selector_string, attribute_id, attr_val); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -12152,6 +12819,9 @@ namespace nirfmxspecan_grpc { auto attr_val = const_cast(request->attr_val().data()); int32 array_size = static_cast(request->attr_val().size()); auto status = library_->SetAttributeF64Array(instrument, selector_string, attribute_id, attr_val, array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -12183,6 +12853,9 @@ namespace nirfmxspecan_grpc { auto attr_val = static_cast(attr_val_raw); auto status = library_->SetAttributeI16(instrument, selector_string, attribute_id, attr_val); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -12223,6 +12896,9 @@ namespace nirfmxspecan_grpc { } auto status = library_->SetAttributeI32(instrument, selector_string, attribute_id, attr_val); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -12254,6 +12930,9 @@ namespace nirfmxspecan_grpc { int32 array_size = static_cast(request->attr_val().size()); auto status = library_->SetAttributeI32Array(instrument, selector_string, attribute_id, attr_val, array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -12276,6 +12955,9 @@ namespace nirfmxspecan_grpc { int32 attribute_id = request->attribute_id(); int64 attr_val = request->attr_val(); auto status = library_->SetAttributeI64(instrument, selector_string, attribute_id, attr_val); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -12299,6 +12981,9 @@ namespace nirfmxspecan_grpc { auto attr_val = const_cast(reinterpret_cast(request->attr_val().data())); int32 array_size = static_cast(request->attr_val().size()); auto status = library_->SetAttributeI64Array(instrument, selector_string, attribute_id, attr_val, array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -12330,6 +13015,9 @@ namespace nirfmxspecan_grpc { auto attr_val = static_cast(attr_val_raw); auto status = library_->SetAttributeI8(instrument, selector_string, attribute_id, attr_val); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -12373,6 +13061,9 @@ namespace nirfmxspecan_grpc { int32 array_size = static_cast(request->attr_val().size()); auto status = library_->SetAttributeI8Array(instrument, selector_string, attribute_id, attr_val.data(), array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -12399,6 +13090,9 @@ namespace nirfmxspecan_grpc { auto attr_val = convert_from_grpc(request->attr_val()); int32 array_size = static_cast(request->attr_val().size()); auto status = library_->SetAttributeNIComplexDoubleArray(instrument, selector_string, attribute_id, attr_val.data(), array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -12422,6 +13116,9 @@ namespace nirfmxspecan_grpc { auto attr_val = convert_from_grpc(request->attr_val()); int32 array_size = static_cast(request->attr_val().size()); auto status = library_->SetAttributeNIComplexSingleArray(instrument, selector_string, attribute_id, attr_val.data(), array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -12463,6 +13160,9 @@ namespace nirfmxspecan_grpc { } auto status = library_->SetAttributeString(instrument, selector_string, attribute_id, attr_val); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -12494,6 +13194,9 @@ namespace nirfmxspecan_grpc { auto attr_val = static_cast(attr_val_raw); auto status = library_->SetAttributeU16(instrument, selector_string, attribute_id, attr_val); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -12519,6 +13222,9 @@ namespace nirfmxspecan_grpc { int32 attribute_id = request->attribute_id(); uInt32 attr_val = request->attr_val(); auto status = library_->SetAttributeU32(instrument, selector_string, attribute_id, attr_val); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -12542,6 +13248,9 @@ namespace nirfmxspecan_grpc { auto attr_val = const_cast(reinterpret_cast(request->attr_val().data())); int32 array_size = static_cast(request->attr_val().size()); auto status = library_->SetAttributeU32Array(instrument, selector_string, attribute_id, attr_val, array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -12565,6 +13274,9 @@ namespace nirfmxspecan_grpc { auto attr_val = const_cast(reinterpret_cast(request->attr_val().data())); int32 array_size = static_cast(request->attr_val().size()); auto status = library_->SetAttributeU64Array(instrument, selector_string, attribute_id, attr_val, array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -12587,6 +13299,9 @@ namespace nirfmxspecan_grpc { int32 attribute_id = request->attribute_id(); uInt8 attr_val = request->attr_val(); auto status = library_->SetAttributeU8(instrument, selector_string, attribute_id, attr_val); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -12610,6 +13325,9 @@ namespace nirfmxspecan_grpc { uInt8* attr_val = (uInt8*)request->attr_val().c_str(); int32 array_size = static_cast(request->attr_val().size()); auto status = library_->SetAttributeU8Array(instrument, selector_string, attribute_id, attr_val, array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -12663,6 +13381,9 @@ namespace nirfmxspecan_grpc { } auto status = library_->SpectrumCfgAveraging(instrument, selector_string, averaging_enabled, averaging_count, averaging_type); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -12700,6 +13421,9 @@ namespace nirfmxspecan_grpc { int32 detector_points = request->detector_points(); auto status = library_->SpectrumCfgDetector(instrument, selector_string, detector_type, detector_points); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -12737,6 +13461,9 @@ namespace nirfmxspecan_grpc { float64 fft_padding = request->fft_padding(); auto status = library_->SpectrumCfgFFT(instrument, selector_string, fft_window, fft_padding); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -12759,6 +13486,9 @@ namespace nirfmxspecan_grpc { float64 start_frequency = request->start_frequency(); float64 stop_frequency = request->stop_frequency(); auto status = library_->SpectrumCfgFrequencyStartStop(instrument, selector_string, start_frequency, stop_frequency); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -12795,6 +13525,9 @@ namespace nirfmxspecan_grpc { } auto status = library_->SpectrumCfgNoiseCompensationEnabled(instrument, selector_string, noise_compensation_enabled); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -12831,6 +13564,9 @@ namespace nirfmxspecan_grpc { } auto status = library_->SpectrumCfgPowerUnits(instrument, selector_string, spectrum_power_units); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -12884,6 +13620,9 @@ namespace nirfmxspecan_grpc { } auto status = library_->SpectrumCfgRBWFilter(instrument, selector_string, rbw_auto, rbw, rbw_filter_type); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -12905,6 +13644,9 @@ namespace nirfmxspecan_grpc { char* selector_string = (char*)request->selector_string().c_str(); float64 span = request->span(); auto status = library_->SpectrumCfgSpan(instrument, selector_string, span); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -12942,6 +13684,9 @@ namespace nirfmxspecan_grpc { float64 sweep_time_interval = request->sweep_time_interval(); auto status = library_->SpectrumCfgSweepTime(instrument, selector_string, sweep_time_auto, sweep_time_interval); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -12980,6 +13725,9 @@ namespace nirfmxspecan_grpc { float64 vbw = request->vbw(); float64 vbw_to_rbw_ratio = request->vbw_to_rbw_ratio(); auto status = library_->SpectrumCfgVBWFilter(instrument, selector_string, vbw_auto, vbw, vbw_to_rbw_ratio); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -13004,12 +13752,13 @@ namespace nirfmxspecan_grpc { float64 peak_frequency {}; float64 frequency_resolution {}; auto status = library_->SpectrumFetchMeasurement(instrument, selector_string, timeout, &peak_amplitude, &peak_frequency, &frequency_resolution); - response->set_status(status); - if (status_ok(status)) { - response->set_peak_amplitude(peak_amplitude); - response->set_peak_frequency(peak_frequency); - response->set_frequency_resolution(frequency_resolution); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_peak_amplitude(peak_amplitude); + response->set_peak_frequency(peak_frequency); + response->set_frequency_resolution(frequency_resolution); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -13034,9 +13783,8 @@ namespace nirfmxspecan_grpc { int32 actual_array_size {}; while (true) { auto status = library_->SpectrumFetchPowerTrace(instrument, selector_string, timeout, &x0, &dx, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_power()->Resize(actual_array_size, 0); float32* power = response->mutable_power()->mutable_data(); @@ -13046,13 +13794,14 @@ namespace nirfmxspecan_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_x0(x0); - response->set_dx(dx); - response->mutable_power()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_x0(x0); + response->set_dx(dx); + response->mutable_power()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -13078,9 +13827,8 @@ namespace nirfmxspecan_grpc { int32 actual_array_size {}; while (true) { auto status = library_->SpectrumFetchSpectrum(instrument, selector_string, timeout, &x0, &dx, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_spectrum()->Resize(actual_array_size, 0); float32* spectrum = response->mutable_spectrum()->mutable_data(); @@ -13090,13 +13838,14 @@ namespace nirfmxspecan_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_x0(x0); - response->set_dx(dx); - response->mutable_spectrum()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_x0(x0); + response->set_dx(dx); + response->mutable_spectrum()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -13122,9 +13871,8 @@ namespace nirfmxspecan_grpc { int32 actual_array_size {}; while (true) { auto status = library_->SpectrumRead(instrument, selector_string, timeout, &x0, &dx, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_spectrum()->Resize(actual_array_size, 0); float32* spectrum = response->mutable_spectrum()->mutable_data(); @@ -13134,13 +13882,14 @@ namespace nirfmxspecan_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_x0(x0); - response->set_dx(dx); - response->mutable_spectrum()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_x0(x0); + response->set_dx(dx); + response->mutable_spectrum()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -13162,11 +13911,12 @@ namespace nirfmxspecan_grpc { char* selector_string = (char*)request->selector_string().c_str(); int32 noise_calibration_data_valid {}; auto status = library_->SpectrumValidateNoiseCalibrationData(instrument, selector_string, &noise_calibration_data_valid); - response->set_status(status); - if (status_ok(status)) { - response->set_noise_calibration_data_valid(static_cast(noise_calibration_data_valid)); - response->set_noise_calibration_data_valid_raw(noise_calibration_data_valid); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_noise_calibration_data_valid(static_cast(noise_calibration_data_valid)); + response->set_noise_calibration_data_valid_raw(noise_calibration_data_valid); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -13219,6 +13969,9 @@ namespace nirfmxspecan_grpc { } auto status = library_->SpurCfgAveraging(instrument, selector_string, averaging_enabled, averaging_count, averaging_type); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -13255,6 +14008,9 @@ namespace nirfmxspecan_grpc { } auto status = library_->SpurCfgFFTWindowType(instrument, selector_string, fft_window); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -13276,6 +14032,9 @@ namespace nirfmxspecan_grpc { char* selector_string = (char*)request->selector_string().c_str(); int32 number_of_ranges = request->number_of_ranges(); auto status = library_->SpurCfgNumberOfRanges(instrument, selector_string, number_of_ranges); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -13314,6 +14073,9 @@ namespace nirfmxspecan_grpc { float64 absolute_limit_start = request->absolute_limit_start(); float64 absolute_limit_stop = request->absolute_limit_stop(); auto status = library_->SpurCfgRangeAbsoluteLimit(instrument, selector_string, absolute_limit_mode, absolute_limit_start, absolute_limit_stop); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -13364,6 +14126,9 @@ namespace nirfmxspecan_grpc { auto number_of_elements = number_of_elements_size_calculation.size; auto status = library_->SpurCfgRangeAbsoluteLimitArray(instrument, selector_string, absolute_limit_mode, absolute_limit_start, absolute_limit_stop, number_of_elements); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -13401,6 +14166,9 @@ namespace nirfmxspecan_grpc { int32 detector_points = request->detector_points(); auto status = library_->SpurCfgRangeDetector(instrument, selector_string, detector_type, detector_points); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -13448,6 +14216,9 @@ namespace nirfmxspecan_grpc { auto number_of_elements = number_of_elements_size_calculation.size; auto status = library_->SpurCfgRangeDetectorArray(instrument, selector_string, detector_type, detector_points, number_of_elements); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -13486,6 +14257,9 @@ namespace nirfmxspecan_grpc { } auto status = library_->SpurCfgRangeFrequency(instrument, selector_string, start_frequency, stop_frequency, range_enabled); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -13536,6 +14310,9 @@ namespace nirfmxspecan_grpc { auto number_of_elements = number_of_elements_size_calculation.size; auto status = library_->SpurCfgRangeFrequencyArray(instrument, selector_string, start_frequency, stop_frequency, range_enabled, number_of_elements); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -13557,6 +14334,9 @@ namespace nirfmxspecan_grpc { char* selector_string = (char*)request->selector_string().c_str(); int32 number_of_spurs_to_report = request->number_of_spurs_to_report(); auto status = library_->SpurCfgRangeNumberOfSpursToReport(instrument, selector_string, number_of_spurs_to_report); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -13579,6 +14359,9 @@ namespace nirfmxspecan_grpc { auto number_of_spurs_to_report = const_cast(reinterpret_cast(request->number_of_spurs_to_report().data())); int32 number_of_elements = static_cast(request->number_of_spurs_to_report().size()); auto status = library_->SpurCfgRangeNumberOfSpursToReportArray(instrument, selector_string, number_of_spurs_to_report, number_of_elements); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -13601,6 +14384,9 @@ namespace nirfmxspecan_grpc { float64 threshold = request->threshold(); float64 excursion = request->excursion(); auto status = library_->SpurCfgRangePeakCriteria(instrument, selector_string, threshold, excursion); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -13640,6 +14426,9 @@ namespace nirfmxspecan_grpc { auto number_of_elements = number_of_elements_size_calculation.size; auto status = library_->SpurCfgRangePeakCriteriaArray(instrument, selector_string, threshold, excursion, number_of_elements); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -13698,6 +14487,9 @@ namespace nirfmxspecan_grpc { auto number_of_elements = number_of_elements_size_calculation.size; auto status = library_->SpurCfgRangeRBWArray(instrument, selector_string, rbw_auto, rbw, rbw_filter_type, number_of_elements); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -13751,6 +14543,9 @@ namespace nirfmxspecan_grpc { } auto status = library_->SpurCfgRangeRBWFilter(instrument, selector_string, rbw_auto, rbw, rbw_filter_type); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -13772,6 +14567,9 @@ namespace nirfmxspecan_grpc { char* selector_string = (char*)request->selector_string().c_str(); float64 relative_attenuation = request->relative_attenuation(); auto status = library_->SpurCfgRangeRelativeAttenuation(instrument, selector_string, relative_attenuation); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -13794,6 +14592,9 @@ namespace nirfmxspecan_grpc { auto relative_attenuation = const_cast(request->relative_attenuation().data()); int32 number_of_elements = static_cast(request->relative_attenuation().size()); auto status = library_->SpurCfgRangeRelativeAttenuationArray(instrument, selector_string, relative_attenuation, number_of_elements); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -13831,6 +14632,9 @@ namespace nirfmxspecan_grpc { float64 sweep_time_interval = request->sweep_time_interval(); auto status = library_->SpurCfgRangeSweepTime(instrument, selector_string, sweep_time_auto, sweep_time_interval); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -13878,6 +14682,9 @@ namespace nirfmxspecan_grpc { auto number_of_elements = number_of_elements_size_calculation.size; auto status = library_->SpurCfgRangeSweepTimeArray(instrument, selector_string, sweep_time_auto, sweep_time_interval, number_of_elements); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -13916,6 +14723,9 @@ namespace nirfmxspecan_grpc { float64 vbw = request->vbw(); float64 vbw_to_rbw_ratio = request->vbw_to_rbw_ratio(); auto status = library_->SpurCfgRangeVBWFilter(instrument, selector_string, vbw_auto, vbw, vbw_to_rbw_ratio); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -13966,6 +14776,9 @@ namespace nirfmxspecan_grpc { auto number_of_elements = number_of_elements_size_calculation.size; auto status = library_->SpurCfgRangeVBWFilterArray(instrument, selector_string, vbw_auto, vbw, vbw_to_rbw_ratio, number_of_elements); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -13987,6 +14800,9 @@ namespace nirfmxspecan_grpc { char* selector_string = (char*)request->selector_string().c_str(); int32 trace_range_index = request->trace_range_index(); auto status = library_->SpurCfgTraceRangeIndex(instrument, selector_string, trace_range_index); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -14010,9 +14826,8 @@ namespace nirfmxspecan_grpc { int32 actual_array_size {}; while (true) { auto status = library_->SpurFetchAllSpurs(instrument, selector_string, timeout, nullptr, nullptr, nullptr, nullptr, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_spur_frequency()->Resize(actual_array_size, 0); float64* spur_frequency = response->mutable_spur_frequency()->mutable_data(); @@ -14030,15 +14845,16 @@ namespace nirfmxspecan_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->mutable_spur_frequency()->Resize(actual_array_size, 0); - response->mutable_spur_amplitude()->Resize(actual_array_size, 0); - response->mutable_spur_margin()->Resize(actual_array_size, 0); - response->mutable_spur_absolute_limit()->Resize(actual_array_size, 0); - response->mutable_spur_range_index()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->mutable_spur_frequency()->Resize(actual_array_size, 0); + response->mutable_spur_amplitude()->Resize(actual_array_size, 0); + response->mutable_spur_margin()->Resize(actual_array_size, 0); + response->mutable_spur_absolute_limit()->Resize(actual_array_size, 0); + response->mutable_spur_range_index()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -14061,11 +14877,12 @@ namespace nirfmxspecan_grpc { float64 timeout = request->timeout(); int32 measurement_status {}; auto status = library_->SpurFetchMeasurementStatus(instrument, selector_string, timeout, &measurement_status); - response->set_status(status); - if (status_ok(status)) { - response->set_measurement_status(static_cast(measurement_status)); - response->set_measurement_status_raw(measurement_status); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_measurement_status(static_cast(measurement_status)); + response->set_measurement_status_raw(measurement_status); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -14090,9 +14907,8 @@ namespace nirfmxspecan_grpc { int32 actual_array_size {}; while (true) { auto status = library_->SpurFetchRangeAbsoluteLimitTrace(instrument, selector_string, timeout, &x0, &dx, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_absolute_limit()->Resize(actual_array_size, 0); float32* absolute_limit = response->mutable_absolute_limit()->mutable_data(); @@ -14102,13 +14918,14 @@ namespace nirfmxspecan_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_x0(x0); - response->set_dx(dx); - response->mutable_absolute_limit()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_x0(x0); + response->set_dx(dx); + response->mutable_absolute_limit()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -14134,9 +14951,8 @@ namespace nirfmxspecan_grpc { int32 actual_array_size {}; while (true) { auto status = library_->SpurFetchRangeSpectrumTrace(instrument, selector_string, timeout, &x0, &dx, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_range_spectrum()->Resize(actual_array_size, 0); float32* range_spectrum = response->mutable_range_spectrum()->mutable_data(); @@ -14146,13 +14962,14 @@ namespace nirfmxspecan_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_x0(x0); - response->set_dx(dx); - response->mutable_range_spectrum()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_x0(x0); + response->set_dx(dx); + response->mutable_range_spectrum()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -14176,12 +14993,13 @@ namespace nirfmxspecan_grpc { int32 range_status {}; int32 detected_spurs {}; auto status = library_->SpurFetchRangeStatus(instrument, selector_string, timeout, &range_status, &detected_spurs); - response->set_status(status); - if (status_ok(status)) { - response->set_range_status(static_cast(range_status)); - response->set_range_status_raw(range_status); - response->set_detected_spurs(detected_spurs); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_range_status(static_cast(range_status)); + response->set_range_status_raw(range_status); + response->set_detected_spurs(detected_spurs); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -14204,9 +15022,8 @@ namespace nirfmxspecan_grpc { int32 actual_array_size {}; while (true) { auto status = library_->SpurFetchRangeStatusArray(instrument, selector_string, timeout, nullptr, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_range_status_raw()->Resize(actual_array_size, 0); int32* range_status = reinterpret_cast(response->mutable_range_status_raw()->mutable_data()); @@ -14218,8 +15035,10 @@ namespace nirfmxspecan_grpc { // buffer is now too small, try again continue; } + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); - if (status_ok(status)) { response->mutable_range_status()->Clear(); response->mutable_range_status()->Reserve(actual_array_size); std::transform( @@ -14229,10 +15048,9 @@ namespace nirfmxspecan_grpc { [&](auto x) { return static_cast(x); }); - response->mutable_range_status()->Resize(actual_array_size, 0); - response->mutable_number_of_detected_spurs()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); - } + response->mutable_range_status()->Resize(actual_array_size, 0); + response->mutable_number_of_detected_spurs()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -14258,13 +15076,14 @@ namespace nirfmxspecan_grpc { float64 spur_margin {}; float64 spur_absolute_limit {}; auto status = library_->SpurFetchSpurMeasurement(instrument, selector_string, timeout, &spur_frequency, &spur_amplitude, &spur_margin, &spur_absolute_limit); - response->set_status(status); - if (status_ok(status)) { - response->set_spur_frequency(spur_frequency); - response->set_spur_amplitude(spur_amplitude); - response->set_spur_margin(spur_margin); - response->set_spur_absolute_limit(spur_absolute_limit); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_spur_frequency(spur_frequency); + response->set_spur_amplitude(spur_amplitude); + response->set_spur_margin(spur_margin); + response->set_spur_absolute_limit(spur_absolute_limit); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -14287,9 +15106,8 @@ namespace nirfmxspecan_grpc { int32 actual_array_size {}; while (true) { auto status = library_->SpurFetchSpurMeasurementArray(instrument, selector_string, timeout, nullptr, nullptr, nullptr, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_spur_frequency()->Resize(actual_array_size, 0); float64* spur_frequency = response->mutable_spur_frequency()->mutable_data(); @@ -14305,14 +15123,15 @@ namespace nirfmxspecan_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->mutable_spur_frequency()->Resize(actual_array_size, 0); - response->mutable_spur_amplitude()->Resize(actual_array_size, 0); - response->mutable_spur_absolute_limit()->Resize(actual_array_size, 0); - response->mutable_spur_margin()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->mutable_spur_frequency()->Resize(actual_array_size, 0); + response->mutable_spur_amplitude()->Resize(actual_array_size, 0); + response->mutable_spur_absolute_limit()->Resize(actual_array_size, 0); + response->mutable_spur_margin()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -14366,6 +15185,9 @@ namespace nirfmxspecan_grpc { } auto status = library_->TXPCfgAveraging(instrument, selector_string, averaging_enabled, averaging_count, averaging_type); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -14387,6 +15209,9 @@ namespace nirfmxspecan_grpc { char* selector_string = (char*)request->selector_string().c_str(); float64 measurement_interval = request->measurement_interval(); auto status = library_->TXPCfgMeasurementInterval(instrument, selector_string, measurement_interval); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -14425,6 +15250,9 @@ namespace nirfmxspecan_grpc { float64 rrc_alpha = request->rrc_alpha(); auto status = library_->TXPCfgRBWFilter(instrument, selector_string, rbw, rbw_filter_type, rrc_alpha); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -14478,6 +15306,9 @@ namespace nirfmxspecan_grpc { } auto status = library_->TXPCfgThreshold(instrument, selector_string, threshold_enabled, threshold_level, threshold_type); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -14516,6 +15347,9 @@ namespace nirfmxspecan_grpc { float64 vbw = request->vbw(); float64 vbw_to_rbw_ratio = request->vbw_to_rbw_ratio(); auto status = library_->TXPCfgVBWFilter(instrument, selector_string, vbw_auto, vbw, vbw_to_rbw_ratio); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -14541,13 +15375,14 @@ namespace nirfmxspecan_grpc { float64 maximum_power {}; float64 minimum_power {}; auto status = library_->TXPFetchMeasurement(instrument, selector_string, timeout, &average_mean_power, &peak_to_average_ratio, &maximum_power, &minimum_power); - response->set_status(status); - if (status_ok(status)) { - response->set_average_mean_power(average_mean_power); - response->set_peak_to_average_ratio(peak_to_average_ratio); - response->set_maximum_power(maximum_power); - response->set_minimum_power(minimum_power); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_average_mean_power(average_mean_power); + response->set_peak_to_average_ratio(peak_to_average_ratio); + response->set_maximum_power(maximum_power); + response->set_minimum_power(minimum_power); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -14572,9 +15407,8 @@ namespace nirfmxspecan_grpc { int32 actual_array_size {}; while (true) { auto status = library_->TXPFetchPowerTrace(instrument, selector_string, timeout, &x0, &dx, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_power()->Resize(actual_array_size, 0); float32* power = response->mutable_power()->mutable_data(); @@ -14584,13 +15418,14 @@ namespace nirfmxspecan_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_x0(x0); - response->set_dx(dx); - response->mutable_power()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_x0(x0); + response->set_dx(dx); + response->mutable_power()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -14616,13 +15451,14 @@ namespace nirfmxspecan_grpc { float64 maximum_power {}; float64 minimum_power {}; auto status = library_->TXPRead(instrument, selector_string, timeout, &average_mean_power, &peak_to_average_ratio, &maximum_power, &minimum_power); - response->set_status(status); - if (status_ok(status)) { - response->set_average_mean_power(average_mean_power); - response->set_peak_to_average_ratio(peak_to_average_ratio); - response->set_maximum_power(maximum_power); - response->set_minimum_power(minimum_power); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_average_mean_power(average_mean_power); + response->set_peak_to_average_ratio(peak_to_average_ratio); + response->set_maximum_power(maximum_power); + response->set_minimum_power(minimum_power); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -14642,6 +15478,9 @@ namespace nirfmxspecan_grpc { niRFmxInstrHandle instrument = session_repository_->access_session(instrument_grpc_session.id(), instrument_grpc_session.name()); float64 timeout = request->timeout(); auto status = library_->WaitForAcquisitionComplete(instrument, timeout); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -14663,6 +15502,9 @@ namespace nirfmxspecan_grpc { char* selector_string = (char*)request->selector_string().c_str(); float64 timeout = request->timeout(); auto status = library_->WaitForMeasurementComplete(instrument, selector_string, timeout); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } diff --git a/generated/nirfmxspecan/nirfmxspecan_service.h b/generated/nirfmxspecan/nirfmxspecan_service.h index b1078a32b..55342d717 100644 --- a/generated/nirfmxspecan/nirfmxspecan_service.h +++ b/generated/nirfmxspecan/nirfmxspecan_service.h @@ -460,6 +460,7 @@ class NiRFmxSpecAnService final : public NiRFmxSpecAn::Service { NiRFmxSpecAnLibraryInterface* library_; ResourceRepositorySharedPtr session_repository_; ViSessionResourceRepositorySharedPtr vi_session_resource_repository_; + ::grpc::Status ConvertApiErrorStatusForNiRFmxInstrHandle(google::protobuf::int32 status, niRFmxInstrHandle instrumentHandle); std::map digitaledgetriggersource_input_map_ { {1, "PFI0"},{2, "PFI1"},{3, "PXI_Trig0"},{4, "PXI_Trig1"},{5, "PXI_Trig2"},{6, "PXI_Trig3"},{7, "PXI_Trig4"},{8, "PXI_Trig5"},{9, "PXI_Trig6"},{10, "PXI_Trig7"},{11, "PXI_STAR"},{12, "PXIe_DStarB"},{13, "TimerEvent"}, }; std::map digitaledgetriggersource_output_map_ { {"PFI0", 1},{"PFI1", 2},{"PXI_Trig0", 3},{"PXI_Trig1", 4},{"PXI_Trig2", 5},{"PXI_Trig3", 6},{"PXI_Trig4", 7},{"PXI_Trig5", 8},{"PXI_Trig6", 9},{"PXI_Trig7", 10},{"PXI_STAR", 11},{"PXIe_DStarB", 12},{"TimerEvent", 13}, }; std::map frequencyreferencesource_input_map_ { {1, "OnboardClock"},{2, "RefIn"},{3, "PXI_Clk"},{4, "ClkIn"}, }; diff --git a/generated/nirfmxspecan_restricted/nirfmxspecan_restricted_service.cpp b/generated/nirfmxspecan_restricted/nirfmxspecan_restricted_service.cpp index 8983d3789..fe37263ec 100644 --- a/generated/nirfmxspecan_restricted/nirfmxspecan_restricted_service.cpp +++ b/generated/nirfmxspecan_restricted/nirfmxspecan_restricted_service.cpp @@ -61,11 +61,12 @@ namespace nirfmxspecan_restricted_grpc { selector_string_out.resize(selector_string_out_size - 1); } auto status = library_->CacheResult(instrument, selector_string, selector_string_out_size, (char*)selector_string_out.data()); - response->set_status(status); - if (status_ok(status)) { - response->set_selector_string_out(selector_string_out); - nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_selector_string_out())); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_selector_string_out(selector_string_out); + nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_selector_string_out())); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -93,9 +94,8 @@ namespace nirfmxspecan_restricted_grpc { int32 actual_array_size {}; while (true) { auto status = library_->IQFetchDataOverrideBehavior(instrument, selector_string, timeout, record_to_fetch, samples_to_read, delete_on_fetch, &t0, &dt, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } std::vector data(actual_array_size, NIComplexSingle()); auto array_size = actual_array_size; @@ -104,20 +104,21 @@ namespace nirfmxspecan_restricted_grpc { // buffer is now too small, try again continue; } + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); - if (status_ok(status)) { - response->set_t0(t0); - response->set_dt(dt); - convert_to_grpc(data, response->mutable_data()); - { - auto shrunk_size = actual_array_size; - auto current_size = response->mutable_data()->size(); - if (shrunk_size != current_size) { - response->mutable_data()->DeleteSubrange(shrunk_size, current_size - shrunk_size); - } + response->set_t0(t0); + response->set_dt(dt); + convert_to_grpc(data, response->mutable_data()); + { + auto shrunk_size = actual_array_size; + auto current_size = response->mutable_data()->size(); + if (shrunk_size != current_size) { + response->mutable_data()->DeleteSubrange(shrunk_size, current_size - shrunk_size); } - response->set_actual_array_size(actual_array_size); } + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } diff --git a/generated/nirfmxspecan_restricted/nirfmxspecan_restricted_service.h b/generated/nirfmxspecan_restricted/nirfmxspecan_restricted_service.h index 476cf361b..c86e49c44 100644 --- a/generated/nirfmxspecan_restricted/nirfmxspecan_restricted_service.h +++ b/generated/nirfmxspecan_restricted/nirfmxspecan_restricted_service.h @@ -46,6 +46,7 @@ class NiRFmxSpecAnRestrictedService final : public NiRFmxSpecAnRestricted::Servi private: NiRFmxSpecAnRestrictedLibraryInterface* library_; ResourceRepositorySharedPtr session_repository_; + ::grpc::Status ConvertApiErrorStatusForNiRFmxInstrHandle(google::protobuf::int32 status, niRFmxInstrHandle instrumentHandle); NiRFmxSpecAnRestrictedFeatureToggles feature_toggles_; }; diff --git a/generated/nirfmxwlan/nirfmxwlan_service.cpp b/generated/nirfmxwlan/nirfmxwlan_service.cpp index 7fb76b948..259a1cb5f 100644 --- a/generated/nirfmxwlan/nirfmxwlan_service.cpp +++ b/generated/nirfmxwlan/nirfmxwlan_service.cpp @@ -60,6 +60,9 @@ namespace nirfmxwlan_grpc { niRFmxInstrHandle instrument = session_repository_->access_session(instrument_grpc_session.id(), instrument_grpc_session.name()); char* selector_string = (char*)request->selector_string().c_str(); auto status = library_->AbortMeasurements(instrument, selector_string); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -87,6 +90,9 @@ namespace nirfmxwlan_grpc { int32 reset = request->reset(); auto reserved = 0; auto status = library_->AnalyzeIQ1Waveform(instrument, selector_string, result_name, x0, dx, iq.data(), array_size, reset, reserved); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -132,6 +138,9 @@ namespace nirfmxwlan_grpc { int32 reset = request->reset(); auto status = library_->AnalyzeNWaveformsIQ(instrument, selector_string, result_name, x0, dx, iq.data(), iq_sizes, array_size, reset); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -177,6 +186,9 @@ namespace nirfmxwlan_grpc { int32 reset = request->reset(); auto status = library_->AnalyzeNWaveformsSpectrum(instrument, selector_string, result_name, x0, dx, spectrum, spectrum_sizes, array_size, reset); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -204,6 +216,9 @@ namespace nirfmxwlan_grpc { int32 reset = request->reset(); auto reserved = 0; auto status = library_->AnalyzeSpectrum1Waveform(instrument, selector_string, result_name, x0, dx, spectrum, array_size, reset, reserved); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -225,6 +240,9 @@ namespace nirfmxwlan_grpc { char* selector_string = (char*)request->selector_string().c_str(); float64 timeout = request->timeout(); auto status = library_->AutoDetectSignal(instrument, selector_string, timeout); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -246,6 +264,9 @@ namespace nirfmxwlan_grpc { char* selector_string = (char*)request->selector_string().c_str(); float64 measurement_interval = request->measurement_interval(); auto status = library_->AutoLevel(instrument, selector_string, measurement_interval); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -267,9 +288,8 @@ namespace nirfmxwlan_grpc { while (true) { auto status = library_->BuildChainString(selector_string, chain_number, 0, nullptr); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, 0); } int32 selector_string_out_length = status; @@ -282,11 +302,12 @@ namespace nirfmxwlan_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_selector_string_out(selector_string_out); - nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_selector_string_out())); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, 0); } + response->set_status(status); + response->set_selector_string_out(selector_string_out); + nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_selector_string_out())); return ::grpc::Status::OK; } } @@ -308,9 +329,8 @@ namespace nirfmxwlan_grpc { while (true) { auto status = library_->BuildGateString(selector_string, gate_number, 0, nullptr); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, 0); } int32 selector_string_out_length = status; @@ -323,11 +343,12 @@ namespace nirfmxwlan_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_selector_string_out(selector_string_out); - nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_selector_string_out())); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, 0); } + response->set_status(status); + response->set_selector_string_out(selector_string_out); + nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_selector_string_out())); return ::grpc::Status::OK; } } @@ -349,9 +370,8 @@ namespace nirfmxwlan_grpc { while (true) { auto status = library_->BuildOffsetString(selector_string, offset_number, 0, nullptr); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, 0); } int32 selector_string_out_length = status; @@ -364,11 +384,12 @@ namespace nirfmxwlan_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_selector_string_out(selector_string_out); - nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_selector_string_out())); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, 0); } + response->set_status(status); + response->set_selector_string_out(selector_string_out); + nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_selector_string_out())); return ::grpc::Status::OK; } } @@ -390,9 +411,8 @@ namespace nirfmxwlan_grpc { while (true) { auto status = library_->BuildSegmentString(selector_string, segment_number, 0, nullptr); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, 0); } int32 selector_string_out_length = status; @@ -405,11 +425,12 @@ namespace nirfmxwlan_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_selector_string_out(selector_string_out); - nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_selector_string_out())); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, 0); } + response->set_status(status); + response->set_selector_string_out(selector_string_out); + nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_selector_string_out())); return ::grpc::Status::OK; } } @@ -431,9 +452,8 @@ namespace nirfmxwlan_grpc { while (true) { auto status = library_->BuildSignalString(signal_name, result_name, 0, nullptr); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, 0); } int32 selector_string_length = status; @@ -446,11 +466,12 @@ namespace nirfmxwlan_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_selector_string(selector_string); - nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_selector_string())); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, 0); } + response->set_status(status); + response->set_selector_string(selector_string); + nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_selector_string())); return ::grpc::Status::OK; } } @@ -472,9 +493,8 @@ namespace nirfmxwlan_grpc { while (true) { auto status = library_->BuildStreamString(selector_string, stream_number, 0, nullptr); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, 0); } int32 selector_string_out_length = status; @@ -487,11 +507,12 @@ namespace nirfmxwlan_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_selector_string_out(selector_string_out); - nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_selector_string_out())); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, 0); } + response->set_status(status); + response->set_selector_string_out(selector_string_out); + nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_selector_string_out())); return ::grpc::Status::OK; } } @@ -513,9 +534,8 @@ namespace nirfmxwlan_grpc { while (true) { auto status = library_->BuildUserString(selector_string, user_number, 0, nullptr); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, 0); } int32 selector_string_out_length = status; @@ -528,11 +548,12 @@ namespace nirfmxwlan_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_selector_string_out(selector_string_out); - nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_selector_string_out())); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, 0); } + response->set_status(status); + response->set_selector_string_out(selector_string_out); + nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_selector_string_out())); return ::grpc::Status::OK; } } @@ -554,6 +575,9 @@ namespace nirfmxwlan_grpc { char* selector_string = (char*)request->selector_string().c_str(); float64 channel_bandwidth = request->channel_bandwidth(); auto status = library_->CfgChannelBandwidth(instrument, selector_string, channel_bandwidth); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -593,6 +617,9 @@ namespace nirfmxwlan_grpc { float64 trigger_delay = request->trigger_delay(); int32 enable_trigger = request->enable_trigger(); auto status = library_->CfgDigitalEdgeTrigger(instrument, selector_string, digital_edge_source, digital_edge, trigger_delay, enable_trigger); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -614,6 +641,9 @@ namespace nirfmxwlan_grpc { char* selector_string = (char*)request->selector_string().c_str(); float64 external_attenuation = request->external_attenuation(); auto status = library_->CfgExternalAttenuation(instrument, selector_string, external_attenuation); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -635,6 +665,9 @@ namespace nirfmxwlan_grpc { char* selector_string = (char*)request->selector_string().c_str(); float64 center_frequency = request->center_frequency(); auto status = library_->CfgFrequency(instrument, selector_string, center_frequency); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -657,6 +690,9 @@ namespace nirfmxwlan_grpc { auto center_frequency = const_cast(request->center_frequency().data()); int32 number_of_elements = static_cast(request->center_frequency().size()); auto status = library_->CfgFrequencyArray(instrument, selector_string, center_frequency, number_of_elements); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -698,6 +734,9 @@ namespace nirfmxwlan_grpc { float64 frequency_reference_frequency = request->frequency_reference_frequency(); auto status = library_->CfgFrequencyReference(instrument, channel_name, frequency_reference_source, frequency_reference_frequency); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -771,6 +810,9 @@ namespace nirfmxwlan_grpc { int32 enable_trigger = request->enable_trigger(); auto status = library_->CfgIQPowerEdgeTrigger(instrument, selector_string, iq_power_edge_source, iq_power_edge_slope, iq_power_edge_level, trigger_delay, trigger_min_quiet_time_mode, trigger_min_quiet_time_duration, iq_power_edge_level_type, enable_trigger); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -808,6 +850,9 @@ namespace nirfmxwlan_grpc { float64 mechanical_attenuation_value = request->mechanical_attenuation_value(); auto status = library_->CfgMechanicalAttenuation(instrument, channel_name, mechanical_attenuation_auto, mechanical_attenuation_value); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -830,6 +875,9 @@ namespace nirfmxwlan_grpc { int32 number_of_frequency_segments = request->number_of_frequency_segments(); int32 number_of_receive_chains = request->number_of_receive_chains(); auto status = library_->CfgNumberOfFrequencySegmentsAndReceiveChains(instrument, selector_string, number_of_frequency_segments, number_of_receive_chains); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -867,6 +915,9 @@ namespace nirfmxwlan_grpc { float64 rf_attenuation_value = request->rf_attenuation_value(); auto status = library_->CfgRFAttenuation(instrument, channel_name, rf_attenuation_auto, rf_attenuation_value); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -888,6 +939,9 @@ namespace nirfmxwlan_grpc { char* selector_string = (char*)request->selector_string().c_str(); float64 reference_level = request->reference_level(); auto status = library_->CfgReferenceLevel(instrument, selector_string, reference_level); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -909,6 +963,9 @@ namespace nirfmxwlan_grpc { char* selector_string = (char*)request->selector_string().c_str(); char* selected_ports = (char*)request->selected_ports().c_str(); auto status = library_->CfgSelectedPortsMultiple(instrument, selector_string, selected_ports); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -931,6 +988,9 @@ namespace nirfmxwlan_grpc { float64 trigger_delay = request->trigger_delay(); int32 enable_trigger = request->enable_trigger(); auto status = library_->CfgSoftwareEdgeTrigger(instrument, selector_string, trigger_delay, enable_trigger); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -967,6 +1027,9 @@ namespace nirfmxwlan_grpc { } auto status = library_->CfgStandard(instrument, selector_string, standard); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -988,10 +1051,11 @@ namespace nirfmxwlan_grpc { char* selector_string = (char*)request->selector_string().c_str(); int32 is_done {}; auto status = library_->CheckMeasurementStatus(instrument, selector_string, &is_done); - response->set_status(status); - if (status_ok(status)) { - response->set_is_done(is_done); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_is_done(is_done); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -1011,6 +1075,9 @@ namespace nirfmxwlan_grpc { niRFmxInstrHandle instrument = session_repository_->access_session(instrument_grpc_session.id(), instrument_grpc_session.name()); char* selector_string = (char*)request->selector_string().c_str(); auto status = library_->ClearAllNamedResults(instrument, selector_string); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1031,6 +1098,9 @@ namespace nirfmxwlan_grpc { niRFmxInstrHandle instrument = session_repository_->access_session(instrument_grpc_session.id(), instrument_grpc_session.name()); char* selector_string = (char*)request->selector_string().c_str(); auto status = library_->ClearNamedResult(instrument, selector_string); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1052,6 +1122,9 @@ namespace nirfmxwlan_grpc { char* old_signal_name = (char*)request->old_signal_name().c_str(); char* new_signal_name = (char*)request->new_signal_name().c_str(); auto status = library_->CloneSignalConfiguration(instrument, old_signal_name, new_signal_name); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1073,6 +1146,9 @@ namespace nirfmxwlan_grpc { int32 force_destroy = request->force_destroy(); session_repository_->remove_session(instrument_grpc_session.id(), instrument_grpc_session.name()); auto status = library_->Close(instrument, force_destroy); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1093,6 +1169,9 @@ namespace nirfmxwlan_grpc { niRFmxInstrHandle instrument = session_repository_->access_session(instrument_grpc_session.id(), instrument_grpc_session.name()); char* selector_string = (char*)request->selector_string().c_str(); auto status = library_->Commit(instrument, selector_string); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1113,6 +1192,9 @@ namespace nirfmxwlan_grpc { niRFmxInstrHandle instrument = session_repository_->access_session(instrument_grpc_session.id(), instrument_grpc_session.name()); char* signal_name = (char*)request->signal_name().c_str(); auto status = library_->CreateSignalConfiguration(instrument, signal_name); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1150,6 +1232,9 @@ namespace nirfmxwlan_grpc { float64 acquisition_length = request->acquisition_length(); auto status = library_->DSSSModAccCfgAcquisitionLength(instrument, selector_string, acquisition_length_mode, acquisition_length); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1187,6 +1272,9 @@ namespace nirfmxwlan_grpc { int32 averaging_count = request->averaging_count(); auto status = library_->DSSSModAccCfgAveraging(instrument, selector_string, averaging_enabled, averaging_count); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1223,6 +1311,9 @@ namespace nirfmxwlan_grpc { } auto status = library_->DSSSModAccCfgEVMUnit(instrument, selector_string, evm_unit); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1245,6 +1336,9 @@ namespace nirfmxwlan_grpc { int32 measurement_offset = request->measurement_offset(); int32 maximum_measurement_length = request->maximum_measurement_length(); auto status = library_->DSSSModAccCfgMeasurementLength(instrument, selector_string, measurement_offset, maximum_measurement_length); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1284,6 +1378,9 @@ namespace nirfmxwlan_grpc { auto number_of_elements = number_of_elements_size_calculation.size; auto status = library_->DSSSModAccCfgPowerMeasurementCustomGateArray(instrument, selector_string, start_time, stop_time, number_of_elements); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1320,6 +1417,9 @@ namespace nirfmxwlan_grpc { } auto status = library_->DSSSModAccCfgPowerMeasurementEnabled(instrument, selector_string, power_measurement_enabled); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1341,6 +1441,9 @@ namespace nirfmxwlan_grpc { char* selector_string = (char*)request->selector_string().c_str(); int32 number_of_custom_gates = request->number_of_custom_gates(); auto status = library_->DSSSModAccCfgPowerMeasurementNumberOfCustomGates(instrument, selector_string, number_of_custom_gates); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1366,13 +1469,14 @@ namespace nirfmxwlan_grpc { float64 data_average_power_mean {}; float64 ppdu_average_power_mean {}; auto status = library_->DSSSModAccFetchAveragePowers(instrument, selector_string, timeout, &preamble_average_power_mean, &header_average_power_mean, &data_average_power_mean, &ppdu_average_power_mean); - response->set_status(status); - if (status_ok(status)) { - response->set_preamble_average_power_mean(preamble_average_power_mean); - response->set_header_average_power_mean(header_average_power_mean); - response->set_data_average_power_mean(data_average_power_mean); - response->set_ppdu_average_power_mean(ppdu_average_power_mean); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_preamble_average_power_mean(preamble_average_power_mean); + response->set_header_average_power_mean(header_average_power_mean); + response->set_data_average_power_mean(data_average_power_mean); + response->set_ppdu_average_power_mean(ppdu_average_power_mean); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -1395,9 +1499,8 @@ namespace nirfmxwlan_grpc { int32 actual_array_size {}; while (true) { auto status = library_->DSSSModAccFetchConstellationTrace(instrument, selector_string, timeout, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } std::vector constellation(actual_array_size, NIComplexSingle()); auto array_size = actual_array_size; @@ -1406,18 +1509,19 @@ namespace nirfmxwlan_grpc { // buffer is now too small, try again continue; } + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); - if (status_ok(status)) { - convert_to_grpc(constellation, response->mutable_constellation()); - { - auto shrunk_size = actual_array_size; - auto current_size = response->mutable_constellation()->size(); - if (shrunk_size != current_size) { - response->mutable_constellation()->DeleteSubrange(shrunk_size, current_size - shrunk_size); - } + convert_to_grpc(constellation, response->mutable_constellation()); + { + auto shrunk_size = actual_array_size; + auto current_size = response->mutable_constellation()->size(); + if (shrunk_size != current_size) { + response->mutable_constellation()->DeleteSubrange(shrunk_size, current_size - shrunk_size); } - response->set_actual_array_size(actual_array_size); } + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -1441,9 +1545,8 @@ namespace nirfmxwlan_grpc { int32 actual_array_size {}; while (true) { auto status = library_->DSSSModAccFetchCustomGatePowersArray(instrument, selector_string, timeout, nullptr, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_average_power_mean()->Resize(actual_array_size, 0); float64* average_power_mean = response->mutable_average_power_mean()->mutable_data(); @@ -1455,12 +1558,13 @@ namespace nirfmxwlan_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->mutable_average_power_mean()->Resize(actual_array_size, 0); - response->mutable_peak_power_maximum()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->mutable_average_power_mean()->Resize(actual_array_size, 0); + response->mutable_peak_power_maximum()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -1484,9 +1588,8 @@ namespace nirfmxwlan_grpc { int32 actual_array_size {}; while (true) { auto status = library_->DSSSModAccFetchDecodedHeaderBitsTrace(instrument, selector_string, timeout, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_decoded_header_bits()->Resize(actual_array_size, 0); int32* decoded_header_bits = reinterpret_cast(response->mutable_decoded_header_bits()->mutable_data()); @@ -1496,11 +1599,12 @@ namespace nirfmxwlan_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->mutable_decoded_header_bits()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->mutable_decoded_header_bits()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -1524,9 +1628,8 @@ namespace nirfmxwlan_grpc { int32 actual_array_size {}; while (true) { auto status = library_->DSSSModAccFetchDecodedPSDUBitsTrace(instrument, selector_string, timeout, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_decoded_psdu_bits()->Resize(actual_array_size, 0); int32* decoded_psdu_bits = reinterpret_cast(response->mutable_decoded_psdu_bits()->mutable_data()); @@ -1536,11 +1639,12 @@ namespace nirfmxwlan_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->mutable_decoded_psdu_bits()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->mutable_decoded_psdu_bits()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -1569,16 +1673,17 @@ namespace nirfmxwlan_grpc { float64 chip_clock_error_mean {}; int32 number_of_chips_used {}; auto status = library_->DSSSModAccFetchEVM(instrument, selector_string, timeout, &rms_evm_mean, &peak_evm_80211_2016_maximum, &peak_evm_80211_2007_maximum, &peak_evm_80211_1999_maximum, &frequency_error_mean, &chip_clock_error_mean, &number_of_chips_used); - response->set_status(status); - if (status_ok(status)) { - response->set_rms_evm_mean(rms_evm_mean); - response->set_peak_evm_80211_2016_maximum(peak_evm_80211_2016_maximum); - response->set_peak_evm_80211_2007_maximum(peak_evm_80211_2007_maximum); - response->set_peak_evm_80211_1999_maximum(peak_evm_80211_1999_maximum); - response->set_frequency_error_mean(frequency_error_mean); - response->set_chip_clock_error_mean(chip_clock_error_mean); - response->set_number_of_chips_used(number_of_chips_used); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_rms_evm_mean(rms_evm_mean); + response->set_peak_evm_80211_2016_maximum(peak_evm_80211_2016_maximum); + response->set_peak_evm_80211_2007_maximum(peak_evm_80211_2007_maximum); + response->set_peak_evm_80211_1999_maximum(peak_evm_80211_1999_maximum); + response->set_frequency_error_mean(frequency_error_mean); + response->set_chip_clock_error_mean(chip_clock_error_mean); + response->set_number_of_chips_used(number_of_chips_used); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -1603,9 +1708,8 @@ namespace nirfmxwlan_grpc { int32 actual_array_size {}; while (true) { auto status = library_->DSSSModAccFetchEVMPerChipMeanTrace(instrument, selector_string, timeout, &x0, &dx, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_evm_per_chip_mean()->Resize(actual_array_size, 0); float32* evm_per_chip_mean = response->mutable_evm_per_chip_mean()->mutable_data(); @@ -1615,13 +1719,14 @@ namespace nirfmxwlan_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_x0(x0); - response->set_dx(dx); - response->mutable_evm_per_chip_mean()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_x0(x0); + response->set_dx(dx); + response->mutable_evm_per_chip_mean()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -1646,12 +1751,13 @@ namespace nirfmxwlan_grpc { float64 iq_gain_imbalance_mean {}; float64 iq_quadrature_error_mean {}; auto status = library_->DSSSModAccFetchIQImpairments(instrument, selector_string, timeout, &iq_origin_offset_mean, &iq_gain_imbalance_mean, &iq_quadrature_error_mean); - response->set_status(status); - if (status_ok(status)) { - response->set_iq_origin_offset_mean(iq_origin_offset_mean); - response->set_iq_gain_imbalance_mean(iq_gain_imbalance_mean); - response->set_iq_quadrature_error_mean(iq_quadrature_error_mean); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_iq_origin_offset_mean(iq_origin_offset_mean); + response->set_iq_gain_imbalance_mean(iq_gain_imbalance_mean); + response->set_iq_quadrature_error_mean(iq_quadrature_error_mean); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -1678,19 +1784,20 @@ namespace nirfmxwlan_grpc { int32 header_crc_status {}; int32 psdu_crc_status {}; auto status = library_->DSSSModAccFetchPPDUInformation(instrument, selector_string, timeout, &data_modulation_format, &payload_length, &preamble_type, &locked_clocks_bit, &header_crc_status, &psdu_crc_status); - response->set_status(status); - if (status_ok(status)) { - response->set_data_modulation_format(static_cast(data_modulation_format)); - response->set_data_modulation_format_raw(data_modulation_format); - response->set_payload_length(payload_length); - response->set_preamble_type(static_cast(preamble_type)); - response->set_preamble_type_raw(preamble_type); - response->set_locked_clocks_bit(locked_clocks_bit); - response->set_header_crc_status(static_cast(header_crc_status)); - response->set_header_crc_status_raw(header_crc_status); - response->set_psdu_crc_status(static_cast(psdu_crc_status)); - response->set_psdu_crc_status_raw(psdu_crc_status); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_data_modulation_format(static_cast(data_modulation_format)); + response->set_data_modulation_format_raw(data_modulation_format); + response->set_payload_length(payload_length); + response->set_preamble_type(static_cast(preamble_type)); + response->set_preamble_type_raw(preamble_type); + response->set_locked_clocks_bit(locked_clocks_bit); + response->set_header_crc_status(static_cast(header_crc_status)); + response->set_header_crc_status_raw(header_crc_status); + response->set_psdu_crc_status(static_cast(psdu_crc_status)); + response->set_psdu_crc_status_raw(psdu_crc_status); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -1715,13 +1822,14 @@ namespace nirfmxwlan_grpc { float64 data_peak_power_maximum {}; float64 ppdu_peak_power_maximum {}; auto status = library_->DSSSModAccFetchPeakPowers(instrument, selector_string, timeout, &preamble_peak_power_maximum, &header_peak_power_maximum, &data_peak_power_maximum, &ppdu_peak_power_maximum); - response->set_status(status); - if (status_ok(status)) { - response->set_preamble_peak_power_maximum(preamble_peak_power_maximum); - response->set_header_peak_power_maximum(header_peak_power_maximum); - response->set_data_peak_power_maximum(data_peak_power_maximum); - response->set_ppdu_peak_power_maximum(ppdu_peak_power_maximum); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_preamble_peak_power_maximum(preamble_peak_power_maximum); + response->set_header_peak_power_maximum(header_peak_power_maximum); + response->set_data_peak_power_maximum(data_peak_power_maximum); + response->set_ppdu_peak_power_maximum(ppdu_peak_power_maximum); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -1741,6 +1849,9 @@ namespace nirfmxwlan_grpc { niRFmxInstrHandle instrument = session_repository_->access_session(instrument_grpc_session.id(), instrument_grpc_session.name()); char* signal_name = (char*)request->signal_name().c_str(); auto status = library_->DeleteSignalConfiguration(instrument, signal_name); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1761,6 +1872,9 @@ namespace nirfmxwlan_grpc { niRFmxInstrHandle instrument = session_repository_->access_session(instrument_grpc_session.id(), instrument_grpc_session.name()); char* selector_string = (char*)request->selector_string().c_str(); auto status = library_->DisableTrigger(instrument, selector_string); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1784,9 +1898,8 @@ namespace nirfmxwlan_grpc { int32 default_result_exists {}; while (true) { auto status = library_->GetAllNamedResultNames(instrument, selector_string, nullptr, 0, &actual_result_names_size, &default_result_exists); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } std::string result_names; if (actual_result_names_size > 0) { @@ -1798,13 +1911,14 @@ namespace nirfmxwlan_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_result_names(result_names); - nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_result_names())); - response->set_actual_result_names_size(actual_result_names_size); - response->set_default_result_exists(default_result_exists); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_result_names(result_names); + nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_result_names())); + response->set_actual_result_names_size(actual_result_names_size); + response->set_default_result_exists(default_result_exists); return ::grpc::Status::OK; } } @@ -1827,10 +1941,11 @@ namespace nirfmxwlan_grpc { int32 attribute_id = request->attribute_id(); float32 attr_val {}; auto status = library_->GetAttributeF32(instrument, selector_string, attribute_id, &attr_val); - response->set_status(status); - if (status_ok(status)) { - response->set_attr_val(attr_val); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_attr_val(attr_val); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -1853,9 +1968,8 @@ namespace nirfmxwlan_grpc { int32 actual_array_size {}; while (true) { auto status = library_->GetAttributeF32Array(instrument, selector_string, attribute_id, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_attr_val()->Resize(actual_array_size, 0); float32* attr_val = response->mutable_attr_val()->mutable_data(); @@ -1865,11 +1979,12 @@ namespace nirfmxwlan_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->mutable_attr_val()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->mutable_attr_val()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -1892,10 +2007,11 @@ namespace nirfmxwlan_grpc { int32 attribute_id = request->attribute_id(); float64 attr_val {}; auto status = library_->GetAttributeF64(instrument, selector_string, attribute_id, &attr_val); - response->set_status(status); - if (status_ok(status)) { - response->set_attr_val(attr_val); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_attr_val(attr_val); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -1918,9 +2034,8 @@ namespace nirfmxwlan_grpc { int32 actual_array_size {}; while (true) { auto status = library_->GetAttributeF64Array(instrument, selector_string, attribute_id, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_attr_val()->Resize(actual_array_size, 0); float64* attr_val = response->mutable_attr_val()->mutable_data(); @@ -1930,11 +2045,12 @@ namespace nirfmxwlan_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->mutable_attr_val()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->mutable_attr_val()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -1957,10 +2073,11 @@ namespace nirfmxwlan_grpc { int32 attribute_id = request->attribute_id(); int16 attr_val {}; auto status = library_->GetAttributeI16(instrument, selector_string, attribute_id, &attr_val); - response->set_status(status); - if (status_ok(status)) { - response->set_attr_val(attr_val); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_attr_val(attr_val); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -1982,16 +2099,17 @@ namespace nirfmxwlan_grpc { int32 attribute_id = request->attribute_id(); int32 attr_val {}; auto status = library_->GetAttributeI32(instrument, selector_string, attribute_id, &attr_val); - response->set_status(status); - if (status_ok(status)) { - auto checked_convert_attr_val = [](auto raw_value) { - bool raw_value_is_valid = nirfmxwlan_grpc::NiRFmxWLANInt32AttributeValues_IsValid(raw_value); - auto valid_enum_value = raw_value_is_valid ? raw_value : 0; - return static_cast(valid_enum_value); - }; - response->set_attr_val(checked_convert_attr_val(attr_val)); - response->set_attr_val_raw(attr_val); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + auto checked_convert_attr_val = [](auto raw_value) { + bool raw_value_is_valid = nirfmxwlan_grpc::NiRFmxWLANInt32AttributeValues_IsValid(raw_value); + auto valid_enum_value = raw_value_is_valid ? raw_value : 0; + return static_cast(valid_enum_value); + }; + response->set_attr_val(checked_convert_attr_val(attr_val)); + response->set_attr_val_raw(attr_val); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -2014,9 +2132,8 @@ namespace nirfmxwlan_grpc { int32 actual_array_size {}; while (true) { auto status = library_->GetAttributeI32Array(instrument, selector_string, attribute_id, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_attr_val_raw()->Resize(actual_array_size, 0); int32* attr_val = reinterpret_cast(response->mutable_attr_val_raw()->mutable_data()); @@ -2026,13 +2143,15 @@ namespace nirfmxwlan_grpc { // buffer is now too small, try again continue; } + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); - if (status_ok(status)) { - auto checked_convert_attr_val = [](auto raw_value) { - bool raw_value_is_valid = nirfmxwlan_grpc::NiRFmxWLANInt32AttributeValues_IsValid(raw_value); - auto valid_enum_value = raw_value_is_valid ? raw_value : 0; - return static_cast(valid_enum_value); - }; + auto checked_convert_attr_val = [](auto raw_value) { + bool raw_value_is_valid = nirfmxwlan_grpc::NiRFmxWLANInt32AttributeValues_IsValid(raw_value); + auto valid_enum_value = raw_value_is_valid ? raw_value : 0; + return static_cast(valid_enum_value); + }; response->mutable_attr_val()->Clear(); response->mutable_attr_val()->Reserve(actual_array_size); std::transform( @@ -2042,9 +2161,8 @@ namespace nirfmxwlan_grpc { [&](auto x) { return checked_convert_attr_val(x); }); - response->mutable_attr_val()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); - } + response->mutable_attr_val()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -2067,10 +2185,11 @@ namespace nirfmxwlan_grpc { int32 attribute_id = request->attribute_id(); int64 attr_val {}; auto status = library_->GetAttributeI64(instrument, selector_string, attribute_id, &attr_val); - response->set_status(status); - if (status_ok(status)) { - response->set_attr_val(attr_val); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_attr_val(attr_val); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -2093,9 +2212,8 @@ namespace nirfmxwlan_grpc { int32 actual_array_size {}; while (true) { auto status = library_->GetAttributeI64Array(instrument, selector_string, attribute_id, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_attr_val()->Resize(actual_array_size, 0); int64* attr_val = reinterpret_cast(response->mutable_attr_val()->mutable_data()); @@ -2105,11 +2223,12 @@ namespace nirfmxwlan_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->mutable_attr_val()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->mutable_attr_val()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -2132,10 +2251,11 @@ namespace nirfmxwlan_grpc { int32 attribute_id = request->attribute_id(); int8 attr_val {}; auto status = library_->GetAttributeI8(instrument, selector_string, attribute_id, &attr_val); - response->set_status(status); - if (status_ok(status)) { - response->set_attr_val(attr_val); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_attr_val(attr_val); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -2158,9 +2278,8 @@ namespace nirfmxwlan_grpc { int32 actual_array_size {}; while (true) { auto status = library_->GetAttributeI8Array(instrument, selector_string, attribute_id, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } std::vector attr_val(actual_array_size); auto array_size = actual_array_size; @@ -2169,8 +2288,10 @@ namespace nirfmxwlan_grpc { // buffer is now too small, try again continue; } + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); - if (status_ok(status)) { response->mutable_attr_val()->Clear(); response->mutable_attr_val()->Reserve(actual_array_size); std::transform( @@ -2180,9 +2301,8 @@ namespace nirfmxwlan_grpc { [&](auto x) { return x; }); - response->mutable_attr_val()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); - } + response->mutable_attr_val()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -2206,9 +2326,8 @@ namespace nirfmxwlan_grpc { int32 actual_array_size {}; while (true) { auto status = library_->GetAttributeNIComplexDoubleArray(instrument, selector_string, attribute_id, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } std::vector attr_val(actual_array_size, NIComplexDouble()); auto array_size = actual_array_size; @@ -2217,18 +2336,19 @@ namespace nirfmxwlan_grpc { // buffer is now too small, try again continue; } + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); - if (status_ok(status)) { - convert_to_grpc(attr_val, response->mutable_attr_val()); - { - auto shrunk_size = actual_array_size; - auto current_size = response->mutable_attr_val()->size(); - if (shrunk_size != current_size) { - response->mutable_attr_val()->DeleteSubrange(shrunk_size, current_size - shrunk_size); - } + convert_to_grpc(attr_val, response->mutable_attr_val()); + { + auto shrunk_size = actual_array_size; + auto current_size = response->mutable_attr_val()->size(); + if (shrunk_size != current_size) { + response->mutable_attr_val()->DeleteSubrange(shrunk_size, current_size - shrunk_size); } - response->set_actual_array_size(actual_array_size); } + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -2252,9 +2372,8 @@ namespace nirfmxwlan_grpc { int32 actual_array_size {}; while (true) { auto status = library_->GetAttributeNIComplexSingleArray(instrument, selector_string, attribute_id, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } std::vector attr_val(actual_array_size, NIComplexSingle()); auto array_size = actual_array_size; @@ -2263,18 +2382,19 @@ namespace nirfmxwlan_grpc { // buffer is now too small, try again continue; } + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); - if (status_ok(status)) { - convert_to_grpc(attr_val, response->mutable_attr_val()); - { - auto shrunk_size = actual_array_size; - auto current_size = response->mutable_attr_val()->size(); - if (shrunk_size != current_size) { - response->mutable_attr_val()->DeleteSubrange(shrunk_size, current_size - shrunk_size); - } + convert_to_grpc(attr_val, response->mutable_attr_val()); + { + auto shrunk_size = actual_array_size; + auto current_size = response->mutable_attr_val()->size(); + if (shrunk_size != current_size) { + response->mutable_attr_val()->DeleteSubrange(shrunk_size, current_size - shrunk_size); } - response->set_actual_array_size(actual_array_size); } + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -2298,9 +2418,8 @@ namespace nirfmxwlan_grpc { while (true) { auto status = library_->GetAttributeString(instrument, selector_string, attribute_id, 0, nullptr); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } int32 array_size = status; @@ -2313,11 +2432,12 @@ namespace nirfmxwlan_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_attr_val(attr_val); - nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_attr_val())); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_attr_val(attr_val); + nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_attr_val())); return ::grpc::Status::OK; } } @@ -2340,10 +2460,11 @@ namespace nirfmxwlan_grpc { int32 attribute_id = request->attribute_id(); uInt16 attr_val {}; auto status = library_->GetAttributeU16(instrument, selector_string, attribute_id, &attr_val); - response->set_status(status); - if (status_ok(status)) { - response->set_attr_val(attr_val); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_attr_val(attr_val); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -2365,10 +2486,11 @@ namespace nirfmxwlan_grpc { int32 attribute_id = request->attribute_id(); uInt32 attr_val {}; auto status = library_->GetAttributeU32(instrument, selector_string, attribute_id, &attr_val); - response->set_status(status); - if (status_ok(status)) { - response->set_attr_val(attr_val); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_attr_val(attr_val); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -2391,9 +2513,8 @@ namespace nirfmxwlan_grpc { int32 actual_array_size {}; while (true) { auto status = library_->GetAttributeU32Array(instrument, selector_string, attribute_id, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_attr_val()->Resize(actual_array_size, 0); uInt32* attr_val = reinterpret_cast(response->mutable_attr_val()->mutable_data()); @@ -2403,11 +2524,12 @@ namespace nirfmxwlan_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->mutable_attr_val()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->mutable_attr_val()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -2431,9 +2553,8 @@ namespace nirfmxwlan_grpc { int32 actual_array_size {}; while (true) { auto status = library_->GetAttributeU64Array(instrument, selector_string, attribute_id, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_attr_val()->Resize(actual_array_size, 0); uInt64* attr_val = reinterpret_cast(response->mutable_attr_val()->mutable_data()); @@ -2443,11 +2564,12 @@ namespace nirfmxwlan_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->mutable_attr_val()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->mutable_attr_val()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -2470,10 +2592,11 @@ namespace nirfmxwlan_grpc { int32 attribute_id = request->attribute_id(); uInt8 attr_val {}; auto status = library_->GetAttributeU8(instrument, selector_string, attribute_id, &attr_val); - response->set_status(status); - if (status_ok(status)) { - response->set_attr_val(attr_val); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_attr_val(attr_val); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -2496,9 +2619,8 @@ namespace nirfmxwlan_grpc { int32 actual_array_size {}; while (true) { auto status = library_->GetAttributeU8Array(instrument, selector_string, attribute_id, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } std::string attr_val(actual_array_size, '\0'); auto array_size = actual_array_size; @@ -2507,12 +2629,13 @@ namespace nirfmxwlan_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_attr_val(attr_val); - response->mutable_attr_val()->resize(actual_array_size); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_attr_val(attr_val); + response->mutable_attr_val()->resize(actual_array_size); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -2534,9 +2657,8 @@ namespace nirfmxwlan_grpc { while (true) { auto status = library_->GetError(instrument, nullptr, 0, nullptr); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } int32 error_description_buffer_size = status; @@ -2550,12 +2672,13 @@ namespace nirfmxwlan_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_error_code(error_code); - response->set_error_description(error_description); - nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_error_description())); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_error_code(error_code); + response->set_error_description(error_description); + nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_error_description())); return ::grpc::Status::OK; } } @@ -2578,9 +2701,8 @@ namespace nirfmxwlan_grpc { while (true) { auto status = library_->GetErrorString(instrument, error_code, 0, nullptr); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } int32 error_description_buffer_size = status; @@ -2593,11 +2715,12 @@ namespace nirfmxwlan_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_error_description(error_description); - nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_error_description())); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_error_description(error_description); + nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_error_description())); return ::grpc::Status::OK; } } @@ -2627,15 +2750,12 @@ namespace nirfmxwlan_grpc { const std::string& grpc_device_session_name = request->session_name(); auto cleanup_lambda = [&] (niRFmxInstrHandle id) { library_->Close(id, RFMXWLAN_VAL_FALSE); }; int status = session_repository_->add_session(grpc_device_session_name, init_lambda, cleanup_lambda, session_id); - response->set_status(status); - if (status_ok(status)) { - response->mutable_instrument()->set_id(session_id); - response->set_is_new_session(is_new_session); - } - else { - const auto error_message = get_last_error_message(library_); - response->set_error_message(error_message); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, 0); } + response->set_status(status); + response->mutable_instrument()->set_id(session_id); + response->set_is_new_session(is_new_session); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -2666,14 +2786,11 @@ namespace nirfmxwlan_grpc { const std::string& grpc_device_session_name = request->session_name(); auto cleanup_lambda = [&] (niRFmxInstrHandle id) { library_->Close(id, RFMXWLAN_VAL_FALSE); }; int status = session_repository_->add_session(grpc_device_session_name, init_lambda, cleanup_lambda, session_id); - response->set_status(status); - if (status_ok(status)) { - response->mutable_instrument()->set_id(session_id); - } - else { - const auto error_message = get_last_error_message(library_); - response->set_error_message(error_message); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, 0); } + response->set_status(status); + response->mutable_instrument()->set_id(session_id); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -2697,6 +2814,9 @@ namespace nirfmxwlan_grpc { char* selector_string = (char*)request->selector_string().c_str(); char* result_name = (char*)request->result_name().c_str(); auto status = library_->Initiate(instrument, selector_string, result_name); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -2718,6 +2838,9 @@ namespace nirfmxwlan_grpc { char* selector_string = (char*)request->selector_string().c_str(); float64 timeout = request->timeout(); auto status = library_->OFDMModAccAutoLevel(instrument, selector_string, timeout); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -2742,6 +2865,9 @@ namespace nirfmxwlan_grpc { auto reference_waveform = convert_from_grpc(request->reference_waveform()); int32 array_size = static_cast(request->reference_waveform().size()); auto status = library_->OFDMModAccCfg1ReferenceWaveform(instrument, selector_string, x0, dx, reference_waveform.data(), array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -2779,6 +2905,9 @@ namespace nirfmxwlan_grpc { float64 acquisition_length = request->acquisition_length(); auto status = library_->OFDMModAccCfgAcquisitionLength(instrument, selector_string, acquisition_length_mode, acquisition_length); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -2815,6 +2944,9 @@ namespace nirfmxwlan_grpc { } auto status = library_->OFDMModAccCfgAmplitudeTrackingEnabled(instrument, selector_string, amplitude_tracking_enabled); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -2852,6 +2984,9 @@ namespace nirfmxwlan_grpc { int32 averaging_count = request->averaging_count(); auto status = library_->OFDMModAccCfgAveraging(instrument, selector_string, averaging_enabled, averaging_count); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -2888,6 +3023,9 @@ namespace nirfmxwlan_grpc { } auto status = library_->OFDMModAccCfgChannelEstimationType(instrument, selector_string, channel_estimation_type); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -2924,6 +3062,9 @@ namespace nirfmxwlan_grpc { } auto status = library_->OFDMModAccCfgCommonClockSourceEnabled(instrument, selector_string, common_clock_source_enabled); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -2960,6 +3101,9 @@ namespace nirfmxwlan_grpc { } auto status = library_->OFDMModAccCfgEVMUnit(instrument, selector_string, evm_unit); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -2996,6 +3140,9 @@ namespace nirfmxwlan_grpc { } auto status = library_->OFDMModAccCfgFrequencyErrorEstimationMethod(instrument, selector_string, frequency_error_estimation_method); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -3018,6 +3165,9 @@ namespace nirfmxwlan_grpc { int32 measurement_offset = request->measurement_offset(); int32 maximum_measurement_length = request->maximum_measurement_length(); auto status = library_->OFDMModAccCfgMeasurementLength(instrument, selector_string, measurement_offset, maximum_measurement_length); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -3054,6 +3204,9 @@ namespace nirfmxwlan_grpc { } auto status = library_->OFDMModAccCfgMeasurementMode(instrument, selector_string, measurement_mode); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -3097,6 +3250,9 @@ namespace nirfmxwlan_grpc { auto array_size = array_size_size_calculation.size; auto status = library_->OFDMModAccCfgNReferenceWaveforms(instrument, selector_string, x0, dx, reference_waveform.data(), reference_waveform_sizes, array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -3133,6 +3289,9 @@ namespace nirfmxwlan_grpc { } auto status = library_->OFDMModAccCfgNoiseCompensationEnabled(instrument, selector_string, noise_compensation_enabled); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -3170,6 +3329,9 @@ namespace nirfmxwlan_grpc { double optimize_dynamic_range_for_evm_margin = request->optimize_dynamic_range_for_evm_margin(); auto status = library_->OFDMModAccCfgOptimizeDynamicRangeForEVM(instrument, selector_string, optimize_dynamic_range_for_evm_enabled, optimize_dynamic_range_for_evm_margin); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -3206,6 +3368,9 @@ namespace nirfmxwlan_grpc { } auto status = library_->OFDMModAccCfgPhaseTrackingEnabled(instrument, selector_string, phase_tracking_enabled); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -3242,6 +3407,9 @@ namespace nirfmxwlan_grpc { } auto status = library_->OFDMModAccCfgSymbolClockErrorCorrectionEnabled(instrument, selector_string, symbol_clock_error_correction_enabled); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -3261,6 +3429,9 @@ namespace nirfmxwlan_grpc { auto instrument_grpc_session = request->instrument(); niRFmxInstrHandle instrument = session_repository_->access_session(instrument_grpc_session.id(), instrument_grpc_session.name()); auto status = library_->OFDMModAccClearNoiseCalibrationDatabase(instrument); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -3286,9 +3457,8 @@ namespace nirfmxwlan_grpc { int32 actual_array_size {}; while (true) { auto status = library_->OFDMModAccFetchChainDataRMSEVMPerSymbolMeanTrace(instrument, selector_string, timeout, &x0, &dx, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_chain_data_rms_evm_per_symbol_mean()->Resize(actual_array_size, 0); float32* chain_data_rms_evm_per_symbol_mean = response->mutable_chain_data_rms_evm_per_symbol_mean()->mutable_data(); @@ -3298,13 +3468,14 @@ namespace nirfmxwlan_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_x0(x0); - response->set_dx(dx); - response->mutable_chain_data_rms_evm_per_symbol_mean()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_x0(x0); + response->set_dx(dx); + response->mutable_chain_data_rms_evm_per_symbol_mean()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -3330,9 +3501,8 @@ namespace nirfmxwlan_grpc { int32 actual_array_size {}; while (true) { auto status = library_->OFDMModAccFetchChainPilotRMSEVMPerSymbolMeanTrace(instrument, selector_string, timeout, &x0, &dx, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_chain_pilot_rms_evm_per_symbol_mean()->Resize(actual_array_size, 0); float32* chain_pilot_rms_evm_per_symbol_mean = response->mutable_chain_pilot_rms_evm_per_symbol_mean()->mutable_data(); @@ -3342,13 +3512,14 @@ namespace nirfmxwlan_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_x0(x0); - response->set_dx(dx); - response->mutable_chain_pilot_rms_evm_per_symbol_mean()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_x0(x0); + response->set_dx(dx); + response->mutable_chain_pilot_rms_evm_per_symbol_mean()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -3373,12 +3544,13 @@ namespace nirfmxwlan_grpc { float64 chain_data_rms_evm_mean {}; float64 chain_pilot_rms_evm_mean {}; auto status = library_->OFDMModAccFetchChainRMSEVM(instrument, selector_string, timeout, &chain_rms_evm_mean, &chain_data_rms_evm_mean, &chain_pilot_rms_evm_mean); - response->set_status(status); - if (status_ok(status)) { - response->set_chain_rms_evm_mean(chain_rms_evm_mean); - response->set_chain_data_rms_evm_mean(chain_data_rms_evm_mean); - response->set_chain_pilot_rms_evm_mean(chain_pilot_rms_evm_mean); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_chain_rms_evm_mean(chain_rms_evm_mean); + response->set_chain_data_rms_evm_mean(chain_data_rms_evm_mean); + response->set_chain_pilot_rms_evm_mean(chain_pilot_rms_evm_mean); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -3403,9 +3575,8 @@ namespace nirfmxwlan_grpc { int32 actual_array_size {}; while (true) { auto status = library_->OFDMModAccFetchChainRMSEVMPerSubcarrierMeanTrace(instrument, selector_string, timeout, &x0, &dx, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_chain_rms_evm_per_subcarrier_mean()->Resize(actual_array_size, 0); float32* chain_rms_evm_per_subcarrier_mean = response->mutable_chain_rms_evm_per_subcarrier_mean()->mutable_data(); @@ -3415,13 +3586,14 @@ namespace nirfmxwlan_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_x0(x0); - response->set_dx(dx); - response->mutable_chain_rms_evm_per_subcarrier_mean()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_x0(x0); + response->set_dx(dx); + response->mutable_chain_rms_evm_per_subcarrier_mean()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -3447,9 +3619,8 @@ namespace nirfmxwlan_grpc { int32 actual_array_size {}; while (true) { auto status = library_->OFDMModAccFetchChainRMSEVMPerSymbolMeanTrace(instrument, selector_string, timeout, &x0, &dx, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_chain_rms_evm_per_symbol_mean()->Resize(actual_array_size, 0); float32* chain_rms_evm_per_symbol_mean = response->mutable_chain_rms_evm_per_symbol_mean()->mutable_data(); @@ -3459,13 +3630,14 @@ namespace nirfmxwlan_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_x0(x0); - response->set_dx(dx); - response->mutable_chain_rms_evm_per_symbol_mean()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_x0(x0); + response->set_dx(dx); + response->mutable_chain_rms_evm_per_symbol_mean()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -3491,9 +3663,8 @@ namespace nirfmxwlan_grpc { int32 actual_array_size {}; while (true) { auto status = library_->OFDMModAccFetchChannelFrequencyResponseMeanTrace(instrument, selector_string, timeout, &x0, &dx, nullptr, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_channel_frequency_response_mean_magnitude()->Resize(actual_array_size, 0); float32* channel_frequency_response_mean_magnitude = response->mutable_channel_frequency_response_mean_magnitude()->mutable_data(); @@ -3505,14 +3676,15 @@ namespace nirfmxwlan_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_x0(x0); - response->set_dx(dx); - response->mutable_channel_frequency_response_mean_magnitude()->Resize(actual_array_size, 0); - response->mutable_channel_frequency_response_mean_phase()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_x0(x0); + response->set_dx(dx); + response->mutable_channel_frequency_response_mean_magnitude()->Resize(actual_array_size, 0); + response->mutable_channel_frequency_response_mean_phase()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -3538,9 +3710,8 @@ namespace nirfmxwlan_grpc { int32 actual_array_size {}; while (true) { auto status = library_->OFDMModAccFetchCommonPilotErrorTrace(instrument, selector_string, timeout, &x0, &dx, nullptr, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_common_pilot_error_magnitude()->Resize(actual_array_size, 0); float32* common_pilot_error_magnitude = response->mutable_common_pilot_error_magnitude()->mutable_data(); @@ -3552,14 +3723,15 @@ namespace nirfmxwlan_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_x0(x0); - response->set_dx(dx); - response->mutable_common_pilot_error_magnitude()->Resize(actual_array_size, 0); - response->mutable_common_pilot_error_phase()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_x0(x0); + response->set_dx(dx); + response->mutable_common_pilot_error_magnitude()->Resize(actual_array_size, 0); + response->mutable_common_pilot_error_phase()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -3584,12 +3756,13 @@ namespace nirfmxwlan_grpc { float64 composite_data_rms_evm_mean {}; float64 composite_pilot_rms_evm_mean {}; auto status = library_->OFDMModAccFetchCompositeRMSEVM(instrument, selector_string, timeout, &composite_rms_evm_mean, &composite_data_rms_evm_mean, &composite_pilot_rms_evm_mean); - response->set_status(status); - if (status_ok(status)) { - response->set_composite_rms_evm_mean(composite_rms_evm_mean); - response->set_composite_data_rms_evm_mean(composite_data_rms_evm_mean); - response->set_composite_pilot_rms_evm_mean(composite_pilot_rms_evm_mean); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_composite_rms_evm_mean(composite_rms_evm_mean); + response->set_composite_data_rms_evm_mean(composite_data_rms_evm_mean); + response->set_composite_pilot_rms_evm_mean(composite_pilot_rms_evm_mean); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -3611,10 +3784,11 @@ namespace nirfmxwlan_grpc { float64 timeout = request->timeout(); float64 cross_power_mean {}; auto status = library_->OFDMModAccFetchCrossPower(instrument, selector_string, timeout, &cross_power_mean); - response->set_status(status); - if (status_ok(status)) { - response->set_cross_power_mean(cross_power_mean); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_cross_power_mean(cross_power_mean); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -3637,9 +3811,8 @@ namespace nirfmxwlan_grpc { int32 actual_array_size {}; while (true) { auto status = library_->OFDMModAccFetchCustomGatePowersArray(instrument, selector_string, timeout, nullptr, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_average_power_mean()->Resize(actual_array_size, 0); float64* average_power_mean = response->mutable_average_power_mean()->mutable_data(); @@ -3651,12 +3824,13 @@ namespace nirfmxwlan_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->mutable_average_power_mean()->Resize(actual_array_size, 0); - response->mutable_peak_power_maximum()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->mutable_average_power_mean()->Resize(actual_array_size, 0); + response->mutable_peak_power_maximum()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -3679,10 +3853,11 @@ namespace nirfmxwlan_grpc { float64 timeout = request->timeout(); float64 data_average_power_mean {}; auto status = library_->OFDMModAccFetchDataAveragePower(instrument, selector_string, timeout, &data_average_power_mean); - response->set_status(status); - if (status_ok(status)) { - response->set_data_average_power_mean(data_average_power_mean); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_data_average_power_mean(data_average_power_mean); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -3705,9 +3880,8 @@ namespace nirfmxwlan_grpc { int32 actual_array_size {}; while (true) { auto status = library_->OFDMModAccFetchDataConstellationTrace(instrument, selector_string, timeout, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } std::vector data_constellation(actual_array_size, NIComplexSingle()); auto array_size = actual_array_size; @@ -3716,18 +3890,19 @@ namespace nirfmxwlan_grpc { // buffer is now too small, try again continue; } + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); - if (status_ok(status)) { - convert_to_grpc(data_constellation, response->mutable_data_constellation()); - { - auto shrunk_size = actual_array_size; - auto current_size = response->mutable_data_constellation()->size(); - if (shrunk_size != current_size) { - response->mutable_data_constellation()->DeleteSubrange(shrunk_size, current_size - shrunk_size); - } + convert_to_grpc(data_constellation, response->mutable_data_constellation()); + { + auto shrunk_size = actual_array_size; + auto current_size = response->mutable_data_constellation()->size(); + if (shrunk_size != current_size) { + response->mutable_data_constellation()->DeleteSubrange(shrunk_size, current_size - shrunk_size); } - response->set_actual_array_size(actual_array_size); } + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -3750,10 +3925,11 @@ namespace nirfmxwlan_grpc { float64 timeout = request->timeout(); float64 data_peak_power_maximum {}; auto status = library_->OFDMModAccFetchDataPeakPower(instrument, selector_string, timeout, &data_peak_power_maximum); - response->set_status(status); - if (status_ok(status)) { - response->set_data_peak_power_maximum(data_peak_power_maximum); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_data_peak_power_maximum(data_peak_power_maximum); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -3776,9 +3952,8 @@ namespace nirfmxwlan_grpc { int32 actual_array_size {}; while (true) { auto status = library_->OFDMModAccFetchDecodedEHTSIGBitsTrace(instrument, selector_string, timeout, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_decoded_eht_sig_bits()->Resize(actual_array_size, 0); int32* decoded_eht_sig_bits = reinterpret_cast(response->mutable_decoded_eht_sig_bits()->mutable_data()); @@ -3788,11 +3963,12 @@ namespace nirfmxwlan_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->mutable_decoded_eht_sig_bits()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->mutable_decoded_eht_sig_bits()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -3816,9 +3992,8 @@ namespace nirfmxwlan_grpc { int32 actual_array_size {}; while (true) { auto status = library_->OFDMModAccFetchDecodedLSIGBitsTrace(instrument, selector_string, timeout, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_decoded_l_sig_bits()->Resize(actual_array_size, 0); int32* decoded_l_sig_bits = reinterpret_cast(response->mutable_decoded_l_sig_bits()->mutable_data()); @@ -3828,11 +4003,12 @@ namespace nirfmxwlan_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->mutable_decoded_l_sig_bits()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->mutable_decoded_l_sig_bits()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -3856,9 +4032,8 @@ namespace nirfmxwlan_grpc { int32 actual_array_size {}; while (true) { auto status = library_->OFDMModAccFetchDecodedPSDUBitsTrace(instrument, selector_string, timeout, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_decoded_psdu_bits()->Resize(actual_array_size, 0); int32* decoded_psdu_bits = reinterpret_cast(response->mutable_decoded_psdu_bits()->mutable_data()); @@ -3868,11 +4043,12 @@ namespace nirfmxwlan_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->mutable_decoded_psdu_bits()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->mutable_decoded_psdu_bits()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -3896,9 +4072,8 @@ namespace nirfmxwlan_grpc { int32 actual_array_size {}; while (true) { auto status = library_->OFDMModAccFetchDecodedSIGBBitsTrace(instrument, selector_string, timeout, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_decoded_sig_b_bits()->Resize(actual_array_size, 0); int32* decoded_sig_b_bits = reinterpret_cast(response->mutable_decoded_sig_b_bits()->mutable_data()); @@ -3908,11 +4083,12 @@ namespace nirfmxwlan_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->mutable_decoded_sig_b_bits()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->mutable_decoded_sig_b_bits()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -3936,9 +4112,8 @@ namespace nirfmxwlan_grpc { int32 actual_array_size {}; while (true) { auto status = library_->OFDMModAccFetchDecodedSIGBitsTrace(instrument, selector_string, timeout, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_decoded_sig_bits()->Resize(actual_array_size, 0); int32* decoded_sig_bits = reinterpret_cast(response->mutable_decoded_sig_bits()->mutable_data()); @@ -3948,11 +4123,12 @@ namespace nirfmxwlan_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->mutable_decoded_sig_bits()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->mutable_decoded_sig_bits()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -3976,9 +4152,8 @@ namespace nirfmxwlan_grpc { int32 actual_array_size {}; while (true) { auto status = library_->OFDMModAccFetchDecodedServiceBitsTrace(instrument, selector_string, timeout, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_decoded_service_bits()->Resize(actual_array_size, 0); int32* decoded_service_bits = reinterpret_cast(response->mutable_decoded_service_bits()->mutable_data()); @@ -3988,11 +4163,12 @@ namespace nirfmxwlan_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->mutable_decoded_service_bits()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->mutable_decoded_service_bits()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -4016,9 +4192,8 @@ namespace nirfmxwlan_grpc { int32 actual_array_size {}; while (true) { auto status = library_->OFDMModAccFetchDecodedUSIGBitsTrace(instrument, selector_string, timeout, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_decoded_u_sig_bits()->Resize(actual_array_size, 0); int32* decoded_u_sig_bits = reinterpret_cast(response->mutable_decoded_u_sig_bits()->mutable_data()); @@ -4028,11 +4203,12 @@ namespace nirfmxwlan_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->mutable_decoded_u_sig_bits()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->mutable_decoded_u_sig_bits()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -4056,9 +4232,8 @@ namespace nirfmxwlan_grpc { int32 actual_array_size {}; while (true) { auto status = library_->OFDMModAccFetchEVMSubcarrierIndices(instrument, selector_string, timeout, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_subcarrier_indices()->Resize(actual_array_size, 0); int32* subcarrier_indices = reinterpret_cast(response->mutable_subcarrier_indices()->mutable_data()); @@ -4068,11 +4243,12 @@ namespace nirfmxwlan_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->mutable_subcarrier_indices()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->mutable_subcarrier_indices()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -4095,10 +4271,11 @@ namespace nirfmxwlan_grpc { float64 timeout = request->timeout(); float64 frequency_error_ccdf_10_percent {}; auto status = library_->OFDMModAccFetchFrequencyErrorCCDF10Percent(instrument, selector_string, timeout, &frequency_error_ccdf_10_percent); - response->set_status(status); - if (status_ok(status)) { - response->set_frequency_error_ccdf_10_percent(frequency_error_ccdf_10_percent); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_frequency_error_ccdf_10_percent(frequency_error_ccdf_10_percent); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -4120,10 +4297,11 @@ namespace nirfmxwlan_grpc { float64 timeout = request->timeout(); float64 frequency_error_mean {}; auto status = library_->OFDMModAccFetchFrequencyErrorMean(instrument, selector_string, timeout, &frequency_error_mean); - response->set_status(status); - if (status_ok(status)) { - response->set_frequency_error_mean(frequency_error_mean); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_frequency_error_mean(frequency_error_mean); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -4148,9 +4326,8 @@ namespace nirfmxwlan_grpc { int32 actual_array_size {}; while (true) { auto status = library_->OFDMModAccFetchGroupDelayMeanTrace(instrument, selector_string, timeout, &x0, &dx, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_group_delay_mean()->Resize(actual_array_size, 0); float32* group_delay_mean = response->mutable_group_delay_mean()->mutable_data(); @@ -4160,13 +4337,14 @@ namespace nirfmxwlan_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_x0(x0); - response->set_dx(dx); - response->mutable_group_delay_mean()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_x0(x0); + response->set_dx(dx); + response->mutable_group_delay_mean()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -4189,11 +4367,12 @@ namespace nirfmxwlan_grpc { float64 timeout = request->timeout(); int32 guard_interval_type {}; auto status = library_->OFDMModAccFetchGuardIntervalType(instrument, selector_string, timeout, &guard_interval_type); - response->set_status(status); - if (status_ok(status)) { - response->set_guard_interval_type(static_cast(guard_interval_type)); - response->set_guard_interval_type_raw(guard_interval_type); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_guard_interval_type(static_cast(guard_interval_type)); + response->set_guard_interval_type_raw(guard_interval_type); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -4218,9 +4397,8 @@ namespace nirfmxwlan_grpc { int32 actual_array_size {}; while (true) { auto status = library_->OFDMModAccFetchIQGainImbalancePerSubcarrierMeanTrace(instrument, selector_string, timeout, &x0, &dx, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_iq_gain_imbalance_per_subcarrier_mean()->Resize(actual_array_size, 0); float32* iq_gain_imbalance_per_subcarrier_mean = response->mutable_iq_gain_imbalance_per_subcarrier_mean()->mutable_data(); @@ -4230,13 +4408,14 @@ namespace nirfmxwlan_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_x0(x0); - response->set_dx(dx); - response->mutable_iq_gain_imbalance_per_subcarrier_mean()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_x0(x0); + response->set_dx(dx); + response->mutable_iq_gain_imbalance_per_subcarrier_mean()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -4263,14 +4442,15 @@ namespace nirfmxwlan_grpc { float64 absolute_iq_origin_offset_mean {}; float64 iq_timing_skew_mean {}; auto status = library_->OFDMModAccFetchIQImpairments(instrument, selector_string, timeout, &relative_iq_origin_offset_mean, &iq_gain_imbalance_mean, &iq_quadrature_error_mean, &absolute_iq_origin_offset_mean, &iq_timing_skew_mean); - response->set_status(status); - if (status_ok(status)) { - response->set_relative_iq_origin_offset_mean(relative_iq_origin_offset_mean); - response->set_iq_gain_imbalance_mean(iq_gain_imbalance_mean); - response->set_iq_quadrature_error_mean(iq_quadrature_error_mean); - response->set_absolute_iq_origin_offset_mean(absolute_iq_origin_offset_mean); - response->set_iq_timing_skew_mean(iq_timing_skew_mean); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_relative_iq_origin_offset_mean(relative_iq_origin_offset_mean); + response->set_iq_gain_imbalance_mean(iq_gain_imbalance_mean); + response->set_iq_quadrature_error_mean(iq_quadrature_error_mean); + response->set_absolute_iq_origin_offset_mean(absolute_iq_origin_offset_mean); + response->set_iq_timing_skew_mean(iq_timing_skew_mean); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -4295,9 +4475,8 @@ namespace nirfmxwlan_grpc { int32 actual_array_size {}; while (true) { auto status = library_->OFDMModAccFetchIQQuadratureErrorPerSubcarrierMeanTrace(instrument, selector_string, timeout, &x0, &dx, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_iq_quadrature_error_per_subcarrier_mean()->Resize(actual_array_size, 0); float32* iq_quadrature_error_per_subcarrier_mean = response->mutable_iq_quadrature_error_per_subcarrier_mean()->mutable_data(); @@ -4307,13 +4486,14 @@ namespace nirfmxwlan_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_x0(x0); - response->set_dx(dx); - response->mutable_iq_quadrature_error_per_subcarrier_mean()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_x0(x0); + response->set_dx(dx); + response->mutable_iq_quadrature_error_per_subcarrier_mean()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -4336,11 +4516,12 @@ namespace nirfmxwlan_grpc { float64 timeout = request->timeout(); int32 l_sig_parity_check_status {}; auto status = library_->OFDMModAccFetchLSIGParityCheckStatus(instrument, selector_string, timeout, &l_sig_parity_check_status); - response->set_status(status); - if (status_ok(status)) { - response->set_l_sig_parity_check_status(static_cast(l_sig_parity_check_status)); - response->set_l_sig_parity_check_status_raw(l_sig_parity_check_status); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_l_sig_parity_check_status(static_cast(l_sig_parity_check_status)); + response->set_l_sig_parity_check_status_raw(l_sig_parity_check_status); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -4362,11 +4543,12 @@ namespace nirfmxwlan_grpc { float64 timeout = request->timeout(); int32 ltf_size {}; auto status = library_->OFDMModAccFetchLTFSize(instrument, selector_string, timeout, <f_size); - response->set_status(status); - if (status_ok(status)) { - response->set_ltf_size(static_cast(ltf_size)); - response->set_ltf_size_raw(ltf_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_ltf_size(static_cast(ltf_size)); + response->set_ltf_size_raw(ltf_size); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -4388,10 +4570,11 @@ namespace nirfmxwlan_grpc { float64 timeout = request->timeout(); int32 mcs_index {}; auto status = library_->OFDMModAccFetchMCSIndex(instrument, selector_string, timeout, &mcs_index); - response->set_status(status); - if (status_ok(status)) { - response->set_mcs_index(mcs_index); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_mcs_index(mcs_index); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -4413,10 +4596,11 @@ namespace nirfmxwlan_grpc { float64 timeout = request->timeout(); int32 number_of_he_sig_b_symbols {}; auto status = library_->OFDMModAccFetchNumberOfHESIGBSymbols(instrument, selector_string, timeout, &number_of_he_sig_b_symbols); - response->set_status(status); - if (status_ok(status)) { - response->set_number_of_he_sig_b_symbols(number_of_he_sig_b_symbols); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_number_of_he_sig_b_symbols(number_of_he_sig_b_symbols); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -4438,10 +4622,11 @@ namespace nirfmxwlan_grpc { float64 timeout = request->timeout(); int32 number_of_space_time_streams {}; auto status = library_->OFDMModAccFetchNumberOfSpaceTimeStreams(instrument, selector_string, timeout, &number_of_space_time_streams); - response->set_status(status); - if (status_ok(status)) { - response->set_number_of_space_time_streams(number_of_space_time_streams); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_number_of_space_time_streams(number_of_space_time_streams); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -4463,10 +4648,11 @@ namespace nirfmxwlan_grpc { float64 timeout = request->timeout(); int32 number_of_users {}; auto status = library_->OFDMModAccFetchNumberOfUsers(instrument, selector_string, timeout, &number_of_users); - response->set_status(status); - if (status_ok(status)) { - response->set_number_of_users(number_of_users); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_number_of_users(number_of_users); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -4488,10 +4674,11 @@ namespace nirfmxwlan_grpc { float64 timeout = request->timeout(); int32 number_of_symbols_used {}; auto status = library_->OFDMModAccFetchNumberofSymbolsUsed(instrument, selector_string, timeout, &number_of_symbols_used); - response->set_status(status); - if (status_ok(status)) { - response->set_number_of_symbols_used(number_of_symbols_used); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_number_of_symbols_used(number_of_symbols_used); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -4513,10 +4700,11 @@ namespace nirfmxwlan_grpc { float64 timeout = request->timeout(); float64 pe_average_power_mean {}; auto status = library_->OFDMModAccFetchPEAveragePower(instrument, selector_string, timeout, &pe_average_power_mean); - response->set_status(status); - if (status_ok(status)) { - response->set_pe_average_power_mean(pe_average_power_mean); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_pe_average_power_mean(pe_average_power_mean); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -4538,10 +4726,11 @@ namespace nirfmxwlan_grpc { float64 timeout = request->timeout(); float64 pe_duration {}; auto status = library_->OFDMModAccFetchPEDuration(instrument, selector_string, timeout, &pe_duration); - response->set_status(status); - if (status_ok(status)) { - response->set_pe_duration(pe_duration); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_pe_duration(pe_duration); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -4563,10 +4752,11 @@ namespace nirfmxwlan_grpc { float64 timeout = request->timeout(); float64 pe_peak_power_maximum {}; auto status = library_->OFDMModAccFetchPEPeakPower(instrument, selector_string, timeout, &pe_peak_power_maximum); - response->set_status(status); - if (status_ok(status)) { - response->set_pe_peak_power_maximum(pe_peak_power_maximum); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_pe_peak_power_maximum(pe_peak_power_maximum); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -4588,10 +4778,11 @@ namespace nirfmxwlan_grpc { float64 timeout = request->timeout(); float64 ppdu_average_power_mean {}; auto status = library_->OFDMModAccFetchPPDUAveragePower(instrument, selector_string, timeout, &ppdu_average_power_mean); - response->set_status(status); - if (status_ok(status)) { - response->set_ppdu_average_power_mean(ppdu_average_power_mean); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_ppdu_average_power_mean(ppdu_average_power_mean); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -4613,10 +4804,11 @@ namespace nirfmxwlan_grpc { float64 timeout = request->timeout(); float64 ppdu_peak_power_maximum {}; auto status = library_->OFDMModAccFetchPPDUPeakPower(instrument, selector_string, timeout, &ppdu_peak_power_maximum); - response->set_status(status); - if (status_ok(status)) { - response->set_ppdu_peak_power_maximum(ppdu_peak_power_maximum); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_ppdu_peak_power_maximum(ppdu_peak_power_maximum); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -4638,11 +4830,12 @@ namespace nirfmxwlan_grpc { float64 timeout = request->timeout(); int32 ppdu_type {}; auto status = library_->OFDMModAccFetchPPDUType(instrument, selector_string, timeout, &ppdu_type); - response->set_status(status); - if (status_ok(status)) { - response->set_ppdu_type(static_cast(ppdu_type)); - response->set_ppdu_type_raw(ppdu_type); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_ppdu_type(static_cast(ppdu_type)); + response->set_ppdu_type_raw(ppdu_type); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -4664,11 +4857,12 @@ namespace nirfmxwlan_grpc { float64 timeout = request->timeout(); int32 psdu_crc_status {}; auto status = library_->OFDMModAccFetchPSDUCRCStatus(instrument, selector_string, timeout, &psdu_crc_status); - response->set_status(status); - if (status_ok(status)) { - response->set_psdu_crc_status(static_cast(psdu_crc_status)); - response->set_psdu_crc_status_raw(psdu_crc_status); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_psdu_crc_status(static_cast(psdu_crc_status)); + response->set_psdu_crc_status_raw(psdu_crc_status); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -4691,9 +4885,8 @@ namespace nirfmxwlan_grpc { int32 actual_array_size {}; while (true) { auto status = library_->OFDMModAccFetchPilotConstellationTrace(instrument, selector_string, timeout, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } std::vector pilot_constellation(actual_array_size, NIComplexSingle()); auto array_size = actual_array_size; @@ -4702,18 +4895,19 @@ namespace nirfmxwlan_grpc { // buffer is now too small, try again continue; } + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); - if (status_ok(status)) { - convert_to_grpc(pilot_constellation, response->mutable_pilot_constellation()); - { - auto shrunk_size = actual_array_size; - auto current_size = response->mutable_pilot_constellation()->size(); - if (shrunk_size != current_size) { - response->mutable_pilot_constellation()->DeleteSubrange(shrunk_size, current_size - shrunk_size); - } + convert_to_grpc(pilot_constellation, response->mutable_pilot_constellation()); + { + auto shrunk_size = actual_array_size; + auto current_size = response->mutable_pilot_constellation()->size(); + if (shrunk_size != current_size) { + response->mutable_pilot_constellation()->DeleteSubrange(shrunk_size, current_size - shrunk_size); } - response->set_actual_array_size(actual_array_size); } + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -4739,13 +4933,14 @@ namespace nirfmxwlan_grpc { float64 vht_ltf_average_power_mean {}; float64 vht_sig_b_average_power_mean {}; auto status = library_->OFDMModAccFetchPreambleAveragePowers80211ac(instrument, selector_string, timeout, &vht_sig_a_average_power_mean, &vht_stf_average_power_mean, &vht_ltf_average_power_mean, &vht_sig_b_average_power_mean); - response->set_status(status); - if (status_ok(status)) { - response->set_vht_sig_a_average_power_mean(vht_sig_a_average_power_mean); - response->set_vht_stf_average_power_mean(vht_stf_average_power_mean); - response->set_vht_ltf_average_power_mean(vht_ltf_average_power_mean); - response->set_vht_sig_b_average_power_mean(vht_sig_b_average_power_mean); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_vht_sig_a_average_power_mean(vht_sig_a_average_power_mean); + response->set_vht_stf_average_power_mean(vht_stf_average_power_mean); + response->set_vht_ltf_average_power_mean(vht_ltf_average_power_mean); + response->set_vht_sig_b_average_power_mean(vht_sig_b_average_power_mean); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -4771,14 +4966,15 @@ namespace nirfmxwlan_grpc { float64 he_stf_average_power_mean {}; float64 he_ltf_average_power_mean {}; auto status = library_->OFDMModAccFetchPreambleAveragePowers80211ax(instrument, selector_string, timeout, &rl_sig_average_power_mean, &he_sig_a_average_power_mean, &he_sig_b_average_power_mean, &he_stf_average_power_mean, &he_ltf_average_power_mean); - response->set_status(status); - if (status_ok(status)) { - response->set_rl_sig_average_power_mean(rl_sig_average_power_mean); - response->set_he_sig_a_average_power_mean(he_sig_a_average_power_mean); - response->set_he_sig_b_average_power_mean(he_sig_b_average_power_mean); - response->set_he_stf_average_power_mean(he_stf_average_power_mean); - response->set_he_ltf_average_power_mean(he_ltf_average_power_mean); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_rl_sig_average_power_mean(rl_sig_average_power_mean); + response->set_he_sig_a_average_power_mean(he_sig_a_average_power_mean); + response->set_he_sig_b_average_power_mean(he_sig_b_average_power_mean); + response->set_he_stf_average_power_mean(he_stf_average_power_mean); + response->set_he_ltf_average_power_mean(he_ltf_average_power_mean); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -4803,13 +4999,14 @@ namespace nirfmxwlan_grpc { float64 ht_dltf_average_power_mean {}; float64 ht_eltf_average_power_mean {}; auto status = library_->OFDMModAccFetchPreambleAveragePowers80211n(instrument, selector_string, timeout, &ht_sig_average_power_mean, &ht_stf_average_power_mean, &ht_dltf_average_power_mean, &ht_eltf_average_power_mean); - response->set_status(status); - if (status_ok(status)) { - response->set_ht_sig_average_power_mean(ht_sig_average_power_mean); - response->set_ht_stf_average_power_mean(ht_stf_average_power_mean); - response->set_ht_dltf_average_power_mean(ht_dltf_average_power_mean); - response->set_ht_eltf_average_power_mean(ht_eltf_average_power_mean); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_ht_sig_average_power_mean(ht_sig_average_power_mean); + response->set_ht_stf_average_power_mean(ht_stf_average_power_mean); + response->set_ht_dltf_average_power_mean(ht_dltf_average_power_mean); + response->set_ht_eltf_average_power_mean(ht_eltf_average_power_mean); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -4833,12 +5030,13 @@ namespace nirfmxwlan_grpc { float64 l_ltf_average_power_mean {}; float64 l_sig_average_power_mean {}; auto status = library_->OFDMModAccFetchPreambleAveragePowersCommon(instrument, selector_string, timeout, &l_stf_average_power_mean, &l_ltf_average_power_mean, &l_sig_average_power_mean); - response->set_status(status); - if (status_ok(status)) { - response->set_l_stf_average_power_mean(l_stf_average_power_mean); - response->set_l_ltf_average_power_mean(l_ltf_average_power_mean); - response->set_l_sig_average_power_mean(l_sig_average_power_mean); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_l_stf_average_power_mean(l_stf_average_power_mean); + response->set_l_ltf_average_power_mean(l_ltf_average_power_mean); + response->set_l_sig_average_power_mean(l_sig_average_power_mean); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -4863,9 +5061,8 @@ namespace nirfmxwlan_grpc { int32 actual_array_size {}; while (true) { auto status = library_->OFDMModAccFetchPreambleFrequencyErrorTrace(instrument, selector_string, timeout, &x0, &dx, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_preamble_frequency_error()->Resize(actual_array_size, 0); float32* preamble_frequency_error = response->mutable_preamble_frequency_error()->mutable_data(); @@ -4875,13 +5072,14 @@ namespace nirfmxwlan_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_x0(x0); - response->set_dx(dx); - response->mutable_preamble_frequency_error()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_x0(x0); + response->set_dx(dx); + response->mutable_preamble_frequency_error()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -4907,13 +5105,14 @@ namespace nirfmxwlan_grpc { float64 vht_ltf_peak_power_maximum {}; float64 vht_sig_b_peak_power_maximum {}; auto status = library_->OFDMModAccFetchPreamblePeakPowers80211ac(instrument, selector_string, timeout, &vht_sig_a_peak_power_maximum, &vht_stf_peak_power_maximum, &vht_ltf_peak_power_maximum, &vht_sig_b_peak_power_maximum); - response->set_status(status); - if (status_ok(status)) { - response->set_vht_sig_a_peak_power_maximum(vht_sig_a_peak_power_maximum); - response->set_vht_stf_peak_power_maximum(vht_stf_peak_power_maximum); - response->set_vht_ltf_peak_power_maximum(vht_ltf_peak_power_maximum); - response->set_vht_sig_b_peak_power_maximum(vht_sig_b_peak_power_maximum); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_vht_sig_a_peak_power_maximum(vht_sig_a_peak_power_maximum); + response->set_vht_stf_peak_power_maximum(vht_stf_peak_power_maximum); + response->set_vht_ltf_peak_power_maximum(vht_ltf_peak_power_maximum); + response->set_vht_sig_b_peak_power_maximum(vht_sig_b_peak_power_maximum); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -4939,14 +5138,15 @@ namespace nirfmxwlan_grpc { float64 he_stf_peak_power_maximum {}; float64 he_ltf_peak_power_maximum {}; auto status = library_->OFDMModAccFetchPreamblePeakPowers80211ax(instrument, selector_string, timeout, &rl_sig_peak_power_maximum, &he_sig_a_peak_power_maximum, &he_sig_b_peak_power_maximum, &he_stf_peak_power_maximum, &he_ltf_peak_power_maximum); - response->set_status(status); - if (status_ok(status)) { - response->set_rl_sig_peak_power_maximum(rl_sig_peak_power_maximum); - response->set_he_sig_a_peak_power_maximum(he_sig_a_peak_power_maximum); - response->set_he_sig_b_peak_power_maximum(he_sig_b_peak_power_maximum); - response->set_he_stf_peak_power_maximum(he_stf_peak_power_maximum); - response->set_he_ltf_peak_power_maximum(he_ltf_peak_power_maximum); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_rl_sig_peak_power_maximum(rl_sig_peak_power_maximum); + response->set_he_sig_a_peak_power_maximum(he_sig_a_peak_power_maximum); + response->set_he_sig_b_peak_power_maximum(he_sig_b_peak_power_maximum); + response->set_he_stf_peak_power_maximum(he_stf_peak_power_maximum); + response->set_he_ltf_peak_power_maximum(he_ltf_peak_power_maximum); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -4971,13 +5171,14 @@ namespace nirfmxwlan_grpc { float64 ht_dltf_peak_power_maximum {}; float64 ht_eltf_peak_power_maximum {}; auto status = library_->OFDMModAccFetchPreamblePeakPowers80211n(instrument, selector_string, timeout, &ht_sig_peak_power_maximum, &ht_stf_peak_power_maximum, &ht_dltf_peak_power_maximum, &ht_eltf_peak_power_maximum); - response->set_status(status); - if (status_ok(status)) { - response->set_ht_sig_peak_power_maximum(ht_sig_peak_power_maximum); - response->set_ht_stf_peak_power_maximum(ht_stf_peak_power_maximum); - response->set_ht_dltf_peak_power_maximum(ht_dltf_peak_power_maximum); - response->set_ht_eltf_peak_power_maximum(ht_eltf_peak_power_maximum); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_ht_sig_peak_power_maximum(ht_sig_peak_power_maximum); + response->set_ht_stf_peak_power_maximum(ht_stf_peak_power_maximum); + response->set_ht_dltf_peak_power_maximum(ht_dltf_peak_power_maximum); + response->set_ht_eltf_peak_power_maximum(ht_eltf_peak_power_maximum); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -5001,12 +5202,13 @@ namespace nirfmxwlan_grpc { float64 l_ltf_peak_power_maximum {}; float64 l_sig_peak_power_maximum {}; auto status = library_->OFDMModAccFetchPreamblePeakPowersCommon(instrument, selector_string, timeout, &l_stf_peak_power_maximum, &l_ltf_peak_power_maximum, &l_sig_peak_power_maximum); - response->set_status(status); - if (status_ok(status)) { - response->set_l_stf_peak_power_maximum(l_stf_peak_power_maximum); - response->set_l_ltf_peak_power_maximum(l_ltf_peak_power_maximum); - response->set_l_sig_peak_power_maximum(l_sig_peak_power_maximum); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_l_stf_peak_power_maximum(l_stf_peak_power_maximum); + response->set_l_ltf_peak_power_maximum(l_ltf_peak_power_maximum); + response->set_l_sig_peak_power_maximum(l_sig_peak_power_maximum); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -5029,11 +5231,12 @@ namespace nirfmxwlan_grpc { int32 ru_offset {}; int32 ru_size {}; auto status = library_->OFDMModAccFetchRUOffsetAndSize(instrument, selector_string, timeout, &ru_offset, &ru_size); - response->set_status(status); - if (status_ok(status)) { - response->set_ru_offset(ru_offset); - response->set_ru_size(ru_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_ru_offset(ru_offset); + response->set_ru_size(ru_size); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -5055,11 +5258,12 @@ namespace nirfmxwlan_grpc { float64 timeout = request->timeout(); int32 sig_b_crc_status {}; auto status = library_->OFDMModAccFetchSIGBCRCStatus(instrument, selector_string, timeout, &sig_b_crc_status); - response->set_status(status); - if (status_ok(status)) { - response->set_sig_b_crc_status(static_cast(sig_b_crc_status)); - response->set_sig_b_crc_status_raw(sig_b_crc_status); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_sig_b_crc_status(static_cast(sig_b_crc_status)); + response->set_sig_b_crc_status_raw(sig_b_crc_status); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -5081,11 +5285,12 @@ namespace nirfmxwlan_grpc { float64 timeout = request->timeout(); int32 sig_crc_status {}; auto status = library_->OFDMModAccFetchSIGCRCStatus(instrument, selector_string, timeout, &sig_crc_status); - response->set_status(status); - if (status_ok(status)) { - response->set_sig_crc_status(static_cast(sig_crc_status)); - response->set_sig_crc_status_raw(sig_crc_status); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_sig_crc_status(static_cast(sig_crc_status)); + response->set_sig_crc_status_raw(sig_crc_status); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -5108,11 +5313,12 @@ namespace nirfmxwlan_grpc { float64 spectral_flatness_margin {}; int32 spectral_flatness_margin_subcarrier_index {}; auto status = library_->OFDMModAccFetchSpectralFlatness(instrument, selector_string, timeout, &spectral_flatness_margin, &spectral_flatness_margin_subcarrier_index); - response->set_status(status); - if (status_ok(status)) { - response->set_spectral_flatness_margin(spectral_flatness_margin); - response->set_spectral_flatness_margin_subcarrier_index(spectral_flatness_margin_subcarrier_index); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_spectral_flatness_margin(spectral_flatness_margin); + response->set_spectral_flatness_margin_subcarrier_index(spectral_flatness_margin_subcarrier_index); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -5137,9 +5343,8 @@ namespace nirfmxwlan_grpc { int32 actual_array_size {}; while (true) { auto status = library_->OFDMModAccFetchSpectralFlatnessMeanTrace(instrument, selector_string, timeout, &x0, &dx, nullptr, nullptr, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_spectral_flatness_mean()->Resize(actual_array_size, 0); float32* spectral_flatness_mean = response->mutable_spectral_flatness_mean()->mutable_data(); @@ -5153,15 +5358,16 @@ namespace nirfmxwlan_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_x0(x0); - response->set_dx(dx); - response->mutable_spectral_flatness_mean()->Resize(actual_array_size, 0); - response->mutable_spectral_flatness_lower_mask()->Resize(actual_array_size, 0); - response->mutable_spectral_flatness_upper_mask()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_x0(x0); + response->set_dx(dx); + response->mutable_spectral_flatness_mean()->Resize(actual_array_size, 0); + response->mutable_spectral_flatness_lower_mask()->Resize(actual_array_size, 0); + response->mutable_spectral_flatness_upper_mask()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -5187,9 +5393,8 @@ namespace nirfmxwlan_grpc { int32 actual_array_size {}; while (true) { auto status = library_->OFDMModAccFetchStreamDataRMSEVMPerSymbolMeanTrace(instrument, selector_string, timeout, &x0, &dx, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_stream_data_rms_evm_per_symbol_mean()->Resize(actual_array_size, 0); float32* stream_data_rms_evm_per_symbol_mean = response->mutable_stream_data_rms_evm_per_symbol_mean()->mutable_data(); @@ -5199,13 +5404,14 @@ namespace nirfmxwlan_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_x0(x0); - response->set_dx(dx); - response->mutable_stream_data_rms_evm_per_symbol_mean()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_x0(x0); + response->set_dx(dx); + response->mutable_stream_data_rms_evm_per_symbol_mean()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -5231,9 +5437,8 @@ namespace nirfmxwlan_grpc { int32 actual_array_size {}; while (true) { auto status = library_->OFDMModAccFetchStreamPilotRMSEVMPerSymbolMeanTrace(instrument, selector_string, timeout, &x0, &dx, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_stream_pilot_rms_evm_per_symbol_mean()->Resize(actual_array_size, 0); float32* stream_pilot_rms_evm_per_symbol_mean = response->mutable_stream_pilot_rms_evm_per_symbol_mean()->mutable_data(); @@ -5243,13 +5448,14 @@ namespace nirfmxwlan_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_x0(x0); - response->set_dx(dx); - response->mutable_stream_pilot_rms_evm_per_symbol_mean()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_x0(x0); + response->set_dx(dx); + response->mutable_stream_pilot_rms_evm_per_symbol_mean()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -5274,12 +5480,13 @@ namespace nirfmxwlan_grpc { float64 stream_data_rms_evm_mean {}; float64 stream_pilot_rms_evm_mean {}; auto status = library_->OFDMModAccFetchStreamRMSEVM(instrument, selector_string, timeout, &stream_rms_evm_mean, &stream_data_rms_evm_mean, &stream_pilot_rms_evm_mean); - response->set_status(status); - if (status_ok(status)) { - response->set_stream_rms_evm_mean(stream_rms_evm_mean); - response->set_stream_data_rms_evm_mean(stream_data_rms_evm_mean); - response->set_stream_pilot_rms_evm_mean(stream_pilot_rms_evm_mean); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_stream_rms_evm_mean(stream_rms_evm_mean); + response->set_stream_data_rms_evm_mean(stream_data_rms_evm_mean); + response->set_stream_pilot_rms_evm_mean(stream_pilot_rms_evm_mean); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -5304,9 +5511,8 @@ namespace nirfmxwlan_grpc { int32 actual_array_size {}; while (true) { auto status = library_->OFDMModAccFetchStreamRMSEVMPerSubcarrierMeanTrace(instrument, selector_string, timeout, &x0, &dx, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_stream_rms_evm_per_subcarrier_mean()->Resize(actual_array_size, 0); float32* stream_rms_evm_per_subcarrier_mean = response->mutable_stream_rms_evm_per_subcarrier_mean()->mutable_data(); @@ -5316,13 +5522,14 @@ namespace nirfmxwlan_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_x0(x0); - response->set_dx(dx); - response->mutable_stream_rms_evm_per_subcarrier_mean()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_x0(x0); + response->set_dx(dx); + response->mutable_stream_rms_evm_per_subcarrier_mean()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -5348,9 +5555,8 @@ namespace nirfmxwlan_grpc { int32 actual_array_size {}; while (true) { auto status = library_->OFDMModAccFetchStreamRMSEVMPerSymbolMeanTrace(instrument, selector_string, timeout, &x0, &dx, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_stream_rms_evm_per_symbol_mean()->Resize(actual_array_size, 0); float32* stream_rms_evm_per_symbol_mean = response->mutable_stream_rms_evm_per_symbol_mean()->mutable_data(); @@ -5360,13 +5566,14 @@ namespace nirfmxwlan_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_x0(x0); - response->set_dx(dx); - response->mutable_stream_rms_evm_per_symbol_mean()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_x0(x0); + response->set_dx(dx); + response->mutable_stream_rms_evm_per_symbol_mean()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -5393,9 +5600,8 @@ namespace nirfmxwlan_grpc { int32 actual_array_size {}; while (true) { auto status = library_->OFDMModAccFetchSubcarrierChainEVMPerSymbolTrace(instrument, selector_string, timeout, subcarrier_index, &x0, &dx, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_subcarrier_chain_evm_per_symbol()->Resize(actual_array_size, 0); float32* subcarrier_chain_evm_per_symbol = response->mutable_subcarrier_chain_evm_per_symbol()->mutable_data(); @@ -5405,13 +5611,14 @@ namespace nirfmxwlan_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_x0(x0); - response->set_dx(dx); - response->mutable_subcarrier_chain_evm_per_symbol()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_x0(x0); + response->set_dx(dx); + response->mutable_subcarrier_chain_evm_per_symbol()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -5438,9 +5645,8 @@ namespace nirfmxwlan_grpc { int32 actual_array_size {}; while (true) { auto status = library_->OFDMModAccFetchSubcarrierStreamEVMPerSymbolTrace(instrument, selector_string, timeout, subcarrier_index, &x0, &dx, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_subcarrier_stream_evm_per_symbol()->Resize(actual_array_size, 0); float32* subcarrier_stream_evm_per_symbol = response->mutable_subcarrier_stream_evm_per_symbol()->mutable_data(); @@ -5450,13 +5656,14 @@ namespace nirfmxwlan_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_x0(x0); - response->set_dx(dx); - response->mutable_subcarrier_stream_evm_per_symbol()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_x0(x0); + response->set_dx(dx); + response->mutable_subcarrier_stream_evm_per_symbol()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -5483,9 +5690,8 @@ namespace nirfmxwlan_grpc { int32 actual_array_size {}; while (true) { auto status = library_->OFDMModAccFetchSymbolChainEVMPerSubcarrierTrace(instrument, selector_string, timeout, symbol_index, &x0, &dx, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_symbol_chain_evm_per_subcarrier()->Resize(actual_array_size, 0); float32* symbol_chain_evm_per_subcarrier = response->mutable_symbol_chain_evm_per_subcarrier()->mutable_data(); @@ -5495,13 +5701,14 @@ namespace nirfmxwlan_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_x0(x0); - response->set_dx(dx); - response->mutable_symbol_chain_evm_per_subcarrier()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_x0(x0); + response->set_dx(dx); + response->mutable_symbol_chain_evm_per_subcarrier()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -5524,10 +5731,11 @@ namespace nirfmxwlan_grpc { float64 timeout = request->timeout(); float64 symbol_clock_error_mean {}; auto status = library_->OFDMModAccFetchSymbolClockErrorMean(instrument, selector_string, timeout, &symbol_clock_error_mean); - response->set_status(status); - if (status_ok(status)) { - response->set_symbol_clock_error_mean(symbol_clock_error_mean); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_symbol_clock_error_mean(symbol_clock_error_mean); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -5553,9 +5761,8 @@ namespace nirfmxwlan_grpc { int32 actual_array_size {}; while (true) { auto status = library_->OFDMModAccFetchSymbolStreamEVMPerSubcarrierTrace(instrument, selector_string, timeout, symbol_index, &x0, &dx, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_symbol_stream_evm_per_subcarrier()->Resize(actual_array_size, 0); float32* symbol_stream_evm_per_subcarrier = response->mutable_symbol_stream_evm_per_subcarrier()->mutable_data(); @@ -5565,13 +5772,14 @@ namespace nirfmxwlan_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_x0(x0); - response->set_dx(dx); - response->mutable_symbol_stream_evm_per_subcarrier()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_x0(x0); + response->set_dx(dx); + response->mutable_symbol_stream_evm_per_subcarrier()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -5595,11 +5803,12 @@ namespace nirfmxwlan_grpc { float64 unused_tone_error_margin {}; int32 unused_tone_error_margin_ru_index {}; auto status = library_->OFDMModAccFetchUnusedToneError(instrument, selector_string, timeout, &unused_tone_error_margin, &unused_tone_error_margin_ru_index); - response->set_status(status); - if (status_ok(status)) { - response->set_unused_tone_error_margin(unused_tone_error_margin); - response->set_unused_tone_error_margin_ru_index(unused_tone_error_margin_ru_index); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_unused_tone_error_margin(unused_tone_error_margin); + response->set_unused_tone_error_margin_ru_index(unused_tone_error_margin_ru_index); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -5622,9 +5831,8 @@ namespace nirfmxwlan_grpc { int32 actual_array_size {}; while (true) { auto status = library_->OFDMModAccFetchUnusedToneErrorMarginPerRU(instrument, selector_string, timeout, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_unused_tone_error_margin_per_ru()->Resize(actual_array_size, 0); float64* unused_tone_error_margin_per_ru = response->mutable_unused_tone_error_margin_per_ru()->mutable_data(); @@ -5634,11 +5842,12 @@ namespace nirfmxwlan_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->mutable_unused_tone_error_margin_per_ru()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->mutable_unused_tone_error_margin_per_ru()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -5664,9 +5873,8 @@ namespace nirfmxwlan_grpc { int32 actual_array_size {}; while (true) { auto status = library_->OFDMModAccFetchUnusedToneErrorMeanTrace(instrument, selector_string, timeout, &x0, &dx, nullptr, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_unused_tone_error()->Resize(actual_array_size, 0); float32* unused_tone_error = response->mutable_unused_tone_error()->mutable_data(); @@ -5678,14 +5886,15 @@ namespace nirfmxwlan_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_x0(x0); - response->set_dx(dx); - response->mutable_unused_tone_error()->Resize(actual_array_size, 0); - response->mutable_unused_tone_error_mask()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_x0(x0); + response->set_dx(dx); + response->mutable_unused_tone_error()->Resize(actual_array_size, 0); + response->mutable_unused_tone_error_mask()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -5709,9 +5918,8 @@ namespace nirfmxwlan_grpc { int32 actual_array_size {}; while (true) { auto status = library_->OFDMModAccFetchUserDataConstellationTrace(instrument, selector_string, timeout, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } std::vector user_data_constellation(actual_array_size, NIComplexSingle()); auto array_size = actual_array_size; @@ -5720,18 +5928,19 @@ namespace nirfmxwlan_grpc { // buffer is now too small, try again continue; } + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); - if (status_ok(status)) { - convert_to_grpc(user_data_constellation, response->mutable_user_data_constellation()); - { - auto shrunk_size = actual_array_size; - auto current_size = response->mutable_user_data_constellation()->size(); - if (shrunk_size != current_size) { - response->mutable_user_data_constellation()->DeleteSubrange(shrunk_size, current_size - shrunk_size); - } + convert_to_grpc(user_data_constellation, response->mutable_user_data_constellation()); + { + auto shrunk_size = actual_array_size; + auto current_size = response->mutable_user_data_constellation()->size(); + if (shrunk_size != current_size) { + response->mutable_user_data_constellation()->DeleteSubrange(shrunk_size, current_size - shrunk_size); } - response->set_actual_array_size(actual_array_size); } + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -5755,9 +5964,8 @@ namespace nirfmxwlan_grpc { int32 actual_array_size {}; while (true) { auto status = library_->OFDMModAccFetchUserPilotConstellationTrace(instrument, selector_string, timeout, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } std::vector user_pilot_constellation(actual_array_size, NIComplexSingle()); auto array_size = actual_array_size; @@ -5766,18 +5974,19 @@ namespace nirfmxwlan_grpc { // buffer is now too small, try again continue; } + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); - if (status_ok(status)) { - convert_to_grpc(user_pilot_constellation, response->mutable_user_pilot_constellation()); - { - auto shrunk_size = actual_array_size; - auto current_size = response->mutable_user_pilot_constellation()->size(); - if (shrunk_size != current_size) { - response->mutable_user_pilot_constellation()->DeleteSubrange(shrunk_size, current_size - shrunk_size); - } + convert_to_grpc(user_pilot_constellation, response->mutable_user_pilot_constellation()); + { + auto shrunk_size = actual_array_size; + auto current_size = response->mutable_user_pilot_constellation()->size(); + if (shrunk_size != current_size) { + response->mutable_user_pilot_constellation()->DeleteSubrange(shrunk_size, current_size - shrunk_size); } - response->set_actual_array_size(actual_array_size); } + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -5800,10 +6009,11 @@ namespace nirfmxwlan_grpc { float64 timeout = request->timeout(); float64 user_power_mean {}; auto status = library_->OFDMModAccFetchUserPower(instrument, selector_string, timeout, &user_power_mean); - response->set_status(status); - if (status_ok(status)) { - response->set_user_power_mean(user_power_mean); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_user_power_mean(user_power_mean); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -5828,9 +6038,8 @@ namespace nirfmxwlan_grpc { int32 actual_array_size {}; while (true) { auto status = library_->OFDMModAccFetchUserStreamDataRMSEVMPerSymbolMeanTrace(instrument, selector_string, timeout, &x0, &dx, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_user_stream_data_rms_evm_per_symbol_mean()->Resize(actual_array_size, 0); float32* user_stream_data_rms_evm_per_symbol_mean = response->mutable_user_stream_data_rms_evm_per_symbol_mean()->mutable_data(); @@ -5840,13 +6049,14 @@ namespace nirfmxwlan_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_x0(x0); - response->set_dx(dx); - response->mutable_user_stream_data_rms_evm_per_symbol_mean()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_x0(x0); + response->set_dx(dx); + response->mutable_user_stream_data_rms_evm_per_symbol_mean()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -5872,9 +6082,8 @@ namespace nirfmxwlan_grpc { int32 actual_array_size {}; while (true) { auto status = library_->OFDMModAccFetchUserStreamPilotRMSEVMPerSymbolMeanTrace(instrument, selector_string, timeout, &x0, &dx, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_user_stream_pilot_rms_evm_per_symbol_mean()->Resize(actual_array_size, 0); float32* user_stream_pilot_rms_evm_per_symbol_mean = response->mutable_user_stream_pilot_rms_evm_per_symbol_mean()->mutable_data(); @@ -5884,13 +6093,14 @@ namespace nirfmxwlan_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_x0(x0); - response->set_dx(dx); - response->mutable_user_stream_pilot_rms_evm_per_symbol_mean()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_x0(x0); + response->set_dx(dx); + response->mutable_user_stream_pilot_rms_evm_per_symbol_mean()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -5915,12 +6125,13 @@ namespace nirfmxwlan_grpc { float64 user_stream_data_rms_evm_mean {}; float64 user_stream_pilot_rms_evm_mean {}; auto status = library_->OFDMModAccFetchUserStreamRMSEVM(instrument, selector_string, timeout, &user_stream_rms_evm_mean, &user_stream_data_rms_evm_mean, &user_stream_pilot_rms_evm_mean); - response->set_status(status); - if (status_ok(status)) { - response->set_user_stream_rms_evm_mean(user_stream_rms_evm_mean); - response->set_user_stream_data_rms_evm_mean(user_stream_data_rms_evm_mean); - response->set_user_stream_pilot_rms_evm_mean(user_stream_pilot_rms_evm_mean); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_user_stream_rms_evm_mean(user_stream_rms_evm_mean); + response->set_user_stream_data_rms_evm_mean(user_stream_data_rms_evm_mean); + response->set_user_stream_pilot_rms_evm_mean(user_stream_pilot_rms_evm_mean); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -5945,9 +6156,8 @@ namespace nirfmxwlan_grpc { int32 actual_array_size {}; while (true) { auto status = library_->OFDMModAccFetchUserStreamRMSEVMPerSubcarrierMeanTrace(instrument, selector_string, timeout, &x0, &dx, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_user_stream_rms_evm_per_subcarrier_mean()->Resize(actual_array_size, 0); float32* user_stream_rms_evm_per_subcarrier_mean = response->mutable_user_stream_rms_evm_per_subcarrier_mean()->mutable_data(); @@ -5957,13 +6167,14 @@ namespace nirfmxwlan_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_x0(x0); - response->set_dx(dx); - response->mutable_user_stream_rms_evm_per_subcarrier_mean()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_x0(x0); + response->set_dx(dx); + response->mutable_user_stream_rms_evm_per_subcarrier_mean()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -5989,9 +6200,8 @@ namespace nirfmxwlan_grpc { int32 actual_array_size {}; while (true) { auto status = library_->OFDMModAccFetchUserStreamRMSEVMPerSymbolMeanTrace(instrument, selector_string, timeout, &x0, &dx, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_user_stream_rms_evm_per_symbol_mean()->Resize(actual_array_size, 0); float32* user_stream_rms_evm_per_symbol_mean = response->mutable_user_stream_rms_evm_per_symbol_mean()->mutable_data(); @@ -6001,13 +6211,14 @@ namespace nirfmxwlan_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_x0(x0); - response->set_dx(dx); - response->mutable_user_stream_rms_evm_per_symbol_mean()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_x0(x0); + response->set_dx(dx); + response->mutable_user_stream_rms_evm_per_symbol_mean()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -6029,11 +6240,12 @@ namespace nirfmxwlan_grpc { char* selector_string = (char*)request->selector_string().c_str(); int32 calibration_data_valid {}; auto status = library_->OFDMModAccValidateCalibrationData(instrument, selector_string, &calibration_data_valid); - response->set_status(status); - if (status_ok(status)) { - response->set_calibration_data_valid(static_cast(calibration_data_valid)); - response->set_calibration_data_valid_raw(calibration_data_valid); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_calibration_data_valid(static_cast(calibration_data_valid)); + response->set_calibration_data_valid_raw(calibration_data_valid); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -6054,6 +6266,9 @@ namespace nirfmxwlan_grpc { char* selector_string = (char*)request->selector_string().c_str(); float64 acquisition_length = request->acquisition_length(); auto status = library_->PowerRampCfgAcquisitionLength(instrument, selector_string, acquisition_length); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -6091,6 +6306,9 @@ namespace nirfmxwlan_grpc { int32 averaging_count = request->averaging_count(); auto status = library_->PowerRampCfgAveraging(instrument, selector_string, averaging_enabled, averaging_count); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -6116,9 +6334,8 @@ namespace nirfmxwlan_grpc { int32 actual_array_size {}; while (true) { auto status = library_->PowerRampFetchFallTrace(instrument, selector_string, timeout, &x0, &dx, nullptr, nullptr, nullptr, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_raw_waveform()->Resize(actual_array_size, 0); float32* raw_waveform = response->mutable_raw_waveform()->mutable_data(); @@ -6134,16 +6351,17 @@ namespace nirfmxwlan_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_x0(x0); - response->set_dx(dx); - response->mutable_raw_waveform()->Resize(actual_array_size, 0); - response->mutable_processed_waveform()->Resize(actual_array_size, 0); - response->mutable_threshold()->Resize(actual_array_size, 0); - response->mutable_power_reference()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_x0(x0); + response->set_dx(dx); + response->mutable_raw_waveform()->Resize(actual_array_size, 0); + response->mutable_processed_waveform()->Resize(actual_array_size, 0); + response->mutable_threshold()->Resize(actual_array_size, 0); + response->mutable_power_reference()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -6167,11 +6385,12 @@ namespace nirfmxwlan_grpc { float64 rise_time_mean {}; float64 fall_time_mean {}; auto status = library_->PowerRampFetchMeasurement(instrument, selector_string, timeout, &rise_time_mean, &fall_time_mean); - response->set_status(status); - if (status_ok(status)) { - response->set_rise_time_mean(rise_time_mean); - response->set_fall_time_mean(fall_time_mean); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_rise_time_mean(rise_time_mean); + response->set_fall_time_mean(fall_time_mean); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -6196,9 +6415,8 @@ namespace nirfmxwlan_grpc { int32 actual_array_size {}; while (true) { auto status = library_->PowerRampFetchRiseTrace(instrument, selector_string, timeout, &x0, &dx, nullptr, nullptr, nullptr, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_raw_waveform()->Resize(actual_array_size, 0); float32* raw_waveform = response->mutable_raw_waveform()->mutable_data(); @@ -6214,16 +6432,17 @@ namespace nirfmxwlan_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_x0(x0); - response->set_dx(dx); - response->mutable_raw_waveform()->Resize(actual_array_size, 0); - response->mutable_processed_waveform()->Resize(actual_array_size, 0); - response->mutable_threshold()->Resize(actual_array_size, 0); - response->mutable_power_reference()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_x0(x0); + response->set_dx(dx); + response->mutable_raw_waveform()->Resize(actual_array_size, 0); + response->mutable_processed_waveform()->Resize(actual_array_size, 0); + response->mutable_threshold()->Resize(actual_array_size, 0); + response->mutable_power_reference()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -6245,6 +6464,9 @@ namespace nirfmxwlan_grpc { char* selector_string = (char*)request->selector_string().c_str(); int32 attribute_id = request->attribute_id(); auto status = library_->ResetAttribute(instrument, selector_string, attribute_id); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -6265,6 +6487,9 @@ namespace nirfmxwlan_grpc { niRFmxInstrHandle instrument = session_repository_->access_session(instrument_grpc_session.id(), instrument_grpc_session.name()); char* selector_string = (char*)request->selector_string().c_str(); auto status = library_->ResetToDefault(instrument, selector_string); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -6318,6 +6543,9 @@ namespace nirfmxwlan_grpc { } auto status = library_->SEMCfgAveraging(instrument, selector_string, averaging_enabled, averaging_count, averaging_type); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -6354,6 +6582,9 @@ namespace nirfmxwlan_grpc { } auto status = library_->SEMCfgMaskType(instrument, selector_string, mask_type); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -6375,6 +6606,9 @@ namespace nirfmxwlan_grpc { char* selector_string = (char*)request->selector_string().c_str(); int32 number_of_offsets = request->number_of_offsets(); auto status = library_->SEMCfgNumberOfOffsets(instrument, selector_string, number_of_offsets); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -6425,6 +6659,9 @@ namespace nirfmxwlan_grpc { auto number_of_elements = number_of_elements_size_calculation.size; auto status = library_->SEMCfgOffsetFrequencyArray(instrument, selector_string, offset_start_frequency, offset_stop_frequency, offset_sideband, number_of_elements); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -6464,6 +6701,9 @@ namespace nirfmxwlan_grpc { auto number_of_elements = number_of_elements_size_calculation.size; auto status = library_->SEMCfgOffsetRelativeLimitArray(instrument, selector_string, relative_limit_start, relative_limit_stop, number_of_elements); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -6501,6 +6741,9 @@ namespace nirfmxwlan_grpc { float64 span = request->span(); auto status = library_->SEMCfgSpan(instrument, selector_string, span_auto, span); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -6538,6 +6781,9 @@ namespace nirfmxwlan_grpc { float64 sweep_time_interval = request->sweep_time_interval(); auto status = library_->SEMCfgSweepTime(instrument, selector_string, sweep_time_auto, sweep_time_interval); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -6561,11 +6807,12 @@ namespace nirfmxwlan_grpc { float64 absolute_power {}; float64 relative_power {}; auto status = library_->SEMFetchCarrierMeasurement(instrument, selector_string, timeout, &absolute_power, &relative_power); - response->set_status(status); - if (status_ok(status)) { - response->set_absolute_power(absolute_power); - response->set_relative_power(relative_power); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_absolute_power(absolute_power); + response->set_relative_power(relative_power); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -6591,15 +6838,16 @@ namespace nirfmxwlan_grpc { float64 margin_absolute_power {}; float64 margin_relative_power {}; auto status = library_->SEMFetchLowerOffsetMargin(instrument, selector_string, timeout, &measurement_status, &margin, &margin_frequency, &margin_absolute_power, &margin_relative_power); - response->set_status(status); - if (status_ok(status)) { - response->set_measurement_status(static_cast(measurement_status)); - response->set_measurement_status_raw(measurement_status); - response->set_margin(margin); - response->set_margin_frequency(margin_frequency); - response->set_margin_absolute_power(margin_absolute_power); - response->set_margin_relative_power(margin_relative_power); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_measurement_status(static_cast(measurement_status)); + response->set_measurement_status_raw(measurement_status); + response->set_margin(margin); + response->set_margin_frequency(margin_frequency); + response->set_margin_absolute_power(margin_absolute_power); + response->set_margin_relative_power(margin_relative_power); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -6622,9 +6870,8 @@ namespace nirfmxwlan_grpc { int32 actual_array_size {}; while (true) { auto status = library_->SEMFetchLowerOffsetMarginArray(instrument, selector_string, timeout, nullptr, nullptr, nullptr, nullptr, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_measurement_status_raw()->Resize(actual_array_size, 0); int32* measurement_status = reinterpret_cast(response->mutable_measurement_status_raw()->mutable_data()); @@ -6642,8 +6889,10 @@ namespace nirfmxwlan_grpc { // buffer is now too small, try again continue; } + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); - if (status_ok(status)) { response->mutable_measurement_status()->Clear(); response->mutable_measurement_status()->Reserve(actual_array_size); std::transform( @@ -6653,13 +6902,12 @@ namespace nirfmxwlan_grpc { [&](auto x) { return static_cast(x); }); - response->mutable_measurement_status()->Resize(actual_array_size, 0); - response->mutable_margin()->Resize(actual_array_size, 0); - response->mutable_margin_frequency()->Resize(actual_array_size, 0); - response->mutable_margin_absolute_power()->Resize(actual_array_size, 0); - response->mutable_margin_relative_power()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); - } + response->mutable_measurement_status()->Resize(actual_array_size, 0); + response->mutable_margin()->Resize(actual_array_size, 0); + response->mutable_margin_frequency()->Resize(actual_array_size, 0); + response->mutable_margin_absolute_power()->Resize(actual_array_size, 0); + response->mutable_margin_relative_power()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -6686,14 +6934,15 @@ namespace nirfmxwlan_grpc { float64 peak_frequency {}; float64 peak_relative_power {}; auto status = library_->SEMFetchLowerOffsetPower(instrument, selector_string, timeout, &total_absolute_power, &total_relative_power, &peak_absolute_power, &peak_frequency, &peak_relative_power); - response->set_status(status); - if (status_ok(status)) { - response->set_total_absolute_power(total_absolute_power); - response->set_total_relative_power(total_relative_power); - response->set_peak_absolute_power(peak_absolute_power); - response->set_peak_frequency(peak_frequency); - response->set_peak_relative_power(peak_relative_power); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_total_absolute_power(total_absolute_power); + response->set_total_relative_power(total_relative_power); + response->set_peak_absolute_power(peak_absolute_power); + response->set_peak_frequency(peak_frequency); + response->set_peak_relative_power(peak_relative_power); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -6716,9 +6965,8 @@ namespace nirfmxwlan_grpc { int32 actual_array_size {}; while (true) { auto status = library_->SEMFetchLowerOffsetPowerArray(instrument, selector_string, timeout, nullptr, nullptr, nullptr, nullptr, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_total_absolute_power()->Resize(actual_array_size, 0); float64* total_absolute_power = response->mutable_total_absolute_power()->mutable_data(); @@ -6736,15 +6984,16 @@ namespace nirfmxwlan_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->mutable_total_absolute_power()->Resize(actual_array_size, 0); - response->mutable_total_relative_power()->Resize(actual_array_size, 0); - response->mutable_peak_absolute_power()->Resize(actual_array_size, 0); - response->mutable_peak_frequency()->Resize(actual_array_size, 0); - response->mutable_peak_relative_power()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->mutable_total_absolute_power()->Resize(actual_array_size, 0); + response->mutable_total_relative_power()->Resize(actual_array_size, 0); + response->mutable_peak_absolute_power()->Resize(actual_array_size, 0); + response->mutable_peak_frequency()->Resize(actual_array_size, 0); + response->mutable_peak_relative_power()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -6767,11 +7016,12 @@ namespace nirfmxwlan_grpc { float64 timeout = request->timeout(); int32 measurement_status {}; auto status = library_->SEMFetchMeasurementStatus(instrument, selector_string, timeout, &measurement_status); - response->set_status(status); - if (status_ok(status)) { - response->set_measurement_status(static_cast(measurement_status)); - response->set_measurement_status_raw(measurement_status); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_measurement_status(static_cast(measurement_status)); + response->set_measurement_status_raw(measurement_status); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -6796,9 +7046,8 @@ namespace nirfmxwlan_grpc { int32 actual_array_size {}; while (true) { auto status = library_->SEMFetchSpectrum(instrument, selector_string, timeout, &x0, &dx, nullptr, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_spectrum()->Resize(actual_array_size, 0); float32* spectrum = response->mutable_spectrum()->mutable_data(); @@ -6810,14 +7059,15 @@ namespace nirfmxwlan_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_x0(x0); - response->set_dx(dx); - response->mutable_spectrum()->Resize(actual_array_size, 0); - response->mutable_composite_mask()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_x0(x0); + response->set_dx(dx); + response->mutable_spectrum()->Resize(actual_array_size, 0); + response->mutable_composite_mask()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -6844,15 +7094,16 @@ namespace nirfmxwlan_grpc { float64 margin_absolute_power {}; float64 margin_relative_power {}; auto status = library_->SEMFetchUpperOffsetMargin(instrument, selector_string, timeout, &measurement_status, &margin, &margin_frequency, &margin_absolute_power, &margin_relative_power); - response->set_status(status); - if (status_ok(status)) { - response->set_measurement_status(static_cast(measurement_status)); - response->set_measurement_status_raw(measurement_status); - response->set_margin(margin); - response->set_margin_frequency(margin_frequency); - response->set_margin_absolute_power(margin_absolute_power); - response->set_margin_relative_power(margin_relative_power); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_measurement_status(static_cast(measurement_status)); + response->set_measurement_status_raw(measurement_status); + response->set_margin(margin); + response->set_margin_frequency(margin_frequency); + response->set_margin_absolute_power(margin_absolute_power); + response->set_margin_relative_power(margin_relative_power); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -6875,9 +7126,8 @@ namespace nirfmxwlan_grpc { int32 actual_array_size {}; while (true) { auto status = library_->SEMFetchUpperOffsetMarginArray(instrument, selector_string, timeout, nullptr, nullptr, nullptr, nullptr, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_measurement_status_raw()->Resize(actual_array_size, 0); int32* measurement_status = reinterpret_cast(response->mutable_measurement_status_raw()->mutable_data()); @@ -6895,8 +7145,10 @@ namespace nirfmxwlan_grpc { // buffer is now too small, try again continue; } + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); - if (status_ok(status)) { response->mutable_measurement_status()->Clear(); response->mutable_measurement_status()->Reserve(actual_array_size); std::transform( @@ -6906,13 +7158,12 @@ namespace nirfmxwlan_grpc { [&](auto x) { return static_cast(x); }); - response->mutable_measurement_status()->Resize(actual_array_size, 0); - response->mutable_margin()->Resize(actual_array_size, 0); - response->mutable_margin_frequency()->Resize(actual_array_size, 0); - response->mutable_margin_absolute_power()->Resize(actual_array_size, 0); - response->mutable_margin_relative_power()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); - } + response->mutable_measurement_status()->Resize(actual_array_size, 0); + response->mutable_margin()->Resize(actual_array_size, 0); + response->mutable_margin_frequency()->Resize(actual_array_size, 0); + response->mutable_margin_absolute_power()->Resize(actual_array_size, 0); + response->mutable_margin_relative_power()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -6939,14 +7190,15 @@ namespace nirfmxwlan_grpc { float64 peak_frequency {}; float64 peak_relative_power {}; auto status = library_->SEMFetchUpperOffsetPower(instrument, selector_string, timeout, &total_absolute_power, &total_relative_power, &peak_absolute_power, &peak_frequency, &peak_relative_power); - response->set_status(status); - if (status_ok(status)) { - response->set_total_absolute_power(total_absolute_power); - response->set_total_relative_power(total_relative_power); - response->set_peak_absolute_power(peak_absolute_power); - response->set_peak_frequency(peak_frequency); - response->set_peak_relative_power(peak_relative_power); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_total_absolute_power(total_absolute_power); + response->set_total_relative_power(total_relative_power); + response->set_peak_absolute_power(peak_absolute_power); + response->set_peak_frequency(peak_frequency); + response->set_peak_relative_power(peak_relative_power); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -6969,9 +7221,8 @@ namespace nirfmxwlan_grpc { int32 actual_array_size {}; while (true) { auto status = library_->SEMFetchUpperOffsetPowerArray(instrument, selector_string, timeout, nullptr, nullptr, nullptr, nullptr, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_total_absolute_power()->Resize(actual_array_size, 0); float64* total_absolute_power = response->mutable_total_absolute_power()->mutable_data(); @@ -6989,15 +7240,16 @@ namespace nirfmxwlan_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->mutable_total_absolute_power()->Resize(actual_array_size, 0); - response->mutable_total_relative_power()->Resize(actual_array_size, 0); - response->mutable_peak_absolute_power()->Resize(actual_array_size, 0); - response->mutable_peak_frequency()->Resize(actual_array_size, 0); - response->mutable_peak_relative_power()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->mutable_total_absolute_power()->Resize(actual_array_size, 0); + response->mutable_total_relative_power()->Resize(actual_array_size, 0); + response->mutable_peak_absolute_power()->Resize(actual_array_size, 0); + response->mutable_peak_frequency()->Resize(actual_array_size, 0); + response->mutable_peak_relative_power()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -7035,6 +7287,9 @@ namespace nirfmxwlan_grpc { int32 enable_all_traces = request->enable_all_traces(); auto status = library_->SelectMeasurements(instrument, selector_string, measurements, enable_all_traces); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -7054,6 +7309,9 @@ namespace nirfmxwlan_grpc { auto instrument_grpc_session = request->instrument(); niRFmxInstrHandle instrument = session_repository_->access_session(instrument_grpc_session.id(), instrument_grpc_session.name()); auto status = library_->SendSoftwareEdgeTrigger(instrument); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -7076,6 +7334,9 @@ namespace nirfmxwlan_grpc { int32 attribute_id = request->attribute_id(); float32 attr_val = request->attr_val(); auto status = library_->SetAttributeF32(instrument, selector_string, attribute_id, attr_val); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -7099,6 +7360,9 @@ namespace nirfmxwlan_grpc { auto attr_val = const_cast(request->attr_val().data()); int32 array_size = static_cast(request->attr_val().size()); auto status = library_->SetAttributeF32Array(instrument, selector_string, attribute_id, attr_val, array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -7121,6 +7385,9 @@ namespace nirfmxwlan_grpc { int32 attribute_id = request->attribute_id(); float64 attr_val = request->attr_val(); auto status = library_->SetAttributeF64(instrument, selector_string, attribute_id, attr_val); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -7144,6 +7411,9 @@ namespace nirfmxwlan_grpc { auto attr_val = const_cast(request->attr_val().data()); int32 array_size = static_cast(request->attr_val().size()); auto status = library_->SetAttributeF64Array(instrument, selector_string, attribute_id, attr_val, array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -7175,6 +7445,9 @@ namespace nirfmxwlan_grpc { auto attr_val = static_cast(attr_val_raw); auto status = library_->SetAttributeI16(instrument, selector_string, attribute_id, attr_val); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -7215,6 +7488,9 @@ namespace nirfmxwlan_grpc { } auto status = library_->SetAttributeI32(instrument, selector_string, attribute_id, attr_val); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -7246,6 +7522,9 @@ namespace nirfmxwlan_grpc { int32 array_size = static_cast(request->attr_val().size()); auto status = library_->SetAttributeI32Array(instrument, selector_string, attribute_id, attr_val, array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -7268,6 +7547,9 @@ namespace nirfmxwlan_grpc { int32 attribute_id = request->attribute_id(); int64 attr_val = request->attr_val(); auto status = library_->SetAttributeI64(instrument, selector_string, attribute_id, attr_val); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -7291,6 +7573,9 @@ namespace nirfmxwlan_grpc { auto attr_val = const_cast(reinterpret_cast(request->attr_val().data())); int32 array_size = static_cast(request->attr_val().size()); auto status = library_->SetAttributeI64Array(instrument, selector_string, attribute_id, attr_val, array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -7322,6 +7607,9 @@ namespace nirfmxwlan_grpc { auto attr_val = static_cast(attr_val_raw); auto status = library_->SetAttributeI8(instrument, selector_string, attribute_id, attr_val); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -7365,6 +7653,9 @@ namespace nirfmxwlan_grpc { int32 array_size = static_cast(request->attr_val().size()); auto status = library_->SetAttributeI8Array(instrument, selector_string, attribute_id, attr_val.data(), array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -7391,6 +7682,9 @@ namespace nirfmxwlan_grpc { auto attr_val = convert_from_grpc(request->attr_val()); int32 array_size = static_cast(request->attr_val().size()); auto status = library_->SetAttributeNIComplexDoubleArray(instrument, selector_string, attribute_id, attr_val.data(), array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -7414,6 +7708,9 @@ namespace nirfmxwlan_grpc { auto attr_val = convert_from_grpc(request->attr_val()); int32 array_size = static_cast(request->attr_val().size()); auto status = library_->SetAttributeNIComplexSingleArray(instrument, selector_string, attribute_id, attr_val.data(), array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -7455,6 +7752,9 @@ namespace nirfmxwlan_grpc { } auto status = library_->SetAttributeString(instrument, selector_string, attribute_id, attr_val); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -7486,6 +7786,9 @@ namespace nirfmxwlan_grpc { auto attr_val = static_cast(attr_val_raw); auto status = library_->SetAttributeU16(instrument, selector_string, attribute_id, attr_val); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -7511,6 +7814,9 @@ namespace nirfmxwlan_grpc { int32 attribute_id = request->attribute_id(); uInt32 attr_val = request->attr_val(); auto status = library_->SetAttributeU32(instrument, selector_string, attribute_id, attr_val); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -7534,6 +7840,9 @@ namespace nirfmxwlan_grpc { auto attr_val = const_cast(reinterpret_cast(request->attr_val().data())); int32 array_size = static_cast(request->attr_val().size()); auto status = library_->SetAttributeU32Array(instrument, selector_string, attribute_id, attr_val, array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -7557,6 +7866,9 @@ namespace nirfmxwlan_grpc { auto attr_val = const_cast(reinterpret_cast(request->attr_val().data())); int32 array_size = static_cast(request->attr_val().size()); auto status = library_->SetAttributeU64Array(instrument, selector_string, attribute_id, attr_val, array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -7579,6 +7891,9 @@ namespace nirfmxwlan_grpc { int32 attribute_id = request->attribute_id(); uInt8 attr_val = request->attr_val(); auto status = library_->SetAttributeU8(instrument, selector_string, attribute_id, attr_val); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -7602,6 +7917,9 @@ namespace nirfmxwlan_grpc { uInt8* attr_val = (uInt8*)request->attr_val().c_str(); int32 array_size = static_cast(request->attr_val().size()); auto status = library_->SetAttributeU8Array(instrument, selector_string, attribute_id, attr_val, array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -7639,6 +7957,9 @@ namespace nirfmxwlan_grpc { int32 averaging_count = request->averaging_count(); auto status = library_->TXPCfgAveraging(instrument, selector_string, averaging_enabled, averaging_count); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -7675,6 +7996,9 @@ namespace nirfmxwlan_grpc { } auto status = library_->TXPCfgBurstDetectionEnabled(instrument, selector_string, burst_detection_enabled); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -7696,6 +8020,9 @@ namespace nirfmxwlan_grpc { char* selector_string = (char*)request->selector_string().c_str(); float64 maximum_measurement_interval = request->maximum_measurement_interval(); auto status = library_->TXPCfgMaximumMeasurementInterval(instrument, selector_string, maximum_measurement_interval); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -7719,11 +8046,12 @@ namespace nirfmxwlan_grpc { float64 average_power_mean {}; float64 peak_power_maximum {}; auto status = library_->TXPFetchMeasurement(instrument, selector_string, timeout, &average_power_mean, &peak_power_maximum); - response->set_status(status); - if (status_ok(status)) { - response->set_average_power_mean(average_power_mean); - response->set_peak_power_maximum(peak_power_maximum); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_average_power_mean(average_power_mean); + response->set_peak_power_maximum(peak_power_maximum); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -7748,9 +8076,8 @@ namespace nirfmxwlan_grpc { int32 actual_array_size {}; while (true) { auto status = library_->TXPFetchPowerTrace(instrument, selector_string, timeout, &x0, &dx, nullptr, 0, &actual_array_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } response->mutable_power()->Resize(actual_array_size, 0); float32* power = response->mutable_power()->mutable_data(); @@ -7760,13 +8087,14 @@ namespace nirfmxwlan_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_x0(x0); - response->set_dx(dx); - response->mutable_power()->Resize(actual_array_size, 0); - response->set_actual_array_size(actual_array_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } + response->set_status(status); + response->set_x0(x0); + response->set_dx(dx); + response->mutable_power()->Resize(actual_array_size, 0); + response->set_actual_array_size(actual_array_size); return ::grpc::Status::OK; } } @@ -7787,6 +8115,9 @@ namespace nirfmxwlan_grpc { niRFmxInstrHandle instrument = session_repository_->access_session(instrument_grpc_session.id(), instrument_grpc_session.name()); float64 timeout = request->timeout(); auto status = library_->WaitForAcquisitionComplete(instrument, timeout); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } @@ -7808,6 +8139,9 @@ namespace nirfmxwlan_grpc { char* selector_string = (char*)request->selector_string().c_str(); float64 timeout = request->timeout(); auto status = library_->WaitForMeasurementComplete(instrument, selector_string, timeout); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); return ::grpc::Status::OK; } diff --git a/generated/nirfmxwlan/nirfmxwlan_service.h b/generated/nirfmxwlan/nirfmxwlan_service.h index b142543d3..6bedbb971 100644 --- a/generated/nirfmxwlan/nirfmxwlan_service.h +++ b/generated/nirfmxwlan/nirfmxwlan_service.h @@ -277,6 +277,7 @@ class NiRFmxWLANService final : public NiRFmxWLAN::Service { NiRFmxWLANLibraryInterface* library_; ResourceRepositorySharedPtr session_repository_; ViSessionResourceRepositorySharedPtr vi_session_resource_repository_; + ::grpc::Status ConvertApiErrorStatusForNiRFmxInstrHandle(google::protobuf::int32 status, niRFmxInstrHandle instrumentHandle); std::map frequencyreferencesource_input_map_ { {1, "OnboardClock"},{2, "RefIn"},{3, "PXI_Clk"},{4, "ClkIn"}, }; std::map frequencyreferencesource_output_map_ { {"OnboardClock", 1},{"RefIn", 2},{"PXI_Clk", 3},{"ClkIn", 4}, }; std::map nirfmxwlanstringattributevaluesmapped_input_map_ { {1, "PFI0"},{2, "PFI1"},{3, "PXI_Trig0"},{4, "PXI_Trig1"},{5, "PXI_Trig2"},{6, "PXI_Trig3"},{7, "PXI_Trig4"},{8, "PXI_Trig5"},{9, "PXI_Trig6"},{10, "PXI_Trig7"},{11, "PXI_STAR"},{12, "PXIe_DStarB"},{13, "TimerEvent"}, }; diff --git a/generated/nirfsa/nirfsa_service.cpp b/generated/nirfsa/nirfsa_service.cpp index d050e77a3..1c6ac7940 100644 --- a/generated/nirfsa/nirfsa_service.cpp +++ b/generated/nirfsa/nirfsa_service.cpp @@ -57,6 +57,9 @@ namespace nirfsa_grpc { auto vi_grpc_session = request->vi(); ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); auto status = library_->Abort(vi); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -77,10 +80,11 @@ namespace nirfsa_grpc { ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); ViBoolean is_done {}; auto status = library_->CheckAcquisitionStatus(vi, &is_done); - response->set_status(status); - if (status_ok(status)) { - response->set_is_done(is_done); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_is_done(is_done); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -99,6 +103,9 @@ namespace nirfsa_grpc { auto vi_grpc_session = request->vi(); ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); auto status = library_->ClearError(vi); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -118,6 +125,9 @@ namespace nirfsa_grpc { auto vi_grpc_session = request->vi(); ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); auto status = library_->ClearSelfCalibrateRange(vi); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -138,6 +148,9 @@ namespace nirfsa_grpc { ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); session_repository_->remove_session(vi_grpc_session.id(), vi_grpc_session.name()); auto status = library_->Close(vi); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -157,6 +170,9 @@ namespace nirfsa_grpc { auto vi_grpc_session = request->vi(); ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); auto status = library_->Commit(vi); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -192,6 +208,9 @@ namespace nirfsa_grpc { } auto status = library_->ConfigureAcquisitionType(vi, acquisition_type); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -229,6 +248,9 @@ namespace nirfsa_grpc { } auto status = library_->ConfigureDeembeddingTableInterpolationLinear(vi, port, table_name, format); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -250,6 +272,9 @@ namespace nirfsa_grpc { auto port = request->port().c_str(); auto table_name = request->table_name().c_str(); auto status = library_->ConfigureDeembeddingTableInterpolationNearest(vi, port, table_name); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -271,6 +296,9 @@ namespace nirfsa_grpc { auto port = request->port().c_str(); auto table_name = request->table_name().c_str(); auto status = library_->ConfigureDeembeddingTableInterpolationSpline(vi, port, table_name); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -326,6 +354,9 @@ namespace nirfsa_grpc { } auto status = library_->ConfigureDigitalEdgeAdvanceTrigger(vi, source, edge); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -382,6 +413,9 @@ namespace nirfsa_grpc { ViInt64 pretrigger_samples = request->pretrigger_samples(); auto status = library_->ConfigureDigitalEdgeRefTrigger(vi, source, edge, pretrigger_samples); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -437,6 +471,9 @@ namespace nirfsa_grpc { } auto status = library_->ConfigureDigitalEdgeStartTrigger(vi, source, edge); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -458,6 +495,9 @@ namespace nirfsa_grpc { auto channel_list = request->channel_list().c_str(); ViReal64 carrier_frequency = request->carrier_frequency(); auto status = library_->ConfigureIQCarrierFrequency(vi, channel_list, carrier_frequency); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -496,6 +536,9 @@ namespace nirfsa_grpc { ViInt64 pretrigger_samples = request->pretrigger_samples(); auto status = library_->ConfigureIQPowerEdgeRefTrigger(vi, source, level, slope, pretrigger_samples); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -517,6 +560,9 @@ namespace nirfsa_grpc { auto channel_list = request->channel_list().c_str(); ViReal64 iq_rate = request->iq_rate(); auto status = library_->ConfigureIQRate(vi, channel_list, iq_rate); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -539,6 +585,9 @@ namespace nirfsa_grpc { ViBoolean number_of_records_is_finite = request->number_of_records_is_finite(); ViInt64 number_of_records = request->number_of_records(); auto status = library_->ConfigureNumberOfRecords(vi, channel_list, number_of_records_is_finite, number_of_records); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -561,6 +610,9 @@ namespace nirfsa_grpc { ViBoolean number_of_samples_is_finite = request->number_of_samples_is_finite(); ViInt64 samples_per_record = request->samples_per_record(); auto status = library_->ConfigureNumberOfSamples(vi, channel_list, number_of_samples_is_finite, samples_per_record); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -600,6 +652,9 @@ namespace nirfsa_grpc { } auto status = library_->ConfigurePXIChassisClk10(vi, pxi_clk10_source); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -640,6 +695,9 @@ namespace nirfsa_grpc { ViReal64 ref_clock_rate = request->ref_clock_rate(); auto status = library_->ConfigureRefClock(vi, clock_source, ref_clock_rate); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -661,6 +719,9 @@ namespace nirfsa_grpc { auto channel_list = request->channel_list().c_str(); ViReal64 reference_level = request->reference_level(); auto status = library_->ConfigureReferenceLevel(vi, channel_list, reference_level); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -682,6 +743,9 @@ namespace nirfsa_grpc { auto channel_list = request->channel_list().c_str(); ViReal64 resolution_bandwidth = request->resolution_bandwidth(); auto status = library_->ConfigureResolutionBandwidth(vi, channel_list, resolution_bandwidth); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -701,6 +765,9 @@ namespace nirfsa_grpc { auto vi_grpc_session = request->vi(); ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); auto status = library_->ConfigureSoftwareEdgeAdvanceTrigger(vi); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -721,6 +788,9 @@ namespace nirfsa_grpc { ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); ViInt64 pretrigger_samples = request->pretrigger_samples(); auto status = library_->ConfigureSoftwareEdgeRefTrigger(vi, pretrigger_samples); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -740,6 +810,9 @@ namespace nirfsa_grpc { auto vi_grpc_session = request->vi(); ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); auto status = library_->ConfigureSoftwareEdgeStartTrigger(vi); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -762,6 +835,9 @@ namespace nirfsa_grpc { ViReal64 center_frequency = request->center_frequency(); ViReal64 span = request->span(); auto status = library_->ConfigureSpectrumFrequencyCenterSpan(vi, channel_list, center_frequency, span); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -784,6 +860,9 @@ namespace nirfsa_grpc { ViReal64 start_frequency = request->start_frequency(); ViReal64 stop_frequency = request->stop_frequency(); auto status = library_->ConfigureSpectrumFrequencyStartStop(vi, channel_list, start_frequency, stop_frequency); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -807,6 +886,9 @@ namespace nirfsa_grpc { auto list_attribute_ids = const_cast(reinterpret_cast(request->list_attribute_ids().data())); ViBoolean set_as_active_list = request->set_as_active_list(); auto status = library_->CreateConfigurationList(vi, list_name, number_of_list_attributes, list_attribute_ids, set_as_active_list); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -827,6 +909,9 @@ namespace nirfsa_grpc { ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); ViBoolean set_as_active_step = request->set_as_active_step(); auto status = library_->CreateConfigurationListStep(vi, set_as_active_step); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -869,6 +954,9 @@ namespace nirfsa_grpc { } auto status = library_->CreateDeembeddingSparameterTableArray(vi, port, table_name, frequencies, frequencies_size, sparameter_table.data(), sparameter_table_size, number_of_ports, sparameter_orientation); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -907,6 +995,9 @@ namespace nirfsa_grpc { } auto status = library_->CreateDeembeddingSparameterTableS2PFile(vi, port, table_name, s2p_file_path, sparameter_orientation); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -926,6 +1017,9 @@ namespace nirfsa_grpc { auto vi_grpc_session = request->vi(); ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); auto status = library_->DeleteAllDeembeddingTables(vi); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -946,6 +1040,9 @@ namespace nirfsa_grpc { ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); auto list_name = request->list_name().c_str(); auto status = library_->DeleteConfigurationList(vi, list_name); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -967,6 +1064,9 @@ namespace nirfsa_grpc { auto port = request->port().c_str(); auto table_name = request->table_name().c_str(); auto status = library_->DeleteDeembeddingTable(vi, port, table_name); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -986,6 +1086,9 @@ namespace nirfsa_grpc { auto vi_grpc_session = request->vi(); ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); auto status = library_->Disable(vi); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1005,6 +1108,9 @@ namespace nirfsa_grpc { auto vi_grpc_session = request->vi(); ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); auto status = library_->DisableAdvanceTrigger(vi); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1024,6 +1130,9 @@ namespace nirfsa_grpc { auto vi_grpc_session = request->vi(); ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); auto status = library_->DisableRefTrigger(vi); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1043,6 +1152,9 @@ namespace nirfsa_grpc { auto vi_grpc_session = request->vi(); ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); auto status = library_->DisableStartTrigger(vi); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1063,6 +1175,9 @@ namespace nirfsa_grpc { ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); ViBoolean enable = request->enable(); auto status = library_->EnableSessionAccess(vi, enable); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1084,11 +1199,12 @@ namespace nirfsa_grpc { ViStatus status_code = request->status_code(); std::string error_message(1024 - 1, '\0'); auto status = library_->ErrorMessage(vi, status_code, (ViChar*)error_message.data()); - response->set_status(status); - if (status_ok(status)) { - response->set_error_message(error_message); - nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_error_message())); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_error_message(error_message); + nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_error_message())); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -1109,12 +1225,13 @@ namespace nirfsa_grpc { ViInt32 error_code {}; std::string error_message(1024 - 1, '\0'); auto status = library_->ErrorQuery(vi, &error_code, (ViChar*)error_message.data()); - response->set_status(status); - if (status_ok(status)) { - response->set_error_code(error_code); - response->set_error_message(error_message); - nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_error_message())); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_error_code(error_code); + response->set_error_message(error_message); + nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_error_message())); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -1170,6 +1287,9 @@ namespace nirfsa_grpc { } auto status = library_->ExportSignal(vi, signal, signal_identifier, output_terminal); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1196,11 +1316,12 @@ namespace nirfsa_grpc { std::vector data(number_of_samples * number_of_records, NIComplexNumberF32_struct()); std::vector wfm_info(number_of_records, niRFSA_wfmInfo_struct()); auto status = library_->FetchIQMultiRecordComplexF32(vi, channel_list, starting_record, number_of_records, number_of_samples, timeout, data.data(), wfm_info.data()); - response->set_status(status); - if (status_ok(status)) { - convert_to_grpc(data, response->mutable_data()); - convert_to_grpc(wfm_info, response->mutable_wfm_info()); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + convert_to_grpc(data, response->mutable_data()); + convert_to_grpc(wfm_info, response->mutable_wfm_info()); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -1226,11 +1347,12 @@ namespace nirfsa_grpc { std::vector data(number_of_samples * number_of_records, NIComplexNumber_struct()); std::vector wfm_info(number_of_records, niRFSA_wfmInfo_struct()); auto status = library_->FetchIQMultiRecordComplexF64(vi, channel_list, starting_record, number_of_records, number_of_samples, timeout, data.data(), wfm_info.data()); - response->set_status(status); - if (status_ok(status)) { - convert_to_grpc(data, response->mutable_data()); - convert_to_grpc(wfm_info, response->mutable_wfm_info()); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + convert_to_grpc(data, response->mutable_data()); + convert_to_grpc(wfm_info, response->mutable_wfm_info()); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -1256,11 +1378,12 @@ namespace nirfsa_grpc { std::vector data(number_of_samples * number_of_records, NIComplexI16_struct()); std::vector wfm_info(number_of_records, niRFSA_wfmInfo_struct()); auto status = library_->FetchIQMultiRecordComplexI16(vi, channel_list, starting_record, number_of_records, number_of_samples, timeout, data.data(), wfm_info.data()); - response->set_status(status); - if (status_ok(status)) { - convert_to_grpc(data, response->mutable_data()); - convert_to_grpc(wfm_info, response->mutable_wfm_info()); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + convert_to_grpc(data, response->mutable_data()); + convert_to_grpc(wfm_info, response->mutable_wfm_info()); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -1285,11 +1408,12 @@ namespace nirfsa_grpc { std::vector data(number_of_samples, NIComplexNumberF32_struct()); niRFSA_wfmInfo_struct wfm_info {}; auto status = library_->FetchIQSingleRecordComplexF32(vi, channel_list, record_number, number_of_samples, timeout, data.data(), &wfm_info); - response->set_status(status); - if (status_ok(status)) { - convert_to_grpc(data, response->mutable_data()); - convert_to_grpc(wfm_info, response->mutable_wfm_info()); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + convert_to_grpc(data, response->mutable_data()); + convert_to_grpc(wfm_info, response->mutable_wfm_info()); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -1314,11 +1438,12 @@ namespace nirfsa_grpc { std::vector data(number_of_samples, NIComplexNumber_struct()); niRFSA_wfmInfo_struct wfm_info {}; auto status = library_->FetchIQSingleRecordComplexF64(vi, channel_list, record_number, number_of_samples, timeout, data.data(), &wfm_info); - response->set_status(status); - if (status_ok(status)) { - convert_to_grpc(data, response->mutable_data()); - convert_to_grpc(wfm_info, response->mutable_wfm_info()); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + convert_to_grpc(data, response->mutable_data()); + convert_to_grpc(wfm_info, response->mutable_wfm_info()); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -1343,11 +1468,12 @@ namespace nirfsa_grpc { std::vector data(number_of_samples, NIComplexI16_struct()); niRFSA_wfmInfo_struct wfm_info {}; auto status = library_->FetchIQSingleRecordComplexI16(vi, channel_list, record_number, number_of_samples, timeout, data.data(), &wfm_info); - response->set_status(status); - if (status_ok(status)) { - convert_to_grpc(data, response->mutable_data()); - convert_to_grpc(wfm_info, response->mutable_wfm_info()); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + convert_to_grpc(data, response->mutable_data()); + convert_to_grpc(wfm_info, response->mutable_wfm_info()); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -1369,10 +1495,11 @@ namespace nirfsa_grpc { ViAttr attribute_id = request->attribute_id(); ViBoolean value {}; auto status = library_->GetAttributeViBoolean(vi, channel_name, attribute_id, &value); - response->set_status(status); - if (status_ok(status)) { - response->set_value(value); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_value(value); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -1394,10 +1521,11 @@ namespace nirfsa_grpc { ViAttr attribute_id = request->attribute_id(); ViInt32 value {}; auto status = library_->GetAttributeViInt32(vi, channel_name, attribute_id, &value); - response->set_status(status); - if (status_ok(status)) { - response->set_value(value); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_value(value); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -1419,10 +1547,11 @@ namespace nirfsa_grpc { ViAttr attribute_id = request->attribute_id(); ViInt64 value {}; auto status = library_->GetAttributeViInt64(vi, channel_name, attribute_id, &value); - response->set_status(status); - if (status_ok(status)) { - response->set_value(value); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_value(value); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -1444,10 +1573,11 @@ namespace nirfsa_grpc { ViAttr attribute_id = request->attribute_id(); ViReal64 value {}; auto status = library_->GetAttributeViReal64(vi, channel_name, attribute_id, &value); - response->set_status(status); - if (status_ok(status)) { - response->set_value(value); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_value(value); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -1469,11 +1599,12 @@ namespace nirfsa_grpc { ViAttr attribute_id = request->attribute_id(); ViSession value {}; auto status = library_->GetAttributeViSession(vi, channel_name, attribute_id, &value); - response->set_status(status); - if (status_ok(status)) { - auto session_id = session_repository_->resolve_session_id(value); - response->mutable_value()->set_id(session_id); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + auto session_id = session_repository_->resolve_session_id(value); + response->mutable_value()->set_id(session_id); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -1496,9 +1627,8 @@ namespace nirfsa_grpc { while (true) { auto status = library_->GetAttributeViString(vi, channel_name, attribute_id, 0, nullptr); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } ViInt32 buf_size = status; @@ -1511,11 +1641,12 @@ namespace nirfsa_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_value(value); - nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_value())); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_value(value); + nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_value())); return ::grpc::Status::OK; } } @@ -1536,11 +1667,12 @@ namespace nirfsa_grpc { ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); std::string info(2048 - 1, '\0'); auto status = library_->GetCalUserDefinedInfo(vi, (ViChar*)info.data()); - response->set_status(status); - if (status_ok(status)) { - response->set_info(info); - nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_info())); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_info(info); + nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_info())); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -1560,10 +1692,11 @@ namespace nirfsa_grpc { ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); ViInt32 info_size {}; auto status = library_->GetCalUserDefinedInfoMaxSize(vi, &info_size); - response->set_status(status); - if (status_ok(status)) { - response->set_info_size(info_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_info_size(info_size); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -1585,9 +1718,8 @@ namespace nirfsa_grpc { ViInt32 number_of_ports {}; while (true) { auto status = library_->GetDeembeddingSparameters(vi, nullptr, 0, &number_of_sparameters, &number_of_ports); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } std::vector sparameters(number_of_sparameters, NIComplexNumber_struct()); auto sparameters_array_size = number_of_sparameters; @@ -1596,19 +1728,20 @@ namespace nirfsa_grpc { // buffer is now too small, try again continue; } + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); - if (status_ok(status)) { - convert_to_grpc(sparameters, response->mutable_sparameters()); - { - auto shrunk_size = number_of_sparameters; - auto current_size = response->mutable_sparameters()->size(); - if (shrunk_size != current_size) { - response->mutable_sparameters()->DeleteSubrange(shrunk_size, current_size - shrunk_size); - } + convert_to_grpc(sparameters, response->mutable_sparameters()); + { + auto shrunk_size = number_of_sparameters; + auto current_size = response->mutable_sparameters()->size(); + if (shrunk_size != current_size) { + response->mutable_sparameters()->DeleteSubrange(shrunk_size, current_size - shrunk_size); } - response->set_number_of_sparameters(number_of_sparameters); - response->set_number_of_ports(number_of_ports); } + response->set_number_of_sparameters(number_of_sparameters); + response->set_number_of_ports(number_of_ports); return ::grpc::Status::OK; } } @@ -1647,9 +1780,8 @@ namespace nirfsa_grpc { ViInt32 number_of_frequencies {}; while (true) { auto status = library_->GetDeviceResponse(vi, channel_list, response_type, 0, nullptr, nullptr, nullptr, &number_of_frequencies); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } response->mutable_frequencies()->Resize(number_of_frequencies, 0); ViReal64* frequencies = response->mutable_frequencies()->mutable_data(); @@ -1663,13 +1795,14 @@ namespace nirfsa_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->mutable_frequencies()->Resize(number_of_frequencies, 0); - response->mutable_magnitude_response()->Resize(number_of_frequencies, 0); - response->mutable_phase_response()->Resize(number_of_frequencies, 0); - response->set_number_of_frequencies(number_of_frequencies); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->mutable_frequencies()->Resize(number_of_frequencies, 0); + response->mutable_magnitude_response()->Resize(number_of_frequencies, 0); + response->mutable_phase_response()->Resize(number_of_frequencies, 0); + response->set_number_of_frequencies(number_of_frequencies); return ::grpc::Status::OK; } } @@ -1691,9 +1824,8 @@ namespace nirfsa_grpc { while (true) { auto status = library_->GetError(vi, nullptr, 0, nullptr); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } ViInt32 error_description_buffer_size = status; @@ -1707,12 +1839,13 @@ namespace nirfsa_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_error_code(error_code); - response->set_error_description(error_description); - nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_error_description())); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_error_code(error_code); + response->set_error_description(error_description); + nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_error_description())); return ::grpc::Status::OK; } } @@ -1737,14 +1870,15 @@ namespace nirfsa_grpc { ViInt32 hour {}; ViInt32 minute {}; auto status = library_->GetExtCalLastDateAndTime(vi, &year, &month, &day, &hour, &minute); - response->set_status(status); - if (status_ok(status)) { - response->set_year(year); - response->set_month(month); - response->set_day(day); - response->set_hour(hour); - response->set_minute(minute); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_year(year); + response->set_month(month); + response->set_day(day); + response->set_hour(hour); + response->set_minute(minute); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -1764,10 +1898,11 @@ namespace nirfsa_grpc { ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); ViReal64 temperature {}; auto status = library_->GetExtCalLastTemp(vi, &temperature); - response->set_status(status); - if (status_ok(status)) { - response->set_temperature(temperature); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_temperature(temperature); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -1787,10 +1922,11 @@ namespace nirfsa_grpc { ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); ViInt32 months {}; auto status = library_->GetExtCalRecommendedInterval(vi, &months); - response->set_status(status); - if (status_ok(status)) { - response->set_months(months); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_months(months); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -1812,10 +1948,11 @@ namespace nirfsa_grpc { ViInt64 record_number = request->record_number(); ViInt64 backlog {}; auto status = library_->GetFetchBacklog(vi, channel_list, record_number, &backlog); - response->set_status(status); - if (status_ok(status)) { - response->set_backlog(backlog); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_backlog(backlog); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -1837,9 +1974,8 @@ namespace nirfsa_grpc { ViInt32 number_of_frequencies {}; while (true) { auto status = library_->GetFrequencyResponse(vi, channel_list, 0, nullptr, nullptr, nullptr, &number_of_frequencies); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } response->mutable_frequencies()->Resize(number_of_frequencies, 0); ViReal64* frequencies = response->mutable_frequencies()->mutable_data(); @@ -1853,13 +1989,14 @@ namespace nirfsa_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->mutable_frequencies()->Resize(number_of_frequencies, 0); - response->mutable_magnitude_response()->Resize(number_of_frequencies, 0); - response->mutable_phase_response()->Resize(number_of_frequencies, 0); - response->set_number_of_frequencies(number_of_frequencies); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->mutable_frequencies()->Resize(number_of_frequencies, 0); + response->mutable_magnitude_response()->Resize(number_of_frequencies, 0); + response->mutable_phase_response()->Resize(number_of_frequencies, 0); + response->set_number_of_frequencies(number_of_frequencies); return ::grpc::Status::OK; } } @@ -1882,9 +2019,8 @@ namespace nirfsa_grpc { ViInt32 number_of_coefficient_sets {}; while (true) { auto status = library_->GetNormalizationCoefficients(vi, channel_list, 0, nullptr, &number_of_coefficient_sets); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } std::vector coefficient_info(number_of_coefficient_sets, niRFSA_coefficientInfo_struct()); auto array_size = number_of_coefficient_sets; @@ -1893,18 +2029,19 @@ namespace nirfsa_grpc { // buffer is now too small, try again continue; } + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); - if (status_ok(status)) { - convert_to_grpc(coefficient_info, response->mutable_coefficient_info()); - { - auto shrunk_size = number_of_coefficient_sets; - auto current_size = response->mutable_coefficient_info()->size(); - if (shrunk_size != current_size) { - response->mutable_coefficient_info()->DeleteSubrange(shrunk_size, current_size - shrunk_size); - } + convert_to_grpc(coefficient_info, response->mutable_coefficient_info()); + { + auto shrunk_size = number_of_coefficient_sets; + auto current_size = response->mutable_coefficient_info()->size(); + if (shrunk_size != current_size) { + response->mutable_coefficient_info()->DeleteSubrange(shrunk_size, current_size - shrunk_size); } - response->set_number_of_coefficient_sets(number_of_coefficient_sets); } + response->set_number_of_coefficient_sets(number_of_coefficient_sets); return ::grpc::Status::OK; } } @@ -1926,10 +2063,11 @@ namespace nirfsa_grpc { auto channel_list = request->channel_list().c_str(); ViInt32 number_of_spectral_lines {}; auto status = library_->GetNumberOfSpectralLines(vi, channel_list, &number_of_spectral_lines); - response->set_status(status); - if (status_ok(status)) { - response->set_number_of_spectral_lines(number_of_spectral_lines); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_number_of_spectral_lines(number_of_spectral_lines); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -1952,9 +2090,8 @@ namespace nirfsa_grpc { ViInt32 buffer_size {}; while (true) { auto status = library_->GetRelayName(vi, channel_list, index, nullptr, &buffer_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } std::string name; if (buffer_size > 0) { @@ -1965,12 +2102,13 @@ namespace nirfsa_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_name(name); - nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_name())); - response->set_buffer_size(buffer_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_name(name); + nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_name())); + response->set_buffer_size(buffer_size); return ::grpc::Status::OK; } } @@ -1993,9 +2131,8 @@ namespace nirfsa_grpc { ViInt32 buffer_size {}; while (true) { auto status = library_->GetRelayOperationsCount(vi, channel_list, nullptr, &buffer_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } response->mutable_operations_count()->Resize(buffer_size, 0); ViInt32* operations_count = reinterpret_cast(response->mutable_operations_count()->mutable_data()); @@ -2004,11 +2141,12 @@ namespace nirfsa_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->mutable_operations_count()->Resize(buffer_size, 0); - response->set_buffer_size(buffer_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->mutable_operations_count()->Resize(buffer_size, 0); + response->set_buffer_size(buffer_size); return ::grpc::Status::OK; } } @@ -2031,9 +2169,8 @@ namespace nirfsa_grpc { ViInt32 number_of_coefficient_sets {}; while (true) { auto status = library_->GetScalingCoefficients(vi, channel_list, 0, nullptr, &number_of_coefficient_sets); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } std::vector coefficient_info(number_of_coefficient_sets, niRFSA_coefficientInfo_struct()); auto array_size = number_of_coefficient_sets; @@ -2042,18 +2179,19 @@ namespace nirfsa_grpc { // buffer is now too small, try again continue; } + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); - if (status_ok(status)) { - convert_to_grpc(coefficient_info, response->mutable_coefficient_info()); - { - auto shrunk_size = number_of_coefficient_sets; - auto current_size = response->mutable_coefficient_info()->size(); - if (shrunk_size != current_size) { - response->mutable_coefficient_info()->DeleteSubrange(shrunk_size, current_size - shrunk_size); - } + convert_to_grpc(coefficient_info, response->mutable_coefficient_info()); + { + auto shrunk_size = number_of_coefficient_sets; + auto current_size = response->mutable_coefficient_info()->size(); + if (shrunk_size != current_size) { + response->mutable_coefficient_info()->DeleteSubrange(shrunk_size, current_size - shrunk_size); } - response->set_number_of_coefficient_sets(number_of_coefficient_sets); } + response->set_number_of_coefficient_sets(number_of_coefficient_sets); return ::grpc::Status::OK; } } @@ -2079,14 +2217,15 @@ namespace nirfsa_grpc { ViInt32 hour {}; ViInt32 minute {}; auto status = library_->GetSelfCalLastDateAndTime(vi, self_calibration_step, &year, &month, &day, &hour, &minute); - response->set_status(status); - if (status_ok(status)) { - response->set_year(year); - response->set_month(month); - response->set_day(day); - response->set_hour(hour); - response->set_minute(minute); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_year(year); + response->set_month(month); + response->set_day(day); + response->set_hour(hour); + response->set_minute(minute); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -2107,10 +2246,11 @@ namespace nirfsa_grpc { ViInt64 self_calibration_step = request->self_calibration_step(); ViReal64 temp {}; auto status = library_->GetSelfCalLastTemp(vi, self_calibration_step, &temp); - response->set_status(status); - if (status_ok(status)) { - response->set_temp(temp); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_temp(temp); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -2130,10 +2270,11 @@ namespace nirfsa_grpc { ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); SmtSpectrumInfo_struct spectrum_info {}; auto status = library_->GetSpectralInfoForSMT(vi, &spectrum_info); - response->set_status(status); - if (status_ok(status)) { - convert_to_grpc(spectrum_info, response->mutable_spectrum_info()); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + convert_to_grpc(spectrum_info, response->mutable_spectrum_info()); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -2154,10 +2295,11 @@ namespace nirfsa_grpc { auto stream_endpoint = request->stream_endpoint().c_str(); ViUInt32 writer_handle {}; auto status = library_->GetStreamEndpointHandle(vi, stream_endpoint, &writer_handle); - response->set_status(status); - if (status_ok(status)) { - response->set_writer_handle(writer_handle); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_writer_handle(writer_handle); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -2198,11 +2340,12 @@ namespace nirfsa_grpc { terminal_name.resize(buffer_size - 1); } auto status = library_->GetTerminalName(vi, signal, signal_identifier, buffer_size, (ViChar*)terminal_name.data()); - response->set_status(status); - if (status_ok(status)) { - response->set_terminal_name(terminal_name); - nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_terminal_name())); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_terminal_name(terminal_name); + nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_terminal_name())); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -2224,9 +2367,8 @@ namespace nirfsa_grpc { ViInt32 actual_data_size {}; while (true) { auto status = library_->GetUserData(vi, identifier, 0, nullptr, &actual_data_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } std::string data(actual_data_size, '\0'); auto buffer_size = actual_data_size; @@ -2235,12 +2377,13 @@ namespace nirfsa_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_data(data); - response->mutable_data()->resize(actual_data_size); - response->set_actual_data_size(actual_data_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_data(data); + response->mutable_data()->resize(actual_data_size); + response->set_actual_data_size(actual_data_size); return ::grpc::Status::OK; } } @@ -2270,14 +2413,11 @@ namespace nirfsa_grpc { const std::string& grpc_device_session_name = request->session_name(); auto cleanup_lambda = [&] (ViSession id) { library_->Close(id); }; int status = session_repository_->add_session(grpc_device_session_name, init_lambda, cleanup_lambda, session_id); - response->set_status(status); - if (status_ok(status)) { - response->mutable_vi()->set_id(session_id); - } - else { - const auto error_message = get_last_error_message(library_); - response->set_error_message(error_message); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, 0); } + response->set_status(status); + response->mutable_vi()->set_id(session_id); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -2310,14 +2450,11 @@ namespace nirfsa_grpc { const std::string& grpc_device_session_name = request->session_name(); auto cleanup_lambda = [&] (ViSession id) { library_->Close(id); }; int status = session_repository_->add_session(grpc_device_session_name, init_lambda, cleanup_lambda, session_id); - response->set_status(status); - if (status_ok(status)) { - response->mutable_vi()->set_id(session_id); - } - else { - const auto error_message = get_last_error_message(library_); - response->set_error_message(error_message); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, 0); } + response->set_status(status); + response->mutable_vi()->set_id(session_id); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -2339,6 +2476,9 @@ namespace nirfsa_grpc { auto vi_grpc_session = request->vi(); ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); auto status = library_->Initiate(vi); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -2358,6 +2498,9 @@ namespace nirfsa_grpc { auto vi_grpc_session = request->vi(); ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); auto status = library_->InvalidateAllAttributes(vi); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -2379,31 +2522,32 @@ namespace nirfsa_grpc { ViBoolean self_cal_valid {}; ViInt64 valid_steps {}; auto status = library_->IsSelfCalValid(vi, &self_cal_valid, &valid_steps); - response->set_status(status); - if (status_ok(status)) { - response->set_self_cal_valid(self_cal_valid); - if (valid_steps & 0x1) - response->add_valid_steps_array(SelfCalibrateSteps::SELF_CALIBRATE_STEPS_ALIGNMENT); - if (valid_steps & 0x2) - response->add_valid_steps_array(SelfCalibrateSteps::SELF_CALIBRATE_STEPS_GAIN_REFERENCE); - if (valid_steps & 0x4) - response->add_valid_steps_array(SelfCalibrateSteps::SELF_CALIBRATE_STEPS_IF_FLATNESS); - if (valid_steps & 0x8) - response->add_valid_steps_array(SelfCalibrateSteps::SELF_CALIBRATE_STEPS_DIGITIZER_SELF_CAL); - if (valid_steps & 0x10) - response->add_valid_steps_array(SelfCalibrateSteps::SELF_CALIBRATE_STEPS_LO_SELF_CAL); - if (valid_steps & 0x20) - response->add_valid_steps_array(SelfCalibrateSteps::SELF_CALIBRATE_STEPS_AMPLITUDE_ACCURACY); - if (valid_steps & 0x40) - response->add_valid_steps_array(SelfCalibrateSteps::SELF_CALIBRATE_STEPS_RESIDUAL_LO_POWER); - if (valid_steps & 0x80) - response->add_valid_steps_array(SelfCalibrateSteps::SELF_CALIBRATE_STEPS_IMAGE_SUPPRESSION); - if (valid_steps & 0x100) - response->add_valid_steps_array(SelfCalibrateSteps::SELF_CALIBRATE_STEPS_SYNTHESIZER_ALIGNMENT); - if (valid_steps & 0x200) - response->add_valid_steps_array(SelfCalibrateSteps::SELF_CALIBRATE_STEPS_DC_OFFSET); - response->set_valid_steps_raw(valid_steps); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_self_cal_valid(self_cal_valid); + if (valid_steps & 0x1) + response->add_valid_steps_array(SelfCalibrateSteps::SELF_CALIBRATE_STEPS_ALIGNMENT); + if (valid_steps & 0x2) + response->add_valid_steps_array(SelfCalibrateSteps::SELF_CALIBRATE_STEPS_GAIN_REFERENCE); + if (valid_steps & 0x4) + response->add_valid_steps_array(SelfCalibrateSteps::SELF_CALIBRATE_STEPS_IF_FLATNESS); + if (valid_steps & 0x8) + response->add_valid_steps_array(SelfCalibrateSteps::SELF_CALIBRATE_STEPS_DIGITIZER_SELF_CAL); + if (valid_steps & 0x10) + response->add_valid_steps_array(SelfCalibrateSteps::SELF_CALIBRATE_STEPS_LO_SELF_CAL); + if (valid_steps & 0x20) + response->add_valid_steps_array(SelfCalibrateSteps::SELF_CALIBRATE_STEPS_AMPLITUDE_ACCURACY); + if (valid_steps & 0x40) + response->add_valid_steps_array(SelfCalibrateSteps::SELF_CALIBRATE_STEPS_RESIDUAL_LO_POWER); + if (valid_steps & 0x80) + response->add_valid_steps_array(SelfCalibrateSteps::SELF_CALIBRATE_STEPS_IMAGE_SUPPRESSION); + if (valid_steps & 0x100) + response->add_valid_steps_array(SelfCalibrateSteps::SELF_CALIBRATE_STEPS_SYNTHESIZER_ALIGNMENT); + if (valid_steps & 0x200) + response->add_valid_steps_array(SelfCalibrateSteps::SELF_CALIBRATE_STEPS_DC_OFFSET); + response->set_valid_steps_raw(valid_steps); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -2422,6 +2566,9 @@ namespace nirfsa_grpc { auto vi_grpc_session = request->vi(); ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); auto status = library_->PerformThermalCorrection(vi); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -2446,11 +2593,12 @@ namespace nirfsa_grpc { std::vector data(data_array_size, NIComplexNumber_struct()); niRFSA_wfmInfo_struct wfm_info {}; auto status = library_->ReadIQSingleRecordComplexF64(vi, channel_list, timeout, data.data(), data_array_size, &wfm_info); - response->set_status(status); - if (status_ok(status)) { - convert_to_grpc(data, response->mutable_data()); - convert_to_grpc(wfm_info, response->mutable_wfm_info()); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + convert_to_grpc(data, response->mutable_data()); + convert_to_grpc(wfm_info, response->mutable_wfm_info()); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -2475,10 +2623,11 @@ namespace nirfsa_grpc { ViReal32* power_spectrum_data = response->mutable_power_spectrum_data()->mutable_data(); niRFSA_spectrumInfo_struct spectrum_info {}; auto status = library_->ReadPowerSpectrumF32(vi, channel_list, timeout, power_spectrum_data, data_array_size, &spectrum_info); - response->set_status(status); - if (status_ok(status)) { - convert_to_grpc(spectrum_info, response->mutable_spectrum_info()); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + convert_to_grpc(spectrum_info, response->mutable_spectrum_info()); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -2503,10 +2652,11 @@ namespace nirfsa_grpc { ViReal64* power_spectrum_data = response->mutable_power_spectrum_data()->mutable_data(); niRFSA_spectrumInfo_struct spectrum_info {}; auto status = library_->ReadPowerSpectrumF64(vi, channel_list, timeout, power_spectrum_data, data_array_size, &spectrum_info); - response->set_status(status); - if (status_ok(status)) { - convert_to_grpc(spectrum_info, response->mutable_spectrum_info()); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + convert_to_grpc(spectrum_info, response->mutable_spectrum_info()); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -2525,6 +2675,9 @@ namespace nirfsa_grpc { auto vi_grpc_session = request->vi(); ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); auto status = library_->Reset(vi); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -2546,6 +2699,9 @@ namespace nirfsa_grpc { auto channel_name = request->channel_name().c_str(); ViAttr attribute_id = request->attribute_id(); auto status = library_->ResetAttribute(vi, channel_name, attribute_id); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -2565,6 +2721,9 @@ namespace nirfsa_grpc { auto vi_grpc_session = request->vi(); ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); auto status = library_->ResetDevice(vi); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -2584,6 +2743,9 @@ namespace nirfsa_grpc { auto vi_grpc_session = request->vi(); ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); auto status = library_->ResetWithDefaults(vi); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -2619,6 +2781,9 @@ namespace nirfsa_grpc { } auto status = library_->ResetWithOptions(vi, steps_to_omit); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -2640,13 +2805,14 @@ namespace nirfsa_grpc { std::string driver_rev(256 - 1, '\0'); std::string instr_rev(256 - 1, '\0'); auto status = library_->RevisionQuery(vi, (ViChar*)driver_rev.data(), (ViChar*)instr_rev.data()); - response->set_status(status); - if (status_ok(status)) { - response->set_driver_rev(driver_rev); - nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_driver_rev())); - response->set_instr_rev(instr_rev); - nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_instr_rev())); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_driver_rev(driver_rev); + nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_driver_rev())); + response->set_instr_rev(instr_rev); + nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_instr_rev())); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -2665,6 +2831,9 @@ namespace nirfsa_grpc { auto vi_grpc_session = request->vi(); ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); auto status = library_->SelfCal(vi); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -2700,6 +2869,9 @@ namespace nirfsa_grpc { } auto status = library_->SelfCalibrate(vi, steps_to_omit); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -2739,6 +2911,9 @@ namespace nirfsa_grpc { ViReal64 min_reference_level = request->min_reference_level(); ViReal64 max_reference_level = request->max_reference_level(); auto status = library_->SelfCalibrateRange(vi, steps_to_omit, min_frequency, max_frequency, min_reference_level, max_reference_level); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -2760,12 +2935,13 @@ namespace nirfsa_grpc { ViInt16 test_result {}; std::string test_message(2048 - 1, '\0'); auto status = library_->SelfTest(vi, &test_result, (ViChar*)test_message.data()); - response->set_status(status); - if (status_ok(status)) { - response->set_test_result(test_result); - response->set_test_message(test_message); - nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_test_message())); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_test_result(test_result); + response->set_test_message(test_message); + nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_test_message())); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -2801,6 +2977,9 @@ namespace nirfsa_grpc { auto trigger_identifier = request->trigger_identifier().c_str(); auto status = library_->SendSoftwareEdgeTrigger(vi, trigger, trigger_identifier); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -2823,6 +3002,9 @@ namespace nirfsa_grpc { ViAttr attribute_id = request->attribute_id(); ViBoolean value = request->value(); auto status = library_->SetAttributeViBoolean(vi, channel_name, attribute_id, value); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -2860,6 +3042,9 @@ namespace nirfsa_grpc { } auto status = library_->SetAttributeViInt32(vi, channel_name, attribute_id, value); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -2882,6 +3067,9 @@ namespace nirfsa_grpc { ViAttr attribute_id = request->attribute_id(); ViInt64 value = request->value_raw(); auto status = library_->SetAttributeViInt64(vi, channel_name, attribute_id, value); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -2904,6 +3092,9 @@ namespace nirfsa_grpc { ViAttr attribute_id = request->attribute_id(); ViReal64 value = request->value_raw(); auto status = library_->SetAttributeViReal64(vi, channel_name, attribute_id, value); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -2927,6 +3118,9 @@ namespace nirfsa_grpc { auto value_grpc_session = request->value(); ViSession value = session_repository_->access_session(value_grpc_session.id(), value_grpc_session.name()); auto status = library_->SetAttributeViSession(vi, channel_name, attribute_id, value); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -2968,6 +3162,9 @@ namespace nirfsa_grpc { } auto status = library_->SetAttributeViString(vi, channel_name, attribute_id, value); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -2988,6 +3185,9 @@ namespace nirfsa_grpc { ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); auto info = request->info().c_str(); auto status = library_->SetCalUserDefinedInfo(vi, info); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -3010,10 +3210,11 @@ namespace nirfsa_grpc { ViInt32 buffer_size = request->buffer_size(); std::string data(buffer_size, '\0'); auto status = library_->SetUserData(vi, identifier, buffer_size, (ViInt8*)data.data()); - response->set_status(status); - if (status_ok(status)) { - response->set_data(data); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_data(data); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { diff --git a/generated/nirfsa/nirfsa_service.h b/generated/nirfsa/nirfsa_service.h index 767299c21..a929df75c 100644 --- a/generated/nirfsa/nirfsa_service.h +++ b/generated/nirfsa/nirfsa_service.h @@ -147,6 +147,7 @@ class NiRFSAService final : public NiRFSA::Service { private: NiRFSALibraryInterface* library_; ResourceRepositorySharedPtr session_repository_; + ::grpc::Status ConvertApiErrorStatusForViSession(google::protobuf::int32 status, ViSession vi); std::map digitaledgetriggersource_input_map_ { {1, "PFI0"},{2, "PFI1"},{3, "PXI_Trig0"},{4, "PXI_Trig1"},{5, "PXI_Trig2"},{6, "PXI_Trig3"},{7, "PXI_Trig4"},{8, "PXI_Trig5"},{9, "PXI_Trig6"},{10, "PXI_Trig7"},{11, "PXI_STAR"},{12, "PXI_Trig0"},{13, "PXI_Trig1"},{14, "PXI_Trig2"},{15, "PXI_Trig3"},{16, "PXI_Trig4"},{17, "PXI_Trig5"},{18, "PXI_Trig6"},{19, "PXI_Trig7"},{20, "TimerEvent"}, }; std::map digitaledgetriggersource_output_map_ { {"PFI0", 1},{"PFI1", 2},{"PXI_Trig0", 3},{"PXI_Trig1", 4},{"PXI_Trig2", 5},{"PXI_Trig3", 6},{"PXI_Trig4", 7},{"PXI_Trig5", 8},{"PXI_Trig6", 9},{"PXI_Trig7", 10},{"PXI_STAR", 11},{"PXI_Trig0", 12},{"PXI_Trig1", 13},{"PXI_Trig2", 14},{"PXI_Trig3", 15},{"PXI_Trig4", 16},{"PXI_Trig5", 17},{"PXI_Trig6", 18},{"PXI_Trig7", 19},{"TimerEvent", 20}, }; std::map exportterminal_input_map_ { {1, ""},{2, "PFI0"},{3, "PFI1"},{4, "PXI_Trig0"},{5, "PXI_Trig1"},{6, "PXI_Trig2"},{7, "PXI_Trig3"},{8, "PXI_Trig4"},{9, "PXI_Trig5"},{10, "PXI_Trig6"},{11, "PXI_Trig7"},{12, "PXI_STAR"},{13, "PXIe_DStarC"},{14, "RefOut"},{15, "RefOut2"},{16, "ClkOut"}, }; diff --git a/generated/nirfsg/nirfsg_service.cpp b/generated/nirfsg/nirfsg_service.cpp index cf0e88ac0..8a8446ce8 100644 --- a/generated/nirfsg/nirfsg_service.cpp +++ b/generated/nirfsg/nirfsg_service.cpp @@ -56,6 +56,9 @@ namespace nirfsg_grpc { auto vi_grpc_session = request->vi(); ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); auto status = library_->Abort(vi); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -77,6 +80,9 @@ namespace nirfsg_grpc { auto waveform_name = request->waveform_name().c_str(); ViInt32 size_in_samples = request->size_in_samples(); auto status = library_->AllocateArbWaveform(vi, waveform_name, size_in_samples); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -99,6 +105,9 @@ namespace nirfsg_grpc { ViAttr attribute_id = request->attribute_id(); ViBoolean value = request->value(); auto status = library_->CheckAttributeViBoolean(vi, channel_name, attribute_id, value); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -136,6 +145,9 @@ namespace nirfsg_grpc { } auto status = library_->CheckAttributeViInt32(vi, channel_name, attribute_id, value); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -158,6 +170,9 @@ namespace nirfsg_grpc { ViAttr attribute_id = request->attribute_id(); ViInt64 value = request->value_raw(); auto status = library_->CheckAttributeViInt64(vi, channel_name, attribute_id, value); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -195,6 +210,9 @@ namespace nirfsg_grpc { } auto status = library_->CheckAttributeViReal64(vi, channel_name, attribute_id, value); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -218,6 +236,9 @@ namespace nirfsg_grpc { auto value_grpc_session = request->value(); ViSession value = session_repository_->access_session(value_grpc_session.id(), value_grpc_session.name()); auto status = library_->CheckAttributeViSession(vi, channel_name, attribute_id, value); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -259,6 +280,9 @@ namespace nirfsg_grpc { } auto status = library_->CheckAttributeViString(vi, channel_name, attribute_id, value); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -279,10 +303,11 @@ namespace nirfsg_grpc { ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); ViBoolean is_done {}; auto status = library_->CheckGenerationStatus(vi, &is_done); - response->set_status(status); - if (status_ok(status)) { - response->set_is_done(is_done); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_is_done(is_done); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -303,10 +328,11 @@ namespace nirfsg_grpc { auto list_name = request->list_name().c_str(); ViBoolean list_exists {}; auto status = library_->CheckIfConfigurationListExists(vi, list_name, &list_exists); - response->set_status(status); - if (status_ok(status)) { - response->set_list_exists(list_exists); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_list_exists(list_exists); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -327,10 +353,11 @@ namespace nirfsg_grpc { auto script_name = request->script_name().c_str(); ViBoolean script_exists {}; auto status = library_->CheckIfScriptExists(vi, script_name, &script_exists); - response->set_status(status); - if (status_ok(status)) { - response->set_script_exists(script_exists); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_script_exists(script_exists); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -351,10 +378,11 @@ namespace nirfsg_grpc { auto waveform_name = request->waveform_name().c_str(); ViBoolean waveform_exists {}; auto status = library_->CheckIfWaveformExists(vi, waveform_name, &waveform_exists); - response->set_status(status); - if (status_ok(status)) { - response->set_waveform_exists(waveform_exists); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_waveform_exists(waveform_exists); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -373,6 +401,9 @@ namespace nirfsg_grpc { auto vi_grpc_session = request->vi(); ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); auto status = library_->ClearAllArbWaveforms(vi); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -393,6 +424,9 @@ namespace nirfsg_grpc { ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); auto name = request->name().c_str(); auto status = library_->ClearArbWaveform(vi, name); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -412,6 +446,9 @@ namespace nirfsg_grpc { auto vi_grpc_session = request->vi(); ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); auto status = library_->ClearError(vi); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -431,6 +468,9 @@ namespace nirfsg_grpc { auto vi_grpc_session = request->vi(); ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); auto status = library_->ClearSelfCalibrateRange(vi); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -451,6 +491,9 @@ namespace nirfsg_grpc { ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); session_repository_->remove_session(vi_grpc_session.id(), vi_grpc_session.name()); auto status = library_->Close(vi); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -470,6 +513,9 @@ namespace nirfsg_grpc { auto vi_grpc_session = request->vi(); ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); auto status = library_->Commit(vi); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -507,6 +553,9 @@ namespace nirfsg_grpc { } auto status = library_->ConfigureDeembeddingTableInterpolationLinear(vi, port, table_name, format); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -528,6 +577,9 @@ namespace nirfsg_grpc { auto port = request->port().c_str(); auto table_name = request->table_name().c_str(); auto status = library_->ConfigureDeembeddingTableInterpolationNearest(vi, port, table_name); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -549,6 +601,9 @@ namespace nirfsg_grpc { auto port = request->port().c_str(); auto table_name = request->table_name().c_str(); auto status = library_->ConfigureDeembeddingTableInterpolationSpline(vi, port, table_name); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -604,6 +659,9 @@ namespace nirfsg_grpc { } auto status = library_->ConfigureDigitalEdgeConfigurationListStepTrigger(vi, source, edge); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -679,6 +737,9 @@ namespace nirfsg_grpc { } auto status = library_->ConfigureDigitalEdgeScriptTrigger(vi, trigger_id, source, edge); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -734,6 +795,9 @@ namespace nirfsg_grpc { } auto status = library_->ConfigureDigitalEdgeStartTrigger(vi, source, edge); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -809,6 +873,9 @@ namespace nirfsg_grpc { } auto status = library_->ConfigureDigitalLevelScriptTrigger(vi, trigger_id, source, level); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -830,6 +897,9 @@ namespace nirfsg_grpc { ViInt32 number_of_samples = static_cast(request->user_defined_waveform().size()); ViInt8* user_defined_waveform = (ViInt8*)request->user_defined_waveform().c_str(); auto status = library_->ConfigureDigitalModulationUserDefinedWaveform(vi, number_of_samples, user_defined_waveform); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -865,6 +935,9 @@ namespace nirfsg_grpc { } auto status = library_->ConfigureGenerationMode(vi, generation_mode); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -885,6 +958,9 @@ namespace nirfsg_grpc { ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); ViBoolean output_enabled = request->output_enabled(); auto status = library_->ConfigureOutputEnabled(vi, output_enabled); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -905,6 +981,9 @@ namespace nirfsg_grpc { ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); ViInt64 p2p_endpoint_fullness_level = request->p2p_endpoint_fullness_level(); auto status = library_->ConfigureP2PEndpointFullnessStartTrigger(vi, p2p_endpoint_fullness_level); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -944,6 +1023,9 @@ namespace nirfsg_grpc { } auto status = library_->ConfigurePXIChassisClk10(vi, pxi_clk10_source); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -979,6 +1061,9 @@ namespace nirfsg_grpc { } auto status = library_->ConfigurePowerLevelType(vi, power_level_type); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1000,6 +1085,9 @@ namespace nirfsg_grpc { ViReal64 frequency = request->frequency(); ViReal64 power_level = request->power_level(); auto status = library_->ConfigureRF(vi, frequency, power_level); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1040,6 +1128,9 @@ namespace nirfsg_grpc { ViReal64 ref_clock_rate = request->ref_clock_rate(); auto status = library_->ConfigureRefClock(vi, ref_clock_source, ref_clock_rate); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1060,6 +1151,9 @@ namespace nirfsg_grpc { ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); ViReal64 signal_bandwidth = request->signal_bandwidth(); auto status = library_->ConfigureSignalBandwidth(vi, signal_bandwidth); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1099,6 +1193,9 @@ namespace nirfsg_grpc { } auto status = library_->ConfigureSoftwareScriptTrigger(vi, trigger_id); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1118,6 +1215,9 @@ namespace nirfsg_grpc { auto vi_grpc_session = request->vi(); ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); auto status = library_->ConfigureSoftwareStartTrigger(vi); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1140,6 +1240,9 @@ namespace nirfsg_grpc { ViBoolean ensure_pll_locked = request->ensure_pll_locked(); auto reserved_for_future_use = 0; auto status = library_->ConfigureUpconverterPLLSettlingTime(vi, pll_settling_time, ensure_pll_locked, reserved_for_future_use); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1163,6 +1266,9 @@ namespace nirfsg_grpc { auto configuration_list_attributes = const_cast(reinterpret_cast(request->configuration_list_attributes().data())); ViBoolean set_as_active_list = request->set_as_active_list(); auto status = library_->CreateConfigurationList(vi, list_name, number_of_attributes, configuration_list_attributes, set_as_active_list); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1183,6 +1289,9 @@ namespace nirfsg_grpc { ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); ViBoolean set_as_active_step = request->set_as_active_step(); auto status = library_->CreateConfigurationListStep(vi, set_as_active_step); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1225,6 +1334,9 @@ namespace nirfsg_grpc { } auto status = library_->CreateDeembeddingSparameterTableArray(vi, port, table_name, frequencies, frequencies_size, sparameter_table.data(), sparameter_table_size, number_of_ports, sparameter_orientation); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1263,6 +1375,9 @@ namespace nirfsg_grpc { } auto status = library_->CreateDeembeddingSparameterTableS2PFile(vi, port, table_name, s2p_file_path, sparameter_orientation); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1282,6 +1397,9 @@ namespace nirfsg_grpc { auto vi_grpc_session = request->vi(); ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); auto status = library_->DeleteAllDeembeddingTables(vi); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1302,6 +1420,9 @@ namespace nirfsg_grpc { ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); auto list_name = request->list_name().c_str(); auto status = library_->DeleteConfigurationList(vi, list_name); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1323,6 +1444,9 @@ namespace nirfsg_grpc { auto port = request->port().c_str(); auto table_name = request->table_name().c_str(); auto status = library_->DeleteDeembeddingTable(vi, port, table_name); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1343,6 +1467,9 @@ namespace nirfsg_grpc { ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); auto script_name = request->script_name().c_str(); auto status = library_->DeleteScript(vi, script_name); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1362,6 +1489,9 @@ namespace nirfsg_grpc { auto vi_grpc_session = request->vi(); ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); auto status = library_->Disable(vi); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1381,6 +1511,9 @@ namespace nirfsg_grpc { auto vi_grpc_session = request->vi(); ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); auto status = library_->DisableAllModulation(vi); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1400,6 +1533,9 @@ namespace nirfsg_grpc { auto vi_grpc_session = request->vi(); ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); auto status = library_->DisableConfigurationListStepTrigger(vi); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1439,6 +1575,9 @@ namespace nirfsg_grpc { } auto status = library_->DisableScriptTrigger(vi, trigger_id); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1458,6 +1597,9 @@ namespace nirfsg_grpc { auto vi_grpc_session = request->vi(); ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); auto status = library_->DisableStartTrigger(vi); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1479,11 +1621,12 @@ namespace nirfsg_grpc { ViStatus error_code = request->error_code(); std::string error_message(1024 - 1, '\0'); auto status = library_->ErrorMessage(vi, error_code, (ViChar*)error_message.data()); - response->set_status(status); - if (status_ok(status)) { - response->set_error_message(error_message); - nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_error_message())); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_error_message(error_message); + nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_error_message())); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -1504,12 +1647,13 @@ namespace nirfsg_grpc { ViInt32 error_code {}; std::string error_message(1024 - 1, '\0'); auto status = library_->ErrorQuery(vi, &error_code, (ViChar*)error_message.data()); - response->set_status(status); - if (status_ok(status)) { - response->set_error_code(error_code); - response->set_error_message(error_message); - nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_error_message())); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_error_code(error_code); + response->set_error_message(error_message); + nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_error_message())); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -1584,6 +1728,9 @@ namespace nirfsg_grpc { } auto status = library_->ExportSignal(vi, signal, signal_identifier, output_terminal); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1606,10 +1753,11 @@ namespace nirfsg_grpc { ViAttr attribute_id = request->attribute_id(); ViBoolean value {}; auto status = library_->GetAttributeViBoolean(vi, channel_name, attribute_id, &value); - response->set_status(status); - if (status_ok(status)) { - response->set_value(value); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_value(value); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -1631,10 +1779,11 @@ namespace nirfsg_grpc { ViAttr attribute_id = request->attribute_id(); ViInt32 value {}; auto status = library_->GetAttributeViInt32(vi, channel_name, attribute_id, &value); - response->set_status(status); - if (status_ok(status)) { - response->set_value(value); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_value(value); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -1656,10 +1805,11 @@ namespace nirfsg_grpc { ViAttr attribute_id = request->attribute_id(); ViInt64 value {}; auto status = library_->GetAttributeViInt64(vi, channel_name, attribute_id, &value); - response->set_status(status); - if (status_ok(status)) { - response->set_value(value); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_value(value); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -1681,10 +1831,11 @@ namespace nirfsg_grpc { ViAttr attribute_id = request->attribute_id(); ViReal64 value {}; auto status = library_->GetAttributeViReal64(vi, channel_name, attribute_id, &value); - response->set_status(status); - if (status_ok(status)) { - response->set_value(value); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_value(value); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -1706,11 +1857,12 @@ namespace nirfsg_grpc { ViAttr attribute_id = request->attribute_id(); ViSession value {}; auto status = library_->GetAttributeViSession(vi, channel_name, attribute_id, &value); - response->set_status(status); - if (status_ok(status)) { - auto session_id = session_repository_->resolve_session_id(value); - response->mutable_value()->set_id(session_id); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + auto session_id = session_repository_->resolve_session_id(value); + response->mutable_value()->set_id(session_id); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -1733,9 +1885,8 @@ namespace nirfsg_grpc { while (true) { auto status = library_->GetAttributeViString(vi, channel_name, attribute_id, 0, nullptr); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } ViInt32 buf_size = status; @@ -1748,11 +1899,12 @@ namespace nirfsg_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_value(value); - nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_value())); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_value(value); + nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_value())); return ::grpc::Status::OK; } } @@ -1775,9 +1927,8 @@ namespace nirfsg_grpc { while (true) { auto status = library_->GetChannelName(vi, index, 0, nullptr); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } ViInt32 buffer_size = status; @@ -1790,11 +1941,12 @@ namespace nirfsg_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_name(name); - nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_name())); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_name(name); + nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_name())); return ::grpc::Status::OK; } } @@ -1817,9 +1969,8 @@ namespace nirfsg_grpc { ViInt32 number_of_ports {}; while (true) { auto status = library_->GetDeembeddingSparameters(vi, nullptr, 0, &number_of_sparameters, &number_of_ports); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } std::vector sparameters(number_of_sparameters, NIComplexNumber_struct()); auto sparameters_array_size = number_of_sparameters; @@ -1828,19 +1979,20 @@ namespace nirfsg_grpc { // buffer is now too small, try again continue; } + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); - if (status_ok(status)) { - convert_to_grpc(sparameters, response->mutable_sparameters()); - { - auto shrunk_size = number_of_sparameters; - auto current_size = response->mutable_sparameters()->size(); - if (shrunk_size != current_size) { - response->mutable_sparameters()->DeleteSubrange(shrunk_size, current_size - shrunk_size); - } + convert_to_grpc(sparameters, response->mutable_sparameters()); + { + auto shrunk_size = number_of_sparameters; + auto current_size = response->mutable_sparameters()->size(); + if (shrunk_size != current_size) { + response->mutable_sparameters()->DeleteSubrange(shrunk_size, current_size - shrunk_size); } - response->set_number_of_sparameters(number_of_sparameters); - response->set_number_of_ports(number_of_ports); } + response->set_number_of_sparameters(number_of_sparameters); + response->set_number_of_ports(number_of_ports); return ::grpc::Status::OK; } } @@ -1862,9 +2014,8 @@ namespace nirfsg_grpc { while (true) { auto status = library_->GetError(vi, nullptr, 0, nullptr); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } ViInt32 error_description_buffer_size = status; @@ -1878,12 +2029,13 @@ namespace nirfsg_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_error_code(error_code); - response->set_error_description(error_description); - nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_error_description())); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_error_code(error_code); + response->set_error_description(error_description); + nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_error_description())); return ::grpc::Status::OK; } } @@ -1909,15 +2061,16 @@ namespace nirfsg_grpc { ViInt32 minute {}; ViInt32 second {}; auto status = library_->GetExternalCalibrationLastDateAndTime(vi, &year, &month, &day, &hour, &minute, &second); - response->set_status(status); - if (status_ok(status)) { - response->set_year(year); - response->set_month(month); - response->set_day(day); - response->set_hour(hour); - response->set_minute(minute); - response->set_second(second); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_year(year); + response->set_month(month); + response->set_day(day); + response->set_hour(hour); + response->set_minute(minute); + response->set_second(second); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -1958,15 +2111,16 @@ namespace nirfsg_grpc { ViInt32 minute {}; ViInt32 second {}; auto status = library_->GetSelfCalibrationDateAndTime(vi, module, &year, &month, &day, &hour, &minute, &second); - response->set_status(status); - if (status_ok(status)) { - response->set_year(year); - response->set_month(month); - response->set_day(day); - response->set_hour(hour); - response->set_minute(minute); - response->set_second(second); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_year(year); + response->set_month(month); + response->set_day(day); + response->set_hour(hour); + response->set_minute(minute); + response->set_second(second); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -2002,10 +2156,11 @@ namespace nirfsg_grpc { ViReal64 temperature {}; auto status = library_->GetSelfCalibrationTemperature(vi, module, &temperature); - response->set_status(status); - if (status_ok(status)) { - response->set_temperature(temperature); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_temperature(temperature); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -2062,9 +2217,8 @@ namespace nirfsg_grpc { while (true) { auto status = library_->GetTerminalName(vi, signal, signal_identifier, 0, nullptr); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } ViInt32 buffer_size = status; @@ -2077,11 +2231,12 @@ namespace nirfsg_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_terminal_name(terminal_name); - nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_terminal_name())); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_terminal_name(terminal_name); + nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_terminal_name())); return ::grpc::Status::OK; } } @@ -2104,9 +2259,8 @@ namespace nirfsg_grpc { ViInt32 actual_data_size {}; while (true) { auto status = library_->GetUserData(vi, identifier, 0, nullptr, &actual_data_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } std::string data(actual_data_size, '\0'); auto buffer_size = actual_data_size; @@ -2115,12 +2269,13 @@ namespace nirfsg_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_data(data); - response->mutable_data()->resize(actual_data_size); - response->set_actual_data_size(actual_data_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_data(data); + response->mutable_data()->resize(actual_data_size); + response->set_actual_data_size(actual_data_size); return ::grpc::Status::OK; } } @@ -2143,9 +2298,8 @@ namespace nirfsg_grpc { ViInt32 required_size {}; while (true) { auto status = library_->GetWaveformBurstStartLocations(vi, channel_name, 0, nullptr, &required_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } response->mutable_locations()->Resize(required_size, 0); ViReal64* locations = response->mutable_locations()->mutable_data(); @@ -2155,11 +2309,12 @@ namespace nirfsg_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->mutable_locations()->Resize(required_size, 0); - response->set_required_size(required_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->mutable_locations()->Resize(required_size, 0); + response->set_required_size(required_size); return ::grpc::Status::OK; } } @@ -2182,9 +2337,8 @@ namespace nirfsg_grpc { ViInt32 required_size {}; while (true) { auto status = library_->GetWaveformBurstStopLocations(vi, channel_name, 0, nullptr, &required_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } response->mutable_locations()->Resize(required_size, 0); ViReal64* locations = response->mutable_locations()->mutable_data(); @@ -2194,11 +2348,12 @@ namespace nirfsg_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->mutable_locations()->Resize(required_size, 0); - response->set_required_size(required_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->mutable_locations()->Resize(required_size, 0); + response->set_required_size(required_size); return ::grpc::Status::OK; } } @@ -2221,9 +2376,8 @@ namespace nirfsg_grpc { ViInt32 required_size {}; while (true) { auto status = library_->GetWaveformMarkerEventLocations(vi, channel_name, 0, nullptr, &required_size); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } response->mutable_locations()->Resize(required_size, 0); ViReal64* locations = response->mutable_locations()->mutable_data(); @@ -2233,11 +2387,12 @@ namespace nirfsg_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->mutable_locations()->Resize(required_size, 0); - response->set_required_size(required_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->mutable_locations()->Resize(required_size, 0); + response->set_required_size(required_size); return ::grpc::Status::OK; } } @@ -2267,14 +2422,11 @@ namespace nirfsg_grpc { const std::string& grpc_device_session_name = request->session_name(); auto cleanup_lambda = [&] (ViSession id) { library_->Close(id); }; int status = session_repository_->add_session(grpc_device_session_name, init_lambda, cleanup_lambda, session_id); - response->set_status(status); - if (status_ok(status)) { - response->mutable_new_vi()->set_id(session_id); - } - else { - const auto error_message = get_last_error_message(library_); - response->set_error_message(error_message); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, 0); } + response->set_status(status); + response->mutable_new_vi()->set_id(session_id); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -2307,14 +2459,11 @@ namespace nirfsg_grpc { const std::string& grpc_device_session_name = request->session_name(); auto cleanup_lambda = [&] (ViSession id) { library_->Close(id); }; int status = session_repository_->add_session(grpc_device_session_name, init_lambda, cleanup_lambda, session_id); - response->set_status(status); - if (status_ok(status)) { - response->mutable_vi()->set_id(session_id); - } - else { - const auto error_message = get_last_error_message(library_); - response->set_error_message(error_message); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, 0); } + response->set_status(status); + response->mutable_vi()->set_id(session_id); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -2336,6 +2485,9 @@ namespace nirfsg_grpc { auto vi_grpc_session = request->vi(); ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); auto status = library_->Initiate(vi); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -2355,6 +2507,9 @@ namespace nirfsg_grpc { auto vi_grpc_session = request->vi(); ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); auto status = library_->InvalidateAllAttributes(vi); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -2376,6 +2531,9 @@ namespace nirfsg_grpc { auto channel_name = request->channel_name().c_str(); auto file_path = request->file_path().c_str(); auto status = library_->LoadConfigurationsFromFile(vi, channel_name, file_path); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -2395,6 +2553,9 @@ namespace nirfsg_grpc { auto vi_grpc_session = request->vi(); ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); auto status = library_->PerformPowerSearch(vi); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -2414,6 +2575,9 @@ namespace nirfsg_grpc { auto vi_grpc_session = request->vi(); ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); auto status = library_->PerformThermalCorrection(vi); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -2437,13 +2601,14 @@ namespace nirfsg_grpc { ViInt32 min_waveform_size {}; ViInt32 max_waveform_size {}; auto status = library_->QueryArbWaveformCapabilities(vi, &max_number_waveforms, &waveform_quantum, &min_waveform_size, &max_waveform_size); - response->set_status(status); - if (status_ok(status)) { - response->set_max_number_waveforms(max_number_waveforms); - response->set_waveform_quantum(waveform_quantum); - response->set_min_waveform_size(min_waveform_size); - response->set_max_waveform_size(max_waveform_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_max_number_waveforms(max_number_waveforms); + response->set_waveform_quantum(waveform_quantum); + response->set_min_waveform_size(min_waveform_size); + response->set_max_waveform_size(max_waveform_size); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -2465,6 +2630,9 @@ namespace nirfsg_grpc { auto file_path = request->file_path().c_str(); ViUInt32 waveform_index = request->waveform_index(); auto status = library_->ReadAndDownloadWaveformFromFileTDMS(vi, waveform_name, file_path, waveform_index); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -2484,6 +2652,9 @@ namespace nirfsg_grpc { auto vi_grpc_session = request->vi(); ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); auto status = library_->Reset(vi); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -2505,6 +2676,9 @@ namespace nirfsg_grpc { auto channel_name = request->channel_name().c_str(); ViAttr attribute_id = request->attribute_id(); auto status = library_->ResetAttribute(vi, channel_name, attribute_id); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -2524,6 +2698,9 @@ namespace nirfsg_grpc { auto vi_grpc_session = request->vi(); ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); auto status = library_->ResetDevice(vi); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -2543,6 +2720,9 @@ namespace nirfsg_grpc { auto vi_grpc_session = request->vi(); ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); auto status = library_->ResetWithDefaults(vi); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -2578,6 +2758,9 @@ namespace nirfsg_grpc { } auto status = library_->ResetWithOptions(vi, steps_to_omit); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -2599,13 +2782,14 @@ namespace nirfsg_grpc { std::string instrument_driver_revision(256 - 1, '\0'); std::string firmware_revision(256 - 1, '\0'); auto status = library_->RevisionQuery(vi, (ViChar*)instrument_driver_revision.data(), (ViChar*)firmware_revision.data()); - response->set_status(status); - if (status_ok(status)) { - response->set_instrument_driver_revision(instrument_driver_revision); - nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_instrument_driver_revision())); - response->set_firmware_revision(firmware_revision); - nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_firmware_revision())); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_instrument_driver_revision(instrument_driver_revision); + nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_instrument_driver_revision())); + response->set_firmware_revision(firmware_revision); + nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_firmware_revision())); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -2626,6 +2810,9 @@ namespace nirfsg_grpc { auto channel_name = request->channel_name().c_str(); auto file_path = request->file_path().c_str(); auto status = library_->SaveConfigurationsToFile(vi, channel_name, file_path); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -2646,6 +2833,9 @@ namespace nirfsg_grpc { ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); auto name = request->name().c_str(); auto status = library_->SelectArbWaveform(vi, name); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -2665,6 +2855,9 @@ namespace nirfsg_grpc { auto vi_grpc_session = request->vi(); ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); auto status = library_->SelfCal(vi); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -2704,6 +2897,9 @@ namespace nirfsg_grpc { ViReal64 min_power_level = request->min_power_level(); ViReal64 max_power_level = request->max_power_level(); auto status = library_->SelfCalibrateRange(vi, steps_to_omit, min_frequency, max_frequency, min_power_level, max_power_level); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -2725,12 +2921,13 @@ namespace nirfsg_grpc { ViInt16 self_test_result {}; std::string self_test_message(2048 - 1, '\0'); auto status = library_->SelfTest(vi, &self_test_result, (ViChar*)self_test_message.data()); - response->set_status(status); - if (status_ok(status)) { - response->set_self_test_result(self_test_result); - response->set_self_test_message(self_test_message); - nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_self_test_message())); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_self_test_result(self_test_result); + response->set_self_test_message(self_test_message); + nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_self_test_message())); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -2785,6 +2982,9 @@ namespace nirfsg_grpc { } auto status = library_->SendSoftwareEdgeTrigger(vi, trigger, trigger_identifier); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -2822,6 +3022,9 @@ namespace nirfsg_grpc { ViInt32 offset = request->offset(); auto status = library_->SetArbWaveformNextWritePosition(vi, waveform_name, relative_to, offset); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -2844,6 +3047,9 @@ namespace nirfsg_grpc { ViAttr attribute_id = request->attribute_id(); ViBoolean value = request->value(); auto status = library_->SetAttributeViBoolean(vi, channel_name, attribute_id, value); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -2881,6 +3087,9 @@ namespace nirfsg_grpc { } auto status = library_->SetAttributeViInt32(vi, channel_name, attribute_id, value); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -2903,6 +3112,9 @@ namespace nirfsg_grpc { ViAttr attribute_id = request->attribute_id(); ViInt64 value = request->value_raw(); auto status = library_->SetAttributeViInt64(vi, channel_name, attribute_id, value); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -2940,6 +3152,9 @@ namespace nirfsg_grpc { } auto status = library_->SetAttributeViReal64(vi, channel_name, attribute_id, value); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -2963,6 +3178,9 @@ namespace nirfsg_grpc { auto value_grpc_session = request->value(); ViSession value = session_repository_->access_session(value_grpc_session.id(), value_grpc_session.name()); auto status = library_->SetAttributeViSession(vi, channel_name, attribute_id, value); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -3004,6 +3222,9 @@ namespace nirfsg_grpc { } auto status = library_->SetAttributeViString(vi, channel_name, attribute_id, value); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -3026,6 +3247,9 @@ namespace nirfsg_grpc { ViInt32 buffer_size = static_cast(request->data().size()); ViInt8* data = (ViInt8*)request->data().c_str(); auto status = library_->SetUserData(vi, identifier, buffer_size, data); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -3048,6 +3272,9 @@ namespace nirfsg_grpc { ViInt32 number_of_locations = static_cast(request->locations().size()); auto locations = const_cast(request->locations().data()); auto status = library_->SetWaveformBurstStartLocations(vi, channel_name, number_of_locations, locations); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -3070,6 +3297,9 @@ namespace nirfsg_grpc { ViInt32 number_of_locations = static_cast(request->locations().size()); auto locations = const_cast(request->locations().data()); auto status = library_->SetWaveformBurstStopLocations(vi, channel_name, number_of_locations, locations); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -3092,6 +3322,9 @@ namespace nirfsg_grpc { ViInt32 number_of_locations = static_cast(request->locations().size()); auto locations = const_cast(request->locations().data()); auto status = library_->SetWaveformMarkerEventLocations(vi, channel_name, number_of_locations, locations); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -3112,6 +3345,9 @@ namespace nirfsg_grpc { ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); ViInt32 max_time_milliseconds = request->max_time_milliseconds(); auto status = library_->WaitUntilSettled(vi, max_time_milliseconds); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -3147,6 +3383,9 @@ namespace nirfsg_grpc { auto q_data = const_cast(request->q_data().data()); ViBoolean more_data_pending = request->more_data_pending(); auto status = library_->WriteArbWaveform(vi, waveform_name, number_of_samples, i_data, q_data, more_data_pending); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -3170,6 +3409,9 @@ namespace nirfsg_grpc { auto wfm_data = convert_from_grpc(request->wfm_data()); ViBoolean more_data_pending = request->more_data_pending(); auto status = library_->WriteArbWaveformComplexF32(vi, waveform_name, number_of_samples, wfm_data.data(), more_data_pending); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -3193,6 +3435,9 @@ namespace nirfsg_grpc { auto wfm_data = convert_from_grpc(request->wfm_data()); ViBoolean more_data_pending = request->more_data_pending(); auto status = library_->WriteArbWaveformComplexF64(vi, waveform_name, number_of_samples, wfm_data.data(), more_data_pending); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -3215,6 +3460,9 @@ namespace nirfsg_grpc { ViInt32 number_of_samples = static_cast(request->wfm_data().size()); auto wfm_data = convert_from_grpc(request->wfm_data()); auto status = library_->WriteArbWaveformComplexI16(vi, waveform_name, number_of_samples, wfm_data.data()); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -3250,6 +3498,9 @@ namespace nirfsg_grpc { auto q_data = const_cast(request->q_data().data()); ViBoolean more_data_pending = request->more_data_pending(); auto status = library_->WriteArbWaveformF32(vi, waveform_name, number_of_samples, i_data, q_data, more_data_pending); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -3270,6 +3521,9 @@ namespace nirfsg_grpc { ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); auto script = request->script().c_str(); auto status = library_->WriteScript(vi, script); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } diff --git a/generated/nirfsg/nirfsg_service.h b/generated/nirfsg/nirfsg_service.h index 8934b44b8..b0bd3d785 100644 --- a/generated/nirfsg/nirfsg_service.h +++ b/generated/nirfsg/nirfsg_service.h @@ -153,6 +153,7 @@ class NiRFSGService final : public NiRFSG::Service { private: NiRFSGLibraryInterface* library_; ResourceRepositorySharedPtr session_repository_; + ::grpc::Status ConvertApiErrorStatusForViSession(google::protobuf::int32 status, ViSession vi); std::map digitaledgeconfigurationliststeptriggersource_input_map_ { {1, "PFI0"},{2, "PFI1"},{3, "PFI2"},{4, "PFI3"},{5, "PXI_Trig0"},{6, "PXI_Trig1"},{7, "PXI_Trig2"},{8, "PXI_Trig3"},{9, "PXI_Trig4"},{10, "PXI_Trig5"},{11, "PXI_Trig6"},{12, "PXI_Trig7"},{13, "PXI_STAR"},{14, "Marker0Event"},{15, "Marker1Event"},{16, "Marker2Event"},{17, "Marker3Event"},{18, "TimerEvent"},{19, "TrigIn"}, }; std::map digitaledgeconfigurationliststeptriggersource_output_map_ { {"PFI0", 1},{"PFI1", 2},{"PFI2", 3},{"PFI3", 4},{"PXI_Trig0", 5},{"PXI_Trig1", 6},{"PXI_Trig2", 7},{"PXI_Trig3", 8},{"PXI_Trig4", 9},{"PXI_Trig5", 10},{"PXI_Trig6", 11},{"PXI_Trig7", 12},{"PXI_STAR", 13},{"Marker0Event", 14},{"Marker1Event", 15},{"Marker2Event", 16},{"Marker3Event", 17},{"TimerEvent", 18},{"TrigIn", 19}, }; std::map digitaledgescripttriggeridentifier_input_map_ { {1, "scriptTrigger0"},{2, "scriptTrigger1"},{3, "scriptTrigger2"},{4, "scriptTrigger3"}, }; diff --git a/generated/niscope/niscope_service.cpp b/generated/niscope/niscope_service.cpp index eca8b2913..e858bda41 100644 --- a/generated/niscope/niscope_service.cpp +++ b/generated/niscope/niscope_service.cpp @@ -56,6 +56,9 @@ namespace niscope_grpc { auto vi_grpc_session = request->vi(); ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); auto status = library_->Abort(vi); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -76,11 +79,12 @@ namespace niscope_grpc { ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); ViInt32 acquisition_status {}; auto status = library_->AcquisitionStatus(vi, &acquisition_status); - response->set_status(status); - if (status_ok(status)) { - response->set_acquisition_status(static_cast(acquisition_status)); - response->set_acquisition_status_raw(acquisition_status); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_acquisition_status(static_cast(acquisition_status)); + response->set_acquisition_status_raw(acquisition_status); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -116,10 +120,11 @@ namespace niscope_grpc { ViInt32 meas_waveform_size {}; auto status = library_->ActualMeasWfmSize(vi, array_meas_function, &meas_waveform_size); - response->set_status(status); - if (status_ok(status)) { - response->set_meas_waveform_size(meas_waveform_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_meas_waveform_size(meas_waveform_size); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -140,10 +145,11 @@ namespace niscope_grpc { auto channel_list = request->channel_list().c_str(); ViInt32 num_wfms {}; auto status = library_->ActualNumWfms(vi, channel_list, &num_wfms); - response->set_status(status); - if (status_ok(status)) { - response->set_num_wfms(num_wfms); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_num_wfms(num_wfms); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -163,10 +169,11 @@ namespace niscope_grpc { ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); ViInt32 record_length {}; auto status = library_->ActualRecordLength(vi, &record_length); - response->set_status(status); - if (status_ok(status)) { - response->set_record_length(record_length); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_record_length(record_length); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -202,6 +209,9 @@ namespace niscope_grpc { } auto status = library_->AddWaveformProcessing(vi, channel_list, meas_function); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -222,6 +232,9 @@ namespace niscope_grpc { ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); ViReal64 delay = request->delay(); auto status = library_->AdjustSampleClockRelativeDelay(vi, delay); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -241,6 +254,9 @@ namespace niscope_grpc { auto vi_grpc_session = request->vi(); ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); auto status = library_->AutoSetup(vi); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -260,6 +276,9 @@ namespace niscope_grpc { auto vi_grpc_session = request->vi(); ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); auto status = library_->CableSenseSignalStart(vi); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -279,6 +298,9 @@ namespace niscope_grpc { auto vi_grpc_session = request->vi(); ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); auto status = library_->CableSenseSignalStop(vi); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -315,6 +337,9 @@ namespace niscope_grpc { } auto status = library_->CalSelfCalibrate(vi, channel_list, option); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -337,6 +362,9 @@ namespace niscope_grpc { ViAttr attribute_id = request->attribute_id(); ViBoolean value = request->value(); auto status = library_->CheckAttributeViBoolean(vi, channel_list, attribute_id, value); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -374,6 +402,9 @@ namespace niscope_grpc { } auto status = library_->CheckAttributeViInt32(vi, channel_list, attribute_id, value); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -411,6 +442,9 @@ namespace niscope_grpc { } auto status = library_->CheckAttributeViInt64(vi, channel_list, attribute_id, value); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -456,6 +490,9 @@ namespace niscope_grpc { } auto status = library_->CheckAttributeViReal64(vi, channel_list, attribute_id, value); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -479,6 +516,9 @@ namespace niscope_grpc { auto value_grpc_session = request->value(); ViSession value = session_repository_->access_session(value_grpc_session.id(), value_grpc_session.name()); auto status = library_->CheckAttributeViSession(vi, channel_list, attribute_id, value); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -520,6 +560,9 @@ namespace niscope_grpc { } auto status = library_->CheckAttributeViString(vi, channel_list, attribute_id, value); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -556,6 +599,9 @@ namespace niscope_grpc { } auto status = library_->ClearWaveformMeasurementStats(vi, channel_list, clearable_measurement_function); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -576,6 +622,9 @@ namespace niscope_grpc { ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); auto channel_list = request->channel_list().c_str(); auto status = library_->ClearWaveformProcessing(vi, channel_list); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -596,6 +645,9 @@ namespace niscope_grpc { ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); session_repository_->remove_session(vi_grpc_session.id(), vi_grpc_session.name()); auto status = library_->Close(vi); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -615,6 +667,9 @@ namespace niscope_grpc { auto vi_grpc_session = request->vi(); ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); auto status = library_->Commit(vi); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -635,6 +690,9 @@ namespace niscope_grpc { ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); ViInt32 acquisition_type = request->acquisition_type(); auto status = library_->ConfigureAcquisition(vi, acquisition_type); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -657,6 +715,9 @@ namespace niscope_grpc { ViReal64 input_impedance = request->input_impedance(); ViReal64 max_input_frequency = request->max_input_frequency(); auto status = library_->ConfigureChanCharacteristics(vi, channel_list, input_impedance, max_input_frequency); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -737,6 +798,9 @@ namespace niscope_grpc { ViBoolean master_enabled = request->master_enabled(); auto status = library_->ConfigureClock(vi, input_clock_source, output_clock_source, clock_sync_pulse_source, master_enabled); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -759,6 +823,9 @@ namespace niscope_grpc { ViInt32 number_of_coefficients = static_cast(request->coefficients().size()); auto coefficients = const_cast(request->coefficients().data()); auto status = library_->ConfigureEqualizationFilterCoefficients(vi, channel_list, number_of_coefficients, coefficients); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -783,6 +850,9 @@ namespace niscope_grpc { ViInt32 num_records = request->num_records(); ViBoolean enforce_realtime = request->enforce_realtime(); auto status = library_->ConfigureHorizontalTiming(vi, min_sample_rate, min_num_pts, ref_position, num_records, enforce_realtime); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -821,6 +891,9 @@ namespace niscope_grpc { ViReal64 holdoff = request->holdoff(); ViReal64 delay = request->delay(); auto status = library_->ConfigureTriggerDigital(vi, trigger_source, slope, holdoff, delay); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -876,6 +949,9 @@ namespace niscope_grpc { ViReal64 holdoff = request->holdoff(); ViReal64 delay = request->delay(); auto status = library_->ConfigureTriggerEdge(vi, trigger_source, level, slope, trigger_coupling, holdoff, delay); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -948,6 +1024,9 @@ namespace niscope_grpc { ViReal64 holdoff = request->holdoff(); ViReal64 delay = request->delay(); auto status = library_->ConfigureTriggerGlitch(vi, trigger_source, level, width, polarity, glitch_condition, trigger_coupling, holdoff, delay); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1004,6 +1083,9 @@ namespace niscope_grpc { ViReal64 holdoff = request->holdoff(); ViReal64 delay = request->delay(); auto status = library_->ConfigureTriggerHysteresis(vi, trigger_source, level, hysteresis, slope, trigger_coupling, holdoff, delay); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1023,6 +1105,9 @@ namespace niscope_grpc { auto vi_grpc_session = request->vi(); ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); auto status = library_->ConfigureTriggerImmediate(vi); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1079,6 +1164,9 @@ namespace niscope_grpc { ViReal64 holdoff = request->holdoff(); ViReal64 delay = request->delay(); auto status = library_->ConfigureTriggerRunt(vi, trigger_source, low_threshold, high_threshold, polarity, trigger_coupling, holdoff, delay); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1100,6 +1188,9 @@ namespace niscope_grpc { ViReal64 holdoff = request->holdoff(); ViReal64 delay = request->delay(); auto status = library_->ConfigureTriggerSoftware(vi, holdoff, delay); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1188,6 +1279,9 @@ namespace niscope_grpc { ViReal64 holdoff = request->holdoff(); ViReal64 delay = request->delay(); auto status = library_->ConfigureTriggerVideo(vi, trigger_source, enable_dc_restore, signal_format, event_parameter, line_number, polarity, trigger_coupling, holdoff, delay); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1261,6 +1355,9 @@ namespace niscope_grpc { ViReal64 holdoff = request->holdoff(); ViReal64 delay = request->delay(); auto status = library_->ConfigureTriggerWidth(vi, trigger_source, level, low_threshold, high_threshold, polarity, condition, trigger_coupling, holdoff, delay); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1317,6 +1414,9 @@ namespace niscope_grpc { ViReal64 holdoff = request->holdoff(); ViReal64 delay = request->delay(); auto status = library_->ConfigureTriggerWindow(vi, trigger_source, low_level, high_level, window_mode, trigger_coupling, holdoff, delay); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1357,6 +1457,9 @@ namespace niscope_grpc { ViReal64 probe_attenuation = request->probe_attenuation(); ViBoolean enabled = request->enabled(); auto status = library_->ConfigureVertical(vi, channel_list, range, offset, coupling, probe_attenuation, enabled); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1376,6 +1479,9 @@ namespace niscope_grpc { auto vi_grpc_session = request->vi(); ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); auto status = library_->Disable(vi); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1398,11 +1504,12 @@ namespace niscope_grpc { ViChar* error_source = (ViChar*)request->error_source().c_str(); std::string error_description(642 - 1, '\0'); auto status = library_->ErrorHandler(vi, error_code, error_source, (ViChar*)error_description.data()); - response->set_status(status); - if (status_ok(status)) { - response->set_error_description(error_description); - nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_error_description())); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_error_description(error_description); + nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_error_description())); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -1423,9 +1530,8 @@ namespace niscope_grpc { while (true) { auto status = library_->ExportAttributeConfigurationBuffer(vi, 0, nullptr); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } ViInt32 size_in_bytes = status; @@ -1435,10 +1541,11 @@ namespace niscope_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_configuration(configuration); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_configuration(configuration); return ::grpc::Status::OK; } } @@ -1459,6 +1566,9 @@ namespace niscope_grpc { ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); auto file_path = request->file_path().c_str(); auto status = library_->ExportAttributeConfigurationFile(vi, file_path); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1515,6 +1625,9 @@ namespace niscope_grpc { } auto status = library_->ExportSignal(vi, signal, signal_identifier, output_terminal); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1537,10 +1650,11 @@ namespace niscope_grpc { ViAttr attribute_id = request->attribute_id(); ViBoolean value {}; auto status = library_->GetAttributeViBoolean(vi, channel_list, attribute_id, &value); - response->set_status(status); - if (status_ok(status)) { - response->set_value(value); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_value(value); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -1562,10 +1676,11 @@ namespace niscope_grpc { ViAttr attribute_id = request->attribute_id(); ViInt32 value {}; auto status = library_->GetAttributeViInt32(vi, channel_list, attribute_id, &value); - response->set_status(status); - if (status_ok(status)) { - response->set_value(value); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_value(value); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -1587,10 +1702,11 @@ namespace niscope_grpc { ViAttr attribute_id = request->attribute_id(); ViInt64 value {}; auto status = library_->GetAttributeViInt64(vi, channel_list, attribute_id, &value); - response->set_status(status); - if (status_ok(status)) { - response->set_value(value); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_value(value); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -1612,10 +1728,11 @@ namespace niscope_grpc { ViAttr attribute_id = request->attribute_id(); ViReal64 value {}; auto status = library_->GetAttributeViReal64(vi, channel_list, attribute_id, &value); - response->set_status(status); - if (status_ok(status)) { - response->set_value(value); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_value(value); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -1637,11 +1754,12 @@ namespace niscope_grpc { ViAttr attribute_id = request->attribute_id(); ViSession value {}; auto status = library_->GetAttributeViSession(vi, channel_list, attribute_id, &value); - response->set_status(status); - if (status_ok(status)) { - auto session_id = session_repository_->resolve_session_id(value); - response->mutable_value()->set_id(session_id); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + auto session_id = session_repository_->resolve_session_id(value); + response->mutable_value()->set_id(session_id); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -1664,9 +1782,8 @@ namespace niscope_grpc { while (true) { auto status = library_->GetAttributeViString(vi, channel_list, attribute_id, 0, nullptr); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } ViInt32 buf_size = status; @@ -1679,11 +1796,12 @@ namespace niscope_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_value(value); - nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_value())); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_value(value); + nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_value())); return ::grpc::Status::OK; } } @@ -1706,9 +1824,8 @@ namespace niscope_grpc { while (true) { auto status = library_->GetChannelName(vi, index, 0, nullptr); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } ViInt32 buffer_size = status; @@ -1721,11 +1838,12 @@ namespace niscope_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_channel_string(channel_string); - nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_channel_string())); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_channel_string(channel_string); + nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_channel_string())); return ::grpc::Status::OK; } } @@ -1748,9 +1866,8 @@ namespace niscope_grpc { while (true) { auto status = library_->GetChannelNameFromString(vi, index, 0, nullptr); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } ViInt32 buffer_size = status; @@ -1763,11 +1880,12 @@ namespace niscope_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_name(name); - nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_name())); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_name(name); + nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_name())); return ::grpc::Status::OK; } } @@ -1791,9 +1909,10 @@ namespace niscope_grpc { response->mutable_coefficients()->Resize(number_of_coefficients, 0); ViReal64* coefficients = response->mutable_coefficients()->mutable_data(); auto status = library_->GetEqualizationFilterCoefficients(vi, channel, number_of_coefficients, coefficients); - response->set_status(status); - if (status_ok(status)) { + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -1814,9 +1933,8 @@ namespace niscope_grpc { while (true) { auto status = library_->GetError(vi, nullptr, 0, nullptr); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } ViInt32 buffer_size = status; @@ -1830,12 +1948,13 @@ namespace niscope_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_error_code(error_code); - response->set_description(description); - nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_description())); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_error_code(error_code); + response->set_description(description); + nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_description())); return ::grpc::Status::OK; } } @@ -1858,9 +1977,8 @@ namespace niscope_grpc { while (true) { auto status = library_->GetErrorMessage(vi, error_code, 0, nullptr); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } ViInt32 buffer_size = status; @@ -1873,11 +1991,12 @@ namespace niscope_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_error_message(error_message); - nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_error_message())); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_error_message(error_message); + nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_error_message())); return ::grpc::Status::OK; } } @@ -1906,10 +2025,11 @@ namespace niscope_grpc { ViReal64* phases = response->mutable_phases()->mutable_data(); ViInt32 number_of_frequencies {}; auto status = library_->GetFrequencyResponse(vi, channel, buffer_size, frequencies, amplitudes, phases, &number_of_frequencies); - response->set_status(status); - if (status_ok(status)) { - response->set_number_of_frequencies(number_of_frequencies); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_number_of_frequencies(number_of_frequencies); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -1930,10 +2050,11 @@ namespace niscope_grpc { auto stream_name = request->stream_name().c_str(); ViUInt32 writer_handle {}; auto status = library_->GetStreamEndpointHandle(vi, stream_name, &writer_handle); - response->set_status(status); - if (status_ok(status)) { - response->set_writer_handle(writer_handle); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_writer_handle(writer_handle); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -1954,6 +2075,9 @@ namespace niscope_grpc { ViInt32 size_in_bytes = static_cast(request->configuration().size()); ViInt8* configuration = (ViInt8*)request->configuration().c_str(); auto status = library_->ImportAttributeConfigurationBuffer(vi, size_in_bytes, configuration); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1974,6 +2098,9 @@ namespace niscope_grpc { ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); auto file_path = request->file_path().c_str(); auto status = library_->ImportAttributeConfigurationFile(vi, file_path); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -2003,14 +2130,11 @@ namespace niscope_grpc { const std::string& grpc_device_session_name = request->session_name(); auto cleanup_lambda = [&] (ViSession id) { library_->Close(id); }; int status = session_repository_->add_session(grpc_device_session_name, init_lambda, cleanup_lambda, session_id); - response->set_status(status); - if (status_ok(status)) { - response->mutable_vi()->set_id(session_id); - } - else { - const auto error_message = get_last_error_message(library_); - response->set_error_message(error_message); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, 0); } + response->set_status(status); + response->mutable_vi()->set_id(session_id); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -2043,14 +2167,11 @@ namespace niscope_grpc { const std::string& grpc_device_session_name = request->session_name(); auto cleanup_lambda = [&] (ViSession id) { library_->Close(id); }; int status = session_repository_->add_session(grpc_device_session_name, init_lambda, cleanup_lambda, session_id); - response->set_status(status); - if (status_ok(status)) { - response->mutable_vi()->set_id(session_id); - } - else { - const auto error_message = get_last_error_message(library_); - response->set_error_message(error_message); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, 0); } + response->set_status(status); + response->mutable_vi()->set_id(session_id); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -2072,6 +2193,9 @@ namespace niscope_grpc { auto vi_grpc_session = request->vi(); ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); auto status = library_->InitiateAcquisition(vi); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -2091,6 +2215,9 @@ namespace niscope_grpc { auto vi_grpc_session = request->vi(); ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); auto status = library_->ProbeCompensationSignalStart(vi); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -2110,6 +2237,9 @@ namespace niscope_grpc { auto vi_grpc_session = request->vi(); ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); auto status = library_->ProbeCompensationSignalStop(vi); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -2129,6 +2259,9 @@ namespace niscope_grpc { auto vi_grpc_session = request->vi(); ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); auto status = library_->Reset(vi); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -2148,6 +2281,9 @@ namespace niscope_grpc { auto vi_grpc_session = request->vi(); ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); auto status = library_->ResetDevice(vi); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -2169,13 +2305,14 @@ namespace niscope_grpc { std::string driver_revision(256 - 1, '\0'); std::string firmware_revision(256 - 1, '\0'); auto status = library_->RevisionQuery(vi, (ViChar*)driver_revision.data(), (ViChar*)firmware_revision.data()); - response->set_status(status); - if (status_ok(status)) { - response->set_driver_revision(driver_revision); - nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_driver_revision())); - response->set_firmware_revision(firmware_revision); - nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_firmware_revision())); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_driver_revision(driver_revision); + nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_driver_revision())); + response->set_firmware_revision(firmware_revision); + nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_firmware_revision())); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -2195,10 +2332,11 @@ namespace niscope_grpc { ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); ViInt32 sample_mode {}; auto status = library_->SampleMode(vi, &sample_mode); - response->set_status(status); - if (status_ok(status)) { - response->set_sample_mode(sample_mode); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_sample_mode(sample_mode); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -2218,10 +2356,11 @@ namespace niscope_grpc { ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); ViReal64 sample_rate {}; auto status = library_->SampleRate(vi, &sample_rate); - response->set_status(status); - if (status_ok(status)) { - response->set_sample_rate(sample_rate); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_sample_rate(sample_rate); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -2242,12 +2381,13 @@ namespace niscope_grpc { ViInt16 self_test_result {}; std::string self_test_message(256 - 1, '\0'); auto status = library_->SelfTest(vi, &self_test_result, (ViChar*)self_test_message.data()); - response->set_status(status); - if (status_ok(status)) { - response->set_self_test_result(self_test_result); - response->set_self_test_message(self_test_message); - nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_self_test_message())); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_self_test_result(self_test_result); + response->set_self_test_message(self_test_message); + nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_self_test_message())); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -2282,6 +2422,9 @@ namespace niscope_grpc { } auto status = library_->SendSoftwareTriggerEdge(vi, which_trigger); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -2304,6 +2447,9 @@ namespace niscope_grpc { ViAttr attribute_id = request->attribute_id(); ViBoolean value = request->value(); auto status = library_->SetAttributeViBoolean(vi, channel_list, attribute_id, value); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -2341,6 +2487,9 @@ namespace niscope_grpc { } auto status = library_->SetAttributeViInt32(vi, channel_list, attribute_id, value); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -2378,6 +2527,9 @@ namespace niscope_grpc { } auto status = library_->SetAttributeViInt64(vi, channel_list, attribute_id, value); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -2423,6 +2575,9 @@ namespace niscope_grpc { } auto status = library_->SetAttributeViReal64(vi, channel_list, attribute_id, value); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -2446,6 +2601,9 @@ namespace niscope_grpc { auto value_grpc_session = request->value(); ViSession value = session_repository_->access_session(value_grpc_session.id(), value_grpc_session.name()); auto status = library_->SetAttributeViSession(vi, channel_list, attribute_id, value); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -2487,6 +2645,9 @@ namespace niscope_grpc { } auto status = library_->SetAttributeViString(vi, channel_list, attribute_id, value); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } diff --git a/generated/niscope/niscope_service.h b/generated/niscope/niscope_service.h index 80538b0b4..d69861b63 100644 --- a/generated/niscope/niscope_service.h +++ b/generated/niscope/niscope_service.h @@ -132,6 +132,7 @@ class NiScopeService final : public NiScope::Service { private: NiScopeLibraryInterface* library_; ResourceRepositorySharedPtr session_repository_; + ::grpc::Status ConvertApiErrorStatusForViSession(google::protobuf::int32 status, ViSession vi); std::map clockingterminalvalues_input_map_ { {1, "VAL_NO_SOURCE"},{2, "VAL_RTSI_CLOCK"},{3, "VAL_EXTERNAL"},{4, "VAL_PFI_0"},{5, "VAL_PFI_1"},{6, "VAL_PFI_2"},{7, "VAL_CLK_IN"},{8, "VAL_CLK_OUT"},{9, "VAL_INTERNAL10MHZ_OSC"},{10, "VAL_PXI_CLK"},{11, "VAL_PXI_CLK10"},{12, "VAL_PXI_CLK100"},{13, "VAL_PXIE_DSTAR_A"},{14, "VAL_AUX_0_CLK_IN"},{15, "VAL_AUX_0_CLK_OUT"},{16, "VAL_ONBOARD_CONFIGURABLE_RATE_CLK"}, }; std::map clockingterminalvalues_output_map_ { {"VAL_NO_SOURCE", 1},{"VAL_RTSI_CLOCK", 2},{"VAL_EXTERNAL", 3},{"VAL_PFI_0", 4},{"VAL_PFI_1", 5},{"VAL_PFI_2", 6},{"VAL_CLK_IN", 7},{"VAL_CLK_OUT", 8},{"VAL_INTERNAL10MHZ_OSC", 9},{"VAL_PXI_CLK", 10},{"VAL_PXI_CLK10", 11},{"VAL_PXI_CLK100", 12},{"VAL_PXIE_DSTAR_A", 13},{"VAL_AUX_0_CLK_IN", 14},{"VAL_AUX_0_CLK_OUT", 15},{"VAL_ONBOARD_CONFIGURABLE_RATE_CLK", 16}, }; std::map niscopereal64attributevaluesmapped_input_map_ { {1, 50.0f},{2, 75.0f},{3, 1000000.0f},{4, 0.0f},{5, -1.0f},{6, 20000000.0f},{7, 100000000.0f},{8, 20000000.0f},{9, 100000000.0f}, }; diff --git a/generated/niswitch/niswitch_service.cpp b/generated/niswitch/niswitch_service.cpp index 57883d567..2426db5db 100644 --- a/generated/niswitch/niswitch_service.cpp +++ b/generated/niswitch/niswitch_service.cpp @@ -56,6 +56,9 @@ namespace niswitch_grpc { auto vi_grpc_session = request->vi(); ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); auto status = library_->AbortScan(vi); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -78,11 +81,12 @@ namespace niswitch_grpc { auto channel2 = request->channel2().c_str(); ViInt32 path_capability {}; auto status = library_->CanConnect(vi, channel1, channel2, &path_capability); - response->set_status(status); - if (status_ok(status)) { - response->set_path_capability(static_cast(path_capability)); - response->set_path_capability_raw(path_capability); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_path_capability(static_cast(path_capability)); + response->set_path_capability_raw(path_capability); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -104,6 +108,9 @@ namespace niswitch_grpc { ViAttr attribute_id = request->attribute_id(); ViBoolean attribute_value = request->attribute_value(); auto status = library_->CheckAttributeViBoolean(vi, channel_name, attribute_id, attribute_value); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -141,6 +148,9 @@ namespace niswitch_grpc { } auto status = library_->CheckAttributeViInt32(vi, channel_name, attribute_id, attribute_value); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -163,6 +173,9 @@ namespace niswitch_grpc { ViAttr attribute_id = request->attribute_id(); ViReal64 attribute_value = request->attribute_value_raw(); auto status = library_->CheckAttributeViReal64(vi, channel_name, attribute_id, attribute_value); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -185,6 +198,9 @@ namespace niswitch_grpc { ViAttr attribute_id = request->attribute_id(); ViString attribute_value = (ViString)request->attribute_value_raw().c_str(); auto status = library_->CheckAttributeViString(vi, channel_name, attribute_id, attribute_value); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -208,6 +224,9 @@ namespace niswitch_grpc { auto attribute_value_grpc_session = request->attribute_value(); ViSession attribute_value = session_repository_->access_session(attribute_value_grpc_session.id(), attribute_value_grpc_session.name()); auto status = library_->CheckAttributeViSession(vi, channel_name, attribute_id, attribute_value); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -227,6 +246,9 @@ namespace niswitch_grpc { auto vi_grpc_session = request->vi(); ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); auto status = library_->ClearError(vi); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -246,6 +268,9 @@ namespace niswitch_grpc { auto vi_grpc_session = request->vi(); ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); auto status = library_->ClearInterchangeWarnings(vi); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -266,6 +291,9 @@ namespace niswitch_grpc { ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); session_repository_->remove_session(vi_grpc_session.id(), vi_grpc_session.name()); auto status = library_->Close(vi); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -285,6 +313,9 @@ namespace niswitch_grpc { auto vi_grpc_session = request->vi(); ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); auto status = library_->Commit(vi); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -321,6 +352,9 @@ namespace niswitch_grpc { } auto status = library_->ConfigureScanList(vi, scanlist, scan_mode); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -373,6 +407,9 @@ namespace niswitch_grpc { } auto status = library_->ConfigureScanTrigger(vi, scan_delay, trigger_input, scan_advanced_output); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -394,6 +431,9 @@ namespace niswitch_grpc { auto channel1 = request->channel1().c_str(); auto channel2 = request->channel2().c_str(); auto status = library_->Connect(vi, channel1, channel2); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -414,6 +454,9 @@ namespace niswitch_grpc { ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); auto connection_list = request->connection_list().c_str(); auto status = library_->ConnectMultiple(vi, connection_list); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -433,6 +476,9 @@ namespace niswitch_grpc { auto vi_grpc_session = request->vi(); ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); auto status = library_->Disable(vi); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -454,6 +500,9 @@ namespace niswitch_grpc { auto channel1 = request->channel1().c_str(); auto channel2 = request->channel2().c_str(); auto status = library_->Disconnect(vi, channel1, channel2); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -473,6 +522,9 @@ namespace niswitch_grpc { auto vi_grpc_session = request->vi(); ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); auto status = library_->DisconnectAll(vi); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -493,6 +545,9 @@ namespace niswitch_grpc { ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); auto disconnection_list = request->disconnection_list().c_str(); auto status = library_->DisconnectMultiple(vi, disconnection_list); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -514,11 +569,12 @@ namespace niswitch_grpc { ViStatus error_code = request->error_code(); std::string error_message(256 - 1, '\0'); auto status = library_->ErrorMessage(vi, error_code, (ViChar*)error_message.data()); - response->set_status(status); - if (status_ok(status)) { - response->set_error_message(error_message); - nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_error_message())); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_error_message(error_message); + nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_error_message())); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -539,12 +595,13 @@ namespace niswitch_grpc { ViInt32 error_code {}; std::string error_message(256 - 1, '\0'); auto status = library_->ErrorQuery(vi, &error_code, (ViChar*)error_message.data()); - response->set_status(status); - if (status_ok(status)) { - response->set_error_code(error_code); - response->set_error_message(error_message); - nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_error_message())); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_error_code(error_code); + response->set_error_message(error_message); + nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_error_message())); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -566,10 +623,11 @@ namespace niswitch_grpc { ViAttr attribute_id = request->attribute_id(); ViBoolean attribute_value {}; auto status = library_->GetAttributeViBoolean(vi, channel_name, attribute_id, &attribute_value); - response->set_status(status); - if (status_ok(status)) { - response->set_attribute_value(attribute_value); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_attribute_value(attribute_value); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -591,10 +649,11 @@ namespace niswitch_grpc { ViAttr attribute_id = request->attribute_id(); ViInt32 attribute_value {}; auto status = library_->GetAttributeViInt32(vi, channel_name, attribute_id, &attribute_value); - response->set_status(status); - if (status_ok(status)) { - response->set_attribute_value(attribute_value); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_attribute_value(attribute_value); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -616,10 +675,11 @@ namespace niswitch_grpc { ViAttr attribute_id = request->attribute_id(); ViReal64 attribute_value {}; auto status = library_->GetAttributeViReal64(vi, channel_name, attribute_id, &attribute_value); - response->set_status(status); - if (status_ok(status)) { - response->set_attribute_value(attribute_value); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_attribute_value(attribute_value); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -642,9 +702,8 @@ namespace niswitch_grpc { while (true) { auto status = library_->GetAttributeViString(vi, channel_name, attribute_id, 0, nullptr); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } ViInt32 array_size = status; @@ -657,11 +716,12 @@ namespace niswitch_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_attribute_value(attribute_value); - nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_attribute_value())); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_attribute_value(attribute_value); + nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_attribute_value())); return ::grpc::Status::OK; } } @@ -684,11 +744,12 @@ namespace niswitch_grpc { ViAttr attribute_id = request->attribute_id(); ViSession attribute_value {}; auto status = library_->GetAttributeViSession(vi, channel_name, attribute_id, &attribute_value); - response->set_status(status); - if (status_ok(status)) { - auto session_id = session_repository_->resolve_session_id(attribute_value); - response->mutable_attribute_value()->set_id(session_id); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + auto session_id = session_repository_->resolve_session_id(attribute_value); + response->mutable_attribute_value()->set_id(session_id); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -710,9 +771,8 @@ namespace niswitch_grpc { while (true) { auto status = library_->GetChannelName(vi, index, 0, nullptr); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } ViInt32 buffer_size = status; @@ -725,11 +785,12 @@ namespace niswitch_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_channel_name_buffer(channel_name_buffer); - nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_channel_name_buffer())); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_channel_name_buffer(channel_name_buffer); + nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_channel_name_buffer())); return ::grpc::Status::OK; } } @@ -751,9 +812,8 @@ namespace niswitch_grpc { while (true) { auto status = library_->GetError(vi, nullptr, 0, nullptr); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } ViInt32 buffer_size = status; @@ -767,12 +827,13 @@ namespace niswitch_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_code(code); - response->set_description(description); - nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_description())); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_code(code); + response->set_description(description); + nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_description())); return ::grpc::Status::OK; } } @@ -794,9 +855,8 @@ namespace niswitch_grpc { while (true) { auto status = library_->GetNextCoercionRecord(vi, 0, nullptr); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } ViInt32 buffer_size = status; @@ -809,11 +869,12 @@ namespace niswitch_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_coercion_record(coercion_record); - nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_coercion_record())); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_coercion_record(coercion_record); + nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_coercion_record())); return ::grpc::Status::OK; } } @@ -835,9 +896,8 @@ namespace niswitch_grpc { while (true) { auto status = library_->GetNextInterchangeWarning(vi, 0, nullptr); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } ViInt32 buffer_size = status; @@ -850,11 +910,12 @@ namespace niswitch_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_interchange_warning(interchange_warning); - nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_interchange_warning())); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_interchange_warning(interchange_warning); + nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_interchange_warning())); return ::grpc::Status::OK; } } @@ -878,9 +939,8 @@ namespace niswitch_grpc { while (true) { auto status = library_->GetPath(vi, channel1, channel2, 0, nullptr); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } ViInt32 buffer_size = status; @@ -893,11 +953,12 @@ namespace niswitch_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_path(path); - nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_path())); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_path(path); + nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_path())); return ::grpc::Status::OK; } } @@ -919,10 +980,11 @@ namespace niswitch_grpc { auto relay_name = request->relay_name().c_str(); ViInt32 relay_count {}; auto status = library_->GetRelayCount(vi, relay_name, &relay_count); - response->set_status(status); - if (status_ok(status)) { - response->set_relay_count(relay_count); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_relay_count(relay_count); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -944,9 +1006,8 @@ namespace niswitch_grpc { while (true) { auto status = library_->GetRelayName(vi, index, 0, nullptr); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } ViInt32 relay_name_buffer_size = status; @@ -959,11 +1020,12 @@ namespace niswitch_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_relay_name_buffer(relay_name_buffer); - nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_relay_name_buffer())); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_relay_name_buffer(relay_name_buffer); + nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_relay_name_buffer())); return ::grpc::Status::OK; } } @@ -985,11 +1047,12 @@ namespace niswitch_grpc { auto relay_name = request->relay_name().c_str(); ViInt32 relay_position {}; auto status = library_->GetRelayPosition(vi, relay_name, &relay_position); - response->set_status(status); - if (status_ok(status)) { - response->set_relay_position(static_cast(relay_position)); - response->set_relay_position_raw(relay_position); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_relay_position(static_cast(relay_position)); + response->set_relay_position_raw(relay_position); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -1018,14 +1081,11 @@ namespace niswitch_grpc { const std::string& grpc_device_session_name = request->session_name(); auto cleanup_lambda = [&] (ViSession id) { library_->Close(id); }; int status = session_repository_->add_session(grpc_device_session_name, init_lambda, cleanup_lambda, session_id); - response->set_status(status); - if (status_ok(status)) { - response->mutable_vi()->set_id(session_id); - } - else { - const auto error_message = get_last_error_message(library_); - response->set_error_message(error_message); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, 0); } + response->set_status(status); + response->mutable_vi()->set_id(session_id); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -1058,14 +1118,11 @@ namespace niswitch_grpc { const std::string& grpc_device_session_name = request->session_name(); auto cleanup_lambda = [&] (ViSession id) { library_->Close(id); }; int status = session_repository_->add_session(grpc_device_session_name, init_lambda, cleanup_lambda, session_id); - response->set_status(status); - if (status_ok(status)) { - response->mutable_vi()->set_id(session_id); - } - else { - const auto error_message = get_last_error_message(library_); - response->set_error_message(error_message); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, 0); } + response->set_status(status); + response->mutable_vi()->set_id(session_id); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -1098,14 +1155,11 @@ namespace niswitch_grpc { const std::string& grpc_device_session_name = request->session_name(); auto cleanup_lambda = [&] (ViSession id) { library_->Close(id); }; int status = session_repository_->add_session(grpc_device_session_name, init_lambda, cleanup_lambda, session_id); - response->set_status(status); - if (status_ok(status)) { - response->mutable_vi()->set_id(session_id); - } - else { - const auto error_message = get_last_error_message(library_); - response->set_error_message(error_message); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, 0); } + response->set_status(status); + response->mutable_vi()->set_id(session_id); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -1127,6 +1181,9 @@ namespace niswitch_grpc { auto vi_grpc_session = request->vi(); ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); auto status = library_->InitiateScan(vi); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1146,6 +1203,9 @@ namespace niswitch_grpc { auto vi_grpc_session = request->vi(); ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); auto status = library_->InvalidateAllAttributes(vi); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1166,10 +1226,11 @@ namespace niswitch_grpc { ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); ViBoolean is_debounced {}; auto status = library_->IsDebounced(vi, &is_debounced); - response->set_status(status); - if (status_ok(status)) { - response->set_is_debounced(is_debounced); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_is_debounced(is_debounced); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -1189,10 +1250,11 @@ namespace niswitch_grpc { ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); ViBoolean is_scanning {}; auto status = library_->IsScanning(vi, &is_scanning); - response->set_status(status); - if (status_ok(status)) { - response->set_is_scanning(is_scanning); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_is_scanning(is_scanning); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -1228,6 +1290,9 @@ namespace niswitch_grpc { } auto status = library_->RelayControl(vi, relay_name, relay_action); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1247,6 +1312,9 @@ namespace niswitch_grpc { auto vi_grpc_session = request->vi(); ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); auto status = library_->Reset(vi); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1266,6 +1334,9 @@ namespace niswitch_grpc { auto vi_grpc_session = request->vi(); ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); auto status = library_->ResetInterchangeCheck(vi); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1285,6 +1356,9 @@ namespace niswitch_grpc { auto vi_grpc_session = request->vi(); ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); auto status = library_->ResetWithDefaults(vi); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1306,13 +1380,14 @@ namespace niswitch_grpc { std::string instrument_driver_revision(256 - 1, '\0'); std::string firmware_revision(256 - 1, '\0'); auto status = library_->RevisionQuery(vi, (ViChar*)instrument_driver_revision.data(), (ViChar*)firmware_revision.data()); - response->set_status(status); - if (status_ok(status)) { - response->set_instrument_driver_revision(instrument_driver_revision); - nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_instrument_driver_revision())); - response->set_firmware_revision(firmware_revision); - nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_firmware_revision())); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_instrument_driver_revision(instrument_driver_revision); + nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_instrument_driver_revision())); + response->set_firmware_revision(firmware_revision); + nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_firmware_revision())); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -1364,6 +1439,9 @@ namespace niswitch_grpc { ViBoolean invert = request->invert(); auto status = library_->RouteScanAdvancedOutput(vi, scan_advanced_output_connector, scan_advanced_output_bus_line, invert); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1416,6 +1494,9 @@ namespace niswitch_grpc { ViBoolean invert = request->invert(); auto status = library_->RouteTriggerInput(vi, trigger_input_connector, trigger_input_bus_line, invert); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1452,6 +1533,9 @@ namespace niswitch_grpc { } auto status = library_->Scan(vi, scanlist, initiation); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1473,12 +1557,13 @@ namespace niswitch_grpc { ViInt16 self_test_result {}; std::string self_test_message(256 - 1, '\0'); auto status = library_->SelfTest(vi, &self_test_result, (ViChar*)self_test_message.data()); - response->set_status(status); - if (status_ok(status)) { - response->set_self_test_result(self_test_result); - response->set_self_test_message(self_test_message); - nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_self_test_message())); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_self_test_result(self_test_result); + response->set_self_test_message(self_test_message); + nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_self_test_message())); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -1497,6 +1582,9 @@ namespace niswitch_grpc { auto vi_grpc_session = request->vi(); ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); auto status = library_->SendSoftwareTrigger(vi); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1519,6 +1607,9 @@ namespace niswitch_grpc { ViAttr attribute_id = request->attribute_id(); ViBoolean attribute_value = request->attribute_value(); auto status = library_->SetAttributeViBoolean(vi, channel_name, attribute_id, attribute_value); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1556,6 +1647,9 @@ namespace niswitch_grpc { } auto status = library_->SetAttributeViInt32(vi, channel_name, attribute_id, attribute_value); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1578,6 +1672,9 @@ namespace niswitch_grpc { ViAttr attribute_id = request->attribute_id(); ViReal64 attribute_value = request->attribute_value_raw(); auto status = library_->SetAttributeViReal64(vi, channel_name, attribute_id, attribute_value); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1600,6 +1697,9 @@ namespace niswitch_grpc { ViAttr attribute_id = request->attribute_id(); ViString attribute_value = (ViString)request->attribute_value_raw().c_str(); auto status = library_->SetAttributeViString(vi, channel_name, attribute_id, attribute_value); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1623,6 +1723,9 @@ namespace niswitch_grpc { auto attribute_value_grpc_session = request->attribute_value(); ViSession attribute_value = session_repository_->access_session(attribute_value_grpc_session.id(), attribute_value_grpc_session.name()); auto status = library_->SetAttributeViSession(vi, channel_name, attribute_id, attribute_value); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1643,6 +1746,9 @@ namespace niswitch_grpc { ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); ViBoolean continuous_scan = request->continuous_scan(); auto status = library_->SetContinuousScan(vi, continuous_scan); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1663,6 +1769,9 @@ namespace niswitch_grpc { ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); auto path_list = request->path_list().c_str(); auto status = library_->SetPath(vi, path_list); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1683,6 +1792,9 @@ namespace niswitch_grpc { ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); ViInt32 maximum_time_ms = request->maximum_time_ms(); auto status = library_->WaitForDebounce(vi, maximum_time_ms); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1703,6 +1815,9 @@ namespace niswitch_grpc { ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); ViInt32 maximum_time_ms = request->maximum_time_ms(); auto status = library_->WaitForScanComplete(vi, maximum_time_ms); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } diff --git a/generated/niswitch/niswitch_service.h b/generated/niswitch/niswitch_service.h index 52c3ecbc3..868cde239 100644 --- a/generated/niswitch/niswitch_service.h +++ b/generated/niswitch/niswitch_service.h @@ -104,6 +104,7 @@ class NiSwitchService final : public NiSwitch::Service { private: NiSwitchLibraryInterface* library_; ResourceRepositorySharedPtr session_repository_; + ::grpc::Status ConvertApiErrorStatusForViSession(google::protobuf::int32 status, ViSession vi); NiSwitchFeatureToggles feature_toggles_; }; diff --git a/generated/nisync/nisync_service.cpp b/generated/nisync/nisync_service.cpp index a1ddd9ab5..d468dcbb1 100644 --- a/generated/nisync/nisync_service.cpp +++ b/generated/nisync/nisync_service.cpp @@ -65,10 +65,11 @@ namespace nisync_grpc { const std::string& grpc_device_session_name = request->session_name(); auto cleanup_lambda = [&] (ViSession id) { library_->Close(id); }; int status = session_repository_->add_session(grpc_device_session_name, init_lambda, cleanup_lambda, session_id); - response->set_status(status); - if (status_ok(status)) { - response->mutable_vi()->set_id(session_id); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, 0); } + response->set_status(status); + response->mutable_vi()->set_id(session_id); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -91,6 +92,9 @@ namespace nisync_grpc { ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); session_repository_->remove_session(vi_grpc_session.id(), vi_grpc_session.name()); auto status = library_->Close(vi); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -112,11 +116,12 @@ namespace nisync_grpc { ViStatus error_code = request->error_code(); std::string error_message(256 - 1, '\0'); auto status = library_->ErrorMessage(vi, error_code, (ViChar*)error_message.data()); - response->set_status(status); - if (status_ok(status)) { - response->set_error_message(error_message); - nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_error_message())); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_error_message(error_message); + nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_error_message())); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -135,6 +140,9 @@ namespace nisync_grpc { auto vi_grpc_session = request->vi(); ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); auto status = library_->Reset(vi); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -154,6 +162,9 @@ namespace nisync_grpc { auto vi_grpc_session = request->vi(); ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); auto status = library_->PersistConfig(vi); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -175,12 +186,13 @@ namespace nisync_grpc { ViInt16 self_test_result {}; std::string self_test_message(256 - 1, '\0'); auto status = library_->SelfTest(vi, &self_test_result, (ViChar*)self_test_message.data()); - response->set_status(status); - if (status_ok(status)) { - response->set_self_test_result(self_test_result); - response->set_self_test_message(self_test_message); - nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_self_test_message())); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_self_test_result(self_test_result); + response->set_self_test_message(self_test_message); + nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_self_test_message())); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -201,13 +213,14 @@ namespace nisync_grpc { std::string driver_revision(256 - 1, '\0'); std::string firmware_revision(256 - 1, '\0'); auto status = library_->RevisionQuery(vi, (ViChar*)driver_revision.data(), (ViChar*)firmware_revision.data()); - response->set_status(status); - if (status_ok(status)) { - response->set_driver_revision(driver_revision); - nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_driver_revision())); - response->set_firmware_revision(firmware_revision); - nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_firmware_revision())); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_driver_revision(driver_revision); + nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_driver_revision())); + response->set_firmware_revision(firmware_revision); + nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_firmware_revision())); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -231,6 +244,9 @@ namespace nisync_grpc { ViInt32 invert = request->invert(); ViInt32 update_edge = request->update_edge(); auto status = library_->ConnectTrigTerminals(vi, src_terminal, dest_terminal, sync_clock, invert, update_edge); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -252,6 +268,9 @@ namespace nisync_grpc { auto src_terminal = request->src_terminal().c_str(); auto dest_terminal = request->dest_terminal().c_str(); auto status = library_->DisconnectTrigTerminals(vi, src_terminal, dest_terminal); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -277,6 +296,9 @@ namespace nisync_grpc { ViInt32 update_edge = request->update_edge(); ViReal64 delay = request->delay(); auto status = library_->ConnectSWTrigToTerminal(vi, src_terminal, dest_terminal, sync_clock, invert, update_edge, delay); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -298,6 +320,9 @@ namespace nisync_grpc { auto src_terminal = request->src_terminal().c_str(); auto dest_terminal = request->dest_terminal().c_str(); auto status = library_->DisconnectSWTrigFromTerminal(vi, src_terminal, dest_terminal); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -318,6 +343,9 @@ namespace nisync_grpc { ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); auto src_terminal = request->src_terminal().c_str(); auto status = library_->SendSoftwareTrigger(vi, src_terminal); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -339,6 +367,9 @@ namespace nisync_grpc { auto src_terminal = request->src_terminal().c_str(); auto dest_terminal = request->dest_terminal().c_str(); auto status = library_->ConnectClkTerminals(vi, src_terminal, dest_terminal); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -360,6 +391,9 @@ namespace nisync_grpc { auto src_terminal = request->src_terminal().c_str(); auto dest_terminal = request->dest_terminal().c_str(); auto status = library_->DisconnectClkTerminals(vi, src_terminal, dest_terminal); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -384,12 +418,13 @@ namespace nisync_grpc { ViReal64 frequency {}; ViReal64 error {}; auto status = library_->MeasureFrequency(vi, src_terminal, duration, &actual_duration, &frequency, &error); - response->set_status(status); - if (status_ok(status)) { - response->set_actual_duration(actual_duration); - response->set_frequency(frequency); - response->set_error(error); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_actual_duration(actual_duration); + response->set_frequency(frequency); + response->set_error(error); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -414,12 +449,13 @@ namespace nisync_grpc { ViReal64 frequency {}; ViReal64 frequency_error {}; auto status = library_->MeasureFrequencyEx(vi, src_terminal, duration, decimation_count, &actual_duration, &frequency, &frequency_error); - response->set_status(status); - if (status_ok(status)) { - response->set_actual_duration(actual_duration); - response->set_frequency(frequency); - response->set_frequency_error(frequency_error); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_actual_duration(actual_duration); + response->set_frequency(frequency); + response->set_frequency_error(frequency_error); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -438,6 +474,9 @@ namespace nisync_grpc { auto vi_grpc_session = request->vi(); ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); auto status = library_->Start1588(vi); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -457,6 +496,9 @@ namespace nisync_grpc { auto vi_grpc_session = request->vi(); ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); auto status = library_->Stop1588(vi); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -476,6 +518,9 @@ namespace nisync_grpc { auto vi_grpc_session = request->vi(); ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); auto status = library_->Start8021AS(vi); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -495,6 +540,9 @@ namespace nisync_grpc { auto vi_grpc_session = request->vi(); ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); auto status = library_->Stop8021AS(vi); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -518,6 +566,9 @@ namespace nisync_grpc { ViUInt32 time_nanoseconds = request->time_nanoseconds(); ViUInt16 time_fractional_nanoseconds = request->time_fractional_nanoseconds(); auto status = library_->SetTime(vi, time_source, time_seconds, time_nanoseconds, time_fractional_nanoseconds); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -540,12 +591,13 @@ namespace nisync_grpc { ViUInt32 time_nanoseconds {}; ViUInt16 time_fractional_nanoseconds {}; auto status = library_->GetTime(vi, &time_seconds, &time_nanoseconds, &time_fractional_nanoseconds); - response->set_status(status); - if (status_ok(status)) { - response->set_time_seconds(time_seconds); - response->set_time_nanoseconds(time_nanoseconds); - response->set_time_fractional_nanoseconds(time_fractional_nanoseconds); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_time_seconds(time_seconds); + response->set_time_nanoseconds(time_nanoseconds); + response->set_time_fractional_nanoseconds(time_fractional_nanoseconds); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -564,6 +616,9 @@ namespace nisync_grpc { auto vi_grpc_session = request->vi(); ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); auto status = library_->ResetFrequency(vi); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -588,6 +643,9 @@ namespace nisync_grpc { ViUInt32 time_nanoseconds = request->time_nanoseconds(); ViUInt16 time_fractional_nanoseconds = request->time_fractional_nanoseconds(); auto status = library_->CreateFutureTimeEvent(vi, terminal, output_level, time_seconds, time_nanoseconds, time_fractional_nanoseconds); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -608,6 +666,9 @@ namespace nisync_grpc { ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); auto terminal = request->terminal().c_str(); auto status = library_->ClearFutureTimeEvents(vi, terminal); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -629,6 +690,9 @@ namespace nisync_grpc { auto terminal = request->terminal().c_str(); ViInt32 active_edge = request->active_edge(); auto status = library_->EnableTimeStampTrigger(vi, terminal, active_edge); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -651,6 +715,9 @@ namespace nisync_grpc { ViInt32 active_edge = request->active_edge(); ViUInt32 decimation_count = request->decimation_count(); auto status = library_->EnableTimeStampTriggerWithDecimation(vi, terminal, active_edge, decimation_count); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -676,13 +743,14 @@ namespace nisync_grpc { ViUInt16 time_fractional_nanoseconds {}; ViInt32 detected_edge {}; auto status = library_->ReadTriggerTimeStamp(vi, terminal, timeout, &time_seconds, &time_nanoseconds, &time_fractional_nanoseconds, &detected_edge); - response->set_status(status); - if (status_ok(status)) { - response->set_time_seconds(time_seconds); - response->set_time_nanoseconds(time_nanoseconds); - response->set_time_fractional_nanoseconds(time_fractional_nanoseconds); - response->set_detected_edge(detected_edge); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_time_seconds(time_seconds); + response->set_time_nanoseconds(time_nanoseconds); + response->set_time_fractional_nanoseconds(time_fractional_nanoseconds); + response->set_detected_edge(detected_edge); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -702,6 +770,9 @@ namespace nisync_grpc { ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); auto terminal = request->terminal().c_str(); auto status = library_->DisableTimeStampTrigger(vi, terminal); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -730,6 +801,9 @@ namespace nisync_grpc { ViUInt32 stop_time_nanoseconds = request->stop_time_nanoseconds(); ViUInt16 stop_time_fractional_nanoseconds = request->stop_time_fractional_nanoseconds(); auto status = library_->CreateClock(vi, terminal, high_ticks, low_ticks, start_time_seconds, start_time_nanoseconds, start_time_fractional_nanoseconds, stop_time_seconds, stop_time_nanoseconds, stop_time_fractional_nanoseconds); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -750,6 +824,9 @@ namespace nisync_grpc { ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); auto terminal = request->terminal().c_str(); auto status = library_->ClearClock(vi, terminal); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -769,6 +846,9 @@ namespace nisync_grpc { auto vi_grpc_session = request->vi(); ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); auto status = library_->SetTimeReferenceFreeRunning(vi); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -788,6 +868,9 @@ namespace nisync_grpc { auto vi_grpc_session = request->vi(); ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); auto status = library_->SetTimeReferenceGPS(vi); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -809,6 +892,9 @@ namespace nisync_grpc { ViInt32 irig_type = request->irig_type(); auto terminal_name = request->terminal_name().c_str(); auto status = library_->SetTimeReferenceIRIG(vi, irig_type, terminal_name); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -833,6 +919,9 @@ namespace nisync_grpc { ViUInt32 initial_time_nanoseconds = request->initial_time_nanoseconds(); ViUInt16 initial_time_fractional_nanoseconds = request->initial_time_fractional_nanoseconds(); auto status = library_->SetTimeReferencePPS(vi, terminal_name, use_manual_time, initial_time_seconds, initial_time_nanoseconds, initial_time_fractional_nanoseconds); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -852,6 +941,9 @@ namespace nisync_grpc { auto vi_grpc_session = request->vi(); ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); auto status = library_->SetTimeReference1588OrdinaryClock(vi); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -871,6 +963,9 @@ namespace nisync_grpc { auto vi_grpc_session = request->vi(); ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); auto status = library_->SetTimeReference8021AS(vi); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -890,6 +985,9 @@ namespace nisync_grpc { auto vi_grpc_session = request->vi(); ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); auto status = library_->EnableGPSTimestamping(vi); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -911,6 +1009,9 @@ namespace nisync_grpc { ViInt32 irig_type = request->irig_type(); auto terminal_name = request->terminal_name().c_str(); auto status = library_->EnableIRIGTimestamping(vi, irig_type, terminal_name); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -936,15 +1037,16 @@ namespace nisync_grpc { ViUInt32 gps_nanoseconds {}; ViUInt16 gps_fractional_nanoseconds {}; auto status = library_->ReadLastGPSTimestamp(vi, ×tamp_seconds, ×tamp_nanoseconds, ×tamp_fractional_nanoseconds, &gps_seconds, &gps_nanoseconds, &gps_fractional_nanoseconds); - response->set_status(status); - if (status_ok(status)) { - response->set_timestamp_seconds(timestamp_seconds); - response->set_timestamp_nanoseconds(timestamp_nanoseconds); - response->set_timestamp_fractional_nanoseconds(timestamp_fractional_nanoseconds); - response->set_gps_seconds(gps_seconds); - response->set_gps_nanoseconds(gps_nanoseconds); - response->set_gps_fractional_nanoseconds(gps_fractional_nanoseconds); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_timestamp_seconds(timestamp_seconds); + response->set_timestamp_nanoseconds(timestamp_nanoseconds); + response->set_timestamp_fractional_nanoseconds(timestamp_fractional_nanoseconds); + response->set_gps_seconds(gps_seconds); + response->set_gps_nanoseconds(gps_nanoseconds); + response->set_gps_fractional_nanoseconds(gps_fractional_nanoseconds); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -970,15 +1072,16 @@ namespace nisync_grpc { ViUInt32 irigb_nanoseconds {}; ViUInt16 irigb_fractional_nanoseconds {}; auto status = library_->ReadLastIRIGTimestamp(vi, terminal, ×tamp_seconds, ×tamp_nanoseconds, ×tamp_fractional_nanoseconds, &irigb_seconds, &irigb_nanoseconds, &irigb_fractional_nanoseconds); - response->set_status(status); - if (status_ok(status)) { - response->set_timestamp_seconds(timestamp_seconds); - response->set_timestamp_nanoseconds(timestamp_nanoseconds); - response->set_timestamp_fractional_nanoseconds(timestamp_fractional_nanoseconds); - response->set_irigb_seconds(irigb_seconds); - response->set_irigb_nanoseconds(irigb_nanoseconds); - response->set_irigb_fractional_nanoseconds(irigb_fractional_nanoseconds); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_timestamp_seconds(timestamp_seconds); + response->set_timestamp_nanoseconds(timestamp_nanoseconds); + response->set_timestamp_fractional_nanoseconds(timestamp_fractional_nanoseconds); + response->set_irigb_seconds(irigb_seconds); + response->set_irigb_nanoseconds(irigb_nanoseconds); + response->set_irigb_fractional_nanoseconds(irigb_fractional_nanoseconds); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -997,6 +1100,9 @@ namespace nisync_grpc { auto vi_grpc_session = request->vi(); ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); auto status = library_->DisableGPSTimestamping(vi); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1017,6 +1123,9 @@ namespace nisync_grpc { ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); auto terminal_name = request->terminal_name().c_str(); auto status = library_->DisableIRIGTimestamping(vi, terminal_name); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1039,12 +1148,13 @@ namespace nisync_grpc { ViReal64 north_velocity {}; ViReal64 up_velocity {}; auto status = library_->GetVelocity(vi, &east_velocity, &north_velocity, &up_velocity); - response->set_status(status); - if (status_ok(status)) { - response->set_east_velocity(east_velocity); - response->set_north_velocity(north_velocity); - response->set_up_velocity(up_velocity); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_east_velocity(east_velocity); + response->set_north_velocity(north_velocity); + response->set_up_velocity(up_velocity); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -1066,12 +1176,13 @@ namespace nisync_grpc { ViReal64 longitude {}; ViReal64 altitude {}; auto status = library_->GetLocation(vi, &latitude, &longitude, &altitude); - response->set_status(status); - if (status_ok(status)) { - response->set_latitude(latitude); - response->set_longitude(longitude); - response->set_altitude(altitude); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_latitude(latitude); + response->set_longitude(longitude); + response->set_altitude(altitude); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -1092,9 +1203,8 @@ namespace nisync_grpc { while (true) { auto status = library_->GetTimeReferenceNames(vi, 0, nullptr); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } ViUInt32 buffer_size = status; @@ -1107,11 +1217,12 @@ namespace nisync_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_time_reference_names(time_reference_names); - nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_time_reference_names())); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_time_reference_names(time_reference_names); + nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_time_reference_names())); return ::grpc::Status::OK; } } @@ -1134,10 +1245,11 @@ namespace nisync_grpc { ViAttr attribute = request->attribute(); ViInt32 value {}; auto status = library_->GetAttributeViInt32(vi, active_item, attribute, &value); - response->set_status(status); - if (status_ok(status)) { - response->set_value(value); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_value(value); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -1159,10 +1271,11 @@ namespace nisync_grpc { ViAttr attribute = request->attribute(); ViReal64 value {}; auto status = library_->GetAttributeViReal64(vi, active_item, attribute, &value); - response->set_status(status); - if (status_ok(status)) { - response->set_value(value); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_value(value); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -1184,10 +1297,11 @@ namespace nisync_grpc { ViAttr attribute = request->attribute(); ViBoolean value {}; auto status = library_->GetAttributeViBoolean(vi, active_item, attribute, &value); - response->set_status(status); - if (status_ok(status)) { - response->set_value(value); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_value(value); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -1210,9 +1324,8 @@ namespace nisync_grpc { while (true) { auto status = library_->GetAttributeViString(vi, active_item, attribute, 0, nullptr); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } ViInt32 buffer_size = status; @@ -1225,11 +1338,12 @@ namespace nisync_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_value(value); - nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_value())); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_value(value); + nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_value())); return ::grpc::Status::OK; } } @@ -1252,6 +1366,9 @@ namespace nisync_grpc { ViAttr attribute = request->attribute(); ViInt32 value = request->value_raw(); auto status = library_->SetAttributeViInt32(vi, active_item, attribute, value); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1274,6 +1391,9 @@ namespace nisync_grpc { ViAttr attribute = request->attribute(); ViReal64 value = request->value_raw(); auto status = library_->SetAttributeViReal64(vi, active_item, attribute, value); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1296,6 +1416,9 @@ namespace nisync_grpc { ViAttr attribute = request->attribute(); ViBoolean value = request->value(); auto status = library_->SetAttributeViBoolean(vi, active_item, attribute, value); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1318,6 +1441,9 @@ namespace nisync_grpc { ViAttr attribute = request->attribute(); auto value = request->value_raw().c_str(); auto status = library_->SetAttributeViString(vi, active_item, attribute, value); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1342,14 +1468,15 @@ namespace nisync_grpc { ViInt32 hour {}; ViInt32 minute {}; auto status = library_->GetExtCalLastDateAndTime(vi, &year, &month, &day, &hour, &minute); - response->set_status(status); - if (status_ok(status)) { - response->set_year(year); - response->set_month(month); - response->set_day(day); - response->set_hour(hour); - response->set_minute(minute); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_year(year); + response->set_month(month); + response->set_day(day); + response->set_hour(hour); + response->set_minute(minute); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -1369,10 +1496,11 @@ namespace nisync_grpc { ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); ViReal64 temp {}; auto status = library_->GetExtCalLastTemp(vi, &temp); - response->set_status(status); - if (status_ok(status)) { - response->set_temp(temp); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_temp(temp); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -1392,10 +1520,11 @@ namespace nisync_grpc { ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); ViInt32 months {}; auto status = library_->GetExtCalRecommendedInterval(vi, &months); - response->set_status(status); - if (status_ok(status)) { - response->set_months(months); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_months(months); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -1416,6 +1545,9 @@ namespace nisync_grpc { auto old_password = request->old_password().c_str(); auto new_password = request->new_password().c_str(); auto status = library_->ChangeExtCalPassword(vi, old_password, new_password); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1436,10 +1568,11 @@ namespace nisync_grpc { ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); ViReal64 temperature {}; auto status = library_->ReadCurrentTemperature(vi, &temperature); - response->set_status(status); - if (status_ok(status)) { - response->set_temperature(temperature); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_temperature(temperature); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -1459,10 +1592,11 @@ namespace nisync_grpc { ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); ViReal64 voltage {}; auto status = library_->CalGetOscillatorVoltage(vi, &voltage); - response->set_status(status); - if (status_ok(status)) { - response->set_voltage(voltage); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_voltage(voltage); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -1482,10 +1616,11 @@ namespace nisync_grpc { ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); ViReal64 voltage {}; auto status = library_->CalGetClk10PhaseVoltage(vi, &voltage); - response->set_status(status); - if (status_ok(status)) { - response->set_voltage(voltage); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_voltage(voltage); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -1505,10 +1640,11 @@ namespace nisync_grpc { ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); ViReal64 voltage {}; auto status = library_->CalGetDDSStartPulsePhaseVoltage(vi, &voltage); - response->set_status(status); - if (status_ok(status)) { - response->set_voltage(voltage); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_voltage(voltage); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -1528,10 +1664,11 @@ namespace nisync_grpc { ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); ViReal64 phase {}; auto status = library_->CalGetDDSInitialPhase(vi, &phase); - response->set_status(status); - if (status_ok(status)) { - response->set_phase(phase); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_phase(phase); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -1559,10 +1696,11 @@ namespace nisync_grpc { const std::string& grpc_device_session_name = request->session_name(); auto cleanup_lambda = [&] (ViSession id) { library_->Close(id); }; int status = session_repository_->add_session(grpc_device_session_name, init_lambda, cleanup_lambda, session_id); - response->set_status(status); - if (status_ok(status)) { - response->mutable_vi()->set_id(session_id); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, 0); } + response->set_status(status); + response->mutable_vi()->set_id(session_id); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -1585,6 +1723,9 @@ namespace nisync_grpc { ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); ViInt32 action = request->action(); auto status = library_->CloseExtCal(vi, action); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1606,10 +1747,11 @@ namespace nisync_grpc { ViReal64 measured_voltage = request->measured_voltage(); ViReal64 old_voltage {}; auto status = library_->CalAdjustOscillatorVoltage(vi, measured_voltage, &old_voltage); - response->set_status(status); - if (status_ok(status)) { - response->set_old_voltage(old_voltage); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_old_voltage(old_voltage); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -1630,10 +1772,11 @@ namespace nisync_grpc { ViReal64 measured_voltage = request->measured_voltage(); ViReal64 old_voltage {}; auto status = library_->CalAdjustClk10PhaseVoltage(vi, measured_voltage, &old_voltage); - response->set_status(status); - if (status_ok(status)) { - response->set_old_voltage(old_voltage); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_old_voltage(old_voltage); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -1654,10 +1797,11 @@ namespace nisync_grpc { ViReal64 measured_voltage = request->measured_voltage(); ViReal64 old_voltage {}; auto status = library_->CalAdjustDDSStartPulsePhaseVoltage(vi, measured_voltage, &old_voltage); - response->set_status(status); - if (status_ok(status)) { - response->set_old_voltage(old_voltage); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_old_voltage(old_voltage); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -1678,10 +1822,11 @@ namespace nisync_grpc { ViReal64 measured_phase = request->measured_phase(); ViReal64 old_phase {}; auto status = library_->CalAdjustDDSInitialPhase(vi, measured_phase, &old_phase); - response->set_status(status); - if (status_ok(status)) { - response->set_old_phase(old_phase); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_old_phase(old_phase); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { diff --git a/generated/nisync/nisync_service.h b/generated/nisync/nisync_service.h index 6d1e215f3..2a55015fa 100644 --- a/generated/nisync/nisync_service.h +++ b/generated/nisync/nisync_service.h @@ -114,6 +114,7 @@ class NiSyncService final : public NiSync::Service { private: NiSyncLibraryInterface* library_; ResourceRepositorySharedPtr session_repository_; + ::grpc::Status ConvertApiErrorStatusForViSession(google::protobuf::int32 status, ViSession vi); NiSyncFeatureToggles feature_toggles_; }; diff --git a/generated/nitclk/nitclk_service.cpp b/generated/nitclk/nitclk_service.cpp index dca3088ed..916a4360c 100644 --- a/generated/nitclk/nitclk_service.cpp +++ b/generated/nitclk/nitclk_service.cpp @@ -61,6 +61,9 @@ namespace nitclk_grpc { std::back_inserter(sessions), [&](auto session) { return session_repository_->access_session(session.id(), session.name()); }); auto status = library_->ConfigureForHomogeneousTriggers(session_count, sessions.data()); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, 0); + } response->set_status(status); return ::grpc::Status::OK; } @@ -87,6 +90,9 @@ namespace nitclk_grpc { [&](auto session) { return session_repository_->access_session(session.id(), session.name()); }); ViReal64 min_time = request->min_time(); auto status = library_->FinishSyncPulseSenderSynchronize(session_count, sessions.data(), min_time); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, 0); + } response->set_status(status); return ::grpc::Status::OK; } @@ -109,10 +115,11 @@ namespace nitclk_grpc { ViAttr attribute_id = request->attribute_id(); ViReal64 value {}; auto status = library_->GetAttributeViReal64(session, channel_name, attribute_id, &value); - response->set_status(status); - if (status_ok(status)) { - response->set_value(value); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, session); } + response->set_status(status); + response->set_value(value); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -134,11 +141,12 @@ namespace nitclk_grpc { ViAttr attribute_id = request->attribute_id(); ViSession value {}; auto status = library_->GetAttributeViSession(session, channel_name, attribute_id, &value); - response->set_status(status); - if (status_ok(status)) { - auto session_id = session_repository_->resolve_session_id(value); - response->mutable_value()->set_id(session_id); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, session); } + response->set_status(status); + auto session_id = session_repository_->resolve_session_id(value); + response->mutable_value()->set_id(session_id); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -157,9 +165,8 @@ namespace nitclk_grpc { while (true) { auto status = library_->GetExtendedErrorInfo(nullptr, 0); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, 0); } ViUInt32 error_string_size = status; @@ -172,11 +179,12 @@ namespace nitclk_grpc { // buffer is now too small, try again continue; } - response->set_status(status); - if (status_ok(status)) { - response->set_error_string(error_string); - nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_error_string())); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, 0); } + response->set_status(status); + response->set_error_string(error_string); + nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_error_string())); return ::grpc::Status::OK; } } @@ -202,6 +210,9 @@ namespace nitclk_grpc { std::back_inserter(sessions), [&](auto session) { return session_repository_->access_session(session.id(), session.name()); }); auto status = library_->Initiate(session_count, sessions.data()); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, 0); + } response->set_status(status); return ::grpc::Status::OK; } @@ -228,10 +239,11 @@ namespace nitclk_grpc { [&](auto session) { return session_repository_->access_session(session.id(), session.name()); }); ViBoolean done {}; auto status = library_->IsDone(session_count, sessions.data(), &done); - response->set_status(status); - if (status_ok(status)) { - response->set_done(done); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, 0); } + response->set_status(status); + response->set_done(done); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -253,6 +265,9 @@ namespace nitclk_grpc { ViAttr attribute_id = request->attribute_id(); ViReal64 value = request->value_raw(); auto status = library_->SetAttributeViReal64(session, channel_name, attribute_id, value); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, session); + } response->set_status(status); return ::grpc::Status::OK; } @@ -276,6 +291,9 @@ namespace nitclk_grpc { auto value_grpc_session = request->value(); ViSession value = session_repository_->access_session(value_grpc_session.id(), value_grpc_session.name()); auto status = library_->SetAttributeViSession(session, channel_name, attribute_id, value); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, session); + } response->set_status(status); return ::grpc::Status::OK; } @@ -298,6 +316,9 @@ namespace nitclk_grpc { ViAttr attribute_id = request->attribute_id(); auto value = request->value_raw().c_str(); auto status = library_->SetAttributeViString(session, channel_name, attribute_id, value); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, session); + } response->set_status(status); return ::grpc::Status::OK; } @@ -324,6 +345,9 @@ namespace nitclk_grpc { [&](auto session) { return session_repository_->access_session(session.id(), session.name()); }); ViReal64 min_time = request->min_time(); auto status = library_->SetupForSyncPulseSenderSynchronize(session_count, sessions.data(), min_time); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, 0); + } response->set_status(status); return ::grpc::Status::OK; } @@ -350,6 +374,9 @@ namespace nitclk_grpc { [&](auto session) { return session_repository_->access_session(session.id(), session.name()); }); ViReal64 min_tclk_period = request->min_tclk_period(); auto status = library_->Synchronize(session_count, sessions.data(), min_tclk_period); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, 0); + } response->set_status(status); return ::grpc::Status::OK; } @@ -376,6 +403,9 @@ namespace nitclk_grpc { [&](auto session) { return session_repository_->access_session(session.id(), session.name()); }); ViReal64 min_time = request->min_time(); auto status = library_->SynchronizeToSyncPulseSender(session_count, sessions.data(), min_time); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, 0); + } response->set_status(status); return ::grpc::Status::OK; } @@ -402,6 +432,9 @@ namespace nitclk_grpc { [&](auto session) { return session_repository_->access_session(session.id(), session.name()); }); ViReal64 timeout = request->timeout(); auto status = library_->WaitUntilDone(session_count, sessions.data(), timeout); + if (!status_ok(status)) { + return ConvertApiErrorStatusForViSession(status, 0); + } response->set_status(status); return ::grpc::Status::OK; } diff --git a/generated/nitclk/nitclk_service.h b/generated/nitclk/nitclk_service.h index 26617699e..d77e5a5ec 100644 --- a/generated/nitclk/nitclk_service.h +++ b/generated/nitclk/nitclk_service.h @@ -59,6 +59,7 @@ class NiTClkService final : public NiTClk::Service { private: NiTClkLibraryInterface* library_; ResourceRepositorySharedPtr session_repository_; + ::grpc::Status ConvertApiErrorStatusForViSession(google::protobuf::int32 status, ViSession session_number); NiTClkFeatureToggles feature_toggles_; }; diff --git a/generated/nixnet/nixnet_service.cpp b/generated/nixnet/nixnet_service.cpp index 770f5ffff..200c34538 100644 --- a/generated/nixnet/nixnet_service.cpp +++ b/generated/nixnet/nixnet_service.cpp @@ -71,6 +71,9 @@ namespace nixnet_grpc { } auto status = library_->Blink(interface_ref, modifier); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNxSessionRef_t(status, interface_ref); + } response->set_status(status); return ::grpc::Status::OK; } @@ -91,6 +94,9 @@ namespace nixnet_grpc { nxSessionRef_t session = session_repository_->access_session(session_grpc_session.id(), session_grpc_session.name()); session_repository_->remove_session(session_grpc_session.id(), session_grpc_session.name()); auto status = library_->Clear(session); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNxSessionRef_t(status, session); + } response->set_status(status); return ::grpc::Status::OK; } @@ -150,6 +156,9 @@ namespace nixnet_grpc { } auto status = library_->ConnectTerminals(session, source, destination); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNxSessionRef_t(status, session); + } response->set_status(status); return ::grpc::Status::OK; } @@ -192,10 +201,11 @@ namespace nixnet_grpc { std::vector buffer(size_of_buffer, u8()); u32 number_of_bytes_returned {}; auto status = library_->ConvertByteArrayToFramesSinglePoint(session, value_buffer, size_of_value_buffer, buffer.data(), size_of_buffer, &number_of_bytes_returned); - response->set_status(status); - if (status_ok(status)) { - convert_to_grpc(buffer, response->mutable_buffer(), number_of_bytes_returned, protocol, enetflags_output_map_); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNxSessionRef_t(status, session); } + response->set_status(status); + convert_to_grpc(buffer, response->mutable_buffer(), number_of_bytes_returned, protocol, enetflags_output_map_); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -218,10 +228,11 @@ namespace nixnet_grpc { u32 size_of_value_buffer = request->size_of_value_buffer(); std::string value_buffer(size_of_value_buffer, '\0'); auto status = library_->ConvertFramesToByteArraySinglePoint(session, frame_buffer, number_of_bytes_for_frames, (u8*)value_buffer.data(), size_of_value_buffer); - response->set_status(status); - if (status_ok(status)) { - response->set_value_buffer(value_buffer); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNxSessionRef_t(status, session); } + response->set_status(status); + response->set_value_buffer(value_buffer); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -249,9 +260,10 @@ namespace nixnet_grpc { response->mutable_timestamp_buffer()->Resize(number_of_signals, 0); nxTimestamp100ns_t* timestamp_buffer = reinterpret_cast(response->mutable_timestamp_buffer()->mutable_data()); auto status = library_->ConvertFramesToSignalsSinglePoint(session, frame_buffer, number_of_bytes_for_frames, value_buffer, size_of_value_buffer, timestamp_buffer, size_of_timestamp_buffer); - response->set_status(status); - if (status_ok(status)) { + if (!status_ok(status)) { + return ConvertApiErrorStatusForNxSessionRef_t(status, session); } + response->set_status(status); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -293,10 +305,11 @@ namespace nixnet_grpc { std::vector buffer(size_of_buffer, u8()); u32 number_of_bytes_returned {}; auto status = library_->ConvertSignalsToFramesSinglePoint(session, value_buffer, size_of_value_buffer, buffer.data(), size_of_buffer, &number_of_bytes_returned); - response->set_status(status); - if (status_ok(status)) { - convert_to_grpc(buffer, response->mutable_buffer(), number_of_bytes_returned, protocol, enetflags_output_map_); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNxSessionRef_t(status, session); } + response->set_status(status); + convert_to_grpc(buffer, response->mutable_buffer(), number_of_bytes_returned, protocol, enetflags_output_map_); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -315,10 +328,11 @@ namespace nixnet_grpc { nxTimestamp100ns_t from_timestamp_100ns = request->from_timestamp_100ns(); nxTimestamp1ns_t to_timestamp_1ns {}; auto status = library_->ConvertTimestamp100nsTo1ns(from_timestamp_100ns, &to_timestamp_1ns); - response->set_status(status); - if (status_ok(status)) { - response->set_to_timestamp_1ns(to_timestamp_1ns); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNxSessionRef_t(status, 0); } + response->set_status(status); + response->set_to_timestamp_1ns(to_timestamp_1ns); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -337,10 +351,11 @@ namespace nixnet_grpc { nxTimestamp1ns_t from_timestamp_1ns = request->from_timestamp_1ns(); nxTimestamp100ns_t to_timestamp_100ns {}; auto status = library_->ConvertTimestamp1nsTo100ns(from_timestamp_1ns, &to_timestamp_100ns); - response->set_status(status); - if (status_ok(status)) { - response->set_to_timestamp_100ns(to_timestamp_100ns); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNxSessionRef_t(status, 0); } + response->set_status(status); + response->set_to_timestamp_100ns(to_timestamp_100ns); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -386,10 +401,11 @@ namespace nixnet_grpc { const std::string& grpc_device_session_name = request->session_name(); auto cleanup_lambda = [&] (nxSessionRef_t id) { library_->Clear(id); }; int status = session_repository_->add_session(grpc_device_session_name, init_lambda, cleanup_lambda, session_id); - response->set_status(status); - if (status_ok(status)) { - response->mutable_session()->set_id(session_id); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNxSessionRef_t(status, 0); } + response->set_status(status); + response->mutable_session()->set_id(session_id); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -443,10 +459,11 @@ namespace nixnet_grpc { const std::string& grpc_device_session_name = request->session_name(); auto cleanup_lambda = [&] (nxSessionRef_t id) { library_->Clear(id); }; int status = session_repository_->add_session(grpc_device_session_name, init_lambda, cleanup_lambda, session_id); - response->set_status(status); - if (status_ok(status)) { - response->mutable_session()->set_id(session_id); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNxSessionRef_t(status, 0); } + response->set_status(status); + response->mutable_session()->set_id(session_id); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -469,6 +486,9 @@ namespace nixnet_grpc { auto database_filepath = request->database_filepath().c_str(); u32 default_baud_rate = request->default_baud_rate(); auto status = library_->DbAddAlias(database_alias, database_filepath, default_baud_rate); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNxSessionRef_t(status, 0); + } response->set_status(status); return ::grpc::Status::OK; } @@ -489,6 +509,9 @@ namespace nixnet_grpc { auto database_filepath = request->database_filepath().c_str(); u64 default_baud_rate = request->default_baud_rate(); auto status = library_->DbAddAlias64(database_alias, database_filepath, default_baud_rate); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNxSessionRef_t(status, 0); + } response->set_status(status); return ::grpc::Status::OK; } @@ -510,6 +533,9 @@ namespace nixnet_grpc { u32 close_all_refs = request->close_all_refs(); nx_database_ref_t_resource_repository_->remove_session(database_grpc_session.id(), database_grpc_session.name()); auto status = library_->DbCloseDatabase(database, close_all_refs); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNxDatabaseRef_t(status, database); + } response->set_status(status); return ::grpc::Status::OK; } @@ -566,6 +592,9 @@ namespace nixnet_grpc { nxDatabaseRef_t db_object = nx_database_ref_t_resource_repository_->access_session(db_object_grpc_session.id(), db_object_grpc_session.name()); nx_database_ref_t_resource_repository_->remove_session(db_object_grpc_session.id(), db_object_grpc_session.name()); auto status = library_->DbDeleteObject(db_object); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNxDatabaseRef_t(status, db_object); + } response->set_status(status); return ::grpc::Status::OK; } @@ -587,10 +616,11 @@ namespace nixnet_grpc { u32 wait_for_complete = request->wait_for_complete(); u32 percent_complete {}; auto status = library_->DbDeploy(ip_address, database_alias, wait_for_complete, &percent_complete); - response->set_status(status); - if (status_ok(status)) { - response->set_percent_complete(percent_complete); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNxSessionRef_t(status, 0); } + response->set_status(status); + response->set_percent_complete(percent_complete); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -663,10 +693,11 @@ namespace nixnet_grpc { auto attribute_name = request->attribute_name().c_str(); u32 attribute_text_size {}; auto status = library_->DbGetDBCAttributeSize(db_object, mode, attribute_name, &attribute_text_size); - response->set_status(status); - if (status_ok(status)) { - response->set_attribute_text_size(attribute_text_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNxDatabaseRef_t(status, db_object); } + response->set_status(status); + response->set_attribute_text_size(attribute_text_size); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -686,11 +717,12 @@ namespace nixnet_grpc { u32 sizeof_alias_buffer {}; u32 sizeof_filepath_buffer {}; auto status = library_->DbGetDatabaseListSizes(ip_address, &sizeof_alias_buffer, &sizeof_filepath_buffer); - response->set_status(status); - if (status_ok(status)) { - response->set_sizeof_alias_buffer(sizeof_alias_buffer); - response->set_sizeof_filepath_buffer(sizeof_filepath_buffer); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNxSessionRef_t(status, 0); } + response->set_status(status); + response->set_sizeof_alias_buffer(sizeof_alias_buffer); + response->set_sizeof_filepath_buffer(sizeof_filepath_buffer); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -726,10 +758,11 @@ namespace nixnet_grpc { u32 property_size {}; auto status = library_->DbGetPropertySize(db_object, property_id, &property_size); - response->set_status(status); - if (status_ok(status)) { - response->set_property_size(property_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNxDatabaseRef_t(status, db_object); } + response->set_status(status); + response->set_property_size(property_size); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -769,10 +802,11 @@ namespace nixnet_grpc { u32 wait_for_complete = request->wait_for_complete(); u32 percent_complete {}; auto status = library_->DbMerge(target_cluster, source_obj, copy_mode, prefix, wait_for_complete, &percent_complete); - response->set_status(status); - if (status_ok(status)) { - response->set_percent_complete(percent_complete); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNxDatabaseRef_t(status, target_cluster); } + response->set_status(status); + response->set_percent_complete(percent_complete); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -799,10 +833,11 @@ namespace nixnet_grpc { const std::string& grpc_device_session_name = request->session_name(); auto cleanup_lambda = [&] (nxDatabaseRef_t id) { library_->DbCloseDatabase(id, false); }; int status = nx_database_ref_t_resource_repository_->add_session(grpc_device_session_name, init_lambda, cleanup_lambda, session_id); - response->set_status(status); - if (status_ok(status)) { - response->mutable_database()->set_id(session_id); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNxSessionRef_t(status, 0); } + response->set_status(status); + response->mutable_database()->set_id(session_id); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -823,6 +858,9 @@ namespace nixnet_grpc { try { auto database_alias = request->database_alias().c_str(); auto status = library_->DbRemoveAlias(database_alias); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNxSessionRef_t(status, 0); + } response->set_status(status); return ::grpc::Status::OK; } @@ -843,6 +881,9 @@ namespace nixnet_grpc { nxDatabaseRef_t database = nx_database_ref_t_resource_repository_->access_session(database_grpc_session.id(), database_grpc_session.name()); auto db_filepath = request->db_filepath().c_str(); auto status = library_->DbSaveDatabase(database, db_filepath); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNxDatabaseRef_t(status, database); + } response->set_status(status); return ::grpc::Status::OK; } @@ -862,6 +903,9 @@ namespace nixnet_grpc { auto ip_address = request->ip_address().c_str(); auto database_alias = request->database_alias().c_str(); auto status = library_->DbUndeploy(ip_address, database_alias); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNxSessionRef_t(status, 0); + } response->set_status(status); return ::grpc::Status::OK; } @@ -921,6 +965,9 @@ namespace nixnet_grpc { } auto status = library_->DisconnectTerminals(session, source, destination); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNxSessionRef_t(status, session); + } response->set_status(status); return ::grpc::Status::OK; } @@ -940,6 +987,9 @@ namespace nixnet_grpc { auto session_grpc_session = request->session(); nxSessionRef_t session = session_repository_->access_session(session_grpc_session.id(), session_grpc_session.name()); auto status = library_->Flush(session); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNxSessionRef_t(status, session); + } response->set_status(status); return ::grpc::Status::OK; } @@ -976,6 +1026,9 @@ namespace nixnet_grpc { } auto status = library_->FutureTimeTrigger(session, when, timescale); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNxSessionRef_t(status, session); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1012,10 +1065,11 @@ namespace nixnet_grpc { u32 property_size {}; auto status = library_->GetPropertySize(session, property_id, &property_size); - response->set_status(status); - if (status_ok(status)) { - response->set_property_size(property_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNxSessionRef_t(status, session); } + response->set_status(status); + response->set_property_size(property_size); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -1052,10 +1106,11 @@ namespace nixnet_grpc { u32 property_size {}; auto status = library_->GetSubPropertySize(session, active_index, property_id, &property_size); - response->set_status(status); - if (status_ok(status)) { - response->set_property_size(property_size); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNxSessionRef_t(status, session); } + response->set_status(status); + response->set_property_size(property_size); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -1111,10 +1166,11 @@ namespace nixnet_grpc { std::vector buffer(size_of_buffer, u8()); u32 number_of_bytes_returned {}; auto status = library_->ReadFrame(session, buffer.data(), size_of_buffer, timeout, &number_of_bytes_returned); - response->set_status(status); - if (status_ok(status)) { - convert_to_grpc(buffer, response->mutable_buffer(), number_of_bytes_returned, protocol, enetflags_output_map_); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNxSessionRef_t(status, session); } + response->set_status(status); + convert_to_grpc(buffer, response->mutable_buffer(), number_of_bytes_returned, protocol, enetflags_output_map_); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -1140,9 +1196,10 @@ namespace nixnet_grpc { response->mutable_timestamp_buffer()->Resize(number_of_signals, 0); nxTimestamp100ns_t* timestamp_buffer = reinterpret_cast(response->mutable_timestamp_buffer()->mutable_data()); auto status = library_->ReadSignalSinglePoint(session, value_buffer, size_of_value_buffer, timestamp_buffer, size_of_timestamp_buffer); - response->set_status(status); - if (status_ok(status)) { + if (!status_ok(status)) { + return ConvertApiErrorStatusForNxSessionRef_t(status, session); } + response->set_status(status); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -1184,12 +1241,13 @@ namespace nixnet_grpc { std::vector value_buffer(samples_per_signal * number_of_signals, f64()); u32 number_of_values_returned {}; auto status = library_->ReadSignalWaveform(session, timeout, &start_time, &delta_time, value_buffer.data(), size_of_value_buffer, &number_of_values_returned); - response->set_status(status); - if (status_ok(status)) { - response->set_start_time(start_time); - response->set_delta_time(delta_time); - convert_to_grpc(value_buffer, response->mutable_value_buffer(), number_of_values_returned, number_of_signals); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNxSessionRef_t(status, session); } + response->set_status(status); + response->set_start_time(start_time); + response->set_delta_time(delta_time); + convert_to_grpc(value_buffer, response->mutable_value_buffer(), number_of_values_returned, number_of_signals); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -1220,9 +1278,10 @@ namespace nixnet_grpc { response->mutable_num_pairs_buffer()->Resize(number_of_signals, 0); u32* num_pairs_buffer = response->mutable_num_pairs_buffer()->mutable_data(); auto status = library_->ReadSignalXY(session, &time_limit, value_buffer, size_of_value_buffer, timestamp_buffer, size_of_timestamp_buffer, num_pairs_buffer, size_of_num_pairs_buffer); - response->set_status(status); - if (status_ok(status)) { + if (!status_ok(status)) { + return ConvertApiErrorStatusForNxSessionRef_t(status, session); } + response->set_status(status); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -1259,10 +1318,11 @@ namespace nixnet_grpc { auto state_size = sizeof(nxTimeLocalNetwork_t); _nxTimeLocalNetwork_t state_value {}; auto status = library_->ReadStateTimeTrigger(session, timeout, state_size, &state_value); - response->set_status(status); - if (status_ok(status)) { - convert_to_grpc(state_value, response->mutable_state_value()); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNxSessionRef_t(status, session); } + response->set_status(status); + convert_to_grpc(state_value, response->mutable_state_value()); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -1297,6 +1357,9 @@ namespace nixnet_grpc { } auto status = library_->Start(session, scope); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNxSessionRef_t(status, session); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1318,11 +1381,12 @@ namespace nixnet_grpc { std::string status_description(2048 - 1, '\0'); library_->StatusToString(status_id, sizeof_string, (char*)status_description.data()); auto status = 0; - response->set_status(status); - if (status_ok(status)) { - response->set_status_description(status_description); - nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_status_description())); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNxSessionRef_t(status, 0); } + response->set_status(status); + response->set_status_description(status_description); + nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_status_description())); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -1357,6 +1421,9 @@ namespace nixnet_grpc { } auto status = library_->Stop(session, scope); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNxSessionRef_t(status, session); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1377,6 +1444,9 @@ namespace nixnet_grpc { nxSessionRef_t system = session_repository_->access_session(system_grpc_session.id(), system_grpc_session.name()); session_repository_->remove_session(system_grpc_session.id(), system_grpc_session.name()); auto status = library_->SystemClose(system); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNxSessionRef_t(status, system); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1403,10 +1473,11 @@ namespace nixnet_grpc { const std::string& grpc_device_session_name = request->session_name(); auto cleanup_lambda = [&] (nxSessionRef_t id) { library_->SystemClose(id); }; int status = session_repository_->add_session(grpc_device_session_name, init_lambda, cleanup_lambda, session_id); - response->set_status(status); - if (status_ok(status)) { - response->mutable_system()->set_id(session_id); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNxSessionRef_t(status, 0); } + response->set_status(status); + response->mutable_system()->set_id(session_id); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -1447,10 +1518,11 @@ namespace nixnet_grpc { f64 timeout = request->timeout(); u32 param_out {}; auto status = library_->Wait(session, condition, param_in, timeout, ¶m_out); - response->set_status(status); - if (status_ok(status)) { - response->set_param_out(param_out); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNxSessionRef_t(status, session); } + response->set_status(status); + response->set_param_out(param_out); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -1487,6 +1559,9 @@ namespace nixnet_grpc { } auto status = library_->WriteFrame(session, buffer, number_of_bytes_for_frames, timeout); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNxSessionRef_t(status, session); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1508,6 +1583,9 @@ namespace nixnet_grpc { auto value_buffer = const_cast(request->value_buffer().data()); u32 size_of_value_buffer = static_cast(request->value_buffer().size() * sizeof(f64)); auto status = library_->WriteSignalSinglePoint(session, value_buffer, size_of_value_buffer); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNxSessionRef_t(status, session); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1545,6 +1623,9 @@ namespace nixnet_grpc { auto value_buffer = const_cast(request->value_buffer().data()); u32 size_of_value_buffer = static_cast(request->value_buffer().size() * sizeof(f64)); auto status = library_->WriteSignalWaveform(session, timeout, value_buffer, size_of_value_buffer); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNxSessionRef_t(status, session); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1586,6 +1667,9 @@ namespace nixnet_grpc { auto num_pairs_buffer = const_cast(request->num_pairs_buffer().data()); u32 size_of_num_pairs_buffer = static_cast(request->num_pairs_buffer().size() * sizeof(u32)); auto status = library_->WriteSignalXY(session, timeout, value_buffer, size_of_value_buffer, timestamp_buffer, size_of_timestamp_buffer, num_pairs_buffer, size_of_num_pairs_buffer); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNxSessionRef_t(status, session); + } response->set_status(status); return ::grpc::Status::OK; } diff --git a/generated/nixnet/nixnet_service.h b/generated/nixnet/nixnet_service.h index 8b4dbfc75..7b01c9a51 100644 --- a/generated/nixnet/nixnet_service.h +++ b/generated/nixnet/nixnet_service.h @@ -105,6 +105,8 @@ class NiXnetService final : public NiXnet::Service { NiXnetLibraryInterface* library_; ResourceRepositorySharedPtr session_repository_; nxDatabaseRef_tResourceRepositorySharedPtr nx_database_ref_t_resource_repository_; + ::grpc::Status ConvertApiErrorStatusForNxSessionRef_t(google::protobuf::int32 status, nxSessionRef_t session); + ::grpc::Status ConvertApiErrorStatusForNxDatabaseRef_t(google::protobuf::int32 status, nxDatabaseRef_t session); std::map dbpropertyvalue_input_map_ { {0, 0},{1, 0},{2, 1},{3, 2},{4, 4294967294},{5, 0},{6, 1},{7, 2},{8, 3},{9, 0},{10, 1},{11, 1},{12, 2},{13, 3},{14, 4},{15, 0},{16, 1},{17, 2},{18, 0},{19, 1},{20, 0},{21, 1},{22, 2},{23, 3},{24, 2},{25, 3},{26, 4},{27, 5},{28, 6},{29, 0},{30, 1},{31, 2},{32, 0},{33, 1},{34, 2},{35, 3}, }; std::map dbpropertyvalue_output_map_ { {0, 0},{0, 1},{1, 2},{2, 3},{4294967294, 4},{0, 5},{1, 6},{2, 7},{3, 8},{0, 9},{1, 10},{1, 11},{2, 12},{3, 13},{4, 14},{0, 15},{1, 16},{2, 17},{0, 18},{1, 19},{0, 20},{1, 21},{2, 22},{3, 23},{2, 24},{3, 25},{4, 26},{5, 27},{6, 28},{0, 29},{1, 30},{2, 31},{0, 32},{1, 33},{2, 34},{3, 35}, }; std::map enetflags_input_map_ { {0, 0},{1, 2147483648},{2, 1073741824},{3, 8388608},{4, 65536}, }; diff --git a/generated/nixnetsocket/nixnetsocket_service.cpp b/generated/nixnetsocket/nixnetsocket_service.cpp index 08c768b2f..e0769f9f6 100644 --- a/generated/nixnetsocket/nixnetsocket_service.cpp +++ b/generated/nixnetsocket/nixnetsocket_service.cpp @@ -67,17 +67,12 @@ namespace nixnetsocket_grpc { const std::string& grpc_device_session_name = request->session_name(); auto cleanup_lambda = [&] (nxSOCKET id) { library_->Close(id); }; int status = session_repository_->add_session(grpc_device_session_name, init_lambda, cleanup_lambda, session_id); - response->set_status(status); - if (status_ok(status)) { - convert_to_grpc(addr, response->mutable_addr()); - response->mutable_socket()->set_id(session_id); - } - else { - const auto error_message = get_last_error_message(library_); - response->set_error_message(error_message); - const auto error_num = get_last_error_num(library_); - response->set_error_num(error_num); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNxSOCKET(status, socket); } + response->set_status(status); + convert_to_grpc(addr, response->mutable_addr()); + response->mutable_socket()->set_id(session_id); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -101,15 +96,10 @@ namespace nixnetsocket_grpc { auto name = convert_from_grpc(request->name()); auto namelen = name.size(); auto status = library_->Bind(socket, name, namelen); - response->set_status(status); - if (status_ok(status)) { - } - else { - const auto error_message = get_last_error_message(library_); - response->set_error_message(error_message); - const auto error_num = get_last_error_num(library_); - response->set_error_num(error_num); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNxSOCKET(status, socket); } + response->set_status(status); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -129,15 +119,10 @@ namespace nixnetsocket_grpc { nxSOCKET socket = session_repository_->access_session(socket_grpc_session.id(), socket_grpc_session.name()); session_repository_->remove_session(socket_grpc_session.id(), socket_grpc_session.name()); auto status = library_->Close(socket); - response->set_status(status); - if (status_ok(status)) { - } - else { - const auto error_message = get_last_error_message(library_); - response->set_error_message(error_message); - const auto error_num = get_last_error_num(library_); - response->set_error_num(error_num); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNxSOCKET(status, socket); } + response->set_status(status); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -158,15 +143,10 @@ namespace nixnetsocket_grpc { auto name = convert_from_grpc(request->name()); auto namelen = name.size(); auto status = library_->Connect(socket, name, namelen); - response->set_status(status); - if (status_ok(status)) { - } - else { - const auto error_message = get_last_error_message(library_); - response->set_error_message(error_message); - const auto error_num = get_last_error_num(library_); - response->set_error_num(error_num); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNxSOCKET(status, socket); } + response->set_status(status); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -187,16 +167,11 @@ namespace nixnetsocket_grpc { auto set = convert_from_grpc(request->set(), session_repository_); auto is_set = library_->FdIsSet(fd, set); auto status = 0; - response->set_status(status); - if (status_ok(status)) { - response->set_is_set(is_set); - } - else { - const auto error_message = get_last_error_message(library_); - response->set_error_message(error_message); - const auto error_num = get_last_error_num(library_); - response->set_error_num(error_num); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNxSOCKET(status, fd); } + response->set_status(status); + response->set_is_set(is_set); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -221,16 +196,11 @@ namespace nixnetsocket_grpc { auto hints = convert_from_grpc(request->hints()); auto res = allocate_output_storage>(library_); auto status = library_->GetAddrInfo(stack_ref, node_api, service_api, hints, &res); - response->set_status(status); - if (status_ok(status)) { - convert_to_grpc(res, response->mutable_res()); - } - else { - const auto error_message = get_last_error_message(library_); - response->set_error_message(error_message); - const auto error_num = get_last_error_num(library_); - response->set_error_num(error_num); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNxIpStackRef_t(status, stack_ref); } + response->set_status(status); + convert_to_grpc(res, response->mutable_res()); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -265,19 +235,14 @@ namespace nixnetsocket_grpc { serv.resize(servlen - 1); } auto status = library_->GetNameInfo(stack_ref, addr, addrlen, (char*)host.data(), hostlen, (char*)serv.data(), servlen, flags); - response->set_status(status); - if (status_ok(status)) { - response->set_host(host); - nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_host())); - response->set_serv(serv); - nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_serv())); - } - else { - const auto error_message = get_last_error_message(library_); - response->set_error_message(error_message); - const auto error_num = get_last_error_num(library_); - response->set_error_num(error_num); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNxIpStackRef_t(status, stack_ref); } + response->set_status(status); + response->set_host(host); + nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_host())); + response->set_serv(serv); + nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_serv())); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -298,16 +263,11 @@ namespace nixnetsocket_grpc { auto addr = allocate_output_storage(); auto addrlen = static_cast(sizeof(addr.storage)); auto status = library_->GetPeerName(socket, &addr, &addrlen); - response->set_status(status); - if (status_ok(status)) { - convert_to_grpc(addr, response->mutable_addr()); - } - else { - const auto error_message = get_last_error_message(library_); - response->set_error_message(error_message); - const auto error_num = get_last_error_num(library_); - response->set_error_num(error_num); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNxSOCKET(status, socket); } + response->set_status(status); + convert_to_grpc(addr, response->mutable_addr()); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -328,16 +288,11 @@ namespace nixnetsocket_grpc { auto addr = allocate_output_storage(); auto addrlen = static_cast(sizeof(addr.storage)); auto status = library_->GetSockName(socket, &addr, &addrlen); - response->set_status(status); - if (status_ok(status)) { - convert_to_grpc(addr, response->mutable_addr()); - } - else { - const auto error_message = get_last_error_message(library_); - response->set_error_message(error_message); - const auto error_num = get_last_error_num(library_); - response->set_error_num(error_num); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNxSOCKET(status, socket); } + response->set_status(status); + convert_to_grpc(addr, response->mutable_addr()); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -390,16 +345,11 @@ namespace nixnetsocket_grpc { auto optval = allocate_output_storage(library_, optname); auto optlen = optval.size(socket, level); auto status = library_->GetSockOpt(socket, level, optname, optval.data(), &optlen); - response->set_status(status); - if (status_ok(status)) { - convert_to_grpc(optval, response->mutable_optval()); - } - else { - const auto error_message = get_last_error_message(library_); - response->set_error_message(error_message); - const auto error_num = get_last_error_num(library_); - response->set_error_num(error_num); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNxSOCKET(status, socket); } + response->set_status(status); + convert_to_grpc(optval, response->mutable_optval()); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -420,16 +370,11 @@ namespace nixnetsocket_grpc { auto cp = request->cp().c_str(); auto addr = library_->InetAddr(stack_ref, cp); auto status = addr == -1 ? -1 : 0; - response->set_status(status); - if (status_ok(status)) { - response->set_addr(addr); - } - else { - const auto error_message = get_last_error_message(library_); - response->set_error_message(error_message); - const auto error_num = get_last_error_num(library_); - response->set_error_num(error_num); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNxIpStackRef_t(status, stack_ref); } + response->set_status(status); + response->set_addr(addr); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -450,16 +395,11 @@ namespace nixnetsocket_grpc { auto cp = request->cp().c_str(); auto name = allocate_output_storage(); auto status = library_->InetAToN(stack_ref, cp, &name); - response->set_status(status); - if (status_ok(status)) { - convert_to_grpc(name, response->mutable_name()); - } - else { - const auto error_message = get_last_error_message(library_); - response->set_error_message(error_message); - const auto error_num = get_last_error_num(library_); - response->set_error_num(error_num); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNxIpStackRef_t(status, stack_ref); } + response->set_status(status); + convert_to_grpc(name, response->mutable_name()); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -480,17 +420,12 @@ namespace nixnetsocket_grpc { auto in_addr = convert_from_grpc(request->in_addr()); auto address = library_->InetNToA(stack_ref, in_addr); auto status = address ? 0 : -1; - response->set_status(status); - if (status_ok(status)) { - response->set_address(address); - nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_address())); - } - else { - const auto error_message = get_last_error_message(library_); - response->set_error_message(error_message); - const auto error_num = get_last_error_num(library_); - response->set_error_num(error_num); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNxIpStackRef_t(status, stack_ref); } + response->set_status(status); + response->set_address(address); + nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_address())); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -514,17 +449,12 @@ namespace nixnetsocket_grpc { std::string dst(nxINET6_ADDRSTRLEN - 1, '\0'); auto address = library_->InetNToP(stack_ref, af, addr, (char*)dst.data(), size); auto status = address ? 0 : -1; - response->set_status(status); - if (status_ok(status)) { - response->set_address(address); - nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_address())); - } - else { - const auto error_message = get_last_error_message(library_); - response->set_error_message(error_message); - const auto error_num = get_last_error_num(library_); - response->set_error_num(error_num); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNxIpStackRef_t(status, stack_ref); } + response->set_status(status); + response->set_address(address); + nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_address())); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -561,16 +491,11 @@ namespace nixnetsocket_grpc { auto address = request->address().c_str(); auto addr = allocate_output_storage(af); auto status = library_->InetPToN(stack_ref, af, address, &addr); - response->set_status(status); - if (status_ok(status)) { - convert_to_grpc(addr, response->mutable_addr()); - } - else { - const auto error_message = get_last_error_message(library_); - response->set_error_message(error_message); - const auto error_num = get_last_error_num(library_); - response->set_error_num(error_num); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNxIpStackRef_t(status, stack_ref); } + response->set_status(status); + convert_to_grpc(addr, response->mutable_addr()); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -590,15 +515,10 @@ namespace nixnetsocket_grpc { nxIpStackRef_t stack_ref = nx_ip_stack_ref_t_resource_repository_->access_session(stack_ref_grpc_session.id(), stack_ref_grpc_session.name()); nx_ip_stack_ref_t_resource_repository_->remove_session(stack_ref_grpc_session.id(), stack_ref_grpc_session.name()); auto status = library_->IpStackClear(stack_ref); - response->set_status(status); - if (status_ok(status)) { - } - else { - const auto error_message = get_last_error_message(library_); - response->set_error_message(error_message); - const auto error_num = get_last_error_num(library_); - response->set_error_num(error_num); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNxIpStackRef_t(status, stack_ref); } + response->set_status(status); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -626,16 +546,11 @@ namespace nixnetsocket_grpc { const std::string& grpc_device_session_name = request->session_name(); auto cleanup_lambda = [&] (nxIpStackRef_t id) { library_->IpStackClear(id); }; int status = nx_ip_stack_ref_t_resource_repository_->add_session(grpc_device_session_name, init_lambda, cleanup_lambda, session_id); - response->set_status(status); - if (status_ok(status)) { - response->mutable_stack_ref()->set_id(session_id); - } - else { - const auto error_message = get_last_error_message(library_); - response->set_error_message(error_message); - const auto error_num = get_last_error_num(library_); - response->set_error_num(error_num); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNxSOCKET(status, 0); } + response->set_status(status); + response->mutable_stack_ref()->set_id(session_id); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -672,17 +587,12 @@ namespace nixnetsocket_grpc { auto info = allocate_output_storage(library_); auto status = library_->IpStackGetAllStacksInfoStr(format, (nixnetsocket_grpc::IpStackInfoString*)info.data()); - response->set_status(status); - if (status_ok(status)) { - convert_to_grpc(info, response->mutable_info()); - nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_info())); - } - else { - const auto error_message = get_last_error_message(library_); - response->set_error_message(error_message); - const auto error_num = get_last_error_num(library_); - response->set_error_num(error_num); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNxSOCKET(status, 0); } + response->set_status(status); + convert_to_grpc(info, response->mutable_info()); + nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_info())); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -703,16 +613,11 @@ namespace nixnetsocket_grpc { auto info_id = nxIPSTACK_INFO_ID; auto virtual_interfaces = allocate_output_storage>(library_); auto status = library_->IpStackGetInfo(stack_ref, info_id, &virtual_interfaces); - response->set_status(status); - if (status_ok(status)) { - convert_to_grpc(virtual_interfaces, response->mutable_virtual_interfaces()); - } - else { - const auto error_message = get_last_error_message(library_); - response->set_error_message(error_message); - const auto error_num = get_last_error_num(library_); - response->set_error_num(error_num); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNxIpStackRef_t(status, stack_ref); } + response->set_status(status); + convert_to_grpc(virtual_interfaces, response->mutable_virtual_interfaces()); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -739,16 +644,11 @@ namespace nixnetsocket_grpc { const std::string& grpc_device_session_name = request->session_name(); auto cleanup_lambda = [&] (nxIpStackRef_t id) { library_->IpStackClear(id); }; int status = nx_ip_stack_ref_t_resource_repository_->add_session(grpc_device_session_name, init_lambda, cleanup_lambda, session_id); - response->set_status(status); - if (status_ok(status)) { - response->mutable_stack_ref()->set_id(session_id); - } - else { - const auto error_message = get_last_error_message(library_); - response->set_error_message(error_message); - const auto error_num = get_last_error_num(library_); - response->set_error_num(error_num); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNxSOCKET(status, 0); } + response->set_status(status); + response->mutable_stack_ref()->set_id(session_id); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -772,15 +672,10 @@ namespace nixnetsocket_grpc { auto local_interface = request->local_interface().c_str(); int32_t timeout_ms = request->timeout_ms(); auto status = library_->IpStackWaitForInterface(stack_ref, local_interface, timeout_ms); - response->set_status(status); - if (status_ok(status)) { - } - else { - const auto error_message = get_last_error_message(library_); - response->set_error_message(error_message); - const auto error_num = get_last_error_num(library_); - response->set_error_num(error_num); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNxIpStackRef_t(status, stack_ref); } + response->set_status(status); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -800,15 +695,10 @@ namespace nixnetsocket_grpc { nxSOCKET socket = session_repository_->access_session(socket_grpc_session.id(), socket_grpc_session.name()); int32_t backlog = request->backlog(); auto status = library_->Listen(socket, backlog); - response->set_status(status); - if (status_ok(status)) { - } - else { - const auto error_message = get_last_error_message(library_); - response->set_error_message(error_message); - const auto error_num = get_last_error_num(library_); - response->set_error_num(error_num); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNxSOCKET(status, socket); } + response->set_status(status); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -833,16 +723,11 @@ namespace nixnetsocket_grpc { std::string data(size, '\0'); auto status = library_->Recv(socket, (char*)data.data(), size, flags); - response->set_status(status); - if (status_ok(status)) { - response->set_data(data); - } - else { - const auto error_message = get_last_error_message(library_); - response->set_error_message(error_message); - const auto error_num = get_last_error_num(library_); - response->set_error_num(error_num); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNxSOCKET(status, socket); } + response->set_status(status); + response->set_data(data); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -869,17 +754,12 @@ namespace nixnetsocket_grpc { auto from_addr = allocate_output_storage(); nxsocklen_t fromlen {}; auto status = library_->RecvFrom(socket, (char*)data.data(), size, flags, &from_addr, &fromlen); - response->set_status(status); - if (status_ok(status)) { - response->set_data(data); - convert_to_grpc(from_addr, response->mutable_from_addr()); - } - else { - const auto error_message = get_last_error_message(library_); - response->set_error_message(error_message); - const auto error_num = get_last_error_num(library_); - response->set_error_num(error_num); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNxSOCKET(status, socket); } + response->set_status(status); + response->set_data(data); + convert_to_grpc(from_addr, response->mutable_from_addr()); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -901,15 +781,10 @@ namespace nixnetsocket_grpc { auto exceptfds = convert_from_grpc(request->exceptfds(), session_repository_); auto timeout = convert_from_grpc(request->timeout()); auto status = library_->Select(nfds, readfds, writefds, exceptfds, timeout); - response->set_status(status); - if (status_ok(status)) { - } - else { - const auto error_message = get_last_error_message(library_); - response->set_error_message(error_message); - const auto error_num = get_last_error_num(library_); - response->set_error_num(error_num); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNxSOCKET(status, 0); } + response->set_status(status); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -931,15 +806,10 @@ namespace nixnetsocket_grpc { int32_t size = static_cast(request->data().size()); int32_t flags_raw = request->flags_raw(); auto status = library_->Send(socket, data, size, flags_raw); - response->set_status(status); - if (status_ok(status)) { - } - else { - const auto error_message = get_last_error_message(library_); - response->set_error_message(error_message); - const auto error_num = get_last_error_num(library_); - response->set_error_num(error_num); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNxSOCKET(status, socket); } + response->set_status(status); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -963,15 +833,10 @@ namespace nixnetsocket_grpc { auto to = convert_from_grpc(request->to()); auto tolen = to.size(); auto status = library_->SendTo(socket, data, size, flags_raw, to, tolen); - response->set_status(status); - if (status_ok(status)) { - } - else { - const auto error_message = get_last_error_message(library_); - response->set_error_message(error_message); - const auto error_num = get_last_error_num(library_); - response->set_error_num(error_num); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNxSOCKET(status, socket); } + response->set_status(status); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -1025,15 +890,10 @@ namespace nixnetsocket_grpc { auto optval = opt_data.data(); auto optlen = opt_data.size(); auto status = library_->SetSockOpt(socket, level, optname, optval, optlen); - response->set_status(status); - if (status_ok(status)) { - } - else { - const auto error_message = get_last_error_message(library_); - response->set_error_message(error_message); - const auto error_num = get_last_error_num(library_); - response->set_error_num(error_num); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNxSOCKET(status, socket); } + response->set_status(status); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -1068,15 +928,10 @@ namespace nixnetsocket_grpc { } auto status = library_->Shutdown(socket, how); - response->set_status(status); - if (status_ok(status)) { - } - else { - const auto error_message = get_last_error_message(library_); - response->set_error_message(error_message); - const auto error_num = get_last_error_num(library_); - response->set_error_num(error_num); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNxSOCKET(status, socket); } + response->set_status(status); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -1152,16 +1007,11 @@ namespace nixnetsocket_grpc { const std::string& grpc_device_session_name = request->session_name(); auto cleanup_lambda = [&] (nxSOCKET id) { library_->Close(id); }; int status = session_repository_->add_session(grpc_device_session_name, init_lambda, cleanup_lambda, session_id); - response->set_status(status); - if (status_ok(status)) { - response->mutable_socket()->set_id(session_id); - } - else { - const auto error_message = get_last_error_message(library_); - response->set_error_message(error_message); - const auto error_num = get_last_error_num(library_); - response->set_error_num(error_num); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNxIpStackRef_t(status, stack_ref); } + response->set_status(status); + response->mutable_socket()->set_id(session_id); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -1188,11 +1038,12 @@ namespace nixnetsocket_grpc { } auto error = library_->StrErrR(errnum, (char*)buf.data(), buf_len); auto status = error ? 0 : -1; - response->set_status(status); - if (status_ok(status)) { - response->set_error(error); - nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_error())); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNxSOCKET(status, 0); } + response->set_status(status); + response->set_error(error); + nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_error())); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { diff --git a/generated/nixnetsocket/nixnetsocket_service.h b/generated/nixnetsocket/nixnetsocket_service.h index 657796efa..02e557403 100644 --- a/generated/nixnetsocket/nixnetsocket_service.h +++ b/generated/nixnetsocket/nixnetsocket_service.h @@ -78,6 +78,8 @@ class NiXnetSocketService final : public NiXnetSocket::Service { NiXnetSocketLibraryInterface* library_; ResourceRepositorySharedPtr session_repository_; nxIpStackRef_tResourceRepositorySharedPtr nx_ip_stack_ref_t_resource_repository_; + ::grpc::Status ConvertApiErrorStatusForNxSOCKET(google::protobuf::int32 status, nxSOCKET socket); + ::grpc::Status ConvertApiErrorStatusForNxIpStackRef_t(google::protobuf::int32 status, nxIpStackRef_t socket); NiXnetSocketFeatureToggles feature_toggles_; }; diff --git a/source/codegen/metadata/nirfmxinstr/config.py b/source/codegen/metadata/nirfmxinstr/config.py index ea9cc880d..4943b66f6 100644 --- a/source/codegen/metadata/nirfmxinstr/config.py +++ b/source/codegen/metadata/nirfmxinstr/config.py @@ -60,5 +60,6 @@ 'metadata_version': '0.1', 'module_name': 'nirfmxinstr', 'session_class_description': 'An NI-RFmxInstr instrument handle', + 'session_handle_parameter_name': 'instrumentHandle', 'duplicate_resource_handles_allowed': True } diff --git a/source/codegen/metadata/nirfmxnr/config.py b/source/codegen/metadata/nirfmxnr/config.py index c0a64da3c..b8bcb0f0a 100644 --- a/source/codegen/metadata/nirfmxnr/config.py +++ b/source/codegen/metadata/nirfmxnr/config.py @@ -59,6 +59,7 @@ 'metadata_version': '0.1', 'module_name': 'nirfmxnr', 'session_class_description': 'An NI-RFmxNR instrument handle', + 'session_handle_parameter_name': 'instrumentHandle', 'duplicate_resource_handles_allowed': True } diff --git a/source/codegen/metadata/nirfmxspecan/config.py b/source/codegen/metadata/nirfmxspecan/config.py index 5568096a3..a362e8e4a 100644 --- a/source/codegen/metadata/nirfmxspecan/config.py +++ b/source/codegen/metadata/nirfmxspecan/config.py @@ -59,5 +59,6 @@ 'metadata_version': '0.1', 'module_name': 'nirfmxspecan', 'session_class_description': 'An NI-RFmxSpecAn instrument handle', + 'session_handle_parameter_name': 'instrumentHandle', 'duplicate_resource_handles_allowed': True } diff --git a/source/codegen/metadata/nirfmxspecan_restricted/config.py b/source/codegen/metadata/nirfmxspecan_restricted/config.py index 48200551e..10207cace 100644 --- a/source/codegen/metadata/nirfmxspecan_restricted/config.py +++ b/source/codegen/metadata/nirfmxspecan_restricted/config.py @@ -54,5 +54,6 @@ "metadata_version": "0.1", "module_name": "nirfmxspecan_restricted", "session_class_description": "An NI-RFmxSpecAn instrument handle", + 'session_handle_parameter_name': 'instrumentHandle', "duplicate_resource_handles_allowed": True, } diff --git a/source/codegen/templates/service.h.mako b/source/codegen/templates/service.h.mako index 4596c54e8..f35627f45 100644 --- a/source/codegen/templates/service.h.mako +++ b/source/codegen/templates/service.h.mako @@ -16,6 +16,7 @@ namespace_prefix = config["namespace_component"] + "_grpc::" custom_types = common_helpers.get_custom_types(config) (input_custom_types, output_custom_types) = common_helpers.get_input_and_output_custom_types(functions) resource_repository_deps = service_helpers.get_driver_shared_resource_repository_ptr_deps(config, functions) +resource_handle_types = service_helpers.get_resource_handle_types(config) async_functions = service_helpers.get_async_functions(functions) has_async_functions = any(async_functions) @@ -95,6 +96,12 @@ private: % for resource_handle_type in resource_repository_deps: ${resource_repository_deps[resource_handle_type].resource_repository_alias} ${resource_repository_deps[resource_handle_type].field_name}; % endfor +% for resource_handle_type in resource_handle_types: +<% + cpp_handle_type = resource_handle_type[0].upper() + resource_handle_type[1:] +%>\ + ::grpc::Status ConvertApiErrorStatusFor${cpp_handle_type}(google::protobuf::int32 status, ${resource_handle_type} ${config["session_handle_parameter_name"]}); +% endfor % if common_helpers.has_viboolean_array_param(functions): void Copy(const std::vector& input, google::protobuf::RepeatedField* output); % endif diff --git a/source/codegen/templates/service_helpers.mako b/source/codegen/templates/service_helpers.mako index c2977f8fc..3646e665c 100644 --- a/source/codegen/templates/service_helpers.mako +++ b/source/codegen/templates/service_helpers.mako @@ -37,7 +37,7 @@ ${call_library_method( const std::string& grpc_device_session_name = request->${session_field_name}(); auto cleanup_lambda = [&] (${resource_handle_type} id) { library_->${close_function_call}; }; int status = ${service_helpers.session_repository_field_name(session_output_param, config)}->add_session(grpc_device_session_name, init_lambda, cleanup_lambda, session_id); -${populate_response(function_data=function_data, output_parameters=output_parameters, init_method=True)}\ +${populate_response(function_data=function_data, parameters=parameters, init_method=True)}\ return ::grpc::Status::OK;\ @@ -87,10 +87,7 @@ ${call_library_method( arg_string=service_helpers.create_args_for_ivi_dance(parameters), indent_level=1) }\ - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; - } +${populate_error_check(function_data, parameters, indent_level=1)}\ ${size_param['type']} ${common_helpers.get_cpp_local_name(size_param)} = status; <%block filter="common_helpers.indent(1)">\ @@ -109,7 +106,7 @@ ${call_library_method( // buffer is now too small, try again continue; } -${populate_response(function_data=function_data, output_parameters=output_parameters, indent_level=1)}\ +${populate_response(function_data=function_data, parameters=parameters, indent_level=1)}\ return ::grpc::Status::OK; }\ @@ -132,10 +129,7 @@ ${call_library_method( arg_string=service_helpers.create_args_for_ivi_dance_with_a_twist(parameters), indent_level=1) }\ - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; - } +${populate_error_check(function_data, parameters, indent_level=1)}\ <%block filter="common_helpers.indent(1)">\ ${initialize_output_params(array_output_parameters)}\ \ @@ -155,7 +149,7 @@ ${call_library_method( // buffer is now too small, try again continue; } -${populate_response(function_data=function_data, output_parameters=output_parameters, indent_level=1)}\ +${populate_response(function_data=function_data, parameters=parameters, indent_level=1)}\ return ::grpc::Status::OK; }\ @@ -244,7 +238,7 @@ ${call_library_method( arg_string=service_helpers.create_args(parameters), library_lval=service_helpers.get_library_lval_for_potentially_umockable_function(config, parameters)) }\ -${populate_response(function_data=function_data, output_parameters=output_parameters)}\ +${populate_response(function_data=function_data, parameters=parameters)}\ return ::grpc::Status::OK;\ @@ -268,7 +262,7 @@ ${call_library_method( function_data=function_data, arg_string=service_helpers.create_args(parameters)) }\ -${populate_response(function_data=function_data, output_parameters=output_parameters)}\ +${populate_response(function_data=function_data, parameters=parameters)}\ return ::grpc::Status::OK;\ @@ -719,30 +713,42 @@ ${initialize_hardcoded_parameter(parameter)} ## Handles populating the response message after calling the driver API. -<%def name="populate_response(function_data, output_parameters, indent_level=0, init_method=False)">\ +<%def name="populate_response(function_data, parameters, indent_level=0, init_method=False)">\ <% + output_parameters = [p for p in parameters if common_helpers.is_output_parameter(p)] get_last_error_outputs = service_helpers.get_last_error_output_params(output_parameters) normal_outputs = [p for p in output_parameters if not p in get_last_error_outputs] %>\ <%block filter="common_helpers.indent(indent_level)">\ +${populate_error_check(function_data, parameters)}\ response->set_status(status); %if output_parameters: - if (status_ok(status)) { ${set_response_values(normal_outputs, init_method)}\ - } -% if any(get_last_error_outputs): - else { -% for get_last_error_output in get_last_error_outputs: +%endif +\ + + +## Handles populating the response message after calling the driver API. +<%def name="populate_error_check(function_data, parameters, indent_level=0)">\ <% - get_last_error_output_name = common_helpers.get_grpc_field_name(get_last_error_output) - get_last_error_method_name = get_last_error_output["get_last_error"] + config = data['config'] + input_parameters = [p for p in parameters if common_helpers.is_input_parameter(p)] + resource_handle_types = service_helpers.get_resource_handle_types(config) %>\ - const auto ${get_last_error_output_name} = ${get_last_error_method_name}(library_); - response->set_${get_last_error_output_name}(${get_last_error_output_name}); -% endfor +<%block filter="common_helpers.indent(indent_level)">\ +<% + session = 0 + handle_type = resource_handle_types[0] + for parameter in input_parameters: + if parameter['type'] in resource_handle_types: + session = common_helpers.get_cpp_local_name(parameter) + handle_type = parameter['type'] + break + cpp_handle_type = handle_type[0].upper() + handle_type[1:] +%>\ + if (!status_ok(status)) { + return ConvertApiErrorStatusFor${cpp_handle_type}(status, ${session}); } -% endif -%endif \ @@ -766,13 +772,13 @@ ${set_response_values(normal_outputs, init_method)}\ varargs_parameter_name = common_helpers.get_cpp_local_name(varargs_parameter) %>\ ## Note that this currently only supports one repeated output parameter. - for (int i = 0; i < ${parameter_name}Vector.size(); ++i) { + for (int i = 0; i < ${parameter_name}Vector.size(); ++i) { % if 'enum' in parameter: - response->add_${varargs_parameter_name}(static_cast<${parameter['enum']}>(${parameter_name}Vector[i])); + response->add_${varargs_parameter_name}(static_cast<${parameter['enum']}>(${parameter_name}Vector[i])); % else: - response->add_${varargs_parameter_name}(${parameter_name}Vector[i]); + response->add_${varargs_parameter_name}(${parameter_name}Vector[i]); % endif - } + } % elif common_helpers.is_repeated_varargs_parameter(parameter): #pass % elif common_helpers.is_enum(parameter) == True: <% @@ -789,21 +795,21 @@ ${set_response_values(normal_outputs, init_method)}\ use_checked_enum_conversion = parameter.get("use_checked_enum_conversion", False) %>\ % if has_mapped_enum: - auto ${mapped_enum_iterator_name} = ${map_name}.find(${parameter_name}); - if(${mapped_enum_iterator_name} != ${map_name}.end()) { - response->set_${field_name}_mapped(static_cast<${namespace_prefix}${mapped_enum_name}>(${mapped_enum_iterator_name}->second)); - } + auto ${mapped_enum_iterator_name} = ${map_name}.find(${parameter_name}); + if(${mapped_enum_iterator_name} != ${map_name}.end()) { + response->set_${field_name}_mapped(static_cast<${namespace_prefix}${mapped_enum_name}>(${mapped_enum_iterator_name}->second)); + } % endif % if has_unmapped_enum: % if use_checked_enum_conversion: - auto checked_convert_${parameter_name} = [](auto raw_value) { - bool raw_value_is_valid = ${namespace_prefix}${parameter["enum"]}_IsValid(raw_value); - auto valid_enum_value = raw_value_is_valid ? raw_value : 0; - return static_cast<${namespace_prefix}${parameter["enum"]}>(valid_enum_value); - }; + auto checked_convert_${parameter_name} = [](auto raw_value) { + bool raw_value_is_valid = ${namespace_prefix}${parameter["enum"]}_IsValid(raw_value); + auto valid_enum_value = raw_value_is_valid ? raw_value : 0; + return static_cast<${namespace_prefix}${parameter["enum"]}>(valid_enum_value); + }; % endif % if is_string: - CopyBytesToEnums(${parameter_name}, response->mutable_${field_name}()); + CopyBytesToEnums(${parameter_name}, response->mutable_${field_name}()); % elif uses_raw_output_as_read_buffer: <% raw_response_field = f"response->{field_name}_raw()" @@ -814,47 +820,47 @@ ${set_response_values(normal_outputs, init_method)}\ ${initialize_response_buffer(parameter_name=parameter_name, parameter=parameter)}\ ${copy_to_response_with_transform(source_buffer=raw_response_field, parameter_name=parameter_name, transform_x=convert_x_to_enum, size=common_helpers.get_size_expression(parameter))}\ % elif parameter['type'] == 'ViReal64': - if(${parameter_name} == (int)${parameter_name}) { - response->set_${field_name}(static_cast<${namespace_prefix}${parameter["enum"]}>(static_cast(${parameter_name}))); - } + if(${parameter_name} == (int)${parameter_name}) { + response->set_${field_name}(static_cast<${namespace_prefix}${parameter["enum"]}>(static_cast(${parameter_name}))); + } % elif parameter.get("use_checked_enum_conversion", False): - response->set_${field_name}(checked_convert_${parameter_name}(${parameter_name})); + response->set_${field_name}(checked_convert_${parameter_name}(${parameter_name})); % else: - response->set_${field_name}(static_cast<${namespace_prefix}${parameter["enum"]}>(${parameter_name})); + response->set_${field_name}(static_cast<${namespace_prefix}${parameter["enum"]}>(${parameter_name})); % endif % endif % if is_bitfield_as_enum_array: % for flag_value, flag_enum_name in service_helpers.get_bitfield_value_to_name_mapping(parameter, enums).items(): - if (${parameter_name} & ${hex(flag_value)}) - response->add_${field_name}_array(${flag_enum_name}); + if (${parameter_name} & ${hex(flag_value)}) + response->add_${field_name}_array(${flag_enum_name}); % endfor % endif % if not uses_raw_output_as_read_buffer: # Set data to raw, unless we *got* the data from raw. - response->set_${field_name}_raw(${parameter_name}); + response->set_${field_name}_raw(${parameter_name}); % endif % elif service_helpers.is_output_array_that_needs_coercion(parameter): ${initialize_response_buffer(parameter_name=parameter_name, parameter=parameter)}\ ${copy_to_response_with_transform(source_buffer=parameter_name, parameter_name=parameter_name, transform_x="x", size=common_helpers.get_size_expression(parameter))}\ % elif common_helpers.supports_standard_copy_conversion_routines(parameter): - convert_to_grpc(${str.join(", ", [f'{parameter_name}', f'response->mutable_{field_name}()'] + parameter.get("additional_arguments_to_copy_convert", []))}); + convert_to_grpc(${str.join(", ", [f'{parameter_name}', f'response->mutable_{field_name}()'] + parameter.get("additional_arguments_to_copy_convert", []))}); % elif common_helpers.is_string_arg(parameter): - response->set_${field_name}(${parameter_name}); + response->set_${field_name}(${parameter_name}); % elif parameter['grpc_type'] == 'nidevice_grpc.Session': % if not init_method: # Non-init methods need to resolve the session ID from the out param. - auto session_id = ${service_helpers.session_repository_field_name(parameter, config)}->resolve_session_id(${parameter_name}); + auto session_id = ${service_helpers.session_repository_field_name(parameter, config)}->resolve_session_id(${parameter_name}); % endif - response->mutable_${field_name}()->set_id(session_id); + response->mutable_${field_name}()->set_id(session_id); % elif common_helpers.is_array(parameter['type']): % if common_helpers.get_size_mechanism(parameter) == 'passed-in-by-ptr': ### size may have changed - response->mutable_${field_name}()->Resize(${common_helpers.get_size_expression(parameter)}, 0); + response->mutable_${field_name}()->Resize(${common_helpers.get_size_expression(parameter)}, 0); % endif ### pass: other array types don't need to copy. % else: - response->set_${field_name}(${parameter_name}); + response->set_${field_name}(${parameter_name}); % endif % if common_helpers.is_regular_string_arg(parameter): - nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_${field_name}())); + nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_${field_name}())); % endif ### Handle ivi-dance-with-a-twist resizing. % if common_helpers.is_ivi_dance_array_with_a_twist_param(parameter): @@ -862,22 +868,22 @@ ${copy_to_response_with_transform(source_buffer=parameter_name, parameter_name=p size = common_helpers.get_size_expression(parameter) %>\ % if common_helpers.is_regular_byte_array_arg(parameter): - response->mutable_${field_name}()->resize(${size}); + response->mutable_${field_name}()->resize(${size}); % elif common_helpers.is_regular_string_arg(parameter): ### pass: handled above with trim_trailing_nulls for all string outputs. % elif common_helpers.is_struct(parameter): ## RepeatedPtrField doesn't support Resize(), so use DeleteSubrange() ## to delete any extra elements. - { - auto shrunk_size = ${size}; - auto current_size = response->mutable_${field_name}()->size(); - if (shrunk_size != current_size) { - response->mutable_${field_name}()->DeleteSubrange(shrunk_size, current_size - shrunk_size); - } + { + auto shrunk_size = ${size}; + auto current_size = response->mutable_${field_name}()->size(); + if (shrunk_size != current_size) { + response->mutable_${field_name}()->DeleteSubrange(shrunk_size, current_size - shrunk_size); } + } % else: ## This code doesn't handle all parameter types (i.e., enums), see what initialize_output_params() does for that. - response->mutable_${field_name}()->Resize(${size}, 0); + response->mutable_${field_name}()->Resize(${size}, 0); % endif % endif % endfor diff --git a/source/custom/nidaqmx_service.custom.cpp b/source/custom/nidaqmx_service.custom.cpp index ec0677fe7..4e02ee9d5 100644 --- a/source/custom/nidaqmx_service.custom.cpp +++ b/source/custom/nidaqmx_service.custom.cpp @@ -1,4 +1,13 @@ #include namespace nidaqmx_grpc { + +::grpc::Status NiDAQmxService::ConvertApiErrorStatusForTaskHandle(google::protobuf::int32 status, TaskHandle task) +{ + // This implementation assumes this method is always called on the same thread where the error occurred. + std::string description(nidevice_grpc::kMaxGrpcErrorDescriptionSize, '\0'); + library_->GetExtendedErrorInfo(&description[0], nidevice_grpc::kMaxGrpcErrorDescriptionSize); + return nidevice_grpc::ApiErrorAndDescriptionToStatus(status, description); +} + } // namespace nidaqmx_grpc diff --git a/source/custom/nidcpower_service.custom.cpp b/source/custom/nidcpower_service.custom.cpp index ed7b952d3..af2557571 100644 --- a/source/custom/nidcpower_service.custom.cpp +++ b/source/custom/nidcpower_service.custom.cpp @@ -4,12 +4,12 @@ namespace nidcpower_grpc { -class DriverErrorException : public std::runtime_error{ +class DriverWarningOrErrorException : public std::runtime_error{ private: int status_ = 0; public: - DriverErrorException(int status) : std::runtime_error(""), status_(status) { } + DriverWarningOrErrorException(int status) : std::runtime_error(""), status_(status) { } int status() const { return status_; @@ -19,40 +19,62 @@ class DriverErrorException : public std::runtime_error{ static void CheckStatus(int status) { if (status != 0) { - throw DriverErrorException(status); + throw DriverWarningOrErrorException(status); } } //--------------------------------------------------------------------- //--------------------------------------------------------------------- ::grpc::Status NiDCPowerService::MeasureMultiple(::grpc::ServerContext* context, const MeasureMultipleRequest* request, MeasureMultipleResponse* response) - { - if (context->IsCancelled()) { - return ::grpc::Status::CANCELLED; - } - try { - auto vi_grpc_session = request->vi(); - ViSession vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); - ViConstString channel_name = request->channel_name().c_str(); - - ViUInt32 number_of_channels; - CheckStatus(library_->ParseChannelCount(vi, channel_name, &number_of_channels)); - response->mutable_voltage_measurements()->Resize(number_of_channels, 0.0); - ViReal64* voltage_measurements = response->mutable_voltage_measurements()->mutable_data(); - response->mutable_current_measurements()->Resize(number_of_channels, 0.0); - ViReal64* current_measurements = response->mutable_current_measurements()->mutable_data(); - - auto status = library_->MeasureMultiple(vi, channel_name, voltage_measurements, current_measurements); - response->set_status(status); - return ::grpc::Status::OK; - } - catch (nidevice_grpc::LibraryLoadException& ex) { - return ::grpc::Status(::grpc::NOT_FOUND, ex.what()); +{ + if (context->IsCancelled()) { + return ::grpc::Status::CANCELLED; + } + ViSession vi = VI_NULL; + try { + auto vi_grpc_session = request->vi(); + vi = session_repository_->access_session(vi_grpc_session.id(), vi_grpc_session.name()); + ViConstString channel_name = request->channel_name().c_str(); + + ViUInt32 number_of_channels; + CheckStatus(library_->ParseChannelCount(vi, channel_name, &number_of_channels)); + response->mutable_voltage_measurements()->Resize(number_of_channels, 0.0); + ViReal64* voltage_measurements = response->mutable_voltage_measurements()->mutable_data(); + response->mutable_current_measurements()->Resize(number_of_channels, 0.0); + ViReal64* current_measurements = response->mutable_current_measurements()->mutable_data(); + + auto status = library_->MeasureMultiple(vi, channel_name, voltage_measurements, current_measurements); + if (status < VI_SUCCESS) { + return ConvertApiErrorStatusForViSession(status, vi); } - catch (const DriverErrorException& ex) { - response->set_status(ex.status()); - return ::grpc::Status::OK; + response->set_status(status); + return ::grpc::Status::OK; + } + catch (nidevice_grpc::LibraryLoadException& ex) { + return ::grpc::Status(::grpc::NOT_FOUND, ex.what()); + } + catch (const DriverWarningOrErrorException& ex) { + if (ex.status() < VI_SUCCESS) { + return ConvertApiErrorStatusForViSession(ex.status(), vi); } + response->set_status(ex.status()); + return ::grpc::Status::OK; } +} + +::grpc::Status NiDCPowerService::ConvertApiErrorStatusForViSession(google::protobuf::int32 status, ViSession vi) +{ + static_assert(nidevice_grpc::kMaxGrpcErrorDescriptionSize >= 256, "ErrorMessage expects a minimum buffer size."); + ViStatus error_code {}; + std::string description(nidevice_grpc::kMaxGrpcErrorDescriptionSize, '\0'); + // Try first to get the most recent error with a dynamic message. + library_->GetError(vi, &error_code, nidevice_grpc::kMaxGrpcErrorDescriptionSize, &description[0]); + if (error_code != status) { + // Since another thread has changed the status, fall back to the static message lookup. + description.assign(nidevice_grpc::kMaxGrpcErrorDescriptionSize, '\0'); + library_->ErrorMessage(vi, status, &description[0]); + } + return nidevice_grpc::ApiErrorAndDescriptionToStatus(status, description); +} } // namespace nidcpower_grpc diff --git a/source/custom/nidigitalpattern_service.custom.cpp b/source/custom/nidigitalpattern_service.custom.cpp index 9dc2c2233..31d622dab 100644 --- a/source/custom/nidigitalpattern_service.custom.cpp +++ b/source/custom/nidigitalpattern_service.custom.cpp @@ -1,5 +1,20 @@ #include -namespace nidigital_grpc { +namespace nidigitalpattern_grpc { -} // namespace nidigital_grpc +::grpc::Status NiDigitalService::ConvertApiErrorStatusForViSession(google::protobuf::int32 status, ViSession vi) +{ + static_assert(nidevice_grpc::kMaxGrpcErrorDescriptionSize >= 256, "ErrorMessage expects a minimum buffer size."); + ViStatus error_code {}; + std::string description(nidevice_grpc::kMaxGrpcErrorDescriptionSize, '\0'); + // Try first to get the most recent error with a dynamic message. + library_->GetError(vi, &error_code, nidevice_grpc::kMaxGrpcErrorDescriptionSize, &description[0]); + if (error_code != status) { + // Since another thread has changed the status, fall back to the static message lookup. + description.assign(nidevice_grpc::kMaxGrpcErrorDescriptionSize, '\0'); + library_->ErrorMessage(vi, status, &description[0]); + } + return nidevice_grpc::ApiErrorAndDescriptionToStatus(status, description); +} + +} // namespace nidigitalpattern_grpc diff --git a/source/custom/nidmm_service.custom.cpp b/source/custom/nidmm_service.custom.cpp index a8924d357..0b79a3411 100644 --- a/source/custom/nidmm_service.custom.cpp +++ b/source/custom/nidmm_service.custom.cpp @@ -2,4 +2,18 @@ namespace nidmm_grpc { +::grpc::Status NiDmmService::ConvertApiErrorStatusForViSession(google::protobuf::int32 status, ViSession vi) +{ + ViStatus error_code {}; + std::string description(nidevice_grpc::kMaxGrpcErrorDescriptionSize, '\0'); + // Try first to get the most recent error with a dynamic message. + library_->GetError(vi, &error_code, nidevice_grpc::kMaxGrpcErrorDescriptionSize, &description[0]); + if (error_code != status) { + // Since another thread has changed the status, fall back to the static message lookup. + description.assign(nidevice_grpc::kMaxGrpcErrorDescriptionSize, '\0'); + library_->GetErrorMessage(vi, status, nidevice_grpc::kMaxGrpcErrorDescriptionSize, &description[0]); + } + return nidevice_grpc::ApiErrorAndDescriptionToStatus(status, description); +} + } // namespace nidmm_grpc diff --git a/source/custom/nifake_extension_service.custom.cpp b/source/custom/nifake_extension_service.custom.cpp index d1f59b7dd..c093a67ce 100644 --- a/source/custom/nifake_extension_service.custom.cpp +++ b/source/custom/nifake_extension_service.custom.cpp @@ -2,4 +2,10 @@ namespace nifake_extension_grpc { +::grpc::Status NiFakeExtensionService::ConvertApiErrorStatusForViSession(google::protobuf::int32 status, ViSession vi) +{ + std::string description = "In a real service, you'd look up the error message here."; + return nidevice_grpc::ApiErrorAndDescriptionToStatus(status, description); +} + } // namespace nifake_extension_grpc diff --git a/source/custom/nifake_non_ivi_service.custom.cpp b/source/custom/nifake_non_ivi_service.custom.cpp index 228352d81..dffd7c94a 100644 --- a/source/custom/nifake_non_ivi_service.custom.cpp +++ b/source/custom/nifake_non_ivi_service.custom.cpp @@ -50,4 +50,19 @@ ::grpc::ServerWriteReactor* NiFakeNonIviService::ReadStream( request->start(), request->stop()); } + +::grpc::Status NiFakeNonIviService::ConvertApiErrorStatusForFakeHandle(google::protobuf::int32 status, FakeHandle handle) +{ + std::string description(nidevice_grpc::kMaxGrpcErrorDescriptionSize, '\0'); + library_->GetLatestErrorMessage(&description[0], nidevice_grpc::kMaxGrpcErrorDescriptionSize); + return nidevice_grpc::ApiErrorAndDescriptionToStatus(status, description); +} + +::grpc::Status NiFakeNonIviService::ConvertApiErrorStatusForSecondarySessionHandle(google::protobuf::int32 status, SecondarySessionHandle handle) +{ + std::string description(nidevice_grpc::kMaxGrpcErrorDescriptionSize, '\0'); + library_->GetLatestErrorMessage(&description[0], nidevice_grpc::kMaxGrpcErrorDescriptionSize); + return nidevice_grpc::ApiErrorAndDescriptionToStatus(status, description); +} + } // namespace nifake_non_ivi_grpc diff --git a/source/custom/nifake_service.custom.cpp b/source/custom/nifake_service.custom.cpp index d8b313fac..7570f389d 100644 --- a/source/custom/nifake_service.custom.cpp +++ b/source/custom/nifake_service.custom.cpp @@ -2,4 +2,11 @@ namespace nifake_grpc { +::grpc::Status NiFakeService::ConvertApiErrorStatusForViSession(google::protobuf::int32 status, ViSession vi) +{ + std::string description(nidevice_grpc::kMaxGrpcErrorDescriptionSize, '\0'); + library_->error_message(vi, status, &description[0]); + return nidevice_grpc::ApiErrorAndDescriptionToStatus(status, description); +} + } // namespace nifake_grpc diff --git a/source/custom/nifgen_service.custom.cpp b/source/custom/nifgen_service.custom.cpp index 7771b7bcd..3388d24f5 100644 --- a/source/custom/nifgen_service.custom.cpp +++ b/source/custom/nifgen_service.custom.cpp @@ -26,10 +26,11 @@ ::grpc::Status NiFgenService::CreateAdvancedArbSequence(::grpc::ServerContext* c ViInt32* coerced_markers_array = reinterpret_cast(response->mutable_coerced_markers_array()->mutable_data()); ViInt32 sequence_handle{}; auto status = library_->CreateAdvancedArbSequence(vi, sequence_length, waveform_handles_array, loop_counts_array, sample_counts_array, marker_location_array, coerced_markers_array, &sequence_handle); - response->set_status(status); - if (status == 0) { - response->set_sequence_handle(sequence_handle); + if (status < VI_SUCCESS) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_sequence_handle(sequence_handle); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -37,4 +38,19 @@ ::grpc::Status NiFgenService::CreateAdvancedArbSequence(::grpc::ServerContext* c } } +::grpc::Status NiFgenService::ConvertApiErrorStatusForViSession(google::protobuf::int32 status, ViSession vi) +{ + static_assert(nidevice_grpc::kMaxGrpcErrorDescriptionSize >= 256, "ErrorMessage expects a minimum buffer size."); + ViStatus error_code {}; + std::string description(nidevice_grpc::kMaxGrpcErrorDescriptionSize, '\0'); + // Try first to get the most recent error with a dynamic message. + library_->GetError(vi, &error_code, nidevice_grpc::kMaxGrpcErrorDescriptionSize, &description[0]); + if (error_code != status) { + // Since another thread has changed the status, fall back to the static message lookup. + description.assign(nidevice_grpc::kMaxGrpcErrorDescriptionSize, '\0'); + library_->ErrorMessage(vi, status, &description[0]); + } + return nidevice_grpc::ApiErrorAndDescriptionToStatus(status, description); +} + } // namespace nifgen_grpc diff --git a/source/custom/nirfmxbluetooth_service.custom.cpp b/source/custom/nirfmxbluetooth_service.custom.cpp index d5f6c709f..24babe22e 100644 --- a/source/custom/nirfmxbluetooth_service.custom.cpp +++ b/source/custom/nirfmxbluetooth_service.custom.cpp @@ -1,2 +1,19 @@ +#include + namespace nirfmxbluetooth_grpc { -} // namespace nirfmxbluetooth_grpc \ No newline at end of file + +::grpc::Status NiRFmxBluetoothService::ConvertApiErrorStatusForNiRFmxInstrHandle(google::protobuf::int32 status, niRFmxInstrHandle instrumentHandle) +{ + ViStatus error_code {}; + std::string description(nidevice_grpc::kMaxGrpcErrorDescriptionSize, '\0'); + // Try first to get the most recent error with a dynamic message. + library_->GetError(instrumentHandle, &error_code, nidevice_grpc::kMaxGrpcErrorDescriptionSize, &description[0]); + if (error_code != status) { + // Since another thread has changed the status, fall back to the static message lookup. + description.assign(nidevice_grpc::kMaxGrpcErrorDescriptionSize, '\0'); + library_->GetErrorString(instrumentHandle, status, nidevice_grpc::kMaxGrpcErrorDescriptionSize, &description[0]); + } + return nidevice_grpc::ApiErrorAndDescriptionToStatus(status, description); +} + +} // namespace nirfmxbluetooth_grpc diff --git a/source/custom/nirfmxinstr_restricted_service.custom.cpp b/source/custom/nirfmxinstr_restricted_service.custom.cpp index 3f96b4ab8..9e5522c55 100644 --- a/source/custom/nirfmxinstr_restricted_service.custom.cpp +++ b/source/custom/nirfmxinstr_restricted_service.custom.cpp @@ -1,2 +1,12 @@ +#include + namespace nirfmxinstr_restricted_grpc { -} // namespace nirfmxinstr_restricted_grpc \ No newline at end of file + +::grpc::Status NiRFmxInstrRestrictedService::ConvertApiErrorStatusForNiRFmxInstrHandle(google::protobuf::int32 status, niRFmxInstrHandle instrumentHandle) +{ + std::string description(nidevice_grpc::kMaxGrpcErrorDescriptionSize, '\0'); + // TODO: How do we get access to a library that can return a useful string? + return nidevice_grpc::ApiErrorAndDescriptionToStatus(status, description); +} + +} // namespace nirfmxinstr_restricted_grpc diff --git a/source/custom/nirfmxinstr_service.custom.cpp b/source/custom/nirfmxinstr_service.custom.cpp index 0ecfb9912..eedc337e2 100644 --- a/source/custom/nirfmxinstr_service.custom.cpp +++ b/source/custom/nirfmxinstr_service.custom.cpp @@ -26,8 +26,7 @@ ::grpc::Status NiRFmxInstrService::GetNIRFSASessionArray(::grpc::ServerContext* while (true) { auto status = library_->GetNIRFSASessionArray(instrument, nullptr, 0, &actual_array_size); if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); } array_size = actual_array_size; nirfsa_sessions.resize(array_size); @@ -42,18 +41,19 @@ ::grpc::Status NiRFmxInstrService::GetNIRFSASessionArray(::grpc::ServerContext* stream << "Number of session_names must be zero or match actual array size (" << array_size << ")."; return ::grpc::Status(::grpc::INVALID_ARGUMENT, stream.str()); } + if (status < 0) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, instrument); + } response->set_status(status); - if (status == 0) { - for (auto i = 0; i < array_size; ++i) { - auto init_lambda = [&]() { - return std::make_tuple(0, nirfsa_sessions[i]); - }; - uint32_t session_id = 0; - const auto session_name = request->session_names_size() ? request->session_names(i) : ""; - int status = vi_session_resource_repository_->add_dependent_session(session_name, init_lambda, initiating_session_id, session_id); - auto session = response->add_nirfsa_sessions(); - session->set_id(session_id); - } + for (auto i = 0; i < array_size; ++i) { + auto init_lambda = [&]() { + return std::make_tuple(0, nirfsa_sessions[i]); + }; + uint32_t session_id = 0; + const auto session_name = request->session_names_size() ? request->session_names(i) : ""; + int status = vi_session_resource_repository_->add_dependent_session(session_name, init_lambda, initiating_session_id, session_id); + auto session = response->add_nirfsa_sessions(); + session->set_id(session_id); } return ::grpc::Status::OK; } @@ -82,8 +82,7 @@ ::grpc::Status NiRFmxInstrService::BuildPortString(::grpc::ServerContext* contex while (true) { auto status = library_->BuildPortString(selector_string, port_name, device_name, channel_number, 0, nullptr); if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, 0); } int32 selector_string_out_length = status + std::to_string(channel_number).length(); // AB#1835966: RFmx Instr BuildPortString2 Bug. @@ -96,11 +95,12 @@ ::grpc::Status NiRFmxInstrService::BuildPortString(::grpc::ServerContext* contex // buffer is now too small, try again continue; } - response->set_status(status); - if (status >= 0) { - response->set_selector_string_out(selector_string_out); - nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_selector_string_out())); + if (status < 0) { + return ConvertApiErrorStatusForNiRFmxInstrHandle(status, 0); } + response->set_status(status); + response->set_selector_string_out(selector_string_out); + nidevice_grpc::converters::trim_trailing_nulls(*(response->mutable_selector_string_out())); return ::grpc::Status::OK; } } @@ -108,4 +108,19 @@ ::grpc::Status NiRFmxInstrService::BuildPortString(::grpc::ServerContext* contex return ::grpc::Status(::grpc::NOT_FOUND, ex.what()); } } + +::grpc::Status NiRFmxInstrService::ConvertApiErrorStatusForNiRFmxInstrHandle(google::protobuf::int32 status, niRFmxInstrHandle instrumentHandle) +{ + int32 error_code {}; + std::string description(nidevice_grpc::kMaxGrpcErrorDescriptionSize, '\0'); + // Try first to get the most recent error with a dynamic message. + library_->GetError(instrumentHandle, &error_code, nidevice_grpc::kMaxGrpcErrorDescriptionSize, &description[0]); + if (error_code != status) { + // Since another thread has changed the status, fall back to the static message lookup. + description.assign(nidevice_grpc::kMaxGrpcErrorDescriptionSize, '\0'); + library_->GetErrorString(instrumentHandle, status, nidevice_grpc::kMaxGrpcErrorDescriptionSize, &description[0]); + } + return nidevice_grpc::ApiErrorAndDescriptionToStatus(status, description); +} + } // namespace nirfmxinstr_grpc diff --git a/source/custom/nirfmxlte_service.custom.cpp b/source/custom/nirfmxlte_service.custom.cpp index 06d2ba7f0..30db43350 100644 --- a/source/custom/nirfmxlte_service.custom.cpp +++ b/source/custom/nirfmxlte_service.custom.cpp @@ -1,2 +1,19 @@ +#include + namespace nirfmxlte_grpc { + +::grpc::Status NiRFmxLTEService::ConvertApiErrorStatusForNiRFmxInstrHandle(google::protobuf::int32 status, niRFmxInstrHandle instrumentHandle) +{ + ViStatus error_code {}; + std::string description(nidevice_grpc::kMaxGrpcErrorDescriptionSize, '\0'); + // Try first to get the most recent error with a dynamic message. + library_->GetError(instrumentHandle, &error_code, nidevice_grpc::kMaxGrpcErrorDescriptionSize, &description[0]); + if (error_code != status) { + // Since another thread has changed the status, fall back to the static message lookup. + description.assign(nidevice_grpc::kMaxGrpcErrorDescriptionSize, '\0'); + library_->GetErrorString(instrumentHandle, status, nidevice_grpc::kMaxGrpcErrorDescriptionSize, &description[0]); + } + return nidevice_grpc::ApiErrorAndDescriptionToStatus(status, description); +} + } // namespace nirfmxlte_grpc diff --git a/source/custom/nirfmxnr_service.custom.cpp b/source/custom/nirfmxnr_service.custom.cpp index 05eae9736..8611ddef6 100644 --- a/source/custom/nirfmxnr_service.custom.cpp +++ b/source/custom/nirfmxnr_service.custom.cpp @@ -1,2 +1,19 @@ +#include + namespace nirfmxnr_grpc { + +::grpc::Status NiRFmxNRService::ConvertApiErrorStatusForNiRFmxInstrHandle(google::protobuf::int32 status, niRFmxInstrHandle instrumentHandle) +{ + int32 error_code {}; + std::string description(nidevice_grpc::kMaxGrpcErrorDescriptionSize, '\0'); + // Try first to get the most recent error with a dynamic message. + library_->GetError(instrumentHandle, &error_code, nidevice_grpc::kMaxGrpcErrorDescriptionSize, &description[0]); + if (error_code != status) { + // Since another thread has changed the status, fall back to the static message lookup. + description.assign(nidevice_grpc::kMaxGrpcErrorDescriptionSize, '\0'); + library_->GetErrorString(instrumentHandle, status, nidevice_grpc::kMaxGrpcErrorDescriptionSize, &description[0]); + } + return nidevice_grpc::ApiErrorAndDescriptionToStatus(status, description); +} + } // namespace nirfmxnr_grpc diff --git a/source/custom/nirfmxspecan_restricted_service.custom.cpp b/source/custom/nirfmxspecan_restricted_service.custom.cpp index 591ea292f..d8732a4bf 100644 --- a/source/custom/nirfmxspecan_restricted_service.custom.cpp +++ b/source/custom/nirfmxspecan_restricted_service.custom.cpp @@ -1,2 +1,12 @@ +#include + namespace nirfmxspecan_restricted_grpc { + +::grpc::Status NiRFmxSpecAnRestrictedService::ConvertApiErrorStatusForNiRFmxInstrHandle(google::protobuf::int32 status, niRFmxInstrHandle instrumentHandle) +{ + std::string description(nidevice_grpc::kMaxGrpcErrorDescriptionSize, '\0'); + // TODO: How do we get access to a library that can return a useful string? + return nidevice_grpc::ApiErrorAndDescriptionToStatus(status, description); +} + } // namespace nirfmxspecan_restricted_grpc diff --git a/source/custom/nirfmxspecan_service.custom.cpp b/source/custom/nirfmxspecan_service.custom.cpp index 45d68b38a..16abe8f58 100644 --- a/source/custom/nirfmxspecan_service.custom.cpp +++ b/source/custom/nirfmxspecan_service.custom.cpp @@ -1,2 +1,18 @@ +#include + namespace nirfmxspecan_grpc { + +::grpc::Status NiRFmxSpecAnService::ConvertApiErrorStatusForNiRFmxInstrHandle(google::protobuf::int32 status, niRFmxInstrHandle instrumentHandle) +{ + ViStatus error_code {}; + std::string description(nidevice_grpc::kMaxGrpcErrorDescriptionSize, '\0'); + // Try first to get the most recent error with a dynamic message. + library_->GetError(instrumentHandle, &error_code, nidevice_grpc::kMaxGrpcErrorDescriptionSize, &description[0]); + if (error_code != status) { + // Since another thread has changed the status, fall back to the static message lookup. + library_->GetErrorString(instrumentHandle, status, nidevice_grpc::kMaxGrpcErrorDescriptionSize, &description[0]); + } + return nidevice_grpc::ApiErrorAndDescriptionToStatus(status, description); +} + } // namespace nirfmxspecan_grpc diff --git a/source/custom/nirfmxwlan_service.custom.cpp b/source/custom/nirfmxwlan_service.custom.cpp index da4d15cdc..59696b0c3 100644 --- a/source/custom/nirfmxwlan_service.custom.cpp +++ b/source/custom/nirfmxwlan_service.custom.cpp @@ -1,2 +1,19 @@ +#include + namespace nirfmxwlan_grpc { + +::grpc::Status NiRFmxWLANService::ConvertApiErrorStatusForNiRFmxInstrHandle(google::protobuf::int32 status, niRFmxInstrHandle instrumentHandle) +{ + int32 error_code {}; + std::string description(nidevice_grpc::kMaxGrpcErrorDescriptionSize, '\0'); + // Try first to get the most recent error with a dynamic message. + library_->GetError(instrumentHandle, &error_code, nidevice_grpc::kMaxGrpcErrorDescriptionSize, &description[0]); + if (error_code != status) { + // Since another thread has changed the status, fall back to the static message lookup. + description.assign(nidevice_grpc::kMaxGrpcErrorDescriptionSize, '\0'); + library_->GetErrorString(instrumentHandle, status, nidevice_grpc::kMaxGrpcErrorDescriptionSize, &description[0]); + } + return nidevice_grpc::ApiErrorAndDescriptionToStatus(status, description); +} + } // namespace nirfmxwlan_grpc diff --git a/source/custom/nirfsa_service.custom.cpp b/source/custom/nirfsa_service.custom.cpp index 6b0d5090a..562fe1503 100644 --- a/source/custom/nirfsa_service.custom.cpp +++ b/source/custom/nirfsa_service.custom.cpp @@ -1,2 +1,20 @@ +#include + namespace nirfsa_grpc { + +::grpc::Status NiRFSAService::ConvertApiErrorStatusForViSession(google::protobuf::int32 status, ViSession vi) +{ + static_assert(nidevice_grpc::kMaxGrpcErrorDescriptionSize >= 1024, "ErrorMessage expects a minimum buffer size."); + ViStatus error_code {}; + std::string description(nidevice_grpc::kMaxGrpcErrorDescriptionSize, '\0'); + // Try first to get the most recent error with a dynamic message. + library_->GetError(vi, &error_code, nidevice_grpc::kMaxGrpcErrorDescriptionSize, &description[0]); + if (error_code != status) { + // Since another thread has changed the status, fall back to the static message lookup. + description.assign(nidevice_grpc::kMaxGrpcErrorDescriptionSize, '\0'); + library_->ErrorMessage(vi, status, &description[0]); + } + return nidevice_grpc::ApiErrorAndDescriptionToStatus(status, description); +} + } // namespace nirfsa_grpc diff --git a/source/custom/nirfsg_service.custom.cpp b/source/custom/nirfsg_service.custom.cpp index 9ff5822bb..bec66d74b 100644 --- a/source/custom/nirfsg_service.custom.cpp +++ b/source/custom/nirfsg_service.custom.cpp @@ -2,4 +2,19 @@ namespace nirfsg_grpc { +::grpc::Status NiRFSGService::ConvertApiErrorStatusForViSession(google::protobuf::int32 status, ViSession vi) +{ + static_assert(nidevice_grpc::kMaxGrpcErrorDescriptionSize >= 1024, "ErrorMessage expects a minimum buffer size."); + ViStatus error_code {}; + std::string description(nidevice_grpc::kMaxGrpcErrorDescriptionSize, '\0'); + // Try first to get the most recent error with a dynamic message. + library_->GetError(vi, &error_code, nidevice_grpc::kMaxGrpcErrorDescriptionSize, &description[0]); + if (error_code != status) { + // Since another thread has changed the status, fall back to the static message lookup. + description.assign(nidevice_grpc::kMaxGrpcErrorDescriptionSize, '\0'); + library_->ErrorMessage(vi, status, &description[0]); + } + return nidevice_grpc::ApiErrorAndDescriptionToStatus(status, description); +} + } // namespace nirfsg_grpc diff --git a/source/custom/niscope_service.custom.cpp b/source/custom/niscope_service.custom.cpp index 715d4d40b..614678e7b 100644 --- a/source/custom/niscope_service.custom.cpp +++ b/source/custom/niscope_service.custom.cpp @@ -9,15 +9,15 @@ using nidevice_grpc::converters::convert_to_grpc; const auto kErrorReadBufferTooSmall = -200229; -struct DriverErrorException : std::runtime_error { - DriverErrorException(int status) : std::runtime_error("") { status_ = status; } +struct DriverWarningOrErrorException : std::runtime_error { + DriverWarningOrErrorException(int status) : std::runtime_error("") { status_ = status; } int status_ = 0; }; void CheckStatus(int status) { if (status != 0) { - throw DriverErrorException(status); + throw DriverWarningOrErrorException(status); } } @@ -28,9 +28,10 @@ ::grpc::Status NiScopeService::Fetch(::grpc::ServerContext* context, const Fetch if (context->IsCancelled()) { return ::grpc::Status::CANCELLED; } + ViSession vi = VI_NULL; try { auto session = request->vi(); - ViSession vi = session_repository_->access_session(session.id(), session.name()); + vi = session_repository_->access_session(session.id(), session.name()); ViConstString channel_list = request->channel_list().c_str(); ViReal64 timeout = request->timeout(); ViInt32 num_samples = request->num_samples(); @@ -45,16 +46,20 @@ ::grpc::Status NiScopeService::Fetch(::grpc::ServerContext* context, const Fetch ViReal64* waveform = response->mutable_waveform()->mutable_data(); std::vector waveform_info(num_waveforms, niScope_wfmInfo()); auto status = library_->Fetch(vi, channel_list, timeout, num_samples, waveform, waveform_info.data()); - response->set_status(status); - if (status == 0) { - convert_to_grpc(waveform_info, response->mutable_wfm_info()); + if (status < VI_SUCCESS) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + convert_to_grpc(waveform_info, response->mutable_wfm_info()); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { return ::grpc::Status(::grpc::NOT_FOUND, ex.what()); } - catch (DriverErrorException& ex) { + catch (const DriverWarningOrErrorException& ex) { + if (ex.status_ < VI_SUCCESS) { + return ConvertApiErrorStatusForViSession(ex.status_, vi); + } response->set_status(ex.status_); return ::grpc::Status::OK; } @@ -67,9 +72,10 @@ ::grpc::Status NiScopeService::FetchBinary8(::grpc::ServerContext* context, cons if (context->IsCancelled()) { return ::grpc::Status::CANCELLED; } + ViSession vi = VI_NULL; try { auto session = request->vi(); - ViSession vi = session_repository_->access_session(session.id(), session.name()); + vi = session_repository_->access_session(session.id(), session.name()); ViConstString channel_list = request->channel_list().c_str(); ViReal64 timeout = request->timeout(); ViInt32 num_samples = request->num_samples(); @@ -84,16 +90,20 @@ ::grpc::Status NiScopeService::FetchBinary8(::grpc::ServerContext* context, cons ViInt8* waveform = (ViInt8*)response->mutable_waveform()->data(); std::vector waveform_info(num_waveforms, niScope_wfmInfo()); auto status = library_->FetchBinary8(vi, channel_list, timeout, num_samples, waveform, waveform_info.data()); - response->set_status(status); - if (status == 0) { - convert_to_grpc(waveform_info, response->mutable_wfm_info()); + if (status < VI_SUCCESS) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + convert_to_grpc(waveform_info, response->mutable_wfm_info()); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { return ::grpc::Status(::grpc::NOT_FOUND, ex.what()); } - catch (DriverErrorException& ex) { + catch (const DriverWarningOrErrorException& ex) { + if (ex.status_ < VI_SUCCESS) { + return ConvertApiErrorStatusForViSession(ex.status_, vi); + } response->set_status(ex.status_); return ::grpc::Status::OK; } @@ -106,9 +116,10 @@ ::grpc::Status NiScopeService::FetchBinary16(::grpc::ServerContext* context, con if (context->IsCancelled()) { return ::grpc::Status::CANCELLED; } + ViSession vi = VI_NULL; try { auto session = request->vi(); - ViSession vi = session_repository_->access_session(session.id(), session.name()); + vi = session_repository_->access_session(session.id(), session.name()); ViConstString channel_list = request->channel_list().c_str(); ViReal64 timeout = request->timeout(); ViInt32 num_samples = request->num_samples(); @@ -122,17 +133,21 @@ ::grpc::Status NiScopeService::FetchBinary16(::grpc::ServerContext* context, con std::vector waveform(num_samples * num_waveforms, 0); std::vector waveform_info(num_waveforms, niScope_wfmInfo()); auto status = library_->FetchBinary16(vi, channel_list, timeout, num_samples, waveform.data(), waveform_info.data()); - response->set_status(status); - if (status == 0) { - convert_to_grpc(waveform_info, response->mutable_wfm_info()); - response->mutable_waveform()->Add(waveform.begin(), waveform.end()); + if (status < VI_SUCCESS) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + convert_to_grpc(waveform_info, response->mutable_wfm_info()); + response->mutable_waveform()->Add(waveform.begin(), waveform.end()); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { return ::grpc::Status(::grpc::NOT_FOUND, ex.what()); } - catch (DriverErrorException& ex) { + catch (const DriverWarningOrErrorException& ex) { + if (ex.status_ < VI_SUCCESS) { + return ConvertApiErrorStatusForViSession(ex.status_, vi); + } response->set_status(ex.status_); return ::grpc::Status::OK; } @@ -145,9 +160,10 @@ ::grpc::Status NiScopeService::FetchBinary32(::grpc::ServerContext* context, con if (context->IsCancelled()) { return ::grpc::Status::CANCELLED; } + ViSession vi = VI_NULL; try { auto session = request->vi(); - ViSession vi = session_repository_->access_session(session.id(), session.name()); + vi = session_repository_->access_session(session.id(), session.name()); ViConstString channel_list = request->channel_list().c_str(); ViReal64 timeout = request->timeout(); ViInt32 num_samples = request->num_samples(); @@ -161,17 +177,21 @@ ::grpc::Status NiScopeService::FetchBinary32(::grpc::ServerContext* context, con std::vector waveform(num_samples * num_waveforms, 0); std::vector waveform_info(num_waveforms, niScope_wfmInfo()); auto status = library_->FetchBinary32(vi, channel_list, timeout, num_samples, waveform.data(), waveform_info.data()); - response->set_status(status); - if (status == 0) { - response->mutable_waveform()->Add(waveform.begin(), waveform.end()); - convert_to_grpc(waveform_info, response->mutable_wfm_info()); + if (status < VI_SUCCESS) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->mutable_waveform()->Add(waveform.begin(), waveform.end()); + convert_to_grpc(waveform_info, response->mutable_wfm_info()); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { return ::grpc::Status(::grpc::NOT_FOUND, ex.what()); } - catch (DriverErrorException& ex) { + catch (const DriverWarningOrErrorException& ex) { + if (ex.status_ < VI_SUCCESS) { + return ConvertApiErrorStatusForViSession(ex.status_, vi); + } response->set_status(ex.status_); return ::grpc::Status::OK; } @@ -184,9 +204,10 @@ ::grpc::Status NiScopeService::FetchArrayMeasurement(::grpc::ServerContext* cont if (context->IsCancelled()) { return ::grpc::Status::CANCELLED; } + ViSession vi = VI_NULL; try { auto session = request->vi(); - ViSession vi = session_repository_->access_session(session.id(), session.name()); + vi = session_repository_->access_session(session.id(), session.name()); ViConstString channel_list = request->channel_list().c_str(); ViReal64 timeout = request->timeout(); ViInt32 array_meas_function; @@ -212,16 +233,20 @@ ::grpc::Status NiScopeService::FetchArrayMeasurement(::grpc::ServerContext* cont ViReal64* meas_wfm = response->mutable_meas_wfm()->mutable_data(); std::vector waveform_info(measurement_waveform_size, niScope_wfmInfo()); auto status = library_->FetchArrayMeasurement(vi, channel_list, timeout, array_meas_function, measurement_waveform_size, meas_wfm, waveform_info.data()); - response->set_status(status); - if (status == 0) { - convert_to_grpc(waveform_info, response->mutable_wfm_info()); + if (status < VI_SUCCESS) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + convert_to_grpc(waveform_info, response->mutable_wfm_info()); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { return ::grpc::Status(::grpc::NOT_FOUND, ex.what()); } - catch (DriverErrorException& ex) { + catch (const DriverWarningOrErrorException& ex) { + if (ex.status_ < VI_SUCCESS) { + return ConvertApiErrorStatusForViSession(ex.status_, vi); + } response->set_status(ex.status_); return ::grpc::Status::OK; } @@ -234,9 +259,10 @@ ::grpc::Status NiScopeService::FetchMeasurementStats(::grpc::ServerContext* cont if (context->IsCancelled()) { return ::grpc::Status::CANCELLED; } + ViSession vi = VI_NULL; try { auto session = request->vi(); - ViSession vi = session_repository_->access_session(session.id(), session.name()); + vi = session_repository_->access_session(session.id(), session.name()); ViConstString channel_list = request->channel_list().c_str(); ViReal64 timeout = request->timeout(); ViInt32 scalar_meas_function; @@ -267,16 +293,20 @@ ::grpc::Status NiScopeService::FetchMeasurementStats(::grpc::ServerContext* cont ViReal64* max = response->mutable_max()->mutable_data(); std::vector num_in_stats(num_waveforms, 0); auto status = library_->FetchMeasurementStats(vi, channel_list, timeout, scalar_meas_function, result, mean, stdev, min, max, num_in_stats.data()); - response->set_status(status); - if (status == 0) { - response->mutable_num_in_stats()->Add(num_in_stats.begin(), num_in_stats.end()); + if (status < VI_SUCCESS) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->mutable_num_in_stats()->Add(num_in_stats.begin(), num_in_stats.end()); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { return ::grpc::Status(::grpc::NOT_FOUND, ex.what()); } - catch (DriverErrorException& ex) { + catch (const DriverWarningOrErrorException& ex) { + if (ex.status_ < VI_SUCCESS) { + return ConvertApiErrorStatusForViSession(ex.status_, vi); + } response->set_status(ex.status_); return ::grpc::Status::OK; } @@ -289,9 +319,10 @@ ::grpc::Status NiScopeService::Read(::grpc::ServerContext* context, const ReadRe if (context->IsCancelled()) { return ::grpc::Status::CANCELLED; } + ViSession vi = VI_NULL; try { auto session = request->vi(); - ViSession vi = session_repository_->access_session(session.id(), session.name()); + vi = session_repository_->access_session(session.id(), session.name()); ViConstString channel_list = request->channel_list().c_str(); ViReal64 timeout = request->timeout(); ViInt32 num_samples = request->num_samples(); @@ -306,16 +337,20 @@ ::grpc::Status NiScopeService::Read(::grpc::ServerContext* context, const ReadRe ViReal64* waveform = response->mutable_waveform()->mutable_data(); std::vector waveform_info(num_waveforms, niScope_wfmInfo()); auto status = library_->Read(vi, channel_list, timeout, num_samples, waveform, waveform_info.data()); - response->set_status(status); - if (status == 0) { - convert_to_grpc(waveform_info, response->mutable_wfm_info()); + if (status < VI_SUCCESS) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + convert_to_grpc(waveform_info, response->mutable_wfm_info()); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { return ::grpc::Status(::grpc::NOT_FOUND, ex.what()); } - catch (DriverErrorException& ex) { + catch (const DriverWarningOrErrorException& ex) { + if (ex.status_ < VI_SUCCESS) { + return ConvertApiErrorStatusForViSession(ex.status_, vi); + } response->set_status(ex.status_); return ::grpc::Status::OK; } @@ -328,9 +363,10 @@ ::grpc::Status NiScopeService::FetchComplex(::grpc::ServerContext* context, cons if (context->IsCancelled()) { return ::grpc::Status::CANCELLED; } + ViSession vi = VI_NULL; try { auto session = request->vi(); - ViSession vi = session_repository_->access_session(session.id(), session.name()); + vi = session_repository_->access_session(session.id(), session.name()); ViConstString channel_list = request->channel_list().c_str(); ViReal64 timeout = request->timeout(); ViInt32 num_samples = request->num_samples(); @@ -344,17 +380,21 @@ ::grpc::Status NiScopeService::FetchComplex(::grpc::ServerContext* context, cons std::vector waveform(num_samples * num_waveforms, NIComplexNumber_struct()); std::vector waveform_info(num_waveforms, niScope_wfmInfo()); auto status = library_->FetchComplex(vi, channel_list, timeout, num_samples, waveform.data(), waveform_info.data()); - response->set_status(status); - if (status == 0) { - convert_to_grpc(waveform, response->mutable_wfm()); - convert_to_grpc(waveform_info, response->mutable_wfm_info()); + if (status < VI_SUCCESS) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + convert_to_grpc(waveform, response->mutable_wfm()); + convert_to_grpc(waveform_info, response->mutable_wfm_info()); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { return ::grpc::Status(::grpc::NOT_FOUND, ex.what()); } - catch (DriverErrorException& ex) { + catch (const DriverWarningOrErrorException& ex) { + if (ex.status_ < VI_SUCCESS) { + return ConvertApiErrorStatusForViSession(ex.status_, vi); + } response->set_status(ex.status_); return ::grpc::Status::OK; } @@ -367,9 +407,10 @@ ::grpc::Status NiScopeService::FetchComplexBinary16(::grpc::ServerContext* conte if (context->IsCancelled()) { return ::grpc::Status::CANCELLED; } + ViSession vi = VI_NULL; try { auto session = request->vi(); - ViSession vi = session_repository_->access_session(session.id(), session.name()); + vi = session_repository_->access_session(session.id(), session.name()); ViConstString channel_list = request->channel_list().c_str(); ViReal64 timeout = request->timeout(); ViInt32 num_samples = request->num_samples(); @@ -383,17 +424,21 @@ ::grpc::Status NiScopeService::FetchComplexBinary16(::grpc::ServerContext* conte std::vector waveform(num_samples * num_waveforms, NIComplexI16_struct()); std::vector waveform_info(num_waveforms, niScope_wfmInfo()); auto status = library_->FetchComplexBinary16(vi, channel_list, timeout, num_samples, waveform.data(), waveform_info.data()); - response->set_status(status); - if (status == 0) { - convert_to_grpc(waveform, response->mutable_wfm()); - convert_to_grpc(waveform_info, response->mutable_wfm_info()); + if (status < VI_SUCCESS) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + convert_to_grpc(waveform, response->mutable_wfm()); + convert_to_grpc(waveform_info, response->mutable_wfm_info()); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { return ::grpc::Status(::grpc::NOT_FOUND, ex.what()); } - catch (DriverErrorException& ex) { + catch (const DriverWarningOrErrorException& ex) { + if (ex.status_ < VI_SUCCESS) { + return ConvertApiErrorStatusForViSession(ex.status_, vi); + } response->set_status(ex.status_); return ::grpc::Status::OK; } @@ -406,9 +451,10 @@ ::grpc::Status NiScopeService::FetchMeasurement(::grpc::ServerContext* context, if (context->IsCancelled()) { return ::grpc::Status::CANCELLED; } + ViSession vi = VI_NULL; try { auto session = request->vi(); - ViSession vi = session_repository_->access_session(session.id(), session.name()); + vi = session_repository_->access_session(session.id(), session.name()); ViConstString channel_list = request->channel_list().c_str(); ViReal64 timeout = request->timeout(); ViInt32 scalar_meas_function; @@ -430,13 +476,19 @@ ::grpc::Status NiScopeService::FetchMeasurement(::grpc::ServerContext* context, response->mutable_result()->Resize(num_waveforms, 0.0); ViReal64* result = response->mutable_result()->mutable_data(); auto status = library_->FetchMeasurement(vi, channel_list, timeout, scalar_meas_function, result); + if (status < VI_SUCCESS) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { return ::grpc::Status(::grpc::NOT_FOUND, ex.what()); } - catch (DriverErrorException& ex) { + catch (const DriverWarningOrErrorException& ex) { + if (ex.status_ < VI_SUCCESS) { + return ConvertApiErrorStatusForViSession(ex.status_, vi); + } response->set_status(ex.status_); return ::grpc::Status::OK; } @@ -449,9 +501,10 @@ ::grpc::Status NiScopeService::GetNormalizationCoefficients(::grpc::ServerContex if (context->IsCancelled()) { return ::grpc::Status::CANCELLED; } + ViSession vi = VI_NULL; try { auto session = request->vi(); - ViSession vi = session_repository_->access_session(session.id(), session.name()); + vi = session_repository_->access_session(session.id(), session.name()); ViConstString channel_list = request->channel_list().c_str(); while (true) { @@ -464,18 +517,22 @@ ::grpc::Status NiScopeService::GetNormalizationCoefficients(::grpc::ServerContex // buffer is now too small, try again continue; } - response->set_status(status); - if (status == 0) { - response->set_number_of_coefficient_sets(number_of_coefficient_sets); - convert_to_grpc(coefficient_info, response->mutable_coefficient_info()); + if (status < VI_SUCCESS) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_number_of_coefficient_sets(number_of_coefficient_sets); + convert_to_grpc(coefficient_info, response->mutable_coefficient_info()); return ::grpc::Status::OK; } } catch (nidevice_grpc::LibraryLoadException& ex) { return ::grpc::Status(::grpc::NOT_FOUND, ex.what()); } - catch (DriverErrorException& ex) { + catch (const DriverWarningOrErrorException& ex) { + if (ex.status_ < VI_SUCCESS) { + return ConvertApiErrorStatusForViSession(ex.status_, vi); + } response->set_status(ex.status_); return ::grpc::Status::OK; } @@ -488,9 +545,10 @@ ::grpc::Status NiScopeService::GetScalingCoefficients(::grpc::ServerContext* con if (context->IsCancelled()) { return ::grpc::Status::CANCELLED; } + ViSession vi = VI_NULL; try { auto session = request->vi(); - ViSession vi = session_repository_->access_session(session.id(), session.name()); + vi = session_repository_->access_session(session.id(), session.name()); ViConstString channel_list = request->channel_list().c_str(); while (true) { @@ -503,19 +561,22 @@ ::grpc::Status NiScopeService::GetScalingCoefficients(::grpc::ServerContext* con // buffer is now too small, try again continue; } - response->set_status(status); - response->set_status(status); - if (status == 0) { - response->set_number_of_coefficient_sets(number_of_coefficient_sets); - convert_to_grpc(coefficient_info, response->mutable_coefficient_info()); + if (status < VI_SUCCESS) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_number_of_coefficient_sets(number_of_coefficient_sets); + convert_to_grpc(coefficient_info, response->mutable_coefficient_info()); return ::grpc::Status::OK; } } catch (nidevice_grpc::LibraryLoadException& ex) { return ::grpc::Status(::grpc::NOT_FOUND, ex.what()); } - catch (DriverErrorException& ex) { + catch (const DriverWarningOrErrorException& ex) { + if (ex.status_ < VI_SUCCESS) { + return ConvertApiErrorStatusForViSession(ex.status_, vi); + } response->set_status(ex.status_); return ::grpc::Status::OK; } @@ -528,9 +589,10 @@ ::grpc::Status NiScopeService::ReadMeasurement(::grpc::ServerContext* context, c if (context->IsCancelled()) { return ::grpc::Status::CANCELLED; } + ViSession vi = VI_NULL; try { auto session = request->vi(); - ViSession vi = session_repository_->access_session(session.id(), session.name()); + vi = session_repository_->access_session(session.id(), session.name()); ViConstString channel_list = request->channel_list().c_str(); ViReal64 timeout = request->timeout(); ViInt32 scalar_meas_function; @@ -552,16 +614,36 @@ ::grpc::Status NiScopeService::ReadMeasurement(::grpc::ServerContext* context, c response->mutable_result()->Resize(num_waveforms, 0.0); ViReal64* result = response->mutable_result()->mutable_data(); auto status = library_->ReadMeasurement(vi, channel_list, timeout, scalar_meas_function, result); + if (status < VI_SUCCESS) { + return ConvertApiErrorStatusForViSession(status, vi); + } response->set_status(status); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { return ::grpc::Status(::grpc::NOT_FOUND, ex.what()); } - catch (DriverErrorException& ex) { + catch (const DriverWarningOrErrorException& ex) { + if (ex.status_ < VI_SUCCESS) { + return ConvertApiErrorStatusForViSession(ex.status_, vi); + } response->set_status(ex.status_); return ::grpc::Status::OK; } } +::grpc::Status NiScopeService::ConvertApiErrorStatusForViSession(google::protobuf::int32 status, ViSession vi) +{ + ViStatus error_code {}; + std::string description(nidevice_grpc::kMaxGrpcErrorDescriptionSize, '\0'); + // Try first to get the most recent error with a dynamic message. + library_->GetError(vi, &error_code, nidevice_grpc::kMaxGrpcErrorDescriptionSize, &description[0]); + if (error_code != status) { + // Since another thread has changed the status, fall back to the static message lookup. + description.assign(nidevice_grpc::kMaxGrpcErrorDescriptionSize, '\0'); + library_->GetErrorMessage(vi, status, nidevice_grpc::kMaxGrpcErrorDescriptionSize, &description[0]); + } + return nidevice_grpc::ApiErrorAndDescriptionToStatus(status, description); +} + } // namespace niscope_grpc diff --git a/source/custom/niswitch_service.custom.cpp b/source/custom/niswitch_service.custom.cpp index 72b56812a..df9423b89 100644 --- a/source/custom/niswitch_service.custom.cpp +++ b/source/custom/niswitch_service.custom.cpp @@ -2,4 +2,19 @@ namespace niswitch_grpc { +::grpc::Status NiSwitchService::ConvertApiErrorStatusForViSession(google::protobuf::int32 status, ViSession vi) +{ + static_assert(nidevice_grpc::kMaxGrpcErrorDescriptionSize >= 256, "ErrorMessage expects a minimum buffer size."); + ViStatus error_code {}; + std::string description(nidevice_grpc::kMaxGrpcErrorDescriptionSize, '\0'); + // Try first to get the most recent error with a dynamic message. + library_->GetError(vi, &error_code, nidevice_grpc::kMaxGrpcErrorDescriptionSize, &description[0]); + if (error_code != status) { + // Since another thread has changed the status, fall back to the static message lookup. + description.assign(nidevice_grpc::kMaxGrpcErrorDescriptionSize, '\0'); + library_->ErrorMessage(vi, status, &description[0]); + } + return nidevice_grpc::ApiErrorAndDescriptionToStatus(status, description); +} + } // namespace niswitch_grpc diff --git a/source/custom/nisync_service.custom.cpp b/source/custom/nisync_service.custom.cpp index c5acef404..9044caf87 100644 --- a/source/custom/nisync_service.custom.cpp +++ b/source/custom/nisync_service.custom.cpp @@ -25,10 +25,11 @@ ::grpc::Status NiSyncService::ReadMultipleTriggerTimeStamp(::grpc::ServerContext ViInt32* detected_edge_buffer = reinterpret_cast(response->mutable_detected_edge_buffer()->mutable_data()); ViUInt32 timestamps_read {}; auto status = library_->ReadMultipleTriggerTimeStamp(vi, terminal, timestamps_to_read, timeout, time_seconds_buffer, time_nanoseconds_buffer, time_fractional_nanoseconds_buffer, detected_edge_buffer, ×tamps_read); - response->set_status(status); - if (status == VI_SUCCESS || status == NISYNC_ERROR_DRIVER_TIMEOUT) { - response->set_timestamps_read(timestamps_read); + if (status < VI_SUCCESS && status != NISYNC_ERROR_DRIVER_TIMEOUT) { + return ConvertApiErrorStatusForViSession(status, vi); } + response->set_status(status); + response->set_timestamps_read(timestamps_read); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -36,4 +37,12 @@ ::grpc::Status NiSyncService::ReadMultipleTriggerTimeStamp(::grpc::ServerContext } } +::grpc::Status NiSyncService::ConvertApiErrorStatusForViSession(google::protobuf::int32 status, ViSession vi) +{ + static_assert(nidevice_grpc::kMaxGrpcErrorDescriptionSize >= 256, "ErrorMessage expects a minimum buffer size."); + std::string description(nidevice_grpc::kMaxGrpcErrorDescriptionSize, '\0'); + library_->ErrorMessage(vi, status, &description[0]); + return nidevice_grpc::ApiErrorAndDescriptionToStatus(status, description); +} + } // namespace nisync_grpc diff --git a/source/custom/nitclk_service.custom.cpp b/source/custom/nitclk_service.custom.cpp index 766c162e4..0b625be33 100644 --- a/source/custom/nitclk_service.custom.cpp +++ b/source/custom/nitclk_service.custom.cpp @@ -20,9 +20,8 @@ ::grpc::Status NiTClkService::GetAttributeViString(::grpc::ServerContext* contex while (true) { auto status = library_->GetAttributeViString(session, channel_name, attribute_id, 0, nullptr); - if (status < 0) { - response->set_status(status); - return ::grpc::Status::OK; + if (status < VI_SUCCESS) { + return ConvertApiErrorStatusForViSession(status, session); } ViInt32 buffer_size = status; @@ -32,10 +31,11 @@ ::grpc::Status NiTClkService::GetAttributeViString(::grpc::ServerContext* contex // buffer is now too small, try again continue; } - response->set_status(status); - if (status == 0) { - response->set_value(value); + if (status < VI_SUCCESS) { + return ConvertApiErrorStatusForViSession(status, session); } + response->set_status(status); + response->set_value(value); return ::grpc::Status::OK; } } @@ -44,4 +44,11 @@ ::grpc::Status NiTClkService::GetAttributeViString(::grpc::ServerContext* contex } } +::grpc::Status NiTClkService::ConvertApiErrorStatusForViSession(google::protobuf::int32 status, ViSession session_number) +{ + std::string description(nidevice_grpc::kMaxGrpcErrorDescriptionSize, '\0'); + library_->GetExtendedErrorInfo(&description[0], nidevice_grpc::kMaxGrpcErrorDescriptionSize); + return nidevice_grpc::ApiErrorAndDescriptionToStatus(status, description); +} + } // namespace nitclk_grpc diff --git a/source/custom/nixnet_service.custom.cpp b/source/custom/nixnet_service.custom.cpp index bae95f22c..2a25a07ad 100644 --- a/source/custom/nixnet_service.custom.cpp +++ b/source/custom/nixnet_service.custom.cpp @@ -168,65 +168,65 @@ ::grpc::Status NiXnetService::ReadState(::grpc::ServerContext* context, const Re nxStatus_t fault{}; auto status = library_->ReadState(session, state_id, state_size, const_cast(response->mutable_state_value()->mutable_state_value_raw()->data()), &fault); - + if (!status_ok(status)) { + return ConvertApiErrorStatusForNxSessionRef_t(status, session); + } response->set_status(status); - if (status == 0) { - void* state_value_raw = (void*)response->state_value().state_value_raw().data(); - switch (state_id) { - case nixnet_grpc::ReadState::READ_STATE_TIME_CURRENT: { - response->mutable_state_value()->set_time_current(*(nxTimestamp100ns_t*)state_value_raw); - break; - } - case nixnet_grpc::ReadState::READ_STATE_TIME_COMMUNICATING: { - response->mutable_state_value()->set_time_communicating(*(nxTimestamp100ns_t*)state_value_raw); - break; - } - case nixnet_grpc::ReadState::READ_STATE_TIME_START: { - response->mutable_state_value()->set_time_start(*(nxTimestamp100ns_t*)state_value_raw); - break; - } - case nixnet_grpc::ReadState::READ_STATE_CAN_COMM: { - SetCanCommResponse(*(u32*)state_value_raw, response->mutable_state_value()->mutable_can_comm()); - break; - } - case nixnet_grpc::ReadState::READ_STATE_FLEX_RAY_COMM: { - SetFlexRayCommResponse(*(u32*)state_value_raw, response->mutable_state_value()->mutable_flex_ray_comm()); - break; - } - case nixnet_grpc::ReadState::READ_STATE_LIN_COMM: { - SetLinCommResponse((u32*)state_value_raw, response->mutable_state_value()->mutable_lin_comm()); - break; - } - case nixnet_grpc::ReadState::READ_STATE_SESSION_INFO: { - SetSessionInfoResponse(*(u32*)state_value_raw, response->mutable_state_value()->mutable_session_info()); - break; - } - case nixnet_grpc::ReadState::READ_STATE_FLEX_RAY_STATS: { - convert_to_grpc(*(_nxFlexRayStats_t*)state_value_raw, response->mutable_state_value()->mutable_flex_ray_stats()); - break; - } - case nixnet_grpc::ReadState::READ_STATE_J1939_COMM: { - convert_to_grpc(*(_nxJ1939CommState_t*)state_value_raw, response->mutable_state_value()->mutable_j1939_comm_state()); - break; - } - case nixnet_grpc::ReadState::READ_STATE_TIME_CURRENT_2: { - convert_to_grpc(*(_nxTimeLocalNetwork_t*)state_value_raw, response->mutable_state_value()->mutable_time_current2()); - break; - } - case nixnet_grpc::ReadState::READ_STATE_TIME_COMMUNICATING_2: { - convert_to_grpc(*(_nxTimeLocalNetwork_t*)state_value_raw, response->mutable_state_value()->mutable_time_communicating2()); - break; - } - case nixnet_grpc::ReadState::READ_STATE_TIME_START_2: { - convert_to_grpc(*(_nxTimeLocalNetwork_t*)state_value_raw, response->mutable_state_value()->mutable_time_start2()); - break; - } - default: { - return ::grpc::Status(::grpc::INVALID_ARGUMENT, "The value for state_id was not specified or out of range"); - } + void* state_value_raw = (void*)response->state_value().state_value_raw().data(); + switch (state_id) { + case nixnet_grpc::ReadState::READ_STATE_TIME_CURRENT: { + response->mutable_state_value()->set_time_current(*(nxTimestamp100ns_t*)state_value_raw); + break; + } + case nixnet_grpc::ReadState::READ_STATE_TIME_COMMUNICATING: { + response->mutable_state_value()->set_time_communicating(*(nxTimestamp100ns_t*)state_value_raw); + break; + } + case nixnet_grpc::ReadState::READ_STATE_TIME_START: { + response->mutable_state_value()->set_time_start(*(nxTimestamp100ns_t*)state_value_raw); + break; + } + case nixnet_grpc::ReadState::READ_STATE_CAN_COMM: { + SetCanCommResponse(*(u32*)state_value_raw, response->mutable_state_value()->mutable_can_comm()); + break; + } + case nixnet_grpc::ReadState::READ_STATE_FLEX_RAY_COMM: { + SetFlexRayCommResponse(*(u32*)state_value_raw, response->mutable_state_value()->mutable_flex_ray_comm()); + break; + } + case nixnet_grpc::ReadState::READ_STATE_LIN_COMM: { + SetLinCommResponse((u32*)state_value_raw, response->mutable_state_value()->mutable_lin_comm()); + break; + } + case nixnet_grpc::ReadState::READ_STATE_SESSION_INFO: { + SetSessionInfoResponse(*(u32*)state_value_raw, response->mutable_state_value()->mutable_session_info()); + break; + } + case nixnet_grpc::ReadState::READ_STATE_FLEX_RAY_STATS: { + convert_to_grpc(*(_nxFlexRayStats_t*)state_value_raw, response->mutable_state_value()->mutable_flex_ray_stats()); + break; + } + case nixnet_grpc::ReadState::READ_STATE_J1939_COMM: { + convert_to_grpc(*(_nxJ1939CommState_t*)state_value_raw, response->mutable_state_value()->mutable_j1939_comm_state()); + break; + } + case nixnet_grpc::ReadState::READ_STATE_TIME_CURRENT_2: { + convert_to_grpc(*(_nxTimeLocalNetwork_t*)state_value_raw, response->mutable_state_value()->mutable_time_current2()); + break; + } + case nixnet_grpc::ReadState::READ_STATE_TIME_COMMUNICATING_2: { + convert_to_grpc(*(_nxTimeLocalNetwork_t*)state_value_raw, response->mutable_state_value()->mutable_time_communicating2()); + break; + } + case nixnet_grpc::ReadState::READ_STATE_TIME_START_2: { + convert_to_grpc(*(_nxTimeLocalNetwork_t*)state_value_raw, response->mutable_state_value()->mutable_time_start2()); + break; + } + default: { + return ::grpc::Status(::grpc::INVALID_ARGUMENT, "The value for state_id was not specified or out of range"); } - response->set_fault(fault); } + response->set_fault(fault); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -307,6 +307,9 @@ ::grpc::Status NiXnetService::WriteState(::grpc::ServerContext* context, const W } } auto status = library_->WriteState(session, state_id, state_size, &state_value); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNxSessionRef_t(status, session); + } response->set_status(status); return ::grpc::Status::OK; } @@ -368,57 +371,62 @@ ::grpc::Status NiXnetService::GetProperty(::grpc::ServerContext* context, const u32 property_size{}; auto status = library_->GetPropertySize(session, property_id, &property_size); if (!status_ok(status)) { - response->set_status(status); - return ::grpc::Status::OK; + return ConvertApiErrorStatusForNxSessionRef_t(status, session); } switch (property_type_map_[property_id]) { case u32_: { u32 property_value{}; status = library_->GetProperty(session, property_id, property_size, &property_value); - if (status_ok(status)) { - response->set_u32_scalar(property_value); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNxSessionRef_t(status, session); } + response->set_u32_scalar(property_value); break; } case boolean_: { bool property_value{}; status = library_->GetProperty(session, property_id, property_size, &property_value); - if (status_ok(status)) { - response->set_bool_scalar(property_value); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNxSessionRef_t(status, session); } + response->set_bool_scalar(property_value); break; } case u64_: { u64 property_value{}; status = library_->GetProperty(session, property_id, property_size, &property_value); - if (status_ok(status)) { - response->set_u64_scalar(property_value); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNxSessionRef_t(status, session); } + response->set_u64_scalar(property_value); break; } case i32_: { i32 property_value{}; status = library_->GetProperty(session, property_id, property_size, &property_value); - if (status_ok(status)) { - response->set_i32_scalar(property_value); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNxSessionRef_t(status, session); } + response->set_i32_scalar(property_value); break; } case f64_: { f64 property_value{}; status = library_->GetProperty(session, property_id, property_size, &property_value); - if (status_ok(status)) { - response->set_f64_scalar(property_value); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNxSessionRef_t(status, session); } + response->set_f64_scalar(property_value); break; } case string_: { std::string property_value(property_size, '\0'); status = library_->GetProperty(session, property_id, property_size, const_cast(property_value.c_str())); - if (status_ok(status)) { - response->set_str(property_value.c_str()); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNxSessionRef_t(status, session); } + response->set_str(property_value.c_str()); break; } case u32_array_: { @@ -427,6 +435,9 @@ ::grpc::Status NiXnetService::GetProperty(::grpc::ServerContext* context, const response->mutable_u32_array()->mutable_u32_array()->Resize(number_of_elements, 0); u32* property_value = reinterpret_cast(response->mutable_u32_array()->mutable_u32_array()->mutable_data()); status = library_->GetProperty(session, property_id, property_size, property_value); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNxSessionRef_t(status, session); + } break; } case db_ref_: { @@ -438,9 +449,10 @@ ::grpc::Status NiXnetService::GetProperty(::grpc::ServerContext* context, const }; uint32_t session_id = 0; status = nx_database_ref_t_resource_repository_->add_dependent_session("", init_lambda, initiating_session_id, session_id); - if (status_ok(status)) { - response->mutable_db_ref()->set_id(session_id); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNxSessionRef_t(status, session); } + response->mutable_db_ref()->set_id(session_id); break; } case db_ref_array_: { @@ -449,24 +461,25 @@ ::grpc::Status NiXnetService::GetProperty(::grpc::ServerContext* context, const std::vector property_value_vector(number_of_elements, 0U); nxDatabaseRef_t* property_value = static_cast(property_value_vector.data()); status = library_->GetProperty(session, property_id, property_size, property_value); - if (status_ok(status)) { - response->mutable_db_ref_array()->mutable_db_ref()->Clear(); - response->mutable_db_ref_array()->mutable_db_ref()->Reserve(number_of_elements); - std::transform( - property_value_vector.begin(), - property_value_vector.end(), - google::protobuf::RepeatedFieldBackInserter(response->mutable_db_ref_array()->mutable_db_ref()), - [&](auto x) { - auto init_lambda = [&]() { - return std::make_tuple(status, x); - }; - uint32_t session_id{}; - status = nx_database_ref_t_resource_repository_->add_dependent_session("", init_lambda, initiating_session_id, session_id); - nidevice_grpc::Session dependent_session{}; - dependent_session.set_id(session_id); - return dependent_session; - }); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNxSessionRef_t(status, session); } + response->mutable_db_ref_array()->mutable_db_ref()->Clear(); + response->mutable_db_ref_array()->mutable_db_ref()->Reserve(number_of_elements); + std::transform( + property_value_vector.begin(), + property_value_vector.end(), + google::protobuf::RepeatedFieldBackInserter(response->mutable_db_ref_array()->mutable_db_ref()), + [&](auto x) { + auto init_lambda = [&]() { + return std::make_tuple(status, x); + }; + uint32_t session_id{}; + status = nx_database_ref_t_resource_repository_->add_dependent_session("", init_lambda, initiating_session_id, session_id); + nidevice_grpc::Session dependent_session{}; + dependent_session.set_id(session_id); + return dependent_session; + }); break; } case dev_ref_: { @@ -480,9 +493,10 @@ ::grpc::Status NiXnetService::GetProperty(::grpc::ServerContext* context, const // We are adding it to session_repository_ and not to "device repository", because devices don't have a close API, // so it makes sense to tie their lifetime with session's lifetime. status = session_repository_->add_dependent_session("", init_lambda, initiating_session_id, session_id); - if (status_ok(status)) { - response->mutable_dev_ref()->set_id(session_id); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNxSessionRef_t(status, session); } + response->mutable_dev_ref()->set_id(session_id); break; } case dev_ref_array_: { @@ -491,26 +505,27 @@ ::grpc::Status NiXnetService::GetProperty(::grpc::ServerContext* context, const std::vector property_value_vector(number_of_elements, 0U); nxSessionRef_t* property_value = property_value_vector.data(); status = library_->GetProperty(session, property_id, property_size, property_value); - if (status_ok(status)) { - response->mutable_dev_ref_array()->mutable_dev_ref()->Clear(); - response->mutable_dev_ref_array()->mutable_dev_ref()->Reserve(number_of_elements); - std::transform( - property_value_vector.begin(), - property_value_vector.end(), - google::protobuf::RepeatedFieldBackInserter(response->mutable_dev_ref_array()->mutable_dev_ref()), - [&](auto x) { - auto init_lambda = [&]() { - return std::make_tuple(status, x); - }; - uint32_t session_id{}; - // We are adding it to session_repository_ and not to "device repository", because devices don't have a close API, - // so it makes sense to tie their lifetime with session's lifetime. - status = session_repository_->add_dependent_session("", init_lambda, initiating_session_id, session_id); - nidevice_grpc::Session dependent_session{}; - dependent_session.set_id(session_id); - return dependent_session; - }); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNxSessionRef_t(status, session); } + response->mutable_dev_ref_array()->mutable_dev_ref()->Clear(); + response->mutable_dev_ref_array()->mutable_dev_ref()->Reserve(number_of_elements); + std::transform( + property_value_vector.begin(), + property_value_vector.end(), + google::protobuf::RepeatedFieldBackInserter(response->mutable_dev_ref_array()->mutable_dev_ref()), + [&](auto x) { + auto init_lambda = [&]() { + return std::make_tuple(status, x); + }; + uint32_t session_id{}; + // We are adding it to session_repository_ and not to "device repository", because devices don't have a close API, + // so it makes sense to tie their lifetime with session's lifetime. + status = session_repository_->add_dependent_session("", init_lambda, initiating_session_id, session_id); + nidevice_grpc::Session dependent_session{}; + dependent_session.set_id(session_id); + return dependent_session; + }); break; } case intf_ref_array_: { @@ -519,26 +534,27 @@ ::grpc::Status NiXnetService::GetProperty(::grpc::ServerContext* context, const std::vector property_value_vector(number_of_elements, 0U); nxSessionRef_t* property_value = property_value_vector.data(); status = library_->GetProperty(session, property_id, property_size, property_value); - if (status_ok(status)) { - response->mutable_intf_ref_array()->mutable_intf_ref()->Clear(); - response->mutable_intf_ref_array()->mutable_intf_ref()->Reserve(number_of_elements); - std::transform( - property_value_vector.begin(), - property_value_vector.end(), - google::protobuf::RepeatedFieldBackInserter(response->mutable_intf_ref_array()->mutable_intf_ref()), - [&](auto x) { - auto init_lambda = [&]() { - return std::make_tuple(status, x); - }; - uint32_t session_id{}; - // We are adding it to session_repository_ and not to "interface repository", because interfaces don't have a close API, - // so it makes sense to tie their lifetime with session's lifetime. - status = session_repository_->add_dependent_session("", init_lambda, initiating_session_id, session_id); - nidevice_grpc::Session dependent_session{}; - dependent_session.set_id(session_id); - return dependent_session; - }); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNxSessionRef_t(status, session); } + response->mutable_intf_ref_array()->mutable_intf_ref()->Clear(); + response->mutable_intf_ref_array()->mutable_intf_ref()->Reserve(number_of_elements); + std::transform( + property_value_vector.begin(), + property_value_vector.end(), + google::protobuf::RepeatedFieldBackInserter(response->mutable_intf_ref_array()->mutable_intf_ref()), + [&](auto x) { + auto init_lambda = [&]() { + return std::make_tuple(status, x); + }; + uint32_t session_id{}; + // We are adding it to session_repository_ and not to "interface repository", because interfaces don't have a close API, + // so it makes sense to tie their lifetime with session's lifetime. + status = session_repository_->add_dependent_session("", init_lambda, initiating_session_id, session_id); + nidevice_grpc::Session dependent_session{}; + dependent_session.set_id(session_id); + return dependent_session; + }); break; } case nxEptRxFilter_Element_t_array_: { @@ -546,9 +562,10 @@ ::grpc::Status NiXnetService::GetProperty(::grpc::ServerContext* context, const std::vector property_value_vector(number_of_elements); nxEptRxFilter_Element_t* property_value = static_cast(property_value_vector.data()); status = library_->GetProperty(session, property_id, property_size, &property_value); - if (status_ok(status)) { - convert_to_grpc(property_value_vector, response->mutable_ept_rx_filter_array()->mutable_ept_rx_filter()); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNxSessionRef_t(status, session); } + convert_to_grpc(property_value_vector, response->mutable_ept_rx_filter_array()->mutable_ept_rx_filter()); break; } default: { @@ -595,33 +612,35 @@ ::grpc::Status NiXnetService::GetSubProperty(::grpc::ServerContext* context, con u32 property_size{}; auto status = library_->GetSubPropertySize(session, active_index, property_id, &property_size); if (!status_ok(status)) { - response->set_status(status); - return ::grpc::Status::OK; + return ConvertApiErrorStatusForNxSessionRef_t(status, session); } switch (subproperty_type_map_[property_id]) { case u32_: { u32 property_value{}; status = library_->GetSubProperty(session, active_index, property_id, property_size, &property_value); - if (status_ok(status)) { - response->set_u32_scalar(property_value); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNxSessionRef_t(status, session); } + response->set_u32_scalar(property_value); break; } case f64_: { f64 property_value{}; status = library_->GetSubProperty(session, active_index, property_id, property_size, &property_value); - if (status_ok(status)) { - response->set_f64_scalar(property_value); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNxSessionRef_t(status, session); } + response->set_f64_scalar(property_value); break; } case string_: { std::string property_value(property_size, '\0'); status = library_->GetSubProperty(session, active_index, property_id, property_size, const_cast(property_value.c_str())); if (!status_ok(status)) { - response->set_str(property_value.c_str()); + return ConvertApiErrorStatusForNxSessionRef_t(status, session); } + response->set_str(property_value.c_str()); break; } default: { @@ -667,49 +686,53 @@ ::grpc::Status NiXnetService::DbGetProperty(::grpc::ServerContext* context, cons u32 property_size{}; auto status = library_->DbGetPropertySize(dbobject, property_id, &property_size); if (!status_ok(status)) { - response->set_status(status); - return ::grpc::Status::OK; + return ConvertApiErrorStatusForNxDatabaseRef_t(status, dbobject); } switch (dbproperty_type_map_[property_id]) { case u32_: { u32 property_value{}; status = library_->DbGetProperty(dbobject, property_id, property_size, &property_value); - if (status_ok(status)) { - response->set_u32_scalar(property_value); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNxDatabaseRef_t(status, dbobject); } + response->set_u32_scalar(property_value); break; } case boolean_: { bool property_value{}; status = library_->DbGetProperty(dbobject, property_id, property_size, &property_value); - if (status_ok(status)) { - response->set_bool_scalar(property_value); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNxDatabaseRef_t(status, dbobject); } + response->set_bool_scalar(property_value); break; } case u64_: { u64 property_value{}; status = library_->DbGetProperty(dbobject, property_id, property_size, &property_value); if (!status_ok(status)) { - response->set_u64_scalar(property_value); + return ConvertApiErrorStatusForNxDatabaseRef_t(status, dbobject); } + response->set_u64_scalar(property_value); break; } case f64_: { f64 property_value{}; status = library_->DbGetProperty(dbobject, property_id, property_size, &property_value); if (!status_ok(status)) { - response->set_f64_scalar(property_value); + return ConvertApiErrorStatusForNxDatabaseRef_t(status, dbobject); } + response->set_f64_scalar(property_value); break; } case string_: { std::string property_value(property_size, '\0'); status = library_->DbGetProperty(dbobject, property_id, property_size, const_cast(property_value.c_str())); if (!status_ok(status)) { - response->set_str(property_value.c_str()); + return ConvertApiErrorStatusForNxDatabaseRef_t(status, dbobject); } + response->set_str(property_value.c_str()); break; } case u32_array_: { @@ -718,15 +741,19 @@ ::grpc::Status NiXnetService::DbGetProperty(::grpc::ServerContext* context, cons response->mutable_u32_array()->mutable_u32_array()->Resize(number_of_elements, 0); u32* property_value = reinterpret_cast(response->mutable_u32_array()->mutable_u32_array()->mutable_data()); status = library_->DbGetProperty(dbobject, property_id, property_size, property_value); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNxDatabaseRef_t(status, dbobject); + } break; } case u8_array_: { int32_t number_of_elements = property_size / sizeof(u8); std::string property_value(number_of_elements, '\0'); status = library_->DbGetProperty(dbobject, property_id, property_size, (u8*)property_value.data()); - if (status_ok(status)) { - response->set_u8_array(property_value); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNxDatabaseRef_t(status, dbobject); } + response->set_u8_array(property_value); } case db_ref_: { auto initiating_session_id = nx_database_ref_t_resource_repository_->access_session_id(dbobject_grpc_session.id(), dbobject_grpc_session.name()); @@ -737,9 +764,10 @@ ::grpc::Status NiXnetService::DbGetProperty(::grpc::ServerContext* context, cons }; uint32_t session_id = 0; status = nx_database_ref_t_resource_repository_->add_dependent_session("", init_lambda, initiating_session_id, session_id); - if (status_ok(status)) { - response->mutable_db_ref()->set_id(session_id); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNxDatabaseRef_t(status, dbobject); } + response->mutable_db_ref()->set_id(session_id); break; } case db_ref_array_: { @@ -748,24 +776,25 @@ ::grpc::Status NiXnetService::DbGetProperty(::grpc::ServerContext* context, cons std::vector property_value_vector(number_of_elements, 0U); nxDatabaseRef_t* property_value = static_cast(property_value_vector.data()); status = library_->DbGetProperty(dbobject, property_id, property_size, property_value); - if (status_ok(status)) { - response->mutable_db_ref_array()->mutable_db_ref()->Clear(); - response->mutable_db_ref_array()->mutable_db_ref()->Reserve(number_of_elements); - std::transform( - property_value_vector.begin(), - property_value_vector.end(), - google::protobuf::RepeatedFieldBackInserter(response->mutable_db_ref_array()->mutable_db_ref()), - [&](auto x) { - auto init_lambda = [&]() { - return std::make_tuple(status, x); - }; - uint32_t session_id{}; - status = nx_database_ref_t_resource_repository_->add_dependent_session("", init_lambda, initiating_session_id, session_id); - nidevice_grpc::Session dependent_session{}; - dependent_session.set_id(session_id); - return dependent_session; - }); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNxDatabaseRef_t(status, dbobject); } + response->mutable_db_ref_array()->mutable_db_ref()->Clear(); + response->mutable_db_ref_array()->mutable_db_ref()->Reserve(number_of_elements); + std::transform( + property_value_vector.begin(), + property_value_vector.end(), + google::protobuf::RepeatedFieldBackInserter(response->mutable_db_ref_array()->mutable_db_ref()), + [&](auto x) { + auto init_lambda = [&]() { + return std::make_tuple(status, x); + }; + uint32_t session_id{}; + status = nx_database_ref_t_resource_repository_->add_dependent_session("", init_lambda, initiating_session_id, session_id); + nidevice_grpc::Session dependent_session{}; + dependent_session.set_id(session_id); + return dependent_session; + }); break; } default: { @@ -888,6 +917,9 @@ ::grpc::Status NiXnetService::SetProperty(::grpc::ServerContext* context, const break; } } + if (!status_ok(status)) { + return ConvertApiErrorStatusForNxSessionRef_t(status, session); + } response->set_status(status); return ::grpc::Status::OK; } @@ -949,6 +981,9 @@ ::grpc::Status NiXnetService::SetSubProperty(::grpc::ServerContext* context, con break; } } + if (!status_ok(status)) { + return ConvertApiErrorStatusForNxSessionRef_t(status, session); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1050,6 +1085,9 @@ ::grpc::Status NiXnetService::DbSetProperty(::grpc::ServerContext* context, cons break; } } + if (!status_ok(status)) { + return ConvertApiErrorStatusForNxDatabaseRef_t(status, dbobject); + } response->set_status(status); return ::grpc::Status::OK; } @@ -1074,8 +1112,7 @@ ::grpc::Status NiXnetService::DbGetDatabaseList(::grpc::ServerContext* context, u32 size_of_file_path_buffer{}; auto status = library_->DbGetDatabaseListSizes(ip_address, &size_of_alias_buffer, &size_of_file_path_buffer); if (!status_ok(status)) { - response->set_status(status); - return ::grpc::Status::OK; + return ConvertApiErrorStatusForNxDatabaseRef_t(status, 0); } std::string alias_buffer(size_of_alias_buffer, '\0'); @@ -1083,12 +1120,13 @@ ::grpc::Status NiXnetService::DbGetDatabaseList(::grpc::ServerContext* context, u32 number_of_databases{}; status = library_->DbGetDatabaseList(ip_address, size_of_alias_buffer, const_cast(alias_buffer.c_str()), size_of_file_path_buffer, const_cast(file_path_buffer.c_str()), &number_of_databases); - response->set_status(status); - if (status_ok(status)) { - response->set_alias_buffer(alias_buffer.c_str()); - response->set_filepath_buffer(file_path_buffer.c_str()); - response->set_number_of_databases(number_of_databases); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNxDatabaseRef_t(status, 0); } + response->set_status(status); + response->set_alias_buffer(alias_buffer.c_str()); + response->set_filepath_buffer(file_path_buffer.c_str()); + response->set_number_of_databases(number_of_databases); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -1106,7 +1144,7 @@ ::grpc::Status NiXnetService::DbGetDBCAttribute(::grpc::ServerContext* context, } try { auto db_object_grpc_session = request->db_object(); - nxDatabaseRef_t db_object = nx_database_ref_t_resource_repository_->access_session(db_object_grpc_session.id(), db_object_grpc_session.name()); + nxDatabaseRef_t dbobject = nx_database_ref_t_resource_repository_->access_session(db_object_grpc_session.id(), db_object_grpc_session.name()); u32 mode; switch (request->mode_enum_case()) { case nixnet_grpc::DbGetDBCAttributeRequest::ModeEnumCase::kMode: { @@ -1125,21 +1163,21 @@ ::grpc::Status NiXnetService::DbGetDBCAttribute(::grpc::ServerContext* context, auto attribute_name = request->attribute_name().c_str(); u32 attribute_text_size{}; - auto status = library_->DbGetDBCAttributeSize(db_object, mode, attribute_name, &attribute_text_size); + auto status = library_->DbGetDBCAttributeSize(dbobject, mode, attribute_name, &attribute_text_size); if (!status_ok(status)) { - response->set_status(status); - return ::grpc::Status::OK; + return ConvertApiErrorStatusForNxDatabaseRef_t(status, dbobject); } std::string attribute_text(attribute_text_size, '\0'); u32 is_default{}; - status = library_->DbGetDBCAttribute(db_object, mode, attribute_name, attribute_text_size, const_cast(attribute_text.c_str()), &is_default); - response->set_status(status); - if (status_ok(status)) { - response->set_is_default(is_default); - response->set_attribute_text(attribute_text.c_str()); + status = library_->DbGetDBCAttribute(dbobject, mode, attribute_name, attribute_text_size, const_cast(attribute_text.c_str()), &is_default); + if (!status_ok(status)) { + return ConvertApiErrorStatusForNxDatabaseRef_t(status, dbobject); } + response->set_status(status); + response->set_is_default(is_default); + response->set_attribute_text(attribute_text.c_str()); return ::grpc::Status::OK; } catch (nidevice_grpc::LibraryLoadException& ex) { @@ -1147,6 +1185,22 @@ ::grpc::Status NiXnetService::DbGetDBCAttribute(::grpc::ServerContext* context, } } +::grpc::Status NiXnetService::ConvertApiErrorStatusForNxSessionRef_t(google::protobuf::int32 status, nxSessionRef_t session) +{ + static_assert(nidevice_grpc::kMaxGrpcErrorDescriptionSize >= 2048, "StatusToString expects a minimum buffer size."); + std::string description(nidevice_grpc::kMaxGrpcErrorDescriptionSize, '\0'); + library_->StatusToString(status, nidevice_grpc::kMaxGrpcErrorDescriptionSize, &description[0]); + return nidevice_grpc::ApiErrorAndDescriptionToStatus(status, description); +} + +::grpc::Status NiXnetService::ConvertApiErrorStatusForNxDatabaseRef_t(google::protobuf::int32 status, nxDatabaseRef_t session) +{ + static_assert(nidevice_grpc::kMaxGrpcErrorDescriptionSize >= 2048, "StatusToString expects a minimum buffer size."); + std::string description(nidevice_grpc::kMaxGrpcErrorDescriptionSize, '\0'); + library_->StatusToString(status, nidevice_grpc::kMaxGrpcErrorDescriptionSize, &description[0]); + return nidevice_grpc::ApiErrorAndDescriptionToStatus(status, description); +} + void convert_to_grpc(std::vector& input, google::protobuf::RepeatedPtrField* output, u32 number_of_bytes, u32 protocol, std::map enetflags_output_map) { auto buffer_ptr = (void*)input.data(); diff --git a/source/custom/nixnetsocket_service.custom.cpp b/source/custom/nixnetsocket_service.custom.cpp index 180a55c16..93a085302 100644 --- a/source/custom/nixnetsocket_service.custom.cpp +++ b/source/custom/nixnetsocket_service.custom.cpp @@ -1,2 +1,27 @@ +#include + namespace nixnetsocket_grpc { + +::grpc::Status NiXnetSocketService::ConvertApiErrorStatusForNxSOCKET(google::protobuf::int32 status, nxSOCKET socket) +{ + // This implementation assumes this method is always called on the same thread where the error occurred. + std::string description(nidevice_grpc::kMaxGrpcErrorDescriptionSize, '\0'); + library_->GetLastErrorStr(&description[0], nidevice_grpc::kMaxGrpcErrorDescriptionSize); + // XNET sockets have special behavior that returns both the API error code and the sockets error number. + int errorNumber = library_->GetLastErrorNum(); + nlohmann::json jsonError{{"errorNumber", errorNumber}}; + return nidevice_grpc::ApiErrorAndDescriptionToStatus(status, description, jsonError); +} + +::grpc::Status NiXnetSocketService::ConvertApiErrorStatusForNxIpStackRef_t(google::protobuf::int32 status, nxIpStackRef_t socket) +{ + // This implementation assumes this method is always called on the same thread where the error occurred. + std::string description(nidevice_grpc::kMaxGrpcErrorDescriptionSize, '\0'); + library_->GetLastErrorStr(&description[0], nidevice_grpc::kMaxGrpcErrorDescriptionSize); + // XNET sockets have special behavior that returns both the API error code and the sockets error number. + int errorNumber = library_->GetLastErrorNum(); + nlohmann::json jsonError{{"errorNumber", errorNumber}}; + return nidevice_grpc::ApiErrorAndDescriptionToStatus(status, description, jsonError); +} + } // namespace nixnetsocket_grpc diff --git a/source/server/converters.h b/source/server/converters.h index c51c90671..b165646b4 100644 --- a/source/server/converters.h +++ b/source/server/converters.h @@ -3,7 +3,9 @@ #include #include +#include #include // For common grpc types. +#include #include // For common C types. #include @@ -317,6 +319,22 @@ typename TypeToStorageType::StorageType allocate_output_ } } // namespace converters + +const int kMaxGrpcErrorDescriptionSize = 2048; + +inline ::grpc::Status ApiErrorAndDescriptionToStatus(int32_t status, std::string& description, nlohmann::json& jsonError) +{ + converters::trim_trailing_nulls(description); + jsonError["code"] = status; + jsonError["message"] = description; + return ::grpc::Status(grpc::StatusCode::UNKNOWN, nlohmann::to_string(jsonError)); +} + +inline ::grpc::Status ApiErrorAndDescriptionToStatus(int32_t status, std::string& description) +{ + nlohmann::json jsonError; + return ApiErrorAndDescriptionToStatus(status, description, jsonError); +} } // namespace nidevice_grpc #endif /* NIDEVICE_GRPC_DEVICE_CONVERTERS_H */ diff --git a/source/tests/system/nidaqmx_driver_api_tests.cpp b/source/tests/system/nidaqmx_driver_api_tests.cpp index cc8bddc51..ed3fed160 100644 --- a/source/tests/system/nidaqmx_driver_api_tests.cpp +++ b/source/tests/system/nidaqmx_driver_api_tests.cpp @@ -1,6 +1,7 @@ #include #include #include // For EXPECT matchers. +#include #include #include @@ -12,6 +13,7 @@ #include "enumerate_devices.h" #include "nidaqmx/nidaqmx_client.h" +using namespace ::nlohmann; using namespace ::testing; using namespace nidaqmx_grpc; using google::protobuf::uint32; @@ -719,17 +721,16 @@ class NiDAQmxDriverApiTests : public Test { EXPECT_EQ(::grpc::Status::OK.error_code(), status.error_code()); } - template - void EXPECT_DAQ_ERROR(int32_t expected_error, const TResponse& response) + void EXPECT_DAQ_ERROR(int32_t expected_error, const std::string& error_message) { - EXPECT_EQ(expected_error, response.status()); + auto error = json::parse(error_message); + EXPECT_EQ(expected_error, error.value("code", 0)); } - template - void EXPECT_DAQ_ERROR(int32_t expected_error, const ::grpc::Status& status, const TResponse& response) + void EXPECT_DAQ_ERROR(int32_t expected_error, const ::grpc::Status& status) { - EXPECT_DAQ_ERROR(expected_error, response); - EXPECT_EQ(::grpc::Status::OK.error_code(), status.error_code()); + EXPECT_EQ(::grpc::StatusCode::UNKNOWN, status.error_code()); + EXPECT_DAQ_ERROR(expected_error, status.error_message()); } template @@ -1000,12 +1001,16 @@ TEST_F(NiDAQmxDriverApiTests, GetScaledUnitsAsDouble_Fails) ScaleStringAttribute::SCALE_ATTRIBUTE_SCALED_UNITS, UNITS); - auto response = client::get_scale_attribute_double( + try { + client::get_scale_attribute_double( stub(), SCALE_NAME, (ScaleDoubleAttribute)ScaleStringAttribute::SCALE_ATTRIBUTE_SCALED_UNITS); - - EXPECT_DAQ_ERROR(SPECIFIED_ATTRIBUTE_NOT_VALID_ERROR, response); + EXPECT_FALSE(true); + } + catch (const std::runtime_error& ex) { + EXPECT_DAQ_ERROR(SPECIFIED_ATTRIBUTE_NOT_VALID_ERROR, ex.what()); + } } TEST_F(NiDAQmxDriverApiTests, SetScaledUnits_GetScaledUnits_ReturnsAttribute) @@ -1078,10 +1083,10 @@ TEST_F(NiDAQmxDriverApiTests, AOVoltageChannel_WriteAODataWithOutOfRangeValue_Re auto write_data = generate_random_data(AO_MIN, AO_MAX, 100); write_data[80] += AO_MAX; WriteAnalogF64Response write_response; - write_analog_f64(write_data, write_response); + auto status = write_analog_f64(write_data, write_response); stop_task(); - EXPECT_EQ(INVALID_AO_DATA_WRITE_ERROR, write_response.status()); + EXPECT_DAQ_ERROR(INVALID_AO_DATA_WRITE_ERROR, status); } TEST_F(NiDAQmxDriverApiTests, TaskWithAOChannel_GetNthTaskDevice_ReturnsDeviceForChannel) @@ -1368,7 +1373,7 @@ TEST_F(NiDAQmxDriverApiTests, AIVoltageChannel_WaitForValidTimestamp_ReturnsErro auto response = WaitForValidTimestampResponse{}; auto status = wait_for_valid_timestamp(response); - EXPECT_DAQ_ERROR(WAIT_FOR_VALID_TIMESTAMP_NOT_SUPPORTED_ERROR, status, response); + EXPECT_DAQ_ERROR(WAIT_FOR_VALID_TIMESTAMP_NOT_SUPPORTED_ERROR, status); } TEST_F(NiDAQmxDriverApiTests, AIVoltageChannel_CfgTimeStartTrig_ReturnsError) @@ -1378,7 +1383,7 @@ TEST_F(NiDAQmxDriverApiTests, AIVoltageChannel_CfgTimeStartTrig_ReturnsError) auto response = CfgTimeStartTrigResponse{}; auto status = cfg_time_start_trig(response); - EXPECT_DAQ_ERROR(INVALID_ATTRIBUTE_VALUE_ERROR, status, response); + EXPECT_DAQ_ERROR(INVALID_ATTRIBUTE_VALUE_ERROR, status); } TEST_F(NiDAQmxDriverApiTests, LoadedVoltageTask_ReadAIData_ReturnsDataInExpectedRange) @@ -1415,14 +1420,18 @@ TEST_F(NiDAQmxDriverApiTests, AddNetworkDeviceWithInvalidIP_ErrorRetrievingNetwo auto response = AddNetworkDeviceResponse{}; auto status = add_network_device("0.0.0.0", response); - EXPECT_DAQ_ERROR(RETRIEVING_NETWORK_DEVICE_PROPERTIES_ERROR, status, response); + EXPECT_DAQ_ERROR(RETRIEVING_NETWORK_DEVICE_PROPERTIES_ERROR, status); } TEST_F(NiDAQmxDriverApiTests, ConfigureTEDSOnNonTEDSChannel_ErrorTEDSSensorNotDetected) { - auto response = client::configure_teds(stub(), AI_CHANNEL, ""); - - EXPECT_DAQ_ERROR(TEDS_SENSOR_NOT_DETECTED_ERROR, response); + try { + client::configure_teds(stub(), AI_CHANNEL, ""); + EXPECT_FALSE(true); + } + catch (const std::runtime_error& ex) { + EXPECT_DAQ_ERROR(TEDS_SENSOR_NOT_DETECTED_ERROR, ex.what()); + } } TEST_F(NiDAQmxDriverApiTests, HardwareTimedTask_WaitForNextSampleClock_Succeeds) @@ -1451,7 +1460,7 @@ TEST_F(NiDAQmxDriverApiTests, ConnectBogusTerms_FailsWithInvalidRoutingError) auto response = ConnectTermsResponse{}; auto status = connect_terms("ABC", "123", response); - EXPECT_DAQ_ERROR(INVALID_TERM_ROUTING_ERROR, status, response); + EXPECT_DAQ_ERROR(INVALID_TERM_ROUTING_ERROR, status); } TEST_F(NiDAQmxDriverApiTests, DOWatchdogTask_StartTaskAndWatchdogTask_Succeeds) @@ -1479,9 +1488,13 @@ TEST_F(NiDAQmxDriverApiTests, DOWatchdogTask_StartTaskAndWatchdogTask_Succeeds) TEST_F(NiDAQmxDriverApiTests, AutoConfigureCDAQSyncConnections_ReturnsNotSupportedError) { - auto response = client::auto_configure_cdaq_sync_connections(stub(), DEVICE_NAME, 1.0); - - EXPECT_DAQ_ERROR(DEVICE_DOES_NOT_SUPPORT_CDAQ_SYNC_CONNECTIONS_ERROR, response); + try { + client::auto_configure_cdaq_sync_connections(stub(), DEVICE_NAME, 1.0); + EXPECT_FALSE(true); + } + catch (const std::runtime_error& ex) { + EXPECT_DAQ_ERROR(DEVICE_DOES_NOT_SUPPORT_CDAQ_SYNC_CONNECTIONS_ERROR, ex.what()); + } } TEST_F(NiDAQmxDriverApiTests, DIChannel_GetSetResetInputBufferSize_UpdatesBufferSize) @@ -1698,16 +1711,24 @@ TEST_F(NiDAQmxDriverApiTests, AIChannel_ReconfigureSampQuantSampsPerChan_Updates TEST_F(NiDAQmxDriverApiTests, SetWrongCategoryAttribute_ReturnsNotValidError) { - auto response = client::get_device_attribute_bool(stub(), DEVICE_NAME, ScaleDoubleAttribute::SCALE_ATTRIBUTE_LIN_SLOPE); - - EXPECT_DAQ_ERROR(SPECIFIED_ATTRIBUTE_NOT_VALID_ERROR, response); + try { + client::get_device_attribute_bool(stub(), DEVICE_NAME, ScaleDoubleAttribute::SCALE_ATTRIBUTE_LIN_SLOPE); + EXPECT_FALSE(true); + } + catch (const std::runtime_error& ex) { + EXPECT_DAQ_ERROR(SPECIFIED_ATTRIBUTE_NOT_VALID_ERROR, ex.what()); + } } TEST_F(NiDAQmxDriverApiTests, SetWrongDataTypeAttribute_ReturnsNotValidError) { - auto response = client::get_device_attribute_bool(stub(), DEVICE_NAME, DeviceStringAttribute::DEVICE_ATTRIBUTE_AO_PHYSICAL_CHANS); - - EXPECT_DAQ_ERROR(SPECIFIED_ATTRIBUTE_NOT_VALID_ERROR, response); + try { + client::get_device_attribute_bool(stub(), DEVICE_NAME, DeviceStringAttribute::DEVICE_ATTRIBUTE_AO_PHYSICAL_CHANS); + EXPECT_FALSE(true); + } + catch (const std::runtime_error& ex) { + EXPECT_DAQ_ERROR(SPECIFIED_ATTRIBUTE_NOT_VALID_ERROR, ex.what()); + } } } // namespace diff --git a/source/tests/system/nidcpower_session_tests.cpp b/source/tests/system/nidcpower_session_tests.cpp index e844bfb02..b4bdd0064 100644 --- a/source/tests/system/nidcpower_session_tests.cpp +++ b/source/tests/system/nidcpower_session_tests.cpp @@ -1,5 +1,6 @@ #include #include +#include #include "device_server.h" #include "nidcpower/nidcpower_client.h" @@ -9,6 +10,7 @@ namespace tests { namespace system { namespace dcpower = nidcpower_grpc; +using namespace ::nlohmann; using namespace ::testing; const int kInvalidRsrc = -1074118656; @@ -120,10 +122,10 @@ TEST_F(NiDCPowerSessionTest, InitializeSessionWithoutDevice_ReturnsDriverError) dcpower::InitializeWithChannelsResponse response; ::grpc::Status status = call_initialize_with_channels(kTestInvalidRsrc, "", "", &response); - EXPECT_TRUE(status.ok()); - EXPECT_EQ(kInvalidRsrc, response.status()); - EXPECT_EQ(0, response.vi().id()); - EXPECT_NE("", response.error_message()); + EXPECT_EQ(::grpc::StatusCode::UNKNOWN, status.error_code()); + auto error = json::parse(status.error_message()); + EXPECT_EQ(kInvalidRsrc, error.value("code", 0)); + EXPECT_NE("", error.value("message", "")); } TEST_F(NiDCPowerSessionTest, InitializedSession_CloseSession_ClosesDriverSession) @@ -155,19 +157,21 @@ TEST_F(NiDCPowerSessionTest, InvalidSession_CloseSession_ReturnsInvalidSessionEr dcpower::CloseResponse response; ::grpc::Status status = GetStub()->Close(&context, request, &response); - EXPECT_TRUE(status.ok()); - EXPECT_EQ(kInvalidDCPowerSession, response.status()); - std::string error_message = get_error_message(response.status()); - EXPECT_THAT(error_message.c_str(), HasSubstr(kInvalidDCPowerSessionMessage)); + EXPECT_EQ(::grpc::StatusCode::UNKNOWN, status.error_code()); + auto error = json::parse(status.error_message()); + EXPECT_EQ(kInvalidDCPowerSession, error.value("code", 0)); + EXPECT_THAT(error.value("message", "").c_str(), HasSubstr(kInvalidDCPowerSessionMessage)); } TEST_F(NiDCPowerSessionTest, InitWithErrorFromDriver_ReturnsUserErrorMessage) { dcpower::InitializeWithChannelsResponse initialize_response; - call_initialize_with_channels(kTestInvalidRsrc, "", "", &initialize_response); + auto status = call_initialize_with_channels(kTestInvalidRsrc, "", "", &initialize_response); - EXPECT_EQ(kInvalidRsrc, initialize_response.status()); - EXPECT_STREQ(kViErrorResourceNotFoundMessage, initialize_response.error_message().c_str()); + EXPECT_EQ(::grpc::StatusCode::UNKNOWN, status.error_code()); + auto error = json::parse(status.error_message()); + EXPECT_EQ(kInvalidRsrc, error.value("code", 0)); + EXPECT_STREQ(kViErrorResourceNotFoundMessage, error.value("message", "").c_str()); } } // namespace system diff --git a/source/tests/system/nidigital_session_tests.cpp b/source/tests/system/nidigital_session_tests.cpp index d947bd1cf..4837716ab 100644 --- a/source/tests/system/nidigital_session_tests.cpp +++ b/source/tests/system/nidigital_session_tests.cpp @@ -1,4 +1,5 @@ #include +#include #include "device_server.h" #include "nidigitalpattern/nidigitalpattern_client.h" @@ -8,6 +9,7 @@ namespace tests { namespace system { namespace digital = nidigitalpattern_grpc; +using namespace ::nlohmann; const int kDigitalRsrcNotFound = -1074098043; const char* kDigitalRsrcNotFoundMessage = "Specified string is not valid, because it is empty."; @@ -85,10 +87,10 @@ TEST_F(NiDigitalSessionTest, InitializeSessionWithoutDevice_ReturnsDriverError) digital::InitWithOptionsResponse response; ::grpc::Status status = call_init_with_options(kDigitalInvalidResourceName, "", "", &response); - EXPECT_TRUE(status.ok()); - EXPECT_EQ(kDigitalRsrcNotFound, response.status()); - EXPECT_EQ(0, response.vi().id()); - EXPECT_NE("", response.error_message()); + EXPECT_EQ(::grpc::StatusCode::UNKNOWN, status.error_code()); + auto error = json::parse(status.error_message()); + EXPECT_EQ(kDigitalRsrcNotFound, error.value("code", 0)); + EXPECT_NE("", error.value("message", "")); } TEST_F(NiDigitalSessionTest, InitializedSession_CloseSession_ClosesDriverSession) @@ -110,10 +112,12 @@ TEST_F(NiDigitalSessionTest, InitializedSession_CloseSession_ClosesDriverSession TEST_F(NiDigitalSessionTest, InitWithErrorFromDriver_ReturnsUserErrorMessage) { digital::InitWithOptionsResponse init_response; - call_init_with_options(kDigitalInvalidResourceName, "", "", &init_response); + auto status = call_init_with_options(kDigitalInvalidResourceName, "", "", &init_response); - EXPECT_EQ(kDigitalRsrcNotFound, init_response.status()); - EXPECT_STREQ(kDigitalRsrcNotFoundMessage, init_response.error_message().c_str()); + EXPECT_EQ(::grpc::StatusCode::UNKNOWN, status.error_code()); + auto error = json::parse(status.error_message()); + EXPECT_EQ(kDigitalRsrcNotFound, error.value("code", 0)); + EXPECT_STREQ(kDigitalRsrcNotFoundMessage, error.value("message", "").c_str()); } } // namespace system diff --git a/source/tests/system/nidmm_session_tests.cpp b/source/tests/system/nidmm_session_tests.cpp index a6dfe1a17..54964efac 100644 --- a/source/tests/system/nidmm_session_tests.cpp +++ b/source/tests/system/nidmm_session_tests.cpp @@ -1,5 +1,6 @@ #include #include +#include #include "device_server.h" #include "nidmm/nidmm_client.h" @@ -10,6 +11,7 @@ namespace tests { namespace system { namespace dmm = nidmm_grpc; +using namespace ::nlohmann; using namespace ::testing; const int kViErrorDmmRsrcNFound = -1074118656; @@ -106,10 +108,10 @@ TEST_F(NiDmmSessionTest, InitializeSessionWithoutDevice_ReturnsDriverError) dmm::InitWithOptionsResponse response; ::grpc::Status status = call_init_with_options(kInvalidRsrc, "", "", &response); - EXPECT_TRUE(status.ok()); - EXPECT_EQ(kViErrorDmmRsrcNFound, response.status()); - EXPECT_EQ(0, response.vi().id()); - EXPECT_NE("", response.error_message()); + EXPECT_EQ(::grpc::StatusCode::UNKNOWN, status.error_code()); + auto error = json::parse(status.error_message()); + EXPECT_EQ(kViErrorDmmRsrcNFound, error.value("code", 0)); + EXPECT_NE("", error.value("message", "")); } TEST_F(NiDmmSessionTest, InitializedSession_CloseSession_ClosesDriverSession) @@ -139,19 +141,21 @@ TEST_F(NiDmmSessionTest, InvalidSession_CloseSession_ReturnsInvalidSesssionError dmm::CloseResponse response; ::grpc::Status status = GetStub()->Close(&context, request, &response); - EXPECT_TRUE(status.ok()); - EXPECT_EQ(kInvalidDmmSession, response.status()); - std::string error_message = get_error_message(response.status()); - EXPECT_THAT(error_message.c_str(), HasSubstr(kInvalidDmmSessionMessage)); + EXPECT_EQ(::grpc::StatusCode::UNKNOWN, status.error_code()); + auto error = json::parse(status.error_message()); + EXPECT_EQ(kInvalidDmmSession, error.value("code", 0)); + EXPECT_THAT(error.value("message", "").c_str(), HasSubstr(kInvalidDmmSessionMessage)); } TEST_F(NiDmmSessionTest, InitWithErrorFromDriver_ReturnsUserErrorMessage) { dmm::InitWithOptionsResponse init_response; - call_init_with_options(kInvalidRsrc, "", "", &init_response); + auto status = call_init_with_options(kInvalidRsrc, "", "", &init_response); - EXPECT_EQ(kViErrorDmmRsrcNFound, init_response.status()); - EXPECT_STREQ(kViErrorDmmRsrcNFoundMessage, init_response.error_message().c_str()); + EXPECT_EQ(::grpc::StatusCode::UNKNOWN, status.error_code()); + auto error = json::parse(status.error_message()); + EXPECT_EQ(kViErrorDmmRsrcNFound, error.value("code", 0)); + EXPECT_STREQ(kViErrorDmmRsrcNFoundMessage, error.value("message", "").c_str()); } } // namespace system diff --git a/source/tests/system/nifgen_session_tests.cpp b/source/tests/system/nifgen_session_tests.cpp index 84250f6e8..2e808d976 100644 --- a/source/tests/system/nifgen_session_tests.cpp +++ b/source/tests/system/nifgen_session_tests.cpp @@ -1,5 +1,6 @@ #include #include +#include #include "device_server.h" #include "nifgen/nifgen_client.h" @@ -11,6 +12,7 @@ namespace tests { namespace system { namespace fgen = nifgen_grpc; +using namespace ::nlohmann; const int kInvalidFgenRsrc = -1074134944; const int kInvalidFgenSession = -1074130544; @@ -107,10 +109,10 @@ TEST_F(NiFgenSessionTest, InitializeSessionWithoutDevice_ReturnsDriverError) fgen::InitWithOptionsResponse response; ::grpc::Status status = call_init_with_options(kTestInvalidFgenRsrc, "", "", &response); - EXPECT_TRUE(status.ok()); - EXPECT_EQ(kInvalidFgenRsrc, response.status()); - EXPECT_EQ(0, response.vi().id()); - EXPECT_NE("", response.error_message()); + EXPECT_EQ(::grpc::StatusCode::UNKNOWN, status.error_code()); + auto error = json::parse(status.error_message()); + EXPECT_EQ(kInvalidFgenRsrc, error.value("code", 0)); + EXPECT_NE("", error.value("message", "")); } TEST_F(NiFgenSessionTest, InitializedSession_CloseSession_ClosesDriverSession) @@ -140,19 +142,21 @@ TEST_F(NiFgenSessionTest, InvalidSession_CloseSession_ReturnsInvalidSessionError fgen::CloseResponse response; ::grpc::Status status = GetStub()->Close(&context, request, &response); - EXPECT_TRUE(status.ok()); - EXPECT_EQ(kInvalidFgenSession, response.status()); - std::string error_message = get_error_message(response.status()); - EXPECT_STREQ(kInvalidFgenSessionMessage, error_message.c_str()); + EXPECT_EQ(::grpc::StatusCode::UNKNOWN, status.error_code()); + auto error = json::parse(status.error_message()); + EXPECT_EQ(kInvalidFgenSession, error.value("code", 0)); + EXPECT_STREQ(kInvalidFgenSessionMessage, error.value("message", "").c_str()); } TEST_F(NiFgenSessionTest, InitWithErrorFromDriver_ReturnsUserErrorMessage) { fgen::InitWithOptionsResponse initialize_response; - call_init_with_options(kTestInvalidFgenRsrc, "", "", &initialize_response); + auto status = call_init_with_options(kTestInvalidFgenRsrc, "", "", &initialize_response); - EXPECT_EQ(kInvalidFgenRsrc, initialize_response.status()); - EXPECT_THAT(initialize_response.error_message().c_str(), HasSubstr(kViErrorFgenResourceNotFoundMessage)); + EXPECT_EQ(::grpc::StatusCode::UNKNOWN, status.error_code()); + auto error = json::parse(status.error_message()); + EXPECT_EQ(kInvalidFgenRsrc, error.value("code", 0)); + EXPECT_THAT(error.value("message", "").c_str(), HasSubstr(kViErrorFgenResourceNotFoundMessage)); } } // namespace system diff --git a/source/tests/system/nirfmxbluetooth_driver_api_tests.cpp b/source/tests/system/nirfmxbluetooth_driver_api_tests.cpp index 128573afb..91daa3fea 100644 --- a/source/tests/system/nirfmxbluetooth_driver_api_tests.cpp +++ b/source/tests/system/nirfmxbluetooth_driver_api_tests.cpp @@ -7,6 +7,7 @@ #include "rfmx_macros.h" #include "waveform_helpers.h" +using namespace ::nlohmann; using namespace ::testing; using namespace nirfmxbluetooth_grpc; namespace client = nirfmxbluetooth_grpc::experimental::client; diff --git a/source/tests/system/nirfmxbluetooth_session_tests.cpp b/source/tests/system/nirfmxbluetooth_session_tests.cpp index a59d92191..d64098b0d 100644 --- a/source/tests/system/nirfmxbluetooth_session_tests.cpp +++ b/source/tests/system/nirfmxbluetooth_session_tests.cpp @@ -1,4 +1,5 @@ #include +#include #include "device_server.h" #include "nirfmxbluetooth/nirfmxbluetooth_client.h" @@ -9,6 +10,7 @@ namespace system { namespace { namespace rfmxbluetooth = nirfmxbluetooth_grpc; +using namespace ::nlohmann; const int kInvalidRsrc = -200220; const int kInvalidRFmxBTSession = -380598; @@ -87,9 +89,9 @@ TEST_F(NiRFmxBluetoothSessionTest, InitializeSessionWithoutDevice_ReturnsDriverE rfmxbluetooth::InitializeResponse response; ::grpc::Status status = call_initialize(kRFmxBTTestInvalidRsrc, "", "", &response); - EXPECT_TRUE(status.ok()); - EXPECT_EQ(kInvalidRsrc, response.status()); - EXPECT_EQ(0, response.instrument().id()); + EXPECT_EQ(::grpc::StatusCode::UNKNOWN, status.error_code()); + auto error = json::parse(status.error_message()); + EXPECT_EQ(kInvalidRsrc, error.value("code", 0)); } TEST_F(NiRFmxBluetoothSessionTest, InitializedSession_CloseSession_ClosesDriverSession) @@ -151,10 +153,11 @@ TEST_F(NiRFmxBluetoothSessionTest, CallInitializeTwiceWithSameSessionNameOnSameD EXPECT_TRUE(status_one.ok()); EXPECT_EQ(0, close_response_one.status()); - EXPECT_TRUE(status_two.ok()); // Initialize was only called once in the driver since the second init call to the service found the Session by the same name and returned it. // Therefore if we try to close the session again the driver will respond that it's not a valid session (it's already been closed). - EXPECT_EQ(kInvalidRFmxBTSession, close_response_two.status()); + EXPECT_EQ(::grpc::StatusCode::UNKNOWN, status_two.error_code()); + auto error = json::parse(status_two.error_message()); + EXPECT_EQ(kInvalidRFmxBTSession, error.value("code", 0)); } TEST_F(NiRFmxBluetoothSessionTest, InvalidSession_CloseSession_ReturnsInvalidSessionError) @@ -169,8 +172,9 @@ TEST_F(NiRFmxBluetoothSessionTest, InvalidSession_CloseSession_ReturnsInvalidSes rfmxbluetooth::CloseResponse response; ::grpc::Status status = GetStub()->Close(&context, request, &response); - EXPECT_TRUE(status.ok()); - EXPECT_EQ(kInvalidRFmxBTSession, response.status()); + EXPECT_EQ(::grpc::StatusCode::UNKNOWN, status.error_code()); + auto error = json::parse(status.error_message()); + EXPECT_EQ(kInvalidRFmxBTSession, error.value("code", 0)); } } // namespace diff --git a/source/tests/system/nirfmxlte_driver_api_tests.cpp b/source/tests/system/nirfmxlte_driver_api_tests.cpp index 1f20ab3d8..8c7672656 100644 --- a/source/tests/system/nirfmxlte_driver_api_tests.cpp +++ b/source/tests/system/nirfmxlte_driver_api_tests.cpp @@ -1,10 +1,12 @@ #include +#include #include "device_server.h" #include "nirfmxlte/nirfmxlte_client.h" #include "nirfsa/nirfsa_client.h" #include "rfmx_macros.h" +using namespace ::nlohmann; using namespace ::testing; using namespace nirfmxlte_grpc; namespace client = nirfmxlte_grpc::experimental::client; @@ -341,7 +343,7 @@ TEST_F(NiRFmxLTEDriverApiTests, NBIoTModAccFromExample_FetchData_DataLooksReason { nidevice_grpc::Session session; ModAccFetchCompositeEVMResponse mod_acc_fetch_composite_evm_response; - int attempts = 1; + int actualStatus = -1, attempts = 1; while (1) { session = init_session(stub(), PXI_5663E); EXPECT_SUCCESS(session, client::cfg_frequency_reference(stub(), session, "", FREQUENCY_REFERENCE_SOURCE_ONBOARD_CLOCK, 10e6)); @@ -359,8 +361,15 @@ TEST_F(NiRFmxLTEDriverApiTests, NBIoTModAccFromExample_FetchData_DataLooksReason EXPECT_SUCCESS(session, client::initiate(stub(), session, "", "")); // Intermittently fails with: "Autodetected NPUSCH channel parameters are not 3GPP spec compliant." - mod_acc_fetch_composite_evm_response = client::mod_acc_fetch_composite_evm(stub(), session, "", 10.0); - if (mod_acc_fetch_composite_evm_response.status() == MODACC_NB_IOT_AUTODETECT_CHECK && attempts < 5) { + try { + mod_acc_fetch_composite_evm_response = client::mod_acc_fetch_composite_evm(stub(), session, "", 10.0); + actualStatus = mod_acc_fetch_composite_evm_response.status(); + } + catch (const std::runtime_error& ex) { + auto error = json::parse(ex.what()); + actualStatus = error.value("code", -1); + } + if (actualStatus == MODACC_NB_IOT_AUTODETECT_CHECK && attempts < 5) { TearDown(); SetUp(); ++attempts; @@ -369,10 +378,9 @@ TEST_F(NiRFmxLTEDriverApiTests, NBIoTModAccFromExample_FetchData_DataLooksReason break; } } - EXPECT_SUCCESS(session, mod_acc_fetch_composite_evm_response); - if (mod_acc_fetch_composite_evm_response.status() < 0) { - return; - } + // If this fails, we want the test to be over now. + ASSERT_GE(actualStatus, 0); + const auto mod_acc_fetch_iq_impairments_response = EXPECT_SUCCESS(session, client::mod_acc_fetch_iq_impairments(stub(), session, "", 10.0)); const auto mod_acc_fetch_in_band_emission_margin_response = EXPECT_SUCCESS(session, client::mod_acc_fetch_in_band_emission_margin(stub(), session, "", 10.0)); const auto mod_acc_fetch_npusch_constellation_trace_response = EXPECT_SUCCESS(session, client::mod_acc_fetch_npusch_constellation_trace(stub(), session, "", 10.0)); @@ -407,7 +415,7 @@ TEST_F(NiRFmxLTEDriverApiTests, NBIoTModAccAcpChpObwSemCompositeSingleCarrierFro { nidevice_grpc::Session session; ModAccFetchCompositeEVMResponse mod_acc_fetch_composite_evm_response; - int attempts = 1; + int actualStatus = -1, attempts = 1; while (1) { session = init_session(stub(), PXI_5663E); EXPECT_SUCCESS(session, client::cfg_frequency_reference(stub(), session, "", FREQUENCY_REFERENCE_SOURCE_ONBOARD_CLOCK, 10e6)); @@ -433,8 +441,15 @@ TEST_F(NiRFmxLTEDriverApiTests, NBIoTModAccAcpChpObwSemCompositeSingleCarrierFro EXPECT_SUCCESS(session, client::initiate(stub(), session, "", "")); // Intermittently fails with: "Autodetected NPUSCH channel parameters are not 3GPP spec compliant." - mod_acc_fetch_composite_evm_response = client::mod_acc_fetch_composite_evm(stub(), session, "", 10.0); - if (mod_acc_fetch_composite_evm_response.status() == MODACC_NB_IOT_AUTODETECT_CHECK && attempts < 5) { + try { + mod_acc_fetch_composite_evm_response = client::mod_acc_fetch_composite_evm(stub(), session, "", 10.0); + actualStatus = mod_acc_fetch_composite_evm_response.status(); + } + catch (const std::runtime_error& ex) { + auto error = json::parse(ex.what()); + actualStatus = error.value("code", -1); + } + if (actualStatus == MODACC_NB_IOT_AUTODETECT_CHECK && attempts < 5) { TearDown(); SetUp(); ++attempts; @@ -443,10 +458,9 @@ TEST_F(NiRFmxLTEDriverApiTests, NBIoTModAccAcpChpObwSemCompositeSingleCarrierFro break; } } - EXPECT_SUCCESS(session, mod_acc_fetch_composite_evm_response); - if (mod_acc_fetch_composite_evm_response.status() < 0) { - return; - } + // If this fails, we want the test to be over now. + ASSERT_GE(actualStatus, 0); + const auto mod_acc_fetch_iq_impairments_response = EXPECT_SUCCESS(session, client::mod_acc_fetch_iq_impairments(stub(), session, "", 10.0)); const auto mod_acc_fetch_in_band_emission_margin_response = EXPECT_SUCCESS(session, client::mod_acc_fetch_in_band_emission_margin(stub(), session, "", 10.0)); const auto acp_fetch_offset_measurement_array_response = EXPECT_SUCCESS(session, client::acp_fetch_offset_measurement_array(stub(), session, "", 10.0)); @@ -1098,7 +1112,6 @@ TEST_F(NiRFmxLTEDriverApiTests, ULModAccSingleCarrierFromExample_FetchData_DataL EXPECT_SUCCESS(session, client::initiate(stub(), session, "", "")); // Intermittently gives "374603: Unable to synchronize." and outputs nan values - mod_acc_fetch_composite_evm_response = client::mod_acc_fetch_composite_evm(stub(), session, "", 10.0); if (mod_acc_fetch_composite_evm_response.status() == SYNC_FAILURE_WARNING && attempts < 5) { TearDown(); SetUp(); diff --git a/source/tests/system/nirfmxlte_session_tests.cpp b/source/tests/system/nirfmxlte_session_tests.cpp index f3e88719a..725d399cf 100644 --- a/source/tests/system/nirfmxlte_session_tests.cpp +++ b/source/tests/system/nirfmxlte_session_tests.cpp @@ -1,4 +1,5 @@ #include +#include #include "device_server.h" #include "nirfmxlte/nirfmxlte_client.h" @@ -9,6 +10,7 @@ namespace system { namespace { namespace rfmxlte = nirfmxlte_grpc; +using namespace ::nlohmann; const int kInvalidRsrc = -200220; const int kInvalidRFmxLTESession = -380598; @@ -87,9 +89,9 @@ TEST_F(NiRFmxLTESessionTest, InitializeSessionWithoutDevice_ReturnsDriverError) rfmxlte::InitializeResponse response; ::grpc::Status status = call_initialize(kRFmxLTETestInvalidRsrc, "", "", &response); - EXPECT_TRUE(status.ok()); - EXPECT_EQ(kInvalidRsrc, response.status()); - EXPECT_EQ(0, response.instrument().id()); + EXPECT_EQ(::grpc::StatusCode::UNKNOWN, status.error_code()); + auto error = json::parse(status.error_message()); + EXPECT_EQ(kInvalidRsrc, error.value("code", 0)); } TEST_F(NiRFmxLTESessionTest, InitializedSession_CloseSession_ClosesDriverSession) @@ -151,10 +153,11 @@ TEST_F(NiRFmxLTESessionTest, CallInitializeTwiceWithSameSessionNameOnSameDevice_ EXPECT_TRUE(status_one.ok()); EXPECT_EQ(0, close_response_one.status()); - EXPECT_TRUE(status_two.ok()); // Initialize was only called once in the driver since the second init call to the service found the Session by the same name and returned it. // Therefore if we try to close the session again the driver will respond that it's not a valid session (it's already been closed). - EXPECT_EQ(kInvalidRFmxLTESession, close_response_two.status()); + EXPECT_EQ(::grpc::StatusCode::UNKNOWN, status_two.error_code()); + auto error = json::parse(status_two.error_message()); + EXPECT_EQ(kInvalidRFmxLTESession, error.value("code", 0)); } TEST_F(NiRFmxLTESessionTest, InvalidSession_CloseSession_ReturnsInvalidSessionError) @@ -169,8 +172,9 @@ TEST_F(NiRFmxLTESessionTest, InvalidSession_CloseSession_ReturnsInvalidSessionEr rfmxlte::CloseResponse response; ::grpc::Status status = GetStub()->Close(&context, request, &response); - EXPECT_TRUE(status.ok()); - EXPECT_EQ(kInvalidRFmxLTESession, response.status()); + EXPECT_EQ(::grpc::StatusCode::UNKNOWN, status.error_code()); + auto error = json::parse(status.error_message()); + EXPECT_EQ(kInvalidRFmxLTESession, error.value("code", 0)); } } // namespace diff --git a/source/tests/system/nirfmxnr_driver_api_tests.cpp b/source/tests/system/nirfmxnr_driver_api_tests.cpp index e3b588cbc..9bf2b226a 100644 --- a/source/tests/system/nirfmxnr_driver_api_tests.cpp +++ b/source/tests/system/nirfmxnr_driver_api_tests.cpp @@ -155,8 +155,7 @@ TEST_F(NiRFmxNRDriverApiTests, AcpNonContiguousMultiCarrierFromExample_FetchData EXPECT_SUCCESS(session, client::set_attribute_f64(stub(), session, carrier_string_response.selector_string_out(), NIRFMXNR_ATTRIBUTE_COMPONENT_CARRIER_FREQUENCY, componentCarrierFrequency[i][j])); } } - auto auto_level_response = client::auto_level(stub(), session, "", 10.0e-3); - EXPECT_ERROR(IVI_INVALID_VALUE_ERROR, IVI_INVALID_VALUE_ERROR_STR, session, auto_level_response); + EXPECT_ERROR(IVI_INVALID_VALUE_ERROR, IVI_INVALID_VALUE_ERROR_STR, session, client::auto_level(stub(), session, "", 10.0e-3)); EXPECT_SUCCESS(session, client::select_measurements(stub(), session, "", MEASUREMENT_TYPES_ACP, true)); EXPECT_SUCCESS(session, client::acp_cfg_measurement_method(stub(), session, "", ACP_MEASUREMENT_METHOD_NORMAL)); EXPECT_SUCCESS(session, client::acp_cfg_noise_compensation_enabled(stub(), session, "", ACP_NOISE_COMPENSATION_ENABLED_FALSE)); @@ -172,7 +171,6 @@ TEST_F(NiRFmxNRDriverApiTests, AcpNonContiguousMultiCarrierFromExample_FetchData fetch_measurement_responses[i] = EXPECT_SUCCESS(session, client::acp_fetch_offset_measurement(stub(), session, subblock_string_response.selector_string_out(), 10.0)); } - EXPECT_EQ(0.0, auto_level_response.reference_level()); EXPECT_LT(0.0, fetch_subblock_responses[0].subblock_power()); EXPECT_LT(0.0, fetch_subblock_responses[0].integration_bandwidth()); EXPECT_LT(0.0, fetch_subblock_responses[0].frequency()); diff --git a/source/tests/system/nirfmxnr_session_tests.cpp b/source/tests/system/nirfmxnr_session_tests.cpp index 94a5cba6f..6569816cc 100644 --- a/source/tests/system/nirfmxnr_session_tests.cpp +++ b/source/tests/system/nirfmxnr_session_tests.cpp @@ -1,4 +1,5 @@ #include +#include #include "device_server.h" #include "nirfmxnr/nirfmxnr_client.h" @@ -9,6 +10,7 @@ namespace system { namespace { namespace rfmxnr = nirfmxnr_grpc; +using namespace ::nlohmann; const int kInvalidRsrc = -200220; const int kInvalidRFmxNRSession = -380598; @@ -87,9 +89,9 @@ TEST_F(NiRFmxNRSessionTest, InitializeSessionWithoutDevice_ReturnsDriverError) rfmxnr::InitializeResponse response; ::grpc::Status status = call_initialize(kRFmxNRTestInvalidRsrc, "", "", &response); - EXPECT_TRUE(status.ok()); - EXPECT_EQ(kInvalidRsrc, response.status()); - EXPECT_EQ(0, response.instrument().id()); + EXPECT_EQ(::grpc::StatusCode::UNKNOWN, status.error_code()); + auto error = json::parse(status.error_message()); + EXPECT_EQ(kInvalidRsrc, error.value("code", 0)); } TEST_F(NiRFmxNRSessionTest, InitializedSession_CloseSession_ClosesDriverSession) @@ -151,10 +153,11 @@ TEST_F(NiRFmxNRSessionTest, CallInitializeTwiceWithSameSessionNameOnSameDevice_C EXPECT_TRUE(status_one.ok()); EXPECT_EQ(0, close_response_one.status()); - EXPECT_TRUE(status_two.ok()); // Initialize was only called once in the driver since the second init call to the service found the Session by the same name and returned it. // Therefore if we try to close the session again the driver will respond that it's not a valid session (it's already been closed). - EXPECT_EQ(kInvalidRFmxNRSession, close_response_two.status()); + EXPECT_EQ(::grpc::StatusCode::UNKNOWN, status_two.error_code()); + auto error = json::parse(status_two.error_message()); + EXPECT_EQ(kInvalidRFmxNRSession, error.value("code", 0)); } TEST_F(NiRFmxNRSessionTest, InvalidSession_CloseSession_ReturnsInvalidSessionError) @@ -169,8 +172,9 @@ TEST_F(NiRFmxNRSessionTest, InvalidSession_CloseSession_ReturnsInvalidSessionErr rfmxnr::CloseResponse response; ::grpc::Status status = GetStub()->Close(&context, request, &response); - EXPECT_TRUE(status.ok()); - EXPECT_EQ(kInvalidRFmxNRSession, response.status()); + EXPECT_EQ(::grpc::StatusCode::UNKNOWN, status.error_code()); + auto error = json::parse(status.error_message()); + EXPECT_EQ(kInvalidRFmxNRSession, error.value("code", 0)); } } // namespace diff --git a/source/tests/system/nirfmxspecan_driver_api_tests.cpp b/source/tests/system/nirfmxspecan_driver_api_tests.cpp index 3a99912f6..4aca5c0bd 100644 --- a/source/tests/system/nirfmxspecan_driver_api_tests.cpp +++ b/source/tests/system/nirfmxspecan_driver_api_tests.cpp @@ -1,5 +1,6 @@ #include #include +#include #include #include @@ -14,6 +15,7 @@ using namespace nirfmxspecan_grpc; namespace client = nirfmxspecan_grpc::experimental::client; namespace instr_client = nirfmxinstr_grpc::experimental::client; namespace pb = google::protobuf; +using nlohmann::json; using namespace ::testing; namespace ni { @@ -61,8 +63,15 @@ class NiRFmxSpecAnDriverApiTests : public ::testing::Test { bool is_driver_session_valid(const instr_client::StubPtr& stub, const nidevice_grpc::Session& session) { - auto response = instr_client::get_attribute_string(stub, session, "", nirfmxinstr_grpc::NiRFmxInstrAttribute::NIRFMXINSTR_ATTRIBUTE_INSTRUMENT_MODEL); - return response.status() != INVALID_SESSION_HANDLE_ERROR; + try { + auto response = instr_client::get_attribute_string(stub, session, "", nirfmxinstr_grpc::NiRFmxInstrAttribute::NIRFMXINSTR_ATTRIBUTE_INSTRUMENT_MODEL); + EXPECT_EQ(0, response.status()); + return true; + } + catch (const std::runtime_error& ex) { + auto error = json::parse(ex.what()); + return error.value("code", 0) != INVALID_SESSION_HANDLE_ERROR; + } } void config_dpd_reference_waveform(const nidevice_grpc::Session& session) @@ -639,9 +648,13 @@ TEST_P(NiRFmxSpecAnDriverApiConflictingResourceInitTests, InitializeResource_Ini const auto session1 = init_session(stub(), PXI_5663, std::get<0>(GetParam())); EXPECT_VALID_DRIVER_SESSION(session1); - const auto second_init_response = init(stub(), PXI_5663, std::get<1>(GetParam())); - - EXPECT_RESPONSE_ERROR(DEVICE_IN_USE_ERROR, second_init_response); + try { + init(stub(), PXI_5663, std::get<1>(GetParam())); + EXPECT_FALSE(true); + } + catch (const std::runtime_error& ex) { + EXPECT_STATUS_ERROR(DEVICE_IN_USE_ERROR, ex.what()); + } } TEST_P(NiRFmxSpecAnDriverApiConflictingResourceInitTests, InitializeAndCloseResource_InitializeResourceThatWouldHaveConflicted_Succeeds) diff --git a/source/tests/system/nirfmxspecan_session_tests.cpp b/source/tests/system/nirfmxspecan_session_tests.cpp index f84e64abe..b6884332c 100644 --- a/source/tests/system/nirfmxspecan_session_tests.cpp +++ b/source/tests/system/nirfmxspecan_session_tests.cpp @@ -1,5 +1,6 @@ #include #include +#include #include "device_server.h" #include "nirfmxspecan/nirfmxspecan_client.h" @@ -9,6 +10,7 @@ namespace tests { namespace system { namespace rfmxspecan = nirfmxspecan_grpc; +using namespace ::nlohmann; using ::testing::IsEmpty; const int kInvalidRsrc = -200220; @@ -77,9 +79,9 @@ TEST_F(NiRFmxSpecAnSessionTest, InitializeSessionWithoutDevice_ReturnsDriverErro rfmxspecan::InitializeResponse response; ::grpc::Status status = call_initialize(kRFmxSpecAnTestInvalidRsrc, "", "", &response); - EXPECT_TRUE(status.ok()); - EXPECT_EQ(kInvalidRsrc, response.status()); - EXPECT_EQ(0, response.instrument().id()); + EXPECT_EQ(::grpc::StatusCode::UNKNOWN, status.error_code()); + auto error = json::parse(status.error_message()); + EXPECT_EQ(kInvalidRsrc, error.value("code", 0)); } TEST_F(NiRFmxSpecAnSessionTest, InitializedSession_CloseSession_ClosesDriverSession) @@ -105,22 +107,27 @@ TEST_F(NiRFmxSpecAnSessionTest, InitializedSession_CloseSession_ClosesDriverSess TEST_F(NiRFmxSpecAnSessionTest, InitWithErrorFromDriver_ReturnsUserErrorMessage) { rfmxspecan::InitializeResponse init_response; - call_initialize(kRFmxSpecAnTestInvalidRsrc, "", "", &init_response); - EXPECT_EQ(kInvalidRsrc, init_response.status()); + auto status = call_initialize(kRFmxSpecAnTestInvalidRsrc, "", "", &init_response); - nidevice_grpc::Session session = init_response.instrument(); - EXPECT_EQ(std::string(kRFmxSpecAnErrorResourceNotFoundMessage), init_response.error_message()); + EXPECT_EQ(::grpc::StatusCode::UNKNOWN, status.error_code()); + auto error = json::parse(status.error_message()); + EXPECT_EQ(kInvalidRsrc, error.value("code", 0)); + EXPECT_STREQ(kRFmxSpecAnErrorResourceNotFoundMessage, error.value("message", "").c_str()); } TEST_F(NiRFmxSpecAnSessionTest, InitWithErrorFromDriver_ReinitSuccessfully_ErrorMessageIsEmpty) { rfmxspecan::InitializeResponse failed_init_response; - call_initialize(kRFmxSpecAnTestInvalidRsrc, "", "", &failed_init_response); + auto status_one = call_initialize(kRFmxSpecAnTestInvalidRsrc, "", "", &failed_init_response); rfmxspecan::InitializeResponse successful_init_response; - call_initialize(kRFmxSpecAnTestRsrc, kRFmxSpecAnOptionsString, kRFmxSpecAnTestSession, &successful_init_response); + auto status_two = call_initialize(kRFmxSpecAnTestRsrc, kRFmxSpecAnOptionsString, kRFmxSpecAnTestSession, &successful_init_response); - EXPECT_EQ(std::string(kRFmxSpecAnErrorResourceNotFoundMessage), failed_init_response.error_message()); + EXPECT_EQ(::grpc::StatusCode::UNKNOWN, status_one.error_code()); + auto error = json::parse(status_one.error_message()); + EXPECT_STREQ(kRFmxSpecAnErrorResourceNotFoundMessage, error.value("message", "").c_str()); + EXPECT_EQ(::grpc::StatusCode::OK, status_two.error_code()); + EXPECT_THAT(status_two.error_message(), IsEmpty()); EXPECT_THAT(successful_init_response.error_message(), IsEmpty()); } @@ -136,8 +143,9 @@ TEST_F(NiRFmxSpecAnSessionTest, InvalidSession_CloseSession_ReturnsInvalidSessio rfmxspecan::CloseResponse response; ::grpc::Status status = GetStub()->Close(&context, request, &response); - EXPECT_TRUE(status.ok()); - EXPECT_EQ(kInvalidRFmxSpecAnSession, response.status()); + EXPECT_EQ(::grpc::StatusCode::UNKNOWN, status.error_code()); + auto error = json::parse(status.error_message()); + EXPECT_EQ(kInvalidRFmxSpecAnSession, error.value("code", 0)); } } // namespace system diff --git a/source/tests/system/nirfmxwlan_session_tests.cpp b/source/tests/system/nirfmxwlan_session_tests.cpp index 3a46fda9a..ac33edd53 100644 --- a/source/tests/system/nirfmxwlan_session_tests.cpp +++ b/source/tests/system/nirfmxwlan_session_tests.cpp @@ -1,4 +1,5 @@ #include +#include #include "device_server.h" #include "nirfmxwlan/nirfmxwlan_client.h" @@ -9,6 +10,7 @@ namespace system { namespace { namespace rfmxwlan = nirfmxwlan_grpc; +using namespace ::nlohmann; const int kInvalidRsrc = -200220; const int kInvalidRFmxWLANSession = -380598; @@ -87,9 +89,9 @@ TEST_F(NiRFmxWLANSessionTest, InitializeSessionWithoutDevice_ReturnsDriverError) rfmxwlan::InitializeResponse response; ::grpc::Status status = call_initialize(kRFmxWLANTestInvalidRsrc, "", "", &response); - EXPECT_TRUE(status.ok()); - EXPECT_EQ(kInvalidRsrc, response.status()); - EXPECT_EQ(0, response.instrument().id()); + EXPECT_EQ(::grpc::StatusCode::UNKNOWN, status.error_code()); + auto error = json::parse(status.error_message()); + EXPECT_EQ(kInvalidRsrc, error.value("code", 0)); } TEST_F(NiRFmxWLANSessionTest, InitializedSession_CloseSession_ClosesDriverSession) @@ -144,8 +146,9 @@ TEST_F(NiRFmxWLANSessionTest, InvalidSession_CloseSession_ReturnsInvalidSessionE rfmxwlan::CloseResponse response; ::grpc::Status status = GetStub()->Close(&context, request, &response); - EXPECT_TRUE(status.ok()); - EXPECT_EQ(kInvalidRFmxWLANSession, response.status()); + EXPECT_EQ(::grpc::StatusCode::UNKNOWN, status.error_code()); + auto error = json::parse(status.error_message()); + EXPECT_EQ(kInvalidRFmxWLANSession, error.value("code", 0)); } TEST_F(NiRFmxWLANSessionTest, CallInitializeTwiceWithSameSessionNameOnSameDevice_CloseSessionTwice_SecondCloseReturnsInvalidSessionError) @@ -167,10 +170,11 @@ TEST_F(NiRFmxWLANSessionTest, CallInitializeTwiceWithSameSessionNameOnSameDevice EXPECT_TRUE(status_one.ok()); EXPECT_EQ(0, close_response_one.status()); - EXPECT_TRUE(status_two.ok()); // Initialize was only called once in the driver since the second init call to the service found the Session by the same name and returned it. // Therefore if we try to close the session again the driver will respond that it's not a valid session (it's already been closed). - EXPECT_EQ(kInvalidRFmxWLANSession, close_response_two.status()); + EXPECT_EQ(::grpc::StatusCode::UNKNOWN, status_two.error_code()); + auto error = json::parse(status_two.error_message()); + EXPECT_EQ(kInvalidRFmxWLANSession, error.value("code", 0)); } } // namespace diff --git a/source/tests/system/nirfsa_driver_api_tests.cpp b/source/tests/system/nirfsa_driver_api_tests.cpp index 93e1632e5..5bdf78155 100644 --- a/source/tests/system/nirfsa_driver_api_tests.cpp +++ b/source/tests/system/nirfsa_driver_api_tests.cpp @@ -1,5 +1,6 @@ #include #include // For EXPECT matchers. +#include #include @@ -9,6 +10,7 @@ #include "niscope/niscope_client.h" #include "nitclk/nitclk_client.h" +using namespace ::nlohmann; using namespace ::testing; using namespace nirfsa_grpc; namespace client = nirfsa_grpc::experimental::client; @@ -32,12 +34,6 @@ void EXPECT_SUCCESS(const TResponse& response) EXPECT_EQ(0, response.status()); } -template -void EXPECT_RFSA_ERROR(pb::int32 expected_error, const TResponse& response) -{ - EXPECT_EQ(expected_error, response.status()); -} - class NiRFSADriverApiTests : public Test { protected: NiRFSADriverApiTests() @@ -87,12 +83,17 @@ class NiRFSADriverApiTests : public Test { check_error(session); } - template - void EXPECT_RFSA_ERROR(pb::int32 expected_error, const std::string& message_substring, const nidevice_grpc::Session& session, const TResponse& response) + std::string EXPECT_RFSA_ERROR(int32_t expected_error, const std::string& error_message) + { + auto error = json::parse(error_message); + EXPECT_EQ(expected_error, error.value("code", 0)); + return error.value("message", ""); + } + + void EXPECT_RFSA_ERROR(pb::int32 expected_error, const std::string& message_substring, const char* error_message, const nidevice_grpc::Session& session) { - ni::tests::system::EXPECT_RFSA_ERROR(expected_error, response); - const auto error = client::get_error(stub(), session); - EXPECT_THAT(error.error_description(), HasSubstr(message_substring)); + auto message = EXPECT_RFSA_ERROR(expected_error, error_message); + EXPECT_THAT(message, HasSubstr(message_substring)); clear_error(session); } @@ -128,10 +129,14 @@ TEST_F(NiRFSADriverApiTests, Init_Close_Succeeds) TEST_F(NiRFSADriverApiTests, InitWithErrorFromDriver_ReturnsUserErrorMessage) { - auto initialize_response = client::init_with_options(stub(), "", false, false, ""); - - EXPECT_EQ(-200220, initialize_response.status()); - EXPECT_STREQ("Device identifier is invalid.", initialize_response.error_message().c_str()); + try { + client::init_with_options(stub(), "", false, false, ""); + EXPECT_FALSE(true); + } + catch (const std::runtime_error& ex) { + auto message = EXPECT_RFSA_ERROR(-200220, ex.what()); + EXPECT_STREQ("Device identifier is invalid.", message.c_str()); + } } MATCHER(IsNonDefaultComplexArray, "") @@ -498,14 +503,19 @@ TEST_F(NiRFSADriverApiTests, CreateConfigurationListWithInvalidAttribute_Reports { const auto LIST_NAME = "MyList"; auto session = init_session(stub(), PXI_5663E); - auto response = client::create_configuration_list( + + try { + client::create_configuration_list( stub(), session, LIST_NAME, {NiRFSAAttribute::NIRFSA_ATTRIBUTE_EXTERNAL_GAIN, NiRFSAAttribute::NIRFSA_ATTRIBUTE_NOTCH_FILTER_ENABLED}, true); - - EXPECT_RFSA_ERROR(IVI_ATTRIBUTE_NOT_SUPPORTED_ERROR, "Attribute or property not supported.", session, response); + EXPECT_FALSE(true); + } + catch (const std::runtime_error& ex) { + EXPECT_RFSA_ERROR(IVI_ATTRIBUTE_NOT_SUPPORTED_ERROR, "Attribute or property not supported.", ex.what(), session); + } } TEST_F(NiRFSADriverApiTests, GetScalingCoefficients_ReturnsCoefficients) diff --git a/source/tests/system/nirfsg_session_tests.cpp b/source/tests/system/nirfsg_session_tests.cpp index dfa15e2b0..bc9d59bf1 100644 --- a/source/tests/system/nirfsg_session_tests.cpp +++ b/source/tests/system/nirfsg_session_tests.cpp @@ -1,4 +1,5 @@ #include +#include #include "device_server.h" #include "nirfsg/nirfsg_client.h" @@ -8,6 +9,7 @@ namespace tests { namespace system { namespace rfsg = nirfsg_grpc; +using namespace ::nlohmann; const int kInvalidRsrc = -200220; const int kInvalidRFSGSession = -1074130544; @@ -91,10 +93,10 @@ TEST_F(NiRFSGSessionTest, InitializeSessionWithoutDevice_ReturnsDriverError) rfsg::InitWithOptionsResponse response; ::grpc::Status status = call_init_with_options(kRFSGTestInvalidRsrc, "", "", &response); - EXPECT_TRUE(status.ok()); - EXPECT_EQ(kInvalidRsrc, response.status()); - EXPECT_EQ(0, response.vi().id()); - EXPECT_NE("", response.error_message()); + EXPECT_EQ(::grpc::StatusCode::UNKNOWN, status.error_code()); + auto error = json::parse(status.error_message()); + EXPECT_EQ(kInvalidRsrc, error.value("code", 0)); + EXPECT_NE("", error.value("message", "")); } TEST_F(NiRFSGSessionTest, InitializedSession_CloseSession_ClosesDriverSession) @@ -116,10 +118,12 @@ TEST_F(NiRFSGSessionTest, InitializedSession_CloseSession_ClosesDriverSession) TEST_F(NiRFSGSessionTest, InitWithErrorFromDriver_ReturnsUserErrorMessage) { rfsg::InitWithOptionsResponse init_response; - call_init_with_options(kRFSGTestInvalidRsrc, "", "", &init_response); + auto status = call_init_with_options(kRFSGTestInvalidRsrc, "", "", &init_response); - EXPECT_EQ(kInvalidRsrc, init_response.status()); - EXPECT_STREQ(kRFSGErrorResourceNotFoundMessage, init_response.error_message().c_str()); + EXPECT_EQ(::grpc::StatusCode::UNKNOWN, status.error_code()); + auto error = json::parse(status.error_message()); + EXPECT_EQ(kInvalidRsrc, error.value("code", 0)); + EXPECT_STREQ(kRFSGErrorResourceNotFoundMessage, error.value("message", "").c_str()); } TEST_F(NiRFSGSessionTest, InvalidSession_CloseSession_ReturnsInvalidSessionError) @@ -133,8 +137,9 @@ TEST_F(NiRFSGSessionTest, InvalidSession_CloseSession_ReturnsInvalidSessionError rfsg::CloseResponse response; ::grpc::Status status = GetStub()->Close(&context, request, &response); - EXPECT_TRUE(status.ok()); - EXPECT_EQ(kInvalidRFSGSession, response.status()); + EXPECT_EQ(::grpc::StatusCode::UNKNOWN, status.error_code()); + auto error = json::parse(status.error_message()); + EXPECT_EQ(kInvalidRFSGSession, error.value("code", 0)); } } // namespace system diff --git a/source/tests/system/niscope_session_tests.cpp b/source/tests/system/niscope_session_tests.cpp index 721465bc2..f03fcf087 100644 --- a/source/tests/system/niscope_session_tests.cpp +++ b/source/tests/system/niscope_session_tests.cpp @@ -1,4 +1,5 @@ #include +#include #include "device_server.h" #include "niscope/niscope_client.h" @@ -8,6 +9,7 @@ namespace tests { namespace system { namespace scope = niscope_grpc; +using namespace ::nlohmann; const int kViErrorRsrcNFound = -1073807343; const int kInvalidScopeSession = -1074130544; @@ -97,10 +99,10 @@ TEST_F(NiScopeSessionTest, InitializeSessionWithoutDevice_ReturnsDriverError) scope::InitWithOptionsResponse response; ::grpc::Status status = call_init_with_options(kInvalidResourceName, "", "", &response); - EXPECT_TRUE(status.ok()); - EXPECT_EQ(kViErrorRsrcNFound, response.status()); - EXPECT_EQ(0, response.vi().id()); - EXPECT_NE("", response.error_message()); + EXPECT_EQ(::grpc::StatusCode::UNKNOWN, status.error_code()); + auto error = json::parse(status.error_message()); + EXPECT_EQ(kViErrorRsrcNFound, error.value("code", 0)); + EXPECT_NE("", error.value("message", "")); } TEST_F(NiScopeSessionTest, InitializedSession_CloseSession_ClosesDriverSession) @@ -130,19 +132,21 @@ TEST_F(NiScopeSessionTest, InvalidSession_CloseSession_ReturnsInvalidSesssionErr scope::CloseResponse response; ::grpc::Status status = GetStub()->Close(&context, request, &response); - EXPECT_TRUE(status.ok()); - EXPECT_EQ(kInvalidScopeSession, response.status()); - std::string error_message = get_error_message(response.status()); - EXPECT_STREQ(kInvalidScopeSessionMessage, error_message.c_str()); + EXPECT_EQ(::grpc::StatusCode::UNKNOWN, status.error_code()); + auto error = json::parse(status.error_message()); + EXPECT_EQ(kInvalidScopeSession, error.value("code", 0)); + EXPECT_STREQ(kInvalidScopeSessionMessage, error.value("message", "").c_str()); } TEST_F(NiScopeSessionTest, InitWithErrorFromDriver_ReturnsUserErrorMessage) { scope::InitWithOptionsResponse init_response; - call_init_with_options(kInvalidResourceName, "", "", &init_response); + auto status = call_init_with_options(kInvalidResourceName, "", "", &init_response); - EXPECT_EQ(kViErrorRsrcNFound, init_response.status()); - EXPECT_STREQ(kViErrorRsrcNFoundMessage, init_response.error_message().c_str()); + EXPECT_EQ(::grpc::StatusCode::UNKNOWN, status.error_code()); + auto error = json::parse(status.error_message()); + EXPECT_EQ(kViErrorRsrcNFound, error.value("code", 0)); + EXPECT_STREQ(kViErrorRsrcNFoundMessage, error.value("message", "").c_str()); } } // namespace system diff --git a/source/tests/system/niswitch_session_tests.cpp b/source/tests/system/niswitch_session_tests.cpp index e73ddc09f..9dabe1440 100644 --- a/source/tests/system/niswitch_session_tests.cpp +++ b/source/tests/system/niswitch_session_tests.cpp @@ -1,4 +1,5 @@ #include +#include #include "device_server.h" #include "niswitch/niswitch_client.h" @@ -8,11 +9,12 @@ namespace tests { namespace system { namespace niswitch = niswitch_grpc; +using namespace ::nlohmann; const int kViErrorRsrcNotFound = -1074118654; const int kInvalidSwitchSession = -1074130544; const char* kViErrorRsrcNotFoundMessage = "Invalid resource name.\n\nInvalid Identifier: InvalidName"; -const char* kInvalidSwitchSessionMessage = "The session handle is not valid."; +const char* kInvalidSwitchSessionMessage = "IVI: The session handle is not valid."; const char* kTestRsrcName = ""; const char* kTestSessName = "SessionName"; const char* kInvalidRsrcName = "InvalidName"; @@ -97,10 +99,10 @@ TEST_F(NiSwitchSessionTest, InitializeSessionWithoutDevice_ReturnsDriverError) niswitch::InitWithTopologyResponse response; ::grpc::Status status = call_init_with_topology(kInvalidRsrcName, "", "", &response); - EXPECT_TRUE(status.ok()); - EXPECT_EQ(kViErrorRsrcNotFound, response.status()); - EXPECT_EQ(0, response.vi().id()); - EXPECT_NE("", response.error_message()); + EXPECT_EQ(::grpc::StatusCode::UNKNOWN, status.error_code()); + auto error = json::parse(status.error_message()); + EXPECT_EQ(kViErrorRsrcNotFound, error.value("code", 0)); + EXPECT_NE("", error.value("message", "")); } TEST_F(NiSwitchSessionTest, InitializedSession_CloseSession_ClosesDriverSession) @@ -130,19 +132,21 @@ TEST_F(NiSwitchSessionTest, InvalidSession_CloseSession_ReturnsInvalidSesssionEr niswitch::CloseResponse response; ::grpc::Status status = GetStub()->Close(&context, request, &response); - EXPECT_TRUE(status.ok()); - EXPECT_EQ(kInvalidSwitchSession, response.status()); - std::string error_message = get_error_message(response.status()); - EXPECT_STREQ(kInvalidSwitchSessionMessage, error_message.c_str()); + EXPECT_EQ(::grpc::StatusCode::UNKNOWN, status.error_code()); + auto error = json::parse(status.error_message()); + EXPECT_EQ(kInvalidSwitchSession, error.value("code", 0)); + EXPECT_STREQ(kInvalidSwitchSessionMessage, error.value("message", "").c_str()); } TEST_F(NiSwitchSessionTest, InitWithErrorFromDriver_ReturnsUserErrorMessage) { niswitch::InitWithTopologyResponse init_response; - call_init_with_topology(kInvalidRsrcName, "", "", &init_response); + auto status = call_init_with_topology(kInvalidRsrcName, "", "", &init_response); - EXPECT_EQ(kViErrorRsrcNotFound, init_response.status()); - EXPECT_STREQ(kViErrorRsrcNotFoundMessage, init_response.error_message().c_str()); + EXPECT_EQ(::grpc::StatusCode::UNKNOWN, status.error_code()); + auto error = json::parse(status.error_message()); + EXPECT_EQ(kViErrorRsrcNotFound, error.value("code", 0)); + EXPECT_STREQ(kViErrorRsrcNotFoundMessage, error.value("message", "").c_str()); } } // namespace system diff --git a/source/tests/system/nixnetsocket_driver_api_tests.cpp b/source/tests/system/nixnetsocket_driver_api_tests.cpp index 52046a909..e741228d2 100644 --- a/source/tests/system/nixnetsocket_driver_api_tests.cpp +++ b/source/tests/system/nixnetsocket_driver_api_tests.cpp @@ -235,6 +235,12 @@ class NiXnetSocketNoHardwareTests : public NiXnetSocketDriverApiTests { EXPECT_EQ(error, (response).status()); \ } +#define EXPECT_XNET_ERROR_CODE(expected, error) \ + EXPECT_EQ(expected, error.value("code", 0)); + +#define EXPECT_XNET_ERROR_NUMBER(expected, error) \ + EXPECT_EQ(expected, error.value("errorNumber", 0)); + #define EXPECT_XNET_ERROR(expected_status, error, message, response) \ if (1) { \ EXPECT_EQ(expected_status, (response).status()); \ @@ -280,36 +286,47 @@ SocketResponse socket(client::StubPtr& stub) TEST_F(NiXnetSocketNoHardwareTests, InitWithInvalidIpStack_Close_ReturnsAndSetsExpectedErrors) { - auto socket_response = socket(stub()); - - auto close_response = client::close(stub(), socket_response.socket()); + SocketResponse invalid_socket; + invalid_socket.mutable_socket()->set_id(static_cast(INVALID_XNET_SOCKET)); - EXPECT_XNET_STATUS(GENERIC_NXSOCKET_ERROR, socket_response); - EXPECT_EQ(INVALID_IP_STACK_ERROR, socket_response.error_num()); - EXPECT_THAT(socket_response.error_message(), HasSubstr(INVALID_IP_STACK_MESSAGE)); - EXPECT_XNET_STATUS(GENERIC_NXSOCKET_ERROR, close_response); - EXPECT_EQ(INVALID_SOCKET_ERROR, close_response.error_num()); - EXPECT_THAT(close_response.error_message(), HasSubstr(INVALID_SOCKET_MESSAGE)); + try { + client::close(stub(), invalid_socket.socket()); + EXPECT_FALSE(true); + } + catch (const std::runtime_error& ex) { + auto error = json::parse(ex.what()); + EXPECT_XNET_ERROR_CODE(GENERIC_NXSOCKET_ERROR, error); + EXPECT_XNET_ERROR_NUMBER(INVALID_SOCKET_ERROR, error); + EXPECT_THAT(error.value("message", ""), HasSubstr(INVALID_SOCKET_MESSAGE)); + } } TEST_F(NiXnetSocketNoHardwareTests, InitWithInvalidIpStack_Bind_ReturnsAndSetsExpectedErrors) { + SocketResponse invalid_socket; + invalid_socket.mutable_socket()->set_id(static_cast(INVALID_XNET_SOCKET)); auto sock_addr = SockAddr{}; sock_addr.mutable_ipv4()->mutable_addr()->set_addr(0x7F000001); sock_addr.mutable_ipv4()->set_port(31764); - auto socket_response = socket(stub()); - auto bind_response = client::bind(stub(), socket_response.socket(), sock_addr); - EXPECT_XNET_STATUS(GENERIC_NXSOCKET_ERROR, socket_response); - EXPECT_XNET_STATUS(GENERIC_NXSOCKET_ERROR, bind_response); - EXPECT_EQ(INVALID_SOCKET_ERROR, bind_response.error_num()); - EXPECT_THAT(bind_response.error_message(), HasSubstr(INVALID_SOCKET_MESSAGE)); + try { + client::bind(stub(), invalid_socket.socket(), sock_addr); + EXPECT_FALSE(true); + } + catch (const std::runtime_error& ex) { + auto error = json::parse(ex.what()); + EXPECT_XNET_ERROR_CODE(GENERIC_NXSOCKET_ERROR, error); + EXPECT_XNET_ERROR_NUMBER(INVALID_SOCKET_ERROR, error); + EXPECT_THAT(error.value("message", ""), HasSubstr(INVALID_SOCKET_MESSAGE)); + } } TEST_F(NiXnetSocketNoHardwareTests, SocketAndEmptySet_IsSet_ReturnsFalse) { - auto socket_response = socket(stub()); - auto is_set_response = client::fd_is_set(stub(), socket_response.socket(), {}); + SocketResponse invalid_socket; + invalid_socket.mutable_socket()->set_id(static_cast(INVALID_XNET_SOCKET)); + + auto is_set_response = client::fd_is_set(stub(), invalid_socket.socket(), {}); EXPECT_SUCCESS(is_set_response); EXPECT_EQ(NXSOCKET_FALSE, is_set_response.is_set()); @@ -317,8 +334,10 @@ TEST_F(NiXnetSocketNoHardwareTests, SocketAndEmptySet_IsSet_ReturnsFalse) TEST_F(NiXnetSocketNoHardwareTests, SocketAndSetContainingSocket_IsSet_ReturnsTrue) { - auto socket_response = socket(stub()); - auto is_set_response = client::fd_is_set(stub(), socket_response.socket(), {socket_response.socket()}); + SocketResponse invalid_socket; + invalid_socket.mutable_socket()->set_id(static_cast(INVALID_XNET_SOCKET)); + + auto is_set_response = client::fd_is_set(stub(), invalid_socket.socket(), {invalid_socket.socket()}); EXPECT_SUCCESS(is_set_response); EXPECT_EQ(NXSOCKET_TRUE, is_set_response.is_set()); @@ -326,33 +345,52 @@ TEST_F(NiXnetSocketNoHardwareTests, SocketAndSetContainingSocket_IsSet_ReturnsTr TEST_F(NiXnetSocketNoHardwareTests, InvalidSocket_Select_ReturnsAndSetsExpectedErrors) { - auto socket_response = socket(stub()); + SocketResponse invalid_socket; + invalid_socket.mutable_socket()->set_id(static_cast(INVALID_XNET_SOCKET)); auto duration = pb::Duration{}; duration.set_seconds(1); duration.set_nanos(500000); - auto select_response = client::select(stub(), {socket_response.socket()}, {socket_response.socket()}, {}, duration); - EXPECT_XNET_STATUS(GENERIC_NXSOCKET_ERROR, select_response); - EXPECT_EQ(INVALID_SOCKET_ERROR, select_response.error_num()); - EXPECT_THAT(select_response.error_message(), HasSubstr(INVALID_SOCKET_MESSAGE)); + try { + client::select(stub(), {invalid_socket.socket()}, {invalid_socket.socket()}, {}, duration); + EXPECT_FALSE(true); + } + catch (const std::runtime_error& ex) { + auto error = json::parse(ex.what()); + EXPECT_XNET_ERROR_CODE(GENERIC_NXSOCKET_ERROR, error); + EXPECT_XNET_ERROR_NUMBER(INVALID_SOCKET_ERROR, error); + EXPECT_THAT(error.value("message", ""), HasSubstr(INVALID_SOCKET_MESSAGE)); + } } TEST_F(NiXnetSocketNoHardwareTests, InvalidEmptyConfigJson_IpStackCreate_ReturnsInvalidInterfaceNameError) { constexpr auto TEST_CONFIG = "{}"; constexpr auto JSON_OBJECT_MISSING_VALUE = -13017; - const auto stack_response = client::ip_stack_create(stub(), "", "{}"); - EXPECT_XNET_STATUS(JSON_OBJECT_MISSING_VALUE, stack_response); + try { + client::ip_stack_create(stub(), "", "{}"); + EXPECT_FALSE(true); + } + catch (const std::runtime_error& ex) { + auto error = json::parse(ex.what()); + EXPECT_XNET_ERROR_CODE(JSON_OBJECT_MISSING_VALUE, error); + } } TEST_F(NiXnetSocketNoHardwareTests, ValidConfigJsonForMissingDevice_IpStackCreate_ReturnsInvalidInterfaceNameError) { const auto TEST_CONFIG = create_simple_config("ENET6"); constexpr auto INVALID_INTERFACE_NAME = -1074384758; - const auto stack_response = client::ip_stack_create(stub(), "", TEST_CONFIG); - EXPECT_XNET_STATUS(INVALID_INTERFACE_NAME, stack_response); + try { + client::ip_stack_create(stub(), "", TEST_CONFIG); + EXPECT_FALSE(true); + } + catch (const std::runtime_error& ex) { + auto error = json::parse(ex.what()); + EXPECT_XNET_ERROR_CODE(INVALID_INTERFACE_NAME, error); + } } TEST_F(NiXnetSocketNoHardwareTests, StackAlreadyExistsError_StrErrR_ReturnsExpectedMessage) @@ -369,10 +407,15 @@ TEST_F(NiXnetSocketNoHardwareTests, StackAlreadyExistsError_StrErrRWithZeroBuffe { constexpr auto STACK_ALREADY_EXISTS = static_cast(0xFFFFCD24); - const auto str_err = client::str_err_r(stub(), STACK_ALREADY_EXISTS, 0); - - EXPECT_XNET_STATUS(GENERIC_NXSOCKET_ERROR, str_err); - EXPECT_EQ("", str_err.error()); + try { + client::str_err_r(stub(), STACK_ALREADY_EXISTS, 0); + EXPECT_FALSE(true); + } + catch (const std::runtime_error& ex) { + auto error = json::parse(ex.what()); + EXPECT_XNET_ERROR_CODE(GENERIC_NXSOCKET_ERROR, error); + EXPECT_EQ(std::string(), error.value("message", "default")); + } } TEST_F(NiXnetSocketLoopbackTests, IPv4LocalhostAddress_AToNAndPToNRoundtrip_ReturnsCorrectAddr) diff --git a/source/tests/system/rfmx_macros.h b/source/tests/system/rfmx_macros.h index d300988b3..96d37b56f 100644 --- a/source/tests/system/rfmx_macros.h +++ b/source/tests/system/rfmx_macros.h @@ -3,6 +3,7 @@ #include #include +#include #define EXPECT_NO_ERROR_MESSAGE(session, response) \ if (1) { \ @@ -31,11 +32,10 @@ EXPECT_EQ(expected_warning, (response).status()); \ } -#define EXPECT_RESPONSE_ERROR(expected_error, response) \ - if (1) { \ - EXPECT_LT(expected_error, 0); \ - EXPECT_EQ(expected_error, (response).status()); \ - } +#define EXPECT_STATUS_ERROR(expected_error, error_message) \ + EXPECT_LT(expected_error, 0); \ + auto error = nlohmann::json::parse(error_message); \ + EXPECT_EQ(expected_error, error.value("code", 0)); #define EXPECT_SUCCESS(session_, response_) \ ([this](auto& session, auto& response) { \ @@ -44,12 +44,15 @@ return response; \ })((session_), (response_)) -#define EXPECT_ERROR(expected_error_, message_substring_, session_, response_) \ - ([this](auto expected_error, const auto& message_substring, auto& session, auto& response) { \ - EXPECT_RESPONSE_ERROR(expected_error, response) \ - EXPECT_ERROR_SUBSTRING(message_substring, session); \ - return response; \ - })(expected_error_, message_substring_, session_, response_) +#define EXPECT_ERROR(expected_error_, message_substring_, session_, response_call_) \ + try { \ + response_call_; \ + EXPECT_FALSE(true); \ + } \ + catch (const std::runtime_error& ex) { \ + EXPECT_STATUS_ERROR(expected_error_, ex.what()); \ + EXPECT_THAT(error.value("message", ""), HasSubstr(message_substring_)); \ + } #define EXPECT_WARNING(expected_warning_, message_substring_, session_, response_) \ ([this](auto expected_warning, const auto& message_substring, auto& session, auto& response) { \ diff --git a/source/tests/unit/ni_fake_non_ivi_service_tests.cpp b/source/tests/unit/ni_fake_non_ivi_service_tests.cpp index e7b2072e2..e433b02b7 100644 --- a/source/tests/unit/ni_fake_non_ivi_service_tests.cpp +++ b/source/tests/unit/ni_fake_non_ivi_service_tests.cpp @@ -3,6 +3,7 @@ #include #include #include +#include #include #include @@ -11,6 +12,7 @@ #include using namespace nifake_non_ivi_grpc; +using namespace ::nlohmann; using namespace ::testing; bool operator==(const StructWithCoercion_struct& left, const StructWithCoercion& right) @@ -1704,11 +1706,15 @@ TEST_F(NiFakeNonIviServiceTests, InitWithReturnedSessionFailsInit_AccessSession_ InitWithReturnedSessionRequest request; InitWithReturnedSessionResponse response; request.set_handle_name(SESSION_NAME); - service_.InitWithReturnedSession(&context, &request, &response); + auto status = service_.InitWithReturnedSession(&context, &request, &response); const auto accessed_handle = resource_repository_->access_session(response.handle().id(), ""); - EXPECT_EQ(FAILED_INIT, response.status()); + EXPECT_FALSE(status.ok()); + EXPECT_EQ(::grpc::StatusCode::UNKNOWN, status.error_code()); + auto error = json::parse(status.error_message()); + EXPECT_EQ(FAILED_INIT, error.value("code", 0)); + EXPECT_NE(FAILED_INIT, response.status()); EXPECT_EQ(0, accessed_handle); } @@ -1726,7 +1732,7 @@ TEST_F(NiFakeNonIviServiceTests, GetStringAsReturnedValue_ReturnsString) EXPECT_EQ(kDriverSuccess, response.status()); } -TEST_F(NiFakeNonIviServiceTests, GetStringAsReturnedValueReturnsNull_ReturnsErrorAndEmptryString) +TEST_F(NiFakeNonIviServiceTests, GetStringAsReturnedValueReturnsNull_ReturnsError) { constexpr auto FAILED_GET = -1; EXPECT_CALL(library_, GetStringAsReturnedValue(_)) @@ -1734,10 +1740,13 @@ TEST_F(NiFakeNonIviServiceTests, GetStringAsReturnedValueReturnsNull_ReturnsErro ::grpc::ServerContext context; GetStringAsReturnedValueRequest request; GetStringAsReturnedValueResponse response; - service_.GetStringAsReturnedValue(&context, &request, &response); + auto status = service_.GetStringAsReturnedValue(&context, &request, &response); - EXPECT_THAT(response.string_out(), IsEmpty()); - EXPECT_EQ(FAILED_GET, response.status()); + EXPECT_FALSE(status.ok()); + EXPECT_EQ(::grpc::StatusCode::UNKNOWN, status.error_code()); + auto error = json::parse(status.error_message()); + EXPECT_EQ(FAILED_GET, error.value("code", 0)); + EXPECT_NE(FAILED_GET, response.status()); } TEST_F(NiFakeNonIviServiceTests, InitWithError_CallsGetLatestErrorAndReturnsMessage) @@ -1747,9 +1756,7 @@ TEST_F(NiFakeNonIviServiceTests, InitWithError_CallsGetLatestErrorAndReturnsMess const auto ERROR_MESSAGE_BUFFER_SIZE = static_cast(ERROR_MESSAGE.size() + 1); EXPECT_CALL(library_, Init(_, _)) .WillOnce(Return(SOME_ERROR)); - EXPECT_CALL(library_, GetLatestErrorMessage(nullptr, 0)) - .WillOnce(Return(ERROR_MESSAGE_BUFFER_SIZE)); - EXPECT_CALL(library_, GetLatestErrorMessage(_, ERROR_MESSAGE_BUFFER_SIZE)) + EXPECT_CALL(library_, GetLatestErrorMessage(_, 2048)) .WillOnce( DoAll( SetArrayArgument<0>(ERROR_MESSAGE.c_str(), ERROR_MESSAGE.c_str() + ERROR_MESSAGE_BUFFER_SIZE), @@ -1757,10 +1764,14 @@ TEST_F(NiFakeNonIviServiceTests, InitWithError_CallsGetLatestErrorAndReturnsMess ::grpc::ServerContext context; InitRequest request; InitResponse response; - service_.Init(&context, &request, &response); - - EXPECT_EQ(ERROR_MESSAGE, response.error_message()); - EXPECT_EQ(SOME_ERROR, response.status()); + auto status = service_.Init(&context, &request, &response); + + EXPECT_FALSE(status.ok()); + EXPECT_EQ(::grpc::StatusCode::UNKNOWN, status.error_code()); + auto error = json::parse(status.error_message()); + EXPECT_EQ(SOME_ERROR, error.value("code", 0)); + EXPECT_EQ(ERROR_MESSAGE, error.value("message", "")); + EXPECT_NE(SOME_ERROR, response.status()); } TEST_F(NiFakeNonIviServiceTests, InitWithNoError_DoesNotCallGetLatestError) diff --git a/source/tests/unit/ni_fake_service_tests.cpp b/source/tests/unit/ni_fake_service_tests.cpp index 72d8d9cfc..95544036b 100644 --- a/source/tests/unit/ni_fake_service_tests.cpp +++ b/source/tests/unit/ni_fake_service_tests.cpp @@ -4,12 +4,15 @@ #include #include #include +#include #include #include #include #include +using namespace ::nlohmann; + // fixes seg faults caused by https://github.com/grpc/grpc/issues/14633 static grpc::internal::GrpcLibraryInitializer g_gli_initializer; @@ -423,8 +426,12 @@ TEST(NiFakeServiceTests, NiFakeService_FunctionCallErrors_ResponseValuesNotSet) nifake_grpc::GetABooleanResponse response; ::grpc::Status status = service.GetABoolean(&context, &request, &response); - EXPECT_TRUE(status.ok()); - EXPECT_EQ(kDriverFailure, response.status()); + EXPECT_FALSE(status.ok()); + EXPECT_EQ(::grpc::StatusCode::UNKNOWN, status.error_code()); + auto error = json::parse(status.error_message()); + EXPECT_EQ(kDriverFailure, error.value("code", 0)); + EXPECT_TRUE(error.contains("message")); + EXPECT_NE(kDriverFailure, response.status()); EXPECT_NE(a_boolean, response.a_boolean()); }