Module: powerNodeBase

Executive Summary

The powerNodeBase class is used generate a standard interface and list of features for modules that consume or provide power. Specifically, each PowerNodeBase:

  1. Writes out a powerNodeUsageSimMsg describing its power consumption at each sim update

  2. Can be switched on or off using an optional powerNodeStatusIntMsg

  3. Can also be switched on or off using the public variable powerStatus

Core functionality is wrapped in the evaluatePowerModel() protected virtual void method, which is assumed to compute power usage based on a module specific mathematical model.

Protected methods prepended with custom are intended for module developers to override with additional, module-specific functionality.

For more information on how to set up and use classes derived from this module, see the simple power system example: scenarioPowerDemo.

Module Assumptions and Limitations

The power draw or supply for this module is assumed to be constant.

Message Connection Descriptions

The following table lists all the module input and output messages. The module msg variable name is set by the user from python. The msg type contains a link to the message structure definition, while the description provides information on what this message is used for.

Module I/O Messages

Msg Variable Name

Msg Type

Description

nodePowerOutMsgName

powerNodeUsageSimMsg

Writes out the net power used/generated by a PowerNodeBase instance.

nodeStatusInMsgName

powerNodeStatusIntMsg

(optional). If powerStatus is 0, the node is disabled; other values indicate various power modes depending on the module.

User Guide

  • To specify the modules simulated power draw (neg. value) or generation (pos. value), set the variable nodePowerOut to the desired value in units of Watts.

  • Specify the module output message name using the variable nodePowerOutMsgName

  • The module power status can be set using the public variable powerStatus. The default value is 1 meaning the device is on. If set to 0 the device is off and the power value returns to 0.

  • The module power status can be set also through an optional input message. By specifying a non-empty string from nodeStatusInMsgName the status message is read in at every time step.


class PowerNodeBase : public SysModel
#include <powerNodeBase.h>

power node base class

Public Functions

PowerNodeBase()

This method initializes the messaging parameters to either empty strings for message names or -1 for message IDs.

Return

void

~PowerNodeBase()

Destructor.

Return

void

void SelfInit()

SelfInit creates a PowerNodeUsageSimMsg using the provided message output name.

Return

void

void CrossInit()

This method subscribes to anything that would tell the power node to turn on/off.

Return

void

void Reset(uint64_t CurrentSimNanos)

This method is used to reset the module. In general, no functionality must be reset.

Return

void

void computePowerStatus(double currentTime)

Core compute operation that implements switching logic and computes module-wise power consumption.

void UpdateState(uint64_t CurrentSimNanos)

Provides logic for running the read / compute / write operation that is the module’s function.

Parameters
  • CurrentSimNanos: The current simulation time in nanoseconds

Public Members

std::string nodePowerOutMsgName

Message name for the node’s output message.

std::string nodeStatusInMsgName

String for the message name that tells the node it’s status.

double nodePowerOut

[W] Power provided (+) or consumed (-).

uint64_t powerStatus

Device power mode; by default, 0 is off and 1 is on. Additional modes can fill other slots.

BSKLogger bskLogger

BSK Logging

Protected Functions

void writeMessages(uint64_t CurrentClock)

This method writes out a message.

Return

void

bool readMessages()

This method is used to read incoming power status messages.

Return

void

void evaluatePowerModel(PowerNodeUsageSimMsg *powerUsageMsg) = 0

Virtual void method used to compute module-wise power usage/generation.

void customSelfInit()

Custom output input reading method. This allows a child class to add additional functionality.

Custom SelfInit() method. This allows a child class to add additional functionality to the SelfInit() method

Return

void

void customCrossInit()

Custom subscription method, similar to customSelfInit.

Custom CrossInit() method. This allows a child class to add additional functionality to the CrossInit() method

Return

void

void customReset(uint64_t CurrentClock)

Custom Reset method, similar to customSelfInit.

Custom Reset() method. This allows a child class to add additional functionality to the Reset() method

Return

void

void customWriteMessages(uint64_t CurrentClock)

custom Write method, similar to customSelfInit.

custom Write method, similar to customSelfInit.

Return

void

bool customReadMessages()

Custom read method, similar to customSelfInit; returns true by default.

Custom read method, similar to customSelfInit; returns true by default.

Return

void

Protected Attributes

int64_t nodePowerOutMsgId

class variable

int64_t nodeStatusInMsgId

class variable

PowerNodeUsageSimMsg nodePowerMsg

class variable

DeviceStatusIntMsg nodeStatusMsg

class variable

double currentPowerConsumption

class variable

double previousTime

Previous time used for integration.

Private Members

uint64_t outputBufferCount