Pleora Technologies Inc. eBUS SDK v7.0.1.7536 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 <PvSoftDeviceGEVLib.h>
12 
13 
19 class PV_SOFT_DEVICE_GEV_API IPvTriggerSelector
20 {
21 public:
23  enum State
24  {
34  State_OneShot
35  };
36 
40  virtual ~IPvTriggerSelector() {}
41 
49  virtual void Start( const uint32_t aHeight ) = 0;
50 
56  virtual void Stop() = 0;
57 
61  virtual void FireTrigger() = 0;
62 
68  virtual void Rearm() = 0;
69 
75  virtual void SetMode( const bool aIsEnabled ) = 0;
76 
82  virtual bool GetMode() const = 0;
83 
89  virtual void SetSource( const uint32_t aSource ) = 0;
90 
96  virtual uint32_t GetSource() const = 0;
97 
103  virtual PvString GetName() const = 0;
104 
110  virtual State GetState() const = 0;
111 
117  virtual bool IsEnabled() const = 0;
118 };
119 
120 
128 class PV_SOFT_DEVICE_GEV_API PvTriggerSelectorDefault
129  : public IPvTriggerSelector
130 {
131 public:
132 
138  PvTriggerSelectorDefault( const char * const aName = "N/A" )
139  : mSource( 0 )
140  , mState( State_Disabled )
141  {
142  mName = PvString( aName );
143  }
144 
149 
155  void Start( const uint32_t aHeight ) override { PVUNREFPARAM( aHeight ); }
156 
160  void Stop() override {}
161 
165  void FireTrigger() override {}
166 
170  void Rearm() override {}
171 
177  void SetMode( const bool aIsEnabled ) override { SetState( aIsEnabled ? State_Enabled : State_Disabled ); }
178 
184  bool GetMode() const override { return IsEnabled(); }
185 
191  void SetSource( const uint32_t aSource) override { mSource = aSource; }
192 
198  uint32_t GetSource() const override { return mSource; }
199 
205  PvString GetName() const override { return mName; }
206 
212  bool IsEnabled() const override { return State_Disabled != mState; }
213 
214 protected:
215 
221  void SetState( const State aState ) { mState = aState; }
222 
228  State GetState() const override { return mState; }
229 
230 private:
231 
232  PvString mName;
233  uint32_t mSource;
234  volatile State mState;
235 
236 };
237 
238 
244 class PV_SOFT_DEVICE_GEV_API PvTriggerSelectorAcquisitionStart
245  : public PvTriggerSelectorDefault
246 {
247 public:
248 
254  PvTriggerSelectorAcquisitionStart( const char * const aName = "AcquisitionStart" )
255  : PvTriggerSelectorDefault( aName ) {}
256 
261 
267  void Start( const uint32_t aHeight ) override
268  {
269  PVUNREFPARAM( aHeight );
270 
271  if ( State_Enabled == GetState() )
272  {
273  SetState( State_Armed );
274  }
275  }
276 
280  void Stop() override
281  {
282  if ( State_Disabled != GetState() )
283  {
284  SetState( State_Enabled );
285  }
286  }
287 
291  void FireTrigger() override
292  {
293  if ( State_Armed == GetState() )
294  {
295  SetState( State_OneShot );
296  }
297  }
298 
299 };
300 
301 
307 class PV_SOFT_DEVICE_GEV_API PvTriggerSelectorFrameStart
309 {
310 public:
311 
317  PvTriggerSelectorFrameStart( const char * const aName = "FrameStart" )
319 
324 
328  void Rearm() override
329  {
330  if ( GetState() == State_Fired )
331  {
332  SetState( State_Armed );
333  }
334  }
335 
339  void FireTrigger() override
340  {
341  if ( State_Armed == GetState() )
342  {
343  SetState( State_Fired );
344  }
345  }
346 
347 };
348 
349 
355 class PV_SOFT_DEVICE_GEV_API PvTriggerSelectorLineStart
357 {
358 public:
359 
365  PvTriggerSelectorLineStart( const char * const aName = "LineStart" )
366  : PvTriggerSelectorFrameStart( aName )
367  , mTrigCount( 1 )
368  , mTrigReload( 1 )
369  {}
370 
375 
381  void Start( const uint32_t aHeight ) override
382  {
383  if ( State_Enabled == GetState() )
384  {
385  mTrigReload = aHeight;
386  mTrigCount = mTrigReload;
387  SetState( State_Armed );
388  }
389  }
393  void FireTrigger() override
394  {
395  if ( State_Armed == GetState() )
396  {
397  --mTrigCount;
398  if ( !mTrigCount )
399  {
400  SetState( State_Fired );
401  }
402  }
403  }
404 
408  void Rearm() override
409  {
410  if ( GetState() == State_Fired )
411  {
412  mTrigCount = mTrigReload;
413  SetState( State_Armed );
414  }
415  }
416 
417 private:
418 
419  uint32_t mTrigCount;
420  uint32_t mTrigReload;
421 
422 };
423 
424 #endif // __PVTRIGGERSELECTOR_H__
Interface used by PvStreamingChannelSourceTrigger to support a trigger mechanism.
Definition: PvTriggerSelector.h:20
virtual void FireTrigger()=0
With all conditions met, fires a trigger signal to move to the Fired state.
virtual bool GetMode() const =0
Gets the trigger mode.
virtual PvString GetName() const =0
Gets the selector name.
virtual void SetMode(const bool aIsEnabled)=0
Sets the trigger mode (enabled or disabled).
virtual bool IsEnabled() const =0
Checks if the trigger is enabled.
virtual void SetSource(const uint32_t aSource)=0
Sets the trigger source.
State
Trigger selector state enum.
Definition: PvTriggerSelector.h:24
@ State_Disabled
Trigger selector disabled.
Definition: PvTriggerSelector.h:26
@ State_Fired
Trigger selector fired.
Definition: PvTriggerSelector.h:32
@ State_Enabled
Trigger selector enabled.
Definition: PvTriggerSelector.h:28
@ State_Armed
Trigger selector armed.
Definition: PvTriggerSelector.h:30
virtual State GetState() const =0
Gets the current selector state.
virtual void Rearm()=0
Moves the state from Fired, to another state like Armed (in case of a per-frame TriggerSelector like ...
virtual ~IPvTriggerSelector()
Virtual destructor.
Definition: PvTriggerSelector.h:40
virtual uint32_t GetSource() const =0
Gets the trigger source.
virtual void Start(const uint32_t aHeight)=0
Signals the state machine to move from the Enabled state to the Armed state.
virtual void Stop()=0
Unconditionally moves the state machine into the Enabled state.
String class.
Definition: PvString.h:26
AcquisitionStart requires to be triggered once, and remains triggered until stopped.
Definition: PvTriggerSelector.h:246
virtual ~PvTriggerSelectorAcquisitionStart()
Virtual destructor.
Definition: PvTriggerSelector.h:260
void Stop() override
Unconditionally moves the state machine into the Enabled state.
Definition: PvTriggerSelector.h:280
PvTriggerSelectorAcquisitionStart(const char *const aName="AcquisitionStart")
Constructor.
Definition: PvTriggerSelector.h:254
void Start(const uint32_t aHeight) override
Signals the state machine to move from the Enabled state to the Armed state.
Definition: PvTriggerSelector.h:267
void FireTrigger() override
Moves the state from armed to one-shot.
Definition: PvTriggerSelector.h:291
A default implementation for the IPvTriggerSelector interface. This defines the typical base behavior...
Definition: PvTriggerSelector.h:130
void FireTrigger() override
Nothing to do for the default implementation.
Definition: PvTriggerSelector.h:165
void SetMode(const bool aIsEnabled) override
Sets the trigger mode (enabled or disabled).
Definition: PvTriggerSelector.h:177
void SetSource(const uint32_t aSource) override
Sets the trigger source.
Definition: PvTriggerSelector.h:191
virtual ~PvTriggerSelectorDefault()
Virtual destructor.
Definition: PvTriggerSelector.h:148
PvTriggerSelectorDefault(const char *const aName="N/A")
Constructor.
Definition: PvTriggerSelector.h:138
void Start(const uint32_t aHeight) override
Nothing to do for the default implementation.
Definition: PvTriggerSelector.h:155
void Stop() override
Nothing to do for the default implementation.
Definition: PvTriggerSelector.h:160
State GetState() const override
Gets the current selector state.
Definition: PvTriggerSelector.h:228
uint32_t GetSource() const override
Gets the trigger source.
Definition: PvTriggerSelector.h:198
bool IsEnabled() const override
Checks if the trigger is enabled.
Definition: PvTriggerSelector.h:212
void Rearm() override
Nothing to do for the default implementation.
Definition: PvTriggerSelector.h:170
bool GetMode() const override
Gets the trigger mode.
Definition: PvTriggerSelector.h:184
PvString GetName() const override
Gets the selector name.
Definition: PvTriggerSelector.h:205
void SetState(const State aState)
Sets the selector state.
Definition: PvTriggerSelector.h:221
Behaves just like AcquisitionStart, but is re-armed on a frame basis.
Definition: PvTriggerSelector.h:309
void Rearm() override
Moves the state from Fired to Armed.
Definition: PvTriggerSelector.h:328
void FireTrigger() override
Moves the state from Armed to Fired.
Definition: PvTriggerSelector.h:339
virtual ~PvTriggerSelectorFrameStart()
Virtual destructor.
Definition: PvTriggerSelector.h:323
PvTriggerSelectorFrameStart(const char *const aName="FrameStart")
Constructor.
Definition: PvTriggerSelector.h:317
Behaves like FrameStart, but moves to Fired state once all lines of a frame are received.
Definition: PvTriggerSelector.h:357
void FireTrigger() override
If Armed and all lines are received, moves to the Fired state.
Definition: PvTriggerSelector.h:393
~PvTriggerSelectorLineStart()
Virtual destructor.
Definition: PvTriggerSelector.h:374
void Start(const uint32_t aHeight) override
Signals the state machine to move from the Enabled state to the Armed state.
Definition: PvTriggerSelector.h:381
void Rearm() override
Moves the state from Fired to Armed.
Definition: PvTriggerSelector.h:408
PvTriggerSelectorLineStart(const char *const aName="LineStart")
Constructor.
Definition: PvTriggerSelector.h:365

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