Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to set heading bug #14

Closed
markusbuschhoff opened this issue May 1, 2021 · 2 comments · Fixed by #19
Closed

Unable to set heading bug #14

markusbuschhoff opened this issue May 1, 2021 · 2 comments · Fixed by #19
Assignees

Comments

@markusbuschhoff
Copy link

markusbuschhoff commented May 1, 2021

Hi,

I successfully connected to FS2020 and received the heading bug setting using RequestData on FsSimVar.AutopilotHeadingLockDir.
However, I was unable to set the value using a client event. I basically followed the example in the README. After successful connection I call:

        fsConnect.MapClientEventToSimEvent(ev.group, ev.setHeadingBug, FsEventNameId.HeadingBugSet);
        fsConnect.SetNotificationGroupPriority(ev.group);
        fsConnect.TransmitClientEvent(ev.setHeadingBug, (uint) 0, ev.group);

I expected the AP heading selector to switch to 0, but it stays at the heading dialed in. I tried several alternatives (e.g. binding my event to FsEventNameId.HeadingBugInc, FsEventNameId.FlapsIncr), but none worked. However, a call to SetText does show a text popup in MSFS (so, it's probably not a connection issue).

Any help appreciated.

EDIT: Inserted 2nd code line

@TimianHeber TimianHeber self-assigned this May 1, 2021
@TimianHeber
Copy link
Contributor

Hi! I'll look into it this weekend.

@TimianHeber
Copy link
Contributor

HI, I made a quick integration test and the following works for me.
But it seems to be the same as your example, so there may be something else wrong. Please see if the FsError event is raised, maybe something interesting will be reported there, such as duplicate IDs.
Good luck and please let me know if you still have problems!

    [TestFixture, Explicit]
    public class FsConnectIntegrationTest
    {
        enum TestEnums
        {
            GroupId=1234,
            EventId=1235
        }

        [Test]
        public void Test()
        {
            // Arrange
            AutoResetEvent resetEvent = new AutoResetEvent(false);
            int errorCount = 0;

            FsConnect fsConnect = new FsConnect();
            fsConnect.ConnectionChanged += (sender, b) =>
            {
                if (b) resetEvent.Set();
            };
            fsConnect.FsError += (sender, args) =>
            {
                errorCount++;
                Console.WriteLine($"Error: {args.ExceptionDescription}");
            };

            fsConnect.Connect("FsConnectIntegrationTest", 0);

            bool res = resetEvent.WaitOne(2000);
            if (!res) Assert.Fail("Not connected to MSFS within timeout");

            // Act
            fsConnect.MapClientEventToSimEvent(TestEnums.GroupId, TestEnums.EventId, FsEventNameId.HeadingBugSet);
            fsConnect.SetNotificationGroupPriority(TestEnums.GroupId);
            
            fsConnect.TransmitClientEvent(TestEnums.EventId, (uint)DateTime.Now.Second*6, TestEnums.GroupId);

            // Assert
            Assert.That(errorCount, Is.Zero);

            // Teardown
            fsConnect?.Disconnect();
        }
    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants