private static void WarmTaskStart() { TaskStop = false; for (int i = 1; i < PLCconnect.WriteOutCold.TsakNumber + 1; i++) { try { WriteOutWarmTime(); GetWeight = false; WeightStatus = false; GetLocation = false; string Location = ""; string FillBottle = ""; string EmptyBottle = ""; string SlotID = ""; CheckOnSite = false; int WarmType = 0; DateTime dt = DateTime.Now; do { if (ATSData.AutomaticModeStatus == ATSData.AutomaticModeStatusType.Stop) { TaskStop = true; } if (ReadSystemStatus.TaskLocation[3] != "0") { Location = ReadSystemStatus.TaskLocation[3]; WarmType = ReadSystemStatus.WarmType[int.Parse(Location) - 1]; WriteOutWarmReplyLocation(Location); GetLocation = true; SlotID = ATS.Models.UserData.Instance.SelectSlotID(Location); } System.Threading.Thread.Sleep(100); if ((DateTime.Now - dt).TotalSeconds > 3000) { ATSData.AutomaticModeStatus = ATSData.AutomaticModeStatusType.Stop; PLCCommon.ShowErrorInformation("回溫庫位對未失敗,請確認是否有機故", "超時提醒"); TaskStop = true; WarmThread.Abort(); break; } }while (GetLocation == false && TaskStop == false); do { if (ReadSystemStatus.PlcStatus[6]) { if (SystemConfig.WeightCheck == "1") { if (Convert.ToInt32(ReadSystemStatus.BottleWeight) == 0) { continue; } else { FillBottle = ReadSystemStatus.BottleWeight; StartSendWeight(FillBottle); GetWeight = true; ATS.Models.UserData.Instance.OutWarmFillWeight(Location, FillBottle); if (WeightEvent != null) { WeightEvent(FillBottle); } } } else { FillBottle = "100"; StartSendWeight("100"); GetWeight = true; ATS.Models.UserData.Instance.OutWarmFillWeight(Location, FillBottle); if (WeightEvent != null) { WeightEvent(FillBottle); } } } if (ATSData.AutomaticModeStatus == ATSData.AutomaticModeStatusType.Stop) { TaskStop = true; } Thread.Sleep(100); if ((DateTime.Now - dt).TotalSeconds > 3000) { ATSData.AutomaticModeStatus = ATSData.AutomaticModeStatusType.Stop; PLCCommon.ShowErrorInformation("超過時間沒有讀取到磅秤重量,請確認是否有機故", "超時提醒"); TaskStop = true; WarmThread.Abort(); break; } }while (GetWeight == false && TaskStop == false); GetWeight = false; dt = DateTime.Now; WeightStatus = true; do { if (ReadSystemStatus.PlcStatus[7]) { if (SystemConfig.WeightCheck == "1") { Thread.Sleep(2000); if (Convert.ToInt32(ReadSystemStatus.BottleWeight) == 0) { continue; } else { EmptyBottle = ReadSystemStatus.BottleWeight; if (Convert.ToInt32(EmptyBottle) / 1000 > Convert.ToInt32(SystemConfig.WeightDownLimit)) { PLCCommon.PLC_WRITE("1840", "1", "1"); PLCCommon.PLC_WRITE("1840", "0", "1"); System.Windows.Forms.MessageBox.Show("倒料失敗,膠材剩餘量過多(剩餘量超過設定值)"); WiseTech.Log.Logger.SystemLog("倒料失敗,膠材剩餘量過多(剩餘量超過設定值)"); TaskStop = true; } else { StartSendWeight(EmptyBottle); GetWeight = true; ATS.Models.UserData.Instance.OutWarmEmptyWeight(Location, EmptyBottle, FillBottle); ATS.Models.UserData.Instance.CreatCSVFile(Convert.ToInt32(Location), WarmType); if (EmptyWeightEvent != null) { EmptyWeightEvent(EmptyBottle); } } } } else { EmptyBottle = "100"; StartSendWeight("100"); GetWeight = true; ATS.Models.UserData.Instance.OutWarmEmptyWeight(Location, EmptyBottle, FillBottle); ATS.Models.UserData.Instance.CreatCSVFile(Convert.ToInt32(Location), WarmType); if (EmptyWeightEvent != null) { EmptyWeightEvent("100"); } } } if (ATSData.AutomaticModeStatus == ATSData.AutomaticModeStatusType.Stop) { TaskStop = true; } System.Threading.Thread.Sleep(100); if ((DateTime.Now - dt).TotalSeconds > 3000) { ATSData.AutomaticModeStatus = ATSData.AutomaticModeStatusType.Pause; PLCCommon.ShowErrorInformation("超過時間沒有讀取到磅秤重量,請確認是否有機故", "超時提醒"); TaskStop = true; WarmThread.Abort(); break; } }while (GetWeight == false && TaskStop == false); do { if (PLCconnect.ReadSystemStatus.PlcStatus[1] && (!PLCconnect.ReadSystemStatus.PlcStatus[2])) { OutWarmSuccess = true; ATS.Models.UserData.Instance.OutWarmSuccess(Location); } System.Threading.Thread.Sleep(1000); if ((DateTime.Now - dt).TotalSeconds > 3000) { ATSData.AutomaticModeStatus = ATSData.AutomaticModeStatusType.Pause; PLCCommon.ShowErrorInformation("丟料失敗,請確認是否有機故", "超時提醒"); TaskStop = true; WarmThread.Abort(); break; } if (ATSData.AutomaticModeStatus == ATSData.AutomaticModeStatusType.Stop) { TaskStop = true; } }while (OutWarmSuccess == false && TaskStop == false); //ATS.Models.UserData.Instance.OutWarmSuccess(Location, FillBottle, EmptyBottle); if (OutWarmSuccess == true || PLCconnect.WriteOutCold.TsakNumber == i) { PLCconnect.ReadSystemStatus.RecycleBottleNum += i; sc.SaveRecycleBottle(ReadSystemStatus.RecycleBottleNum.ToString()); if (RecycleBottleChange != null) { RecycleBottleChange(PLCconnect.ReadSystemStatus.RecycleBottleNum); } if (UpdateEvent != null) { UpdateEvent("", ""); } WarmSuccess success = new WarmSuccess(); success.TitleChange("批號 : " + SlotID + "\r\n 倒料完成 \r\n 完成時間 : " + DateTime.Now.ToString()); success.ShowDialog(); WeightStatus = false; OutWarmSuccess = false; GetWeight = false; } } catch (Exception err) { ATS.LCSCommon.WriteAppErrorLog(err); } } }
private static void InWarmTaskStart() { TaskStop = false; for (int i = 1; i < TsakNumber + 1; i++) { string ColdLocation = "0"; string WarmLocation = "0"; GetColdLocation = false; OutColdSuccess = false; GetWarmLocation = false; WriteOperator(); WriteOutColdTime(); //PLCCommon.PLC_WRITE("1766", "1"); DateTime dt = DateTime.Now; do { if (ATSData.AutomaticModeStatus == ATSData.AutomaticModeStatusType.Stop) { TaskStop = true; } Thread.Sleep(500); if (ReadSystemStatus.TaskLocation[1] != "0") { ColdLocation = ReadSystemStatus.TaskLocation[1]; WriteOutColdReplyColdLocation(ColdLocation); GetColdLocation = true; SpinWait.SpinUntil(() => { return(false); }, 5000); if (ReadSystemStatus.TaskLocation[1] != "0") { GetColdLocation = false; } } if ((DateTime.Now - dt).TotalSeconds > 300) { System.Windows.Forms.MessageBox.Show("入回溫作業逾時,請確認機台是否有機故", "訊息提醒"); TaskStop = true; PLCconnect.WriteSystem.WriteSystemStop(); ATSData.AutomaticModeStatus = ATSData.AutomaticModeStatusType.Stop; ATSData.MaintainModeStatus = ATSData.MaintainModeStatusType.Init; } }while (GetColdLocation == false && !TaskStop); if (TaskStop != true) { do { if (ReadSystemStatus.RobotResinID != "") { LotID = ReadSystemStatus.RobotResinID; } if (ATSData.AutomaticModeStatus == ATSData.AutomaticModeStatusType.Stop) { TaskStop = true; } Thread.Sleep(500); if (ReadSystemStatus.TaskLocation[2] != "0") { WarmLocation = ReadSystemStatus.TaskLocation[2]; WriteOutColdReplyWarmLocation(WarmLocation); GetWarmLocation = true; OutColdFirstSendInfo(int.Parse(WarmLocation)); ATS.Models.UserData.Instance.InWarmSuccess(ColdLocation, WarmLocation); SpinWait.SpinUntil(() => { return(false); }, 5000); if (ReadSystemStatus.TaskLocation[2] != "0") { GetWarmLocation = false; } } if ((DateTime.Now - dt).TotalSeconds > 300) { System.Windows.Forms.MessageBox.Show("入回溫作業逾時,請確認機台是否有機故", "訊息提醒"); PLCconnect.WriteSystem.WriteSystemStop(); ATSData.AutomaticModeStatus = ATSData.AutomaticModeStatusType.Stop; ATSData.MaintainModeStatus = ATSData.MaintainModeStatusType.Init; TaskStop = true; GetWarmLocation = true; WarmThread.Abort(); } }while (GetWarmLocation == false && !TaskStop); } if (TaskStop != true) { do { if (ATSData.AutomaticModeStatus == ATSData.AutomaticModeStatusType.Stop) { TaskStop = true; } Thread.Sleep(2000); if (!PLCconnect.ReadSystemStatus.PlcStatus[2]) { OutColdSuccess = true; } if ((DateTime.Now - dt).TotalSeconds > 300) { System.Windows.Forms.MessageBox.Show("入回溫作業逾時,請確認機台是否有機故", "訊息提醒"); PLCconnect.WriteSystem.WriteSystemStop(); ATSData.AutomaticModeStatus = ATSData.AutomaticModeStatusType.Stop; ATSData.MaintainModeStatus = ATSData.MaintainModeStatusType.Init; TaskStop = true; OutColdSuccess = true; } }while (OutColdSuccess == false && !TaskStop); } if (OutColdSuccess == true) { if (UpdateEvent != null) { UpdateEvent.Invoke(ColdLocation, WarmLocation); UpdateWarmEvent.Invoke(Convert.ToInt32(WarmLocation) - 1, "0", "0", 0); } if (i == TsakNumber) { if (TaskOverEvent != null) { TaskOverEvent.Invoke(ColdLocation, WarmLocation); } PLCconnect.WarmSuccess success = new WarmSuccess(); success.TitleChange("入回溫完成"); success.Location = new System.Drawing.Point(940, 500); success.ShowDialog(); } } } }
public static void MatchDataWithBarcoThread() { try { TaskFail = false; //BarcoReader = "1801930101;;8088X78;1.4;20190224;20180825"; string[] BarcoReaderList = BarcoReader.Split(';'); if (BarcoReaderList[2] == SlotThread && BarcoReaderList[4] == OverTimeThread) { SlotThread = SlotThread + "-" + WiseTech.Log.Logger.TodayTaskNumber(SlotThread); WriteStartTaskTime(); string Location = "0"; DateTime dt = DateTime.Now; bool CheckLocation = false; UserData.Instance.InColdStart(SlotThread, OverTimeThread, Location); UserData.Instance.InColdWriteLotBottleInfo(SlotThread, BarcoReader); do { if (ATSData.AutomaticModeStatus == ATSData.AutomaticModeStatusType.Stop) { TaskFail = true; } if (ReadSystemStatus.TaskLocation[0] != "0") { Location = ReadSystemStatus.TaskLocation[0]; UserData.Instance.InColdLocationUpdate(SlotThread, Location); Thread.Sleep(1000); WriteIncoldCheckGetInformation(ReadSystemStatus.TaskLocation[0]); CheckLocation = true; SpinWait.SpinUntil(() => { return(false); }, 5000); if (ReadSystemStatus.TaskLocation[0] != "0") { CheckLocation = false; } } if ((DateTime.Now - dt).TotalSeconds > 300) { MessageBox.Show("入庫失敗:冷藏庫開啟逾時,請確認是否有機故"); WiseTech.Log.Logger.SystemLog("入冷藏失敗: 冷藏庫開啟逾時,請確認是否有機故"); CheckLocation = true; TaskSuccess = true; TaskFail = true; } }while (CheckLocation == false && !TaskFail); do { if (ATSData.AutomaticModeStatus == ATSData.AutomaticModeStatusType.Stop) { TaskFail = true; } if (ReadSystemStatus.PlcStatus[2] == false) { if (Update != null) { Update.Invoke(Location, SlotThread, OverTimeThread); } if (Success != null) { Success.Invoke(true); } TaskSuccess = true; //ATS.Models.UserData.Instance.InColdSuccess(Slot, Overtime, Location); } if ((DateTime.Now - dt).TotalSeconds > 500) { MessageBox.Show("入庫失敗:完成流程未回到定位,請確認是否有機故"); WiseTech.Log.Logger.SystemLog("入庫失敗:完成流程未回到定位,請確認是否有機故"); TaskSuccess = true; TaskFail = true; } }while (TaskSuccess == false || !TaskFail); if (TaskSuccess && !TaskFail) { if (UpdateEvent != null) { UpdateEvent(Location, SlotThread); } WarmSuccess success = new WarmSuccess(); success.TitleChange("入冷藏完成"); success.Location = new System.Drawing.Point(940, 500); success.ShowDialog(); } } else { MessageBox.Show("條碼比對錯誤比對錯誤", "訊息錯誤警告"); } } catch (Exception err) { ATS.LCSCommon.WriteRunLog(err.Message); } }