Beispiel #1
0
        private void GridCellClick(object sender, DataGridViewCellEventArgs e)
        {
            int columnIndex = e.ColumnIndex;
            int rowIndex    = e.RowIndex;

            if (columnIndex == 5 && e.RowIndex != -1 && !this.grid1.Rows[e.RowIndex].IsNewRow)
            {
                this.grid1.EndEdit();
                string text    = Convert.ToString(this.grid1.Rows[rowIndex].Cells[2].Value);
                string text2   = Convert.ToString(this.grid1.Rows[rowIndex].Cells[3].Value);
                string iValues = Convert.ToString(this.grid1.Rows[rowIndex].Cells[columnIndex].Value);
                this.IsCustomize    = (Convert.ToString(this.grid1.Rows[rowIndex].Cells[0].Value) == "自定义规约");
                this.CustomizeItems = Program.gFaDataBase.GetCustomizeItems(text, text2);
                FormFactory frmOut = new FormFactory();
                frmOut.IsCustomize    = this.IsCustomize;
                frmOut.CustomizeItems = this.CustomizeItems;
                this.grid1.Rows[rowIndex].Cells[columnIndex].Value = frmOut.CreateForm(text, text2, iValues);
                this.grid1.EndEdit();
            }
            if (columnIndex == 4 && e.RowIndex != -1 && !this.grid1.Rows[e.RowIndex].IsNewRow)
            {
                string text  = Convert.ToString(this.grid1.Rows[rowIndex].Cells[2].Value);
                string text2 = Convert.ToString(this.grid1.Rows[rowIndex].Cells[3].Value);
                this.grid1.Rows[rowIndex].Cells[columnIndex].Value = InputPN.GetPN(text, text2);
            }
        }
Beispiel #2
0
 private void Run()
 {
     Thread.Sleep(0);
     checked
     {
         if (base.InvokeRequired)
         {
             base.Invoke(new TimingTask.RunDelegate(this.Run), new object[0]);
         }
         else
         {
             for (int i = 0; i < this.grid1.Rows.Count; i++)
             {
                 if (this.grid1.Rows[i] is CollapseDataGridViewRow)
                 {
                     string aFN    = Convert.ToString(this.grid1.Rows[i].Cells[2].Value);
                     string fN     = Convert.ToString(this.grid1.Rows[i].Cells[3].Value);
                     string value  = Convert.ToString(this.grid1.Rows[i].Cells[4].Value);
                     string value2 = Convert.ToString(this.grid1.Rows[i].Cells[5].Value);
                     if (string.IsNullOrEmpty(value))
                     {
                         this.grid1.Rows[i].Cells[4].Value = InputPN.GetPN(aFN, fN);
                     }
                     if (string.IsNullOrEmpty(value2))
                     {
                         this.grid1.Rows[i].Cells[5].Value = InputPN.GetData(aFN, fN);
                     }
                 }
             }
             for (int i = 0; i < Program.gList.Count; i++)
             {
                 Application.DoEvents();
                 if (Program.gList[i].Checked)
                 {
                     RW698Data rW698Data = new RW698Data();
                     rW698Data.ListIndex = i;
                     rW698Data.grid1     = this.grid1;
                     rW698Data.needrun   = true;
                     rW698Data.isruning  = true;
                     new Thread(new ThreadStart(rW698Data.Run))
                     {
                         IsBackground = true
                     }.Start();
                     this.gThread.Add(rW698Data);
                     Application.DoEvents();
                 }
             }
         }
     }
 }
Beispiel #3
0
        public static void ReadAndWrite(string iAFN, string iFN, string iValues)
        {
            string pN = InputPN.GetPN(iAFN, iFN);

            Program.gList.Clear();
            DataGridView gridV = MainForm.gMainForm.gAddressList.GridV;

            checked
            {
                for (int i = 0; i < gridV.Rows.Count; i++)
                {
                    Program.AddList item = default(Program.AddList);
                    if (!gridV.Rows[i].IsNewRow)
                    {
                        item.Checked = Convert.ToBoolean(gridV.Rows[i].Cells[0].Value);
                        item.A1      = Convert.ToString(gridV.Rows[i].Cells[2].Value);
                        item.A2      = Convert.ToString(gridV.Rows[i].Cells[3].Value);
                        item.Mode    = Program.GetLeiXing(Convert.ToString(gridV.Rows[i].Cells[4].Value));
                        Program.gList.Add(item);
                    }
                }
                if (Program.gList.Count == 0)
                {
                    MessageBox.Show("请先初始化终端列表 !", "失败", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                }
                else
                {
                    OtherOpera.dlt.AFN         = iAFN;
                    OtherOpera.dlt.FN          = iFN;
                    OtherOpera.dlt.PN          = pN;
                    OtherOpera.dlt.SendMSG     = iValues;
                    OtherOpera.dlt.ListenPort  = Program.gPort;
                    OtherOpera.dlt.CID         = Program.CID;
                    OtherOpera.dlt.Tp          = Program.Tp;
                    OtherOpera.dlt.PW          = Program.PW;
                    OtherOpera.dlt.Flag        = Program.Flag;
                    OtherOpera.dlt.ReadTimeout = Program.ReadTimeout;
                    new Thread(new ThreadStart(OtherOpera.Run))
                    {
                        IsBackground = true
                    }.Start();
                }
            }
        }
Beispiel #4
0
        private void ToolStripButton1Click(object sender, EventArgs e)
        {
            checked
            {
                if (string.IsNullOrEmpty(this.toolStripTextBox2.Text))
                {
                    MessageBox.Show("请选择抄读规约");
                }
                else
                {
                    this.toolStripButton1.Enabled = false;
                    string text = string.Empty;
                    text += this.OperaSend(this.toolStripComboBox1.Text, 1, "BIN");
                    string str = string.Empty;
                    try
                    {
                        str = this.toolStripButton2.Text.Split(new char[]
                        {
                            '-'
                        })[1];
                    }
                    catch
                    {
                        goto IL_7CE;
                    }
                    text += str;
                    int num = 0;

                    text += (num | 30).ToString("X2");
                    text += this.OperaSend("30", 1, "BIN");
                    string text2 = this.Get645Frame();
                    text += DataConvert.ReverseStr((text2.Trim().Length / 2).ToString("X4"));
                    text += text2.Trim();
                    if (text2.Trim().Length != 0)
                    {
                        this.dlt.AFN         = "10";
                        this.dlt.FN          = "0001";
                        this.dlt.PN          = InputPN.GetPN("10", "0001");
                        this.dlt.SendMSG     = text;
                        this.dlt.ListenPort  = Program.gPort;
                        this.dlt.CID         = Program.CID;
                        this.dlt.Tp          = Program.Tp;
                        this.dlt.PW          = Program.PW;
                        this.dlt.Flag        = Program.Flag;
                        this.dlt.ReadTimeout = Program.ReadTimeout;
                        Program.gList.Clear();
                        DataGridView gridV = MainForm.gMainForm.gAddressList.GridV;
                        for (int i = 0; i < gridV.Rows.Count; i++)
                        {
                            Program.AddList item = default(Program.AddList);
                            if (!gridV.Rows[i].IsNewRow)
                            {
                                item.Checked = Convert.ToBoolean(gridV.Rows[i].Cells[0].Value);
                                item.A1      = Convert.ToString(gridV.Rows[i].Cells[2].Value);
                                item.A2      = Convert.ToString(gridV.Rows[i].Cells[3].Value);
                                item.Mode    = Program.GetLeiXing(Convert.ToString(gridV.Rows[i].Cells[4].Value));
                                Program.gList.Add(item);
                            }
                        }
                        if (Program.gList.Count == 0)
                        {
                            MessageBox.Show("请先初始化终端列表 !", "失败", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                        }
                        else
                        {
                            int    port = 0;
                            string temp = "";
                            Application.DoEvents();
                            for (int i = 0; i < Program.gList.Count; i++)
                            {
                                Application.DoEvents();
                                if (Program.gList[i].Checked)
                                {
                                    if (Program.gList[i].Mode == ComunicationType.Serial)
                                    {
                                        this.dlt.FrameDelay = 5;
                                        this.dlt.Delay      = Program.gDelay;
                                        port = Program.gComPort;
                                        temp = Program.gCommSetting;
                                    }
                                    else
                                    {
                                        if (Program.gList[i].Mode == ComunicationType.TCPMyisServer)
                                        {
                                            this.dlt.FrameDelay = Program.gDelay;
                                            this.dlt.Delay      = Program.gDelay;
                                            this.dlt.m_Port     = Program.GetSocket(Program.gList[i].Mode, Program.gList[i].A1, Program.gList[i].A2);
                                        }
                                        else
                                        {
                                            if (Program.gList[i].Mode == ComunicationType.TCPMyisClient)
                                            {
                                                this.dlt.FrameDelay = Program.gDelay;
                                                this.dlt.Delay      = Program.gDelay;
                                                port            = Program.RemotePort;
                                                temp            = Program.RemoteIP;
                                                this.dlt.m_Port = Program.GetSocket(Program.gList[i].Mode, Program.gList[i].A1, Program.gList[i].A2);
                                            }
                                            else
                                            {
                                                if (Program.gList[i].Mode == ComunicationType.UDP)
                                                {
                                                    this.dlt.FrameDelay = 5;
                                                    this.dlt.Delay      = Program.gDelay;
                                                }
                                            }
                                        }
                                    }
                                    this.dlt.OperType = Program.gList[i].Mode;
                                    bool flag = (this.dlt.OperType == ComunicationType.UDP) ? this.dlt.Open(Program.UdpOpera, Program.UDP_Port_Send, Program.UDP_Port_Recieve, Program.UDP_RemoteAddress) : this.dlt.Open(port, temp);
                                    if (flag)
                                    {
                                        this.dlt.A1  = Program.gList[i].A1;
                                        this.dlt.A2  = Program.gList[i].A2;
                                        this.dlt.MSA = Program.MSA;
                                        bool   flag2      = this.dlt.SendData();
                                        string receiveMSG = this.dlt.ReceiveMSG;
                                        string caption    = "A1=" + this.dlt.A1 + ",A2=" + this.dlt.A2;
                                        if (string.IsNullOrEmpty(receiveMSG))
                                        {
                                            MessageBox.Show("无数据返回");
                                            break;
                                        }
                                        if (receiveMSG.ToUpper().IndexOf("ERROR") >= 0 | receiveMSG.ToUpper().IndexOf("确认") >= 0 | receiveMSG.ToUpper().IndexOf("否认") >= 0)
                                        {
                                            MessageBox.Show(receiveMSG.ToString(), caption, MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                                            break;
                                        }
                                        this.gAS.DoInfo("10", "0001", receiveMSG, false, "", this.toolStripLabel3.Text);
                                        this.grid3.Rows.Clear();
                                        for (int j = 0; j < this.gAS.ItemData.Count; j++)
                                        {
                                            if (!string.IsNullOrEmpty(this.gAS.ItemData[j].Items))
                                            {
                                                this.grid3.Rows.Add();
                                                this.grid3.Rows[j].Cells[0].Value = this.gAS.ItemData[j].Items;
                                                this.grid3.Rows[j].Cells[1].Value = this.gAS.ItemData[j].Values;
                                            }
                                        }
                                    }
                                    Application.DoEvents();
                                }
                            }
                        }
                    }
IL_7CE:
                    this.dlt.Close();
                    this.toolStripButton1.Enabled = true;
                }
            }
        }
Beispiel #5
0
        private void 数据点抄ToolStripMenuItemClick(object sender, EventArgs e)
        {
            this.grid1.EndEdit();
            Program.gList.Clear();
            DataGridView gridV = MainForm.gMainForm.gAddressList.GridV;

            checked
            {
                for (int i = 0; i < gridV.Rows.Count; i++)
                {
                    Program.AddList item = default(Program.AddList);
                    if (!gridV.Rows[i].IsNewRow)
                    {
                        item.Checked = Convert.ToBoolean(gridV.Rows[i].Cells[0].Value);
                        item.A1      = Convert.ToString(gridV.Rows[i].Cells[2].Value);
                        item.A2      = Convert.ToString(gridV.Rows[i].Cells[3].Value);
                        item.Mode    = Program.GetLeiXing(Convert.ToString(gridV.Rows[i].Cells[4].Value));
                        Program.gList.Add(item);
                    }
                }
                if (Program.gList.Count == 0)
                {
                    MessageBox.Show("请先初始化终端列表 !", "失败", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                }
                else
                {
                    int    port = 0;
                    string temp = "";
                    Application.DoEvents();
                    for (int i = 0; i < Program.gList.Count; i++)
                    {
                        Application.DoEvents();
                        if (Program.gList[i].Checked)
                        {
                            if (Program.gList[i].Mode == 0)
                            {
                                this.dlt.FrameDelay = 5;
                                this.dlt.Delay      = Program.gDelay;
                                port = Program.gComPort;
                                temp = Program.gCommSetting;
                            }
                            else
                            {
                                if (Program.gList[i].Mode == ComunicationType.TCPMyisServer)
                                {
                                    this.dlt.FrameDelay = Program.gDelay;
                                    this.dlt.Delay      = Program.gDelay;
                                    this.dlt.m_Port     = Program.GetSocket(Program.gList[i].Mode, Program.gList[i].A1, Program.gList[i].A2);
                                }
                                else
                                {
                                    if (Program.gList[i].Mode == ComunicationType.TCPMyisClient)
                                    {
                                        this.dlt.FrameDelay = Program.gDelay;
                                        this.dlt.Delay      = Program.gDelay;
                                        port            = Program.RemotePort;
                                        temp            = Program.RemoteIP;
                                        this.dlt.m_Port = Program.GetSocket(Program.gList[i].Mode, Program.gList[i].A1, Program.gList[i].A2);
                                    }
                                }
                            }
                            this.dlt.OperType = Program.gList[i].Mode;
                            bool flag = this.dlt.Open(port, temp);
                            if (flag)
                            {
                                DataGridViewRow currentRow = this.grid1.CurrentRow;
                                if (currentRow is CollapseDataGridViewRow)
                                {
                                    this.dlt.AFN        = "10";
                                    this.dlt.FN         = "0009";
                                    this.dlt.PN         = InputPN.GetPN("10", "0009");
                                    this.dlt.SendMSG    = this.GetSendText(currentRow);
                                    this.dlt.ListenPort = Program.gPort;
                                    this.dlt.CID        = Program.CID;
                                    this.dlt.Tp         = Program.Tp;
                                    this.dlt.PW         = Program.PW;
                                    this.dlt.Flag       = Program.Flag;
                                    this.dlt.A1         = Program.gList[i].A1;
                                    this.dlt.A2         = Program.gList[i].A2;
                                    this.dlt.MSA        = Program.MSA;
                                    bool   flag2 = this.dlt.SendData();
                                    string text  = this.dlt.ReceiveMSG;
                                    if (flag2)
                                    {
                                        text = this.dlt.ReceiveMSG;
                                    }
                                    else
                                    {
                                        text = "Error";
                                    }
                                    if (!string.IsNullOrEmpty(text))
                                    {
                                        if (string.IsNullOrEmpty(text) | text.ToUpper().IndexOf("ERROR") >= 0 | text.ToUpper().IndexOf("确认") >= 0 | text.ToUpper().IndexOf("否认") >= 0)
                                        {
                                            this.AddData(currentRow as CollapseDataGridViewRow, text, "");
                                        }
                                        else
                                        {
                                            DLT698_Recv dLT698_Recv = new DLT698_Recv();
                                            dLT698_Recv.DoInfo("10", "0009", text, false, "", Convert.ToString(currentRow.Cells[4].Value));
                                            this.AddData(currentRow as CollapseDataGridViewRow, text, dLT698_Recv.AF10_F9_Val);
                                        }
                                    }
                                }
                                Application.DoEvents();
                            }
                        }
                    }
                }
                this.dlt.Close();
            }
        }
Beispiel #6
0
        private void ToolStripButton1Click(object sender, EventArgs e)
        {
            this.toolStripButton1.Enabled = false;
            this.toolStripButton4.Enabled = true;
            this.RunCB = true;
            this.grid1.EndEdit();
            Program.gList.Clear();
            DataGridView gridV = MainForm.gMainForm.gAddressList.GridV;

            checked
            {
                for (int i = 0; i < gridV.Rows.Count; i++)
                {
                    Program.AddList item = default(Program.AddList);
                    if (!gridV.Rows[i].IsNewRow)
                    {
                        item.Checked = Convert.ToBoolean(gridV.Rows[i].Cells[0].Value);
                        item.A1      = Convert.ToString(gridV.Rows[i].Cells[2].Value);
                        item.A2      = Convert.ToString(gridV.Rows[i].Cells[3].Value);
                        item.Mode    = Program.GetLeiXing(Convert.ToString(gridV.Rows[i].Cells[4].Value));
                        Program.gList.Add(item);
                    }
                }
                if (Program.gList.Count == 0)
                {
                    MessageBox.Show("请先初始化终端列表 !", "失败", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                }
                else
                {
                    int    port = 0;
                    string temp = "";
                    Application.DoEvents();
                    for (int i = 0; i < Program.gList.Count; i++)
                    {
                        Application.DoEvents();
                        if (Program.gList[i].Checked)
                        {
                            if (Program.gList[i].Mode == 0)
                            {
                                this.dlt.FrameDelay  = 5;
                                this.dlt.Delay       = Program.gDelay;
                                this.dlt.ReadTimeout = Program.ReadTimeout;
                                port = Program.gComPort;
                                temp = Program.gCommSetting;
                            }
                            else
                            {
                                if (Program.gList[i].Mode == ComunicationType.TCPMyisServer)
                                {
                                    this.dlt.FrameDelay = Program.gDelay;
                                    this.dlt.Delay      = Program.gDelay;
                                    this.dlt.m_Port     = Program.GetSocket(Program.gList[i].Mode, Program.gList[i].A1, Program.gList[i].A2);
                                }
                                else
                                {
                                    if (Program.gList[i].Mode == ComunicationType.TCPMyisClient)
                                    {
                                        this.dlt.FrameDelay = Program.gDelay;
                                        this.dlt.Delay      = Program.gDelay;
                                        port            = Program.RemotePort;
                                        temp            = Program.RemoteIP;
                                        this.dlt.m_Port = Program.GetSocket(Program.gList[i].Mode, Program.gList[i].A1, Program.gList[i].A2);
                                    }
                                    else
                                    {
                                        if (Program.gList[i].Mode == ComunicationType.UDP)
                                        {
                                            this.dlt.FrameDelay = 5;
                                            this.dlt.Delay      = Program.gDelay;
                                        }
                                    }
                                }
                            }
                            this.dlt.OperType = Program.gList[i].Mode;
                            bool flag = (this.dlt.OperType == ComunicationType.UDP) ? this.dlt.Open(Program.UdpOpera, Program.UDP_Port_Send, Program.UDP_Port_Recieve, Program.UDP_RemoteAddress) : this.dlt.Open(port, temp);
                            if (flag)
                            {
                                for (int j = 0; j < int.Parse(this.toolStripTextBox1.Text); j++)
                                {
                                    foreach (DataGridViewRow dataGridViewRow in (IEnumerable)this.grid1.Rows)
                                    {
                                        if (dataGridViewRow is CollapseDataGridViewRow)
                                        {
                                            if (!this.RunCB)
                                            {
                                                goto IL_7B3;
                                            }
                                            if (Convert.ToBoolean(dataGridViewRow.Cells[0].Value))
                                            {
                                                this.dlt.AFN        = "10";
                                                this.dlt.FN         = "0009";
                                                this.dlt.PN         = InputPN.GetPN("10", "0009");
                                                this.dlt.SendMSG    = this.GetSendText(dataGridViewRow);
                                                this.dlt.ListenPort = Program.gPort;
                                                this.dlt.CID        = Program.CID;
                                                this.dlt.Tp         = Program.Tp;
                                                this.dlt.PW         = Program.PW;
                                                this.dlt.Flag       = Program.Flag;
                                                this.dlt.A1         = Program.gList[i].A1;
                                                this.dlt.A2         = Program.gList[i].A2;
                                                this.dlt.MSA        = Program.MSA;
                                                bool   flag2 = this.dlt.SendData();
                                                string text  = this.dlt.ReceiveMSG;
                                                if (flag2)
                                                {
                                                    text = this.dlt.ReceiveMSG;
                                                }
                                                else
                                                {
                                                    text = "Error";
                                                }
                                                if (!string.IsNullOrEmpty(text))
                                                {
                                                    if (string.IsNullOrEmpty(text) | text.ToUpper().IndexOf("ERROR") >= 0 | text.ToUpper().IndexOf("确认") >= 0 | text.ToUpper().IndexOf("否认") >= 0)
                                                    {
                                                        this.AddData(dataGridViewRow as CollapseDataGridViewRow, text, "");
                                                        Program.gDBDataBase.InsertDataAF10F9(this.dlt.A1, this.dlt.A2, Convert.ToString(dataGridViewRow.Cells[2].Value), "数据转发", "F9 数据直抄", "00", "0009", "0000", text, text);
                                                        if (text.ToUpper().IndexOf("ERROR") >= 0)
                                                        {
                                                            Thread.Sleep(Program.LC_ERR * 1000);
                                                        }
                                                    }
                                                    else
                                                    {
                                                        DLT698_Recv dLT698_Recv = new DLT698_Recv();
                                                        dLT698_Recv.DoInfo("10", "0009", text, false, "", Convert.ToString(dataGridViewRow.Cells[4].Value));
                                                        this.AddData(dataGridViewRow as CollapseDataGridViewRow, text, dLT698_Recv.AF10_F9_Val);
                                                        Program.gDBDataBase.InsertDataAF10F9(this.dlt.A1, this.dlt.A2, Convert.ToString(dataGridViewRow.Cells[2].Value), "数据转发", "F9 数据直抄", "00", "0009", "0000", text, dLT698_Recv.AF10_F9_Val);
                                                    }
                                                }
                                            }
                                            Application.DoEvents();
                                        }
                                    }
                                    Thread.Sleep(Program.LC_JG * 1000);
                                }
                            }
                        }
                    }
                }
IL_7B3:
                this.dlt.Close();
                this.toolStripButton1.Enabled = true;
                this.toolStripButton4.Enabled = false;
                this.RunCB = false;
            }
        }