using System.Numerics; using EGFramework; using Tmds.Linux; public class ModelTrackControl : EGModule, IEGFramework { public int CurrentPosition { set; get; } = 0; private ushort LowSpeed { set; get; } private ushort Speed { set; get; } public int CurrentRotation { set; get; } = 0; public override void Init() { // List portList = this.EGSerialPort().RefreshSerialPort(); CurrentPosition = this.GetModule().Status.Position; CurrentRotation = this.GetModule().Status.Rotate; LowSpeed = (ushort)this.GetModule().Setting.MoveLowSpeed; Speed = (ushort)this.GetModule().Setting.MoveSpeed; ResetTarget(); } public void StartTarget() { if (CurrentRotation != 90) { this.EGSendMessage(new RequestTargetControl(2000,500,false), this.GetModule().EngineSerialPort, ProtocolType.SerialPort); CurrentRotation = 90; this.GetModule().SetRotation(CurrentRotation); } } public void RevertTarget() { if (CurrentRotation != 0) { this.EGSendMessage(new RequestTargetControl(2000, 0, false), this.GetModule().EngineSerialPort, ProtocolType.SerialPort); CurrentRotation = 0; this.GetModule().SetRotation(CurrentRotation); } } public void ResetTarget() { if (CurrentRotation != 0) { this.EGSendMessage(new RequestTargetControl(2000, 500, true), this.GetModule().EngineSerialPort, ProtocolType.SerialPort); this.EGSendMessage(new RequestTargetResetPosition(), this.GetModule().EngineSerialPort, ProtocolType.SerialPort); CurrentRotation = 0; this.GetModule().SetRotation(CurrentRotation); } } } public enum StatusTrack { Stop = 0x00, Start = 0x01, StartSlow = 0x02, Back = 0x03, BackSlow = 0x04, Reset = 0x05 }