@@ -7,6 +7,13 @@ | |||
<UseWindowsForms>true</UseWindowsForms> | |||
</PropertyGroup> | |||
<ItemGroup> | |||
<Compile Remove="Fonts\Debug\**" /> | |||
<EmbeddedResource Remove="Fonts\Debug\**" /> | |||
<None Remove="Fonts\Debug\**" /> | |||
<Page Remove="Fonts\Debug\**" /> | |||
</ItemGroup> | |||
<ItemGroup> | |||
<Compile Remove="Properties\App.xaml.cs" /> | |||
</ItemGroup> | |||
@@ -16,7 +16,7 @@ namespace BPASmartClient.DRCoffee | |||
/// <summary> | |||
/// 咖啡机 | |||
/// </summary> | |||
public class CoffeeMachine :BasePeripheral | |||
public class CoffeeMachine : BasePeripheral | |||
{ | |||
//通讯代理 | |||
SerialPortClient commProxy = null; | |||
@@ -95,7 +95,7 @@ namespace BPASmartClient.DRCoffee | |||
commProxy.SendData(cmdAsk); | |||
} | |||
Thread.Sleep(200); | |||
}),"咖啡机询问线程"); | |||
}), "咖啡机询问线程"); | |||
ThreadManage.GetInstance().StartLong(new Action(() => | |||
{ | |||
@@ -132,7 +132,7 @@ namespace BPASmartClient.DRCoffee | |||
} | |||
} | |||
Thread.Sleep(5); | |||
}),"咖啡机解析线程"); | |||
}), "咖啡机解析线程"); | |||
} | |||
/// <summary> | |||
@@ -141,30 +141,29 @@ namespace BPASmartClient.DRCoffee | |||
/// <param name="package"></param> | |||
public void ProcessPackage(DrCoffeePackage package) | |||
{ | |||
lastRefreshTime = DateTime.Now; | |||
IsConnected = OnLine; | |||
status["CoffeeIsConnected"] = OnLine; | |||
if (((DrCoffeeStatus)status["CoffeeStatus"]) == DrCoffeeStatus.Running && package.Status != DrCoffeeStatus.Running) | |||
{ | |||
status["CoffeeStatus"] = package.Status; | |||
lastRefreshTime = DateTime.Now; | |||
IsConnected = OnLine; | |||
status["CoffeConnected"] = OnLine; | |||
new DRCoffee_CoffeEndCookEvent() { DeviceId = DeviceId }.Publish(); | |||
EventBus.EventBus.GetInstance().Publish(new DRCoffee_CoffeEndCookEvent() { DeviceId = DeviceId }); | |||
} | |||
else status["CoffeeStatus"] = package.Status; | |||
status["CoffeeAppStatus"] = package.ApplicationStatus; | |||
status["CoffeeWarning"] = package.Warning; | |||
status["CoffeeFault"] = package.Fault; | |||
if ((DrCoffeeStatus)status["CoffeeStatus"] == DrCoffeeStatus.Warning | |||
|| (DrCoffeeStatus)status["CoffeeStatus"] == DrCoffeeStatus.Fault | |||
|| (DrCoffeeWarning)status["CoffeeWarning"] != DrCoffeeWarning.无警告 | |||
|| (DrCoffeeFault)status["CoffeeFault"] != DrCoffeeFault.无故障 | |||
) | |||
{ | |||
IsWork = false; | |||
IsWork = false; | |||
} | |||
else | |||
IsWork = true; | |||
IsWork = true; | |||
} | |||
protected override void InitStatus() | |||
@@ -177,68 +176,75 @@ namespace BPASmartClient.DRCoffee | |||
public override void Init() | |||
{ | |||
commProxy = new SerialPortClient(communicationPar.SerialPort,(BaudRates)communicationPar.BaudRate); | |||
commProxy = new SerialPortClient(communicationPar.SerialPort, (BaudRates)communicationPar.BaudRate); | |||
commProxy.SetDataStorage(dataStorage); | |||
//咖博士咖啡机制作 | |||
EventBus.EventBus.GetInstance().Subscribe<DRCoffee_MakeCoffeeEvent>(DeviceId,delegate (IEvent @event,EventCallBackHandle callBack) | |||
{ | |||
try | |||
{ | |||
free = true; | |||
Thread.Sleep(200); | |||
drinksOrder.CommCmd = DrCoffeeCommCmd.饮品制作指令; | |||
drinksOrder.DrinksCode = ((DRCoffee_MakeCoffeeEvent)@event).DrinkCode; | |||
commProxy.SendData(DrCoffee.Packe(drinksOrder)); | |||
Thread.Sleep(200); | |||
free = false; | |||
} | |||
catch (Exception ex) | |||
{ | |||
MessageLog.GetInstance.ShowEx($"BPASmartClient.DRCoffee 中引发错误,CoffeeMachine 类,描述:[{ex.Message}]"); | |||
} | |||
}); | |||
EventBus.EventBus.GetInstance().Subscribe<DRCoffee_MakeCoffeeEvent>(DeviceId, delegate (IEvent @event, EventCallBackHandle callBack) | |||
{ | |||
try | |||
{ | |||
free = true; | |||
Thread.Sleep(200); | |||
drinksOrder.CommCmd = DrCoffeeCommCmd.饮品制作指令; | |||
drinksOrder.DrinksCode = ((DRCoffee_MakeCoffeeEvent)@event).DrinkCode; | |||
commProxy.SendData(DrCoffee.Packe(drinksOrder)); | |||
Thread.Sleep(200); | |||
free = false; | |||
} | |||
catch (Exception ex) | |||
{ | |||
MessageLog.GetInstance.ShowEx($"BPASmartClient.DRCoffee 中引发错误,CoffeeMachine 类,描述:[{ex.Message}]"); | |||
} | |||
}); | |||
//咖博士咖啡机取消制作咖啡 | |||
EventBus.EventBus.GetInstance().Subscribe<DRCoffee_CancelMakeCoffeeEvent>(DeviceId,delegate (IEvent @event,EventCallBackHandle callBack) | |||
{ | |||
try | |||
{ | |||
free = true; | |||
Thread.Sleep(200); | |||
drinksOrder.CommCmd = DrCoffeeCommCmd.取消应用指令; | |||
drinksOrder.DrinksCode = 0; | |||
commProxy.SendData(DrCoffee.Packe(drinksOrder)); | |||
Thread.Sleep(200); | |||
free = false; | |||
} | |||
catch (Exception ex) | |||
{ | |||
MessageLog.GetInstance.ShowEx($"BPASmartClient.DRCoffee 中引发错误,CoffeeMachine 类,描述:[{ex.Message}]"); | |||
} | |||
}); | |||
EventBus.EventBus.GetInstance().Subscribe<DRCoffee_CancelMakeCoffeeEvent>(DeviceId, delegate (IEvent @event, EventCallBackHandle callBack) | |||
{ | |||
try | |||
{ | |||
free = true; | |||
Thread.Sleep(200); | |||
drinksOrder.CommCmd = DrCoffeeCommCmd.取消应用指令; | |||
drinksOrder.DrinksCode = 0; | |||
commProxy.SendData(DrCoffee.Packe(drinksOrder)); | |||
Thread.Sleep(200); | |||
free = false; | |||
} | |||
catch (Exception ex) | |||
{ | |||
MessageLog.GetInstance.ShowEx($"BPASmartClient.DRCoffee 中引发错误,CoffeeMachine 类,描述:[{ex.Message}]"); | |||
} | |||
}); | |||
//咖博士咖啡机模式设置 | |||
EventBus.EventBus.GetInstance().Subscribe<DRCoffee_CoffeeCommCmdEvent>(DeviceId,delegate (IEvent @event,EventCallBackHandle callBack) | |||
{ | |||
try | |||
{ | |||
free = true; | |||
Thread.Sleep(200); | |||
drinksOrder.CommCmd = ((DRCoffee_CoffeeCommCmdEvent)@event).CommCmd; | |||
commProxy.SendData(DrCoffee.Packe(drinksOrder)); | |||
Thread.Sleep(200); | |||
free = false; | |||
} | |||
catch (Exception ex) | |||
{ | |||
MessageLog.GetInstance.ShowEx($"BPASmartClient.DRCoffee 中引发错误,CoffeeMachine 类,描述:[{ex.Message}]"); | |||
} | |||
}); | |||
EventBus.EventBus.GetInstance().Subscribe<DRCoffee_CoffeeCommCmdEvent>(DeviceId, delegate (IEvent @event, EventCallBackHandle callBack) | |||
{ | |||
try | |||
{ | |||
free = true; | |||
Thread.Sleep(200); | |||
drinksOrder.CommCmd = ((DRCoffee_CoffeeCommCmdEvent)@event).CommCmd; | |||
commProxy.SendData(DrCoffee.Packe(drinksOrder)); | |||
Thread.Sleep(200); | |||
free = false; | |||
} | |||
catch (Exception ex) | |||
{ | |||
MessageLog.GetInstance.ShowEx($"BPASmartClient.DRCoffee 中引发错误,CoffeeMachine 类,描述:[{ex.Message}]"); | |||
} | |||
}); | |||
InitStatus(); | |||
//测试 | |||
Start(); | |||
} | |||
public override void WriteData(string address, object value) | |||
{ | |||
} | |||
//public override void ReadData(string address) | |||
//{ | |||
//} | |||
} | |||
} |
@@ -13,6 +13,8 @@ using System.Text; | |||
using System.Threading; | |||
using System.Threading.Tasks; | |||
using System.Collections.ObjectModel; | |||
using BPASmartClient.Model.单片机; | |||
using BPASmartClient.EventBus; | |||
namespace BPASmartClient.Device | |||
{ | |||
@@ -110,6 +112,22 @@ namespace BPASmartClient.Device | |||
#endregion | |||
/// <summary> | |||
/// 写控制 | |||
/// </summary> | |||
/// <param name="address"></param> | |||
/// <param name="value"></param> | |||
public void WriteControl(string address, object value) | |||
{ | |||
if (peripherals != null) | |||
{ | |||
for (int i = 0; i < peripherals.Count; i++) | |||
{ | |||
peripherals.ElementAt(i).WriteData(address, value); | |||
} | |||
} | |||
} | |||
/// <summary> | |||
/// 设备过程日志显示 | |||
/// </summary> | |||
@@ -325,7 +343,7 @@ namespace BPASmartClient.Device | |||
{ | |||
MainTask(); | |||
Thread.Sleep(10); | |||
}), $"MainTask:{DeviceId}"); | |||
}) ,$"MainTask:{DeviceId}",true); | |||
#endregion | |||
#region 设备状态监控 | |||
@@ -525,5 +543,6 @@ namespace BPASmartClient.Device | |||
IEnumerable<System.Reflection.PropertyInfo> property = from pi in t.GetProperties() where pi.Name.ToLower() == field.ToLower() select pi; | |||
return property.First().GetValue(info, null); | |||
} | |||
} | |||
} |
@@ -14,8 +14,8 @@ using static BPASmartClient.GSIceCream.MessageDefine; | |||
namespace BPASmartClient.GSIceCream | |||
{ | |||
public class IceCreamMachine :BasePeripheral | |||
{ | |||
public class IceCreamMachine : BasePeripheral | |||
{ | |||
//通讯代理 | |||
SerialPortClient commProxy = null; | |||
//是否下发指令,主线程等待 | |||
@@ -179,13 +179,13 @@ namespace BPASmartClient.GSIceCream | |||
IsConnected = OnLine; | |||
status["IceCreamIsConnected"] = OnLine; | |||
status["IceCreamCurrentMode"] = heartUpMsg.MS; | |||
status["IceCreamYLWD"] = BitConverter.ToInt16(new byte[] { heartUpMsg.YLWD_L,heartUpMsg.YLWD_H },0); | |||
status["IceCreamHQWD"] = BitConverter.ToInt16(new byte[] { heartUpMsg.HQWD_L,heartUpMsg.HQWD_H },0); | |||
status["IceCreamHJWD"] = BitConverter.ToInt16(new byte[] { heartUpMsg.HJWD_L,heartUpMsg.HJWD_H },0); | |||
status["IceCreamYLWD"] = BitConverter.ToInt16(new byte[] { heartUpMsg.YLWD_L, heartUpMsg.YLWD_H }, 0); | |||
status["IceCreamHQWD"] = BitConverter.ToInt16(new byte[] { heartUpMsg.HQWD_L, heartUpMsg.HQWD_H }, 0); | |||
status["IceCreamHJWD"] = BitConverter.ToInt16(new byte[] { heartUpMsg.HJWD_L, heartUpMsg.HJWD_H }, 0); | |||
status["IceCreamDL"] = BitConverter.ToInt16(new byte[] { heartUpMsg.DL_L, heartUpMsg.DL_H }, 0); | |||
status["IceCreamFault"] = (MORKI_FAULT)BitConverter.ToInt16(new byte[] { heartUpMsg.GZ_L,heartUpMsg.GZ_H },0); | |||
status["IceCreamFault"] = (MORKI_FAULT)BitConverter.ToInt16(new byte[] { heartUpMsg.GZ_L, heartUpMsg.GZ_H }, 0); | |||
status["IceCreamCXB"] = heartUpMsg.CXB; | |||
status["IceCreamDLCompleted"] = (heartUpMsg.DLTJ >> 4 & 1) == 1; | |||
status["IceCreamDLCompleted"] = (heartUpMsg.DLTJ >> 4 & 1) == 1; | |||
if (RTrig.GetInstance("打料完成检测").Start((bool)status["IceCreamDLCompleted"])) | |||
{ | |||
@@ -201,7 +201,7 @@ namespace BPASmartClient.GSIceCream | |||
private void ProcessModeUp(ICMSG_MODE_UP modeUpMsg) | |||
{ | |||
MessageLog.GetInstance.Show(string.Format("模式返回为:{0}",modeUpMsg.Mode)); | |||
MessageLog.GetInstance.Show(string.Format("模式返回为:{0}", modeUpMsg.Mode)); | |||
} | |||
public void ProcessMsg(byte[] data) | |||
@@ -269,79 +269,83 @@ namespace BPASmartClient.GSIceCream | |||
}); | |||
//广深冰淇淋机打料 | |||
EventBus.EventBus.GetInstance().Subscribe<GSIceCream_DischargeEvent>(DeviceId,delegate (IEvent @event,EventCallBackHandle callBack) | |||
{ | |||
try | |||
{ | |||
if ((MORKI_FAULT)status["IceCreamFault"] != MORKI_FAULT.未发生故障) | |||
{ | |||
MessageLog.GetInstance.Show(string.Format("当前存在故障[{0}%],不允许制作",(MORKI_FAULT)status["IceCreamFault"])); | |||
new GSIceCream_EndCookEvent() { DeviceId = DeviceId,Status = false }.Publish(); | |||
callBack?.Invoke(false); | |||
return; | |||
} | |||
if ((byte)status["IceCreamCXB"] <= 86) | |||
{ | |||
MessageLog.GetInstance.Show(string.Format("当前成型比[{0}%],低于86%,不允许制作",(byte)status["IceCreamCXB"])); | |||
new GSIceCream_EndCookEvent() { DeviceId = DeviceId,Status = false }.Publish(); | |||
callBack?.Invoke(false ); | |||
return; | |||
} | |||
EventBus.EventBus.GetInstance().Subscribe<GSIceCream_DischargeEvent>(DeviceId, delegate (IEvent @event, EventCallBackHandle callBack) | |||
{ | |||
try | |||
{ | |||
if ((MORKI_FAULT)status["IceCreamFault"] != MORKI_FAULT.未发生故障) | |||
{ | |||
MessageLog.GetInstance.Show(string.Format("当前存在故障[{0}%],不允许制作", (MORKI_FAULT)status["IceCreamFault"])); | |||
new GSIceCream_EndCookEvent() { DeviceId = DeviceId, Status = false }.Publish(); | |||
callBack?.Invoke(false); | |||
return; | |||
} | |||
if ((byte)status["IceCreamCXB"] <= 86) | |||
{ | |||
MessageLog.GetInstance.Show(string.Format("当前成型比[{0}%],低于86%,不允许制作", (byte)status["IceCreamCXB"])); | |||
new GSIceCream_EndCookEvent() { DeviceId = DeviceId, Status = false }.Publish(); | |||
callBack?.Invoke(false); | |||
return; | |||
} | |||
bool modeRight = (MORKI_MODE)status["IceCreamCurrentMode"] == MORKI_MODE.制冷模式; | |||
bool modeRight = (MORKI_MODE)status["IceCreamCurrentMode"] == MORKI_MODE.制冷模式; | |||
if (!modeRight) | |||
{ | |||
free = true; | |||
Thread.Sleep(200); | |||
if (!modeRight) | |||
{ | |||
free = true; | |||
Thread.Sleep(200); | |||
var temp = IcPack.StructureToByte(ICMSG_MODE_DW.Build(MORKI_MODE.制冷模式)); | |||
commProxy.SendData(temp); | |||
var temp = IcPack.StructureToByte(ICMSG_MODE_DW.Build(MORKI_MODE.制冷模式)); | |||
commProxy.SendData(temp); | |||
Thread.Sleep(200); | |||
free = false; | |||
MessageLog.GetInstance.Show(string.Format("出料操作->设置模式[{0}]",MORKI_MODE.制冷模式)); | |||
Thread.Sleep(200); | |||
free = false; | |||
MessageLog.GetInstance.Show(string.Format("出料操作->设置模式[{0}]", MORKI_MODE.制冷模式)); | |||
DateTime freeTime = DateTime.Now.AddSeconds(5); | |||
while (DateTime.Now < freeTime) | |||
{ | |||
Thread.Sleep(10); | |||
modeRight = (MORKI_MODE)status["IceCreamCurrentMode"] == MORKI_MODE.制冷模式; | |||
if (modeRight) | |||
break; | |||
} | |||
} | |||
DateTime freeTime = DateTime.Now.AddSeconds(5); | |||
while (DateTime.Now < freeTime) | |||
{ | |||
Thread.Sleep(10); | |||
modeRight = (MORKI_MODE)status["IceCreamCurrentMode"] == MORKI_MODE.制冷模式; | |||
if (modeRight) | |||
break; | |||
} | |||
} | |||
if (modeRight) | |||
{ | |||
free = true; | |||
Thread.Sleep(200); | |||
var data = IcPack.StructureToByte(ICMSG_MODE_DW.Build(MORKI_MODE.打料)); | |||
commProxy.SendData(data); | |||
Thread.Sleep(200); | |||
free = false; | |||
new GSIceCream_EndCookEvent() { DeviceId = DeviceId,Status =true}.Publish(); | |||
MessageLog.GetInstance.Show(string.Format("出料操作->设置模式[{0}]",MORKI_MODE.打料)); | |||
callBack?.Invoke(true); | |||
} | |||
else | |||
{ | |||
MessageLog.GetInstance.Show(string.Format("出料操作->模式切换失败,当前模式[{0}],不允许出料",(MORKI_MODE)status["IceCreamCurrentMode"])); | |||
new GSIceCream_EndCookEvent() { DeviceId = DeviceId,Status = false }.Publish(); | |||
callBack?.Invoke(false); | |||
} | |||
} | |||
catch (Exception ex) | |||
{ | |||
MessageLog.GetInstance.ShowEx($"BPASmartClient.GSIceCream 中引发错误,IceCreamMachine 类,描述:[{ex.Message}]"); | |||
callBack?.Invoke(false); | |||
} | |||
}); | |||
if (modeRight) | |||
{ | |||
free = true; | |||
Thread.Sleep(200); | |||
var data = IcPack.StructureToByte(ICMSG_MODE_DW.Build(MORKI_MODE.打料)); | |||
commProxy.SendData(data); | |||
Thread.Sleep(200); | |||
free = false; | |||
new GSIceCream_EndCookEvent() { DeviceId = DeviceId, Status = true }.Publish(); | |||
MessageLog.GetInstance.Show(string.Format("出料操作->设置模式[{0}]", MORKI_MODE.打料)); | |||
callBack?.Invoke(true); | |||
} | |||
else | |||
{ | |||
MessageLog.GetInstance.Show(string.Format("出料操作->模式切换失败,当前模式[{0}],不允许出料", (MORKI_MODE)status["IceCreamCurrentMode"])); | |||
new GSIceCream_EndCookEvent() { DeviceId = DeviceId, Status = false }.Publish(); | |||
callBack?.Invoke(false); | |||
} | |||
} | |||
catch (Exception ex) | |||
{ | |||
MessageLog.GetInstance.ShowEx($"BPASmartClient.GSIceCream 中引发错误,IceCreamMachine 类,描述:[{ex.Message}]"); | |||
callBack?.Invoke(false); | |||
} | |||
}); | |||
InitStatus(); | |||
//测试用 | |||
Start(); | |||
MessageLog.GetInstance.Show("冰淇淋机器初始化完成"); | |||
} | |||
public override void WriteData(string address, object value) | |||
{ | |||
} | |||
} | |||
} |
@@ -43,11 +43,6 @@ namespace BPASmartClient.Helper | |||
{ | |||
action?.Invoke(); | |||
callback?.Invoke(); | |||
//if (action != null) | |||
//{ | |||
// action(); | |||
// if (callback != null) callback(); | |||
//} | |||
} | |||
/// <summary> | |||
@@ -60,56 +55,105 @@ namespace BPASmartClient.Helper | |||
{ | |||
action?.Invoke(par); | |||
callback?.Invoke(); | |||
//if (action != null) | |||
//{ | |||
// action(par); | |||
// if (callback != null) callback(); | |||
//} | |||
} | |||
public static void Invokes(this Action<object[]> action, object[] par, Action callback) | |||
{ | |||
action?.Invoke(par); | |||
callback?.Invoke(); | |||
//if (action != null) | |||
//{ | |||
// action(par); | |||
// if (callback != null) callback(); | |||
//} | |||
} | |||
/// <summary> | |||
/// 字节数组转换成32位整数 | |||
/// </summary> | |||
/// <param name="bytes"></param> | |||
/// <returns></returns> | |||
public static int BytesToInt(this byte[] bytes) | |||
{ | |||
if (bytes.Length > 4) return -1; | |||
int ReturnVlaue = 0; | |||
for (int i = 0; i < bytes.Length; i++) | |||
{ | |||
ReturnVlaue += (int)(bytes[i] << (i * 8)); | |||
} | |||
return ReturnVlaue; | |||
} | |||
/// <summary> | |||
/// 字节数组转换成 ushort 数组 | |||
/// </summary> | |||
/// <param name="bytes">要转换的字节数组</param> | |||
/// <param name="reverse">字节高度顺序控制</param> | |||
/// <returns></returns> | |||
public static ushort[] BytesToUshorts(this byte[] bytes, bool reverse = false) | |||
{ | |||
int len = bytes.Length; | |||
byte[] srcPlus = new byte[len + 1]; | |||
bytes.CopyTo(srcPlus, 0); | |||
int count = len >> 1; | |||
if (len % 2 != 0) | |||
{ | |||
count += 1; | |||
} | |||
ushort[] dest = new ushort[count]; | |||
if (reverse) | |||
{ | |||
for (int i = 0; i < count; i++) | |||
{ | |||
dest[i] = (ushort)(srcPlus[i * 2] << 8 | srcPlus[2 * i + 1] & 0xff); | |||
} | |||
} | |||
else | |||
{ | |||
for (int i = 0; i < count; i++) | |||
{ | |||
dest[i] = (ushort)(srcPlus[i * 2] & 0xff | srcPlus[2 * i + 1] << 8); | |||
} | |||
} | |||
return dest; | |||
} | |||
/// <summary> | |||
/// ushort 数组转换成字节数组 | |||
/// </summary> | |||
/// <param name="src">需要转换的 ushort数组</param> | |||
/// <param name="reverse">高低字节的设置</param> | |||
/// <returns></returns> | |||
public static byte[] UshortsToBytes(this ushort[] src, bool reverse = false) | |||
{ | |||
int count = src.Length; | |||
byte[] dest = new byte[count << 1]; | |||
if (reverse) | |||
{ | |||
for (int i = 0; i < count; i++) | |||
{ | |||
dest[i * 2] = (byte)(src[i] >> 8); | |||
dest[i * 2 + 1] = (byte)(src[i] >> 0); | |||
} | |||
} | |||
else | |||
{ | |||
for (int i = 0; i < count; i++) | |||
{ | |||
dest[i * 2] = (byte)(src[i] >> 0); | |||
dest[i * 2 + 1] = (byte)(src[i] >> 8); | |||
} | |||
} | |||
return dest; | |||
} | |||
///// <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; } | |||
// } | |||
// } | |||
//} | |||
} | |||
} |
@@ -35,7 +35,6 @@ namespace BPASmartClient.IoT | |||
public DataVClient() | |||
{ | |||
DataVApiAddress = InternetInfo.DataVApiAddress; | |||
//ClientId = System.Configuration.ConfigurationManager.AppSettings["ClientId"].ToString(); | |||
ClientId = Plugin.GetInstance().GetPlugin<ConfigMgr>().ClientId.ToString(); | |||
DeviceName = System.Configuration.ConfigurationManager.AppSettings["DeviceName"].ToString(); | |||
ProductKey = System.Configuration.ConfigurationManager.AppSettings["ProductKey"].ToString(); | |||
@@ -71,6 +70,7 @@ namespace BPASmartClient.IoT | |||
/// 客户端ID | |||
/// </summary> | |||
public string ClientId { set; get; } | |||
public List<int> ListDeviceId { set; get; } = new List<int>(); | |||
/// <summary> | |||
/// MQTT上报集合 | |||
/// </summary> | |||
@@ -99,7 +99,9 @@ namespace BPASmartClient.IoT | |||
{ | |||
if (DeviceDataV != null && DeviceDataV.GetIsConnected() && DeviceDataV.deviceTable != null) | |||
{ | |||
DeviceDataV.IOT_Publish(BroadcastPubTopic, Tools.JsonConvertTools("刷新店铺列表")); | |||
string api = DataVApiAddress + "/api/Device/FlushedDevice"; | |||
HttpRequestHelper.HttpGetRequest(api, 1000); | |||
//DeviceDataV.IOT_Publish(BroadcastPubTopic, Tools.JsonConvertTools("刷新店铺列表")); | |||
} | |||
} | |||
catch (Exception ex) | |||
@@ -200,7 +202,17 @@ namespace BPASmartClient.IoT | |||
string message = string.Empty; | |||
if (StartupMode == "API") | |||
{ | |||
if (DeviceDataV.Initialize(DataVApiAddress, ClientId, "", ref message)) | |||
while (ListDeviceId.Count == 0) | |||
{ | |||
Plugin.GetInstance()?.GetPlugin<DeviceMgr>()?.GetDevices()?.ForEach(device => | |||
{ | |||
if (device != null) | |||
{ | |||
ListDeviceId.Add(device.DeviceId); | |||
} | |||
}); | |||
} | |||
if (DeviceDataV.Initialize(DataVApiAddress, ClientId, ListDeviceId.Count==0?"": ListDeviceId?.First().ToString(), ref message)) | |||
{ | |||
ProductKey = DeviceDataV.deviceTable.productkey; | |||
DeviceName = DeviceDataV.deviceTable.devicename; | |||
@@ -0,0 +1,14 @@ | |||
<Project Sdk="Microsoft.NET.Sdk"> | |||
<PropertyGroup> | |||
<TargetFramework>net6.0</TargetFramework> | |||
<ImplicitUsings>enable</ImplicitUsings> | |||
<Nullable>enable</Nullable> | |||
</PropertyGroup> | |||
<ItemGroup> | |||
<ProjectReference Include="..\BPASmartClient.JakaRobot\BPASmartClient.JakaRobot.csproj" /> | |||
<ProjectReference Include="..\BPASmartClient.Peripheral\BPASmartClient.Peripheral.csproj" /> | |||
</ItemGroup> | |||
</Project> |
@@ -0,0 +1,83 @@ | |||
using BPASmartClient.EventBus; | |||
using BPASmartClient.Helper; | |||
using BPASmartClient.JakaRobot; | |||
using BPASmartClient.Model; | |||
using BPASmartClient.Peripheral; | |||
using static BPASmartClient.EventBus.EventBus; | |||
namespace BPASmartClient.JAKA | |||
{ | |||
public class JakaMachine : BasePeripheral | |||
{ | |||
JaKaHelper jaKaHelper = new JaKaHelper(); | |||
public override void Init() | |||
{ | |||
jaKaHelper.Connect(communicationPar.IPAddress); | |||
ThreadManage.GetInstance().StartLong(new Action(() => | |||
{ | |||
IsConnected = jaKaHelper.IsConnected; | |||
if (!IsConnected) IsWork = false; | |||
while (IsConnected) | |||
{ | |||
IsWork = true; | |||
if (status != null) | |||
{ | |||
SetStatus("GetProgramStatus", (int)jaKaHelper.GetProgramStatus()); | |||
SetStatus("Get_RobotAO1", jaKaHelper.Get_RobotAO1()); | |||
} | |||
Thread.Sleep(500); | |||
} | |||
Thread.Sleep(1000); | |||
}), $"设备[{DeviceId}]节卡机器人读取线程", true); | |||
EventBus.EventBus.GetInstance().Subscribe<WriteJaka>(DeviceId, delegate (IEvent @event, EventCallBackHandle callBack) | |||
{ | |||
if (@event == null) return; | |||
var par = @event as WriteJaka; | |||
switch (par?.TagName) | |||
{ | |||
case "Power_On": | |||
jaKaHelper.Power_On(); | |||
break; | |||
case "Enable_robot": | |||
jaKaHelper.Enable_robot(); | |||
break; | |||
case "Set_RobotAO1": | |||
if (par?.Value is int intvalue) jaKaHelper.Set_RobotAO1(intvalue); | |||
break; | |||
case "JaKaProgramName": | |||
if (par?.Value is string stringvalue) jaKaHelper.JaKaProgramName(stringvalue); | |||
break; | |||
default: | |||
break; | |||
} | |||
}); | |||
} | |||
//public override void ReadData(string address) | |||
//{ | |||
//} | |||
public override void Start() | |||
{ | |||
} | |||
public override void Stop() | |||
{ | |||
} | |||
public override void WriteData(string address, object value) | |||
{ | |||
} | |||
protected override void InitStatus() | |||
{ | |||
} | |||
} | |||
} |
@@ -0,0 +1,13 @@ | |||
<Project Sdk="Microsoft.NET.Sdk"> | |||
<PropertyGroup> | |||
<TargetFramework>net6.0</TargetFramework> | |||
<ImplicitUsings>enable</ImplicitUsings> | |||
<Nullable>enable</Nullable> | |||
</PropertyGroup> | |||
<ItemGroup> | |||
<ProjectReference Include="..\BPASmartClient.Message\BPASmartClient.Message.csproj" /> | |||
</ItemGroup> | |||
</Project> |
@@ -0,0 +1,371 @@ | |||
using BPASmartClient.Message; | |||
using System.Text; | |||
namespace BPASmartClient.JakaRobot | |||
{ | |||
public class JaKaHelper | |||
{ | |||
#region 果汁机设备 | |||
/*public const string SENCE_取咖啡杯 = "10000"; | |||
public const string SENCE_取果汁杯 = "10001"; | |||
public const string SENCE_取茶水杯 = "10002"; | |||
public const string SENCE_取水杯 = "10003"; | |||
public const string SENCE_取咖啡杯检测 = "11000"; | |||
public const string SENCE_取果汁杯检测 = "11001"; | |||
public const string SENCE_取茶水杯检测 = "11002"; | |||
public const string SENCE_取水杯检测 = "11003"; | |||
public const string SENCE_接咖啡 = "12000"; | |||
public const string SENCE_接果汁1 = "12001"; | |||
public const string SENCE_接果汁2 = "12002"; | |||
public const string SENCE_接果汁3 = "12003"; | |||
public const string SENCE_接果汁4 = "12004"; | |||
public const string SENCE_接茶 = "12005"; | |||
public const string SENCE_接水 = "12006"; | |||
public const string SENCE_放咖啡杯 = "13000"; | |||
public const string SENCE_放果汁杯1 = "13001"; | |||
public const string SENCE_放果汁杯2 = "13002"; | |||
public const string SENCE_放果汁杯3 = "13003"; | |||
public const string SENCE_放果汁杯4 = "13004"; | |||
public const string SENCE_放茶水杯 = "13005"; | |||
public const string SENCE_放水杯 = "13006";*/ | |||
//public const string SENCE_取杯 = "10000"; | |||
//public const string SENCE_放杯位检测 = "10100"; | |||
//public const string SENCE_取杯检测 = "11000"; | |||
//public const string SENCE_接咖啡 = "12000"; | |||
//public const string SENCE_接果汁1 = "12001"; | |||
//public const string SENCE_接果汁2 = "12002"; | |||
//public const string SENCE_接果汁3 = "12003"; | |||
//public const string SENCE_接果汁4 = "12004"; | |||
//public const string SENCE_接茶 = "12005"; | |||
//public const string SENCE_接水 = "12006"; | |||
//public const string SENCE_接茶_接水 = "12007"; | |||
//public const string SENCE_放咖啡杯 = "13000";//接饮料位---放饮料过渡位 | |||
//public const string SENCE_放果汁杯1 = "13001"; | |||
//public const string SENCE_放果汁杯2 = "13002"; | |||
//public const string SENCE_放果汁杯3 = "13003"; | |||
//public const string SENCE_放果汁杯4 = "13004"; | |||
//public const string SENCE_放茶水杯 = "13005"; | |||
//public const string SENCE_放杯 = "14000";//放杯过渡位到-放杯 | |||
//public const string SENCE_放杯检测 = "15000"; | |||
//public const string SENCE_初始位 = "20000"; | |||
#endregion | |||
private int rshd = -1; | |||
private bool login = false; | |||
/// <summary> | |||
/// 机器人的状态 | |||
/// </summary> | |||
private JKTYPE.RobotStatus robot_Status; | |||
private JKTYPE.ProgramState program_status; | |||
//private volatile static JaKaHelper _Instance; | |||
//public static JaKaHelper GetInstance => _Instance ?? (_Instance = new JaKaHelper()); | |||
//private JaKaHelper() { } | |||
public bool IsIdle { get; set; } = false; | |||
public bool IsConnected { get { return login; } } | |||
public void Connect(string ip) | |||
{ | |||
bool ErrorFlag = false; | |||
while (rshd == -1 || login == false) | |||
{ | |||
try | |||
{ | |||
jakaAPI.create_handler(ip.ToCharArray(), ref rshd); | |||
login = true; | |||
} | |||
catch (Exception ex) | |||
{ | |||
if (!ErrorFlag) | |||
{ | |||
MessageLog.GetInstance.ShowEx(ex.ToString()); | |||
ErrorFlag = true; | |||
login = false; | |||
} | |||
Thread.Sleep(3000); | |||
} | |||
} | |||
if (login) | |||
{ | |||
try | |||
{ | |||
Power_On();//打开机器人电源 | |||
Thread.Sleep(1000); | |||
Enable_robot();//机器人上使能 | |||
MessageLog.GetInstance.Show("机器人已上电使能"); | |||
} | |||
catch (Exception ex) | |||
{ | |||
MessageLog.GetInstance.ShowEx("机器人未完成上电和使能"); | |||
} | |||
} | |||
} | |||
public void Power_On() | |||
{ | |||
if (login) | |||
{ | |||
try | |||
{ | |||
jakaAPI.power_on(ref rshd); | |||
} | |||
catch (System.AccessViolationException ave) | |||
{ | |||
MessageLog.GetInstance.ShowEx(ave.ToString()); | |||
} | |||
//catch (Exception ex) | |||
//{ | |||
// MessageLog.GetInstance.ShowEx(ex.ToString()); | |||
//} | |||
} | |||
else | |||
{ | |||
MessageLog.GetInstance.Show("jaka机器人未连接成功!"); | |||
} | |||
} | |||
public void Power_Off() | |||
{ | |||
if (login) | |||
{ | |||
try | |||
{ | |||
jakaAPI.power_off(ref rshd); | |||
} | |||
catch (Exception ex) | |||
{ | |||
} | |||
} | |||
else | |||
{ | |||
MessageLog.GetInstance.Show("jaka机器人未连接成功!"); | |||
} | |||
} | |||
public void Enable_robot() | |||
{ | |||
if (!(rshd == -1)) | |||
{ | |||
try | |||
{ | |||
jakaAPI.enable_robot(ref rshd); | |||
} | |||
catch (Exception ex) | |||
{ | |||
} | |||
} | |||
else | |||
{ | |||
MessageLog.GetInstance.Show("jaka机器人未连接成功!"); | |||
} | |||
} | |||
public void disEnable_robot() | |||
{ | |||
if (!(rshd == -1)) | |||
{ | |||
try | |||
{ | |||
jakaAPI.disable_robot(ref rshd); | |||
} | |||
catch (Exception ex) | |||
{ | |||
} | |||
} | |||
else | |||
{ | |||
MessageLog.GetInstance.Show("jaka机器人未连接成功!"); | |||
} | |||
} | |||
/// <summary> | |||
/// 设置机器人的DO值 | |||
/// </summary> | |||
/// <param name="DOIndex"></param> | |||
/// <param name="value"></param> | |||
/// <returns></returns> | |||
public bool Set_RobotDO(int DOIndex, bool value) | |||
{ | |||
try | |||
{ | |||
jakaAPI.set_digital_output(ref rshd, JKTYPE.IOType.IO_CABINET, DOIndex, value); | |||
return value; | |||
} | |||
catch (Exception ex) | |||
{ | |||
return false; | |||
} | |||
} | |||
/// <summary> | |||
/// 设置机器人的AO值 | |||
/// </summary> | |||
/// <param name="value">设置值</param> | |||
/// <returns></returns> | |||
public int Set_RobotAO1(int Value) | |||
{ | |||
try | |||
{ | |||
return jakaAPI.set_analog_output(ref rshd, JKTYPE.IOType.IO_CABINET, 0, Value); | |||
} | |||
catch (Exception ex) | |||
{ | |||
return 0; | |||
} | |||
} | |||
/// <summary> | |||
/// 设置机器人的AO值 | |||
/// </summary> | |||
/// <param name="Index">索引值</param> | |||
/// <param name="value">设置值</param> | |||
/// <returns></returns> | |||
public int Set_RobotAO(int Index, int Value) | |||
{ | |||
try | |||
{ | |||
return jakaAPI.set_analog_output(ref rshd, JKTYPE.IOType.IO_CABINET, Index, Value); | |||
} | |||
catch (Exception ex) | |||
{ | |||
return 0; | |||
} | |||
} | |||
/// <summary> | |||
/// 获取机器人的AO值 | |||
/// </summary> | |||
/// <param name="Index">索引值</param> | |||
/// <param name="value">设置值</param> | |||
/// <returns></returns> | |||
public float Get_RobotAO(int Index, int value) | |||
{ | |||
try | |||
{ | |||
float bResult = 0; | |||
jakaAPI.get_analog_output(ref rshd, JKTYPE.IOType.IO_CABINET, Index, ref bResult); | |||
return bResult; | |||
} | |||
catch (Exception ex) | |||
{ | |||
return 0; | |||
} | |||
} | |||
/// <summary> | |||
/// 获取机器人的AO值 | |||
/// </summary> | |||
/// <param name="Index">索引值</param> | |||
/// <param name="value">设置值</param> | |||
/// <returns></returns> | |||
public float Get_RobotAO1() | |||
{ | |||
try | |||
{ | |||
float bResult = 0; | |||
jakaAPI.get_analog_output(ref rshd, JKTYPE.IOType.IO_CABINET, 0, ref bResult); | |||
return bResult; | |||
} | |||
catch (Exception ex) | |||
{ | |||
return 0; | |||
} | |||
} | |||
/// <summary> | |||
/// 获取机器人的DI输入 | |||
/// </summary> | |||
/// <param name="index"></param> | |||
/// <returns></returns> | |||
public bool Get_RobotDI(int index) | |||
{ | |||
bool bResult = false; | |||
jakaAPI.get_digital_input(ref rshd, JKTYPE.IOType.IO_CABINET, index, ref bResult); | |||
return bResult; | |||
} | |||
/// <summary> | |||
/// 获取机器人的状态 | |||
/// </summary> | |||
public void GetRobotStatus() | |||
{ | |||
jakaAPI.get_robot_status(ref rshd, ref robot_Status); | |||
} | |||
public JKTYPE.ProgramState GetProgramStatus() | |||
{ | |||
jakaAPI.get_program_state(ref rshd, ref program_status); | |||
return program_status; | |||
} | |||
StringBuilder jakafile; | |||
JKTYPE.ProgramState status; | |||
char[] file; | |||
public void JaKaProgramName(String Programname) | |||
{ | |||
try | |||
{ | |||
//加载 | |||
file = Programname.ToCharArray(); | |||
MessageLog.GetInstance.Show($"调用文件名:{Programname}"); | |||
status = new JKTYPE.ProgramState(); | |||
jakaAPI.get_program_state(ref rshd, ref status); | |||
if (status != JKTYPE.ProgramState.PROGRAM_IDLE) | |||
{ | |||
MessageLog.GetInstance.Show($"程序运行中,无法加载程序!!!"); | |||
} | |||
else | |||
{ | |||
if (jakaAPI.program_load(ref rshd, file) == 0) | |||
{ | |||
MessageLog.GetInstance.Show($"加载程序完成"); | |||
} | |||
else | |||
{ | |||
MessageLog.GetInstance.Show($"加载程序失败!!!"); | |||
} | |||
} | |||
if (status == JKTYPE.ProgramState.PROGRAM_RUNNING) | |||
{ | |||
MessageLog.GetInstance.Show($"程序处于已处于启动状态!!!"); | |||
} | |||
else if (status == JKTYPE.ProgramState.PROGRAM_IDLE) | |||
{ | |||
jakafile = new StringBuilder(); | |||
jakaAPI.get_loaded_program(ref rshd, jakafile); | |||
if (jakafile.Length == 0) | |||
{ | |||
MessageLog.GetInstance.Show($"未加载程序,无法运行!!!"); | |||
} | |||
else | |||
{ | |||
MessageLog.GetInstance.Show($"当前加载程序为:" + jakafile); | |||
jakaAPI.program_run(ref rshd); | |||
MessageLog.GetInstance.Show($"程序启动"); | |||
} | |||
} | |||
else | |||
{ | |||
MessageLog.GetInstance.Show($"程序处于暂停状态,无法重新启动程序!!!"); | |||
} | |||
} | |||
catch (Exception ex) | |||
{ | |||
MessageLog.GetInstance.ShowEx(ex.ToString()); | |||
} | |||
} | |||
} | |||
} |
@@ -0,0 +1,364 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
//using System.Numerics; | |||
using System.Text; | |||
using System.Runtime.InteropServices; | |||
namespace BPASmartClient.JakaRobot | |||
{ | |||
public class JKTYPE | |||
{ | |||
/** | |||
* @brief 笛卡尔空间位置数据类型 | |||
*/ | |||
[StructLayout(LayoutKind.Sequential)] | |||
public struct CartesianTran | |||
{ | |||
public double x; ///< x轴坐标,单位mm | |||
public double y; ///< y轴坐标,单位mm | |||
public double z; ///< z轴坐标,单位mm | |||
}; | |||
/** | |||
* @brief 欧拉角姿态数据类型 | |||
*/ | |||
[StructLayout(LayoutKind.Sequential)] | |||
public struct Rpy | |||
{ | |||
public double rx; ///< 绕固定轴X旋转角度,单位:rad | |||
public double ry; ///< 绕固定轴Y旋转角度,单位:rad | |||
public double rz; ///< 绕固定轴Z旋转角度,单位:rad | |||
}; | |||
/** | |||
* @brief 四元数姿态数据类型 | |||
*/ | |||
[StructLayout(LayoutKind.Sequential)] | |||
public struct Quaternion | |||
{ | |||
public double s; | |||
public double x; | |||
public double y; | |||
public double z; | |||
}; | |||
/** | |||
*@brief 笛卡尔空间位姿类型 | |||
*/ | |||
[StructLayout(LayoutKind.Sequential)] | |||
public struct CartesianPose | |||
{ | |||
public CartesianTran tran; ///< 笛卡尔空间位置 | |||
public Rpy rpy; ///< 笛卡尔空间姿态 | |||
}; | |||
/** | |||
* @brief 旋转矩阵数据类型 | |||
*/ | |||
[StructLayout(LayoutKind.Sequential)] | |||
public struct RotMatrix | |||
{ | |||
public CartesianTran x; ///< x轴列分量 | |||
public CartesianTran y; ///< y轴列分量 | |||
public CartesianTran z; ///< z轴列分量 | |||
}; | |||
/** | |||
* @brief 程序运行状态枚举类型 | |||
*/ | |||
public enum ProgramState | |||
{ | |||
PROGRAM_IDLE, ///< 机器人停止运行 | |||
PROGRAM_RUNNING, ///< 机器人正在运行 | |||
PROGRAM_PAUSED ///< 机器人暂停 | |||
}; | |||
/** | |||
* @brief 坐标系选择枚举类型 | |||
*/ | |||
public enum CoordType | |||
{ | |||
COORD_BASE, ///< 基坐标系 | |||
COORD_JOINT, ///< 关节空间 | |||
COORD_TOOL ///< 工具坐标系 | |||
}; | |||
/** | |||
* @brief jog运动模式枚举 | |||
*/ | |||
public enum MoveMode | |||
{ | |||
ABS = 0, ///< 绝对运动 | |||
INCR ///< 增量运动 | |||
}; | |||
/** | |||
* @brief 系统监测数据类型 | |||
*/ | |||
[StructLayout(LayoutKind.Sequential)] | |||
public struct SystemMonitorData | |||
{ | |||
public int scbMajorVersion; ///<scb主版本号 | |||
public int scbMinorVersion; ///<scb次版本号 | |||
public int cabTemperature; ///<控制柜温度 | |||
public double robotAveragePower; ///<控制柜总线平均功率 | |||
public double robotAverageCurrent; ///<控制柜总线平均电流 | |||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 6)] | |||
public double[] instCurrent; ///<机器人6个轴的瞬时电流 | |||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 6)] | |||
public double[] instVoltage; ///<机器人6个轴的瞬时电压 | |||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 6)] | |||
public double[] instTemperature; ///<机器人6个轴的瞬时温度 | |||
}; | |||
/** | |||
* @brief 负载数据类型 | |||
*/ | |||
[StructLayout(LayoutKind.Sequential)] | |||
public struct PayLoad | |||
{ | |||
public double mass; ///<负载质量,单位:kg | |||
public CartesianTran centroid; ///<负载质心, 单位:mm | |||
}; | |||
/** | |||
* @brief 关节位置数据类型 | |||
*/ | |||
public struct JointValue | |||
{ | |||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 6)] | |||
public double[] jVal; ///< 6关节位置值,单位:rad | |||
}; | |||
/** | |||
* @brief IO类型枚举 | |||
*/ | |||
public enum IOType | |||
{ | |||
IO_CABINET, ///< 控制柜面板IO | |||
IO_TOOL, ///< 工具IO | |||
IO_EXTEND ///< 扩展IO | |||
}; | |||
/** | |||
* @brief 机器人状态数据 | |||
*/ | |||
[StructLayout(LayoutKind.Sequential)] | |||
public struct RobotState | |||
{ | |||
public int estoped; ///< 是否急停 | |||
public int poweredOn; ///< 是否打开电源 | |||
public int servoEnabled; ///< 是否使能 | |||
}; | |||
/** | |||
* @brief 机器人力矩数据 | |||
*/ | |||
[StructLayout(LayoutKind.Sequential)] | |||
public struct TorqueValue | |||
{ | |||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 6)] | |||
public double[] jTorque; ///< 是否使能 | |||
} | |||
/** | |||
* @brief 机器人关节监测数据类型 | |||
*/ | |||
[StructLayout(LayoutKind.Sequential)] | |||
public struct JointMonitorData | |||
{ | |||
double instCurrent; ///< 瞬时电流 | |||
double instVoltage; ///< 瞬时电压 | |||
double instTemperature; ///< 瞬时温度 | |||
} | |||
/** | |||
* @brief 机器人监测数据类型 | |||
*/ | |||
[StructLayout(LayoutKind.Sequential)] | |||
public struct RobotMonitorData | |||
{ | |||
double scbMajorVersion; ///< scb主版本号 | |||
double scbMinorVersion; ///< scb小版本号 | |||
double cabTemperature; ///< 控制器温度 | |||
double robotAveragePower; ///< 机器人平均电压 | |||
double robotAverageCurrent; ///< 机器人平均电流 | |||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 6)] | |||
public JointMonitorData[] jointMonitorData; ///< 机器人6个关节的监测数据 | |||
} | |||
/** | |||
* @brief 力矩传感器监测数据类型 | |||
*/ | |||
[StructLayout(LayoutKind.Sequential)] | |||
public struct TorqSensorMonitorData | |||
{ | |||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 20)] | |||
public char[] ip; ///< 力矩传感器ip地址 | |||
int port; ///< 力矩传感器端口号 | |||
PayLoad payLoad; ///< 工具负载 | |||
int status; ///< 力矩传感器状态 | |||
int errcode; ///< 力矩传感器异常错误码 | |||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 6)] | |||
public double[] actTorque; ///< 力矩传感器实际接触力值 | |||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 6)] | |||
public double[] torque; ///< 力矩传感器原始读数值 | |||
} | |||
/** | |||
* @brief 机器人状态监测数据,使用get_robot_status函数更新机器人状态数据 | |||
*/ | |||
[StructLayout(LayoutKind.Sequential)] | |||
public struct RobotStatus | |||
{ | |||
public int errcode; ///< 机器人运行出错时错误编号,0为运行正常,其它为运行异常 | |||
public int inpos; ///< 机器人运动是否到位标志,0为没有到位,1为运动到位 | |||
public int powered_on; ///< 机器人是否上电标志,0为没有上电,1为上电 | |||
public int enabled; ///< 机器人是否使能标志,0为没有使能,1为使能 | |||
public double rapidrate; ///< 机器人运动倍率 | |||
public int protective_stop; ///< 机器人是否检测到碰撞,0为没有检测到碰撞,1为检测到碰撞 | |||
public int emergency_stop; ///< 机器人是否急停,0为没有急停,1为急停 | |||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 65)] | |||
public int[] dout; ///< 机器人控制柜数字输出信号,dout[0]为信号的个数 | |||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 10)] | |||
public int[] tio_dout; ///< 机器人末端工具数字输出信号,tio_dout[0]为信号的个数 | |||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 65)] | |||
public int[] extio; ///< 机器人外部应用数字输出信号,extio[0]为信号的个数 | |||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 65)] | |||
public int[] din; ///< 机器人控制柜数字输入信号,din[0]为信号的个数 | |||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 10)] | |||
public int[] tio_din; ///< 机器人末端工具数字输入信号,tio_din[0]为信号的个数 | |||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 65)] | |||
public double[] ain; ///< 机器人控制柜模拟输入信号,ain[0]为信号的个数 | |||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 10)] | |||
public double[] tio_ain; ///< 机器人末端工具模拟输入信号,tio_ain[0]为信号的个数 | |||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 65)] | |||
public double[] aout; ///< 机器人控制柜模拟输出信号,aout[0]为信号的个数 | |||
public int current_tool_id; ///< 机器人目前使用的工具坐标系id | |||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 6)] | |||
public double[] cartesiantran_position; ///< 机器人末端所在的笛卡尔空间位置 | |||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 6)] | |||
public double[] joint_position; ///< 机器人关节空间位置 | |||
public int on_soft_limit; ///< 机器人是否处于限位,0为没有触发限位保护,1为触发限位保护 | |||
public int current_user_id; ///< 机器人目前使用的用户坐标系id | |||
public int drag_status; ///< 机器人是否处于拖拽状态,0为没有处于拖拽状态,1为处于拖拽状态 | |||
public RobotMonitorData robot_monitor_data; ///< 机器人状态监测数据 | |||
public TorqSensorMonitorData torq_sensor_monitor_data; ///< 机器人力矩传感器状态监测数据 | |||
int is_socket_connect; ///< sdk与控制器连接通道是否正常,0为连接通道异常,1为连接通道正常 | |||
} | |||
/** | |||
* @brief 机器人错误码数据类型 | |||
*/ | |||
[StructLayout(LayoutKind.Sequential)] | |||
public struct ErrorCode | |||
{ | |||
public long code; ///< 错误码编号 | |||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 120)] | |||
public char[] message; ///< 错误码对应提示信息 | |||
} | |||
/** | |||
* @brief 轨迹复现配置参数数据类型 | |||
*/ | |||
[StructLayout(LayoutKind.Sequential)] | |||
public struct TrajTrackPara | |||
{ | |||
public double xyz_interval; ///< 空间位置采集精度 | |||
public double rpy_interval; ///< 姿态采集精度 | |||
public double vel; ///< 执行脚本运行速度 | |||
public double acc; ///< 执行脚本运行加速度 | |||
} | |||
/** | |||
* @brief 多个字符串存储数据类型 | |||
*/ | |||
[StructLayout(LayoutKind.Sequential)] | |||
public struct MultStrStorType | |||
{ | |||
public int len; ///< 字符串个数 | |||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 128 * 128)] | |||
public char[] message; ///< 错误码对应提示信息 | |||
} | |||
/** | |||
* @brief 运动参数可选项 | |||
*/ | |||
[StructLayout(LayoutKind.Sequential)] | |||
public struct OptionalCond | |||
{ | |||
int executingLineId; ///< 控制命令id编号 | |||
} | |||
/** | |||
* @brief 网络异常机器人运动自动终止类型枚举 | |||
*/ | |||
public enum ProcessType | |||
{ | |||
MOT_KEEP, ///< 网络异常时机器人继续保持原来的运动 | |||
MOT_PAUSE, ///< 网络异常时机器人暂停运动 | |||
MOT_ABORT ///< 网络异常时机器人终止运动 | |||
} | |||
/** | |||
* @brief 柔顺控制参数类型 | |||
*/ | |||
[StructLayout(LayoutKind.Sequential)] | |||
public struct AdmitCtrlType | |||
{ | |||
int opt; ///< 柔顺方向,可选值为 1 2 3 4 5 6分别对应 fx fy fz mx my mz,0代表没有勾选 | |||
double ft_user; ///< 用户用多大的力才能让机器人的沿着某个方向以最大速度进行运动 | |||
double ft_rebound; ///< 回弹力:机器人回到初始状态的能力 | |||
double ft_constant; ///< 恒力 | |||
int ft_normal_track; ///< 法向跟踪是否开启,0为没有开启,1为开启 | |||
} | |||
/** | |||
* @brief 机器人柔顺控制参数类型 | |||
*/ | |||
[StructLayout(LayoutKind.Sequential)] | |||
public struct RobotAdmitCtrl | |||
{ | |||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 6)] | |||
public AdmitCtrlType[] admit_ctrl; | |||
} | |||
/** | |||
* @brief 速度柔顺控制等级和比率等级设置 | |||
* 速度柔顺控制分三个等级,并且 1>rate1>rate2>rate3>rate4>0 | |||
* 等级为1时,只能设置rate1,rate2两个等级。rate3,rate4的值为0 | |||
* 等级为2时,只能设置rate1,rate2,rate3 三个等级。rate4的值为0 | |||
* 等级为3时,能设置 rate1,rate2,rate3,rate4 4个等级 | |||
*/ | |||
[StructLayout(LayoutKind.Sequential)] | |||
public struct VelCom | |||
{ | |||
int vc_level; //速度柔顺控制等级 | |||
double rate1; //比率1等级 | |||
double rate2; //比率2等级 | |||
double rate3; //比率3等级 | |||
double rate4; //比率4等级 | |||
} | |||
/** | |||
* @brief 力传感器的受力分量和力矩分量 | |||
*/ | |||
[StructLayout(LayoutKind.Sequential)] | |||
public struct FTxyz | |||
{ | |||
double fx; // 沿x轴受力分量 | |||
double fy; // 沿y轴受力分量 | |||
double fz; // 沿z轴受力分量 | |||
double tx; // 绕x轴力矩分量 | |||
double ty; // 绕y轴力矩分量 | |||
double tz; // 绕z轴力矩分量 | |||
} | |||
} | |||
} |
@@ -0,0 +1,14 @@ | |||
<Project Sdk="Microsoft.NET.Sdk"> | |||
<PropertyGroup> | |||
<TargetFramework>net6.0</TargetFramework> | |||
<ImplicitUsings>enable</ImplicitUsings> | |||
<Nullable>enable</Nullable> | |||
</PropertyGroup> | |||
<ItemGroup> | |||
<ProjectReference Include="..\BPASmartClient.Peripheral\BPASmartClient.Peripheral.csproj" /> | |||
<ProjectReference Include="..\BPASmartClient.SerialPort\BPASmartClient.SerialPort.csproj" /> | |||
</ItemGroup> | |||
</Project> |
@@ -0,0 +1,61 @@ | |||
using BPASmartClient.EventBus; | |||
using BPASmartClient.Helper; | |||
using BPASmartClient.Model; | |||
using BPASmartClient.Peripheral; | |||
using BPASmartClient.SerialPort; | |||
using static BPASmartClient.EventBus.EventBus; | |||
namespace BPASmartClient.Juicer | |||
{ | |||
public class JuicerMachine : BasePeripheral | |||
{ | |||
JuicerHelper juicerHelper = new JuicerHelper(); | |||
public override void Init() | |||
{ | |||
juicerHelper.Open(communicationPar.SerialPort, communicationPar.BaudRate); | |||
ThreadManage.GetInstance().StartLong(new Action(() => | |||
{ | |||
IsConnected = juicerHelper.IsOpen; | |||
if (!IsConnected) IsWork = false; | |||
while (IsConnected) | |||
{ | |||
IsWork = true; | |||
if (status != null) | |||
{ | |||
SetStatus("GetDeviceStatus", juicerHelper.GetDeviceStatus()); | |||
} | |||
Thread.Sleep(500); | |||
} | |||
Thread.Sleep(1000); | |||
}), $"设备[{DeviceId}]果汁机读取线程", true); | |||
EventBus.EventBus.GetInstance().Subscribe<WriteJuicer>(DeviceId, delegate (IEvent @event, EventCallBackHandle callBack) | |||
{ | |||
if (@event == null) return; | |||
var par = @event as WriteJuicer; | |||
juicerHelper.StartCook(Convert.ToByte(par?.Value)); | |||
}); | |||
} | |||
//public override void ReadData(string address) | |||
//{ | |||
//} | |||
public override void Start() | |||
{ | |||
} | |||
public override void Stop() | |||
{ | |||
} | |||
public override void WriteData(string address, object value) | |||
{ | |||
} | |||
protected override void InitStatus() | |||
{ | |||
} | |||
} | |||
} |
@@ -19,7 +19,7 @@ namespace BPASmartClient.KLMCoffee | |||
/// <summary> | |||
/// 伽乐美咖啡机 | |||
/// </summary> | |||
public class CoffeeMachine :BasePeripheral | |||
public class CoffeeMachine : BasePeripheral | |||
{ | |||
//通讯代理 | |||
SerialPortClient commProxy = null; | |||
@@ -92,12 +92,12 @@ namespace BPASmartClient.KLMCoffee | |||
commProxy.SendData(cmdAsk); | |||
} | |||
Thread.Sleep(200); | |||
}),"咖啡机询问线程"); | |||
}), "咖啡机询问线程"); | |||
ThreadManage.GetInstance().StartLong(new Action(() => | |||
{ | |||
ResolveMsg(); | |||
}),"咖啡机解析线程"); | |||
}), "咖啡机解析线程"); | |||
} | |||
private void ResolveMsg() | |||
@@ -117,7 +117,7 @@ namespace BPASmartClient.KLMCoffee | |||
{ | |||
temp.Add(dataStorage.GetData()); | |||
} | |||
List<byte> vs = new List<byte>() { temp[temp.Count - 4],temp[temp.Count - 3],temp[temp.Count - 2],temp[temp.Count - 1] }; | |||
List<byte> vs = new List<byte>() { temp[temp.Count - 4], temp[temp.Count - 3], temp[temp.Count - 2], temp[temp.Count - 1] }; | |||
//帧尾 | |||
if (Encoding.ASCII.GetString(vs.ToArray()).ToLower() == "\\r\\n" || Encoding.ASCII.GetString(vs.ToArray()).ToLower() == "\r\n") | |||
@@ -146,9 +146,9 @@ namespace BPASmartClient.KLMCoffee | |||
status["Warning"] = systemStatus.faultMessage.dataFault(); | |||
status["Keep"] = systemStatus.upkeepMessage; | |||
if (systemStatus.faultMessage.IsFault() || systemStatus.upkeepMessage.IsUpkeep()) | |||
IsWork=false; | |||
IsWork = false; | |||
else | |||
IsWork=true; | |||
IsWork = true; | |||
} | |||
} | |||
@@ -164,128 +164,130 @@ namespace BPASmartClient.KLMCoffee | |||
status["drinkType"] = DrinkType.意式; | |||
status["AppStatus"] = TaskIndex.无任务; | |||
status["progress"] = 0; | |||
status["Warning"] = new FaultMessage(0x00,0x00).dataFault(); | |||
status["Warning"] = new FaultMessage(0x00, 0x00).dataFault(); | |||
status["Keep"] = new UpkeepMessage(0x00).dataFault(); | |||
} | |||
public override void Init() | |||
{ | |||
commProxy = new SerialPortClient(PortName,(BaudRates)Enum.Parse(typeof(BaudRates),BaudRate)); | |||
commProxy = new SerialPortClient(PortName, (BaudRates)Enum.Parse(typeof(BaudRates), BaudRate)); | |||
commProxy.SetDataStorage(dataStorage); | |||
//伽乐美咖啡机制作 | |||
EventBus.EventBus.GetInstance().Subscribe<KLMCoffee_MakeCoffeeEvent>(DeviceId,delegate (IEvent @event,EventCallBackHandle callBack) | |||
{ | |||
try | |||
{ | |||
free = true; | |||
Thread.Sleep(200); | |||
byte[] data=command.ReturnsCommandData(K95CommandEnum.配方咖啡制作.GetString(),new RecipeModel().Packe(((KLMCoffee_MakeCoffeeEvent)@event).DrinkCode)); | |||
commProxy.SendData(data); | |||
Thread.Sleep(200); | |||
free = false; | |||
} | |||
catch (Exception ex) | |||
{ | |||
MessageLog.GetInstance.ShowEx($"BPASmartClient.KLMCoffee 中引发错误,CoffeeMachine 类,描述:[{ex.Message}]"); | |||
} | |||
}); | |||
EventBus.EventBus.GetInstance().Subscribe<KLMCoffee_MakeCoffeeEvent>(DeviceId, delegate (IEvent @event, EventCallBackHandle callBack) | |||
{ | |||
try | |||
{ | |||
free = true; | |||
Thread.Sleep(200); | |||
byte[] data = command.ReturnsCommandData(K95CommandEnum.配方咖啡制作.GetString(), new RecipeModel().Packe(((KLMCoffee_MakeCoffeeEvent)@event).DrinkCode)); | |||
commProxy.SendData(data); | |||
Thread.Sleep(200); | |||
free = false; | |||
} | |||
catch (Exception ex) | |||
{ | |||
MessageLog.GetInstance.ShowEx($"BPASmartClient.KLMCoffee 中引发错误,CoffeeMachine 类,描述:[{ex.Message}]"); | |||
} | |||
}); | |||
//伽乐美咖啡机取消制作咖啡 | |||
EventBus.EventBus.GetInstance().Subscribe<KLMCoffee_CancelMakeCoffeeEvent>(DeviceId,delegate (IEvent @event,EventCallBackHandle callBack) | |||
{ | |||
try | |||
{ | |||
free = true; | |||
Thread.Sleep(200); | |||
byte[] data = command.ReturnsCancelMake(); | |||
commProxy.SendData(data); | |||
Thread.Sleep(200); | |||
free = false; | |||
} | |||
catch (Exception ex) | |||
{ | |||
MessageLog.GetInstance.ShowEx($"BPASmartClient.KLMCoffee 中引发错误,CoffeeMachine 类,描述:[{ex.Message}]"); | |||
} | |||
}); | |||
EventBus.EventBus.GetInstance().Subscribe<KLMCoffee_CancelMakeCoffeeEvent>(DeviceId, delegate (IEvent @event, EventCallBackHandle callBack) | |||
{ | |||
try | |||
{ | |||
free = true; | |||
Thread.Sleep(200); | |||
byte[] data = command.ReturnsCancelMake(); | |||
commProxy.SendData(data); | |||
Thread.Sleep(200); | |||
free = false; | |||
} | |||
catch (Exception ex) | |||
{ | |||
MessageLog.GetInstance.ShowEx($"BPASmartClient.KLMCoffee 中引发错误,CoffeeMachine 类,描述:[{ex.Message}]"); | |||
} | |||
}); | |||
//伽乐美咖啡机清洗冲泡器 | |||
EventBus.EventBus.GetInstance().Subscribe<KLMCoffee_WashCPJEvent>(DeviceId,delegate (IEvent @event,EventCallBackHandle callBack) | |||
{ | |||
try | |||
{ | |||
free = true; | |||
Thread.Sleep(200); | |||
byte[] data = command.ReturnsWashCPJ(); | |||
commProxy.SendData(data); | |||
Thread.Sleep(200); | |||
free = false; | |||
} | |||
catch (Exception ex) | |||
{ | |||
MessageLog.GetInstance.ShowEx($"BPASmartClient.KLMCoffee 中引发错误,CoffeeMachine 类,描述:[{ex.Message}]"); | |||
} | |||
}); | |||
EventBus.EventBus.GetInstance().Subscribe<KLMCoffee_WashCPJEvent>(DeviceId, delegate (IEvent @event, EventCallBackHandle callBack) | |||
{ | |||
try | |||
{ | |||
free = true; | |||
Thread.Sleep(200); | |||
byte[] data = command.ReturnsWashCPJ(); | |||
commProxy.SendData(data); | |||
Thread.Sleep(200); | |||
free = false; | |||
} | |||
catch (Exception ex) | |||
{ | |||
MessageLog.GetInstance.ShowEx($"BPASmartClient.KLMCoffee 中引发错误,CoffeeMachine 类,描述:[{ex.Message}]"); | |||
} | |||
}); | |||
//伽乐美咖啡机放杯确认 | |||
EventBus.EventBus.GetInstance().Subscribe<KLMCoffee_CupIsOKEvent>(DeviceId,delegate (IEvent @event,EventCallBackHandle callBack) | |||
{ | |||
try | |||
{ | |||
free = true; | |||
Thread.Sleep(200); | |||
byte[] data = command.ReturnsCupIsOK(); | |||
commProxy.SendData(data); | |||
Thread.Sleep(200); | |||
free = false; | |||
} | |||
catch (Exception ex) | |||
{ | |||
MessageLog.GetInstance.ShowEx($"BPASmartClient.KLMCoffee 中引发错误,CoffeeMachine 类,描述:[{ex.Message}]"); | |||
} | |||
}); | |||
EventBus.EventBus.GetInstance().Subscribe<KLMCoffee_CupIsOKEvent>(DeviceId, delegate (IEvent @event, EventCallBackHandle callBack) | |||
{ | |||
try | |||
{ | |||
free = true; | |||
Thread.Sleep(200); | |||
byte[] data = command.ReturnsCupIsOK(); | |||
commProxy.SendData(data); | |||
Thread.Sleep(200); | |||
free = false; | |||
} | |||
catch (Exception ex) | |||
{ | |||
MessageLog.GetInstance.ShowEx($"BPASmartClient.KLMCoffee 中引发错误,CoffeeMachine 类,描述:[{ex.Message}]"); | |||
} | |||
}); | |||
//伽乐美咖啡机清洗奶沫器 | |||
EventBus.EventBus.GetInstance().Subscribe<KLMCoffee_WashNMJEvent>(DeviceId,delegate (IEvent @event,EventCallBackHandle callBack) | |||
{ | |||
try | |||
{ | |||
free = true; | |||
Thread.Sleep(200); | |||
byte[] data = command.ReturnsWashNMJ(); | |||
commProxy.SendData(data); | |||
Thread.Sleep(200); | |||
free = false; | |||
} | |||
catch (Exception ex) | |||
{ | |||
MessageLog.GetInstance.ShowEx($"BPASmartClient.KLMCoffee 中引发错误,CoffeeMachine 类,描述:[{ex.Message}]"); | |||
} | |||
}); | |||
EventBus.EventBus.GetInstance().Subscribe<KLMCoffee_WashNMJEvent>(DeviceId, delegate (IEvent @event, EventCallBackHandle callBack) | |||
{ | |||
try | |||
{ | |||
free = true; | |||
Thread.Sleep(200); | |||
byte[] data = command.ReturnsWashNMJ(); | |||
commProxy.SendData(data); | |||
Thread.Sleep(200); | |||
free = false; | |||
} | |||
catch (Exception ex) | |||
{ | |||
MessageLog.GetInstance.ShowEx($"BPASmartClient.KLMCoffee 中引发错误,CoffeeMachine 类,描述:[{ex.Message}]"); | |||
} | |||
}); | |||
//伽乐美咖啡机清洗奶沫器确认 | |||
EventBus.EventBus.GetInstance().Subscribe<KLMCoffee_WashNMJIsOKEvent>(DeviceId,delegate (IEvent @event,EventCallBackHandle callBack) | |||
{ | |||
try | |||
{ | |||
free = true; | |||
Thread.Sleep(200); | |||
byte[] data = command.ReturnsWashNMJIsOK(); | |||
commProxy.SendData(data); | |||
Thread.Sleep(200); | |||
free = false; | |||
} | |||
catch (Exception ex) | |||
{ | |||
MessageLog.GetInstance.ShowEx($"BPASmartClient.KLMCoffee 中引发错误,CoffeeMachine 类,描述:[{ex.Message}]"); | |||
} | |||
}); | |||
EventBus.EventBus.GetInstance().Subscribe<KLMCoffee_WashNMJIsOKEvent>(DeviceId, delegate (IEvent @event, EventCallBackHandle callBack) | |||
{ | |||
try | |||
{ | |||
free = true; | |||
Thread.Sleep(200); | |||
byte[] data = command.ReturnsWashNMJIsOK(); | |||
commProxy.SendData(data); | |||
Thread.Sleep(200); | |||
free = false; | |||
} | |||
catch (Exception ex) | |||
{ | |||
MessageLog.GetInstance.ShowEx($"BPASmartClient.KLMCoffee 中引发错误,CoffeeMachine 类,描述:[{ex.Message}]"); | |||
} | |||
}); | |||
InitStatus(); | |||
} | |||
public override void WriteData(string address, object value) | |||
{ | |||
} | |||
} | |||
} |
@@ -19,7 +19,7 @@ using BPASmartClient.Model.乐白机器人; | |||
namespace BPASmartClient.Lebai | |||
{ | |||
public class LebaiRobot: BasePeripheral | |||
public class LebaiRobot : BasePeripheral | |||
{ | |||
/// <summary> | |||
@@ -48,10 +48,14 @@ namespace BPASmartClient.Lebai | |||
status["RobotIsConnected"] = LebaiHelper.GetInstance().IsConnected; | |||
status["RobotOK"] = LebaiHelper.GetInstance().GetValueAsync().Ok; | |||
status["RobotValue"] = LebaiHelper.GetInstance().GetValueAsync().Value; | |||
if (LebaiHelper.GetInstance().robotData != null) status["RobotMode"] =(ELebaiRModel)LebaiHelper.GetInstance().robotData.RobotMode.Mode; | |||
status["RobotValue1"] = LebaiHelper.GetInstance().GetValueAsync(1).Value; | |||
status["GetInput"] = LebaiHelper.GetInstance().GetInput(); | |||
status["GetInput2"] = LebaiHelper.GetInstance().GetInput(2); | |||
if (LebaiHelper.GetInstance().robotData != null) status["RobotMode"] = LebaiHelper.GetInstance().robotData.RobotMode.Mode; | |||
LebaiHelper.GetInstance().GetRobotModeStatus(); | |||
Thread.Sleep(10); | |||
},"获取乐白机器人数据"); | |||
}, "获取乐白机器人数据"); | |||
} | |||
@@ -62,7 +66,7 @@ namespace BPASmartClient.Lebai | |||
public override void Init() | |||
{ | |||
EventBus.EventBus.GetInstance().Subscribe<Demo_MakeCoffeeEvent>(DeviceId, delegate (IEvent @event, EventCallBackHandle callBack ) | |||
EventBus.EventBus.GetInstance().Subscribe<Demo_MakeCoffeeEvent>(DeviceId, delegate (IEvent @event, EventCallBackHandle callBack) | |||
{ | |||
}); | |||
@@ -90,7 +94,7 @@ namespace BPASmartClient.Lebai | |||
if (@event == null) return; | |||
if (@event is LebaiRobot_SetValueEvent SetValueEvent) | |||
{ | |||
LebaiHelper.GetInstance().SetValue(SetValueEvent.RobotSetValue); | |||
LebaiHelper.GetInstance().SetValue(SetValueEvent.RobotSetValue); | |||
} | |||
}); | |||
//控制机器人 | |||
@@ -116,7 +120,7 @@ namespace BPASmartClient.Lebai | |||
default: | |||
break; | |||
} | |||
} | |||
}); | |||
//选择机器人场景 | |||
@@ -134,6 +138,8 @@ namespace BPASmartClient.Lebai | |||
MessageLog.GetInstance.Show("乐白机器人初始化完成"); | |||
} | |||
public override void WriteData(string address, object value) | |||
{ | |||
} | |||
} | |||
} |
@@ -0,0 +1,14 @@ | |||
<Project Sdk="Microsoft.NET.Sdk"> | |||
<PropertyGroup> | |||
<TargetFramework>net6.0</TargetFramework> | |||
<ImplicitUsings>enable</ImplicitUsings> | |||
<Nullable>enable</Nullable> | |||
</PropertyGroup> | |||
<ItemGroup> | |||
<ProjectReference Include="..\BPASmartClient.Peripheral\BPASmartClient.Peripheral.csproj" /> | |||
<ProjectReference Include="..\BPASmartClient.SerialPort\BPASmartClient.SerialPort.csproj" /> | |||
</ItemGroup> | |||
</Project> |
@@ -0,0 +1,71 @@ | |||
using BPASmartClient.EventBus; | |||
using BPASmartClient.Model.PLC; | |||
using BPASmartClient.Model.单片机; | |||
using BPASmartClient.Peripheral; | |||
using BPASmartClient.SerialPort; | |||
using static BPASmartClient.EventBus.EventBus; | |||
namespace BPASmartClient.MCU | |||
{ | |||
public class MCUMachine : BasePeripheral | |||
{ | |||
MCUSerialHelper mCUSerialHelper = new MCUSerialHelper(); | |||
public override void Init() | |||
{ | |||
mCUSerialHelper.Open(communicationPar.SerialPort, communicationPar.BaudRate); | |||
EventBus.EventBus.GetInstance().Subscribe<ReadMcu>(DeviceId, delegate (IEvent @event, EventCallBackHandle callBack) | |||
{ | |||
if (@event == null) return; | |||
var par = @event as ReadMcu; | |||
if (status != null) | |||
{ | |||
SetStatus(par?.TagName, mCUSerialHelper.GetInputStatus(Convert.ToByte(par?.ReadPar))); | |||
} | |||
}); | |||
EventBus.EventBus.GetInstance().Subscribe<WriteMcu>(DeviceId, delegate (IEvent @event, EventCallBackHandle callBack) | |||
{ | |||
if (@event == null) return; | |||
var par = @event as WriteMcu; | |||
switch (par?.TagName) | |||
{ | |||
case "OutputControl": | |||
mCUSerialHelper.OutputControl(Convert.ToByte(par?.Address), Convert.ToBoolean(par?.Value)); | |||
break; | |||
case "ServoControl": | |||
mCUSerialHelper.ServoControl(Convert.ToByte(par?.Address), Convert.ToByte(par?.Value)); | |||
break; | |||
default: | |||
break; | |||
} | |||
}); | |||
} | |||
//public override void ReadData(string address) | |||
//{ | |||
//} | |||
public override void Start() | |||
{ | |||
} | |||
public override void Stop() | |||
{ | |||
} | |||
public override void WriteData(string address, object value) | |||
{ | |||
} | |||
protected override void InitStatus() | |||
{ | |||
} | |||
} | |||
} |
@@ -48,11 +48,15 @@ namespace BPASmartClient.PLC | |||
{ | |||
if (@event == null) return; | |||
var par = @event as WriteModel; | |||
modbusTcp.Write(par?.Address, par?.Value); | |||
}); | |||
} | |||
//public override void ReadData(string address) | |||
//{ | |||
//} | |||
public override void Start() | |||
{ | |||
@@ -63,6 +67,12 @@ namespace BPASmartClient.PLC | |||
} | |||
public override void WriteData(string address, object value) | |||
{ | |||
if (address != null && value != null) | |||
modbusTcp.Write(address, value); | |||
} | |||
protected override void InitStatus() | |||
{ | |||
@@ -1,4 +1,4 @@ | |||
<Project Sdk="Microsoft.NET.Sdk"> | |||
<Project Sdk="Microsoft.NET.Sdk"> | |||
<PropertyGroup> | |||
<TargetFramework>net6.0</TargetFramework> | |||
@@ -9,6 +9,7 @@ | |||
</ItemGroup> | |||
<ItemGroup> | |||
<ProjectReference Include="..\BPASmartClient.Helper\BPASmartClient.Helper.csproj" /> | |||
<ProjectReference Include="..\BPASmartClient.Message\BPASmartClient.Message.csproj" /> | |||
</ItemGroup> | |||
@@ -0,0 +1,211 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace BPASmartClient.Modbus | |||
{ | |||
public class MODBUS | |||
{ | |||
/// <summary> | |||
/// 赋值string | |||
/// </summary> | |||
/// <param name="src"></param> | |||
/// <param name="start"></param> | |||
/// <param name="value"></param> | |||
/// <returns></returns> | |||
public static void SetString(ushort[] src, int start, string value) | |||
{ | |||
byte[] bytesTemp = Encoding.UTF8.GetBytes(value); | |||
ushort[] dest = Bytes2Ushorts(bytesTemp); | |||
dest.CopyTo(src, start); | |||
} | |||
/// <summary> | |||
/// 获取string | |||
/// </summary> | |||
/// <param name="src"></param> | |||
/// <param name="start"></param> | |||
/// <param name="len"></param> | |||
/// <returns></returns> | |||
public static string GetString(ushort[] src, int start, int len) | |||
{ | |||
ushort[] temp = new ushort[len]; | |||
for (int i = 0; i < len; i++) | |||
{ | |||
temp[i] = src[i + start]; | |||
} | |||
byte[] bytesTemp = Ushorts2Bytes(temp); | |||
string res = Encoding.UTF8.GetString(bytesTemp).Trim(new char[] { '\0' }); | |||
return res; | |||
} | |||
/// <summary> | |||
/// 赋值Real类型数据 | |||
/// </summary> | |||
/// <param name="src"></param> | |||
/// <param name="start"></param> | |||
/// <param name="value"></param> | |||
public static void SetReal(ushort[] src, int start, float value) | |||
{ | |||
byte[] bytes = BitConverter.GetBytes(value); | |||
ushort[] dest = Bytes2Ushorts(bytes); | |||
dest.CopyTo(src, start); | |||
} | |||
/// <summary> | |||
/// 获取float类型数据 | |||
/// </summary> | |||
/// <param name="src"></param> | |||
/// <param name="start"></param> | |||
/// <returns></returns> | |||
public static float GetReal(ushort[] src, int start) | |||
{ | |||
ushort[] temp = new ushort[2]; | |||
for (int i = 0; i < 2; i++) | |||
{ | |||
temp[i] = src[i + start]; | |||
} | |||
byte[] bytesTemp = Ushorts2Bytes(temp); | |||
float res = BitConverter.ToSingle(bytesTemp, 0); | |||
return res; | |||
} | |||
/// <summary> | |||
/// 赋值Short类型数据 | |||
/// </summary> | |||
/// <param name="src"></param> | |||
/// <param name="start"></param> | |||
/// <param name="value"></param> | |||
public static void SetShort(ushort[] src, int start, short value) | |||
{ | |||
byte[] bytes = BitConverter.GetBytes(value); | |||
ushort[] dest = Bytes2Ushorts(bytes); | |||
dest.CopyTo(src, start); | |||
} | |||
/// <summary> | |||
/// 获取short类型数据 | |||
/// </summary> | |||
/// <param name="src"></param> | |||
/// <param name="start"></param> | |||
/// <returns></returns> | |||
public static short GetShort(ushort[] src, int start) | |||
{ | |||
ushort[] temp = new ushort[1]; | |||
temp[0] = src[start]; | |||
byte[] bytesTemp = Ushorts2Bytes(temp); | |||
short res = BitConverter.ToInt16(bytesTemp, 0); | |||
return res; | |||
} | |||
public static bool[] GetBools(ushort[] src, int start, int num) | |||
{ | |||
ushort[] temp = new ushort[num]; | |||
for (int i = start; i < start + num; i++) | |||
{ | |||
temp[i] = src[i + start]; | |||
} | |||
byte[] bytes = Ushorts2Bytes(temp); | |||
bool[] res = Bytes2Bools(bytes); | |||
return res; | |||
} | |||
private static bool[] Bytes2Bools(byte[] b) | |||
{ | |||
bool[] array = new bool[8 * b.Length]; | |||
for (int i = 0; i < b.Length; i++) | |||
{ | |||
for (int j = 0; j < 8; j++) | |||
{ | |||
array[i * 8 + j] = (b[i] & 1) == 1;//判定byte的最后一位是否为1,若为1,则是true;否则是false | |||
b[i] = (byte)(b[i] >> 1);//将byte右移一位 | |||
} | |||
} | |||
return array; | |||
} | |||
private static byte Bools2Byte(bool[] array) | |||
{ | |||
if (array != null && array.Length > 0) | |||
{ | |||
byte b = 0; | |||
for (int i = 0; i < 8; i++) | |||
{ | |||
if (array[i]) | |||
{ | |||
byte nn = (byte)(1 << i);//左移一位,相当于×2 | |||
b += nn; | |||
} | |||
} | |||
return b; | |||
} | |||
return 0; | |||
} | |||
private static ushort[] Bytes2Ushorts(byte[] src, bool reverse = false) | |||
{ | |||
int len = src.Length; | |||
byte[] srcPlus = new byte[len + 1]; | |||
src.CopyTo(srcPlus, 0); | |||
int count = len >> 1; | |||
if (len % 2 != 0) | |||
{ | |||
count += 1; | |||
} | |||
ushort[] dest = new ushort[count]; | |||
if (reverse) | |||
{ | |||
for (int i = 0; i < count; i++) | |||
{ | |||
dest[i] = (ushort)(srcPlus[i * 2] << 8 | srcPlus[2 * i + 1] & 0xff); | |||
} | |||
} | |||
else | |||
{ | |||
for (int i = 0; i < count; i++) | |||
{ | |||
dest[i] = (ushort)(srcPlus[i * 2] & 0xff | srcPlus[2 * i + 1] << 8); | |||
} | |||
} | |||
return dest; | |||
} | |||
private static byte[] Ushorts2Bytes(ushort[] src, bool reverse = false) | |||
{ | |||
int count = src.Length; | |||
byte[] dest = new byte[count << 1]; | |||
if (reverse) | |||
{ | |||
for (int i = 0; i < count; i++) | |||
{ | |||
dest[i * 2] = (byte)(src[i] >> 8); | |||
dest[i * 2 + 1] = (byte)(src[i] >> 0); | |||
} | |||
} | |||
else | |||
{ | |||
for (int i = 0; i < count; i++) | |||
{ | |||
dest[i * 2] = (byte)(src[i] >> 0); | |||
dest[i * 2 + 1] = (byte)(src[i] >> 8); | |||
} | |||
} | |||
return dest; | |||
} | |||
} | |||
} |
@@ -1,9 +1,11 @@ | |||
using BPASmartClient.Message; | |||
using BPASmartClient.Helper; | |||
using BPASmartClient.Message; | |||
using NModbus; | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Net.Sockets; | |||
using System.Text; | |||
using System.Threading; | |||
using System.Threading.Tasks; | |||
@@ -107,28 +109,6 @@ namespace BPASmartClient.Modbus | |||
return -1; | |||
} | |||
//public void Readbool(ushort startAddress, ushort len, Action<bool[]> action) | |||
//{ | |||
// object result; | |||
// result = Read(startAddress, CommandType.Coils, len); | |||
// if (result != null) | |||
// { | |||
// if (result is bool[] bools) | |||
// { | |||
// if (bools.Length == len) | |||
// { | |||
// action(bools); | |||
// } | |||
// } | |||
// else if (result is bool bl) | |||
// { | |||
// List<bool> boolLists = new List<bool>(); | |||
// boolLists.Add(bl); | |||
// action(boolLists.ToArray()); | |||
// } | |||
// } | |||
//} | |||
public object Read(string address, ushort len = 1, byte slaveAddress = 1) | |||
{ | |||
if (address == null || tcpClient == null) return default(object); | |||
@@ -228,125 +208,65 @@ namespace BPASmartClient.Modbus | |||
} | |||
} | |||
//public object Read(ushort startAddress, CommandType readType, ushort num = 1, byte slaveAddress = 1) | |||
//{ | |||
// object result = new object(); | |||
// if (tcpClient == null) return result; | |||
// if (num <= 0) return result; | |||
// try | |||
// { | |||
// switch (readType) | |||
// { | |||
// case CommandType.Coils: | |||
// result = master.ReadCoils(slaveAddress, startAddress, num); | |||
// break; | |||
// case CommandType.Inputs: | |||
// result = master.ReadInputs(slaveAddress, startAddress, num); | |||
// break; | |||
// case CommandType.HoldingRegisters: | |||
// result = master.ReadHoldingRegisters(slaveAddress, startAddress, num); | |||
// break; | |||
// case CommandType.InputRegisters: | |||
// result = master.ReadInputRegisters(slaveAddress, startAddress, num); | |||
// break; | |||
// default: | |||
// break; | |||
// } | |||
// if (result == null) return new object(); | |||
// if (result is bool[] bools) | |||
// { | |||
// if (bools.Length == 1) | |||
// return bools[0]; | |||
// else | |||
// return bools; | |||
// } | |||
// if (result is ushort[] ushorts) | |||
// { | |||
// if (ushorts.Length == 1) | |||
// return ushorts[0]; | |||
// else | |||
// return ushorts; | |||
// } | |||
// } | |||
// catch (Exception ex) | |||
// { | |||
// MessageLog.GetInstance.ShowEx($"读取地址:【{startAddress}】,读取类型:【{readType}】出错,{ex.ToString()}"); | |||
// if (ex.InnerException is SocketException) | |||
// { | |||
// tcpClient = null; | |||
// Connect(); | |||
// } | |||
// } | |||
// return result; | |||
//} | |||
//public bool Write(ushort startAddress, CommandType writeType, object InputValue, byte slaveAddress = 1) | |||
//{ | |||
// bool result = false; | |||
// if (tcpClient == null) return result; | |||
// if (!(InputValue is bool || InputValue is bool[] || InputValue is ushort || InputValue is ushort[])) return result; | |||
// try | |||
// { | |||
// switch (writeType) | |||
// { | |||
// case CommandType.Coils: | |||
// if (InputValue is bool boolValue) | |||
// master.WriteSingleCoil(slaveAddress, startAddress, boolValue); | |||
// if (InputValue is bool[] boolsValue) | |||
// master.WriteMultipleCoils(slaveAddress, startAddress, boolsValue); | |||
// break; | |||
// case CommandType.HoldingRegisters: | |||
// if (InputValue is ushort ushortValue) | |||
// master.WriteSingleRegister(slaveAddress, startAddress, ushortValue); | |||
// if (InputValue is ushort[] ushortsValue) | |||
// { | |||
// int len = 100; | |||
// if (ushortsValue.Length > len) | |||
// { | |||
// List<ushort[]> ushortLists = new List<ushort[]>(); | |||
// for (int i = 0; i < ushortsValue.Length / len; i++) | |||
// { | |||
// ushortLists.Add(ushortsValue.Skip(0).Take(len).ToArray()); | |||
// } | |||
// int y = ushortsValue.Length % len; | |||
// if (y > 0) | |||
// { | |||
// ushortLists.Add(ushortsValue.Skip(ushortsValue.Length - y).Take(y).ToArray()); | |||
// } | |||
// foreach (var item in ushortLists) | |||
// { | |||
// master.WriteMultipleRegisters(slaveAddress, startAddress, item); | |||
// startAddress += (ushort)item.Length; | |||
// } | |||
// } | |||
// else | |||
// { | |||
// master.WriteMultipleRegisters(slaveAddress, startAddress, ushortsValue); | |||
// } | |||
// } | |||
// break; | |||
// default: | |||
// break; | |||
// } | |||
// } | |||
// catch (Exception ex) | |||
// { | |||
// MessageLog.GetInstance.ShowEx(ex.ToString()); | |||
// if (ex.InnerException is SocketException) | |||
// { | |||
// tcpClient = null; | |||
// Connect(); | |||
// } | |||
// return false; | |||
// } | |||
// return true; | |||
//} | |||
#region 字符串数据读写 | |||
/// <summary> | |||
/// 赋值string | |||
/// </summary> | |||
/// <param name="StartAddress"></param> | |||
/// <param name="value"></param> | |||
/// <returns></returns> | |||
public void SetString(string StartAddress, string value) | |||
{ | |||
var bytes = Encoding.UTF8.GetBytes(value); | |||
Write(StartAddress, bytes.BytesToUshorts()); | |||
} | |||
/// <summary> | |||
/// 获取string | |||
/// </summary> | |||
/// <param name="StartAddress"></param> | |||
/// <param name="len"></param> | |||
/// <returns></returns> | |||
public string GetString(string StartAddress, ushort len) | |||
{ | |||
var res = Read(StartAddress, len); | |||
if (res != null && res is ushort[] ushorts) | |||
{ | |||
return Encoding.UTF8.GetString(ushorts.UshortsToBytes()).Trim(new char[] { '\0' }); | |||
} | |||
return String.Empty; | |||
} | |||
#endregion | |||
#region 浮点数数据读写 | |||
/// <summary> | |||
/// 赋值Real类型数据 | |||
/// </summary> | |||
/// <param name="StartAddress"></param> | |||
/// <param name="value"></param> | |||
public void SetReal(string StartAddress, float value) | |||
{ | |||
var bytes = BitConverter.GetBytes(value); | |||
Write(StartAddress, bytes.BytesToUshorts()); | |||
} | |||
/// <summary> | |||
/// 获取float类型数据 | |||
/// </summary> | |||
/// <param name="StartAddress"></param> | |||
/// <returns></returns> | |||
public float GetReal(string StartAddress) | |||
{ | |||
var res = Read(StartAddress, 2); | |||
if (res != null && res is ushort[] ushorts) | |||
{ | |||
return BitConverter.ToSingle(ushorts.UshortsToBytes(), 0); | |||
} | |||
return 0; | |||
} | |||
#endregion | |||
#region 批量数据读取 | |||
/// <summary> | |||
@@ -11,6 +11,8 @@ namespace BPASmartClient.Model | |||
public class BaseEvent : IEvent | |||
{ | |||
public int DeviceId { get; set; } | |||
public string TagName { get; set; } | |||
public DeviceClientType deviceClientType { get; set; } | |||
} | |||
} |
@@ -8,7 +8,9 @@ namespace BPASmartClient.Model.PLC | |||
{ | |||
public class ReadModel : BaseEvent | |||
{ | |||
public string Address { get; set; } | |||
public ushort Length { get; set; } | |||
public object ReadPar { get; set; } | |||
} | |||
} |
@@ -1,4 +1,5 @@ | |||
using BPASmartClient.Model.单片机.Enum; | |||
using BPASmartClient.Model.PLC; | |||
using BPASmartClient.Model.单片机.Enum; | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
@@ -16,7 +17,7 @@ namespace BPASmartClient.Model.单片机 | |||
/// <summary> | |||
/// STM32F103RCT6单片机下杯 | |||
/// </summary> | |||
public class SCChip_TakeCupEvent :BaseEvent | |||
public class SCChip_TakeCupEvent : BaseEvent | |||
{ | |||
/// <summary> | |||
/// 杯 | |||
@@ -27,7 +28,7 @@ namespace BPASmartClient.Model.单片机 | |||
/// <summary> | |||
/// STM32F103RCT6单片机舵机打料 | |||
/// </summary> | |||
public class SCChip_MakeIceCreamEvent :BaseEvent | |||
public class SCChip_MakeIceCreamEvent : BaseEvent | |||
{ | |||
public IC_SE SteeringEngine { get; set; } | |||
} | |||
@@ -35,7 +36,7 @@ namespace BPASmartClient.Model.单片机 | |||
/// <summary> | |||
/// STM32F103RCT6单片机舵机打开或者关闭 | |||
/// </summary> | |||
public class SCChip_SESwitchCreamEvent :BaseEvent | |||
public class SCChip_SESwitchCreamEvent : BaseEvent | |||
{ | |||
public IC_SE SteeringEngine { get; set; } | |||
public bool IsOpen { get; set; } | |||
@@ -44,7 +45,7 @@ namespace BPASmartClient.Model.单片机 | |||
/// <summary> | |||
/// STM32F103RCT6单片机控制冰淇淋机器转 | |||
/// </summary> | |||
public class SCChip_RotorSwitchEvent :BaseEvent | |||
public class SCChip_RotorSwitchEvent : BaseEvent | |||
{ | |||
public bool TurnOn { get; set; } | |||
} | |||
@@ -62,4 +63,14 @@ namespace BPASmartClient.Model.单片机 | |||
{ | |||
} | |||
public class WriteMcu : WriteModel | |||
{ | |||
} | |||
public class ReadMcu : ReadModel | |||
{ | |||
} | |||
} |
@@ -0,0 +1,66 @@ | |||
using BPASmartClient.Model.PLC; | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace BPASmartClient.Model | |||
{ | |||
public class JuicerModel | |||
{ | |||
#region 果汁机设备MORKT2 Lebai机器人 | |||
public const int JUICE2_初始位 = 10021; | |||
public const int JUICE2_检测位回原点 = 10023; | |||
public const int JUICE2_取纸杯 = 10006; | |||
public const int JUICE2_二次取杯 = 10008; | |||
public const int JUICE2_纸杯检测 = 10007; | |||
public const int JUICE2_再检测 = 10024; | |||
public const int JUICE2_接咖啡 = 10009; | |||
public const int JUICE2_放咖啡杯 = 10010; | |||
public const int JUICE2_接茶叶 = 10017; | |||
public const int JUICE2_接茶水 = 10018; | |||
public const int JUICE2_接水 = 10020; | |||
public const int JUICE2_放水杯 = 10019; | |||
public const int JUICE2_接果汁公共位 = 10011; | |||
public const int JUICE2_接1号果汁 = 10012; | |||
public const int JUICE2_接2号果汁 = 10013; | |||
public const int JUICE2_接3号果汁 = 10014; | |||
public const int JUICE2_接4号果汁 = 10015; | |||
public const int JUICE2_放果汁杯 = 10016; | |||
#endregion | |||
#region 果汁机设备 MORKT1 JAKA机器人 | |||
public const int JUICE_初始位 = 20000; | |||
public const int JUICE_取杯 = 20001; | |||
public const int JUICE_取杯检测 = 20010; | |||
public const int JUICE_接咖啡 = 20020; | |||
public const int JUICE_接1号果汁 = 20030; | |||
public const int JUICE_接2号果汁 = 20040; | |||
public const int JUICE_接3号果汁 = 20050; | |||
public const int JUICE_接4号果汁 = 20060; | |||
public const int JUICE_接茶 = 20070; | |||
public const int JUICE_接茶水 = 20075; | |||
public const int JUICE_接水 = 20080; | |||
public const int JUICE_放咖啡杯 = 20090; | |||
public const int JUICE_放果汁杯 = 20100; | |||
public const int JUICE_放茶水杯 = 20110; | |||
public const int JUICE_放杯 = 20120; | |||
public const int JUICE_放杯检测 = 20120; | |||
#endregion | |||
} | |||
public class WriteJuicer : WriteModel | |||
{ | |||
} | |||
public class ReadJuicer : ReadModel | |||
{ | |||
} | |||
} |
@@ -0,0 +1,51 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace BPASmartClient.Model | |||
{ | |||
public class JakaModel | |||
{ | |||
public const string SENCE_取杯 = "10000"; | |||
public const string SENCE_放杯位检测 = "10100"; | |||
public const string SENCE_取杯检测 = "11000"; | |||
public const string SENCE_接咖啡 = "12000"; | |||
public const string SENCE_接果汁1 = "12001"; | |||
public const string SENCE_接果汁2 = "12002"; | |||
public const string SENCE_接果汁3 = "12003"; | |||
public const string SENCE_接果汁4 = "12004"; | |||
public const string SENCE_接茶 = "12005"; | |||
public const string SENCE_接水 = "12006"; | |||
public const string SENCE_接茶_接水 = "12007"; | |||
public const string SENCE_放咖啡杯 = "13000";//接饮料位---放饮料过渡位 | |||
public const string SENCE_放果汁杯1 = "13001"; | |||
public const string SENCE_放果汁杯2 = "13002"; | |||
public const string SENCE_放果汁杯3 = "13003"; | |||
public const string SENCE_放果汁杯4 = "13004"; | |||
public const string SENCE_放茶水杯 = "13005"; | |||
public const string SENCE_放杯 = "14000";//放杯过渡位到-放杯 | |||
public const string SENCE_放杯检测 = "15000"; | |||
public const string SENCE_初始位 = "20000"; | |||
} | |||
public class WriteJaka : BaseEvent | |||
{ | |||
public string Address { get; set; } | |||
public object Value { get; set; } | |||
} | |||
public class ReadJaka : BaseEvent | |||
{ | |||
public string Address { get; set; } | |||
public ushort Length { get; set; } | |||
public object ReadPar { get; set; } | |||
} | |||
} | |||
@@ -17,6 +17,7 @@ using System.Reflection; | |||
using BPASmartClient.MorkS.Model; | |||
using System.Collections.ObjectModel; | |||
using BPASmartClient.MorkS.ViewModel; | |||
using BPASmartClient.Business; | |||
namespace BPASmartClient.MorkS | |||
{ | |||
@@ -287,8 +288,6 @@ namespace BPASmartClient.MorkS | |||
else | |||
IsHealth = true; | |||
//if (mORKS.AllowRun) | |||
//{ | |||
TakeBowlTask(); | |||
TakeNoodleTask(); | |||
@@ -298,7 +297,15 @@ namespace BPASmartClient.MorkS | |||
SingleDetect(); | |||
TurntableControl(); | |||
//} | |||
var data = new List<bool>(); | |||
for (int i = 0; i < Json<MorksPar>.Data.parSets.Count; i++) | |||
{ | |||
data.Add(Json<MorksPar>.Data.parSets.ElementAt(i).IsShield); | |||
} | |||
WriteControl("M260.0", data.ToArray()); | |||
} | |||
private void BowlControl(OrderLocInfo orderLocInfo) | |||
@@ -400,6 +407,11 @@ namespace BPASmartClient.MorkS | |||
{ | |||
if (mORKS.TurntableFeedbackloc != loc && !mORKS.TurntableLocLists.Contains(loc)) | |||
{ | |||
if (!mORKS.TurntableLowerLimit) | |||
{ | |||
WriteData("M32.7", false); | |||
DeviceProcessLogShow($"执行了转台启动互锁信号复位"); | |||
} | |||
TurntableStart(loc); | |||
DeviceProcessLogShow($"没有物料检测的启动转台控制,转台位置:[{loc}]"); | |||
break; | |||
@@ -414,6 +426,15 @@ namespace BPASmartClient.MorkS | |||
} | |||
} | |||
//if (DelayRTrig.GetInstance("互锁信号复位").Start(!mORKS.TurntableLowerLimit && mORKS.TurntableMoveInPlace, 2)) | |||
//{ | |||
// if (!mORKS.TurntableLowerLimit) | |||
// { | |||
// WriteData("M32.7", false); | |||
// DeviceProcessLogShow($"执行了转台启动互锁信号复位"); | |||
// } | |||
//} | |||
//补料中检测 | |||
if (RTrig.GetInstance("mORKS.Feeding").Start(mORKS.Feeding)) | |||
{ | |||
@@ -488,6 +509,17 @@ namespace BPASmartClient.MorkS | |||
RobotOutMeal(); | |||
CookNoodleStatusReset((ushort)(loc + 1)); | |||
ResetAllowFallNoodle(); | |||
//新增,待测试 | |||
if (mORKS.RbOutMealComplete) | |||
{ | |||
ResetCookComplete(); | |||
mORKS.CookCompleteFlatBit = false; | |||
DeviceProcessLogShow("取餐过程中复位出餐完成信号"); | |||
} | |||
mORKS.OutMealId = mORKS.IngredientsCompleteId; | |||
mORKS.IngredientsCompleteId = string.Empty; | |||
mORKS.CookNodelId[loc] = string.Empty; | |||
@@ -522,7 +554,7 @@ namespace BPASmartClient.MorkS | |||
} | |||
//取餐完成逻辑处理 | |||
if (Delay.GetInstance("CompleteChange1").Start(mORKS.CookCompleteFlatBit && !mORKS.TakeMealDetect, 2)) | |||
if (Delay.GetInstance("CompleteChange1").Start(mORKS.CookCompleteFlatBit && !mORKS.TakeMealDetect, 1)) | |||
{ | |||
OrderChange(mORKS.OutMealId, ORDER_STATUS.COMPLETED_TAKE); | |||
DeviceProcessLogShow($"订单【{mORKS.OutMealId}】取餐完成"); | |||
@@ -531,15 +563,6 @@ namespace BPASmartClient.MorkS | |||
mORKS.OutMealId = string.Empty; | |||
} | |||
//if (DelayRTrig.GetInstance("CompleteChange1").Start(mORKS.CookCompleteFlatBit && !mORKS.TakeMealDetect, 2)) | |||
//{ | |||
// OrderChange(mORKS.OutMealId, ORDER_STATUS.COMPLETED_TAKE); | |||
// DeviceProcessLogShow($"订单【{mORKS.OutMealId}】取餐完成"); | |||
// ResetCookComplete(); | |||
// mORKS.CookCompleteFlatBit = false; | |||
// mORKS.OutMealId = string.Empty; | |||
//} | |||
//机器人取面完成信号检测 | |||
if (RTrig.GetInstance("TakeNoodleComplete").Start(mORKS.RbTakeNoodleComplete)) | |||
{ | |||
@@ -552,7 +575,11 @@ namespace BPASmartClient.MorkS | |||
int OutMealRequstCount = mORKS.CookNoodlesComplete.Where(p => p == true).ToList().Count; | |||
int mlCount = mORKS.NoodleCookerStatus.Where(p => p == true).ToList().Count; | |||
mORKS.RobotTaskInterlock = OutMealRequstCount > 0 && mORKS.AllowFallNoodle && (mlCount >= 2 || mORKS.RBTakeNoodleTask.Count == 0); | |||
mORKS.PriorityJudgment = Delay.GetInstance("取餐优先级判断").Start(mORKS.TurntableLocLists.Count > 0 && !mORKS.TurntableLowerLimit, 4); | |||
mORKS.RobotTaskInterlock = OutMealRequstCount > 0 && mORKS.AllowFallNoodle && (mlCount >= 2 || mORKS.RBTakeNoodleTask.Count == 0 || mORKS.PriorityJudgment); | |||
} | |||
@@ -42,7 +42,13 @@ namespace BPASmartClient.MorkS | |||
public bool AllowRun { get; set; } | |||
/// <summary> | |||
/// //机器人任务互锁信号 | |||
/// 优先级判断 | |||
/// </summary> | |||
[VariableMonitor("优先级判断条件")] | |||
public bool PriorityJudgment { get; set; } | |||
/// <summary> | |||
/// 机器人任务互锁信号,false:取面,true:出餐 | |||
/// </summary> | |||
//[Circuit(new string[] { "机器人取面", "出面控制" }, "机器人互锁", new bool[] { true, false })] | |||
[VariableMonitor("机器人任务互锁信号")] | |||
@@ -6,4 +6,8 @@ | |||
<UseWPF>true</UseWPF> | |||
</PropertyGroup> | |||
<ItemGroup> | |||
<ProjectReference Include="..\BPASmartClient.Device\BPASmartClient.Device.csproj" /> | |||
</ItemGroup> | |||
</Project> |
@@ -1,8 +0,0 @@ | |||
using System; | |||
namespace BPASmartClient.MorkT.Lebai.JC | |||
{ | |||
public class Class1 | |||
{ | |||
} | |||
} |
@@ -0,0 +1,865 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Configuration; | |||
using System.Linq; | |||
using System.Threading; | |||
using System.Collections.Concurrent; | |||
using System.Diagnostics; | |||
using System.Threading.Tasks; | |||
using BPASmartClient.Device; | |||
using BPA.Message.Enum; | |||
using BPA.Message; | |||
using BPASmartClient.Helper; | |||
using BPASmartClient.Model.咖啡机.Enum; | |||
using BPASmartClient.Model; | |||
using BPASmartClient.EventBus; | |||
using static BPASmartClient.EventBus.EventBus; | |||
using BPASmartClient.Message; | |||
using BPASmartClient.Model.乐白机器人; | |||
using BPASmartClient.Model.单片机; | |||
namespace BPASmartClient.MorkTLebaiJC | |||
{ | |||
/* | |||
* 冰淇淋咖啡机组合套装 | |||
* 物料位置: | |||
* 1:冰淇料 | |||
* 2:冰淇淋杯 | |||
* 5:咖啡 | |||
* 6:咖啡杯 | |||
* 9: 茶 | |||
* 10: 茶杯 | |||
*/ | |||
public class Control_MORKJC2 : BaseDevice | |||
{ | |||
//private CoffeEndCook coffeEndCook = new CoffeEndCook();//模拟咖啡制作成功 | |||
//咖啡机主控程序 | |||
//private CoffeeMachine coffeeMachine; | |||
//物料存放位置 | |||
private Dictionary<string, PolymerBatching> batchings = new Dictionary<string, PolymerBatching>(); | |||
//容器位置 | |||
private string holderLoc; | |||
/// <summary> | |||
/// 获取乐百机器人的数据 | |||
/// </summary> | |||
//SignalResult lebai = new SignalResult(); | |||
//主料位置 | |||
private string mainMaterialLoc; | |||
//子订单ID | |||
private string subOrderId; | |||
private bool enableFunny = false; | |||
private DateTime lastRecvdOrder = DateTime.Now; | |||
private bool working = false; | |||
/// <summary> | |||
/// 果汁机做法,true:热饮,false:冷饮 | |||
/// </summary> | |||
private bool GuMake = false; | |||
//private SerialPortClient commProxy; | |||
public void ConnectOk() | |||
{ | |||
} | |||
ConcurrentQueue<MorkOrderPush> morkOrderPushes = new ConcurrentQueue<MorkOrderPush>(); | |||
public void Init() | |||
{ | |||
//ActionManage.GetInstance.Register(new Action<object>((s) => | |||
//{ | |||
// if (s is DrCoffeeDrinksCode cf) | |||
// { | |||
// DoCoffee(); | |||
// } | |||
// else if (s is Dictionary<string, string> ms) | |||
// { | |||
// if (ms.ContainsKey("Button")) | |||
// { | |||
// switch (ms["Button"]) | |||
// { | |||
// case "启动示教": | |||
// JuicerModel.GetInstance.StartTeachMode(); | |||
// break; | |||
// case "停止示教": | |||
// JuicerModel.GetInstance.EndtTeachMode(); | |||
// break; | |||
// case "启动机器人": | |||
// JuicerModel.GetInstance.StartRobot(); | |||
// break; | |||
// case "急停": | |||
// JuicerModel.GetInstance.EStopRobot(); | |||
// break; | |||
// default: | |||
// break; | |||
// } | |||
// } | |||
// } | |||
//}), "SimCoffee"); | |||
//构建所有商品物料信息 | |||
batchings = PolymerBatching.BuildAll(); | |||
EventBus.EventBus.GetInstance().Subscribe<DRCoffee_CoffeEndCookEvent>(DeviceId, CoffeEndCookHandle); | |||
System.Configuration.Configuration config = System.Configuration.ConfigurationManager.OpenExeConfiguration(System.Configuration.ConfigurationUserLevel.None); | |||
//一系列外围基础配置 | |||
var com_Coffee = config.AppSettings.Settings["COM_Coffee"].Value; | |||
var baud_Coffee = config.AppSettings.Settings["BAUD_Coffee"].Value; | |||
//咖啡机创建 | |||
//coffeeMachine = new CoffeeMachine(com_Coffee, (BaudRates)Enum.Parse(typeof(BaudRates), baud_Coffee)); | |||
Main(); | |||
ReadData(); | |||
ThreadManage.GetInstance().StartLong(new Action(() => | |||
{ | |||
while (IsHealth && (morkOrderPushes.Count > 0)) | |||
{ | |||
working = true; | |||
if (morkOrderPushes.TryDequeue(out MorkOrderPush order)) | |||
{ | |||
MessageLog.GetInstance.Show($"开始制作订单[{order.SortNum}]"); | |||
//商品类型 | |||
GOODS_TYPE currentGoodsType = GOODS_TYPE.NEITHER; | |||
//子订单ID | |||
subOrderId = order.SuborderId; | |||
//遍历物料 | |||
foreach (var item in order.GoodBatchings) | |||
{ | |||
var res = Json<BatchingInfoPar>.Data.orderMaterialDelivery.BatchingInfo.FirstOrDefault(p => p.BatchingId == item.BatchingId); | |||
if (res != null) | |||
{ | |||
//获取主料和容器位置 | |||
switch (batchings[res.BatchingLoc].BatchingClass) | |||
{ | |||
case BATCHING_CLASS.HOLDER: | |||
holderLoc = res.BatchingLoc; | |||
break; | |||
case BATCHING_CLASS.MAIN_MATERIAL: | |||
// mainMaterialLoc ="1"; | |||
mainMaterialLoc = res.BatchingLoc; | |||
//验证商品是咖啡还是冰淇淋 | |||
if (ValidateGoodsByBatching(res.BatchingLoc) != GOODS_TYPE.NEITHER) | |||
{ | |||
//获取当前物料所属商品类型 | |||
currentGoodsType = ValidateGoodsByBatching(res.BatchingLoc); | |||
} | |||
break; | |||
} | |||
} | |||
} | |||
//根据商品类型执行具体制作流程 | |||
switch (currentGoodsType) | |||
{ | |||
case GOODS_TYPE.COFFEE: | |||
DoCoffee(); | |||
break; | |||
case GOODS_TYPE.JUICE: | |||
GuMake = order.MakeID == "2"; | |||
DoJuicer(); | |||
break; | |||
case GOODS_TYPE.TEA: | |||
DoTea(); | |||
break; | |||
case GOODS_TYPE.WATER: | |||
DoWater(); | |||
break; | |||
case GOODS_TYPE.NEITHER: | |||
MessageLog.GetInstance.Show("未知的商品类型"); | |||
break; | |||
} | |||
} | |||
working = false; | |||
lastRecvdOrder = DateTime.Now; | |||
} | |||
Thread.Sleep(1000); | |||
}), "订单制作"); | |||
} | |||
public void Main() | |||
{ | |||
//咖啡机开启主线程 | |||
//coffeeMachine.Start(); | |||
//开始心跳刷新,根据咖啡机及冰淇淋机来判断 | |||
ThreadManage.GetInstance().StartLong(new Action(() => | |||
{ | |||
//GeneralConfig.Healthy = | |||
// JuicerModel.GetInstance.IsConnected && | |||
// MorkCStatus.GetInstance().CanDo && | |||
// JuicerHelper.GetInstance.IsOpen && | |||
// MCUSerialHelper.GetInstance.IsOpen; | |||
//GeneralConfig.Healthy = true; | |||
Thread.Sleep(100); | |||
}), "MORK-IC心跳刷新"); | |||
//ThreadManage.GetInstance.Start(new Action(() => | |||
//{ | |||
// while (!JuicerModel.GetInstance.IsConnected) | |||
// { | |||
// Thread.Sleep(10); | |||
// } | |||
// //Sence(JuicerModel.SENCE_欢迎); | |||
//}), "MORK-JC欢迎"); | |||
} | |||
private void OrderChange(string subid, ORDER_STATUS oRDER_STATUS) | |||
{ | |||
EventBus.EventBus.GetInstance().Publish(new OrderStatusChangedEvent() { Status = oRDER_STATUS, SubOrderId = subid, deviceClientType = DeviceType }); | |||
} | |||
public void DataParse<T>(T order) | |||
{ | |||
if (order is MorkOrderPush morkOrderPush) | |||
{ | |||
morkOrderPushes.Enqueue(morkOrderPush); | |||
} | |||
} | |||
/// <summary> | |||
/// 验证当前是做咖啡还是做冰淇淋 | |||
/// </summary> | |||
/// <param name="batchingLoc">物料位置</param> | |||
private GOODS_TYPE ValidateGoodsByBatching(string batchingLoc) | |||
{ | |||
if (batchings.ContainsKey(batchingLoc)) | |||
return batchings[batchingLoc].GoodsType; | |||
return GOODS_TYPE.NEITHER; | |||
} | |||
private AutoResetEvent are = new AutoResetEvent(false); | |||
private void Wait(int value = 101) | |||
{ | |||
while (!((bool)peripheralStatus["RobotOK"] && (int)peripheralStatus["RobotValue"] == value)) | |||
{ | |||
Thread.Sleep(5); | |||
} | |||
new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 0 }.Publish(); | |||
} | |||
private void Sence(int sen) | |||
{ | |||
new LebaiRobot_LebaiSenceEvent { DeviceId = DeviceId, LebaiSence = sen }.Publish(); | |||
} | |||
private T GetStatus<T>(string key) | |||
{ | |||
if (peripheralStatus.ContainsKey(key)) | |||
{ | |||
if (peripheralStatus[key] != null) | |||
{ | |||
return (T)(peripheralStatus[key]); | |||
} | |||
} | |||
return default; | |||
} | |||
int[] devStatusBy = new int[2] { 0, 0 }; | |||
bool outCupCheck = false;//放纸杯位置有无判断 | |||
/// <summary> | |||
/// 传感器的输入信号 0:无意义 1:有信号 2:无信号 3:信号不正确 | |||
/// </summary> | |||
int bSensorInput; | |||
/// <summary> | |||
/// 延迟的超时时间 | |||
/// </summary> | |||
DateTime delayTimeOut; | |||
/// <summary> | |||
/// 做咖啡 | |||
/// </summary> | |||
private void DoCoffee() | |||
{ | |||
#region 接咖啡流程 | |||
are.Reset(); | |||
while (GetStatus<bool>("RobotValue1"))//判断放杯位置是否有物品 | |||
{ | |||
if (!outCupCheck) | |||
MessageLog.GetInstance.ShowEx("成品处有纸杯存在,请取走!!"); | |||
outCupCheck = true; | |||
} | |||
outCupCheck = false; | |||
OrderChange(subOrderId, BPA.Message.Enum.ORDER_STATUS.COOKING); | |||
int resultTakeCup = takeCup(); | |||
if (resultTakeCup == 1) | |||
{ | |||
MessageLog.GetInstance.Show("咖啡杯取杯完成"); | |||
new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 0 }.Publish(); | |||
Sence(JuicerModel.JUICE2_接咖啡); | |||
Wait(); | |||
new DRCoffee_MakeCoffeeEvent() { DrinkCode = (DrCoffeeDrinksCode)int.Parse(mainMaterialLoc) }.Publish(); //接咖啡控制 //DrCoffeeDrinksCode.热水 | |||
//Task.Delay(10000).Wait();//模拟接咖啡 | |||
//coffeEndCook.Publish();//模拟咖啡制作完成 | |||
are.WaitOne(1000 * 360); | |||
while (GetStatus<bool>("RobotValue1"))//判断放杯位置是否有物品 | |||
{ | |||
if (!outCupCheck) | |||
MessageLog.GetInstance.ShowEx("成品处有纸杯存在,请取走!!"); | |||
outCupCheck = true; | |||
} | |||
outCupCheck = false; | |||
while (GetStatus<bool>("RobotValue1"))//判断放杯位置是否有物品 | |||
{ | |||
if (!outCupCheck) | |||
MessageLog.GetInstance.ShowEx("成品处有纸杯存在,请取走!!"); | |||
outCupCheck = true; | |||
} | |||
outCupCheck = false; | |||
new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 0 }.Publish(); | |||
Sence(JuicerModel.JUICE2_放咖啡杯); | |||
Wait(); | |||
OrderChange(subOrderId, BPA.Message.Enum.ORDER_STATUS.COMPLETED_TAKE); | |||
MessageLog.GetInstance.Show("咖啡制作完成"); | |||
} | |||
else | |||
{ | |||
return; | |||
} | |||
#endregion | |||
} | |||
/// <summary> | |||
/// 做茶 | |||
/// </summary> | |||
private void DoTea() | |||
{ | |||
#region 接茶流程 | |||
while (GetStatus<bool>("RobotValue1"))//判断放杯位置是否有物品 | |||
{ | |||
if (!outCupCheck) | |||
MessageLog.GetInstance.ShowEx("成品处有纸杯存在,请取走!!"); | |||
outCupCheck = true; | |||
} | |||
outCupCheck = false; | |||
OrderChange(subOrderId, BPA.Message.Enum.ORDER_STATUS.COOKING); | |||
int resultTakeCup = takeCup(); | |||
if (resultTakeCup == 1) | |||
{ | |||
MessageLog.GetInstance.Show("取茶杯完成"); | |||
new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 0 }.Publish(); | |||
Sence(JuicerModel.JUICE2_接茶叶); | |||
Wait(); | |||
new WriteMcu() { TagName = "ServoControl", Address = "1", Value = 90 }.Publish(); | |||
Thread.Sleep(1000); | |||
new WriteMcu() { TagName = "ServoControl", Address = "1", Value = 150 }.Publish(); | |||
Thread.Sleep(1000); | |||
new WriteMcu() { TagName = "ServoControl", Address = "1", Value = 90 }.Publish(); | |||
Thread.Sleep(3000); | |||
new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 0 }.Publish(); | |||
Sence(JuicerModel.JUICE2_接茶水); | |||
Wait(); | |||
new WriteMcu() { TagName = "OutputControl", Address = "1", Value = false }.Publish(); | |||
new WriteMcu() { TagName = "OutputControl", Address = "0", Value = false }.Publish(); | |||
Thread.Sleep(100); | |||
new WriteMcu() { TagName = "OutputControl", Address = "0", Value = true }.Publish(); | |||
Thread.Sleep(3000); | |||
new WriteMcu() { TagName = "OutputControl", Address = "0", Value = false }.Publish(); | |||
Thread.Sleep(100); | |||
new WriteMcu() { TagName = "OutputControl", Address = "1", Value = false }.Publish(); | |||
Thread.Sleep(100); | |||
new WriteMcu() { TagName = "OutputControl", Address = "1", Value = true }.Publish(); | |||
Thread.Sleep(500); | |||
new WriteMcu() { TagName = "OutputControl", Address = "1", Value = false }.Publish(); | |||
Thread.Sleep(46000); | |||
while (GetStatus<bool>("RobotValue1"))//判断放杯位置是否有物品 | |||
{ | |||
if (!outCupCheck) | |||
MessageLog.GetInstance.ShowEx("成品处有纸杯存在,请取走!!"); | |||
outCupCheck = true; | |||
} | |||
outCupCheck = false; | |||
new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 0 }.Publish(); | |||
Sence(JuicerModel.JUICE2_放水杯); | |||
Wait(); | |||
OrderChange(subOrderId, BPA.Message.Enum.ORDER_STATUS.COMPLETED_TAKE); | |||
MessageLog.GetInstance.Show("茶水制作完成"); | |||
} | |||
else | |||
{ | |||
return; | |||
} | |||
#endregion | |||
} | |||
/// <summary> | |||
/// 接开水 | |||
/// </summary> | |||
private void DoWater() | |||
{ | |||
#region 接水流程 | |||
while (GetStatus<bool>("RobotValue1"))//判断放杯位置是否有物品 | |||
{ | |||
if (!outCupCheck) | |||
MessageLog.GetInstance.ShowEx("成品处有纸杯存在,请取走!!"); | |||
outCupCheck = true; | |||
} | |||
outCupCheck = false; | |||
OrderChange(subOrderId, BPA.Message.Enum.ORDER_STATUS.COOKING); | |||
int resultTakeCup = takeCup(); | |||
if (resultTakeCup == 1) | |||
{ | |||
new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 0 }.Publish(); | |||
Sence(JuicerModel.JUICE2_接水); | |||
Wait(); | |||
new WriteMcu() { TagName = "OutputControl", Address = "1", Value = false }.Publish(); | |||
new WriteMcu() { TagName = "OutputControl", Address = "0", Value = false }.Publish(); | |||
Thread.Sleep(100); | |||
new WriteMcu() { TagName = "OutputControl", Address = "0", Value = true }.Publish(); | |||
Thread.Sleep(3000); | |||
new WriteMcu() { TagName = "OutputControl", Address = "0", Value = false }.Publish(); | |||
Thread.Sleep(100); | |||
new WriteMcu() { TagName = "OutputControl", Address = "1", Value = false }.Publish(); | |||
Thread.Sleep(100); | |||
new WriteMcu() { TagName = "OutputControl", Address = "1", Value = true }.Publish(); | |||
Thread.Sleep(500); | |||
new WriteMcu() { TagName = "OutputControl", Address = "1", Value = false }.Publish(); | |||
Thread.Sleep(46000); | |||
while (GetStatus<bool>("RobotValue1"))//判断放杯位置是否有物品 | |||
{ | |||
if (!outCupCheck) | |||
MessageLog.GetInstance.ShowEx("成品处有纸杯存在,请取走!!"); | |||
outCupCheck = true; | |||
} | |||
outCupCheck = false; | |||
//添加控制接水机构程序 | |||
new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 0 }.Publish(); | |||
Sence(JuicerModel.JUICE2_放水杯); | |||
Wait(); | |||
OrderChange(subOrderId, BPA.Message.Enum.ORDER_STATUS.COMPLETED_TAKE); | |||
MessageLog.GetInstance.Show("纯净水制作完成"); | |||
} | |||
else | |||
{ | |||
return; | |||
} | |||
#endregion | |||
} | |||
/// <summary> | |||
/// 果汁机控制信号 | |||
/// </summary> | |||
private byte JuicerNum; | |||
/// <summary> | |||
/// 做果汁 | |||
/// </summary> | |||
private void DoJuicer() | |||
{ | |||
#region 接果汁流程 | |||
are.Reset(); | |||
while (GetStatus<bool>("RobotValue1"))//判断放杯位置是否有物品 | |||
{ | |||
if (!outCupCheck) | |||
MessageLog.GetInstance.ShowEx("成品处有纸杯存在,请取走!!"); | |||
outCupCheck = true; | |||
} | |||
OrderChange(subOrderId, BPA.Message.Enum.ORDER_STATUS.COOKING); | |||
int resultTakeCup = takeCup(); | |||
if (resultTakeCup == 1) | |||
{ | |||
int JuicerNum1 = int.Parse(mainMaterialLoc); | |||
switch (JuicerNum1) | |||
{ | |||
case 52: | |||
if (GuMake) | |||
{ | |||
JuicerNum = 0x00; | |||
} | |||
else | |||
{ | |||
JuicerNum = 0x01; | |||
} | |||
new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 0 }.Publish(); | |||
Sence(JuicerModel.JUICE2_接果汁公共位); | |||
Wait(); | |||
new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 0 }.Publish(); | |||
Sence(JuicerModel.JUICE2_接1号果汁); | |||
Wait(); | |||
break; | |||
case 53: | |||
if (GuMake) | |||
{ | |||
JuicerNum = 0x02; | |||
} | |||
else | |||
{ | |||
JuicerNum = 0x03; | |||
} | |||
new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 0 }.Publish(); | |||
Sence(JuicerModel.JUICE2_接果汁公共位); | |||
Wait(); | |||
new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 0 }.Publish(); | |||
Sence(JuicerModel.JUICE2_接2号果汁); | |||
Wait(); | |||
break; | |||
case 54: | |||
if (GuMake) | |||
{ | |||
JuicerNum = 0x04; | |||
} | |||
else | |||
{ | |||
JuicerNum = 0x05; | |||
} | |||
new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 0 }.Publish(); | |||
Sence(JuicerModel.JUICE2_接果汁公共位); | |||
Wait(); | |||
new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 0 }.Publish(); | |||
Sence(JuicerModel.JUICE2_接3号果汁); | |||
Wait(); | |||
break; | |||
case 55: | |||
if (GuMake) | |||
{ | |||
JuicerNum = 0x06; | |||
} | |||
else | |||
{ | |||
JuicerNum = 0x07; | |||
} | |||
new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 0 }.Publish(); | |||
Sence(JuicerModel.JUICE2_接果汁公共位); | |||
Wait(); | |||
new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 0 }.Publish(); | |||
Sence(JuicerModel.JUICE2_接4号果汁); ; | |||
Wait(); | |||
break; | |||
default: | |||
JuicerNum = 0x00; | |||
new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 0 }.Publish(); | |||
Sence(JuicerModel.JUICE2_接果汁公共位); | |||
Wait(); | |||
new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 0 }.Publish(); | |||
Sence(JuicerModel.JUICE_接1号果汁); | |||
Wait(); | |||
break; | |||
} | |||
var devStatus = GetStatus<int[]>("GetDeviceStatus"); | |||
var devStatus1 = Convert.ToString(devStatus[0], 2); | |||
var devStatus2 = devStatus[1]; | |||
if (devStatus1.IndexOf("0") == 1 && devStatus2 == 0) | |||
{ | |||
new WriteJuicer() { Value = JuicerNum }.Publish(); | |||
Thread.Sleep(100); | |||
devStatusBy = GetStatus<int[]>("GetDeviceStatus"); | |||
while (!(devStatusBy[1] == 0)) | |||
{ | |||
Thread.Sleep(100); | |||
devStatusBy = GetStatus<int[]>("GetDeviceStatus"); | |||
while (devStatusBy.Length != 2) | |||
{ | |||
Thread.Sleep(100); | |||
devStatusBy = GetStatus<int[]>("GetDeviceStatus"); | |||
} | |||
} | |||
devStatusBy = GetStatus<int[]>("GetDeviceStatus"); | |||
Thread.Sleep(5000); | |||
while (GetStatus<bool>("RobotValue1"))//判断放杯位置是否有物品 | |||
{ | |||
if (!outCupCheck) | |||
MessageLog.GetInstance.ShowEx("成品处有纸杯存在,请取走!!"); | |||
outCupCheck = true; | |||
} | |||
outCupCheck = false; | |||
new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 0 }.Publish(); | |||
Sence(JuicerModel.JUICE2_放果汁杯); | |||
Wait(); | |||
OrderChange(subOrderId, BPA.Message.Enum.ORDER_STATUS.COMPLETED_TAKE); | |||
MessageLog.GetInstance.Show("果汁制作完成"); | |||
} | |||
////模拟果汁 | |||
//Thread.Sleep(15000); | |||
//while (GetStatus<bool>("RobotValue1"))//判断放杯位置是否有物品 | |||
//{ | |||
// if (!outCupCheck) | |||
// MessageLog.GetInstance.ShowEx("成品处有纸杯存在,请取走!!"); | |||
// outCupCheck = true; | |||
//} | |||
//outCupCheck = false; | |||
//new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 0 }.Publish(); | |||
//Sence(JuicerModel.JUICE2_放果汁杯); | |||
//Wait(); | |||
//OrderChange(subOrderId, BPA.Message.Enum.ORDER_STATUS.COMPLETED_TAKE); | |||
//MessageLog.GetInstance.Show("果汁制作完成"); | |||
} | |||
else | |||
{ | |||
return; | |||
} | |||
#endregion | |||
} | |||
/// <summary> | |||
/// 取杯的次数 | |||
/// </summary> | |||
private int nCnt; | |||
private int checkCnt;//检测次数 | |||
public override DeviceClientType DeviceType => throw new NotImplementedException(); | |||
/// <summary> | |||
/// 取杯流程 | |||
/// </summary> | |||
/// <returns>0:无意义,1:取杯成功 2:取杯失败</returns> | |||
private int takeCup() | |||
{ | |||
try | |||
{ | |||
nCnt = 0; | |||
new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 0 }.Publish(); | |||
Sence(JuicerModel.JUICE2_初始位); | |||
Wait(); | |||
new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 0 }.Publish(); | |||
Sence(JuicerModel.JUICE2_取纸杯); | |||
Wait(); | |||
new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 0 }.Publish(); | |||
Sence(JuicerModel.JUICE2_纸杯检测); | |||
Wait(); | |||
nCnt++; | |||
Thread.Sleep(2000); | |||
while (checkCnt < 3) | |||
{ | |||
if (!GetStatus<bool>("GetInput")) | |||
{ | |||
new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 0 }.Publish(); | |||
Sence(JuicerModel.JUICE2_再检测); | |||
Wait(); | |||
} | |||
else | |||
{ | |||
break; | |||
} | |||
checkCnt++; | |||
} | |||
checkCnt = 0; | |||
while (!GetStatus<bool>("GetInput")) //读取传感器的值 | |||
{ | |||
if (nCnt > 3) | |||
{ | |||
nCnt = 0; | |||
MessageLog.GetInstance.ShowEx("三次取杯失败,回原点"); | |||
new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 0 }.Publish(); | |||
Sence(JuicerModel.JUICE2_检测位回原点); | |||
Wait(); | |||
return 2; | |||
} | |||
else | |||
{ | |||
nCnt++; | |||
new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 0 }.Publish(); | |||
Sence(JuicerModel.JUICE2_二次取杯); | |||
Wait(); | |||
new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 0 }.Publish(); | |||
Sence(JuicerModel.JUICE2_纸杯检测); | |||
Wait(); | |||
checkCnt = 0; | |||
while (checkCnt < 3) | |||
{ | |||
if (!GetStatus<bool>("GetInput")) | |||
{ | |||
new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 0 }.Publish(); | |||
Sence(JuicerModel.JUICE2_再检测); | |||
Wait(); | |||
} | |||
else | |||
{ | |||
checkCnt = 0; | |||
return 1; | |||
} | |||
checkCnt++; | |||
} | |||
} | |||
Thread.Sleep(1000); | |||
} | |||
} | |||
catch (Exception ex) | |||
{ | |||
MessageLog.GetInstance.Show(ex.ToString()); | |||
} | |||
return 1; | |||
} | |||
/// <summary> | |||
/// 放杯 | |||
/// </summary> | |||
/// <returns>0:无意义 1:放杯成功 2:执行失败(传感器还有信号) 3:放杯异常</returns> | |||
private int putCup() | |||
{ | |||
try | |||
{ | |||
if (GetStatus<bool>("RobotValue1")) return 2; | |||
Sence(JuicerModel.JUICE_放杯); | |||
Wait(); | |||
new LebaiRobot_SetValueEvent() { RobotSetValue = 1 }.Publish(); | |||
Sence(JuicerModel.JUICE_放杯检测); | |||
Wait(); | |||
new LebaiRobot_SetValueEvent() { RobotSetValue = 1 }.Publish(); | |||
if (GetStatus<bool>("GetInput2")) | |||
{ | |||
return 1; | |||
} | |||
else | |||
{ | |||
return 3; | |||
} | |||
} | |||
catch (Exception ex) | |||
{ | |||
MessageLog.GetInstance.Show(ex.ToString()); | |||
return 0; | |||
} | |||
} | |||
/// <summary> | |||
/// 检测放杯位,是否有杯子 | |||
/// </summary> | |||
/// <returns>0:无意义 1:没有杯子 2:有杯子 </returns> | |||
private int checkCup() | |||
{ | |||
try | |||
{ | |||
while (GetStatus<bool>("RobotValue1")) | |||
{ | |||
Thread.Sleep(100); | |||
if (DateTime.Now.Subtract(delayTimeOut).TotalSeconds >= 1) return 2; | |||
} | |||
MessageLog.GetInstance.Show("放杯位有杯子未取走,等待取走,最多等待60s,即跳出流程"); | |||
return 1; | |||
} | |||
catch (Exception ex) | |||
{ | |||
MessageLog.GetInstance.Show(ex.ToString()); | |||
return 0; | |||
} | |||
} | |||
private void CoffeEndCookHandle(IEvent @event, EventCallBackHandle callBack) | |||
{ | |||
are.Set(); | |||
} | |||
//public void ReadData() | |||
//{ | |||
// //ThreadManage.GetInstance.StartLong(new Action(() => | |||
// //{ | |||
// // lebai = JuicerModel.GetInstance.GetValueAsync(); | |||
// // JuicerModel.GetInstance.GetRobotModeStatus(); | |||
// // //JuicerModel.GetInstance.GetInput(); | |||
// // Thread.Sleep(100); | |||
// //}), "乐百机器人数据读取", true); | |||
//} | |||
public void SimOrder<T>(T simOrder) | |||
{ | |||
//if (morkOrderPushes.Count > 0) | |||
//{ | |||
// morkOrderPushes.Clear(); | |||
//} | |||
//morkOrderPushes.Enqueue(simOrder as MorkOrderPush); | |||
} | |||
/// <summary> | |||
/// IOT 广播消息命令 | |||
/// </summary> | |||
//public void IotBroadcast<T>(T broadcast) | |||
//{ | |||
// if (broadcast != null && broadcast is IOTCommandModel iOTCommand) | |||
// { | |||
// switch (iOTCommand.CommandName) | |||
// { | |||
// case 0://控制类 | |||
// if (iOTCommand.CommandValue != null) | |||
// { | |||
// if (iOTCommand.CommandValue.ContainsKey("SimOrder")) | |||
// { | |||
// //SimOrder(new SimOrderData { NoodleLoc = 1, BowlLoc = 10 }); | |||
// } | |||
// } | |||
// break; | |||
// case 1://设置属性 | |||
// break; | |||
// case 2://通知消息 | |||
// break; | |||
// default: | |||
// break; | |||
// } | |||
// } | |||
//} | |||
public override void DoMain() | |||
{ | |||
} | |||
public override void Stop() | |||
{ | |||
} | |||
public override void ReadData() | |||
{ | |||
} | |||
public override void MainTask() | |||
{ | |||
} | |||
public override void ResetProgram() | |||
{ | |||
} | |||
public class SimOrderData | |||
{ | |||
public string id { get; set; } | |||
public int OrderStatus { get; set; } | |||
public string Loc { get; set; } | |||
public MorkOrderPush morkOrder { get; set; } | |||
public SimOrderData() | |||
{ | |||
id = Guid.NewGuid().ToString(); | |||
OrderStatus = 0; | |||
} | |||
} | |||
} | |||
} |
@@ -0,0 +1,152 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace BPASmartClient.MorkTLebaiJC | |||
{ | |||
internal enum GOODS_TYPE | |||
{ | |||
/// <summary> | |||
/// 未知 | |||
/// </summary> | |||
NEITHER, | |||
/// <summary> | |||
/// 咖啡 | |||
/// </summary> | |||
COFFEE, | |||
/// <summary> | |||
/// 果汁 | |||
/// </summary> | |||
JUICE, | |||
/// <summary> | |||
/// 茶水 | |||
/// </summary> | |||
TEA, | |||
/// <summary> | |||
/// 水 | |||
/// </summary> | |||
WATER, | |||
/// <summary> | |||
/// 杯子 | |||
/// </summary> | |||
CUP | |||
} | |||
internal enum BATCHING_CLASS | |||
{ | |||
HOLDER, | |||
MAIN_MATERIAL, | |||
} | |||
internal class PolymerBatching | |||
{ | |||
internal const string Juicer_MAIN_BATCHIN1_LOC = "52"; | |||
internal const string Juicer_MAIN_BATCHIN2_LOC = "53"; | |||
internal const string Juicer_MAIN_BATCHIN3_LOC = "54"; | |||
internal const string Juicer_MAIN_BATCHIN4_LOC = "55"; | |||
//internal const string Juicer_MAIN_BATCHIN5_LOC = "56"; | |||
//internal const string Juicer_MAIN_BATCHIN6_LOC = "57"; | |||
//internal const string Juicer_MAIN_BATCHIN7_LOC = "58"; | |||
//internal const string Juicer_MAIN_BATCHIN8_LOC = "59"; | |||
internal const string COFFEE_HOLDER_LOC = "30"; | |||
internal const string TEA_HOLDER_LOC = "51"; | |||
public static Dictionary<string, GOODS_TYPE> GOODS_TYPES = new Dictionary<string, GOODS_TYPE>() { | |||
{"1", GOODS_TYPE.COFFEE}, | |||
{"2", GOODS_TYPE.COFFEE}, | |||
{"3", GOODS_TYPE.COFFEE}, | |||
{"4", GOODS_TYPE.COFFEE}, | |||
{"5", GOODS_TYPE.COFFEE}, | |||
{"6", GOODS_TYPE.COFFEE}, | |||
{"7", GOODS_TYPE.COFFEE}, | |||
{"8", GOODS_TYPE.COFFEE}, | |||
{"9", GOODS_TYPE.COFFEE}, | |||
{"10",GOODS_TYPE.COFFEE}, | |||
{"11",GOODS_TYPE.COFFEE}, | |||
{"12",GOODS_TYPE.COFFEE}, | |||
{"13",GOODS_TYPE.COFFEE}, | |||
{"14",GOODS_TYPE.COFFEE}, | |||
{"15",GOODS_TYPE.COFFEE}, | |||
{"16",GOODS_TYPE.COFFEE}, | |||
{"17",GOODS_TYPE.COFFEE}, | |||
{"18",GOODS_TYPE.COFFEE}, | |||
{"19",GOODS_TYPE.COFFEE}, | |||
{"20",GOODS_TYPE.COFFEE}, | |||
{"21",GOODS_TYPE.COFFEE}, | |||
{"22",GOODS_TYPE.COFFEE}, | |||
{"23",GOODS_TYPE.COFFEE}, | |||
{"24",GOODS_TYPE.COFFEE}, | |||
{"25",GOODS_TYPE.COFFEE}, | |||
{ COFFEE_HOLDER_LOC,GOODS_TYPE.CUP}, | |||
{"56",GOODS_TYPE.TEA }, | |||
{"61",GOODS_TYPE.WATER }, | |||
{Juicer_MAIN_BATCHIN1_LOC,GOODS_TYPE.JUICE}, | |||
{Juicer_MAIN_BATCHIN2_LOC,GOODS_TYPE.JUICE}, | |||
{Juicer_MAIN_BATCHIN3_LOC,GOODS_TYPE.JUICE}, | |||
{Juicer_MAIN_BATCHIN4_LOC,GOODS_TYPE.JUICE}, | |||
//{Juicer_MAIN_BATCHIN5_LOC,GOODS_TYPE.JUICE}, | |||
//{Juicer_MAIN_BATCHIN6_LOC,GOODS_TYPE.JUICE}, | |||
//{Juicer_MAIN_BATCHIN7_LOC,GOODS_TYPE.JUICE}, | |||
//{Juicer_MAIN_BATCHIN8_LOC,GOODS_TYPE.JUICE}, | |||
}; | |||
public GOODS_TYPE GoodsType { get; set; } | |||
public BATCHING_CLASS BatchingClass { get; set; } | |||
private string loc; | |||
public string Loc | |||
{ | |||
get { return loc; } | |||
set | |||
{ | |||
loc = value; | |||
if (GOODS_TYPES.ContainsKey(loc)) | |||
GoodsType = GOODS_TYPES[loc]; | |||
switch (loc) | |||
{ | |||
case COFFEE_HOLDER_LOC: | |||
case TEA_HOLDER_LOC: | |||
BatchingClass = BATCHING_CLASS.HOLDER; | |||
break; | |||
default: | |||
BatchingClass = BATCHING_CLASS.MAIN_MATERIAL; | |||
break; | |||
} | |||
} | |||
} | |||
internal static Dictionary<string, PolymerBatching> BuildAll() | |||
{ | |||
Dictionary<string, PolymerBatching> temp = new Dictionary<string, PolymerBatching>(); | |||
foreach (var item in GOODS_TYPES) | |||
{ | |||
temp.Add(item.Key, new PolymerBatching() { Loc = item.Key }); | |||
} | |||
return temp; | |||
} | |||
//internal static IC_SE GetIceCreamSE(string loc, out string sence) | |||
//{ | |||
// switch (loc) | |||
// { | |||
// case Juicer_MAIN_BATCHIN1_LOC: | |||
// sence = JaKaHelper.SENCE_接果汁1; | |||
// return IC_SE.SE_1; | |||
// case Juicer_MAIN_BATCHIN2_LOC: | |||
// sence = JaKaHelper.SENCE_接果汁2; | |||
// return IC_SE.SE_2; | |||
// case Juicer_MAIN_BATCHIN3_LOC: | |||
// sence = JaKaHelper.SENCE_接果汁3; | |||
// return IC_SE.SE_3; | |||
// default: | |||
// sence = JaKaHelper.SENCE_接果汁1; | |||
// return IC_SE.SE_1; | |||
// } | |||
//} | |||
} | |||
} |
@@ -9,6 +9,7 @@ | |||
<ItemGroup> | |||
<ProjectReference Include="..\BPASmartClient.Business\BPASmartClient.Business.csproj" /> | |||
<ProjectReference Include="..\BPASmartClient.CustomResource\BPASmartClient.CustomResource.csproj" /> | |||
<ProjectReference Include="..\BPASmartClient.Device\BPASmartClient.Device.csproj" /> | |||
<ProjectReference Include="..\BPASmartClient.DRCoffee\BPASmartClient.DRCoffee.csproj" /> | |||
<ProjectReference Include="..\BPASmartClient.GSIceCream\BPASmartClient.GSIceCream.csproj" /> | |||
@@ -45,7 +45,7 @@ namespace BPASmartClient.MorkT | |||
morkT.MakeCoffeeOrder.OrderStatus = 1; | |||
}); | |||
int i = 0; | |||
EventBus.EventBus.GetInstance().Publish(new GSIceCream_ModeSetEvent { DeviceId = DeviceId, Mode = MORKI_MODE.制冷模式 }); | |||
MessageLog.GetInstance.Show("MORKT 设备初始化完成"); | |||
@@ -71,7 +71,21 @@ namespace BPASmartClient.MorkT | |||
public override void MainTask() | |||
{ | |||
if (morkT.waitMorkOrder != null)//更新订单取走状态 | |||
{ | |||
EventBus.EventBus.GetInstance().Publish(new LebaiRobot_GetInputEvent() { DeviceId = DeviceId, Pin = 0 }, (o) => | |||
{ | |||
if (o != null && o.Length > 0 && o[0] is bool res) | |||
{ | |||
if (!res) | |||
{ | |||
OrderChange(morkT.waitMorkOrder.SuborderId, ORDER_STATUS.COMPLETED_TAKE); | |||
DeviceProcessLogShow("订单取餐完成"); | |||
morkT.waitMorkOrder = null; | |||
} | |||
} | |||
}); | |||
} | |||
MakeCoffeeProcess(); | |||
EventBus.EventBus.GetInstance().Publish(new LebaiRobot_GetInputEvent { DeviceId = DeviceId, Pin = 0 },(o)=> | |||
{ | |||
@@ -84,7 +98,8 @@ namespace BPASmartClient.MorkT | |||
} | |||
} | |||
}); | |||
} | |||
public override void ReadData() | |||
@@ -371,6 +386,7 @@ namespace BPASmartClient.MorkT | |||
{ | |||
DeviceProcessLogShow($"开始制作 [咖啡] 订单[{orderLoc.SortNum}]"); | |||
GetAndCheeckCoffe(orderLoc);//取咖啡杯 | |||
if (!morkT.GetCoffeeCup) return; | |||
EventBus.EventBus.GetInstance().Publish(new LebaiRobot_LebaiSenceEvent { DeviceId = DeviceId, LebaiSence = 10051}); //接咖啡后回原点 | |||
Wait(); | |||
EventBus.EventBus.GetInstance().Publish(new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 1 }); | |||
@@ -380,6 +396,7 @@ namespace BPASmartClient.MorkT | |||
} | |||
} | |||
} | |||
@@ -411,6 +428,7 @@ namespace BPASmartClient.MorkT | |||
EventBus.EventBus.GetInstance().Publish(new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 1 }); | |||
//订单状态改变:完成 | |||
OrderChange(order.SuborderId, ORDER_STATUS.COMPLETED_COOK); | |||
morkT.waitMorkOrder = order; | |||
DeviceProcessLogShow($"{order.GoodsName}等待取餐"); | |||
//WaitTakeMealOrder.Enqueue(order); | |||
@@ -454,6 +472,7 @@ namespace BPASmartClient.MorkT | |||
EventBus.EventBus.GetInstance().Publish(new LebaiRobot_LebaiSenceEvent { DeviceId = DeviceId, LebaiSence = 10050 }); //SENCE_咖啡杯回原点 | |||
Wait(); | |||
EventBus.EventBus.GetInstance().Publish(new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 1 }); | |||
morkT.GetCoffeeCup = false; | |||
return; | |||
} | |||
DeviceProcessLogShow("执行二次取咖啡杯"); | |||
@@ -464,6 +483,7 @@ namespace BPASmartClient.MorkT | |||
count++; | |||
goto p; | |||
} | |||
morkT.GetCoffeeCup = true; | |||
DeviceProcessLogShow("取咖啡杯完成"); | |||
} | |||
@@ -482,40 +502,45 @@ namespace BPASmartClient.MorkT | |||
/// </summary> | |||
private void MakeIceCreamProcess() | |||
{ | |||
if (IceCreamCanMake()) | |||
{ | |||
if(peripheralStatus.ContainsKey("IceCreamCurrentMode")) | |||
{ | |||
if ((MORKI_MODE)peripheralStatus["IceCreamCurrentMode"] != MORKI_MODE.制冷模式) new GSIceCream_ModeSetEvent() { Mode = MORKI_MODE.制冷模式 }.Publish(); | |||
} | |||
if(peripheralStatus.ContainsKey("IceCreamCXB")) | |||
{ | |||
if ((byte)peripheralStatus["IceCreamCXB"] >= 86 && morkT.morkOrderPushesIceCream.Count > 0)//成型比大于86才可以制作 | |||
{ | |||
bool result = true; | |||
EventBus.EventBus.GetInstance().Publish(new LebaiRobot_GetInputEvent { DeviceId = DeviceId, Pin = 3 }, (res) => | |||
{ | |||
if (res[0] is bool resultValue) | |||
{ | |||
result = resultValue; | |||
} | |||
}); | |||
if (result) | |||
{ | |||
if (morkT.IceIsOK) DeviceProcessLogShow("请检查冰淇淋出料口有无遮挡"); | |||
morkT.IceIsOK = false; | |||
} | |||
else if (morkT.morkOrderPushesIceCream.TryDequeue(out OrderLocInfo order)) | |||
{ | |||
morkT.IceIsOK = true; | |||
DeviceProcessLogShow($"开始制作 [冰淇淋] 订单[{order.SortNum}]"); | |||
DoIceCream(order); | |||
} | |||
} | |||
} | |||
} | |||
//if (IceCreamCanMake()) | |||
//{ | |||
if (morkT.morkOrderPushesIceCream.TryDequeue(out OrderLocInfo order)) | |||
{ | |||
DoIceCream(order); | |||
} | |||
//if(peripheralStatus.ContainsKey("IceCreamCurrentMode")) | |||
//{ | |||
// if ((MORKI_MODE)peripheralStatus["IceCreamCurrentMode"] != MORKI_MODE.制冷模式) EventBus.EventBus.GetInstance().Publish(new GSIceCream_ModeSetEvent { DeviceId = DeviceId, Mode = MORKI_MODE.制冷模式 }); | |||
//} | |||
//if(peripheralStatus.ContainsKey("IceCreamCXB")) | |||
//{ | |||
// if ((byte)peripheralStatus["IceCreamCXB"] >= 86 && morkT.morkOrderPushesIceCream.Count > 0)//成型比大于86才可以制作 | |||
// { | |||
// bool result = true; | |||
// EventBus.EventBus.GetInstance().Publish(new LebaiRobot_GetInputEvent { DeviceId = DeviceId, Pin = 3 }, (res) => | |||
// { | |||
// if (res[0] is bool resultValue) | |||
// { | |||
// result = resultValue; | |||
// } | |||
// }); | |||
// if (result) | |||
// { | |||
// if (morkT.IceIsOK) DeviceProcessLogShow("请检查冰淇淋出料口有无遮挡"); | |||
// morkT.IceIsOK = false; | |||
// } | |||
// else if (morkT.morkOrderPushesIceCream.TryDequeue(out OrderLocInfo order)) | |||
// { | |||
// morkT.IceIsOK = true; | |||
// DeviceProcessLogShow($"开始制作 [冰淇淋] 订单[{order.SortNum}]"); | |||
// DoIceCream(order); | |||
// } | |||
// } | |||
//} | |||
//} | |||
} | |||
@@ -526,8 +551,12 @@ namespace BPASmartClient.MorkT | |||
{ | |||
GetIceCreamCup(); | |||
CheckICeCreaCup(); | |||
GetIceCream(order); | |||
PutIceCream(order); | |||
if(morkT.GetIceCreamCup) | |||
{ | |||
GetIceCream(order); | |||
PutIceCream(order); | |||
} | |||
} | |||
/// <summary> | |||
@@ -572,6 +601,7 @@ namespace BPASmartClient.MorkT | |||
EventBus.EventBus.GetInstance().Publish(new LebaiRobot_LebaiSenceEvent { DeviceId = DeviceId, LebaiSence = 10049 }); //SENCE_冰淇淋杯回原点 | |||
Wait(); | |||
EventBus.EventBus.GetInstance().Publish(new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 1 }); | |||
morkT.GetIceCreamCup = false; | |||
return; | |||
} | |||
DeviceProcessLogShow($"执行{count}次取冰淇淋杯!"); | |||
@@ -582,6 +612,7 @@ namespace BPASmartClient.MorkT | |||
count++; | |||
goto p; | |||
} | |||
morkT.GetIceCreamCup = true; | |||
DeviceProcessLogShow("冰淇淋杯检测完成"); | |||
} | |||
@@ -592,34 +623,43 @@ namespace BPASmartClient.MorkT | |||
private void GetIceCream(OrderLocInfo order) | |||
{ | |||
//制冷模式 | |||
EventBus.EventBus.GetInstance().Publish(new GSIceCream_ModeSetEvent {DeviceId = DeviceId, Mode = MORKI_MODE.制冷模式 }); | |||
//EventBus.EventBus.GetInstance().Publish(new GSIceCream_ModeSetEvent {DeviceId = DeviceId, Mode = MORKI_MODE.制冷模式 }); | |||
EventBus.EventBus.GetInstance().Publish(new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 0 }); | |||
OrderChange(order.SuborderId, ORDER_STATUS.COOKING); | |||
EventBus.EventBus.GetInstance().Publish(new LebaiRobot_LebaiSenceEvent { DeviceId = DeviceId, LebaiSence = 10039 }); //SENCE_接1号冰淇淋 | |||
Wait(); | |||
bool doItResult = true; | |||
//出料 | |||
EventBus.EventBus.GetInstance().Publish(new GSIceCream_DischargeEvent { DeviceId = DeviceId },(o)=> | |||
{ | |||
doItResult = (bool)o[0]; | |||
}); | |||
if (doItResult) | |||
{ | |||
IceCreamCookCheck(); | |||
} | |||
else | |||
{ | |||
int count_1 = 0; | |||
EventBus.EventBus.GetInstance().Publish(new SCChip_RotorSwitchEvent { DeviceId = DeviceId, TurnOn = true }); | |||
Thread.Sleep(500); | |||
EventBus.EventBus.GetInstance().Publish(new SCChip_RotorSwitchEvent { DeviceId = DeviceId, TurnOn = false }); | |||
EventBus.EventBus.GetInstance().Publish(new SCChip_MakeIceCreamEvent { DeviceId = DeviceId ,SteeringEngine = IC_SE.SE_2 });//冰淇淋出料 | |||
DeviceProcessLogShow("开始等待6s"); | |||
Thread.Sleep(6000); | |||
while ((byte)peripheralStatus["IceCreamCXB"] <= 86) | |||
{ | |||
Thread.Sleep(5); | |||
count_1++; | |||
if (count_1 >= 2000) | |||
break; | |||
} | |||
IceCreamCookCheck(); | |||
} | |||
//出料 | |||
//EventBus.EventBus.GetInstance().Publish(new GSIceCream_DischargeEvent { DeviceId = DeviceId },(o)=> | |||
//{ | |||
// doItResult = (bool)o[0]; | |||
//}); | |||
//if (doItResult) | |||
//{ | |||
// IceCreamCookCheck(); | |||
//} | |||
//else | |||
//{ | |||
// int count_1 = 0; | |||
// while ((byte)peripheralStatus["IceCreamCXB"] <= 86) | |||
// { | |||
// Thread.Sleep(5); | |||
// count_1++; | |||
// if (count_1 >= 2000) | |||
// break; | |||
// } | |||
// IceCreamCookCheck(); | |||
//} | |||
EventBus.EventBus.GetInstance().Publish(new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 1 }); | |||
} | |||
@@ -629,21 +669,25 @@ namespace BPASmartClient.MorkT | |||
/// <param name="order"></param> | |||
private void PutIceCream(OrderLocInfo order) | |||
{ | |||
EventBus.EventBus.GetInstance().Publish(new LebaiRobot_GetInputEvent { DeviceId = DeviceId, Pin = 0 }, (res) => | |||
bool resultValue = true; | |||
while (resultValue) | |||
{ | |||
if (res[0] is bool resultValue) | |||
EventBus.EventBus.GetInstance().Publish(new LebaiRobot_GetInputEvent { DeviceId = DeviceId, Pin = 0 }, (res) => | |||
{ | |||
while (resultValue) | |||
if (res[0] is bool b) | |||
{ | |||
Thread.Sleep(500); | |||
resultValue = b; | |||
} | |||
} | |||
}); | |||
}); | |||
Thread.Sleep(500); | |||
} | |||
EventBus.EventBus.GetInstance().Publish(new LebaiRobot_LebaiSenceEvent { DeviceId = DeviceId, LebaiSence = 10043 }); //SENCE_放冰淇淋位置 | |||
Wait(); | |||
EventBus.EventBus.GetInstance().Publish(new LebaiRobot_SetValueEvent { DeviceId = DeviceId, RobotSetValue = 1 }); | |||
//订单状态改变:完成 | |||
OrderChange(order.SuborderId, ORDER_STATUS.COMPLETED_COOK); | |||
morkT.waitMorkOrder = order; | |||
DeviceProcessLogShow($"{order.GoodsName}等待取餐"); | |||
//WaitTakeMealOrder.Enqueue(order); | |||
@@ -25,6 +25,10 @@ namespace BPASmartClient.MorkT | |||
/// </summary> | |||
public ConcurrentQueue<OrderLocInfo> morkOrderPushesIceCream = new ConcurrentQueue<OrderLocInfo>(); | |||
/// <summary> | |||
/// 等待取餐订单 | |||
/// </summary> | |||
public OrderLocInfo waitMorkOrder = null; | |||
/// <summary> | |||
/// 物料存放位置 | |||
/// </summary> | |||
public Dictionary<string, PolymerBatching> batchings = new Dictionary<string, PolymerBatching>(); | |||
@@ -44,6 +48,14 @@ namespace BPASmartClient.MorkT | |||
/// 冰淇淋机器出料口传感器检测 | |||
/// </summary> | |||
public bool IceIsOK = true; | |||
/// <summary> | |||
/// 去咖啡杯成功 | |||
/// </summary> | |||
public bool GetCoffeeCup; | |||
/// <summary> | |||
/// 取冰淇淋杯成功 | |||
/// </summary> | |||
public bool GetIceCreamCup; | |||
#region | |||
@@ -6,7 +6,7 @@ | |||
xmlns:vm ="clr-namespace:BPASmartClient.MorkT.ViewModel" | |||
mc:Ignorable="d" | |||
Name="调试界面" | |||
d:DesignHeight="450" d:DesignWidth="1000" > | |||
d:DesignHeight="500" d:DesignWidth="1000" Unloaded="Dubug_Unloaded"> | |||
<UserControl.DataContext> | |||
<vm:DebugViewModel/> | |||
</UserControl.DataContext> | |||
@@ -20,12 +20,13 @@ | |||
</UserControl.Resources> | |||
<Grid> | |||
<Grid.ColumnDefinitions> | |||
<ColumnDefinition Width="*"/> | |||
<ColumnDefinition Width="*"/> | |||
<ColumnDefinition Width="10*"/> | |||
<ColumnDefinition Width="10*"/> | |||
</Grid.ColumnDefinitions> | |||
<Grid.RowDefinitions> | |||
<RowDefinition Height="9*"/> | |||
<RowDefinition Height="10*"/> | |||
<RowDefinition Height="14*"/> | |||
<RowDefinition Height="6*"/> | |||
<RowDefinition Height="20*"/> | |||
</Grid.RowDefinitions> | |||
<GroupBox Grid.ColumnSpan="2" | |||
@@ -81,7 +82,7 @@ | |||
</ListBox> | |||
</Grid> | |||
</GroupBox> | |||
<GroupBox Grid.Row="1" | |||
<GroupBox Grid.Row="2" | |||
FontFamily="楷体" | |||
FontSize="20" | |||
Header=" 冰淇淋机器 "> | |||
@@ -172,7 +173,7 @@ | |||
</StackPanel> | |||
</Grid> | |||
</GroupBox> | |||
<GroupBox Grid.Row="1" Grid.Column="1" | |||
<GroupBox Grid.Row="2" Grid.Column="1" | |||
FontFamily="楷体" | |||
FontSize="20" | |||
Header=" 咖啡机"> | |||
@@ -203,13 +204,13 @@ | |||
<ColumnDefinition Width="171" /> | |||
</Grid.ColumnDefinitions> | |||
<TextBlock Height="23" Width="100" FontSize="18" HorizontalAlignment="Center">咖啡机状态</TextBlock> | |||
<TextBlock FontSize="18" | |||
<TextBlock FontSize="18" | |||
Grid.Column="1" | |||
Text="{Binding CoffeeStatus}" Height="23" Width="0" /> | |||
Text="{Binding CoffeeStatus}" Height="23" /> | |||
<TextBlock Grid.Column="2" Height="23" Width="80" FontSize="18">应用状态</TextBlock> | |||
<TextBlock FontSize="18" | |||
Grid.Column="3" | |||
Text="{Binding AppStatus}" Height="23" Width="100" /> | |||
Text="{Binding AppStatus}" Height="23"/> | |||
<TextBlock Grid.Row="1" Grid.Column="0" Height="22" Width="80" FontSize="18">告警信息</TextBlock> | |||
<TextBlock FontSize="15" | |||
Grid.Row="1" | |||
@@ -248,5 +249,32 @@ | |||
</StackPanel> | |||
</Grid> | |||
</GroupBox> | |||
<GroupBox Header="单片机控制" | |||
FontSize="18" | |||
Grid.Row="1" Grid.ColumnSpan="2" | |||
Margin="0,0,0,10"> | |||
<StackPanel Orientation="Horizontal" | |||
VerticalAlignment="Center" > | |||
<Button Content="咖啡杯落杯" | |||
Command="{Binding Button_CupControlCommand}" | |||
CommandParameter="CUP_COFFEE" | |||
Margin="0,0,50,0"/> | |||
<Button Content="冰淇淋杯落杯" | |||
Command="{Binding Button_CupControlCommand}" | |||
CommandParameter="CUP_ICECREAM" | |||
/> | |||
<Button Content="单片机冰淇淋制冷" | |||
Command="{Binding Button_SCChipRefrigerationCommand}" Cursor="Hand" | |||
Margin="50,0" | |||
/> | |||
<Button Content="单片机冰淇淋打料" | |||
Command="{Binding Button_SCChipDischargeCommand}" Cursor="Hand" /> | |||
<Button Content="单片机冰淇淋模拟" | |||
Command="{Binding Button_SCChipTestCommand}" Cursor="Hand" | |||
Margin="50,0"/> | |||
</StackPanel> | |||
</GroupBox> | |||
</Grid> | |||
</UserControl> |
@@ -1,4 +1,5 @@ | |||
using System; | |||
using BPASmartClient.Helper; | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
@@ -24,5 +25,11 @@ namespace BPASmartClient.MorkT.View | |||
{ | |||
InitializeComponent(); | |||
} | |||
private void Dubug_Unloaded(object sender, RoutedEventArgs e) | |||
{ | |||
ThreadManage.GetInstance().StopTask("MorkT-状态刷新"); | |||
ThreadManage.GetInstance().StopTask("MorkT-传感器监视"); | |||
} | |||
} | |||
} |
@@ -0,0 +1,75 @@ | |||
<UserControl x:Class="BPASmartClient.MorkT.View.Monitor" | |||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | |||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | |||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | |||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | |||
xmlns:local="clr-namespace:BPASmartClient.MorkT.View" | |||
xmlns:vm="clr-namespace:BPASmartClient.MorkT.ViewModel" | |||
mc:Ignorable="d" | |||
Name="监控画面" | |||
d:DesignHeight="450" d:DesignWidth="800" Unloaded="Monitor_Unloaded"> | |||
<UserControl.DataContext> | |||
<vm:MonitorViewModel/> | |||
</UserControl.DataContext> | |||
<UserControl.Resources> | |||
<ResourceDictionary > | |||
<vm:BoolToColorConvert x:Key="BoolToColorConvert"/> | |||
<Style x:Key="tx_Status" TargetType="TextBlock"> | |||
<Setter Property="FontFamily" Value="/BPASmartClient.CustomResource;component/Fonts/Debug/#iconfont"/> | |||
<Setter Property="FontSize" Value="26"/> | |||
<Setter Property="Text" Value=""/> | |||
<Setter Property="VerticalAlignment" Value="Center"/> | |||
<Setter Property="HorizontalAlignment" Value="Left"/> | |||
</Style> | |||
</ResourceDictionary> | |||
</UserControl.Resources> | |||
<Grid Margin="10,0"> | |||
<Grid.ColumnDefinitions> | |||
</Grid.ColumnDefinitions> | |||
<Grid.RowDefinitions> | |||
<RowDefinition Height="*"/> | |||
<RowDefinition Height="*"/> | |||
<RowDefinition Height="*"/> | |||
</Grid.RowDefinitions> | |||
<GroupBox Header="传感器状态" | |||
FontSize="20" Foreground="#40e8ff" | |||
BorderThickness="0"> | |||
<Grid Margin="20,0"> | |||
<Grid.ColumnDefinitions> | |||
<ColumnDefinition Width="3*"/> | |||
<ColumnDefinition Width="*"/> | |||
<ColumnDefinition Width="3*"/> | |||
<ColumnDefinition Width="*"/> | |||
</Grid.ColumnDefinitions> | |||
<Grid.RowDefinitions> | |||
<RowDefinition Height="*"/> | |||
<RowDefinition Height="*"/> | |||
<RowDefinition Height="*"/> | |||
</Grid.RowDefinitions> | |||
<TextBlock Text="机器人夹爪处检测传感器" | |||
FontSize="18" | |||
VerticalAlignment="Center"/> | |||
<TextBlock Text="冰淇淋出料口传感器" | |||
Grid.Row="1" | |||
FontSize="18" | |||
VerticalAlignment="Center"/> | |||
<TextBlock Text="取餐口传感器" | |||
Grid.Row="2" | |||
FontSize="18" | |||
VerticalAlignment="Center"/> | |||
<TextBlock Grid.Row="0" Grid.Column="1" | |||
Style="{StaticResource tx_Status}" | |||
Foreground="{Binding RobotSenser,Converter={StaticResource BoolToColorConvert }}"/> | |||
<TextBlock Grid.Row="1" Grid.Column="1" | |||
Style="{StaticResource tx_Status}" | |||
Foreground="{Binding IceCreamSenser,Converter={StaticResource BoolToColorConvert }}"/> | |||
<TextBlock Grid.Row="2" Grid.Column="1" | |||
Style="{StaticResource tx_Status}" | |||
Foreground="{Binding TakeMealSenser,Converter={StaticResource BoolToColorConvert}}"/> | |||
</Grid> | |||
</GroupBox> | |||
</Grid> | |||
</UserControl> |
@@ -0,0 +1,34 @@ | |||
using BPASmartClient.Helper; | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
using System.Windows; | |||
using System.Windows.Controls; | |||
using System.Windows.Data; | |||
using System.Windows.Documents; | |||
using System.Windows.Input; | |||
using System.Windows.Media; | |||
using System.Windows.Media.Imaging; | |||
using System.Windows.Navigation; | |||
using System.Windows.Shapes; | |||
namespace BPASmartClient.MorkT.View | |||
{ | |||
/// <summary> | |||
/// Monitor.xaml 的交互逻辑 | |||
/// </summary> | |||
public partial class Monitor : UserControl | |||
{ | |||
public Monitor() | |||
{ | |||
InitializeComponent(); | |||
} | |||
private void Monitor_Unloaded(object sender, RoutedEventArgs e) | |||
{ | |||
} | |||
} | |||
} |
@@ -0,0 +1,13 @@ | |||
<UserControl x:Class="BPASmartClient.MorkT.View.ParSer" | |||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | |||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | |||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | |||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | |||
xmlns:local="clr-namespace:BPASmartClient.MorkT.View" | |||
mc:Ignorable="d" | |||
Name="参数设置界面" | |||
d:DesignHeight="450" d:DesignWidth="800"> | |||
<Grid> | |||
</Grid> | |||
</UserControl> |
@@ -0,0 +1,28 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
using System.Windows; | |||
using System.Windows.Controls; | |||
using System.Windows.Data; | |||
using System.Windows.Documents; | |||
using System.Windows.Input; | |||
using System.Windows.Media; | |||
using System.Windows.Media.Imaging; | |||
using System.Windows.Navigation; | |||
using System.Windows.Shapes; | |||
namespace BPASmartClient.MorkT.View | |||
{ | |||
/// <summary> | |||
/// ParSer.xaml 的交互逻辑 | |||
/// </summary> | |||
public partial class ParSer : UserControl | |||
{ | |||
public ParSer() | |||
{ | |||
InitializeComponent(); | |||
} | |||
} | |||
} |
@@ -9,6 +9,8 @@ using BPASmartClient.Message; | |||
using BPASmartClient.Model; | |||
using BPASmartClient.Model.乐白机器人; | |||
using BPASmartClient.Model.冰淇淋.Enum; | |||
using BPASmartClient.Model.单片机; | |||
using BPASmartClient.Model.单片机.Enum; | |||
using BPASmartClient.Model.咖啡机.Enum; | |||
using Microsoft.Toolkit.Mvvm.ComponentModel; | |||
using Microsoft.Toolkit.Mvvm.Input; | |||
@@ -156,21 +158,100 @@ namespace BPASmartClient.MorkT.ViewModel | |||
public List<string> CoffeeCmds { get; set; } = new List<string>(); | |||
public string SelectedCoffeeCmd { get; set; } | |||
/// <summary> | |||
/// 制作咖啡 | |||
/// </summary> | |||
public RelayCommand Button_MakeCoffeeCommand { get; set; } | |||
/// <summary> | |||
/// 停止制作咖啡 | |||
/// </summary> | |||
public RelayCommand Button_StopMakeCoffeCommand { get; set; } | |||
/// <summary> | |||
/// 咖啡模式设置 | |||
/// </summary> | |||
public RelayCommand Button_CoffeeModeSetCommand { get; set; } | |||
private void Button_MakeCoffee() | |||
{ | |||
EventBus.EventBus.GetInstance().Publish(new DRCoffee_MakeCoffeeEvent() { DeviceId = DeviceId, DrinkCode = (DrCoffeeDrinksCode)Enum.Parse(typeof(DrCoffeeDrinksCode), SelectedCoffee)}); | |||
} | |||
private void Button_StopMakeCoffe() | |||
{ | |||
EventBus.EventBus.GetInstance().Publish(new DRCoffee_CancelMakeCoffeeEvent() { DeviceId = DeviceId }); | |||
} | |||
private void Button_CoffeeModeSet() | |||
{ | |||
EventBus.EventBus.GetInstance().Publish(new DRCoffee_CoffeeCommCmdEvent() { DeviceId = DeviceId, CommCmd = (DrCoffeeCommCmd)Enum.Parse(typeof(DrCoffeeCommCmd), SelectedCoffeeCmd)}); | |||
} | |||
#endregion | |||
#region 单片机 | |||
/// <summary> | |||
/// 设备ID | |||
/// 咖啡杯或冰淇淋杯落杯 | |||
/// </summary> | |||
public int DeviceId { get; set; } | |||
public RelayCommand<object> Button_CupControlCommand { get; set; } | |||
/// <summary> | |||
/// 单片机冰淇淋机器制冷 | |||
/// </summary> | |||
public RelayCommand Button_SCChipRefrigerationCommand { get; set; } | |||
/// <summary> | |||
/// 单片机冰淇淋机器打料 | |||
/// </summary> | |||
public RelayCommand Button_SCChipDischargeCommand { get; set; } | |||
/// <summary> | |||
/// 模拟测试 | |||
/// </summary> | |||
public RelayCommand Button_SCChipTestCommand { get; set; } | |||
public ObservableCollection<VariableMonitor> variableMonitors { get; set; } | |||
private void Button_CupControl(object CupType) | |||
{ | |||
EventBus.EventBus.GetInstance().Publish(new SCChip_TakeCupEvent() { DeviceId = DeviceId, Cup = (IC_CUP)Enum.Parse(typeof(IC_CUP), CupType.ToString()) }); | |||
} | |||
private void Button_SCChipRefrigeration() | |||
{ | |||
EventBus.EventBus.GetInstance().Publish(new SCChip_RotorSwitchEvent { DeviceId = DeviceId, TurnOn = true }); | |||
Thread.Sleep(500); | |||
EventBus.EventBus.GetInstance().Publish(new SCChip_RotorSwitchEvent { DeviceId = DeviceId, TurnOn = false }); | |||
} | |||
private void Button_SCChipDischarge() | |||
{ | |||
EventBus.EventBus.GetInstance().Publish(new SCChip_MakeIceCreamEvent { DeviceId = DeviceId, SteeringEngine = IC_SE.SE_2 }); | |||
} | |||
#endregion | |||
/// <summary> | |||
/// 设备ID | |||
/// </summary> | |||
public int DeviceId { get; set; } | |||
/// <summary> | |||
/// 设备数据 | |||
/// </summary> | |||
public ObservableCollection<VariableMonitor> variableMonitors { get; set; } | |||
public DebugViewModel() | |||
{ | |||
Button_RobotControlCommand = new RelayCommand<object>(Button_RobotControl); | |||
Button_MakeIceCreamCommand = new RelayCommand(Button_MakeIceCream); | |||
Button_SetIceCreamModelCommand = new RelayCommand(Button_SetIceCreamModel); | |||
Button_MakeCoffeeCommand = new RelayCommand(Button_MakeCoffee); | |||
Button_StopMakeCoffeCommand = new RelayCommand(Button_StopMakeCoffe); | |||
Button_CoffeeModeSetCommand = new RelayCommand(Button_CoffeeModeSet); | |||
Button_CupControlCommand = new RelayCommand<object>(Button_CupControl); | |||
Button_SCChipRefrigerationCommand = new RelayCommand(Button_SCChipRefrigeration); | |||
Button_SCChipDischargeCommand = new RelayCommand(Button_SCChipDischarge); | |||
Button_SCChipTestCommand = new RelayCommand(() => | |||
{ | |||
Button_SCChipRefrigeration(); | |||
Thread.Sleep(50); | |||
Button_SCChipDischarge(); | |||
}); | |||
foreach (DrCoffeeDrinksCode code in Enum.GetValues(typeof(DrCoffeeDrinksCode))) | |||
{ | |||
Coffees.Add(code.ToString()); | |||
@@ -0,0 +1,94 @@ | |||
using BPASmartClient.Business; | |||
using BPASmartClient.Helper; | |||
using BPASmartClient.Model.乐白机器人; | |||
using Microsoft.Toolkit.Mvvm.ComponentModel; | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Globalization; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading; | |||
using System.Threading.Tasks; | |||
using System.Windows.Data; | |||
using System.Windows.Media; | |||
namespace BPASmartClient.MorkT.ViewModel | |||
{ | |||
public class MonitorViewModel: ObservableObject | |||
{ | |||
#region 传感器 | |||
/// <summary> | |||
/// 机器人夹爪传感器 | |||
/// </summary> | |||
public bool RobotSenser { get { return _robotSenser; } set { _robotSenser = value; OnPropertyChanged(); } } | |||
private bool _robotSenser; | |||
/// <summary> | |||
/// 冰淇淋出口传感器 | |||
/// </summary> | |||
public bool IceCreamSenser { get { return _iceCreamSenser; } set { _iceCreamSenser = value; OnPropertyChanged(); } } | |||
private bool _iceCreamSenser; | |||
/// <summary> | |||
/// 取餐口检测传感器 | |||
/// </summary> | |||
public bool TakeMealSenser { get { return _takeMealSenser; } set { _takeMealSenser = value; OnPropertyChanged(); } } | |||
private bool _takeMealSenser; | |||
#endregion | |||
/// <summary> | |||
/// 设备ID | |||
/// </summary> | |||
int DeviceId; | |||
public MonitorViewModel() | |||
{ | |||
Plugin.GetInstance()?.GetPlugin<DeviceMgr>()?.GetDevices().ForEach(device => | |||
{ | |||
if (device.Name == "MorkT") DeviceId = device.DeviceId; | |||
}); | |||
ThreadManage.GetInstance().StartLong(new Action(() => | |||
{ | |||
EventBus.EventBus.GetInstance().Publish(new LebaiRobot_GetTCPInputEvent() { DeviceId = DeviceId, Pin = 1 },(res)=> | |||
{ | |||
if(res != null&& res.Length>0&& res[0] is bool b) | |||
{ | |||
RobotSenser = b; | |||
} | |||
}); | |||
EventBus.EventBus.GetInstance().Publish(new LebaiRobot_GetInputEvent() { DeviceId = DeviceId, Pin = 0 }, (res) => | |||
{ | |||
if (res != null && res.Length > 0 && res[0] is bool b) | |||
{ | |||
TakeMealSenser = b; | |||
} | |||
}); | |||
EventBus.EventBus.GetInstance().Publish(new LebaiRobot_GetTCPInputEvent() { DeviceId = DeviceId, Pin = 3 }, (res) => | |||
{ | |||
if (res != null && res.Length > 0 && res[0] is bool b) | |||
{ | |||
IceCreamSenser = b; | |||
} | |||
}); | |||
Thread.Sleep(500); | |||
}), "MorkT-传感器监视"); | |||
} | |||
} | |||
public class BoolToColorConvert : IValueConverter | |||
{ | |||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) | |||
{ | |||
return (bool) value? new SolidColorBrush(Color.FromRgb(144, 238, 144)) : new SolidColorBrush(Color.FromRgb(178, 34, 34)); | |||
} | |||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) | |||
{ | |||
throw new NotImplementedException(); | |||
} | |||
} | |||
} |
@@ -6,4 +6,8 @@ | |||
<UseWPF>true</UseWPF> | |||
</PropertyGroup> | |||
<ItemGroup> | |||
<ProjectReference Include="..\BPASmartClient.Device\BPASmartClient.Device.csproj" /> | |||
</ItemGroup> | |||
</Project> |
@@ -1,8 +0,0 @@ | |||
using System; | |||
namespace BPASmartClient.Morkt.JAKA.JC | |||
{ | |||
public class Class1 | |||
{ | |||
} | |||
} |
@@ -0,0 +1,828 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Configuration; | |||
using System.Linq; | |||
using System.Threading; | |||
using System.Collections.Concurrent; | |||
using System.Diagnostics; | |||
using System.Threading.Tasks; | |||
using BPASmartClient.Device; | |||
using BPA.Message.Enum; | |||
using BPA.Message; | |||
using BPASmartClient.Helper; | |||
using BPASmartClient.Model.咖啡机.Enum; | |||
using BPASmartClient.Model; | |||
using BPASmartClient.EventBus; | |||
using static BPASmartClient.EventBus.EventBus; | |||
using BPASmartClient.Model.PLC; | |||
using BPASmartClient.Model.单片机; | |||
namespace BPASmartClient.MorktJAKAJC | |||
{ | |||
/* | |||
* 冰淇淋咖啡机组合套装 | |||
* 物料位置: | |||
* 1:冰淇料 | |||
* 2:冰淇淋杯 | |||
* 5:咖啡 | |||
* 6:咖啡杯 | |||
* 9: 茶 | |||
* 10: 茶杯 | |||
*/ | |||
public class Control_MORKJC : BaseDevice | |||
{ | |||
GVL_MORKJC mORKD = new GVL_MORKJC(); | |||
//咖啡机主控程序 | |||
//private CoffeeMachine coffeeMachine; | |||
////果汁机主控程序 | |||
//private JuicerMachine juicerMachine; | |||
////单片机主控程序 | |||
//private ICChipMachine icchipMachine; | |||
//物料存放位置 | |||
private Dictionary<string, PolymerBatching> batchings = new Dictionary<string, PolymerBatching>(); | |||
//容器位置 | |||
private string holderLoc; | |||
//主料位置 | |||
private string mainMaterialLoc; | |||
//子订单ID | |||
private string subOrderId; | |||
private bool enableFunny = false; | |||
private DateTime lastRecvdOrder = DateTime.Now; | |||
private bool working = false; | |||
/// <summary> | |||
/// 果汁机做法,true:热饮,false:冷饮 | |||
/// </summary> | |||
private bool GuMake = false; | |||
private void OrderChange(string subid, ORDER_STATUS oRDER_STATUS) | |||
{ | |||
EventBus.EventBus.GetInstance().Publish(new OrderStatusChangedEvent() { Status = oRDER_STATUS, SubOrderId = subid, deviceClientType = DeviceType }); | |||
} | |||
//private SerialPortClient commProxy; | |||
public void ConnectOk() | |||
{ | |||
} | |||
ConcurrentQueue<MorkOrderPush> morkOrderPushes = new ConcurrentQueue<MorkOrderPush>(); | |||
public void Init() | |||
{ | |||
ActionManage.GetInstance.Register(new Action<object>((s) => | |||
{ | |||
if (s is DrCoffeeDrinksCode cf) | |||
{ | |||
mainMaterialLoc = ((int)cf).ToString(); | |||
DoCoffee(); | |||
} | |||
}), "SimCoffee"); | |||
//构建所有商品物料信息 | |||
batchings = PolymerBatching.BuildAll(); | |||
EventBus.EventBus.GetInstance().Subscribe<DRCoffee_CoffeEndCookEvent>(DeviceId, DRCoffee_CoffeEndCookEventHandle); | |||
System.Configuration.Configuration config = System.Configuration.ConfigurationManager.OpenExeConfiguration(System.Configuration.ConfigurationUserLevel.None); | |||
//一系列外围基础配置 | |||
var com_Coffee = config.AppSettings.Settings["COM_Coffee"].Value; | |||
var baud_Coffee = config.AppSettings.Settings["BAUD_Coffee"].Value; | |||
//咖啡机创建 | |||
//coffeeMachine = new CoffeeMachine(com_Coffee, (BaudRates)Enum.Parse(typeof(BaudRates), baud_Coffee)); | |||
Main(); | |||
ReadData(); | |||
ThreadManage.GetInstance().StartLong(new Action(() => | |||
{ | |||
while (morkOrderPushes.Count > 0) | |||
{ | |||
while (enableFunny) { Thread.Sleep(10); } | |||
DeviceProcessLogShow("当前非自嗨模式,允许开工"); | |||
working = true; | |||
if (morkOrderPushes.TryDequeue(out MorkOrderPush order)) | |||
{ | |||
DeviceProcessLogShow($"开始制作订单[{order.SortNum}]"); | |||
//商品类型 | |||
GOODS_TYPE currentGoodsType = GOODS_TYPE.NEITHER; | |||
//子订单ID | |||
subOrderId = order.SuborderId; | |||
//遍历物料 | |||
foreach (var item in order.GoodBatchings) | |||
{ | |||
var res = Json<BatchingInfoPar>.Data.orderMaterialDelivery.BatchingInfo.FirstOrDefault(p => p.BatchingId == item.BatchingId); | |||
if (res != null) | |||
{ | |||
//获取主料和容器位置 | |||
switch (batchings[res.BatchingLoc].BatchingClass) | |||
{ | |||
case BATCHING_CLASS.HOLDER: | |||
holderLoc = res.BatchingLoc; | |||
break; | |||
case BATCHING_CLASS.MAIN_MATERIAL: | |||
// mainMaterialLoc ="1"; | |||
mainMaterialLoc = res.BatchingLoc; | |||
//验证商品是咖啡还是冰淇淋 | |||
if (ValidateGoodsByBatching(res.BatchingLoc) != GOODS_TYPE.NEITHER) | |||
{ | |||
//获取当前物料所属商品类型 | |||
currentGoodsType = ValidateGoodsByBatching(res.BatchingLoc); | |||
} | |||
break; | |||
} | |||
} | |||
} | |||
//根据商品类型执行具体制作流程 | |||
switch (currentGoodsType) | |||
{ | |||
case GOODS_TYPE.COFFEE: | |||
DoCoffee(); | |||
break; | |||
case GOODS_TYPE.JUICE: | |||
GuMake = order.MakeID == "2"; | |||
DoJuicer(); | |||
break; | |||
case GOODS_TYPE.TEA: | |||
DoTea(); | |||
break; | |||
case GOODS_TYPE.WATER: | |||
DoWater(); | |||
break; | |||
case GOODS_TYPE.NEITHER: | |||
DeviceProcessLogShow("未知的商品类型"); | |||
break; | |||
} | |||
} | |||
working = false; | |||
lastRecvdOrder = DateTime.Now; | |||
} | |||
Thread.Sleep(1000); | |||
}), "订单制作"); | |||
} | |||
public void Main() | |||
{ | |||
//咖啡机开启主线程 | |||
//coffeeMachine.Start(); | |||
//开始心跳刷新,根据咖啡机及冰淇淋机来判断 | |||
ThreadManage.GetInstance().StartLong(new Action(() => | |||
{ | |||
//IsHealth = | |||
// Write.IsConnected && | |||
// MorkCStatus.GetInstance().CanDo && | |||
// JuicerHelper.GetInstance.IsOpen && | |||
// MCUSerialHelper.GetInstance.IsOpen; | |||
//GeneralConfig.Healthy = true; | |||
Thread.Sleep(100); | |||
}), "MORK-IC心跳刷新"); | |||
//ThreadManage.GetInstance().Start(new Action(() => | |||
//{ | |||
// while (!Write.IsConnected) | |||
// { | |||
// Thread.Sleep(10); | |||
// } | |||
// //LebaiHelper.GetInstance.Scene(LebaiHelper.SENCE_欢迎); | |||
//}), "MORK-JC欢迎"); | |||
} | |||
public void DataParse<T>(T order) | |||
{ | |||
if (order is MorkOrderPush morkOrderPush) | |||
{ | |||
morkOrderPushes.Enqueue(morkOrderPush); | |||
} | |||
} | |||
/// <summary> | |||
/// 验证当前是做咖啡还是做冰淇淋 | |||
/// </summary> | |||
/// <param name="batchingLoc">物料位置</param> | |||
private GOODS_TYPE ValidateGoodsByBatching(string batchingLoc) | |||
{ | |||
if (batchings.ContainsKey(batchingLoc)) | |||
return batchings[batchingLoc].GoodsType; | |||
return GOODS_TYPE.NEITHER; | |||
} | |||
private AutoResetEvent are = new AutoResetEvent(false); | |||
private T GetStatus<T>(string key) | |||
{ | |||
if (peripheralStatus.ContainsKey(key)) | |||
{ | |||
if (peripheralStatus[key] != null) | |||
{ | |||
return (T)(peripheralStatus[key]); | |||
} | |||
} | |||
return default; | |||
} | |||
private void Wait(int value) | |||
{ | |||
while (!((GetStatus<int>("Get_RobotAO1") == value) && GetStatus<int>("GetProgramStatus") == 0))//判断文件是否已经执行结束 且 文件末端变量值==文件名 | |||
{ | |||
Thread.Sleep(5); | |||
} | |||
} | |||
int[] devStatusBy = new int[2] { 0, 0 }; | |||
/// <summary> | |||
/// 传感器的输入信号 0:无意义 1:有信号 2:无信号 3:信号不正确 | |||
/// </summary> | |||
int bSensorInput; | |||
/// <summary> | |||
/// 延迟的超时时间 | |||
/// </summary> | |||
DateTime delayTimeOut; | |||
/// <summary> | |||
/// 做咖啡 | |||
/// </summary> | |||
private void DoCoffee() | |||
{ | |||
#region 接咖啡流程 | |||
are.Reset(); | |||
// OrderChange(subOrderId, BPA.Message.Enum.ORDER_STATUS.COOKING); | |||
OrderChange(subOrderId, BPA.Message.Enum.ORDER_STATUS.COOKING); | |||
int resultTakeCup = takeCup(); | |||
if (resultTakeCup == 1) | |||
{ | |||
DeviceProcessLogShow("咖啡杯取杯完成"); | |||
new WriteJaka() { TagName = "JaKaProgramName", Value = JakaModel.SENCE_接咖啡 }.Publish(); | |||
// Write("JaKaProgramName",JakaModel.SENCE_接咖啡); | |||
Wait(int.Parse(JakaModel.SENCE_接咖啡)); | |||
new DRCoffee_MakeCoffeeEvent() { DeviceId = DeviceId, DrinkCode = (DrCoffeeDrinksCode)int.Parse(mainMaterialLoc) }.Publish(); //接咖啡控制 //DrCoffeeDrinksCode.热水 | |||
are.WaitOne(1000 * 180); | |||
new WriteJaka() { TagName = "JaKaProgramName", Value = JakaModel.SENCE_放咖啡杯 }.Publish(); | |||
Wait(int.Parse(JakaModel.SENCE_放咖啡杯)); | |||
int resultputCup = putCup(); | |||
if (resultputCup == 1) | |||
{ | |||
//订单状态改变:完成 | |||
new WriteJaka() { TagName = "JaKaProgramName", Value = JakaModel.SENCE_初始位 }.Publish(); | |||
Wait(int.Parse(JakaModel.SENCE_初始位)); | |||
OrderChange(subOrderId, BPA.Message.Enum.ORDER_STATUS.COMPLETED_TAKE); | |||
} | |||
else | |||
{ | |||
new WriteJaka() { TagName = "JaKaProgramName", Value = JakaModel.SENCE_初始位 }.Publish(); | |||
Wait(int.Parse(JakaModel.SENCE_初始位)); | |||
} | |||
} | |||
else if (resultTakeCup == 2 || resultTakeCup == 3) | |||
{ | |||
new WriteJaka() { TagName = "JaKaProgramName", Value = JakaModel.SENCE_初始位 }.Publish(); | |||
Wait(int.Parse(JakaModel.SENCE_初始位)); | |||
} | |||
#endregion | |||
} | |||
/// <summary> | |||
/// 做茶 | |||
/// </summary> | |||
private void DoTea() | |||
{ | |||
#region 接茶流程 | |||
OrderChange(subOrderId, BPA.Message.Enum.ORDER_STATUS.COOKING); | |||
int resultTakeCup = takeCup(); | |||
if (resultTakeCup == 1) | |||
{ | |||
DeviceProcessLogShow("取茶杯完成"); | |||
new WriteJaka() { TagName = "JaKaProgramName", Value = JakaModel.SENCE_接茶 }.Publish(); | |||
Wait(int.Parse(JakaModel.SENCE_接茶)); | |||
new WriteMcu() { TagName = "ServoControl", Address = "1", Value = 105 }.Publish(); | |||
Thread.Sleep(1000); | |||
new WriteMcu() { TagName = "ServoControl", Address = "1", Value = 130 }.Publish(); | |||
Thread.Sleep(1000); | |||
new WriteMcu() { TagName = "ServoControl", Address = "1", Value = 105 }.Publish(); | |||
Thread.Sleep(3000); | |||
new WriteJaka() { TagName = "JaKaProgramName", Value = JakaModel.SENCE_接茶_接水 }.Publish(); | |||
Wait(int.Parse(JakaModel.SENCE_接茶_接水)); | |||
new WriteMcu() { TagName = "OutputControl", Value = false, Address = "4" }.Publish(); | |||
new WriteMcu() { TagName = "OutputControl", Value = false, Address = "3" }.Publish(); | |||
Thread.Sleep(100); | |||
new WriteMcu() { TagName = "OutputControl", Value = true, Address = "3" }.Publish(); | |||
Thread.Sleep(3000); | |||
new WriteMcu() { TagName = "OutputControl", Value = false, Address = "3" }.Publish(); | |||
Thread.Sleep(100); | |||
new WriteMcu() { TagName = "OutputControl", Value = false, Address = "4" }.Publish(); | |||
Thread.Sleep(100); | |||
new WriteMcu() { TagName = "OutputControl", Value = true, Address = "4" }.Publish(); | |||
Thread.Sleep(500); | |||
new WriteMcu() { TagName = "OutputControl", Value = false, Address = "4" }.Publish(); | |||
Thread.Sleep(50000); | |||
new WriteJaka() { TagName = "JaKaProgramName", Value = JakaModel.SENCE_放茶水杯 }.Publish(); | |||
Wait(int.Parse(JakaModel.SENCE_放茶水杯)); | |||
int resultputCup = putCup(); | |||
if (resultputCup == 1) | |||
{ | |||
new WriteJaka() { TagName = "JaKaProgramName", Value = JakaModel.SENCE_初始位 }.Publish(); | |||
Wait(int.Parse(JakaModel.SENCE_初始位)); | |||
OrderChange(subOrderId, BPA.Message.Enum.ORDER_STATUS.COMPLETED_TAKE); | |||
} | |||
else | |||
{ | |||
new WriteJaka() { TagName = "JaKaProgramName", Value = JakaModel.SENCE_初始位 }.Publish(); | |||
Wait(int.Parse(JakaModel.SENCE_初始位)); | |||
} | |||
} | |||
else if (resultTakeCup == 2 || resultTakeCup == 3) | |||
{ | |||
new WriteJaka() { TagName = "JaKaProgramName", Value = JakaModel.SENCE_初始位 }.Publish(); | |||
Wait(int.Parse(JakaModel.SENCE_初始位)); | |||
} | |||
#endregion | |||
} | |||
/// <summary> | |||
/// 接开水 | |||
/// </summary> | |||
private void DoWater() | |||
{ | |||
#region 接水流程 | |||
OrderChange(subOrderId, BPA.Message.Enum.ORDER_STATUS.COOKING); | |||
int resultTakeCup = takeCup(); | |||
if (resultTakeCup == 1) | |||
{ | |||
new WriteJaka() { TagName = "JaKaProgramName", Value = JakaModel.SENCE_接水 }.Publish(); | |||
Wait(int.Parse(JakaModel.SENCE_接水)); | |||
new WriteMcu() { TagName = "OutputControl", Value = false, Address = "4" }.Publish(); | |||
new WriteMcu() { TagName = "OutputControl", Value = false, Address = "3" }.Publish(); | |||
Thread.Sleep(100); | |||
new WriteMcu() { TagName = "OutputControl", Value = true, Address = "3" }.Publish(); | |||
Thread.Sleep(3000); | |||
new WriteMcu() { TagName = "OutputControl", Value = false, Address = "3" }.Publish(); | |||
Thread.Sleep(100); | |||
new WriteMcu() { TagName = "OutputControl", Value = false, Address = "4" }.Publish(); | |||
Thread.Sleep(100); | |||
new WriteMcu() { TagName = "OutputControl", Value = true, Address = "4" }.Publish(); | |||
Thread.Sleep(500); | |||
new WriteMcu() { TagName = "OutputControl", Value = false, Address = "4" }.Publish(); | |||
Thread.Sleep(50000); | |||
//添加控制接水机构程序 | |||
new WriteJaka() { TagName = "JaKaProgramName", Value = JakaModel.SENCE_放茶水杯 }.Publish(); | |||
Wait(int.Parse(JakaModel.SENCE_放茶水杯)); | |||
int resultputCup = putCup(); | |||
if (resultputCup == 1) | |||
{ | |||
new WriteJaka() { TagName = "JaKaProgramName", Value = JakaModel.SENCE_初始位 }.Publish(); | |||
Wait(int.Parse(JakaModel.SENCE_初始位)); | |||
OrderChange(subOrderId, BPA.Message.Enum.ORDER_STATUS.COMPLETED_TAKE); | |||
} | |||
else | |||
{ | |||
new WriteJaka() { TagName = "JaKaProgramName", Value = JakaModel.SENCE_初始位 }.Publish(); | |||
Wait(int.Parse(JakaModel.SENCE_初始位)); | |||
} | |||
} | |||
else if (resultTakeCup == 2 || resultTakeCup == 3) | |||
{ | |||
new WriteJaka() { TagName = "JaKaProgramName", Value = JakaModel.SENCE_初始位 }.Publish(); | |||
Wait(int.Parse(JakaModel.SENCE_初始位)); | |||
} | |||
#endregion | |||
} | |||
/// <summary> | |||
/// 果汁机控制信号 | |||
/// </summary> | |||
private byte JuicerNum; | |||
/// <summary> | |||
/// 做果汁 | |||
/// </summary> | |||
private void DoJuicer() | |||
{ | |||
#region 接果汁流程 | |||
are.Reset(); | |||
OrderChange(subOrderId, BPA.Message.Enum.ORDER_STATUS.COOKING); | |||
int resultTakeCup = takeCup(); | |||
if (resultTakeCup == 1) | |||
{ | |||
int JuicerNum1 = int.Parse(mainMaterialLoc); | |||
switch (JuicerNum1) | |||
{ | |||
case 52: | |||
if (GuMake) | |||
{ | |||
JuicerNum = 0x00; | |||
} | |||
else | |||
{ | |||
JuicerNum = 0x01; | |||
} | |||
new WriteJaka() { TagName = "JaKaProgramName", Value = JakaModel.SENCE_接果汁1 }.Publish(); | |||
Wait(int.Parse(JakaModel.SENCE_接果汁1)); | |||
break; | |||
case 53: | |||
if (GuMake) | |||
{ | |||
JuicerNum = 0x02; | |||
} | |||
else | |||
{ | |||
JuicerNum = 0x03; | |||
} | |||
new WriteJaka() { TagName = "JaKaProgramName", Value = JakaModel.SENCE_接果汁2 }.Publish(); | |||
Wait(int.Parse(JakaModel.SENCE_接果汁2)); | |||
break; | |||
case 54: | |||
if (GuMake) | |||
{ | |||
JuicerNum = 0x04; | |||
} | |||
else | |||
{ | |||
JuicerNum = 0x05; | |||
} | |||
new WriteJaka() { TagName = "JaKaProgramName", Value = JakaModel.SENCE_接果汁3 }.Publish(); | |||
Wait(int.Parse(JakaModel.SENCE_接果汁3)); | |||
break; | |||
case 55: | |||
if (GuMake) | |||
{ | |||
JuicerNum = 0x06; | |||
} | |||
else | |||
{ | |||
JuicerNum = 0x07; | |||
} | |||
new WriteJaka() { TagName = "JaKaProgramName", Value = JakaModel.SENCE_接果汁4 }.Publish(); | |||
Wait(int.Parse(JakaModel.SENCE_接果汁4)); | |||
break; | |||
default: | |||
JuicerNum = 0x00; | |||
new WriteJaka() { TagName = "JaKaProgramName", Value = JakaModel.SENCE_接果汁1 }.Publish(); | |||
Wait(int.Parse(JakaModel.SENCE_接果汁1)); | |||
break; | |||
} | |||
var devStatus = GetStatus<int[]>("GetDeviceStatus"); | |||
var devStatus1 = Convert.ToString(devStatus[0], 2); | |||
var devStatus2 = devStatus[1]; | |||
if (devStatus1.IndexOf("0") == 1 && devStatus2 == 0) | |||
{ | |||
if (sensor_Sign(1) == 1) | |||
{ | |||
new WriteJuicer() { Value = JuicerNum }.Publish(); | |||
} | |||
Thread.Sleep(100); | |||
devStatusBy = GetStatus<int[]>("GetDeviceStatus"); | |||
while (!(devStatusBy[1] == 0)) | |||
{ | |||
Thread.Sleep(100); | |||
devStatusBy = GetStatus<int[]>("GetDeviceStatus"); | |||
while (devStatusBy.Length != 2) | |||
{ | |||
Thread.Sleep(100); | |||
devStatusBy = GetStatus<int[]>("GetDeviceStatus"); | |||
} | |||
} | |||
devStatusBy = GetStatus<int[]>("GetDeviceStatus"); | |||
Thread.Sleep(5000); | |||
switch (JuicerNum1) | |||
{ | |||
case 52: | |||
new WriteJaka() { TagName = "JaKaProgramName", Value = JakaModel.SENCE_放果汁杯1 }.Publish(); | |||
Wait(int.Parse(JakaModel.SENCE_放果汁杯1)); | |||
break; | |||
case 53: | |||
new WriteJaka() { TagName = "JaKaProgramName", Value = JakaModel.SENCE_放果汁杯2 }.Publish(); | |||
Wait(int.Parse(JakaModel.SENCE_放果汁杯2)); | |||
break; | |||
case 54: | |||
new WriteJaka() { TagName = "JaKaProgramName", Value = JakaModel.SENCE_放果汁杯3 }.Publish(); | |||
Wait(int.Parse(JakaModel.SENCE_放果汁杯3)); | |||
break; | |||
case 55: | |||
new WriteJaka() { TagName = "JaKaProgramName", Value = JakaModel.SENCE_放果汁杯4 }.Publish(); | |||
Wait(int.Parse(JakaModel.SENCE_放果汁杯4)); | |||
break; | |||
default: | |||
new WriteJaka() { TagName = "JaKaProgramName", Value = JakaModel.SENCE_放果汁杯1 }.Publish(); | |||
Wait(int.Parse(JakaModel.SENCE_放果汁杯1)); | |||
break; | |||
} | |||
int resultputCup = putCup(); | |||
if (resultputCup == 1) | |||
{ | |||
new WriteJaka() { TagName = "JaKaProgramName", Value = JakaModel.SENCE_初始位 }.Publish(); | |||
Wait(int.Parse(JakaModel.SENCE_初始位)); | |||
OrderChange(subOrderId, BPA.Message.Enum.ORDER_STATUS.COMPLETED_TAKE); | |||
} | |||
else | |||
{ | |||
new WriteJaka() { TagName = "JaKaProgramName", Value = JakaModel.SENCE_初始位 }.Publish(); | |||
Wait(int.Parse(JakaModel.SENCE_初始位)); | |||
} | |||
} | |||
else | |||
{ | |||
switch (JuicerNum1) | |||
{ | |||
case 52: | |||
new WriteJaka() { TagName = "JaKaProgramName", Value = JakaModel.SENCE_放果汁杯1 }.Publish(); | |||
Wait(int.Parse(JakaModel.SENCE_放果汁杯1)); | |||
break; | |||
case 53: | |||
new WriteJaka() { TagName = "JaKaProgramName", Value = JakaModel.SENCE_放果汁杯2 }.Publish(); | |||
Wait(int.Parse(JakaModel.SENCE_放果汁杯2)); | |||
break; | |||
case 54: | |||
new WriteJaka() { TagName = "JaKaProgramName", Value = JakaModel.SENCE_放果汁杯3 }.Publish(); | |||
Wait(int.Parse(JakaModel.SENCE_放果汁杯3)); | |||
break; | |||
case 55: | |||
new WriteJaka() { TagName = "JaKaProgramName", Value = JakaModel.SENCE_放果汁杯4 }.Publish(); | |||
Wait(int.Parse(JakaModel.SENCE_放果汁杯4)); | |||
break; | |||
default: | |||
new WriteJaka() { TagName = "JaKaProgramName", Value = JakaModel.SENCE_放果汁杯1 }.Publish(); | |||
Wait(int.Parse(JakaModel.SENCE_放果汁杯1)); | |||
break; | |||
} | |||
int resultputCup = putCup(); | |||
if (resultputCup == 1) | |||
{ | |||
new WriteJaka() { TagName = "JaKaProgramName", Value = JakaModel.SENCE_初始位 }.Publish(); | |||
Wait(int.Parse(JakaModel.SENCE_初始位)); | |||
OrderChange(subOrderId, BPA.Message.Enum.ORDER_STATUS.COMPLETED_TAKE); | |||
} | |||
else | |||
{ | |||
new WriteJaka() { TagName = "JaKaProgramName", Value = JakaModel.SENCE_初始位 }.Publish(); | |||
Wait(int.Parse(JakaModel.SENCE_初始位)); | |||
} | |||
} | |||
} | |||
else if (resultTakeCup == 2 || resultTakeCup == 3) | |||
{ | |||
new WriteJaka() { TagName = "JaKaProgramName", Value = JakaModel.SENCE_初始位 }.Publish(); | |||
Wait(int.Parse(JakaModel.SENCE_初始位)); | |||
} | |||
#endregion | |||
} | |||
private int getCup_cnt; | |||
/// <summary> | |||
/// 取杯流程 | |||
/// </summary> | |||
/// <returns>0:无意义,1:取杯成功 2:机构有杯子,取杯失败 3:机构没有杯子</returns> | |||
private int takeCup() | |||
{ | |||
try | |||
{ | |||
getCup_cnt = 0;//取杯次数复位 | |||
new WriteJaka() { TagName = "Set_RobotAO1", Value = 0 }.Publish(); | |||
Wait(0); | |||
new WriteJaka() { TagName = "JaKaProgramName", Value = JakaModel.SENCE_初始位 }.Publish(); | |||
Wait(int.Parse(JakaModel.SENCE_初始位)); | |||
new WriteMcu() { TagName = "OutputControl", Address = "1", Value = true }.Publish(); | |||
Thread.Sleep(10); | |||
new WriteMcu() { TagName = "OutputControl", Address = "1", Value = true }.Publish(); | |||
new WriteJaka() { TagName = "Set_RobotAO1", Value = 0 }.Publish(); | |||
Wait(0); | |||
new WriteJaka() { TagName = "JaKaProgramName", Value = JakaModel.SENCE_取杯 }.Publish(); | |||
Wait(int.Parse(JakaModel.SENCE_取杯)); | |||
bSensorInput = sensor_Sign(1); | |||
if (bSensorInput == 2) | |||
{ | |||
Thread.Sleep(100); | |||
new WriteMcu() { TagName = "OutputControl", Address = "1", Value = false }.Publish(); | |||
new WriteMcu() { TagName = "OutputControl", Address = "1", Value = false }.Publish(); | |||
Thread.Sleep(100); | |||
new WriteJaka() { TagName = "JaKaProgramName", Value = JakaModel.SENCE_取杯检测 }.Publish(); | |||
Wait(int.Parse(JakaModel.SENCE_取杯检测)); | |||
DeviceProcessLogShow("落杯器没有纸杯了"); | |||
return 3; | |||
} | |||
if (bSensorInput == 1) | |||
{ | |||
Thread.Sleep(100); | |||
new WriteMcu() { TagName = "OutputControl", Address = "1", Value = false }.Publish(); | |||
new WriteMcu() { TagName = "OutputControl", Address = "1", Value = false }.Publish(); | |||
Thread.Sleep(100); | |||
new WriteJaka() { TagName = "JaKaProgramName", Value = JakaModel.SENCE_取杯检测 }.Publish(); | |||
Wait(int.Parse(JakaModel.SENCE_取杯检测)); | |||
bSensorInput = sensor_Sign(1); | |||
/*delayTimeOut = DateTime.Now; | |||
bSensorInput = sensor_Sign(1); | |||
while (bSensorInput == 3) | |||
{ | |||
Thread.Sleep(100); | |||
bSensorInput = sensor_Sign(1); | |||
}*/ | |||
while (getCup_cnt < 4 && (bSensorInput == 2 || bSensorInput == 3)) | |||
{ | |||
DeviceProcessLogShow($"第{getCup_cnt}次取杯失败"); | |||
Thread.Sleep(100); | |||
new WriteMcu() { TagName = "OutputControl", Address = "1", Value = true }.Publish(); | |||
new WriteMcu() { TagName = "OutputControl", Address = "1", Value = true }.Publish(); | |||
Thread.Sleep(100); | |||
new WriteJaka() { TagName = "JaKaProgramName", Value = JakaModel.SENCE_取杯 }.Publish(); | |||
Wait(int.Parse(JakaModel.SENCE_取杯)); | |||
getCup_cnt = getCup_cnt + 1; | |||
Thread.Sleep(100); | |||
new WriteMcu() { TagName = "OutputControl", Address = "1", Value = false }.Publish(); | |||
new WriteMcu() { TagName = "OutputControl", Address = "1", Value = false }.Publish(); | |||
Thread.Sleep(100); | |||
new WriteJaka() { TagName = "JaKaProgramName", Value = JakaModel.SENCE_取杯检测 }.Publish(); | |||
Wait(int.Parse(JakaModel.SENCE_取杯检测)); | |||
bSensorInput = sensor_Sign(1); | |||
} | |||
if (bSensorInput == 1) | |||
{ | |||
return 1; | |||
} | |||
else | |||
{ | |||
return 2; | |||
} | |||
} | |||
return 1; | |||
} | |||
catch (Exception ex) | |||
{ | |||
DeviceProcessLogShow(ex.ToString()); | |||
return 0; | |||
} | |||
} | |||
/// <summary> | |||
/// 放杯 | |||
/// </summary> | |||
/// <returns>0:无意义 1:执行成功 2:执行失败(传感器还有信号)</returns> | |||
private int putCup() | |||
{ | |||
try | |||
{ | |||
while (checkCup() == 2) | |||
{ | |||
Thread.Sleep(100); | |||
} | |||
new WriteJaka() { TagName = "JaKaProgramName", Value = JakaModel.SENCE_放杯 }.Publish(); | |||
Wait(int.Parse(JakaModel.SENCE_放杯)); | |||
new WriteMcu() { TagName = "OutputControl", Address = "1", Value = true }.Publish(); | |||
Thread.Sleep(10); | |||
new WriteMcu() { TagName = "OutputControl", Address = "1", Value = true }.Publish(); | |||
Thread.Sleep(10); | |||
new WriteJaka() { TagName = "JaKaProgramName", Value = JakaModel.SENCE_放杯检测 }.Publish(); | |||
Wait(int.Parse(JakaModel.SENCE_放杯检测)); | |||
bSensorInput = sensor_Sign(2); | |||
delayTimeOut = DateTime.Now; | |||
while (bSensorInput == 2) | |||
{ | |||
Thread.Sleep(100); | |||
bSensorInput = sensor_Sign(2); | |||
if (DateTime.Now.Subtract(delayTimeOut).TotalSeconds >= 2) return 2; | |||
} | |||
if (bSensorInput == 2) | |||
{ | |||
DeviceProcessLogShow("放杯失败传感器没有信号"); | |||
new WriteJaka() { TagName = "JaKaProgramName", Value = JakaModel.SENCE_初始位 }.Publish(); | |||
Wait(int.Parse(JakaModel.SENCE_初始位)); | |||
return 1; | |||
} | |||
return 1; | |||
} | |||
catch (Exception ex) | |||
{ | |||
DeviceProcessLogShow(ex.ToString()); | |||
return 0; | |||
} | |||
} | |||
private int cnt_Check; | |||
public override DeviceClientType DeviceType => throw new NotImplementedException(); | |||
/// <summary> | |||
/// 检测放杯位,是否有杯子 | |||
/// </summary> | |||
/// <returns>0:无意义 1:没有杯子 2:有杯子 </returns> | |||
private int checkCup() | |||
{ | |||
try | |||
{ | |||
//cnt_Check = 0; | |||
bSensorInput = sensor_Sign(2); | |||
if (bSensorInput == 2) | |||
{ | |||
DeviceProcessLogShow($"放杯位传感器没有信号:{cnt_Check}"); | |||
return 1; | |||
} | |||
else if (bSensorInput == 1) | |||
{ | |||
DeviceProcessLogShow($"放杯位传感器有信号:{cnt_Check}"); | |||
return 2; | |||
} | |||
return 2; | |||
} | |||
catch (Exception ex) | |||
{ | |||
DeviceProcessLogShow(ex.ToString()); | |||
return 0; | |||
} | |||
} | |||
private T McuRead<T>(string tagName, object par) | |||
{ | |||
new ReadMcu() { DeviceId = DeviceId, TagName = tagName, ReadPar = par }; | |||
if (peripheralStatus.ContainsKey(tagName)) | |||
{ | |||
if (peripheralStatus[tagName] != null) | |||
{ | |||
return (T)peripheralStatus[tagName]; | |||
} | |||
} | |||
return default; | |||
} | |||
/// <summary> | |||
/// 传感器防抖0.2s内检测20次, | |||
/// </summary> | |||
/// <param name="num"></param> | |||
/// <returns></returns> | |||
private int sensor_Sign(byte num) | |||
{ | |||
DeviceProcessLogShow($"开始检测{num}号传感器信号"); | |||
int cnt = 0; | |||
cnt_Check = 0; | |||
while (true) | |||
{ | |||
Thread.Sleep(10); | |||
bSensorInput = McuRead<int>("GetInputStatus", num); | |||
if (bSensorInput == 1) | |||
{ | |||
cnt_Check = cnt_Check + 1; | |||
cnt = cnt + 1; | |||
} | |||
else if (bSensorInput == 2) | |||
{ | |||
cnt_Check = cnt_Check - 1; | |||
cnt = cnt + 1; | |||
} | |||
if (cnt >= 20) | |||
{ | |||
break; | |||
} | |||
} | |||
if (cnt_Check >= 0) | |||
{ | |||
DeviceProcessLogShow($"{num}传感器有信号:{cnt_Check}"); | |||
return 1; | |||
} | |||
else | |||
{ | |||
DeviceProcessLogShow($"{num}传感器没有信号:{cnt_Check}"); | |||
return 2; | |||
} | |||
} | |||
private void DRCoffee_CoffeEndCookEventHandle(IEvent @event, EventCallBackHandle callBack) | |||
{ | |||
are.Set(); | |||
} | |||
public void SimOrder<T>(T simOrder) | |||
{ | |||
} | |||
public override void DoMain() | |||
{ | |||
} | |||
public override void Stop() | |||
{ | |||
} | |||
public override void ReadData() | |||
{ | |||
} | |||
public override void MainTask() | |||
{ | |||
} | |||
public override void ResetProgram() | |||
{ | |||
} | |||
} | |||
} |
@@ -0,0 +1,8 @@ | |||
using BPASmartClient.Device; | |||
namespace BPASmartClient.MorktJAKAJC | |||
{ | |||
public class GVL_MORKJC : IStatus | |||
{ | |||
} | |||
} |
@@ -0,0 +1,152 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace BPASmartClient.MorktJAKAJC | |||
{ | |||
internal enum GOODS_TYPE | |||
{ | |||
/// <summary> | |||
/// 未知 | |||
/// </summary> | |||
NEITHER, | |||
/// <summary> | |||
/// 咖啡 | |||
/// </summary> | |||
COFFEE, | |||
/// <summary> | |||
/// 果汁 | |||
/// </summary> | |||
JUICE, | |||
/// <summary> | |||
/// 茶水 | |||
/// </summary> | |||
TEA, | |||
/// <summary> | |||
/// 水 | |||
/// </summary> | |||
WATER, | |||
/// <summary> | |||
/// 杯子 | |||
/// </summary> | |||
CUP | |||
} | |||
internal enum BATCHING_CLASS | |||
{ | |||
HOLDER, | |||
MAIN_MATERIAL, | |||
} | |||
internal class PolymerBatching | |||
{ | |||
internal const string Juicer_MAIN_BATCHIN1_LOC = "52"; | |||
internal const string Juicer_MAIN_BATCHIN2_LOC = "53"; | |||
internal const string Juicer_MAIN_BATCHIN3_LOC = "54"; | |||
internal const string Juicer_MAIN_BATCHIN4_LOC = "55"; | |||
//internal const string Juicer_MAIN_BATCHIN5_LOC = "56"; | |||
//internal const string Juicer_MAIN_BATCHIN6_LOC = "57"; | |||
//internal const string Juicer_MAIN_BATCHIN7_LOC = "58"; | |||
//internal const string Juicer_MAIN_BATCHIN8_LOC = "59"; | |||
internal const string COFFEE_HOLDER_LOC = "30"; | |||
internal const string TEA_HOLDER_LOC = "51"; | |||
public static Dictionary<string, GOODS_TYPE> GOODS_TYPES = new Dictionary<string, GOODS_TYPE>() { | |||
{"1", GOODS_TYPE.COFFEE}, | |||
{"2", GOODS_TYPE.COFFEE}, | |||
{"3", GOODS_TYPE.COFFEE}, | |||
{"4", GOODS_TYPE.COFFEE}, | |||
{"5", GOODS_TYPE.COFFEE}, | |||
{"6", GOODS_TYPE.COFFEE}, | |||
{"7", GOODS_TYPE.COFFEE}, | |||
{"8", GOODS_TYPE.COFFEE}, | |||
{"9", GOODS_TYPE.COFFEE}, | |||
{"10",GOODS_TYPE.COFFEE}, | |||
{"11",GOODS_TYPE.COFFEE}, | |||
{"12",GOODS_TYPE.COFFEE}, | |||
{"13",GOODS_TYPE.COFFEE}, | |||
{"14",GOODS_TYPE.COFFEE}, | |||
{"15",GOODS_TYPE.COFFEE}, | |||
{"16",GOODS_TYPE.COFFEE}, | |||
{"17",GOODS_TYPE.COFFEE}, | |||
{"18",GOODS_TYPE.COFFEE}, | |||
{"19",GOODS_TYPE.COFFEE}, | |||
{"20",GOODS_TYPE.COFFEE}, | |||
{"21",GOODS_TYPE.COFFEE}, | |||
{"22",GOODS_TYPE.COFFEE}, | |||
{"23",GOODS_TYPE.COFFEE}, | |||
{"24",GOODS_TYPE.COFFEE}, | |||
{"25",GOODS_TYPE.COFFEE}, | |||
{ COFFEE_HOLDER_LOC,GOODS_TYPE.CUP}, | |||
{"56",GOODS_TYPE.TEA }, | |||
{Juicer_MAIN_BATCHIN1_LOC,GOODS_TYPE.JUICE}, | |||
{Juicer_MAIN_BATCHIN2_LOC,GOODS_TYPE.JUICE}, | |||
{Juicer_MAIN_BATCHIN3_LOC,GOODS_TYPE.JUICE}, | |||
{Juicer_MAIN_BATCHIN4_LOC,GOODS_TYPE.JUICE}, | |||
{"61",GOODS_TYPE.WATER}, | |||
//{Juicer_MAIN_BATCHIN5_LOC,GOODS_TYPE.JUICE}, | |||
//{Juicer_MAIN_BATCHIN6_LOC,GOODS_TYPE.JUICE}, | |||
//{Juicer_MAIN_BATCHIN7_LOC,GOODS_TYPE.JUICE}, | |||
//{Juicer_MAIN_BATCHIN8_LOC,GOODS_TYPE.JUICE}, | |||
}; | |||
public GOODS_TYPE GoodsType { get; set; } | |||
public BATCHING_CLASS BatchingClass { get; set; } | |||
private string loc; | |||
public string Loc | |||
{ | |||
get { return loc; } | |||
set | |||
{ | |||
loc = value; | |||
if (GOODS_TYPES.ContainsKey(loc)) | |||
GoodsType = GOODS_TYPES[loc]; | |||
switch (loc) | |||
{ | |||
case COFFEE_HOLDER_LOC: | |||
case TEA_HOLDER_LOC: | |||
BatchingClass = BATCHING_CLASS.HOLDER; | |||
break; | |||
default: | |||
BatchingClass = BATCHING_CLASS.MAIN_MATERIAL; | |||
break; | |||
} | |||
} | |||
} | |||
internal static Dictionary<string, PolymerBatching> BuildAll() | |||
{ | |||
Dictionary<string, PolymerBatching> temp = new Dictionary<string, PolymerBatching>(); | |||
foreach (var item in GOODS_TYPES) | |||
{ | |||
temp.Add(item.Key, new PolymerBatching() { Loc = item.Key }); | |||
} | |||
return temp; | |||
} | |||
//internal static IC_SE GetIceCreamSE(string loc, out string sence) | |||
//{ | |||
// switch (loc) | |||
// { | |||
// case Juicer_MAIN_BATCHIN1_LOC: | |||
// sence = JaKaHelper.SENCE_接果汁1; | |||
// return IC_SE.SE_1; | |||
// case Juicer_MAIN_BATCHIN2_LOC: | |||
// sence = JaKaHelper.SENCE_接果汁2; | |||
// return IC_SE.SE_2; | |||
// case Juicer_MAIN_BATCHIN3_LOC: | |||
// sence = JaKaHelper.SENCE_接果汁3; | |||
// return IC_SE.SE_3; | |||
// default: | |||
// sence = JaKaHelper.SENCE_接果汁1; | |||
// return IC_SE.SE_1; | |||
// } | |||
//} | |||
} | |||
} |
@@ -47,6 +47,13 @@ namespace BPASmartClient.Peripheral | |||
return null; | |||
} | |||
public void SetStatus(string statusName, object value) | |||
{ | |||
if (status.ContainsKey(statusName)) | |||
status[statusName] = value; | |||
else | |||
status.TryAdd(statusName, value); | |||
} | |||
public abstract void Start(); | |||
@@ -54,9 +61,14 @@ namespace BPASmartClient.Peripheral | |||
public abstract void Init(); | |||
//public abstract void ReadData(string address); | |||
public abstract void WriteData(string address, object value); | |||
public ConcurrentDictionary<string, object> GetAllStatus() | |||
{ | |||
return status; | |||
} | |||
} | |||
} |
@@ -53,6 +53,10 @@ namespace BPASmartClient.Peripheral | |||
/// </summary> | |||
ConcurrentDictionary<string, object> status { get; set; } | |||
void WriteData(string address, object value); | |||
//void ReadData(string address); | |||
/// <summary> | |||
/// 初始化 | |||
/// </summary> | |||
@@ -14,7 +14,7 @@ using static BPASmartClient.EventBus.EventBus; | |||
namespace BPASmartClient.SCChip | |||
{ | |||
public class ICChipMachine :BasePeripheral | |||
public class ICChipMachine : BasePeripheral | |||
{ | |||
//通讯代理 | |||
SerialPortClient commProxy = null; | |||
@@ -33,6 +33,43 @@ namespace BPASmartClient.SCChip | |||
/// </summary> | |||
public bool OnLine { get { return DateTime.Now.Subtract(lastRefreshTime).TotalSeconds <= 3; } } | |||
#region 无需上传的数据 | |||
/// <summary> | |||
/// 1号舵机打开完成 | |||
/// </summary> | |||
public bool CompletedOpen_SE_1 { get; set; } | |||
/// <summary> | |||
/// 2号舵机打开完成 | |||
/// </summary> | |||
public bool CompletedOpen_SE_2 { get; set; } | |||
/// <summary> | |||
/// 3号舵机打开完成 | |||
/// </summary> | |||
public bool CompletedOpen_SE_3 { get; set; } | |||
/// <summary> | |||
/// 1号舵机关闭完成 | |||
/// </summary> | |||
public bool CompletedClose_SE_1 { get; set; } | |||
/// <summary> | |||
/// 2号舵机关闭完成 | |||
/// </summary> | |||
public bool CompletedClose_SE_2 { get; set; } | |||
/// <summary> | |||
/// 3号舵机关闭完成 | |||
/// </summary> | |||
public bool CompletedClose_SE_3 { get; set; } | |||
/// <summary> | |||
/// 是否存在物品 | |||
/// </summary> | |||
public bool ArticleExits { get; set; } | |||
/// <summary> | |||
/// 物品距离 | |||
/// </summary> | |||
public byte ArticleDist { get; set; } | |||
#endregion | |||
public ICChipMachine() | |||
{ | |||
@@ -80,7 +117,7 @@ namespace BPASmartClient.SCChip | |||
ThreadManage.GetInstance().StartLong(new Action(() => | |||
{ | |||
ResolveMsg(); | |||
}),"单片机解析线程"); | |||
}), "单片机解析线程"); | |||
} | |||
private void ResolveMsg() | |||
@@ -120,8 +157,8 @@ namespace BPASmartClient.SCChip | |||
IntPtr allocIntPtr = Marshal.AllocHGlobal(size); | |||
try | |||
{ | |||
Marshal.Copy(dataBuffer,0,allocIntPtr,size); | |||
structure = (ICChipPackage)Marshal.PtrToStructure(allocIntPtr,typeof(ICChipPackage)); | |||
Marshal.Copy(dataBuffer, 0, allocIntPtr, size); | |||
structure = (ICChipPackage)Marshal.PtrToStructure(allocIntPtr, typeof(ICChipPackage)); | |||
} | |||
finally | |||
{ | |||
@@ -141,8 +178,8 @@ namespace BPASmartClient.SCChip | |||
IntPtr bufferIntPtr = Marshal.AllocHGlobal(size); | |||
try | |||
{ | |||
Marshal.StructureToPtr(structure,bufferIntPtr,true); | |||
Marshal.Copy(bufferIntPtr,buffer,0,size); | |||
Marshal.StructureToPtr(structure, bufferIntPtr, true); | |||
Marshal.Copy(bufferIntPtr, buffer, 0, size); | |||
} | |||
finally | |||
{ | |||
@@ -176,13 +213,13 @@ namespace BPASmartClient.SCChip | |||
switch ((IC_SE)data.Value) | |||
{ | |||
case IC_SE.SE_1: | |||
status["CompletedOpen_SE_1"] = true; | |||
break; | |||
CompletedOpen_SE_1 = true; | |||
break; | |||
case IC_SE.SE_2: | |||
status["CompletedOpen_SE_2"] = true; | |||
break; | |||
CompletedOpen_SE_2 = true; | |||
break; | |||
case IC_SE.SE_3: | |||
status["CompletedOpen_SE_3"] = true; | |||
CompletedOpen_SE_3 = true; | |||
break; | |||
} | |||
break; | |||
@@ -190,19 +227,19 @@ namespace BPASmartClient.SCChip | |||
switch ((IC_SE)data.Value) | |||
{ | |||
case IC_SE.SE_1: | |||
status["CompletedClose_SE_1"] = true; | |||
CompletedClose_SE_1 = true; | |||
break; | |||
case IC_SE.SE_2: | |||
status["CompletedClose_SE_2"] = true; | |||
CompletedClose_SE_2= true; | |||
break; | |||
case IC_SE.SE_3: | |||
status["CompletedClose_SE_3"] = true; | |||
CompletedClose_SE_3 = true; | |||
break; | |||
} | |||
break; | |||
} | |||
if(!OnLine) IsWork = false; | |||
else IsWork = true; | |||
if (!OnLine) IsWork = false; | |||
else IsWork = true; | |||
} | |||
catch (Exception ex) | |||
{ | |||
@@ -214,62 +251,62 @@ namespace BPASmartClient.SCChip | |||
{ | |||
status["CompletedTake_CPU_CUP_ICECREAM"] = false; | |||
status["CompletedTake_CPU_CUP_COFFEE"] = false; | |||
status["CompletedOpen_SE_1"] = false; | |||
status["CompletedOpen_SE_2"] = false; | |||
status["CompletedOpen_SE_3"] = false; | |||
status["CompletedClose_SE_1"] = false; | |||
status["CompletedClose_SE_2"] = false; | |||
status["CompletedClose_SE_3"] = false; | |||
//status["CompletedOpen_SE_1"] = false; | |||
//status["CompletedOpen_SE_2"] = false; | |||
//status["CompletedOpen_SE_3"] = false; | |||
//status["CompletedClose_SE_1"] = false; | |||
//status["CompletedClose_SE_2"] = false; | |||
//status["CompletedClose_SE_3"] = false; | |||
} | |||
public override void Init() | |||
{ | |||
commProxy = new SerialPortClient(communicationPar.SerialPort,(BaudRates)communicationPar.BaudRate); | |||
commProxy = new SerialPortClient(communicationPar.SerialPort, (BaudRates)communicationPar.BaudRate); | |||
commProxy.SetDataStorage(dataStorage); | |||
//STM32F103RCT6单片机下杯 | |||
EventBus.EventBus.GetInstance().Subscribe<SCChip_TakeCupEvent>(DeviceId,delegate (IEvent @event,EventCallBackHandle callBack) | |||
{ | |||
try | |||
{ | |||
switch ((@event as SCChip_TakeCupEvent).Cup) | |||
{ | |||
case IC_CUP.CUP_ICECREAM: | |||
status["CompletedTake_CPU_CUP_ICECREAM"] = false; | |||
break; | |||
case IC_CUP.CUP_COFFEE: | |||
status["CompletedTake_CPU_CUP_COFFEE"] = false; | |||
break; | |||
} | |||
package.Cmd = IC_CMD.TAKE_CUP; | |||
package.Value = (byte)(@event as SCChip_TakeCupEvent).Cup; | |||
commProxy.SendData(StructureToByte(package)); | |||
EventBus.EventBus.GetInstance().Subscribe<SCChip_TakeCupEvent>(DeviceId, delegate (IEvent @event, EventCallBackHandle callBack) | |||
{ | |||
try | |||
{ | |||
switch ((@event as SCChip_TakeCupEvent).Cup) | |||
{ | |||
case IC_CUP.CUP_ICECREAM: | |||
status["CompletedTake_CPU_CUP_ICECREAM"] = false; | |||
break; | |||
case IC_CUP.CUP_COFFEE: | |||
status["CompletedTake_CPU_CUP_COFFEE"] = false; | |||
break; | |||
} | |||
package.Cmd = IC_CMD.TAKE_CUP; | |||
package.Value = (byte)(@event as SCChip_TakeCupEvent).Cup; | |||
commProxy.SendData(StructureToByte(package)); | |||
bool wait = true; | |||
var waitTimeout = DateTime.Now.AddSeconds(3); | |||
while (wait) | |||
{ | |||
wait = DateTime.Now < waitTimeout; | |||
if (wait) | |||
{ | |||
switch ((@event as SCChip_TakeCupEvent).Cup) | |||
{ | |||
case IC_CUP.CUP_ICECREAM: | |||
wait = !(bool)status["CompletedTake_CPU_CUP_ICECREAM"]; | |||
break; | |||
case IC_CUP.CUP_COFFEE: | |||
wait = !(bool)status["CompletedTake_CPU_CUP_COFFEE"]; | |||
break; | |||
} | |||
} | |||
Thread.Sleep(10); | |||
} | |||
} | |||
catch (Exception ex) | |||
{ | |||
MessageLog.GetInstance.ShowEx($"BPASmartClient.SCChip 中引发错误,ICChipMachine 类,描述:[{ex.Message}]"); | |||
} | |||
}); | |||
bool wait = true; | |||
var waitTimeout = DateTime.Now.AddSeconds(3); | |||
while (wait) | |||
{ | |||
wait = DateTime.Now < waitTimeout; | |||
if (wait) | |||
{ | |||
switch ((@event as SCChip_TakeCupEvent).Cup) | |||
{ | |||
case IC_CUP.CUP_ICECREAM: | |||
wait = !(bool)status["CompletedTake_CPU_CUP_ICECREAM"]; | |||
break; | |||
case IC_CUP.CUP_COFFEE: | |||
wait = !(bool)status["CompletedTake_CPU_CUP_COFFEE"]; | |||
break; | |||
} | |||
} | |||
Thread.Sleep(10); | |||
} | |||
} | |||
catch (Exception ex) | |||
{ | |||
MessageLog.GetInstance.ShowEx($"BPASmartClient.SCChip 中引发错误,ICChipMachine 类,描述:[{ex.Message}]"); | |||
} | |||
}); | |||
//STM32F103RCT6单片机舵机打料 | |||
EventBus.EventBus.GetInstance().Subscribe<SCChip_MakeIceCreamEvent>(DeviceId,delegate (IEvent @event,EventCallBackHandle callBack) | |||
@@ -279,13 +316,13 @@ namespace BPASmartClient.SCChip | |||
switch ((IC_SE)(@event as SCChip_MakeIceCreamEvent).SteeringEngine) | |||
{ | |||
case IC_SE.SE_1: | |||
status["CompletedOpen_SE_1"] = false; | |||
CompletedOpen_SE_1 = false; | |||
break; | |||
case IC_SE.SE_2: | |||
status["CompletedOpen_SE_2"] = false; | |||
CompletedOpen_SE_2 = false; | |||
break; | |||
case IC_SE.SE_3: | |||
status["CompletedOpen_SE_3"] = false; | |||
CompletedOpen_SE_3 = false; | |||
break; | |||
} | |||
package.Cmd = IC_CMD.OPEN_SE; | |||
@@ -302,19 +339,31 @@ namespace BPASmartClient.SCChip | |||
switch ((IC_SE)(@event as SCChip_MakeIceCreamEvent).SteeringEngine) | |||
{ | |||
case IC_SE.SE_1: | |||
wait = !(bool)status["CompletedOpen_SE_1"]; | |||
wait = !CompletedOpen_SE_1; | |||
break; | |||
case IC_SE.SE_2: | |||
wait = !(bool)status["CompletedOpen_SE_2"]; | |||
wait = !CompletedOpen_SE_2; | |||
break; | |||
case IC_SE.SE_3: | |||
wait = !(bool)status["CompletedOpen_SE_3"]; | |||
wait = !CompletedOpen_SE_3; | |||
break; | |||
} | |||
} | |||
Thread.Sleep(10); | |||
} | |||
Thread.Sleep(2000); | |||
switch ((IC_SE)(@event as SCChip_MakeIceCreamEvent).SteeringEngine) | |||
{ | |||
case IC_SE.SE_1: | |||
CompletedClose_SE_1 = false; | |||
break; | |||
case IC_SE.SE_2: | |||
CompletedClose_SE_2 = false; | |||
break; | |||
case IC_SE.SE_3: | |||
CompletedClose_SE_3 = false; | |||
break; | |||
} | |||
package.Cmd = IC_CMD.CLOSE_SE; | |||
package.Value = (byte)(@event as SCChip_MakeIceCreamEvent).SteeringEngine; | |||
commProxy.SendData(StructureToByte(package)); | |||
@@ -329,13 +378,13 @@ namespace BPASmartClient.SCChip | |||
switch ((IC_SE)(@event as SCChip_MakeIceCreamEvent).SteeringEngine) | |||
{ | |||
case IC_SE.SE_1: | |||
wait = !(bool)status["CompletedClose_SE_1"]; | |||
wait = !CompletedClose_SE_1; | |||
break; | |||
case IC_SE.SE_2: | |||
wait = !(bool)status["CompletedClose_SE_2"]; | |||
wait = !CompletedClose_SE_2; | |||
break; | |||
case IC_SE.SE_3: | |||
wait = !(bool)status["CompletedClose_SE_3"]; | |||
wait = !CompletedClose_SE_3; | |||
break; | |||
} | |||
} | |||
@@ -349,38 +398,42 @@ namespace BPASmartClient.SCChip | |||
}); | |||
//STM32F103RCT6单片机舵机打开或者关闭 | |||
EventBus.EventBus.GetInstance().Subscribe<SCChip_SESwitchCreamEvent>(DeviceId,delegate (IEvent @event,EventCallBackHandle callBack) | |||
{ | |||
try | |||
{ | |||
package.Cmd = (@event as SCChip_SESwitchCreamEvent).IsOpen ? IC_CMD.OPEN_SE : IC_CMD.CLOSE_SE; | |||
package.Value = (byte)(@event as SCChip_SESwitchCreamEvent).SteeringEngine; | |||
commProxy.SendData(StructureToByte(package)); | |||
} | |||
catch (Exception ex) | |||
{ | |||
MessageLog.GetInstance.ShowEx($"BPASmartClient.SCChip 中引发错误,ICChipMachine 类,描述:[{ex.Message}]"); | |||
} | |||
}); | |||
EventBus.EventBus.GetInstance().Subscribe<SCChip_SESwitchCreamEvent>(DeviceId, delegate (IEvent @event, EventCallBackHandle callBack) | |||
{ | |||
try | |||
{ | |||
package.Cmd = (@event as SCChip_SESwitchCreamEvent).IsOpen ? IC_CMD.OPEN_SE : IC_CMD.CLOSE_SE; | |||
package.Value = (byte)(@event as SCChip_SESwitchCreamEvent).SteeringEngine; | |||
commProxy.SendData(StructureToByte(package)); | |||
} | |||
catch (Exception ex) | |||
{ | |||
MessageLog.GetInstance.ShowEx($"BPASmartClient.SCChip 中引发错误,ICChipMachine 类,描述:[{ex.Message}]"); | |||
} | |||
}); | |||
//STM32F103RCT6单片机控制冰淇淋机器转 | |||
EventBus.EventBus.GetInstance().Subscribe<SCChip_RotorSwitchEvent>(DeviceId,delegate (IEvent @event,EventCallBackHandle callBack) | |||
{ | |||
try | |||
{ | |||
package.Cmd = IC_CMD.ROTOR; | |||
package.Value = (@event as SCChip_RotorSwitchEvent).TurnOn ? (byte)IC_ROTOR.OPEN_ROTOR : (byte)IC_ROTOR.CLOSE_ROTOR; | |||
commProxy.SendData(StructureToByte(package)); | |||
} | |||
catch (Exception ex) | |||
{ | |||
MessageLog.GetInstance.ShowEx($"BPASmartClient.SCChip 中引发错误,ICChipMachine 类,描述:[{ex.Message}]"); | |||
} | |||
}); | |||
EventBus.EventBus.GetInstance().Subscribe<SCChip_RotorSwitchEvent>(DeviceId, delegate (IEvent @event, EventCallBackHandle callBack) | |||
{ | |||
try | |||
{ | |||
package.Cmd = IC_CMD.ROTOR; | |||
package.Value = (@event as SCChip_RotorSwitchEvent).TurnOn ? (byte)IC_ROTOR.OPEN_ROTOR : (byte)IC_ROTOR.CLOSE_ROTOR; | |||
commProxy.SendData(StructureToByte(package)); | |||
} | |||
catch (Exception ex) | |||
{ | |||
MessageLog.GetInstance.ShowEx($"BPASmartClient.SCChip 中引发错误,ICChipMachine 类,描述:[{ex.Message}]"); | |||
} | |||
}); | |||
InitStatus(); | |||
//测试 | |||
Start(); | |||
} | |||
public override void WriteData(string address, object value) | |||
{ | |||
} | |||
} | |||
} |
@@ -39,5 +39,6 @@ namespace BPASmartClient.SCChip | |||
/// 检测物品距离 | |||
/// </summary> | |||
ARTICLE_DIST = 0x06 | |||
} | |||
} |
@@ -0,0 +1,113 @@ | |||
using BPASmartClient.Helper; | |||
using BPASmartClient.Message; | |||
using System; | |||
using System.Collections.Concurrent; | |||
using System.Collections.Generic; | |||
using System.IO.Ports; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading; | |||
using System.Threading.Tasks; | |||
namespace BPASmartClient.SerialPort | |||
{ | |||
public class JuicerHelper | |||
{ | |||
//private volatile static JuicerHelper _Instance; | |||
//public static JuicerHelper GetInstance => _Instance ?? (_Instance = new JuicerHelper()); | |||
//private JuicerHelper() { } | |||
private System.IO.Ports.SerialPort comPort = new System.IO.Ports.SerialPort(); | |||
ConcurrentQueue<byte[]> SerialMessages = new ConcurrentQueue<byte[]>(); | |||
public bool IsOpen => comPort.IsOpen; | |||
public bool Open(string portName, int baudRate) | |||
{ | |||
while (!System.IO.Ports.SerialPort.GetPortNames().Contains(portName)) | |||
{ | |||
Thread.Sleep(1000); | |||
} | |||
while (!comPort.IsOpen) | |||
{ | |||
comPort.PortName = portName; | |||
comPort.BaudRate = baudRate; | |||
comPort.DataBits = 8; | |||
comPort.Parity = Parity.None; | |||
comPort.StopBits = StopBits.One; | |||
comPort.ReadTimeout = 1000; | |||
comPort.WriteTimeout = 1000; | |||
//comPort.DataReceived += ComPort_DataReceived; | |||
comPort.RtsEnable = true; | |||
try | |||
{ | |||
comPort.Open(); | |||
} | |||
catch (Exception ex) | |||
{ | |||
MessageLog.GetInstance.ShowEx(ex.ToString()); | |||
Thread.Sleep(5000); | |||
} | |||
} | |||
MessageLog.GetInstance.Show($"{portName} 串口打开成功"); | |||
return comPort.IsOpen; | |||
} | |||
/// <summary> | |||
/// 开始制作 | |||
/// </summary> | |||
/// <param name="aisle"></param> | |||
/// <returns></returns> | |||
public bool StartCook(byte aisle) | |||
{ | |||
byte sum = (byte)(0x21 + aisle); | |||
byte checksum = (byte)~sum; | |||
checksum++; | |||
byte[] buffers = new byte[6] { 0x7E, 0x03, 0x00, 0x21, aisle, checksum }; | |||
if (comPort.IsOpen) | |||
{ | |||
comPort.Write(buffers, 0, buffers.Length); | |||
while (comPort.BytesToRead < 6) | |||
{ | |||
Thread.Sleep(1); | |||
} | |||
byte[] receive = new byte[comPort.BytesToRead]; | |||
comPort.Read(receive, 0, receive.Length); | |||
if (receive.Length == 6) | |||
return receive[4] == 1; | |||
} | |||
return false; | |||
} | |||
/// <summary> | |||
/// 获取果汁机状态 | |||
/// </summary> | |||
/// <param name="index"></param> | |||
/// <returns></returns> | |||
public int[] GetDeviceStatus() | |||
{ | |||
List<int> res = new List<int>(); | |||
byte[] buffers = new byte[5] { 0x7E, 0x02, 0x00, 0x13, 0xED }; | |||
if (comPort.IsOpen) | |||
{ | |||
comPort.Write(buffers, 0, buffers.Length); | |||
DateTime newDate = DateTime.Now; | |||
while (comPort.BytesToRead < 33) | |||
{ | |||
Thread.Sleep(1); | |||
if (DateTime.Now.Subtract(newDate).TotalSeconds >= 2) break; | |||
} | |||
byte[] receive = new byte[comPort.BytesToRead]; | |||
comPort.Read(receive, 0, receive.Length); | |||
if (receive.Length == 33) | |||
{ | |||
res.Add(receive.Skip(24).Take(4).ToArray().BytesToInt()); | |||
res.Add(receive.Skip(28).Take(4).ToArray().BytesToInt()); | |||
} | |||
return res.ToArray(); | |||
} | |||
return default; | |||
} | |||
} | |||
} |
@@ -0,0 +1,140 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
using System.IO; | |||
using System.IO.Ports; | |||
using System.Threading; | |||
using System.Collections.Concurrent; | |||
using BPASmartClient.Message; | |||
namespace BPASmartClient.SerialPort | |||
{ | |||
public class MCUSerialHelper | |||
{ | |||
//private volatile static MCUSerialHelper _Instance; | |||
//public static MCUSerialHelper GetInstance => _Instance ?? (_Instance = new MCUSerialHelper()); | |||
//private MCUSerialHelper() { } | |||
private System.IO.Ports.SerialPort comPort = new System.IO.Ports.SerialPort(); | |||
public bool IsOpen => comPort.IsOpen; | |||
public bool Open(string portName, int baudRate) | |||
{ | |||
while (!System.IO.Ports.SerialPort.GetPortNames().Contains(portName)) | |||
{ | |||
Thread.Sleep(1000); | |||
} | |||
while (!comPort.IsOpen) | |||
{ | |||
comPort.PortName = portName; | |||
comPort.BaudRate = baudRate; | |||
comPort.DataBits = 8; | |||
comPort.Parity = Parity.None; | |||
comPort.StopBits = StopBits.One; | |||
comPort.ReadTimeout = 1000; | |||
comPort.WriteTimeout = 1000; | |||
//comPort.RtsEnable = true; //设置为 true后会读取不到数据 | |||
//comPort.DtrEnable = true;//获取或设置一个值,该值在串行通信过程中启用数据终端就绪 (DTR) 信号。 | |||
//comPort.RtsEnable = true;//获取或设置一个值,该值指示在串行通信中是否启用请求发送 (RTS) 信号 | |||
try | |||
{ | |||
comPort.Open(); | |||
} | |||
catch (Exception ex) | |||
{ | |||
MessageLog.GetInstance.ShowEx(ex.ToString()); | |||
Thread.Sleep(5000); | |||
} | |||
} | |||
MessageLog.GetInstance.Show($"{portName} 串口打开成功"); | |||
return comPort.IsOpen; | |||
} | |||
private static readonly object OutPutLock = new object(); | |||
/// <summary> | |||
/// 单片机输出端口控制 | |||
/// </summary> | |||
/// <param name="index">通道号 1 - 8 </param> | |||
/// <param name="value">控制值</param> | |||
public void OutputControl(byte index, bool value) | |||
{ | |||
lock (OutPutLock) | |||
{ | |||
byte NumValue = (byte)(value ? 0x01 : 0x00); | |||
byte[] buffers = new byte[6] { 0xCC, 0x01, 0x01, index, NumValue, 0xDD }; | |||
if (IsOpen) comPort.Write(buffers, 0, buffers.Length); | |||
} | |||
} | |||
/// <summary> | |||
/// 舵机控制 | |||
/// </summary> | |||
/// <param name="index">通道号 1 - 8</param> | |||
/// <param name="value">舵机位置 0 - 180</param> | |||
public void ServoControl(byte index, byte value) | |||
{ | |||
byte[] buffers = new byte[6] { 0xCC, 0x01, 0x02, index, value, 0xDD }; | |||
if (IsOpen) comPort.Write(buffers, 0, buffers.Length); | |||
} | |||
/// <summary> | |||
/// 获取单片机输入端口状态 | |||
/// </summary> | |||
/// <param name="index"></param> | |||
/// <returns>0:无意义 1:有信号 2:无信号 3:信号不正确</returns> | |||
public int GetInputStatus(byte index) | |||
{ | |||
if (index <= 0 || index > 8) return 0; | |||
byte[] buffers = new byte[6] { 0xCC, 0x01, 0x03, index, 0x00, 0xDD }; | |||
if (IsOpen) | |||
{ | |||
comPort.Write(buffers, 0, buffers.Length); | |||
DateTime dt = DateTime.Now; | |||
List<byte> receive = new List<byte>(); | |||
while (true) | |||
{ | |||
byte[] re = new byte[comPort.BytesToRead]; | |||
comPort.Read(re, 0, re.Length); | |||
if (re.Contains<byte>(0xcc) && re.Contains<byte>(0xDD)) receive.AddRange(re); | |||
comPort.DiscardInBuffer(); | |||
if (receive.Contains(0xcc) && receive.Contains(0xdd)) break; | |||
if (DateTime.Now.Subtract(dt).TotalSeconds >= 2) break; | |||
Thread.Sleep(1); | |||
} | |||
if (receive != null) | |||
{ | |||
int Reindex = Array.FindIndex(receive.ToArray(), p => p == 0xcc); | |||
if (Reindex < receive.Count && Reindex >= 0) | |||
{ | |||
var res = receive.GetRange(Array.FindIndex(receive.ToArray(), p => p == 0xcc), 6); | |||
if (res.ElementAt(2) == 0x03) | |||
{ | |||
if (res != null && res.Count() == 6 && res.ElementAt(4) == 0x01) | |||
{ | |||
return 1; | |||
} | |||
else if (res != null && res.Count() == 6 && res.ElementAt(4) == 0x00) | |||
{ | |||
return 2; | |||
} | |||
} | |||
else | |||
{ | |||
return 3; | |||
} | |||
} | |||
else | |||
{ | |||
return 0; | |||
} | |||
} | |||
} | |||
return 0; | |||
} | |||
} | |||
} |
@@ -65,6 +65,7 @@ namespace BPASmartClient.ViewModel | |||
})); | |||
}); | |||
dispatcherTimer = new DispatcherTimer(); | |||
dispatcherTimer.Tick += delegate | |||
{ | |||
@@ -7,14 +7,14 @@ | |||
<add key="IsEnableTest" value="false"/> | |||
<!--开发环境--> | |||
<add key="apollouri" value="http://10.2.1.21:28080/"/> | |||
<!--<add key="apollouri" value="http://10.2.1.21:28080/"/> | |||
<add key="AppId" value="dev1_common"/> | |||
<add key ="Namespaces" value="DEV.Config"/> | |||
<add key ="Namespaces" value="DEV.Config"/>--> | |||
<!--正式环境--> | |||
<!--<add key="apollouri" value="http://47.108.65.220:28080/"/> | |||
<add key="apollouri" value="http://47.108.65.220:28080/"/> | |||
<add key="AppId" value="order"/> | |||
<add key ="Namespaces" value="TEST1.Config"/>--> | |||
<add key ="Namespaces" value="TEST1.Config"/> | |||
<!--阿里云上报启动方式:API 或者 LOCAL--> | |||
<!--API :通过客户端ID,调用接口查询“设备连接信息”--> | |||
@@ -33,12 +33,19 @@ | |||
<TextBox x:Name="chen" Margin="10,0,0,0" Width="200" >1</TextBox> | |||
<Button Tag="Inquire" Margin="10,0,0,0" Click="Button_Click" Style="{DynamicResource CommonBtn_返回}" Width="45">查询</Button> | |||
</StackPanel> | |||
<StackPanel Orientation="Horizontal" Margin="0,10,0,0"> | |||
<TextBlock Width="80" HorizontalAlignment="Right" FontSize="12">客户端ID:</TextBlock> | |||
<TextBox x:Name="clientId" Margin="10,0,0,0" Width="200" Text="{Binding device.ClientId, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"></TextBox> | |||
</StackPanel> | |||
<StackPanel Orientation="Horizontal" Margin="0,10,0,0"> | |||
<TextBlock Width="80" HorizontalAlignment="Right" FontSize="12">设备ID:</TextBlock> | |||
<TextBox x:Name="sbId" Margin="10,0,0,0" Width="200" Text="{Binding device.DeviceId, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"></TextBox> | |||
</StackPanel> | |||
<StackPanel Orientation="Horizontal" Margin="0,10,0,0"> | |||
<TextBlock Width="80" FontSize="12">devicename:</TextBlock> | |||
<TextBox x:Name="devicename" Margin="10,0,0,0" Width="200" Text="{Binding device.devicename, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"></TextBox> | |||
@@ -100,6 +107,13 @@ | |||
</DataTemplate> | |||
</DataGridTemplateColumn.CellTemplate> | |||
</DataGridTemplateColumn> | |||
<DataGridTemplateColumn Header="设备ID" Width="2*"> | |||
<DataGridTemplateColumn.CellTemplate> | |||
<DataTemplate> | |||
<TextBlock HorizontalAlignment="Center" Text="{Binding DeviceId, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" FontSize="12" /> | |||
</DataTemplate> | |||
</DataGridTemplateColumn.CellTemplate> | |||
</DataGridTemplateColumn> | |||
<DataGridTemplateColumn Header="云名称" Width="5*"> | |||
<DataGridTemplateColumn.CellTemplate> | |||
<DataTemplate> | |||
@@ -78,11 +78,19 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BPASmartClient.MorkF", "BPA | |||
EndProject | |||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BPASmartClient.LebaiRobot", "BPASmartClient.LebaiRobot\BPASmartClient.LebaiRobot.csproj", "{D40C3CC7-C07C-4882-93D3-7F9ABCD3B5F0}" | |||
EndProject | |||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BPASmartClient.MorkM", "BPASmartClient.MorkM\BPASmartClient.MorkM.csproj", "{74DB1F85-9B73-4113-8FE4-A63754BC7DF9}" | |||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BPASmartClient.MorkM", "BPASmartClient.MorkM\BPASmartClient.MorkM.csproj", "{74DB1F85-9B73-4113-8FE4-A63754BC7DF9}" | |||
EndProject | |||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BPASmartClient.MorkT.Lebai.JC", "BPASmartClient.MorkT.Lebai.JC\BPASmartClient.MorkT.Lebai.JC.csproj", "{0A06C9E5-5C42-4BCE-B6E6-D8054C72255D}" | |||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BPASmartClient.MorkTLebaiJC", "BPASmartClient.MorkT.Lebai.JC\BPASmartClient.MorkTLebaiJC.csproj", "{0A06C9E5-5C42-4BCE-B6E6-D8054C72255D}" | |||
EndProject | |||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BPASmartClient.Morkt.JAKA.JC", "BPASmartClient.Morkt.JAKA.JC\BPASmartClient.Morkt.JAKA.JC.csproj", "{6B0FD858-A60D-41B9-A923-358B0CE2A254}" | |||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BPASmartClient.MorkTJAKAJC", "BPASmartClient.Morkt.JAKA.JC\BPASmartClient.MorkTJAKAJC.csproj", "{6B0FD858-A60D-41B9-A923-358B0CE2A254}" | |||
EndProject | |||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BPASmartClient.MCU", "BPASmartClient.MCU\BPASmartClient.MCU.csproj", "{1C7E17B3-40E0-44ED-B8E0-C52D824604DB}" | |||
EndProject | |||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BPASmartClient.JakaRobot", "BPASmartClient.JakaRobot\BPASmartClient.JakaRobot.csproj", "{1055EA6E-6C10-4A0D-A053-85871AF8D7A9}" | |||
EndProject | |||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BPASmartClient.JAKA", "BPASmartClient.JAKA\BPASmartClient.JAKA.csproj", "{C935435D-6182-4A01-8E59-B832B2FF0D72}" | |||
EndProject | |||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BPASmartClient.Juicer", "BPASmartClient.Juicer\BPASmartClient.Juicer.csproj", "{C28A88B1-E449-484C-AC67-B5038FF2CA79}" | |||
EndProject | |||
Global | |||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | |||
@@ -738,6 +746,86 @@ Global | |||
{6B0FD858-A60D-41B9-A923-358B0CE2A254}.Release|x64.Build.0 = Release|Any CPU | |||
{6B0FD858-A60D-41B9-A923-358B0CE2A254}.Release|x86.ActiveCfg = Release|Any CPU | |||
{6B0FD858-A60D-41B9-A923-358B0CE2A254}.Release|x86.Build.0 = Release|Any CPU | |||
{1C7E17B3-40E0-44ED-B8E0-C52D824604DB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | |||
{1C7E17B3-40E0-44ED-B8E0-C52D824604DB}.Debug|Any CPU.Build.0 = Debug|Any CPU | |||
{1C7E17B3-40E0-44ED-B8E0-C52D824604DB}.Debug|ARM.ActiveCfg = Debug|Any CPU | |||
{1C7E17B3-40E0-44ED-B8E0-C52D824604DB}.Debug|ARM.Build.0 = Debug|Any CPU | |||
{1C7E17B3-40E0-44ED-B8E0-C52D824604DB}.Debug|ARM64.ActiveCfg = Debug|Any CPU | |||
{1C7E17B3-40E0-44ED-B8E0-C52D824604DB}.Debug|ARM64.Build.0 = Debug|Any CPU | |||
{1C7E17B3-40E0-44ED-B8E0-C52D824604DB}.Debug|x64.ActiveCfg = Debug|Any CPU | |||
{1C7E17B3-40E0-44ED-B8E0-C52D824604DB}.Debug|x64.Build.0 = Debug|Any CPU | |||
{1C7E17B3-40E0-44ED-B8E0-C52D824604DB}.Debug|x86.ActiveCfg = Debug|Any CPU | |||
{1C7E17B3-40E0-44ED-B8E0-C52D824604DB}.Debug|x86.Build.0 = Debug|Any CPU | |||
{1C7E17B3-40E0-44ED-B8E0-C52D824604DB}.Release|Any CPU.ActiveCfg = Release|Any CPU | |||
{1C7E17B3-40E0-44ED-B8E0-C52D824604DB}.Release|Any CPU.Build.0 = Release|Any CPU | |||
{1C7E17B3-40E0-44ED-B8E0-C52D824604DB}.Release|ARM.ActiveCfg = Release|Any CPU | |||
{1C7E17B3-40E0-44ED-B8E0-C52D824604DB}.Release|ARM.Build.0 = Release|Any CPU | |||
{1C7E17B3-40E0-44ED-B8E0-C52D824604DB}.Release|ARM64.ActiveCfg = Release|Any CPU | |||
{1C7E17B3-40E0-44ED-B8E0-C52D824604DB}.Release|ARM64.Build.0 = Release|Any CPU | |||
{1C7E17B3-40E0-44ED-B8E0-C52D824604DB}.Release|x64.ActiveCfg = Release|Any CPU | |||
{1C7E17B3-40E0-44ED-B8E0-C52D824604DB}.Release|x64.Build.0 = Release|Any CPU | |||
{1C7E17B3-40E0-44ED-B8E0-C52D824604DB}.Release|x86.ActiveCfg = Release|Any CPU | |||
{1C7E17B3-40E0-44ED-B8E0-C52D824604DB}.Release|x86.Build.0 = Release|Any CPU | |||
{1055EA6E-6C10-4A0D-A053-85871AF8D7A9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | |||
{1055EA6E-6C10-4A0D-A053-85871AF8D7A9}.Debug|Any CPU.Build.0 = Debug|Any CPU | |||
{1055EA6E-6C10-4A0D-A053-85871AF8D7A9}.Debug|ARM.ActiveCfg = Debug|Any CPU | |||
{1055EA6E-6C10-4A0D-A053-85871AF8D7A9}.Debug|ARM.Build.0 = Debug|Any CPU | |||
{1055EA6E-6C10-4A0D-A053-85871AF8D7A9}.Debug|ARM64.ActiveCfg = Debug|Any CPU | |||
{1055EA6E-6C10-4A0D-A053-85871AF8D7A9}.Debug|ARM64.Build.0 = Debug|Any CPU | |||
{1055EA6E-6C10-4A0D-A053-85871AF8D7A9}.Debug|x64.ActiveCfg = Debug|Any CPU | |||
{1055EA6E-6C10-4A0D-A053-85871AF8D7A9}.Debug|x64.Build.0 = Debug|Any CPU | |||
{1055EA6E-6C10-4A0D-A053-85871AF8D7A9}.Debug|x86.ActiveCfg = Debug|Any CPU | |||
{1055EA6E-6C10-4A0D-A053-85871AF8D7A9}.Debug|x86.Build.0 = Debug|Any CPU | |||
{1055EA6E-6C10-4A0D-A053-85871AF8D7A9}.Release|Any CPU.ActiveCfg = Release|Any CPU | |||
{1055EA6E-6C10-4A0D-A053-85871AF8D7A9}.Release|Any CPU.Build.0 = Release|Any CPU | |||
{1055EA6E-6C10-4A0D-A053-85871AF8D7A9}.Release|ARM.ActiveCfg = Release|Any CPU | |||
{1055EA6E-6C10-4A0D-A053-85871AF8D7A9}.Release|ARM.Build.0 = Release|Any CPU | |||
{1055EA6E-6C10-4A0D-A053-85871AF8D7A9}.Release|ARM64.ActiveCfg = Release|Any CPU | |||
{1055EA6E-6C10-4A0D-A053-85871AF8D7A9}.Release|ARM64.Build.0 = Release|Any CPU | |||
{1055EA6E-6C10-4A0D-A053-85871AF8D7A9}.Release|x64.ActiveCfg = Release|Any CPU | |||
{1055EA6E-6C10-4A0D-A053-85871AF8D7A9}.Release|x64.Build.0 = Release|Any CPU | |||
{1055EA6E-6C10-4A0D-A053-85871AF8D7A9}.Release|x86.ActiveCfg = Release|Any CPU | |||
{1055EA6E-6C10-4A0D-A053-85871AF8D7A9}.Release|x86.Build.0 = Release|Any CPU | |||
{C935435D-6182-4A01-8E59-B832B2FF0D72}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | |||
{C935435D-6182-4A01-8E59-B832B2FF0D72}.Debug|Any CPU.Build.0 = Debug|Any CPU | |||
{C935435D-6182-4A01-8E59-B832B2FF0D72}.Debug|ARM.ActiveCfg = Debug|Any CPU | |||
{C935435D-6182-4A01-8E59-B832B2FF0D72}.Debug|ARM.Build.0 = Debug|Any CPU | |||
{C935435D-6182-4A01-8E59-B832B2FF0D72}.Debug|ARM64.ActiveCfg = Debug|Any CPU | |||
{C935435D-6182-4A01-8E59-B832B2FF0D72}.Debug|ARM64.Build.0 = Debug|Any CPU | |||
{C935435D-6182-4A01-8E59-B832B2FF0D72}.Debug|x64.ActiveCfg = Debug|Any CPU | |||
{C935435D-6182-4A01-8E59-B832B2FF0D72}.Debug|x64.Build.0 = Debug|Any CPU | |||
{C935435D-6182-4A01-8E59-B832B2FF0D72}.Debug|x86.ActiveCfg = Debug|Any CPU | |||
{C935435D-6182-4A01-8E59-B832B2FF0D72}.Debug|x86.Build.0 = Debug|Any CPU | |||
{C935435D-6182-4A01-8E59-B832B2FF0D72}.Release|Any CPU.ActiveCfg = Release|Any CPU | |||
{C935435D-6182-4A01-8E59-B832B2FF0D72}.Release|Any CPU.Build.0 = Release|Any CPU | |||
{C935435D-6182-4A01-8E59-B832B2FF0D72}.Release|ARM.ActiveCfg = Release|Any CPU | |||
{C935435D-6182-4A01-8E59-B832B2FF0D72}.Release|ARM.Build.0 = Release|Any CPU | |||
{C935435D-6182-4A01-8E59-B832B2FF0D72}.Release|ARM64.ActiveCfg = Release|Any CPU | |||
{C935435D-6182-4A01-8E59-B832B2FF0D72}.Release|ARM64.Build.0 = Release|Any CPU | |||
{C935435D-6182-4A01-8E59-B832B2FF0D72}.Release|x64.ActiveCfg = Release|Any CPU | |||
{C935435D-6182-4A01-8E59-B832B2FF0D72}.Release|x64.Build.0 = Release|Any CPU | |||
{C935435D-6182-4A01-8E59-B832B2FF0D72}.Release|x86.ActiveCfg = Release|Any CPU | |||
{C935435D-6182-4A01-8E59-B832B2FF0D72}.Release|x86.Build.0 = Release|Any CPU | |||
{C28A88B1-E449-484C-AC67-B5038FF2CA79}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | |||
{C28A88B1-E449-484C-AC67-B5038FF2CA79}.Debug|Any CPU.Build.0 = Debug|Any CPU | |||
{C28A88B1-E449-484C-AC67-B5038FF2CA79}.Debug|ARM.ActiveCfg = Debug|Any CPU | |||
{C28A88B1-E449-484C-AC67-B5038FF2CA79}.Debug|ARM.Build.0 = Debug|Any CPU | |||
{C28A88B1-E449-484C-AC67-B5038FF2CA79}.Debug|ARM64.ActiveCfg = Debug|Any CPU | |||
{C28A88B1-E449-484C-AC67-B5038FF2CA79}.Debug|ARM64.Build.0 = Debug|Any CPU | |||
{C28A88B1-E449-484C-AC67-B5038FF2CA79}.Debug|x64.ActiveCfg = Debug|Any CPU | |||
{C28A88B1-E449-484C-AC67-B5038FF2CA79}.Debug|x64.Build.0 = Debug|Any CPU | |||
{C28A88B1-E449-484C-AC67-B5038FF2CA79}.Debug|x86.ActiveCfg = Debug|Any CPU | |||
{C28A88B1-E449-484C-AC67-B5038FF2CA79}.Debug|x86.Build.0 = Debug|Any CPU | |||
{C28A88B1-E449-484C-AC67-B5038FF2CA79}.Release|Any CPU.ActiveCfg = Release|Any CPU | |||
{C28A88B1-E449-484C-AC67-B5038FF2CA79}.Release|Any CPU.Build.0 = Release|Any CPU | |||
{C28A88B1-E449-484C-AC67-B5038FF2CA79}.Release|ARM.ActiveCfg = Release|Any CPU | |||
{C28A88B1-E449-484C-AC67-B5038FF2CA79}.Release|ARM.Build.0 = Release|Any CPU | |||
{C28A88B1-E449-484C-AC67-B5038FF2CA79}.Release|ARM64.ActiveCfg = Release|Any CPU | |||
{C28A88B1-E449-484C-AC67-B5038FF2CA79}.Release|ARM64.Build.0 = Release|Any CPU | |||
{C28A88B1-E449-484C-AC67-B5038FF2CA79}.Release|x64.ActiveCfg = Release|Any CPU | |||
{C28A88B1-E449-484C-AC67-B5038FF2CA79}.Release|x64.Build.0 = Release|Any CPU | |||
{C28A88B1-E449-484C-AC67-B5038FF2CA79}.Release|x86.ActiveCfg = Release|Any CPU | |||
{C28A88B1-E449-484C-AC67-B5038FF2CA79}.Release|x86.Build.0 = Release|Any CPU | |||
EndGlobalSection | |||
GlobalSection(SolutionProperties) = preSolution | |||
HideSolutionNode = FALSE | |||
@@ -775,6 +863,10 @@ Global | |||
{74DB1F85-9B73-4113-8FE4-A63754BC7DF9} = {9FB27073-61A0-4FE3-94DB-5FDDE062332F} | |||
{0A06C9E5-5C42-4BCE-B6E6-D8054C72255D} = {9FB27073-61A0-4FE3-94DB-5FDDE062332F} | |||
{6B0FD858-A60D-41B9-A923-358B0CE2A254} = {9FB27073-61A0-4FE3-94DB-5FDDE062332F} | |||
{1C7E17B3-40E0-44ED-B8E0-C52D824604DB} = {666CB1A9-562E-453A-A2C7-FD9D77CFDFDD} | |||
{1055EA6E-6C10-4A0D-A053-85871AF8D7A9} = {3D1D0E04-03FD-480A-8CF8-6E01A2E28625} | |||
{C935435D-6182-4A01-8E59-B832B2FF0D72} = {666CB1A9-562E-453A-A2C7-FD9D77CFDFDD} | |||
{C28A88B1-E449-484C-AC67-B5038FF2CA79} = {666CB1A9-562E-453A-A2C7-FD9D77CFDFDD} | |||
EndGlobalSection | |||
GlobalSection(ExtensibilityGlobals) = postSolution | |||
SolutionGuid = {9AEC9B81-0222-4DE9-B642-D915C29222AC} | |||