예제 #1
0
        private bool readMAC()
        {
            bool result = true;

            if (numSub.Value == 255 || numDev.Value == 255)
            {
                return(false);
            }
            Cursor.Current = Cursors.WaitCursor;
            byte bytSub = Convert.ToByte(numSub.Value);
            byte bytDev = Convert.ToByte(numDev.Value);

            String sMacInformation = HdlUdpPublicFunctions.ReadDeviceMacInformation(bytSub, bytDev, false);

            if (sMacInformation != "")
            {
                tbMAC.Text = sMacInformation;
                string str = tbMAC.Text.Replace(".", "");
                tbHint1.Text = Convert.ToInt64(str, 16).ToString();
            }
            else
            {
                result = false;
            }
            Cursor.Current = Cursors.Default;
            return(result);
        }
예제 #2
0
        void calculationWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            BackgroundWorker worker = sender as BackgroundWorker;

            CsConst.FastSearch = true;
            //下面的内容相当于线程要处理的内容。//注意:不要在此事件中和界面控件打交道
            while (worker.CancellationPending == false)
            {
                try
                {
                    HdlUdpPublicFunctions.StartSimpleSearchWay(SearchType, dgOnline);
                    worker.CancelAsync();
                }
                catch
                {
                    worker.CancelAsync();
                }
            }
        }
예제 #3
0
 private void button1_Click(object sender, EventArgs e)
 {
     ((Button)sender).Enabled = false;
     Cursor.Current           = Cursors.WaitCursor;
     tbMAC.Text = "";
     if (MyintDeviceType != -1 && MyintDeviceType != 0)
     {
         String sMacInformation = HdlUdpPublicFunctions.ReadDeviceMacInformation(bytSubID, bytDevID, false);
         if (sMacInformation == "")
         {
             sMacInformation = HdlUdpPublicFunctions.ReadDeviceMacInformationViaBroadcast(bytSubID, bytDevID, MyintDeviceType);
         }
         if (sMacInformation != "")  //读取MAC备注
         {
             gbMAC.Visible    = true;
             gbManual.Visible = false;
             tbMAC.Text       = sMacInformation;
         }
         else
         {
             gbMAC.Visible    = false;
             gbManual.Visible = true;
             tbsub.Text       = "0";
             tbDev.Text       = "0";
         }
     }
     else
     {
         gbMAC.Visible    = false;
         gbManual.Visible = true;
         tbsub.Text       = "0";
         tbDev.Text       = "0";
     }
     Cursor.Current           = Cursors.Default;
     ((Button)sender).Enabled = true;
 }
예제 #4
0
파일: frmSA.cs 프로젝트: Test0222/Test02
        void HDLDeviceCheckFunctionsStepByStep(int intRowIndex)
        {
            string str1 = "";

            try
            {
                CsConst.MyBlnFinish = false;
                DateTime d1 = DateTime.Now;
                DateTime d2 = DateTime.Now;
                CsConst.MyBlnWait15FE = true;
                #region
                Boolean bIsSuccess           = false;
                String  sTestResult          = "通过";
                String  sMacInformation      = "";
                String  sHardwareInformation = "";
                switch (intRowIndex)
                {
                case 0: bIsSuccess = HdlUdpPublicFunctions.LocateDeviceWhereItIs(bSubNetId, bDeviceId); break;             // 自动定位

                case 1: bIsSuccess = HdlUdpPublicFunctions.CheckDeviceIfCouldBeFound(0x000E, bSubNetId, bDeviceId); break; //搜索设备

                case 2: bIsSuccess = HdlUdpPublicFunctions.CheckDeviceIfCouldBeFound(0xE548, bSubNetId, bDeviceId); break; // 简易编程搜索

                case 3:
                    CsConst.FastSearch = false;       // 读取版本信息
                    String sTmpVersion = HDLSysPF.ReadDeviceVersion(bSubNetId, bDeviceId, true);
                    if (sTmpVersion != null && sTmpVersion != "")
                    {
                        bIsSuccess   = true;
                        sTestResult += " " + sTmpVersion;
                    }
                    break;

                case 4:
                    bIsSuccess = HDLSysPF.ModifyDeviceMainRemark(bSubNetId, bDeviceId, "测试备注 + " + bDeviceId.ToString(), -1);
                    if (bIsSuccess == true)
                    {
                        sTestResult += "测试备注 + " + bDeviceId.ToString();
                    }
                    break;     // 修改备注

                case 5:
                    sMacInformation = HdlUdpPublicFunctions.ReadDeviceMacInformation(bSubNetId, bDeviceId, false);     // 根据MAC修改地址
                    if (sMacInformation != "")
                    {
                        bIsSuccess = HdlUdpPublicFunctions.ModifyDeviceAddressWithTwoDifferentways(bSubNetId, bDeviceId, sMacInformation,
                                                                                                   iMyDeviceType, bSubNetId, (Byte)(bDeviceId + 1), 0);
                        if (bIsSuccess == true)
                        {
                            bDeviceId = (Byte)(bDeviceId + 1);
                        }
                    }
                    break;

                case 6:                                                                                            // 一端口自动分配地址
                    sMacInformation = HdlUdpPublicFunctions.ReadDeviceMacInformation(bSubNetId, bDeviceId, false); // 根据MAC修改地址
                    if (sMacInformation != "")
                    {
                        bIsSuccess = HdlUdpPublicFunctions.ModifyDeviceAddressAutomaticallyWithIpModule(bSubNetId, bDeviceId, sMacInformation,
                                                                                                        iMyDeviceType, bSubNetId, (Byte)(bDeviceId + 1));
                        if (bIsSuccess == true)
                        {
                            bDeviceId = (Byte)(bDeviceId + 1);
                        }
                    }
                    break;

                case 7:
                    DialogResult result = MessageBox.Show("请确认已经按住按键并且LED变红!", "问题",       // 按住按键修改地址
                                                          MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2);
                    if (result == DialogResult.No)
                    {
                        sTestResult = "测试未通过";
                    }
                    else if (result == DialogResult.Yes)
                    {
                        bIsSuccess = HdlUdpPublicFunctions.ModifyDeviceAddressWithTwoDifferentways(bSubNetId, bDeviceId, "",
                                                                                                   iMyDeviceType, bSubNetId, (Byte)(bDeviceId + 1), 1);
                        if (bIsSuccess == true)
                        {
                            bDeviceId = (Byte)(bDeviceId + 1);
                        }
                    }
                    break;

                case 9:                                                                                            // 恢复出厂设置
                    sMacInformation = HdlUdpPublicFunctions.ReadDeviceMacInformation(bSubNetId, bDeviceId, false); // 根据MAC修改地址
                    if (sMacInformation != "")
                    {
                        bIsSuccess = HdlUdpPublicFunctions.IntialDeviceFactorySettings(bSubNetId, bDeviceId, sMacInformation, iMyDeviceType);
                        if (bIsSuccess == true)
                        {
                            bDeviceId = (Byte)(bDeviceId + 1);
                        }
                    }
                    break;

                case 8:                                                                                               // 读取硬件信息
                    sHardwareInformation = HdlUdpPublicFunctions.ReadDeviceHardwareInformation(bSubNetId, bDeviceId); // 根据MAC修改地址
                    if (sHardwareInformation != "")
                    {
                        bIsSuccess = true;
                    }
                    break;
                }

                if (intRowIndex == 0 && bIsSuccess == true)
                {
                    DialogResult result = MessageBox.Show("请确认是否可以找到设备!", "问题",
                                                          MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2);
                    if (result == DialogResult.No)
                    {
                        sTestResult = "测试未通过";
                    }
                }
                else if (intRowIndex == 4 && bIsSuccess == true)
                {
                    sTestResult = "请在测试完成后断电确认是否保存";
                }
                else if (intRowIndex == 9 && bIsSuccess == true) //恢复出厂后地址修改
                {
                    CsConst.myOnlines[cboDevA.SelectedIndex].bytSub  = bSubNetId;
                    CsConst.myOnlines[cboDevA.SelectedIndex].bytDev  = bDeviceId;
                    CsConst.myOnlines[cboDevA.SelectedIndex].DevName = bSubNetId.ToString() + "-" + bDeviceId.ToString() + "\\" + "测试备注 + " + bDeviceId.ToString().ToString();
                    numDevA.Value = bDeviceId;
                    cboDevA.Items[cboDevA.SelectedIndex] = CsConst.myOnlines[cboDevA.SelectedIndex].DevName;
                }
                else if (bIsSuccess == false)
                {
                    sTestResult = "测试未通过";
                }
                List <String> Tmp = new List <string> {
                    sTestResult, sHardwareInformation
                };
                HdlUdpPublicFunctions.UpdateDataGridWhenNeedsRefreshDisplay(dgvListA, Tmp, intRowIndex, 3, bIsSuccess);
                #endregion
            }
            catch
            {
            }
        }
예제 #5
0
 private void ftmFind_Click(object sender, EventArgs e)
 {
     GetSubnetIdAndDeviceIdFromSelectedOnlineDevice();
     HdlUdpPublicFunctions.LocateDeviceWhereItIs(currentSelectDeviceSubnetId, currentSelectDeviceDeviceId);
 }