Table of Contents

Struct PowerPlan

Namespace
Pamoja.Power
Assembly
Pamoja.Power.dll

The work intervals a node uses in each mode, and where they change.

public readonly record struct PowerPlan : IEquatable<PowerPlan>
Implements
Inherited Members

Remarks

A node on a battery and a panel has to decide how often to do anything at all. A plan stretches the interval between work as the charge falls, so a node that would otherwise go dark in a cloudy week keeps reporting, less often.

Constructors

PowerPlan(ulong, ulong, ulong, float, float)

The work intervals a node uses in each mode, and where they change.

public PowerPlan(ulong ActiveUs, ulong SaverUs, ulong CriticalUs, float SaverBelow, float CriticalBelow)

Parameters

ActiveUs ulong

The interval at a healthy charge, in microseconds.

SaverUs ulong

The longer interval used to conserve, in microseconds.

CriticalUs ulong

The longest interval, in microseconds.

SaverBelow float

Enter Saver below this charge.

CriticalBelow float

Enter Critical below this charge.

Remarks

A node on a battery and a panel has to decide how often to do anything at all. A plan stretches the interval between work as the charge falls, so a node that would otherwise go dark in a cloudy week keeps reporting, less often.

Properties

ActiveUs

The interval at a healthy charge, in microseconds.

public ulong ActiveUs { get; init; }

Property Value

ulong

CriticalBelow

Enter Critical below this charge.

public float CriticalBelow { get; init; }

Property Value

float

CriticalUs

The longest interval, in microseconds.

public ulong CriticalUs { get; init; }

Property Value

ulong

SaverBelow

Enter Saver below this charge.

public float SaverBelow { get; init; }

Property Value

float

SaverUs

The longer interval used to conserve, in microseconds.

public ulong SaverUs { get; init; }

Property Value

ulong

Methods

Create(ulong, ulong, ulong)

Creates a plan from its three work intervals, with the defaults.

public static PowerPlan Create(ulong activeUs, ulong saverUs, ulong criticalUs)

Parameters

activeUs ulong

The interval at a healthy charge, in microseconds.

saverUs ulong

The longer interval used to conserve, in microseconds.

criticalUs ulong

The longest interval, in microseconds.

Returns

PowerPlan

The power plan.

Remarks

The defaults enter Saver below 50% charge and Critical below 20%.

IntervalForUs(PowerMode)

Returns the work interval for a mode, in microseconds.

public ulong IntervalForUs(PowerMode mode)

Parameters

mode PowerMode

The mode to look up.

Returns

ulong

The interval in microseconds.

IntervalUs(float)

Returns the work interval at a state of charge, in microseconds.

public ulong IntervalUs(float soc)

Parameters

soc float

The battery state of charge, from 0 through 1.

Returns

ulong

The interval in microseconds.

Mode(float)

Returns the mode this plan calls for at a state of charge.

public PowerMode Mode(float soc)

Parameters

soc float

The battery state of charge, from 0 through 1.

Returns

PowerMode

The mode the node should run in.

ModeWhileCharging(float, bool)

Returns the mode, eased one step toward full duty while charging.

public PowerMode ModeWhileCharging(float soc, bool charging)

Parameters

soc float

The battery state of charge, from 0 through 1.

charging bool

Whether the node is taking charge.

Returns

PowerMode

The mode the node should run in.

WithThresholds(float, float)

Returns a plan with the state-of-charge thresholds moved.

public PowerPlan WithThresholds(float saverBelow, float criticalBelow)

Parameters

saverBelow float

Enter saver mode below this charge.

criticalBelow float

Enter critical mode below this charge.

Returns

PowerPlan

The adjusted plan.