Example #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;
                 }
             }
         }
     }
 }
Example #2
0
        private bool ParseCtlnodes(XElement CtlnodeRoot, ref string reStr)
        {
            if (CtlnodeRoot == null)
            {
                reStr = "系统配置文件错误,不存在CtlNodes节点";
                return(false);
            }
            try
            {
                IEnumerable <XElement> nodeXEList =
                    from el in CtlnodeRoot.Elements()
                    where el.Name == "Node"
                    select el;
                foreach (XElement el in nodeXEList)
                {
                    string           className = (string)el.Attribute("className");
                    CtlNodeBaseModel ctlNode   = null;
                    switch (className)
                    {
                    case "LineNodes.ProductInput":
                    {
                        ctlNode = new NodeProductInput();
                        break;
                    }

                    case "LineNodes.NodeAirlossCheck":
                    {
                        ctlNode = new NodeAirlossCheck();
                        break;
                    }

                    case "LineNodes.NodeFireZero":
                    {
                        ctlNode = new NodeFireZero();
                        break;
                    }

                    case "LineNodes.NodeFireTryingA":
                    {
                        ctlNode = new NodeFireTryingA();
                        break;
                    }

                    case "LineNodes.NodeFireTryingB":
                    {
                        ctlNode = new NodeFireTryingB();
                        break;
                    }

                    case "LineNodes.NodeFaceCheck":
                    {
                        ctlNode = new NodeFaceCheck();
                        break;
                    }

                    case "LineNodes.NodePack":
                    {
                        ctlNode = new NodePack();
                        break;
                    }

                    case "LineNodes.NodeRobotPallet":
                    {
                        ctlNode = new NodeRobotPallet();
                        break;
                    }

                    default:
                        break;
                    }
                    if (ctlNode != null)
                    {
                        if (!ctlNode.BuildCfg(el, ref reStr))
                        {
                            return(false);
                        }
                        //Console.WriteLine(ctlNode.NodeName + ",ID:" + ctlNode.NodeID + "创建成功!");
                        this.nodeList.Add(ctlNode);
                    }
                }
            }
            catch (Exception ex)
            {
                reStr = ex.ToString();
                return(false);
            }

            return(true);
        }
Example #3
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 = "";//!NodeFactory.SimMode &&
            DateTime mesSt = DateTime.Now;

            try
            {
                if (!SysCfgModel.MesOfflineMode && PLProcessModel.SysCfgModel.MesCheckEnable)
                {
                    mesRe = mesDA.MesAssemDown(new string[] { productBarcode, LineMonitorPresenter.mesLineID }, ref reStr);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
            }

            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 + 10))
                {
                    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);
                }
            }
        }
Example #4
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);
            }
        }