1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677 |
- using StageController.M3H;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace StageController
- {
- /// <summary>
- /// 8.2.1 查询单独电机位置
- /// </summary>
- public class CommandPosition : CommandBase
- {
- private Motor m_motor;
- // 当前位置步长
- private int m_currentStep;
- // 边界
- private Border m_border;
- /// <summary>
- /// 查询单独电机位置 构造器
- /// </summary>
- /// <param name="axis">轴</param>
- public CommandPosition(Motor motor)
- {
- m_motor = motor;
- }
- /// <summary>
- ///
- /// </summary>
- /// <returns> @x! </returns>
- public override string Make()
- {
- return "@" + Enum.GetName(typeof(Motor), m_motor) + "!";
- }
- /// <summary>
- ///
- /// </summary>
- /// <param name="respons"> @Mx:X000A0=12345678,+12345678! </param>
- /// <returns></returns>
- public override bool Parse(string respons)
- {
- string motor = Enum.GetName(typeof(Motor), m_motor);
- string temp = "@M" + motor + ":" + motor.ToUpper();
- if (respons.Length != 30 || !respons.StartsWith(temp))
- {
- return false;
- }
- m_currentStep = int.Parse(respons.Substring(20, 9));
- m_border = (Border)Enum.ToObject(typeof(Border), int.Parse(respons.Substring(9, 1)));
- return true;
- }
- public Border CurrentBorder
- {
- get
- {
- return m_border;
- }
- }
- public int CurrentStep
- {
- get
- {
- return m_currentStep;
- }
- }
- }
- }
|