Exemplo n.º 1
0
        private void Cmb_Protocol_SelectionChangeCommitted(object sender, EventArgs e)
        {
            MessageBoxEx.UseSystemLocalizedString = true;
            if (Cmb_Protocol.Tag != null & Cmb_Protocol.Tag.ToString() != Cmb_Protocol.Text)
            {
                CLDC_DataCore.Model.DgnProtocol.DgnProtocolInfo _Protocol = new CLDC_DataCore.Model.DgnProtocol.DgnProtocolInfo(Cmb_Protocol.Text);
                if (!_Protocol.Loading)
                {
                    Cmb_Protocol.Text = Cmb_Protocol.Tag.ToString();
                    return;
                }

                if (MessageBoxEx.Show(this, "是否所有表都使用该通信协议?\n点击确认将自动更新所有被检表的通信协议,点击取消将只更新当前选中被检表的通信协议。"
                                      , "询问"
                                      , MessageBoxButtons.OKCancel
                                      , MessageBoxIcon.Question) == DialogResult.Cancel)
                {
                    this.ValueChanged("DgnProtocol", _Protocol, this._Bwh);
                }
                else
                {
                    this.ValueChanged("DgnProtocol", _Protocol, 999);          //约定全部更新使用999
                }
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// 菜单按钮点击事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ToolMenuItem_Click(object sender, EventArgs e)
        {
            CLDC_DataCore.Model.DgnProtocol.DgnProtocolInfo _Protocol = new CLDC_DataCore.Model.DgnProtocol.DgnProtocolInfo(((ToolStripItem)sender).Tag.ToString());
            if (!_Protocol.Loading)          //加载失败
            {
                MessageBox.Show("打开通信协议出错,请联系厂家技术人员.....", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }


            this.SetFormTitle(_Protocol.ProtocolName);

            Cmb_ZZCJ.Text          = _Protocol.DnbFactroy;
            Cmb_Bxh.Text           = _Protocol.DnbSize;
            Cmb_ProtocolClass.Text = _Protocol.ClassName;
            Txt_Clock.Text         = _Protocol.ClockPL.ToString();
            object _Item = null;

            _Item = Panel_Data.Controls[0];
            if (_Item is ProtocolView.DLT645)
            {
                if (((ProtocolView.DLT645)_Item).setInfo(_Protocol))
                {
                    return;
                }
            }
            if (_Item is ProtocolView.DLT6452007)
            {
                if (((ProtocolView.DLT6452007)_Item).setInfo(_Protocol))
                {
                    return;
                }
            }
            if (_Item is ProtocolView.EDMIMK)
            {
                if (((ProtocolView.EDMIMK)_Item).setInfo(_Protocol))
                {
                    return;
                }
            }
            if (_Item is ProtocolView.IEC1107St)
            {
                if (((ProtocolView.IEC1107St)_Item).setInfo(_Protocol))
                {
                    return;
                }
            }
            if (_Item is ProtocolView.A1600)
            {
                if (((ProtocolView.A1600)_Item).setInfo(_Protocol))
                {
                    return;
                }
            }

            MessageBox.Show("协议信息加载失败....", "错误", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
        }
Exemplo n.º 3
0
 private void SetNewProtocolInfo(CLDC_DataCore.Model.DgnProtocol.DgnProtocolInfo Protocol, int RowIndex)
 {
     Dgv_Data.Rows[RowIndex].Cells[4].Value = Protocol.ProtocolName;
     Dgv_Data.Rows[RowIndex].Cells[5].Value = Protocol.Setting;
     Dgv_Data.Rows[RowIndex].Cells[7].Value = Protocol.WritePassword + Protocol.WriteClass;
     Dgv_Data.Rows[RowIndex].Cells[7].Tag   = Dgv_Data.Rows[RowIndex].Cells[7].Value;
     Dgv_Data.Rows[RowIndex].Cells[8].Value = Protocol.ClearDemandPassword + Protocol.ClearDemandClass;
     Dgv_Data.Rows[RowIndex].Cells[8].Tag   = Dgv_Data.Rows[RowIndex].Cells[8].Value;
     Dgv_Data.Rows[RowIndex].Cells[9].Value = Protocol.ClearDLPassword + Protocol.ClearDLClass;
     Dgv_Data.Rows[RowIndex].Cells[9].Tag   = Dgv_Data.Rows[RowIndex].Cells[9].Value;
 }
Exemplo n.º 4
0
        /// <summary>
        /// 第4列(协议名称)选择变化触发的事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Dgv_Data_CellValueChanged(object sender, DataGridViewCellEventArgs e)
        {
            if (e.ColumnIndex == -1 || e.RowIndex == -1)
            {
                return;
            }
            if (e.ColumnIndex == 4)
            {
                if (Dgv_Data[e.ColumnIndex, e.RowIndex].Tag != null)           //如果还没有初始化完成则退出
                {
                    if (Dgv_Data[e.ColumnIndex, e.RowIndex].Tag == Dgv_Data[e.ColumnIndex, e.RowIndex].Value)
                    {
                        return;
                    }
                }
                else
                {
                    Dgv_Data[e.ColumnIndex, e.RowIndex].Tag = string.Empty;
                }
                CLDC_DataCore.Model.DgnProtocol.DgnProtocolInfo _Protocol = new CLDC_DataCore.Model.DgnProtocol.DgnProtocolInfo(Dgv_Data[e.ColumnIndex, e.RowIndex].Value.ToString());

                if (!_Protocol.Loading)      //如果打开协议失败,则警告并返回
                {
                    //MessageBoxEx.Show(this,"协议加载失败,请选择其他协议,或联系供应商解决...", "加载失败", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    Dgv_Data[e.ColumnIndex, e.RowIndex].Value = Dgv_Data[e.ColumnIndex, e.RowIndex].Tag;
                    return;
                }

                if (e.RowIndex == 0)            //如果是第一行,则全部相同
                {
                    for (int i = 0; i < Dgv_Data.Rows.Count; i++)
                    {
                        if (Dgv_Data.Rows[i].Cells[1].Value == null || Dgv_Data.Rows[i].Cells[1].Value.ToString() == string.Empty)
                        {
                            continue;
                        }

                        this.SetNewProtocolInfo(_Protocol, i);
                    }
                }
                else
                {
                    this.SetNewProtocolInfo(_Protocol, e.RowIndex);
                }
                Dgv_Data[e.ColumnIndex, e.RowIndex].Tag = Dgv_Data[e.ColumnIndex, e.RowIndex].Value;
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// 输入协议名称后的保存事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Cmd_Save_Click(object sender, EventArgs e)
        {
            if (Txt_ProtocolName.Text == "")
            {
                MessageBox.Show("请输入一个协议名称...", "错误", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                Txt_ProtocolName.Focus();
                return;
            }
            CLDC_DataCore.Model.DgnProtocol.DgnProtocolInfo _ProtocolInfo = (CLDC_DataCore.Model.DgnProtocol.DgnProtocolInfo)Panel_SaveName.Tag;

            if (CLDC_DataCore.Model.DgnProtocol.DgnProtocolInfo.ContainsNodeBypName(Txt_ProtocolName.Text))
            {
                if (Cmd_Save.Tag == null)         //该标示如果是Null,则标示是另存为,如果不为空则表示是保存,不需要询问直接删除存在的协议
                {
                    if (MessageBox.Show(string.Format("已经存在协议名称为:{0}的协议文件,请问是否覆盖?\n如果选择不覆盖,将放弃本次保存", Txt_ProtocolName.Text), "保存询问", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
                    {
                        return;
                    }
                }
                CLDC_DataCore.Model.DgnProtocol.DgnProtocolInfo.RemoveProtocol(Txt_ProtocolName.Text);
            }
            if (Cmd_Save.Tag == null && (bool)Txt_ProtocolName.Tag)
            {
                CLDC_DataCore.Model.DgnProtocol.DgnProtocolInfo.RemoveProtocol(Cmb_ZZCJ.Text, Cmb_Bxh.Text);
            }


            _ProtocolInfo.ProtocolName = Txt_ProtocolName.Text;
            try
            {
                if (_ProtocolInfo.AddNewProtocol())
                {
                    MessageBox.Show("保存成功,请返回...", "保存提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    this.SetFormTitle(_ProtocolInfo.ProtocolName);
                }
                else
                {
                    MessageBox.Show("保存失败,请联系厂家...", "未知错误", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            this.Cmd_CancelSave_Click(sender, e);
        }
Exemplo n.º 6
0
        public override bool getInfo(ref CLDC_DataCore.Model.DgnProtocol.DgnProtocolInfo ProtocolInfo)
        {
            if (ProtocolInfo == null)
            {
                return(false);
            }

            ProtocolInfo.Setting             = Cmb_Setting.Text;                        //通信参数
            ProtocolInfo.UserID              = Txt_UserID.Text;                         //登陆用户名
            ProtocolInfo.WritePassword       = Txt_WritePwd.Text;                       //写密码
            ProtocolInfo.WriteClass          = Txt_WriteClass.Text;                     //写等级
            ProtocolInfo.ClearDemandPassword = Txt_ClearXLPwd.Text;                     //清需量密码
            ProtocolInfo.ClearDemandClass    = Txt_ClearXLClass.Text;                   //清需量等级
            ProtocolInfo.ClearDLPassword     = Txt_ClearDLPwd.Text;                     //清电量密码
            ProtocolInfo.ClearDLClass        = Txt_ClearDLClass.Text;                   //清电量等级
            ProtocolInfo.VerifyPasswordType  = Cmb_VerifyType.SelectedIndex;            //密码验证了姓

            try
            {
                ProtocolInfo.FECount = int.Parse(Txt_FECount.Text);                     //下发FE个数
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message, "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(false);
            }

            {
                string[] TmpFeiLvOrder = new string[4];

                TmpFeiLvOrder[int.Parse(Cmb_Jian.Text) - 1] = "1";

                TmpFeiLvOrder[int.Parse(Cmb_Feng.Text) - 1] = "2";

                TmpFeiLvOrder[int.Parse(Cmb_Ping.Text) - 1] = "3";

                TmpFeiLvOrder[int.Parse(Cmb_Gu.Text) - 1] = "4";

                ProtocolInfo.TariffOrderType = string.Join("", TmpFeiLvOrder);         //费率排序

                TmpFeiLvOrder = null;
            }

            ProtocolInfo.DateTimeFormat     = Cmb_DateTimeFormat.Text;        //时间格式化字符串
            ProtocolInfo.SundayIndex        = int.Parse(Cmb_SundayType.Text); //周末表示
            ProtocolInfo.DataFieldPassword  = Chk_DataFiledPwd.Checked;       //数据域是否包含密码
            ProtocolInfo.BlockAddAA         = Chk_BlockAddAA.Checked;         //写数据块是否+AA
            ProtocolInfo.ConfigFile         = Txt_ConfigFile.Text;            //配置文件,暂时无用
            ProtocolInfo.HaveProgrammingkey = Chk_IsHaveProgramKey.Checked;   //是否有编程键
            ProtocolInfo.IsSouthEncryption  = chk_IsSouthEn.Checked;          //是否是南网费控表

            ProtocolInfo.DgnPras = new Dictionary <string, string>();

            if (Type_CommTest.SelectedIndex > -1)
            {
                ProtocolInfo.DgnPras.Add("001", Type_CommTest.SelectedIndex.ToString() + "|");      //通信测试
            }

            ProtocolInfo.DgnPras.Add("002", Type_WriteTime.SelectedIndex.ToString() + "|");    //写表时间
            ProtocolInfo.DgnPras.Add("003", Type_ReadTime.SelectedIndex.ToString() + "|");     //读表时间
            ProtocolInfo.DgnPras.Add("004", Type_ClearXL.SelectedIndex.ToString() + "|");      //清空需量

            if (Type_ReadXL.SelectedIndex > -1)
            {
                ProtocolInfo.DgnPras.Add("005", Type_ReadXL.SelectedIndex.ToString() + "|");       //读表需量
            }
            if (Type_ReadDL.SelectedIndex > -1)
            {
                ProtocolInfo.DgnPras.Add("006", Type_ReadDL.SelectedIndex.ToString() + "|");        //读表电量
            }
            if (Type_ReadSD.SelectedIndex > -1)
            {
                ProtocolInfo.DgnPras.Add("007", Type_ReadSD.SelectedIndex.ToString() + "|");     //读表时段
            }
            ProtocolInfo.DgnPras.Add("008", Type_ClearDL.SelectedIndex.ToString() + "|");        //清空电量

            if (Title_EventLog.Text.Trim().Length > 0)
            {
                ProtocolInfo.DgnPras.Add("100", string.Format("{0}|{1}|{2}", Title_EventLog.Text, Len_EventLog.Text, Dot_EventLog.Text));        //事件记录
            }

            if (Title_NowRom.Text.Trim().Length > 0)
            {
                ProtocolInfo.DgnPras.Add("101", string.Format("{0}|{1}|{2}", Title_NowRom.Text, Len_NowRom.Text, Dot_NowRom.Text));        //瞬时寄存器检查
            }

            if (Title_State.Text.Trim().Length > 0)
            {
                ProtocolInfo.DgnPras.Add("102", string.Format("{0}|{1}|{2}", Title_State.Text, Len_State.Text, Dot_State.Text));        //状态寄存器检查
            }

            if (Title_Lost.Text.Trim().Length > 0)
            {
                ProtocolInfo.DgnPras.Add("103", string.Format("{0}|{1}|{2}", Title_Lost.Text, Len_Lost.Text, Dot_Lost.Text));        //失压寄存器检查
            }

            if (Title_Run.Text.Trim().Length > 0)
            {
                ProtocolInfo.DgnPras.Add("104", string.Format("{0}|{1}|{2}", Title_Run.Text, Len_Run.Text, Dot_Run.Text));        //运行状态检查
            }

            if (Title_Yff.Text.Trim().Length > 0)
            {
                ProtocolInfo.DgnPras.Add("105", string.Format("{0}|{1}|{2}", Title_Yff.Text, Len_Yff.Text, Dot_Yff.Text));        //预付费检查
            }

            return(true);
        }
Exemplo n.º 7
0
        /// <summary>
        /// 根据协议模型将协议配置数据填充到窗体中
        /// </summary>
        /// <param name="ProtocolInfo"></param>
        /// <returns></returns>
        public bool setInfo(CLDC_DataCore.Model.DgnProtocol.DgnProtocolInfo ProtocolInfo)
        {
            if (ProtocolInfo == null || !ProtocolInfo.Loading)//如果协议模型为空,或者加载失败的话直接退出
            {
                return(false);
            }
            this.TestProtocol            = ProtocolInfo;
            Cmb_Setting.Text             = ProtocolInfo.Setting;                                       //通信参数
            Txt_UserID.Text              = ProtocolInfo.UserID;                                        //登陆用户
            Txt_WritePwd.Text            = ProtocolInfo.WritePassword;                                 //写密码
            Txt_WriteClass.Text          = ProtocolInfo.WriteClass;                                    //写密码等级
            Txt_ClearXLPwd.Text          = ProtocolInfo.ClearDemandPassword;                           //清需量密码
            Txt_ClearXLClass.Text        = ProtocolInfo.ClearDemandClass;                              //清需量等级
            Txt_ClearDLPwd.Text          = ProtocolInfo.ClearDLPassword;                               //清电量密码
            Txt_ClearDLClass.Text        = ProtocolInfo.ClearDLClass;                                  //清电量等级
            Cmb_VerifyType.SelectedIndex = ProtocolInfo.VerifyPasswordType;                            //验证方式
            Txt_FECount.Text             = ProtocolInfo.FECount.ToString();                            //下发FE个数
            Cmb_Jian.Text                = (ProtocolInfo.TariffOrderType.IndexOf("1") + 1).ToString(); //尖费率号
            Cmb_Feng.Text                = (ProtocolInfo.TariffOrderType.IndexOf("2") + 1).ToString(); //峰费率号
            Cmb_Ping.Text                = (ProtocolInfo.TariffOrderType.IndexOf("3") + 1).ToString(); //平费率号
            Cmb_Gu.Text                  = (ProtocolInfo.TariffOrderType.IndexOf("4") + 1).ToString(); //谷费率号
            Cmb_DateTimeFormat.Text      = ProtocolInfo.DateTimeFormat;                                //日期格式化字符串
            Cmb_SundayType.Text          = ProtocolInfo.SundayIndex.ToString();                        //周末表示
            Chk_DataFiledPwd.Checked     = ProtocolInfo.DataFieldPassword;                             //数据域是否包含密码
            Chk_BlockAddAA.Checked       = ProtocolInfo.BlockAddAA;                                    //写数据库块是否+AA
            Txt_ConfigFile.Text          = ProtocolInfo.ConfigFile;                                    //配置文件,暂时无用
            Chk_IsHaveProgramKey.Checked = ProtocolInfo.HaveProgrammingkey;                            //是否有编程键
            chk_IsSouthEn.Checked        = ProtocolInfo.IsSouthEncryption;

            Type_CommTest.SelectedIndex  = -1;
            Type_WriteTime.SelectedIndex = -1;
            Type_ReadTime.SelectedIndex  = -1;
            Type_ClearXL.SelectedIndex   = -1;
            Type_ReadXL.SelectedIndex    = -1;
            Type_ReadDL.SelectedIndex    = -1;
            Type_ReadSD.SelectedIndex    = -1;
            Type_ClearDL.SelectedIndex   = -1;
            Title_EventLog.Text          = "";
            Len_EventLog.Text            = "";
            Dot_EventLog.Text            = "";
            Title_NowRom.Text            = "";
            Len_NowRom.Text  = "";
            Dot_NowRom.Text  = "";
            Title_State.Text = "";
            Len_State.Text   = "";
            Dot_State.Text   = "";
            Title_Lost.Text  = "";
            Len_Lost.Text    = "";
            Dot_Lost.Text    = "";
            Title_Run.Text   = "";
            Len_Run.Text     = "";
            Dot_Run.Text     = "";
            Title_Yff.Text   = "";
            Len_Yff.Text     = "";
            Dot_Yff.Text     = "";

            if (ProtocolInfo.DgnPras.Count > 0)
            {
                string[] TmpArr;
                if (ProtocolInfo.DgnPras.ContainsKey("001"))
                {
                    Type_CommTest.SelectedIndex = int.Parse(ProtocolInfo.DgnPras["001"].Split('|')[0]);           //通信测试
                }
                if (ProtocolInfo.DgnPras.ContainsKey("002"))
                {
                    Type_WriteTime.SelectedIndex = int.Parse(ProtocolInfo.DgnPras["002"].Split('|')[0]);            //写表时间
                }
                if (ProtocolInfo.DgnPras.ContainsKey("003"))
                {
                    Type_ReadTime.SelectedIndex = int.Parse(ProtocolInfo.DgnPras["003"].Split('|')[0]);             //杜彪时间
                }
                if (ProtocolInfo.DgnPras.ContainsKey("004"))
                {
                    Type_ClearXL.SelectedIndex = int.Parse(ProtocolInfo.DgnPras["004"].Split('|')[0]);              //清空需量
                }
                if (ProtocolInfo.DgnPras.ContainsKey("005"))
                {
                    Type_ReadXL.SelectedIndex = int.Parse(ProtocolInfo.DgnPras["005"].Split('|')[0]);               //读取需量
                }
                if (ProtocolInfo.DgnPras.ContainsKey("006"))
                {
                    Type_ReadDL.SelectedIndex = int.Parse(ProtocolInfo.DgnPras["006"].Split('|')[0]);               //读取电量
                }
                if (ProtocolInfo.DgnPras.ContainsKey("007"))
                {
                    Type_ReadSD.SelectedIndex = int.Parse((ProtocolInfo.DgnPras["007"].Split('|'))[0]);             //读取时段
                }
                if (ProtocolInfo.DgnPras.ContainsKey("008"))
                {
                    Type_ClearDL.SelectedIndex = int.Parse(ProtocolInfo.DgnPras["008"].Split('|')[0]); //清空电量
                }
                if (ProtocolInfo.DgnPras.ContainsKey("100"))                                           //事件记录
                {
                    TmpArr = ProtocolInfo.DgnPras["100"].Split('|');
                    if (TmpArr.Length < 3)
                    {
                        return(false);
                    }
                    Title_EventLog.Text = TmpArr[0];
                    Len_EventLog.Text   = TmpArr[1];
                    Dot_EventLog.Text   = TmpArr[2];
                }
                if (ProtocolInfo.DgnPras.ContainsKey("101"))                                //瞬时存储器
                {
                    TmpArr = ProtocolInfo.DgnPras["101"].Split('|');
                    if (TmpArr.Length < 3)
                    {
                        return(false);
                    }
                    Title_NowRom.Text = TmpArr[0];
                    Len_NowRom.Text   = TmpArr[1];
                    Dot_NowRom.Text   = TmpArr[2];
                }
                if (ProtocolInfo.DgnPras.ContainsKey("102"))                                //状态寄存器
                {
                    TmpArr = ProtocolInfo.DgnPras["102"].Split('|');
                    if (TmpArr.Length < 3)
                    {
                        return(false);
                    }
                    Title_State.Text = TmpArr[0];
                    Len_State.Text   = TmpArr[1];
                    Dot_State.Text   = TmpArr[2];
                }
                if (ProtocolInfo.DgnPras.ContainsKey("103"))                                //失压寄存器
                {
                    TmpArr = ProtocolInfo.DgnPras["103"].Split('|');
                    if (TmpArr.Length < 3)
                    {
                        return(false);
                    }
                    Title_Lost.Text = TmpArr[0];
                    Len_Lost.Text   = TmpArr[1];
                    Dot_Lost.Text   = TmpArr[2];
                }
                if (ProtocolInfo.DgnPras.ContainsKey("104"))
                {
                    TmpArr = ProtocolInfo.DgnPras["104"].Split('|');             //运行状态
                    if (TmpArr.Length < 3)
                    {
                        return(false);
                    }
                    Title_Run.Text = TmpArr[0];
                    Len_Run.Text   = TmpArr[1];
                    Dot_Run.Text   = TmpArr[2];
                }
                if (ProtocolInfo.DgnPras.ContainsKey("105"))                                //预付费
                {
                    TmpArr = ProtocolInfo.DgnPras["105"].Split('|');
                    if (TmpArr.Length < 3)
                    {
                        return(false);
                    }
                    Title_Yff.Text = TmpArr[0];
                    Len_Yff.Text   = TmpArr[1];
                    Dot_Yff.Text   = TmpArr[2];
                }
            }

            return(true);
        }
Exemplo n.º 8
0
        /// <summary>
        /// 如果项目参数改变
        /// </summary>
        /// <returns></returns>
        public bool ChangeFAPram()
        {
            bool Changed = false;

            CLDC_DataCore.Model.DgnProtocol.DgnProtocolInfo _Protocol = new CLDC_DataCore.Model.DgnProtocol.DgnProtocolInfo();

            for (int i = 0; i < _DnbInfo.MeterGroup.Count; i++)
            {
                if (!_DnbInfo.MeterGroup[i].YaoJianYn)
                {
                    continue;
                }
                if (Dgv_Data.Rows.Count <= i)
                {
                    return(Changed);
                }
                if (Dgv_Data.Rows[i].Cells[4].Value == null || Dgv_Data.Rows[i].Cells[4].Value.ToString() == string.Empty)         //如果没有协议就不需要处理了!
                {
                    if (_DnbInfo.MeterGroup[i].DgnProtocol.Loading)
                    {
                        Changed = true;
                        _DnbInfo.MeterGroup[i].DgnProtocol = _Protocol;             //赋值一个空的协议
                    }
                    continue;
                }
                if (!_DnbInfo.MeterGroup[i].DgnProtocol.Loading ||
                    _DnbInfo.MeterGroup[i].DgnProtocol.ProtocolName != Dgv_Data.Rows[i].Cells[4].Value.ToString())            //如果协议为空,或者当前选择协议和模型中协议不一致,则重新创建
                {
                    CLDC_DataCore.Model.DgnProtocol.DgnProtocolInfo _NewProtocol = new CLDC_DataCore.Model.DgnProtocol.DgnProtocolInfo(Dgv_Data.Rows[i].Cells[4].Value.ToString());
                    if (_NewProtocol.Loading)           //如果新选择的协议加载成功则改变,否则不做任何操作
                    {
                        Changed = true;
                        _DnbInfo.MeterGroup[i].DgnProtocol       = _NewProtocol;
                        _DnbInfo.MeterGroup[i].AVR_PROTOCOL_NAME = _NewProtocol.ProtocolName;
                    }
                }
                if (!_DnbInfo.MeterGroup[i].DgnProtocol.Loading)
                {
                    continue;
                }

                CLDC_DataCore.Model.DgnProtocol.DgnProtocolInfo _MeterProtocol = _DnbInfo.MeterGroup[i].DgnProtocol;

                if (_MeterProtocol.Setting != Dgv_Data.Rows[i].Cells[5].Value.ToString())
                {
                    _MeterProtocol.Setting = Dgv_Data.Rows[i].Cells[5].Value.ToString();
                    Changed = true;
                }

                #region ----------------------------------------------密码修改---------------------------------------------------------
                if (_MeterProtocol.WritePassword + _MeterProtocol.WriteClass != Dgv_Data.Rows[i].Cells[7].Value.ToString())     //写表密码
                {
                    Changed = true;
                    try
                    {
                        if (_MeterProtocol.WriteClass != string.Empty)         //如果等级不空,则表示是645的协议,如果等级空则是其他协议,不带写等级的
                        {
                            _MeterProtocol.WriteClass = Dgv_Data.Rows[i].Cells[7].Value.ToString().Substring(Dgv_Data.Rows[i].Cells[7].Value.ToString().Length - 2);

                            _MeterProtocol.WritePassword = Dgv_Data.Rows[i].Cells[7].Value.ToString().Substring(0, Dgv_Data.Rows[i].Cells[7].Value.ToString().Length - 2);
                        }
                        else
                        {
                            _MeterProtocol.WritePassword = Dgv_Data.Rows[i].Cells[7].Value.ToString();
                        }
                    }
                    catch
                    { }
                }

                if (_MeterProtocol.ClearDemandPassword + _MeterProtocol.ClearDemandClass != Dgv_Data.Rows[i].Cells[7].Value.ToString())     //清需量密码
                {
                    Changed = true;
                    try
                    {
                        if (_MeterProtocol.ClearDemandClass != string.Empty)         //如果等级不空,则表示是645的协议,如果等级空则是其他协议,不带写等级的
                        {
                            _MeterProtocol.ClearDemandClass = Dgv_Data.Rows[i].Cells[8].Value.ToString().Substring(Dgv_Data.Rows[i].Cells[8].Value.ToString().Length - 2);

                            _MeterProtocol.ClearDemandPassword = Dgv_Data.Rows[i].Cells[8].Value.ToString().Substring(0, Dgv_Data.Rows[i].Cells[8].Value.ToString().Length - 2);
                        }
                        else
                        {
                            _MeterProtocol.ClearDemandPassword = Dgv_Data.Rows[i].Cells[8].Value.ToString();
                        }
                    }
                    catch
                    { }
                }
                if (_MeterProtocol.ClearDLPassword + _MeterProtocol.ClearDLClass != Dgv_Data.Rows[i].Cells[7].Value.ToString())         //清电量密码
                {
                    Changed = true;
                    try
                    {
                        if (_MeterProtocol.ClearDLClass != string.Empty)         //如果等级不空,则表示是645的协议,如果等级空则是其他协议,不带写等级的
                        {
                            _MeterProtocol.ClearDLClass = Dgv_Data.Rows[i].Cells[9].Value.ToString().Substring(Dgv_Data.Rows[i].Cells[9].Value.ToString().Length - 2);

                            _MeterProtocol.ClearDLPassword = Dgv_Data.Rows[i].Cells[9].Value.ToString().Substring(0, Dgv_Data.Rows[i].Cells[9].Value.ToString().Length - 2);
                        }
                        else
                        {
                            _MeterProtocol.ClearDLPassword = Dgv_Data.Rows[i].Cells[9].Value.ToString();
                        }
                    }
                    catch
                    { }
                }

                #endregion

                if (Dgv_Data.Rows[i].Cells[6].Value != null && Dgv_Data.Rows[i].Cells[6].Value.ToString() != string.Empty)
                {
                    if (_DnbInfo.MeterGroup[i].Mb_chrAddr != Dgv_Data.Rows[i].Cells[6].Value.ToString())
                    {
                        Changed = true;

                        _DnbInfo.MeterGroup[i].Mb_chrAddr = Dgv_Data.Rows[i].Cells[6].Value.ToString();
                    }
                }
            }

            return(Changed);
        }
Exemplo n.º 9
0
        /// <summary>
        /// 开始测试
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Cmd_Start_Click(object sender, EventArgs e)
        {
            if (Txt_Adr.Text == "")
            {
                CLDC_DataCore.Const.GlobalUnit.g_MsgControl.OutMessage("请输入一个正确的测试表地址", false, CLDC_Comm.Enum.Cus_MessageType.提示消息);

                return;
            }
            if (txtBW.Text == "" || !CLDC_DataCore.Function.Number.IsIntNumber(txtBW.Text))
            {
                CLDC_DataCore.Const.GlobalUnit.g_MsgControl.OutMessage("请输入一个正确的测试表位表", false, CLDC_Comm.Enum.Cus_MessageType.提示消息);
                return;
            }
            if (cmbU.Text == "")
            {
                CLDC_DataCore.Const.GlobalUnit.g_MsgControl.OutMessage("请选择一个测试电压", false, CLDC_Comm.Enum.Cus_MessageType.提示消息);
                return;
            }
            float u     = float.Parse(cmbU.Text);
            int   Index = int.Parse(txtBW.Text) - 1;

            //隐藏测试面板
            CLDC_DataCore.Function.SetControl.SetVisible(Panel_Test, false);

            // Panel_Test.Visible = false;
            ProtocolView.BaseControl _Item = null;
            _Item = Panel_Data.Controls[0] as ProtocolView.BaseControl;
            if (!(_Item is ProtocolView.BaseControl))
            {
                return;
            }

            // if (_Item.EquipmentUnit == null)
            //{
            //_Item.EquipmentUnit = m_EquipUnit;
            //_Item.EquipmentUnit = m_EquipUnit;
            //}
            CLDC_DataCore.Model.DgnProtocol.DgnProtocolInfo TmpProtocol = new CLDC_DataCore.Model.DgnProtocol.DgnProtocolInfo();
            //init verifyadapter


            TmpProtocol.DllFile   = "ClAmMeterProtocol";      //这个是固定的!协议库名称
            TmpProtocol.ClassName = Cmb_ProtocolClass.Text;   //协议类名称

            _Item.TestProtocolPra = TmpProtocol;
            _Item.StartTest(Txt_Adr.Text, u, Index);

            //if (_Item is ProtocolView.DLT645)
            //{
            //    //指定多功能组件
            //    //((ProtocolView.DLT645)_Item).m_DgnControl = m_DgnControl;
            //    ((ProtocolView.DLT645)_Item).StartTest(Txt_Adr.Text);
            //}
            //if (_Item is ProtocolView.DLT6452007)
            //{
            //    ((ProtocolView.DLT6452007)_Item).StartTest(Txt_Adr.Text);
            //} if (_Item is ProtocolView.EDMIMK)
            //{
            //    ((ProtocolView.EDMIMK)_Item).StartTest(Txt_Adr.Text);
            //} if (_Item is ProtocolView.IEC1107St)
            //{
            //    ((ProtocolView.IEC1107St)_Item).StartTest(Txt_Adr.Text);
            //} if (_Item is ProtocolView.A1600)
            //{
            //    ((ProtocolView.A1600)_Item).StartTest(Txt_Adr.Text);
            //}
        }
Exemplo n.º 10
0
        /// <summary>
        /// 存储协议方法
        /// </summary>
        /// <param name="SaveAs">是否是另存为</param>
        private void SaveProtocolInfo(bool SaveAs)
        {
            if (Panel_Data.Controls.Count == 0)
            {
                return;
            }


            Txt_ProtocolName.Text = "";
            Cmd_Save.Tag          = null;
            Panel_SaveName.Tag    = null;
            Txt_ProtocolName.Tag  = null;

            object _Item = null;

            bool _FindFactory = false;                  //是否发现存在相同制造厂家和表型号的协议

            _Item = Panel_Data.Controls[0];
            if (_Item is ProtocolView.DLT645)
            {
                if (!((ProtocolView.DLT645)_Item).CheckNull())
                {
                    return;
                }
            }
            if (_Item is ProtocolView.DLT6452007)
            {
                if (!((ProtocolView.DLT6452007)_Item).CheckNull())
                {
                    return;
                }
            }
            if (_Item is ProtocolView.EDMIMK)
            {
                if (!((ProtocolView.EDMIMK)_Item).CheckNull())
                {
                    return;
                }
            }
            if (_Item is ProtocolView.IEC1107St)
            {
                if (!((ProtocolView.IEC1107St)_Item).CheckNull())
                {
                    return;
                }
            }
            if (_Item is ProtocolView.A1600)
            {
                if (!((ProtocolView.A1600)_Item).CheckNull())
                {
                    return;
                }
            }

            CLDC_DataCore.Model.DgnProtocol.DgnProtocolInfo _Protocol = new CLDC_DataCore.Model.DgnProtocol.DgnProtocolInfo();

            _Protocol.DnbFactroy = Cmb_ZZCJ.Text;           //制造厂家
            _Protocol.DnbSize    = Cmb_Bxh.Text;            //表型号
            _Protocol.DllFile    = "ClAmMeterProtocol";     //这个是固定的!协议库名称
            _Protocol.ClassName  = Cmb_ProtocolClass.Text;  //协议类名称

            try
            {
                _Protocol.ClockPL = float.Parse(Txt_Clock.Text.Trim() == "" ? "1" : Txt_Clock.Text.Trim());       //时钟频率
            }
            catch
            {
                MessageBox.Show("时钟频率必须为一个数字,请重新输入...", "保存出错", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }

            if (_Item is ProtocolView.DLT645)
            {
                if (!((ProtocolView.DLT645)_Item).getInfo(ref _Protocol))
                {
                    return;
                }
            }
            if (_Item is ProtocolView.DLT6452007)
            {
                if (!((ProtocolView.DLT6452007)_Item).getInfo(ref _Protocol))
                {
                    return;
                }
            }
            if (_Item is ProtocolView.EDMIMK)
            {
                if (!((ProtocolView.EDMIMK)_Item).getInfo(ref _Protocol))
                {
                    return;
                }
            }
            if (_Item is ProtocolView.IEC1107St)
            {
                if (!((ProtocolView.IEC1107St)_Item).getInfo(ref _Protocol))
                {
                    return;
                }
            }
            if (_Item is ProtocolView.A1600)
            {
                if (!((ProtocolView.A1600)_Item).getInfo(ref _Protocol))
                {
                    return;
                }
            }

            if (CLDC_DataCore.Model.DgnProtocol.DgnProtocolInfo.ContainsNodeByFactroy(Cmb_ZZCJ.Text, Cmb_Bxh.Text))
            {
                if (SaveAs)          //如果是另存为
                {
                    if (MessageBox.Show(string.Format("已经存在制造厂家为:{0},表型号为:{1}的通信协议,是否覆盖原有协议?\n点“否”退出保存", Cmb_ZZCJ.Text, Cmb_Bxh.Text), "保存询问", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
                    {
                        return;
                    }
                    else
                    {
                        _FindFactory = true;
                    }
                }
                else
                {
                    CLDC_DataCore.Model.DgnProtocol.DgnProtocolInfo.RemoveProtocol(Cmb_ZZCJ.Text, Cmb_Bxh.Text);
                }
            }

            Panel_SaveName.Tag = _Protocol;         //把协议对象放入Tag

            Txt_ProtocolName.Tag = _FindFactory;    //把是否存在相同的表协议的厂家和型号的判断放入文本框的Tag

            if (SaveAs || this.ProtocolName == "")  //如果是另存为,或者ProtocolName为空(这个表示新增)
            {
                tableLayoutPanel1.Enabled = false;  //锁定表单中所有可操作部分

                Panel_SaveName.Visible = true;      //显示存储协议名称输入界面

                Txt_ProtocolName.Text = "";
            }
            else if (!SaveAs && this.ProtocolName != "")           //如果是保存
            {
                Txt_ProtocolName.Text = this.ProtocolName;
                Cmd_Save.Tag          = false;                      //使用存盘按钮的Tag标志该存盘不是由另存为触发
                this.Cmd_Save_Click(Cmd_Save, new EventArgs());
            }
        }
Exemplo n.º 11
0
 public virtual bool getInfo(ref CLDC_DataCore.Model.DgnProtocol.DgnProtocolInfo ProtocolInfo)
 {
     return(true);
 }
Exemplo n.º 12
0
        private void setMeterData(int Index)
        {
            int BwCount = CLDC_VerifyAdapter.Adapter.Instance.BwCount;

            CLDC_VerifyAdapter.MeterProtocolAdapter.Instance.SetBwCount(BwCount);
            //ClInterface.CAmMeterInfo[] meterDgnInfo = new CAmMeterInfo[BwCount];
            if (!(TestProtocol is CLDC_DataCore.Model.DgnProtocol.DgnProtocolInfo))
            {
                MessageBox.Show("协议加载失败!");
                return;
            }
            TestProtocol.Load();
            string[] arrAddress = new string[BwCount];
            CLDC_DataCore.Model.DgnProtocol.DgnProtocolInfo[] protocols = new CLDC_DataCore.Model.DgnProtocol.DgnProtocolInfo[BwCount];
            for (int k = 0; k < BwCount; k++)
            {
                // meterDgnInfo[k] = new CAmMeterInfo();
                protocols[k]  = TestProtocol;
                arrAddress[k] = MeterAdr;
                //if (k == Index)
                //{

                //VerifyAdapter.MeterProtocolAdapter.Instance.Selected[k] = true;
                //meterDgnInfo[k].DllFile = TestProtocol.DllFile;     //动态
                //meterDgnInfo[k].ClassName = TestProtocol.ClassName;
                //meterDgnInfo[k].Address = MeterAdr;
                //meterDgnInfo[k].Setting = TestProtocol.Setting;
                //meterDgnInfo[k].UserID = TestProtocol.UserID;
                //meterDgnInfo[k].VerifyPasswordType = TestProtocol.VerifyPasswordType;
                //meterDgnInfo[k].WritePassword = TestProtocol.WritePassword;
                //meterDgnInfo[k].WritePswClass = TestProtocol.WriteClass;
                //meterDgnInfo[k].ClearDemandPassword = TestProtocol.ClearDemandPassword;
                //meterDgnInfo[k].ClearDemandPswClass = TestProtocol.ClearDemandClass;
                //meterDgnInfo[k].ClearEnergyPassword = TestProtocol.ClearDLPassword;
                //meterDgnInfo[k].ClearEnergyPswClass = TestProtocol.ClearDLClass;
                //meterDgnInfo[k].DataFieldPassword = TestProtocol.DataFieldPassword;
                //meterDgnInfo[k].BlockAddAA = TestProtocol.BlockAddAA;
                //meterDgnInfo[k].TariffOrderType = TestProtocol.TariffOrderType;
                //meterDgnInfo[k].DateTimeFormat = TestProtocol.DateTimeFormat;
                //meterDgnInfo[k].SundayIndex = TestProtocol.SundayIndex;
                //meterDgnInfo[k].ConfigFile = TestProtocol.ConfigFile;
                //meterDgnInfo[k].ComTestType = this.getType("001", 1);
                //// meterDgnInfo[k].BroadcastTimeType = 1;
                //meterDgnInfo[k].ReadEnergyType = this.getType("006", 1);
                //meterDgnInfo[k].ReadDemandType = this.getType("005", 1);
                //meterDgnInfo[k].ReadDateTimeType = this.getType("003", 1);
                ////meterDgnInfo[k].ReadAddressType = 1;
                //meterDgnInfo[k].ReadPeriodTimeType = this.getType("007", 1);
                //// meterDgnInfo[k].ReadDataType = 1;
                //// meterDgnInfo[k].WriteAddressType = 1;
                //meterDgnInfo[k].WriteDateTimeType = this.getType("002", 1);
                //// meterDgnInfo[k].WritePeriodTimeType = 1;
                //// meterDgnInfo[k].WriteDataType = 1;
                //meterDgnInfo[k].ClearDemandType = this.getType("004", 1);
                //meterDgnInfo[k].ClearEnergyType = this.getType("008", 1);
                ////meterDgnInfo[k].ClearEventLogType = 1;
                //// meterDgnInfo[k].SetPulseComType = 1;
                //// meterDgnInfo[k].FreezeCmdType = 1;
                ////meterDgnInfo[k].ChangeSettingType = 1;
                ////meterDgnInfo[k].ChangePasswordType = 1;
                //meterDgnInfo[k].FECount = TestProtocol.FECount;
                //后面跟其它信息
                //}
            }
            CLDC_VerifyAdapter.MeterProtocolAdapter.Instance.Initialize(protocols, arrAddress);
            //VerifyAdapter.MeterProtocolAdapter.Instance.AmMeterInfo = meterDgnInfo;
        }