Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into users/alenka/btdevice
Browse files Browse the repository at this point in the history
  • Loading branch information
reckenro committed Dec 12, 2023
2 parents 4fd100d + 9b7967d commit fb0cba5
Show file tree
Hide file tree
Showing 28 changed files with 303 additions and 74 deletions.
3 changes: 0 additions & 3 deletions .idea/.gitignore

This file was deleted.

12 changes: 0 additions & 12 deletions .idea/grpc-device.iml

This file was deleted.

6 changes: 0 additions & 6 deletions .idea/inspectionProfiles/profiles_settings.xml

This file was deleted.

7 changes: 0 additions & 7 deletions .idea/misc.xml

This file was deleted.

8 changes: 0 additions & 8 deletions .idea/modules.xml

This file was deleted.

37 changes: 0 additions & 37 deletions .idea/vcs.xml

This file was deleted.

30 changes: 30 additions & 0 deletions generated/nirfmxspecan_restricted/nirfmxspecan_restricted.proto
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import "nidevice.proto";
import "session.proto";

service NiRFmxSpecAnRestricted {
rpc AMPMLoadReferenceWaveformFromTDMSFile(AMPMLoadReferenceWaveformFromTDMSFileRequest) returns (AMPMLoadReferenceWaveformFromTDMSFileResponse);
rpc CacheResult(CacheResultRequest) returns (CacheResultResponse);
rpc IQFetchDataOverrideBehavior(IQFetchDataOverrideBehaviorRequest) returns (IQFetchDataOverrideBehaviorResponse);
}
Expand All @@ -27,6 +28,35 @@ enum IQDeleteOnFetch {
IQ_DELETE_ON_FETCH_FALSE = 2;
}

enum AmpmReferenceWaveformIdleDurationPresent {
AMPM_REFERENCE_WAVEFORM_IDLE_DURATION_PRESENT_FALSE = 0;
AMPM_REFERENCE_WAVEFORM_IDLE_DURATION_PRESENT_TRUE = 1;
}

enum AmpmSignalType {
AMPM_SIGNAL_TYPE_MODULATED = 0;
AMPM_SIGNAL_TYPE_TONES = 1;
}

message AMPMLoadReferenceWaveformFromTDMSFileRequest {
nidevice_grpc.Session instrument_handle = 1;
string selector_string = 2;
string waveform_file_path = 3;
oneof idle_duration_present_enum {
AmpmReferenceWaveformIdleDurationPresent idle_duration_present = 4;
int32 idle_duration_present_raw = 5;
}
oneof signal_type_enum {
AmpmSignalType signal_type = 6;
int32 signal_type_raw = 7;
}
int32 waveform_index = 8;
}

message AMPMLoadReferenceWaveformFromTDMSFileResponse {
int32 status = 1;
}

message CacheResultRequest {
nidevice_grpc.Session instrument = 1;
string selector_string = 2;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,42 @@

namespace nirfmxspecan_restricted_grpc::experimental::client {

AMPMLoadReferenceWaveformFromTDMSFileResponse
ampm_load_reference_waveform_from_tdms_file(const StubPtr& stub, const nidevice_grpc::Session& instrument_handle, const std::string& selector_string, const std::string& waveform_file_path, const simple_variant<AmpmReferenceWaveformIdleDurationPresent, pb::int32>& idle_duration_present, const simple_variant<AmpmSignalType, pb::int32>& signal_type, const pb::int32& waveform_index)
{
::grpc::ClientContext context;

auto request = AMPMLoadReferenceWaveformFromTDMSFileRequest{};
request.mutable_instrument_handle()->CopyFrom(instrument_handle);
request.set_selector_string(selector_string);
request.set_waveform_file_path(waveform_file_path);
const auto idle_duration_present_ptr = idle_duration_present.get_if<AmpmReferenceWaveformIdleDurationPresent>();
const auto idle_duration_present_raw_ptr = idle_duration_present.get_if<pb::int32>();
if (idle_duration_present_ptr) {
request.set_idle_duration_present(*idle_duration_present_ptr);
}
else if (idle_duration_present_raw_ptr) {
request.set_idle_duration_present_raw(*idle_duration_present_raw_ptr);
}
const auto signal_type_ptr = signal_type.get_if<AmpmSignalType>();
const auto signal_type_raw_ptr = signal_type.get_if<pb::int32>();
if (signal_type_ptr) {
request.set_signal_type(*signal_type_ptr);
}
else if (signal_type_raw_ptr) {
request.set_signal_type_raw(*signal_type_raw_ptr);
}
request.set_waveform_index(waveform_index);

auto response = AMPMLoadReferenceWaveformFromTDMSFileResponse{};

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

return response;
}

CacheResultResponse
cache_result(const StubPtr& stub, const nidevice_grpc::Session& instrument, const std::string& selector_string, const pb::int32& selector_string_out_size)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ using StubPtr = std::unique_ptr<NiRFmxSpecAnRestricted::Stub>;
using namespace nidevice_grpc::experimental::client;


AMPMLoadReferenceWaveformFromTDMSFileResponse ampm_load_reference_waveform_from_tdms_file(const StubPtr& stub, const nidevice_grpc::Session& instrument_handle, const std::string& selector_string, const std::string& waveform_file_path, const simple_variant<AmpmReferenceWaveformIdleDurationPresent, pb::int32>& idle_duration_present, const simple_variant<AmpmSignalType, pb::int32>& signal_type, const pb::int32& waveform_index);
CacheResultResponse cache_result(const StubPtr& stub, const nidevice_grpc::Session& instrument, const std::string& selector_string, const pb::int32& selector_string_out_size);
IQFetchDataOverrideBehaviorResponse iq_fetch_data_override_behavior(const StubPtr& stub, const nidevice_grpc::Session& instrument, const std::string& selector_string, const double& timeout, const pb::int32& record_to_fetch, const pb::int64& samples_to_read, const simple_variant<IQDeleteOnFetch, pb::int32>& delete_on_fetch);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ NiRFmxSpecAnRestrictedLibrary::NiRFmxSpecAnRestrictedLibrary(std::shared_ptr<nid
if (!loaded) {
return;
}
function_pointers_.AMPMLoadReferenceWaveformFromTDMSFile = reinterpret_cast<AMPMLoadReferenceWaveformFromTDMSFilePtr>(shared_library_->get_function_pointer("RFmxSpecAn_AMPMLoadReferenceWaveformFromTDMSFile"));
function_pointers_.CacheResult = reinterpret_cast<CacheResultPtr>(shared_library_->get_function_pointer("RFmxSpecAn_CacheResult"));
function_pointers_.GetError = reinterpret_cast<GetErrorPtr>(shared_library_->get_function_pointer("RFmxSpecAn_GetError"));
function_pointers_.GetErrorString = reinterpret_cast<GetErrorStringPtr>(shared_library_->get_function_pointer("RFmxSpecAn_GetErrorString"));
Expand All @@ -44,6 +45,14 @@ ::grpc::Status NiRFmxSpecAnRestrictedLibrary::check_function_exists(std::string
: ::grpc::Status(::grpc::NOT_FOUND, "Could not find the function " + functionName);
}

int32 NiRFmxSpecAnRestrictedLibrary::AMPMLoadReferenceWaveformFromTDMSFile(niRFmxInstrHandle instrumentHandle, char selectorString[], char waveformFilePath[], int32 idleDurationPresent, int32 signalType, int32 waveformIndex)
{
if (!function_pointers_.AMPMLoadReferenceWaveformFromTDMSFile) {
throw nidevice_grpc::LibraryLoadException("Could not find RFmxSpecAn_AMPMLoadReferenceWaveformFromTDMSFile.");
}
return function_pointers_.AMPMLoadReferenceWaveformFromTDMSFile(instrumentHandle, selectorString, waveformFilePath, idleDurationPresent, signalType, waveformIndex);
}

int32 NiRFmxSpecAnRestrictedLibrary::CacheResult(niRFmxInstrHandle instrumentHandle, char selectorString[], int32 selectorStringOutSize, char selectorStringOut[])
{
if (!function_pointers_.CacheResult) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,21 @@ class NiRFmxSpecAnRestrictedLibrary : public nirfmxspecan_restricted_grpc::NiRFm
virtual ~NiRFmxSpecAnRestrictedLibrary();

::grpc::Status check_function_exists(std::string functionName);
int32 AMPMLoadReferenceWaveformFromTDMSFile(niRFmxInstrHandle instrumentHandle, char selectorString[], char waveformFilePath[], int32 idleDurationPresent, int32 signalType, int32 waveformIndex) override;
int32 CacheResult(niRFmxInstrHandle instrumentHandle, char selectorString[], int32 selectorStringOutSize, char selectorStringOut[]) override;
int32 GetError(niRFmxInstrHandle instrumentHandle, int32* errorCode, int32 errorDescriptionBufferSize, char errorDescription[]) override;
int32 GetErrorString(niRFmxInstrHandle instrumentHandle, int32 errorCode, int32 errorDescriptionBufferSize, char errorDescription[]) override;
int32 IQFetchDataOverrideBehavior(niRFmxInstrHandle instrumentHandle, char selectorString[], float64 timeout, int32 recordToFetch, int64 samplesToRead, int32 deleteOnFetch, float64* t0, float64* dt, NIComplexSingle data[], int32 arraySize, int32* actualArraySize) override;

private:
using AMPMLoadReferenceWaveformFromTDMSFilePtr = int32 (*)(niRFmxInstrHandle instrumentHandle, char selectorString[], char waveformFilePath[], int32 idleDurationPresent, int32 signalType, int32 waveformIndex);
using CacheResultPtr = int32 (*)(niRFmxInstrHandle instrumentHandle, char selectorString[], int32 selectorStringOutSize, char selectorStringOut[]);
using GetErrorPtr = int32 (*)(niRFmxInstrHandle instrumentHandle, int32* errorCode, int32 errorDescriptionBufferSize, char errorDescription[]);
using GetErrorStringPtr = int32 (*)(niRFmxInstrHandle instrumentHandle, int32 errorCode, int32 errorDescriptionBufferSize, char errorDescription[]);
using IQFetchDataOverrideBehaviorPtr = int32 (*)(niRFmxInstrHandle instrumentHandle, char selectorString[], float64 timeout, int32 recordToFetch, int64 samplesToRead, int32 deleteOnFetch, float64* t0, float64* dt, NIComplexSingle data[], int32 arraySize, int32* actualArraySize);

typedef struct FunctionPointers {
AMPMLoadReferenceWaveformFromTDMSFilePtr AMPMLoadReferenceWaveformFromTDMSFile;
CacheResultPtr CacheResult;
GetErrorPtr GetError;
GetErrorStringPtr GetErrorString;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class NiRFmxSpecAnRestrictedLibraryInterface {
public:
virtual ~NiRFmxSpecAnRestrictedLibraryInterface() {}

virtual int32 AMPMLoadReferenceWaveformFromTDMSFile(niRFmxInstrHandle instrumentHandle, char selectorString[], char waveformFilePath[], int32 idleDurationPresent, int32 signalType, int32 waveformIndex) = 0;
virtual int32 CacheResult(niRFmxInstrHandle instrumentHandle, char selectorString[], int32 selectorStringOutSize, char selectorStringOut[]) = 0;
virtual int32 GetError(niRFmxInstrHandle instrumentHandle, int32* errorCode, int32 errorDescriptionBufferSize, char errorDescription[]) = 0;
virtual int32 GetErrorString(niRFmxInstrHandle instrumentHandle, int32 errorCode, int32 errorDescriptionBufferSize, char errorDescription[]) = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ namespace unit {

class NiRFmxSpecAnRestrictedMockLibrary : public nirfmxspecan_restricted_grpc::NiRFmxSpecAnRestrictedLibraryInterface {
public:
MOCK_METHOD(int32, AMPMLoadReferenceWaveformFromTDMSFile, (niRFmxInstrHandle instrumentHandle, char selectorString[], char waveformFilePath[], int32 idleDurationPresent, int32 signalType, int32 waveformIndex), (override));
MOCK_METHOD(int32, CacheResult, (niRFmxInstrHandle instrumentHandle, char selectorString[], int32 selectorStringOutSize, char selectorStringOut[]), (override));
MOCK_METHOD(int32, GetError, (niRFmxInstrHandle instrumentHandle, int32* errorCode, int32 errorDescriptionBufferSize, char errorDescription[]), (override));
MOCK_METHOD(int32, GetErrorString, (niRFmxInstrHandle instrumentHandle, int32 errorCode, int32 errorDescriptionBufferSize, char errorDescription[]), (override));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,65 @@ namespace nirfmxspecan_restricted_grpc {
return status >= 0;
}

//---------------------------------------------------------------------
//---------------------------------------------------------------------
::grpc::Status NiRFmxSpecAnRestrictedService::AMPMLoadReferenceWaveformFromTDMSFile(::grpc::ServerContext* context, const AMPMLoadReferenceWaveformFromTDMSFileRequest* request, AMPMLoadReferenceWaveformFromTDMSFileResponse* response)
{
if (context->IsCancelled()) {
return ::grpc::Status::CANCELLED;
}
try {
auto instrument_handle_grpc_session = request->instrument_handle();
niRFmxInstrHandle instrument_handle = session_repository_->access_session(instrument_handle_grpc_session.name());
auto selector_string_mbcs = convert_from_grpc<std::string>(request->selector_string());
char* selector_string = (char*)selector_string_mbcs.c_str();
auto waveform_file_path_mbcs = convert_from_grpc<std::string>(request->waveform_file_path());
char* waveform_file_path = (char*)waveform_file_path_mbcs.c_str();
int32 idle_duration_present;
switch (request->idle_duration_present_enum_case()) {
case nirfmxspecan_restricted_grpc::AMPMLoadReferenceWaveformFromTDMSFileRequest::IdleDurationPresentEnumCase::kIdleDurationPresent: {
idle_duration_present = static_cast<int32>(request->idle_duration_present());
break;
}
case nirfmxspecan_restricted_grpc::AMPMLoadReferenceWaveformFromTDMSFileRequest::IdleDurationPresentEnumCase::kIdleDurationPresentRaw: {
idle_duration_present = static_cast<int32>(request->idle_duration_present_raw());
break;
}
case nirfmxspecan_restricted_grpc::AMPMLoadReferenceWaveformFromTDMSFileRequest::IdleDurationPresentEnumCase::IDLE_DURATION_PRESENT_ENUM_NOT_SET: {
return ::grpc::Status(::grpc::INVALID_ARGUMENT, "The value for idle_duration_present was not specified or out of range");
break;
}
}

int32 signal_type;
switch (request->signal_type_enum_case()) {
case nirfmxspecan_restricted_grpc::AMPMLoadReferenceWaveformFromTDMSFileRequest::SignalTypeEnumCase::kSignalType: {
signal_type = static_cast<int32>(request->signal_type());
break;
}
case nirfmxspecan_restricted_grpc::AMPMLoadReferenceWaveformFromTDMSFileRequest::SignalTypeEnumCase::kSignalTypeRaw: {
signal_type = static_cast<int32>(request->signal_type_raw());
break;
}
case nirfmxspecan_restricted_grpc::AMPMLoadReferenceWaveformFromTDMSFileRequest::SignalTypeEnumCase::SIGNAL_TYPE_ENUM_NOT_SET: {
return ::grpc::Status(::grpc::INVALID_ARGUMENT, "The value for signal_type was not specified or out of range");
break;
}
}

int32 waveform_index = request->waveform_index();
auto status = library_->AMPMLoadReferenceWaveformFromTDMSFile(instrument_handle, selector_string, waveform_file_path, idle_duration_present, signal_type, waveform_index);
if (!status_ok(status)) {
return ConvertApiErrorStatusForNiRFmxInstrHandle(context, status, instrument_handle);
}
response->set_status(status);
return ::grpc::Status::OK;
}
catch (nidevice_grpc::NonDriverException& ex) {
return ex.GetStatus();
}
}

//---------------------------------------------------------------------
//---------------------------------------------------------------------
::grpc::Status NiRFmxSpecAnRestrictedService::CacheResult(::grpc::ServerContext* context, const CacheResultRequest* request, CacheResultResponse* response)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ class NiRFmxSpecAnRestrictedService final : public NiRFmxSpecAnRestricted::Servi
const NiRFmxSpecAnRestrictedFeatureToggles& feature_toggles = {});
virtual ~NiRFmxSpecAnRestrictedService();

::grpc::Status AMPMLoadReferenceWaveformFromTDMSFile(::grpc::ServerContext* context, const AMPMLoadReferenceWaveformFromTDMSFileRequest* request, AMPMLoadReferenceWaveformFromTDMSFileResponse* response) override;
::grpc::Status CacheResult(::grpc::ServerContext* context, const CacheResultRequest* request, CacheResultResponse* response) override;
::grpc::Status IQFetchDataOverrideBehavior(::grpc::ServerContext* context, const IQFetchDataOverrideBehaviorRequest* request, IQFetchDataOverrideBehaviorResponse* response) override;
private:
Expand Down
Loading

0 comments on commit fb0cba5

Please sign in to comment.