示例#1
0
        //出库后任务处理,通知物流线是空筐还是满筐
        private bool AsrsOutTaskBusiness(AsrsControl.AsrsPortalModel outPort, CtlDBAccess.Model.ControlTaskModel task, ref string reStr)
        {
            try
            {
                if (task == null)
                {
                    reStr = "任务为空";
                    return(false);
                }
                if (task.TaskType == (int)SysCfg.EnumAsrsTaskType.产品出库)
                {
                    outPort.Db1ValsToSnd[1] = 2;
                }
                else if (task.TaskType == (int)SysCfg.EnumAsrsTaskType.空筐出库)
                {
                    outPort.Db1ValsToSnd[1] = 1;
                }
                if (!outPort.NodeCmdCommit(true, ref reStr))
                {
                    reStr = string.Format("出库站台{0}状态'出库完成'提交失败", outPort.PortSeq);
                    return(false);
                }
                System.Threading.Thread.Sleep(500);

                return(true);
            }
            catch (Exception ex)
            {
                reStr = ex.ToString();
                return(false);
            }
        }
示例#2
0
        private void OnSave()
        {
            MesDBAccess.BLL.AsrsPortBufferBll portBufBll = new AsrsPortBufferBll();
            if (!portNameMap.Keys.Contains(this.comboBoxPortin.Text))
            {
                MessageBox.Show("不存在的入库口");
                return;
            }

            string          portID   = portNameMap[this.comboBoxPortin.Text];
            AsrsPortalModel asrsPort = GetPortByID(portID);

            if (asrsPort == null)
            {
                MessageBox.Show("不存在的入库口对象");
                return;
            }


            AsrsPortBufferModel bufModel = portBufBll.GetModel(portID);

            if (bufModel == null)
            {
                MessageBox.Show("数据库不存在该入口对象ID:" + portID);
                return;
            }
            string strPallets = "";

            asrsPort.PalletBuffer.Clear();
            for (int i = 0; i < this.listBoxPallet.Items.Count; i++)
            {
                asrsPort.PushPalletID(this.listBoxPallet.Items[i].ToString());

                if (i == (this.listBoxPallet.Items.Count - 1))
                {
                    strPallets += this.listBoxPallet.Items[i].ToString();
                }
                else
                {
                    strPallets += this.listBoxPallet.Items[i].ToString() + ",";
                }
            }
            bufModel.palletBuffers = strPallets;
            portBufBll.Update(bufModel);
        }
示例#3
0
        private bool AsrsOutTaskBusiness(AsrsControl.AsrsPortalModel outPort, AsrsControl.AsrsTaskParamModel taskParam, ref string reStr)
        {
            try
            {
                outPort.Db1ValsToSnd[1] = (short)taskParam.CellPos1.Row;
                if (!outPort.NodeCmdCommit(true, ref reStr))
                {
                    reStr = string.Format("出库站台{0}状态'出库完成'提交失败", outPort.PortSeq);
                    return(false);
                }
                System.Threading.Thread.Sleep(500);

                return(true);
            }
            catch (Exception ex)
            {
                reStr = ex.ToString();
                return(false);
            }
        }
示例#4
0
 private bool AsrsOutportBusiness(AsrsControl.AsrsPortalModel port, ref string reStr)
 {
     try
     {
         if (port.PortCata == 2)
         {
             //出口,无板时,出库完成信号复位
             if (port.Db2Vals[0] == 2) //无板时,DB1复位
             {
                 // port.DevCmdReset();
                 port.Db1ValsToSnd[0] = 1;
                 port.Db1ValsToSnd[1] = 0;
             }
         }
         return(true);
     }
     catch (Exception ex)
     {
         reStr = ex.ToString();
         return(false);
     }
 }
示例#5
0
        public override bool ExeBusiness(ref string reStr)
        {
            if (!devStatusRestore)
            {
                devStatusRestore = DevStatusRestore();
            }
            if (db2Vals[0] == 1)
            {
                currentTaskPhase = 0;
                Array.Clear(this.db1ValsToSnd, 0, this.db1ValsToSnd.Count());
                rfidUID             = string.Empty;
                currentTaskDescribe = "等待新的任务";
                //return true;
            }
            //if(db1ValsToSnd[0] >1) //分流完成后
            //{
            //    return true;
            //}
            if (db2Vals[0] == 2)
            {
                if (currentTaskPhase == 0)
                {
                    currentTaskPhase = 1;
                }
            }
            switch (this.currentTaskPhase)
            {
            case 1:
            {
                currentTaskDescribe = "开始读RFID";
                this.rfidUID        = "";
                if (SysCfg.SysCfgModel.UnbindMode)
                {
                    this.rfidUID = System.Guid.NewGuid().ToString();
                }
                else
                {
                    if (SysCfg.SysCfgModel.SimMode || SysCfg.SysCfgModel.RfidSimMode)
                    {
                        this.rfidUID = this.SimRfidUID;
                    }
                    else
                    {
                        this.rfidUID = this.barcodeRW.ReadBarcode();
                    }
                }

                if (string.IsNullOrWhiteSpace(this.rfidUID))
                {
                    if (this.db1ValsToSnd[0] != barcodeFailedStat)
                    {
                        logRecorder.AddDebugLog(nodeName, "读料框条码失败");
                    }
                    this.db1ValsToSnd[0] = barcodeFailedStat;
                    break;
                }
                this.rfidUID = this.rfidUID.Trim(new char[] { '\0', '\r', '\n', '\t', ' ' });

                string palletPattern = @"^[a-z|A-Z|0-9]{4}TP[0-9]{4,}";
                if (!Regex.IsMatch(this.rfidUID, palletPattern))
                {
                    if (this.db1ValsToSnd[0] != barcodeFailedStat)
                    {
                        logRecorder.AddDebugLog(nodeName, "读料框条码不符合规则," + this.rfidUID);
                        this.currentTaskDescribe = "读料框条码不符合规则," + this.rfidUID;
                    }
                    this.db1ValsToSnd[0] = barcodeFailedStat;
                    break;
                }

                /*
                 * //检测是否跟库里有重码
                 * string[] houseNames = new string[] { AsrsModel.EnumStoreHouse.A1库房.ToString(), AsrsModel.EnumStoreHouse.A2库房.ToString(),
                 *  AsrsModel.EnumStoreHouse.B1库房.ToString(), AsrsModel.EnumStoreHouse.C1库房.ToString(),AsrsModel.EnumStoreHouse.C2库房.ToString(),AsrsModel.EnumStoreHouse.C3库房.ToString() };
                 * foreach (string houseName in houseNames)
                 * {
                 *  string cellIn = AsrsResManage.IsProductCodeInStore(houseName, this.rfidUID, ref reStr);
                 *  if (!string.IsNullOrWhiteSpace(cellIn))
                 *  {
                 *      if (this.db1ValsToSnd[0] != 3)
                 *      {
                 *          currentTaskDescribe = string.Format("条码异常,条码{0}已经在库房{1},库位{2}", this.rfidUID.Length.ToString(), houseName, cellIn);
                 *          logRecorder.AddDebugLog(nodeName, currentTaskDescribe);
                 *      }
                 *      this.db1ValsToSnd[0] = 3;
                 *      return true;
                 *  }
                 * }*/

                logRecorder.AddDebugLog(this.nodeName, "读到托盘号:" + this.rfidUID);
                this.currentTaskPhase++;
                break;
            }

            case 2:
            {
                //分流
                currentTaskDescribe = "等待分流";
                int switchRe = 0;
                int step     = 0;
                if (!MesAcc.GetStep(this.rfidUID, out step, ref reStr))
                {
                    currentTaskDescribe = "查询MES工步失败:" + reStr;
                    break;
                }
                if (this.nodeID == "4001")
                {
                    if (step == 0)
                    {
                        currentTaskDescribe = string.Format("{0} 入库分流失败,步号为0,禁止入库", this.rfidUID);
                        if (this.db1ValsToSnd[0] != 4)
                        {
                            logRecorder.AddDebugLog(nodeName, string.Format("{0} 入库分流失败,步号为0,禁止入库", this.rfidUID));
                        }
                        this.db1ValsToSnd[0] = 4;         //

                        break;
                    }
                }
                if (this.nodeID == "4004")
                {
                    step = 5;
                    if (!MesAcc.UpdateStep(step, this.rfidUID, ref reStr))
                    {
                        currentTaskDescribe = "更新MES工步失败:" + reStr;
                        break;
                    }
                }
                if (this.nodeID == "4005")
                {
                    step = 6;
                    if (!MesAcc.UpdateStep(step, this.rfidUID, ref reStr))
                    {
                        currentTaskDescribe = "更新MES工步失败:" + reStr;
                        break;
                    }
                }
                if (this.nodeID == "4006")
                {
                    if (step > 0)
                    {
                        if (step >= 11)
                        {
                            step = 0;
                            if (!MesAcc.UpdateStep(step, this.rfidUID, ref reStr))
                            {
                                currentTaskDescribe = "更新MES工步失败:" + reStr;
                                break;
                            }
                        }
                        else if (step != 10)
                        {
                            step = 10;
                            if (!MesAcc.UpdateStep(step, this.rfidUID, ref reStr))
                            {
                                currentTaskDescribe = "更新MES工步失败:" + reStr;
                                break;
                            }
                        }
                    }
                }
                FlowPathModel switchPath = FindFirstValidPath(this.rfidUID, ref reStr);
                if (switchPath == null)
                {
                    switchRe                 = 0; //无可用路径,等待
                    this.db1ValsToSnd[0]     = (short)switchRe;
                    this.currentTaskDescribe = reStr;
                    break;
                }
                else
                {
                    CtlNodeBaseModel node = switchPath.NodeList[0];

                    if (this.nodeID == "4004")
                    {
                        AsrsControl.AsrsPortalModel port = (node as AsrsControl.AsrsPortalModel);
                        if (port == null)
                        {
                            break;
                        }
                        AsrsModel.CellCoordModel       requireCell   = null;
                        AsrsControl.AsrsCtlModel       asrsCtl       = port.AsrsCtl;
                        AsrsInterface.IAsrsManageToCtl asrsResManage = port.AsrsCtl.AsrsResManage;
                        string logicArea = "通用分区";
                        if (dlgtGetLogicArea != null)
                        {
                            logicArea = dlgtGetLogicArea(this.rfidUID, asrsCtl, step);
                        }
                        if (string.IsNullOrWhiteSpace(logicArea))
                        {
                            this.currentTaskDescribe = string.Format("{0} 检索货区失败,未配置", this.rfidUID);
                            break;
                        }
                        // AsrsModel.EnumLogicArea logicArea = (AsrsModel.EnumLogicArea)Enum.Parse(typeof(AsrsModel.EnumLogicArea), SysCfg.SysCfgModel.asrsStepCfg.AsrsAreaSwitch(step));
                        if (!asrsResManage.CellRequire(asrsCtl.HouseName, logicArea, ref requireCell, ref reStr))
                        {
                            Console.WriteLine("{0}申请库位失败,{1}", nodeName, reStr);
                            break;
                        }
                        if (requireCell.Row == 1)
                        {
                            switchRe = 2;
                            asrsCtl.SetAsrsCheckinRow(requireCell.Row);
                        }
                        else if (requireCell.Row == 2)
                        {
                            switchRe = 3;
                            asrsCtl.SetAsrsCheckinRow(requireCell.Row);
                        }
                        else
                        {
                            break;
                        }
                        logRecorder.AddDebugLog(nodeName, string.Format("{0}锁定分容库位第{1}排", this.rfidUID, requireCell.Row));
                    }
                    else
                    {
                        switchRe = switchPath.PathSeq + 1;
                    }

                    this.db1ValsToSnd[0] = (short)switchRe;

                    /*
                     * if(this.nodeID=="4006") //OCV后入库分流时,把条码后4位以整形发给PLC
                     * {
                     *  this.db1ValsToSnd[1] = short.Parse(this.rfidUID.Substring(this.rfidUID.Length - 4, 4));
                     * }*/
                    if (node.GetType().ToString() == "AsrsControl.AsrsPortalModel")
                    {
                        (node as AsrsControl.AsrsPortalModel).PushPalletID(this.rfidUID);
                    }
                    string logStr = string.Format("{0}分流,进入{1}", this.rfidUID, switchPath.NodeList[0].NodeName);
                    logRecorder.AddDebugLog(nodeName, logStr);
                    AddProduceRecord(this.rfidUID, logStr);

                    if (this.nodeID == "4001")
                    {
                        if (step >= 4)
                        {
                            step = 0;
                            if (!MesAcc.UpdateStep(step, this.rfidUID, ref reStr))
                            {
                                currentTaskDescribe = "更新MES工步失败:" + reStr;
                                break;
                            }
                        }
                    }
                }

                this.currentTaskPhase++;
                break;
            }

            case 3:
            {
                currentTaskDescribe = "分流完成";
                break;
            }

            default:
                break;
            }
            return(true);
        }
示例#6
0
        /// <summary>
        /// 空筐出库请求处理
        /// </summary>
        private void EmptyPalletOutputRequire()
        {
            AsrsCtlModel    asrsHouse          = asrsCtls[0];
            AsrsPortalModel emptyPalletOutport = asrsHouse.GetPortByDeviceID("2003");

            if (emptyPalletOutport.Db2Vals[1] == 1)
            {
                //出口有框,禁止出库
                return;
            }
            if (emptyPalletOutport.Db1ValsToSnd[0] == 2)
            {
                return;
            }
            if (emptyPalletOutport.Db2Vals[0] != 3)
            {
                return;
            }
            bool exitFlag = false;
            int  row = 2, col = 21, layer = 6; //要查询得到

            int r = 1, c = 1, L = 1;

            for (r = 1; r < row + 1; r++)
            {
                if (exitFlag)
                {
                    break;
                }
                for (c = 1; c < col + 1; c++)
                {
                    if (exitFlag)
                    {
                        break;
                    }
                    for (L = 1; L < layer + 1; L++)
                    {
                        CellCoordModel   cell          = new CellCoordModel(r, c, L);
                        EnumCellStatus   cellStoreStat = EnumCellStatus.空闲;
                        EnumGSTaskStatus cellTaskStat  = EnumGSTaskStatus.完成;
                        if (!this.asrsResourceManage.GetCellStatus(asrsHouse.HouseName, cell, ref cellStoreStat, ref cellTaskStat))
                        {
                            continue;
                        }
                        if (cellStoreStat == EnumCellStatus.空料框 && cellTaskStat != EnumGSTaskStatus.锁定)
                        {
                            if (asrsHouse.GenerateOutputTask(cell, null, SysCfg.EnumAsrsTaskType.空筐出库, true))
                            {
                                exitFlag = true;
                                emptyPalletOutport.Db1ValsToSnd[0] = 2;
                                string reStr = "";
                                if (!emptyPalletOutport.NodeCmdCommit(true, ref reStr))
                                {
                                    logRecorder.AddDebugLog(emptyPalletOutport.NodeName, "发送命令失败" + reStr);
                                }
                                else
                                {
                                    return;
                                }
                                break;
                            }
                        }
                    }
                }
            }
        }