public void Reset()
 {
     Motion.SetSpeed(DefaultRobotSpeed);
     //SystemFault = false;
     RobotReleaseControlOnConveyor();
     ResetConveyor();
     Conveyor.HasBinAPhone = false;
     Conveyor.StopBeltBin();
     Conveyor.HasPlaceAPhone = false;
 }
        public void Bin(RackGripper gripper, Phone phone = null)
        {
            OnInfoOccured(20019, "Try binning phone with " + gripper + ".");

            if (phone != null)
            {
                string footprint = string.Empty;
                foreach (var foot in phone.TargetPositionFootprint)
                {
                    footprint += (int)foot.TeachPos + ",";
                }
                OnProductionComplete(false, phone.SerialNumber, footprint, phone.FailDetail);
            }

            Stopwatch stopwatch = new Stopwatch();

            stopwatch.Start();
            while (Conveyor.NgFullWarning)
            {
                if (stopwatch.ElapsedMilliseconds > 2 * 60 * 60 * 1000) // 2 hour waiting.
                {
                    throw new Exception("Can't bin because ng conveyor is full.");
                }
                Delay(1000);
            }

            if (Conveyor.HasBinAPhone == true || EcatIo.GetInput(Input.ConveyorBinIn) == true ||
                EcatIo.GetInput(Input.ConveyorBinInTwo) == true)
            {
                throw new Exception("Last bin movement has't finished.");
            }

            Conveyor.RobotBinning  = true;
            ShieldBox3.RobotBining = true;
            bool needReopen = false;

            if (gripper == RackGripper.One)
            {
                if (ShieldBox3.WasEnabled)
                {
                    if (ShieldBox3.IsClosed() == false)
                    {
                        ShieldBox3.CloseBox(5000, false);
                        needReopen = true;
                    }
                }
            }

            Conveyor.StopBeltBin();

            MoveToTargetPosition(gripper, Motion.BinPosition, true);
            OpenGripper(gripper);

            Conveyor.HasBinAPhone = true;

            MoveToPointTillEnd(Motion.MotorZ, Motion.BinPosition.ApproachHeight);
            YRetractFromBox();

            Conveyor.RunBeltBin();

            if (needReopen && ShieldBox3.Enabled)
            {
                ShieldBox3.OpenBox(5000, true, true);
            }

            ShieldBox3.RobotBining = false;
            Conveyor.RobotBinning  = false;

            OnInfoOccured(20019, "Finish binning phone with " + gripper + ".");
        }