2323using System . Windows . Navigation ;
2424using System . Windows . Shapes ;
2525using System . Windows . Threading ;
26+ using static System . Windows . Forms . VisualStyles . VisualStyleElement . TaskbarClock ;
2627using MouseEventArgs = System . Windows . Forms . MouseEventArgs ;
2728
2829
@@ -62,12 +63,13 @@ public partial class MainWindow : Window
6263 static List < PlaneInfoResponse > Inair = new List < PlaneInfoResponse > ( ) ;
6364 static List < PlaneInfoResponse > Onground = new List < PlaneInfoResponse > ( ) ;
6465 static FsConnect fsConnect = new FsConnect ( ) ;
65- static List < SimProperty > definition = new List < SimProperty > ( ) ;
66+ static List < SimVar > definition = new List < SimVar > ( ) ;
6667 static string updateUri ;
6768 static public string version ;
6869 int lastDeactivateTick ;
6970 bool lastDeactivateValid ;
7071 int bounces = 0 ;
72+ int myDefineId ;
7173
7274 const int SAMPLE_RATE = 20 ; //ms
7375 const int BUFFER_SIZE = 2 ;
@@ -119,19 +121,21 @@ public MainWindow()
119121 timerRead . Tick += timerRead_Tick ;
120122 timerBounce . Tick += timerBounce_Tick ;
121123 fsConnect . FsDataReceived += HandleReceivedFsData ;
122- definition . Add ( new SimProperty ( "TITLE" , null , SIMCONNECT_DATATYPE . STRING256 ) ) ;
123- definition . Add ( new SimProperty ( "SIM ON GROUND" , "Bool" , SIMCONNECT_DATATYPE . INT32 ) ) ;
124- definition . Add ( new SimProperty ( "AIRCRAFT WIND X" , "Knots" , SIMCONNECT_DATATYPE . FLOAT64 ) ) ;
125- definition . Add ( new SimProperty ( "AIRCRAFT WIND Z" , "Knots" , SIMCONNECT_DATATYPE . FLOAT64 ) ) ;
126- definition . Add ( new SimProperty ( "AIRSPEED INDICATED" , "Knots" , SIMCONNECT_DATATYPE . FLOAT64 ) ) ;
127- definition . Add ( new SimProperty ( "GROUND VELOCITY" , "Knots" , SIMCONNECT_DATATYPE . FLOAT64 ) ) ;
128- definition . Add ( new SimProperty ( "VELOCITY BODY X" , "Feet per second" , SIMCONNECT_DATATYPE . FLOAT64 ) ) ;
129- definition . Add ( new SimProperty ( "VELOCITY BODY Z" , "Feet per second" , SIMCONNECT_DATATYPE . FLOAT64 ) ) ;
130- definition . Add ( new SimProperty ( "G FORCE" , "GForce" , SIMCONNECT_DATATYPE . FLOAT64 ) ) ;
131- definition . Add ( new SimProperty ( "PLANE TOUCHDOWN NORMAL VELOCITY" , "Feet per second" , SIMCONNECT_DATATYPE . FLOAT64 ) ) ;
124+ definition . Add ( new SimVar ( "TITLE" , null , SIMCONNECT_DATATYPE . STRING256 ) ) ;
125+ definition . Add ( new SimVar ( "SIM ON GROUND" , "Bool" , SIMCONNECT_DATATYPE . INT32 ) ) ;
126+ definition . Add ( new SimVar ( "AIRCRAFT WIND X" , "Knots" , SIMCONNECT_DATATYPE . FLOAT64 ) ) ;
127+ definition . Add ( new SimVar ( "AIRCRAFT WIND Z" , "Knots" , SIMCONNECT_DATATYPE . FLOAT64 ) ) ;
128+ definition . Add ( new SimVar ( "AIRSPEED INDICATED" , "Knots" , SIMCONNECT_DATATYPE . FLOAT64 ) ) ;
129+ definition . Add ( new SimVar ( "GROUND VELOCITY" , "Knots" , SIMCONNECT_DATATYPE . FLOAT64 ) ) ;
130+ definition . Add ( new SimVar ( "VELOCITY BODY X" , "Feet per second" , SIMCONNECT_DATATYPE . FLOAT64 ) ) ;
131+ definition . Add ( new SimVar ( "VELOCITY BODY Z" , "Feet per second" , SIMCONNECT_DATATYPE . FLOAT64 ) ) ;
132+ definition . Add ( new SimVar ( "G FORCE" , "GForce" , SIMCONNECT_DATATYPE . FLOAT64 ) ) ;
133+ definition . Add ( new SimVar ( "PLANE TOUCHDOWN NORMAL VELOCITY" , "Feet per second" , SIMCONNECT_DATATYPE . FLOAT64 ) ) ;
132134 //SHOW LRM
133135 winLRM = new LRMDisplay ( viewModel ) ;
134136 winLRM . Show ( ) ;
137+
138+
135139 }
136140
137141 #region Reading and processing simconnect data
@@ -141,7 +145,7 @@ private void timerRead_Tick(object sender, EventArgs e)
141145 {
142146 try
143147 {
144- fsConnect . RequestData ( Requests . PlaneInfo ) ;
148+ fsConnect . RequestData ( Requests . PlaneInfo , Requests . PlaneInfo ) ;
145149 }
146150 catch
147151 {
@@ -170,7 +174,7 @@ private static void HandleReceivedFsData(object sender, FsDataReceivedEventArgs
170174 {
171175 if ( ! ShowLanding )
172176 {
173- PlaneInfoResponse r = ( PlaneInfoResponse ) e . Data ;
177+ PlaneInfoResponse r = ( PlaneInfoResponse ) e . Data . FirstOrDefault ( ) ;
174178 //ignore when noone is flying
175179 if ( r . ForwardSpeed < 4 ) //if less then 4kt, it's not a landing or out to menu
176180 {
@@ -309,7 +313,7 @@ private void backgroundConnector_DoWork(object sender, System.ComponentModel.DoW
309313 {
310314 try
311315 {
312- fsConnect . Connect ( "TestApp" , "localhost" , 500 ) ;
316+ fsConnect . Connect ( "TestApp" , "localhost" , 500 , SimConnectProtocol . Ipv4 ) ;
313317 fsConnect . RegisterDataDefinition < PlaneInfoResponse > ( Requests . PlaneInfo , definition ) ;
314318 }
315319 catch { } // ignore
@@ -452,6 +456,5 @@ private void backgroundWorkerUpdate_DoWork(object sender, System.ComponentModel.
452456 }
453457
454458 #endregion
455-
456459 }
457460}
0 commit comments