Struct PowerPlan
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
ActiveUsulongThe interval at a healthy charge, in microseconds.
SaverUsulongThe longer interval used to conserve, in microseconds.
CriticalUsulongThe longest interval, in microseconds.
SaverBelowfloatEnter Saver below this charge.
CriticalBelowfloatEnter 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
CriticalBelow
Enter Critical below this charge.
public float CriticalBelow { get; init; }
Property Value
CriticalUs
The longest interval, in microseconds.
public ulong CriticalUs { get; init; }
Property Value
SaverBelow
Enter Saver below this charge.
public float SaverBelow { get; init; }
Property Value
SaverUs
The longer interval used to conserve, in microseconds.
public ulong SaverUs { get; init; }
Property Value
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
activeUsulongThe interval at a healthy charge, in microseconds.
saverUsulongThe longer interval used to conserve, in microseconds.
criticalUsulongThe longest interval, in microseconds.
Returns
- PowerPlan
The power plan.
Remarks
IntervalForUs(PowerMode)
Returns the work interval for a mode, in microseconds.
public ulong IntervalForUs(PowerMode mode)
Parameters
modePowerModeThe 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
socfloatThe 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
socfloatThe 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
socfloatThe battery state of charge, from 0 through 1.
chargingboolWhether 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
saverBelowfloatEnter saver mode below this charge.
criticalBelowfloatEnter critical mode below this charge.
Returns
- PowerPlan
The adjusted plan.