16 #include "Common.pb.h"
17 #include "Common.grpc.pb.h"
21 template <
typename BaseInstr,
typename std::enable_if_t<std::is_base_of_v<DynExp::InstrumentBase, BaseInstr>,
int>,
typename... gRPCStubs>
27 namespace gRPCInstrumentTasks
33 template <
typename BaseInstr, std::enable_if_t<std::is_base_of_v<DynExp::InstrumentBase, BaseInstr>,
int>,
typename... gRPCStubs>
34 class InitTask :
public BaseInstr::InitTaskType
40 template <
typename Type>
55 InstrData->StubPtrs = std::make_tuple(gRPCStubs::NewStub(grpc::CreateChannel(InstrParams->NetworkParams.MakeAddress(), grpc::InsecureChannelCredentials()))...);
71 template <
typename BaseInstr, std::enable_if_t<std::is_base_of_v<DynExp::InstrumentBase, BaseInstr>,
int>,
typename... gRPCStubs>
72 class ExitTask :
public BaseInstr::ExitTaskType
78 template <
typename Type>
93 InstrData->ResetStubPtrs();
112 template <
typename BaseInstr, std::enable_if_t<std::is_base_of_v<DynExp::InstrumentBase, BaseInstr>,
int>,
typename... gRPCStubs>
119 template <
typename Type>
142 template <
typename gRPCStub>
149 template <
typename BaseInstr,
typename std::enable_if_t<std::is_base_of_v<DynExp::InstrumentBase, BaseInstr>,
int>,
typename... gRPCStubs>
162 template <
typename... ArgTs>
173 template <
size_t Index>
182 template <
typename T>
216 template <
typename BaseInstr,
typename std::enable_if_t<std::is_base_of_v<DynExp::InstrumentBase, BaseInstr>,
int>,
typename... gRPCStubs>
232 virtual const char*
GetParamClassTag() const noexcept
override {
return "gRPCInstrumentParams"; }
260 template <
typename BaseInstr,
typename std::enable_if_t<std::is_base_of_v<DynExp::InstrumentBase, BaseInstr>,
int>,
typename... gRPCStubs>
291 template <
typename BaseInstr,
typename std::enable_if_t<std::is_base_of_v<DynExp::InstrumentBase, BaseInstr>,
int>,
typename... gRPCStubs>
299 constexpr
static auto Name() noexcept {
return "gRPC Instrument"; }
300 constexpr
static auto Category() noexcept {
return "Network Instruments (Clients)"; }
307 : BaseInstr(OwnerThreadID, std::move(Params)) {}
351 template <
typename gRPCStub,
typename RequestMsgType,
typename ResponseMsgType>
352 using StubFuncPtrType = grpc::Status(gRPCStub::*)(grpc::ClientContext*,
const RequestMsgType&, ResponseMsgType*);
372 template <
typename gRPCStub,
typename RequestMsgType,
typename ResponseMsgType>
375 grpc::ClientContext Context;
376 ResponseMsgType ReplyMsg;
383 static const auto Timeout = std::chrono::milliseconds(2000);
384 Context.set_deadline(std::chrono::system_clock::now() +
Timeout);
386 auto Result = (*StubPtr.*StubFunc)(&Context, RequestMsg, &ReplyMsg);
Implementation of a data stream meta instrument and of data streams input/output devices might work o...
Defines DynExp's core module as an interface between the UI and DynExp objects.
Implementation of a hardware adapter to communicate over TCP sockets using gRPC.
Defines an exception caused by an operation involving the gRPC library and communication over a TCP s...
Configurator class for gRPCInstrument.
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...
gRPCInstrumentConfigurator()=default
virtual ~gRPCInstrumentConfigurator()=default
Data class for gRPCInstrument.
virtual ~gRPCInstrumentData()=default
virtual void ResetImpl(DynExp::InstrumentDataBase::dispatch_tag< gRPCInstrumentData >)
Refer to DynExp::InstrumentDataBase::Reset(). Using tag dispatch mechanism to ensure that ResetImpl()...
gRPCInstrumentData(ArgTs &&...Args)
Constructs a gRPCInstrumentData instance and forwards all arguments passed to the constructor to the ...
auto GetStub() const noexcept
Returns a stub pointer this gRPCInstrument uses selected by the stub index in the gRPCStubs list of g...
void ResetImpl(DynExp::InstrumentDataBase::dispatch_tag< typename BaseInstr::InstrumentDataType >) override final
Refer to DynExp::InstrumentDataBase::Reset(). Using tag dispatch mechanism to ensure that ResetImpl()...
void ResetStubPtrs()
Sets all pointers contained in StubPtrs to nullptr.
std::tuple< StubPtrType< gRPCStubs >... > StubPtrs
Tuple of pointers to all the stubs this gRPCInstrument uses.
Parameter class for gRPCInstrument.
virtual ~gRPCInstrumentParams()=default
gRPCInstrumentParams(DynExp::ItemIDType ID, const DynExp::DynExpCore &Core)
Constructs the parameters for a gRPCInstrument instance.
DynExp::NetworkParamsExtension NetworkParams
Network address of the gRPC server to connect to.
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...
virtual const DynExp::NetworkParamsExtension * GetNetworkAddressParamsChild() const noexcept override
Returns the network address parameters of a derived gRPC instrument. Override GetNetworkAddressParams...
virtual void ConfigureParamsImpl(DynExp::InstrumentParamsBase::dispatch_tag< gRPCInstrumentParams >)
Called by DynExp::ParamsBase::ConfigureParams() as a starting point for the tag dispatch mechanism to...
void ConfigureParamsImpl(DynExp::InstrumentParamsBase::dispatch_tag< typename BaseInstr::ParamsType >) override final
Called by DynExp::ParamsBase::ConfigureParams() as a starting point for the tag dispatch mechanism to...
Defines a task for deinitializing an instrument within an instrument inheritance hierarchy....
virtual void ExitFuncImpl(dispatch_tag< ExitTask >, DynExp::InstrumentInstance &Instance)
Deinitializes the respective instrument within the instrument inheritance hierarchy....
void ExitFuncImpl(dispatch_tag< typename BaseInstr::ExitTaskType >, DynExp::InstrumentInstance &Instance) override final
Deinitializes the respective instrument within the instrument inheritance hierarchy....
Defines a task for initializing an instrument within an instrument inheritance hierarchy....
void InitFuncImpl(dispatch_tag< typename BaseInstr::InitTaskType >, DynExp::InstrumentInstance &Instance) override final
Initializes the respective instrument within the instrument inheritance hierarchy....
virtual void InitFuncImpl(dispatch_tag< InitTask< BaseInstr, 0, gRPCStubs... >>, DynExp::InstrumentInstance &Instance)
Initializes the respective instrument within the instrument inheritance hierarchy....
Defines a task for updating an instrument within an instrument inheritance hierarchy....
void UpdateFuncImpl(dispatch_tag< typename BaseInstr::UpdateTaskType >, DynExp::InstrumentInstance &Instance) override final
Updates the respective instrument within the instrument inheritance hierarchy. Call UpdateFuncImpl() ...
Meta instrument template for transforming meta instruments into network instruments,...
void ResetImpl(DynExp::Object::dispatch_tag< BaseInstr >) override final
Refer to DynExp::Object::Reset(). Using tag dispatch mechanism to ensure that ResetImpl() of every de...
virtual std::unique_ptr< DynExp::UpdateTaskBase > MakeUpdateTask() const override
Factory function for an update task (UpdateTaskBase). Override to define the desired update task in d...
virtual void ResetImpl(DynExp::Object::dispatch_tag< gRPCInstrument >)
Refer to DynExp::Object::Reset(). Using tag dispatch mechanism to ensure that ResetImpl() of every de...
virtual std::string GetCategory() const override
Returns the category of this Object type.
virtual std::unique_ptr< DynExp::InitTaskBase > MakeInitTask() const override
Factory function for an init task (InitTaskBase). Override to define the desired initialization task ...
virtual ~gRPCInstrument()
virtual std::unique_ptr< DynExp::ExitTaskBase > MakeExitTask() const override
Factory function for an exit task (ExitTaskBase). Override to define the desired deinitialization tas...
constexpr static auto Name() noexcept
Every derived class has to redefine this function.
virtual std::string GetName() const override
Returns the name of this Object type.
gRPCInstrument(const std::thread::id OwnerThreadID, DynExp::ParamsBasePtrType &&Params)
Constructs an instrument instance.
constexpr static auto Category() noexcept
Every derived class has to redefine this function.
DynExp's core class acts as the interface between the user interface and DynExp's internal data like ...
Refer to DynExp::ParamsBase::dispatch_tag.
Refer to DynExp::ParamsBase::dispatch_tag.
Refer to ParamsBase::dispatch_tag.
Defines data for a thread belonging to a InstrumentBase instance. Refer to RunnableInstance.
Bundles several parameters to describe a network connection. Use in parameter classes.
Refer to ParamsBase::dispatch_tag.
Tag for function dispatching mechanism within this class used when derived classes are not intended t...
Refer to DynExp::ParamsBase::dispatch_tag.
An invalid argument like a null pointer has been passed to a function.
An operation cannot be performed currently since the related object is in an invalid state like an er...
DynExp's instrument namespace contains the implementation of DynExp instruments which extend DynExp's...
ResponseMsgType InvokeStubFunc(StubPtrType< gRPCStub > StubPtr, StubFuncPtrType< gRPCStub, RequestMsgType, ResponseMsgType > StubFunc, const RequestMsgType &RequestMsg)
Invokes a gRPC stub function as a remote procedure call. Waits for a fixed amount of time (2 seconds)...
std::shared_ptr< typename gRPCStub::Stub > StubPtrType
Alias for a pointer to a gRPC stub.
grpc::Status(gRPCStub::*)(grpc::ClientContext *, const RequestMsgType &, ResponseMsgType *) StubFuncPtrType
Alias for a pointer to a gRPC stub function, which can be invoked as a remote procedure call.
std::unique_ptr< TaskT > MakeTask(ArgTs &&...Args)
Factory function to create a task to be enqueued in an instrument's task queue.
T::ParamsType * dynamic_Params_cast(ParamsBasePtrType::element_type *Params)
Casts the parameter base class to a derived Object's parameter class.
auto dynamic_InstrumentData_cast(Util::SynchronizedPointer< From > &&InstrumentDataPtr)
Casts the data base class From into a derived InstrumentBase's (To) data class keeping the data locke...
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.
Accumulates include statements to provide a precompiled header.