@@ -9,6 +9,7 @@ | |||
</ItemGroup> | |||
<ItemGroup> | |||
<ProjectReference Include="..\BPASmartClient.Helper\BPASmartClient.Helper.csproj" /> | |||
<ProjectReference Include="..\BPASmartClient.Peripheral\BPASmartClient.Peripheral.csproj" /> | |||
</ItemGroup> | |||
@@ -1,10 +1,13 @@ | |||
using BPA.Message.Enum; | |||
using BPASmartClient.Helper; | |||
using BPASmartClient.Peripheral; | |||
using System; | |||
using System.Collections.Concurrent; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Reflection; | |||
using System.Text; | |||
using System.Threading; | |||
using System.Threading.Tasks; | |||
namespace BPASmartClient.Device | |||
@@ -43,6 +46,10 @@ namespace BPASmartClient.Device | |||
/// </summary> | |||
public bool IsHealth { get; protected set; } | |||
//外设状态 | |||
protected ConcurrentDictionary<string, object> peripheralStatus = new ConcurrentDictionary<string, object>(); | |||
private List<IPeripheral> peripherals; | |||
public void Initliaze() | |||
{ | |||
} | |||
@@ -54,10 +61,26 @@ namespace BPASmartClient.Device | |||
p.DeviceId = this.DeviceId; | |||
p.Init(); | |||
}); | |||
this.peripherals = peripherals; | |||
} | |||
public abstract void StartMain(); | |||
public virtual void StartMain() | |||
{ | |||
ThreadManage.GetInstance().StartLong(new Action(() => | |||
{ | |||
foreach (var peripheral in peripherals) | |||
{ | |||
foreach (var key in peripheral.GetAllStatus().Keys) | |||
{ | |||
peripheralStatus[key] = peripheral.GetAllStatus()[key]; | |||
} | |||
} | |||
Thread.Sleep(100); | |||
}), "ResetProgram"); | |||
DoMain(); | |||
} | |||
public abstract void DoMain(); | |||
public abstract void Stop(); | |||
} | |||
} |
@@ -32,7 +32,7 @@ namespace BPASmartClient.MorkS | |||
int OrderCount; | |||
bool Initing; | |||
public override void StartMain() | |||
public override void DoMain() | |||
{ | |||
ServerInit(); | |||
DataParse(); | |||
@@ -105,7 +105,62 @@ namespace BPASmartClient.MorkS | |||
private void ReadPLCData() | |||
{ | |||
/*替换为内部主动读取 | |||
ThreadManage.GetInstance().StartLong(new Action(() => | |||
{ | |||
var bools = (bool[])peripheralStatus["M0.3"]; | |||
mORKS.RobotTakeNoodle = bools[0]; | |||
mORKS.RobotTakeNoodle = bools[0]; | |||
mORKS.RobotOutMeal = bools[1]; | |||
mORKS.MoveTurntable = bools[2]; | |||
bools = (bool[])peripheralStatus["M100.0"]; | |||
mORKS.InitComplete = bools[0]; | |||
mORKS.TakeBowlIdle = bools[1]; | |||
mORKS.TemperatureReached = bools[2]; | |||
mORKS.AllowFallNoodle = bools[3]; | |||
mORKS.RbTakeNoodleComplete = bools[4]; | |||
mORKS.RbFallNoodleComplete = bools[5]; | |||
mORKS.RbOutMealComplete = bools[6]; | |||
mORKS.RobotIdle = bools[7]; | |||
mORKS.TakeMealDetect = bools[8]; | |||
mORKS.MissingBowl = bools[9]; | |||
Initing = bools[10]; | |||
mORKS.TurntableLowerLimit = bools[11]; | |||
mORKS.MissingBowlSignal2 = bools[12]; | |||
mORKS.TurntableUpLimit = bools[13]; | |||
mORKS.FeedComplete = bools[14]; | |||
mORKS.TurntableMoveInPlace = bools[15]; | |||
bools = (bool[])peripheralStatus["M235.0"]; | |||
mORKS.Error = bools[0]; | |||
bools = (bool[])peripheralStatus["M102.0"]; | |||
for (int i = 0; i < 6; i++) | |||
{ | |||
mORKS.NoodleCookerStatus[i] = bools[i]; | |||
} | |||
mORKS.Feeding = bools[6]; | |||
bools = (bool[])peripheralStatus["M103.0"]; | |||
for (int i = 0; i < 6; i++) | |||
{ | |||
mORKS.CookNoodlesComplete[i] = bools[i]; | |||
} | |||
EventBus.EventBus.GetInstance().Publish(new ReadModel() { Id = DeviceId, Address = "VW372", Length = 1 }, (o) => | |||
{ | |||
if (o != null && o.Length > 0 && o[0] is ushort value) | |||
{ | |||
mORKS.TurntableFeedbackloc = value; | |||
} | |||
}); | |||
Thread.Sleep(500); | |||
}), "ReadPLCData", true); | |||
#region 替换为内部主动读取 | |||
/* | |||
ThreadManage.GetInstance().StartLong(new Action(() => | |||
{ | |||
@@ -186,6 +241,7 @@ namespace BPASmartClient.MorkS | |||
Thread.Sleep(500); | |||
}), "ReadPLCData", true); | |||
*/ | |||
#endregion | |||
} | |||
/// <summary> | |||
@@ -12,7 +12,7 @@ namespace BPASmartClient.MorkT | |||
{ | |||
public override global::BPA.Message.Enum.DeviceClientType DeviceType { get { return BPA.Message.Enum.DeviceClientType.MORKIC; } } | |||
public override void StartMain() | |||
public override void DoMain() | |||
{ | |||
} | |||
@@ -1,4 +1,5 @@ | |||
using System; | |||
using System.Collections.Concurrent; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
@@ -27,7 +28,7 @@ namespace BPASmartClient.Peripheral | |||
/// <summary> | |||
/// 外设状态集合 | |||
/// </summary> | |||
protected Dictionary<string, object> status = new Dictionary<string, object>(); | |||
protected ConcurrentDictionary<string, object> status = new ConcurrentDictionary<string, object>(); | |||
/// <summary> | |||
/// 初始化外设状态 | |||
@@ -47,5 +48,10 @@ namespace BPASmartClient.Peripheral | |||
public abstract void Stop(); | |||
public abstract void Init(); | |||
public ConcurrentDictionary<string, object> GetAllStatus() | |||
{ | |||
return status; | |||
} | |||
} | |||
} |
@@ -1,4 +1,5 @@ | |||
using System; | |||
using System.Collections.Concurrent; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
@@ -22,6 +23,11 @@ namespace BPASmartClient.Peripheral | |||
/// <returns>状态值</returns> | |||
object? GetStatus(string statusName); | |||
/// <summary> | |||
/// 获取所有状态 | |||
/// </summary> | |||
/// <returns>状态值</returns> | |||
ConcurrentDictionary<string, object> GetAllStatus(); | |||
/// <summary> | |||
/// 初始化 | |||
/// </summary> | |||
void Init(); | |||