Skip to content

Commit 4fe688c

Browse files
committed
Finished adding in the preflight fuel calculations.
1 parent 542710d commit 4fe688c

File tree

2 files changed

+28
-7
lines changed

2 files changed

+28
-7
lines changed

myFlightInfo/SpeedTimeFuel.cs

+23-2
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ private void btn_calc_speed_time_fuel_Click(object sender, EventArgs e)
1818
try
1919
{
2020
if (SpeedDataCheck(txtbx_speed_wind_speed.Text, txtbx_speed_wind_direction.Text,
21-
txtbx_speed_course.Text, txtbx_speed_true_airspeed.Text))
21+
txtbx_speed_course.Text, txtbx_speed_true_airspeed.Text,
22+
txtbx_speed_wind_pre_flight_running.Text, txtbx_speed_wind_return_pre_flight_running.Text))
2223
{
2324
bool TimeFuelFlag = TimeFuelCheck(txtbx_speed_distance.Text, txtbx_speed_fuel_consumption.Text,
2425
txtbx_min_landing_fuel.Text, txtbx_speed_fuel_specific_gravity.Text);
@@ -178,7 +179,8 @@ private void btn_calc_speed_time_fuel_Click(object sender, EventArgs e)
178179
}
179180

180181

181-
private bool SpeedDataCheck(string myWindStrength, string myDirection, string myCourse, string myAirspeed)
182+
private bool SpeedDataCheck(string myWindStrength, string myDirection, string myCourse, string myAirspeed,
183+
string mySpeed_wind_pre_flight_running, string mySpeed_wind_return_pre_flight_running)
182184
{
183185
//catch for incomplete data
184186
if (myCourse == "")
@@ -270,6 +272,25 @@ private bool SpeedDataCheck(string myWindStrength, string myDirection, string my
270272
MessageBoxButtons.OK, MessageBoxIcon.Error);
271273
return false;
272274
}
275+
else if ((double.Parse(mySpeed_wind_pre_flight_running) < 0) || (double.Parse(mySpeed_wind_pre_flight_running) > 999))
276+
{
277+
MsgBox.Show("Check Pre-flight running Data is a valid number >0 and <999)", "Data out of scope",
278+
MessageBoxButtons.OK, MessageBoxIcon.Error);
279+
return false;
280+
}
281+
else if ((double.Parse(mySpeed_wind_return_pre_flight_running) < 0) || (double.Parse(mySpeed_wind_return_pre_flight_running) > 999))
282+
{
283+
MsgBox.Show("Check Return Pre-flight running Data is a valid number >0 and <999)", "Data out of scope",
284+
MessageBoxButtons.OK, MessageBoxIcon.Error);
285+
return false;
286+
}
287+
288+
if (double.Parse(myAirspeed) < double.Parse(myWindStrength))
289+
{
290+
MsgBox.Show("Flying into a wind that is faster than your airspeed means you fly backwards, not advisable, best stay at home.", "Stay at Home",
291+
MessageBoxButtons.OK, MessageBoxIcon.Error);
292+
return false;
293+
}
273294

274295
return true;
275296
}

myFlightInfo/crosswind/Speed_Time_Fuel.cs

+5-5
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,12 @@ The above equation is a simple vector addition of the true airspeed and wind spe
3737
* follows: ѱ = δ + ⍺
3838
*/
3939

40-
if (!Double.TryParse(myTrueAirSpeed.Text, out double TrueAirspeed))
41-
{
42-
return (999, 999, 999, 999, 999, 999, 999);
43-
}
40+
//if (!double.TryParse(myTrueAirSpeed.Text, out double TrueAirspeed))
41+
//{
42+
// return (999, 999, 999, 999, 999, 999, 999);
43+
//}
4444

45-
//double TrueAirspeed = Double.Parse(myTrueAirSpeed.Text);
45+
double TrueAirspeed = Double.Parse(myTrueAirSpeed.Text);
4646
double WindSpeed = Double.Parse(myWindSpeed.Text);
4747
double Course = Double.Parse(myCourse.Text);
4848
if (myReturnLeg) Course += 180;

0 commit comments

Comments
 (0)