Rev 156 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.FlightSimulator.SimConnect;
using System.Runtime.InteropServices;
namespace NITNavComm {
public class FSXObject {
public SimData simdata;
public SimConnect hSimConnect = null;
public enum DATA_REQUESTS {
AIRCRAFT,
AVIONICS,
NAVCOM1_REQ,
NAVCOM2_REQ
}
public enum DEFINITIONS {
AIRCRAFT,
AVIONICS,
NAVCOM1_DATA,
NAVCOM2_DATA
}
public enum EVENT_ID {
COM1_SWAP_FREQ,
NAV1_SWAP_FREQ,
COM_RADIO_WHOLE_INC,
COM_RADIO_WHOLE_DEC,
COM_RADIO_FRACT_INC,
COM_RADIO_FRACT_DEC,
NAV1_RADIO_WHOLE_INC,
NAV1_RADIO_WHOLE_DEC,
NAV1_RADIO_FRACT_INC,
NAV1_RADIO_FRACT_DEC,
COM2_SWAP_FREQ,
NAV2_SWAP_FREQ,
COM2_RADIO_WHOLE_INC,
COM2_RADIO_WHOLE_DEC,
COM2_RADIO_FRACT_INC,
COM2_RADIO_FRACT_DEC,
NAV2_RADIO_WHOLE_INC,
NAV2_RADIO_WHOLE_DEC,
NAV2_RADIO_FRACT_INC,
NAV2_RADIO_FRACT_DEC,
}
public enum GROUP_ID {
NAVCOM1,
NAVCOM2
}
public struct SimData {
public uint objectid;
public Aircraft_Data aircraft;
}
[StructLayout(LayoutKind.Sequential, Pack = 1)]
public struct NavCom_Data {
public double Freq0;
public double Freq1;
public double Freq2;
public double Freq3;
}
[StructLayout(LayoutKind.Sequential, Pack = 1)]
public struct Avionics_Data {
public bool avionics_master;
public double com1_status;
public double com2_status;
}
[StructLayout(LayoutKind.Sequential, Pack = 1)]
public struct Aircraft_Data {
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 32)]
public string atc_type;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 32)]
public string atc_model;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 32)]
public string atc_id;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 128)]
public string title;
}
public FSXObject() {
this.simdata = new SimData();
}
public void Comm1DecFract() {
this.hSimConnect.TransmitClientEvent(
this.simdata.objectid,
FSXObject.EVENT_ID.COM_RADIO_FRACT_DEC, 1,
FSXObject.GROUP_ID.NAVCOM1,
SIMCONNECT_EVENT_FLAG.GROUPID_IS_PRIORITY
);
}
public void Comm1DecWhole() {
this.hSimConnect.TransmitClientEvent(
this.simdata.objectid,
FSXObject.EVENT_ID.COM_RADIO_WHOLE_DEC, 1,
FSXObject.GROUP_ID.NAVCOM1,
SIMCONNECT_EVENT_FLAG.GROUPID_IS_PRIORITY
);
}
public void Comm1IncFract() {
this.hSimConnect.TransmitClientEvent(
this.simdata.objectid,
FSXObject.EVENT_ID.COM_RADIO_FRACT_INC, 1,
FSXObject.GROUP_ID.NAVCOM1,
SIMCONNECT_EVENT_FLAG.GROUPID_IS_PRIORITY
);
}
public void Comm1IncWhole() {
this.hSimConnect.TransmitClientEvent(
this.simdata.objectid,
FSXObject.EVENT_ID.COM_RADIO_WHOLE_INC, 1,
FSXObject.GROUP_ID.NAVCOM1,
SIMCONNECT_EVENT_FLAG.GROUPID_IS_PRIORITY
);
}
public void Comm1SwapFreq() {
this.hSimConnect.TransmitClientEvent(
this.simdata.objectid,
FSXObject.EVENT_ID.COM1_SWAP_FREQ, 1,
FSXObject.GROUP_ID.NAVCOM1,
SIMCONNECT_EVENT_FLAG.GROUPID_IS_PRIORITY
);
}
public void Nav1DecFract() {
this.hSimConnect.TransmitClientEvent(
this.simdata.objectid,
FSXObject.EVENT_ID.NAV1_RADIO_FRACT_DEC, 1,
FSXObject.GROUP_ID.NAVCOM1,
SIMCONNECT_EVENT_FLAG.GROUPID_IS_PRIORITY
);
}
public void Nav1DecWhole() {
this.hSimConnect.TransmitClientEvent(
this.simdata.objectid,
FSXObject.EVENT_ID.NAV1_RADIO_WHOLE_DEC, 1,
FSXObject.GROUP_ID.NAVCOM1,
SIMCONNECT_EVENT_FLAG.GROUPID_IS_PRIORITY
);
}
public void Nav1IncFract() {
this.hSimConnect.TransmitClientEvent(
this.simdata.objectid,
FSXObject.EVENT_ID.NAV1_RADIO_FRACT_INC, 1,
FSXObject.GROUP_ID.NAVCOM1,
SIMCONNECT_EVENT_FLAG.GROUPID_IS_PRIORITY
);
}
public void Nav1IncWhole() {
this.hSimConnect.TransmitClientEvent(
this.simdata.objectid,
FSXObject.EVENT_ID.NAV1_RADIO_WHOLE_INC, 1,
FSXObject.GROUP_ID.NAVCOM1,
SIMCONNECT_EVENT_FLAG.GROUPID_IS_PRIORITY
);
}
public void Nav1SwapFreq() {
this.hSimConnect.TransmitClientEvent(
this.simdata.objectid,
FSXObject.EVENT_ID.NAV1_SWAP_FREQ, 1,
FSXObject.GROUP_ID.NAVCOM1,
SIMCONNECT_EVENT_FLAG.GROUPID_IS_PRIORITY
);
}
public void Comm2DecFract() {
this.hSimConnect.TransmitClientEvent(
this.simdata.objectid,
FSXObject.EVENT_ID.COM2_RADIO_FRACT_DEC, 1,
FSXObject.GROUP_ID.NAVCOM2,
SIMCONNECT_EVENT_FLAG.GROUPID_IS_PRIORITY
);
}
public void Comm2DecWhole() {
this.hSimConnect.TransmitClientEvent(
this.simdata.objectid,
FSXObject.EVENT_ID.COM2_RADIO_WHOLE_DEC, 1,
FSXObject.GROUP_ID.NAVCOM2,
SIMCONNECT_EVENT_FLAG.GROUPID_IS_PRIORITY
);
}
public void Comm2IncFract() {
this.hSimConnect.TransmitClientEvent(
this.simdata.objectid,
FSXObject.EVENT_ID.COM2_RADIO_FRACT_INC, 1,
FSXObject.GROUP_ID.NAVCOM2,
SIMCONNECT_EVENT_FLAG.GROUPID_IS_PRIORITY
);
}
public void Comm2IncWhole() {
this.hSimConnect.TransmitClientEvent(
this.simdata.objectid,
FSXObject.EVENT_ID.COM2_RADIO_WHOLE_INC, 1,
FSXObject.GROUP_ID.NAVCOM2,
SIMCONNECT_EVENT_FLAG.GROUPID_IS_PRIORITY
);
}
public void Comm2SwapFreq() {
this.hSimConnect.TransmitClientEvent(
this.simdata.objectid,
FSXObject.EVENT_ID.COM2_SWAP_FREQ, 1,
FSXObject.GROUP_ID.NAVCOM2,
SIMCONNECT_EVENT_FLAG.GROUPID_IS_PRIORITY
);
}
public void Nav2DecFract() {
this.hSimConnect.TransmitClientEvent(
this.simdata.objectid,
FSXObject.EVENT_ID.NAV2_RADIO_FRACT_DEC, 1,
FSXObject.GROUP_ID.NAVCOM1,
SIMCONNECT_EVENT_FLAG.GROUPID_IS_PRIORITY
);
}
public void Nav2DecWhole() {
this.hSimConnect.TransmitClientEvent(
this.simdata.objectid,
FSXObject.EVENT_ID.NAV2_RADIO_WHOLE_DEC, 1,
FSXObject.GROUP_ID.NAVCOM2,
SIMCONNECT_EVENT_FLAG.GROUPID_IS_PRIORITY
);
}
public void Nav2IncFract() {
this.hSimConnect.TransmitClientEvent(
this.simdata.objectid,
FSXObject.EVENT_ID.NAV2_RADIO_FRACT_INC, 1,
FSXObject.GROUP_ID.NAVCOM2,
SIMCONNECT_EVENT_FLAG.GROUPID_IS_PRIORITY
);
}
public void Nav2IncWhole() {
this.hSimConnect.TransmitClientEvent(
this.simdata.objectid,
FSXObject.EVENT_ID.NAV2_RADIO_WHOLE_INC, 1,
FSXObject.GROUP_ID.NAVCOM2,
SIMCONNECT_EVENT_FLAG.GROUPID_IS_PRIORITY
);
}
public void Nav2SwapFreq() {
this.hSimConnect.TransmitClientEvent(
this.simdata.objectid,
FSXObject.EVENT_ID.NAV2_SWAP_FREQ, 1,
FSXObject.GROUP_ID.NAVCOM2,
SIMCONNECT_EVENT_FLAG.GROUPID_IS_PRIORITY
);
}
}
}