Class Interface

Nested Relationships

Nested Types

Class Documentation

class Interface

interface class for the network power switch(es)

This class defines the interface for all of the power control hardware and contains the functions used to communicate with it.

Public Functions

inline Interface()
inline long init_pubsub(const std::initializer_list<std::string> &topics = {})
inline void start_subscriber_thread()
inline void stop_subscriber_thread()
void handletopic_snapshot(const nlohmann::json &jmessage)
void configure_interface(Power::NpsInfo npsinfo)

configure the NPS interface vector with info from configuration file

long initialize_class()

initialize class variables

long open()

open the NPS socket connection

long close()

close the NPS socket connection

bool isopen()

is the NPS socket connection open?

long command(std::string cmd, std::string &retstring)

parse and form a command to send to the NPS unit

void list(std::string args, std::string &retstring)

list plug devices

long get_status(std::string args, std::string &retstring)

status of all plug devices

void publish_status(bool force = false)

publish power state on change (or force)

Public Members

std::unique_ptr<Common::PubSub> publisher

publisher object

std::string publisher_address

publish socket endpoint

std::string publisher_topic

my default topic for publishing

std::unique_ptr<Common::PubSub> subscriber

subscriber object

std::string subscriber_address

subscribe socket endpoint

std::vector<std::string> subscriber_topics

list of topics I subscribe to

std::atomic<bool> is_subscriber_thread_running

is my subscriber thread running?

std::atomic<bool> should_subscriber_thread_run

should my subscriber thread run?

std::unordered_map<std::string, std::function<void(const nlohmann::json&)>> topic_handlers

maps a handler function to each topic

Common::Queue async

asynchronous message queue object

std::map<int, Power::NpsInfo> nps_info

STL map of NpsInfo objects indexed by NPS unit#.

std::map<int, WTI::NPS> npsmap

STL map of WTI NPS objects indexed by NPS unit#.

std::vector<int> npsvec

vector of npsnums for indexing

std::string missing

reports any missing hardware (configured but unresponsive)

std::map<std::string, plug_t> plugmap

STL map of plug number indexed by plug name, allows finding {npsnum,plugnum} by plugname.

std::map<std::string, std::string> plugname

STL map of plug names indexed by a string made of “unit# plug#”, e.g. “1 1” or “2 8” etc.

struct plug_t

structure to contain location of a plug, both nps and plug number

Public Members

int npsnum

NPS number.

int plugnum

plug number