Esempio n. 1
0
 /// <summary>
 /// 贴标队列处理,周期执行
 /// </summary>
 public void PrinterListProcess()
 {
     lock (lockPrintbuf)
     {
         if (!PLProcessModel.SysCfgModel.PrienterEnable)
         {
             this.printList.Clear();
             return;
         }
         if (this.printList.Count() == 0)
         {
             return;
         }
         string productBarcode = this.printList[0];
         int    mesRe          = 0;
         string reStr          = "";
         if (!SysCfgModel.MesOfflineMode && PLProcessModel.SysCfgModel.MesCheckEnable)
         {
             mesRe = mesDA.MesAssemDown(new string[] { productBarcode, LineMonitorPresenter.mesLineID }, ref reStr);
         }
         if (0 == mesRe)
         {
             if (!PLProcessModel.SysCfgModel.PrienterEnable)
             {
                 this.printList.Clear();
                 return;
             }
             bool re = prienterRW.SndBarcode(productBarcode, ref reStr);
             if (!re)
             {
                 string failInfo = string.Format("给贴标机发送条码{0} 失败,错误信息:{1}", productBarcode, reStr);
                 logRecorder.AddDebugLog(nodeName, failInfo);
             }
             else
             {
                 this.printList.Remove(productBarcode);
                 logRecorder.AddDebugLog(nodeName, "成功发送贴标条码:" + productBarcode + "," + reStr);
             }
         }
         else
         {
             MesStatRecord mesStat = NodePack.GetMequeryStat(productBarcode);
             if (mesStat != null)
             {
                 if (3 == mesStat.StatVal)
                 {
                     logRecorder.AddDebugLog(this.nodeName, productBarcode + ":MES禁止下线:" + reStr);
                     this.printList.Remove(productBarcode);
                     return;
                 }
             }
         }
     }
 }
Esempio n. 2
0
        /// <summary>
        /// 贴标队列处理,周期执行
        /// </summary>
        public void PrinterListProcess()
        {
            string productBarcode = "";

            lock (lockPrintbuf)
            {
                if (!PLProcessModel.SysCfgModel.PrienterEnable)
                {
                    this.printList.Clear();
                    return;
                }
                if (this.printList.Count() == 0)
                {
                    return;
                }
                productBarcode = this.printList[0];
            }
            int    mesRe = 0;
            string reStr = "";//!SysCfgModel.SimMode &&

            //DateTime mesSt = DateTime.Now;
            //if (!SysCfgModel.MesOfflineMode && PLProcessModel.SysCfgModel.MesCheckEnable)
            //{
            //    mesRe = mesDA.MesAssemDown(new string[] { productBarcode, LineMonitorPresenter.mesLineID }, ref reStr);
            //}
            //int queryInterval = 100;

            //while (mesRe != 0)
            //{
            //    MesStatRecord mesStat = NodePack.GetMequeryStat(productBarcode);
            //    if (mesStat != null)
            //    {
            //        if (3 == mesStat.StatVal)
            //        {
            //            logRecorder.AddDebugLog(this.nodeName, productBarcode + ":MES禁止下线:" + reStr);
            //            break;
            //        }
            //    }
            //    TimeSpan timeElapse = System.DateTime.Now - mesSt;
            //    if (timeElapse.TotalSeconds > (SysCfgModel.MesTimeout + 5))
            //    {
            //        break;
            //    }
            //    Thread.Sleep(queryInterval);
            //    mesRe = mesDA.MesAssemDown(new string[] { productBarcode, LineMonitorPresenter.mesLineID }, ref reStr);
            //}
            if (0 == mesRe)
            {
                bool re = prienterRW.SndBarcode(productBarcode, ref reStr);
                if (!re)
                {
                    string failInfo = string.Format("给贴标机发送条码{0} 失败,错误信息:{1}", productBarcode, reStr);
                    logRecorder.AddDebugLog(nodeName, failInfo);
                }
                else
                {
                    lock (lockPrintbuf)
                    {
                        this.printList.Remove(productBarcode);
                    }

                    logRecorder.AddDebugLog(nodeName, "成功发送贴标条码:" + productBarcode + "," + reStr);
                }
            }
            else
            {
                logRecorder.AddDebugLog(this.nodeName, productBarcode + ":MES下线查询超时," + reStr);
                lock (lockPrintbuf)
                {
                    this.printList.Remove(productBarcode);
                }
            }
        }
Esempio n. 3
0
        /// <summary>
        /// 异步发送条码给贴标机
        /// </summary>
        /// <param name="productBarcode"></param>
        /// <param name="reStr"></param>
        /// <returns></returns>
        private bool AsySndPrinterinfo(string productBarcode, ref string reStr)
        {
            if (!PLProcessModel.SysCfgModel.PrienterEnable)
            {
                reStr = "贴标机已经禁用";
                return(true);
            }
            int mesRe = 0;

            if (!SysCfgModel.MesOfflineMode && PLProcessModel.SysCfgModel.MesCheckEnable)
            {
                mesRe = mesDA.MesAssemDown(new string[] { productBarcode, LineMonitorPresenter.mesLineID }, ref reStr);
            }

            int      delayTimeOut  = 600;//
            int      queryInterval = 100;
            DateTime mesSt         = DateTime.Now;

            while (0 != mesRe)
            {
                //this.currentStat.StatDescribe = productBarcode + ":MES禁止下线:" + reStr;
                // logRecorder.AddDebugLog(this.nodeName, this.currentStat.StatDescribe);
                MesStatRecord mesStat = NodePack.GetMequeryStat(productBarcode);
                if (mesStat != null)
                {
                    if (3 == mesStat.StatVal)
                    {
                        logRecorder.AddDebugLog(this.nodeName, productBarcode + ":MES禁止下线:" + reStr);
                        return(false);
                    }
                }
                TimeSpan timeElapse = System.DateTime.Now - mesSt;
                if (timeElapse.TotalMilliseconds > delayTimeOut * 1000)
                {
                    break;
                }
                Thread.Sleep(queryInterval);
                mesRe = mesDA.MesAssemDown(new string[] { productBarcode, LineMonitorPresenter.mesLineID }, ref reStr);
            }
            if (0 == mesRe)
            {
                //PushBarcodeToBuf(productBarcode);
                bool re         = prienterRW.SndBarcode(productBarcode, ref reStr);
                int  reTryMax   = 20;
                int  tryCounter = 0;
                while (!re)
                {
                    tryCounter++;
                    string failInfo = string.Format("给贴标机发送条码{0} 失败,错误信息:{1}", productBarcode, reStr);
                    logRecorder.AddDebugLog(nodeName, failInfo);
                    if (tryCounter > reTryMax)
                    {
                        break;
                    }
                    Thread.Sleep(1000);
                    re = prienterRW.SndBarcode(productBarcode, ref reStr);
                }
                if (re)
                {
                    logRecorder.AddDebugLog(nodeName, "成功发送贴标条码:" + productBarcode + "," + reStr);
                    return(true);
                }
                else
                {
                    string failInfo = string.Format("给贴标机发送条码失败:{0},错误信息:{1}", productBarcode, reStr);
                    logRecorder.AddDebugLog(nodeName, failInfo);
                    return(false);
                }
            }
            else
            {
                string logStr = productBarcode + ":MES禁止下线:" + reStr;
                logRecorder.AddDebugLog(this.nodeName, logStr);
                return(false);
            }
        }
Esempio n. 4
0
        public override bool ExeBusiness(ref string reStr)
        {
            if (!NodeStatParse(ref reStr))
            {
                return(false);
            }

            switch (currentTaskPhase)
            {
            case 0:
            {
                db1ValsToSnd[0]                 = db1StatCheckNoneed; //空板进入,放行
                this.currentStat.Status         = EnumNodeStatus.工位有板;
                this.currentStat.ProductBarcode = "";
                this.currentStat.StatDescribe   = "空板";
                break;
            }

            case 1:
            {
                DevCmdReset();
                rfidUID = string.Empty;
                this.currentStat.Status         = EnumNodeStatus.设备空闲;
                this.currentStat.ProductBarcode = "";
                this.currentStat.StatDescribe   = "设备空闲";
                break;
            }

            case 2:
            {
                if (this.currentStat.Status == EnumNodeStatus.设备故障)
                {
                    break;
                }
                this.currentStat.Status         = EnumNodeStatus.设备使用中;
                this.currentStat.ProductBarcode = "";
                this.currentStat.StatDescribe   = "设备使用中";
                //开始读卡
                if (!SimMode)
                {
                    rfidUID = rfidRW.ReadUID();
                }
                else
                {
                    rfidUID = SimRfidUID;
                }
                if (!string.IsNullOrWhiteSpace(rfidUID))
                {
                    this.currentStat.StatDescribe = "RFID识别完成";
                    //根据绑定,查询条码,赋条码
                    OnlineProductsModel productBind = productBindBll.GetModelByrfid(rfidUID);
                    if (productBind == null)
                    {
                        db1ValsToSnd[0]               = db1StatRfidFailed;
                        this.currentTaskPhase         = 4;
                        this.currentStat.StatDescribe = "未投产";
                        break;
                    }

                    //查询本地数据库,之前工位是否有不合格项,若有,下线
                    if (!PreDetectCheck(productBind.productBarcode))
                    {
                        db1ValsToSnd[0] = db1StatNG;        //
                    }
                    barcode = productBind.productBarcode;
                    productBind.currentNode = this.nodeName;
                    productBindBll.Update(productBind);
                    BarcodeFillDB1(productBind.productBarcode, 1);
                    //状态赋条码,
                    this.currentStat.ProductBarcode = productBind.productBarcode;
                    currentTaskPhase++;
                }
                else
                {
                    db1ValsToSnd[0]               = db1StatRfidFailed;
                    this.currentStat.Status       = EnumNodeStatus.无法识别;
                    this.currentStat.StatDescribe = "读RFID卡失败";
                    break;
                }
                if (LineMonitorPresenter.DebugMode)
                {
                    logRecorder.AddDebugLog(this.nodeName, "读卡完成:" + rfidUID);
                }
                break;
            }

            case 3:
            {
                //查询MES是否允许下线
                if (0 != mesDA.MesAssemDown(new string[] { LineMonitorPresenter.mesLineID, barcode }, ref reStr))
                {
                    db1ValsToSnd[0] = db1StatNG;       //禁止下线

                    //检测不合格,下线
                    OutputRecord(this.currentStat.ProductBarcode);
                }
                else
                {
                    db1ValsToSnd[0] = db1StatCheckOK;        //允许下线
                }
                //发送条码到贴标机
                if (!prienterRW.SndBarcode(barcode, ref reStr))
                {
                    ThrowErrorStat("给贴标机发送条码失败", EnumNodeStatus.设备故障);
                    break;
                }
                this.currentStat.StatDescribe = "下线";
                if (LineMonitorPresenter.DebugMode)
                {
                    logRecorder.AddDebugLog(this.nodeName, "下线");
                }
                currentTaskPhase++;
                break;
            }

            case 4:
            {
                //流程结束
                break;
            }

            default:
                break;
            }
            return(true);
        }