Avionics
Dropship Simulator
Devices::Apcupsd Class Reference

C++ monitoring implementation of http://www.apcupsd.org. More...

#include <apcupsd.h>

Collaboration diagram for Devices::Apcupsd:
[legend]

Classes

struct  STATUS
 

Public Member Functions

 Apcupsd ()
 
void Initialize (Logger *logger, ApcupsdConfig *config, Bus *bus)
 
void FrameMove (float fElapsed)
 
 ~Apcupsd ()
 

Public Attributes

STATUS status
 

Private Types

enum  cable { Custom_Cable_Smart, USB_Cable }
 
enum  driver { APC_Smart_UPS__any_, USB_UPS_Driver }
 
enum  upsmode { Stand_Alone }
 
enum  status1 {
  ONLINE_ = 0, NoSignal = 1, ONBATT_ = 2, BOOST_ONLINE_ = 4,
  CAL_ONBATT_ = 8, ONLINE_LOWBATT_ = 16
}
 
enum  sense { High, Medium, Low }
 
enum  selftest { OK, BT, NG, NO }
 

Private Member Functions

void Log (char *msg, Logger::Level level, int errorno) const
 
void Connect ()
 

Static Private Member Functions

static bool ReadText (std::string, const char *, char *, size_t)
 
static bool ReadDateTime (std::string, const char *, time_t *)
 
static bool ReadDate (std::string, const char *, time_t *)
 
static bool ReadFloat (std::string, const char *, float *)
 
static bool ReadInt (std::string, const char *, int *)
 

Private Attributes

int datafile = 0
 
float timeSinceLastUpdate = 0.0f
 
SOCKET tcp = static_cast<SOCKET>(SOCKET_ERROR)
 
bool connected = false
 
char buf [4096]
 
Loggerlogger = nullptr
 
ApcupsdConfigconfig = nullptr
 
Busbus = nullptr
 
float * avionicsBayTemp = nullptr
 

Detailed Description

C++ monitoring implementation of http://www.apcupsd.org.

Definition at line 32 of file apcupsd.h.

Member Enumeration Documentation

◆ cable

Enumerator
Custom_Cable_Smart 
USB_Cable 

Definition at line 48 of file apcupsd.h.

◆ driver

Enumerator
APC_Smart_UPS__any_ 
USB_UPS_Driver 

Definition at line 54 of file apcupsd.h.

◆ selftest

Enumerator
OK 

self test indicates good battery

BT 

self test failed due to insufficient battery capacity

NG 

self test failed due to overload

NO 

No results (i.e. no self test performed in the last 5 minutes)

Definition at line 83 of file apcupsd.h.

◆ sense

Enumerator
High 
Medium 
Low 

Definition at line 76 of file apcupsd.h.

◆ status1

Enumerator
ONLINE_ 
NoSignal 

Not a real APC status, reserved for compatibility across the board.

ONBATT_ 
BOOST_ONLINE_ 
CAL_ONBATT_ 
ONLINE_LOWBATT_ 

Definition at line 65 of file apcupsd.h.

◆ upsmode

Enumerator
Stand_Alone 

Definition at line 60 of file apcupsd.h.

Constructor & Destructor Documentation

◆ Apcupsd()

Devices::Apcupsd::Apcupsd ( )

Definition at line 19 of file apcupsd.cpp.

◆ ~Apcupsd()

Devices::Apcupsd::~Apcupsd ( )

Definition at line 67 of file apcupsd.cpp.

Here is the call graph for this function:

Member Function Documentation

◆ Connect()

void Devices::Apcupsd::Connect ( )
private

Definition at line 515 of file apcupsd.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ FrameMove()

void Devices::Apcupsd::FrameMove ( float  fElapsedTime)

So 4/11 recap

See also
http://frontier.userland.com/reference/windows/tcpErrorCodes ERROR: Apcupsd::FrameMove Recv failed (error 10053) (Connection aborted) we had a Send fail (not sure what error code but that has been fixed) which put is back into connect mode ERROR: Apcupsd::Initialize Connect failed (error 10056) (Socket is already connected) (if we get that now we put it back to connected=true)
Todo:
we would lose connection if the service stopped? we should try to connect every few seconds

SKIP DATE HERE

Definition at line 163 of file apcupsd.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Initialize()

void Devices::Apcupsd::Initialize ( Logger logger,
ApcupsdConfig config,
Bus bus 
)
Todo:
need to make this configurable? Or get rid of it from this file actually what we need to do is make components out of each of these values so we can FDR it?

Definition at line 24 of file apcupsd.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Log()

void Devices::Apcupsd::Log ( char *  msg,
Logger::Level  level = Logger::Level::Info,
int  errorno = 0 
) const
private

Definition at line 12 of file apcupsd.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ReadDate()

bool Devices::Apcupsd::ReadDate ( std::string  str,
const char *  pattern,
time_t *  ret 
)
staticprivate

Definition at line 131 of file apcupsd.cpp.

Here is the caller graph for this function:

◆ ReadDateTime()

bool Devices::Apcupsd::ReadDateTime ( std::string  str,
const char *  pattern,
time_t *  ret 
)
staticprivate

Definition at line 109 of file apcupsd.cpp.

Here is the caller graph for this function:

◆ ReadFloat()

bool Devices::Apcupsd::ReadFloat ( std::string  str,
const char *  pattern,
float *  retval 
)
staticprivate

Definition at line 91 of file apcupsd.cpp.

Here is the caller graph for this function:

◆ ReadInt()

bool Devices::Apcupsd::ReadInt ( std::string  str,
const char *  pattern,
int *  retval 
)
staticprivate

Definition at line 100 of file apcupsd.cpp.

Here is the caller graph for this function:

◆ ReadText()

bool Devices::Apcupsd::ReadText ( std::string  str,
const char *  pattern,
char *  output,
size_t  outputsize 
)
staticprivate

Definition at line 76 of file apcupsd.cpp.

Here is the caller graph for this function:

Member Data Documentation

◆ avionicsBayTemp

float* Devices::Apcupsd::avionicsBayTemp = nullptr
private

Definition at line 46 of file apcupsd.h.

◆ buf

char Devices::Apcupsd::buf[4096]
private

Definition at line 40 of file apcupsd.h.

◆ bus

Bus* Devices::Apcupsd::bus = nullptr
private

Definition at line 44 of file apcupsd.h.

◆ config

ApcupsdConfig* Devices::Apcupsd::config = nullptr
private

Definition at line 43 of file apcupsd.h.

◆ connected

bool Devices::Apcupsd::connected = false
private

Definition at line 39 of file apcupsd.h.

◆ datafile

int Devices::Apcupsd::datafile = 0
private

Definition at line 35 of file apcupsd.h.

◆ logger

Logger* Devices::Apcupsd::logger = nullptr
private

Definition at line 42 of file apcupsd.h.

◆ status

STATUS Devices::Apcupsd::status

Definition at line 208 of file apcupsd.h.

◆ tcp

SOCKET Devices::Apcupsd::tcp = static_cast<SOCKET>(SOCKET_ERROR)
private

Definition at line 38 of file apcupsd.h.

◆ timeSinceLastUpdate

float Devices::Apcupsd::timeSinceLastUpdate = 0.0f
private

Definition at line 36 of file apcupsd.h.


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