Relacs DAQ Library
0.9.8
|
#include <trigger.h>
Classes | |
struct | HoopParams |
Public Types | |
enum | BelowActions { BelowIgnore = 0x0000, BelowSet = 0x0001, BelowReset = 0x0002, BelowMask = BelowIgnore | BelowSet | BelowReset } |
enum | AboveActions { AboveIgnore = 0x0000, AboveSet = 0x0100, AboveReset = 0x0200, AboveMask = AboveIgnore | AboveSet | AboveReset } |
Public Types inherited from Device | |
enum | DeviceTypes { MiscellaneousType = 0, AnalogInputType = 1, AnalogOutputType = 2, DigitalIOType = 3, TriggerType = 4, AttenuatorType = 5, AttenuateType = 6, ManipulatorType = 7, TemperatureType = 8, CameraType = 9 } |
Public Member Functions | |
Trigger (void) | |
Trigger (const string &deviceclass) | |
void | setCrossing (int mode, double level) |
void | setRising (double level) |
void | setFalling (double level) |
void | setCrossing (int amode, double alevel, int bmode, double blevel) |
void | setRisingHysteresis (double alevel, double blevel) |
void | setFallingHysteresis (double alevel, double blevel) |
void | setWindow (double alevel, double blevel) |
void | setPeakTrough (double threshold, int peakamode, int troughamode, double alevel, int peakbmode, int troughbmode, double blevel) |
void | setPeak (double threshold) |
void | setTrough (double threshold) |
void | setPeak (double threshold, double level) |
void | setTrough (double threshold, double level) |
void | setPeak (double threshold, double alevel, double blevel) |
void | setTrough (double threshold, double alevel, double blevel) |
int | set (void) |
int | addHoop (double delay, double width) |
void | clear (void) |
void | setSettings (void) |
virtual int | activate (void)=0 |
virtual int | disable (void)=0 |
virtual int | reset (void) |
Public Member Functions inherited from Device | |
Device (int type=MiscellaneousType) | |
Device (const string &deviceclass, int type=MiscellaneousType) | |
virtual | ~Device (void) |
virtual int | open (const string &device) |
virtual int | open (Device &device) |
virtual bool | isOpen (void) const =0 |
virtual void | close (void)=0 |
virtual const Options & | info (void) const |
virtual const Options & | settings (void) const |
int | deviceType (void) const |
string | deviceTypeStr (void) const |
string | deviceClass (void) const |
string | deviceFile (void) const |
string | deviceName (void) const |
string | deviceVendor (void) const |
string | deviceIdent (void) const |
virtual void | setDeviceIdent (const string &ident) |
virtual void | clearError (void) |
virtual string | errorStr (void) const |
void | setErrorStr (const string &strg) |
void | addErrorStr (const string &strg) |
void | setErrorStr (int errnum) |
void | addErrorStr (int errnum) |
virtual bool | success (void) const |
virtual bool | failed (void) const |
Protected Member Functions | |
virtual void | initOptions (void) |
Protected Member Functions inherited from Device | |
void | setDeviceType (int type) |
void | setDeviceClass (const string &deviceclass) |
void | setDeviceFile (const string &devicefile) |
void | setDeviceName (const string &devicename) |
void | setDeviceVendor (const string &devicevendor) |
void | addInfo (void) |
void | lock (void) const |
void | unlock (void) const |
QMutex * | mutex (void) const |
Protected Attributes | |
HoopParams | Hoop [MaxHoops] |
int | Hoops |
Protected Attributes inherited from Device | |
Options | Info |
Options | Settings |
Static Protected Attributes | |
static const int | MaxHoops = 5 |
Additional Inherited Members | |
Static Public Member Functions inherited from Device | |
static int | deviceTypes (void) |
static string | deviceTypeStr (int type) |
static string | getErrorStr (int ern) |
Static Public Attributes inherited from Device | |
static const int | NotOpen = -1 |
static const int | InvalidDevice = -2 |
static const int | ReadError = -3 |
static const int | WriteError = -4 |
static const int | InvalidParam = -5 |
Virtual class for setting up an analog trigger device.
A trigger device sets it output to high if a certain type of event was detected on its input. On a different type of input event the output is set back to low. The event types supported by the Trigger interface are threshold crossings, peaks, and troughs. By the setCrossing() and setPeakTrough() functions, these events can be associated with the actions "set output to high" (AboveSet, BelowSet), "set output to low" (AboveReset, BelowReset), or "ignore" (AboveIgnore, BelowIgnore). Always call clear() before specifying new trigger settings with setCrossing() or setPeakTrough()!
The trigger settings need to be activated by calling activate(). The trigger device can be stopped to emit trigger signals by calling disable().
Only the activate() and disable() functions need to be implemented along with the open(), isOpen(), and close() functions. Towards the end of the open() function you should call set() for setting trigger parameters from the supplied options, followed by activate().
In case you want to use a trigger device within RELACS, your DigitalIO implementation needs to provide a void default constructor (i.e. with no parameters) that does not open the device. Also, include the header file <relacs/relacsplugin.h>
and make the Trigger device known to RELACS with the addTrigger
( ClassNameOfYourTriggerImplementation, PluginSetName ) macro.
enum BelowActions |
The actions to be taken for a trigger event that falls below the corresponding threshold level (threshold crossing from above, peak/trough below threshold).
Enumerator | |
---|---|
BelowIgnore |
Ignore the event. |
BelowSet |
Set the level of the trigger output to high. |
BelowReset |
Reset the level of the trigger output to low. |
BelowMask |
Bitmask for the BelowActions. |
enum AboveActions |
The actions to be taken for a trigger event that falls above the corresponding threshold level (threshold crossing from below, peak/trough above threshold).
Enumerator | |
---|---|
AboveIgnore |
Ignore the event. |
AboveSet |
Set the level of the trigger output to high. |
AboveReset |
Reset the level of the trigger output to low. |
AboveMask |
Bitmask for the AboveActions. |
Trigger | ( | void | ) |
References Trigger::initOptions().
Trigger | ( | const string & | deviceclass | ) |
Construct a Trigger Device with class deviceclass.
References Trigger::initOptions().
void setCrossing | ( | int | mode, |
double | level | ||
) |
Setup a single threshold crossing detector.
[in] | level | is the threshold level. |
[in] | mode | determines what to do if the signal crosses the threshold. It is a combination (OR) of one of the BelowActions and one of the AboveActions. |
References Trigger::HoopParams::ACrossing, Trigger::HoopParams::ALevel, Trigger::HoopParams::APeak, Trigger::HoopParams::ATrough, Trigger::HoopParams::BCrossing, Trigger::HoopParams::BLevel, Trigger::HoopParams::BPeak, Trigger::HoopParams::BTrough, Trigger::Hoop, and Trigger::Hoops.
Referenced by Trigger::setFalling(), Trigger::setFallingHysteresis(), Trigger::setRising(), Trigger::setRisingHysteresis(), and Trigger::setWindow().
void setRising | ( | double | level | ) |
Setup the trigger output to be high as long as the signal is above the threshold (high mode). This is a shortcut for setCrossing( AboveSet | BelowReset, level ).
[in] | level | the level of the threshold. |
References Trigger::AboveSet, Trigger::BelowReset, and Trigger::setCrossing().
Referenced by Trigger::set().
void setFalling | ( | double | level | ) |
Setup the trigger output to be high as long as the signal is below the threshold (low mode). This is a shortcut for setCrossing( AboveReset | BelowSet, level ).
[in] | level | the level of the threshold. |
References Trigger::AboveReset, Trigger::BelowSet, and Trigger::setCrossing().
Referenced by Trigger::set().
void setCrossing | ( | int | amode, |
double | alevel, | ||
int | bmode, | ||
double | blevel | ||
) |
Setup a two-threshold crossing detector.
[in] | alevel | is the level of the lower of the two thresholds. |
[in] | amode | determines what to do if the signal crosses the lower threshold. It is a combination (OR) of one of the BelowActions and one of the AboveActions. |
[in] | blevel | is the level of the higher of the two thresholds. |
[in] | bmode | determines what to do if the signal crosses the higher threshold. It is a combination (OR) of one of the BelowActions and one of the AboveActions. |
References Trigger::HoopParams::ACrossing, Trigger::HoopParams::ALevel, Trigger::HoopParams::BCrossing, Trigger::HoopParams::BLevel, Trigger::Hoop, and Trigger::Hoops.
void setRisingHysteresis | ( | double | alevel, |
double | blevel | ||
) |
Setup the trigger output to be high if the signal is above the higher threshold. The trigger output is set low if the signal falls below the lower threshold (hysteresis high mode). This is a shortcut for setCrossing( BelowReset, alevel, AboveSet, blevel ).
[in] | alevel | the level of the lower threshold. |
[in] | blevel | the level of the higher threshold. |
References Trigger::AboveSet, Trigger::BelowReset, and Trigger::setCrossing().
Referenced by Trigger::set().
void setFallingHysteresis | ( | double | alevel, |
double | blevel | ||
) |
Setup the trigger output to be high if the signal is below the lower threshold. The trigger output is set low if the signal rises above the higher threshold (hysteresis low mode). This is a shortcut for setCrossing( BelowSet, alevel, AboveReset, blevel ).
[in] | alevel | the level of the lower threshold. |
[in] | blevel | the level of the higher threshold. |
References Trigger::AboveReset, Trigger::BelowSet, and Trigger::setCrossing().
Referenced by Trigger::set().
void setWindow | ( | double | alevel, |
double | blevel | ||
) |
Setup the trigger output to be high if the signal is inbetween the lower and the higher threshold. Above the higher threshold and below the lower threshold the trigger output is set low (middle mode or window mode). This is a shortcut for setCrossing( AboveSet | BelowReset, alevel, AboveReset | BelowSet, blevel ).
[in] | alevel | the level of the lower threshold. |
[in] | blevel | the level of the higher threshold. |
References Trigger::AboveReset, Trigger::AboveSet, Trigger::BelowReset, Trigger::BelowSet, and Trigger::setCrossing().
Referenced by Trigger::set().
void setPeakTrough | ( | double | threshold, |
int | peakamode, | ||
int | troughamode, | ||
double | alevel, | ||
int | peakbmode, | ||
int | troughbmode, | ||
double | blevel | ||
) |
Setup a peak/trough detector.
[in] | threshold | is the threshold used for detecting peaks and troughs (only peaks and troughs that differ by more than threshold are detected. If threshold is zero, all peaks and troughs are detected.) |
[in] | alevel | is the level of the lower of the two thresholds. |
[in] | peakamode | determines what to do if a peak is above or below the lower threshold. |
[in] | troughamode | determines what to do if a trough is above or below the lower threshold. |
[in] | blevel | is the level of the higher of the two thresholds. |
[in] | peakbmode | determines what to do if a peak is above or below the higher threshold. |
[in] | troughbmode | determines what to do if a trough is above or below the higher threshold. |
peakamode, troughamode, peakbmode, and troughbmode are all combinations (OR) of one of the BelowActions and one of the AboveActions.
References Trigger::HoopParams::ALevel, Trigger::HoopParams::APeak, Trigger::HoopParams::ATrough, Trigger::HoopParams::BLevel, Trigger::HoopParams::BPeak, Trigger::HoopParams::BTrough, Trigger::Hoop, Trigger::Hoops, and Trigger::HoopParams::Threshold.
Referenced by Trigger::setPeak(), and Trigger::setTrough().
void setPeak | ( | double | threshold | ) |
Trigger at any detected peak. Shortcut for setPeakTrough( threshold, AboveSet | BelowSet, AboveReset | BelowReset, 0.0, 0, 0, 0.0 ).
[in] | threshold | is the threshold used for detecting peaks and troughs (only peaks and troughs that differ by more than threshold are detected. |
References Trigger::AboveReset, Trigger::AboveSet, Trigger::BelowReset, Trigger::BelowSet, and Trigger::setPeakTrough().
Referenced by Trigger::set().
void setTrough | ( | double | threshold | ) |
Trigger at any detected trough. Shortcut for setPeakTrough( threshold, AboveReset | BelowReset, AboveSet | BelowSet, 0.0, 0, 0, 0.0 ).
[in] | threshold | is the threshold used for detecting peaks and troughs (only peaks and troughs that differ by more than threshold are detected. |
References Trigger::AboveReset, Trigger::AboveSet, Trigger::BelowReset, Trigger::BelowSet, and Trigger::setPeakTrough().
Referenced by Trigger::set().
void setPeak | ( | double | threshold, |
double | level | ||
) |
Trigger at detected peaks that are above the specified level. Shortcut for setPeakTrough( threshold, AboveSet, AboveReset | BelowReset, level, 0, 0, 0.0 ).
[in] | threshold | is the threshold used for detecting peaks and troughs (only peaks and troughs that differ by more than threshold are detected. |
[in] | level | the peak must be above this level. |
References Trigger::AboveReset, Trigger::AboveSet, Trigger::BelowReset, and Trigger::setPeakTrough().
void setTrough | ( | double | threshold, |
double | level | ||
) |
Trigger at detected troughs that are below the specified level. Shortcut for setPeakTrough( threshold, AboveReset | BelowReset, BelowSet, level, 0, 0, 0.0 ).
[in] | threshold | is the threshold used for detecting peaks and troughs (only peaks and troughs that differ by more than threshold are detected. |
[in] | level | the trough must be below this level. |
References Trigger::AboveReset, Trigger::BelowReset, Trigger::BelowSet, and Trigger::setPeakTrough().
void setPeak | ( | double | threshold, |
double | alevel, | ||
double | blevel | ||
) |
Trigger at detected peaks that are above the specified level alevel and below the specified level blevel. Shortcut for setPeakTrough( threshold, AboveSet | BelowReset, AboveReset | BelowReset, alevel, AboveReset | BelowSet, 0, blevel ).
[in] | threshold | is the threshold used for detecting peaks and troughs (only peaks and troughs that differ by more than threshold are detected. |
[in] | alevel | the peak must be above this level. |
[in] | blevel | the peak must be below this level (alevel < blevel). |
References Trigger::AboveReset, Trigger::AboveSet, Trigger::BelowReset, Trigger::BelowSet, and Trigger::setPeakTrough().
void setTrough | ( | double | threshold, |
double | alevel, | ||
double | blevel | ||
) |
Trigger at detected troughs that are above the specified level alevel and below the specified level blevel. Shortcut for setPeakTrough( threshold, AboveReset | BelowReset, AboveSet | BelowReset, alevel, 0, AboveReset | BelowSet, blevel ).
[in] | threshold | is the threshold used for detecting peaks and troughs (only peaks and troughs that differ by more than threshold are detected. |
[in] | alevel | the trough must be above this level. |
[in] | blevel | the trough must be below this level (alevel < blevel). |
References Trigger::AboveReset, Trigger::AboveSet, Trigger::BelowReset, Trigger::BelowSet, and Trigger::setPeakTrough().
int set | ( | void | ) |
Read parameter from opts and call the corresponding setCrossing() or setPeakTrough() function. The following parameter are used:
type:
the type of the trigger event ("rising", "falling", "risinghysteresis", "fallinghysteresis", "window", "peak", "trough", "peakabove", "troughbelow", "peakwindow", "troughwindow", corresponding to the setRising(), setFalling(), setRisingHysteresis(), setFallingHysteresis(), setWindow(), setPeak( double ), setTrough( double ), setPeak( double, double ), setTrough( double, double ), setPeak( double, double, double ), setTrough( double, double, double ), respectively. level:
the level for the trigger events that take one level into account. alevel:
the lower level for the trigger events that take two levels into account. blevel:
the higher level for the trigger events that take two levels into account. threshold:
the threshold parameter for detecting peak and troughs. References Trigger::clear(), Trigger::setFalling(), Trigger::setFallingHysteresis(), Trigger::setPeak(), Trigger::setRising(), Trigger::setRisingHysteresis(), Trigger::setTrough(), and Trigger::setWindow().
int addHoop | ( | double | delay, |
double | width | ||
) |
Add a new hoop to the trigger chain. All subsequent calls to the set* functions configure the new hoop.
[in] | delay | the time relative to the first trigger event after which the trigger of this hoop has to occur. |
[in] | width | the time interval during which the trigger of this hoop has to occur. |
References Trigger::HoopParams::ACrossing, Trigger::HoopParams::ALevel, Trigger::HoopParams::APeak, Trigger::HoopParams::ATrough, Trigger::HoopParams::BCrossing, Trigger::HoopParams::BLevel, Trigger::HoopParams::BPeak, Trigger::HoopParams::BTrough, Trigger::HoopParams::Delay, Trigger::Hoop, Trigger::Hoops, Trigger::MaxHoops, Trigger::HoopParams::Threshold, and Trigger::HoopParams::Width.
void clear | ( | void | ) |
Clear all settings. The next call of a set* function will specify the first hoop.
References Trigger::HoopParams::ACrossing, Trigger::HoopParams::ALevel, Trigger::HoopParams::APeak, Trigger::HoopParams::ATrough, Trigger::HoopParams::BCrossing, Trigger::HoopParams::BLevel, Trigger::HoopParams::BPeak, Trigger::HoopParams::BTrough, Trigger::Hoop, Trigger::Hoops, and Trigger::HoopParams::Threshold.
Referenced by Trigger::reset(), and Trigger::set().
void setSettings | ( | void | ) |
Update the settings() of the device with the current trigger parameter.
References Device::Settings.
|
pure virtual |
Call this function to transfer all settings to the trigger device and to activate them.
The implementation of this function has to read out the Hoop array and configure the device accordingly. Note that the number of configured hoops is Hoops plus one. Any functionality of this interface that is not supported by the device should be gracefully ignored. Also the settings of the device should be updated, e.g. by calling setSettings().
|
pure virtual |
Disable the trigger device, i.e. no more trigger events will be emitted.
Referenced by Trigger::reset().
|
virtual |
Disables the trigger device and clears all hoops.
Reimplemented from Device.
References Trigger::clear(), and Trigger::disable().
|
protectedvirtual |
|
staticprotected |
Maximum number of supported trigger hoops.
Referenced by Trigger::addHoop().
|
protected |
The parameter of the trigger hoops.
Referenced by Trigger::addHoop(), Trigger::clear(), Trigger::setCrossing(), and Trigger::setPeakTrough().
|
protected |
The number of hoops minus one.
Referenced by Trigger::addHoop(), Trigger::clear(), Trigger::setCrossing(), and Trigger::setPeakTrough().