|
|
@@ -8,6 +8,7 @@ using SqlSugar; |
|
|
|
using System; |
|
|
|
using System.Collections.Generic; |
|
|
|
using System.Linq; |
|
|
|
using System.Net.WebSockets; |
|
|
|
using System.Reflection; |
|
|
|
using System.Text; |
|
|
|
using System.Threading.Tasks; |
|
|
@@ -63,10 +64,10 @@ namespace BPASmartClient.MorkCL |
|
|
|
|
|
|
|
#if !FORMAL |
|
|
|
devices[EDeviceType.炒锅1].Init(Json<ConnectPar>.Data.FryingPanIP1); |
|
|
|
devices[EDeviceType.炒锅2].Init(Json<ConnectPar>.Data.FryingPanIP2); |
|
|
|
//devices[EDeviceType.炒锅2].Init(Json<ConnectPar>.Data.FryingPanIP2); |
|
|
|
devices[EDeviceType.机器人].Init(Json<ConnectPar>.Data.RobotIP); |
|
|
|
devices[EDeviceType.压力锅].Init(Json<ConnectPar>.Data.PressureCookerIP); |
|
|
|
devices[EDeviceType.外部设备].Init(Json<ConnectPar>.Data.PPortName); |
|
|
|
//devices[EDeviceType.压力锅].Init(Json<ConnectPar>.Data.PressureCookerIP); |
|
|
|
//devices[EDeviceType.外部设备].Init(Json<ConnectPar>.Data.PPortName); |
|
|
|
|
|
|
|
ManualActionRegiester(); |
|
|
|
#endif |
|
|
@@ -98,7 +99,7 @@ namespace BPASmartClient.MorkCL |
|
|
|
if (TaskList.ContainsKey(res)) TaskList.TryRemove(res, out _); |
|
|
|
} |
|
|
|
|
|
|
|
private void FryingPanControl(EDeviceType et, ControlData cd) |
|
|
|
private async void FryingPanControl(EDeviceType et, ControlData cd) |
|
|
|
{ |
|
|
|
DeviceProcessLogShow($"开始执行-{cd.Name} 任务"); |
|
|
|
if (TaskList.ContainsKey(et) && TaskList[et].Cts.IsCancellationRequested) return; |
|
|
@@ -106,35 +107,38 @@ namespace BPASmartClient.MorkCL |
|
|
|
{ |
|
|
|
if (cd.ControlFuncs.TryDequeue(out FuncModel fm)) |
|
|
|
{ |
|
|
|
//var device = (FryingPanServer)devices[et]; |
|
|
|
//var robot = (RobotServer)devices[EDeviceType.机器人]; |
|
|
|
var device = (FryingPanServer)devices[et]; |
|
|
|
var robot = (RobotServer)devices[EDeviceType.机器人]; |
|
|
|
int index = (ushort)et - 1; |
|
|
|
DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}。"); |
|
|
|
switch (fm.eFunc) |
|
|
|
{ |
|
|
|
case EFunc.搅拌启动: |
|
|
|
DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-写入搅拌频率-{fm.funcPars.ElementAt(0).ParValue.ToString()}HZ。"); |
|
|
|
//device.MixingFrequencySet(fm.funcPars.ElementAt(0).ParValue.ToString()); |
|
|
|
device.MixingFrequencySet(fm.funcPars.ElementAt(0).ParValue.ToString()); |
|
|
|
DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-写入搅拌频率-{fm.funcPars.ElementAt(0).ParValue.ToString()}HZ完成。"); |
|
|
|
|
|
|
|
DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-写入开始搅拌。"); |
|
|
|
//device.StirStartOrStop = true; |
|
|
|
device.StirStartOrStop = true; |
|
|
|
DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-写入开始搅拌完成。"); |
|
|
|
|
|
|
|
break; |
|
|
|
case EFunc.搅拌停止: |
|
|
|
DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-写入停止搅拌。"); |
|
|
|
//device.StirStartOrStop = false; |
|
|
|
device.StirStartOrStop = false; |
|
|
|
DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-写入停止搅拌完成。"); |
|
|
|
break; |
|
|
|
case EFunc.加热启动: |
|
|
|
DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-设置加热挡位-【{fm.funcPars.ElementAt(0).ParValue.ToString()}】。"); |
|
|
|
//device.HeatingGearSet(fm.funcPars.ElementAt(0).ParValue.ToString()); |
|
|
|
device.HeatingGearSet(fm.funcPars.ElementAt(0).ParValue.ToString()); |
|
|
|
DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-设置加热挡位完成,设置加热启动。"); |
|
|
|
//device.HeatStartOrStop = true; |
|
|
|
|
|
|
|
device.HeatStartOrStop = true; |
|
|
|
DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-设置加热启动完成。"); |
|
|
|
break; |
|
|
|
case EFunc.加热停止: |
|
|
|
DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-设置加热停止。"); |
|
|
|
//device.HeatStartOrStop = false; |
|
|
|
device.HeatStartOrStop = false; |
|
|
|
DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-设置加热停止完成。"); |
|
|
|
break; |
|
|
|
case EFunc.添加调料: |
|
|
@@ -142,8 +146,10 @@ namespace BPASmartClient.MorkCL |
|
|
|
var Seasoning = SqliteHelper.GetInstance.GetSeasoning().FirstOrDefault(p => p.Id == fm.funcPars.ElementAt(0).Id); |
|
|
|
if (Seasoning != null) |
|
|
|
{ |
|
|
|
//device.CuttingControl(Seasoning.Loc.ToString(), fm.funcPars.ElementAt(1).ParValue.ToString()); |
|
|
|
//TODO:应该为下料完成就关闭。 |
|
|
|
device.CuttingControl(Seasoning.Loc.ToString(), fm.funcPars.ElementAt(1).ParValue.ToString()); |
|
|
|
DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-执行下料,下料位置:{Seasoning.Loc.ToString()},下料重量:【{fm.funcPars.ElementAt(1).ParValue.ToString()}】。"); |
|
|
|
|
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
@@ -164,26 +170,33 @@ namespace BPASmartClient.MorkCL |
|
|
|
//device.CuttingControl(Seasoning.Loc.ToString(), fm.funcPars.ElementAt(1).ParValue.ToString()); |
|
|
|
var ingredientes = Json<ItemStorageInfo>.Data.IngredientsStorage[ingre_index]; |
|
|
|
//TODO:机器人下发取料 |
|
|
|
DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-执行下料,控制取{ingre_index}库物料,下料名称:{ingredientes.Name.ToString()},下料重量:【{fm.funcPars.ElementAt(1).ParValue.ToString()}】。"); |
|
|
|
DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-执行下料,控制取{ingre_index+1}库物料,下料名称:{ingredientes.Name.ToString()},下料重量:【{fm.funcPars.ElementAt(1).ParValue.ToString()}】。"); |
|
|
|
|
|
|
|
DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-设置机器人任务【{ingre_index.ToString()}】,子任务【{et}】。"); |
|
|
|
//robot.RobotTaskControl(ingre_index.ToString(), et); |
|
|
|
DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-设置机器人任务【{ingre_index.ToString()}】,子任务【{et}】完成。"); |
|
|
|
DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-设置机器人任务【{ingre_index+1.ToString()}】,子任务【{et}】。"); |
|
|
|
robot.RobotTaskControl(ingre_index+1.ToString(), et); |
|
|
|
DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-设置机器人任务【{ingre_index+1.ToString()}】,子任务【{et}】完成。"); |
|
|
|
|
|
|
|
DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-设置炒锅回原点。"); |
|
|
|
device.FryingPanHome = true; |
|
|
|
DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-设置炒锅回原点完成。"); |
|
|
|
|
|
|
|
DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-等待炒锅到投料位置。"); |
|
|
|
//device.FeedingLocFB.Wait(Cts: TaskList[et].Cts);//等待炒锅到投料位置 |
|
|
|
device.FeedingLocFB.Wait(Cts: TaskList[et].Cts);//等待炒锅到投料位置 |
|
|
|
device.FryingPanHome = false; |
|
|
|
DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-等待炒锅到投料位置完成。"); |
|
|
|
|
|
|
|
|
|
|
|
DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-等待机器人到投料位置。"); |
|
|
|
//robot.MaterialPouringRequest[index].Wait(Cts: TaskList[et].Cts); //等待机器人到投料位置 |
|
|
|
robot.MaterialPouringRequest[index].Wait(Cts: TaskList[et].Cts); //等待机器人到投料位置 |
|
|
|
DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-等待机器人到投料位置完成。"); |
|
|
|
|
|
|
|
|
|
|
|
DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-设置允许机器人开始投料。"); |
|
|
|
//robot.AllowPourVegetables(et);//允许机器人开始投料 |
|
|
|
robot.AllowPourVegetables(et);//允许机器人开始投料 |
|
|
|
DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-设置允许机器人开始投料完成。"); |
|
|
|
|
|
|
|
DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-开始等待机器人投料完成。"); |
|
|
|
//robot.MaterialPouringComplete[index].Wait(Cts: TaskList[et].Cts); //等待机器人投料完成 |
|
|
|
robot.MaterialPouringComplete[index].Wait(Cts: TaskList[et].Cts); //等待机器人投料完成 |
|
|
|
DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-机器人投料完成。"); |
|
|
|
|
|
|
|
Json<ItemStorageInfo>.Data.IngredientsStorage[ingre_index] = new ItemStorage(); |
|
|
@@ -197,20 +210,22 @@ namespace BPASmartClient.MorkCL |
|
|
|
} |
|
|
|
break; |
|
|
|
case EFunc.添加辅料: |
|
|
|
MaterialBase mb = new MaterialBase(); |
|
|
|
if (fm.eFunc == EFunc.添加辅料) |
|
|
|
mb = SqliteHelper.GetInstance.GetAccessories().FirstOrDefault(p => p.Id == fm.funcPars.ElementAt(0).Id); |
|
|
|
else mb = SqliteHelper.GetInstance.GetIngredients().FirstOrDefault(p => p.Id == fm.funcPars.ElementAt(0).Id); |
|
|
|
DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-设置机器人任务【{mb.Loc.ToString()}】,子任务【{et}】。"); |
|
|
|
//robot.RobotTaskControl(mb.Loc.ToString(), et); |
|
|
|
DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-设置机器人任务【{mb.Loc.ToString()}】,子任务【{et}】完成。"); |
|
|
|
MaterialBase mb = SqliteHelper.GetInstance.GetAccessories().FirstOrDefault(p => p.Id == fm.funcPars.ElementAt(0).Id); |
|
|
|
DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-设置机器人任务【{(mb.Loc+12).ToString()}】,子任务【{et}】。"); |
|
|
|
robot.RobotTaskControl((mb.Loc+12).ToString(), et); |
|
|
|
DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-设置机器人任务【{(mb.Loc+12).ToString()}】,子任务【{et}】完成。"); |
|
|
|
|
|
|
|
DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-设置炒锅回原点。"); |
|
|
|
device.FryingPanHome = true; |
|
|
|
DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-设置炒锅回原点完成。"); |
|
|
|
|
|
|
|
DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-等待炒锅到投料位置。"); |
|
|
|
//device.FeedingLocFB.Wait(Cts: TaskList[et].Cts);//等待炒锅到投料位置 |
|
|
|
device.FeedingLocFB.Wait(Cts: TaskList[et].Cts);//等待炒锅到投料位置 |
|
|
|
device.FryingPanHome = false; |
|
|
|
DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-等待炒锅到投料位置完成。"); |
|
|
|
|
|
|
|
DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-等待机器人到投料位置。"); |
|
|
|
//robot.MaterialPouringRequest[index].Wait(Cts: TaskList[et].Cts); //等待机器人到投料位置 |
|
|
|
robot.MaterialPouringRequest[index].Wait(Cts: TaskList[et].Cts); //等待机器人到投料位置 |
|
|
|
DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-等待机器人到投料位置完成。"); |
|
|
|
|
|
|
|
DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-设置允许机器人开始投料。"); |
|
|
@@ -218,36 +233,69 @@ namespace BPASmartClient.MorkCL |
|
|
|
DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-设置允许机器人开始投料完成。"); |
|
|
|
|
|
|
|
DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-开始等待机器人投料完成。"); |
|
|
|
//robot.MaterialPouringComplete[index].Wait(Cts: TaskList[et].Cts); //等待机器人投料完成 |
|
|
|
robot.MaterialPouringComplete[index].Wait(Cts: TaskList[et].Cts); //等待机器人投料完成 |
|
|
|
DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-机器人投料完成。"); |
|
|
|
break; |
|
|
|
case EFunc.炒锅回原点位: |
|
|
|
|
|
|
|
|
|
|
|
DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-设置炒锅回原点。"); |
|
|
|
//device.FryingPanHome = true; |
|
|
|
device.FryingPanHome = true; |
|
|
|
DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-设置炒锅回原点完成。"); |
|
|
|
|
|
|
|
DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-等待回原点完成。"); |
|
|
|
device.FeedingLocFB.Wait(Cts: TaskList[et].Cts); |
|
|
|
device.FryingPanHome = false; |
|
|
|
|
|
|
|
break; |
|
|
|
case EFunc.出餐启动: |
|
|
|
|
|
|
|
device.DiningOutStart = false; |
|
|
|
DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-设置机器人取空盆。"); |
|
|
|
//robot.RobotTaskControl("1", et);//取空盆 |
|
|
|
//TODO:正常应该是哪个有空盆取哪个。 |
|
|
|
robot.RobotTaskControl("21", et);//取空盆 |
|
|
|
DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-设置机器人取空盆完成,等待机器人到出菜位置。"); |
|
|
|
//robot.DiningOutRequest[index].Wait(Cts: TaskList[et].Cts);//等待机器人到出菜位置 |
|
|
|
|
|
|
|
robot.DiningOutRequest[index].Wait(Cts: TaskList[et].Cts);//等待机器人到出菜位置 |
|
|
|
DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-机器人已到出餐位置,出餐启动。"); |
|
|
|
//device.DiningOutStart = true; |
|
|
|
device.DiningOutStart = true; |
|
|
|
|
|
|
|
device.OutDinningSlowDownFlag.Wait(Cts: TaskList[et].Cts) ; |
|
|
|
robot.ModerateInPlace(et); |
|
|
|
DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-到达出餐减速位。"); |
|
|
|
|
|
|
|
device.OutDinningFinsh.Wait(Cts: TaskList[et].Cts); |
|
|
|
robot.DiningOutComplete(et); |
|
|
|
|
|
|
|
DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-出餐完成。"); |
|
|
|
//回到投料位置就复位。 |
|
|
|
Thread.Sleep(500); |
|
|
|
device.FeedingLocFB.Wait(Cts: TaskList[et].Cts); |
|
|
|
device.DiningOutStart = false; |
|
|
|
break; |
|
|
|
case EFunc.炒锅清洗: |
|
|
|
DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-设置超过清洗。"); |
|
|
|
//device.FryingPanClear = true; |
|
|
|
DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-设置炒锅清洗。"); |
|
|
|
device.FryingPanClear = true; |
|
|
|
DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-炒锅清洗已写入。"); |
|
|
|
|
|
|
|
Thread.Sleep(500); |
|
|
|
device.CleanFinish.Wait(Cts: TaskList[et].Cts); |
|
|
|
device.FryingPanClear = false; |
|
|
|
break; |
|
|
|
case EFunc.炒锅回投料位置: |
|
|
|
DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-设置炒锅到调料位置。"); |
|
|
|
//device.FryingPanFeedingLoc = true; |
|
|
|
device.FryingPanFeedingLoc = true; |
|
|
|
DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-设置炒锅到调料位置完成。"); |
|
|
|
|
|
|
|
//回到投料位置就复位。 |
|
|
|
|
|
|
|
Thread.Sleep(500); |
|
|
|
device.FeedingLocFB.Wait(Cts: TaskList[et].Cts); |
|
|
|
device.DiningOutStart = false; |
|
|
|
break; |
|
|
|
case EFunc.去指定炒制位: |
|
|
|
DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-设置去指定炒制位。"); |
|
|
|
//device.SetStirFryingLoc(fm.funcPars.ElementAt(0).ParValue.ToString()); |
|
|
|
device.SetStirFryingLoc(fm.funcPars.ElementAt(0).ParValue.ToString()); |
|
|
|
DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-设置去指定炒制位【{fm.funcPars.ElementAt(0).ParValue.ToString()}】完成。"); |
|
|
|
break; |
|
|
|
case EFunc.炒制: |
|
|
@@ -280,6 +328,31 @@ namespace BPASmartClient.MorkCL |
|
|
|
//这两个是字段。直接赋值 |
|
|
|
morkCL.FeedingLocFB1 = fryingPan1.FeedingLocFB; |
|
|
|
morkCL.FeedingLocFB2=fryingPan2.FeedingLocFB; |
|
|
|
morkCL.CleanFinish1 = fryingPan1.CleanFinish; |
|
|
|
morkCL.CleanFinish2 = fryingPan2.CleanFinish; |
|
|
|
morkCL.OutDinningFinsh1 = fryingPan1.OutDinningFinsh; |
|
|
|
morkCL.OutDinningFinsh2 = fryingPan2.OutDinningFinsh; |
|
|
|
morkCL.OutDinningSlowDownFlag1 = fryingPan1.OutDinningSlowDownFlag; |
|
|
|
morkCL.OutDinningSlowDownFlag2 = fryingPan2.OutDinningSlowDownFlag; |
|
|
|
|
|
|
|
if (fryingPan1.FeedingLocFB) |
|
|
|
{ |
|
|
|
robot.AllowPourVegetables(EDeviceType.炒锅1); |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
robot.DisablePourVegetables(EDeviceType.炒锅1); |
|
|
|
} |
|
|
|
|
|
|
|
if (fryingPan2.FeedingLocFB) |
|
|
|
{ |
|
|
|
robot.AllowPourVegetables(EDeviceType.炒锅2); |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
robot.DisablePourVegetables(EDeviceType.炒锅2); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
foreach (var property in propertyInfos) |
|
|
|
{ |
|
|
@@ -358,10 +431,13 @@ namespace BPASmartClient.MorkCL |
|
|
|
{ |
|
|
|
ActionManage.GetInstance.Register((object location) => |
|
|
|
{ |
|
|
|
if (String.IsNullOrEmpty(location.ToString()) &&location.ToString().Length>=0) |
|
|
|
var loc = location.ToString(); |
|
|
|
if (!String.IsNullOrEmpty(loc) && loc.Length>=0) |
|
|
|
{ |
|
|
|
var robot = (RobotServer)devices[EDeviceType.机器人]; |
|
|
|
robot.WarehousingControl(location.ToString()); |
|
|
|
robot.WarehousingControl(loc); |
|
|
|
//会卡死。 |
|
|
|
//robot.WarehousingComplete[(Convert.ToInt32(loc)-1)].Wait(); |
|
|
|
} |
|
|
|
},"ItemStorage",true); |
|
|
|
|
|
|
|