public void SetNewConfig(CPortConfig c, StabilityExchangeConfig stabilityExchangeConfig)
        {
            var p = (CComPort)IoC.Resolve <IPort>();

            p.Reconfig(c);
            _device.ExchangeConfig = stabilityExchangeConfig;
        }
Beispiel #2
0
        //public static double[] AlphaBetaKoefs { get; private set; }
        // public static InputFilterType FilterType { get; private set; }

        static MainConfig()
        {
            PortConfig     = new CPortConfig();
            WeightKoefs    = new double[4];
            ZeroAdcVals    = new double[4];
            ExchangeConfig = new StabilityExchangeConfig();
            //AlphaBetaKoefs = new double[4];

            if (ConfigurationManager.AppSettings.Count == 0)
            {
                Init();
            }

            Load();
        }
Beispiel #3
0
        public void GetWinState(out CPortConfig c, out StabilityExchangeConfig c1)
        {
            var name = combo_portName.SelectedValue;

            c = new CPortConfig()
            {
                AutoConnect = (bool)check_AutoConnect.IsChecked, Baud = MainConfig.PortConfig.Baud, UseSLIP = true, PortName = (string)name
            };

            var n = combo_RxPeriod.SelectedIndex;

            c1 = new StabilityExchangeConfig
            {
                FilterType        = (InputFilterType)combo_RxFilterType.SelectedIndex,
                SavePureADCs      = (bool)check_SavePureADCs.IsChecked,
                CorrectRxMistakes = (bool)check_CorrectMistakes.IsChecked,
                Period            = _periods[n],
                AlphaBetaKoefs    = w_koefs
            };
        }
Beispiel #4
0
        public static void Update(StabilityExchangeConfig config)
        {
            Configuration currentConfig = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);

            if (config != null)
            {
                currentConfig.AppSettings.Settings["FilterType"].Value        = config.FilterType.ToString();
                currentConfig.AppSettings.Settings["Period"].Value            = config.Period.ToString(CultureInfo.InvariantCulture);
                currentConfig.AppSettings.Settings["SavePureADCs"].Value      = config.SavePureADCs.ToString();
                currentConfig.AppSettings.Settings["CorrectRxMistakes"].Value = config.CorrectRxMistakes.ToString();

                currentConfig.AppSettings.Settings["AlphaBetaKoefs"].Value = config.AlphaBetaKoefs[0].ToString(CultureInfo.CreateSpecificCulture("en-GB")) + "," +
                                                                             config.AlphaBetaKoefs[1].ToString(CultureInfo.CreateSpecificCulture("en-GB")) + "," +
                                                                             config.AlphaBetaKoefs[2].ToString(CultureInfo.CreateSpecificCulture("en-GB")) + "," +
                                                                             config.AlphaBetaKoefs[3].ToString(CultureInfo.CreateSpecificCulture("en-GB"));
            }

            currentConfig.Save(ConfigurationSaveMode.Modified);
            ConfigurationManager.RefreshSection("appSettings");
            Load();
        }