Jump to content
The simFlight Network Forums

Paul Henty

Members
  • Posts

    1,724
  • Joined

  • Days Won

    76

Everything posted by Paul Henty

  1. Hi Jason, I can have a look and see if anything can be done. I don't have MSFS however. Would you be able to zip and attach the MakeRunways files make with MSFS so I can test with those? Runways.xml F5.csv R5.csv G5.csv Helipads.csv T5.csv Paul
  2. For regular updates you just need to keep calling the code I've put in btnLoad_Click(). That can all go in your timer tick() function (or a separate method that you call from tick()). All other code is configuration and can just be done once. The time taken to build a new list for the datagrid is negligible (<1 ms). If you keep the list in memory and try to update it with the new information it's going to be far more trouble than it's worth. Paul
  3. Hi Tony, The coms frequencies for airports are available in the FsAirport.COMFrequencies property. This is a collection of FsAirportComFrequency objects which contain the name, type and frequency of all the coms available at the airport. Getting them into the grid is not as simple as the other properties (e.g. ICAO) as the grid doesn't know what to do with collections, so you'll need to use the grid in a more laborious way: The full code is pasted below. It will work on a form with a button and a datagrid. The basic idea is this: (Same numbers are used in code comments) Create a new class that will hold the data displayed in each row of the grid. Setup the columns in the gridview control Set current location and get airports in range Create a new list to store all the new grid items: Create a datagrid item for each airport Go through com frequencies for the airport and add an extra grid row for each public partial class frmAirportsWithComs : Form { // 1. Create a new class that will hold the data displayed in each row of the grid. private class DataGridItem { public string ICAO { get; set; } public string Name { get; set; } public string City { get; set; } public string Distance { get; set; } public string Bearing { get; set; } public string Coms { get; set; } } public frmAirportsWithComs() { InitializeComponent(); FSUIPCConnection.Open(); configureGrid(); FSUIPCConnection.AirportsDatabase.Load(); } // 2. Setup the columns in the gridview control private void configureGrid() { this.dataGridView1.AutoGenerateColumns = false; DataGridViewColumnCollection cols = this.dataGridView1.Columns; cols.Add(createColumn("ICAO", 60, null)); cols.Add(createColumn("Name", 120, null)); cols.Add(createColumn("City", 120, null)); cols.Add(createColumn("Distance", 60, null)); cols.Add(createColumn("Bearing", 60, null)); cols.Add(createColumn("Coms", 120, null)); } private DataGridViewColumn createColumn(string propertyName, int width, string format) { DataGridViewTextBoxColumn col = new DataGridViewTextBoxColumn(); col.DataPropertyName = propertyName; col.HeaderText = propertyName; col.Name = propertyName; col.ReadOnly = true; col.Resizable = DataGridViewTriState.True; col.Width = width; if (!string.IsNullOrWhiteSpace(format)) { col.DefaultCellStyle.Format = format; col.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight; } return col; } private void btnLoad_Click(object sender, EventArgs e) { // 3. Set current location and get airports in range FSUIPCConnection.AirportsDatabase.SetReferenceLocation(); FsAirportCollection airports = FSUIPCConnection.AirportsDatabase.Airports; airports = airports.InRangeOfNauticalMiles(40); airports = airports.WithRunway(rw => rw.LengthFeet > 100); // Now we have the airports we need // 4. Create a new list to store all the new grid items: List<DataGridItem> gridItems = new List<DataGridItem>(); // 5. create a datagrid item for each airport foreach (FsAirport ap in airports) { // Create new grid item and add the list DataGridItem item = new DataGridItem(); gridItems.Add(item); // Set the basic properties item.ICAO = ap.ICAO; item.Name = ap.Name; item.City = ap.City; item.Distance = ap.DistanceNauticalMiles.ToString("F2"); item.Bearing = ap.BearingToMagnetic.ToString("000"); // 6. Go through com frequencies for the airport and add an extra grid row for each for (int i = 0; i < ap.COMFrequencies.Count; i++) { // get the next frequency for the airport FsAirportComFrequency freq = ap.COMFrequencies[i]; // if this is not the first com frequency then make a new grid item so it appears on a new row if (i > 0) { item = new DataGridItem(); gridItems.Add(item); } // Add the frequency information item.Coms = freq.ComType.ToString() + ":" + freq.Frequency; } } // Display the grid items this.dataGridView1.DataSource = gridItems; } } Paul
  4. Thanks for the test. That looks to me like a problem on the FSUIPC end. We'll see if John can find anything when he gets back next week, Paul
  5. Hi John, I can't see anything wrong with your code. Have you tried just writing a basic offset - e.g. declare a standard int offset for 7F00 and just write 1 and 0 to it and see if it has any effect? Should activate the first button on stick 64. If you're using FSUIPC7, the offsets list I have says this offset has not been tested/has unknown status. I can't check it here but maybe @John Dowsoncould have a quick look at this offset in FSUIPC7 and confirm if it's working or not. Paul
  6. SetValue() can be used on any writable offset which is most of them listed in the FSUIPC Offsets Status pdf. These offsets mainly map to K Variables internally. Events (Also known as controls) can be sent using FSUIPCConnection.SendControlToFS(). The PMDG SDK uses different methods for reading and controlling the aircraft. Using FSUIPC, reading is done with the special offset area. Controlling the aircraft is done by sending controls (events). There are helper Enums built into my DLL for PMDG aircraft (e.g. PMDG_737_NGX_Control). The values of these can be passed to FSUIPCConnection.SendControlToFS(). You also need to send a parameter value with the control. This can be a direct value (e.g. 0 or 1 for simple off/on switches) or a mouse button code to simulate a mouse click. See the PMDG .h file for details of the mouse codes. Paul
  7. Hi, There are a few mistakes: 1. You're not calling Process(): This is the main problem. Process() tells my DLL to get the latest values from FSUIPC. Without that nothing is ever read. Offset myOffset = new Offset(address, variableLength); FSUIPCConnection.Process(); 2. Your first switch statement doesn't contain an entry for 'bool' so the variableLength will be 0. 3. You're trying to convert to float but asking for an Int64... valueFloat = Convert.ToInt64(...); should be: valueFloat = Convert.ToSingle(...); 4. 'bool' and 'char' are not supported by my DLL as they have no equivalents in FSUIPC. Bools in FSUIPC are stored as integers of any size with a value of 0 or 1. For the PMDG offsets they are usually a 'byte' type (Length 1) with the value 0 or 1. You'll need something like this: case "Bool": byte valueByte = myOffset.GetValue<byte>(); valueFloat = Convert.ToSingle(valueByte); valueBool = (valueByte > 0); break; 5. For Char you should use 'string' if you're trying to get back text from the char[] arrays: Of course these is no way to convert these to float: case "Char": string valueString = myOffset.GetValue<string>(); break; The size of the offset should be set to the number of characters in the PMDG documentation: e.g. for AIR_DisplayLandAlt - char[6] : Offset AIR_DisplayLandAlt = new Offset(0x6572, 6); 6. It's best not to keep opening and closing the connection if possible. Open it when your application starts and close it before it unloads. 7. When you create new temporary offsets it's important to dispose of them. If you don't they stay active and take up space in the FSUIPC data table. Eventually your app will crash because the table will be full. Call the myOffset.Disconnect() method when you're finished with it. This will remove it from the FSUIPC table and allow the .NET garbage collector to dispose of it. With those changes you should be able to read proper values. Paul
  8. There are a number of ways to get the data from the CDU, depending on what level of detail you want. Here are the options: cdu0 = new PMDG_NGX_CDU_Screen(0x5400); cdu0.RefreshData(); // Entire screen this.txtCDU.Text = cdu0.ToString("\r\n"); // Individual Rows: string row3Text = cdu0.Rows[2].ToString(); // Rows are 0 based. Third row has index 2 // Individual Cells: // e.g. Character in Row 3 (Index 2), First Character (Index 0): char R3C1Char = cdu0.Rows[2].Cells[0].Symbol; // Same but as a string: string R3C1String = cdu0.Rows[2].Cells[0].ToString(); // Get cell colour: PMDG_NGX_CDU_COLOR R3C1Colour = cdu0.Rows[2].Cells[0].Color; // Get cell Flag: PMDG_NGX_CDU_FLAG R3C1Flags = cdu0.Rows[2].Cells[0].Flags; // Flags values can be combined (e.g. Small and Reversed). To check if a certain bit is set use the HasFlag method: bool cellIsReversed = R3C1Flags.HasFlag(PMDG_NGX_CDU_FLAG.REVERSE); Paul
  9. It's not possible to read and write SimVars directly using FSUIPC. If you ask John Dowson in the MSFS (FSUIPC7) support forum he might add this variable as a new offset. Paul
  10. You can combine the modifier keys by using the bitwise or operator |. Like this: SendModifierKeys.Shift | SendModifierKeys.Control | SendModifierKeys.Alt Paul
  11. It looks likes there is a very old version of my DLL in the SDK. Version 2.4. You should use the latest from NuGet instead. Paul
  12. Hi Mattias, My DLL is only available on NuGet. You need to use the NuGet package manager to install it into your project. Search NuGet for FSUIPC. SendKeyToFS is available when connected to FSUIPC7. Paul
  13. Thanks for the files. The problem was the user has an airport with an ICAO code of "0". My code assumed 3 or 4 characters. I've fixed this in version 3.2.25, now available on NuGet. Any length of ICAO is now supported. Paul
  14. Hi Peter, The problem is going to be specific to your user's scenery (e.g. third party airports etc). Maybe one of the airports has a strange character in the name, or a missing runway number or something. The easiest way to solve this is if I could get the MakeRunways output files from the user's computer. I could then run the load() here and see what's causing the problem. I'll be able to put a check or workaround in my code to stop it crashing. I'll need: Runways.xml F5.csv R5.csv G5.csv Helipads.csv T5.csv If your user is not willing to send these to you then I'll come up with another plan. Paul
  15. Hi Cliff, The FSUIPC protocol is based on the Win32 API, specifically sending messages between processes using the windows message pump. So the FSUIPC part is tied exclusively to the Windows operating system. It can't work on the Pi. For non-windows operating systems, one option is to use my WebSocketServer which allows reads and writes to offsets over a standard TCP WebSocket connection. The server runs on the Flight Sim PC and the data is exchanged using JSON format. Details are here: http://fsuipcwebsockets.paulhenty.com/ You can use any tech that can can use WebSockets and JSON. If you're using .NET on the Pi there is a .NET library to make this process much easier called "FSUIPCWebSocketClientDLL" (also on NuGet). This library is very cross platform and targets .NET Standard 2 as well as more specific frameworks like .NET6 and Mono. It sets up and handles the websocket for you and does the conversion to/from JSON. The website above also includes details of this client DLL and has example code in C# and VB.NET and Javascript (for those using it from webbrowsers). An alternative would be to create your own client/server protocol to send messages to/from the Pi. There's no way to talk to FSUIPC directly on the Pi, you have to have some kind of bridge. Paul
  16. Hi Everyone, Version 3.2.24-beta is now on Nuget. This has a single, combined PMDG_737_NGX_Offsets class which automatically maps the offsets to the correct address depending on the simulator being used. Thanks to Andy B. for the idea. In theory you should be able to use existing PMDG code with no changes and have it work with any simulator. Except: In order to determine the simulator being used, the class now needs an open connection when it's created. If you are currently calling "new PMDG_737_NGX_Offsets()" before your connection is open, you need to delay it until after the connection is open. The PMDG_737_MSFS_Offsets class has been deleted. There are a couple of offsets that have had their type corrected (e.g. vertical speed is now signed instead of unsigned). Also if anyone is using specific WideClient class instances, you now pass the class instance to the constructor and not to RefreshData(). Paul
  17. Yes, that's a great idea. I've had a look and it's possible to do a combined class. I didn't realise the offsets names were almost identical. The new MSFS class will be scrapped and I'll extend the old NGX class to include any new MSFS offsets. When you instantiate the class it will look at the flight sim you are connected to and create the offsets with the correct addresses. I'll have a new beta out later today. Paul
  18. Yes, I'll fix it. The documentation says this is a byte array instead of a character array so that's why it's wrong. I'll have a new beta version out soon. I'll be getting rid of the new MSFS version of the 737 offsets class and amending the original 'NGX' to intelligently switch to the MSFS offsets when connected to MSFS. The offsets names will be the same, you'll just have to change the class name where you instantiate it. Paul
  19. @John DowsonI've marked this method as obsolete now and linked to the other FAQ. I didn't want to delete it as it would create dead links on the forum. It might be an idea to unpin it though. (Or delete it if you don't mind the dead links.) Paul
  20. A new version of my DLL is now on NuGet (3.2.23-beta). You will need to tick the [show pre-release] box in the NuGet package manager to see this version. The current PMDG_737_NGX_Controls enum has been updated with the new controls for the MSFS 737s. There is also a new class called PMDG_737_MFSF_Offsets for the MSFS versions of the PMDG 737s. This works like the previous offset helpers. Details in this post if you're unfamiliar: Paul
  21. New version is now on NuGet (3.2.23-beta). You will need to tick the [show pre-release] box in the NuGet package manager to see this version. The current PMDG_737_NGX_Controls enum has been updated with the new controls for the MSFS 737s. The offsets for the MSFS version are very different to previous versions, so there is a new class called PMDG_737_MFSF_Offsets that contains the new offsets. This works like the previous offset helpers. Details in this post for anyone unfamiliar: Paul
  22. New version is now on NuGet (3.2.23-beta). You will need to tick the [show pre-release] box in the NuGet package manager to see this version. IsRunning should now behave properly. I can't test it here so I'd be grateful if you could let me know if works or not. Paul
  23. Thanks for the document. I've just looked at the WebSocketServer - There's no need for a new version. It just needs the WAPID dll replacing with the new 0.9.1 version, but it looks like you've already done that in the latest installer. So everything looks okay. Paul
  24. Yes, I'll get a new version to you by the end of today. Is the latest version of the PMDG Offsets list the MSFS 737 in this post? Paul
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use. Guidelines Privacy Policy We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.