Beispiel #1
0
        public void SaveConfig()
        {
            configData = new FilterConfigData();

            for (int i = 0; i < (int)GenericProviderData.DataKey.Max; ++i)
            {
                List <FilterBase> filterList = filters[i];
                if (filterList == null)
                {
                    continue;
                }
                else
                {
                    FilterDataKey newConfig = new FilterDataKey(i);
                    configData.keys.Add(newConfig);

                    foreach (FilterBase filter in filterList)
                    {
                        if (filter is NestedSmoothFilter)
                        {
                            SmoothFilterData   newFilterData    = new SmoothFilterData();
                            NestedSmoothFilter nestSmoothFilter = (NestedSmoothFilter)filter;
                            newFilterData.nestCount   = nestSmoothFilter.GetNestCount();
                            newFilterData.sampleCount = nestSmoothFilter.GetSampleCount();
                            newFilterData.maxDelta    = nestSmoothFilter.GetMaxDelta();

                            newConfig.filters.Add(newFilterData);
                        }
                        else
                        if (filter is KalmanNoiseFilter)
                        {
                            KalmanFilterData  newFilterData     = new KalmanFilterData();
                            KalmanNoiseFilter kalmanNoiseFilter = (KalmanNoiseFilter)filter;
                            newFilterData.a = kalmanNoiseFilter.GetA();
                            newFilterData.h = kalmanNoiseFilter.GetH();
                            newFilterData.q = kalmanNoiseFilter.GetQ();
                            newFilterData.r = kalmanNoiseFilter.GetR();
                            newFilterData.p = kalmanNoiseFilter.GetP();
                            newFilterData.x = kalmanNoiseFilter.GetX();

                            newConfig.filters.Add(newFilterData);
                        }
                    }
                }
            }


            string outputString = JsonConvert.SerializeObject(configData, Formatting.Indented, new JsonSerializerSettings
            {
                TypeNameHandling = TypeNameHandling.All
            });


            File.WriteAllText(configFilename, outputString);
        }
Beispiel #2
0
        public void SetFilter(KalmanNoiseFilter _filter)
        {
            filter = _filter;

            ignoreChanges = true;

            A.Text = "" + filter.GetA();
            H.Text = "" + filter.GetH();
            Q.Text = "" + filter.GetQ();
            R.Text = "" + filter.GetR();
            P.Text = "" + filter.GetP();
            X.Text = "" + filter.GetX();

            ignoreChanges = false;
        }
Beispiel #3
0
        private void A_TextChanged(object sender, EventArgs e)
        {
            if (ignoreChanges)
            {
                return;
            }

            filter.SetParameters(Utils.TextBoxSafeParseFloat(A, filter.GetA()),
                                 Utils.TextBoxSafeParseFloat(H, filter.GetH()),
                                 Utils.TextBoxSafeParseFloat(Q, filter.GetQ()),
                                 Utils.TextBoxSafeParseFloat(R, filter.GetR()),
                                 Utils.TextBoxSafeParseFloat(P, filter.GetP()),
                                 Utils.TextBoxSafeParseFloat(X, filter.GetX()));
        }