Beispiel #1
0
        public ShieldBox ConverterTeachPosToShieldBox(TeachPos teachPos)
        {
            switch (teachPos)
            {
            case TeachPos.ShieldBox1:
                return(ShieldBox1);

            case TeachPos.ShieldBox2:
                return(ShieldBox2);

            case TeachPos.ShieldBox3:
                return(ShieldBox3);

            case TeachPos.ShieldBox4:
                return(ShieldBox4);

            case TeachPos.ShieldBox5:
                return(ShieldBox5);

            case TeachPos.ShieldBox6:
                return(ShieldBox6);

            default:
                return(null);
            }
        }
Beispiel #2
0
        public void CalculateG1ToG2Offset(TeachPos selectedTeachPos)
        {
            double XPos = Convert.ToDouble(
                XmlReaderWriter.GetTeachAttribute(Files.RackData, selectedTeachPos, PosItem.XPos));
            double YPos = Convert.ToDouble(
                XmlReaderWriter.GetTeachAttribute(Files.RackData, selectedTeachPos, PosItem.YPos));
            double APos = Convert.ToDouble(
                XmlReaderWriter.GetTeachAttribute(Files.RackData, selectedTeachPos, PosItem.APos));

            double xOffset = Motion.GetPositionX() - XPos;
            double yOffset = Motion.GetPosition(Motion.MotorY) - YPos;
            double aOffset = Steppers.GetPosition(RackGripper.Two) - APos;

            if (Math.Abs(xOffset) > 5 | Math.Abs(yOffset) > 5 | Math.Abs(aOffset) > 5)
            {
                throw new Exception("CalculateG1ToG2Offset offset over 5.");
            }

            XmlReaderWriter.SetTeachAttribute(Files.RackData, TeachPos.G1ToG2Offset, PosItem.XPos,
                                              xOffset.ToString(CultureInfo.CurrentCulture));
            XmlReaderWriter.SetTeachAttribute(Files.RackData, TeachPos.G1ToG2Offset, PosItem.YPos,
                                              yOffset.ToString(CultureInfo.CurrentCulture));
            XmlReaderWriter.SetTeachAttribute(Files.RackData, TeachPos.G1ToG2Offset, PosItem.APos,
                                              aOffset.ToString(CultureInfo.CurrentCulture));
        }
Beispiel #3
0
        public void LoadForTeaching(RackGripper gripper, TeachPos selectedTeachPos)
        {
            TargetPosition target = ConverterTeachPosToTargetPosition(selectedTeachPos);

            target.ZPos = target.ZPos + 30;
            MoveToTargetPosition(gripper, target, false);
            DisableMotorsForTeaching();
            Motion.SetSpeed(3);
        }
Beispiel #4
0
        public static string GetTeachAttribute(string file, TeachPos PosName, PosItem attribute)
        {
            XElement root = XElement.Load(file);

            XElement elem = root
                            .Elements(PosItem.Teach.ToString())
                            .Elements(PosItem.Pos.ToString())
                            .Single(itemName => itemName.Attribute(PosItem.Name.ToString()).Value == PosName.ToString());

            return(elem.Attribute(attribute.ToString()).Value);
        }
Beispiel #5
0
        public void SaveTeachPosition(TeachPos selectedTeachPos)
        {
            TargetPosition target = new TargetPosition()
            {
                XPos = Motion.GetPositionX(),
                YPos = Motion.GetPosition(Motion.MotorY),
                ZPos = Motion.GetPosition(Motion.MotorZ),
                RPos = Motion.GetPosition(Motion.MotorR),
                APos = Steppers.GetPosition(RackGripper.One)
            };

            XmlReaderWriter.SetTeachAttribute(Files.RackData, selectedTeachPos, PosItem.XPos,
                                              target.XPos.ToString());
            XmlReaderWriter.SetTeachAttribute(Files.RackData, selectedTeachPos, PosItem.YPos,
                                              target.YPos.ToString());
            XmlReaderWriter.SetTeachAttribute(Files.RackData, selectedTeachPos, PosItem.ZPos,
                                              target.ZPos.ToString());
            XmlReaderWriter.SetTeachAttribute(Files.RackData, selectedTeachPos, PosItem.RPos,
                                              target.RPos.ToString());

            XmlReaderWriter.SetTeachAttribute(Files.RackData, selectedTeachPos, PosItem.APos,
                                              target.APos.ToString());

            if (XmlReaderWriter.GetTeachAttribute(Files.RackData, selectedTeachPos, PosItem.XPos) !=
                target.XPos.ToString())
            {
                throw new Exception("SaveTeachPosition fail.");
            }

            if (XmlReaderWriter.GetTeachAttribute(Files.RackData, selectedTeachPos, PosItem.YPos) !=
                target.YPos.ToString())
            {
                throw new Exception("SaveTeachPosition fail.");
            }

            if (XmlReaderWriter.GetTeachAttribute(Files.RackData, selectedTeachPos, PosItem.ZPos) !=
                target.ZPos.ToString())
            {
                throw new Exception("SaveTeachPosition fail.");
            }

            if (XmlReaderWriter.GetTeachAttribute(Files.RackData, selectedTeachPos, PosItem.RPos) !=
                target.RPos.ToString())
            {
                throw new Exception("SaveTeachPosition fail.");
            }

            if (XmlReaderWriter.GetTeachAttribute(Files.RackData, selectedTeachPos, PosItem.APos) !=
                target.APos.ToString())
            {
                throw new Exception("SaveTeachPosition fail.");
            }
        }
Beispiel #6
0
        public void SaveApproachHeight(TeachPos selectedTeachPos)
        {
            double zPos = Convert.ToDouble(XmlReaderWriter.GetTeachAttribute(Files.RackData, selectedTeachPos, PosItem.ZPos));

            if (Motion.GetPosition(Motion.MotorZ) < zPos + 30)
            {
                throw new Exception("Approach is less than ZPos + 30.");
            }

            XmlReaderWriter.SetTeachAttribute(Files.RackData, selectedTeachPos, PosItem.ApproachHeight,
                                              Motion.GetPosition(Motion.MotorZ).ToString(CultureInfo.CurrentCulture));
        }
Beispiel #7
0
        public static void SetTeachAttribute(string file, TeachPos posName, PosItem attribute, string newValue)
        {
            XElement root = XElement.Load(file);

            XElement elem = root
                            .Elements(PosItem.Teach.ToString())
                            .Elements(PosItem.Pos.ToString())
                            .Single(itemName => itemName.Attribute(PosItem.Name.ToString()).Value == posName.ToString());

            elem.Attribute(attribute.ToString()).Value = newValue;

            root.Save(file);
        }
        public static string GetTeachAttribute(string file, TeachPos PosName, PosItem attribute)
        {
            XElement root = XElement.Load(file);

            var child1 = root.Elements(PosItem.Teach.ToString());
            var child2 = child1.Elements(PosItem.Pos.ToString());
            var elem = child2.Single(element => element.Attribute(PosItem.Name.ToString()).Value == PosName.ToString());

            //XElement elem = root
            //  .Elements(PosItem.Teach.ToString())
            //  .Elements(PosItem.Pos.ToString())
            //  .Single(element => element.Attribute(PosItem.Name.ToString()).Value == PosName.ToString());

            return elem.Attribute(attribute.ToString()).Value;
        }
Beispiel #9
0
        public void SaveTeachPosition(TeachPos selectedTeachPos)
        {
            XmlReaderWriter.SetTeachAttribute(Files.RackData, selectedTeachPos, PosItem.XPos,
                                              _motion.GetPositionX().ToString());
            XmlReaderWriter.SetTeachAttribute(Files.RackData, selectedTeachPos, PosItem.YPos,
                                              _motion.GetPosition(_motion.MotorY).ToString());
            XmlReaderWriter.SetTeachAttribute(Files.RackData, selectedTeachPos, PosItem.ZPos,
                                              _motion.GetPosition(_motion.MotorZ).ToString());
            XmlReaderWriter.SetTeachAttribute(Files.RackData, selectedTeachPos, PosItem.RPos,
                                              _motion.GetPosition(_motion.MotorR).ToString());

            XmlReaderWriter.SetTeachAttribute(Files.RackData, selectedTeachPos, PosItem.APos,
                                              _motion.GetPosition(_motion.MotorR) > 0
                    ? _gripper.GetPosition(Gripper.One).ToString()
                    : _gripper.GetPosition(Gripper.Two).ToString());
        }
Beispiel #10
0
        public TargetPosition ConverterTeachPosToTargetPosition(TeachPos teachPos)
        {
            switch (teachPos)
            {
            case TeachPos.Pick:
                return(Motion.PickPosition);

            case TeachPos.Bin:
                return(Motion.BinPosition);

            case TeachPos.ShieldBox1:
                return(Motion.ShieldBox1);

            case TeachPos.ShieldBox2:
                return(Motion.ShieldBox2);

            case TeachPos.ShieldBox3:
                return(Motion.ShieldBox3);

            case TeachPos.ShieldBox4:
                return(Motion.ShieldBox4);

            case TeachPos.ShieldBox5:
                return(Motion.ShieldBox5);

            case TeachPos.ShieldBox6:
                return(Motion.ShieldBox6);

            case TeachPos.Gold1:
                return(Motion.Gold1);

            case TeachPos.Gold2:
                return(Motion.Gold2);

            case TeachPos.Gold3:
                return(Motion.Gold3);

            case TeachPos.Gold4:
                return(Motion.Gold4);

            case TeachPos.Gold5:
                return(Motion.Gold5);

            default:
                throw new Exception("Shield box Id out of range exception.");
            }
        }
Beispiel #11
0
        private TargetPosition LoadPosition(TeachPos pos, Location id)
        {
            TargetPosition target = new TargetPosition
            {
                Id   = id,
                XPos = Convert.ToDouble(
                    XmlReaderWriter.GetTeachAttribute(Files.RackData, pos, PosItem.XPos)),
                YPos = Convert.ToDouble(
                    XmlReaderWriter.GetTeachAttribute(Files.RackData, pos, PosItem.YPos)),
                ZPos = Convert.ToDouble(
                    XmlReaderWriter.GetTeachAttribute(Files.RackData, pos, PosItem.ZPos)),
                RPos = Convert.ToDouble(
                    XmlReaderWriter.GetTeachAttribute(Files.RackData, pos, PosItem.RPos)),
                APos = Convert.ToDouble(
                    XmlReaderWriter.GetTeachAttribute(Files.RackData, pos, PosItem.APos)),
                ApproachHeight = Convert.ToDouble(
                    XmlReaderWriter.GetTeachAttribute(Files.RackData, pos, PosItem.ApproachHeight))
            };

            return(target);
        }
Beispiel #12
0
 private void comboBoxMovePos_SelectedIndexChanged(object sender, EventArgs e)
 {
     _selectedTargetPosition = (TeachPos)comboBoxMovePos.SelectedItem;
 }
Beispiel #13
0
 private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
 {
     _selectedTeachPos = (TeachPos)comboBox1.SelectedItem;
 }
Beispiel #14
0
 public void SaveApproachHeight(TeachPos selectedTeachPos)
 {
     XmlReaderWriter.SetTeachAttribute(Files.RackData, selectedTeachPos, PosItem.ApproachHeight,
                                       _motion.GetPosition(_motion.MotorZ).ToString());
 }