Exemplo n.º 1
0
        public ViewModelCHB(string name, MainViewModel parent)
        {
            FileName    = name;
            DisplayName = name;
            modelChb    = new ModelCHB();
            modelChb.PropertyChanged += modelChb_PropertyChanged;
            var    Text    = File.ReadAllLines(name);
            string primNum = string.Empty;
            string secNum  = string.Empty;
            string volt    = string.Empty;

            IsCanBild = false;
            try
            {
                modelChb.ClearAll();

                AnData = Text.Where(txtItem => txtItem.Split('|').Any(strItem => strItem.Trim().Equals("").Equals(false))).
                         Where(txtItem => txtItem.Split('|').ElementAt(5).Trim().Equals("").Equals(false)).
                         Where(txtItem => txtItem.Split('|').Any(strItem => strItem.Trim().Equals("PrimNumb")).Equals(false)).Select(strItem =>
                {
                    string[] strArr = strItem.Split('|').Select(item => item.Trim()).ToArray();

                    if (!strArr[2].Equals(""))
                    {
                        primNum = !strArr[2].Equals("0000") ? strArr[2].TrimStart('0') : "0";
                        secNum  = !strArr[3].Equals("0000") ? strArr[3].TrimStart('0') : "0";
                        volt    = strArr[4];
                    }

                    return(new AnalizerData()
                    {
                        Date = strArr[0],
                        Time = strArr[1],
                        PrimNumber = primNum,
                        SecNumber = secNum,
                        Voltage = volt,
                        Frequency = strArr[5].Split('.').First(),
                        ZValue = strArr[6],
                        RValue = strArr[7],
                        XValue = strArr[8],
                        AValue = strArr[9]
                    });
                }).ToList();
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
            BatteryNums     = AnData.Select(item => item.PrimNumber).Distinct().OrderBy(item => int.Parse(item)).ToList();
            SelectedBattery = BatteryNums.FirstOrDefault();

            IsCanBild = true;

            modelChb.GetRVData();
            modelChb.GetAxisScale();
            modelChb.GetModa();
            modelChb.ViewChart();
        }
Exemplo n.º 2
0
        public ViewModelCHB()
        {
            modelChb = new ModelCHB();


            modelChb.PropertyChanged += modelChb_PropertyChanged;
            ChartTitle = (Thread.CurrentThread.CurrentUICulture.ToString().Contains("en") ? "Battery Parameters" : "Параметры АКБ");

            modelChb.ViewChart();
        }