示例#1
0
        private void refreshAvailablePoKeysList()
        {
            AvailablePoKeysList.Clear();

            List <PoKeysDeviceInfo> devices = PoKeysDevice.EnumeratePoKeysDevices(true, true, true);

            foreach (PoKeysDeviceInfo device in devices)
            {
                if (PoKeysDevice.ConnectToDevice(device))
                {
                    int    pokeysSerial = PoKeysDevice.GetDeviceSerialNumber();
                    string pokeysName   = PoKeysDevice.GetDeviceName();

                    byte pokeysUserId   = 0;
                    bool pokeysUserIdOk = false;
                    if (PoKeysDevice.GetUserID(ref pokeysUserId))
                    {
                        pokeysUserIdOk = true;
                    }

                    AvailablePoKeys availablePoKeys = new AvailablePoKeys(pokeysSerial, pokeysName, pokeysUserIdOk ? pokeysUserId : (byte?)null, device);
                    AvailablePoKeysList.Add(availablePoKeys);

                    PoKeysDevice.DisconnectDevice();
                }
            }
        }
示例#2
0
        private void refreshAvailablePoKeysList()
        {
            AvailablePoKeysList.Clear();

            int nbPokeys = PoKeysDevice.EnumerateDevices();

            for (int pokeysIndex = 0; pokeysIndex < nbPokeys; ++pokeysIndex)
            {
                if (PoKeysDevice.ConnectToDevice(pokeysIndex))
                {
                    int    pokeysSerial = PoKeysDevice.GetDeviceSerialNumber();
                    string pokeysName   = PoKeysDevice.GetDeviceName();

                    byte pokeysUserId   = 0;
                    bool pokeysUserIdOk = false;
                    if (PoKeysDevice.GetUserID(ref pokeysUserId))
                    {
                        pokeysUserIdOk = true;
                    }

                    AvailablePoKeys availablePoKeys = new AvailablePoKeys(pokeysSerial, pokeysName, pokeysUserIdOk ? pokeysUserId : (byte?)null, pokeysIndex);
                    AvailablePoKeysList.Add(availablePoKeys);

                    PoKeysDevice.DisconnectDevice();
                }
            }
        }
        private void Disconnect()
        {
            PokeysDevice.DisconnectDevice();

            connected = false;
            RaisePropertyChanged("Connected");

            selectedPokeys = null;
            updateStatus();
        }
示例#4
0
        private void TryToUpdateFromFormatV1_0ToV1_1()
        {
            Version formatVersionV1_0 = new Version(1, 0);
            Version formatVersionV1_1 = new Version(1, 1);

            string oldConfigFileName = "F4ToPokeys.xml";

            if (!File.Exists(oldConfigFileName))
            {
                return;
            }

            XDocument oldConfiguration = XDocument.Load(oldConfigFileName);

            Version oldFormatVersion;

            if (!Version.TryParse((string)oldConfiguration.Root.Attribute("formatVersion"), out oldFormatVersion))
            {
                oldFormatVersion = formatVersionV1_0;
            }

            if (oldFormatVersion != formatVersionV1_0)
            {
                return;
            }

            oldConfiguration.Root.SetAttributeValue("formatVersion", formatVersionV1_1);

            foreach (XElement poKeysElement in oldConfiguration.Root.Descendants("PoKeys"))
            {
                byte?userId = (byte?)(uint?)poKeysElement.Element("UserId");
                if (userId.HasValue)
                {
                    AvailablePoKeys availablePoKeys = PoKeysEnumerator.Singleton.AvailablePoKeysList
                                                      .FirstOrDefault(ap => ap.PokeysUserId == userId);

                    if (availablePoKeys != null)
                    {
                        poKeysElement.SetElementValue("Serial", availablePoKeys.PokeysSerial);
                    }

                    poKeysElement.SetElementValue("UserId", null);
                }
            }

            Dictionary <string, string> renamedLightLabels = new Dictionary <string, string>();

            renamedLightLabels.Add("OXY LOW (Eyebrown)", "OXY LOW (R. Warning)");
            renamedLightLabels.Add("LEFlaps", "LE FLAPS");
            renamedLightLabels.Add("Fuel Low", "FUEL LOW");
            renamedLightLabels.Add("PRIORITY MODE", "PRIORITY");
            renamedLightLabels.Add("Bingo chaff", "BINGO CHAFF");
            renamedLightLabels.Add("Bingo flare", "BINGO FLARE");
            renamedLightLabels.Add("EPU On", "EPU ON");
            renamedLightLabels.Add("Gear handle", "GEAR HANDLE");
            renamedLightLabels.Add("Lef Fault", "LEF FAULT");
            renamedLightLabels.Add("Outer Marker", "OUTER MARKER");
            renamedLightLabels.Add("Middle Marker", "MIDDLE MARKER");
            renamedLightLabels.Add("Nose gear down", "NOSE GEAR DOWN");
            renamedLightLabels.Add("Left gear down", "LEFT GEAR DOWN");
            renamedLightLabels.Add("Right gear down", "RIGHT GEAR DOWN");
            renamedLightLabels.Add("SpeedBrake > 0%", "SPEEDBRAKE > 0%");
            renamedLightLabels.Add("SpeedBrake > 33%", "SPEEDBRAKE > 33%");
            renamedLightLabels.Add("SpeedBrake > 66%", "SPEEDBRAKE > 66%");
            renamedLightLabels.Add("FLCS BIT Magnetic Switch Off", "FLCS BIT DIY MAG SW RESET");
            renamedLightLabels.Add("JFS Magnetic Switch Off", "JFS DIY MAG SW RESET");
            renamedLightLabels.Add("Parking Brake Magnetic Switch Off", "PARK BRAKE DIY MAG SW RESET");
            renamedLightLabels.Add("Autopilot PITCH Magnetic Switch Off", "AUTOPILOT DIY MAG SW RESET");

            foreach (string oldLabel in renamedLightLabels.Keys)
            {
                foreach (XElement falconLightLabelElement in oldConfiguration.Root.Descendants("FalconLightLabel").Where(e => (string)e == oldLabel))
                {
                    falconLightLabelElement.SetValue(renamedLightLabels[oldLabel]);
                }
            }

            Dictionary <string, string> renamedGaugeLabels = new Dictionary <string, string>();

            renamedGaugeLabels.Add("NOZ Pos", "NOZ POS");
            renamedGaugeLabels.Add("NOZ Pos 2", "NOZ POS 2");
            renamedGaugeLabels.Add("SpeedBrake", "SPEEDBRAKE");
            renamedGaugeLabels.Add("Oil Pressure", "OIL PRESSURE");
            renamedGaugeLabels.Add("Oil Pressure 2", "OIL PRESSURE 2");
            renamedGaugeLabels.Add("Chaff Count", "CHAFF COUNT");
            renamedGaugeLabels.Add("Flare Count", "FLARE COUNT");
            renamedGaugeLabels.Add("Trim Pitch", "TRIM PITCH");
            renamedGaugeLabels.Add("Trim Roll", "TRIM ROLL");
            renamedGaugeLabels.Add("Trim Yaw", "TRIM YAW");
            renamedGaugeLabels.Add("Current Heading", "CURRENT HEADING");

            foreach (string oldLabel in renamedGaugeLabels.Keys)
            {
                foreach (XElement falconGaugeLabelElement in oldConfiguration.Root.Descendants("FalconGaugeLabel").Where(e => (string)e == oldLabel))
                {
                    falconGaugeLabelElement.SetValue(renamedGaugeLabels[oldLabel]);
                }
            }

            oldConfiguration.Save(configFileName);
        }