Jump to content
The simFlight Network Forums
zuby

FSUIPCConnection.Process problem

Recommended Posts

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();
            
        }  
}

 

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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]

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

Oh!....I was understanding that it will be declared as an array....Now I understood :)

Under of thanks Paul for your help and time.

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now

×

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.