// ================================================================================================ // SmartHome v1.2 // ================================================================================================ string Axes = "XYZABC"; int Axis = 0; if (Qvar == null) { Axis = Convert.ToInt32(AS3.Getfielddouble(SmartHomeAxisFld)); if (Axis == 6) { for (int i = 0; i <= 5; i++) { Axis = Axes.IndexOf(AS3.Getcomboboxselection(4 + i)); if (Axis != -1) exec.Setaxishomestate(Axis, false); } for (int i = 0; i <= 5; i++) { Axis = Axes.IndexOf(AS3.Getcomboboxselection(4 + i)); if (Axis != -1) if (!HomeAxis(Axis)) return; } } else { exec.Setaxishomestate(Axis, false); HomeAxis(Axis); } return; } int Qint = Convert.ToInt32(Qvar); if ((Qint < 0) || (Qint > 5)) { AS3.Additemtolistbeginning("* M20928: Invalid Q", 2); return; } HomeAxis(Qint); // ================================================================================================ #Events const int SmartHomeAxisFld = 20602; bool HomeAxis(int AxisNo) { string WorkAxis = "XYZABC".Substring(AxisNo, 1); bool G28Move = Convert.ToBoolean(exec.Readkey("SmartHome", "G28Move" + WorkAxis, "false")); double G28Goto = Convert.ToDouble(exec.Readkey("SmartHome", "G28Goto" + WorkAxis, "0.0")); double CurrentPos = 0.0; bool SoftLimit = exec.GetLED(67); if (G28Move) AS3.Additemtolistbeginning("Homing " + WorkAxis + " with move to " + G28Goto, 2); else AS3.Additemtolistbeginning("Homing " + WorkAxis, 2); while (exec.IsMoving()){} if(exec.Ismacrostopped()) return false; switch (AxisNo) { case 0: CurrentPos = exec.GetXpos(); break; case 1: CurrentPos = exec.GetYpos(); break; case 2: CurrentPos = exec.GetZpos(); break; case 3: CurrentPos = exec.GetApos(); break; case 4: CurrentPos = exec.GetBpos(); break; case 5: CurrentPos = exec.GetCpos(); break; } exec.Code("G28.1 " + WorkAxis + CurrentPos); while (exec.IsMoving()){} if(exec.Ismacrostopped()) return false; if (G28Move) { if (SoftLimit) { exec.Callbutton(519); while (exec.IsMoving()){} } exec.Code("G0 G53 " + WorkAxis + G28Goto); while (exec.IsMoving()){} if(exec.Ismacrostopped()) { if (SoftLimit) { exec.Callbutton(518); while (exec.IsMoving()){} } return false; } if (SoftLimit) { exec.Callbutton(518); while (exec.IsMoving()){} } } return true; } // ================================================================================================