public List <VOR> FillVORs() { List <VOR> list = new List <VOR>(); if (this.ConnectioString != null) { try { using (var conn = new SQLiteConnection(this.ConnectioString)) { conn.Open(); SQLiteCommand cmd = new SQLiteCommand(@"SELECT * FROM VOR", conn); SQLiteDataReader r = cmd.ExecuteReader(); while (r.Read()) { VOR vo = new VOR(); vo.vor_id = r.GetValue(0) != DBNull.Value ? r.GetInt64(0) : 0; vo.file_id = r.GetValue(1) != DBNull.Value ? r.GetInt64(1) : 0; vo.ident = r.GetValue(2) != DBNull.Value ? r.GetString(2) : ""; vo.name = r.GetValue(3) != DBNull.Value ? r.GetString(3) : ""; vo.region = r.GetValue(4) != DBNull.Value ? r.GetString(4) : ""; vo.airport_id = r.GetValue(5) != DBNull.Value ? r.GetInt64(5) : 0; vo.type = r.GetValue(6) != DBNull.Value ? r.GetString(6) : ""; vo.frequency = r.GetValue(7) != DBNull.Value ? r.GetInt64(7) : 0; vo.channel = r.GetValue(8) != DBNull.Value ? r.GetString(8) : ""; vo.range = r.GetValue(9) != DBNull.Value ? r.GetInt64(9) : 0; vo.mag_var = r.GetValue(10) != DBNull.Value ? r.GetDouble(10) : 0; vo.dme_only = r.GetValue(11) != DBNull.Value ? r.GetInt64(11) : 0; vo.dme_altitude = r.GetValue(12) != DBNull.Value ? r.GetInt64(12) : 0; vo.dme_lonx = r.GetValue(13) != DBNull.Value ? r.GetDouble(13) : 0; vo.dme_laty = r.GetValue(14) != DBNull.Value ? r.GetDouble(14) : 0; vo.altitude = r.GetValue(15) != DBNull.Value ? r.GetInt64(15) : 0; vo.lonx = r.GetValue(16) != DBNull.Value ? r.GetDouble(16) : 0; vo.laty = r.GetValue(17) != DBNull.Value ? r.GetDouble(17) : 0; list.Add(vo); } } } catch (Exception ex) { } } return(list); }
private void initialize() { if (cVOR == null) { cVOR = new VOR(); cVOR.iStation_ID_Characters = new int[3]; cVOR.iStation_ID_Characters[0] = 10; // K cVOR.iStation_ID_Characters[1] = 18; // S cVOR.iStation_ID_Characters[2] = 15; // P cVOR.buildStationID(); sStation_ID = cVOR.sStation_ID; } if (cNav_Master == null) { cNav_Master = new NAVmaster(); } }
public override void OnUpdate() { base.OnUpdate(); double dElectric_Draw = 10.0 * dW_to_EC; double elecAvail = part.RequestResource("ElectricCharge", dElectric_Draw) / dElectric_Draw; bool bPowered = (elecAvail > 0.90); dIndicated_Deviation = -10.0; sStation_ID = "---"; sTo_From = "####"; if (bPowered) { cNav_Select = null; foreach (Part p in vessel.Parts) { //string sMsg1 = "VI: " + p.name; //print(sMsg1); foreach (PartModule m in p.Modules) { //string sMsg2 = "VIm: " + m.name; //print(sMsg2); VHF_NAV_Receiver cNav = m as VHF_NAV_Receiver; if (cNav != null) { cNav_Select = cNav; } } } if (cNav_Select != null) { //string sMsg = "VOR indicator found receiver " + cNav_Select.moduleName; //print(sMsg); VOR cVOR = cNav_Select.getTunedVOR(); if (cVOR != null) { bool bZOC = cVOR.inZoneOfConfusion(cNav_Select.getPosition()); if (!bZOC) { double dDeviation = (iOBS - cVOR.getBearingFrom(cNav_Select.getPosition())) % 360.0; if (dDeviation > 180.0) { dDeviation -= 360.0; } while (dDeviation < -180.0) { dDeviation += 360.0; } bool bTo = dDeviation <-90.0 || dDeviation> 90.0; if (bTo) { sTo_From = " TO "; if (dDeviation < -90.0) { dDeviation = -180.0 - dDeviation; } else { dDeviation = 180.0 - dDeviation; } } else { sTo_From = "FROM"; } dIndicated_Deviation = dDeviation / 2.5; sStation_ID = cVOR.sStation_ID; } } } } }
public override void OnUpdate() { initialize(); string ResName = "ElectricCharge"; double dPowerRequired = 10.0 * dW_to_EC; // 10 W is typical receive power for NAV radio double dElectric_Draw = dPowerRequired * TimeWarp.deltaTime; double elecAvail = 0.0; if (bOn) { elecAvail = part.RequestResource(ResName, dElectric_Draw) / dElectric_Draw; } bPowered = (elecAvail > 0.90); if (cRecv.vPosition.updatePositionData(vessel.mainBody, vessel.latitude, vessel.longitude, vessel.altitude)) { cNav_Master.updateReceiver(iReceiver_ID, cRecv); } //string sMsg = "Recv freq " + cRecv.getFrequency().ToString("000.00"); //print(sMsg); cNav_Master.onReceiverUpdate(); if (bPowered) { if (cRecv.isActiveILS()) { cTuned_GLS = cNav_Master.getStationGLS(iReceiver_ID) as GLS; cTuned_LOC = cNav_Master.getStationLOC(iReceiver_ID) as LOC; cTuned_VOR = null; } else { cTuned_VOR = cNav_Master.getStationVOR(iReceiver_ID) as VOR; cTuned_GLS = null; cTuned_LOC = null; } cTuned_DME = cNav_Master.getStationDME(iReceiver_ID) as DME; } else { cTuned_VOR = null; cTuned_LOC = null; cTuned_DME = null; cTuned_GLS = null; } if (cTuned_VOR != null) { if (cTuned_VOR.getFlux(cRecv.vPosition) < 2.0e-9 || !cTuned_VOR.inLineOfSight(cRecv.vPosition)) { cTuned_VOR = null; } } if (cTuned_LOC != null) { if (cTuned_LOC.getFlux(cRecv.vPosition) < 2.0e-9 || !cTuned_LOC.inLineOfSight(cRecv.vPosition)) { cTuned_LOC = null; } } if (cTuned_DME != null) { if (cTuned_DME.getFlux(cRecv.vPosition) < 2.0e-9 || !cTuned_DME.inLineOfSight(cRecv.vPosition)) { cTuned_DME = null; } } if (cTuned_GLS != null) { if (cTuned_GLS.getFlux(cRecv.vPosition) > 2.0e-9 || !cTuned_GLS.inLineOfSight(cRecv.vPosition)) { cTuned_GLS = null; } } if (cTuned_VOR != null) { sTuned_Station = cTuned_VOR.sStation_ID; } else if (cTuned_LOC != null) { sTuned_Station = cTuned_LOC.sStation_ID; } else if (cTuned_DME != null) { sTuned_Station = cTuned_LOC.sStation_ID; } else if (cTuned_GLS != null) { sTuned_Station = cTuned_GLS.sStation_ID; } else { sTuned_Station = "---"; } }