public static void WriteWarmC(double num) { string ReadNumber = PLCCommon.Trans16((int)num); ReadNumber = PLCCommon.TransLengthToString(ReadNumber); PLCCommon.PLC_WRITE("1775", ReadNumber, "1"); }
public static void WriteSystemStop() { PLCCommon.PLC_WRITE("1702", "1", "1"); System.Threading.Thread.Sleep(200); PLCCommon.PLC_WRITE("1702", "0", "1"); PLCCommon.PLC_WRITE("1701", "0", "1"); }
public static void CheckTime() { DateTime dt = DateTime.Now; string TotalSendTime = PLCCommon.TransLengthToString(PLCCommon.Trans16((dt.Year).ToString())) + PLCCommon.TransLengthToString(PLCCommon.Trans16((dt.Month).ToString())) + PLCCommon.TransLengthToString(PLCCommon.Trans16((dt.Day).ToString())) + PLCCommon.TransLengthToString(PLCCommon.Trans16((dt.Minute).ToString())) + PLCCommon.TransLengthToString(PLCCommon.Trans16((dt.Second).ToString())); PLCCommon.PLC_WRITE("1780", TotalSendTime, "5"); }
public static void WriteWeight(string Weight) //NO => 1~8 { if (WeightStatus == false) { PLCCommon.PLC_WRITE("1770", Weight, "2"); } else { PLCCommon.PLC_WRITE("1772", Weight, "2"); } }
public static void WriteInColdSaveTime(string dt) { string Year = PLCCommon.TransLengthToString(PLCCommon.Trans16(dt.Substring(0, 4))); string Month = PLCCommon.TransLengthToString(PLCCommon.Trans16(dt.Substring(4, 2))); string Day = PLCCommon.TransLengthToString(PLCCommon.Trans16(dt.Substring(6, 2))); string TotalSendDate = Year + Month + Day; //PLCCommon.PLC_WRITE("1740", TotalSendDate,"3"); PLCCommon.PLC_WRITE("1740", Year, "1"); PLCCommon.PLC_WRITE("1741", Month, "1"); PLCCommon.PLC_WRITE("1742", Day, "1"); }
public static void WriteOutWarmTime() { DateTime dt = DateTime.Now; string TotalSendString = PLCCommon.TransLengthToString(PLCCommon.Trans16(dt.Year.ToString())) + PLCCommon.TransLengthToString(PLCCommon.Trans16(dt.Month.ToString())) + PLCCommon.TransLengthToString(PLCCommon.Trans16(dt.Day.ToString())) + PLCCommon.TransLengthToString(PLCCommon.Trans16(dt.Hour.ToString())) + PLCCommon.TransLengthToString(PLCCommon.Trans16(dt.Day.ToString())); //PLCCommon.PLC_WRITE("1760", PLCCommon.TransLengthToString(PLCCommon.Trans16(dt.Year.ToString())),"5"); PLCCommon.PLC_WRITE("1761", PLCCommon.TransLengthToString(PLCCommon.Trans16(dt.Month.ToString())), "1"); PLCCommon.PLC_WRITE("1762", PLCCommon.TransLengthToString(PLCCommon.Trans16(dt.Day.ToString())), "1"); PLCCommon.PLC_WRITE("1763", PLCCommon.TransLengthToString(PLCCommon.Trans16(dt.Hour.ToString())), "1"); PLCCommon.PLC_WRITE("1764", PLCCommon.TransLengthToString(PLCCommon.Trans16(dt.Day.ToString())), "1"); }
public static void WriteOperator() { PLCCommon.PLC_WRITE("1710", WriteInClod.NowLv, "1"); for (int i = 0; i < WriteInClod.NowName.Length; i++) { //SendTotlaWord += PLCCommon.TransLengthToString(PLCCommon.Trans16((int)WriteInClod.NowName[i])); PLCCommon.PLC_WRITE((1711 + i).ToString(), PLCCommon.TransLengthToString(PLCCommon.Trans16((int)WriteInClod.NowName[i])), "1"); } //PLCCommon.PLC_WRITE("1711", SendTotlaWord, WriteInClod.NowName.Length.ToString()); }
public static void WriteSystemPause() { switch (ATSData.AutomaticModeStatus) { case ATSData.AutomaticModeStatusType.Run: PLCCommon.PLC_WRITE("1701", "1", "1"); break; case ATSData.AutomaticModeStatusType.Pause: PLCCommon.PLC_WRITE("1701", "0", "1"); break; } }
public void WriteWeight(double Weight) { string num = PLCCommon.Trans16((int)(Weight)); string AfterPoint = PLCCommon.Trans16((int)(Weight * 1000) - (((int)(Weight)) * 1000)); num = PLCCommon.TransLengthToString(num); AfterPoint = PLCCommon.TransLengthToString(AfterPoint); string TotalSendWeight = AfterPoint + num; PLCCommon.PLC_WRITE("1772", TotalSendWeight, "2"); //PLCCommon.PLC_WRITE("1772", AfterPoint); //PLCCommon.PLC_WRITE("1773", num); }
public static void WriteStartTaskTime() { DateTime dt = DateTime.Now; string SendTotalStartTime = PLCCommon.TransLengthToString(PLCCommon.Trans16(dt.Year.ToString())) + PLCCommon.TransLengthToString(PLCCommon.Trans16(dt.Month.ToString())) + PLCCommon.TransLengthToString(PLCCommon.Trans16(dt.Day.ToString())) + PLCCommon.TransLengthToString(PLCCommon.Trans16(dt.Hour.ToString())) + PLCCommon.TransLengthToString(PLCCommon.Trans16(dt.Minute.ToString())); //PLCCommon.PLC_WRITE("1743", SendTotalStartTime,"5"); PLCCommon.PLC_WRITE("1743", PLCCommon.TransLengthToString(PLCCommon.Trans16(dt.Year.ToString())), "1"); PLCCommon.PLC_WRITE("1744", PLCCommon.TransLengthToString(PLCCommon.Trans16(dt.Month.ToString())), "1"); PLCCommon.PLC_WRITE("1745", PLCCommon.TransLengthToString(PLCCommon.Trans16(dt.Day.ToString())), "1"); PLCCommon.PLC_WRITE("1746", PLCCommon.TransLengthToString(PLCCommon.Trans16(dt.Hour.ToString())), "1"); PLCCommon.PLC_WRITE("1747", PLCCommon.TransLengthToString(PLCCommon.Trans16(dt.Minute.ToString())), "1"); }
public static void WriteOutColdTime() { //PLCCommon.PLC_WRITE("1755", "2", "1"); //PLCCommon.PLC_WRITE("1756", "1", "1"); DateTime dt = DateTime.Now; string SendWord = PLCCommon.TransLengthToString(PLCCommon.Trans16(dt.Year.ToString())) + PLCCommon.TransLengthToString(PLCCommon.Trans16(dt.Month.ToString())) + PLCCommon.TransLengthToString(PLCCommon.Trans16(dt.Day.ToString())) + PLCCommon.TransLengthToString(PLCCommon.Trans16(dt.Hour.ToString())) + PLCCommon.TransLengthToString(PLCCommon.Trans16(dt.Minute.ToString())); //PLCCommon.PLC_WRITE("1750", SendWord, "5"); PLCCommon.PLC_WRITE("1750", PLCCommon.TransLengthToString(PLCCommon.Trans16(dt.Year.ToString())), "1"); PLCCommon.PLC_WRITE("1751", PLCCommon.TransLengthToString(PLCCommon.Trans16(dt.Month.ToString())), "1"); PLCCommon.PLC_WRITE("1752", PLCCommon.TransLengthToString(PLCCommon.Trans16(dt.Day.ToString())), "1"); PLCCommon.PLC_WRITE("1753", PLCCommon.TransLengthToString(PLCCommon.Trans16(dt.Hour.ToString())), "1"); PLCCommon.PLC_WRITE("1754", PLCCommon.TransLengthToString(PLCCommon.Trans16(dt.Minute.ToString())), "1"); }
public static void WriteOperator(string Lv, string Name) { NowLv = Lv; NowName = Name; string TotalSendName = ""; PLCCommon.PLC_WRITE("1710", Lv, "1"); for (int i = 0; i < Name.Length; i++) { TotalSendName += PLCCommon.TransLengthToString(PLCCommon.Trans16((int)Name[i])); //PLCCommon.PLC_WRITE((1711 + i).ToString(), PLCCommon.TransLengthToString(PLCCommon.Trans16((int)Name[i]))); } PLCCommon.PLC_WRITE("1711", TotalSendName, Name.Length.ToString()); }
public static void WriteBarcoNo(string BarcoNumber) { if (BarcoNumber.Length % 2 == 0) { for (int i = 0; i < BarcoNumber.Length / 2; i++) { PLCCommon.PLC_WRITE((1730 + i).ToString(), PLCCommon.Trans16(BarcoNumber[(i * 2) + 1]) + PLCCommon.Trans16(BarcoNumber[(i * 2)]), "1"); } } else { for (int i = 0; i < BarcoNumber.Length / 2; i++) { PLCCommon.PLC_WRITE((1730 + i).ToString(), PLCCommon.Trans16(BarcoNumber[(i * 2) + 1]) + PLCCommon.Trans16(BarcoNumber[(i * 2)]), "1"); } PLCCommon.PLC_WRITE((1730 + (BarcoNumber.Length / 2)).ToString(), PLCCommon.TransLengthToString(PLCCommon.Trans16(BarcoNumber[BarcoNumber.Length - 1])), "1"); } //上下顛倒 Ex.8088X78 //for (int i = 0; i < BarcoNumber.Length; i++) //{ // PLCCommon.PLC_WRITE((1730 + i).ToString(), PLCCommon.TransLengthToString(PLCCommon.Trans16(BarcoNumber[i])), "1"); //} }
public static void WriteCommon(string Common) { //for (int i = 0; i < BarcoNumber.Length; i++) //{ // PLCCommon.PLC_WRITE((1730 + i).ToString(), PLCCommon.TransLengthToString(PLCCommon.Trans16(BarcoNumber[i])), "1"); //} //8088X78 7 if (Common.Length % 2 == 0) { for (int i = 0; i < Common.Length / 2; i++) { PLCCommon.PLC_WRITE((1730 + i).ToString(), PLCCommon.Trans16(Common[(i * 2) + 1]) + PLCCommon.Trans16(Common[(i * 2)]), "2"); } } else { for (int i = 0; i < Common.Length / 2; i++) { PLCCommon.PLC_WRITE((1730 + i).ToString(), PLCCommon.Trans16(Common[(i * 2) + 1]) + PLCCommon.Trans16(Common[(i * 2)]), "2"); } PLCCommon.PLC_WRITE((1730 + (Common.Length / 2)).ToString(), PLCCommon.TransLengthToString(PLCCommon.Trans16(Common[Common.Length - 1])), "1"); } }
public static void WriteIncoldStartFinally() { PLCCommon.PLC_WRITE("1001", "1", "1"); }
public void WriteOutCold(string No) //NO => 1~8 { PLCCommon.PLC_WRITE("1765", PLCCommon.TransLengthToString(No), "1"); }
private static void WriteOutColdReplyWarmLocation(string Location) { PLCCommon.PLC_WRITE("1812", Location, "1"); }
public static void WriteOutColdSeat(string OneorTwo) { PLCCommon.PLC_WRITE("1755", PLCCommon.TransLengthToString(OneorTwo), "1"); }
public static void WriteOutColdChoose(string No) { PLCCommon.PLC_WRITE("1754", PLCCommon.TransLengthToString(No), "1"); }
public static void WriteInitialize() { PLCCommon.PLC_WRITE("1700", "1", "1"); PLCCommon.PLC_WRITE("1700", "0", "1"); }
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); } } }