示例#1
0
 /// <summary>
 /// 根据DivertReq对象创建消息对象
 /// </summary>
 /// <param name="divertReq">DivertReq对象</param>
 /// <param name="tLaneId">分拣线路</param>
 public DivertCmd(DivertReq divertReq, Int16 tLaneId) : base(messageId)
 {
     nodeId   = divertReq.nodeId;
     cartSeq  = divertReq.cartSeq;
     priority = 0;
     laneId   = tLaneId;
     Pack();
 }
        /// <summary>
        /// 解析消息数组至单个消息对象
        /// </summary>
        /// <param name="buf">消息数组</param>
        /// <param name="offset">偏移量引用</param>
        /// <returns>消息对象</returns>
        static public MessageBase MessageCreate(byte[] buf, ref int offset)
        {
            Int16       tMsgId = 0;
            MessageBase messageBase;

            DataConversion.ByteToNum(buf, offset, ref tMsgId, false);
            switch (tMsgId)
            {
            case (Int16)MessageType.DivertReq:
                messageBase = new DivertReq(buf, offset);
                offset     += DivertReq.len;
                break;

            case (Int16)MessageType.DivertRes:
                messageBase = new DivertRes(buf, offset);
                offset     += DivertRes.len;
                break;

            case (Int16)MessageType.HeartBeat:
                messageBase = new HeartBeat(buf, offset);
                offset     += HeartBeat.len;
                break;

            case (Int16)MessageType.NodeAva:
                messageBase = new NodeAva(buf, offset);
                offset     += NodeAva.len;
                break;

            case (Int16)MessageType.CommsErr:
                messageBase = new CommsErr(buf, offset);
                offset     += CommsErr.len;
                break;

            default:
                throw new NotImplementedException();
            }
            return(messageBase);
        }
示例#3
0
        static private DivertCmd HanderReq(DivertReq divertReq)
        {
            if (sortStatus == SortStatus.Stoping)
            {
                return(null);
            }
            Box box;

            if (divertReq.codeStr.Contains("?"))
            {
                Log.log.Info("find unknow box in node:" + divertReq.nodeId);
                if (divertReq.nodeId == solveNode)
                {
                    Log.log.Info("removing unknow box from line");
                    return(new DivertCmd(divertReq, solveLane));
                }
                else
                {
                    Log.log.Info("Will remove unknow box from line in solve node[" + solveLane + "]");
                }
            }

            if (CheckStackSeq() == true)
            {
                box = FindBox(workingStack, divertReq.codeStr);
                if (box != null)
                {
                    foreach (NodeSeq nodeSeq in workingStack.nodeSeqList)
                    {
                        if (nodeSeq.node == divertReq.nodeId)
                        {
                            if (nodeSeq.HanderReq(box) == true)
                            {
                                Log.log.Info("Box: " + box.barcode + " is sorting");
                                box.status = BoxStatus.Sorting;
                                return(new DivertCmd(divertReq, box.lane));
                            }
                        }
                    }
                    return(null);
                }
            }


            foreach (StackSeq stackSeq in waitingStackSeqList)
            {
                box = FindBox(stackSeq, divertReq.codeStr);
                if (box != null)
                {
                    if (waitingStackSeqList.IndexOf(stackSeq) != 0)
                    {
                        return(null);
                    }
                    if (box.status == BoxStatus.Inital)
                    {
                        box.status = BoxStatus.Checked;
                        Log.log.Info("Seq[" + stackSeq.SeqNum + "] Box[" + box.barcode + "]" + " has been checked");
                        SortingTimeReset();
                        if (stackSeq.boxList.TrueForAll(mBox => mBox.status == BoxStatus.Checked) == true)
                        {
                            Log.log.Info("Seq[" + stackSeq.SeqNum + "] all box has been checked");
                            SortingTimerStop();
                            stackSeq.stackStatus = StackStatus.BoxChecked;
                        }
                    }
                    return(null);
                }
            }

            Log.log.Info("find box[" + divertReq.codeStr + "] out of list");
            if (divertReq.nodeId == solveNode)
            {
                Log.log.Info("removing outlist box[" + divertReq.codeStr + "] from line");
                outListBox.Add(divertReq.codeStr);
                return(new DivertCmd(divertReq, solveLane));
            }
            else
            {
                Log.log.Info("Will remove outlist box[" + divertReq.codeStr + "] from line in solve node[" + solveLane + "]");
            }
            return(null);
        }