Innovenergy_trunk/csharp/Lib/StatusData/Current.cs

32 lines
1.4 KiB
C#
Raw Normal View History

namespace InnovEnergy.Lib.StatusData;
2023-02-23 06:55:15 +00:00
public readonly struct Current
{
public static String Unit => "A";
public static String Symbol => "I";
public Decimal Value { get; }
public Current(Decimal value) => Value = value;
public override String ToString() => Value + Unit;
// parallel
public static Current operator |(Current left, Current right) => new Current(left.Value + right.Value);
// scalar multiplication
public static Current operator *(Decimal scalar , Current current) => new Current(scalar * current.Value);
public static Current operator *(Current current, Decimal scalar) => new Current(scalar * current.Value);
public static Current operator *(Int32 scalar , Current current) => new Current(scalar * current.Value);
public static Current operator *(Current current, Int32 scalar) => new Current(scalar * current.Value);
public static Current operator /(Current current, Decimal scalar) => new Current(current.Value / scalar);
public static Current operator /(Current current, Int32 scalar) => new Current(current.Value / scalar);
// P=UI
public static Power operator *(Current current, Voltage voltage) => new Power(current.Value * voltage.Value);
// U=RI
public static Voltage operator *(Current current, Resistance resistance) => new Voltage(resistance.Value* current.Value);
}