예제 #1
0
        private bool AsrsPortBarcodeCheck(AsrsPortalModel port, ref string reStr)
        {
            try
            {
                string[] checkNodeids = new string[] { "2013", "2017", "2021" };
                if (!checkNodeids.Contains(port.NodeID))
                {
                    return(true);
                }
                bool re = true;
                for (int i = 0; i < port.PortinBufCapacity; i++)
                {
                    if (port.Db2Vals[i] == 2)
                    {
                        if (port.PalletBuffer.Count < i + 1)
                        {
                            re    = false;
                            reStr = reStr + "系统记录的缓存托盘数量跟实际不符,缓存托盘数量:" + port.PalletBuffer.Count.ToString();
                            break;
                        }
                        string strBarcodeRail = port.PalletBuffer[i].Substring(port.PalletBuffer[i].Length - 4, 4);
                        int    iBarcode       = 0;
                        if (!int.TryParse(strBarcodeRail, out iBarcode))
                        {
                            reStr = reStr + "条码校验失败,解析条码后4位错误,条码:" + port.PalletBuffer[i];
                            re    = false;
                            break;
                        }
                        if (iBarcode != port.Db2Vals[i + 3])
                        {
                            re    = false;
                            reStr = reStr + string.Format("条码校验失败,缓存条码后4位{0},PLC系统反馈条码后4位{1}", iBarcode, port.Db2Vals[i + 3]);

                            break;
                        }
                    }
                }
                if (!re)
                {
                    port.Db1ValsToSnd[0] = 4;
                }
                return(re);
            }
            catch (Exception ex)
            {
                reStr = ex.Message;
                return(false);
            }
        }
예제 #2
0
        private bool AsrsCheckinGroupEnabled(AsrsPortalModel port, string palletID, ref string reStr)
        {
            int step = 0;

            if (!port.MesAcc.GetStep(palletID, out step, ref reStr))
            {
                Console.WriteLine("在组盘入库判断过程中,查询托盘步号失败,因为:" + reStr);
                return(false);
            }
            if (port.PortinBufCapacity < 2)
            {
                return(true);
            }
            else //只有入口最大允许缓存数量大于1时才考虑库区,批次
            {
                if (port.PalletBuffer.Count() > 0)
                {
                    //1 判断是否同一个库区
                    string lastPalletID = port.PalletBuffer[0];
                    string lastCata     = lastPalletID.Substring(0, 4);
                    string cata         = palletID.Substring(0, 4);
                    int    lastStep     = 0;
                    if (!port.MesAcc.GetStep(lastPalletID, out lastStep, ref reStr))
                    {
                        return(false);
                    }
                    string areaLast = port.AsrsCtl.GetAreaToCheckin(lastPalletID, lastStep).ToString(); // AsrsModel.EnumLogicArea.注液高温区.ToString();
                    // areaLast=SysCfg.SysCfgModel.asrsStepCfg.AsrsAreaSwitch(lastStep);
                    string areaCur = port.AsrsCtl.GetAreaToCheckin(palletID, step).ToString();          //AsrsModel.EnumLogicArea.注液高温区.ToString(); ;
                    //     areaCur=SysCfg.SysCfgModel.asrsStepCfg.AsrsAreaSwitch(step);

                    if (areaLast != areaCur)
                    {
                        reStr = string.Format("托盘{0}待进入的立库分区{1},跟当前缓存托盘待进入的分区{2}不同", palletID, areaCur, areaLast);
                        return(false);
                    }
                    if (step > 0)
                    {
                        //2 是否同批
                        string batchLast = "";
                        string batch     = "";
                        if (!port.MesAcc.GetTrayCellLotNO(palletID, out batch, ref reStr))
                        {
                            return(false);
                        }
                        if (!port.MesAcc.GetTrayCellLotNO(lastPalletID, out batchLast, ref reStr))
                        {
                            return(false);
                        }
                        if (batchLast != batch)
                        {
                            reStr = string.Format("托盘{0} 批次{1},与入口缓存的托盘{2} 批次{3}不同", palletID, batch, lastPalletID, batchLast);
                            return(false);
                        }
                        ////3 是否同型号
                        if (lastCata != cata)
                        {
                            return(false);
                        }
                    }
                    return(true);
                }
                return(true);
            }
        }
예제 #3
0
        public bool ProcessInit()
        {
            // nodeList = new List<CtlNodeBaseModel>();
            MesAcc = new YHMesWrapper();

            monitorNodeList     = new List <CtlNodeBaseModel>();
            this.nodeStatusList = new List <CtlNodeStatus>();
            //解析配置文件
            string reStr = "";
            //string xmlCfgFile = System.AppDomain.CurrentDomain.BaseDirectory + @"data/AcCfg.xml";
            XElement root = null;

            if (!SysCfg.SysCfgModel.LoadCfg(ref root, ref reStr))
            {
                Console.WriteLine("系统配置解析错误,{0}", reStr);
                return(false);
            }


            //1 通信设备创建、初始化
            hkAccessList = new List <IHKAccess>();
            if (SysCfg.SysCfgModel.SimMode)
            {
                plcRWs = new List <IPlcRW>();
                for (int i = 0; i < 5; i++)
                {
                    IPlcRW plcRW = new PlcRWSim();
                    plcRW.PlcID = i + 1;
                    plcRWs.Add(plcRW);
                }
                rfidRWs = new List <IrfidRW>();
                for (int i = 0; i < 13; i++)
                {
                    int     rfidID = i + 1;
                    IrfidRW rfidRW = new rfidRWSim();
                    rfidRW.ReaderID = (byte)rfidID;
                    rfidRWs.Add(rfidRW);
                }
                HKAccess hk = new HKAccess(1, "127.0.0.1", 13535);
                hkAccessList.Add(hk);
                hk = new HKAccess(2, "127.0.0.1", 13535);
                hkAccessList.Add(hk);
                if (!hk.Conn(ref reStr))
                {
                    Console.WriteLine(reStr);
                }
                string ocvDBConn = "Data Source = 192.168.100.20;Initial Catalog=SRANCH;User ID=L_Guest;Password=Guest@123;";;  //
                ocvAccess = new OcvAccess(ocvDBConn, 36);
            }
            else
            {
                XElement commDevXERoot = root.Element("CommDevCfg");
                if (!ParseCommDevCfg(commDevXERoot, ref reStr))
                {
                    //logRecorder.AddLog(new LogModel(objectName, "PLC初始化错误,"+reStr, EnumLoglevel.错误));
                    Console.WriteLine("通信设备错误," + reStr);
                    return(false);
                }
            }

            //2 控制节点初始化
            XElement CtlnodeRoot = root.Element("CtlNodes");

            if (!ParseCtlnodes(CtlnodeRoot, ref reStr))
            {
                logRecorder.AddLog(new LogModel(objectName, "节点初始化错误," + reStr, EnumLoglevel.错误));
                return(false);
            }
            foreach (AsrsCtlModel asrsModel in asrsCtlPresenter.AsrsCtls)
            {
                monitorNodeList.Add(asrsModel.StackDevice);
                monitorNodeList.AddRange(asrsModel.Ports.ToArray());
            }

            //3 工位控制线程初始化
            this.threadList = new List <ThreadRunModel>();
            XElement ThreadnodeRoot = root.Element("ThreadAlloc");

            if (!ParseTheadNodes(ThreadnodeRoot, ref reStr))
            {
                logRecorder.AddLog(new LogModel(objectName, "任务分配错误," + reStr, EnumLoglevel.错误));
                return(false);
            }
            NodeSwitch switchNode = GetNodeByID("7001") as NodeSwitch;
            List <AsrsControl.AsrsPortalModel> targetPorts = new List <AsrsPortalModel>();

            foreach (string portID in switchNode.TargetPortIDs)
            {
                AsrsPortalModel portObj = GetNodeByID(portID) as AsrsControl.AsrsPortalModel;
                targetPorts.Add(portObj);
            }
            switchNode.TargetPorts = targetPorts;

            foreach (ThreadRunModel threadObj in threadList)
            {
                threadObj.LogRecorder = logRecorder;
            }

            for (int i = 0; i < this.monitorNodeList.Count(); i++)
            {
                CtlNodeBaseModel node = this.monitorNodeList[i];
                node.LogRecorder = this.logRecorder;
                this.nodeStatusList.Add(node.CurrentStat);
            }

            //ThreadRunModel palletBindThread = new ThreadRunModel("工装板绑定");
            //palletBindThread.TaskInit();
            //CtlNodeBaseModel palletBindNode = GetNodeByID("6001");
            //if(palletBindNode != null && palletBindNode.NodeEnabled)
            //{
            //    palletBindThread.AddNode(palletBindNode);
            //}
            //this.threadList.Add(palletBindThread);

            //4 plc通信线程初始化

            //5 历史数据清理线程
            historyDataClearThread = new ThreadBaseModel("历史数据集清理");

            historyDataClearThread.SetThreadRoutine(ClearHistoryLoop);
            historyDataClearThread.LoopInterval = 60000;
            historyDataClearThread.TaskInit();


            //5 通信对象分配
            asrsCtlPresenter.PlcRWs     = this.plcRWs;
            asrsCtlPresenter.RfidRWs    = this.rfidRWs;
            asrsCtlPresenter.BarcodeRWs = this.barcodeRWList;
            foreach (AsrsCtlModel asrsCtl in asrsCtlPresenter.AsrsCtls)
            {
                asrsCtl.MesAcc = this.MesAcc;
                if (asrsCtl.HouseName == AsrsModel.EnumStoreHouse.A1库房.ToString())
                {
                    asrsCtl.dlgtGetTaskTorun = GetCheckoutOfA1;
                }
            }
            if (!asrsCtlPresenter.AsrsCommCfg())
            {
                return(false);
            }

            //view.InitNodeMonitorview();
            bool re = asrsCtlPresenter.DevStatusRestore();

            if (!re)
            {
                return(false);
            }
            return(true);
        }
예제 #4
0
        /// <summary>
        /// 是否组盘入库允许
        /// </summary>
        /// <param name="port"></param>
        /// <param name="palletID"></param>
        /// <param name="reStr"></param>
        /// <returns></returns>
        private bool AsrsCheckinGroupEnabled(AsrsPortalModel port, string palletID, ref string reStr)
        {
            int step = 0;

            if (!port.MesAcc.GetStep(palletID, out step, ref reStr))
            {
                Console.WriteLine("在组盘入库判断过程中,查询托盘步号失败,因为:" + reStr);
                return(false);
            }
            if (port.PortinBufCapacity < 2)
            {
                return(true);
            }
            else //只有入口最大允许缓存数量大于1时才考虑库区,批次
            {
                if (port.PalletBuffer.Count() > 0)
                {
                    //1 判断是否同一个库区
                    string lastPalletID = port.PalletBuffer[0];
                    string lastCata     = lastPalletID.Substring(0, 4);
                    string cata         = palletID.Substring(0, 4);
                    int    lastStep     = 0;
                    if (!port.MesAcc.GetStep(lastPalletID, out lastStep, ref reStr))
                    {
                        return(false);
                    }

                    string areaLast = port.AsrsCtl.GetAreaToCheckin(lastPalletID, lastStep).ToString(); // AsrsModel.EnumLogicArea.注液高温区.ToString();
                    // areaLast=SysCfg.SysCfgModel.asrsStepCfg.AsrsAreaSwitch(lastStep);
                    string areaCur = port.AsrsCtl.GetAreaToCheckin(palletID, step).ToString();          //AsrsModel.EnumLogicArea.注液高温区.ToString(); ;
                    //     areaCur=SysCfg.SysCfgModel.asrsStepCfg.AsrsAreaSwitch(step);

                    if (areaLast != areaCur)
                    {
                        reStr = string.Format("托盘{0}待进入的立库分区{1},跟当前缓存托盘待进入的分区{2}不同", palletID, areaCur, areaLast);
                        return(false);
                    }
                    if (step > 0)
                    {
                        //2 是否同批
                        string batchLast = "";
                        string batch     = "";
                        if (!port.MesAcc.GetTrayCellLotNO(palletID, out batch, ref reStr))
                        {
                            return(false);
                        }
                        if (!port.MesAcc.GetTrayCellLotNO(lastPalletID, out batchLast, ref reStr))
                        {
                            return(false);
                        }
                        if (batchLast != batch)
                        {
                            reStr = string.Format("托盘{0} 批次{1},与入口缓存的托盘{2} 批次{3}不同", palletID, batch, lastPalletID, batchLast);
                            return(false);
                        }
                        ////3 是否同型号
                        //if (port.NodeID == "2011" || port.NodeID == "2015" || port.NodeID == "2019")
                        //{
                        //    if (lastCata != cata)
                        //    {
                        //        return false;
                        //    }
                        //}
                    }
                    else
                    {
                        //空筐,只判断筐子类型
                        MesDBAccess.BLL.BatteryCataBll     batteryCataBll = new MesDBAccess.BLL.BatteryCataBll();
                        MesDBAccess.Model.BatteryCataModel batCata        = batteryCataBll.GetModel(cata);
                        if (batCata == null)
                        {
                            reStr = "不存在的电池型号配置:" + cata;
                            Console.Write(reStr);
                            return(false);
                        }
                        if (batCata.palletCataID == "A筐")
                        {
                            if ((port.NodeID != "2013") && (port.NodeID != "2017"))
                            {
                                return(false);
                            }
                        }
                        else if (batCata.palletCataID == "B筐")
                        {
                            if (port.NodeID != "2021")
                            {
                                return(false);
                            }
                        }
                        else
                        {
                            reStr = "不存在的筐类型配置:" + batCata.palletCataID;
                            return(false);
                        }
                    }

                    return(true);
                }
                return(true);
            }
        }
예제 #5
0
        /// <summary>
        /// 判断物流线是否堵塞,选择出库任务
        /// </summary>
        /// <param name="asrsCtl"></param>
        /// <param name="asrsResManage"></param>
        /// <param name="taskList"></param>
        /// <param name="taskType"></param>
        /// <returns></returns>
        public CtlDBAccess.Model.ControlTaskModel AsrsCheckoutTaskTorun(AsrsControl.AsrsCtlModel asrsCtl, IAsrsManageToCtl asrsResManage, IList <CtlDBAccess.Model.ControlTaskModel> taskList, SysCfg.EnumAsrsTaskType taskType)
        {
            try
            {
                if (taskList == null)
                {
                    return(null);
                }

                string houseName = asrsCtl.HouseName;
                CtlDBAccess.Model.ControlTaskModel task = null;
                foreach (CtlDBAccess.Model.ControlTaskModel t in taskList)
                {
                    if (t.TaskStatus != "待执行")
                    {
                        continue;
                    }
                    string             reStr      = "";
                    AsrsTaskParamModel paramModel = new AsrsTaskParamModel();
                    if (!paramModel.ParseParam(taskType, t.TaskParam, ref reStr))
                    {
                        continue;
                    }
                    AsrsPortalModel port          = asrsCtl.Ports[paramModel.OutputPort - 1];
                    int             switchPathSeq = 1;
                    CellCoordModel  cell          = paramModel.CellPos1;
                    if (asrsCtl.NodeName == "A1库房" || asrsCtl.HouseName == "A2库房")
                    {
                        string area = "注液高温区";
                        if (!this.asrsResManage.GetLogicAreaName(houseName, cell, ref area))
                        {
                            continue;
                        }
                        if (area == "注液高温区")
                        {
                            switchPathSeq = 1;
                        }
                        else if (area == "化成高温区")
                        {
                            switchPathSeq = 2;
                        }
                        else
                        {
                            continue;
                        }
                        if (port.Db2Vals[switchPathSeq] != 1)
                        {
                            continue;
                        }
                    }
                    else if (asrsCtl.HouseName == "C1库房" || asrsCtl.HouseName == "C2库房" || asrsCtl.HouseName == "C3库房")
                    {
                        if (taskType == SysCfg.EnumAsrsTaskType.空筐出库)
                        {
                            if (port.Db2Vals[switchPathSeq] != 1)
                            {
                                continue;
                            }
                        }
                    }

                    AsrsModel.EnumGSEnabledStatus cellEnabledStatus = AsrsModel.EnumGSEnabledStatus.启用;
                    if (!asrsResManage.GetCellEnabledStatus(houseName, paramModel.CellPos1, ref cellEnabledStatus))
                    {
                        // reStr = "获取货位启用状态失败";
                        continue;
                    }
                    if (cellEnabledStatus == AsrsModel.EnumGSEnabledStatus.禁用)
                    {
                        continue;
                    }
                    task = t;
                    break;
                }
                return(task);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
                return(null);
            }
        }