14 #include "pulse_streamer.pb.h"
15 #include "pulse_streamer.grpc.pb.h"
19 class SIPulseStreamerHardwareAdapter;
36 virtual const char*
GetParamClassTag() const noexcept
override {
return "SIPulseStreamerParams"; }
39 "Trigger Edge",
"Signal edge or event which triggers the pulse streamer.",
40 true, TriggerEdgeType::Immediate };
42 "Trigger Mode",
"Determines whether the puslse streamer waits for subsequent trigger events (normal) or only for one (single).",
43 true, TriggerModeType::Normal };
45 "Determines how often the stored pulse sequence should be repeated after triggering. -1 means indefinitely.",
79 std::unique_ptr<pulse_streamer::PulseMessage>
ToPulseMessage()
const;
99 constexpr
static auto Name() noexcept {
return "Swabian Instruments Pulse Streamer (gRPC)"; }
100 constexpr
static auto Category() noexcept {
return "I/O"; }
123 template <
typename MessageType>
124 using StubFuncPtrType = grpc::Status(pulse_streamer::PulseStreamer::Stub::*)(grpc::ClientContext*,
const MessageType&, pulse_streamer::PulseStreamerReply*);
129 template <
typename MessageType>
130 uint32_t
InvokeStubFunc(StubFuncPtrType<MessageType> Func,
const MessageType& Message)
const;
156 template <
typename MessageType>
159 grpc::ClientContext Context;
160 pulse_streamer::PulseStreamerReply Reply;
162 static const auto Timeout = std::chrono::milliseconds(1000);
163 Context.set_deadline(std::chrono::system_clock::now() +
Timeout);
165 auto Result = (
GetStubUnsafe().*Func)(&Context, Message, &Reply);
168 return Reply.value();
Implementation of a hardware adapter to communicate over TCP sockets using gRPC.
virtual DynExp::ParamsBasePtrType MakeParams(DynExp::ItemIDType ID, const DynExp::DynExpCore &Core) const override
Override to make derived classes call DynExp::MakeParams with the correct configurator type derived f...
virtual ~SIPulseStreamerHardwareAdapterConfigurator()=default
SIPulseStreamerHardwareAdapterConfigurator()=default
static Util::TextValueListType< OutputChannelType > OutputChannelTypeStrList()
Param< ParamsConfigDialog::NumberType > NumRuns
Param< TriggerEdgeType > TriggerEdge
SIPulseStreamerHardwareAdapterParams(DynExp::ItemIDType ID, const DynExp::DynExpCore &Core)
virtual void ConfigureParamsImpl(dispatch_tag< SIPulseStreamerHardwareAdapterParams >)
static Util::TextValueListType< TriggerEdgeType > TriggerEdgeTypeStrList()
Param< TriggerModeType > TriggerMode
static Util::TextValueListType< TriggerModeType > TriggerModeTypeStrList()
virtual ~SIPulseStreamerHardwareAdapterParams()=default
void ConfigureParamsImpl(dispatch_tag< gRPCHardwareAdapterParams >) override final
virtual const char * GetParamClassTag() const noexcept override
This function is intended to be overridden once in each derived class returning the name of the respe...
void ForceFinalSample() const
void SetNumRuns(int64_t NumRuns=-1) const
void SetTrigger(SIPulseStreamerHardwareAdapterParams::TriggerEdgeType TriggerEdge, SIPulseStreamerHardwareAdapterParams::TriggerModeType TriggerMode=SIPulseStreamerHardwareAdapterParams::TriggerModeType::Normal) const
uint32_t InvokeStubFunc(StubFuncPtrType< pulse_streamer::VoidMessage > Func) const
virtual ~SIPulseStreamerHardwareAdapter()
virtual void ResetImpl(dispatch_tag< SIPulseStreamerHardwareAdapter >)
virtual void OpenUnsafeChild() override
Override to add additional initialization steps. Gets executed after the gRPC connection has been est...
void SetSamples(SIPulseStreamerHardwareAdapterParams::OutputChannelType OutputChannel, const std::vector< SampleType > &NewSamples) const
std::vector< SampleType > Samples
Combined sample vector of all channels. Assumed to be always sorted.
constexpr static auto Category() noexcept
void SetConstantOutput(const PulseType &Pulse={}) const
bool HasSequenceUnsafe() const
void SetSamplesUnsafe(SIPulseStreamerHardwareAdapterParams::OutputChannelType OutputChannel, const std::vector< SampleType > &NewSamples) const
virtual std::string GetName() const override
Returns the name of this Object type.
void ResetDeviceUnsafe() const
SIPulseStreamerHardwareAdapter(const std::thread::id OwnerThreadID, DynExp::ParamsBasePtrType &&Params)
int64_t NumRuns
How often to repeat the sample sequence. -1 means indefinitely.
std::vector< PulseType > ComposePulseSequence() const
void SetTriggerUnsafe(SIPulseStreamerHardwareAdapterParams::TriggerEdgeType TriggerEdge, SIPulseStreamerHardwareAdapterParams::TriggerModeType TriggerMode=SIPulseStreamerHardwareAdapterParams::TriggerModeType::Normal) const
bool HasFinishedUnsafe() const
bool IsStreamingUnsafe() const
void RearmTriggerUnsafe() const
constexpr static auto Name() noexcept
void ForceTriggerUnsafe() const
void RearmTrigger() const
void ForceTrigger() const
void SetNumRunsUnsafe(int64_t NumRuns=-1) const
void ForceFinalSampleUnsafe() const
void ResetImpl(dispatch_tag< gRPCHardwareAdapter >) override final
virtual std::string GetCategory() const override
Returns the category of this Object type.
void SetConstantOutputUnsafe(const PulseType &Pulse={}) const
uint32_t InvokeStubFunc(StubFuncPtrType< MessageType > Func, const MessageType &Message) const
grpc::Status(pulse_streamer::PulseStreamer::Stub::*)(grpc::ClientContext *, const MessageType &, pulse_streamer::PulseStreamerReply *) StubFuncPtrType
Configurator class for gRPCHardwareAdapter.
Parameter class for gRPCHardwareAdapter.
This template class provides basic functionality to design hardware adapters for instruments which co...
void CheckError(const grpc::Status Result, const std::source_location Location=std::source_location::current()) const
Checks whether Result denotes an error state. If this is the case, a respective gRPCException is cons...
gRPCStub::Stub & GetStubUnsafe() const
Getter for the gRPC stub.
DynExp's core class acts as the interface between the user interface and DynExp's internal data like ...
Defines the base class for a hardware adapter object. Hardware adapters describe interfaces/connectio...
Configurator class for HardwareAdapterBase.
Parameter class for HardwareAdapterBase.
const std::thread::id OwnerThreadID
Thread id of the thread which has constructed (and owns) this Object instance.
const ParamsBasePtrType Params
Pointer to the parameter class instance belonging to this Object instance.
Refer to ParamsBase::dispatch_tag.
const ItemIDType ID
ID of the Object this parameter class instance belongs to.
const DynExpCore & Core
Reference to DynExp's core.
Tag for function dispatching mechanism within this class used when derived classes are not intended t...
DynExp's hardware namespace contains the implementation of DynExp hardware adapters which extend DynE...
std::strong_ordering operator<=>(const SIPulseStreamerHardwareAdapter::SampleType &lhs, const SIPulseStreamerHardwareAdapter::SampleType &rhs)
@ Pulse
Manually defined pulses.
std::unique_ptr< ParamsBase > ParamsBasePtrType
Alias for a pointer to the parameter system base class ParamsBase.
size_t ItemIDType
ID type of objects/items managed by DynExp.
std::vector< std::pair< TextType, ValueType > > TextValueListType
Type of a list containing key-value pairs where key is a text of type Util::TextType.
Accumulates include statements to provide a precompiled header.
Swabian Instruments Pulse Streamer 8/2's internal representation of a single pulse.
int16_t ao1
Analog out channel 1 (-0x7FFF is -1.0V, 0x7FFF is 1.0V)
uint32_t ticks
Duration in ns.
uint8_t digi
Digital out bit mask (LSB is channel 0, MSB is channel 7)
std::unique_ptr< pulse_streamer::PulseMessage > ToPulseMessage() const
int16_t ao0
Analog out channel 0 (-0x7FFF is -1.0V, 0x7FFF is 1.0V)
Sample of one output channel.
uint8_t ComposeDOValue() const
std::chrono::nanoseconds Timestamp
SIPulseStreamerHardwareAdapterParams::OutputChannelType Channel
static int16_t MakeValueFromVoltage(const double Voltage)