diff --git a/csharp/InnovEnergy.sln b/csharp/InnovEnergy.sln index 71a6f912e..cef15dbc8 100644 --- a/csharp/InnovEnergy.sln +++ b/csharp/InnovEnergy.sln @@ -91,6 +91,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Backend", "app\Backend\Back EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FossilTui", "app\FossilTui\FossilTui.csproj", "{C40264BB-C834-4C48-9B3F-6BEF8F37C0ED}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Units", "lib\Units\Units.csproj", "{C04FB6DA-23C6-46BB-9B21-8F4FBA32FFF7}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -240,6 +242,10 @@ Global {C40264BB-C834-4C48-9B3F-6BEF8F37C0ED}.Debug|Any CPU.Build.0 = Debug|Any CPU {C40264BB-C834-4C48-9B3F-6BEF8F37C0ED}.Release|Any CPU.ActiveCfg = Release|Any CPU {C40264BB-C834-4C48-9B3F-6BEF8F37C0ED}.Release|Any CPU.Build.0 = Release|Any CPU + {C04FB6DA-23C6-46BB-9B21-8F4FBA32FFF7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {C04FB6DA-23C6-46BB-9B21-8F4FBA32FFF7}.Debug|Any CPU.Build.0 = Debug|Any CPU + {C04FB6DA-23C6-46BB-9B21-8F4FBA32FFF7}.Release|Any CPU.ActiveCfg = Release|Any CPU + {C04FB6DA-23C6-46BB-9B21-8F4FBA32FFF7}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(NestedProjects) = preSolution {CF4834CB-91B7-4172-AC13-ECDA8613CD17} = {145597B4-3E30-45E6-9F72-4DD43194539A} @@ -284,5 +290,6 @@ Global {A56F58C2-B265-435B-A985-53B4D6F49B1A} = {145597B4-3E30-45E6-9F72-4DD43194539A} {C40264BB-C834-4C48-9B3F-6BEF8F37C0ED} = {145597B4-3E30-45E6-9F72-4DD43194539A} {F162D50B-4B99-496D-8354-1FB68E992B2D} = {D846B46B-46FF-4EF7-9B9D-DDBEF9533C56} + {C04FB6DA-23C6-46BB-9B21-8F4FBA32FFF7} = {AD5B98A8-AB7F-4DA2-B66D-5B4E63E7D854} EndGlobalSection EndGlobal diff --git a/csharp/app/API/obj/Debug/net6.0/API.csproj.AssemblyReference.cache b/csharp/app/API/obj/Debug/net6.0/API.csproj.AssemblyReference.cache deleted file mode 100644 index 542003cc5..000000000 Binary files a/csharp/app/API/obj/Debug/net6.0/API.csproj.AssemblyReference.cache and /dev/null differ diff --git a/csharp/app/BmsTunnel/obj/Debug/net6.0/BmsTunnel.csproj.CoreCompileInputs.cache b/csharp/app/BmsTunnel/obj/Debug/net6.0/BmsTunnel.csproj.CoreCompileInputs.cache deleted file mode 100644 index 9eaf27f23..000000000 --- a/csharp/app/BmsTunnel/obj/Debug/net6.0/BmsTunnel.csproj.CoreCompileInputs.cache +++ /dev/null @@ -1 +0,0 @@ -36e3a7f5349a4b6ca48316c35ee500d6385e011f diff --git a/csharp/app/SaliMax/obj/Debug/net6.0/SaliMax.csproj.AssemblyReference.cache b/csharp/app/SaliMax/obj/Debug/net6.0/SaliMax.csproj.AssemblyReference.cache deleted file mode 100644 index 204fdef64..000000000 Binary files a/csharp/app/SaliMax/obj/Debug/net6.0/SaliMax.csproj.AssemblyReference.cache and /dev/null differ diff --git a/csharp/lib/Devices/AMPT/obj/Debug/net6.0/Ampt.csproj.AssemblyReference.cache b/csharp/lib/Devices/AMPT/obj/Debug/net6.0/Ampt.csproj.AssemblyReference.cache deleted file mode 100644 index 890d617e6..000000000 Binary files a/csharp/lib/Devices/AMPT/obj/Debug/net6.0/Ampt.csproj.AssemblyReference.cache and /dev/null differ diff --git a/csharp/lib/Devices/Adam6060/obj/Debug/net6.0/Adam6060.csproj.AssemblyReference.cache b/csharp/lib/Devices/Adam6060/obj/Debug/net6.0/Adam6060.csproj.AssemblyReference.cache deleted file mode 100644 index 204fdef64..000000000 Binary files a/csharp/lib/Devices/Adam6060/obj/Debug/net6.0/Adam6060.csproj.AssemblyReference.cache and /dev/null differ diff --git a/csharp/lib/Devices/Trumpf/TruConvert/obj/Debug/net6.0/TruConvert.csproj.AssemblyReference.cache b/csharp/lib/Devices/Trumpf/TruConvert/obj/Debug/net6.0/TruConvert.csproj.AssemblyReference.cache deleted file mode 100644 index d1e398d3c..000000000 Binary files a/csharp/lib/Devices/Trumpf/TruConvert/obj/Debug/net6.0/TruConvert.csproj.AssemblyReference.cache and /dev/null differ diff --git a/csharp/lib/Protocols/DBus/obj/Debug/net6.0/DBus.csproj.AssemblyReference.cache b/csharp/lib/Protocols/DBus/obj/Debug/net6.0/DBus.csproj.AssemblyReference.cache deleted file mode 100644 index 204fdef64..000000000 Binary files a/csharp/lib/Protocols/DBus/obj/Debug/net6.0/DBus.csproj.AssemblyReference.cache and /dev/null differ diff --git a/csharp/lib/Protocols/Modbus/obj/Debug/net6.0/Modbus.csproj.AssemblyReference.cache b/csharp/lib/Protocols/Modbus/obj/Debug/net6.0/Modbus.csproj.AssemblyReference.cache deleted file mode 100644 index 204fdef64..000000000 Binary files a/csharp/lib/Protocols/Modbus/obj/Debug/net6.0/Modbus.csproj.AssemblyReference.cache and /dev/null differ diff --git a/csharp/lib/SysTools/obj/Debug/net6.0/SysTools.csproj.AssemblyReference.cache b/csharp/lib/SysTools/obj/Debug/net6.0/SysTools.csproj.AssemblyReference.cache deleted file mode 100644 index d1e398d3c..000000000 Binary files a/csharp/lib/SysTools/obj/Debug/net6.0/SysTools.csproj.AssemblyReference.cache and /dev/null differ diff --git a/csharp/lib/Time/obj/Debug/net6.0/Time.csproj.AssemblyReference.cache b/csharp/lib/Time/obj/Debug/net6.0/Time.csproj.AssemblyReference.cache deleted file mode 100644 index 204fdef64..000000000 Binary files a/csharp/lib/Time/obj/Debug/net6.0/Time.csproj.AssemblyReference.cache and /dev/null differ diff --git a/csharp/lib/Units/Current.cs b/csharp/lib/Units/Current.cs new file mode 100644 index 000000000..e313271b8 --- /dev/null +++ b/csharp/lib/Units/Current.cs @@ -0,0 +1,34 @@ +namespace InnovEnergy.Units; + +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); + + + +} \ No newline at end of file diff --git a/csharp/lib/Units/Power.cs b/csharp/lib/Units/Power.cs new file mode 100644 index 000000000..d6e88bccc --- /dev/null +++ b/csharp/lib/Units/Power.cs @@ -0,0 +1,31 @@ +namespace InnovEnergy.Units; + +public readonly struct Power +{ + public static String Unit => "W"; + public static String Symbol => "P"; + + public Decimal Value { get; } + + public Power(Decimal value) => Value = value; + + public override String ToString() => Value + Unit; + + + // parallel + public static Power operator |(Power left, Power right) => new Power(left.Value + right.Value); + // series + public static Power operator +(Power left, Power right) => new Power(left.Value + right.Value); + + // scalar multiplication + public static Power operator *(Decimal scalar, Power power ) => new Power(scalar * power.Value); + public static Power operator *(Power power , Decimal scalar) => new Power(scalar * power.Value); + public static Power operator *(Int32 scalar, Power power ) => new Power(scalar * power.Value); + public static Power operator *(Power power , Int32 scalar) => new Power(scalar * power.Value); + public static Power operator /(Power power , Decimal scalar) => new Power(power.Value / scalar); + public static Power operator /(Power power , Int32 scalar) => new Power(power.Value / scalar); + + // P=UI + public static Voltage operator /(Power power, Current current) => new Voltage(power.Value / current.Value); + public static Current operator /(Power power, Voltage voltage) => new Current(power.Value / voltage.Value); +} \ No newline at end of file diff --git a/csharp/lib/Units/Resistance.cs b/csharp/lib/Units/Resistance.cs new file mode 100644 index 000000000..ae551e019 --- /dev/null +++ b/csharp/lib/Units/Resistance.cs @@ -0,0 +1,35 @@ +namespace InnovEnergy.Units; + +public readonly struct Resistance +{ + public static String Unit => "Ω"; + public static String Symbol => "R"; + + public Decimal Value { get; } + + public Resistance(Decimal value) => Value = value; + + public override String ToString() => Value + Unit; + + // series + public static Resistance operator +(Resistance left, Resistance right) => new Resistance(left.Value + right.Value); + // parallel + public static Resistance operator |(Resistance left, Resistance right) => new Resistance(1m / (1m / left.Value + 1m / right.Value)); + + // scalar multiplication + public static Resistance operator *(Decimal scalar , Resistance resistance) => new Resistance(scalar * resistance.Value); + public static Resistance operator *(Resistance resistance, Decimal scalar ) => new Resistance(scalar * resistance.Value); + public static Resistance operator *(Int32 scalar , Resistance resistance) => new Resistance(scalar * resistance.Value); + public static Resistance operator *(Resistance resistance, Int32 scalar ) => new Resistance(scalar * resistance.Value); + public static Resistance operator /(Resistance resistance, Decimal scalar ) => new Resistance(resistance.Value / scalar); + public static Resistance operator /(Resistance resistance, Int32 scalar ) => new Resistance(resistance.Value / scalar); + + + // U=RI + public static Voltage operator *(Resistance resistance, Current current) => new Voltage(resistance.Value* current.Value); + + + + // public static Voltage operator /(Power power, Current current) => new Voltage(power.Value / current.Value); + // public static Current operator /(Power power, Voltage voltage) => new Current(power.Value / voltage.Value); +} \ No newline at end of file diff --git a/csharp/lib/Units/Units.csproj b/csharp/lib/Units/Units.csproj new file mode 100644 index 000000000..090825d42 --- /dev/null +++ b/csharp/lib/Units/Units.csproj @@ -0,0 +1,9 @@ + + + + + Library + InnovEnergy.Units + + + diff --git a/csharp/lib/Units/Voltage.cs b/csharp/lib/Units/Voltage.cs new file mode 100644 index 000000000..ae39f9a0d --- /dev/null +++ b/csharp/lib/Units/Voltage.cs @@ -0,0 +1,32 @@ +namespace InnovEnergy.Units; + +public readonly struct Voltage +{ + public static String Unit => "V"; + public static String Symbol => "U"; + + public Decimal Value { get; } + + public Voltage(Decimal value) => Value = value; + + public override String ToString() => Value + Unit; + + + // series + public static Voltage operator +(Voltage left, Voltage right) => new Voltage(left.Value + right.Value); + + public static Voltage operator *(Decimal scalar , Voltage voltage) => new Voltage(scalar * voltage.Value); + public static Voltage operator *(Voltage voltage, Decimal scalar) => new Voltage(scalar * voltage.Value); + public static Voltage operator *(Int32 scalar , Voltage voltage) => new Voltage(scalar * voltage.Value); + public static Voltage operator *(Voltage voltage, Int32 scalar) => new Voltage(scalar * voltage.Value); + + public static Voltage operator /(Voltage voltage, Decimal scalar) => new Voltage(voltage.Value / scalar); + public static Voltage operator /(Voltage voltage, Int32 scalar) => new Voltage(voltage.Value / scalar); + + + // U=RI + public static Current operator /(Voltage voltage, Resistance resistance) => new Current(voltage.Value / resistance.Value); + + // P=UI + public static Power operator *(Voltage voltage, Current current) => new Power(current.Value * voltage.Value); +} \ No newline at end of file diff --git a/csharp/lib/Victron/VeDBus/obj/Debug/net6.0/VeDBus.csproj.AssemblyReference.cache b/csharp/lib/Victron/VeDBus/obj/Debug/net6.0/VeDBus.csproj.AssemblyReference.cache deleted file mode 100644 index 204fdef64..000000000 Binary files a/csharp/lib/Victron/VeDBus/obj/Debug/net6.0/VeDBus.csproj.AssemblyReference.cache and /dev/null differ diff --git a/csharp/lib/Victron/VictronVRM/obj/Debug/net6.0/VictronVRM.csproj.AssemblyReference.cache b/csharp/lib/Victron/VictronVRM/obj/Debug/net6.0/VictronVRM.csproj.AssemblyReference.cache deleted file mode 100644 index 341d34208..000000000 Binary files a/csharp/lib/Victron/VictronVRM/obj/Debug/net6.0/VictronVRM.csproj.AssemblyReference.cache and /dev/null differ