DynExp
Highly flexible laboratory automation for dynamically changing experiments.
Loading...
Searching...
No Matches
NetworkDigitalInModule.h
Go to the documentation of this file.
1// This file is part of DynExp.
2
9#pragma once
10
11#include "stdafx.h"
12#include "../MetaInstruments/DigitalIn.h"
14
15#include "NetworkDigitalIn.grpc.pb.h"
16
17namespace DynExpModule
18{
19 template <typename... gRPCServices>
20 class NetworkDigitalInT;
21
22 template <typename... gRPCServices>
39
40 template <typename... gRPCServices>
55
56 template <typename... gRPCServices>
58 {
59 public:
60 using ObjectType = NetworkDigitalInT<gRPCServices...>;
61 using ParamsType = NetworkDigitalInParams<gRPCServices...>;
62
64 virtual ~NetworkDigitalInConfigurator() = default;
65
66 private:
67 virtual DynExp::ParamsBasePtrType MakeParams(DynExp::ItemIDType ID, const DynExp::DynExpCore& Core) const override { return DynExp::MakeParams<NetworkDigitalInConfigurator>(ID, Core); }
68 };
69
70 template <typename... gRPCServices>
71 class NetworkDigitalInT : public NetworkDataStreamInstrumentT<gRPCServices...>
72 {
73 public:
74 using ParamsType = NetworkDigitalInParams<gRPCServices...>;
75 using ConfigType = NetworkDigitalInConfigurator<gRPCServices...>;
76 using ModuleDataType = NetworkDigitalInData<gRPCServices...>;
77 using ThisServiceType = DynExpProto::NetworkDigitalIn::NetworkDigitalIn;
78
79 constexpr static auto Name() noexcept { return "Network Digital In"; }
80
83 virtual ~NetworkDigitalInT() = default;
84
85 virtual std::string GetName() const override { return Name(); }
86
87 protected:
89 : public gRPCModule<gRPCServices...>::template TypedCallDataBase<CallDataGetAsync, ThisServiceType, DynExpProto::Common::VoidMessage, DynExpProto::NetworkDigitalIn::SampleMessage>
90 {
91 using Base = gRPCModule<gRPCServices...>::template TypedCallDataBase<CallDataGetAsync, ThisServiceType, DynExpProto::Common::VoidMessage, DynExpProto::NetworkDigitalIn::SampleMessage>;
92 using Base::ResponseMessage;
93
94 public:
95 CallDataGetAsync(const gRPCModule<gRPCServices...>* const OwningModule) noexcept
96 : Base::TypedCallDataBase(OwningModule, &ThisServiceType::AsyncService::RequestGetAsync) {}
97 virtual ~CallDataGetAsync() = default;
98
99 private:
100 virtual void ProcessChildImpl(DynExp::ModuleInstance& Instance) override
101 {
102 auto ModuleData = DynExp::dynamic_ModuleData_cast<NetworkDigitalInT>(Instance.ModuleDataGetter());
103
104 ResponseMessage.set_value(static_cast<bool>(ModuleData->GetDigitalIn()->Get()));
105 }
106 };
107
109 : public gRPCModule<gRPCServices...>::template TypedCallDataBase<CallDataGetSync, ThisServiceType, DynExpProto::Common::VoidMessage, DynExpProto::NetworkDigitalIn::SampleMessage>
110 {
111 using Base = gRPCModule<gRPCServices...>::template TypedCallDataBase<CallDataGetSync, ThisServiceType, DynExpProto::Common::VoidMessage, DynExpProto::NetworkDigitalIn::SampleMessage>;
112 using Base::ResponseMessage;
113
114 public:
115 CallDataGetSync(const gRPCModule<gRPCServices...>* const OwningModule) noexcept
116 : Base::TypedCallDataBase(OwningModule, &DynExpProto::NetworkDigitalIn::NetworkDigitalIn::AsyncService::RequestGetSync) {}
117 virtual ~CallDataGetSync() = default;
118
119 private:
120 virtual void ProcessChildImpl(DynExp::ModuleInstance& Instance) override
121 {
122 auto ModuleData = DynExp::dynamic_ModuleData_cast<NetworkDigitalInT>(Instance.ModuleDataGetter());
123
124 ResponseMessage.set_value(static_cast<bool>(ModuleData->GetDigitalIn()->GetSync()));
125 }
126 };
127
128 private:
133
135
137 {
138 CallDataGetAsync::MakeCall(this, Instance);
139 CallDataGetSync::MakeCall(this, Instance);
140
142 }
143
145
146 virtual void ValidateInstrType(const DynExpInstr::DataStreamInstrument* Instr) const override { DynExp::dynamic_Object_cast<typename ModuleDataType::InstrType>(Instr); }
147 };
148
153}
Implementation of a gRPC server module to provide remote access to a data stream instrument meta inst...
Implementation of the data stream meta instrument, which is a base class for all instruments reading/...
Meta instrument for a single digital input port based on the data stream and generic input port meta ...
Definition DigitalIn.h:136
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 void ResetImpl(DynExp::ModuleDataBase::dispatch_tag< NetworkDigitalInData >)
virtual ~NetworkDigitalInData()=default
void ResetImpl(DynExp::ModuleDataBase::dispatch_tag< NetworkDataStreamInstrumentData< gRPCServices... > >) override final
virtual ~NetworkDigitalInParams()=default
DynExp::ParamsBase::DummyParam Dummy
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...
NetworkDigitalInParams(DynExp::ItemIDType ID, const DynExp::DynExpCore &Core)
void ConfigureParamsImpl(DynExp::ParamsBase::dispatch_tag< NetworkDataStreamInstrumentParams< gRPCServices... > >) override final
virtual void ConfigureParamsImpl(DynExp::ParamsBase::dispatch_tag< NetworkDigitalInParams >)
gRPCModule< gRPCServices... >::template TypedCallDataBase< CallDataGetAsync, ThisServiceType, DynExpProto::Common::VoidMessage, DynExpProto::NetworkDigitalIn::SampleMessage > Base
virtual void ProcessChildImpl(DynExp::ModuleInstance &Instance) override
CallDataGetAsync(const gRPCModule< gRPCServices... > *const OwningModule) noexcept
gRPCModule< gRPCServices... >::template TypedCallDataBase< CallDataGetSync, ThisServiceType, DynExpProto::Common::VoidMessage, DynExpProto::NetworkDigitalIn::SampleMessage > Base
virtual void ProcessChildImpl(DynExp::ModuleInstance &Instance) override
CallDataGetSync(const gRPCModule< gRPCServices... > *const OwningModule) noexcept
DynExpProto::NetworkDigitalIn::NetworkDigitalIn ThisServiceType
virtual std::string GetName() const override
Returns the name of this Object type.
virtual void ValidateInstrType(const DynExpInstr::DataStreamInstrument *Instr) const override
virtual void ResetImpl(DynExp::Object::dispatch_tag< NetworkDigitalInT >)
NetworkDigitalInT(const std::thread::id OwnerThreadID, DynExp::ParamsBasePtrType &&Params)
virtual void CreateInitialCallDataObjectsImpl(DynExp::Object::dispatch_tag< NetworkDigitalInT >, DynExp::ModuleInstance &Instance) const
static constexpr auto Name() noexcept
void CreateInitialCallDataObjectsImpl(DynExp::Object::dispatch_tag< NetworkDataStreamInstrumentT< gRPCServices... > >, DynExp::ModuleInstance &Instance) const override final
virtual ~NetworkDigitalInT()=default
void ResetImpl(DynExp::Object::dispatch_tag< NetworkDataStreamInstrumentT< gRPCServices... > >) override final
Module template for building gRPC servers listening on TCP sockets for network instruments to connect...
Definition gRPCModule.h:116
DynExp's core class acts as the interface between the user interface and DynExp's internal data like ...
Definition DynExpCore.h:127
const std::unique_ptr< ModuleDataType > ModuleData
Module data belonging to this ModuleBase instance.
Definition Module.h:743
Refer to ParamsBase::dispatch_tag.
Definition Module.h:189
Defines data for a thread belonging to a ModuleBase instance. Refer to RunnableInstance.
Definition Module.h:793
const ModuleBase::ModuleDataGetterType ModuleDataGetter
Getter for module's data. Refer to ModuleBase::ModuleDataGetterType.
Definition Module.h:825
const std::thread::id OwnerThreadID
Thread id of the thread which has constructed (and owns) this Object instance.
Definition Object.h:2302
const ParamsBasePtrType Params
Pointer to the parameter class instance belonging to this Object instance.
Definition Object.h:2303
Refer to ParamsBase::dispatch_tag.
Definition Object.h:2018
Dummy parameter which is to be owned once by parameter classes that do not contain any other paramete...
Definition Object.h:522
const ItemIDType ID
ID of the Object this parameter class instance belongs to.
Definition Object.h:1779
const DynExpCore & Core
Reference to DynExp's core.
Definition Object.h:1780
Tag for function dispatching mechanism within this class used when derived classes are not intended t...
Definition Object.h:349
DynExp's module namespace contains the implementation of DynExp modules which extend DynExp's core fu...
std::unique_ptr< ParamsBase > ParamsBasePtrType
Alias for a pointer to the parameter system base class ParamsBase.
Definition Object.h:1807
size_t ItemIDType
ID type of objects/items managed by DynExp.
Accumulates include statements to provide a precompiled header.