You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
62 lines
1.9 KiB
62 lines
1.9 KiB
|
4 weeks ago
|
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<string> portList = this.EGSerialPort().RefreshSerialPort();
|
||
|
|
CurrentPosition = this.GetModule<ModelActionStatus>().Status.Position;
|
||
|
|
CurrentRotation = this.GetModule<ModelActionStatus>().Status.Rotate;
|
||
|
|
LowSpeed = (ushort)this.GetModule<ModelParamSetting>().Setting.MoveLowSpeed;
|
||
|
|
Speed = (ushort)this.GetModule<ModelParamSetting>().Setting.MoveSpeed;
|
||
|
|
ResetTarget();
|
||
|
|
}
|
||
|
|
|
||
|
|
public void StartTarget()
|
||
|
|
{
|
||
|
|
if (CurrentRotation != 90)
|
||
|
|
{
|
||
|
|
this.EGSendMessage(new RequestTargetControl(2000,500,false), this.GetModule<ModelSerialTest>().EngineSerialPort, ProtocolType.SerialPort);
|
||
|
|
CurrentRotation = 90;
|
||
|
|
this.GetModule<ModelActionStatus>().SetRotation(CurrentRotation);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
public void RevertTarget()
|
||
|
|
{
|
||
|
|
if (CurrentRotation != 0)
|
||
|
|
{
|
||
|
|
this.EGSendMessage(new RequestTargetControl(2000, 0, false), this.GetModule<ModelSerialTest>().EngineSerialPort, ProtocolType.SerialPort);
|
||
|
|
CurrentRotation = 0;
|
||
|
|
this.GetModule<ModelActionStatus>().SetRotation(CurrentRotation);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
public void ResetTarget()
|
||
|
|
{
|
||
|
|
if (CurrentRotation != 0)
|
||
|
|
{
|
||
|
|
this.EGSendMessage(new RequestTargetControl(2000, 500, true), this.GetModule<ModelSerialTest>().EngineSerialPort, ProtocolType.SerialPort);
|
||
|
|
CurrentRotation = 0;
|
||
|
|
this.GetModule<ModelActionStatus>().SetRotation(CurrentRotation);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
public enum StatusTrack
|
||
|
|
{
|
||
|
|
Stop = 0x00,
|
||
|
|
Start = 0x01,
|
||
|
|
StartSlow = 0x02,
|
||
|
|
Back = 0x03,
|
||
|
|
BackSlow = 0x04,
|
||
|
|
Reset = 0x05
|
||
|
|
}
|