pry 2 years ago
parent
commit
88ad8e1a2f
42 changed files with 452 additions and 382 deletions
  1. +1
    -1
      HBLConsole.Business/HeartbeatReport.cs
  2. +2
    -2
      HBLConsole.Business/IotReport.cs
  3. +1
    -1
      HBLConsole.Business/M2MqttHelper.cs
  4. +4
    -4
      HBLConsole.Business/MessageServer/Base.cs
  5. +1
    -1
      HBLConsole.Business/ServerData.cs
  6. +1
    -1
      HBLConsole.Communication/ConnectHelper.cs
  7. +0
    -1
      HBLConsole.Communication/HBLConsole.Communication.csproj
  8. +2
    -2
      HBLConsole.Communication/ModbusTcpHelper.cs
  9. +5
    -5
      HBLConsole.Debug/ViewModel/ViewModel_MORKIC.cs
  10. +6
    -6
      HBLConsole.Factory/SimpleFactory.cs
  11. +7
    -7
      HBLConsole.MORKD/Control_MORKD.cs
  12. +6
    -6
      HBLConsole.MORKIC/Control_MORKIC.cs
  13. +6
    -6
      HBLConsole.MORKS/Control_MORKS.cs
  14. +2
    -2
      HBLConsole.MainConsole/Main.cs
  15. +1
    -1
      HBLConsole.Model/HBLConsole.Model.csproj
  16. +1
    -1
      HBLConsole.Model/SQL/VariableInfo.cs
  17. +129
    -0
      HBLConsole.Service/ActionManage.cs
  18. +0
    -119
      HBLConsole.Service/ActionOperate.cs
  19. +61
    -18
      HBLConsole.Service/ExpandMethod.cs
  20. +1
    -1
      HBLConsole.Service/HBLConsole.Service.csproj
  21. +1
    -1
      HBLConsole.Service/Json.cs
  22. +1
    -2
      HBLConsole.Service/SystemHelper.cs
  23. +172
    -0
      HBLConsole.Service/ThreadManage.cs
  24. +0
    -153
      HBLConsole.Service/ThreadOperate.cs
  25. +2
    -2
      HBLConsole/App.xaml.cs
  26. +4
    -4
      HBLConsole/DialogWindow/View/DeviceManagermentSetView.xaml.cs
  27. +4
    -4
      HBLConsole/DialogWindow/View/SimOrderConfitView.xaml.cs
  28. +2
    -2
      HBLConsole/DialogWindow/ViewModel/DeviceManagermentSetViewModel.cs
  29. +3
    -3
      HBLConsole/DialogWindow/ViewModel/ListDialogViewModel.cs
  30. +3
    -3
      HBLConsole/DialogWindow/ViewModel/SimOrderConfitViewModel.cs
  31. +1
    -1
      HBLConsole/View/DeviceManageView.xaml.cs
  32. +1
    -1
      HBLConsole/View/VariableConfig.xaml.cs
  33. +5
    -5
      HBLConsole/ViewModel/DebugViewModel.cs
  34. +2
    -2
      HBLConsole/ViewModel/MainViewModel.cs
  35. +1
    -1
      HBLConsole/ViewModel/ProcessMonitoringViewModel.cs
  36. +2
    -2
      HBLConsole/ViewModel/VariableConfig.cs
  37. +1
    -1
      HBLConsole/ViewModel/VariableMonitorViewModel.cs
  38. +2
    -2
      HBLConsole/ViewModel/ViewModelBase.cs
  39. +4
    -4
      HBLDevice.Coffee/CoffeeMachine.cs
  40. +1
    -1
      HBLDevice.ICChip/HBLDevice.ICChip.csproj
  41. +1
    -1
      HBLDevice.ICChip/ICChipMachine.cs
  42. +2
    -2
      HBLDevice.IceCream/IceCreamMachine.cs

+ 1
- 1
HBLConsole.Business/HeartbeatReport.cs View File

@@ -34,7 +34,7 @@ namespace HBLConsole.Business
deviceStatus.DeviceType = GeneralConfig.DeviceType;
Topic = TOPIC.GetInstance.GetHeatbeatTopic(GeneralConfig.DeviceType);

ThreadOperate.GetInstance.StartLong(new Action(() =>
ThreadManage.GetInstance.StartLong(new Action(() =>
{
deviceStatus.BatchingInfo = GeneralConfig.BatchingInfos;
deviceStatus.Healthy = GeneralConfig.Healthy ? DeviceHealthy.Health : DeviceHealthy.UnHealth;


+ 2
- 2
HBLConsole.Business/IotReport.cs View File

@@ -151,7 +151,7 @@ namespace HBLConsole.Business
/// </summary>
public void Init()
{
ThreadOperate.GetInstance.StartLong(new Action(() =>
ThreadManage.GetInstance.StartLong(new Action(() =>
{
if (IOTDev.client.IsConnected && GeneralConfig.DeviceType.ToString() == "MORKS")
{
@@ -173,7 +173,7 @@ namespace HBLConsole.Business
{
IOTCommandModel iOTCommand = Tools.JsonToObjectTools<IOTCommandModel>(message);
if (iOTCommand.deviceName == InternetInfo.DeviceName)
ActionOperate.GetInstance.Send("IotBroadcast", iOTCommand);
ActionManage.GetInstance.Send("IotBroadcast", iOTCommand);
}
}
#endregion


+ 1
- 1
HBLConsole.Business/M2MqttHelper.cs View File

@@ -22,7 +22,7 @@ namespace HBLConsole.Business

public void Init()
{
ThreadOperate.GetInstance.StartLong(new Action(() =>
ThreadManage.GetInstance.StartLong(new Action(() =>
{
//AlarmHelper.GetInstance.EdgeAlarm(GVL_Fault.GetInstance.MCUDisconnected, "单片机掉线", AlarmLevel.严重报警);
//AlarmHelper.GetInstance.EdgeAlarm(GVL_Fault.GetInstance.IceCreamAbnormal, "冰淇淋机异常");


+ 4
- 4
HBLConsole.Business/MessageServer/Base.cs View File

@@ -31,8 +31,8 @@ namespace HBLConsole.Business.MessageServer
IsSelected = true,
OrderPush = morkOrderpush
});
ActionOperate.GetInstance.Send("AddOrder", morkOrderpush);
ActionOperate.GetInstance.Send("DataParse", morkOrderpush);
ActionManage.GetInstance.Send("AddOrder", morkOrderpush);
ActionManage.GetInstance.Send("DataParse", morkOrderpush);
}
}
}
@@ -73,7 +73,7 @@ namespace HBLConsole.Business.MessageServer
if (PushType == 1)
{
Json<BatchingInfoPar>.Data.recipeBoms = JsonConvert.DeserializeObject<RecipeBoms>(result);
ActionOperate.GetInstance.Send("recipeBom");
ActionManage.GetInstance.Send("recipeBom");
//WritePlcData();
}
else if (PushType == 0)
@@ -107,7 +107,7 @@ namespace HBLConsole.Business.MessageServer
{
Json<BatchingInfoPar>.Data.recipeBoms = recipeBom;
MessageLog.GetInstance.Show("接收到辅料信息");
ActionOperate.GetInstance.Send("recipeBom");
ActionManage.GetInstance.Send("recipeBom");
}
//WritePlcData();
}


+ 1
- 1
HBLConsole.Business/ServerData.cs View File

@@ -24,7 +24,7 @@ namespace HBLConsole.Business

public void Init()
{
ThreadOperate.GetInstance.StartLong(new Action(() =>
ThreadManage.GetInstance.StartLong(new Action(() =>
{
while (receives.Count > 0)
{


+ 1
- 1
HBLConsole.Communication/ConnectHelper.cs View File

@@ -57,7 +57,7 @@ namespace HBLConsole.Communication
//}
}
}
ActionOperate.GetInstance.Send($"{GVL.GeneralConfig.DeviceType.ToString()}/ConnectOk");
ActionManage.GetInstance.Send($"{GVL.GeneralConfig.DeviceType.ToString()}/ConnectOk");
}

}


+ 0
- 1
HBLConsole.Communication/HBLConsole.Communication.csproj View File

@@ -13,7 +13,6 @@
<ItemGroup>
<ProjectReference Include="..\HBLConsole.GVL\HBLConsole.GVL.csproj" />
<ProjectReference Include="..\HBLConsole.Model\HBLConsole.Model.csproj" />
<ProjectReference Include="..\HBLConsole.Service\HBLConsole.Service.csproj" />
<ProjectReference Include="..\Lebai.SDK\Lebai.SDK.csproj" />
</ItemGroup>



+ 2
- 2
HBLConsole.Communication/ModbusTcpHelper.cs View File

@@ -47,8 +47,8 @@ namespace HBLConsole.Communication
master.Transport.ReadTimeout = 2000;//读取超时时间
master.Transport.WriteTimeout = 2000;//写入超时时间
master.Transport.Retries = 10;//重试次数
//ActionOperate.GetInstance.Send("ConnectOk");
//ActionOperate.GetInstance.Send($"{GVL.GeneralConfig.DeviceType.ToString()}/ConnectOk");
//ActionManage.GetInstance.Send("ConnectOk");
//ActionManage.GetInstance.Send($"{GVL.GeneralConfig.DeviceType.ToString()}/ConnectOk");
MessageLog.GetInstance.Show($"设备【{ip}:{port}】连接成功");
}



+ 5
- 5
HBLConsole.Debug/ViewModel/ViewModel_MORKIC.cs View File

@@ -105,11 +105,11 @@ namespace HBLConsole.Debug



ThreadOperate.GetInstance.StartLong(new Action(() =>
ThreadManage.GetInstance.StartLong(new Action(() =>
{
RobotConnected = LebaiHelper.GetInstance.IsConnected?"已连接":"未连接";
IceCreamConnected = MorkIStatus.GetInstance().OnLine ? "已连接":"未连接";
CoffeeConnected = MorkCStatus.GetInstance().OnLine ? "已连接": "未连接";
RobotConnected = LebaiHelper.GetInstance.IsConnected ? "已连接" : "未连接";
IceCreamConnected = MorkIStatus.GetInstance().OnLine ? "已连接" : "未连接";
CoffeeConnected = MorkCStatus.GetInstance().OnLine ? "已连接" : "未连接";



@@ -126,7 +126,7 @@ namespace HBLConsole.Debug
CurrentMode = MorkIStatus.GetInstance().CurrentMode;
IceCreamFault = MorkIStatus.GetInstance().Fault;
CXB = MorkIStatus.GetInstance().CXB;
DLCompleted = MorkIStatus.GetInstance().DLCompleted?"打料完成":"打料中";
DLCompleted = MorkIStatus.GetInstance().DLCompleted ? "打料完成" : "打料中";
Thread.Sleep(500);
}), "MORK IC-状态刷新");
}


+ 6
- 6
HBLConsole.Factory/SimpleFactory.cs View File

@@ -15,7 +15,7 @@ namespace HBLConsole.Factory

private volatile static SimpleFactory _Instance;
public static SimpleFactory GetInstance => _Instance ?? (_Instance = new SimpleFactory());
private SimpleFactory() { ActionOperate.GetInstance.Register(new Action(() => { GetInterfaceData(); }), "ResetProgram"); }
private SimpleFactory() { ActionManage.GetInstance.Register(new Action(() => { GetInterfaceData(); }), "ResetProgram"); }

public AbstractMessageServer GetAbsMessageServer => _GetAbsMessageServer ?? (_GetAbsMessageServer = GetAbstractMessageServer());
private AbstractMessageServer _GetAbsMessageServer;
@@ -50,7 +50,7 @@ namespace HBLConsole.Factory
bool res = GetAbsMessageServer.OrderStatusChange(subid, status);
if (res)
{
ActionOperate.GetInstance.Send("OrderStatusChange", new OrderStatusChange()
ActionManage.GetInstance.Send("OrderStatusChange", new OrderStatusChange()
{
CookingStatus = status,
SuborderId = subid
@@ -86,10 +86,10 @@ namespace HBLConsole.Factory
GetBatchingInfo();
GetInterfaceData();
control?.Init();
ActionOperate.GetInstance.Register(new Action<object>((o) => { control?.DataParse(o); }), "DataParse");
ActionOperate.GetInstance.Register(new Action(() => { control?.ConnectOk(); }), $"{GeneralConfig.DeviceType.ToString()}/ConnectOk");
ActionOperate.GetInstance.Register(new Action<object>((o) => { control?.SimOrder(o); }), "SimOrder");
ActionOperate.GetInstance.Register(new Action<object>((o) => { control?.IotBroadcast(o); }), "IotBroadcast");
ActionManage.GetInstance.Register(new Action<object>((o) => { control?.DataParse(o); }), "DataParse");
ActionManage.GetInstance.Register(new Action(() => { control?.ConnectOk(); }), $"{GeneralConfig.DeviceType.ToString()}/ConnectOk");
ActionManage.GetInstance.Register(new Action<object>((o) => { control?.SimOrder(o); }), "SimOrder");
ActionManage.GetInstance.Register(new Action<object>((o) => { control?.IotBroadcast(o); }), "IotBroadcast");
ConnectHelper.GetInstance.Init();

}


+ 7
- 7
HBLConsole.MORKD/Control_MORKD.cs View File

@@ -55,7 +55,7 @@ namespace HBLConsole.MORKD

public void Init()
{
ActionOperate.GetInstance.Register(new Action(() => { mORKD.InitControl(); }), "InitCommand");
ActionManage.GetInstance.Register(new Action(() => { mORKD.InitControl(); }), "InitCommand");
}

bool Initing = false;
@@ -65,17 +65,17 @@ namespace HBLConsole.MORKD
/// </summary>
private void ResetProgram()
{
ThreadOperate.GetInstance.StartLong(new Action(() =>
ThreadManage.GetInstance.StartLong(new Action(() =>
{
if (RTrig.GetInstance("ResetProgram").Start(Initing))
{
ThreadOperate.GetInstance.StopTask("MainTask", new Action(() =>
ThreadManage.GetInstance.StopTask("MainTask", new Action(() =>
{
ThreadOperate.GetInstance.StopTask("ReadPLCData", new Action(() =>
ThreadManage.GetInstance.StopTask("ReadPLCData", new Action(() =>
{
mORKD = null;
mORKD = new GVL_MORKD();
ActionOperate.GetInstance.Send("ResetProgram");
ActionManage.GetInstance.Send("ResetProgram");
ReadData();
Main();
}));
@@ -88,7 +88,7 @@ namespace HBLConsole.MORKD

public void Main()
{
ThreadOperate.GetInstance.StartLong(new Action(() =>
ThreadManage.GetInstance.StartLong(new Action(() =>
{
mORKD.AllowRun = mORKD.InitComplete && !mORKD.TemperatureReached;

@@ -113,7 +113,7 @@ namespace HBLConsole.MORKD

public void ReadData()
{
ThreadOperate.GetInstance.StartLong(new Action(() =>
ThreadManage.GetInstance.StartLong(new Action(() =>
{
ModbusTcpHelper.GetInstance.Readbool(1120, 30, new Action<bool[]>((bools) =>
{


+ 6
- 6
HBLConsole.MORKIC/Control_MORKIC.cs View File

@@ -90,7 +90,7 @@ namespace HBLConsole.MORKIC
Main();
ReadData();

ThreadOperate.GetInstance.StartLong(new Action(() =>
ThreadManage.GetInstance.StartLong(new Action(() =>
{
while (morkOrderPushes.Count > 0)
{
@@ -177,7 +177,7 @@ namespace HBLConsole.MORKIC
//todo:先调用机器人


ThreadOperate.GetInstance.Start(new Action(() => { LebaiHelper.GetInstance.Scene(10002); }), "调用乐百机器人做咖啡场景");
ThreadManage.GetInstance.Start(new Action(() => { LebaiHelper.GetInstance.Scene(10002); }), "调用乐百机器人做咖啡场景");
while (!(lebai.Ok && lebai.Value == 1))
{
Thread.Sleep(5);
@@ -219,7 +219,7 @@ namespace HBLConsole.MORKIC
//订单状态改变:开始制作
SimpleFactory.GetInstance.OrderChanged(subOrderId, BPA.Message.Enum.ORDER_STATUS.COOKING);
//todo:先调用机器人
ThreadOperate.GetInstance.Start(new Action(() => { LebaiHelper.GetInstance.Scene(scene); }), "调用乐百机器人做冰淇淋场景");
ThreadManage.GetInstance.Start(new Action(() => { LebaiHelper.GetInstance.Scene(scene); }), "调用乐百机器人做冰淇淋场景");

while (!(lebai.Ok && lebai.Value == 1))
{
@@ -259,7 +259,7 @@ namespace HBLConsole.MORKIC
new ModeSetEvent() { Mode = MORKI_MODE.制冷模式 }.Publish();

//开始心跳刷新,根据咖啡机及冰淇淋机来判断
ThreadOperate.GetInstance.StartLong(new Action(() =>
ThreadManage.GetInstance.StartLong(new Action(() =>
{

//GeneralConfig.Healthy = true;
@@ -279,7 +279,7 @@ namespace HBLConsole.MORKIC

public void ReadData()
{
ThreadOperate.GetInstance.StartLong(new Action(() =>
ThreadManage.GetInstance.StartLong(new Action(() =>
{
lebai = LebaiHelper.GetInstance.GetValueAsync();
LebaiHelper.GetInstance.GetRobotModeStatus();
@@ -289,7 +289,7 @@ namespace HBLConsole.MORKIC

public void SimOrder<T>(T simOrder)
{
//ThreadOperate.GetInstance.Start(new Action(() =>
//ThreadManage.GetInstance.Start(new Action(() =>
//{
// DoIceCream();
// //DoCoffee();


+ 6
- 6
HBLConsole.MORKS/Control_MORKS.cs View File

@@ -23,8 +23,8 @@ namespace HBLConsole.MORKS
GVL_MORKS mORKS = new GVL_MORKS();
public void Init()
{
ActionOperate.GetInstance.Register(new Action(() => { WriteRecipeBoms(); }), "recipeBom");
ActionOperate.GetInstance.Register(new Action(() => { DeviceInit(); }), "InitCommand");
ActionManage.GetInstance.Register(new Action(() => { WriteRecipeBoms(); }), "recipeBom");
ActionManage.GetInstance.Register(new Action(() => { DeviceInit(); }), "InitCommand");
}

public void ConnectOk()
@@ -41,11 +41,11 @@ namespace HBLConsole.MORKS
/// </summary>
private void ResetProgram()
{
ThreadOperate.GetInstance.StartLong(new Action(() =>
ThreadManage.GetInstance.StartLong(new Action(() =>
{
if (RTrig.GetInstance("ResetProgram").Start(mORKS.DeviceIniting))
{
ThreadOperate.GetInstance.StopTask("MainTask", new Action(() =>
ThreadManage.GetInstance.StopTask("MainTask", new Action(() =>
{
mORKS.AllowRun = false;
TakeBowlId = string.Empty;
@@ -68,7 +68,7 @@ namespace HBLConsole.MORKS
/// </summary>
public void ReadData()
{
ThreadOperate.GetInstance.StartLong(new Action(() =>
ThreadManage.GetInstance.StartLong(new Action(() =>
{
ModbusTcpHelper.GetInstance.Readbool(323, 3, new Action<bool[]>((bools) =>
{
@@ -261,7 +261,7 @@ namespace HBLConsole.MORKS

public void Main()
{
ThreadOperate.GetInstance.StartLong(new Action(() =>
ThreadManage.GetInstance.StartLong(new Action(() =>
{
mORKS.AllowRun = mORKS.InitComplete && !mORKS.TemperatureReached;
//mORKS.AllowRun = mORKS.InitComplete && mORKS.TemperatureReached;


+ 2
- 2
HBLConsole.MainConsole/Main.cs View File

@@ -29,7 +29,7 @@ namespace HBLConsole.MainConsole
GeneralConfig.DeviceType = DeviceClientType.MORKS;
if (Enum.TryParse(deviceType, out DeviceClientType dct)) GeneralConfig.DeviceType = dct;
LocaPath.GetInstance.FilePath = $"AccessFile\\{GeneralConfig.DeviceType.ToString()}\\";
ThreadOperate.GetInstance.Start(new Action(() => { Sqlite<Alarm>.GetInstance.GetData(); }), "GetAlarm");
ThreadManage.GetInstance.Start(new Action(() => { Sqlite<Alarm>.GetInstance.GetData(); }), "GetAlarm");
Json<MorkOrderPushPar>.Read();
Json<BatchingInfoPar>.Read();
Json<SimOrderConfig>.Read();
@@ -51,7 +51,7 @@ namespace HBLConsole.MainConsole

public void BusinessInit()
{
ThreadOperate.GetInstance.Start(new Action(() =>
ThreadManage.GetInstance.Start(new Action(() =>
{
InternetInfo.ConfigInit();//从 consul 获取配置数据
Topics.Clear();


+ 1
- 1
HBLConsole.Model/HBLConsole.Model.csproj View File

@@ -20,7 +20,7 @@
<HintPath>D:\BPACommon_output\net5.0\BPA.Message.dll</HintPath>
</Reference>
<Reference Include="BPA.Models">
<HintPath>..\..\..\..\BPACommon_output\net5.0\BPA.Models.dll</HintPath>
<HintPath>D:\BPACommon_output\net5.0\BPA.Models.dll</HintPath>
</Reference>
</ItemGroup>



+ 1
- 1
HBLConsole.Model/SQL/VariableInfo.cs View File

@@ -32,7 +32,7 @@ namespace HBLConsole.Model
{
_mVarName = value;
OnPropertyChanged();
ActionOperate.GetInstance.Send("VarNameChanged", _mID);
ActionManage.GetInstance.Send("VarNameChanged", _mID);
}
}
private string _mVarName;


+ 129
- 0
HBLConsole.Service/ActionManage.cs View File

@@ -0,0 +1,129 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Collections.Concurrent;

namespace HBLConsole.Service
{
public class ActionManage
{

private volatile static ActionManage _Instance;
public static ActionManage GetInstance => _Instance ?? (_Instance = new ActionManage());
private ActionManage() { }

private static ConcurrentDictionary<string, Delegation> actions = new ConcurrentDictionary<string, Delegation>();

static readonly object SendLock = new object();
static readonly object SendParLock = new object();
static readonly object RegisterLock = new object();

/// <summary>
/// 注销委托
/// </summary>
/// <param name="key"></param>
public void CancelRegister(string key)
{
if (actions.ContainsKey(key))
actions.TryRemove(key, out Delegation t);
}

/// <summary>
/// 执行注册过的委托
/// </summary>
/// <param name="key">注册委托的key</param>
/// <param name="par">委托参数</param>
/// <param name="Callback">委托回调</param>
public void Send(string key, object par, Action Callback = null)
{
lock (SendLock)
if (actions.ContainsKey(key)) actions[key].ActionPar.Invoke(par, Callback);
//if (actions[key].ActionPar != null)
//{
// actions[key].ActionPar(par);
// if (Callback != null) Callback();
//}
}

/// <summary>
/// 执行注册过的委托
/// </summary>
/// <param name="key">注册委托的key</param>
/// <param name="Callback">委托回调</param>
public void Send(string key, Action Callback = null)
{
lock (SendLock)
if (actions.ContainsKey(key)) actions[key].ActionBus?.Invoke(Callback);
}

public object SendResult(string key, object par = null)
{
lock (SendLock)
if (actions.ContainsKey(key))
if (par == null)
{
if (actions[key].FuncObj != null)
return actions[key].FuncObj;
}
else
{
if (actions[key].FuncPar != null)
return actions[key].FuncPar(par);
}
return default;
}

public void Register<T>(T action, string key)
{
lock (RegisterLock)
{
if (action != null)
{
if (!actions.ContainsKey(key))
{
MessageLog.GetInstance.Show($"注册委托:【{key}】");
if (action is Action actionBus)
actions.TryAdd(key, new Delegation() { ActionBus = actionBus });

if (action is Action<object> actionObj)
actions.TryAdd(key, new Delegation() { ActionPar = actionObj });

if (action is Func<object> funcObj)
actions.TryAdd(key, new Delegation() { FuncObj = funcObj });

if (action is Func<object, object> puncPar)
actions.TryAdd(key, new Delegation() { FuncPar = puncPar });
}
}
}

}

}


internal class Delegation
{
/// <summary>
/// 带参数的委托
/// </summary>
public Action<object> ActionPar { get; set; }
/// <summary>
/// 无参数的委托
/// </summary>
public Action ActionBus { get; set; }
public Action CallBack { get; set; }
/// <summary>
/// 有返回值的委托
/// </summary>
public Func<object> FuncObj { get; set; }
/// <summary>
/// 有返回值,有参数的委托
/// </summary>
public Func<object, object> FuncPar { get; set; }
}


}

+ 0
- 119
HBLConsole.Service/ActionOperate.cs View File

@@ -1,119 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Collections.Concurrent;

namespace HBLConsole.Service
{
public class ActionOperate
{

private volatile static ActionOperate _Instance;
public static ActionOperate GetInstance => _Instance ?? (_Instance = new ActionOperate());
private ActionOperate() { }

private static ConcurrentDictionary<string, Delegation> actions = new ConcurrentDictionary<string, Delegation>();

//private static ConcurrentDictionary<string, ActionManagerment> actionManagers = new ConcurrentDictionary<string, ActionManagerment>();

static readonly object SendLock = new object();
static readonly object SendParLock = new object();
static readonly object RegisterLock = new object();

/// <summary>
/// 注销委托
/// </summary>
/// <param name="name"></param>
public void CancelRegister(string name)
{
if (actions.ContainsKey(name))
{
actions.TryRemove(name, out Delegation t);
}
}

public void Send(string name, object token, Action action = null)
{
lock (SendLock)
if (actions.ContainsKey(name))
if (actions[name].ActionObj != null)
{
actions[name].ActionObj(token);
if (action != null) action();
}
}

public void Send(string name, AsyncCallback action = null)
{
lock (SendLock)
if (actions.ContainsKey(name))
if (actions[name].ActionBus != null)
{
if (action != null)
actions[name].ActionBus.BeginInvoke(action, null);
else
actions[name].ActionBus();
}

}

public object SendResult(string name, object token = null)
{
object result = new object();
lock (SendLock)
if (actions.ContainsKey(name))
if (token == null)
{
if (actions[name].FuncObj != null)
result = actions[name].FuncObj;
}
else
{
if (actions[name].FuncPar != null)
result = actions[name].FuncPar(token);
}
return result;
}

public void Register<T>(T action, string name)
{
lock (RegisterLock)
{
if (action != null)
{
if (!actions.ContainsKey(name))
{
if (action is Action actionBus)
actions.TryAdd(name, new Delegation() { ActionBus = actionBus });

if (action is Action<object> actionObj)
actions.TryAdd(name, new Delegation() { ActionObj = actionObj });

if (action is Func<object> funcObj)
actions.TryAdd(name, new Delegation() { FuncObj = funcObj });

if (action is Func<object, object> puncPar)
actions.TryAdd(name, new Delegation() { FuncPar = puncPar });
}
}
}

}

}


internal class Delegation
{
public Action<object> ActionObj { get; set; }

public Action ActionBus { get; set; }
public Action CallBack { get; set; }
public Func<object> FuncObj { get; set; }
public Func<object, object> FuncPar { get; set; }
}


}

+ 61
- 18
HBLConsole.Service/ExpandMethod.cs View File

@@ -10,12 +10,24 @@ namespace HBLConsole.Service
{
public static class ExpandMethod
{
/// <summary>
/// 获取布尔数组指定值得索引
/// </summary>
/// <param name="obj">要获取索引的数组</param>
/// <param name="value">要获取索引的值</param>
/// <returns></returns>
public static int GetIndex(this bool[] obj, bool value)
{
if (obj == null) return -1;
return Array.FindIndex(obj, p => p == value);
}

/// <summary>
/// 获取字符串数组指定值得索引
/// </summary>
/// <param name="obj">要获取索引的数组</param>
/// <param name="value">要获取索引的值</param>
/// <returns></returns>
public static int GetIndex(this string[] obj, string value)
{
if (obj == null || value == null) return -1;
@@ -23,35 +35,66 @@ namespace HBLConsole.Service
}

/// <summary>
/// 保存数据
/// 委托回调
/// </summary>
public static void Save<T>(this T ot)
/// <param name="action">要执行的委托</param>
/// <param name="callback">委托回调</param>
public static void Invoke(this Action action, Action callback)
{
string outjson = JsonConvert.SerializeObject(ot);
var str = ot.GetType().GenericTypeArguments;
if (str != null && str.Length > 0)
if (action != null)
{
File.WriteAllText(LocaPath.GetInstance.Getpath(str[0].Name), outjson);
action();
if (callback != null) callback();
}

}

/// <summary>
/// 获取保存的数据
/// 委托回调
/// </summary>
public static void Read(this object ot)
/// <param name="action">要执行的委托</param>
/// <param name="par">要执行的委托的参数</param>
/// <param name="callback">委托回调</param>
public static void Invoke(this Action<object> action, object par, Action callback)
{
var str = ot.GetType().GenericTypeArguments;
if (str != null && str.Length > 0)
if (action != null)
{
string pa = LocaPath.GetInstance.Getpath(str[0].Name);
if (File.Exists(pa))
{
string JsonString = File.ReadAllText(pa);
var result = JsonConvert.DeserializeObject<object>(JsonString);
if (result != null) { Json<object>.Data = result; }
}
action(par);
if (callback != null) callback();
}
}



///// <summary>
///// 保存数据
///// </summary>
//public static void Save<T>(this T ot)
//{
// string outjson = JsonConvert.SerializeObject(ot);
// var str = ot.GetType().GenericTypeArguments;
// if (str != null && str.Length > 0)
// {
// File.WriteAllText(LocaPath.GetInstance.Getpath(str[0].Name), outjson);
// }

//}

///// <summary>
///// 获取保存的数据
///// </summary>
//public static void Read(this object ot)
//{
// var str = ot.GetType().GenericTypeArguments;
// if (str != null && str.Length > 0)
// {
// string pa = LocaPath.GetInstance.Getpath(str[0].Name);
// if (File.Exists(pa))
// {
// string JsonString = File.ReadAllText(pa);
// var result = JsonConvert.DeserializeObject<object>(JsonString);
// if (result != null) { Json<object>.Data = result; }
// }
// }
//}
}
}

+ 1
- 1
HBLConsole.Service/HBLConsole.Service.csproj View File

@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<TargetFramework>netstandard2.1</TargetFramework>
</PropertyGroup>

<ItemGroup>


+ 1
- 1
HBLConsole.Service/Json.cs View File

@@ -12,7 +12,7 @@ namespace HBLConsole.Service
public class Json<T> where T : class, new()
{

//private static string DeviceType = ActionOperate.GetInstance.SendResult("GetDeviceType").ToString();
//private static string DeviceType = ActionManage.GetInstance.SendResult("GetDeviceType").ToString();

//static string path
//{


+ 1
- 2
HBLConsole.Service/SystemHelper.cs View File

@@ -46,9 +46,8 @@ namespace HBLConsole.Service
//System.IO.File.Delete(deskTop + FileName + ".lnk");//删除原来的桌面快捷键方式
}
WshShell shell = new WshShell();

//快捷键方式创建的位置、名称
IWshShortcut shortcut = (IWshShortcut)shell.CreateShortcut(deskTop + GetApplicationName + ".lnk");
IWshShortcut shortcut = shell.CreateShortcut(deskTop + GetApplicationName + ".lnk") as IWshShortcut;
shortcut.TargetPath = GetApplicationPath; //目标文件
//该属性指定应用程序的工作目录,当用户没有指定一个具体的目录时,快捷方式的目标应用程序将使用该属性所指定的目录来装载或保存文件。
shortcut.WorkingDirectory = System.Environment.CurrentDirectory;


+ 172
- 0
HBLConsole.Service/ThreadManage.cs View File

@@ -0,0 +1,172 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Collections.Concurrent;
using System.Diagnostics;
using System.Threading;

namespace HBLConsole.Service
{
/// <summary>
/// 线程管理
/// </summary>
public class ThreadManage
{
private volatile static ThreadManage _Instance;
public static ThreadManage GetInstance => _Instance ?? (_Instance = new ThreadManage());
private ThreadManage() { }
string guid = "871d7e28-c413-4675-8d28-64e4dca4c2d3-";
private static readonly object _lock = new object();
StringBuilder callbackKey = new StringBuilder();
List<string> keys = new List<string>();
ConcurrentDictionary<string, Task> Threads = new ConcurrentDictionary<string, Task>();
ConcurrentDictionary<string, CancellationTokenSource> CancellationTokenSources = new ConcurrentDictionary<string, CancellationTokenSource>();

/// <summary>
/// 停止指定任务
/// </summary>
/// <param name="key">任务名</param>
/// <param name="ExitCallback">任务结束的回调</param>
public void StopTask(string key, Action ExitCallback = null)
{
if (CancellationTokenSources.ContainsKey(guid + key))
CancellationTokenSources[guid + key]?.Cancel();
ActionManage.GetInstance.Register(ExitCallback, guid + key);
}

//public void StopTask(string[] keys, Action ExitCallback = null)
//{
// lock (_lock)
// if (keys != null)
// {
// for (int i = 0; i < keys.Length; i++)
// {
// this.keys.Add(keys[i]);
// callbackKey.Append(keys[i]);
// if (CancellationTokenSources.ContainsKey(guid + keys[i]))
// CancellationTokenSources[guid + keys[i]]?.Cancel();
// }
// callbackKey.Append(guid);
// ActionManage.GetInstance.Register(ExitCallback, callbackKey.ToString());
// }

//}

/// <summary>
/// 长任务,带 while true 的循环
/// </summary>
/// <param name="action"></param>
/// <param name="key"></param>
public void StartLong(Action action, string key, Action RunComplete = null)
{
CancellationTokenSources.TryAdd(guid + key, new CancellationTokenSource());
bool result = Threads.TryAdd(guid + key, Task.Factory.StartNew(new Action(() =>
{
try
{
while (!CancellationTokenSources[guid + key].IsCancellationRequested)
{
if (action != null) action();
}
}
catch (Exception ex)
{
MessageLog.GetInstance.Show($"线程 【{key}】运行发生异常,已重启");
CancellationTokenSources.TryRemove(guid + key, out CancellationTokenSource temp);
Threads.TryRemove(guid + key, out Task temp1);

}
}), CancellationTokenSources[guid + key].Token).ContinueWith(new Action<Task, object>((t, o) =>
{
ThreadStatus(t, o.ToString());
if (RunComplete != null) RunComplete();
}), guid + key));
MessageLog.GetInstance.Show($"启动线程 【{key}】");
if (!result) MessageLog.GetInstance.Show($"【{key}】任务已存在,请检查 TaskName");

}


/// <summary>
/// 不带 while true 的循环任务
/// </summary>
/// <param name="action"></param>
/// <param name="key"></param>
public void Start(Action action, string key)
{
CancellationTokenSources.TryAdd(guid + key, new CancellationTokenSource());
bool result = Threads.TryAdd(guid + key, Task.Factory.StartNew(new Action(() =>
{
if (action != null) action();
}), CancellationTokenSources[guid + key].Token).ContinueWith(new Action<Task, object>((t, o) =>
{
ThreadStatus(t, o.ToString());
}), guid + key));
if (!result) MessageLog.GetInstance.Show($"【{key}】任务已存在,请检查 TaskName");
}

private void ThreadStatus(Task task, string key)
{
bool IsRemove = false;
string name = key.Substring(key.LastIndexOf('-') + 1);
switch (task.Status)
{
case TaskStatus.RanToCompletion:
MessageLog.GetInstance.Show($"线程【{name}】执行完成");
IsRemove = true;
break;
case TaskStatus.Faulted:
MessageLog.GetInstance.Show($"线程【{name}】执行异常,{task.Exception}");
IsRemove = true;
break;
case TaskStatus.Canceled:
MessageLog.GetInstance.Show($"线程【{name}】已取消");
IsRemove = true;
break;
default:
break;
}

if (IsRemove)
{
if (Threads.ContainsKey(key))
Threads.TryRemove(key, out Task t);
//Threads.TryRemove(Threads.FirstOrDefault(p => p.Key == TaskName));


if (CancellationTokenSources.ContainsKey(key))
CancellationTokenSources.TryRemove(key, out CancellationTokenSource cts);
//CancellationTokenSources.TryRemove(CancellationTokenSources.FirstOrDefault(p => p.Key == TaskName));
//keys.Remove(key);
//if (keys != null && keys.Count == 0) ActionManage.GetInstance.Send(callbackKey.ToString());
ActionManage.GetInstance.Send(key);
}
}

/// <summary>
/// 释放所有线程资源
/// </summary>
public void Dispose()
{
for (int i = 0; i < CancellationTokenSources.Count; i++)
{
CancellationTokenSources.ElementAt(i).Value.Cancel();
}
}

/// <summary>
/// 判断指定线程是否完成
/// </summary>
/// <param name="key"></param>
/// <returns></returns>
public bool IsComplete(string key)
{
if (Threads.ContainsKey(guid + key)) return Threads[guid + key].IsCompleted;
return false;
}

}

}

+ 0
- 153
HBLConsole.Service/ThreadOperate.cs View File

@@ -1,153 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Collections.Concurrent;
using System.Diagnostics;
using System.Threading;

namespace HBLConsole.Service
{
/// <summary>
/// 线程管理
/// </summary>
public class ThreadOperate
{
private volatile static ThreadOperate _Instance;
public static ThreadOperate GetInstance => _Instance ?? (_Instance = new ThreadOperate());
private ThreadOperate() { }
string guid = "871d7e28-c413-4675-8d28-64e4dca4c2d3-";
ConcurrentDictionary<string, Task> Threads = new ConcurrentDictionary<string, Task>();
ConcurrentDictionary<string, CancellationTokenSource> CancellationTokenSources = new ConcurrentDictionary<string, CancellationTokenSource>();

/// <summary>
/// 停止指定任务
/// </summary>
/// <param name="taskName">任务名</param>
/// <param name="ExitCallback">任务结束的回调</param>
public void StopTask(string taskName, Action ExitCallback = null)
{
if (CancellationTokenSources.ContainsKey(guid + taskName))
CancellationTokenSources[guid + taskName]?.Cancel();
ActionOperate.GetInstance.Register(ExitCallback, guid + taskName);
}

/// <summary>
/// 长任务,带 while true 的循环
/// </summary>
/// <param name="action"></param>
/// <param name="TaskName"></param>
public void StartLong(Action action, string TaskName, Action RunComplete = null)
{
CancellationTokenSources.TryAdd(guid + TaskName, new CancellationTokenSource());
bool result = Threads.TryAdd(guid + TaskName, Task.Factory.StartNew(new Action(() =>
{
try
{
while (!CancellationTokenSources[guid + TaskName].IsCancellationRequested)
{
if (action != null) action();
}
}
catch (Exception ex)
{
MessageLog.GetInstance.Show($"线程 【{TaskName}】运行发生异常,已重启");
CancellationTokenSources.TryRemove(guid + TaskName, out CancellationTokenSource temp);
Threads.TryRemove(guid + TaskName, out Task temp1);

}
}), CancellationTokenSources[guid + TaskName].Token).ContinueWith(new Action<Task, object>((t, o) =>
{
ThreadStatus(t, o.ToString());
if (RunComplete != null) RunComplete();
}), guid + TaskName));
MessageLog.GetInstance.Show($"启动线程 【{TaskName}】");
if (!result) MessageLog.GetInstance.Show($"【{TaskName}】任务已存在,请检查 TaskName");

}


/// <summary>
/// 不带 while true 的循环任务
/// </summary>
/// <param name="action"></param>
/// <param name="TaskName"></param>
public void Start(Action action, string TaskName)
{
CancellationTokenSources.TryAdd(guid + TaskName, new CancellationTokenSource());
bool result = Threads.TryAdd(guid + TaskName, Task.Factory.StartNew(new Action(() =>
{
action();
}), CancellationTokenSources[guid + TaskName].Token).ContinueWith(new Action<Task, object>((t, o) =>
{
ThreadStatus(t, o.ToString());
}), guid + TaskName));
if (!result) MessageLog.GetInstance.Show($"【{TaskName}】任务已存在,请检查 TaskName");
}

private void ThreadStatus(Task task, string TaskName)
{
bool IsRemove = false;
string name = TaskName.Substring(TaskName.LastIndexOf('-') + 1);
switch (task.Status)
{
case TaskStatus.RanToCompletion:
MessageLog.GetInstance.Show($"线程【{name}】执行完成");
IsRemove = true;
break;
case TaskStatus.Faulted:
MessageLog.GetInstance.Show($"线程【{name}】执行异常,{task.Exception}");
IsRemove = true;
break;
case TaskStatus.Canceled:
MessageLog.GetInstance.Show($"线程【{name}】已取消");
IsRemove = true;
break;
default:
break;
}

if (IsRemove)
{
if (Threads.ContainsKey(TaskName))
Threads.TryRemove(Threads.FirstOrDefault(p => p.Key == TaskName));

if (CancellationTokenSources.ContainsKey(TaskName))
CancellationTokenSources.TryRemove(CancellationTokenSources.FirstOrDefault(p => p.Key == TaskName));

ActionOperate.GetInstance.Send(TaskName);
}
}

/// <summary>
/// 释放所有线程资源
/// </summary>
public void Dispose()
{
for (int i = 0; i < CancellationTokenSources.Count; i++)
{
CancellationTokenSources.ElementAt(i).Value.Cancel();
}
}

/// <summary>
/// 判断指定线程是否完成
/// </summary>
/// <param name="TaskName"></param>
/// <returns></returns>
public bool IsComplete(string TaskName)
{
if (Threads.ContainsKey(guid + TaskName))
{
return Threads[guid + TaskName].IsCompleted;
}
else
{
return false;
}
}

}

}

+ 2
- 2
HBLConsole/App.xaml.cs View File

@@ -39,7 +39,7 @@ namespace HBLConsole
SystemHelper.GetInstance.CreateDesktopShortcut();
AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
MainConsole.Main.GetInstance.DataInit();
ThreadOperate.GetInstance.Start(new Action(() => { SqlHelper.GetInstance.GetData(); }), "GetSqliteData");
ThreadManage.GetInstance.Start(new Action(() => { SqlHelper.GetInstance.GetData(); }), "GetSqliteData");
mainView = new MainView();
mainView.Show();
SplitScreenDisplay();
@@ -104,7 +104,7 @@ namespace HBLConsole
IotReport.Close();
SqlHelper.GetInstance.Save();
MainConsole.Main.GetInstance.DataSave();
ThreadOperate.GetInstance.Dispose();
ThreadManage.GetInstance.Dispose();
System.Environment.Exit(0);

}


+ 4
- 4
HBLConsole/DialogWindow/View/DeviceManagermentSetView.xaml.cs View File

@@ -34,20 +34,20 @@ namespace HBLConsole.DialogWindow.View
this.MaxWidth = SystemParameters.WorkArea.Width;
this.MaxHeight = SystemParameters.WorkArea.Height;

ActionOperate.GetInstance.Register(new Action<object>((s) =>
ActionManage.GetInstance.Register(new Action<object>((s) =>
{
//this.Tag = s;
//this.DialogResult = false;
ActionOperate.GetInstance.CancelRegister("Cancel");
ActionManage.GetInstance.CancelRegister("Cancel");
this.Close();

}), "Cancel");

ActionOperate.GetInstance.Register(new Action<object>((s) =>
ActionManage.GetInstance.Register(new Action<object>((s) =>
{
//this.Tag = s;
//this.DialogResult = true;
ActionOperate.GetInstance.CancelRegister("Confirm");
ActionManage.GetInstance.CancelRegister("Confirm");
this.Close();

}), "Confirm");


+ 4
- 4
HBLConsole/DialogWindow/View/SimOrderConfitView.xaml.cs View File

@@ -28,15 +28,15 @@ namespace HBLConsole.DialogWindow.View
this.MoveBorder.MouseLeftButtonDown += (o, e) => { this.DragMove(); };
this.ButMin.Click += (o, e) => { this.WindowState = WindowState.Minimized; };
this.ButMax.Click += (o, e) => { this.WindowState = this.WindowState == WindowState.Maximized ? WindowState.Normal : WindowState.Maximized; };
this.ButClose.Click += (o, e) => { this.Close(); ActionOperate.GetInstance.CancelRegister("SendSimData"); };
this.ButClose.Click += (o, e) => { this.Close(); ActionManage.GetInstance.CancelRegister("SendSimData"); };
this.MaxWidth = SystemParameters.WorkArea.Width;
this.MaxHeight = SystemParameters.WorkArea.Height;

ActionOperate.GetInstance.Register(new Action(() =>
ActionManage.GetInstance.Register(new Action(() =>
{
this.Close();
ActionOperate.GetInstance.CancelRegister("SimOrderConfitViewModelExit");
ActionOperate.GetInstance.CancelRegister("SendSimData");
ActionManage.GetInstance.CancelRegister("SimOrderConfitViewModelExit");
ActionManage.GetInstance.CancelRegister("SendSimData");
}), "SimOrderConfitViewModelExit");
}



+ 2
- 2
HBLConsole/DialogWindow/ViewModel/DeviceManagermentSetViewModel.cs View File

@@ -24,7 +24,7 @@ namespace HBLConsole.DialogWindow.ViewModel
Init();
CancelCommand = new RelayCommand(() =>
{
ActionOperate.GetInstance.Send("Cancel", devcieManagerResult);
ActionManage.GetInstance.Send("Cancel", devcieManagerResult);
});
ConfirmCommand = new RelayCommand(() =>
{
@@ -68,7 +68,7 @@ namespace HBLConsole.DialogWindow.ViewModel
{
LogInfo = $"警告:设备【{devcieManagerResult.DeviceName}】已存在,请重试";
}
ActionOperate.GetInstance.Send("Confirm", devcieManagerResult);
ActionManage.GetInstance.Send("Confirm", devcieManagerResult);
});
}



+ 3
- 3
HBLConsole/DialogWindow/ViewModel/ListDialogViewModel.cs View File

@@ -58,7 +58,7 @@ namespace HBLConsole.DialogWindow.ViewModel

//if (Json<MorkOrderPushPar>.Data.morkOrderPushes.Count > 0)
//{
// ThreadOperate.GetInstance.Start(new Action(() =>
// ThreadManage.GetInstance.Start(new Action(() =>
// {
// Thread.Sleep(10000);
// if (!IsAutoClose) WeakReferenceMessenger.Default.Send("false", "Close");
@@ -96,7 +96,7 @@ namespace HBLConsole.DialogWindow.ViewModel
{
item.OrderStatus = ORDER_STATUS.WAIT;
Json<KeepDataBase>.Data.orderLists.Add(item);
ActionOperate.GetInstance.Send("DataParse", item.OrderPush);
ActionManage.GetInstance.Send("DataParse", item.OrderPush);
}
}
//}
@@ -105,7 +105,7 @@ namespace HBLConsole.DialogWindow.ViewModel

if (Json<MorkOrderPushPar>.Data.morkOrderPushes.Count > 0)
{
ThreadOperate.GetInstance.Start(new Action(() =>
ThreadManage.GetInstance.Start(new Action(() =>
{
Thread.Sleep(10000);
if (!IsAutoClose) WeakReferenceMessenger.Default.Send("false", "Close");


+ 3
- 3
HBLConsole/DialogWindow/ViewModel/SimOrderConfitViewModel.cs View File

@@ -19,7 +19,7 @@ namespace HBLConsole.DialogWindow.ViewModel
public SimOrderConfitViewModel()
{
DeviceType = GVL.GeneralConfig.DeviceType.ToString();
ActionOperate.GetInstance.Register(new Action<object>((o) =>
ActionManage.GetInstance.Register(new Action<object>((o) =>
{
if (o != null)
{
@@ -65,9 +65,9 @@ namespace HBLConsole.DialogWindow.ViewModel
Json<KeepDataBase>.Data.simOrderConfig.ElementAt(index).IsSelected = simOrderVisibleData.IsSelected;
}
}
ActionOperate.GetInstance.Send("SimOrderConfitViewModelExit");
ActionManage.GetInstance.Send("SimOrderConfitViewModelExit");
});
CancelCommand = new RelayCommand(() => { ActionOperate.GetInstance.Send("SimOrderConfitViewModelExit"); });
CancelCommand = new RelayCommand(() => { ActionManage.GetInstance.Send("SimOrderConfitViewModelExit"); });
}




+ 1
- 1
HBLConsole/View/DeviceManageView.xaml.cs View File

@@ -31,7 +31,7 @@ namespace HBLConsole.View
{
if (!obj.IsVisible)
{
ActionOperate.GetInstance.Send("DataSave");
ActionManage.GetInstance.Send("DataSave");
}
}



+ 1
- 1
HBLConsole/View/VariableConfig.xaml.cs View File

@@ -33,7 +33,7 @@ namespace HBLConsole.View
var obj = (VariableConfig)sender;
if (!obj.IsVisible)
{
ActionOperate.GetInstance.Send("VariableSave");
ActionManage.GetInstance.Send("VariableSave");
}
}



+ 5
- 5
HBLConsole/ViewModel/DebugViewModel.cs View File

@@ -48,12 +48,12 @@ namespace HBLConsole.ViewModel

}

ActionOperate.GetInstance.Send("SimOrder", locs);
ActionManage.GetInstance.Send("SimOrder", locs);
});

InitCommand = new RelayCommand(() =>
{
ActionOperate.GetInstance.Send("InitCommand");
ActionManage.GetInstance.Send("InitCommand");
});

LoopSimOrderCommand = new RelayCommand(() =>
@@ -61,7 +61,7 @@ namespace HBLConsole.ViewModel
LoopButton = LoopButton == "循环跑单" ? "停止跑单" : "循环跑单";

});
//ThreadOperate.GetInstance.StartLong(new Action(() =>
//ThreadManage.GetInstance.StartLong(new Action(() =>
//{
// //try
// //{
@@ -73,7 +73,7 @@ namespace HBLConsole.ViewModel
// // if (simOrderVisibleDatas.ElementAt(0).IsSelected)
// // simOrderVisibleDatas.ElementAt(0).Loc = (ushort)(new Random().Next(1,6));

// // ActionOperate.GetInstance.Send("SimOrder",new SimOrderData()
// // ActionManage.GetInstance.Send("SimOrder",new SimOrderData()
// // {
// // NoodleLoc = simOrderVisibleDatas.ElementAt(0).Loc,
// // SoupLoc = simOrderVisibleDatas.ElementAt(1).Loc,
@@ -103,7 +103,7 @@ namespace HBLConsole.ViewModel
{
SimOrderConfitView simOrderConfitView = new SimOrderConfitView();
simOrderConfitView.Show();
ActionOperate.GetInstance.Send("SendSimData", res);
ActionManage.GetInstance.Send("SendSimData", res);
}
//}
}


+ 2
- 2
HBLConsole/ViewModel/MainViewModel.cs View File

@@ -25,7 +25,7 @@ namespace HBLConsole.ViewModel
MqttReceive();
DoNavChanged("MessageLogView");
NavChangedCommand = new RelayCommand<object>(DoNavChanged);
ThreadOperate.GetInstance.StartLong(new Action(() =>
ThreadManage.GetInstance.StartLong(new Action(() =>
{
InternetInfo.NetworkConnectState = UniversalHelper.GetInstance.GetNetworkState();
NetworkConnectState = InternetInfo.NetworkConnectState;
@@ -37,7 +37,7 @@ namespace HBLConsole.ViewModel

private void AlarmMonitoring()
{
ThreadOperate.GetInstance.StartLong(new Action(() =>
ThreadManage.GetInstance.StartLong(new Action(() =>
{
if (SimpleFactory.GetInstance.Alarm != null)
{


+ 1
- 1
HBLConsole/ViewModel/ProcessMonitoringViewModel.cs View File

@@ -83,7 +83,7 @@ namespace HBLConsole.ViewModel
private static void UpdateProcess()
{
if (SimpleFactory.GetInstance.GVL == null) return;
ThreadOperate.GetInstance.StartLong(new Action(() =>
ThreadManage.GetInstance.StartLong(new Action(() =>
{
foreach (var item in SimpleFactory.GetInstance.GVL.GetType().GetProperties())
{


+ 2
- 2
HBLConsole/ViewModel/VariableConfig.cs View File

@@ -17,8 +17,8 @@ namespace HBLConsole.ViewModel
{
public VariableConfig()
{
ActionOperate.GetInstance.Register(new Action(() => { SaveDataAsync(); }), "VariableSave");
ActionOperate.GetInstance.Register(new Action<object>((o) =>
ActionManage.GetInstance.Register(new Action(() => { SaveDataAsync(); }), "VariableSave");
ActionManage.GetInstance.Register(new Action<object>((o) =>
{
if (o is int p)
{


+ 1
- 1
HBLConsole/ViewModel/VariableMonitorViewModel.cs View File

@@ -128,7 +128,7 @@ namespace HBLConsole.ViewModel
private static void UpdateValue()
{
if (SimpleFactory.GetInstance.GVL == null) return;
ThreadOperate.GetInstance.StartLong(new Action(() =>
ThreadManage.GetInstance.StartLong(new Action(() =>
{
foreach (var item in SimpleFactory.GetInstance.GVL.GetType().GetProperties())
{


+ 2
- 2
HBLConsole/ViewModel/ViewModelBase.cs View File

@@ -138,7 +138,7 @@ namespace HBLConsole.ViewModel
public void MqttReceive()
{
Test();
ActionOperate.GetInstance.Register(new Action<object>((o) =>
ActionManage.GetInstance.Register(new Action<object>((o) =>
{
if (o is MorkOrderPush morkOrderpush)
{
@@ -161,7 +161,7 @@ namespace HBLConsole.ViewModel
}
}), "AddOrder");

ActionOperate.GetInstance.Register(new Action<object>((o) =>
ActionManage.GetInstance.Register(new Action<object>((o) =>
{
if (o is OrderStatusChange orderStatusChange)
{


+ 4
- 4
HBLDevice.Coffee/CoffeeMachine.cs View File

@@ -14,7 +14,7 @@ namespace HBLDevice.Coffee
/// <summary>
/// 咖啡机
/// </summary>
public class CoffeeMachine
public class CoffeeMachine
{
//通讯代理
SerialPortClient commProxy = null;
@@ -123,7 +123,7 @@ namespace HBLDevice.Coffee
/// </summary>
private void MainLoop()
{
ThreadOperate.GetInstance.StartLong(new Action(() =>
ThreadManage.GetInstance.StartLong(new Action(() =>
{
if (free)
{
@@ -146,7 +146,7 @@ namespace HBLDevice.Coffee
//}, "咖啡机询问线程");


ThreadOperate.GetInstance.StartLong(new Action(() =>
ThreadManage.GetInstance.StartLong(new Action(() =>
{
List<byte> temp = new List<byte>();
//一系列解包
@@ -224,6 +224,6 @@ namespace HBLDevice.Coffee
//}, "咖啡机解析线程");
}

}
}

+ 1
- 1
HBLDevice.ICChip/HBLDevice.ICChip.csproj View File

@@ -10,7 +10,7 @@

<ItemGroup>
<Reference Include="BPA.Utility">
<HintPath>..\..\..\..\BPACommon_output\net5.0\BPA.Utility.dll</HintPath>
<HintPath>D:\BPACommon_output\net5.0\BPA.Utility.dll</HintPath>
</Reference>
</ItemGroup>



+ 1
- 1
HBLDevice.ICChip/ICChipMachine.cs View File

@@ -44,7 +44,7 @@ namespace HBLDevice.ICChip

private void MainLoop()
{
ThreadOperate.GetInstance.StartLong(new Action(() =>
ThreadManage.GetInstance.StartLong(new Action(() =>
{
ResolveMsg();
//Thread.Sleep(2000);


+ 2
- 2
HBLDevice.IceCream/IceCreamMachine.cs View File

@@ -51,7 +51,7 @@ namespace HBLDevice.IceCream
private MSG_RESOLVE_STEP currentStep;
private void MainLoop()
{
ThreadOperate.GetInstance.StartLong(new Action(() =>
ThreadManage.GetInstance.StartLong(new Action(() =>
{
if (free)
{
@@ -61,7 +61,7 @@ namespace HBLDevice.IceCream
Thread.Sleep(500);
}), "冰淇淋询问线程");

ThreadOperate.GetInstance.StartLong(new Action(() =>
ThreadManage.GetInstance.StartLong(new Action(() =>
{
ResolveMsg();
//Thread.Sleep(2000);


Loading…
Cancel
Save