Ejemplo n.º 1
0
        public void LoadConfiguration(Configuration configuration, Dictionarys dicts)
        {
            Name = configuration.Name;
            FileLocation = configuration.FileLocation;
            Intensity = configuration.TMDisplaySettings.Intensity;
            ShiftIntensity = configuration.TMDisplaySettings.ShiftIntensity;
            ShiftIntensityType = configuration.TMDisplaySettings.ShiftIntensityType;
            ShiftIntensityAmount = configuration.TMDisplaySettings.ShiftIntensityAmount;
            ShowHeader = configuration.TMDisplaySettings.ShowHeaders;
            HeaderDisplayTime = configuration.TMDisplaySettings.HeaderDisplayTime - 1;
            QuickInfoDisplayTime = configuration.TMDisplaySettings.QuickInfoDisplayTime - 1;
            LapTimeDisplayTime = configuration.TMDisplaySettings.LapDisplayTime - 1;
            PreferredComPort = configuration.SerialPortSettings.PreferredComPort;
            LogArduinoMessages = configuration.AdvancedSettings.LogArduinoMessages;
            SerialPortSpeed = configuration.SerialPortSettings.SerialPortSpeed.ToString(CultureInfo.InvariantCulture);
            DisplayRefreshRate = configuration.RefreshRates.DisplayRefreshRate.ToString(CultureInfo.InvariantCulture);
            LEDRefreshRate = configuration.RefreshRates.LEDRefreshRate.ToString(CultureInfo.InvariantCulture);
            UseCustomSerialSpeed = configuration.SerialPortSettings.UseCustomSerialSpeed;
            ColourDeltaByDD = configuration.TMDisplaySettings.ColourDeltaByDD;
            DeltaLightsOnDefault = configuration.TMDisplaySettings.DeltaLightsOnDefault;
            DeltaMessageScreen = configuration.TMDisplaySettings.DeltaMessageScreen;
            DeltaRange = configuration.TMDisplaySettings.DeltaRange - 1;
            UseCustomFuelCalculationOptions = configuration.OtherSettings.UseCustomFuelCalculationOptions;
            FuelCalculationLaps = configuration.OtherSettings.FuelCalculationLaps - 2;
            UseWeightedFuelCalculations = configuration.OtherSettings.UseWeightedFuelCalculations;
            WarningTextDisplayTime = configuration.TMDisplaySettings.WarningTextDisplayTime - 1;
            QuickInfoLightsColour = configuration.TMDisplaySettings.QuickInfoLightsColour;

            ArduinoIOConfiguration = new ArduinoIO();
            FergoTechConfiguration = new FergoTechComponents();

            ControllerConfigurations = new List<ControllerButtonConfiguration>();
            foreach (ControllerConfiguration item in configuration.ControllerConfigurations)
            {
                var temp = new ControllerButtonConfiguration
                    {
                        DeviceGuid = item.DeviceGuid,
                        ButtonNumbers = item.ButtonNumbers,
                        ButtonOptions = item.ButtonOptions,
                        ButtonOptionsScreens = item.ButtonOptionsScreens,
                        Selected = item.Selected
                    };
                for (int k = 0; k < Constants.MaxNumberJoystickButtons; k++)
                {
                    temp.ButtonFunctions[k] = dicts.ButtonFunctions[item.ButtonFunctions[k]].Name;
                }
                ControllerConfigurations.Add(temp);
            }
            NumberControllers = configuration.ControllerConfigurations.Count;
            DisplayUnitConfigurations = new List<DisplayUnitConfiguration>();
            int unitCount = 0;
            foreach (DisplayConfiguration displayConf in configuration.DisplayConfigurations)
            {
                unitCount++;
                var temp = new DisplayUnitConfiguration
                    {
                        NumScreens = displayConf.NumScreens - 1,
                        Inverted = displayConf.Inverted,
                        IsTM1640 = displayConf.IsTM1640,
                        SwitchLEDs = displayConf.SwitchLEDs,
                        ShowDC = displayConf.ShowDC,
                        DCDisplayTime = displayConf.DCDisplayTime,
                        ShowLap = displayConf.ShowLap,
                        ButtonConfigurations = new ButtonConfiguration(),
                        UnitNumber = unitCount,
                        ShowEngineWarnings = displayConf.ShowEngineWarnings
                    };
                DisplayConfiguration conf = displayConf;
                foreach (var lstyle in dicts.LapDisplayStyles.Where(lstyle => conf.LapStyle == lstyle.Value))
                {
                    temp.LapStyle = lstyle.Key;
                } foreach (var wtype in dicts.WarningTypes.Where(wtype => conf.WarningType == wtype.Value))
                {
                    temp.WarningType = wtype.Key;
                }

                for (int n = 0; n < Constants.NumberButtonsOnTm1638; n++)
                {
                    temp.ButtonConfigurations.ButtonFunctions[n] =
                        dicts.ButtonFunctions[displayConf.ButtonFunctions[n]].Name;
                    temp.ButtonConfigurations.ButtonOptions[n] = displayConf.ButtonOptions[n];
                    temp.ButtonConfigurations.ButtonOptionsScreens[n] = displayConf.ButtonOptionsScreens[n];
                }
                temp.LEDsConfigurations = new LEDsConfiguration
                                              {
                                                      FFBClippingLights = displayConf.FFBClippingLights,
                                                      FFBClippingScreen = displayConf.FFBClippingScreen - 1,
                                                      PitLights = displayConf.PitLights,
                                                      RevLimiterLights = displayConf.RevLimiterLights,
                                                      ShowShiftLights = displayConf.ShowShiftLights,
                                                      ShiftClumps = displayConf.ShiftClumps,
                                                      MatchCarShiftLights = displayConf.MatchCarShiftStyle,
                                                      MatchRedShift = displayConf.MatchRedShift,
                                                      DeltaLightsShow = displayConf.DeltaLightsShow,
                                                      MatchCarShiftOptions = "",
                                              };
                foreach (var opt in dicts.MatchCarShiftOptions)
                {
                    if (opt.Value == displayConf.MatchCarShiftStyleOption)
                    {
                        temp.LEDsConfigurations.MatchCarShiftOptions = opt.Key;
                    }
                }
                temp.LEDsConfigurations.DeltaLightsPosition = "";
                foreach (var opt in dicts.DeltaLightsPositionOptions)
                {
                    if (opt.Value == displayConf.DeltaLightsPosition)
                    {
                        temp.LEDsConfigurations.DeltaLightsPosition = opt.Key;
                    }
                }
                foreach (var plspeed in dicts.PitFlashSpeeds)
                {
                    if (plspeed.Value == displayConf.PitLimiterSpeed)
                    {
                        temp.LEDsConfigurations.PitLimiterSpeed = plspeed.Key;
                    }
                }
                foreach (var plstyle in dicts.PitFlashStyles)
                {
                    if (plstyle.Value == displayConf.PitLimiterStyle)
                    {
                        temp.LEDsConfigurations.PitLimiterStyle = plstyle.Key;
                    }
                }
                foreach (var revlstyle in dicts.RevFlashStyles)
                {
                    if (revlstyle.Value == displayConf.RevLimiterStyle)
                    {
                        temp.LEDsConfigurations.RevLimiterStyle = revlstyle.Key;
                    }
                }
                foreach (var shiftstyle in dicts.ShiftStyles)
                {
                    if (shiftstyle.Value == displayConf.ShiftLightStyle)
                    {
                        temp.LEDsConfigurations.ShiftLightStyle = shiftstyle.Key;
                    }
                }
                temp.Screens = displayConf.Screens;
                DisplayUnitConfigurations.Add(temp);
            }
        }
Ejemplo n.º 2
0
        public void LoadConfiguration(Configuration configuration, Dictionarys dicts)
        {
            Name                            = configuration.Name;
            FileLocation                    = configuration.FileLocation;
            Intensity                       = configuration.TMDisplaySettings.Intensity;
            ShiftIntensity                  = configuration.TMDisplaySettings.ShiftIntensity;
            ShiftIntensityType              = configuration.TMDisplaySettings.ShiftIntensityType;
            ShiftIntensityAmount            = configuration.TMDisplaySettings.ShiftIntensityAmount;
            ShowHeader                      = configuration.TMDisplaySettings.ShowHeaders;
            HeaderDisplayTime               = configuration.TMDisplaySettings.HeaderDisplayTime - 1;
            QuickInfoDisplayTime            = configuration.TMDisplaySettings.QuickInfoDisplayTime - 1;
            LapTimeDisplayTime              = configuration.TMDisplaySettings.LapDisplayTime - 1;
            PreferredComPort                = configuration.SerialPortSettings.PreferredComPort;
            LogArduinoMessages              = configuration.AdvancedSettings.LogArduinoMessages;
            SerialPortSpeed                 = configuration.SerialPortSettings.SerialPortSpeed.ToString(CultureInfo.InvariantCulture);
            DisplayRefreshRate              = configuration.RefreshRates.DisplayRefreshRate.ToString(CultureInfo.InvariantCulture);
            LEDRefreshRate                  = configuration.RefreshRates.LEDRefreshRate.ToString(CultureInfo.InvariantCulture);
            UseCustomSerialSpeed            = configuration.SerialPortSettings.UseCustomSerialSpeed;
            ColourDeltaByDD                 = configuration.TMDisplaySettings.ColourDeltaByDD;
            DeltaLightsOnDefault            = configuration.TMDisplaySettings.DeltaLightsOnDefault;
            DeltaMessageScreen              = configuration.TMDisplaySettings.DeltaMessageScreen;
            DeltaRange                      = configuration.TMDisplaySettings.DeltaRange - 1;
            UseCustomFuelCalculationOptions = configuration.OtherSettings.UseCustomFuelCalculationOptions;
            FuelCalculationLaps             = configuration.OtherSettings.FuelCalculationLaps - 2;
            UseWeightedFuelCalculations     = configuration.OtherSettings.UseWeightedFuelCalculations;
            WarningTextDisplayTime          = configuration.TMDisplaySettings.WarningTextDisplayTime - 1;
            QuickInfoLightsColour           = configuration.TMDisplaySettings.QuickInfoLightsColour;

            ControllerConfigurations = new List <ControllerButtonConfiguration>();
            foreach (ControllerConfiguration item in configuration.ControllerConfigurations)
            {
                var temp = new ControllerButtonConfiguration
                {
                    DeviceGuid           = item.DeviceGuid,
                    ButtonNumbers        = item.ButtonNumbers,
                    ButtonOptions        = item.ButtonOptions,
                    ButtonOptionsScreens = item.ButtonOptionsScreens,
                    Selected             = item.Selected
                };
                for (int k = 0; k < Constants.MaxNumberJoystickButtons; k++)
                {
                    temp.ButtonFunctions[k] = dicts.ButtonFunctions[item.ButtonFunctions[k]].Name;
                }
                ControllerConfigurations.Add(temp);
            }
            NumberControllers         = configuration.ControllerConfigurations.Count;
            DisplayUnitConfigurations = new List <DisplayUnitConfiguration>();
            int unitCount = 0;

            foreach (DisplayConfiguration displayConf in configuration.DisplayConfigurations)
            {
                unitCount++;
                var temp = new DisplayUnitConfiguration
                {
                    NumScreens           = displayConf.NumScreens - 1,
                    Inverted             = displayConf.Inverted,
                    IsTM1640             = displayConf.IsTM1640,
                    SwitchLEDs           = displayConf.SwitchLEDs,
                    ShowDC               = displayConf.ShowDC,
                    DCDisplayTime        = displayConf.DCDisplayTime,
                    ShowLap              = displayConf.ShowLap,
                    ButtonConfigurations = new ButtonConfiguration(),
                    UnitNumber           = unitCount,
                    ShowEngineWarnings   = displayConf.ShowEngineWarnings
                };
                DisplayConfiguration conf = displayConf;
                foreach (var lstyle in dicts.LapDisplayStyles.Where(lstyle => conf.LapStyle == lstyle.Value))
                {
                    temp.LapStyle = lstyle.Key;
                }
                foreach (var wtype in dicts.WarningTypes.Where(wtype => conf.WarningType == wtype.Value))
                {
                    temp.WarningType = wtype.Key;
                }

                for (int n = 0; n < Constants.NumberButtonsOnTm1638; n++)
                {
                    temp.ButtonConfigurations.ButtonFunctions[n] =
                        dicts.ButtonFunctions[displayConf.ButtonFunctions[n]].Name;
                    temp.ButtonConfigurations.ButtonOptions[n]        = displayConf.ButtonOptions[n];
                    temp.ButtonConfigurations.ButtonOptionsScreens[n] = displayConf.ButtonOptionsScreens[n];
                }
                temp.LEDsConfigurations = new LEDsConfiguration
                {
                    FFBClippingLights    = displayConf.FFBClippingLights,
                    FFBClippingScreen    = displayConf.FFBClippingScreen - 1,
                    PitLights            = displayConf.PitLights,
                    RevLimiterLights     = displayConf.RevLimiterLights,
                    ShowShiftLights      = displayConf.ShowShiftLights,
                    ShiftClumps          = displayConf.ShiftClumps,
                    MatchCarShiftLights  = displayConf.MatchCarShiftStyle,
                    MatchRedShift        = displayConf.MatchRedShift,
                    DeltaLightsShow      = displayConf.DeltaLightsShow,
                    MatchCarShiftOptions = "",
                };
                foreach (var opt in dicts.MatchCarShiftOptions)
                {
                    if (opt.Value == displayConf.MatchCarShiftStyleOption)
                    {
                        temp.LEDsConfigurations.MatchCarShiftOptions = opt.Key;
                    }
                }
                temp.LEDsConfigurations.DeltaLightsPosition = "";
                foreach (var opt in dicts.DeltaLightsPositionOptions)
                {
                    if (opt.Value == displayConf.DeltaLightsPosition)
                    {
                        temp.LEDsConfigurations.DeltaLightsPosition = opt.Key;
                    }
                }
                foreach (var plspeed in dicts.PitFlashSpeeds)
                {
                    if (plspeed.Value == displayConf.PitLimiterSpeed)
                    {
                        temp.LEDsConfigurations.PitLimiterSpeed = plspeed.Key;
                    }
                }
                foreach (var plstyle in dicts.PitFlashStyles)
                {
                    if (plstyle.Value == displayConf.PitLimiterStyle)
                    {
                        temp.LEDsConfigurations.PitLimiterStyle = plstyle.Key;
                    }
                }
                foreach (var revlstyle in dicts.RevFlashStyles)
                {
                    if (revlstyle.Value == displayConf.RevLimiterStyle)
                    {
                        temp.LEDsConfigurations.RevLimiterStyle = revlstyle.Key;
                    }
                }
                foreach (var shiftstyle in dicts.ShiftStyles)
                {
                    if (shiftstyle.Value == displayConf.ShiftLightStyle)
                    {
                        temp.LEDsConfigurations.ShiftLightStyle = shiftstyle.Key;
                    }
                }
                temp.Screens = displayConf.Screens;
                DisplayUnitConfigurations.Add(temp);
            }
        }