Scanframe Modular Application 0.1.0
Loading...
Searching...
No Matches
RsaEmulator.h
Go to the documentation of this file.
1#pragma once
2
4#include <misc/gen/Sustain.h>
7
8namespace sf
9{
14{
15 public:
16 // Constructor.
18 // Virtual destructor.
20 // Overridden from base class.
21 bool setRunMode(bool runMode, bool clear) override;
22 // Overridden from base class.
23 [[nodiscard]] bool getRunMode() const override;
24 // Overloaded from base class.
25 [[nodiscard]] IdType getParamId(EDefaultParam param, unsigned gate, unsigned channel) const override;
26 // Overridden from base class.
27 bool handleParam(IdType id, ParamInfo* info, const Value* setval, Value* getval) override;
28 // Overridden from base class.
29 [[nodiscard]] IdType getResultId(EDefaultResult result, unsigned gate, unsigned channel) const override;
30 // Overridden from base class.
31 bool handleResult(IdType id, ResultInfo* info, BufferInfo* bufInfo) override;
32 // Overridden from base class.
33 bool enumParamIds(IdList& ids) override;
34 // Overridden from base class.
35 bool enumResultIds(IdList& ids) override;
36
40 enum EPolarity : int
41 {
45 plFull = 0,
48 };
49
50 private:
51 // Overloaded from base class.
52 bool doInitialize(bool init) override;
53 // Sustain function.
54 bool sustain(const timespec& t);
55 // Hook for the sustain interface.
57 // Holds the run mode flag.
58 bool RunMode{false};
59 // Holds the time the run mode was started.
60 double SyncTimeStart{0.0};
61 // Holds the flag for determining the fixed gate state or the dynamic gates.
62 bool FlagFixed{false};
63 // Holds the digitiser“s amplitude unit.
64 double AmplitudeUnit{0.01};
65 // Holds the amount of channels supported by this interface.
66 unsigned ChannelCount{0};
67 //
68 struct TGateInfo
69 {
70 // Holds the name of the gate.
71 std::string Name;
72 // Holds the id of the method selected for this gate.
73 int MethodId{0};
74 // Holds the delay of this gate in time units.
75 long Delay{200};
76 // Holds the range of this gate in time units.
77 long Range{100};
78 // Holds the gate to which this gate is slaved.
79 long SlavedTo{-1};
80 // Holds the data generation enable status of this gate.
81 bool DataEnable{true};
82 // Hold the threshold level.
83 unsigned Threshold{60};
84 // Actual value in percentages.
85 double ThresholdValue{70.0};
86 // Copy method buffer.
87 DynamicBuffer CopyBuf;
88 // Holds the last peak value.
89 unsigned PeakAmp{0};
90 // Holds the last peak time of flight value.
91 unsigned PeakTof{0};
92 // Flag telling if a peak was found.
93 bool PeakFound{false};
94 // Gate polarity.
95 EPolarity Polarity{plFull};
96 // Calculate the threshold depending on the polarity.
97 void CalculateThreshold();
98 };
99 //
100 struct TChannelInfo
101 {
102 TChannelInfo()
103 : GateInfo(new TGateInfo[8])
104 {}
105 ~TChannelInfo()
106 {
107 delete[] GateInfo;
108 }
109
110 // Holds the time offset when the RepRate was changed on the fly.
111 double SyncTimeOffset{0.0};
112
113 // Params
114 long CopyDelay{0};
115 long CopyRange{0};
116 // Interface gate position for emulation.
117 long IfPos{0};
118 //
119 unsigned GateCount{0};
120 double RepRate{100};
121 double TimeUnits{1e6};
122 double Gain{30};
123 long SyncMode{0};
124 // Divider used to generate the position orientation pulse result.
125 long PopDivider{100};
126 int PopManual{0};
127 //
128 TGateInfo* GateInfo;
129 // Current sync counter value.
130 uint32_t SyncCounter{0};
131 // Buffer used for copy info transport.
132 DynamicBuffer CopyBuf;
133 // Sync Index table for the async copy result.
134 uint32_t CopySyncIndex{0};
135 // Position orientation pulse sync counter value.
136 uint32_t PopIndex{0};
137 //
138 bool CopyEnabled{false};
139 // TCG gate info.
140 int TcgSlavedTo{-1};
141 long TcgRange{0};
142 long TcgDelay{0};
143 bool TcgEnable{false};
144 // Bidirectional scanning.
145 bool BiDirMode{false};
146 //
147 int AscanRectify{0};
148 // Offset for the indications.
149 double Sweep[3]{0, 0, 0};
150 };
151 //
152 TChannelInfo* FChannelInfo{nullptr};
153 //
154 int ErrorValue{0};
155 // Holds status of single shot generation
156 ElapseTimer SingleShotTimer;
157 //
158 [[nodiscard]] long TimeUnits(const TChannelInfo& ci, const Value& value) const;
162 struct
163 {
164 double Time{0};
165 double Gain{0};
166 } Tcg[20];
167};
168
169}// namespace sf
Implements a repetitive signal acquisition emulator.
Definition RsaEmulator.h:14
double Gain
Definition RsaEmulator.h:165
double Time
Definition RsaEmulator.h:164
~AcquisitionEmulator() override
AcquisitionEmulator(const Parameters &)
bool handleParam(IdType id, ParamInfo *info, const Value *setval, Value *getval) override
Pure virtual method to be overridden in a derived class. This method handles the interface parameters...
EPolarity
Definition RsaEmulator.h:41
@ plPositive
Definition RsaEmulator.h:47
@ plFull
Definition RsaEmulator.h:45
@ plNegative
Definition RsaEmulator.h:43
bool enumParamIds(IdList &ids) override
Gets all interface parameters ids.
bool setRunMode(bool runMode, bool clear) override
Sets the implementation in hold or Run mode.
IdType getParamId(EDefaultParam param, unsigned gate, unsigned channel) const override
Gets the ID of the parameter for the specified gate.
IdType getResultId(EDefaultResult result, unsigned gate, unsigned channel) const override
Returns the ID of the result for the specified gate.
bool getRunMode() const override
Gets the current run mode of a derived class.
bool handleResult(IdType id, ResultInfo *info, BufferInfo *bufInfo) override
Handles results.
bool enumResultIds(IdList &ids) override
Gets interface results ids.
Base class for the repetitive signal acquisition interface.
Definition RsaInterface.h:19
Template to make the sustain system call a class method regularly.
Definition Sustain.h:184
Counted vector having additional methods and operators for ease of usage.
Definition TVector.h:25
Value container class able to performing arithmetic functions.
Definition Value.h:19
Definition Application.h:10
TDynamicBuffer< Allocator > DynamicBuffer
Actual specialized dynamic buffer type using the default allocator.
Definition TDynamicBuffer.h:540
Parameters structure passed to an RSA implementation class.
Definition RsaInterface.h:25
Definition RsaTypes.h:328
Structure to hold parameter information.
Definition RsaTypes.h:121
Definition RsaTypes.h:232
EDefaultResult
Definition RsaTypes.h:471
EDefaultParam
Definition RsaTypes.h:384
unsigned long long IdType
Type for gathering parameter ID's.
Definition RsaTypes.h:26