G1000 Events
-
- Posts: 11
- Joined: Mon Mar 27, 2017 1:48 pm
G1000 Events
Hi all! I have some issues related to catching G1000 events in p3d. I try to use simconnect_OnRecvEvent method (code is on C#), for most of all events it works- when any event is happening -simconnect gives feedback about it. But as for G1000 events, for example : G1000_PFD_PROCEDURE_BUTTON , and all that starts with G1000, I cannot get any feedback from simconnect. Code looks fine- all other event caprute works for all events but not for G1000 ones. Any ideas about that? Thank you in advance
- Rob McCarthy
- Lockheed Martin
- Posts: 3703
- Joined: Wed Aug 24, 2011 1:37 pm
Re: G1000 Events
Hello,
Which aircraft are you using when you see this problem? Are you seeing this when attempting to use the G1000 in the virtual cockpit or as a 2D panel?
Regards,
Rob McCarthy
Which aircraft are you using when you see this problem? Are you seeing this when attempting to use the G1000 in the virtual cockpit or as a 2D panel?
Regards,
Rob McCarthy
Rob McCarthy
Prepar3D® Core Lead
Prepar3D® Core Lead
-
- Posts: 11
- Joined: Mon Mar 27, 2017 1:48 pm
Re: G1000 Events
Hello, i have this issues with "Beech Baron 58 w G1000", "Mooney Acclaim with G1000 ", as well as with "Cessna 172 SP Skyhawk(G1000) -SimViation"- the third one is from third part developers. All times i was testing code in virtual cockpit, i will try it in 2D , to see what happens
-
- Posts: 11
- Joined: Mon Mar 27, 2017 1:48 pm
Re: G1000 Events
Neither in Virtual Cockpit nor in 2D Panel mode SimConnect does not give any output related to G1000 events
-
- Posts: 11
- Joined: Mon Mar 27, 2017 1:48 pm
Re: G1000 Events
Can you please help me with this issue? problem still occurs(Rob McCarthy wrote: ↑Tue Jul 10, 2018 12:26 pm Hello,
Which aircraft are you using when you see this problem? Are you seeing this when attempting to use the G1000 in the virtual cockpit or as a 2D panel?
Regards,
Rob McCarthy
- Rob McCarthy
- Lockheed Martin
- Posts: 3703
- Joined: Wed Aug 24, 2011 1:37 pm
Re: G1000 Events
Hello,
Can you post a code sample?
Regards,
Rob McCarthy
Can you post a code sample?
Regards,
Rob McCarthy
Rob McCarthy
Prepar3D® Core Lead
Prepar3D® Core Lead
-
- Posts: 11
- Joined: Mon Mar 27, 2017 1:48 pm
Re: G1000 Events
Yes, sure, here is code sample based on Managed Data Request sasmple from SDK
Here is some buttons with events that I send to Simconnect. As for send events everything is ok, but I `m trying to catch events on real time based on void simconnect_OnRecvEvent(SimConnect sender, SIMCONNECT_RECV_EVENT data) this method.
When it comes to many events - for example AILERONS_LEFT/ RIGHT, etc everything is fine- when user triggers them outside my programm- I have output based on simconnect_OnRecvEvent, but for G1000 events - when I activate them from my programm- everything good- when user for example press procedure button on FPL in Virtual cockpit - i have nothing in simconnect_OnRecvEvent, very strange issue
Code: Select all
//Copyright (c) Lockheed Martin Corporation. All rights reserved.
//
//
// Managed Data Request sample
//
// Click on Connect to try and connect to a running version of Prepar3D
// Click on Request Data any number of times
// Click on Disconnect to close the connection, and then you should
// be able to click on Connect and restart the process
//
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
// Add these two statements to all SimConnect clients
using LockheedMartin.Prepar3D.SimConnect;
using System.Runtime.InteropServices;
namespace Managed_Data_Request
{
public partial class Form1 : Form
{
// User-defined win32 event
const int WM_USER_SIMCONNECT = 0x0402;
// SimConnect object
SimConnect simconnect = null;
enum DEFINITIONS
{
Struct1,
}
enum DATA_REQUESTS
{
REQUEST_1,
};
enum GRUOP_ID
{
GRUOP_1,
GROUP_1,
};
enum EVENTS
{
G1000_PFD_FLIGHTPLAN_BUTTON,
AILERONS_LEFT,
KEY_AILERONS_LEFT,
KEY_AILERONS_RIGHT,
}
enum EVENT_CTRL
{
PAUSE, //set pause
ABORT, //Quit without message
CLOCK, //Hours of Local Time
AILERONS_LEFT, //kren vlevo
AILERONS_RIGHT, //kren vpravo
G1000_PFD_FLIGHTPLAN_BUTTON,
KEY_AILERONS_LEFT,
KEY_AILERONS_RIGHT,
G1000_PFD_PROCEDURE_BUTTON,
TOGGLE_AIRCRAFT_EXIT,
}
enum GROUP_IDS
{
GROUP_1,
}
// this is how you declare a data structure so that
// simconnect knows how to fill it/read it.
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi, Pack = 1)]
struct Struct1
{
// this is how you declare a fixed size string
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)]
public String title;
public double latitude;
public double longitude;
public double altitude;
};
public Form1()
{
InitializeComponent();
setButtons(true, false, false);
}
// Simconnect client will send a win32 message when there is
// a packet to process. ReceiveMessage must be called to
// trigger the events. This model keeps simconnect processing on the main thread.
protected override void DefWndProc(ref Message m)
{
if (m.Msg == WM_USER_SIMCONNECT)
{
if (simconnect != null)
{
simconnect.ReceiveMessage();
}
}
else
{
base.DefWndProc(ref m);
}
}
private void setButtons(bool bConnect, bool bGet, bool bDisconnect)
{
buttonConnect.Enabled = bConnect;
buttonRequestData.Enabled = bGet;
buttonDisconnect.Enabled = bDisconnect;
}
private void closeConnection()
{
if (simconnect != null)
{
// Dispose serves the same purpose as SimConnect_Close()
simconnect.Dispose();
simconnect = null;
displayText("Connection closed");
}
}
// Set up all the SimConnect related data definitions and event handlers
private void initDataRequest()
{
try
{
// listen to connect and quit msgs
simconnect.OnRecvOpen += new SimConnect.RecvOpenEventHandler(simconnect_OnRecvOpen);
simconnect.OnRecvQuit += new SimConnect.RecvQuitEventHandler(simconnect_OnRecvQuit);
simconnect.OnRecvEvent += new SimConnect.RecvEventEventHandler(simconnect_OnRecvEvent);
// listen to exceptions
simconnect.OnRecvException += new SimConnect.RecvExceptionEventHandler(simconnect_OnRecvException);
// define a data structure
simconnect.AddToDataDefinition(DEFINITIONS.Struct1, "Title", null, SIMCONNECT_DATATYPE.STRING256, 0.0f, SimConnect.SIMCONNECT_UNUSED);
simconnect.AddToDataDefinition(DEFINITIONS.Struct1, "Plane Latitude", "degrees", SIMCONNECT_DATATYPE.FLOAT64, 0.0f, SimConnect.SIMCONNECT_UNUSED);
simconnect.AddToDataDefinition(DEFINITIONS.Struct1, "Plane Longitude", "degrees", SIMCONNECT_DATATYPE.FLOAT64, 0.0f, SimConnect.SIMCONNECT_UNUSED);
simconnect.AddToDataDefinition(DEFINITIONS.Struct1, "Plane Altitude", "feet", SIMCONNECT_DATATYPE.FLOAT64, 0.0f, SimConnect.SIMCONNECT_UNUSED);
/*simconnect.MapClientEventToSimEvent(EVENT_CTRL.ABORT, "ABORT");
simconnect.MapClientEventToSimEvent(EVENT_CTRL.PAUSE, "PAUSE_SET");
simconnect.MapClientEventToSimEvent(EVENT_CTRL.CLOCK, "CLOCK_HOURS_SET");*/
simconnect.MapClientEventToSimEvent(EVENT_CTRL.AILERONS_LEFT, "AILERONS_LEFT");
simconnect.MapClientEventToSimEvent(EVENT_CTRL.AILERONS_RIGHT, "AILERONS_RIGHT");
simconnect.MapClientEventToSimEvent(EVENT_CTRL.G1000_PFD_FLIGHTPLAN_BUTTON, "G1000_PFD_FLIGHTPLAN_BUTTON");
simconnect.MapClientEventToSimEvent(EVENT_CTRL.G1000_PFD_PROCEDURE_BUTTON, "G1000_PFD_PROCEDURE_BUTTON");
simconnect.MapClientEventToSimEvent(EVENT_CTRL.TOGGLE_AIRCRAFT_EXIT, "TOGGLE_AIRCRAFT_EXIT");
simconnect.AddClientEventToNotificationGroup(GRUOP_ID.GROUP_1, EVENT_CTRL.G1000_PFD_FLIGHTPLAN_BUTTON, false);
simconnect.AddClientEventToNotificationGroup(GRUOP_ID.GROUP_1, EVENT_CTRL.AILERONS_LEFT, false);
simconnect.AddClientEventToNotificationGroup(GRUOP_ID.GROUP_1, EVENT_CTRL.G1000_PFD_PROCEDURE_BUTTON, false);
simconnect.AddClientEventToNotificationGroup(GRUOP_ID.GROUP_1, EVENT_CTRL.TOGGLE_AIRCRAFT_EXIT, false);
// IMPORTANT: register it with the simconnect managed wrapper marshaller
// if you skip this step, you will only receive a uint in the .dwData field.
simconnect.RegisterDataDefineStruct<Struct1>(DEFINITIONS.Struct1);
// catch a simobject data request
simconnect.OnRecvSimobjectDataBytype += new SimConnect.RecvSimobjectDataBytypeEventHandler(simconnect_OnRecvSimobjectDataBytype);
simconnect.OnRecvEvent += new SimConnect.RecvEventEventHandler(simconnect_OnRecvEvent);
simconnect.OnRecvEventFrame += new SimConnect.RecvEventFrameEventHandler(simconnect_OnRecvEventFrame);
}
catch (COMException ex)
{
displayText(ex.Message);
}
}
void simconnect_OnRecvOpen(SimConnect sender, SIMCONNECT_RECV_OPEN data)
{
displayText("Connected to Prepar3D");
}
void simconnect_OnRecvEventFrame(SimConnect sender, SIMCONNECT_RECV_EVENT_FRAME data)
{
// displayText(Convert.ToString((EVENTS)data.uEventID));
}
// The case where the user closes Prepar3D
void simconnect_OnRecvQuit(SimConnect sender, SIMCONNECT_RECV data)
{
displayText("Prepar3D has exited");
closeConnection();
}
void simconnect_OnRecvException(SimConnect sender, SIMCONNECT_RECV_EXCEPTION data)
{
displayText("Exception received: " + data.dwException);
}
// The case where the user closes the client
private void Form1_FormClosed(object sender, FormClosedEventArgs e)
{
closeConnection();
}
void simconnect_OnRecvSimobjectDataBytype(SimConnect sender, SIMCONNECT_RECV_SIMOBJECT_DATA_BYTYPE data)
{
switch ((DATA_REQUESTS)data.dwRequestID)
{
case DATA_REQUESTS.REQUEST_1:
Struct1 s1 = (Struct1)data.dwData[0];
displayText("Title: " + s1.title);
displayText("Lat: " + s1.latitude);
displayText("Lon: " + s1.longitude);
displayText("Alt: " + s1.altitude);
break;
default:
displayText("Unknown request ID: " + data.dwRequestID);
break;
}
}
private void buttonConnect_Click(object sender, EventArgs e)
{
if (simconnect == null)
{
try
{
// the constructor is similar to SimConnect_Open in the native API
simconnect = new SimConnect("Managed Data Request", this.Handle, WM_USER_SIMCONNECT, null, 0);
setButtons(false, true, true);
initDataRequest();
}
catch (COMException ex)
{
displayText("Unable to connect to Prepar3D:\n\n" + ex.Message);
}
}
else
{
displayText("Error - try again");
closeConnection();
setButtons(true, false, false);
}
}
private void buttonDisconnect_Click(object sender, EventArgs e)
{
closeConnection();
setButtons(true, false, false);
}
private void buttonRequestData_Click(object sender, EventArgs e)
{
// The following call returns identical information to:
// simconnect.RequestDataOnSimObject(DATA_REQUESTS.REQUEST_1, DEFINITIONS.Struct1, SimConnect.SIMCONNECT_OBJECT_ID_USER, SIMCONNECT_PERIOD.ONCE);
simconnect.RequestDataOnSimObjectType(DATA_REQUESTS.REQUEST_1,DEFINITIONS.Struct1, 0, SIMCONNECT_SIMOBJECT_TYPE.USER);
displayText("Request sent...");
}
// Response number
int response = 1;
// Output text - display a maximum of 10 lines
string output = "\n\n\n\n\n\n\n\n\n\n";
void displayText(string s)
{
// remove first string from output
output = output.Substring(output.IndexOf("\n") + 1);
// add the new string
output += "\n" + response++ + ": " + s;
// display it
richResponse.Text = output;
}
private void button1_Click(object sender, EventArgs e)
{
simconnect.TransmitClientEvent(0, EVENT_CTRL.G1000_PFD_FLIGHTPLAN_BUTTON, 0, GROUP_IDS.GROUP_1, SIMCONNECT_EVENT_FLAG.GROUPID_IS_PRIORITY);
}
void simconnect_OnRecvEvent(SimConnect sender, SIMCONNECT_RECV_EVENT data) {
//MessageBox.Show("Event catch", "");
displayText( Convert.ToString((EVENT_CTRL)data.uEventID));
}
private void button2_Click(object sender, EventArgs e)
{
simconnect.TransmitClientEvent(0, EVENT_CTRL.AILERONS_LEFT, 0, GROUP_IDS.GROUP_1, SIMCONNECT_EVENT_FLAG.GROUPID_IS_PRIORITY);
}
private void button3_Click(object sender, EventArgs e)
{
simconnect.TransmitClientEvent(0, EVENT_CTRL.G1000_PFD_PROCEDURE_BUTTON, 0, GROUP_IDS.GROUP_1, SIMCONNECT_EVENT_FLAG.GROUPID_IS_PRIORITY);
}
private void button4_Click(object sender, EventArgs e)
{
simconnect.TransmitClientEvent(0, EVENT_CTRL.TOGGLE_AIRCRAFT_EXIT, 0, GROUP_IDS.GROUP_1, SIMCONNECT_EVENT_FLAG.GROUPID_IS_PRIORITY);
}
}
}
// End of sample
Here is some buttons with events that I send to Simconnect. As for send events everything is ok, but I `m trying to catch events on real time based on void simconnect_OnRecvEvent(SimConnect sender, SIMCONNECT_RECV_EVENT data) this method.
When it comes to many events - for example AILERONS_LEFT/ RIGHT, etc everything is fine- when user triggers them outside my programm- I have output based on simconnect_OnRecvEvent, but for G1000 events - when I activate them from my programm- everything good- when user for example press procedure button on FPL in Virtual cockpit - i have nothing in simconnect_OnRecvEvent, very strange issue
-
- Posts: 11
- Joined: Mon Mar 27, 2017 1:48 pm
Re: G1000 Events
ruslan.berz wrote: ↑Mon Aug 20, 2018 2:26 pm Yes, sure, here is code sample based on Managed Data Request sasmple from SDK
Code: Select all
//Copyright (c) Lockheed Martin Corporation. All rights reserved. // // // Managed Data Request sample // // Click on Connect to try and connect to a running version of Prepar3D // Click on Request Data any number of times // Click on Disconnect to close the connection, and then you should // be able to click on Connect and restart the process // using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; // Add these two statements to all SimConnect clients using LockheedMartin.Prepar3D.SimConnect; using System.Runtime.InteropServices; namespace Managed_Data_Request { public partial class Form1 : Form { // User-defined win32 event const int WM_USER_SIMCONNECT = 0x0402; // SimConnect object SimConnect simconnect = null; enum DEFINITIONS { Struct1, } enum DATA_REQUESTS { REQUEST_1, }; enum GRUOP_ID { GRUOP_1, GROUP_1, }; enum EVENTS { G1000_PFD_FLIGHTPLAN_BUTTON, AILERONS_LEFT, KEY_AILERONS_LEFT, KEY_AILERONS_RIGHT, } enum EVENT_CTRL { PAUSE, //set pause ABORT, //Quit without message CLOCK, //Hours of Local Time AILERONS_LEFT, //kren vlevo AILERONS_RIGHT, //kren vpravo G1000_PFD_FLIGHTPLAN_BUTTON, KEY_AILERONS_LEFT, KEY_AILERONS_RIGHT, G1000_PFD_PROCEDURE_BUTTON, TOGGLE_AIRCRAFT_EXIT, } enum GROUP_IDS { GROUP_1, } // this is how you declare a data structure so that // simconnect knows how to fill it/read it. [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi, Pack = 1)] struct Struct1 { // this is how you declare a fixed size string [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)] public String title; public double latitude; public double longitude; public double altitude; }; public Form1() { InitializeComponent(); setButtons(true, false, false); } // Simconnect client will send a win32 message when there is // a packet to process. ReceiveMessage must be called to // trigger the events. This model keeps simconnect processing on the main thread. protected override void DefWndProc(ref Message m) { if (m.Msg == WM_USER_SIMCONNECT) { if (simconnect != null) { simconnect.ReceiveMessage(); } } else { base.DefWndProc(ref m); } } private void setButtons(bool bConnect, bool bGet, bool bDisconnect) { buttonConnect.Enabled = bConnect; buttonRequestData.Enabled = bGet; buttonDisconnect.Enabled = bDisconnect; } private void closeConnection() { if (simconnect != null) { // Dispose serves the same purpose as SimConnect_Close() simconnect.Dispose(); simconnect = null; displayText("Connection closed"); } } // Set up all the SimConnect related data definitions and event handlers private void initDataRequest() { try { // listen to connect and quit msgs simconnect.OnRecvOpen += new SimConnect.RecvOpenEventHandler(simconnect_OnRecvOpen); simconnect.OnRecvQuit += new SimConnect.RecvQuitEventHandler(simconnect_OnRecvQuit); simconnect.OnRecvEvent += new SimConnect.RecvEventEventHandler(simconnect_OnRecvEvent); // listen to exceptions simconnect.OnRecvException += new SimConnect.RecvExceptionEventHandler(simconnect_OnRecvException); // define a data structure simconnect.AddToDataDefinition(DEFINITIONS.Struct1, "Title", null, SIMCONNECT_DATATYPE.STRING256, 0.0f, SimConnect.SIMCONNECT_UNUSED); simconnect.AddToDataDefinition(DEFINITIONS.Struct1, "Plane Latitude", "degrees", SIMCONNECT_DATATYPE.FLOAT64, 0.0f, SimConnect.SIMCONNECT_UNUSED); simconnect.AddToDataDefinition(DEFINITIONS.Struct1, "Plane Longitude", "degrees", SIMCONNECT_DATATYPE.FLOAT64, 0.0f, SimConnect.SIMCONNECT_UNUSED); simconnect.AddToDataDefinition(DEFINITIONS.Struct1, "Plane Altitude", "feet", SIMCONNECT_DATATYPE.FLOAT64, 0.0f, SimConnect.SIMCONNECT_UNUSED); /*simconnect.MapClientEventToSimEvent(EVENT_CTRL.ABORT, "ABORT"); simconnect.MapClientEventToSimEvent(EVENT_CTRL.PAUSE, "PAUSE_SET"); simconnect.MapClientEventToSimEvent(EVENT_CTRL.CLOCK, "CLOCK_HOURS_SET");*/ simconnect.MapClientEventToSimEvent(EVENT_CTRL.AILERONS_LEFT, "AILERONS_LEFT"); simconnect.MapClientEventToSimEvent(EVENT_CTRL.AILERONS_RIGHT, "AILERONS_RIGHT"); simconnect.MapClientEventToSimEvent(EVENT_CTRL.G1000_PFD_FLIGHTPLAN_BUTTON, "G1000_PFD_FLIGHTPLAN_BUTTON"); simconnect.MapClientEventToSimEvent(EVENT_CTRL.G1000_PFD_PROCEDURE_BUTTON, "G1000_PFD_PROCEDURE_BUTTON"); simconnect.MapClientEventToSimEvent(EVENT_CTRL.TOGGLE_AIRCRAFT_EXIT, "TOGGLE_AIRCRAFT_EXIT"); simconnect.AddClientEventToNotificationGroup(GRUOP_ID.GROUP_1, EVENT_CTRL.G1000_PFD_FLIGHTPLAN_BUTTON, false); simconnect.AddClientEventToNotificationGroup(GRUOP_ID.GROUP_1, EVENT_CTRL.AILERONS_LEFT, false); simconnect.AddClientEventToNotificationGroup(GRUOP_ID.GROUP_1, EVENT_CTRL.G1000_PFD_PROCEDURE_BUTTON, false); simconnect.AddClientEventToNotificationGroup(GRUOP_ID.GROUP_1, EVENT_CTRL.TOGGLE_AIRCRAFT_EXIT, false); // IMPORTANT: register it with the simconnect managed wrapper marshaller // if you skip this step, you will only receive a uint in the .dwData field. simconnect.RegisterDataDefineStruct<Struct1>(DEFINITIONS.Struct1); // catch a simobject data request simconnect.OnRecvSimobjectDataBytype += new SimConnect.RecvSimobjectDataBytypeEventHandler(simconnect_OnRecvSimobjectDataBytype); simconnect.OnRecvEvent += new SimConnect.RecvEventEventHandler(simconnect_OnRecvEvent); simconnect.OnRecvEventFrame += new SimConnect.RecvEventFrameEventHandler(simconnect_OnRecvEventFrame); } catch (COMException ex) { displayText(ex.Message); } } void simconnect_OnRecvOpen(SimConnect sender, SIMCONNECT_RECV_OPEN data) { displayText("Connected to Prepar3D"); } void simconnect_OnRecvEventFrame(SimConnect sender, SIMCONNECT_RECV_EVENT_FRAME data) { // displayText(Convert.ToString((EVENTS)data.uEventID)); } // The case where the user closes Prepar3D void simconnect_OnRecvQuit(SimConnect sender, SIMCONNECT_RECV data) { displayText("Prepar3D has exited"); closeConnection(); } void simconnect_OnRecvException(SimConnect sender, SIMCONNECT_RECV_EXCEPTION data) { displayText("Exception received: " + data.dwException); } // The case where the user closes the client private void Form1_FormClosed(object sender, FormClosedEventArgs e) { closeConnection(); } void simconnect_OnRecvSimobjectDataBytype(SimConnect sender, SIMCONNECT_RECV_SIMOBJECT_DATA_BYTYPE data) { switch ((DATA_REQUESTS)data.dwRequestID) { case DATA_REQUESTS.REQUEST_1: Struct1 s1 = (Struct1)data.dwData[0]; displayText("Title: " + s1.title); displayText("Lat: " + s1.latitude); displayText("Lon: " + s1.longitude); displayText("Alt: " + s1.altitude); break; default: displayText("Unknown request ID: " + data.dwRequestID); break; } } private void buttonConnect_Click(object sender, EventArgs e) { if (simconnect == null) { try { // the constructor is similar to SimConnect_Open in the native API simconnect = new SimConnect("Managed Data Request", this.Handle, WM_USER_SIMCONNECT, null, 0); setButtons(false, true, true); initDataRequest(); } catch (COMException ex) { displayText("Unable to connect to Prepar3D:\n\n" + ex.Message); } } else { displayText("Error - try again"); closeConnection(); setButtons(true, false, false); } } private void buttonDisconnect_Click(object sender, EventArgs e) { closeConnection(); setButtons(true, false, false); } private void buttonRequestData_Click(object sender, EventArgs e) { // The following call returns identical information to: // simconnect.RequestDataOnSimObject(DATA_REQUESTS.REQUEST_1, DEFINITIONS.Struct1, SimConnect.SIMCONNECT_OBJECT_ID_USER, SIMCONNECT_PERIOD.ONCE); simconnect.RequestDataOnSimObjectType(DATA_REQUESTS.REQUEST_1,DEFINITIONS.Struct1, 0, SIMCONNECT_SIMOBJECT_TYPE.USER); displayText("Request sent..."); } // Response number int response = 1; // Output text - display a maximum of 10 lines string output = "\n\n\n\n\n\n\n\n\n\n"; void displayText(string s) { // remove first string from output output = output.Substring(output.IndexOf("\n") + 1); // add the new string output += "\n" + response++ + ": " + s; // display it richResponse.Text = output; } private void button1_Click(object sender, EventArgs e) { simconnect.TransmitClientEvent(0, EVENT_CTRL.G1000_PFD_FLIGHTPLAN_BUTTON, 0, GROUP_IDS.GROUP_1, SIMCONNECT_EVENT_FLAG.GROUPID_IS_PRIORITY); } void simconnect_OnRecvEvent(SimConnect sender, SIMCONNECT_RECV_EVENT data) { //MessageBox.Show("Event catch", ""); displayText( Convert.ToString((EVENT_CTRL)data.uEventID)); } private void button2_Click(object sender, EventArgs e) { simconnect.TransmitClientEvent(0, EVENT_CTRL.AILERONS_LEFT, 0, GROUP_IDS.GROUP_1, SIMCONNECT_EVENT_FLAG.GROUPID_IS_PRIORITY); } private void button3_Click(object sender, EventArgs e) { simconnect.TransmitClientEvent(0, EVENT_CTRL.G1000_PFD_PROCEDURE_BUTTON, 0, GROUP_IDS.GROUP_1, SIMCONNECT_EVENT_FLAG.GROUPID_IS_PRIORITY); } private void button4_Click(object sender, EventArgs e) { simconnect.TransmitClientEvent(0, EVENT_CTRL.TOGGLE_AIRCRAFT_EXIT, 0, GROUP_IDS.GROUP_1, SIMCONNECT_EVENT_FLAG.GROUPID_IS_PRIORITY); } } } // End of sample
Here is some buttons with events that I send to Simconnect. As for send events everything is ok, but I `m trying to catch events on real time based on void simconnect_OnRecvEvent(SimConnect sender, SIMCONNECT_RECV_EVENT data) this method.
When it comes to many events - for example AILERONS_LEFT/ RIGHT, etc everything is fine- when user triggers them outside my programm- I have output based on simconnect_OnRecvEvent, but for G1000 events - when I activate them from my programm- everything good- when user for example press procedure button on FPL in Virtual cockpit - i have nothing in simconnect_OnRecvEvent, very strange issue
-
- Posts: 11
- Joined: Mon Mar 27, 2017 1:48 pm
Re: G1000 Events
Here is the full codeRob McCarthy wrote: ↑Fri Aug 17, 2018 11:08 am Hello,
Can you post a code sample?
Regards,
Rob McCarthy
https://drive.google.com/open?id=1VCRDW ... 5e_Fqw5bpR
and here is a video with the issue
https://drive.google.com/open?id=1Nt_BU ... 5j7GfD3Pky
-
- Posts: 11
- Joined: Mon Mar 27, 2017 1:48 pm
Re: G1000 Events
ruslan.berz wrote: ↑Mon Aug 20, 2018 2:42 pmHere is the full codeRob McCarthy wrote: ↑Fri Aug 17, 2018 11:08 am Hello,
Can you post a code sample?
Regards,
Rob McCarthy
https://drive.google.com/open?id=1VCRDW ... 5e_Fqw5bpR
and here is a video with the issue
https://drive.google.com/open?id=1Nt_BU ... 5j7GfD3Pky
Fixed links:
for program:
https://drive.google.com/open?id=1VCRDW ... 5e_Fqw5bpR
for video:
https://drive.google.com/open?id=1Nt_BU ... 5j7GfD3Pky
-
- Posts: 11
- Joined: Mon Mar 27, 2017 1:48 pm
Re: G1000 Events
Rob McCarthy wrote: ↑Fri Aug 17, 2018 11:08 am Hello,
Can you post a code sample?
Regards,
Rob McCarthy
Can you please check the code?