Pleora Technologies Inc. eBUS SDK v6.4.0.6670 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 <string>
12 
13 #include <PvVirtualDeviceLib.h>
14 
15 
16 
20 
21 class PV_VIRTUAL_DEVICE_API IPvTriggerSelector
22 {
23 public:
24  enum State
25  {
26  State_Disabled,
27  State_Enabled,
28  State_Armed,
29  State_Fired,
30  State_OneShot
31  };
32 
33  virtual ~IPvTriggerSelector() {}
34 
35  virtual void Start( const uint32_t aHeight ) = 0;
36  virtual void Stop() = 0;
37  virtual void FireTrigger() = 0;
38  virtual void Rearm() = 0;
39 
40  virtual void SetMode( bool aIsEnabled ) = 0;
41  virtual bool GetMode() const = 0;
42  virtual void SetSource( uint32_t aSource ) = 0;
43  virtual uint32_t GetSource() const = 0;
44  virtual std::string GetName() const = 0;
45  virtual State GetState() const = 0;
46  virtual bool IsEnabled() const = 0;
47 };
48 
49 
50 // Default base class.
51 // Used internally when TriggerMode[TriggerSelector] is set to OFF.
52 // Also defines base behavior for most of trigger selectors.
53 class PV_VIRTUAL_DEVICE_API PvTriggerSelectorDefault
54  : public IPvTriggerSelector
55 {
56 public:
57  PvTriggerSelectorDefault( const char * const aName = "N/A" )
58  : mSource( 0 )
59  , mState( State_Disabled )
60  {
61  mName = new std::string( aName );
62  }
63  virtual ~PvTriggerSelectorDefault() { PVDELETE( mName ); }
64 
65  void Start( const uint32_t aHeight ) override { PVUNREFPARAM( aHeight ); }
66  void Stop() override {}
67  void FireTrigger() override {}
68  void Rearm() override {};
69 
70  void SetMode( const bool aIsEnabled ) override { SetState( aIsEnabled ? State_Enabled : State_Disabled ); }
71  bool GetMode() const override { return IsEnabled(); }
72  void SetSource( const uint32_t aSource) override { mSource = aSource; }
73  uint32_t GetSource() const override { return mSource; }
74  std::string GetName() const override { return *mName; }
75  bool IsEnabled() const override { return State_Disabled != mState; }
76 
77 protected:
78 
79  void SetState( const State aState ) { mState = aState; }
80  State GetState() const override { return mState; }
81 
82 private:
83  std::string *mName;
84  uint32_t mSource;
85  volatile State mState;
86 
87 };
88 
89 
95 class PV_VIRTUAL_DEVICE_API PvTriggerSelectorAcquisitionStart
97 {
98 public:
99  PvTriggerSelectorAcquisitionStart( const char * const aName = "AcquisitionStart" )
100  : PvTriggerSelectorDefault( aName ) {}
102 
103  void Start( const uint32_t aHeight ) override
104  {
105  PVUNREFPARAM( aHeight );
106 
107  if ( State_Enabled == GetState() )
108  {
109  SetState( State_Armed );
110  }
111  }
112 
113  void Stop() override
114  {
115  if ( State_Disabled != GetState() )
116  {
117  SetState( State_Enabled );
118  }
119  }
120 
121  void FireTrigger() override
122  {
123  if ( State_Armed == GetState() )
124  {
125  SetState( State_OneShot );
126  }
127  }
128 
129 };
130 
131 
137 class PV_VIRTUAL_DEVICE_API PvTriggerSelectorFrameStart
139 {
140 public:
141  PvTriggerSelectorFrameStart( const char * const aName = "FrameStart" )
143  virtual ~PvTriggerSelectorFrameStart() {}
144 
145  void Rearm() override
146  {
147  if ( GetState() == State_Fired )
148  {
149  SetState( State_Armed );
150  }
151  }
152 
153  void FireTrigger() override
154  {
155  if ( State_Armed == GetState() )
156  {
157  SetState( State_Fired );
158  }
159  }
160 
161 };
162 
163 
169 class PV_VIRTUAL_DEVICE_API PvTriggerSelectorLineStart
171 {
172 public:
173  PvTriggerSelectorLineStart( const char * const aName = "LineStart" )
174  : PvTriggerSelectorFrameStart( aName )
175  , mTrigCount( 1 )
176  , mTrigReload( 1 )
177  {}
179 
180  void Start( const uint32_t aHeight ) override
181  {
182  if ( State_Enabled == GetState() )
183  {
184  mTrigReload = aHeight;
185  mTrigCount = mTrigReload;
186  SetState( State_Armed );
187  }
188  }
189 
190  void FireTrigger() override
191  {
192  if ( State_Armed == GetState() )
193  {
194  --mTrigCount;
195  if ( !mTrigCount )
196  {
197  SetState( State_Fired );
198  }
199  }
200  }
201 
202  void Rearm() override
203  {
204  if ( GetState() == State_Fired )
205  {
206  mTrigCount = mTrigReload;
207  SetState( State_Armed );
208  }
209  }
210 
211 private:
212  uint32_t mTrigCount;
213  uint32_t mTrigReload;
214 };
215 
216 #endif // __PVTRIGGERSELECTOR_H__
PvTriggerSelectorFrameStart
Definition: PvTriggerSelector.h:137
PvTriggerSelectorDefault
Definition: PvTriggerSelector.h:53
IPvTriggerSelector
This class implements a triggering mechanism.
Definition: PvTriggerSelector.h:21
PvTriggerSelectorLineStart
Definition: PvTriggerSelector.h:169
PvTriggerSelectorAcquisitionStart
Definition: PvTriggerSelector.h:95

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