Exemplo n.º 1
0
        void ElevatorTasks_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
        {
            if (e.Action == System.Collections.Specialized.NotifyCollectionChangedAction.Add)
            {
                if (e.NewItems != null)
                {
                    ElevatorTask etNew = null;

                    foreach (ElevatorTask newTask in e.NewItems)
                    {
                        newTask.SourceLoadAConv      = ParentMultiShuttle.GetConveyorFromLocName(newTask.SourceLoadA);
                        newTask.SourceLoadBConv      = ParentMultiShuttle.GetConveyorFromLocName(newTask.SourceLoadB);
                        newTask.DestinationLoadAConv = ParentMultiShuttle.GetConveyorFromLocName(newTask.DestinationLoadA);
                        newTask.DestinationLoadBConv = ParentMultiShuttle.GetConveyorFromLocName(newTask.DestinationLoadB);
                        newTask.Elevator             = this;
                        etNew = newTask;
                    }

                    ///// Check for repeated tasks This shouldn't happen however the controller/WMS may issue repeated tasks //////
                    List <ElevatorTask> listET = ElevatorTasks.ToList();

                    if (CurrentTask != null)
                    {
                        listET.Add(CurrentTask);
                    }

                    listET.Remove(etNew);

                    foreach (ElevatorTask st in listET)
                    {
                        if (st.Equals(etNew)) // Already have this task
                        {
                            ElevatorTasks.Remove(etNew);
                            //etNew = null;
                        }
                    }
                    ///////

                    Log.Write(etNew.ToString());
                    if (CurrentTask == null && etNew != null)  //elevator not doing a task add this to the current task
                    {
                        CurrentTask = etNew;
                    }
                }
            }
        }
Exemplo n.º 2
0
        //public override bool Equals(object obj)
        public override bool Equals(object obj)
        {
            if (obj == null)
            {
                return(false);
            }

            ElevatorTask et = obj as ElevatorTask;

            if (et == null)
            {
                return(false);
            }

            //Not checking CaseData

            bool retVal = false;

            if (et.DestinationLoadAConv == null && DestinationLoadAConv == null)
            {
                retVal = true;
            }
            else if (et.DestinationLoadAConv != null && et.DestinationLoadAConv.Equals(DestinationLoadAConv))
            {
                retVal = true;
            }

            //if (!(retVal && et.DestinationLoadBConv == null && DestinationLoadBConv == null))
            if ((retVal && et.DestinationLoadBConv == null && DestinationLoadBConv == null))
            {
                retVal = false;
            }
            else if (et.DestinationLoadBConv != null && et.DestinationLoadBConv.Equals(DestinationLoadBConv))
            {
                retVal = true;
            }

            return(retVal && et.ToString() == this.ToString());
        }