Pleora Technologies Inc. eBUS SDK v6.5.1.6797 API



PvTriggerSelector.h
1 // *****************************************************************************
2 //
3 // Copyright (c) 2022, Pleora Technologies Inc., All rights reserved.
4 //
5 // *****************************************************************************
6 
7 #ifndef __PVTRIGGERSELECTOR_H__
8 #define __PVTRIGGERSELECTOR_H__
9 
10 
11 #include <PvVirtualDeviceLib.h>
12 
13 
19 class PV_VIRTUAL_DEVICE_API IPvTriggerSelector
20 {
21 public:
22 
23  enum State
24  {
25  State_Disabled,
26  State_Enabled,
27  State_Armed,
28  State_Fired,
29  State_OneShot
30  };
31 
35  virtual ~IPvTriggerSelector() {}
36 
44  virtual void Start( const uint32_t aHeight ) = 0;
45 
51  virtual void Stop() = 0;
52 
56  virtual void FireTrigger() = 0;
57 
63  virtual void Rearm() = 0;
64 
70  virtual void SetMode( bool aIsEnabled ) = 0;
71 
77  virtual bool GetMode() const = 0;
78 
84  virtual void SetSource( uint32_t aSource ) = 0;
85 
91  virtual uint32_t GetSource() const = 0;
92 
98  virtual PvString GetName() const = 0;
99 
105  virtual State GetState() const = 0;
106 
112  virtual bool IsEnabled() const = 0;
113 };
114 
115 
123 class PV_VIRTUAL_DEVICE_API PvTriggerSelectorDefault
124  : public IPvTriggerSelector
125 {
126 public:
127 
133  PvTriggerSelectorDefault( const char * const aName = "N/A" )
134  : mSource( 0 )
135  , mState( State_Disabled )
136  {
137  mName = PvString( aName );
138  }
139 
144 
150  void Start( const uint32_t aHeight ) override { PVUNREFPARAM( aHeight ); }
151 
155  void Stop() override {}
156 
160  void FireTrigger() override {}
161 
165  void Rearm() override {}
166 
172  void SetMode( const bool aIsEnabled ) override { SetState( aIsEnabled ? State_Enabled : State_Disabled ); }
173 
179  bool GetMode() const override { return IsEnabled(); }
180 
186  void SetSource( const uint32_t aSource) override { mSource = aSource; }
187 
193  uint32_t GetSource() const override { return mSource; }
194 
200  PvString GetName() const override { return mName; }
201 
207  bool IsEnabled() const override { return State_Disabled != mState; }
208 
209 protected:
210 
216  void SetState( const State aState ) { mState = aState; }
217 
223  State GetState() const override { return mState; }
224 
225 private:
226 
227  PvString mName;
228  uint32_t mSource;
229  volatile State mState;
230 
231 };
232 
233 
239 class PV_VIRTUAL_DEVICE_API PvTriggerSelectorAcquisitionStart
240  : public PvTriggerSelectorDefault
241 {
242 public:
243 
249  PvTriggerSelectorAcquisitionStart( const char * const aName = "AcquisitionStart" )
250  : PvTriggerSelectorDefault( aName ) {}
251 
256 
262  void Start( const uint32_t aHeight ) override
263  {
264  PVUNREFPARAM( aHeight );
265 
266  if ( State_Enabled == GetState() )
267  {
268  SetState( State_Armed );
269  }
270  }
271 
275  void Stop() override
276  {
277  if ( State_Disabled != GetState() )
278  {
279  SetState( State_Enabled );
280  }
281  }
282 
286  void FireTrigger() override
287  {
288  if ( State_Armed == GetState() )
289  {
290  SetState( State_OneShot );
291  }
292  }
293 
294 };
295 
296 
302 class PV_VIRTUAL_DEVICE_API PvTriggerSelectorFrameStart
304 {
305 public:
306 
312  PvTriggerSelectorFrameStart( const char * const aName = "FrameStart" )
314 
319 
323  void Rearm() override
324  {
325  if ( GetState() == State_Fired )
326  {
327  SetState( State_Armed );
328  }
329  }
330 
334  void FireTrigger() override
335  {
336  if ( State_Armed == GetState() )
337  {
338  SetState( State_Fired );
339  }
340  }
341 
342 };
343 
344 
350 class PV_VIRTUAL_DEVICE_API PvTriggerSelectorLineStart
352 {
353 public:
354 
360  PvTriggerSelectorLineStart( const char * const aName = "LineStart" )
361  : PvTriggerSelectorFrameStart( aName )
362  , mTrigCount( 1 )
363  , mTrigReload( 1 )
364  {}
365 
370 
376  void Start( const uint32_t aHeight ) override
377  {
378  if ( State_Enabled == GetState() )
379  {
380  mTrigReload = aHeight;
381  mTrigCount = mTrigReload;
382  SetState( State_Armed );
383  }
384  }
388  void FireTrigger() override
389  {
390  if ( State_Armed == GetState() )
391  {
392  --mTrigCount;
393  if ( !mTrigCount )
394  {
395  SetState( State_Fired );
396  }
397  }
398  }
399 
403  void Rearm() override
404  {
405  if ( GetState() == State_Fired )
406  {
407  mTrigCount = mTrigReload;
408  SetState( State_Armed );
409  }
410  }
411 
412 private:
413 
414  uint32_t mTrigCount;
415  uint32_t mTrigReload;
416 
417 };
418 
419 #endif // __PVTRIGGERSELECTOR_H__
void Start(const uint32_t aHeight) override
Signals the state machine to move from the Enabled state to the Armed state.
Definition: PvTriggerSelector.h:262
void Start(const uint32_t aHeight) override
Nothing to do for the default implementation.
Definition: PvTriggerSelector.h:150
~PvTriggerSelectorLineStart()
Virtual destructor.
Definition: PvTriggerSelector.h:369
void Rearm() override
Moves the state from Fired to Armed.
Definition: PvTriggerSelector.h:403
PvTriggerSelectorDefault(const char *const aName="N/A")
Constructor.
Definition: PvTriggerSelector.h:133
uint32_t GetSource() const override
Gets the trigger source.
Definition: PvTriggerSelector.h:193
bool GetMode() const override
Gets the trigger mode.
Definition: PvTriggerSelector.h:179
void FireTrigger() override
If Armed and all lines are received, moves to the Fired state.
Definition: PvTriggerSelector.h:388
String class.
Definition: PvString.h:25
Behaves like FrameStart, but moves to Fired state once all lines of a frame are received.
Definition: PvTriggerSelector.h:350
void SetSource(const uint32_t aSource) override
Sets the trigger source.
Definition: PvTriggerSelector.h:186
void FireTrigger() override
Moves the state from Armed to Fired.
Definition: PvTriggerSelector.h:334
void FireTrigger() override
Nothing to do for the default implementation.
Definition: PvTriggerSelector.h:160
PvTriggerSelectorAcquisitionStart(const char *const aName="AcquisitionStart")
Constructor.
Definition: PvTriggerSelector.h:249
A default implementation for the IPvTriggerSelector interface. This defines the typical base behavior...
Definition: PvTriggerSelector.h:123
void SetMode(const bool aIsEnabled) override
Sets the trigger mode (enabled or disabled).
Definition: PvTriggerSelector.h:172
void FireTrigger() override
Moves the state from armed to one-shot.
Definition: PvTriggerSelector.h:286
bool IsEnabled() const override
Checks if the trigger is enabled.
Definition: PvTriggerSelector.h:207
void Stop() override
Nothing to do for the default implementation.
Definition: PvTriggerSelector.h:155
Behaves just like AcquisitionStart, but is re-armed on a frame basis.
Definition: PvTriggerSelector.h:302
void Rearm() override
Moves the state from Fired to Armed.
Definition: PvTriggerSelector.h:323
void Start(const uint32_t aHeight) override
Signals the state machine to move from the Enabled state to the Armed state.
Definition: PvTriggerSelector.h:376
void Rearm() override
Nothing to do for the default implementation.
Definition: PvTriggerSelector.h:165
virtual ~IPvTriggerSelector()
Virtual destructor.
Definition: PvTriggerSelector.h:35
void SetState(const State aState)
Sets the selector state.
Definition: PvTriggerSelector.h:216
Interface used by PvStreamingChannelSourceTrigger to support a trigger mechanism. ...
Definition: PvTriggerSelector.h:19
virtual ~PvTriggerSelectorAcquisitionStart()
Virtual destructor.
Definition: PvTriggerSelector.h:255
virtual bool IsEnabled() const =0
Checks if the trigger is enabled.
PvString GetName() const override
Gets the selector name.
Definition: PvTriggerSelector.h:200
PvTriggerSelectorFrameStart(const char *const aName="FrameStart")
Constructor.
Definition: PvTriggerSelector.h:312
AcquisitionStart requires to be triggered once, and remains triggered until stopped.
Definition: PvTriggerSelector.h:239
void Stop() override
Unconditionally moves the state machine into the Enabled state.
Definition: PvTriggerSelector.h:275
virtual ~PvTriggerSelectorFrameStart()
Virtual destructor.
Definition: PvTriggerSelector.h:318
State GetState() const override
Gets the current selector state.
Definition: PvTriggerSelector.h:223
PvTriggerSelectorLineStart(const char *const aName="LineStart")
Constructor.
Definition: PvTriggerSelector.h:360
virtual ~PvTriggerSelectorDefault()
Virtual destructor.
Definition: PvTriggerSelector.h:143

Copyright (c) 2002-2024 Pleora Technologies Inc.
www.pleora.com