예제 #1
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            //權限檢查
            using (var form = new FormConfirm("是否儲存變更?"))
            {
                var result = form.ShowDialog();
                if (result != DialogResult.OK)
                {
                    MessageBox.Show("Cancel.", "Notice");
                    return;
                }
            }

            SystemConfig config = SystemConfig.Get();

            //目前只開放查詢以下資料
            config.EquipmentID      = tbEqpId.Text;
            config.OCR1ImgToJpgPath = tbOcr1ImgBak.Text;
            config.FoupTxfLogPath   = tbTxfLogPath.Text;
            config.CurrentRecipe    = cbRecipe.SelectedItem.ToString();

            config.Save();
            MessageBox.Show("Update Completed.", "Success");
            FormMainUpdate.UpdateRecipe(config.CurrentRecipe);
        }
예제 #2
0
        private void btnChange_Click_1(object sender, EventArgs e)
        {
            string oldRecipeId = SystemConfig.Get().CurrentRecipe;
            string newRecipeId = cbRecipe.SelectedItem.ToString();

            using (var form = new FormConfirm("是否變更生產 Recipe:" + oldRecipeId + "=>" + newRecipeId))
            {
                var result = form.ShowDialog();
                if (result == DialogResult.OK)
                {
                    SystemConfig config = SystemConfig.Get();
                    config.CurrentRecipe = cbRecipe.SelectedItem.ToString();
                    config.Save();
                    FormMainUpdate.UpdateRecipe(config.CurrentRecipe);
                    SanwaUtil.addActionLog("Recipe", "Change", Global.currentUser, "變更生產 Recipe:" + oldRecipeId + "=>" + newRecipeId);
                    MessageBox.Show("Change recipe completed.", "Success");
                    this.DialogResult = DialogResult.OK;
                    this.Close();
                }
                else
                {
                    MessageBox.Show("Cancel.", "Notice");
                }
            }
        }
예제 #3
0
        private void UpdateNodeList()
        {
            string strSql = string.Empty;
            Dictionary <string, object> keyValues = new Dictionary <string, object>();
            DBUtil dBUtil = new DBUtil();

            try
            {
                strSql = @"SELECT * 
                            FROM config_node
                            WHERE equipment_model_id = @equipment_model_id
                            ORDER BY node_id";
                keyValues.Add("@equipment_model_id", SystemConfig.Get().SystemMode);
                dtConfigNode = dBUtil.GetDataTable(strSql, keyValues);

                if (dtConfigNode.Rows.Count > 0)
                {
                    lstNodeList.DataSource    = dtConfigNode;
                    lstNodeList.DisplayMember = "node_id";
                    lstNodeList.ValueMember   = "node_id";
                    lstNodeList.SelectedIndex = -1;
                }
                else
                {
                    lstNodeList.DataSource = null;
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.ToString());
            }
        }
예제 #4
0
        public FormSimpleSetting(Config_Type config_Type)
        {
            string model_id = SystemConfig.Get().SystemMode;

            InitializeComponent();
            sql = Global.Config_sql(config_Type);
        }
예제 #5
0
        public TaskFlowManagement(IUserInterfaceReport TaskReport)
        {
            _TaskReport = TaskReport;

            switch (SystemConfig.Get().TaskFlow.ToUpper())
            {
            case "KAWASAKI_3P_EFEM":
                //TaskFlow = new Kawasaki_3P_EFEM();
                break;

            case "SANWA_SORTER":
                //TaskFlow = new Sanwa_Sorter();
                break;

            case "WTS":
                //TaskFlow = new WTS();
                break;

            case "VERTICALCHAMBEROVEN_200":
                TaskFlow = new VerticalChamberOven_200(this);
                break;

            case "SANWA_EFEM":
                TaskFlow = new Sanwa_EFEM(this);;
                break;

            default:
                throw new NotSupportedException();
            }
            Ctrl = new MainControl(this);
        }
예제 #6
0
        private void FormCommunications_Load(object sender, EventArgs e)
        {
            string strSql = string.Empty;
            DBUtil dBUtil = new DBUtil();
            //DataTable dtList = new DataTable();
            Dictionary <string, object> keyValues = new Dictionary <string, object>();
            DataTable dtTemp = new DataTable();

            try
            {
                strSql = "SELECT t.device_name FROM config_controller_setting t where t.equipment_model_id =@equipment_model_id";


                keyValues.Add("@equipment_model_id", SystemConfig.Get().SystemMode);

                dtNode = dBUtil.GetDataTable(strSql, keyValues);

                if (dtNode.Rows.Count > 0)
                {
                    libDeviceList.DataSource    = dtNode;
                    libDeviceList.DisplayMember = "device_name";
                    libDeviceList.ValueMember   = "device_name";
                    libDeviceList.SelectedIndex = -1;
                }

                strSql = "SELECT* FROM config_controller_setting t where t.equipment_model_id =@equipment_model_id";
                keyValues.Clear();
                keyValues.Add("@equipment_model_id", SystemConfig.Get().SystemMode);
                dtController = dBUtil.GetDataTable(strSql, keyValues);



                //strSql = "select * from config_list_item where list_type = 'NODE_CONTROLLER_TYPE' ";

                //dtTemp = dBUtil.GetDataTable(strSql, null);

                //if (dtTemp.Rows.Count > 0)
                //{
                //    cmbComControllerType.DataSource = dtTemp.Copy();
                //    cmbComControllerType.DisplayMember = "list_value";
                //    cmbComControllerType.ValueMember = "list_value";
                //    cmbComControllerType.SelectedIndex = -1;


                //}
                //else
                //{

                //}

                CleanConnectMode();
            }
            catch (Exception ex)
            {
                throw new Exception(ex.ToString());
            }
        }
예제 #7
0
파일: FoupInfo.cs 프로젝트: bookorz/Sachiel
        public FoupInfo(string recipe_file, string login_user, string foup_id)
        {
            this.recipe_file = recipe_file;
            this.login_user  = login_user;
            this.foup_id     = foup_id;
            string date = System.DateTime.Now.ToString("yyyyMMdd");
            string time = System.DateTime.Now.ToString("HHmmss");

            this.file_name = SystemConfig.Get().EquipmentID + "_" + foup_id + "_" + date + "_" + time + ".csv";
            record         = new waferInfo[25];
        }
예제 #8
0
        private void UpdateNodeList()
        {
            string strSql = string.Empty;
            Dictionary <string, object> keyValues = new Dictionary <string, object>();
            DBUtil dBUtil = new DBUtil();

            try
            {
                strSql = "select *, concat(CommandScriptID, ',', `Index`) as CommandScriptIndex from config_command_script order by CommandScriptID asc, `Index` asc";
                keyValues.Add("@equipment_model_id", SystemConfig.Get().SystemMode);
                dtCommandType = dBUtil.GetDataTable(strSql, keyValues);

                if (dtCommandType.Rows.Count > 0)
                {
                    lstConditionList.DataSource    = dtCommandType;
                    lstConditionList.DisplayMember = "CommandScriptIndex";
                    lstConditionList.ValueMember   = "CommandScriptIndex";
                    lstConditionList.SelectedIndex = -1;

                    var query = (from a in dtCommandType.AsEnumerable()
                                 select a.Field <string>("CommandScriptID")).Distinct().ToList();

                    if (query.Count() > 0)
                    {
                        cmdCommandScriptID.Items.Clear();

                        foreach (var item in query)
                        {
                            cmdCommandScriptID.Items.Add(item.ToString());
                        }
                    }
                }
                else
                {
                    lstConditionList.DataSource = null;
                }


                cmdCommandScriptID.Text = string.Empty;
                txbExcuteMethod.Text    = string.Empty;
                txbFinishMethod.Text    = string.Empty;
                txbMethod.Text          = string.Empty;
                txbArm.Text             = string.Empty;
                txbSlot.Text            = string.Empty;
                txbPosition.Text        = string.Empty;
                txbValue.Text           = string.Empty;
                txbIndex.Text           = string.Empty;
                txbFlag.Text            = string.Empty;
            }
            catch (Exception ex)
            {
                throw new Exception(ex.ToString());
            }
        }
예제 #9
0
        private static MySqlConnection open_Conn()
        {
            MySqlConnection Connection_;
            string          connectionStr = SystemConfig.Get().DBConnectionString;

            Connection_ = new MySqlConnection(connectionStr);

            Connection_.Open();
            return(Connection_);

            //MessageBox.Show("Connect OK!");
        }
예제 #10
0
        private void Unload_btn(object sender, EventArgs e)
        {
            string PortName = ((Button)sender).Name.Substring(0, ((Button)sender).Name.IndexOf("_"));
            Node   port     = NodeManagement.Get(PortName);

            if (port == null)
            {
                MessageBox.Show(PortName + " not found");
            }
            if (port.Enable)
            {
                FoupInfo foup = FoupInfo.Get(port.Name);
                if (foup != null)
                {
                    foup.SetAllUnloadTime(DateTime.Now);
                }
                else
                {
                    foup = new Adam.FoupInfo(SystemConfig.Get().CurrentRecipe, Global.currentUser, port.FoupID);
                    foreach (Job j in port.JobList.Values)
                    {
                        if (j.MapFlag && !j.ErrPosition)
                        {
                            int slot = Convert.ToInt16(j.Slot);
                            foup.record[slot - 1] = new Adam.waferInfo(port.Name, port.FoupID, j.Slot, j.FromPort, j.FromFoupID, j.FromPortSlot, j.ToPort, j.ToFoupID, j.ToPortSlot);
                            foup.record[slot - 1].SetStartTime(j.StartTime);
                            foup.record[slot - 1].setM12(j.OCR_M12_Result);
                            foup.record[slot - 1].setT7(j.OCR_T7_Result);
                            foup.record[slot - 1].SetEndTime(j.EndTime);
                            foup.record[slot - 1].SetLoadTime(port.LoadTime);
                            foup.record[slot - 1].SetUnloadTime(DateTime.Now);
                            foup.record[slot - 1].setM12Score(j.OCR_M12_Score);
                            foup.record[slot - 1].setT7Score(j.OCR_T7_Score);
                        }
                    }
                }
                foup.Save();

                ((Button)sender).Enabled = false;
                string TaskName = "LOADPORT_CLOSE_NOMAP";
                string Message  = "";
                Dictionary <string, string> param1 = new Dictionary <string, string>();
                param1.Add("@Target", port.Name);
                TaskJobManagment.CurrentProceedTask tmpTask;
                RouteControl.Instance.TaskJob.Excute(Guid.NewGuid().ToString() + "Unload_btn", out Message, out tmpTask, TaskName, param1);
            }
            else
            {
                MessageBox.Show(PortName + " is disabled");
            }
        }
예제 #11
0
파일: FoupInfo.cs 프로젝트: bookorz/Sachiel
 public void Save()
 {
     try
     {
         //string fullPath = @"d:\log\foup\" + file_name;
         string path = SystemConfig.Get().FoupTxfLogPath.Replace("\\", "/");
         path = path.EndsWith("/") ? path : path + "/";
         string   date     = System.DateTime.Now.ToString("yyyyMMdd");
         string   fullPath = path + date + "/" + file_name;
         FileInfo fi       = new FileInfo(fullPath);
         if (!fi.Directory.Exists)
         {
             fi.Directory.Create();
         }
         FileStream fs = new FileStream(fullPath, System.IO.FileMode.Create, System.IO.FileAccess.Write);
         //StreamWriter sw = new StreamWriter(fs, System.Text.Encoding.Default);
         StreamWriter sw   = new StreamWriter(fs, System.Text.Encoding.UTF8);
         string       data = "";
         //寫出列名稱
         data = "port,foup_id,slot,from_port,from_id,from_slot,to_port_id,to_id,to_slot,t7,t7_score,m12,m12_score,start_datedime,end_datetime,load_datetime,unload_datetime,recipe_file,login_user";
         sw.WriteLine(data);
         //寫出各行數據
         for (int i = 0; i < record.Length; i++)
         {
             if (record[i] == null)
             {
                 continue;
             }
             data = "";
             string[] column = record[i].getData();
             for (int j = 0; j < column.Length; j++)
             {
                 string str = column[j] == null ? "" : column[j].ToString();
                 str   = string.Format("\"{0}\"", str).Replace("\r", "\\r").Replace("\n", "\\n");
                 data += str;
                 data += ",";
             }
             data += recipe_file + ",";
             data += login_user;
             sw.WriteLine(data);
         }
         sw.Close();
         fs.Close();
         //Process.Start(fullPath);打開檔案
     }
     catch (Exception ex)
     {
         logger.Error(ex.StackTrace);
     }
 }
예제 #12
0
파일: FormMain.cs 프로젝트: bookorz/Lilith
 private void Mode_btn_Click(object sender, EventArgs e)
 {
     if (Mode_btn.Text.Equals("Manual-Mode"))
     {
         HostControl.OnlineMode = true;
         Mode_btn.Text          = "Online-Mode";
         Mode_btn.BackColor     = Color.Green;
         btnManual.Enabled      = false;
         btnManual.BackColor    = Color.Gray;
         tbcMian.Enabled        = false;
         tbcMian.SelectedIndex  = 0;
         if (formManual != null)
         {
             formManual.Close();
         }
     }
     else
     {
         //check 密碼
         MD5      md5             = MD5.Create();
         string[] use_info        = ShowLoginDialog();
         string   user_id         = use_info[0];
         string   password        = use_info[1];
         byte[]   source          = Encoding.Default.GetBytes(password);                                //將字串轉為Byte[]
         byte[]   crypto          = md5.ComputeHash(source);                                            //進行MD5加密
         string   md5_result      = BitConverter.ToString(crypto).Replace("-", String.Empty).ToUpper(); //取得 MD5
         string   config_password = SystemConfig.Get().AdminPassword;
         if (md5_result.Equals(config_password))
         {
             HostControl.OnlineMode = false;
             Mode_btn.Text          = "Manual-Mode";
             Mode_btn.BackColor     = Color.Orange;
             btnManual.Enabled      = true;
             btnManual.BackColor    = Color.Orange;
             tbcMian.Enabled        = true;
         }
         else
         {
             MessageBox.Show("Password incorrect !!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly);
             btnManual.Enabled   = false;
             btnManual.BackColor = Color.Gray;
         }
     }
 }
        public static void LoadConfig(ICommandReport Report)
        {
            //if (Controllers != null)
            //{
            //    foreach(DeviceController each in Controllers.Values)
            //    {
            //        each.Close();
            //    }
            //}
            Dictionary <string, object> keyValues = new Dictionary <string, object>();

            Controllers = new ConcurrentDictionary <string, DeviceController>();
            string Sql = @"SELECT UPPER(t.device_name) as DeviceName,t.device_type as DeviceType,
										UPPER(t.vendor) as vendor,
                            case when t.conn_type = 'Socket' then  t.conn_address else '' end as IPAdress ,
                            case when t.conn_type = 'Socket' then  CONVERT(t.conn_prot,SIGNED) else 0 end as Port ,
                            case when t.conn_type = 'Comport' then   CONVERT(t.conn_prot,SIGNED) else 0 end as BaudRate ,
                            case when t.conn_type = 'Comport' then  t.conn_address else '' end as PortName ,
                            t.com_parity_bit as ParityBit,
                            ifnull(CONVERT(t.com_data_bits,SIGNED),0) as DataBits,
                            t.com_stop_bit as StopBit,
                            t.conn_type as ConnectionType,
                            t.enable_flg as Enable
                            FROM config_controller_setting t
                            WHERE t.equipment_model_id = @equipment_model_id
                            AND t.device_type <> 'DIO'";

            keyValues.Add("@equipment_model_id", SystemConfig.Get().SystemMode);
            DataTable dt       = dBUtil.GetDataTable(Sql, keyValues);
            string    str_json = JsonConvert.SerializeObject(dt, Formatting.Indented);

            List <DeviceConfig> ctrlList = JsonConvert.DeserializeObject <List <DeviceConfig> >(str_json);


            foreach (DeviceConfig each in ctrlList)
            {
                if (each.Enable)
                {
                    DeviceController tmp = new DeviceController(each, Report);
                    Controllers.TryAdd(each.DeviceName, tmp);
                }
            }
        }
예제 #14
0
        public void StartListening(object msg)
        {
            // Establish the local endpoint for the socket.
            // The DNS name of the computer

            //IPHostEntry ipHostInfo = Dns.GetHostEntry(Dns.GetHostName());
            //IPAddress ipAddress = IPAddress.Parse("127.0.0.1");
            IPAddress  ipAddress     = IPAddress.Parse(SystemConfig.Get().EFEMInterfaceConn);
            IPEndPoint localEndPoint = new IPEndPoint(ipAddress, SystemConfig.Get().EFEMInterfaceConn_Port);

            // Create a TCP/IP socket.
            Socket listener = new Socket(ipAddress.AddressFamily,
                                         SocketType.Stream, ProtocolType.Tcp);

            // Bind the socket to the local endpoint and listen for incoming connections.
            try
            {
                listener.Bind(localEndPoint);
                listener.Listen(1);
                _EventReport.On_Connection_Connecting();
                while (true)
                {
                    // Set the event to nonsignaled state.
                    allDone.Reset();

                    // Start an asynchronous socket to listen for connections.
                    //Console.WriteLine("Waiting for a connection...");
                    listener.BeginAccept(
                        new AsyncCallback(AcceptCallback),
                        listener);

                    // Wait until a connection is made before continuing.
                    allDone.WaitOne();
                }
            }
            catch (Exception e)
            {
                //Console.WriteLine(e.ToString());
            }

            //Console.WriteLine("\nPress ENTER to continue...");
            //Console.Read();
        }
예제 #15
0
        private void btnDeleteRecipe_Click(object sender, EventArgs e)
        {
            if (trvRecipe.SelectedNode == null)
            {
                MessageBox.Show("Please select a recipe first.", "Notice");
                return;
            }
            Recipe recipe = Recipe.Get(trvRecipe.SelectedNode.Text);

            if (recipe.recipe_id.Equals("default"))
            {
                MessageBox.Show("default recipe 不得刪除.", "Notice");
                return;
            }
            else if (SystemConfig.Get().CurrentRecipe.Equals(recipe.recipe_id))
            {
                MessageBox.Show("Recipe 使用中,請先切換 recipe 後再刪除.", "Notice");
                return;
            }
            using (var form = new FormConfirm("確認是否刪除 Recipe:" + recipe.recipe_id))
            {
                var result = form.ShowDialog();
                if (result == DialogResult.OK)
                {
                    if (Recipe.Delete(recipe.recipe_id))
                    {
                        refreshList();
                        Util.SanwaUtil.addActionLog("Recipe", "Delete", Global.currentUser, "刪除 Recipe:" + recipe.recipe_id);
                        MessageBox.Show("Delete completed.", "Success");
                    }
                    else
                    {
                        MessageBox.Show("Delete fail.", "Error");
                    }
                }
                else
                {
                    MessageBox.Show("Cancel.", "Notice");
                }
            }
        }
예제 #16
0
        private void FormDeviceManager_Load(object sender, EventArgs e)
        {
            string strSql = string.Empty;
            Dictionary <string, object> keyValues = new Dictionary <string, object>();
            DBUtil    dBUtil = new DBUtil();
            DataTable dtTemp = new DataTable();

            try
            {
                UpdateNodeList();

                txbEquipmentModel.Text = SystemConfig.Get().SystemMode;

                dtTemp = new DataTable();
                strSql = "SELECT list_type, list_id, list_name, list_name_en, CASE WHEN list_value = 'DIO' THEN 'SYSTEM' ELSE list_value END list_value, sort_sequence " +
                         "FROM config_list_item " +
                         "WHERE list_type = 'DEVICE_TYPE'";
                dtTemp = dBUtil.GetDataTable(strSql, null);

                if (dtTemp.Rows.Count > 0)
                {
                    cmbDeviceNodeType.DataSource    = dtTemp;
                    cmbDeviceNodeType.DisplayMember = "list_name";
                    cmbDeviceNodeType.ValueMember   = "list_value";
                    cmbDeviceNodeType.SelectedIndex = -1;
                }
                else
                {
                    cmbDeviceNodeType.DataSource = null;
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.ToString());
            }
        }
예제 #17
0
        private void FormSysConfig_Load(object sender, EventArgs e)
        {
            //init recipe combobox
            cbRecipe.Items.Clear(); DirectoryInfo d = new DirectoryInfo(@".\recipe");
            FileInfo[] Files = d.GetFiles("*.json"); //Getting Json files
            foreach (FileInfo file in Files)
            {
                string recipeId = file.Name.Replace(".json", "");
                cbRecipe.Items.Add(recipeId);
            }
            //set gui data
            SystemConfig config = SystemConfig.Get();

            tbConnString.Text     = config.DBConnectionString;
            tbEqpId.Text          = config.EquipmentID;
            tbOcr1Exe.Text        = config.OCR1ExePath;
            tbOcr1ImgBak.Text     = config.OCR1ImgToJpgPath;
            tbOcr1ImgSrc.Text     = config.OCR1ImgSourcePath;
            tbSysMode.Text        = config.SystemMode;
            tbTxfLogPath.Text     = config.FoupTxfLogPath;
            cbChkBypass.Checked   = config.SaftyCheckByPass;
            cbFakeData.Checked    = config.FakeData;
            cbRecipe.SelectedItem = config.CurrentRecipe;
        }
예제 #18
0
        private static void updateLoadPortConfig(Recipe recipe)
        {
            Boolean result = false;

            try
            {
                DBUtil dBUtil = new DBUtil();
                Dictionary <string, object> keyValues = new Dictionary <string, object>();
                string strSql = " UPDATE config_node SET carrier_type = CASE node_id WHEN 'LOADPORT01' THEN @ctype1 " +
                                "                                                    WHEN 'LOADPORT02' THEN @ctype2 " +
                                "                                                    WHEN 'LOADPORT03' THEN @ctype3 " +
                                "                                                    WHEN 'LOADPORT04' THEN @ctype4 " +
                                "                                                    ELSE carrier_type END, " +
                                "                          mode = CASE node_id WHEN 'LOADPORT01' THEN @mode1 " +
                                "                                              WHEN 'LOADPORT02' THEN @mode2 " +
                                "                                              WHEN 'LOADPORT03' THEN @mode3 " +
                                "                                              WHEN 'LOADPORT04' THEN @mode4 " +
                                "                                              ELSE mode END," +
                                "                          enable_flg = CASE node_id WHEN 'LOADPORT01' THEN @enable1 " +
                                "                                                    WHEN 'LOADPORT02' THEN @enable2 " +
                                "                                                    WHEN 'LOADPORT03' THEN @enable3 " +
                                "                                                    WHEN 'LOADPORT04' THEN @enable4 " +
                                "                                                    ELSE enable_flg END," +
                                "                          bypass = CASE node_id     WHEN 'ALIGNER01' THEN @bypassA1 " +
                                "                                                    ELSE bypass END," +
                                "                          double_arm = CASE node_id WHEN 'ROBOT01' THEN @double_arm_r1 " +
                                "                                                    ELSE double_arm END, " +
                                "                          r_arm = CASE node_id WHEN 'ROBOT01' THEN @r_arm_r1 " +
                                "                                                    ELSE r_arm END, " +
                                "                          l_arm = CASE node_id WHEN 'ROBOT01' THEN @l_arm_r1 " +
                                "                                                    ELSE l_arm END, " +
                                "                          modify_user = @modify_user, modify_timestamp = NOW() " +
                                " WHERE equipment_model_id = @equipment_model_id " +
                                "   AND node_type IN ('LOADPORT','ROBOT','Aligner') ;";

                keyValues.Add("@equipment_model_id", SystemConfig.Get().SystemMode);
                keyValues.Add("@modify_user", Global.currentUser);
                keyValues.Add("@ctype1", recipe.port1_carrier_type);
                keyValues.Add("@ctype2", recipe.port2_carrier_type);
                keyValues.Add("@ctype3", recipe.port3_carrier_type);
                keyValues.Add("@ctype4", recipe.port4_carrier_type);
                keyValues.Add("@mode1", getPortType(recipe.port1_type));
                keyValues.Add("@mode2", getPortType(recipe.port2_type));
                keyValues.Add("@mode3", getPortType(recipe.port3_type));
                keyValues.Add("@mode4", getPortType(recipe.port4_type));
                keyValues.Add("@enable1", getEnable(recipe.port1_type));
                keyValues.Add("@enable2", getEnable(recipe.port2_type));
                keyValues.Add("@enable3", getEnable(recipe.port3_type));
                keyValues.Add("@enable4", getEnable(recipe.port4_type));
                keyValues.Add("@bypassA1", recipe.is_use_aligner1 ? 0 : 1);//要用ALIGNER 時 bypass = 0, ELSE bypass = 1
                keyValues.Add("@double_arm_r1", recipe.is_use_double_arm ? 1 : 0);
                keyValues.Add("@r_arm_r1", recipe.is_use_r_arm ? 1 : 0);
                keyValues.Add("@l_arm_r1", recipe.is_use_l_arm ? 1 : 0);
                dBUtil.ExecuteNonQuery(strSql, keyValues);
                foreach (Node node in NodeManagement.GetList())
                {
                    switch (node.Name.ToUpper())
                    {
                    case "LOADPORT01":
                        node.CarrierType       = recipe.port1_carrier_type;
                        node.Mode              = getPortType(recipe.port1_type);
                        node.Enable            = getEnable(recipe.port1_type) == 1 ? true : false;
                        node.OrgSearchComplete = false;
                        break;

                    case "LOADPORT02":
                        node.CarrierType       = recipe.port2_carrier_type;
                        node.Mode              = getPortType(recipe.port2_type);
                        node.Enable            = getEnable(recipe.port2_type) == 1 ? true : false;
                        node.OrgSearchComplete = false;
                        break;

                    case "LOADPORT03":
                        node.CarrierType       = recipe.port3_carrier_type;
                        node.Mode              = getPortType(recipe.port3_type);
                        node.Enable            = getEnable(recipe.port3_type) == 1 ? true : false;
                        node.OrgSearchComplete = false;
                        break;

                    case "LOADPORT04":
                        node.CarrierType       = recipe.port4_carrier_type;
                        node.Mode              = getPortType(recipe.port4_type);
                        node.Enable            = getEnable(recipe.port4_type) == 1 ? true : false;
                        node.OrgSearchComplete = false;
                        break;

                    case "ROBOT01":
                        node.RArmActive      = recipe.is_use_r_arm;
                        node.LArmActive      = recipe.is_use_l_arm;
                        node.DoubleArmActive = recipe.is_use_double_arm;
                        break;

                    case "ALIGNER01":
                        node.ByPass = !recipe.is_use_aligner1;
                        break;

                    case "ALIGNER02":
                        node.ByPass = !recipe.is_use_aligner2;
                        break;
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Update load port 資訊失敗! " + ex.StackTrace);
            }
        }
예제 #19
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            string        strSql                  = string.Empty;
            StringBuilder sbErrorMessage          = new StringBuilder();
            Dictionary <string, object> keyValues = new Dictionary <string, object>();
            DBUtil    dBUtil = new DBUtil();
            DataTable dtTemp = new DataTable();


            try
            {
                Node currentNode = NodeManagement.Get(Setting_NodeName_lb.Text);

                if (currentNode == null)
                {
                    MessageBox.Show("Node " + Setting_NodeName_lb.Text + " is not exist!");
                    return;
                }
                IController currentController = ControllerManagement.Get(currentNode.Controller);
                if (currentController == null)
                {
                    MessageBox.Show("Controller " + currentNode.Controller + " is not exist!");
                    return;
                }
                //權限檢查
                using (var form = new FormConfirm("是否儲存變更?"))
                {
                    var result = form.ShowDialog();
                    if (result != DialogResult.OK)
                    {
                        MessageBox.Show("Cancel.", "Notice");
                        return;
                    }
                }
                currentNode.Enable      = Setting_NodeEnable_rb.Checked;
                currentNode.CarrierType = Setting_CarrierType_cb.Text;
                currentNode.Mode        = Setting_Mode_cb.Text;
                strSql = @"UPDATE config_node SET enable_flg = @enable_flg ,carrier_type = @carrier_type, mode = @mode WHERE equipment_model_id = @equipment_model_id AND node_id = @node_id";

                keyValues.Add("@equipment_model_id", SystemConfig.Get().SystemMode);
                keyValues.Add("@node_id", currentNode.Name);
                keyValues.Add("@enable_flg", currentNode.Enable ? 1 : 0);
                keyValues.Add("@carrier_type", currentNode.CarrierType);
                keyValues.Add("@mode", currentNode.Mode);

                dBUtil.ExecuteNonQuery(strSql, keyValues);

                keyValues.Clear();

                strSql = "UPDATE config_controller_setting SET conn_type = @conn_type, conn_address = @conn_address , conn_port = @conn_port WHERE equipment_model_id = @equipment_model_id AND device_name = @device_name";

                keyValues.Add("@equipment_model_id", SystemConfig.Get().SystemMode);
                keyValues.Add("@device_name", currentNode.Controller);
                keyValues.Add("@conn_type", Setting_connectType_cb.Text);
                keyValues.Add("@conn_address", Setting_Address_tb.Text);
                keyValues.Add("@conn_port", Setting_Port_tb.Text);
                dBUtil.ExecuteNonQuery(strSql, keyValues);



                MessageBox.Show("連線相關設定值,將於重啟程式後生效.", "Save", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.ToString());
            }
        }
예제 #20
0
        public void Initial()
        {
            Ctrls    = new ConcurrentDictionary <string, IDIOController>();
            Params   = new ConcurrentDictionary <string, ParamConfig>();
            Controls = new ConcurrentDictionary <string, ParamConfig>();
            Dictionary <string, object> keyValues = new Dictionary <string, object>();

            keyValues.Add("@equipment_model_id", SystemConfig.Get().SystemMode);



            string    Sql      = @"select t.dioname DeviceName,t.`type` 'Type',t.address ,upper(t.Parameter) Parameter,t.abnormal,t.error_code  from config_dio_point t
                    where  t.equipment_model_id = @equipment_model_id";
            DataTable dt       = dBUtil.GetDataTable(Sql, keyValues);
            string    str_json = JsonConvert.SerializeObject(dt, Formatting.Indented);

            List <ParamConfig> ParamList = JsonConvert.DeserializeObject <List <ParamConfig> >(str_json);


            foreach (ParamConfig each in ParamList)
            {
                if (each.Type.ToUpper().Equals("AIN") || each.Type.ToUpper().Equals("DIN"))
                {
                    Params.TryAdd(each.DeviceName + each.Address + each.Type, each);
                }
                else if (each.Type.ToUpper().Equals("AOUT") || each.Type.ToUpper().Equals("DOUT"))
                {
                    each.Status = "N/A";
                    Controls.TryAdd(each.Parameter, each);
                }
            }

            Sql = @"SELECT t.device_name as DeviceName,t.device_type as DeviceType,t.vendor as vendor,
                            case when t.conn_type = 'Socket' then  t.conn_address else '' end as IPAdress ,
                            case when t.conn_type = 'Socket' then  CONVERT(t.conn_port,SIGNED) else 0 end as Port ,
                            case when t.conn_type = 'Comport' then   CONVERT(t.conn_port,SIGNED) else 0 end as BaudRate ,
                            case when t.conn_type = 'Comport' then  t.conn_address else '' end as PortName ,             
                            t.conn_type as ConnectionType,
                            t.enable_flg as Enable
                            FROM config_controller_setting t
                            WHERE t.equipment_model_id = @equipment_model_id
                            AND t.device_type = 'DIO'";

            dt       = dBUtil.GetDataTable(Sql, keyValues);
            str_json = JsonConvert.SerializeObject(dt, Formatting.Indented);

            List <CtrlConfig> ctrlList = JsonConvert.DeserializeObject <List <CtrlConfig> >(str_json);

            // List<CtrlConfig> ctrlList = new List<CtrlConfig>();
            foreach (CtrlConfig each in ctrlList)
            {
                IDIOController eachCtrl = null;
                if (each.Enable)
                {
                    var find = from Param in Params.Values.ToList()
                               where Param.DeviceName.ToUpper().Equals(each.DeviceName.ToUpper())
                               select Param;
                    foreach (ParamConfig eachDio in find)
                    {
                        if (eachDio.Type.ToUpper().Equals("DIN") || eachDio.Type.ToUpper().Equals("DOUT"))
                        {
                            each.Digital = true;
                        }
                        else if (eachDio.Type.ToUpper().Equals("AIN") || eachDio.Type.ToUpper().Equals("AOUT"))
                        {
                            each.Analog = true;
                        }
                    }

                    find = from Param in Controls.Values.ToList()
                           where Param.DeviceName.ToUpper().Equals(each.DeviceName.ToUpper())
                           select Param;
                    foreach (ParamConfig eachDio in find)
                    {
                        if (eachDio.Type.ToUpper().Equals("DIN") || eachDio.Type.ToUpper().Equals("DOUT"))
                        {
                            each.Digital = true;
                        }
                        else if (eachDio.Type.ToUpper().Equals("AIN") || eachDio.Type.ToUpper().Equals("AOUT"))
                        {
                            each.Analog = true;
                        }
                    }


                    each.slaveID = 1;
                    each.DigitalInputQuantity = 8;
                    each.Delay       = 100;
                    each.ReadTimeout = 1000;
                    switch (each.Vendor)
                    {
                    case "ICPCONDIGITAL":

                        eachCtrl = new ICPconDigitalController(each, this);

                        break;

                    case "SANWADIGITAL":

                        eachCtrl = new SanwaDigitalController(each, this);

                        break;
                    }
                    if (eachCtrl != null)
                    {
                        Ctrls.TryAdd(each.DeviceName, eachCtrl);
                    }
                }
            }


            Thread BlinkTd = new Thread(Blink);

            BlinkTd.IsBackground = true;
            BlinkTd.Start();
        }
예제 #21
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;
                    }
                }
            }
        }
예제 #22
0
        private void updateInfo(string recipeID)
        {
            try
            {
                //gbRecipe.Enabled = true;
                Recipe recipe = Recipe.Get(recipeID);
                tbA1_angle.Text = recipe.aligner1_angle;
                tbA1_speed.Text = recipe.aligner1_speed;
                tbA2_angle.Text = recipe.aligner2_angle;
                tbA2_speed.Text = recipe.aligner2_speed;

                //recipe.auto_fin_unclamp = "Y";//固定Y 無UI

                cbAutoGetRule.SelectedItem = recipe.auto_get_constrict;
                cbAutoPutRule.SelectedItem = recipe.auto_put_constrict;
                //tbEqpID.Text = recipe.equip_id;


                tbFFUCloseRpm.Text = recipe.ffu_rpm_close;
                tbFFUOpenRpm.Text  = recipe.ffu_rpm_open;

                //recipe.manual_fin_unclamp = "Y";//固定Y 無UI

                cbManualGetRule.SelectedItem = recipe.manual_get_constrict;

                cbManualPutRule.SelectedItem = recipe.manual_put_constrict;

                cbP1CstType.SelectedItem  = recipe.port1_carrier_type;
                cbP1Seq.SelectedItem      = recipe.port1_priority.ToString();
                cbP1LoadType.SelectedItem = recipe.port1_type;

                cbP2CstType.SelectedItem  = recipe.port2_carrier_type;
                cbP2Seq.SelectedItem      = recipe.port2_priority.ToString();
                cbP2LoadType.SelectedItem = recipe.port2_type;

                cbP3CstType.SelectedItem  = recipe.port3_carrier_type;
                cbP3Seq.SelectedItem      = recipe.port3_priority.ToString();
                cbP3LoadType.SelectedItem = recipe.port3_type;

                cbP4CstType.SelectedItem  = recipe.port4_carrier_type;
                cbP4Seq.SelectedItem      = recipe.port4_priority.ToString();
                cbP4LoadType.SelectedItem = recipe.port4_type;

                cbGetSlotOrder.SelectedItem = recipe.get_slot_order;
                cbPutSlotOrder.SelectedItem = recipe.put_slot_order;

                tbRecipeID.Text   = recipe.recipe_id;
                tbRecipeName.Text = recipe.recipe_name;
                tbR1Speed.Text    = recipe.robot1_speed;
                //tbR2Speed.Text = recipe.robot2_speed;

                tbNotch_angle.Text = recipe.notch_angle;

                cbUseA1.Checked = recipe.is_use_aligner1;
                cbUseA2.Checked = recipe.is_use_aligner2;

                cbUseLArm.Checked     = recipe.is_use_l_arm;
                cbUseRArm.Checked     = recipe.is_use_r_arm;
                cbUserBothArm.Checked = recipe.is_use_double_arm;


                //gbRecipe.Enabled = false;
                string CurrentRecipe = SystemConfig.Get().CurrentRecipe;
                if (CurrentRecipe.Equals(tbRecipeID.Text))//取消生效
                {
                    cbActive.Checked = true;
                }
                else
                {
                    cbActive.Checked = false;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Recipe 格式錯誤,讀取失敗! " + ex.StackTrace);
            }
        }
예제 #23
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            //檢查資料
            if (tbRecipeID.Text.Trim().Equals("") || tbRecipeName.Text.Trim().Equals(""))
            {
                MessageBox.Show("Recipe Name or recipe id should not be empty.", "Data check error");
                return;
            }
            //權限檢查
            using (var form = new FormConfirm("確認是否儲存 Recipe:" + tbRecipeID.Text))
            {
                var result = form.ShowDialog();
                if (result != DialogResult.OK)
                {
                    MessageBox.Show("Cancel.", "Notice");
                    return;
                }
            }
            //GUI 處理
            //gbRecipe.Enabled = false;
            btnCreateRecipe.Enabled = true;
            btnModifyRecipe.Enabled = true;
            btnCancel.Enabled       = false;
            btnSave.Enabled         = false;
            tbRecipeName.ReadOnly   = true;
            tbRecipeID.ReadOnly     = true;
            trvRecipe.Enabled       = true;
            //Recipe 存檔
            Recipe recipe = new Recipe();

            recipe.aligner1_angle = tbA1_angle.Text.Equals("") ? "0" : Int32.Parse(tbA1_angle.Text).ToString();
            recipe.aligner1_speed = tbA1_speed.Text.Equals("") ? "20" : Int32.Parse(tbA1_speed.Text).ToString();
            recipe.aligner2_angle = tbA2_angle.Text.Equals("") ? "0" : Int32.Parse(tbA2_angle.Text).ToString();
            recipe.aligner2_speed = tbA2_speed.Text.Equals("") ? "20" : Int32.Parse(tbA2_speed.Text).ToString();

            recipe.is_use_aligner1 = cbUseA1.Checked;
            recipe.is_use_aligner2 = cbUseA2.Checked;


            recipe.auto_fin_unclamp = "Y";//固定Y

            recipe.auto_get_constrict = cbAutoGetRule.Text;
            recipe.auto_put_constrict = cbAutoPutRule.Text;
            //recipe.equip_id = tbEqpID.Text;
            recipe.ffu_rpm_close = tbFFUCloseRpm.Text;
            recipe.ffu_rpm_open  = tbFFUOpenRpm.Text;

            recipe.manual_fin_unclamp = "Y";//固定Y

            recipe.manual_get_constrict = cbManualGetRule.Text;
            recipe.manual_put_constrict = cbManualPutRule.Text;

            recipe.port1_carrier_type = cbP1CstType.Text;
            recipe.port1_priority     = Int32.Parse(cbP1Seq.Text);
            recipe.port1_type         = cbP1LoadType.Text;

            recipe.port2_carrier_type = cbP2CstType.Text;
            recipe.port2_priority     = Int32.Parse(cbP2Seq.Text);
            recipe.port2_type         = cbP2LoadType.Text;

            recipe.port3_carrier_type = cbP3CstType.Text;
            recipe.port3_priority     = Int32.Parse(cbP3Seq.Text);
            recipe.port3_type         = cbP3LoadType.Text;

            recipe.port4_carrier_type = cbP4CstType.Text;
            recipe.port4_priority     = Int32.Parse(cbP4Seq.Text);
            recipe.port4_type         = cbP4LoadType.Text;

            recipe.recipe_id    = tbRecipeID.Text.Trim();
            recipe.recipe_name  = tbRecipeName.Text;
            recipe.robot1_speed = tbR1Speed.Text.Equals("") ? "20" : Int32.Parse(tbR1Speed.Text).ToString();
            recipe.robot2_speed = "20";//default tbR2Speed.Text.Equals("") ? "20" : Int32.Parse(tbR2Speed.Text).ToString();

            recipe.notch_angle = tbNotch_angle.Text.Equals("") ? "0" : Int32.Parse(tbNotch_angle.Text).ToString();

            recipe.is_use_l_arm      = cbUseLArm.Checked;
            recipe.is_use_r_arm      = cbUseRArm.Checked;
            recipe.is_use_double_arm = cbUserBothArm.Checked;
            recipe.get_slot_order    = cbGetSlotOrder.Text;
            recipe.put_slot_order    = cbPutSlotOrder.Text;

            Recipe.Set(recipe.recipe_id, recipe);

            string CurrentRecipe = SystemConfig.Get().CurrentRecipe;

            if (cbActive.Checked)//設定生效
            {
                SystemConfig config = SystemConfig.Get();
                config.CurrentRecipe = tbRecipeID.Text;
                config.Save();
                FormMainUpdate.UpdateRecipe(tbRecipeID.Text);
            }
            else if (CurrentRecipe.Equals(tbRecipeID.Text))//取消生效
            {
                SystemConfig config = SystemConfig.Get();
                config.CurrentRecipe = "default";
                config.Save();
                //update node config
                FormMainUpdate.UpdateRecipe("default");
            }
            //紀錄修改Log
            if (tbRecipeID.Enabled)
            {
                Util.SanwaUtil.addActionLog("Recipe", "Create", Global.currentUser, "建立 Recipe:" + recipe.recipe_id);
            }
            if (tbRecipeID.Enabled)
            {
                Util.SanwaUtil.addActionLog("Recipe", "Modify", Global.currentUser, "修改 Recipe:" + recipe.recipe_id);
            }

            refreshList();
            MessageBox.Show("Execute successfully.", "Success");
        }
예제 #24
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if ((DataTable)libDeviceList.DataSource == null || ((DataTable)libDeviceList.DataSource).Rows.Count == 0)
            {
                MessageBox.Show("The grid data does not exist.", this.Name, MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1);
                return;
            }

            if (libDeviceList.SelectedIndex < 0)
            {
                MessageBox.Show("Choose the condition.", this.Name, MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1);
                return;
            }

            string strReplaceSql = string.Empty;

            DBUtil dBUtil = new DBUtil();
            Dictionary <string, object> keyValues = new Dictionary <string, object>();

            try
            {
                strReplaceSql = "REPLACE INTO config_controller_setting " +
                                "(equipment_model_id,device_name, device_type,vendor, conn_address, conn_type, conn_prot, " +
                                "com_parity_bit, com_data_bits, com_stop_bit, enable_flg, " +
                                "create_user, create_timestamp, modify_user, modify_timestamp) " +
                                "VALUES (" +
                                "@equipment_model_id, " +
                                "@device_name, " +
                                "@device_type, " +
                                "@vendor, " +
                                "@conn_address, " +
                                "@conn_type, " +
                                "@conn_prot, " +
                                "@com_parity_bit, " +
                                "@com_data_bits, " +
                                "@com_stop_bit, " +
                                "@enable_flg, " +
                                "@create_user, " +
                                "@create_timestamp, " +
                                "@modify_user, " +
                                "NOW() " +
                                ") ";

                keyValues.Add("@equipment_model_id", SystemConfig.Get().SystemMode);
                keyValues.Add("@device_name", ControllerID);
                keyValues.Add("@device_type", DeviceType_cb.Text);
                keyValues.Add("@vendor", Vendor_tb.Text);

                if (btnTCPIP.BackColor == Color.DodgerBlue)
                {
                    keyValues.Add("@conn_address", string.Format("{0}.{1}.{2}.{3}", nudIP01.Value.ToString(), nudIP02.Value.ToString(), nudIP03.Value.ToString(), nudIP04.Value.ToString()));
                    keyValues.Add("@conn_type", btnTCPIP.Tag.ToString());
                    keyValues.Add("@conn_prot", nudIPPort.Value.ToString());
                    keyValues.Add("@com_parity_bit", string.Empty);
                    keyValues.Add("@com_data_bits", string.Empty);
                    keyValues.Add("@com_stop_bit", string.Empty);
                    keyValues.Add("@enable_flg", chbTCPIPActive.Checked ? 1 : 0);



                    //if (dtControlSetting != null || dtControlSetting.Rows.Count > 0)
                    //{
                    //    keyValues.Add("@control_setting", JsonConvert.SerializeObject(dtControlSetting, Formatting.Indented));
                    //}
                    //else
                    //{
                    //    keyValues.Add("@control_setting", string.Empty);
                    //}

                    //if (dtParameterSetting != null || dtParameterSetting.Rows.Count > 0)
                    //{
                    //    keyValues.Add("@parameter_setting", JsonConvert.SerializeObject(dtParameterSetting, Formatting.Indented));
                    //}
                    //else
                    //{
                    //    keyValues.Add("@parameter_setting", string.Empty);
                    //}
                }

                if (btnRS232C.BackColor == Color.DodgerBlue)
                {
                    keyValues.Add("@conn_address", cmbPortName.Text);
                    keyValues.Add("@conn_type", btnRS232C.Tag.ToString());
                    keyValues.Add("@conn_prot", nudBaudRate.Value.ToString());
                    keyValues.Add("@com_parity_bit", txbParityBit.Text.Trim());
                    keyValues.Add("@com_data_bits", nudDataBits.Value.ToString());
                    keyValues.Add("@com_stop_bit", txbStopBit.Text.Trim());
                    keyValues.Add("@enable_flg", chbRS232CActive.Checked ? 1 : 0);
                }

                Form  form   = Application.OpenForms["FormMain"];
                Label Signal = form.Controls.Find("lbl_login_id", true).FirstOrDefault() as Label;


                keyValues.Add("@create_user", Signal.Text);
                strReplaceSql = strReplaceSql.Replace("@create_timestamp,", "NOW(),");


                keyValues.Add("@modify_user", Signal.Text);

                dBUtil.ExecuteNonQuery(strReplaceSql, keyValues);

                MessageBox.Show("Done it.", "Save", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);

                Adam.Util.SanwaUtil.addActionLog("Adam.Menu.SystemSetting", "FormCpmmandScript", Signal.Text);

                FormCommunications_Load(sender, e);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.ToString());
            }
        }
예제 #25
0
        public static void UpdateOCRRead(string OCRName, string WaferID, Job Job)
        {
            try
            {
                Form    form = Application.OpenForms["FormMonitoring"];
                TextBox Tb_OCRRead;
                if (form == null)
                {
                    return;
                }

                Tb_OCRRead = form.Controls.Find(OCRName + "Read_Tb", true).FirstOrDefault() as TextBox;
                if (Tb_OCRRead == null)
                {
                    return;
                }

                if (Tb_OCRRead.InvokeRequired)
                {
                    UpdateOCR ph = new UpdateOCR(UpdateOCRRead);
                    Tb_OCRRead.BeginInvoke(ph, OCRName, WaferID, Job);
                }
                else
                {
                    string save      = "";
                    string src       = "";
                    string OCRResult = WaferID;
                    if (WaferID.IndexOf("*") != -1)
                    {
                        WaferID = "Failed";
                    }
                    switch (OCRName)
                    {
                    case "OCR01":
                        save = SystemConfig.Get().OCR1ImgToJpgPath;
                        src  = SystemConfig.Get().OCR1ImgSourcePath;
                        break;

                    case "OCR02":
                        save = SystemConfig.Get().OCR2ImgToJpgPath;
                        src  = SystemConfig.Get().OCR2ImgSourcePath;
                        break;
                    }

                    Thread.Sleep(500);
                    Node OCR = NodeManagement.Get(OCRName);
                    if (OCR != null)
                    {
                        if (!Directory.Exists(save))
                        {
                            Directory.CreateDirectory(save);
                        }
                        string saveTmpPath = save + "/" + WaferID + "_" + DateTime.Now.ToString("yyyy_mm_dd_HH_MM_ss") + ".bmp";
                        string FileName    = WaferID + "_" + DateTime.Now.ToString("yyyy_mm_dd_HH_MM_ss") + ".jpg";
                        string savePath    = save + "/" + FileName;

                        if (savePath != "")
                        {
                            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_OCRRead.Text = info;
                                FTP        ftp     = new FTP("192.168.0.5", "21", "", "admin", "");
                                string     imgPath = ftp.Get("image.jpg", FileName, save);
                                PictureBox Pic_OCR = form.Controls.Find(OCRName + "_Pic", true).FirstOrDefault() as PictureBox;
                                if (Pic_OCR == null)
                                {
                                    return;
                                }
                                Bitmap t = new Bitmap(Image.FromFile(savePath), new Size(320, 240));
                                Pic_OCR.Image  = t;
                                Pic_OCR.Tag    = Job;
                                Job.OCRImgPath = savePath;
                                Job.OCRScore   = ocrResult[1];
                                ProcessRecord.updateSubstrateOCR(NodeManagement.Get(Job.FromPort).PrID, Job);
                                break;

                            case "HST":
                                ocrResult = OCRResult.Replace("[", "").Replace("]", "").Split(',');
                                WaferID   = ocrResult[0];
                                if (ocrResult.Length >= 2)
                                {
                                    WaferID += " Score:" + ocrResult[1];
                                }
                                else
                                {
                                    WaferID += " Score:0";
                                }
                                Tb_OCRRead.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))); });
                                    File.Copy(fileList[0], saveTmpPath);
                                    Image bmp = Image.FromFile(saveTmpPath);

                                    bmp.Save(savePath, System.Drawing.Imaging.ImageFormat.Jpeg);
                                    bmp.Dispose();
                                    Pic_OCR = form.Controls.Find(OCRName + "_Pic", true).FirstOrDefault() as PictureBox;
                                    File.Delete(saveTmpPath);
                                    if (Pic_OCR == null)
                                    {
                                        return;
                                    }
                                    t              = new Bitmap(Image.FromFile(savePath), new Size(320, 240));
                                    Pic_OCR.Image  = t;
                                    Pic_OCR.Tag    = Job;
                                    Job.OCRImgPath = savePath;
                                    Job.OCRScore   = ocrResult[1];
                                    ProcessRecord.updateSubstrateOCR(NodeManagement.Get(Job.FromPort).PrID, Job);
                                }
                                break;
                            }
                        }
                    }
                }
            }
            catch (Exception e)
            {
                logger.Error("UpdateOCRRead: Update fail.");
            }
        }
예제 #26
0
        private void AutoAssign_btn_Click(object sender, EventArgs e)
        {
            if (Source_cb.Text.Equals(To_cb.Text))
            {
                MessageBox.Show("Not support assign to the same loadport");
                return;
            }

            Node Loadport   = NodeManagement.Get(Source_cb.Text);
            Node UnLoadport = NodeManagement.Get(To_cb.Text);

            if (Loadport == null)
            {
                MessageBox.Show("Source loadport not found!");
                return;
            }
            if (UnLoadport == null)
            {
                MessageBox.Show("To loadport not found!");
                return;
            }
            var LD_Jobs = (from wafer in Loadport.JobList.Values
                           where wafer.MapFlag && !wafer.ErrPosition && wafer.Destination.Equals("")
                           select wafer).OrderByDescending(x => Convert.ToInt16(x.Slot));

            if (Recipe.Get(SystemConfig.Get().CurrentRecipe).get_slot_order.Equals("BOTTOM_UP"))
            {
                LD_Jobs = (from wafer in Loadport.JobList.Values
                           where wafer.MapFlag && !wafer.ErrPosition && wafer.Destination.Equals("")
                           select wafer).OrderBy(x => Convert.ToInt16(x.Slot));
            }

            int assignCnt = LD_Jobs.Count();


            bool isAssign = false;

            var ULD_Jobs = (from Slot in UnLoadport.JobList.Values
                            where !Slot.MapFlag && !Slot.ErrPosition && !Slot.IsAssigned
                            select Slot).OrderByDescending(x => Convert.ToInt16(x.Slot));

            if (Recipe.Get(SystemConfig.Get().CurrentRecipe).put_slot_order.Equals("BOTTOM_UP"))
            {
                ULD_Jobs = (from Slot in UnLoadport.JobList.Values
                            where !Slot.MapFlag && !Slot.ErrPosition && !Slot.IsAssigned
                            select Slot).OrderBy(x => Convert.ToInt16(x.Slot));
            }

            foreach (Job wafer in LD_Jobs)
            {//檢查LD的所有WAFER
                isAssign = false;
                foreach (Job Slot in ULD_Jobs)
                {     //搜尋所有FOSB Slot 找到能放的
                    if (Recipe.Get(SystemConfig.Get().CurrentRecipe).manual_put_constrict.Equals("1") && UnLoadport.CheckPreviousPresence(Slot.Slot) && Recipe.Get(SystemConfig.Get().CurrentRecipe).put_slot_order.Equals("TOP_DOWN"))
                    { //下一層有片所以不能放
                        Slot.Locked = true;
                    }
                    else if (Recipe.Get(SystemConfig.Get().CurrentRecipe).manual_put_constrict.Equals("2") && UnLoadport.CheckForwardPresence(Slot.Slot) && Recipe.Get(SystemConfig.Get().CurrentRecipe).put_slot_order.Equals("TOP_DOWN"))
                    {//下方所有都不能有片
                        Slot.Locked = true;
                    }
                    else
                    {
                        wafer.NeedProcess = true;
                        wafer.ProcessFlag = false;
                        wafer.AssignPort(UnLoadport.Name, Slot.Slot);
                        isAssign = true;

                        Slot.IsAssigned = true;
                        logger.Debug("Assign booktest2 from " + Loadport.Name + " slot:" + wafer.Slot + " to " + UnLoadport.Name + " slot:" + Slot.Slot);

                        break;
                    }
                }
                if (!isAssign)
                {
                    break;
                }
            }
            if (assignCnt != 0)
            {
                LD_Jobs = (from wafer in Loadport.JobList.Values
                           where wafer.NeedProcess && !wafer.IsReversed
                           select wafer).OrderByDescending(x => Convert.ToInt16(x.Slot));
                if (Recipe.Get(SystemConfig.Get().CurrentRecipe).get_slot_order.Equals("BOTTOM_UP"))
                {
                    LD_Jobs = (from wafer in Loadport.JobList.Values
                               where wafer.NeedProcess && !wafer.IsReversed
                               select wafer).OrderBy(x => Convert.ToInt16(x.Slot));
                }

                Node Rbt = NodeManagement.Get("ROBOT01");
                if (!Recipe.Get(SystemConfig.Get().CurrentRecipe).put_slot_order.Equals(Recipe.Get(SystemConfig.Get().CurrentRecipe).get_slot_order))
                {
                    if (Rbt.RArmActive && Rbt.LArmActive && Rbt.DoubleArmActive)
                    {
                        for (int i = 1; i < LD_Jobs.Count(); i = i + 2)
                        {//重新排序目的地for雙Arm
                            Job upper = LD_Jobs.ToList()[i];
                            Job lower = LD_Jobs.ToList()[i - 1];
                            if (upper.Destination.Equals(lower.Destination) && upper.NeedProcess && lower.NeedProcess && Math.Abs(Convert.ToInt16(upper.DestinationSlot) - Convert.ToInt16(lower.DestinationSlot)) == 1)
                            {//目的地Slot相鄰 才進來
                                string swapDes  = upper.Destination;
                                string swapSlot = upper.DestinationSlot;
                                upper.AssignPort(lower.Destination, lower.DestinationSlot);
                                lower.AssignPort(swapDes, swapSlot);
                                logger.Debug("Reverse booktest2 from " + Loadport.Name + " slot:" + upper.Slot + " to " + upper.Destination + " slot:" + upper.DestinationSlot);
                                logger.Debug("Reverse booktest2 from " + Loadport.Name + " slot:" + lower.Slot + " to " + upper.Destination + " slot:" + lower.DestinationSlot);
                                logger.Debug("Reverse booktest2 ---------- ");
                            }
                        }
                        foreach (Job each in Loadport.JobList.Values)
                        {
                            if (!each.Destination.Equals(""))
                            {
                                each.IsReversed = true;
                            }
                        }
                    }
                }
            }
            RefreshMap();
        }
예제 #27
0
        public void DoWork(Transaction orgTxn, bool WaitForData = false)
        {
            Transaction Txn = null;


            Txn = orgTxn;


            if (Txn.CommandEncodeStr.Equals("GetMappingDummy"))
            {
                string mappingData = "";
                if (Txn.NodeName.Equals("LOADPORT01"))
                {
                    //mappingData = "1111111111111111111111111";
                    mappingData = SystemConfig.Get().FakeDataP1;
                }
                else if (Txn.NodeName.Equals("LOADPORT02"))
                {
                    mappingData = SystemConfig.Get().FakeDataP2;
                }
                else if (Txn.NodeName.Equals("LOADPORT03"))
                {
                    mappingData = SystemConfig.Get().FakeDataP3;
                }
                else if (Txn.NodeName.Equals("LOADPORT04"))
                {
                    mappingData = SystemConfig.Get().FakeDataP4;
                }

                CommandReturnMessage cm = new CommandReturnMessage();
                //cm.CommandType = Transaction.Command.LoadPortType.GetMapping;
                cm.Value = mappingData;
                //Txn.Method= Transaction.Command.LoadPortType.GetMapping;
                _ReportTarget.On_Command_Excuted(NodeManagement.Get(Txn.NodeName), Txn, cm);
            }
            //conn.WaitForData(WaitForData);

            // lock (TransactionList)
            List <CommandReturnMessage> msgList = _Decoder.GetMessage(Txn.CommandEncodeStr);


            if (!Txn.NodeType.Equals("OCR"))
            {
                if (msgList.Count != 0)
                {
                    Txn.Type = msgList[0].Command;
                    //Txn.CommandType = msgList[0].CommandType;
                }
            }
            else
            {
                Txn.Type = "";
                //Txn.CommandType = "";
            }
            string key = "";

            if (Vendor.ToUpper().Equals("KAWASAKI"))
            {
                key = Txn.Seq;
            }
            if (DeviceType.ToUpper().Equals("SMARTTAG"))
            {
                key = "00";
            }
            else if (Vendor.ToUpper().Equals("HST") || Vendor.ToUpper().Equals("COGNEX"))
            {
                key = "1" + Txn.Type;
            }

            else if (Vendor.ToUpper().Equals("SANWA") || Vendor.ToUpper().Equals("ATEL_NEW"))
            {
                key = Txn.AdrNo + Txn.Type;
                //支援同時多發命令
                for (int seq = 0; seq <= 99; seq++)
                {
                    string tmpKey = key + seq.ToString("00");

                    if (!TransactionList.ContainsKey(tmpKey))
                    {
                        key = tmpKey;
                        break;
                    }
                    if (seq == 99)
                    {
                        logger.Error("seq is run out!");
                    }
                }
            }
            else
            {
                if (Vendor.ToUpper().Equals("SANWA_MC"))
                {
                    if (orgTxn.CommandEncodeStr.Contains("MCR:"))
                    {
                        Txn.CommandType = "CMD";
                    }
                    if (Txn.Method == Transaction.Command.LoadPortType.Reset)
                    {
                        key = "0";
                    }
                    else
                    {
                        key = Txn.AdrNo;
                    }
                    //}
                    //else
                    //{
                    //    key = "0" + msgList[0].Command;
                    //}
                }
                else
                {
                    key = Txn.AdrNo + Txn.Type;
                }
            }

            if (TransactionList.TryAdd(key, Txn) || Txn.Method.Equals("Stop"))
            {
                Txn.SetTimeOutReport(this);
                Txn.SetTimeOutMonitor(true);



                //if (Vendor.ToUpper().Equals("ACDT"))
                //{
                //    byte[] byteAry = Encoding.UTF8.GetBytes(Txn.CommandEncodeStr);


                //    logger.Debug(DeviceName + " Send:" + BitConverter.ToString(byteAry) + " Wafer:" + waferids);
                //}
                //else
                //{

                if (Txn.CommandType.Equals(""))
                {
                    Txn.CommandType = _Decoder.GetMessage(Txn.CommandEncodeStr)[0].CommandType;
                }
                //if (Txn.CommandType.Equals("GET") || Txn.CommandType.IndexOf("FS") != -1)
                //{

                //}
                if (Txn.Method.Equals(Transaction.Command.LoadPortType.Reset))
                {
                    Txn.SetTimeOut(15000);
                }
                else
                {
                    Txn.SetTimeOut(Txn.AckTimeOut);
                }
                try
                {
                    //logger.Info(DeviceName + " Send:" + Txn.CommandEncodeStr.Replace("\r", ""));
                    //if (!this.Vendor.ToUpper().Equals("MITSUBISHI_PLC"))
                    //{
                    //    _ReportTarget.On_Message_Log("CMD", DeviceName + " Send:" + Txn.CommandEncodeStr.Replace("\r", ""));
                    //}
                    //if (this.Vendor.Equals("SMARTTAG8200") || this.Vendor.Equals("SMARTTAG8400"))
                    //{
                    //    //if (Txn.Method == Transaction.Command.SmartTagType.GetLCDData)
                    //    //{
                    //    //    conn.WaitForData(true);
                    //    //}
                    //    ThreadPool.QueueUserWorkItem(new WaitCallback(conn.SendHexData), Txn.CommandEncodeStr);

                    //}
                    //else
                    //{

                    //    ThreadPool.QueueUserWorkItem(new WaitCallback(conn.Send), Txn.CommandEncodeStr);
                    //}
                    if (Txn.NodeName.ToUpper().Equals("SMIF1"))
                    {
                        ch1Send = Txn.CommandEncodeStr;
                    }
                    else if (Txn.NodeName.ToUpper().Equals("SMIF2"))
                    {
                        ch2Send = Txn.CommandEncodeStr;
                    }
                }
                catch (Exception eex)
                {
                    logger.Error(eex.StackTrace);
                    _ReportTarget.On_Message_Log("CMD", DeviceName + " Err:" + eex.StackTrace);
                    Txn.SetTimeOutMonitor(false);
                    Transaction tmp;
                    TransactionList.TryRemove(key, out tmp);
                    CommandReturnMessage rm = new CommandReturnMessage();
                    rm.Value = "ConnectionError";
                    _ReportTarget.On_Command_Error(NodeManagement.Get(Txn.NodeName), Txn, rm);
                }
            }
            else
            {
                Transaction workingTxn;
                TransactionList.TryRemove(key, out workingTxn);
                logger.Debug(DeviceName + "(DoWork " + IPAdress + ":" + Port.ToString() + ":" + Txn.CommandEncodeStr + ") Same type command " + workingTxn.CommandEncodeStr + " is already excuting.");
                _ReportTarget.On_Message_Log("CMD", DeviceName + "(DoWork " + IPAdress + ":" + Port.ToString() + ":" + Txn.CommandEncodeStr + ") Same type command " + workingTxn.CommandEncodeStr + " is already excuting.");
                Txn.SetTimeOutMonitor(false);
                CommandReturnMessage rm = new CommandReturnMessage();
                rm.Value = "AlreadyExcuting";
                _ReportTarget.On_Command_Error(NodeManagement.Get(Txn.NodeName), Txn, rm);
            }
        }
예제 #28
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            string        strSql                  = string.Empty;
            StringBuilder sbErrorMessage          = new StringBuilder();
            Dictionary <string, object> keyValues = new Dictionary <string, object>();
            DBUtil    dBUtil = new DBUtil();
            DataTable dtTemp = new DataTable();

            DataRow[] drsTemp;

            try
            {
                if (txbDeviceNodeName.Text.Trim().Equals(string.Empty) &&
                    cmbDeviceNodeType.SelectedIndex == -1 &&
                    nudSerialNo.Value == 0 &&
                    cmbVendor.SelectedIndex == -1 &&
                    txbModel.Text.Trim().Equals(string.Empty) &&
                    txbFirmwareVersion.Text.Trim().Equals(string.Empty) &&
                    txbAddress.Text.Trim().Equals(string.Empty) &&
                    txbControllerID.Text.Trim().Equals(string.Empty)
                    )
                {
                    MessageBox.Show("Miss input data in the form.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
                    return;
                }

                if (txbDeviceNodeName.Text.Trim().Equals(string.Empty) ||
                    cmbDeviceNodeType.SelectedIndex == -1 || cmbVendor.SelectedIndex == -1)
                {
                    MessageBox.Show("Miss input data in the form.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
                    return;
                }

                strSql = "select * from config_node where equipment_model_id = @equipment_model_id and node_type = @node_type order by node_id, sn_no";
                keyValues.Add("@equipment_model_id", SystemConfig.Get().SystemMode);
                keyValues.Add("@node_type", cmbDeviceNodeType.SelectedValue.ToString());
                dtTemp = dBUtil.GetDataTable(strSql, keyValues);

                if (dtTemp.Rows.Count > 0)
                {
                    if (dtTemp.Select("node_id in ('" + txbDeviceNodeName.Tag + "','" + cmbDeviceNodeType.Text + Convert.ToInt32(nudSerialNo.Value).ToString("D2") + "')").Length > 0)
                    {
                        sbErrorMessage.Append("Node ID exist.");
                        sbErrorMessage.AppendLine();
                    }

                    if (dtTemp.Select("sn_no = " + Convert.ToInt32(nudSerialNo.Value).ToString()).Length > 0)
                    {
                        sbErrorMessage.Append("Serial No exist.");
                        sbErrorMessage.AppendLine();
                    }

                    if (dtTemp.Select("controller_id = '" + txbControllerID.Text + "'").Length > 0)
                    {
                        sbErrorMessage.Append("Controller ID exist.");
                        sbErrorMessage.AppendLine();
                    }
                }

                if (sbErrorMessage.ToString().Length > 0)
                {
                    if (MessageBox.Show(sbErrorMessage.ToString() + "\r\n Do you want to overwrite???", "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1) == DialogResult.No)
                    {
                        return;
                    }
                }

                keyValues.Clear();

                strSql = "REPLACE INTO config_node " +
                         "(equipment_model_id, node_id, node_type, sn_no, vendor, model_no, firmware_ver, conn_address, controller_id, bypass, default_aligner, alternative_aligner, route_table, enable_flg, create_user, create_timestamp, modify_user, modify_timestamp) " +
                         "VALUES " +
                         "(@equipment_model_id, @node_id, @node_type, @sn_no, @vendor, @model_no, @firmware_ver, @conn_address, @controller_id, @bypass, @default_aligner, @alternative_aligner, @route_table, @enable_flg, @create_user, @create_timestamp, @modify_user, NOW())";

                keyValues.Add("@equipment_model_id", SystemConfig.Get().SystemMode);
                keyValues.Add("@node_id", txbDeviceNodeName.Text.Trim());
                keyValues.Add("@node_type", cmbDeviceNodeType.SelectedValue.ToString());
                keyValues.Add("@sn_no", nudSerialNo.Value);
                keyValues.Add("@vendor", cmbVendor.SelectedValue.ToString());
                keyValues.Add("@model_no", txbModel.Text.Trim());
                keyValues.Add("@firmware_ver", txbFirmwareVersion.Text.Trim());
                keyValues.Add("@conn_address", txbAddress.Text.Trim());
                keyValues.Add("@controller_id", txbControllerID.Text.Trim());
                keyValues.Add("@enable_flg", chbActive.Checked ? 1 : 0);
                keyValues.Add("@default_aligner", txbDefaultAligner.Text.Trim());
                keyValues.Add("@alternative_aligner", txbAlternativeAligner.Text.Trim());
                keyValues.Add("@route_table", JsonConvert.SerializeObject(dtRouteTable, Formatting.Indented).Replace("\r\n", string.Empty));
                keyValues.Add("@bypass", chbByPass.Checked ? 1 : 0);

                drsTemp = dtTemp.Select("node_id = '" + cmbDeviceNodeType.Text + Convert.ToInt32(nudSerialNo.Value).ToString("D2") + "'");
                Form  form   = Application.OpenForms["FormMain"];
                Label Signal = form.Controls.Find("lbl_login_id", true).FirstOrDefault() as Label;

                if (drsTemp.Length > 0)
                {
                    keyValues.Add("@create_user", drsTemp[0]["create_user"].ToString());
                    keyValues.Add("@create_timestamp", Convert.ToDateTime(drsTemp[0]["create_timestamp"].ToString()).ToString("yyyy-MM-dd HH:mm:ss"));
                }
                else
                {
                    keyValues.Add("@create_user", Signal.Text);
                    strSql = strSql.Replace("@create_timestamp", "NOW()");
                }

                keyValues.Add("@modify_user", Signal.Text);

                dBUtil.ExecuteNonQuery(strSql, keyValues);
                MessageBox.Show("Done it.", "Save", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);

                Lilith.Util.SanwaUtil.addActionLog("Adam.Menu.SystemSetting", "FormCpmmandScript", Signal.Text);

                UpdateNodeList();
                ClearUI();

                //改設定後套用
                NodeManagement.LoadConfig();
                if (cmbDeviceNodeType.Text.Equals("OCR"))
                {
                    OCRUpdate.AssignForm();
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.ToString());
            }
        }
예제 #29
0
        //public static void UpdateOCRM12Read(string OCRName, string WaferID, Job Job)
        //{
        //    try
        //    {
        //        Form form = Application.OpenForms["FormMonitoring"];
        //        TextBox Tb_OCRRead;
        //        if (form == null)
        //            return;

        //        Tb_OCRRead = form.Controls.Find(OCRName + "Read_Tb", true).FirstOrDefault() as TextBox;
        //        if (Tb_OCRRead == null)
        //            return;

        //        if (Tb_OCRRead.InvokeRequired)
        //        {
        //            UpdateOCR ph = new UpdateOCR(UpdateOCRM12Read);
        //            Tb_OCRRead.BeginInvoke(ph, OCRName, WaferID, Job);
        //        }
        //        else
        //        {
        //            string save = "";
        //            string src = "";
        //            string OCRResult = WaferID;
        //            if (WaferID.IndexOf("*") != -1)
        //            {
        //                WaferID = "Failed";
        //            }
        //            switch (OCRName)
        //            {
        //                case "OCR01":
        //                    save = SystemConfig.Get().OCR1ImgToJpgPath;
        //                    src = SystemConfig.Get().OCR1ImgSourcePath;
        //                    break;
        //                case "OCR02":
        //                    save = SystemConfig.Get().OCR2ImgToJpgPath;
        //                    src = SystemConfig.Get().OCR2ImgSourcePath;
        //                    break;
        //            }
        //            save += "/" + DateTime.Now.ToString("yyyyMMdd") + "/" + Job.FromFoupID;
        //            Thread.Sleep(500);
        //            Node OCR = NodeManagement.Get(OCRName);
        //            if (OCR != null)
        //            {

        //                if (!Directory.Exists(save))
        //                {
        //                    Directory.CreateDirectory(save);
        //                }
        //                string saveTmpPath = save + "/" + WaferID + "_" + DateTime.Now.ToString("yyyyMMdd_HHmmss") + ".bmp";
        //                string FileName = WaferID + "_" + DateTime.Now.ToString("yyyyMMdd_HHmmss") + "_M12.jpg";
        //                string savePath = save + "/" + FileName;

        //                if (savePath != "")
        //                {
        //                    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_OCRRead.Text = info;
        //                            FTP ftp = new FTP(OCR.GetController().GetIPAdress(), "21", "", "admin", "");
        //                            string imgPath = ftp.Get("image.jpg", FileName, save);
        //                            PictureBox Pic_OCR = form.Controls.Find(OCRName + "_Pic", true).FirstOrDefault() as PictureBox;
        //                            if (Pic_OCR == null)
        //                                return;
        //                            Bitmap t = new Bitmap(Image.FromFile(savePath), new Size(320, 240));
        //                            Pic_OCR.Image = t;
        //                            Pic_OCR.Tag = Job;
        //                            Job.OCR_M12_ImgPath = savePath;
        //                            Job.OCR_M12_Score = ocrResult[1];
        //                            ProcessRecord.updateSubstrateOCR(NodeManagement.Get(Job.FromPort).PrID, Job);
        //                            break;
        //                        case "HST":
        //                            ocrResult = OCRResult.Replace("[", "").Replace("]", "").Split(',');
        //                            WaferID = ocrResult[0];
        //                            if (ocrResult.Length >= 2)
        //                            {
        //                                WaferID += " Score:" + ocrResult[1];
        //                            }
        //                            else
        //                            {
        //                                WaferID += " Score:0";
        //                            }
        //                            Tb_OCRRead.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)); });

        //                                File.Copy(fileList[0], saveTmpPath);
        //                                Image bmp = Image.FromFile(saveTmpPath);

        //                                bmp.Save(savePath, System.Drawing.Imaging.ImageFormat.Jpeg);
        //                                bmp.Dispose();
        //                                Pic_OCR = form.Controls.Find(OCRName + "_Pic", true).FirstOrDefault() as PictureBox;
        //                                File.Delete(saveTmpPath);
        //                                if (Pic_OCR == null)
        //                                    return;
        //                                t = new Bitmap(Image.FromFile(savePath), new Size(320, 240));
        //                                Pic_OCR.Image = t;
        //                                if (Pic_OCR.Tag != null)
        //                                {
        //                                    if (!Pic_OCR.Tag.Equals(Job))
        //                                    {//不同片
        //                                        TextBox tb = form.Controls.Find(OCRName + "ReadT7_Tb", true).FirstOrDefault() as TextBox;
        //                                        tb.Text = "";
        //                                    }
        //                                }
        //                                Pic_OCR.Tag = Job;
        //                                Job.OCR_M12_ImgPath = savePath;
        //                                Job.OCR_M12_Score = ocrResult[1];
        //                                ProcessRecord.updateSubstrateOCR(NodeManagement.Get(Job.FromPort).PrID, Job);
        //                            }
        //                            break;
        //                    }

        //                }
        //            }
        //        }


        //    }
        //    catch (Exception e)
        //    {
        //        logger.Error("UpdateOCRM12Read: Update fail.");
        //    }
        //}
        //public static void UpdateOCRT7Read(string OCRName, string WaferID, Job Job)
        //{
        //    try
        //    {
        //        Form form = Application.OpenForms["FormMonitoring"];
        //        TextBox Tb_OCRRead;
        //        if (form == null)
        //            return;

        //        Tb_OCRRead = form.Controls.Find(OCRName + "ReadT7_Tb", true).FirstOrDefault() as TextBox;
        //        if (Tb_OCRRead == null)
        //            return;

        //        if (Tb_OCRRead.InvokeRequired)
        //        {
        //            UpdateOCR ph = new UpdateOCR(UpdateOCRT7Read);
        //            Tb_OCRRead.BeginInvoke(ph, OCRName, WaferID, Job);
        //        }
        //        else
        //        {
        //            string save = "";
        //            string src = "";
        //            string OCRResult = WaferID;
        //            if (WaferID.IndexOf("*") != -1)
        //            {
        //                WaferID = "Failed";
        //            }
        //            switch (OCRName)
        //            {
        //                case "OCR01":
        //                    save = SystemConfig.Get().OCR1ImgToJpgPath;
        //                    src = SystemConfig.Get().OCR1ImgSourcePath;
        //                    break;
        //                case "OCR02":
        //                    save = SystemConfig.Get().OCR2ImgToJpgPath;
        //                    src = SystemConfig.Get().OCR2ImgSourcePath;
        //                    break;
        //            }
        //            save += "/"+ DateTime.Now.ToString("yyyyMMdd") + "/" + Job.FromFoupID;
        //            Thread.Sleep(500);
        //            Node OCR = NodeManagement.Get(OCRName);
        //            if (OCR != null)
        //            {

        //                if (!Directory.Exists(save))
        //                {
        //                    Directory.CreateDirectory(save);
        //                }
        //                string saveTmpPath = save + "/" + WaferID + "_" + DateTime.Now.ToString("yyyyMMdd_HHmmss") + ".bmp";
        //                string FileName = WaferID + "_" + DateTime.Now.ToString("yyyyMMdd_HHmmss") + "_T7.jpg";
        //                string savePath = save + "/" + FileName;

        //                if (savePath != "")
        //                {
        //                    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_OCRRead.Text = info;
        //                            FTP ftp = new FTP(OCR.GetController().GetIPAdress(), "21", "", "admin", "");
        //                            string imgPath = ftp.Get("image.jpg", FileName, save);
        //                            PictureBox Pic_OCR = form.Controls.Find(OCRName + "_Pic", true).FirstOrDefault() as PictureBox;
        //                            if (Pic_OCR == null)
        //                                return;
        //                            Bitmap t = new Bitmap(Image.FromFile(savePath), new Size(320, 240));
        //                            Pic_OCR.Image = t;
        //                            Pic_OCR.Tag = Job;
        //                            Job.OCR_T7_ImgPath = savePath;
        //                            Job.OCR_T7_Score = ocrResult[1];
        //                            ProcessRecord.updateSubstrateOCR(NodeManagement.Get(Job.FromPort).PrID, Job);
        //                            break;
        //                        case "HST":
        //                            ocrResult = OCRResult.Replace("[", "").Replace("]", "").Split(',');
        //                            WaferID = ocrResult[0];
        //                            if (ocrResult.Length >= 2)
        //                            {
        //                                WaferID += " Score:" + ocrResult[1];
        //                            }
        //                            else
        //                            {
        //                                WaferID += " Score:0";
        //                            }
        //                            Tb_OCRRead.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)); });

        //                                File.Copy(fileList[0], saveTmpPath);
        //                                Image bmp = Image.FromFile(saveTmpPath);

        //                                bmp.Save(savePath, System.Drawing.Imaging.ImageFormat.Jpeg);
        //                                bmp.Dispose();
        //                                Pic_OCR = form.Controls.Find(OCRName + "_Pic", true).FirstOrDefault() as PictureBox;
        //                                File.Delete(saveTmpPath);
        //                                if (Pic_OCR == null)
        //                                    return;
        //                                t = new Bitmap(Image.FromFile(savePath), new Size(320, 240));
        //                                Pic_OCR.Image = t;
        //                                if (Pic_OCR.Tag != null)
        //                                {
        //                                    if (!Pic_OCR.Tag.Equals(Job))
        //                                    {//不同片
        //                                        TextBox tb = form.Controls.Find(OCRName + "Read_Tb", true).FirstOrDefault() as TextBox;
        //                                        tb.Text = "";
        //                                    }
        //                                }
        //                                Pic_OCR.Tag = Job;
        //                                Job.OCR_T7_ImgPath = savePath;
        //                                Job.OCR_T7_Score = ocrResult[1];
        //                                ProcessRecord.updateSubstrateOCR(NodeManagement.Get(Job.FromPort).PrID, Job);
        //                            }
        //                            break;
        //                    }

        //                }
        //            }
        //        }


        //    }
        //    catch (Exception e)
        //    {
        //        logger.Error("UpdateOCRT7Read: Update fail.");
        //    }
        //}
        public static void UpdateOCRReadXML(string OCRName, OCRInfo OcrResult, Job Job)
        {
            try
            {
                Form    form = Application.OpenForms["FormMonitoring"];
                TextBox Tb_OCRRead;
                if (form == null)
                {
                    return;
                }


                string TbName = OCRName;
                switch (OcrResult.ResultID)
                {
                case "0":
                    TbName += "Read_Tb";
                    break;

                case "1":
                    TbName += "ReadT7_Tb";
                    break;
                }

                Tb_OCRRead = form.Controls.Find(TbName, true).FirstOrDefault() as TextBox;
                if (Tb_OCRRead == null)
                {
                    return;
                }

                if (Tb_OCRRead.InvokeRequired)
                {
                    UpdateOCRInfo ph = new UpdateOCRInfo(UpdateOCRReadXML);
                    Tb_OCRRead.BeginInvoke(ph, OCRName, OcrResult, Job);
                }
                else
                {
                    string save   = "";
                    string src    = "";
                    string Result = "";

                    if (OcrResult.Passed.Equals("0"))
                    {
                        Result = "Failed";
                    }
                    else
                    {
                        Result = OcrResult.Result + "_" + OcrResult.Score;
                    }
                    switch (OCRName)
                    {
                    case "OCR01":
                        save = SystemConfig.Get().OCR1ImgToJpgPath;
                        src  = SystemConfig.Get().OCR1ImgSourcePath;
                        break;

                    case "OCR02":
                        save = SystemConfig.Get().OCR2ImgToJpgPath;
                        src  = SystemConfig.Get().OCR2ImgSourcePath;
                        break;
                    }

                    Thread.Sleep(500);
                    Node OCR = NodeManagement.Get(OCRName);
                    if (OCR != null)
                    {
                        if (!Directory.Exists(save))
                        {
                            Directory.CreateDirectory(save);
                        }
                        string saveTmpPath = save + "/" + Result + "_" + DateTime.Now.ToString("yyyy_mm_dd_HH_MM_ss") + ".bmp";
                        string FileName    = Result + "_" + DateTime.Now.ToString("yyyy_mm_dd_HH_MM_ss") + ".jpg";
                        string savePath    = save + "/" + FileName;

                        if (savePath != "")
                        {
                            switch (OCR.Brand)
                            {
                            case "HST":

                                Tb_OCRRead.Text = OcrResult.Result + " Score:" + OcrResult.Score;

                                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))); });
                                    File.Copy(fileList[0], saveTmpPath);
                                    Image bmp = Image.FromFile(saveTmpPath);

                                    bmp.Save(savePath, System.Drawing.Imaging.ImageFormat.Jpeg);
                                    bmp.Dispose();
                                    PictureBox Pic_OCR = form.Controls.Find(OCRName + "_Pic", true).FirstOrDefault() as PictureBox;
                                    File.Delete(saveTmpPath);
                                    if (Pic_OCR == null)
                                    {
                                        return;
                                    }
                                    Bitmap t = new Bitmap(Image.FromFile(savePath), new Size(320, 240));
                                    Pic_OCR.Image  = t;
                                    Pic_OCR.Tag    = Job;
                                    Job.OCRImgPath = savePath;
                                    if (Job.FromPort != null)
                                    {
                                        ProcessRecord.updateSubstrateOCR(NodeManagement.Get(Job.FromPort).PrID, Job);
                                    }
                                }
                                break;
                            }
                        }
                    }
                }
            }
            catch (Exception e)
            {
                logger.Error("UpdateOCRRead: Update fail." + e.StackTrace);
            }
        }