DynExp
Highly flexible laboratory automation for dynamically changing experiments.
DigitalOut.cpp
Go to the documentation of this file.
1 // This file is part of DynExp.
2 
3 #include "stdafx.h"
4 #include "DigitalOut.h"
5 
6 namespace DynExpInstr
7 {
9  {
11  }
12 
14  {
15  ExitFuncImpl(dispatch_tag<ExitTask>(), Instance);
16  }
17 
19  {
20  ResetImpl(dispatch_tag<DigitalOutData>());
21  }
22 
24  {
25  }
26 
28  {
30  }
31 
33  {
34  }
35 
37  {
38  }
39 
41  {
42  {
43  auto InstrData = dynamic_InstrumentData_cast<DigitalOut>(GetInstrumentData());
44 
45  InstrData->GetSampleStream()->WriteBasicSample({ static_cast<BasicSample::DataType>(Sample), 0 });
46  } // InstrData unlocked here.
47 
48  WriteData(CallbackFunc);
49  }
50 
52  {
53  AsSyncTask(&DigitalOut::Set, Sample);
54  }
55 
57  {
58  {
59  auto InstrParams = DynExp::dynamic_Params_cast<DigitalOut>(GetParams());
60  auto InstrData = dynamic_InstrumentData_cast<DigitalOut>(GetInstrumentData());
61 
62  DigitalOutData::SampleStreamType::SampleType DefaultValue = InstrParams->DefaultValue;
63  auto SampleStream = InstrData->GetSampleStream();
64 
65  SampleStream->Clear();
66  for (auto i = SampleStream->GetStreamSizeWrite(); i > 0; --i)
67  SampleStream->WriteBasicSample({ static_cast<BasicSample::DataType>(DefaultValue), 0 });
68  } // InstrParams and InstrData unlocked here.
69 
70  WriteData();
71  }
72 
74  {
75  SetDefault();
76  }
77 
79  {
80  ResetImpl(dispatch_tag<DigitalOut>());
81  }
82 }
Defines a meta instrument for a single digital output port to write a data stream consisting of digit...
SampleT SampleType
Alias for SampleT.
void ResetImpl(dispatch_tag< OutputPortData >) override final
Definition: DigitalOut.cpp:18
void DisableUserEditable()
Calls DynExp::ParamsBase::DisableUserEditable() on all bundled parameters.
Definition: DigitalOut.cpp:27
void ExitFuncImpl(dispatch_tag< OutputPortTasks::ExitTask >, DynExp::InstrumentInstance &Instance) override final
Deinitializes the respective instrument within the instrument inheritance hierarchy....
Definition: DigitalOut.cpp:13
void InitFuncImpl(dispatch_tag< OutputPortTasks::InitTask >, DynExp::InstrumentInstance &Instance) override final
Initializes the respective instrument within the instrument inheritance hierarchy....
Definition: DigitalOut.cpp:8
virtual void SetDefault(DynExp::TaskBase::CallbackType CallbackFunc=nullptr) const
Writes DigitalOutParams::DefaultValue to the sample stream. CallbackFunc gets called after the task D...
Definition: DigitalOut.cpp:56
virtual void OnPrepareExitChild() const override
This function enables derived classes to enqueue tasks to be executed directly before the final exit ...
Definition: DigitalOut.cpp:73
void ResetImpl(dispatch_tag< OutputPort >) override final
Refer to DynExp::Object::Reset(). Using tag dispatch mechanism to ensure that ResetImpl() of every de...
Definition: DigitalOut.cpp:78
virtual void Set(DigitalOutData::SampleStreamType::SampleType Sample, DynExp::TaskBase::CallbackType CallbackFunc=nullptr) const
Writes one sample to the sample stream. CallbackFunc gets called after the task DataStreamInstrument:...
Definition: DigitalOut.cpp:40
virtual void SetSync(DigitalOutData::SampleStreamType::SampleType Sample) const
Synchronized version of Set(), which blocks until Sample has been written.
Definition: DigitalOut.cpp:51
Refer to DynExp::ParamsBase::dispatch_tag.
Definition: Instrument.h:1151
Refer to DynExp::ParamsBase::dispatch_tag.
Definition: Instrument.h:1120
Refer to ParamsBase::dispatch_tag.
Definition: Instrument.h:146
Defines data for a thread belonging to a InstrumentBase instance. Refer to RunnableInstance.
Definition: Instrument.h:772
Refer to ParamsBase::dispatch_tag.
Definition: Object.h:2018
static void DisableUserEditable(ParamBase &Param) noexcept
Sets the UserEditable property of the parameter Param to false. Refer to ParamBase::UserEditable.
Definition: Object.cpp:292
std::function< void(const TaskBase &, ExceptionContainer &)> CallbackType
Type of a callback function which is invoked when a task has finished, failed or has been aborted....
Definition: Instrument.h:939
DynExp's instrument namespace contains the implementation of DynExp instruments which extend DynExp's...
Definition: Instrument.h:1254
Accumulates include statements to provide a precompiled header.
double DataType
Data type of time and value.