static public int DeleteStackSeq(int tSeqNum) { lock (lockObject) { if (workingStack != null) { if (tSeqNum == workingStack.SeqNum) { workingStack = null; Log.log.Info("Delete stackseq[" + tSeqNum + "] success"); SortingTimerStop(); return(0); } } StackSeq stackSeq; stackSeq = waitingStackSeqList.Find(mStackSeq => mStackSeq.SeqNum == tSeqNum); if (stackSeq != null) { if (waitingStackSeqList.IndexOf(stackSeq) == 0) { SortingTimerStop(); } waitingStackSeqList.Remove(stackSeq); Log.log.Info("Delete stackseq[" + tSeqNum + "] success"); return(0); } } Log.log.Info("stackseq[" + tSeqNum + "] not exist"); return(-1); }
static private bool CheckStackSeq() { if ((workingStack != null)) { if (workingStack.stackStatus == StackStatus.Finished) { workingStack = null; } } if (workingStack != null) { CheckTimeout(); return(true); } else { if (waitingStackSeqList.Count > 0) { if (waitingStackSeqList[0].stackStatus == StackStatus.BoxChecked) { workingStack = waitingStackSeqList[0]; workingStack.stackStatus = StackStatus.Sorting; waitingStackSeqList.RemoveAt(0); Log.log.Info("WorkStack is empty,set waiting stackseq to work"); CheckTimeout(); return(true); } } } CheckTimeout(); return(false); }
static public void Init() { SortingTimerInit(sortingTime); sortStatus = SortStatus.Stoping; workingStack = null; waitingStackSeqList = new List <StackSeq> { }; outListBox = new List <string> { }; }
static public void ClearAll() { lock (lockObject) { workingStack = null; waitingStackSeqList.Clear(); outListBox.Clear(); sortStatus = SortStatus.Stoping; SortingTimerStop(); Log.log.Info("Clear all"); } }
static private Box FindBox(StackSeq tStackSeq, string barcode) { int index = tStackSeq.boxList.FindIndex(box => box.barcode.Equals(barcode)); if (index != -1) { return(tStackSeq.boxList[index]); } else { return(null); } }
static public DivertCmd Hander(MessageBase msg) { lock (lockObject) { if (msg.msgId == (Int16)MessageBase.MessageType.DivertReq) { return(StackSeq.HanderReq((DivertReq)msg)); } if (msg.msgId == (Int16)MessageBase.MessageType.DivertRes) { StackSeq.HanderRes((DivertRes)msg); } return(null); } }
public int AddStackSeq(string strJson) { List <Chest> chestList = Newtonsoft.Json.JsonConvert.DeserializeObject <List <Chest> >(strJson); List <Box> boxList = new List <Box> { }; foreach (Chest chest in chestList) { Box box = new Box(); box.barcode = chest.barcode; box.lane = chest.lane; box.node = chest.node; box.status = Box.BoxStatus.Inital; boxList.Add(box); } return(StackSeq.AddStackSeq(boxList, chestList[0].container)); }
static public int ResetWorkingStackSeq() { if (workingStack == null) { Log.log.Info("Delet working stackseq fail, There is no working stack"); return(-1); } lock (lockObject) { workingStack.boxList.ForEach(box => box.status = BoxStatus.Inital); workingStack.stackStatus = StackStatus.Inital; waitingStackSeqList.Insert(0, workingStack); workingStack = null; SortingTimerStop(); Log.log.Info("Reset working stack"); return(0); } }
static public int AddStackSeq(List <Box> tBoxList, int container) { StackSeq stackSeq = new StackSeq(); int res = stackSeq.AddBoxList(tBoxList); if (res <= 0) { Log.log.Info("StackSeq add fail"); } else { Log.log.Info("Added stacklist, box counts is " + stackSeq.boxList.Count + ", seqnum is " + container); foreach (Box box in stackSeq.boxList) { Log.log.Info("barcode:" + box.barcode + "|node:" + box.node + "|lane" + box.lane); } waitingStackSeqList.Add(stackSeq); stackSeq.SeqNum = container; CheckStackSeq(); return(stackSeq.SeqNum); } return(-1); }
static void Main(string[] args) { RouteDirectControl routeDirectControl = new RouteDirectControl(); routeDirectControl.ContinueConnection(); routeDirectControl.FlushMsg(); StackSeq.Init(); ServiceHost host = new ServiceHost(typeof(Sorting)); host.Open(); Log.log.Info("WCF start"); while (true) { MessageBase msg; msg = routeDirectControl.WaitMsg(); DivertCmd divertCmd = StackSeq.Hander(msg); if (divertCmd != null) { routeDirectControl.SendMsg(divertCmd); } } }
public int StopWorkingStackSeq() { StackSeq.Stop(); return(0); }
public int StartWorkingStackSeq() { StackSeq.Start(); return(0); }
public int ResetWorkingStackSeq() { return(StackSeq.ResetWorkingStackSeq()); }
public int ClearAll() { StackSeq.ClearAll(); return(0); }
public int DeleteStackSeq(int tSeqNum) { return(StackSeq.DeleteStackSeq(tSeqNum)); }