示例#1
0
        public static void WriteWarmC(double num)
        {
            string ReadNumber = PLCCommon.Trans16((int)num);

            ReadNumber = PLCCommon.TransLengthToString(ReadNumber);
            PLCCommon.PLC_WRITE("1775", ReadNumber, "1");
        }
示例#2
0
        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");
        }
示例#3
0
        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");
        }
示例#4
0
        public string ReadSaveTime()
        {
            string Result = "";

            for (int i = 0; i < 3; i++)
            {
                Result += PLCCommon.Trans16To10(PLCCommon.PLC_READ((1620 + i).ToString())) + ":";
            }
            return(Result);
        }
示例#5
0
        public string ReadOperatorWarmOut()
        {
            string Result = "";

            for (int i = 0; i < 9; i++)
            {
                Result += PLCCommon.PLC_READ((1651 + i).ToString());
            }
            return(Result);
        }
示例#6
0
        internal static string TransLenghtByString(string SendWord)
        {
            string TotalSend = "";

            for (int i = 0; i < SendWord.Length; i++)
            {
                TotalSend += PLCCommon.TransLengthToString(PLCCommon.Trans16(SendWord[i]));
            }
            return(TotalSend);
        }
示例#7
0
        public string ReadBarcoNo()
        {
            string Result = "";

            for (int i = 0; i < 20; i++)
            {
                Result += PLCCommon.PLC_READ((1610 + i).ToString());
            }
            return(Result);
        }
示例#8
0
 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");
     }
 }
示例#9
0
 public static void StartSendWeight(string Weight)
 {
     WeightGet = PLCCommon.Trans16(Weight);
     while (WeightGet.Length < 9)
     {
         WeightGet = "0" + WeightGet;
     }
     WeightGet = WeightGet.Substring(4, 4) + WeightGet.Substring(0, 4);
     WriteWeight(WeightGet);
     GetWeight = true;
 }
示例#10
0
        public string ReadWeight()
        {
            string Result = "";

            for (int i = 0; i < 2; i++)
            {
                string Word = PLCCommon.PLC_READ((1692 + i).ToString());
                Result += Word;
            }
            return(Result);
        }
示例#11
0
        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");
        }
示例#12
0
        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");
        }
示例#13
0
 private static void CheckBuzzer()
 {
     //List<string> Status = PLCCommon.ScanPLC_READ("1861", "1");
     Status = PLCCommon.ScanPLC_READ("1861", "1");
     if (Status[0] == "1")
     {
         BuzzerOnOff = false;
     }
     else
     {
         BuzzerOnOff = true;
     }
 }
示例#14
0
        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());
        }
示例#15
0
        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;
            }
        }
示例#16
0
        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");
        }
示例#17
0
        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);
        }
示例#18
0
        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");
        }
示例#19
0
        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());
        }
示例#20
0
        public string ReadTaskStartTime()
        {
            string Result = "";

            for (int i = 0; i < 5; i++)
            {
                string Word = PLCCommon.PLC_READ((1660 + i).ToString());
                if (Word != "")
                {
                    Result += Word + ":";
                }
                else
                {
                    Result += "0";
                }
            }
            return(Result);
        }
示例#21
0
 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");
     }
 }
示例#22
0
 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");
     //}
 }
示例#23
0
 public string ReadClod8()
 {
     return(PLCCommon.PLC_READ("1597"));
 }
示例#24
0
 public static void WriteOutColdChoose(string No)
 {
     PLCCommon.PLC_WRITE("1754", PLCCommon.TransLengthToString(No), "1");
 }
示例#25
0
 public string ReadOperatorLVWarmOut()
 {
     return(PLCCommon.PLC_READ("1651"));
 }
示例#26
0
 public string ReadOperatorLVColdOut()
 {
     return(PLCCommon.PLC_READ("1640"));
 }
示例#27
0
 public string ReadWarm8()
 {
     return(PLCCommon.PLC_READ("1607"));
 }
示例#28
0
        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);
                }
            }
        }
示例#29
0
 public static void WriteOutColdSeat(string OneorTwo)
 {
     PLCCommon.PLC_WRITE("1755", PLCCommon.TransLengthToString(OneorTwo), "1");
 }
示例#30
0
 private static void WriteOutColdReplyWarmLocation(string Location)
 {
     PLCCommon.PLC_WRITE("1812", Location, "1");
 }