Created
December 20, 2011 12:04
-
-
Save clausjoergensen/1501356 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public int TestTimeWithSampling | |
{ | |
get | |
{ | |
return CalculateTestTimeWithSampling(); | |
} | |
} | |
private int CalculateTestTimeWithSampling() | |
{ | |
if (GeneratorSetupTime.HasValue == false) | |
{ | |
return int.MaxValue; | |
} | |
if (RequestedTestTime == 0) | |
{ | |
var power = (Voltage1 * Current1) + (Voltage2 * Current2) + (Voltage3 * Current3); | |
if (power == 0.0) | |
{ | |
return int.MaxValue; | |
} | |
var angle = Math.Cos((PhaseShift - EnergyTypeToAngle()) * Math.PI / 180.0); | |
if (angle == 0.0) | |
{ | |
return int.MaxValue; | |
} | |
checked | |
{ | |
double testTime = GeneratorSetupTime.Value + (Energy / power * 3600000 / angle); | |
if (testTime > int.MaxValue) | |
return int.MaxValue; | |
else | |
return (int)testTime; | |
} | |
} | |
return GeneratorSetupTime.Value + RequestedTestTime; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment