Exemplo n.º 1
0
 private void getDataGridViewList()
 {
     try
     {
         dgvUV.Rows.Clear();
         if (MyActiveObj == null)
         {
             return;
         }
         int Length = MyActiveObj.myBUS2RS.Count;
         if (Type == 1)
         {
             Length = MyActiveObj.myBUS2RS.Count;
         }
         else if (Type == 2)
         {
             Length = MyActiveObj.myBUS2485.Count;
         }
         for (int i = 0; i < Length; i++)
         {
             MHRCU.BUS2RS temp = null;
             if (Type == 1)
             {
                 temp = MyActiveObj.myBUS2RS[i];
             }
             else if (Type == 2)
             {
                 temp = MyActiveObj.myBUS2485[i];
             }
             string strType = CsConst.mstrINIDefault.IniReadValue("TargetType", "00000", "");
             if (temp.bytType == 0x58)
             {
                 strType = CsConst.myPublicControlType[4].ControlTypeName;
             }
             string strParam1 = temp.bytParam1.ToString() + "(" +
                                CsConst.WholeTextsList[2513].sDisplayName + ")";
             string strParam2 = CsConst.Status[0] + "(" +
                                CsConst.WholeTextsList[2529].sDisplayName + ")";
             if (temp.bytParam2 == 255)
             {
                 strParam2 = CsConst.Status[1] + "(" +
                             CsConst.WholeTextsList[2529].sDisplayName + ")";
             }
             object[] obj = new object[] { temp.ID.ToString(), temp.Remark.ToString(), strType, strParam1, strParam2 };
             dgvUV.Rows.Add(obj);
         }
     }
     catch
     {
     }
 }
Exemplo n.º 2
0
        private void btnSure_Click(object sender, EventArgs e)
        {
            if (oRS232 != null)
            {
                if (Type == 1)
                {
                    oRS232.myBUS2RS = new List <RS232.BUS2RS>();
                }
                else if (Type == 2)
                {
                    oRS232.myBUS2485 = new List <RS232.BUS2RS>();
                }
            }
            else if (oMHRCU != null)
            {
                if (Type == 1)
                {
                    oMHRCU.myBUS2RS = new List <MHRCU.BUS2RS>();
                }
                else if (Type == 2)
                {
                    oMHRCU.myBUS2485 = new List <MHRCU.BUS2RS>();
                }
            }
            allVisible(false);
            dgvUV.Rows.Clear();
            Cursor.Current  = Cursors.WaitCursor;
            btnSure.Enabled = false;
            byte[] arayTmp = new byte[1];
            byte   bytFrm  = Convert.ToByte(Convert.ToInt32(txtFrm.Text));
            byte   bytTo   = Convert.ToByte(txtTo.Text);
            int    CMD1    = 0xE420;
            int    CMD2    = 0xE428;

            if (Type == 1)
            {
                CMD1 = 0xE420;
                CMD2 = 0xE428;
            }
            else if (Type == 2)
            {
                CMD1 = 0xDA61;
                CMD2 = 0xDA69;
            }
            for (byte byt = bytFrm; byt <= bytTo; byt++)
            {
                if (oRS232 != null)
                {
                    RS232.BUS2RS temp = new RS232.BUS2RS();
                    temp.ID    = Convert.ToByte(byt);
                    arayTmp    = new byte[1];
                    arayTmp[0] = Convert.ToByte(byt);
                    if (CsConst.mySends.AddBufToSndList(arayTmp, CMD1, SubNetID, DevID, false, true, true, CsConst.minAllWirelessDeviceType.Contains(MyintDeviceType)) == true)
                    {
                        temp.bytType   = CsConst.myRevBuf[27];
                        temp.bytParam1 = CsConst.myRevBuf[28];
                        temp.bytParam2 = CsConst.myRevBuf[29];
                        temp.bytParam3 = CsConst.myRevBuf[30];
                        temp.bytParam4 = CsConst.myRevBuf[31];
                    }
                    else
                    {
                        Cursor.Current = Cursors.Default;
                        return;
                    }

                    HDLUDP.TimeBetwnNext(1);
                    if (CsConst.mySends.AddBufToSndList(arayTmp, CMD2, SubNetID, DevID, false, true, true, CsConst.minAllWirelessDeviceType.Contains(MyintDeviceType)) == true)
                    {
                        byte[] arayRemark = new byte[20];
                        for (int intI = 0; intI < 20; intI++)
                        {
                            arayRemark[intI] = CsConst.myRevBuf[27 + intI];
                        }
                        temp.Remark = HDLPF.Byte2String(arayRemark);
                    }
                    else
                    {
                        Cursor.Current = Cursors.Default;
                        return;
                    }

                    if (Type == 1)
                    {
                        oRS232.myBUS2RS.Add(temp);
                    }
                    else if (Type == 2)
                    {
                        oRS232.myBUS2485.Add(temp);
                    }
                }
                else if (oMHRCU != null)
                {
                    MHRCU.BUS2RS temp = new MHRCU.BUS2RS();
                    temp.ID    = Convert.ToByte(byt);
                    arayTmp    = new byte[1];
                    arayTmp[0] = Convert.ToByte(byt);
                    if (CsConst.mySends.AddBufToSndList(arayTmp, CMD1, SubNetID, DevID, false, true, true, CsConst.minAllWirelessDeviceType.Contains(MyintDeviceType)) == true)
                    {
                        temp.bytType   = CsConst.myRevBuf[27];
                        temp.bytParam1 = CsConst.myRevBuf[28];
                        temp.bytParam2 = CsConst.myRevBuf[29];

                        System.Threading.Thread.Sleep(1);
                    }
                    else
                    {
                        Cursor.Current = Cursors.Default;
                        return;
                    }

                    if (CsConst.mySends.AddBufToSndList(arayTmp, CMD2, SubNetID, DevID, false, true, true, CsConst.minAllWirelessDeviceType.Contains(MyintDeviceType)) == true)
                    {
                        byte[] arayRemark = new byte[20];
                        for (int intI = 0; intI < 20; intI++)
                        {
                            arayRemark[intI] = CsConst.myRevBuf[27 + intI];
                        }
                        temp.Remark = HDLPF.Byte2String(arayRemark);

                        System.Threading.Thread.Sleep(1);
                    }
                    else
                    {
                        Cursor.Current = Cursors.Default;
                        return;
                    }
                    if (Type == 1)
                    {
                        oMHRCU.myBUS2RS.Add(temp);
                    }
                    else if (Type == 2)
                    {
                        oMHRCU.myBUS2485.Add(temp);
                    }
                }
                HDLUDP.TimeBetwnNext(1);
            }
            btnSure.Enabled = true;
            Cursor.Current  = Cursors.Default;
            getDataGridViewList();
        }