DynExp
Highly flexible laboratory automation for dynamically changing experiments.
Loading...
Searching...
No Matches
NetworkDigitalOutModule.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/DigitalOut.h"
14
15#include "NetworkDigitalOut.grpc.pb.h"
16
17namespace DynExpModule
18{
19 template <typename... gRPCServices>
20 class NetworkDigitalOutT;
21
22 template <typename... gRPCServices>
39
40 template <typename... gRPCServices>
55
56 template <typename... gRPCServices>
58 {
59 public:
60 using ObjectType = NetworkDigitalOutT<gRPCServices...>;
61 using ParamsType = NetworkDigitalOutParams<gRPCServices...>;
62
64 virtual ~NetworkDigitalOutConfigurator() = default;
65
66 private:
67 virtual DynExp::ParamsBasePtrType MakeParams(DynExp::ItemIDType ID, const DynExp::DynExpCore& Core) const override { return DynExp::MakeParams<NetworkDigitalOutConfigurator>(ID, Core); }
68 };
69
70 template <typename... gRPCServices>
71 class NetworkDigitalOutT : public NetworkDataStreamInstrumentT<gRPCServices...>
72 {
73 public:
74 using ParamsType = NetworkDigitalOutParams<gRPCServices...>;
75 using ConfigType = NetworkDigitalOutConfigurator<gRPCServices...>;
76 using ModuleDataType = NetworkDigitalOutData<gRPCServices...>;
77 using ThisServiceType = DynExpProto::NetworkDigitalOut::NetworkDigitalOut;
78
79 constexpr static auto Name() noexcept { return "Network Digital Out"; }
80
83 virtual ~NetworkDigitalOutT() = default;
84
85 virtual std::string GetName() const override { return Name(); }
86
87 protected:
89 : public gRPCModule<gRPCServices...>::template TypedCallDataBase<CallDataSetAsync, ThisServiceType, DynExpProto::NetworkDigitalOut::SampleMessage, DynExpProto::Common::VoidMessage>
90 {
91 using Base = gRPCModule<gRPCServices...>::template TypedCallDataBase<CallDataSetAsync, ThisServiceType, DynExpProto::NetworkDigitalOut::SampleMessage, DynExpProto::Common::VoidMessage>;
92 using Base::RequestMessage;
93
94 public:
95 CallDataSetAsync(const gRPCModule<gRPCServices...>* const OwningModule) noexcept
96 : Base::TypedCallDataBase(OwningModule, &ThisServiceType::AsyncService::RequestSetAsync) {}
97 virtual ~CallDataSetAsync() = default;
98
99 private:
100 virtual void ProcessChildImpl(DynExp::ModuleInstance& Instance) override
101 {
102 auto ModuleData = DynExp::dynamic_ModuleData_cast<NetworkDigitalOutT>(Instance.ModuleDataGetter());
103
104 ModuleData->GetDigitalOut()->Set(RequestMessage.value());
105 }
106 };
107
109 : public gRPCModule<gRPCServices...>::template TypedCallDataBase<CallDataSetSync, ThisServiceType, DynExpProto::NetworkDigitalOut::SampleMessage, DynExpProto::Common::VoidMessage>
110 {
111 using Base = gRPCModule<gRPCServices...>::template TypedCallDataBase<CallDataSetSync, ThisServiceType, DynExpProto::NetworkDigitalOut::SampleMessage, DynExpProto::Common::VoidMessage>;
112 using Base::RequestMessage;
113
114 public:
115 CallDataSetSync(const gRPCModule<gRPCServices...>* const OwningModule) noexcept
116 : Base::TypedCallDataBase(OwningModule, &DynExpProto::NetworkDigitalOut::NetworkDigitalOut::AsyncService::RequestSetSync) {}
117 virtual ~CallDataSetSync() = default;
118
119 private:
120 virtual void ProcessChildImpl(DynExp::ModuleInstance& Instance) override
121 {
122 auto ModuleData = DynExp::dynamic_ModuleData_cast<NetworkDigitalOutT>(Instance.ModuleDataGetter());
123
124 ModuleData->GetDigitalOut()->SetSync(RequestMessage.value());
125 }
126 };
127
129 : public gRPCModule<gRPCServices...>::template TypedCallDataBase<CallDataSetDefault, ThisServiceType, DynExpProto::Common::VoidMessage, DynExpProto::Common::VoidMessage>
130 {
131 using Base = gRPCModule<gRPCServices...>::template TypedCallDataBase<CallDataSetDefault, ThisServiceType, DynExpProto::Common::VoidMessage, DynExpProto::Common::VoidMessage>;
132
133 public:
134 CallDataSetDefault(const gRPCModule<gRPCServices...>* const OwningModule) noexcept
135 : Base::TypedCallDataBase(OwningModule, &DynExpProto::NetworkDigitalOut::NetworkDigitalOut::AsyncService::RequestSetDefault) {}
136 virtual ~CallDataSetDefault() = default;
137
138 private:
139 virtual void ProcessChildImpl(DynExp::ModuleInstance& Instance) override
140 {
141 auto ModuleData = DynExp::dynamic_ModuleData_cast<NetworkDigitalOutT>(Instance.ModuleDataGetter());
142
143 ModuleData->GetDigitalOut()->SetDefault();
144 }
145 };
146
147 private:
152
154
156 {
157 CallDataSetAsync::MakeCall(this, Instance);
158 CallDataSetSync::MakeCall(this, Instance);
159 CallDataSetDefault::MakeCall(this, Instance);
160
162 }
163
165
166 virtual void ValidateInstrType(const DynExpInstr::DataStreamInstrument* Instr) const override { DynExp::dynamic_Object_cast<typename ModuleDataType::InstrType>(Instr); }
167 };
168
173}
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 output port based on the data stream, function generator,...
Definition DigitalOut.h:141
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< NetworkDigitalOutData >)
virtual ~NetworkDigitalOutData()=default
void ResetImpl(DynExp::ModuleDataBase::dispatch_tag< NetworkDataStreamInstrumentData< gRPCServices... > >) override final
virtual ~NetworkDigitalOutParams()=default
virtual void ConfigureParamsImpl(DynExp::ParamsBase::dispatch_tag< NetworkDigitalOutParams >)
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 ConfigureParamsImpl(DynExp::ParamsBase::dispatch_tag< NetworkDataStreamInstrumentParams< gRPCServices... > >) override final
NetworkDigitalOutParams(DynExp::ItemIDType ID, const DynExp::DynExpCore &Core)
CallDataSetAsync(const gRPCModule< gRPCServices... > *const OwningModule) noexcept
gRPCModule< gRPCServices... >::template TypedCallDataBase< CallDataSetAsync, ThisServiceType, DynExpProto::NetworkDigitalOut::SampleMessage, DynExpProto::Common::VoidMessage > Base
virtual void ProcessChildImpl(DynExp::ModuleInstance &Instance) override
CallDataSetDefault(const gRPCModule< gRPCServices... > *const OwningModule) noexcept
virtual void ProcessChildImpl(DynExp::ModuleInstance &Instance) override
gRPCModule< gRPCServices... >::template TypedCallDataBase< CallDataSetDefault, ThisServiceType, DynExpProto::Common::VoidMessage, DynExpProto::Common::VoidMessage > Base
virtual void ProcessChildImpl(DynExp::ModuleInstance &Instance) override
CallDataSetSync(const gRPCModule< gRPCServices... > *const OwningModule) noexcept
gRPCModule< gRPCServices... >::template TypedCallDataBase< CallDataSetSync, ThisServiceType, DynExpProto::NetworkDigitalOut::SampleMessage, DynExpProto::Common::VoidMessage > Base
virtual void ValidateInstrType(const DynExpInstr::DataStreamInstrument *Instr) const override
DynExpProto::NetworkDigitalOut::NetworkDigitalOut ThisServiceType
virtual ~NetworkDigitalOutT()=default
static constexpr auto Name() noexcept
void CreateInitialCallDataObjectsImpl(DynExp::Object::dispatch_tag< NetworkDataStreamInstrumentT< gRPCServices... > >, DynExp::ModuleInstance &Instance) const override final
virtual void CreateInitialCallDataObjectsImpl(DynExp::Object::dispatch_tag< NetworkDigitalOutT >, DynExp::ModuleInstance &Instance) const
NetworkDigitalOutT(const std::thread::id OwnerThreadID, DynExp::ParamsBasePtrType &&Params)
void ResetImpl(DynExp::Object::dispatch_tag< NetworkDataStreamInstrumentT< gRPCServices... > >) override final
virtual std::string GetName() const override
Returns the name of this Object type.
virtual void ResetImpl(DynExp::Object::dispatch_tag< NetworkDigitalOutT >)
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.