예제 #1
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));
        }
예제 #2
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.");
            }
        }
예제 #3
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));
        }
예제 #4
0
        private TargetPosition LoadPosition(TeachPos pos, TeachPos id)
        {
            TargetPosition target = new TargetPosition
            {
                TeachPos = 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);
        }