public static void CalcLongNav(DateTime now) { if (TWA.IsValid() && BRG.IsValid() && DRIFT.IsValid() && NavPolar.IsLoaded) { PolarPoint p = NavPolar.GetTargetVMC(TWS.Average(Inst.BufTwoMin), TWD.Average(Inst.BufTwoMin), BRG.Val, DRIFT.Average(Inst.BufTwoMin), SET.Average(Inst.BufTwoMin)); TGTVMC.Val = p.SPD; TGTVMC.SetValid(now); TGTCTS.Val = TWD.Average(Inst.BufTwoMin) + p.TWA; TGTCTS.SetValid(now); } }
public static void CalcLongNav(DateTime now) { if (TWA.IsValid() && BRG.IsValid() && DRIFT.IsValid() && NavPolar.IsLoaded) { PolarPoint p = NavPolar.GetTargetVMC(TWS.Val, TWD.Val, BRG.Val, DRIFT.Val, SET.Val); TGTVMC.Val = p.SPD; TGTVMC.SetValid(now); TGTCTS.Val = TWD.Val + p.TWA; TGTCTS.SetValid(now); } }
public void SendPerformanceNMEA() { // Build PTAK Sentence **************************************************************************************** if (PERF.IsValid()) { string message1, message2, message3, message5, message6; message1 = "PTAK,FFD1," + TGTSPD.Average(Inst.BufFiveSec).ToString("0.0"); message2 = "PTAK,FFD2," + TGTTWA.Average(Inst.BufFiveSec).ToString("0") + "@"; double pf = PERF.Average(Inst.BufFiveSec) * 100; message3 = "PTAK,FFD3," + pf.ToString("0"); //message5 = "PTAK,FFD5," + TGTVMC.Average(Inst.BufFiveSec).ToString("0.0"); message5 = "PTAK,FFD5," + NTWA.FormattedValue + "@"; message6 = "PTAK,FFD6," + TGTCTS.Average(Inst.BufFiveSec).ToString("0") + "@"; int checksum = 0; checksum = 0; foreach (char c in message1) { checksum ^= Convert.ToByte(c); } message1 = "$" + message1 + "*" + checksum.ToString("X2") + "\r\n"; checksum = 0; foreach (char c in message2) { checksum ^= Convert.ToByte(c); } message2 = "$" + message2 + "*" + checksum.ToString("X2") + "\r\n"; checksum = 0; foreach (char c in message3) { checksum ^= Convert.ToByte(c); } message3 = "$" + message3 + "*" + checksum.ToString("X2") + "\r\n"; checksum = 0; foreach (char c in message5) { checksum ^= Convert.ToByte(c); } message5 = "$" + message5 + "*" + checksum.ToString("X2") + "\r\n"; checksum = 0; foreach (char c in message6) { checksum ^= Convert.ToByte(c); } message6 = "$" + message6 + "*" + checksum.ToString("X2") + "\r\n"; if (Properties.Settings.Default.TacktickPerformanceSentence.OutPort1) { if (SerialPort1.IsOpen) { SerialPort1.WriteLine(message1); SerialPort1.WriteLine(message2); SerialPort1.WriteLine(message3); SerialPort1.WriteLine(message5); SerialPort1.WriteLine(message6); } } if (Properties.Settings.Default.TacktickPerformanceSentence.OutPort2) { if (SerialPort2.IsOpen) { SerialPort2.WriteLine(message1); SerialPort2.WriteLine(message2); SerialPort2.WriteLine(message3); SerialPort2.WriteLine(message5); SerialPort2.WriteLine(message6); } } if (Properties.Settings.Default.TacktickPerformanceSentence.OutPort3) { if (SerialPort3.IsOpen) { SerialPort3.WriteLine(message1); SerialPort3.WriteLine(message2); SerialPort3.WriteLine(message3); SerialPort3.WriteLine(message5); SerialPort3.WriteLine(message6); } } if (Properties.Settings.Default.TacktickPerformanceSentence.OutPort4) { if (SerialPort4.IsOpen) { SerialPort4.WriteLine(message1); SerialPort4.WriteLine(message2); SerialPort4.WriteLine(message3); SerialPort4.WriteLine(message5); SerialPort4.WriteLine(message6); } } } }