Ejemplo n.º 1
0
        /// <summary>
        /// 根据参数名称初始化具体信息
        /// </summary>
        /// <param name="caption"></param>
        /// <param name="dv"></param>
        private void GetMainDigit(string caption, DigitVarViewModel dv)
        {
            switch (caption)
            {
            case "充放电流":
                DigitVarViewModel.CopyTo(BatAmpDigitVar, dv);
                MainListDigit.Add(BatAmpDigitVar);
                break;

            case "总电压":
                DigitVarViewModel.CopyTo(BatVoltDigitVar, dv);
                MainListDigit.Add(BatVoltDigitVar);
                break;

            case "单节最高电压":
                DigitVarViewModel.CopyTo(cellMaxVoltDigit, dv);
                MainListDigit.Add(cellMaxVoltDigit);
                break;

            case "单节最低电压":
                DigitVarViewModel.CopyTo(cellMinVoltDigit, dv);
                MainListDigit.Add(cellMinVoltDigit);
                break;

            case "单节平均电压":
                DigitVarViewModel.CopyTo(cellAvrVoltDigit, dv);
                MainListDigit.Add(cellAvrVoltDigit);
                break;

            default:
                break;
            }
        }
        /// <summary>
        /// itemViewModel初始化
        /// </summary>
        private void LoadDataList()
        {
            //将电芯列表复制过来
            foreach (var item in teleMeterCellList)
            {
                DigitVarViewModel dv = new DigitVarViewModel();
                DigitVarViewModel.CopyTo(dv, item);
                PackCellList.Add(dv);
            }

            //将其他列表复制过来
            foreach (var item in teleMeterOtherList)
            {
                DigitVarViewModel dv = new DigitVarViewModel();
                DigitVarViewModel.CopyTo(dv, item);
                if (dv.VarName.Contains("电池温度"))
                {
                    TempertureList.Add(dv);
                }
                else
                {
                    //电池温度先不添加到teleMeterOtherList中!
                    PackOtherList.Add(dv);
                }
            }

            packGroupIndex = Convert.ToInt32(SelectedItem.GroupHeader.Substring(SelectedItem.GroupHeader.Length - 2, 2)) - 1;
            packIndex      = SelectedItem.ItemId - 1;
        }
Ejemplo n.º 3
0
        public void ChangePackChoose(int _cellNum, int _TemperatureNum)
        {
            PackCellList.Clear();
            TempertureList.Clear();
            PackOtherList.Clear();
            PackMainList.Clear();
            PackListColumn.Clear();
            PackDataTypeComobox.Clear();
            dataHistoryPack.Columns.Clear();
            PackHistoryDataList.Clear();

            //将电芯列表复制过来
            foreach (var item in teleMeterCellList)
            {
                DigitVarViewModel dv = new DigitVarViewModel();
                DigitVarViewModel.CopyTo(dv, item);
                PackCellList.Add(dv);
            }

            //将其他列表复制过来
            foreach (var item in teleMeterOtherList)
            {
                DigitVarViewModel dv = new DigitVarViewModel();
                DigitVarViewModel.CopyTo(dv, item);
                if (dv.VarName.Contains("电池温度"))
                {
                    TempertureList.Add(dv);
                }
                else
                {
                    PackOtherList.Add(dv);
                }
            }
            foreach (var item in MainListDigit)
            {
                DigitVarViewModel dv = new DigitVarViewModel();
                DigitVarViewModel.CopyTo(dv, item);
                PackMainList.Add(dv);
            }

            InitialPackViewModelData(_cellNum, _TemperatureNum, ref PackCellList, ref PackOtherList, ref TempertureList, ref PackMainList);


            foreach (var item in PackMainList)
            {
                PackHistoryDataList.Add(item);
            }
            foreach (var item in PackCellList)
            {
                PackHistoryDataList.Add(item);
            }
            foreach (var item in PackOtherList)
            {
                PackHistoryDataList.Add(item);
            }
            foreach (var item in TempertureList)
            {
                PackHistoryDataList.Add(item);
            }

            //Pack历史信息汇总
            dataHistoryPack.Columns.Add("时间");
            GridColumn dcTime = new GridColumn();

            dcTime.Header    = "时间";
            dcTime.FieldName = "时间";
            PackListColumn.Add(dcTime);
            foreach (DigitVarViewModel dv in PackHistoryDataList)
            {
                GridColumn dc = new GridColumn();
                dc.Header    = dv.VarNameUnit;
                dc.FieldName = dv.VarNameUnit;
                PackListColumn.Add(dc);
                dataHistoryPack.Columns.Add(dv.VarNameUnit);
                PackDataTypeComobox.Add(dv.VarNameUnit);
            }
            AfterSelectPackFun(null);
        }
        /// <summary>
        /// itemPage初始化
        /// </summary>
        public void SetMainList()
        {
            //主要信息复制过来
            DigitVarViewModel.CopyTo(BatVolt, BatVoltDigitVar);
            MainList.Add(BatVolt);

            DigitVarViewModel.CopyTo(BatTemp, BatAmpDigitVar);
            MainList.Add(BatTemp);

            DigitVarViewModel.CopyTo(cellMaxVolt, cellMaxVoltDigit);
            MainList.Add(cellMaxVolt);

            DigitVarViewModel.CopyTo(cellAvrVolt, cellAvrVoltDigit);
            MainList.Add(cellAvrVolt);

            DigitVarViewModel.CopyTo(cellMinVolt, cellMinVoltDigit);
            MainList.Add(cellMinVolt);

            DigitVarViewModel.CopyTo(modeDigit, modeTextDigit);
            //工作模式字节索引
            modeDigit.VarByteIndex += (SelectedItem.CellNum - PackCellList.Count + SelectedItem.TemperatureNum - TempertureList.Count) * 3;

            //判断当前pack电芯数量和温度数量是否和加载的协议一样,不一样的话则重置字节索引
            InitialPackViewModelData(SelectedItem.CellNum, SelectedItem.TemperatureNum, ref PackCellList, ref PackOtherList, ref TempertureList, ref MainList);


            foreach (var item in MainList)
            {
                CurrentDataList.Add(item);
            }

            foreach (var item in PackCellList)
            {
                CurrentDataList.Add(item);
            }

            for (int i = TempertureList.Count - 1; i >= 0; i--)
            {
                //倒序添加到PackOtherList
                PackOtherList.Insert(2, TempertureList[i]);
            }
            foreach (var item in PackOtherList)
            {
                CurrentDataList.Add(item);
            }

            dataCurrent.Columns.Add("时间");
            foreach (DigitVarViewModel dv in CurrentDataList)
            {
                dataCurrent.Columns.Add(dv.VarNameUnit);
                PackDataTypeComobox.Add(dv.VarNameUnit);
            }

            if (socketClient != null)
            {
                OffConnect = socketClient.OffLine;
                //开启自动刷新
                AutoRenovate = true;
                ItemDetail_Tick(this, null);
            }
            else
            {
                OffConnect = true;
            }
        }