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

Detailed Description

This object represents a set of user specified analog sensors that are connected to the NAFE.

Sample code:

#include <libio/analog.h>
void fn()
{
using namespace vsdk::io::analog;
// Configure a profile with profile_builder
// Assume sensors "tc1", "tc2" have been configured
// ...
analog_profile profile = builder.to_profile();
auto tc1 = analog->get_handle("tc1");
auto tc2 = analog->get_handle("tc2");
std::cout << "TC1: " << analog->read_from(tc1).value << '\n';
std::cout << "TC2: " << analog->read_from(tc2).value << '\n';
}
The analog interface.
analog(const analog &)=delete
static analog * instance()
Get a pointer to the singleton instance.
std::tuple< std::vector< sensor >, std::vector< function_channel > > analog_profile
Representation of an analog profile.
Definition analog.h:32
Anything related to configuring or reading analog sensors.

#include <analog.h>

Public Member Functions

void init (const analog_profile &profile)
 Initialize the analog singleton.
void init (const analog_profile &profile, std::unique_ptr< nafe::nafe_interface > nafe)
 Initialize the analog singleton.
void release ()
 Destruct the analog singleton.
analog_result read_from (int8_t handle)
 Read a sensor value.
int8_t get_handle (std::string label)
 Get the handle to a configured sensor.
 ~analog () override
 analog (const analog &)=delete
 analog (analog &&)=delete
analog & operator= (const analog &)=delete
analog & operator= (analog &&)=delete
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.

Static Public Member Functions

static analog * instance ()
 Get a pointer to the singleton instance.

Static Public Attributes

static constexpr uint8_t max_sensor_count = 6
 The maximum number of sensors that can exist in a profile.

Protected Member Functions

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

Detailed Description

This object represents a set of user specified analog sensors that are connected to the NAFE.

Sample code:

#include <libio/analog.h>
void fn()
{
using namespace vsdk::io::analog;
// Configure a profile with profile_builder
// Assume sensors "tc1", "tc2" have been configured
// ...
analog_profile profile = builder.to_profile();
auto tc1 = analog->get_handle("tc1");
auto tc2 = analog->get_handle("tc2");
std::cout << "TC1: " << analog->read_from(tc1).value << '\n';
std::cout << "TC2: " << analog->read_from(tc2).value << '\n';
}

Constructor & Destructor Documentation

◆ ~analog()

vsdk::io::analog::analog::~analog ( )
override

Destructor

◆ analog() [1/2]

vsdk::io::analog::analog::analog ( const analog & )
delete

Deleted constructors

◆ analog() [2/2]

vsdk::io::analog::analog::analog ( analog && )
delete

Deleted constructors

Member Function Documentation

◆ get_handle()

int8_t vsdk::io::analog::analog::get_handle ( std::string label)

Get the handle to a configured sensor.

Returns
A postive integer representing the sensor handle, otherwise -1 if the sensor could not be found

◆ init() [1/2]

void vsdk::io::analog::analog::init ( const analog_profile & profile)

Initialize the analog singleton.

Note
Use the vsdk::io::profile_builder to configure a profile
Warning
This constructor will default to a mock implementation when built for a host machine

◆ init() [2/2]

void vsdk::io::analog::analog::init ( const analog_profile & profile,
std::unique_ptr< nafe::nafe_interface > nafe )

Initialize the analog singleton.

Note
Use the vsdk::io::profile_builder to configure a profile

◆ operator=() [1/2]

analog & vsdk::io::analog::analog::operator= ( analog && )
delete

Deleted constructors

◆ operator=() [2/2]

analog & vsdk::io::analog::analog::operator= ( const analog & )
delete

Deleted constructors

◆ process_notification()

bool vsdk::io::analog::analog::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::analog::analog::read_from ( int8_t handle)

Read a sensor value.

Parameters
handlehandle as provided by the get_handle function
Returns
io_result

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