private void ArrivedAtDest(Load load) { if (CurrentTask.Destination.ConvType() == ConveyorTypes.OutfeedRack) { load.Switch(ParentMultiShuttle.ConveyorLocations.Find(x => x.LocName == CurrentTask.Destination), true); } else { ParentMultiShuttle.ArrivedAtRackLocation(new TaskEventArgs(CurrentTask, load)); load.Dispose(); CurrentTask = null; } }
public override bool Equals(object obj) { if (obj == null) { return(false); } ShuttleTask st = obj as ShuttleTask; if (st == null) { return(false); } return(st.ToString() == this.ToString()); }
void ShuttleTasks_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e) { if (e.NewItems != null) { ShuttleTask stNew = null; foreach (ShuttleTask newTask in e.NewItems) { newTask.SourcePosition = newTask.Source.RackXLocation() * ParentMultiShuttle.BayLength; newTask.DestPosition = newTask.Destination.RackXLocation() * ParentMultiShuttle.BayLength; stNew = newTask; } ///// Check for repeated tasks This shouldn't happen however the controller/WMS may issue repeated tasks ////// List <ShuttleTask> listST = ShuttleTasks.ToList(); if (CurrentTask != null) { listST.Add(CurrentTask); } listST.Remove(stNew); foreach (ShuttleTask st in listST) { if (st.Equals(stNew)) // Already have this task { ShuttleTasks.Remove(stNew); stNew = null; } } /////// //if (CurrentTask == null && stNew != null) //shuttle not doing a task add this to the current task //{ // CurrentTask = stNew; //} if (CurrentTask == null) //shuttle not doing a task add this to the current task { foreach (ShuttleTask newTask in e.NewItems) { CurrentTask = newTask; ShuttleTasks.Remove(newTask); } } } }
/// <summary> /// Deals with a new task added to ShuttleTasks, checks for repeated tasks and adds source and dest positions /// </summary> void ShuttleTasks_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e) { if (e.NewItems != null) { ShuttleTask stNew = null; foreach (ShuttleTask newTask in e.NewItems) { newTask.DestPosition = SetShuttlePosition(newTask.Destination.RackXLocation()); newTask.SourcePosition = SetShuttlePosition(newTask.Source.RackXLocation()); stNew = newTask; } ///// Check for repeated tasks This shouldn't happen however the controller/WMS may issue repeated tasks ////// List <ShuttleTask> listST = ShuttleTasks.ToList(); if (CurrentTask != null) { listST.Add(CurrentTask); } listST.Remove(stNew); foreach (ShuttleTask st in listST) { if (st.Equals(stNew)) // Already have this task { ShuttleTasks.Remove(stNew); stNew = null; } } /////// if (CurrentTask == null) //shuttle not doing a task add this to the current task { var loc = ParentMultiShuttle.ConveyorLocations.Find(c => c.LocName == stNew.Destination); if (loc == null || (loc != null && !loc.Active)) //If destination was a rack conveyor then should not be null if it was a rack location then it will be equal to null AND there is space to put down { foreach (ShuttleTask newTask in e.NewItems) { CurrentTask = newTask; ShuttleTasks.Remove(newTask); } } } } }
/// <summary> /// Deals with a new task added to ShuttleTasks, checks for repeated tasks and adds source and dest positions /// </summary> void ShuttleTasks_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e) { if (e.NewItems != null) { ShuttleTask stNew = null; foreach (ShuttleTask newTask in e.NewItems) { newTask.DestPosition = SetShuttlePosition(newTask.Destination.RackXLocation(), newTask.Destination.ConvType()); newTask.SourcePosition = SetShuttlePosition(newTask.Source.RackXLocation(), newTask.Source.ConvType()); if (newTask.SourcePosition > ParentMS.Raillength || newTask.DestPosition > ParentMS.Raillength || newTask.SourcePosition < 0 || newTask.DestPosition < 0) { Log.Write(string.Format("Error {0} Level {1}: Cannot reach source or destination location - x Location is greater than rail length or invalid", ParentMS.Name, Level), Color.Red); ShuttleTasks.Remove(newTask); return; } else { stNew = newTask; } } //Check for repeated tasks This shouldn't happen however the controller/WMS may issue repeated tasks ////// List <ShuttleTask> listST = ShuttleTasks.ToList(); if (CurrentTask != null) { listST.Add(CurrentTask); } listST.Remove(stNew); foreach (ShuttleTask st in listST) { if (st.Equals(stNew)) // Already have this task { ShuttleTasks.Remove(stNew); stNew = null; } } SetNewShuttleTask(); } }
internal void MoveShuttle(float position) { if (CurrentTask.Source.ConvType() == ConveyorTypes.InfeedRack) { RackConveyor sourceConv = ParentMultiShuttle.GetConveyorFromLocName(CurrentTask.Source) as RackConveyor; if (CurrentTask.Level == Level && sourceConv != null && (shuttleAP.Active || (!shuttleAP.Active && (sourceConv.LocationB.Active && sourceConv.LocationB.ActiveLoad.Identification == CurrentTask.LoadID)))) { //continue....temp debug code! } else { Log.Write("Error in CurrentTask removing current task", Color.Red); CurrentTask = null; return; } } float currentDistance = trackRail.Destination.Distance; if (trackRail.Destination.Distance != position) { trackRail.Destination.Distance = position; if (trackRail.Destination.Distance < currentDistance) { trackRail.Route.Motor.Backward(); } else if (trackRail.Destination.Distance > currentDistance) { trackRail.Route.Motor.Forward(); } trackRail.Route.Motor.Start(); trackRail.ShuttleCar.Release(); } else //no need to move as already at the correct location { ShuttleOnArrived(); } }
public ShuttleTask SetNewShuttleTask() { ShuttleTask newTask = null; if (CurrentTask == null && ShuttleTasks.Count != 0) { string logMess = ""; foreach (ShuttleTask st in ShuttleTasks) { logMess += string.Format("{0}:", st.LoadID); } //Log.Write(string.Format("SHUTTLETASKS - {0} - {1}", Name, logMess)); foreach (ShuttleTask st in ShuttleTasks) { if (st.Destination.ConvType() == ConveyorTypes.OutfeedRack) { var v = ParentMS.ConveyorLocations.Find(c => c.LocName == st.Destination); if (!v.Active) //if outfeed only choose the task if the outfeed location is free { newTask = st; break; } } else { newTask = st; break; } } if (newTask != null) { ShuttleTasks.Remove(newTask); CurrentTask = newTask; //recursive call back to move the shuttle. } } return(newTask); }