Skip to content

Commit

Permalink
Add oneof input handling for custom functions (#137)
Browse files Browse the repository at this point in the history
  • Loading branch information
kreimnitz authored Mar 18, 2021
1 parent 684dd02 commit b0c4e61
Showing 1 changed file with 49 additions and 4 deletions.
53 changes: 49 additions & 4 deletions source/custom/niscope_service.custom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,19 @@ ::grpc::Status NiScopeService::FetchArrayMeasurement(::grpc::ServerContext* cont
ViSession 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 = request->array_meas_function();
ViInt32 array_meas_function;
switch (request->array_meas_function_enum_case()) {
case grpc::niscope::FetchArrayMeasurementRequest::ArrayMeasFunctionEnumCase::kArrayMeasFunction:
array_meas_function = (ViInt32)request->array_meas_function();
break;
case grpc::niscope::FetchArrayMeasurementRequest::ArrayMeasFunctionEnumCase::kArrayMeasFunctionRaw:
array_meas_function = (ViInt32)request->array_meas_function_raw();
break;
case grpc::niscope::FetchArrayMeasurementRequest::ArrayMeasFunctionEnumCase::ARRAY_MEAS_FUNCTION_ENUM_NOT_SET:
return ::grpc::Status(::grpc::INVALID_ARGUMENT, "The value for array_meas_function was not specified or out of range");
break;
}

ViInt32 measurement_waveform_size;
CheckStatus(library_->ActualMeasWfmSize(vi, array_meas_function, &measurement_waveform_size));

Expand Down Expand Up @@ -223,7 +235,18 @@ ::grpc::Status NiScopeService::FetchMeasurementStats(::grpc::ServerContext* cont
ViSession 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 = request->scalar_meas_function();
ViInt32 scalar_meas_function;
switch (request->scalar_meas_function_enum_case()) {
case grpc::niscope::FetchMeasurementStatsRequest::ScalarMeasFunctionEnumCase::kScalarMeasFunction:
scalar_meas_function = (ViInt32)request->scalar_meas_function();
break;
case grpc::niscope::FetchMeasurementStatsRequest::ScalarMeasFunctionEnumCase::kScalarMeasFunctionRaw:
scalar_meas_function = (ViInt32)request->scalar_meas_function_raw();
break;
case grpc::niscope::FetchMeasurementStatsRequest::ScalarMeasFunctionEnumCase::SCALAR_MEAS_FUNCTION_ENUM_NOT_SET:
return ::grpc::Status(::grpc::INVALID_ARGUMENT, "The value for scalar_meas_function was not specified or out of range");
break;
}

ViInt32 num_waveforms;
CheckStatus(library_->ActualNumWfms(vi, channel_list, &num_waveforms));
Expand Down Expand Up @@ -384,7 +407,18 @@ ::grpc::Status NiScopeService::FetchMeasurement(::grpc::ServerContext* context,
ViSession 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 = request->scalar_meas_function();
ViInt32 scalar_meas_function;
switch (request->scalar_meas_function_enum_case()) {
case grpc::niscope::FetchMeasurementRequest::ScalarMeasFunctionEnumCase::kScalarMeasFunction:
scalar_meas_function = (ViInt32)request->scalar_meas_function();
break;
case grpc::niscope::FetchMeasurementRequest::ScalarMeasFunctionEnumCase::kScalarMeasFunctionRaw:
scalar_meas_function = (ViInt32)request->scalar_meas_function_raw();
break;
case grpc::niscope::FetchMeasurementRequest::ScalarMeasFunctionEnumCase::SCALAR_MEAS_FUNCTION_ENUM_NOT_SET:
return ::grpc::Status(::grpc::INVALID_ARGUMENT, "The value for scalar_meas_function was not specified or out of range");
break;
}

ViInt32 num_waveforms;
CheckStatus(library_->ActualNumWfms(vi, channel_list, &num_waveforms));
Expand Down Expand Up @@ -482,7 +516,18 @@ ::grpc::Status NiScopeService::ReadMeasurement(::grpc::ServerContext* context, c
ViSession 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 = request->scalar_meas_function();
ViInt32 scalar_meas_function;
switch (request->scalar_meas_function_enum_case()) {
case grpc::niscope::ReadMeasurementRequest::ScalarMeasFunctionEnumCase::kScalarMeasFunction:
scalar_meas_function = (ViInt32)request->scalar_meas_function();
break;
case grpc::niscope::ReadMeasurementRequest::ScalarMeasFunctionEnumCase::kScalarMeasFunctionRaw:
scalar_meas_function = (ViInt32)request->scalar_meas_function_raw();
break;
case grpc::niscope::ReadMeasurementRequest::ScalarMeasFunctionEnumCase::SCALAR_MEAS_FUNCTION_ENUM_NOT_SET:
return ::grpc::Status(::grpc::INVALID_ARGUMENT, "The value for scalar_meas_function was not specified or out of range");
break;
}

ViInt32 num_waveforms;
CheckStatus(library_->ActualNumWfms(vi, channel_list, &num_waveforms));
Expand Down

0 comments on commit b0c4e61

Please sign in to comment.