mirror of
https://gitee.com/langsisi_admin/serein-flow
synced 2026-03-03 00:00:49 +08:00
重写了Web Api的逻辑,用Emit构造委托加速API处理
This commit is contained in:
@@ -30,10 +30,8 @@ namespace Net462DllTest.ViewModel
|
||||
}
|
||||
}
|
||||
|
||||
[AutoSocketModule(JsonThemeField = "theme", JsonDataField = "data")]
|
||||
public class FromWorkBenchViewModel : INotifyPropertyChanged, ISocketControlBase
|
||||
public class FromWorkBenchViewModel : INotifyPropertyChanged
|
||||
{
|
||||
public Guid HandleGuid { get; } = new Guid();
|
||||
|
||||
private readonly SiemensPlcDevice Device;
|
||||
private readonly ViewManagement viewManagement;
|
||||
@@ -51,81 +49,6 @@ namespace Net462DllTest.ViewModel
|
||||
this.plcVarModelDataProxy = plcVarModelDataProxy;
|
||||
|
||||
InitCommand(); // 初始化指令
|
||||
|
||||
webSocketServer.MsgHandleHelper.AddModule(this); // 用于关闭窗体时移除监听
|
||||
CommandCloseForm = new RelayCommand((p) =>
|
||||
{
|
||||
webSocketServer.MsgHandleHelper.RemoteModule(this); // 用于关闭窗体时移除监听
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//Console.WriteLine($"Emit: {sw.ElapsedTicks * 1000000F / Stopwatch.Frequency:n3}μs");
|
||||
|
||||
|
||||
//var msgHandl = new WsMsgHandl<LibSpace>()
|
||||
//{
|
||||
// DataJsonKey = "data", // 数据键
|
||||
// ThemeJsonKey = "theme", // 主题键
|
||||
//};
|
||||
//msgHandl.AddHandle<LibSpace>(nameof(GetSpace), GetSpace); // theme:AddUser
|
||||
//msgHandl.AddHandle<LibSpace>(nameof(UpData), UpData); // theme:DeleteUser
|
||||
//webSocketServer.AddModule(msgHandl);
|
||||
//CommandCloseForm = new RelayCommand((p) =>
|
||||
//{
|
||||
// webSocketServer.RemoteModule(msgHandl); // 用于关闭窗体时移除监听
|
||||
//});
|
||||
}
|
||||
Action<string> Recover;
|
||||
[AutoSocketHandle(ThemeValue = "SavaRecover")]
|
||||
public async Task SavaRecover(int waitTime , Action<string> Recover)
|
||||
{
|
||||
if(waitTime <=0 || waitTime>= 10000)
|
||||
{
|
||||
return;
|
||||
}
|
||||
await Task.Delay(waitTime);
|
||||
Recover("haha~" );
|
||||
this.Recover = Recover;
|
||||
return;
|
||||
}
|
||||
[AutoSocketHandle(ThemeValue = "Invoke")]
|
||||
public void Invoke(string a)
|
||||
{
|
||||
if (Recover is null)
|
||||
return;
|
||||
Recover("haha~"+a);
|
||||
|
||||
}
|
||||
|
||||
|
||||
[AutoSocketHandle(ThemeValue = "PlcModel")]
|
||||
public async Task<PlcVarModelDataProxy> GetModelData(Action<object> Recover)
|
||||
{
|
||||
Recover("等待5秒");
|
||||
await Task.Delay(5000);
|
||||
//Recover.Invoke(plcVarModelDataProxy);
|
||||
return plcVarModelDataProxy;
|
||||
}
|
||||
|
||||
[AutoSocketHandle(ThemeValue = "Up")]
|
||||
public void UpData(LibSpace libSpace, Action<dynamic> Recover)
|
||||
{
|
||||
Recover("收到");
|
||||
return;
|
||||
}
|
||||
|
||||
[AutoSocketHandle(ThemeValue = "Bind")]
|
||||
public LibSpace SpaceBind(string spaceNum, string plateNumber, Action<string> Recover)
|
||||
{
|
||||
return new LibSpace
|
||||
{
|
||||
PlateNumber = plateNumber,
|
||||
SpaceNum = spaceNum,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user