LRAUV  revA
BPC1 Class Reference

Provides software interface to the Battery Pack Controller. More...

#include <BPC1.h>

Inheritance diagram for BPC1:
Collaboration diagram for BPC1:

Classes

struct  BattStick
 

Public Member Functions

 BPC1 (const Module *module)
 
virtual ~BPC1 ()
 
virtual void run ()
 The actual "payload" of the component. More...
 
virtual RunState start ()
 Do what needs to be done to run Similar to initialize, in old init/run/uninit sequence. More...
 
virtual RunState starting ()
 Might follow a STOP...START sequence. More...
 
virtual RunState pause ()
 Pause for a short period (indicated by pauseTime) More...
 
virtual RunState pausing ()
 Waiting to be paused. More...
 
virtual RunState paused ()
 Should eventually follow a PAUSE request: should set continueTime. More...
 
virtual RunState resume ()
 Resume from PAUSE. More...
 
virtual RunState resuming ()
 Might follow a PAUSE...RESUME sequence. More...
 
virtual RunState runnable ()
 Should eventually follow a START request or RESETTING. More...
 
virtual RunState resetting ()
 Might occur in case of Error. More...
 
virtual RunState stop ()
 Initial state – can be later followed by START. More...
 
virtual RunState stopping ()
 Might follow a STOP request. More...
 
virtual RunState stopped ()
 Initial state – can be later followed by START. More...
 
virtual void uninitialize ()
 Provide a space for uninitialization. More...
 
virtual ConfigURI getConfigURI (ConfigOption configOption) const
 Should return [myNamespace]::SIMULATE_HARDWARE, or [myNamespace]::POWER, etc. More...
 
- Public Member Functions inherited from SyncComponent
CycleOrder getCycleOrder (void)
 Getter function for controlThreadOrderPreference. More...
 
void setRepeating (bool repeating)
 
int getDivisor () const
 
int getModulo () const
 
bool isRepeater ()
 
bool isRepeating ()
 
- Public Member Functions inherited from Component
virtual ~Component ()
 Destructor cleans up readers_ and writers_. More...
 
void registerReader (DataReader *reader)
 
void unregisterReader (DataReader *reader)
 
void registerWriter (DataWriter *writer)
 
void unregisterWriter (DataWriter *writer)
 
void disableMetering (void)
 
FlexArray< DataReader * > & getReaderList (void)
 
FlexArray< DataWriter * > & getWriterList (void)
 
const ModulegetModule ()
 
virtual void initialize ()
 Provide a space for initialization before being run. More...
 
virtual void configure ()
 Read (or re-read!) configuration settings. More...
 
virtual void execute (void)
 
bool isActive () const
 Indicates if the component is active. More...
 
const CodedStrgetName (void) const
 Returns the name. More...
 
const TimestampgetTimeOfLastRun (void) const
 
ComponentState getState (void)
 Return the component's current state. More...
 
void setState (ComponentState state)
 
RunState getRunState (void)
 Return the component's run state. More...
 
bool isUsingRunState ()
 Return true if using runState. More...
 
void requestData (bool requestingData)
 Tell the component to start (or stop) sending data. More...
 
void requestStart ()
 Tell the component to start runnning. More...
 
void requestPause (const Timespan expectedPauseTime)
 Tell the component to pause runnning. More...
 
void requestResume ()
 Tell the component resume from pause. More...
 
void requestStop ()
 Tell the component to stop runnning. More...
 
virtual RunState satisfied ()
 Possible return value of a Behavior. More...
 
void setCriticalFailureReported (bool boolVal)
 
void setRecoveringFromCritical (bool boolVal)
 
void setFailureReported (bool boolVal)
 
bool isFailureUninitialized ()
 
void setFailureUninitialized (bool boolVal)
 
void setRetryTimeout (const Timespan &timeout)
 
virtual bool isCompleted (void)
 Query if this component is completed. More...
 
void setPeriod (const Timespan &period)
 Set the period of this component... used if it is periodic. More...
 
const TimespangetPeriod (void)
 Returns the component's period (regardless of whether it is periodic) More...
 
ComponentType getComponentType ()
 Getter function for ComponentType. More...
 
virtual bool isFailed (void) const
 
virtual FailureMode::FailType getFailureType (void) const
 
virtual bool getCriticalFailureReported (void) const
 
virtual bool getFailureReported (void) const
 
virtual Timespan getRetryTimeout (void) const
 
virtual FailureMode::FailType setFailure (FailureMode::FailType failureType)
 
virtual int getFailCount (void) const
 
virtual bool isFailureMissionCritical ()
 
virtual int getAllowableFailures (void) const
 
virtual void setAllowableFailures (int fails)
 
LoggergetLogger (void)
 
virtual int incrementFailCount (void)
 
virtual void resetFailCount (void)
 
virtual int getSkippedRunsSinceFail (void) const
 
virtual int incrementSkippedRunsSinceFail (void)
 
virtual void logVoltage (float voltage, float averageVoltage)
 
virtual void logCurrent (float current, float averageCurrent)
 
const TimestampgetWriteTimestamp (void)
 
void setWriteTimestamp (const Timestamp &writeTimestamp)
 
BlobReadernewBlobReader (const BlobURI &blobURI)
 
BlobReadernewBlobReaderFromUniversal (const Str &componentName, const UniversalBlobURI &blobURI)
 
BlobWriternewBlobWriter (const BlobURI &blobURI, Logger::TimePrecisionType timePrecision=Logger::TIME_PRECISION_MILLIS)
 
ConfigReadernewConfigReader (const ConfigURI &configURI)
 
DataReadernewDataReader (const DataURI &dataURI)
 
DataReadernewDataReaderFromUniversal (const Str &componentName, const UniversalURI &universalURI)
 
DataWriternewDataWriter (const DataURI &dataURI, Logger::TimePrecisionType timePrecision=Logger::TIME_PRECISION_MILLIS)
 
UniversalBlobReadernewUniversalBlobReader (const UniversalBlobURI &universalURI)
 
UniversalBlobWriternewUniversalBlobWriter (const UniversalBlobURI &universalURI, const Unit &accuracyUnit=Units::NONE, const float accuracy=DataElement::NO_ACCURACY, Logger::TimePrecisionType timePrecision=Logger::TIME_PRECISION_MILLIS)
 
UniversalDataReadernewUniversalReader (const UniversalURI &universalURI)
 
UniversalDataWriternewUniversalWriter (const UniversalURI &universalURI, const Unit &accuracyUnit=Units::NONE, const float accuracy=DataElement::NO_ACCURACY, Logger::TimePrecisionType timePrecision=Logger::TIME_PRECISION_MILLIS)
 

Private Types

enum  SMBStatus {
  OVER_CHARGED_ALARM = 0x8000, TERMINATE_CHARGE_ALARM = 0x4000, OVER_TEMP_ALARM = 0x1000, TERMINATE_DISCHARGE_ALARM = 0x0800,
  REMAINING_CAPACITY_ALARM = 0x0200, REMAINING_TIME_ALARM = 0x0100, INITIALIZED = 0x0080, DISCHARGING = 0x0040,
  FULLY_CHARGED = 0x0020, FULLY_DISCHARGED = 0x0010
}
 

Private Member Functions

 BPC1 (const BPC1 &old)
 
bool readConfig ()
 
bool isDataRequested ()
 
bool parseWriteDataA (int size, int offset)
 
bool parseWriteDataB (int size, int offset)
 
bool voltagesPopulated ()
 
void setVoltagesNull (void)
 
void setWritersInvalid (bool invalid)
 
void calculateTotals (void)
 
void checkBatt (const float capacity, const float voltage)
 
int validData (int dataToCheck, int &msgOffset)
 
void sendIBPSBreak (void)
 
bool menusInitialized ()
 

Private Attributes

bool debug_
 
Timespan battTimeout_
 
Timespan muxTimeout_
 
Timespan poTimeout_
 
Timestamp startTimeA_
 
Timestamp startTimeB_
 
Timestamp startTime_
 
Timestamp muxTime_
 
char deviceResponseA_ [2120]
 
char deviceResponseB_ [2120]
 
UartStream uartA_
 
UartStream uartB_
 
float totalCapacity_
 
float totalVoltage_
 
float totalCapacityA_
 
float totalVoltageA_
 
float totalCapacityB_
 
float totalVoltageB_
 
float batteryCapacityThreshold_
 
float batteryVoltageThreshold_
 
BattStick battSticks_ [NUMBATTSA+NUMBATTSB]
 
UniversalDataWriterbatteryChargeWriter_
 
UniversalDataWriterbatteryVoltageWriter_
 
UniversalDataWriterbatteryDischargingWriter_
 
UniversalDataWriterbatteryFullyChargedWriter_
 
ConfigReaderbatteryCapacityThresholdCfgReader_
 
ConfigReaderbatteryVoltageThresholdCfgReader_
 
bool ok_
 
bool aParsed_
 
bool bParsed_
 
bool capacityFailed_
 
bool voltageFailed_
 

Static Private Attributes

static BPC1Instance_
 Pointer to the singleton-like instance of this component. More...
 

Additional Inherited Members

- Public Types inherited from Component
enum  ComponentState {
  BLOCK_CONTINUOUS, BLOCK_PERIODIC, BLOCK_NORMAL, BLOCK_COMPLETED,
  BLOCK_UNKNOWN
}
 In this model, the component has basically two states: wanting to run, and completed (no longer needing to run). More...
 
enum  ComponentType { COMPONENT_ASYNC, COMPONENT_CONFIG, COMPONENT_BEHAVIOR, COMPONENT_SYNC }
 Components can indicate how they want to be handled by their type. More...
 
enum  RunState {
  NO_RUN_STATE = 0, START, STARTING, RUNNABLE,
  SATISFIED, PAUSE, PAUSING, PAUSED,
  RESUME, RESUMING, RESETTING, STOP,
  STOPPING, STOPPED
}
 
- Static Public Attributes inherited from SyncComponent
static const int CYCLE_INCREMENT
 
static const int CYCLE_REPEAT_OFFSET
 
static const CycleOrder CYCLE_STARTER
 
static const CycleOrder CYCLE_SIMULATOR
 
static const CycleOrder CYCLE_SENSOR
 
static const CycleOrder CYCLE_DERIVATION
 
static const CycleOrder CYCLE_ESTIMATION
 
static const CycleOrder CYCLE_NAVIGATION
 
static const CycleOrder CYCLE_MISSION_MANAGER
 
static const CycleOrder CYCLE_MISSION
 
static const CycleOrder CYCLE_CONTROL
 
static const CycleOrder CYCLE_SERVO
 
static const CycleOrder CYCLE_TEST
 
static const CycleOrder CYCLE_REPORTER
 
static const CycleOrder CYCLE_LOGGER
 
- Protected Types inherited from Component
enum  ConfigOption { CONFIG_SIMULATE_HARDWARE, CONFIG_POWER, CONFIG_FREQUENCY, CONFIG_LATENCY }
 
- Protected Member Functions inherited from SyncSensorComponent
 SyncSensorComponent (const Str &name, const Module *module, int divisor=1, int modulo=0)
 
- Protected Member Functions inherited from SyncComponent
void setRepeater (bool repeater)
 
- Protected Member Functions inherited from Component
virtual ConfigURI getConfigURI (ConfigOption configOption, ElementURI forElement) const
 Should return [myNamespace]::POWER_[forElement], [myNamespace]::LATENCY_[forElement], etc. More...
 
virtual void setDurationOfLastRun (const Timespan &span)
 
virtual void setTimeOfRun (const Timestamp &time)
 
virtual void setTimeOfLastRun (const Timestamp &time)
 
virtual void setDt (const Timespan &dt)
 
virtual bool setEnabled (bool enabled=true)
 
void setRunState (const RunState runState)
 
const Timespan getPauseTime () const
 
virtual void setFailureMissionCritical (bool failureMissionCritical)
 
bool simulateHardware ()
 
- Protected Attributes inherited from Component
Logger logger_
 
Syslog::Severity debugLevel_
 
ComponentState state_
 Keep track of whether the component has "completed" or should be run again. More...
 
Timespan desiredPeriod_
 
CodedStrname_
 Store the component's name (used for logging purposes) More...
 
Timestamp timeOfRun_
 
Timestamp timeOfLastRun_
 
Timespan durationOfLastRun_
 
Timespan dt_
 
Timespan retryTimeout_
 
bool enabled_
 
bool failureReported_
 Indicates if the failure has been reported – cuts down on syslog. More...
 
bool criticalFailureReported_
 Indicates if a "Critical" failure has been reported – cuts down on syslog. More...
 
bool recoveringFromCritical_
 Indicates that a component had a previous critical failure that has been cleared temporarily awaiting final word from the component itself. More...
 
bool failureUninitialized_
 Indicates if the failure has resulted in an uninitialize call. More...
 
int failCount_
 Number of failures logged by PCaller. More...
 
bool failureMissionCritical_
 If true (default), complete failure ends mission. More...
 
int allowableFailures_
 Number of failures allowed to occur. More...
 
int skippedRunsSinceFail_
 Number of skipped runs since failureMode_ set by failCount_. More...
 
FailureMode::FailType failureType_
 Failed status. If failCount_ > 0, then this may be reset. More...
 
Timestamp timeOfFailure_
 Time of last failure. Relevant only if failed=true. More...
 
Timestamp writeTimestamp_
 Time of last write. More...
 
FlexArray< DataReader * > readers_
 
FlexArray< DataWriter * > writers_
 
const Modulemodule_
 
Timespan pauseTime_
 
bool meteringEnabled_
 If true, metering is enabled. More...
 
DataWriterdurationOfLastRunWriter_
 Writer for durationOfLastRun. More...
 
DataWritervoltageWriter_
 
DataWriteravgVoltageWriter_
 
DataWritercurrentWriter_
 
DataWriteravgCurrentWriter_
 
bool persistentPause_
 True if data is persistent while component is paused. More...
 

Detailed Description

Provides software interface to the Battery Pack Controller.

BPC1.h should only be included by BPC1.cpp Other classes should include BPC1IF.h

Constructor & Destructor Documentation

BPC1::~BPC1 ( )
virtual

References Instance_.

BPC1::BPC1 ( const BPC1 old)
private

Member Function Documentation

void BPC1::calculateTotals ( void  )
private
void BPC1::checkBatt ( const float  capacity,
const float  voltage 
)
private
ConfigURI BPC1::getConfigURI ( ConfigOption  configOption) const
virtual

Should return [myNamespace]::SIMULATE_HARDWARE, or [myNamespace]::POWER, etc.

Reimplemented from Component.

References Component::CONFIG_POWER, Component::CONFIG_SIMULATE_HARDWARE, and ConfigURI::NO_CONFIG_URI.

bool BPC1::isDataRequested ( )
private

Referenced by paused(), and stopped().

bool BPC1::menusInitialized ( )
private

References UartStream::canReadUntil(), uartA_, and uartB_.

Referenced by pausing(), and starting().

Component::RunState BPC1::pause ( )
virtual

Pause for a short period (indicated by pauseTime)

Reimplemented from Component.

References debug_, Syslog::INFO, Component::logger_, Timestamp::Now(), Component::PAUSING, sendIBPSBreak(), Component::simulateHardware(), startTime_, and Logger::syslog().

Component::RunState BPC1::paused ( )
virtual

Should eventually follow a PAUSE request: should set continueTime.

Reimplemented from Component.

References debug_, Syslog::INFO, isDataRequested(), Component::logger_, Component::PAUSED, Component::RESUME, and Logger::syslog().

virtual RunState BPC1::resetting ( )
inlinevirtual

Might occur in case of Error.

Reimplemented from Component.

References stop().

Component::RunState BPC1::resuming ( )
virtual

Might follow a PAUSE...RESUME sequence.

Reimplemented from Component.

References debug_, Syslog::INFO, Component::logger_, Component::STOP, and Logger::syslog().

void BPC1::run ( void  )
virtual

The actual "payload" of the component.

Reimplemented from Component.

void BPC1::sendIBPSBreak ( void  )
private

References uartA_, and uartB_.

Referenced by pause(), pausing(), resume(), start(), and stop().

void BPC1::setVoltagesNull ( void  )
private
Component::RunState BPC1::stop ( )
virtual

Initial state – can be later followed by START.

Reimplemented from Component.

References debug_, Syslog::INFO, Component::logger_, sendIBPSBreak(), Component::STOPPING, Logger::syslog(), and uninitialize().

Referenced by resetting().

Component::RunState BPC1::stopping ( )
virtual

Might follow a STOP request.

Reimplemented from Component.

References debug_, Syslog::INFO, Component::logger_, Component::simulateHardware(), Component::STOPPED, and Logger::syslog().

void BPC1::uninitialize ( void  )
virtual

Provide a space for uninitialization.

Reimplemented from Component.

References UartStream::close(), debug_, Syslog::INFO, Component::logger_, Component::simulateHardware(), Logger::syslog(), uartA_, and uartB_.

Referenced by stop().

int BPC1::validData ( int  dataToCheck,
int &  msgOffset 
)
private
bool BPC1::voltagesPopulated ( )
private

References battSticks_, NUMBATTSA, and NUMBATTSB.

Referenced by runnable().

Member Data Documentation

bool BPC1::aParsed_
private

Referenced by runnable().

float BPC1::batteryCapacityThreshold_
private

Referenced by checkBatt(), and readConfig().

ConfigReader* BPC1::batteryCapacityThresholdCfgReader_
private

Referenced by BPC1(), and readConfig().

UniversalDataWriter* BPC1::batteryChargeWriter_
private

Referenced by BPC1(), runnable(), and setWritersInvalid().

UniversalDataWriter* BPC1::batteryDischargingWriter_
private

Referenced by BPC1(), and setWritersInvalid().

UniversalDataWriter* BPC1::batteryFullyChargedWriter_
private

Referenced by BPC1(), and setWritersInvalid().

float BPC1::batteryVoltageThreshold_
private

Referenced by checkBatt(), and readConfig().

ConfigReader* BPC1::batteryVoltageThresholdCfgReader_
private

Referenced by BPC1(), and readConfig().

UniversalDataWriter* BPC1::batteryVoltageWriter_
private

Referenced by BPC1(), runnable(), and setWritersInvalid().

Timespan BPC1::battTimeout_
private

Referenced by pausing(), runnable(), and starting().

bool BPC1::bParsed_
private

Referenced by runnable().

bool BPC1::capacityFailed_
private

Referenced by checkBatt().

char BPC1::deviceResponseA_[2120]
private

Referenced by parseWriteDataA(), and start().

char BPC1::deviceResponseB_[2120]
private
BPC1 * BPC1::Instance_
staticprivate

Pointer to the singleton-like instance of this component.

Referenced by BPC1(), and ~BPC1().

Timestamp BPC1::muxTime_
private

Referenced by runnable(), and starting().

Timespan BPC1::muxTimeout_
private

Referenced by runnable().

bool BPC1::ok_
private

Referenced by start().

Timespan BPC1::poTimeout_
private
Timestamp BPC1::startTime_
private
Timestamp BPC1::startTimeA_
private
Timestamp BPC1::startTimeB_
private
float BPC1::totalCapacity_
private

Referenced by calculateTotals(), and runnable().

float BPC1::totalCapacityA_
private
float BPC1::totalCapacityB_
private
float BPC1::totalVoltage_
private

Referenced by calculateTotals(), and runnable().

float BPC1::totalVoltageA_
private
float BPC1::totalVoltageB_
private
bool BPC1::voltageFailed_
private

Referenced by checkBatt().


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