diff --git a/Components/Pages/Control.razor b/Components/Pages/Control.razor index aa1726a..e3a12ad 100644 --- a/Components/Pages/Control.razor +++ b/Components/Pages/Control.razor @@ -18,7 +18,7 @@ @if (isTargetOperationInProgress) { - @(isTargetActive ? "停止中..." : "启动中...") + @(isTargetActive ? "启动中..." : "停止中...") } else { @@ -36,6 +36,22 @@

空轨移动中,请等待...

} + +
+ + +
+ +
+ + +
+ + @code { @@ -44,6 +60,7 @@ private bool isTargetActive = false; private bool isTargetOperationInProgress = false; public ModelTrackControl ModelTrackControl { set; get; } + public int MoveStep { set; get; } = 0; protected override void OnInitialized() { ModelTrackControl = this.GetModule(); @@ -73,6 +90,14 @@ StateHasChanged(); } + private void SetPosition(){ + this.ModelTrackControl.SetTargetPosition(MoveStep); + } + + private void SetZero(){ + this.ModelTrackControl.ManualClear(); + } + } \ No newline at end of file diff --git a/Script/Model/ModelSerialTest.cs b/Script/Model/ModelSerialTest.cs index 92b906f..67c8bfc 100644 --- a/Script/Model/ModelSerialTest.cs +++ b/Script/Model/ModelSerialTest.cs @@ -1,3 +1,4 @@ +using System.Runtime.InteropServices; using EGFramework; /// @@ -23,8 +24,16 @@ public class ModelSerialTest : EGModule,IEGFramework public IUnRegister EngineInitEvent{ set; get; } public override void Init() - {; + { this.EGOnMessage(); + if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) + { + IsLinux = false; + } + else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) + { + IsLinux = true; + } if (!IsLinux) { TestPort = PORT_WIN; diff --git a/Script/Model/ModelTrackControl.cs b/Script/Model/ModelTrackControl.cs index d293642..2f02885 100644 --- a/Script/Model/ModelTrackControl.cs +++ b/Script/Model/ModelTrackControl.cs @@ -48,6 +48,26 @@ public class ModelTrackControl : EGModule, IEGFramework } } + public void SetTargetPosition(int position) + { + if (position >= 0) + { + this.EGSendMessage(new RequestTargetControl(2000, (ushort)position, false), this.GetModule().EngineSerialPort, ProtocolType.SerialPort); + } + else + { + position = -position; + this.EGSendMessage(new RequestTargetControl(2000, (ushort)position, true), this.GetModule().EngineSerialPort, ProtocolType.SerialPort); + } + } + + public void ManualClear() + { + this.EGSendMessage(new RequestTargetResetPosition(), this.GetModule().EngineSerialPort, ProtocolType.SerialPort); + CurrentRotation = 0; + this.GetModule().SetRotation(CurrentRotation); + } + public async void DelayClear() { await Task.Delay(3000);