zuby Posted July 27, 2018 Report Posted July 27, 2018 Hello Paul, I'm receiving the error, "Communication With FSUIPC Faild Group ' ' does not exist.", when FSUIPCConnection.Process is called. when i declare offset into PMDG737MCP then program runs well. how do i resolve that issue? Here is the code below. class PMDGOffset { private static Offset<float> _AIR_SPEED = new Offset<float>(0x6524); public static float AIR_SPEED { get { return _AIR_SPEED.Value; } set { FSUIPCConnection.SendControlToFS(PMDGEvent.EVT_MCP_IAS_SET, (int)value); } } } class PMDG737MCP { public static void Update() { FSUIPCConnection.Process(); txt.Text = PMDGOffset.HEADING.ToString(); } }
Paul Henty Posted July 27, 2018 Report Posted July 27, 2018 The static fields in PMDGOffset are not initialised until you either: Create an instance of that class Call a static method/property on that class It looks like you've not used the PMDGOffset class before you've called Update() Here are some possible solutions: 1. Create an instance of the class when your application starts. You don't need to do anything with it if you don't want it: new PMDGOffset(); 2. Add a static method you can call that will force the static fields to be initialised: internal class PMDGOffsets { private static Offset<float> _AIR_SPEED = new Offset<float>("PMDG", 0x6524); internal static void InitOffsets() { // forces static fields to be initialised. } public static float AIR_SPEED { get { return _AIR_SPEED.Value; } set { FSUIPCConnection.SendControlToFS(PMDG_737_NGX_Control.EVT_MCP_IAS_SET, (int)value); } } } Then call PMDGOffsets.InitOffsets() when your program starts. The InitOffsets() method doesn't need to do anything. I recommend that you use offset grouping so that you only process the offsets you need. In the code above, I've changed the airspeed to be in the PMDG group. You would then process just this group in the update class: class PMDG737MCP { public static void Update() { FSUIPCConnection.Process("PMDG"); txt.Text = PMDGOffset.HEADING.ToString(); } } Paul
zuby Posted July 28, 2018 Author Report Posted July 28, 2018 Thank you very much Paul...it's working...Now I'm initializing offsets like below, and grouped offsets. private static Offset<float> _AIR_SPEED; internal static void InitOffsets() { _AIR_SPEED = new Offset<float>("PMDG", 0x6524); } also i have question how do i declare left and right Backcourse for reading? below is the list of PMDG offsets mapping from pdf. but declaration not mentioned. could guide me. thanks 6520 4 WORD x 2 MCP_Course[2]
Paul Henty Posted July 28, 2018 Report Posted July 28, 2018 6520 | 4 | WORD x 2 | MCP_Course[2] From left to right, this means... The data starts at offset 6520 The total length of the data is 4 Bytes. The data is 2 Words (1 Word = 2 bytes = short in c#). The first word (2 bytes) is for one MCP course (probably left), the second word is for the other (probably right). The easiest way to deal with this is to declare 2 ushort offsets for each word. The first one starts at 6520, the second will start 2 bytes later at 6522. e.g. private offset<ushort> MCP_Course_Left = new offset<ushort>("PMDG", 0x6520) private offset<ushort> MCP_Course_Right = new offset<ushort>("PMDG", 0x6522) Paul
zuby Posted July 28, 2018 Author Report Posted July 28, 2018 Oh!....I was understanding that it will be declared as an array....Now I understood :) Under of thanks Paul for your help and time.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now