Explorar el Código

煮面机逻辑优化

样式分支
pry hace 2 años
padre
commit
6c7db8cb88
Se han modificado 11 ficheros con 474 adiciones y 405 borrados
  1. +61
    -58
      BPASmartClient.DRCoffee/CoffeeMachine.cs
  2. +11
    -0
      BPASmartClient.Device/BaseDevice.cs
  3. +74
    -70
      BPASmartClient.GSIceCream/IceCreamMachine.cs
  4. +107
    -105
      BPASmartClient.KLMCoffee/CoffeeMachine.cs
  5. +8
    -6
      BPASmartClient.Lebai/LebaiRobot.cs
  6. +7
    -1
      BPASmartClient.MORKSM.BK.PLC/PLCMachine.cs
  7. +41
    -14
      BPASmartClient.MorkS/Control_Morks.cs
  8. +7
    -1
      BPASmartClient.MorkS/GVL_MORKS.cs
  9. +3
    -1
      BPASmartClient.Peripheral/BasePeripheral.cs
  10. +2
    -0
      BPASmartClient.Peripheral/IPeripheral.cs
  11. +153
    -149
      BPASmartClient.SCChip/ICChipMachine.cs

+ 61
- 58
BPASmartClient.DRCoffee/CoffeeMachine.cs Ver fichero

@@ -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,7 +141,7 @@ namespace BPASmartClient.DRCoffee
/// <param name="package"></param>
public void ProcessPackage(DrCoffeePackage package)
{
if (((DrCoffeeStatus)status["CoffeeStatus"]) == DrCoffeeStatus.Running && package.Status != DrCoffeeStatus.Running)
{
status["CoffeeStatus"] = package.Status;
@@ -154,17 +154,17 @@ namespace BPASmartClient.DRCoffee
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 +177,71 @@ 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)
{
}
}
}

+ 11
- 0
BPASmartClient.Device/BaseDevice.cs Ver fichero

@@ -110,6 +110,17 @@ namespace BPASmartClient.Device

#endregion

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>


+ 74
- 70
BPASmartClient.GSIceCream/IceCreamMachine.cs Ver fichero

@@ -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)
{
}
}

}

+ 107
- 105
BPASmartClient.KLMCoffee/CoffeeMachine.cs Ver fichero

@@ -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)
{
}
}
}

+ 8
- 6
BPASmartClient.Lebai/LebaiRobot.cs Ver fichero

@@ -19,7 +19,7 @@ using BPASmartClient.Model.乐白机器人;

namespace BPASmartClient.Lebai
{
public class LebaiRobot: BasePeripheral
public class LebaiRobot : BasePeripheral
{

/// <summary>
@@ -51,7 +51,7 @@ namespace BPASmartClient.Lebai
if (LebaiHelper.GetInstance().robotData != null) status["RobotMode"] = LebaiHelper.GetInstance().robotData.RobotMode.Mode;
LebaiHelper.GetInstance().GetRobotModeStatus();
Thread.Sleep(10);
},"获取乐白机器人数据");
}, "获取乐白机器人数据");

}

@@ -62,7 +62,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 +90,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 +116,7 @@ namespace BPASmartClient.Lebai
default:
break;
}
}
});
//选择机器人场景
@@ -134,6 +134,8 @@ namespace BPASmartClient.Lebai
MessageLog.GetInstance.Show("乐白机器人初始化完成");
}

public override void WriteData(string address, object value)
{
}
}
}

+ 7
- 1
BPASmartClient.MORKSM.BK.PLC/PLCMachine.cs Ver fichero

@@ -48,7 +48,7 @@ namespace BPASmartClient.PLC
{
if (@event == null) return;
var par = @event as WriteModel;
//M32.7地址复位
modbusTcp.Write(par?.Address, par?.Value);
});
}
@@ -63,6 +63,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()
{



+ 41
- 14
BPASmartClient.MorkS/Control_Morks.cs Ver fichero

@@ -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);


}




+ 7
- 1
BPASmartClient.MorkS/GVL_MORKS.cs Ver fichero

@@ -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("机器人任务互锁信号")]


+ 3
- 1
BPASmartClient.Peripheral/BasePeripheral.cs Ver fichero

@@ -47,16 +47,18 @@ namespace BPASmartClient.Peripheral
return null;
}


public abstract void Start();

public abstract void Stop();

public abstract void Init();

public abstract void WriteData(string address, object value);

public ConcurrentDictionary<string, object> GetAllStatus()
{
return status;
}

}
}

+ 2
- 0
BPASmartClient.Peripheral/IPeripheral.cs Ver fichero

@@ -53,6 +53,8 @@ namespace BPASmartClient.Peripheral
/// </summary>
ConcurrentDictionary<string, object> status { get; set; }

void WriteData(string address, object value);

/// <summary>
/// 初始化
/// </summary>


+ 153
- 149
BPASmartClient.SCChip/ICChipMachine.cs Ver fichero

@@ -14,7 +14,7 @@ using static BPASmartClient.EventBus.EventBus;

namespace BPASmartClient.SCChip
{
public class ICChipMachine :BasePeripheral
public class ICChipMachine : BasePeripheral
{
//通讯代理
SerialPortClient commProxy = null;
@@ -80,7 +80,7 @@ namespace BPASmartClient.SCChip
ThreadManage.GetInstance().StartLong(new Action(() =>
{
ResolveMsg();
}),"单片机解析线程");
}), "单片机解析线程");
}

private void ResolveMsg()
@@ -120,8 +120,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 +141,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
{
@@ -201,8 +201,8 @@ namespace BPASmartClient.SCChip
}
break;
}
if(!OnLine) IsWork = false;
else IsWork = true;
if (!OnLine) IsWork = false;
else IsWork = true;
}
catch (Exception ex)
{
@@ -224,163 +224,167 @@ namespace BPASmartClient.SCChip

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)
{
try
{
switch ((IC_SE)(@event as SCChip_MakeIceCreamEvent).SteeringEngine)
{
case IC_SE.SE_1:
status["CompletedOpen_SE_1"] = false;
break;
case IC_SE.SE_2:
status["CompletedOpen_SE_2"] = false;
break;
case IC_SE.SE_3:
status["CompletedOpen_SE_3"] = false;
break;
}
package.Cmd = IC_CMD.OPEN_SE;
package.Value = (byte)(@event as SCChip_MakeIceCreamEvent).SteeringEngine;
commProxy.SendData(StructureToByte(package));
EventBus.EventBus.GetInstance().Subscribe<SCChip_MakeIceCreamEvent>(DeviceId, delegate (IEvent @event, EventCallBackHandle callBack)
{
try
{
switch ((IC_SE)(@event as SCChip_MakeIceCreamEvent).SteeringEngine)
{
case IC_SE.SE_1:
status["CompletedOpen_SE_1"] = false;
break;
case IC_SE.SE_2:
status["CompletedOpen_SE_2"] = false;
break;
case IC_SE.SE_3:
status["CompletedOpen_SE_3"] = false;
break;
}
package.Cmd = IC_CMD.OPEN_SE;
package.Value = (byte)(@event as SCChip_MakeIceCreamEvent).SteeringEngine;
commProxy.SendData(StructureToByte(package));

bool wait = true;
DateTime waitTimeout = DateTime.Now.AddSeconds(3);
while (wait)
{
wait = DateTime.Now < waitTimeout;
if (wait)
{
switch ((IC_SE)(@event as SCChip_MakeIceCreamEvent).SteeringEngine)
{
case IC_SE.SE_1:
wait = !(bool)status["CompletedOpen_SE_1"];
break;
case IC_SE.SE_2:
wait = !(bool)status["CompletedOpen_SE_2"];
break;
case IC_SE.SE_3:
wait = !(bool)status["CompletedOpen_SE_3"];
break;
}
}
Thread.Sleep(10);
}
Thread.Sleep(2000);
package.Cmd = IC_CMD.CLOSE_SE;
package.Value = (byte)(@event as SCChip_MakeIceCreamEvent).SteeringEngine;
commProxy.SendData(StructureToByte(package));
bool wait = true;
DateTime waitTimeout = DateTime.Now.AddSeconds(3);
while (wait)
{
wait = DateTime.Now < waitTimeout;
if (wait)
{
switch ((IC_SE)(@event as SCChip_MakeIceCreamEvent).SteeringEngine)
{
case IC_SE.SE_1:
wait = !(bool)status["CompletedOpen_SE_1"];
break;
case IC_SE.SE_2:
wait = !(bool)status["CompletedOpen_SE_2"];
break;
case IC_SE.SE_3:
wait = !(bool)status["CompletedOpen_SE_3"];
break;
}
}
Thread.Sleep(10);
}
Thread.Sleep(2000);
package.Cmd = IC_CMD.CLOSE_SE;
package.Value = (byte)(@event as SCChip_MakeIceCreamEvent).SteeringEngine;
commProxy.SendData(StructureToByte(package));

wait = true;
waitTimeout = DateTime.Now.AddSeconds(3);
while (wait)
{
wait = DateTime.Now < waitTimeout;
if (wait)
{
switch ((IC_SE)(@event as SCChip_MakeIceCreamEvent).SteeringEngine)
{
case IC_SE.SE_1:
wait = !(bool)status["CompletedClose_SE_1"];
break;
case IC_SE.SE_2:
wait = !(bool)status["CompletedClose_SE_2"];
break;
case IC_SE.SE_3:
wait = !(bool)status["CompletedClose_SE_3"];
break;
}
}
Thread.Sleep(10);
}
}
catch (Exception ex)
{
MessageLog.GetInstance.ShowEx($"BPASmartClient.SCChip 中引发错误,ICChipMachine 类,描述:[{ex.Message}]");
}
});
wait = true;
waitTimeout = DateTime.Now.AddSeconds(3);
while (wait)
{
wait = DateTime.Now < waitTimeout;
if (wait)
{
switch ((IC_SE)(@event as SCChip_MakeIceCreamEvent).SteeringEngine)
{
case IC_SE.SE_1:
wait = !(bool)status["CompletedClose_SE_1"];
break;
case IC_SE.SE_2:
wait = !(bool)status["CompletedClose_SE_2"];
break;
case IC_SE.SE_3:
wait = !(bool)status["CompletedClose_SE_3"];
break;
}
}
Thread.Sleep(10);
}
}
catch (Exception ex)
{
MessageLog.GetInstance.ShowEx($"BPASmartClient.SCChip 中引发错误,ICChipMachine 类,描述:[{ex.Message}]");
}
});

//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)
{
}
}

}

Cargando…
Cancelar
Guardar