/// <summary> /// 设置UI上显示的项目参数 /// </summary> /// <param name="Item">误差检定方案项目</param> public void SetItemValue(StPlan_SpecalCheck Item) { Txt_PrjName.Text = Item.PrjName; Cmb_Fx.SelectedIndex = (int)Item.PowerFangXiang - 1; //功率方向 Cmb_Glys.Text = Item.PowerYinSu; //功率因素 Txt_Ua.Text = Item.xUa.ToString(); //A相电压倍数 Txt_Ub.Text = Item.xUb.ToString(); //B相电压倍数 Txt_Uc.Text = Item.xUc.ToString(); //C相电压倍数 Txt_Ia.Text = Item.xIa.ToString(); //A相电流倍数 Txt_Ib.Text = Item.xIb.ToString(); //B相电流倍数 Txt_Ic.Text = Item.xIc.ToString(); //C相电流倍数 Txt_Pl.Text = Item.PingLv.ToString(); Cmb_Xx.SelectedIndex = Item.XiangXu == 0 ? 0 : 1; //相序 if (Item.XieBo == 0) //是否加谐波 { Cmb_XieBo.SelectedIndex = 0; } else { Cmb_XieBo.Text = Item.XieBoFa; } Txt_Wccs.Text = Item.WcCheckNumic.ToString(); //误差次数 Txt_Wcqs.Text = Item.LapCount.ToString(); //误差圈数 Txt_WcUp.Text = Item.WuChaXian_Shang.ToString(); //误差上限 Txt_WcDown.Text = Item.WuChaXian_Xia.ToString(); //误差下限 }
/// <summary> /// 移动特殊检定项目 /// </summary> /// <param name="i">需要移动到的列表位置</param> /// <param name="Item">项目结构体</param> public void Move(int i, StPlan_SpecalCheck Item) { i = i < 0 ? 0 : i; i = i >= _LstSpecal.Count ? _LstSpecal.Count - 1 : i; this.Remove(Item); _LstSpecal.Insert(i, Item); return; }
/// <summary> /// 根据项目移除 /// </summary> /// <param name="Item">项目结构体</param> public void Remove(StPlan_SpecalCheck Item) { if (!_LstSpecal.Contains(Item)) { return; } _LstSpecal.Remove(Item); return; }
/// <summary> /// 添加一个项目信息 /// </summary> /// <param name="Item">特殊检定项目</param> /// <returns></returns> public bool Add(StPlan_SpecalCheck Item) { if (_LstSpecal.Contains(Item)) { return(false); } _LstSpecal.Add(Item); return(true); }
/// <summary> /// 根据列表索引ID获取项目数据 /// </summary> /// <param name="i">项目列表索引</param> /// <returns></returns> public StPlan_SpecalCheck getSpecalPrj(int i) { if (i >= _LstSpecal.Count) { return(new StPlan_SpecalCheck()); } StPlan_SpecalCheck Item = _LstSpecal[i]; Item.LoadXieBo(); //加载一次谐波参数 return(Item); }
/// <summary> /// 获取特殊检定项目对象 /// </summary> /// <returns>误差检定方案项目</returns> public StPlan_SpecalCheck GetItem() { StPlan_SpecalCheck Item = new StPlan_SpecalCheck(); if (Txt_PrjName.Text == string.Empty) //项目名称 { Item.PrjName = "新特殊检定项目"; } else { Item.PrjName = Txt_PrjName.Text; } Item.PowerFangXiang = (CLDC_Comm.Enum.Cus_PowerFangXiang)Cmb_Fx.SelectedIndex + 1; //功率方向 Item.PowerYinSu = Cmb_Glys.Text; //功率因数 Item.xUa = Txt_Ua.Text == string.Empty ? 0 : float.Parse(Txt_Ua.Text); //A相电压倍数 Item.xUb = Txt_Ub.Text == string.Empty ? 0 : float.Parse(Txt_Ub.Text); //B相电压倍数 Item.xUc = Txt_Ub.Text == string.Empty ? 0 : float.Parse(Txt_Uc.Text); //C相电压倍数 Item.xIa = Txt_Ia.Text == string.Empty ? 0 : float.Parse(Txt_Ia.Text); //A相电流倍数 Item.xIb = Txt_Ib.Text == string.Empty ? 0 : float.Parse(Txt_Ib.Text); //B相电流倍数 Item.xIc = Txt_Ic.Text == string.Empty ? 0 : float.Parse(Txt_Ic.Text); //C相电流倍数 Item.PingLv = Txt_Pl.Text == string.Empty ? 50 : float.Parse(Txt_Pl.Text); //频率 Item.XiangXu = Cmb_Xx.SelectedIndex; //相序 if (Cmb_XieBo.SelectedIndex == 0) //谐波 { Item.XieBo = 0; } else { Item.XieBo = 1; } if (Item.XieBo == 1) { Item.XieBoFa = Cmb_XieBo.Text; //谐波方案 } Item.WcCheckNumic = Txt_Wccs.Text == string.Empty ? 2 : int.Parse(Txt_Wccs.Text); //误差次数 Item.LapCount = Txt_Wcqs.Text == string.Empty ? 1 : int.Parse(Txt_Wcqs.Text); //误差圈数 if (!CLDC_DataCore.Function.Number.IsNumeric(Txt_WcUp.Text.Replace("+", ""))) //误差上限 { Txt_WcUp.Text = "1"; } if (!CLDC_DataCore.Function.Number.IsNumeric(Txt_WcDown.Text.Replace("+", ""))) //误差下限 { Txt_WcDown.Text = "-1"; } Item.WuChaXian_Shang = float.Parse(Txt_WcUp.Text.Replace("+", "")); Item.WuChaXian_Xia = float.Parse(Txt_WcDown.Text.Replace("+", "")); return(Item); }
/// <summary> /// 加载特殊检定方案 /// </summary> private void Load() { string _ErrorString = ""; try { _LstSpecal = new List <StPlan_SpecalCheck>(); XmlNode _XmlNode = clsXmlControl.LoadXml(_FAPath, out _ErrorString); if (_ErrorString != "") { return; } for (int _i = 0; _i < _XmlNode.ChildNodes.Count; _i++) { StPlan_SpecalCheck _Item = new StPlan_SpecalCheck(); _Item.PrjName = _XmlNode.ChildNodes[_i].Attributes["PrjName"].Value; //项目名称 _Item.PowerFangXiang = (CLDC_Comm.Enum.Cus_PowerFangXiang) int.Parse(_XmlNode.ChildNodes[_i].Attributes["GLFX"].Value); //功率方向 _Item.PowerYinSu = _XmlNode.ChildNodes[_i].Attributes["GLYS"].Value; //功率因素 _Item.ExplainUString(_XmlNode.ChildNodes[_i].Attributes["xU"].Value); //解析电压倍数 _Item.ExplainIString(_XmlNode.ChildNodes[_i].Attributes["xIb"].Value); //解析电流倍数 _Item.ExplainXwString(_XmlNode.ChildNodes[_i].Attributes["Xw"].Value); //解析相位 _Item.ExplainWcx(_XmlNode.ChildNodes[_i].Attributes["Wcx"].Value); //解析误差限 _Item.PingLv = float.Parse(_XmlNode.ChildNodes[_i].Attributes["Pl"].Value); //频率 _Item.WcCheckNumic = int.Parse(_XmlNode.ChildNodes[_i].Attributes["Wccs"].Value); //误差次数 _Item.LapCount = int.Parse(_XmlNode.ChildNodes[_i].Attributes["qs"].Value); _Item.XieBoFa = _XmlNode.ChildNodes[_i].Attributes["xiebo"].Value.Trim(); //谐波方案 if (_Item.XieBoFa == string.Empty) { _Item.XieBo = 0; } else { _Item.XieBo = 1; } _Item.XiangXu = int.Parse(_XmlNode.ChildNodes[_i].Attributes["xiangxu"].Value); _LstSpecal.Add(_Item); } } catch { } return; }
/// <summary> /// 数据刷新 /// </summary> /// <param name="MeterGroup">电能表数据集合</param> /// <param name="CheckOrderID">当前检定点</param> private void RefreshGrid(CLDC_DataCore.Model.DnbModel.DnbGroupInfo MeterGroup, int CheckOrderID) { if (!(MeterGroup.CheckPlan[CheckOrderID] is StPlan_SpecalCheck)) { return; } StPlan_SpecalCheck _Item = (StPlan_SpecalCheck)MeterGroup.CheckPlan[CheckOrderID]; #region ---------------------动态创建数据表格样式------------------------------ this.CreateColumnStyle(MeterGroup, _Item); //创建表格列样式 #endregion for (int i = 0; i < MeterGroup.MeterGroup.Count; i++) { CLDC_DataCore.Model.DnbModel.DnbInfo.MeterBasicInfo _MeterInfo = MeterGroup.MeterGroup[i]; DataGridViewRow _Row = Data_Error.Rows[i]; _Row.Cells[1].Value = _MeterInfo.ToString(); //表位号 if (!_MeterInfo.YaoJianYn) //如果不检 { _Row.Cells[0].Value = false; if (_MeterInfo.Mb_chrBcs == String.Empty || _MeterInfo.Mb_chrBdj == String.Empty) //如果不检,并且常数或者等级都为空,则将勾选单元格设置为只读 { _Row.Cells[0].ReadOnly = true; } for (int j = 2; j < _Row.Cells.Count; j++) { _Row.Cells[j].Value = string.Empty; } continue; } _Row.Cells[0].Value = true; _Row.Cells[2].Value = _Item.ToString(); //项目描述 string _Key = "P_" + CheckOrderID.ToString(); if (_MeterInfo.MeterSpecialErrs.ContainsKey(_Key)) //如果数据模型中已经存在改点的数据 { _Row.Cells[3].Value = _MeterInfo.MeterSpecialErrs[_Key].Mse_Result; string[] Arr_Err = _MeterInfo.MeterSpecialErrs[_Key].Mse_Wc.Split('|'); if (Arr_Err.Length <= 1) { continue; } for (int j = 0; j < Arr_Err.Length; j++) { if (Data_Error.Columns.Count <= j + 4) { break; } _Row.Cells[j + 4].Value = Arr_Err[j]; } if (_MeterInfo.MeterSpecialErrs[_Key].Mse_Result == CLDC_DataCore.Const.Variable.CTG_BuHeGe) //如果不合格需要修改当前行背景颜色为红色 { _Row.DefaultCellStyle.ForeColor = CLDC_DataCore.Const.Variable.Color_Grid_BuHeGe; //} foreach (DataGridViewCell cell in _Row.Cells) { cell.ToolTipText = MeterGroup.MeterGroup[i].MeterSpecialErrs[_Key].AVR_DIS_REASON; } } else { _Row.DefaultCellStyle.ForeColor = Color.Black; //} foreach (DataGridViewCell cell in _Row.Cells) { cell.ToolTipText = string.Empty; } } } else { //_Row.DefaultCellStyle.ForeColor = Color.Black; for (int j = 3; j < Data_Error.Columns.Count; j++) { _Row.Cells[j].Value = ""; } } if (_MeterInfo.Mb_Result == CLDC_DataCore.Const.Variable.CTG_BuHeGe) { _Row.DefaultCellStyle.ForeColor = Color.Red; } else { _Row.DefaultCellStyle.ForeColor = Color.Black; } } }
/// <summary> /// 设置创建表格列的样式 /// </summary> /// <param name="Index">列下标</param> private void CreateColumnStyle(CLDC_DataCore.Model.DnbModel.DnbGroupInfo MeterGroup, StPlan_SpecalCheck Item) { if (Data_Error.Columns.Count != Item.WcCheckNumic + 4 + 2) //如果误差数据表格的列数大于默认列数,则需要删除大于部分 误差次数+固定列+平均值,化整值列 { for (int i = Data_Error.Columns.Count - 1; i > 3; i--) { Data_Error.Columns.RemoveAt(i); } for (int i = 0; i < Item.WcCheckNumic; i++) { Data_Error.Columns.Add("Tmp_Col" + i.ToString(), "误差" + (i + 1).ToString()); } Data_Error.Columns.Add("Tmp_Pj", "平均值"); Data_Error.Columns.Add("Tmp_Hz", "化整值"); } float _FillWeight = 100F / (Data_Error.Columns.Count - 4); for (int i = 4; i < Data_Error.Columns.Count; i++) { DataGridViewColumn _Column = Data_Error.Columns[i]; _Column.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter; _Column.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; _Column.FillWeight = _FillWeight; } Data_Error.Refresh(); }