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); } }
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)); }
public void LoadForTeaching(RackGripper gripper, TeachPos selectedTeachPos) { TargetPosition target = ConverterTeachPosToTargetPosition(selectedTeachPos); target.ZPos = target.ZPos + 30; MoveToTargetPosition(gripper, target, false); DisableMotorsForTeaching(); Motion.SetSpeed(3); }
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); }
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."); } }
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)); }
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; }
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()); }
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."); } }
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); }
private void comboBoxMovePos_SelectedIndexChanged(object sender, EventArgs e) { _selectedTargetPosition = (TeachPos)comboBoxMovePos.SelectedItem; }
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e) { _selectedTeachPos = (TeachPos)comboBox1.SelectedItem; }
public void SaveApproachHeight(TeachPos selectedTeachPos) { XmlReaderWriter.SetTeachAttribute(Files.RackData, selectedTeachPos, PosItem.ApproachHeight, _motion.GetPosition(_motion.MotorZ).ToString()); }