Example #1
0
        public void OverrideGroundTrafficINISettings(ATCIdentifier?ATCId, bool?PreferActive, byte?RangeInAirInNM, byte?RangeOnGroundInNM)
        {
            bool flag = false;

            if (ATCId.HasValue)
            {
                this.AIOptGroundIDString.Value = (byte)ATCId.Value;
                flag = true;
            }
            if (PreferActive.HasValue)
            {
                this.AIOptGroundPreferActive.Value = PreferActive.Value ? (byte)1 : (byte)0;
                flag = true;
            }
            byte?nullable1 = RangeInAirInNM;

            if ((nullable1.HasValue ? new int?((int)nullable1.GetValueOrDefault()) : new int?()).HasValue)
            {
                this.AIOptGroundRangeInAir.Value = RangeInAirInNM.Value;
                flag = true;
            }
            byte?nullable2 = RangeOnGroundInNM;

            if ((nullable2.HasValue ? new int?((int)nullable2.GetValueOrDefault()) : new int?()).HasValue)
            {
                this.AIOptGroundRangeOnGround.Value = RangeOnGroundInNM.Value;
                flag = true;
            }
            if (!flag)
            {
                return;
            }
            FSUIPCConnection.Process(this.classInstance, this.AIWriteOptionsGroupGround);
        }
Example #2
0
        public void RemoveAll()
        {
            if (this.keySlotIndicators.Count + this.buttonSlotIndicators.Count + this.menuSlotIndicators.Count <= 0)
            {
                return;
            }
            IDictionaryEnumerator enumerator1 = (IDictionaryEnumerator)this.keySlotIndicators.GetEnumerator();

            while (enumerator1.MoveNext())
            {
                new Offset <int>(this.temporaryGroup, this.keySlotIndicators[enumerator1.Key.ToString()].Address - 3, true).Value = 0;
            }
            IDictionaryEnumerator enumerator2 = (IDictionaryEnumerator)this.buttonSlotIndicators.GetEnumerator();

            while (enumerator2.MoveNext())
            {
                new Offset <int>(this.temporaryGroup, this.buttonSlotIndicators[enumerator2.Key.ToString()].Address - 3, true).Value = 0;
            }
            IDictionaryEnumerator enumerator3 = (IDictionaryEnumerator)this.menuSlotIndicators.GetEnumerator();

            while (enumerator3.MoveNext())
            {
                new Offset <int>(this.temporaryGroup, this.menuSlotIndicators[enumerator3.Key.ToString()].Address - 3, true).Value = 0;
            }
            FSUIPCConnection.Process(this.classinstance, this.temporaryGroup);
            FSUIPCConnection.DeleteGroup(this.temporaryGroup);
            FSUIPCConnection.DeleteGroup(this.pollingSlotsGroup);
            this.menuSlotIndicators.Clear();
            this.buttonSlotIndicators.Clear();
            this.keySlotIndicators.Clear();
        }
Example #3
0
        private string getATCString(int ID, int Command)
        {
            int num = 4112;

            this.atcInfoCommand.Value   = Command;
            this.atcInfoAiID.Value      = ID;
            this.atcInfoSignature.Value = num;
            FSUIPCConnection.Process(this.classInstance, this.AITrafficIDStringGroupWrite);
            Thread.Sleep(10);
            FSUIPCConnection.Process(this.classInstance, this.AITrafficIDStringGroupTest);
            while (this.atcInfoTimeStampInit.Value == this.atcInfoTimeStamp.Value)
            {
                Thread.Sleep(10);
                FSUIPCConnection.Process(this.classInstance, this.AITrafficIDStringGroupTest);
            }
            FSUIPCConnection.Process(this.classInstance, this.AITrafficIDStringGroupRead);
            string str1 = Encoding.ASCII.GetString(this.atcInfoString.Value);
            string str2;

            if (Command == 3)
            {
                int length = str1.IndexOf(char.MinValue);
                str2 = str1.Substring(0, length) + "~" + str1.Substring(length + 1, str1.IndexOf(char.MinValue, length + 1) - length - 1);
            }
            else
            {
                str2 = str1.Substring(0, str1.IndexOf(char.MinValue));
            }
            return(str2);
        }
Example #4
0
 public static void Process(byte ClassInstance, string GroupName)
 {
     FSUIPCConnection.Process(ClassInstance, (IEnumerable <string>) new List <string>()
     {
         GroupName
     });
 }
Example #5
0
 public void RemoveJoystickButtonPress(string ID)
 {
     new Offset <int>(this.temporaryGroup, this.buttonSlotIndicators[ID].Address - 3, true).Value = 0;
     FSUIPCConnection.Process(this.classinstance, this.temporaryGroup);
     FSUIPCConnection.DeleteGroup(this.temporaryGroup);
     this.buttonSlotIndicators[ID].Disconnect();
     this.buttonSlotIndicators.Remove(ID);
 }
Example #6
0
 public void RemoveMenuItem(string ID)
 {
     new Offset <int>(this.temporaryGroup, this.menuSlotIndicators[ID].Address - 3, true).Value = 0;
     FSUIPCConnection.Process(this.classinstance, this.temporaryGroup);
     FSUIPCConnection.DeleteGroup(this.temporaryGroup);
     this.menuSlotIndicators[ID].Disconnect();
     this.menuSlotIndicators.Remove(ID);
     this.menuKeepAlives[ID].Disconnect();
     this.menuKeepAlives.Remove(ID);
 }
Example #7
0
        public void KeepMenuItemsAlive()
        {
            if (this.menuKeepAlives.Count <= 0)
            {
                return;
            }
            IDictionaryEnumerator enumerator = (IDictionaryEnumerator)this.menuKeepAlives.GetEnumerator();

            while (enumerator.MoveNext())
            {
                ((Offset <byte>)enumerator.Value).Value = byte.MaxValue;
            }
            FSUIPCConnection.Process(this.classinstance, this.keepAliveGroup);
        }
Example #8
0
 public void SendTCASTargets()
 {
     if (this.aiTCASTargets.Count <= 0)
     {
         return;
     }
     foreach (AIPlaneInfo aiTcasTarget in this.aiTCASTargets)
     {
         new Offset <byte[]>(this.AITCASWrite, 8064, 40, true).Value = aiTcasTarget.getTCASByteArray();
     }
     FSUIPCConnection.Process(this.classInstance, this.AITCASWrite);
     FSUIPCConnection.DeleteGroup(this.AITCASWrite);
     this.aiTCASTargets.Clear();
 }
Example #9
0
        internal UserInputServices(byte ClassInstance)
        {
            this.classinstance           = ClassInstance;
            this.temporaryGroup         += this.classinstance.ToString();
            this.pollingSlotsGroup      += this.classinstance.ToString();
            this.pollingSlotsResetGroup += this.classinstance.ToString();
            this.keepAliveGroup         += this.classinstance.ToString();
            Offset <int> offset1 = new Offset <int>(this.temporaryGroup, 10508);
            Offset <int> offset2 = new Offset <int>(this.temporaryGroup, 12812);

            FSUIPCConnection.Process(this.classinstance, this.temporaryGroup);
            this.keySlotCount    = offset2.Value;
            this.buttonSlotCount = offset1.Value;
            FSUIPCConnection.DeleteGroup(this.temporaryGroup);
        }
Example #10
0
        public void AddJoystickButtonPress(string ID, byte JoystickNumber, byte ButtonNumber, StateChange StateChangeToDetect)
        {
            if (this.buttonSlotCount <= 0 || this.buttonSlotCount >= 9000)
            {
                throw new FSUIPCException(FSUIPCError.FSUIPC_ERR_VERSION, "This version of FSUIPC is too old to support joystick button user input.");
            }
            int freeSlot = this.findFreeSlot(this.buttonSlotsBase, this.buttonSlotCount);

            if (freeSlot < 0)
            {
                throw new FSUIPCException(FSUIPCError.FSUIPC_BUTTON_SLOTS_FULL, "Cannot add button press: " + ID);
            }
            new Offset <int>(this.temporaryGroup, this.buttonSlotsBase + freeSlot * 4, true).Value = this.assembleInt((byte)((uint)JoystickNumber + 128U), ButtonNumber, (byte)StateChangeToDetect);
            FSUIPCConnection.Process(this.classinstance, this.temporaryGroup);
            FSUIPCConnection.DeleteGroup(this.temporaryGroup);
            Offset <byte> offset = new Offset <byte>(this.pollingSlotsGroup, this.buttonSlotsBase + freeSlot * 4 + 3);

            this.buttonSlotIndicators.Add(ID, offset);
        }
Example #11
0
        public void AddKeyPresss(string ID, ModifierKeys Modifier, Keys Key, bool PassThroughToFS)
        {
            if (this.keySlotCount <= 0 || this.keySlotCount >= 9000)
            {
                throw new FSUIPCException(FSUIPCError.FSUIPC_ERR_VERSION, "This version of FSUIPC is too old to support hot key user input.");
            }
            int freeSlot = this.findFreeSlot(this.keySlotsBase, this.keySlotCount);

            if (freeSlot < 0)
            {
                throw new FSUIPCException(FSUIPCError.FSUIPC_KEY_SLOTS_FULL, "Cannot add keypress: " + ID);
            }
            new Offset <int>(this.temporaryGroup, this.keySlotsBase + freeSlot * 4, true).Value = this.assembleInt((byte)Key, (byte)Modifier, PassThroughToFS ? (byte)2 : (byte)0);
            FSUIPCConnection.Process(this.classinstance, this.temporaryGroup);
            FSUIPCConnection.DeleteGroup(this.temporaryGroup);
            Offset <byte> offset = new Offset <byte>(this.pollingSlotsGroup, this.keySlotsBase + freeSlot * 4 + 3);

            this.keySlotIndicators.Add(ID, offset);
        }
Example #12
0
        private int findFreeSlot(int slotsBase, int slotCount)
        {
            int num = -1;

            Offset <int>[] offsetArray = new Offset <int> [slotCount];
            for (int index = 0; index < slotCount; ++index)
            {
                offsetArray[index] = new Offset <int>(this.temporaryGroup, slotsBase + 4 * index);
            }
            FSUIPCConnection.Process(this.classinstance, this.temporaryGroup);
            for (int index = 0; index < slotCount && num < 0; ++index)
            {
                if (offsetArray[index].Value == 0)
                {
                    num = index;
                }
            }
            FSUIPCConnection.DeleteGroup(this.temporaryGroup);
            return(num);
        }
Example #13
0
        public void OverrideAirborneTrafficINISettings(ATCIdentifier?ATCId, byte?RangeInNM)
        {
            bool flag = false;

            if (ATCId.HasValue)
            {
                this.AIOptAirIDString.Value = (byte)ATCId.Value;
                flag = true;
            }
            byte?nullable = RangeInNM;

            if ((nullable.HasValue ? new int?((int)nullable.GetValueOrDefault()) : new int?()).HasValue)
            {
                this.AIOptAirRange.Value = RangeInNM.Value;
                flag = true;
            }
            if (!flag)
            {
                return;
            }
            FSUIPCConnection.Process(this.classInstance, this.AIWriteOptionsGroupAirborne);
        }
Example #14
0
        public void AddMenuItem(string ID, string MenuText, bool PauseFSOnSelection)
        {
            if (this.keySlotCount <= 0 || this.keySlotCount >= 9000)
            {
                throw new FSUIPCException(FSUIPCError.FSUIPC_ERR_VERSION, "This version of FSUIPC is too old to support adding FS menu items.");
            }
            int freeSlot = this.findFreeSlot(this.keySlotsBase, this.keySlotCount);

            if (freeSlot < 0)
            {
                throw new FSUIPCException(FSUIPCError.FSUIPC_KEY_SLOTS_FULL, "Cannot add menu item: " + ID);
            }
            new Offset <int>(this.temporaryGroup, this.keySlotsBase + freeSlot * 4, true).Value = this.assembleInt(byte.MaxValue, byte.MaxValue, PauseFSOnSelection ? (byte)2 : (byte)0);
            new Offset <string>(this.temporaryGroup, 12256, 31, true).Value = new string(Convert.ToChar(freeSlot), 1) + MenuText;
            FSUIPCConnection.Process(this.classinstance, this.temporaryGroup);
            FSUIPCConnection.DeleteGroup(this.temporaryGroup);
            Offset <byte> offset1 = new Offset <byte>(this.pollingSlotsGroup, this.keySlotsBase + freeSlot * 4 + 3);

            this.menuSlotIndicators.Add(ID, offset1);
            Offset <byte> offset2 = new Offset <byte>(this.keepAliveGroup, this.keySlotsBase + freeSlot * 4 + 1, true);

            this.menuKeepAlives.Add(ID, offset2);
            Thread.Sleep(250);
        }
Example #15
0
 public static void Process(byte ClassInstance)
 {
     FSUIPCConnection.Process(ClassInstance, "");
 }
Example #16
0
        public void RefreshData()
        {
            Offset <int>    offset1  = new Offset <int>(this.payloadGroup, 5116);
            Offset <double> offset2  = new Offset <double>(this.payloadGroup, 12480);
            Offset <int>    offset3  = new Offset <int>(this.payloadGroup, 2932);
            Offset <int>    offset4  = new Offset <int>(this.payloadGroup, 2936);
            Offset <int>    offset5  = new Offset <int>(this.payloadGroup, 2940);
            Offset <int>    offset6  = new Offset <int>(this.payloadGroup, 2944);
            Offset <int>    offset7  = new Offset <int>(this.payloadGroup, 2948);
            Offset <int>    offset8  = new Offset <int>(this.payloadGroup, 2952);
            Offset <int>    offset9  = new Offset <int>(this.payloadGroup, 2956);
            Offset <int>    offset10 = new Offset <int>(this.payloadGroup, 2960);
            Offset <int>    offset11 = new Offset <int>(this.payloadGroup, 2964);
            Offset <int>    offset12 = new Offset <int>(this.payloadGroup, 2968);
            Offset <int>    offset13 = new Offset <int>(this.payloadGroup, 2972);
            Offset <int>    offset14 = new Offset <int>(this.payloadGroup, 2976);
            Offset <int>    offset15 = new Offset <int>(this.payloadGroup, 2980);
            Offset <int>    offset16 = new Offset <int>(this.payloadGroup, 2984);
            Offset <int>    offset17 = new Offset <int>(this.payloadGroup, 4676);
            Offset <int>    offset18 = new Offset <int>(this.payloadGroup, 4680);
            Offset <int>    offset19 = new Offset <int>(this.payloadGroup, 4684);
            Offset <int>    offset20 = new Offset <int>(this.payloadGroup, 4688);
            Offset <int>    offset21 = new Offset <int>(this.payloadGroup, 4692);
            Offset <int>    offset22 = new Offset <int>(this.payloadGroup, 4696);
            Offset <int>    offset23 = new Offset <int>(this.payloadGroup, 4700);
            Offset <int>    offset24 = new Offset <int>(this.payloadGroup, 4704);
            Offset <short>  offset25 = new Offset <short>(this.payloadGroup, 2804);

            FSUIPCConnection.Process(this.classInstance, this.payloadGroup);
            FSUIPCConnection.DeleteGroup(this.payloadGroup);
            this.totalWeightLbs = offset2.Value;
            Offset <double>[] offsetArray1 = new Offset <double> [offset1.Value];
            Offset <double>[] offsetArray2 = new Offset <double> [offset1.Value];
            Offset <double>[] offsetArray3 = new Offset <double> [offset1.Value];
            Offset <double>[] offsetArray4 = new Offset <double> [offset1.Value];
            Offset <string>[] offsetArray5 = new Offset <string> [offset1.Value];
            for (int index = 0; index < offset1.Value; ++index)
            {
                offsetArray1[index] = new Offset <double>(this.payloadGroup, 5120 + 48 * index);
                offsetArray2[index] = new Offset <double>(this.payloadGroup, 5128 + 48 * index);
                offsetArray3[index] = new Offset <double>(this.payloadGroup, 5136 + 48 * index);
                offsetArray4[index] = new Offset <double>(this.payloadGroup, 5144 + 48 * index);
                offsetArray5[index] = new Offset <string>(this.payloadGroup, 5152 + 48 * index, 16);
            }
            if (offset1.Value > 0)
            {
                FSUIPCConnection.Process(this.classInstance, this.payloadGroup);
                FSUIPCConnection.DeleteGroup(this.payloadGroup);
            }
            this.payloadStations.Clear();
            for (int Index = 0; Index < offset1.Value; ++Index)
            {
                this.payloadStations.Add(new FsPayloadStation(Index, offsetArray1[Index].Value, offsetArray2[Index].Value, offsetArray3[Index].Value, offsetArray4[Index].Value, offsetArray5[Index].Value));
            }
            double PoundsPerGallon = (double)offset25.Value / 256.0;

            this.fuelTanks.Clear();
            this.fuelTankLookup.Clear();
            double     Level1      = (double)offset3.Value / 128.0 / 65536.0;
            FsFuelTank fsFuelTank1 = new FsFuelTank(FSFuelTanks.Centre_Main, (double)offset4.Value, Level1, PoundsPerGallon);

            this.fuelTanks.Add(fsFuelTank1);
            this.fuelTankLookup.Add(fsFuelTank1.Tank, fsFuelTank1);
            double     Level2      = (double)offset17.Value / 128.0 / 65536.0;
            FsFuelTank fsFuelTank2 = new FsFuelTank(FSFuelTanks.Centre_2, (double)offset18.Value, Level2, PoundsPerGallon);

            this.fuelTanks.Add(fsFuelTank2);
            this.fuelTankLookup.Add(fsFuelTank2.Tank, fsFuelTank2);
            double     Level3      = (double)offset19.Value / 128.0 / 65536.0;
            FsFuelTank fsFuelTank3 = new FsFuelTank(FSFuelTanks.Centre_3, (double)offset20.Value, Level3, PoundsPerGallon);

            this.fuelTanks.Add(fsFuelTank3);
            this.fuelTankLookup.Add(fsFuelTank3.Tank, fsFuelTank3);
            double     Level4      = (double)offset21.Value / 128.0 / 65536.0;
            FsFuelTank fsFuelTank4 = new FsFuelTank(FSFuelTanks.External_1, (double)offset22.Value, Level4, PoundsPerGallon);

            this.fuelTanks.Add(fsFuelTank4);
            this.fuelTankLookup.Add(fsFuelTank4.Tank, fsFuelTank4);
            double     Level5      = (double)offset23.Value / 128.0 / 65536.0;
            FsFuelTank fsFuelTank5 = new FsFuelTank(FSFuelTanks.External_2, (double)offset24.Value, Level5, PoundsPerGallon);

            this.fuelTanks.Add(fsFuelTank5);
            this.fuelTankLookup.Add(fsFuelTank5.Tank, fsFuelTank5);
            double     Level6      = (double)offset7.Value / 128.0 / 65536.0;
            FsFuelTank fsFuelTank6 = new FsFuelTank(FSFuelTanks.Left_Aux, (double)offset8.Value, Level6, PoundsPerGallon);

            this.fuelTanks.Add(fsFuelTank6);
            this.fuelTankLookup.Add(fsFuelTank6.Tank, fsFuelTank6);
            double     Level7      = (double)offset5.Value / 128.0 / 65536.0;
            FsFuelTank fsFuelTank7 = new FsFuelTank(FSFuelTanks.Left_Main, (double)offset6.Value, Level7, PoundsPerGallon);

            this.fuelTanks.Add(fsFuelTank7);
            this.fuelTankLookup.Add(fsFuelTank7.Tank, fsFuelTank7);
            double     Level8      = (double)offset9.Value / 128.0 / 65536.0;
            FsFuelTank fsFuelTank8 = new FsFuelTank(FSFuelTanks.Left_Tip, (double)offset10.Value, Level8, PoundsPerGallon);

            this.fuelTanks.Add(fsFuelTank8);
            this.fuelTankLookup.Add(fsFuelTank8.Tank, fsFuelTank8);
            double     Level9      = (double)offset13.Value / 128.0 / 65536.0;
            FsFuelTank fsFuelTank9 = new FsFuelTank(FSFuelTanks.Right_Aux, (double)offset14.Value, Level9, PoundsPerGallon);

            this.fuelTanks.Add(fsFuelTank9);
            this.fuelTankLookup.Add(fsFuelTank9.Tank, fsFuelTank9);
            double     Level10      = (double)offset11.Value / 128.0 / 65536.0;
            FsFuelTank fsFuelTank10 = new FsFuelTank(FSFuelTanks.Right_Main, (double)offset12.Value, Level10, PoundsPerGallon);

            this.fuelTanks.Add(fsFuelTank10);
            this.fuelTankLookup.Add(fsFuelTank10.Tank, fsFuelTank10);
            double     Level11      = (double)offset15.Value / 128.0 / 65536.0;
            FsFuelTank fsFuelTank11 = new FsFuelTank(FSFuelTanks.Right_Tip, (double)offset16.Value, Level11, PoundsPerGallon);

            this.fuelTanks.Add(fsFuelTank11);
            this.fuelTankLookup.Add(fsFuelTank11.Tank, fsFuelTank11);
        }
Example #17
0
 public static void Process(string GroupName)
 {
     FSUIPCConnection.Process((byte)0, GroupName);
 }
Example #18
0
 public static void Process(IEnumerable <string> GroupNames)
 {
     FSUIPCConnection.Process((byte)0, GroupNames);
 }
Example #19
0
 public static void Process()
 {
     FSUIPCConnection.Process((byte)0, "");
 }
Example #20
0
        public static void Open(byte ClassInstance, int RequiredFlightSimVersion)
        {
            FSUIPCConnection.DeleteGroup(FSUIPCConnection.SystemOffsetsGroup);
            bool flag = false;

            if (FSUIPCConnection.connections.ContainsKey(ClassInstance))
            {
                throw new FSUIPCException(FSUIPCError.FSUIPC_ERR_OPEN, "The connection to FSUIPC is already open.");
            }
            ConnectionInfo connectionInfo = new ConnectionInfo();

            FSUIPCConnection.connections.Add(ClassInstance, connectionInfo);
            if ((int)ClassInstance == 0)
            {
                connectionInfo.hWnd = Win32.FindWindowEx(IntPtr.Zero, IntPtr.Zero, "UIPCMAIN", IntPtr.Zero);
                if (connectionInfo.hWnd == IntPtr.Zero)
                {
                    connectionInfo.hWnd = Win32.FindWindowEx(IntPtr.Zero, IntPtr.Zero, "FS98MAIN", IntPtr.Zero);
                    flag = true;
                }
            }
            else
            {
                connectionInfo.hWnd = Win32.FindWindowEx(IntPtr.Zero, IntPtr.Zero, "FS98MAIN" + ClassInstance.ToString("D2"), IntPtr.Zero);
                flag = true;
            }
            if (connectionInfo.hWnd == IntPtr.Zero)
            {
                FSUIPCConnection.Close(ClassInstance);
                throw new FSUIPCException(FSUIPCError.FSUIPC_ERR_NOFS, "Cannot find FSUIPC or WideFS running on this machine.");
            }
            connectionInfo.messageID = Win32.RegisterWindowMessage(FSUIPCConnection.FS6IPCMessageName);
            if ((int)connectionInfo.messageID == 0)
            {
                FSUIPCConnection.Close(ClassInstance);
                throw new FSUIPCException(FSUIPCError.FSUIPC_ERR_REGMSG, "Could not register the IPC window message");
            }
            ++FSUIPCConnection.tryCount;
            string str = FSUIPCConnection.FS6IPCMessageName + ":" + Process.GetCurrentProcess().Id.ToString("X") + ":" + FSUIPCConnection.tryCount.ToString("X");

            connectionInfo.atomFileName = Win32.GlobalAddAtom(str);
            if (connectionInfo.atomFileName == IntPtr.Zero)
            {
                FSUIPCConnection.Close(ClassInstance);
                throw new FSUIPCException(FSUIPCError.FSUIPC_ERR_ATOM, "Could not add the Global Atom for the file mapping path.");
            }
            connectionInfo.hMap = Win32.CreateFileMapping(new IntPtr(-1), IntPtr.Zero, PageProtection.ReadWrite, 0U, FSUIPCConnection.MaximumDataSize + 256U, str);
            if (connectionInfo.hMap == IntPtr.Zero || Marshal.GetLastWin32Error() == FSUIPCConnection.ERROR_ALREADY_EXISTS)
            {
                FSUIPCConnection.Close(ClassInstance);
                throw new FSUIPCException(FSUIPCError.FSUIPC_ERR_MAP, "Could not create file mapping.");
            }
            connectionInfo.pView = Win32.MapViewOfFile(connectionInfo.hMap, DesiredAccess.MapWrite, 0U, 0U, 0U);
            if (connectionInfo.pView == IntPtr.Zero)
            {
                FSUIPCConnection.Close(ClassInstance);
                throw new FSUIPCException(FSUIPCError.FSUIPC_ERR_VIEW, "Could not Open file view.");
            }
            Offset <int> offset1 = new Offset <int>(FSUIPCConnection.SystemOffsetsGroup, 13060);
            Offset <int> offset2 = new Offset <int>(FSUIPCConnection.SystemOffsetsGroup, 13064);

            for (int index = 0; index < 5 && (offset1.dataValue == 0 || offset2.dataValue == 0); ++index)
            {
                FSUIPCConnection.Process(ClassInstance, FSUIPCConnection.SystemOffsetsGroup);
                Thread.Sleep(100);
            }
            if (offset1.dataValue < 429391877 || ((long)offset2.dataValue & 4294901760L) != 4208852992L)
            {
                if (flag)
                {
                    FSUIPCConnection.Close(ClassInstance);
                    throw new FSUIPCException(FSUIPCError.FSUIPC_ERR_RUNNING, "FSUIPC is not running.");
                }
                FSUIPCConnection.Close(ClassInstance);
                throw new FSUIPCException(FSUIPCError.FSUIPC_ERR_VERSION, "Incorrect version of FSUIPC.");
            }
            int num = offset2.dataValue & (int)ushort.MaxValue;

            FSUIPCConnection.fsVersionConnected = (FlightSim)num;
            if (RequiredFlightSimVersion != 0 && RequiredFlightSimVersion != num)
            {
                FSUIPCConnection.Close(ClassInstance);
                throw new FSUIPCException(FSUIPCError.FSUIPC_ERR_WRONGFS, "Incorrect version of Flight Sim");
            }
            FSUIPCConnection.DeleteGroup(FSUIPCConnection.SystemOffsetsGroup);
            if (!FSUIPCConnection.aiServices.ContainsKey(ClassInstance))
            {
                FSUIPCConnection.aiServices.Add(ClassInstance, new AITrafficServices(ClassInstance));
            }
            if (!FSUIPCConnection.userInput.ContainsKey(ClassInstance))
            {
                FSUIPCConnection.userInput.Add(ClassInstance, new UserInputServices(ClassInstance));
            }
            if (FSUIPCConnection.payloadServices.ContainsKey(ClassInstance))
            {
                return;
            }
            FSUIPCConnection.payloadServices.Add(ClassInstance, new PayloadServices(ClassInstance));
        }
Example #21
0
        public void CheckForInput()
        {
            if (this.keySlotIndicators.Count + this.buttonSlotIndicators.Count + this.menuSlotIndicators.Count <= 0)
            {
                return;
            }
            FSUIPCConnection.Process(this.classinstance, this.pollingSlotsGroup);
            List <UserInputKeyEventArgs>    inputKeyEventArgsList    = new List <UserInputKeyEventArgs>();
            List <UserInputButtonEventArgs> inputButtonEventArgsList = new List <UserInputButtonEventArgs>();
            List <UserInputMenuEventArgs>   inputMenuEventArgsList   = new List <UserInputMenuEventArgs>();
            IDictionaryEnumerator           enumerator1 = (IDictionaryEnumerator)this.keySlotIndicators.GetEnumerator();

            while (enumerator1.MoveNext())
            {
                Offset <byte> offset = (Offset <byte>)enumerator1.Value;
                if ((int)offset.Value > 0)
                {
                    Keys keys = Keys.None;
                    if ((int)offset.Value > 1)
                    {
                        keys = (Keys)offset.Value;
                    }
                    inputKeyEventArgsList.Add(new UserInputKeyEventArgs()
                    {
                        ID = enumerator1.Key.ToString(),
                        SecondKeyPressed = keys
                    });
                    new Offset <byte>(this.pollingSlotsResetGroup, offset.address, true).Value = (byte)0;
                }
            }
            IDictionaryEnumerator enumerator2 = (IDictionaryEnumerator)this.menuSlotIndicators.GetEnumerator();

            while (enumerator2.MoveNext())
            {
                Offset <byte> offset = (Offset <byte>)enumerator2.Value;
                if (((int)offset.Value & 1) == 1)
                {
                    inputMenuEventArgsList.Add(new UserInputMenuEventArgs()
                    {
                        ID = enumerator2.Key.ToString()
                    });
                    new Offset <byte>(this.pollingSlotsResetGroup, offset.address, true).Value = (byte)0;
                }
            }
            IDictionaryEnumerator enumerator3 = (IDictionaryEnumerator)this.buttonSlotIndicators.GetEnumerator();

            while (enumerator3.MoveNext())
            {
                Offset <byte> offset = (Offset <byte>)enumerator3.Value;
                if (((int)offset.Value & 1) == 1)
                {
                    bool flag = ((int)offset.Value & 2) == 2;
                    inputButtonEventArgsList.Add(new UserInputButtonEventArgs()
                    {
                        ID          = enumerator3.Key.ToString(),
                        ButtonState = flag
                    });
                    new Offset <byte>(this.pollingSlotsResetGroup, offset.address, true).Value = (byte)0;
                }
            }
            if (inputKeyEventArgsList.Count + inputButtonEventArgsList.Count + inputMenuEventArgsList.Count <= 0)
            {
                return;
            }
            FSUIPCConnection.Process(this.classinstance, this.pollingSlotsResetGroup);
            FSUIPCConnection.DeleteGroup(this.pollingSlotsResetGroup);
            foreach (UserInputKeyEventArgs e in inputKeyEventArgsList)
            {
                if (this.KeyPressed != null)
                {
                    this.KeyPressed((object)this, e);
                }
            }
            foreach (UserInputButtonEventArgs e in inputButtonEventArgsList)
            {
                if (this.ButtonPressed != null)
                {
                    this.ButtonPressed((object)this, e);
                }
            }
            foreach (UserInputMenuEventArgs e in inputMenuEventArgsList)
            {
                if (this.MenuSelected != null)
                {
                    this.MenuSelected((object)this, e);
                }
            }
        }
Example #22
0
        public void WriteChanges()
        {
            Offset <int> offset1 = new Offset <int>(this.payloadGroup, 5116);

            foreach (FsFuelTank fuelTank in this.fuelTanks)
            {
                if (fuelTank.valueChanged)
                {
                    Offset <int> offset2 = (Offset <int>)null;
                    switch (fuelTank.Tank)
                    {
                    case FSFuelTanks.Centre_Main:
                        offset2 = new Offset <int>(this.payloadGroup, 2932, true);
                        break;

                    case FSFuelTanks.Left_Main:
                        offset2 = new Offset <int>(this.payloadGroup, 2940, true);
                        break;

                    case FSFuelTanks.Right_Main:
                        offset2 = new Offset <int>(this.payloadGroup, 2964, true);
                        break;

                    case FSFuelTanks.Left_Aux:
                        offset2 = new Offset <int>(this.payloadGroup, 2948, true);
                        break;

                    case FSFuelTanks.Right_Aux:
                        offset2 = new Offset <int>(this.payloadGroup, 2972, true);
                        break;

                    case FSFuelTanks.Left_Tip:
                        offset2 = new Offset <int>(this.payloadGroup, 2956, true);
                        break;

                    case FSFuelTanks.Right_Tip:
                        offset2 = new Offset <int>(this.payloadGroup, 2980, true);
                        break;

                    case FSFuelTanks.Centre_2:
                        offset2 = new Offset <int>(this.payloadGroup, 4676, true);
                        break;

                    case FSFuelTanks.Centre_3:
                        offset2 = new Offset <int>(this.payloadGroup, 4684, true);
                        break;

                    case FSFuelTanks.External_1:
                        offset2 = new Offset <int>(this.payloadGroup, 4692, true);
                        break;

                    case FSFuelTanks.External_2:
                        offset2 = new Offset <int>(this.payloadGroup, 4700, true);
                        break;
                    }
                    if (offset2 != null)
                    {
                        offset2.Value = (int)(fuelTank.LevelPercentage / 100.0 * 128.0 * 65536.0);
                    }
                }
            }
            foreach (FsPayloadStation payloadStation in this.payloadStations)
            {
                if (payloadStation.valueChanged)
                {
                    new Offset <double>(this.payloadGroup, 5120 + 48 * payloadStation.Index, true).Value = payloadStation.WeightLbs;
                }
            }
            FSUIPCConnection.Process(this.classInstance, this.payloadGroup);
            FSUIPCConnection.DeleteGroup(this.payloadGroup);
        }
Example #23
0
        public void RefreshAITrafficInformation(bool UpdateGroundTraffic, bool UpdateAirbourneTraffic)
        {
            FSUIPCConnection.Process(this.classInstance, this.AISystemGroup);
            List <int> processedPlaneIDs = new List <int>();

            this.aiArrivalRunwaysInUse.Clear();
            this.aiDepartureRunwaysInUse.Clear();
            if (UpdateGroundTraffic)
            {
                List <Offset <byte[]> > offsetList1 = new List <Offset <byte[]> >();
                List <Offset <byte[]> > offsetList2 = new List <Offset <byte[]> >();
                for (int index = 0; index < (int)this.slotsUsedGround.Value; ++index)
                {
                    Offset <byte[]> offset1 = new Offset <byte[]>(this.AISlotGroup, 57472 + 40 * index, 40);
                    Offset <byte[]> offset2 = new Offset <byte[]>(this.AISlotGroup, 53312 + 20 * index, 20);
                    offsetList1.Add(offset1);
                    offsetList2.Add(offset2);
                }
                if (offsetList1.Count > 0)
                {
                    FSUIPCConnection.Process(this.classInstance, this.AISlotGroup);
                    FSUIPCConnection.DeleteGroup(this.AISlotGroup);
                    processedPlaneIDs = new List <int>();
                    for (int index = 0; index < offsetList1.Count; ++index)
                    {
                        AIPlaneInfo planeInfo = this.updatePlaneInfo(offsetList1[index].Value, offsetList2[index].Value, this.aiGround, this.aiGroundIDs, processedPlaneIDs);
                        if (planeInfo != null)
                        {
                            this.addToRunwaysInUse(planeInfo);
                        }
                    }
                }
                List <int> intList = new List <int>();
                foreach (int aiGroundId in this.aiGroundIDs)
                {
                    if (!processedPlaneIDs.Contains(aiGroundId))
                    {
                        intList.Add(this.aiGroundIDs.IndexOf(aiGroundId));
                    }
                }
                intList.Sort();
                intList.Reverse();
                foreach (int index in intList)
                {
                    AIPlaneInfo aiPlaneInfo = this.aiGround[index];
                    aiPlaneInfo.id = 0;
                    this.aiGround.Remove(aiPlaneInfo);
                }
                this.aiGround.Sort(new Comparison <AIPlaneInfo>(this.comparePlaneDistance));
                this.aiGroundIDs.Clear();
                foreach (AIPlaneInfo aiPlaneInfo in this.aiGround)
                {
                    this.aiGroundIDs.Add(aiPlaneInfo.id);
                }
            }
            if (UpdateAirbourneTraffic)
            {
                List <Offset <byte[]> > offsetList1 = new List <Offset <byte[]> >();
                List <Offset <byte[]> > offsetList2 = new List <Offset <byte[]> >();
                for (int index = 0; index < (int)this.slotsUsedAir.Value; ++index)
                {
                    Offset <byte[]> offset1 = new Offset <byte[]>(this.AISlotGroup, 61568 + 40 * index, 40);
                    Offset <byte[]> offset2 = new Offset <byte[]>(this.AISlotGroup, 55360 + 20 * index, 20);
                    offsetList1.Add(offset1);
                    offsetList2.Add(offset2);
                }
                if (offsetList1.Count > 0)
                {
                    FSUIPCConnection.Process(this.classInstance, this.AISlotGroup);
                    FSUIPCConnection.DeleteGroup(this.AISlotGroup);
                    processedPlaneIDs = new List <int>();
                    for (int index = 0; index < offsetList1.Count; ++index)
                    {
                        AIPlaneInfo planeInfo = this.updatePlaneInfo(offsetList1[index].Value, offsetList2[index].Value, this.aiAirborne, this.aiAirbornIDs, processedPlaneIDs);
                        if (planeInfo != null)
                        {
                            this.addToRunwaysInUse(planeInfo);
                        }
                    }
                }
                List <int> intList = new List <int>();
                foreach (int aiAirbornId in this.aiAirbornIDs)
                {
                    if (!processedPlaneIDs.Contains(aiAirbornId))
                    {
                        intList.Add(this.aiAirbornIDs.IndexOf(aiAirbornId));
                    }
                }
                intList.Sort();
                intList.Reverse();
                foreach (int index in intList)
                {
                    AIPlaneInfo aiPlaneInfo = this.aiAirborne[index];
                    aiPlaneInfo.id = 0;
                    this.aiAirborne.Remove(aiPlaneInfo);
                }
                this.aiAirborne.Sort(new Comparison <AIPlaneInfo>(this.comparePlaneDistance));
                this.aiAirbornIDs.Clear();
                foreach (AIPlaneInfo aiPlaneInfo in this.aiAirborne)
                {
                    this.aiAirbornIDs.Add(aiPlaneInfo.id);
                }
            }
            this.aiAll.Clear();
            this.aiAll.AddRange((IEnumerable <AIPlaneInfo>) this.aiGround);
            this.aiAll.AddRange((IEnumerable <AIPlaneInfo>) this.aiAirborne);
            if (this.aiAll.Count <= 0)
            {
                return;
            }
            this.aiAll.Sort(new Comparison <AIPlaneInfo>(this.comparePlaneDistance));
            this.aiAllIDs.Clear();
            foreach (AIPlaneInfo aiPlaneInfo in this.aiAll)
            {
                this.aiAllIDs.Add(aiPlaneInfo.id);
            }
        }