Beispiel #1
0
        public static void UpdateRobotConnection(string name, string status)
        {
            Form manual = Application.OpenForms["FormManual"];

            if (manual == null)
            {
                return;
            }

            TextBox tb = manual.Controls.Find("RobotConnection_tb", true).FirstOrDefault() as TextBox;

            if (tb == null)
            {
                return;
            }

            if (tb.InvokeRequired)
            {
                UpdateRobotStatus_D ph = new UpdateRobotStatus_D(UpdateRobotConnection);
                tb.BeginInvoke(ph, name, status);
            }
            else
            {
                tb.Text = status;
            }
        }
Beispiel #2
0
        public static void UpdateOCRConnection(string name, string status)
        {
            Form manual = Application.OpenForms["FormManual"];

            if (manual == null)
            {
                return;
            }

            TextBox tb = manual.Controls.Find("OCRConnection_tb", true).FirstOrDefault() as TextBox;

            if (tb == null)
            {
                return;
            }

            if (tb.InvokeRequired)
            {
                UpdateRobotStatus_D ph = new UpdateRobotStatus_D(UpdateOCRConnection);
                tb.BeginInvoke(ph, name, status);
            }
            else
            {
                ComboBox ocrName = manual.Controls.Find("Cb_OCRSelect", true).FirstOrDefault() as ComboBox;
                if (ocrName.Text.ToUpper().Equals(name.ToUpper()))
                {
                    tb.Text = status;
                    Button connectBtn = manual.Controls.Find("OCRConnect_btn", true).FirstOrDefault() as Button;
                    switch (status)
                    {
                    case "Connected":
                    case "Connecting":
                        connectBtn.Enabled = false;
                        break;

                    default:
                        connectBtn.Enabled = true;
                        break;
                    }
                }
            }
        }
Beispiel #3
0
        public static void UpdateRobotStatus(string name, string status)
        {
            Form manual = Application.OpenForms["FormManual"];

            if (manual == null)
            {
                return;
            }

            if (manual.InvokeRequired)
            {
                UpdateRobotStatus_D ph = new UpdateRobotStatus_D(UpdateRobotStatus);
                manual.BeginInvoke(ph, name, status);
            }
            else
            {
                StateUtil.Init();
                RobotState robot = StateUtil.GetDeviceState(name) != null ? (RobotState)StateUtil.GetDeviceState(name) : null;
                if (robot == null)
                {
                    return;
                }
                //update robot status
                TextBox tbRStatus = manual.Controls.Find("tbRStatus", true).FirstOrDefault() as TextBox;
                tbRStatus.Text = status;
                switch (status)
                {
                case "RUN":
                    tbRStatus.BackColor = Color.Lime;
                    break;

                case "IDLE":
                    tbRStatus.BackColor = Color.Yellow;
                    break;
                }
            }
        }
Beispiel #4
0
        public static void UpdateOCRRead(string name, string status)
        {
            Form manual = Application.OpenForms["FormManual"];

            if (manual == null)
            {
                return;
            }

            TextBox tb = manual.Controls.Find("OCRRead_tb", true).FirstOrDefault() as TextBox;

            if (tb == null)
            {
                return;
            }

            if (tb.InvokeRequired)
            {
                UpdateRobotStatus_D ph = new UpdateRobotStatus_D(UpdateOCRRead);
                tb.BeginInvoke(ph, name, status);
            }
            else
            {
                string src = "";
                switch (name)
                {
                case "OCR01":

                    src = SystemConfig.Get().OCR1ImgSourcePath;
                    break;

                case "OCR02":

                    src = SystemConfig.Get().OCR2ImgSourcePath;
                    break;
                }
                Thread.Sleep(500);
                Node OCR = NodeManagement.Get(name);
                if (OCR != null)
                {
                    string OCRResult = status;

                    switch (OCR.Brand)
                    {
                    case "COGNEX":
                        string[] ocrResult = OCRResult.Replace("[", "").Replace("]", "").Split(',');
                        string   info      = ocrResult[0];
                        if (ocrResult.Length >= 2)
                        {
                            info += " Score:" + ocrResult[1];
                        }
                        else
                        {
                            info += " Score:0";
                        }
                        tb.Text = info;
                        FTP ftp = new FTP(OCR.GetController().GetIPAdress(), "21", "", "admin", "");

                        PictureBox Pic_OCR = manual.Controls.Find("OCR_Pic", true).FirstOrDefault() as PictureBox;
                        if (Pic_OCR == null)
                        {
                            return;
                        }
                        Bitmap t = new Bitmap(Image.FromFile(src), new Size(320, 240));
                        Pic_OCR.Image = t;

                        break;

                    case "HST":
                        ocrResult = OCRResult.Replace("[", "").Replace("]", "").Split(',');
                        string WaferID = ocrResult[0];
                        if (ocrResult.Length >= 2)
                        {
                            WaferID += " Score:" + ocrResult[1];
                        }
                        else
                        {
                            WaferID += " Score:0";
                        }
                        tb.Text = WaferID;

                        string[]      files    = Directory.GetFiles(src);
                        List <string> fileList = files.ToList();
                        if (fileList.Count != 0)
                        {
                            fileList.Sort((x, y) => { return(-File.GetLastWriteTime(x).CompareTo(File.GetLastWriteTime(y))); });


                            Pic_OCR = manual.Controls.Find("OCR_Pic", true).FirstOrDefault() as PictureBox;

                            if (Pic_OCR == null)
                            {
                                return;
                            }
                            t             = new Bitmap(Image.FromFile(fileList[0]), new Size(320, 240));
                            Pic_OCR.Image = t;
                        }
                        break;
                    }
                }
            }
        }