Пример #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 void ShieldBoxSetup()
        {
            if (_shieldBoxInstanced == false)
            {
                ShieldBox1 = new ShieldBox(1);
                ShieldBox2 = new ShieldBox(2);
                ShieldBox3 = new ShieldBox(3);
                ShieldBox4 = new ShieldBox(4);
                ShieldBox5 = new ShieldBox(5);
                ShieldBox6 = new ShieldBox(6);

                ShieldBox1.Position = Motion.ShieldBox1;
                ShieldBox2.Position = Motion.ShieldBox2;
                ShieldBox3.Position = Motion.ShieldBox3;
                ShieldBox4.Position = Motion.ShieldBox4;
                ShieldBox5.Position = Motion.ShieldBox5;
                ShieldBox6.Position = Motion.ShieldBox6;

                ShieldBoxs = new ShieldBox[6] {
                    ShieldBox1, ShieldBox2, ShieldBox3, ShieldBox4, ShieldBox5, ShieldBox6
                };
                _shieldBoxInstanced = true;
            }

            foreach (var box in ShieldBoxs)
            {
                box.PortName = XmlReaderWriter.GetBoxAttribute(Files.BoxData, box.Id, ShieldBoxItem.COM);
                box.Enabled  = XmlReaderWriter.GetBoxAttribute(Files.BoxData, box.Id, ShieldBoxItem.State) == "Enable";
                if (!Enum.TryParse(XmlReaderWriter.GetBoxAttribute(Files.BoxData, box.Id, ShieldBoxItem.Type), out ShieldBoxType type))
                {
                    throw new Exception("ShieldBoxSetup fail due to box type convert failure");
                }
                box.Type = type;

                if (box.Enabled)
                {
                    try
                    {
                        box.Start();
                        box.GreenLight();
                        box.ErrorOccured -= Box_ErrorOccured;
                        box.ErrorOccured += Box_ErrorOccured;
                    }
                    catch (Exception e)
                    {
                        throw new Exception("Box " + box.Id + " is enabled but can't communicate: " + e.Message);
                    }
                }
            }
        }
Пример #5
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());
        }
Пример #6
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);
        }
Пример #7
0
 public void SaveApproachHeight(TeachPos selectedTeachPos)
 {
     XmlReaderWriter.SetTeachAttribute(Files.RackData, selectedTeachPos, PosItem.ApproachHeight,
                                       _motion.GetPosition(_motion.MotorZ).ToString());
 }