Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: ElectricAcDc #1312

Closed
wants to merge 8 commits into from
Closed

WIP: ElectricAcDc #1312

wants to merge 8 commits into from

Conversation

McNeight
Copy link
Contributor

@McNeight McNeight commented Sep 4, 2023

This is a rough cut at the reference type suggested in #1296. Primarily for review and to see if I'm on the right track or not.

# Conflicts:
#	Common/GeneratedCode/Quantities/Mass.Common.g.cs
#	Common/GeneratedCode/Quantities/MassMomentOfInertia.Common.g.cs
#	Common/UnitDefinitions/Mass.json
#	Common/UnitDefinitions/MassMomentOfInertia.json
#	UnitsNet/GeneratedCode/Extensions/Number/NumberToMassExtensions.g.cs
#	UnitsNet/GeneratedCode/Extensions/Number/NumberToMassMomentOfInertiaExtensions.g.cs
#	UnitsNet/GeneratedCode/Quantities/Mass.NetFramework.g.cs
#	UnitsNet/GeneratedCode/Quantities/MassMomentOfInertia.NetFramework.g.cs
# Conflicts:
#	UnitsNet.Tests/CustomCode/ParseTests.cs
Initial attempt at removing ElectricPotentialAc and ElectricPotentialDc
and replacing them with a Reference type for ElectricPotential.
Reference type initially implemented for ElectricCurrent.
Copy link
Owner

@angularsen angularsen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would helpful if you could summarize the changes and what the changes aim to accomplish in the PR description.

On the surface, this looks useful enough.
However, I don't know this domain well enough to give any meaningful comments on the design of the wrapper types. It's just one those things that someone who actually needs it will have to start using and massage until it solves several use cases.

It is important for me to only add something to UnitsNet that will actually be used and solves a need that many UnitsNet consumers will benefit from.

So to be very direct 😄
Do you plan to use this yourself?
Will it solve a real need for you?
Are there any known unknowns, things to still explore or figure out in the design or use cases to test the design against?
Do you know other developers working in this domain that we could involve in this discussion?

It doesn't have to be perfect on the first go, but it is helpful to think along these lines from the start.

}

/// <summary>
/// Converts <see cref="UnitsNet.Pressure.Value" /> to <see cref="double" /> at <see cref="ElectricCurrentFlowReference" />
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some old references to pressure here and there, but you can fix these things later when the design is more complete.

{
if (Current.Value < 0)
{
throw new ArgumentOutOfRangeException(nameof(Current), "Direct or RMS current cannot be less than zero.");
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we enforce this in the constructor instead, then it will fail earlier and it seems like none of the reference types allow negative current value.

/// </summary>
/// <param name="reference">The <see cref="ElectricCurrentFlowReference" /> to convert <see cref="ElectricCurrentFlow" /> to.</param>
/// <returns>The value of pressure at <see cref="ElectricCurrentFlowReference" /></returns>
private double AsBaseNumericType(ElectricCurrentFlowReference reference)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know you just based it on the existing PressureReference type, but the name AsBaseNumericType does not tell me much.

To be more consistent with IQuantity, maybe wrapper types could follow this:

  • double As(reference), similar to double IQuantity.As(unit)
  • ElectricCurrentFlow ToReference(reference), similar to IQuantity.ToUnit(unit).
  • ToReference(reference) also allows you to do double current = myCurrentFlow.ToReference(myReference).Current.Value similar to double value = myIQuantity.ToUnit(myUnit).Value;

The only minor gotcha is Power is using decimal as its numeric value type, but we already intend to change this to double in #1195.

@@ -1,20 +0,0 @@
{
"Name": "ElectricPotentialAc",
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a heads up that we can't delete these, we have to mark them obsolete in JSON with ObsoleteText on the quantity for example just below Name on line 3, then add to #1200 , then remove them in next major version.

The obsolete text should describe what they should use instead for AC and DC operations.
This can wait until the design is more complete of course.

@angularsen
Copy link
Owner

If I understand correctly, we concluded to not continue with this PR?

#1296 (comment)

@angularsen angularsen closed this Jul 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants