|
|
@@ -19,7 +19,8 @@ namespace HBLDevice.IceCream |
|
|
|
private DataStorage<byte> dataStorage = new DataStorage<byte>(); |
|
|
|
//主线程运行标识 |
|
|
|
private bool running = false; |
|
|
|
|
|
|
|
//是否下发指令,主线程等待 |
|
|
|
private bool free = true; |
|
|
|
public Action<string> SendCallback; |
|
|
|
public Action<string> ReciveCallback; |
|
|
|
|
|
|
@@ -30,7 +31,10 @@ namespace HBLDevice.IceCream |
|
|
|
commProxy = new SerialPortClient(portName, baud); |
|
|
|
commProxy.SetDataStorage(dataStorage); |
|
|
|
commandHandler.Init(commProxy); |
|
|
|
|
|
|
|
commandHandler.PauseAsk = delegate (bool pause) |
|
|
|
{ |
|
|
|
free = !pause; |
|
|
|
}; |
|
|
|
} |
|
|
|
|
|
|
|
public void Start() |
|
|
@@ -49,8 +53,11 @@ namespace HBLDevice.IceCream |
|
|
|
{ |
|
|
|
ThreadOperate.GetInstance.StartLong(new Action(() => |
|
|
|
{ |
|
|
|
commProxy.SendData(commandHandler.GetHeartDW()); |
|
|
|
SendCallback?.Invoke(BitConverter.ToString(commandHandler.GetHeartDW())); |
|
|
|
if (free) |
|
|
|
{ |
|
|
|
commProxy.SendData(commandHandler.GetHeartDW()); |
|
|
|
SendCallback?.Invoke(BitConverter.ToString(commandHandler.GetHeartDW())); |
|
|
|
} |
|
|
|
Thread.Sleep(500); |
|
|
|
}), "冰淇淋询问线程"); |
|
|
|
|
|
|
|