private void FormWaferMapping_Load(object sender, EventArgs e) { Form form = this; foreach (Node port in NodeManagement.GetLoadPortList()) { for (int i = 1; i <= 25; i++) { Label present = form.Controls.Find(port.Name + "_Slot_" + i.ToString(), true).FirstOrDefault() as Label; if (present != null) { switch (port.CarrierType.ToUpper()) { case "FOSB": case "FOUP": present.Visible = true; break; case "OPEN": if (i > 13) { present.Visible = false; } else { present.Visible = true; } break; } } } } Node al2 = NodeManagement.Get("ALIGNER02"); if (al2 != null) { OCR02_pl.Visible = true; Aligner02_pl.Visible = true; } }
private void Slot_Click(object sender, EventArgs e) { Label Slot_Label = (Label)sender; string PortName = Slot_Label.Name.Substring(0, Slot_Label.Name.IndexOf("_Slot")).ToUpper(); string SlotNo = Slot_Label.Name.Substring(Slot_Label.Name.IndexOf("_Slot") + 6); Node port = NodeManagement.Get(PortName); Job s; if (!port.JobList.TryGetValue(SlotNo, out s)) { return; } if ((PortName.Equals(fromPort) && SlotNo.Equals(fromSlot) && toPort.Equals("") && toSlot.Equals("")) || (fromPort.Equals("") && fromSlot.Equals(""))) {//選擇來源slot if (s.MapFlag && !s.ErrPosition) { if (Slot_Label.BackColor == Color.SkyBlue) { // 取消選擇來源slot if (s.Destination.Equals("") && s.DestinationSlot.Equals("")) { //還沒選 Slot_Label.BackColor = Color.Green; Slot_Label.ForeColor = Color.White; } else {//已選 Slot_Label.BackColor = Color.Brown; Slot_Label.ForeColor = Color.White; } fromPort = ""; fromSlot = ""; Form form = Application.OpenForms["FormWaferMapping"]; foreach (Node p in NodeManagement.GetLoadPortList())//更新所有目的地slot被選的狀態 { if (p.Enable && p.IsMapping) { foreach (Job eachSlot in p.JobList.Values) { if (!eachSlot.MapFlag && !eachSlot.ErrPosition)//找到空slot { Label present = form.Controls.Find(p.Name + "_Slot_" + eachSlot.Slot, true).FirstOrDefault() as Label; if (present != null) { if (eachSlot.ReservePort.Equals("") && eachSlot.ReserveSlot.Equals("")) {//沒被選 present.BackColor = Color.DimGray; present.ForeColor = Color.White; } else {//已被選 present.BackColor = Color.Brown; present.ForeColor = Color.White; } } } } } } } else {// 選擇來源 Form form = Application.OpenForms["FormWaferMapping"]; Job lastSlot; if (!bypass) { foreach (Node p in NodeManagement.GetLoadPortList()) //標記不能選的位置 { if (p.Enable && p.IsMapping) { foreach (Job eachSlot in p.JobList.Values) { if (eachSlot.MapFlag && !eachSlot.ErrPosition) { //只能由下往上取,標記不能取的Wafer if (p.JobList.TryGetValue((Convert.ToInt16(eachSlot.Slot) - 1).ToString(), out lastSlot)) { if ((lastSlot.MapFlag && lastSlot.Destination.Equals("")) || (!lastSlot.MapFlag && !lastSlot.ReservePort.Equals(""))) { Label present = form.Controls.Find(p.Name + "_Slot_" + eachSlot.Slot, true).FirstOrDefault() as Label; if (present != null) {//把不能取的slot標記 present.ForeColor = Color.Red; } } } } } } } //判斷能不能選,不能選就跳脫 Node pt = NodeManagement.Get(PortName); if (pt.JobList.TryGetValue((Convert.ToInt16(SlotNo) - 1).ToString(), out lastSlot)) { if ((lastSlot.MapFlag && lastSlot.Destination.Equals("")) || (!lastSlot.MapFlag && !lastSlot.ReservePort.Equals(""))) { Label present = form.Controls.Find(pt.Name + "_Slot_" + SlotNo, true).FirstOrDefault() as Label; if (present != null) { return; } } } } //標記選定來源 Slot_Label.BackColor = Color.SkyBlue; Slot_Label.ForeColor = Color.White; fromPort = PortName; fromSlot = SlotNo; foreach (Node p in NodeManagement.GetLoadPortList()) //標記能放的位置 { if (p.Enable && p.IsMapping) { foreach (Job eachSlot in p.JobList.Values) { if (!eachSlot.MapFlag && !eachSlot.ErrPosition) {//找到空slot Label present = form.Controls.Find(p.Name + "_Slot_" + eachSlot.Slot, true).FirstOrDefault() as Label; if (present != null) { if (eachSlot.ReservePort.Equals("") && eachSlot.ReserveSlot.Equals("")) {//該空slot沒被預約 if (!bypass) { Job nextSlot = null; if (p.JobList.TryGetValue((Convert.ToInt16(eachSlot.Slot) - 1).ToString(), out nextSlot)) { if (!nextSlot.ReservePort.Equals("")) { continue;//判斷是否能從上往下放的SLOT,不能放的話就不標記 } } } present.BackColor = Color.White; present.ForeColor = Color.Black; } else { //該slot已被選定 if (eachSlot.ReservePort.ToUpper().Equals(fromPort.ToUpper()) && eachSlot.ReserveSlot.ToUpper().Equals(fromSlot.ToUpper())) { //被目前選擇的來源綁定 present.BackColor = Color.Yellow; present.ForeColor = Color.Black; toPort = eachSlot.Position; toSlot = eachSlot.Slot; } else {//被其他綁定 present.BackColor = Color.Brown; present.ForeColor = Color.White; } } } } } } } } } } else if ((PortName.Equals(toPort) && SlotNo.Equals(toSlot)) || (toPort.Equals("") && toSlot.Equals(""))) {//select to //判斷可不可以選 Job lastSlot; Form form = Application.OpenForms["FormWaferMapping"]; if (!bypass) { Node pt = NodeManagement.Get(PortName); //只能由上往下放 if (pt.JobList.TryGetValue((Convert.ToInt16(SlotNo) - 1).ToString(), out lastSlot)) { if (!lastSlot.ReservePort.Equals("")) { Label present = form.Controls.Find(pt.Name + "_Slot_" + SlotNo, true).FirstOrDefault() as Label; if (present != null) { return;//如果下面的slot有東西,跳脫不給選 } } } } if (!s.MapFlag && !s.ErrPosition) { if (Slot_Label.BackColor == Color.Yellow) {// 取消選擇目的地 Slot_Label.BackColor = Color.White; Slot_Label.ForeColor = Color.Black; Node fPort = NodeManagement.Get(fromPort); if (fPort != null) { Job fSlot; if (fPort.JobList.TryGetValue(fromSlot, out fSlot)) { fSlot.UnAssignPort();//取消綁定 } } if (!bypass) { Node tPort = NodeManagement.Get(toPort); if (tPort != null) { Job tSlot; if (tPort.JobList.TryGetValue((Convert.ToInt16(toSlot) + 1).ToString(), out tSlot)) { Label present = form.Controls.Find(toPort + "_Slot_" + (Convert.ToInt16(toSlot) + 1).ToString(), true).FirstOrDefault() as Label; if (!tSlot.MapFlag && !tSlot.ErrPosition && tSlot.ReservePort.Equals("")) {//如果上一層還沒被指派,標記為可被選 present.BackColor = Color.White; present.ForeColor = Color.Black; } else if (tSlot.MapFlag && !tSlot.ErrPosition && tSlot.Destination.Equals("")) {//如果上一層還沒被指派,標記為可被選 if (!tSlot.Slot.Equals(fromSlot) || !port.Name.ToUpper().Equals(fromPort)) { present.BackColor = Color.Green; present.ForeColor = Color.White; } } } } } foreach (Node p in NodeManagement.GetLoadPortList()) { if (p.Enable && p.IsMapping) { foreach (Job eachSlot in p.JobList.Values) { if (eachSlot.MapFlag && !eachSlot.ErrPosition) { //只能由下往上取,標記能取的Wafer if (p.JobList.TryGetValue((Convert.ToInt16(eachSlot.Slot) - 1).ToString(), out lastSlot)) { Label present = form.Controls.Find(p.Name + "_Slot_" + eachSlot.Slot, true).FirstOrDefault() as Label; if (present != null) { if (((lastSlot.MapFlag && lastSlot.Destination.Equals("")) || (!lastSlot.MapFlag && !lastSlot.ReservePort.Equals(""))) && !bypass) { //下面一層Slot未被選,則標記為不可選 present.ForeColor = Color.Red; } else { //標記可選 present.ForeColor = Color.White; } } } } } } } toPort = ""; toSlot = ""; } else if (s.ReservePort.Equals("") && s.ReserveSlot.Equals("")) {// not select Slot_Label.BackColor = Color.Yellow; Slot_Label.ForeColor = Color.Black; toPort = PortName; toSlot = SlotNo; Node fPort = NodeManagement.Get(fromPort); if (fPort != null) { Job fSlot; if (fPort.JobList.TryGetValue(fromSlot, out fSlot)) { fSlot.AssignPort(toPort, toSlot); Label present = form.Controls.Find(fromPort + "_Slot_" + fromSlot.ToString(), true).FirstOrDefault() as Label; present.Text += ""; } } if (!bypass) { Node tPort = NodeManagement.Get(toPort);//如果上一層還沒被指派,標記為不可被選 if (tPort != null) { Job tSlot; if (tPort.JobList.TryGetValue((Convert.ToInt16(toSlot) + 1).ToString(), out tSlot)) { Label present = form.Controls.Find(toPort + "_Slot_" + (Convert.ToInt16(toSlot) + 1).ToString(), true).FirstOrDefault() as Label; if (!tSlot.MapFlag && !tSlot.ErrPosition && tSlot.ReservePort.Equals("")) { present.BackColor = Color.DimGray; present.ForeColor = Color.White; } else if (tSlot.MapFlag && !tSlot.ErrPosition && tSlot.Destination.Equals("")) { present.BackColor = Color.Green; present.ForeColor = Color.White; } } } foreach (Node p in NodeManagement.GetLoadPortList()) { if (p.Enable && p.IsMapping) { foreach (Job eachSlot in p.JobList.Values) { if (p.Name.ToUpper().Equals(fromPort.ToUpper()) && eachSlot.Slot.Equals(fromSlot)) { continue; } if (eachSlot.MapFlag && !eachSlot.ErrPosition) { //只能由下往上取,標記能取的Wafer if (p.JobList.TryGetValue((Convert.ToInt16(eachSlot.Slot) - 1).ToString(), out lastSlot)) { Label present = form.Controls.Find(p.Name + "_Slot_" + eachSlot.Slot, true).FirstOrDefault() as Label; if (present != null) { if (((lastSlot.MapFlag && lastSlot.Destination.Equals("")) || (!lastSlot.MapFlag && !lastSlot.ReservePort.Equals("")))) { present.ForeColor = Color.Red; } else { present.ForeColor = Color.White; } } } } } } } } } } } else if (s.MapFlag && !s.ErrPosition && !(PortName.Equals(fromPort) && SlotNo.Equals(fromSlot))) {//已經選完來源根目的後,點另一個來源 //reset all from slot Job lastSlot; Form form = Application.OpenForms["FormWaferMapping"]; if (!bypass) { //判斷能不能選 Node pt = NodeManagement.Get(PortName); //只能由下往上取,標記能取的Wafer if (pt.JobList.TryGetValue((Convert.ToInt16(SlotNo) - 1).ToString(), out lastSlot)) { if ((lastSlot.MapFlag && lastSlot.Destination.Equals("")) || (!lastSlot.MapFlag && !lastSlot.ReservePort.Equals(""))) { Label present = form.Controls.Find(pt.Name + "_Slot_" + SlotNo, true).FirstOrDefault() as Label; if (present != null) { return; } } } } foreach (Node p in NodeManagement.GetLoadPortList()) { if (p.Enable && p.IsMapping) { foreach (Job eachSlot in p.JobList.Values) { if (eachSlot.MapFlag && !eachSlot.ErrPosition) { Label present = form.Controls.Find(p.Name + "_Slot_" + eachSlot.Slot, true).FirstOrDefault() as Label; if (present != null) { if (eachSlot.Destination.Equals("") && eachSlot.DestinationSlot.Equals("")) { present.BackColor = Color.Green; if (!bypass) { //只能由下往上取,標記能取的Wafer if (p.JobList.TryGetValue((Convert.ToInt16(eachSlot.Slot) - 1).ToString(), out lastSlot)) { if (present != null) { if (((lastSlot.MapFlag && lastSlot.Destination.Equals("")) || (!lastSlot.MapFlag && !lastSlot.ReservePort.Equals(""))) && !bypass) { present.ForeColor = Color.Red; } else { present.ForeColor = Color.White; } } } } } else { present.BackColor = Color.Brown; present.ForeColor = Color.White; } } } } } } if (!s.Destination.Equals("") && !s.DestinationSlot.Equals(""))//選到的是已綁定的slot { Slot_Label.BackColor = Color.SkyBlue; Slot_Label.ForeColor = Color.White; fromPort = PortName; fromSlot = SlotNo; //Form form = Application.OpenForms["FormWaferMapping"]; foreach (Node p in NodeManagement.GetLoadPortList()) { if (p.Enable && p.IsMapping) { foreach (Job eachSlot in p.JobList.Values) { if (!eachSlot.MapFlag && !eachSlot.ErrPosition) {//找到空slot Label present = form.Controls.Find(p.Name + "_Slot_" + eachSlot.Slot, true).FirstOrDefault() as Label; if (present != null) { if (eachSlot.ReservePort.Equals("") && eachSlot.ReserveSlot.Equals("")) {//這個空slot還沒被綁定 Job nextSlot; if (p.JobList.TryGetValue((Convert.ToInt16(eachSlot.Slot) - 1).ToString(), out nextSlot)) { Form tform = Application.OpenForms["FormWaferMapping"]; //Label tpresent = form.Controls.Find(p.Name + "_Slot_" + nextSlot.Slot, true).FirstOrDefault() as Label; if (!nextSlot.ReservePort.Equals("") && !bypass) {//下層slot已被綁定 if (nextSlot.ReservePort.Equals("")) { present.BackColor = Color.White; present.ForeColor = Color.Black; } else {//下層已被綁定,限制放片 present.BackColor = Color.DimGray; present.ForeColor = Color.White; } } else {//bypass present.BackColor = Color.White; present.ForeColor = Color.Black; } } } else { if (eachSlot.ReservePort.ToUpper().Equals(fromPort.ToUpper()) && eachSlot.ReserveSlot.ToUpper().Equals(fromSlot.ToUpper())) { present.BackColor = Color.Yellow; present.ForeColor = Color.Black; toPort = eachSlot.Position; toSlot = eachSlot.Slot; } else { present.BackColor = Color.Brown; present.ForeColor = Color.White; } } } } } } } } else { fromPort = PortName; fromSlot = SlotNo; toPort = ""; toSlot = ""; //在已經選擇來源與目的後,點選新的來源slot Slot_Label.BackColor = Color.SkyBlue; Slot_Label.ForeColor = Color.White; fromPort = PortName; fromSlot = SlotNo; // Form form = Application.OpenForms["FormWaferMapping"]; foreach (Node p in NodeManagement.GetLoadPortList()) { if (p.Enable && p.IsMapping) { foreach (Job eachSlot in p.JobList.Values) { if (!eachSlot.MapFlag && !eachSlot.ErrPosition) {//找到空的slot Label present = form.Controls.Find(p.Name + "_Slot_" + eachSlot.Slot, true).FirstOrDefault() as Label; if (present != null) { if (eachSlot.ReservePort.Equals("") && eachSlot.ReserveSlot.Equals("")) {//該slot還沒被綁定 Form tform = Application.OpenForms["FormWaferMapping"]; Label tpresent = form.Controls.Find(p.Name + "_Slot_" + (Convert.ToInt16(eachSlot.Slot) + 1).ToString(), true).FirstOrDefault() as Label; Job tSlot; if (p.JobList.TryGetValue(toSlot, out tSlot) && !bypass) { if (tSlot.ReservePort.Equals(""))//檢查下層slot是否已被綁定,改變目前slot限制狀態 { //未被綁定 tpresent.BackColor = Color.White; tpresent.ForeColor = Color.Black; } else { //已被綁定 tpresent.BackColor = Color.DimGray; tpresent.ForeColor = Color.White; } } } else { present.BackColor = Color.Brown; present.ForeColor = Color.White; } } } } } } } } }
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); } }
private void button4_Click(object sender, EventArgs e) { LockUI(true); if (!MainProcess._Mode.Equals("Stop") && !MainProcess._Mode.Equals("")) { AlarmUpdate.UpdateMessage("目前狀態為 " + MainProcess._Mode + " 模式,請先停止動作。"); return; } NodeManagement.InitialNodes(); JobManagement.Initial(); if (PortSetting1Active_ck.Checked) { if (!PortSetting1Aligner_cb.Text.Equals("")) { Node Aligner1 = NodeManagement.Get(PortSetting1Aligner_cb.Text); if (Aligner1 != null) { Aligner1.LockByNode = PortSetting1Name_cb.Text; } } Node P1 = NodeManagement.Get(PortSetting1Name_cb.Text); int SlotMode = 0; if (PortSetting1SlotMode_ck.Checked) { SlotMode = 1; } else { SlotMode = 2; } for (int i = Convert.ToInt16(PortSetting1StartSlot_tb.Text); i <= Convert.ToInt16(PortSetting1EndSlot_tb.Text); i = i + SlotMode) { Job w = new Job(); w.Job_Id = "Wafer" + i.ToString("000"); w.AlignerFlag = true; w.OCRFlag = false; w.Position = P1.Name; w.ProcessFlag = false; w.FromPort = P1.Name; w.Slot = i.ToString(); w.Destination = PortSetting1Dest_cb.Text; w.DestinationSlot = i.ToString();; JobManagement.Add(w.Job_Id, w); P1.JobList.TryAdd(w.Slot, w); } } if (PortSetting2Active_ck.Checked) { if (!PortSetting2Aligner_cb.Text.Equals("")) { Node Aligner2 = NodeManagement.Get(PortSetting2Aligner_cb.Text); if (Aligner2 != null) { Aligner2.LockByNode = PortSetting2Name_cb.Text; } } Node P2 = NodeManagement.Get(PortSetting2Name_cb.Text); int SlotMode = 0; if (PortSetting2SlotMode_ck.Checked) { SlotMode = 1; } else { SlotMode = 2; } if (Convert.ToInt16(PortSetting2StartSlot_tb.Text) != 0 && Convert.ToInt16(PortSetting2EndSlot_tb.Text) != 0) { for (int i = Convert.ToInt16(PortSetting2StartSlot_tb.Text); i <= Convert.ToInt16(PortSetting2EndSlot_tb.Text); i = i + SlotMode) { Job w = new Job(); w.Job_Id = "Wafer" + (i + 25).ToString("000"); w.AlignerFlag = true; w.OCRFlag = false; w.Position = P2.Name; w.ProcessFlag = false; w.FromPort = P2.Name; w.Slot = i.ToString(); w.Destination = PortSetting2Dest_cb.Text; w.DestinationSlot = i.ToString();; JobManagement.Add(w.Job_Id, w); P2.JobList.TryAdd(w.Slot, w); } } } NodeManagement.UpdatePortToUI(); if (AutoIni_ck.Checked) { MainProcess.SetMode("AutoInitial");//initial } else { MainProcess.SetMode("Auto"); } }
public static void UpdateNodesJob(string NodeName) { try { Form form = Application.OpenForms["FormRunningScreen"]; CheckBox tb; if (form == null) { return; } tb = form.Controls.Find("use_loadport01_ck", true).FirstOrDefault() as CheckBox; if (tb == null) { return; } if (tb.InvokeRequired) { UpdatePresent ph = new UpdatePresent(UpdateNodesJob); tb.BeginInvoke(ph, NodeName); } else { Node node = NodeManagement.Get(NodeName); if (node.IsMapping) { for (int i = 1; i <= Tools.GetSlotCount(node.Type); i++) { Label present = form.Controls.Find(node.Name + "_Slot_" + i.ToString(), true).FirstOrDefault() as Label; if (present != null) { Job tmp; if (node.JobList.TryGetValue(i.ToString(), out tmp)) { present.Text = tmp.Host_Job_Id; switch (present.Text) { case "No wafer": present.BackColor = Color.DimGray; present.ForeColor = Color.White; break; case "Crossed": case "Undefined": case "Double": present.BackColor = Color.Red; present.ForeColor = Color.White; break; default: present.BackColor = Color.Green; present.ForeColor = Color.White; break; } } else { present.Text = ""; present.BackColor = Color.White; } } } } else { for (int i = 1; i <= Tools.GetSlotCount(node.Type); i++) { Label present = form.Controls.Find(node.Name + "_Slot_" + i.ToString(), true).FirstOrDefault() as Label; if (present != null) { present.Text = ""; present.BackColor = Color.White; } } } } } catch { logger.Error("UpdateNodesJob: Update fail."); } }
private void Assign_Gv_MouseClick(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Right) { ContextMenu m = new ContextMenu(); string PortName = (sender as DataGridView).Name.Replace("Assign_Gv", ""); //if (NodeManagement.Get(PortName).Mode.Equals("LD")) // { if (!NodeManagement.Get(PortName).IsMapping) { return; } CurrentSelected = sender; foreach (Node eachPort in NodeManagement.GetLoadPortList()) { if (!eachPort.IsMapping) { continue; } List <MenuItem> tmpAry = new List <MenuItem>(); bool findFirst = false; for (int i = 1; i <= 25; i++) { MenuItem tmp = new MenuItem(); if (eachPort.Name.Equals(PortName.ToUpper())) { tmp = new MenuItem(eachPort.Name + "-" + i.ToString(), AssignPort); if (!findFirst) { List <DataGridViewRow> JobList = new List <DataGridViewRow>(); foreach (DataGridViewRow each in (CurrentSelected as DataGridView).SelectedRows) { JobList.Add(each); } JobList.Sort((x, y) => { return(-x.Index.CompareTo(y.Index)); }); foreach (DataGridViewRow each in JobList) { string waferId = each.Cells["Job_Id"].Value.ToString(); Job wafer = JobManagement.Get(waferId); if (wafer == null) { MessageBox.Show("請選擇Wafer"); return; } if (!eachPort.ReserveList.ContainsKey(i.ToString())) { if (wafer.Slot.Equals(i.ToString())) { tmp.Enabled = true; findFirst = true; break; } else { tmp.Enabled = false; } } else { tmp.Enabled = false; } } } else { tmp.Enabled = false; } } else { if (!eachPort.ReserveList.ContainsKey(i.ToString())) { if (eachPort.JobList.ContainsKey(i.ToString())) { if (eachPort.JobList[i.ToString()].MapFlag) { tmp = new MenuItem(eachPort.Name + "-" + i.ToString(), AssignPort); tmp.Enabled = false; } else { tmp = new MenuItem(eachPort.Name + "-" + i.ToString(), AssignPort); } } else { tmp = new MenuItem(eachPort.Name + "-" + i.ToString(), AssignPort); } } else { tmp = new MenuItem(eachPort.Name + "-" + i.ToString(), AssignPort); tmp.Enabled = false; } } tmpAry.Add(tmp); } m.MenuItems.Add(eachPort.Name, tmpAry.ToArray()); } m.MenuItems.Add(new MenuItem("取消", UnAssignPort)); //} m.Show((DataGridView)sender, new Point(e.X, e.Y)); } }
private void AssignPort(object sender, EventArgs e) { string PortName = (sender as MenuItem).Text.Split('-')[0]; string LDPort = (CurrentSelected as DataGridView).Name.Replace("Assign_Gv", ""); Node UD = NodeManagement.Get(PortName); Node LD = NodeManagement.Get(LDPort); UD.Mode = "UD"; LD.Mode = "LD"; LD.DestPort = UD.Name; WaferAssignUpdate.UpdateLoadPortMode(UD.Name, UD.Mode); WaferAssignUpdate.UpdateLoadPortMode(LD.Name, LD.Mode); string Slot = (sender as MenuItem).Text.Split('-')[1]; if ((CurrentSelected as DataGridView).SelectedRows.Count == 0) { MessageBox.Show("請選擇來源Slot"); } else if ((CurrentSelected as DataGridView).SelectedRows.Count == 1) { string waferId = (CurrentSelected as DataGridView).SelectedRows[0].Cells["Job_Id"].Value.ToString(); string OrgDest = (CurrentSelected as DataGridView).SelectedRows[0].Cells["Destination"].Value.ToString(); string OrgDestSlot = (CurrentSelected as DataGridView).SelectedRows[0].Cells["DestinationSlot"].Value.ToString(); Job UDSlot = UD.GetJob(Slot); if (UDSlot == null) { MessageBox.Show(PortName + "沒有FOUP或是尚未進行Mapping"); return; } if (UDSlot.MapFlag == false || LD.Name.Equals(UD.Name)) { Job wafer = JobManagement.Get(waferId); if (wafer != null) { wafer.AssignPort(PortName, Slot); wafer.NeedProcess = true; wafer.ProcessFlag = false; //wafer.Position = PortName; if (!OrgDest.Equals("")) { NodeManagement.Get(OrgDest).RemoveReserve(OrgDestSlot); } NodeManagement.Get(PortName).AddReserve(Slot, wafer); (CurrentSelected as DataGridView).Refresh(); MonitoringUpdate.UpdateNodesJob((CurrentSelected as DataGridView).Name.Replace("Assign_Gv", "")); } else { MessageBox.Show("找不到此Wafer資料"); } } } else if ((CurrentSelected as DataGridView).SelectedRows.Count > 1) { int StartSlot = Convert.ToInt32(Slot); List <DataGridViewRow> tmp = new List <DataGridViewRow>(); foreach (DataGridViewRow each in (CurrentSelected as DataGridView).SelectedRows) { tmp.Add(each); } tmp.Sort((x, y) => { return(-x.Index.CompareTo(y.Index)); }); foreach (DataGridViewRow each in tmp) { string waferId = each.Cells["Job_Id"].Value.ToString(); string OrgDest = each.Cells["Destination"].Value.ToString(); string OrgDestSlot = each.Cells["DestinationSlot"].Value.ToString(); Job wafer = JobManagement.Get(waferId); if (wafer != null) { while (true) { if (NodeManagement.Get(PortName).GetJob(StartSlot.ToString()).MapFlag == false || LD.Name.Equals(UD.Name)) { wafer.AssignPort(PortName, StartSlot.ToString()); //wafer.Position = PortName; wafer.NeedProcess = true; wafer.ProcessFlag = false; if (!OrgDest.Equals("")) { NodeManagement.Get(OrgDest).RemoveReserve(OrgDestSlot); } NodeManagement.Get(PortName).AddReserve(StartSlot.ToString(), wafer); break; } else { StartSlot++; if (StartSlot > 25) { break; } } } StartSlot++; if (StartSlot > 25) { break; } } } (CurrentSelected as DataGridView).Refresh(); MonitoringUpdate.UpdateNodesJob((CurrentSelected as DataGridView).Name.Replace("Assign_Gv", "")); } }
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."); } }
private void Cycle_btn_Click(object sender, EventArgs e) { FormMain.cycleRun = true; Node LD = null; Node ULD = null; foreach (Node port in NodeManagement.GetLoadPortList()) { if (LD == null) { if (port.Enable) { LD = port; continue; } } else { if (port.Enable) { ULD = port; break; } } } if (LD != null && ULD != null) { var AvailableSlots = from eachSlot in LD.JobList.Values.ToList() where eachSlot.MapFlag && !eachSlot.ErrPosition select eachSlot; if (AvailableSlots.Count() == 0) { AvailableSlots = from eachSlot in ULD.JobList.Values.ToList() where eachSlot.MapFlag && !eachSlot.ErrPosition select eachSlot; if (AvailableSlots.Count() == 0) { return; } else { string ULDName = LD.Name; LD = NodeManagement.Get(ULD.Name); ULD = NodeManagement.Get(ULDName); } } List <Job> LD_Jobs = LD.JobList.Values.ToList(); LD_Jobs.Sort((x, y) => { return(-Convert.ToInt32(x.Slot).CompareTo(Convert.ToInt32(y.Slot))); }); List <Job> ULD_Jobs = ULD.JobList.Values.ToList(); ULD_Jobs.Sort((x, y) => { return(Convert.ToInt32(x.Slot).CompareTo(Convert.ToInt32(y.Slot))); }); foreach (Job wafer in LD_Jobs) { if (!wafer.MapFlag || wafer.ErrPosition) { continue; } bool isAssign = false; foreach (Job Slot in ULD_Jobs) { if (!Slot.MapFlag && !Slot.ErrPosition && !Slot.IsAssigned) { wafer.NeedProcess = true; wafer.ProcessFlag = false; wafer.AssignPort(ULD.Name, Slot.Slot); isAssign = true; Slot.IsAssigned = true; break; } } if (!isAssign) { break; } } FormMain.xfe.Start(LD.Name); } }
private void FoupID_Read_Confirm_btn_Click(object sender, EventArgs e) { if (!FoupID_Read_tb.Text.Equals("")) { if (!ManualInput_ck.Checked) { //open & mapping foup string end = ""; switch (LoadportName_lb.Text) { case "LOADPORT01": end = "!"; break; case "LOADPORT02": end = "\""; break; case "LOADPORT03": end = "#"; break; case "LOADPORT04": end = "$"; break; } if (!end.Equals(endCode)) { MessageBox.Show("請使用正確的條碼槍"); return; } } else { foupID = FoupID_Read_tb.Text; } TaskJobManagment.CurrentProceedTask Task; Node port = NodeManagement.Get(LoadportName_lb.Text); if (port != null) { port.FoupID = foupID; MonitoringUpdate.UpdateFoupID(port.Name.ToUpper(), foupID); WaferAssignUpdate.UpdateFoupID(port.Name.ToUpper(), foupID); port.OPACCESS = false; string TaskName = "LOADPORT_OPEN"; string Message = ""; Dictionary <string, string> param = new Dictionary <string, string>(); param.Add("@Target", port.Name); RouteControl.Instance.TaskJob.Excute(Guid.NewGuid().ToString(), out Message, out Task, TaskName, param); this.Hide(); } else { MessageBox.Show("找不到該Laodport資料"); } } else { MessageBox.Show("請輸入Foup ID"); } }
public static void RefreshMapping(string PortName) { try { Form form = Application.OpenForms["FormWaferMapping"]; DataGridView Port_gv; if (form == null) { return; } Port_gv = form.Controls.Find(PortName + "Assign_Gv", true).FirstOrDefault() as DataGridView; if (Port_gv == null) { return; } if (Port_gv.InvokeRequired) { UpdatePortMapping ph = new UpdatePortMapping(RefreshMapping); Port_gv.BeginInvoke(ph, PortName); } else { Node port = NodeManagement.Get(PortName); foreach (Job each in port.JobList.Values.ToList()) { each.RecipeID = "300MM"; } List <Job> tmp = port.JobList.Values.ToList(); tmp.Sort((x, y) => { return(-Convert.ToInt16(x.Slot).CompareTo(Convert.ToInt16(y.Slot))); }); Port_gv.DataSource = tmp; Port_gv.Columns["Slot"].Width = 25; Port_gv.Columns["Slot"].HeaderText = "S"; Port_gv.Columns["Host_Job_Id"].Width = 75; Port_gv.Columns["DisplayDestination"].Width = 55; Port_gv.Columns["DestinationSlot"].Width = 30; Port_gv.Columns["Offset"].Visible = false; Port_gv.Columns["Angle"].Visible = false; Port_gv.Columns["Job_Id"].Visible = false; Port_gv.Columns["Destination"].Visible = false; Port_gv.Columns["ProcessFlag"].Visible = false; //Port_gv.Columns["Piority"].Visible = false; Port_gv.Columns["AlignerFlag"].Visible = false; Port_gv.Columns["OCRFlag"].Visible = false; Port_gv.Columns["AlignerFinished"].Visible = false; Port_gv.Columns["OCRFinished"].Visible = false; Port_gv.Columns["Position"].Visible = false; Port_gv.Columns["FromPort"].Visible = false; Port_gv.Columns["LastNode"].Visible = false; Port_gv.Columns["CurrentState"].Visible = false; Port_gv.Columns["WaitToDo"].Visible = false; //Port_gv.Columns["FetchRobot"].Visible = false; Port_gv.Columns["ProcessNode"].Visible = false; Port_gv.Columns["MapFlag"].Visible = false; Port_gv.Columns["DisplayDestination"].HeaderText = "Dest"; Port_gv.Columns["DestinationSlot"].HeaderText = "DS"; Port_gv.Columns["Host_Job_Id"].HeaderText = "ID"; Port_gv.ColumnHeadersDefaultCellStyle.Font = new Font("Arial", 10); Port_gv.Columns["NeedProcess"].Visible = false; Port_gv.Columns["OCRImgPath"].Visible = false; Port_gv.Columns["OCRScore"].Visible = false; Port_gv.Columns["LastSlot"].Visible = false; Port_gv.Columns["FromPortSlot"].Visible = false; Port_gv.Columns["AssignTime"].Visible = false; Port_gv.Columns["DefaultOCR"].Visible = false; Port_gv.Columns["RecipeID"].Visible = false; Port_gv.Columns["ErrPosition"].Visible = false; Port_gv.Columns["InProcess"].Visible = false; Port_gv.Columns["Host_Lot_Id"].Visible = false; //MonitoringUpdate.UpdateNodesJob(PortName); } } catch (Exception e) { logger.Error("UpdateLoadPortMapping: Update fail:" + e.StackTrace); } }
public static void UpdateLoadPortMapping(string PortName, string Mapping) { try { Form form = Application.OpenForms["FormWaferMapping"]; DataGridView Port_gv; if (form == null) { return; } Port_gv = form.Controls.Find(PortName + "Assign_Gv", true).FirstOrDefault() as DataGridView; if (Port_gv == null) { return; } if (Port_gv.InvokeRequired) { UpdatePort ph = new UpdatePort(UpdateLoadPortMapping); Port_gv.BeginInvoke(ph, PortName, Mapping); } else { Node port = NodeManagement.Get(PortName); //List<Job> MappingData = new List<Job>(); //port.IsMapping = true; if (Mapping.Equals("")) { foreach (Job eachJob in port.JobList.Values) { JobManagement.Remove(eachJob.Job_Id); } port.JobList.Clear(); port.ReserveList.Clear(); JobManagement.ClearAssignJobByPort(port.Name); } else { int currentIdx = 1; for (int i = 0; i < Mapping.Length; i++) { Job wafer = RouteControl.CreateJob(); wafer.Slot = (i + 1).ToString(); wafer.FromPort = PortName; wafer.FromPortSlot = wafer.Slot; wafer.Position = PortName; wafer.AlignerFlag = false; wafer.RecipeID = "300MM"; string Slot = (i + 1).ToString("00"); switch (Mapping[i]) { case '0': wafer.Job_Id = "No wafer"; wafer.Host_Job_Id = wafer.Job_Id; //MappingData.Add(wafer); break; case '1': while (true) { wafer.Job_Id = "Wafer" + currentIdx.ToString("00"); wafer.Host_Job_Id = wafer.Job_Id; wafer.MapFlag = true; if (JobManagement.Add(wafer.Job_Id, wafer)) { //MappingData.Add(wafer); break; } currentIdx++; } break; case '2': wafer.Job_Id = "Crossed"; wafer.Host_Job_Id = wafer.Job_Id; wafer.MapFlag = true; //MappingData.Add(wafer); break; case '?': wafer.Job_Id = "Undefined"; wafer.Host_Job_Id = wafer.Job_Id; wafer.MapFlag = true; //MappingData.Add(wafer); break; case 'W': wafer.Job_Id = "Double"; wafer.Host_Job_Id = wafer.Job_Id; wafer.MapFlag = true; //MappingData.Add(wafer); break; } if (!port.AddJob(wafer.Slot, wafer)) { Job org = port.GetJob(wafer.Slot); JobManagement.Remove(org.Job_Id); port.RemoveJob(wafer.Slot); port.AddJob(wafer.Slot, wafer); } } } List <Job> tmp = port.JobList.Values.ToList(); tmp.Sort((x, y) => { return(-Convert.ToInt16(x.Slot).CompareTo(Convert.ToInt16(y.Slot))); }); Port_gv.DataSource = tmp; Port_gv.Columns["Slot"].Width = 25; Port_gv.Columns["Slot"].HeaderText = "S"; Port_gv.Columns["Host_Job_Id"].Width = 75; Port_gv.Columns["DisplayDestination"].Width = 55; Port_gv.Columns["DestinationSlot"].Width = 30; Port_gv.Columns["Offset"].Visible = false; Port_gv.Columns["Angle"].Visible = false; Port_gv.Columns["Job_Id"].Visible = false; Port_gv.Columns["Destination"].Visible = false; Port_gv.Columns["ProcessFlag"].Visible = false; // Port_gv.Columns["Piority"].Visible = false; Port_gv.Columns["AlignerFlag"].Visible = false; Port_gv.Columns["OCRFlag"].Visible = false; Port_gv.Columns["AlignerFinished"].Visible = false; Port_gv.Columns["OCRFinished"].Visible = false; Port_gv.Columns["Position"].Visible = false; Port_gv.Columns["FromPort"].Visible = false; Port_gv.Columns["LastNode"].Visible = false; Port_gv.Columns["CurrentState"].Visible = false; Port_gv.Columns["WaitToDo"].Visible = false; //Port_gv.Columns["FetchRobot"].Visible = false; Port_gv.Columns["ProcessNode"].Visible = false; Port_gv.Columns["MapFlag"].Visible = false; Port_gv.Columns["DisplayDestination"].HeaderText = "Dest"; Port_gv.Columns["DestinationSlot"].HeaderText = "DS"; Port_gv.Columns["Host_Job_Id"].HeaderText = "ID"; Port_gv.ColumnHeadersDefaultCellStyle.Font = new Font("Arial", 10); Port_gv.Columns["NeedProcess"].Visible = false; Port_gv.Columns["OCRImgPath"].Visible = false; Port_gv.Columns["OCRScore"].Visible = false; Port_gv.Columns["LastSlot"].Visible = false; Port_gv.Columns["FromPortSlot"].Visible = false; Port_gv.Columns["AssignTime"].Visible = false; Port_gv.Columns["DefaultOCR"].Visible = false; Port_gv.Columns["RecipeID"].Visible = false; Port_gv.Columns["ErrPosition"].Visible = false; Port_gv.Columns["InProcess"].Visible = false; Port_gv.Columns["Host_Lot_Id"].Visible = false; MonitoringUpdate.UpdateNodesJob(PortName); port.IsMapping = true; } } catch (Exception e) { logger.Error("UpdateLoadPortMapping: Update fail:" + e.StackTrace); } }
public void On_Connection_Message(object MsgObj) { try { string Msg = (string)MsgObj; logger.Debug(_Config.DeviceName + " Recieve:" + Msg.Replace("\r", "")); List <ReturnMessage> ReturnMsgList = _Decoder.GetMessage(Msg); foreach (ReturnMessage ReturnMsg in ReturnMsgList) { if (WaitingForSync) { if (ReturnMsg.Type.Equals(ReturnMessage.ReturnType.Error)) { ReturnForSync = Msg; WaitingForSync = false; return; } else if (ReturnTypeForSync.Equals("CMD")) { if (ReturnMsg.Type.Equals(ReturnMessage.ReturnType.Finished)) { ReturnForSync = Msg; WaitingForSync = false; return; } else { continue; } } else { if (ReturnMsg.Type.Equals(ReturnMessage.ReturnType.Excuted)) { ReturnForSync = Msg; WaitingForSync = false; return; } else { continue; } } } string key = ""; if (_Config.Vendor.ToUpper().Equals("KAWASAKI")) { key = ReturnMsg.Seq; } else if (_Config.Vendor.ToUpper().Equals("HST") || _Config.Vendor.ToUpper().Equals("COGNEX")) { key = "1" + ReturnMsg.Command; } else { key = ReturnMsg.NodeAdr + ReturnMsg.Command; } try { Transaction Txn = null; Node Node = null; if (ReturnMsg != null) { if (_Config.Vendor.ToUpper().Equals("KAWASAKI")) { if (TransactionList.TryGetValue(key, out Txn)) { Node = NodeManagement.Get(Txn.NodeName); if (!Txn.CommandType.Equals("GET") && !Txn.CommandType.Equals("SET") && !Txn.CommandType.Equals("CMD")) { Txn.CommandType = Encoder.GetCommandType(Txn.CommandType); } if (!Txn.CommandType.Equals("CMD")) { if (ReturnMsg.Type.Equals(ReturnMessage.ReturnType.Excuted)) { continue; } else if (ReturnMsg.Type.Equals(ReturnMessage.ReturnType.Finished)) { ReturnMsg.Type = ReturnMessage.ReturnType.Excuted; } } } else { logger.Debug("Transaction not exist:key=" + key); return; } } else if (_Config.Vendor.ToUpper().Equals("TDK")) { if (TransactionList.TryGetValue(key, out Txn)) { Node = NodeManagement.Get(Txn.NodeName); if (Txn.CommandType.Equals("SET") && ReturnMsg.Type.Equals(ReturnMessage.ReturnType.Excuted)) { continue; } } else { Node = NodeManagement.GetByController(_Config.DeviceName, ReturnMsg.NodeAdr); } } else { Node = NodeManagement.GetByController(_Config.DeviceName, ReturnMsg.NodeAdr); if (Node == null) { Node = NodeManagement.GetOCRByController(_Config.DeviceName); } } //lock (TransactionList) //{ lock (Node) { if (ReturnMsg.Type == ReturnMessage.ReturnType.Event) { //_ReportTarget.On_Event_Trigger(Node, ReturnMsg); } else if (TransactionList.TryRemove(key, out Txn)) { // Node.InitialComplete = false; switch (ReturnMsg.Type) { case ReturnMessage.ReturnType.Excuted: if (!Txn.CommandType.Equals("CMD") && !Txn.CommandType.Equals("MOV")) { logger.Debug("Txn timmer stoped."); Txn.SetTimeOutMonitor(false); } else { Txn.SetTimeOutMonitor(false); Txn.SetTimeOut(60000); Txn.SetTimeOutMonitor(true); TransactionList.TryAdd(key, Txn); } //_ReportTarget.On_Command_Excuted(Node, Txn, ReturnMsg); break; case ReturnMessage.ReturnType.Finished: logger.Debug("Txn timmer stoped."); Txn.SetTimeOutMonitor(false); //_ReportTarget.On_Command_Finished(Node, Txn, ReturnMsg); break; case ReturnMessage.ReturnType.Error: logger.Debug("Txn timmer stoped."); Txn.SetTimeOutMonitor(false); //_ReportTarget.On_Command_Error(Node, Txn, ReturnMsg); break; case ReturnMessage.ReturnType.Information: logger.Debug("Txn timmer stoped."); Txn.SetTimeOutMonitor(false); if (_Config.Vendor.ToUpper().Equals("TDK") && Txn.CommandType.Equals("SET")) { ReturnMsg.Type = ReturnMessage.ReturnType.Excuted; } else { ReturnMsg.Type = ReturnMessage.ReturnType.Finished; } SpinWait.SpinUntil(() => false, 50); //ThreadPool.QueueUserWorkItem(new WaitCallback(conn.Send), ReturnMsg.FinCommand); conn.Send(ReturnMsg.FinCommand); logger.Debug(_Config.DeviceName + "Send:" + ReturnMsg.FinCommand); break; } } else { if (ReturnMsg.Type.Equals(ReturnMessage.ReturnType.Information)) { //ThreadPool.QueueUserWorkItem(new WaitCallback(conn.Send), ReturnMsg.FinCommand); conn.Send(ReturnMsg.FinCommand); logger.Debug(_Config.DeviceName + "Send:" + ReturnMsg.FinCommand); } else { logger.Debug(_Config.DeviceName + "(On_Connection_Message Txn is not found. msg:" + Msg); return; } } } switch (ReturnMsg.Type) { case ReturnMessage.ReturnType.Information: case ReturnMessage.ReturnType.Event: Transaction t = new Transaction(); t.NodeName = Node.Name; t.NodeType = Node.Type; t.Value = ReturnMsg.Value; t.CommandEncodeStr = ReturnMsg.OrgMsg; t.Method = ReturnMsg.Command; TransactionRecord.New(t, ReturnMsg.Type); //TransactionRecord.AddDetail(TransactionRecord.GetUUID(), Node.Name,Node.Type,ReturnMsg.Type,ReturnMsg.Value); _ReportTarget.On_Event_Trigger(Node, ReturnMsg); break; case ReturnMessage.ReturnType.Excuted: TransactionRecord.Update(Txn, ReturnMsg); _ReportTarget.On_Command_Excuted(Node, Txn, ReturnMsg); if (Txn.CommandType.Equals("CMD") && !Node.Type.Equals("LOADPORT")) { _ReportTarget.On_Node_State_Changed(Node, "Run"); } break; case ReturnMessage.ReturnType.Finished: TransactionRecord.Update(Txn, ReturnMsg); if (Node.Type.Equals("LOADPORT")) { Node.InterLock = false; } _ReportTarget.On_Command_Finished(Node, Txn, ReturnMsg); if (!Node.Type.Equals("LOADPORT")) { _ReportTarget.On_Node_State_Changed(Node, "Idle"); } break; case ReturnMessage.ReturnType.Error: TransactionRecord.Update(Txn, ReturnMsg); if (Node.Type.Equals("LOADPORT")) { Node.InterLock = false; } _ReportTarget.On_Command_Error(Node, Txn, ReturnMsg); break; } } else { logger.Debug(_Config.DeviceName + "(On_Connection_Message Message decode fail:" + Msg); } } catch (Exception e) { logger.Error(_Config.DeviceName + "(On_Connection_Message " + _Config.IPAdress + ":" + _Config.Port.ToString() + ")" + e.Message + "\n" + e.StackTrace); } } } catch (Exception e) { logger.Error(_Config.DeviceName + "(On_Connection_Message " + _Config.IPAdress + ":" + _Config.Port.ToString() + ")" + e.Message + "\n" + e.StackTrace); } }
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()); } }
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; } } } }
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(); }
public static void UpdateOCRRead(string OCRName, string WaferID, Job Job, string OCRType, string FormName) { try { Form form = Application.OpenForms[FormName]; TextBox Tb_OCRRead; string tbName = ""; if (form == null) { return; } switch (OCRType) { case "M12": tbName = "Read_Tb"; break; case "T7": tbName = "ReadT7_Tb"; break; default: tbName = "Read_Tb"; break; } Tb_OCRRead = form.Controls.Find(OCRName + tbName, 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, OCRType, FormName); } else { Node OCR = NodeManagement.Get(OCRName); if (OCR != null) { string info = ""; switch (OCRType) { case "M12": info = "Score:" + Job.OCR_M12_Score + " Pass:"******"T7": info = "Score:" + Job.OCR_T7_Score + " Pass:"******"Score:" + Job.OCRScore + " Pass:"******""; switch (OCRType) { case "M12": savePath = Job.OCR_M12_ImgPath; break; case "T7": savePath = Job.OCR_T7_ImgPath; break; default: savePath = Job.OCRImgPath; break; } Tb_OCRRead.Text = info; switch (OCR.Brand) { case "COGNEX": 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.OCRScore = ocrResult[1]; //ProcessRecord.updateSubstrateOCR(NodeManagement.Get(Job.FromPort).PrID, Job); break; case "HST": Pic_OCR = form.Controls.Find(OCRName + "_Pic", true).FirstOrDefault() as PictureBox; 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; break; } } } } catch (Exception e) { logger.Error("UpdateOCRRead: Update fail."); } }
public static void ReverseRunning(string FinishPort) { Form form = Application.OpenForms["FormRunningScreen"]; if (form == null) { return; } TextBox tb = form.Controls.Find("TransCount_tb", true).FirstOrDefault() as TextBox; if (tb == null) { return; } if (tb.InvokeRequired) { UpdatePresent ph = new UpdatePresent(ReverseRunning); tb.BeginInvoke(ph, FinishPort); } else { Node FinPort = NodeManagement.Get(FinishPort); if (FinPort != null) { Node DestPort = NodeManagement.Get(FinPort.DestPort); if (DestPort != null) { int StartSlot = 1; List <Job> DestPortJobs = DestPort.JobList.Values.ToList(); DestPortJobs.Sort((x, y) => { return(Convert.ToInt16(x.Slot).CompareTo(Convert.ToInt16(y.Slot))); }); foreach (Job job in DestPortJobs) { if (job.MapFlag) { while (StartSlot <= 25) { if (FinPort.GetJob(StartSlot.ToString()).MapFlag == false) { job.NeedProcess = true; job.ProcessFlag = false; job.AlignerFlag = true; job.OCRFlag = true; job.AssignPort(FinPort.Name, StartSlot.ToString()); FinPort.ReserveList.TryAdd(job.Slot, job); StartSlot++; break; } StartSlot++; } } if (StartSlot > 25) { break; } } //FinPort.DestPort = "Assign"; if (FinPort.Name.Equals(DestPort.Name)) { DestPort.Mode = "LU"; } else { FinPort.Mode = "UD"; DestPort.Mode = "LD"; WaferAssignUpdate.UpdateLoadPortMode(FinPort.Name, FinPort.Mode); WaferAssignUpdate.UpdateLoadPortMode(DestPort.Name, DestPort.Mode); } FinPort.DestPort = ""; DestPort.DestPort = FinPort.Name; DestPort.ReserveList.Clear(); tb = form.Controls.Find("TransCount_tb", true).FirstOrDefault() as TextBox; if (Convert.ToInt32(tb.Text) <= 1)//次數歸零 停止DEMO { DestPort.Available = false; //FormMain.RouteCtrl.Stop(); } else { ProcessRecord.CreatePr(DestPort); WaferAssignUpdate.UpdateAssignCM(DestPort.Name, FinPort.Name, false); DestPort.Available = true; if (DestPort.ByPass) { DestPort.PortUnloadAndLoadFinished = true; } } FinPort.Used = false; } else { return; } } else { return; } } }
//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); } }
private void LoadPort_ASCM_Click(object sender, EventArgs e) { string PortName = (sender as Button).Name.Replace("_ASCM", ""); string AssignStatus = (sender as Button).Text; Node port = NodeManagement.Get(PortName); DataGridView Port_gv = this.Controls.Find(PortName + "Assign_Gv", true).FirstOrDefault() as DataGridView; DataGridView DestPort_gv = this.Controls.Find(port.DestPort + "Assign_Gv", true).FirstOrDefault() as DataGridView; Button DestPort_btn = this.Controls.Find(port.DestPort + "_ASCM", true).FirstOrDefault() as Button; if (port != null) { if (AssignStatus.Equals("Assign Cancel")) { port.Available = false; ProcessRecord.CancelPr(port); (sender as Button).Text = "Assign Complete"; (sender as Button).BackColor = Color.Gainsboro; (sender as Button).ForeColor = Color.Black; Port_gv.Enabled = true; DestPort_gv.Enabled = true; DestPort_btn.Enabled = true; } else if (AssignStatus.Equals("Assign Complete")) { TextBox fp = this.Controls.Find(PortName + "_FoupID", true).FirstOrDefault() as TextBox; port.FoupID = fp.Text; Node desport = NodeManagement.Get(port.DestPort); fp = this.Controls.Find(desport.Name + "_FoupID", true).FirstOrDefault() as TextBox; desport.FoupID = fp.Text; CheckBox Align = this.Controls.Find(port.Name + "_Align_ck", true).FirstOrDefault() as CheckBox; CheckBox Ocr = this.Controls.Find(port.Name + "_Align_ck", true).FirstOrDefault() as CheckBox; foreach (Job j in port.JobList.Values.ToList()) { if (j.NeedProcess) { j.AlignerFlag = Align.Checked; j.OCRFlag = Ocr.Checked; } } port.Available = true; ProcessRecord.CreatePr(port); (sender as Button).Text = "Assign Cancel"; (sender as Button).BackColor = Color.Green; (sender as Button).ForeColor = Color.White; Port_gv.Enabled = false; DestPort_gv.Enabled = false; DestPort_btn.Enabled = false; FormMain.xfe.Start(port.Name); } } else { MessageBox.Show(PortName + "不存在!"); } }
public void On_Transaction_TimeOut(Transaction Txn) { logger.Debug(DeviceName + "(On_Transaction_TimeOut Txn is timeout:" + Txn.Method); _ReportTarget.On_Message_Log("CMD", DeviceName + "(On_Transaction_TimeOut Txn is timeout:" + Txn.Method); string key = ""; if (Vendor.ToUpper().Equals("KAWASAKI")) { key = Txn.Seq; } else if (Vendor.ToUpper().Equals("HST") || Vendor.ToUpper().Equals("COGNEX")) { key = "1"; } else if (Vendor.ToUpper().Equals("SANWA") || Vendor.ToUpper().Equals("ATEL_NEW")) { key = Txn.AdrNo + Txn.Method; 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 { key = Txn.AdrNo; } Txn.SetTimeOutMonitor(false); if (TransactionList.ContainsKey(key)) { if (TransactionList.TryRemove(key, out Txn)) { //Node Node = NodeManagement.GetByController(DeviceName, Txn.AdrNo); Node Node = NodeManagement.Get(Txn.NodeName); Node.IsExcuting = false; if (Node.State.Equals("Pause")) { logger.Debug("Txn timeout,but state is pause. ignore this."); TransactionList.TryAdd(key, Txn); return; } //if (Node != null) //{ // _ReportTarget.On_Command_TimeOut(Node, Txn); //} //else //{ // logger.Debug(DeviceName + "(On_Transaction_TimeOut Get Node fail."); //} } else { logger.Debug(DeviceName + "(On_Transaction_TimeOut TryRemove Txn fail."); } } _ReportTarget.On_Command_TimeOut(NodeManagement.Get(Txn.NodeName), Txn); }
private void BF2_BYPASS_ck_Click(object sender, EventArgs e) { NodeManagement.Get("BF2").ByPassCheck = BF2_BYPASS_ck.Checked; FormMain.HostControl.Events.BF2_BYPASS = BF2_BYPASS_ck.Checked; FormMain.HostControl.Events.Save(); }
public void On_Connection_Message(object MsgObj) { try { string Msg = (string)MsgObj; //if (Vendor.ToUpper().Equals("ACDT")) //{ // byte[] byteAry = Encoding.ASCII.GetBytes(Msg); // logger.Debug(DeviceName + " Recieve:" + BitConverter.ToString(byteAry)); //} //else //{ //} //Node Target = null; List <CommandReturnMessage> ReturnMsgList = _Decoder.GetMessage(Msg); foreach (CommandReturnMessage ReturnMsg in ReturnMsgList) { //logger.Info(DeviceName + " Recieve:" + ReturnMsg.OrgMsg); if (!this.Vendor.ToUpper().Equals("MITSUBISHI_PLC")) { _ReportTarget.On_Message_Log("CMD", DeviceName + " Recieve:" + ReturnMsg.OrgMsg); } try { Transaction Txn = null; Node Node = null; if (ReturnMsg != null) { lock (TransactionList) { if (ReturnMsg.Command != null) { if (ReturnMsg.Command.Equals("PAUSE")) { foreach (Transaction t in TransactionList.Values) { t.SetTimeOutMonitor(false); } } if (ReturnMsg.Command.Equals("CONT_")) { foreach (Transaction t in TransactionList.Values) { t.SetTimeOutMonitor(true); } } } string key = ""; if (Vendor.ToUpper().Equals("KAWASAKI")) { key = ReturnMsg.Seq; } else if (Vendor.ToUpper().Equals("HST") || Vendor.ToUpper().Equals("COGNEX")) { key = "1" + ReturnMsg.Command; } else if (Vendor.ToUpper().Equals("SANWA") || Vendor.ToUpper().Equals("ATEL_NEW")) { key = ReturnMsg.NodeAdr + ReturnMsg.Command; 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 (ReturnMsg.Command.Equals("MCR__")) //{ if (ReturnMsg.Command.Equals("RESET")) { key = "0"; } else { key = ReturnMsg.NodeAdr; } //} //else //{ // key = "0" + ReturnMsg.Command; //} } else if (DeviceType.Equals("SMARTTAG")) { key = "00"; } else { key = (ReturnMsg.NodeAdr + ReturnMsg.Command).Equals("") ? "0" : ReturnMsg.NodeAdr + ReturnMsg.Command; } if (Vendor.ToUpper().Equals("KAWASAKI")) { if (TransactionList.TryGetValue(key, out Txn)) { Node = NodeManagement.Get(Txn.NodeName); if (!Txn.CommandType.Equals("CMD")) { if (ReturnMsg.Type.Equals(CommandReturnMessage.ReturnType.Excuted)) { continue; } else if (ReturnMsg.Type.Equals(CommandReturnMessage.ReturnType.Finished)) { ReturnMsg.Type = CommandReturnMessage.ReturnType.Excuted; } } } else { logger.Debug("Transaction not exist:key=" + key); return; } } else if (Vendor.ToUpper().Equals("TDK")) { if (TransactionList.TryGetValue(key, out Txn)) { Node = NodeManagement.Get(Txn.NodeName); if (Txn.CommandType.Equals("SET") && ReturnMsg.Type.Equals(CommandReturnMessage.ReturnType.Excuted)) { //continue; } } else { Node = NodeManagement.GetByController(DeviceName, ReturnMsg.NodeAdr); } } else { //if (ReturnMsg.NodeAdr.Equals("") || ReturnMsg.Command.Equals("RESET") || ReturnMsg.Command.Equals("SP___") || ReturnMsg.Command.Equals("PAUSE") || ReturnMsg.Command.Equals("CONT_") || ReturnMsg.Command.Equals("STOP_") || ReturnMsg.Command.Equals("TGEVT")) //{ // Node = NodeManagement.GetFirstByController(DeviceName); //} //else //{ // Node = NodeManagement.GetByController(DeviceName, ReturnMsg.NodeAdr); //} Node = NodeManagement.GetByController(DeviceName, ReturnMsg.NodeAdr.Equals("") ? "0" : ReturnMsg.NodeAdr); if (Node == null) { Node = NodeManagement.GetOCRByController(DeviceName); } if (Node == null) { Node = NodeManagement.GetFirstByController(DeviceName); } } //lock (TransactionList) //{ //lock (Node) //{ //Target = Node; if (Node.Vendor.ToUpper().Equals("COGNEX")) { if (ReturnMsg.Type == CommandReturnMessage.ReturnType.UserName) { //conn.Send("admin\r\n"); continue; } if (ReturnMsg.Type == CommandReturnMessage.ReturnType.Password) { //conn.Send("\r\n"); continue; } } if (ReturnMsg.Type == CommandReturnMessage.ReturnType.Event) { //_ReportTarget.On_Event_Trigger(Node, ReturnMsg); } else if ((ReturnMsg.Type == CommandReturnMessage.ReturnType.Information && Node.Vendor.ToUpper().Equals("TDK") && !TransactionList.ContainsKey(key))) { if (ReturnMsg.Type.Equals(CommandReturnMessage.ReturnType.Information)) { //ThreadPool.QueueUserWorkItem(new WaitCallback(conn.Send), ReturnMsg.FinCommand); //conn.Send(ReturnMsg.FinCommand); //isWaiting = false; logger.Debug(DeviceName + " Send:" + ReturnMsg.FinCommand); } } else if (TransactionList.TryRemove(key, out Txn)) { // Node.InitialComplete = false; Node = NodeManagement.Get(Txn.NodeName); switch (ReturnMsg.Type) { case CommandReturnMessage.ReturnType.Excuted: if (!Txn.CommandType.Equals("CMD") && !Txn.CommandType.Equals("MOV") && !Txn.CommandType.Equals("HCS")) { logger.Debug("Txn timmer stoped."); Txn.SetTimeOutMonitor(false); lock (Node.ExcuteLock) { Node.IsExcuting = false; } } else { //if (Txn.Method.Equals(Transaction.Command.LoadPortType.Reset)) //{ // logger.Debug("Txn timmer stoped."); // Txn.SetTimeOutMonitor(false); //} //else if (Txn.Method.Equals(Transaction.Command.RobotType.OrginSearch)) //{ // logger.Debug("Txn timmer stoped."); // Txn.SetTimeOutMonitor(false); // //Node.IsExcuting = false; // TransactionList.TryAdd(key, Txn); //} //else //{ Txn.SetTimeOutMonitor(false); Txn.SetTimeOut(Txn.MotionTimeOut); Txn.SetTimeOutMonitor(true); TransactionList.TryAdd(key, Txn); //} } //_ReportTarget.On_Command_Excuted(Node, Txn, ReturnMsg); break; case CommandReturnMessage.ReturnType.Finished: logger.Debug("Txn timmer stoped."); Txn.SetTimeOutMonitor(false); lock (Node.ExcuteLock) { Node.IsExcuting = false; } //_ReportTarget.On_Command_Finished(Node, Txn, ReturnMsg); break; case CommandReturnMessage.ReturnType.Error: logger.Debug("Txn timmer stoped."); Txn.SetTimeOutMonitor(false); lock (Node.ExcuteLock) { Node.IsExcuting = false; } //_ReportTarget.On_Command_Error(Node, Txn, ReturnMsg); if (Vendor.ToUpper().Equals("TDK") || DeviceType.ToUpper().Equals("SMARTTAG")) { //conn.Send(ReturnMsg.FinCommand); logger.Debug(DeviceName + " Send:" + ReturnMsg.FinCommand); } break; case CommandReturnMessage.ReturnType.Information: logger.Debug("Txn timmer stoped."); Txn.SetTimeOutMonitor(false); lock (Node.ExcuteLock) { Node.IsExcuting = false; } if (Vendor.ToUpper().Equals("TDK") && Txn.CommandType.Equals("SET")) { ReturnMsg.Type = CommandReturnMessage.ReturnType.Excuted; } else { ReturnMsg.Type = CommandReturnMessage.ReturnType.Finished; //Node.IsExcuting = false; } SpinWait.SpinUntil(() => false, 50); //ThreadPool.QueueUserWorkItem(new WaitCallback(conn.Send), ReturnMsg.FinCommand); //conn.Send(ReturnMsg.FinCommand); logger.Debug(DeviceName + " Send:" + ReturnMsg.FinCommand); break; } } else { if (ReturnMsg.Type != null) { if (ReturnMsg.Type.Equals(CommandReturnMessage.ReturnType.Information)) { //ThreadPool.QueueUserWorkItem(new WaitCallback(conn.Send), ReturnMsg.FinCommand); //conn.Send(ReturnMsg.FinCommand); logger.Debug(DeviceName + " Send:" + ReturnMsg.FinCommand); } else { if (ReturnMsg.Type == CommandReturnMessage.ReturnType.Error) { Txn = TransactionList.First().Value; logger.Debug("Txn timmer stoped."); Txn.SetTimeOutMonitor(false); lock (Node.ExcuteLock) { Node.IsExcuting = false; } //_ReportTarget.On_Command_Error(Node, Txn, ReturnMsg); if (Vendor.ToUpper().Equals("TDK") || DeviceType.ToUpper().Equals("SMARTTAG")) { //conn.Send(ReturnMsg.FinCommand); logger.Debug(DeviceName + " Send:" + ReturnMsg.FinCommand); } TransactionList.TryRemove(TransactionList.First().Key, out Txn); } else { logger.Debug(DeviceName + "(On_Connection_Message Txn is not found. msg:" + Msg); continue; } } } else { logger.Debug(DeviceName + "(On_Connection_Message Return type is null. msg:" + Msg); continue; } } //} } switch (ReturnMsg.Type) { case CommandReturnMessage.ReturnType.Information: case CommandReturnMessage.ReturnType.Event: Transaction t = new Transaction(); t.NodeName = Node.Name; t.NodeType = Node.Type; t.Value = ReturnMsg.Value; t.CommandEncodeStr = ReturnMsg.OrgMsg; t.Method = ReturnMsg.Command; //TransactionRecord.AddDetail(TransactionRecord.GetUUID(), Node.Name,Node.Type,ReturnMsg.Type,ReturnMsg.Value); _ReportTarget.On_Event_Trigger(Node, ReturnMsg); break; case CommandReturnMessage.ReturnType.Excuted: _ReportTarget.On_Command_Excuted(Node, Txn, ReturnMsg); if (Txn.CommandType.Equals("CMD") && !Node.Type.Equals("LOADPORT")) { _ReportTarget.On_Node_State_Changed(Node, "Busy"); } break; case CommandReturnMessage.ReturnType.Finished: //if (Node.Type.Equals("LOADPORT")) //{ // Node.InterLock = false; //} _ReportTarget.On_Command_Finished(Node, Txn, ReturnMsg); if (!Node.Type.Equals("LOADPORT")) { _ReportTarget.On_Node_State_Changed(Node, "StandBy"); } break; case CommandReturnMessage.ReturnType.Error: //if (Node.Type.Equals("LOADPORT")) //{ // Node.InterLock = false; //} _ReportTarget.On_Command_Error(Node, Txn, ReturnMsg); break; } } else { logger.Debug(DeviceName + "(On_Connection_Message Message decode fail:" + Msg); } } catch (Exception e) { logger.Error(DeviceName + "(On_Connection_Message " + IPAdress + ":" + Port.ToString() + ")" + e.Message + "\n" + e.StackTrace); } } } catch (Exception e) { logger.Error(DeviceName + "(On_Connection_Message " + IPAdress + ":" + Port.ToString() + ")" + e.Message + "\n" + e.StackTrace); } }
public static void UpdateSmifStatus(string NodeName, string Data) { try { Form form = Application.OpenForms["FormManual"]; ComboBox portName; if (form == null) { return; } portName = form.Controls.Find("Cb_SMIFSelect", true).FirstOrDefault() as ComboBox; if (portName == null) { return; } if (portName.InvokeRequired) { UpdateData ph = new UpdateData(UpdateSmifStatus); portName.BeginInvoke(ph, NodeName, Data); } else { if (portName.Text.Equals(NodeName)) { Node port = NodeManagement.Get(NodeName); MessageParser parser = new MessageParser(port.Brand); port.Status = parser.ParseMessage(Transaction.Command.LoadPortType.ReadStatus, Data); foreach (KeyValuePair <string, string> item in port.Status) { Label StsLb = form.Controls.Find(item.Key + "_lb", true).FirstOrDefault() as Label; if (StsLb != null) { StsLb.Text = item.Value; if (item.Key.Equals("SLOTPOS")) { ComboBox Slot_cb = form.Controls.Find("Move_To_Slot_cb", true).FirstOrDefault() as ComboBox; if (Slot_cb != null) { if (item.Value.Equals("255")) { Slot_cb.SelectedIndex = 0; } else { Slot_cb.SelectedIndex = Convert.ToInt32(item.Value); } } //Lab_I_Slot_11 for (int i = 1; i <= 25; i++) { StsLb = form.Controls.Find("Lab_I_Slot_" + i.ToString("00"), true).FirstOrDefault() as Label; if (i == Convert.ToInt32(item.Value)) { StsLb.BackColor = Color.Yellow; } else { StsLb.BackColor = Color.Silver; } } } } } } } } catch { logger.Error("UpdateSmifStatus: Update fail."); } }
private void Excute_bt_Click(object sender, EventArgs e) { ((Button)sender).Enabled = false; string PortName = ((Button)sender).Name.Replace("Excute_bt", ""); ComboBox cmd = this.Controls.Find(PortName + "Cmd_cb", true).FirstOrDefault() as ComboBox; if (cmd.Text.Equals("")) { return; } Transaction txn = new Transaction(new List <Job>(), "", "", "", "", 30000); switch (cmd.Text) { case "Load": txn.Method = Transaction.Command.LoadPortType.Load; break; case "Mapping Load": txn.Method = Transaction.Command.LoadPortType.MappingLoad; break; case "Mapping": txn.Method = Transaction.Command.LoadPortType.Mapping; break; case "Unload": txn.Method = Transaction.Command.LoadPortType.Unload; break; case "Mapping Unload": txn.Method = Transaction.Command.LoadPortType.MappingUnload; break; case "GetMapping": txn.Method = Transaction.Command.LoadPortType.GetMapping; break; case "GetLED": txn.Method = Transaction.Command.LoadPortType.GetLED; break; case "GetStatus": txn.Method = Transaction.Command.LoadPortType.GetStatus; break; case "Reset": txn.Method = Transaction.Command.LoadPortType.Reset; break; case "Initial Pos": txn.Method = Transaction.Command.LoadPortType.InitialPos; break; case "GetCount": txn.Method = Transaction.Command.LoadPortType.GetCount; break; } NodeManagement.Get(PortName).SendCommand(txn); }