Jump to content
The simFlight Network Forums

Paul Henty

Members
  • Posts

    1,728
  • Joined

  • Days Won

    78

Everything posted by Paul Henty

  1. Hi Rob, I can't test this here as I don't have P3D. If other controls work it could be a P3D or Simconnect bug. I think @John Dowson will be able to look into this a bit more. In the mean time, a useful test would be to map a key or joystick press directly to one of these menu controls. See if these controls work there. Paul
  2. Thank John, What about 0x3308? Will that still be 12 (meaning all P3D 64bit versions)? Paul
  3. I don't know. I'm sure @John Dowson will be able to tell us. If it's different than P3D V4 I will add a new entry to the Enum. Paul
  4. Glad you got it sorted. To answer the above question... These kind of helper methods (getPositionSnapshot(), ReadLVAR() etc.) all do a Process() in the background. You only need to call Process() to handle your own Offsets. It's not required when you use any helper method or module (e.g PayloadServices). Paul
  5. You can't run two connections in the same application. It's not designed like that. It wouldn't help much as I think FSUIPC can only serve one client at a time anyway. The DLL is thread-safe however. So you can use it in a multi-threaded application. For example you can call Process() methods on a background worker thread. This is useful for not blocking the GUI thread and making it feel unresponsive. It's also useful if you have other processing that might slow down the Process() calls - you can put the other processing on its own thread too. Theoretically, you can call Process() and access Offsets from multiple parallel threads. However, I'd advise against this for two reasons: It's complicated to debug Only one Process() call can be communicating with FSUIPC at a time. If you call Process() on thread B before Process() on thread A is finished, thread B will be blocked until thread A completes. So, yes, you can have the Process() calls being made in their own thread, but keep it simple; don't have multiple threads firing off requests to FSUIPC all over the place unless you really know what you're doing. You only need to create the offsets and open the connection once (on any thread). The offsets and that connection can be accessed by any other thread you create. Paul
  6. These are not BitArrays, they are Byte Arrays. Two bytes long. Each byte is either 0 or 1. The BitArray type offsets list what each bit represents. These offsets don't say that, they say 'boolean' which is a single value: 1 or 0. The best way to handle these is to declare two offsets as bytes. Each byte offset will be one of the lights. You will need two offset addresses, one will be the address as stated, the next one will be that address + 1. For example for the FUEL_annunLOWPRESS_Fwd: private Offset<byte> fuelfwdL = new Offset<byte>("fuelfwd", 0x646A); private Offset<byte> fuelfwdR = new Offset<byte>("fuelfwd", 0x646B); The fuelFwdR offset the address is 0x646B which is (0x064A + 1). Then test for 1 or 0: string fuelfwdl = (this.fuelfwdL.Value == 1) ? "On" : "Off"; string fuelfwdr = (this.fuelfwdR.Value == 1) ? "On" : "Off"; Paul
  7. Those Offsets are marked in the document as 'FLT32'. Those are not integers but floating point values. You just need to declare those offsets as 'float', i.e. Offset<float>. No conversion should be required; the 'Value' should just contain the gauge value. Paul
  8. I can't see any way of switching the G1000 off alone. You can switch it off with the Avionics Master switch 0x2E80 but this might affect other things as well. Paul
  9. Please see my reply in the other thread you made.
  10. I also cannot find any offsets for a standby battery. I assume this picture is from a third-party add-on aircraft. If it is, the makers of the aircraft are simulating this switch themselves. There may not be a way to access this switch at all, but here are some things you can try: 1. Use the FSUIPC logging tab to log 'Events' to a console window. Operate the switch. You might see a control number being logged. You can use this to control the switch. 2. Use FSUIPC to bind a key (or joystick press) to log all the known LVars. Again, set the log to go to a console window in the logging tab. Press the key/button and look through the resulting LVars list. You might see something about the standby battery. If you do you can use the facilities in the DLL to read and write the LVar. 3. You might be able to use FSUIPC to set up a "mouse macro" to control this switch. If you can make one you can execute it via the DLL. Which method works will depend on how the author has made the aircraft. Maybe none of these will work. If you say which aircraft it is someone who knows it might be able to help. Paul
  11. Offset 0x0C4E is the OBS for Nav1. This returns 0 to 360. I think you are now talking about the autopilot heading at 0x07CC. This is also 2 bytes. But it returns the heading between 0 and 65535. This is allow for decimal heading like 132.2 degrees. You just need to convert the value like this: double crs1Degrees = (double)CRS1.Value / 65536d * 360d; This is explained in the "FSUIPC5 Offsets Status" PDF. Paul
  12. That number is very large. I think you have declared the Offset as 'int'. It is only 2 Bytes long so you need to declare it as 'ushort'. Paul
  13. Maybe you're using an old version. Try updating through the NuGet package manager. Instructions here: https://www.youtube.com/watch?v=MoppPMp31nc Paul
  14. Try deleting the line and typing it in by hand. (No copy and paste). Paul
  15. Yes, that all looks fine. Can you get a screenshot of the error in Visual Studio? Paul
  16. It's correct, but make sure you put it in the correct place. It goes at the class (or form) level. Next to any offsets you have declared. Not in any methods or functions. If you can't get it working show me a bit more of your code. Paul
  17. Yes, that's fine. Thanks. If you want to experiment with this, the CDU text is quite easy to get with the DLL. First, see the PMDG offsets document for an entry you need to add to your .INI file. And for the starting offset of the two CDU screens. Declare an instance of the CDU screen class: (Pass the starting offset): private PMDG_NGX_CDU_Screen CDU0 = new PMDG_NGX_CDU_Screen(0x5400); // CDU 0 in 737 Then use it like this: private void CDUExample() { this.CDU0.RefreshData(); // Call RefreshData to get the latest text string cduText = ""; // Powered property lets you know if it's on or off: if (CDU0.Powered) { // Get the entire screen in one string. // Delimiter passed as parameter. In this case, new line. cduText = this.CDU0.ToString("\r\n"); } else { cduText = "No Power"; } // OR, you can get a specific row of text, use the Rows collection: // (First row is row 0) string row3Text = this.CDU0.Rows[2].ToString(); // Use normal string functions to search in the row: if (row3Text.Substring(5,2) == "ON") { // do something } else { // do something else } } Paul
  18. I can't see an offset either. You could try looking through the LVars to see if there is one for chocks. It may be that it's not possible to get this information. Developers don't always make everything accessible from outside. I think PMDG has forums. You could try asking there. Paul
  19. No, that's worse. That's an infinite loop that will run run as fast as possible. It will also block any user input to the application. It looks like you need to learn the basics of writing applications in C#. (That's really beyond the scope of what I can support here). I don't know what you want the application to do, so I don't really know if you need a timer or not. Generally you need a timer if you want the application to run automatically without user input, or if you want to display data in real time. For example, if you want your application to open and close doors automatically then you need a timer. If you want to display the state of the doors to the user in real time then you also need a timer. Note that if you're using the automatic connection template there are two timers. One of them tries to make connections to FSUIPC when the app is disconnected. This is required if you want an automatic connection. If you can describe what your app should do I might be able to give some general advice about how to structure the program. Paul
  20. It sounds like you've put this in the timer loop of the template you used. The timer method gets called a few times per second (maybe 20 I can't remember exactly). This is good if you're trying to get data in real time, but it doesn't make sense to put door commands here. You need to organise the code so that the appropriate things and in the timer loop and other things are outside. For example, maybe you want the doors opening on a button press. So you'll need to make a button and put the code on the click event. It might be that your application doesn't even need a timer, but I don't know the details of what you're trying to do here. Paul
  21. You should always use offsets if you can. Reading LVars is very slow compared to using offsets. Only use LVars as a last resort, when there are no offsets or controls (events). I think you can control the door using the PMDG custom controls (events). Send events using FSUIPCConnection.SendControlToFS(). There is an enum for the PMDG controls to make this easy. I think this might work: FSUIPCConnection.SendControlToFS(PMDG_737_NGX_Control.EVT_DOOR_FWD_L, 1); I'm not sure of the parameter though (I don't use PMDG). It might be 1 = open, 0 = Closed. Or the parameter maybe ignored and the door just toggles whenever you send the control. You can test this out for yourself. The enum PMDG_737_MGX_Control contains the other door commands which you will see on the popup when you type the "." after it. I can't see any way to do this. If the PMDG aircraft loads a flight plan into the FlightSim you might be able to get the destination airport from offset 0x6137. Declare as a string of length 5. Paul
  22. Your code looks fine, however I can't advise on how to use the GSX LVars as I don't have this product. Maybe you're writing the wrong values, or maybe these variables are read-only. Do you have any documentation for this? You'll probably need to ask on GSX support forums if they have them, or ask them directly. Paul
  23. If you want to convert it, you need to convert the Value of the offset, rather than the Offset itself: bool result = Convert.ToBoolean(maincabindoor.Value); However, you don't have to convert it - you can just test the value being 1 or 0: if (maincabindoor.Value == 1) { // Door is open } else { // Door is closed } Or maybe do something like this to get a string you can display: string mainDoorState = maincabindoor.Value == 1 ? "Open" : "Closed"; Depends on what you want to do with it. Paul
  24. It's not a name, it tells the ToString() method to format the string. "F2" means format this as a floating point number with 2 decimal places. F4 will give you 4 decimal places etc. There are other formatting options which you can see in the normal Microsoft documentation for Double.ToString(). Mostly offsets store numbers (values) or strings. However there are a few like 0x3367 that use the individual bits (there are 8 bits in each byte) for different functions. In this case each door is represented by a different 'bit'. (A bit can either be 0 (closed) or 1 (open)). The DLL has an easy way of dealing with these types of 'bitwise' offsets. The offset just needs to be declared as a BitArray. The ExampleCode application has a section explaining how to declare and use BitArray offsets. See "AC002_BitArrays" under "Advanced Concepts". The example is for the lights offset, but the doors work the same way. Just remember that 0x3367 is only 1 byte long. The lights offset (0x0D0C) in the example is 2 bytes. You'll need to specify the length when you declare the offset. 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.