Exemple #1
0
        private void FillDGV(DataGridView dGV)
        {
            CStation          Sta  = frmMain.staComm.GetStaByStaName(sListStaName[0]);
            CProtcolModbusTCP STCP = (CProtcolModbusTCP)Sta;

            dGV.RowCount = sListVarName.Length + 3;
            for (int i = 0; i < sListVarName.Length; i++)
            {
                dGV.Rows[i].Cells[0].Value = sListVarName[i];
                dGV.Rows[i].Cells[1].Value = frmMain.staComm.GetVarByStaNameVarName(sListStaName[0], sListVarName[i]).ByteAddr;
                dGV.Rows[i].Cells[2].Value = frmMain.staComm.GetVarByStaNameVarName(sListStaName[0], sListVarName[i]).GetStringValue(sListDF[i]);
                dGV.Rows[i].Cells[3].Value = frmMain.staComm.GetVarByStaNameVarName(sListStaName[1], sListVarName[i]).GetStringValue(sListDF[i]);
                dGV.Rows[i].Cells[4].Value = frmMain.staComm.GetVarByStaNameVarName(sListStaName[2], sListVarName[i]).GetStringValue(sListDF[i]);
            }
            dGV.Rows[sListVarName.Length + 1].Cells[1].ReadOnly = false;
            dGV.Rows[sListVarName.Length + 2].Cells[1].ReadOnly = false;

            dGV.Rows[sListVarName.Length + 1].Cells[0].Value = "手写";
            dGV.Rows[sListVarName.Length + 2].Cells[0].Value = "手写";

            dGV.Rows[0].DefaultCellStyle.BackColor = Color.LightGray;
            dGV.Rows[1].DefaultCellStyle.BackColor = Color.LightGray;

            dGV.Rows[sListVarName.Length + 1].DefaultCellStyle.BackColor = Color.Lime;
            dGV.Rows[sListVarName.Length + 2].DefaultCellStyle.BackColor = Color.Lime;
        }
Exemple #2
0
        private void button1_Click(object sender, EventArgs e)
        {
            CVar              nVar1 = frmMain.staComm.GetVarByStaNameVarName(sListStaName[0], "I_W");
            CVar              nVar2 = frmMain.staComm.GetVarByStaNameVarName(sListStaName[1], "I_W");
            CVar              nVar3 = frmMain.staComm.GetVarByStaNameVarName(sListStaName[2], "I_W");
            CStation          Sta1  = frmMain.staComm.GetStaByStaName(sListStaName[0]);
            CProtcolModbusTCP STCP1 = (CProtcolModbusTCP)Sta1;
            CStation          Sta2  = frmMain.staComm.GetStaByStaName(sListStaName[1]);
            CProtcolModbusTCP STCP2 = (CProtcolModbusTCP)Sta2;
            CStation          Sta3  = frmMain.staComm.GetStaByStaName(sListStaName[2]);
            CProtcolModbusTCP STCP3 = (CProtcolModbusTCP)Sta3;

            double iValue1 = nVar1.GetDoubleValue() + Convert.ToDouble(textBox1.Text);
            int    fSend1  = (int)Math.Round(iValue1 / nVar1.RatioValue);

            STCP1.SendAODO(nVar1.ByteAddr, (int)fSend1, 6);

            double iValue2 = nVar2.GetDoubleValue() + Convert.ToDouble(textBox2.Text);
            int    fSend2  = (int)Math.Round(iValue2 / nVar2.RatioValue);

            STCP2.SendAODO(nVar3.ByteAddr, (int)fSend2, 6);

            double iValue3 = nVar3.GetDoubleValue() + Convert.ToDouble(textBox3.Text);
            int    fSend3  = (int)Math.Round(iValue3 / nVar3.RatioValue);

            STCP3.SendAODO(nVar3.ByteAddr, (int)fSend3, 6);
        }
Exemple #3
0
        private void dGV1_CellEndEdit(object sender, DataGridViewCellEventArgs e)
        {
            if (e.ColumnIndex >= 2 && e.RowIndex > 1)
            {
                DataGridView dGV  = (DataGridView)sender;
                int          iSta = e.ColumnIndex - 2;

                CStation          Sta  = frmMain.staComm.GetStaByStaName(sListStaName[iSta]);
                CProtcolModbusTCP STCP = (CProtcolModbusTCP)Sta;
                if (STCP == null)
                {
                    return;
                }
                try
                {
                    int iVar = e.RowIndex;
                    if (iVar < sListVarName.Length)
                    {
                        CVar  nVar   = frmMain.staComm.GetVarByStaNameVarName(sListStaName[iSta], sListVarName[iVar]);
                        float iValue = Convert.ToSingle(dGV1.Rows[iVar].Cells[2 + iSta].Value);
                        int   fSend  = (int)Math.Round(iValue / nVar.RatioValue);
                        STCP.SendAODO(nVar.ByteAddr, fSend, 6);
                    }
                    else if (iVar == sListVarName.Length + 1 || iVar == sListVarName.Length + 2)
                    {
                        int iValue = Convert.ToInt32(dGV1.Rows[iVar].Cells[2 + iSta].Value);
                        int iAdd   = Convert.ToInt32(dGV.Rows[iVar].Cells[1].Value);
                        if (iAdd > 0)
                        {
                            STCP.SendAODO(iAdd, iValue, 6);
                        }
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
        }
Exemple #4
0
        private void dGV1_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            string   sSta = (string)dGV1.Rows[e.RowIndex].Cells[0].Value;
            CStation nSta = frmMain.staComm.GetStaByStaName(sSta);

            if (nSta == null)
            {
                return;
            }
            if (nSta.StaDevice.PortProtocol == "Modbus_TCP")
            {
                CProtcolModbusTCP nnn = (CProtcolModbusTCP)nSta;
                nnn.Show(true);
                nnn.bDebug = false;
            }
            if (nSta.StaDevice.PortProtocol == "FINS_TCP")
            {
                CProtcolFINS nnn = (CProtcolFINS)nSta;
                nnn.Show(true);
                nnn.bDebug = false;
            }
        }