Innovenergy_trunk/csharp/Lib/Units/DcPower.cs

22 lines
988 B
C#

using InnovEnergy.Lib.SrcGen.Attributes;
using InnovEnergy.Lib.Time.Unix;
namespace InnovEnergy.Lib.Units;
[Generate<Operators>][Generate<Sum>]
public readonly partial struct DcPower
{
public static String Unit => "W";
public static String Symbol => "P";
// P=UI
public static Voltage operator /(DcPower power, Current current) => new Voltage(power.Value / current.Value);
public static Current operator /(DcPower power, Voltage voltage) => new Current(power.Value / voltage.Value);
public static Energy operator *(DcPower power, TimeSpan timeSpan) => power.Value / 1000 * timeSpan.TotalHours;
public static Energy operator *(TimeSpan timeSpan, DcPower power) => power.Value / 1000 * timeSpan.TotalHours;
public static Energy operator *(DcPower power, UnixTimeSpan timeSpan) => power.Value * timeSpan.Ticks / 3_600_000;
public static Energy operator *(UnixTimeSpan timeSpan, DcPower power) => power.Value * timeSpan.Ticks / 3_600_000;
}