public ATCDataPacketBuilder SetFlightSimulatorKind(WswModelKind kind) { byte[] kindBytes = new byte[4]; byte[] numBytes = new byte[6]; switch (kind) { case WswModelKind.EH101: kindBytes = System.Text.Encoding.ASCII.GetBytes("EH10"); numBytes = System.Text.Encoding.ASCII.GetBytes("EH1001"); break; case WswModelKind.CJ6: kindBytes = System.Text.Encoding.ASCII.GetBytes("CJ6" + '\0'); numBytes = System.Text.Encoding.ASCII.GetBytes("CJ601" + '\0'); break; case WswModelKind.F18: kindBytes = System.Text.Encoding.ASCII.GetBytes("F18H"); numBytes = System.Text.Encoding.ASCII.GetBytes("F18H01"); break; default: break; } _packet.FlightKind = Convert.ToUInt32((kindBytes[3] << 24) + (kindBytes[2] << 16) + (kindBytes[1] << 8) + kindBytes[0]); _packet.FlightRegisterNumber1 = Convert.ToUInt16((numBytes[1] << 8) + numBytes[0]); _packet.FlightRegisterNumber2 = Convert.ToUInt16((numBytes[3] << 8) + numBytes[2]); _packet.FlightRegisterNumber3 = Convert.ToUInt16((numBytes[5] << 8) + numBytes[4]); return(this); }
public static WswModelKind GetFlightKindFromIp(string ip) { if (kind != WswModelKind.All) { return(kind); } var config = JsonFileConfig.Instance; if (ip.StartsWith(config.ComConfig.Ip720Platform)) { kind = WswModelKind.F18; return(kind); } else if (ip.StartsWith(config.ComConfig.Ip720Platform2)) { kind = WswModelKind.CJ6; return(kind); } else if (ip.StartsWith(config.ComConfig.IpWswUdpServer)) { kind = WswModelKind.EH101; return(kind); } return(WswModelKind.All); }