Veethree D7 SDK
Loading...
Searching...
No Matches
vsdk::io::i420 Class Reference

Detailed Description

The i420 class.

Class used for reading 4-20 mA inputs.

Note
For inputs i420_input::sns0 to i420_input::sns5, if any is not connected, the value read will be 0 mA. It is possible to get readings of 0.01 mA or less, which is a characteristic of the operational amplifier circuit on the target device.
Any other values are onboard values, like i420_input::vsns_main and i420_input::isns_main. Bear in mind values dependent on the power supply may fluctuate.

For hardware connections, see hardware interfaces and 4-20 mA pins.

Sample code:

#include <libio/i420.h>
int main() {
using namespace vsdk::io;
// There should only be *one* i420 instance on the entire machine.
i420 i;
// Unlike the analog IO library, the pins of the 4-20mA interface can only
// read 1 type of value so there is no configuration to require any
// registration.
//
// The call can only throw in the case of a fatal error like, for instance,
// trying to read before the library is initialized or trying to read from an
// invalid pin.
//
// To read a value, call
// `read_from` on the instance
fmt::println("{}: {} mA", i420_input::sns0, result.value);
}
analog_result read_from(i420_input input) const
Read the selected input.
i420()
The class default constructor, which uses i420_context as its provider.
Include this file to your file so you have access to fmtlib header-only implementation.
@ sns0
input 0 in mA
Definition i420_common.h:22
i420 interface
Any entities that belong to the IO library.
io_result< double > analog_result
Analog result type.
Definition io_common.h:67
ValueType value
Value of the result.
Definition io_common.h:61

#include <i420.h>

Public Member Functions

 i420 ()
 The class default constructor, which uses i420_context as its provider.
 i420 (std::shared_ptr< i420_context_interface > ctx)
 The class constructor.
analog_result read_from (i420_input input) const
 Read the selected input.
Public Member Functions inherited from vsdk::io::event_notification
virtual event_notification_id add_notification (const event_notification_descriptor &desc)
 Add a definition when an event must be notified.
virtual bool remove_notification (event_notification_id id)
 Remove a notification identified by 'id'.
virtual void remove_all_notifications ()
 Remove all notifications.
virtual void start_notifications ()
 Start the event notifications.
virtual void stop_notifications ()
 Stop the event notifications.
 event_notification ()
 Class constructors.
 event_notification (const event_notification &other)=delete
 Class constructors.
 event_notification (event_notification &&other) noexcept
 Class constructors.
event_notification & operator= (const event_notification &other)=delete
 Assignment operators.
event_notification & operator= (event_notification &&other) noexcept
 Assignment operators.

Protected Member Functions

bool process_notification (const event_notification_descriptor &desc) const noexcept override
 Notification processing interface.

Detailed Description

The i420 class.

Class used for reading 4-20 mA inputs.

Note
For inputs i420_input::sns0 to i420_input::sns5, if any is not connected, the value read will be 0 mA. It is possible to get readings of 0.01 mA or less, which is a characteristic of the operational amplifier circuit on the target device.
Any other values are onboard values, like i420_input::vsns_main and i420_input::isns_main. Bear in mind values dependent on the power supply may fluctuate.

For hardware connections, see hardware interfaces and 4-20 mA pins.

Sample code:

#include <libio/i420.h>
int main() {
using namespace vsdk::io;
// There should only be *one* i420 instance on the entire machine.
i420 i;
// Unlike the analog IO library, the pins of the 4-20mA interface can only
// read 1 type of value so there is no configuration to require any
// registration.
//
// The call can only throw in the case of a fatal error like, for instance,
// trying to read before the library is initialized or trying to read from an
// invalid pin.
//
// To read a value, call
// `read_from` on the instance
fmt::println("{}: {} mA", i420_input::sns0, result.value);
}

Constructor & Destructor Documentation

◆ i420()

vsdk::io::i420::i420 ( std::shared_ptr< i420_context_interface > ctx)
explicit

The class constructor.

The i420 context object is the data provider for this class.

Parameters
ctxThe i420 context object that implements i420_context_interface.

Member Function Documentation

◆ process_notification()

bool vsdk::io::i420::process_notification ( const event_notification_descriptor & desc) const
overrideprotectedvirtualnoexcept

Notification processing interface.

When a notification is a vsdk::io::event_notification_frequency::single_shot, once that notification is generated it is automatically removed, so attempting to use its vsdk::io::event_notification_id in the remove_notification function will result in a false return value.

Parameters
descA notification description, see vsdk::io::event_notification_descriptor.
Returns
It returns true when the notification has been handled, otherwise false.

Implements vsdk::io::event_notification.

◆ read_from()

analog_result vsdk::io::i420::read_from ( i420_input input) const

Read the selected input.

See the i420_input description in order to know the result unit (mA or mV). If an input is not connected, read values will be 0 mA (some cases 0.01 mA or less).

Parameters
inputThe input to be read_from. See vsdk::io::i420_input for input names and returned unit.
Returns
A io_result value, see io_result for details.
See also
i420_input
Exceptions
libio_error

The documentation for this class was generated from the following file: