/// <summary> /// MoveAbsAxis /// </summary> /// <param name="axis"></param> public override void MoveAbsAxis(RealAxis axis, MLengthSpeed speed, bool waitForCompletion) { try { string ret = ""; ret = SendPortCommand(string.Format("P1={0}", (int)(axis.TargetPosition * 100)), PortSetting.ReadWriteTimeOut); //System.Threading.Thread.Sleep(10); ret = SendPortCommand(string.Format("S1={0}", (int)speed), PortSetting.ReadWriteTimeOut); //System.Threading.Thread.Sleep(10); ret = SendPortCommand(string.Format("AC1={0}", (int)axis.AccelDecel), PortSetting.ReadWriteTimeOut); //System.Threading.Thread.Sleep(10); ret = SendPortCommand(string.Format("DC1={0}", (int)axis.AccelDecel), PortSetting.ReadWriteTimeOut); //System.Threading.Thread.Sleep(10); ret = SendPortCommand(string.Format("M1=1"), PortSetting.ReadWriteTimeOut); //System.Threading.Thread.Sleep(10); ret = SendPortCommand(String.Format("START1"), PortSetting.ReadWriteTimeOut); System.Threading.Thread.Sleep(10); if (!ret.Contains("RUN") && !ret.Contains("OK")) { throw new MCoreExceptionPopup("Move Absolute Command fail {0}", this.Nickname); } WaitForMoveDone(10000); System.Threading.Thread.Sleep(25); OnUpdateCurrentPositions(); } catch (Exception ex) { //U.LogError(ex, "Move Absolute Command fail {0}", this.Nickname); throw new MCoreExceptionPopup(ex, "Move Absolute Command fail {0}", this.Nickname); } }
public override void MoveRelAxis(RealAxis axis, MLengthSpeed speed, bool waitForCompletion) { Millimeters mmSpeed = new Millimeters(speed); try { lock (this) { int axisNumber = axis.AxisNo + 1; double percent = mmSpeed; double dPos = axis.TargetPosition; string cmd = string.Format("DRIVEI({0},{1:F2}),S={2:F2}", axisNumber, dPos, percent); SendCommand(cmd); string ret = WaitForCommand(); CheckOKReplied("DRIVEI", ret, "RUN"); ret = WaitForCommand(30000); CheckOKReplied("WaitMoveDone", ret, "END"); } lock (this) { OnUpdateCurrentPositions(); } } catch (Exception ex) { //U.LogAlarmPopup(ex, "Move Absolute Command fail {0}", this.Nickname); throw new MCoreExceptionPopup(ex, "Move Absolute Command fail {0}", this.Nickname); } }
public override void MoveLinearXY(AxesBase axes, MLengthSpeed speed) { Millimeters mmSpeed = new Millimeters(speed); try { double xPos = (axes.ChildArray[0] as RealAxis).TargetPosition; double yPos = (axes.ChildArray[1] as RealAxis).TargetPosition; double zPos = (axes.ChildArray[2] as RealAxis).TargetPosition; double rPos = (axes.ChildArray[3] as RealAxis).TargetPosition; double percent = mmSpeed; lock (this) { string cmd = string.Format("MOVE P,{0:F2} {1:F2} {2:F2} {3:F2} 0.0 0.0 {4},S={5:F2}", xPos, yPos, zPos, rPos, this.AxesMoveMode, percent); SendCommand(cmd); string ret = WaitForCommand(); CheckOKReplied("MOVE P", ret, "RUN"); ret = WaitForCommand(30000); CheckOKReplied("WaitMoveDone", ret, "END"); } lock (this) { OnUpdateCurrentPositions(); } } catch (Exception ex) { //U.LogAlarmPopup(ex, "MoveLinearXY Command fail {0}", this.Nickname); throw new MCoreExceptionPopup(ex, "MoveLinearXY Command fail {0}", this.Nickname); } }
/// <summary> /// MoveAbsAxis /// </summary> /// <param name="axis"></param> public override void MoveAbsAxis(RealAxis axis, MLengthSpeed speed, bool waitForCompletion) { try { string ret = ""; double dTargetPos = RealPosionConvertToPulsePos(axis.TargetPosition); ret = SendPortCommand(string.Format("P.{0}={1}", axis.AxisNo, (int)(dTargetPos)), PortSetting.ReadWriteTimeOut, false); //System.Threading.Thread.Sleep(10); double dTargetSpeed = RealSpeedConvertToPulseSpeed(speed); ret = SendPortCommand(string.Format("S.{0}={1}", axis.AxisNo, (int)dTargetSpeed), PortSetting.ReadWriteTimeOut, false); //System.Threading.Thread.Sleep(10); double dTargetAceel = RealSpeedConvertToPulseSpeed(axis.AccelDecel); ret = SendPortCommand(string.Format("A.{0}={1}", axis.AxisNo, (int)dTargetAceel), PortSetting.ReadWriteTimeOut, false); //System.Threading.Thread.Sleep(10); ret = SendPortCommand(string.Format("^.{0}", axis.AxisNo), PortSetting.ReadWriteTimeOut, false); //System.Threading.Thread.Sleep(10); ret = SendPortCommand(string.Format("?99.{0}", axis.AxisNo), PortSetting.ReadWriteTimeOut, true); System.Threading.Thread.Sleep(10); if (!ret.Contains("Ux")) { throw new MCoreExceptionPopup("Move Absolute Command fail {0}", this.Nickname); } WaitForMoveDone(10000); System.Threading.Thread.Sleep(30); OnUpdateCurrentPositions(); } catch (Exception ex) { //U.LogError(ex, "Move Absolute Command fail {0}", this.Nickname); throw new MCoreExceptionPopup(ex, "Move Absolute Command fail {0}", this.Nickname); } }
/// <summary> /// Home an Axis /// </summary> /// <param name="axis"></param> public override void MoveAbsAxis(RealAxis axis, MLengthSpeed speed, bool waitForCompletion) { Millimeters mmSpeed = new Millimeters(speed); MoveAbsAxis(axis, axis.TargetPosition, (float)mmSpeed, waitForCompletion); }
/// <summary> /// MoveAbsAxis /// </summary> /// <param name="axis"></param> public override void MoveAbsAxis(RealAxis axis, MLengthSpeed speed, bool waitForCompletion) { try { int iPos = (int)(axis.TargetPosition / 0.01); int iInpos = 1; int iSpeed = (int)(speed / 0.01); int iAccel = (int)(axis.AccelDecel / 0.01); string sPos = iPos.ToString("X8"); string sInpos = iInpos.ToString("X8"); string sSPeed = iSpeed.ToString("X8"); string s = sPos.Substring(4, 4); int iPos1 = int.Parse(sPos.Substring(0, 4), System.Globalization.NumberStyles.AllowHexSpecifier); int iPos2 = int.Parse(sPos.Substring(4, 4), System.Globalization.NumberStyles.AllowHexSpecifier); int iInpos1 = int.Parse(sInpos.Substring(0, 4), System.Globalization.NumberStyles.AllowHexSpecifier); int iInpos2 = int.Parse(sInpos.Substring(4, 4), System.Globalization.NumberStyles.AllowHexSpecifier); int iSpeed1 = int.Parse(sSPeed.Substring(0, 4), System.Globalization.NumberStyles.AllowHexSpecifier); int iSpeed2 = int.Parse(sSPeed.Substring(4, 4), System.Globalization.NumberStyles.AllowHexSpecifier); int[] regValue = new int[7]; regValue[0] = iPos1; regValue[1] = iPos2; regValue[2] = iInpos1; regValue[3] = iInpos2; regValue[4] = iSpeed1; regValue[5] = iSpeed2; regValue[6] = iAccel; lock (this) { _waitDataRecived.Reset(); try { _modbusClient.WriteMultipleRegisters(IAIConstAddr.PCMD, regValue); } catch { } finally { } WaitDataReceived(ReadTimeOut); } WaitForMoveDone(10000); lock (this) { System.Threading.Thread.Sleep(100); OnUpdateCurrentPositions(); } } catch (Exception ex) { //U.LogAlarmPopup(ex, "Move Absolute Command fail {0}", this.Nickname); throw new MCoreExceptionPopup(ex, "Move Absolute Command fail {0}", this.Nickname); } }
/// <summary> /// SimulateMoveRel /// </summary> /// <param name="speed"></param> public virtual void SimulateMoveRel(MLengthSpeed speed) { CurrentMotorCounts = TargetMotorCounts; }
/// <summary> /// Move the axis to an absolute position (stored in CommandedPosition) /// </summary> /// <param name="axes"></param> /// <param name="speed"></param> public virtual void MoveLinearXY(AxesBase axes, MLengthSpeed speed) { // Simulation }
/// <summary> /// Move the axis to an absolute position (stored in CommandedPosition) /// </summary> /// <param name="axes"></param> /// <param name="speed"></param> public virtual void MoveLinearXY(RealAxes axes, MLengthSpeed speed) { // Simulation }
public virtual void MoveRelAxis(RealAxis axis, MLengthSpeed speed, bool waitForCompletion) { // Simulation axis.SimulateMoveRel(speed); }