Class PowerSensor

Nested Relationships

Nested Types

Class Documentation

class PowerSensor

The main PowerSensor class.

Connects to a PowerSensor device and reads out its sensors continously using a light-overhead thread. Sensor values can be obtained with the read method, or written to a file with the dump method

Public Functions

explicit PowerSensor(std::string device)

Construct a new Power Sensor:: Power Sensor object.

Parameters:

device – path to device, e.g. /dev/ttyACM0

~PowerSensor()

Destroy the Power Sensor:: Power Sensor object.

State read() const

Read sensor values.

Returns:

State

void dump(const std::string dumpFileName)

Enable dumping of sensor values to the given output file.

Parameters:

dumpFileName

void mark(char name)

Instruct device to mark the next sensor value.

Parameters:

name – marker character

void mark(const State &startState, const State &stopState, const std::string name = 0, unsigned int tag = 0) const

Write custom marker to dump file.

Parameters:
  • startStateState used to get start time

  • stopStateState used to get end time

  • name – name of the marker (string)

  • tag – id of the marker (int)

void reset(bool dfuMode)

Reset device, either normally or to DFU mode for firmware upload.

Parameters:

dfuMode

void writeSensorsToEEPROM()

Write sensor configuration to device EEPROM.

void setType(unsigned int sensorID, const std::string type)

Set type of given sensor.

Parameters:
  • sensorID

  • type

void setPairName(unsigned int pairID, const std::string pairName)

Set sensor pair name of given sensor pair.

Parameters:
  • pairID

  • pairName

void setVref(unsigned int sensorID, const float vref)

Set reference voltage (V) of given sensor.

Parameters:
  • sensorID

  • vref

void setSensitivity(unsigned int sensorID, const float slope)

Set sensitivity of given sensor, in V/A (current sensors) of unitless gain (voltage sensors)

Parameters:
  • sensorID

  • sensitivity

void setInUse(unsigned int sensorID, const bool inUse)

Set whether or not the given sensor is in use.

Parameters:
  • sensorID

  • inUse

void setPolarity(unsigned int sensorID, const int polarity)

Set polarity of given sensor.

Parameters:
  • sensorID

  • polarity – (-1 or 1)

std::string getType(unsigned int sensorID) const

Get type of given sensor.

Parameters:

sensorID

Returns:

std::string

std::string getPairName(unsigned int pairID) const

Get name of given sensor pair.

Parameters:

pairID

Returns:

std::string

float getVref(unsigned int sensorID) const

Get reference voltage (V) of given sensor.

Parameters:

sensorID

Returns:

float

float getSensitivity(unsigned int sensorID) const

Get sensitivity of given sensor, in V/A (current sensors) of unitless gain (voltage sensors)

Parameters:

sensorID

Returns:

float

bool getInUse(unsigned int sensorID) const

Get whether or not the given sensor is in use.

Parameters:

sensorID

Returns:

bool

int getPolarity(unsigned int sensorID) const

Get polarity of given sensor.

Parameters:

sensorID

Returns:

int (-1 or 1)

std::string getVersion()

Get the firmware version.

Returns:

std::string