23 lines
1.0 KiB
C#
23 lines
1.0 KiB
C#
using InnovEnergy.Lib.Time.Unix;
|
|
using InnovEnergy.Lib.Units.Generator;
|
|
|
|
namespace InnovEnergy.Lib.Units;
|
|
|
|
[Generate]
|
|
public readonly partial struct ActivePower
|
|
{
|
|
public static String Unit => "W";
|
|
public static String Symbol => "P";
|
|
|
|
public ActivePower(Double value) => Value = value;
|
|
|
|
// P=UI
|
|
public static Voltage operator /(ActivePower power, Current current) => new Voltage(power.Value / current.Value);
|
|
public static Current operator /(ActivePower power, Voltage voltage) => new Current(power.Value / voltage.Value);
|
|
|
|
public static Energy operator *(ActivePower power, TimeSpan timeSpan) => power.Value / 1000 * timeSpan.TotalHours;
|
|
public static Energy operator *(TimeSpan timeSpan, ActivePower power) => power.Value / 1000 * timeSpan.TotalHours;
|
|
|
|
public static Energy operator *(ActivePower power, UnixTimeSpan timeSpan) => power.Value * timeSpan.Ticks / 3_600_000;
|
|
public static Energy operator *(UnixTimeSpan timeSpan, ActivePower power) => power.Value * timeSpan.Ticks / 3_600_000;
|
|
} |