This class controls a group of digital input signals.
For a detailed electrical specification, please take a look at the Hardware Manual for the specific device.
The Multiplexer in the VisionBox and VisionCam has direct access to the digital input signals after debouncing. The DigitalInput device doesn't have to be opened when going through the Multiplexer.
Digital input signals can be filtered by a digital debounce logic. It is configured with the function ConfigureDebounceTime().
The debouncing affects the values returned by Get() / GetBit() and the event function WaitForInputEvent().
The debouncing logic is implemented in the FPGA.
Digital input events can be used to avoid polled reading of the input state:
First, the desired input signals for generating an event are configured with ConfigureInputEvent.
Then, the blocking function WaitForInputEvent() can be used to wait for the event. It is usually called by a dedicated thread in the application.
AbortWaitingForInputEvent() can be used to interrupt waiting threads.
Public Member Functions | |
bool | AbortWaitingForInputEvent () |
Aborts all threads waiting for events. More... | |
bool | ConfigureDebounceTime (unsigned int nsLow, unsigned int nsHigh) |
Sets debouncing time for the digital input signals. More... | |
bool | ConfigureDebounceTime (unsigned int nsLow, unsigned int nsHigh, unsigned int enableMask) |
Sets debouncing time for the digital input signals. More... | |
bool | ConfigureInputEvent (unsigned int SensitivityMask) |
Configures the sensitivity of the input events. More... | |
bool | ConfigureInputEvent (unsigned int SensitivityMaskRising, unsigned int SensitivityMaskFalling) |
Configures the sensitivity of the input events. More... | |
DigitalInput () | |
Default constructor for the device object More... | |
bool | Get (unsigned int &InputState) |
Reads the state of the digital input signals. More... | |
bool | GetBit (unsigned int BitIndex, bool &BitState) |
Reads the state of the specified digital input signal. More... | |
bool | GetNumberOfInputs (unsigned int &NumberOfInputs) |
Returns number of digital input channels. More... | |
bool | Reset () |
Resets the device to default settings. More... | |
bool | WaitForInputEvent (unsigned int msTimeout, unsigned int &NewInputState) |
Waits for an input event. More... | |
bool | WaitForInputEvent (unsigned int msTimeout, unsigned int &SignalState, unsigned int &EventSignals) |
Waits for an input event. More... | |
Public Member Functions inherited from VIB::iDevice | |
bool | Close () |
Closes a device More... | |
iDevice (const iDevice &device) | |
The copy constructor makes a copy of the existing device object More... | |
bool | isOpen (bool &state) |
Returns the open state of a device object More... | |
bool | Open (unsigned int Index=0) |
Opens a device More... | |
iDevice & | operator= (const iDevice &device) |
The assignment operator makes a copy of the existing device object More... | |
virtual | ~iDevice () |
Deletes the device object More... | |
VIB::DigitalInput::DigitalInput | ( | ) |
Default constructor for the device object
The device must be opened with Open() before it can be used.
bool VIB::DigitalInput::AbortWaitingForInputEvent | ( | ) |
Aborts all threads waiting for events.
The function wakes up all threads waiting in WaitForInputEvent(), which will then return with an error.
bool VIB::DigitalInput::ConfigureDebounceTime | ( | unsigned int | nsLow, |
unsigned int | nsHigh | ||
) |
Sets debouncing time for the digital input signals.
The time values are specified for high and low state separately. A value of 0 deactivates the debouncing function.
The same debouncing setting is applied to all input signals.
nsLow | Time in nano-seconds the signal must stay low before it takes effect (falling edge) |
nsHigh | Time in nano-seconds the signal must stay high before it takes effect (rising edge) |
true
for success, use VIBSystem::GetLastErrorString() for an error descriptionbool VIB::DigitalInput::ConfigureDebounceTime | ( | unsigned int | nsLow, |
unsigned int | nsHigh, | ||
unsigned int | enableMask | ||
) |
Sets debouncing time for the digital input signals.
The time values are specified for high and low state separately. A value of 0 deactivates the debouncing function.
Debouncing can be enabled for specific inputs only by using the enableMask
argument.
nsLow | Time in nano-seconds the signal must stay low before it takes effect (falling edge) |
nsHigh | Time in nano-seconds the signal must stay high before it takes effect (rising edge) |
enableMask | Binary representation of signals with debouncing enabled |
true
for success, use VIBSystem::GetLastErrorString() for an error descriptionbool VIB::DigitalInput::ConfigureInputEvent | ( | unsigned int | SensitivityMask | ) |
Configures the sensitivity of the input events.
See overloaded version of ConfigureInputEvent() for a detailed description.
SensitivityMask | If bits 16...31 are zero, the corresponding bits 0...15 activate events for both edges (0: no events, 1: rising and falling edge). If bits 16...31 are set, the corresponding bits 0...15 configure the edge for each signal (0: falling edge, 1: rising edge). |
true
for success, use VIBSystem::GetLastErrorString() for an error descriptionbool VIB::DigitalInput::ConfigureInputEvent | ( | unsigned int | SensitivityMaskRising, |
unsigned int | SensitivityMaskFalling | ||
) |
Configures the sensitivity of the input events.
This function must be called before WaitForInputEvent().
The parameters specify which input lines will be used to generate events. The signal edge can be specified for each line individually.
SensitivityMaskRising | Binary representation of signals that trigger events on the rising edge |
SensitivityMaskFalling | Binary representation of signals that trigger events on the falling edge |
true
for success, use VIBSystem::GetLastErrorString() for an error descriptionbool VIB::DigitalInput::Get | ( | unsigned int & | InputState | ) |
Reads the state of the digital input signals.
InputState | Binary representation of the input signals, LSB is input 0 |
true
for success, use VIBSystem::GetLastErrorString() for an error descriptionbool VIB::DigitalInput::GetBit | ( | unsigned int | BitIndex, |
bool & | BitState | ||
) |
Reads the state of the specified digital input signal.
BitIndex | Input signal index, 0 ... (GetNumberOfInputs() - 1) |
BitState | State of the input |
true
for success, use VIBSystem::GetLastErrorString() for an error descriptionbool VIB::DigitalInput::GetNumberOfInputs | ( | unsigned int & | NumberOfInputs | ) |
Returns number of digital input channels.
NumberOfInputs | Number of inputs |
true
for success, use VIBSystem::GetLastErrorString() for an error descriptionbool VIB::DigitalInput::Reset | ( | ) |
Resets the device to default settings.
true
for success, use VIBSystem::GetLastErrorString() for an error descriptionbool VIB::DigitalInput::WaitForInputEvent | ( | unsigned int | msTimeout, |
unsigned int & | NewInputState | ||
) |
Waits for an input event.
See overloaded version of WaitForInputEvent() for a detailed description.
msTimeout | Timeout in milli-seconds, 0 ... INFINITE |
NewInputState | Result value containing the current state of the digital inputs and the changed signals:
|
true:
success, new event false:
timeout, abort or other errors; use VIBSystem::GetLastErrorString() for an error descriptionbool VIB::DigitalInput::WaitForInputEvent | ( | unsigned int | msTimeout, |
unsigned int & | SignalState, | ||
unsigned int & | EventSignals | ||
) |
Waits for an input event.
The function waits for events on digital input lines which are selected with ConfigureInputEvent(). The function blocks until a new input event occurs, the timeout expires, or AbortWaitingForInputEvent() gets called.
msTimeout | Timeout in milli-seconds, 0 ... INFINITE The actual timeout may be twice as high if there are already other threads waiting for an event. |
SignalState | After success, the function returns the new state of the digital input signals (binary representation). |
EventSignals | After success, the function returns the input signals which triggered the event (binary representation). |
true:
success, new event false:
timeout, abort or other errors; use VIBSystem::GetLastErrorString() for an error description