Selaa lähdekoodia

1

JXJAgvReake
pry 1 vuosi sitten
vanhempi
commit
c9a7ab810f
1 muutettua tiedostoa jossa 137 lisäystä ja 66 poistoa
  1. +137
    -66
      BPASmartClient.Tourism/Control_MorkCL.cs

+ 137
- 66
BPASmartClient.Tourism/Control_MorkCL.cs Näytä tiedosto

@@ -32,7 +32,6 @@ namespace BPASmartClient.MorkCL
MonitorViewModel.DeviceId = DeviceId;

//注册本地配方接收
ActionManage.GetInstance.Send(NotifyTopic.FormulaDistribution, "");
ActionManage.GetInstance.Register(new Action<object>(o =>
{
if (o != null && o is ControlData cd) morkCL.cds.Enqueue(cd);
@@ -77,75 +76,147 @@ namespace BPASmartClient.MorkCL
private void FryingPanControl(EDeviceType et, ControlData cd)
{
DeviceProcessLogShow($"开始执行-{cd.Name} 任务");
for (int i = 0; i < cd.ControlFuncs.Count; i++)
if (TaskList.ContainsKey(et) && TaskList[et].Cts.IsCancellationRequested) return;
while (cd.ControlFuncs.Count > 0)
{
if (TaskList.ContainsKey(et) && TaskList[et].Cts.IsCancellationRequested) return;
var device = (FryingPanServer)devices[et];
var robot = (RobotServer)devices[EDeviceType.机器人];
var keyValues = cd.ControlFuncs.ElementAt(i);
int index = (ushort)et - 1;
DeviceProcessLogShow($"{cd.Name}-任务执行-{keyValues.Key.ToString()}-步骤");
switch (keyValues.Key)
if (cd.ControlFuncs.TryDequeue(out FuncModel fm))
{
case EFunc.搅拌启动:
device.MixingFrequencySet(keyValues.Value[0].ParValue);
device.StirStartOrStop = true;
break;
case EFunc.搅拌停止:
device.StirStartOrStop = false;
break;
case EFunc.加热启动:
device.HeatingGearSet(keyValues.Value[0].ParValue);
device.HeatStartOrStop = true;
break;
case EFunc.加热停止:
device.HeatStartOrStop = false;
break;
case EFunc.添加调料:
var Seasoning = SqliteHelper.GetInstance.GetSeasoning().FirstOrDefault(p => p.Id == keyValues.Value[0].Id);
if (Seasoning != null)
{
device.CuttingControl(Seasoning.Loc.ToString(), keyValues.Value[1].ParValue);
}
break;
case EFunc.添加主料:
case EFunc.添加辅料:
MaterialBase mb = new MaterialBase();
if (keyValues.Key == EFunc.添加辅料)
mb = SqliteHelper.GetInstance.GetAccessories().FirstOrDefault(p => p.Id == keyValues.Value[0].Id);
else mb = SqliteHelper.GetInstance.GetIngredients().FirstOrDefault(p => p.Id == keyValues.Value[0].Id);
robot.RobotTaskControl(mb.Loc.ToString(), et);
device.FeedingLocFB.Wait(Cts: TaskList[et].Cts);//等待炒锅到投料位置
robot.MaterialPouringRequest[index].Wait(Cts: TaskList[et].Cts); //等待机器人到投料位置
robot.AllowPourVegetables(et);//允许机器人开始投料
robot.MaterialPouringComplete[index].Wait(Cts: TaskList[et].Cts); //等待机器人投料完成
break;
case EFunc.炒锅回原点位:
device.FryingPanHome = true;
break;
case EFunc.出餐启动:
robot.RobotTaskControl("1", et);//取空盆
robot.DiningOutRequest[index].Wait(Cts: TaskList[et].Cts);//等待机器人到出菜位置
device.DiningOutStart = true;
break;
case EFunc.炒锅清洗:
device.FryingPanClear = true;
break;
case EFunc.炒锅回投料位置:
device.FryingPanFeedingLoc = true;
break;
case EFunc.去指定炒制位:
device.SetStirFryingLoc(keyValues.Value[0].ParValue);
break;
case EFunc.炒制:
if (int.TryParse(keyValues.Value[0].ParValue, out int time))
Task.Delay(time * 1000).Wait(TaskList[et].Cts.Token);
break;
default:
break;
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.搅拌启动:
device.MixingFrequencySet(fm.funcPars.ElementAt(0).ParValue);
device.StirStartOrStop = true;
break;
case EFunc.搅拌停止:
device.StirStartOrStop = false;
break;
case EFunc.加热启动:
device.HeatingGearSet(fm.funcPars.ElementAt(0).ParValue);
device.HeatStartOrStop = true;
break;
case EFunc.加热停止:
device.HeatStartOrStop = false;
break;
case EFunc.添加调料:
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);
}
break;
case EFunc.添加主料:
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);
robot.RobotTaskControl(mb.Loc.ToString(), et);
device.FeedingLocFB.Wait(Cts: TaskList[et].Cts);//等待炒锅到投料位置
robot.MaterialPouringRequest[index].Wait(Cts: TaskList[et].Cts); //等待机器人到投料位置
robot.AllowPourVegetables(et);//允许机器人开始投料
robot.MaterialPouringComplete[index].Wait(Cts: TaskList[et].Cts); //等待机器人投料完成
break;
case EFunc.炒锅回原点位:
device.FryingPanHome = true;
break;
case EFunc.出餐启动:
robot.RobotTaskControl("1", et);//取空盆
robot.DiningOutRequest[index].Wait(Cts: TaskList[et].Cts);//等待机器人到出菜位置
device.DiningOutStart = true;
break;
case EFunc.炒锅清洗:
device.FryingPanClear = true;
break;
case EFunc.炒锅回投料位置:
device.FryingPanFeedingLoc = true;
break;
case EFunc.去指定炒制位:
device.SetStirFryingLoc(fm.funcPars.ElementAt(0).ParValue);
break;
case EFunc.炒制:
if (int.TryParse(fm.funcPars.ElementAt(0).ParValue, out int time))
Task.Delay(time * 1000).Wait(TaskList[et].Cts.Token);
break;
default:
break;
}
}

}


//for (int i = 0; i < cd.ControlFuncs.Count; i++)
//{
// if (TaskList.ContainsKey(et) && TaskList[et].Cts.IsCancellationRequested) return;
// var device = (FryingPanServer)devices[et];
// var robot = (RobotServer)devices[EDeviceType.机器人];
// var keyValues = cd.ControlFuncs.ElementAt(i);
// int index = (ushort)et - 1;
// DeviceProcessLogShow($"{cd.Name}-任务执行-{keyValues.Key.ToString()}-步骤");
// switch (keyValues.Key)
// {
// case EFunc.搅拌启动:
// device.MixingFrequencySet(keyValues.Value[0].ParValue);
// device.StirStartOrStop = true;
// break;
// case EFunc.搅拌停止:
// device.StirStartOrStop = false;
// break;
// case EFunc.加热启动:
// device.HeatingGearSet(keyValues.Value[0].ParValue);
// device.HeatStartOrStop = true;
// break;
// case EFunc.加热停止:
// device.HeatStartOrStop = false;
// break;
// case EFunc.添加调料:
// var Seasoning = SqliteHelper.GetInstance.GetSeasoning().FirstOrDefault(p => p.Id == keyValues.Value[0].Id);
// if (Seasoning != null)
// {
// device.CuttingControl(Seasoning.Loc.ToString(), keyValues.Value[1].ParValue);
// }
// break;
// case EFunc.添加主料:
// case EFunc.添加辅料:
// MaterialBase mb = new MaterialBase();
// if (keyValues.Key == EFunc.添加辅料)
// mb = SqliteHelper.GetInstance.GetAccessories().FirstOrDefault(p => p.Id == keyValues.Value[0].Id);
// else mb = SqliteHelper.GetInstance.GetIngredients().FirstOrDefault(p => p.Id == keyValues.Value[0].Id);
// robot.RobotTaskControl(mb.Loc.ToString(), et);
// device.FeedingLocFB.Wait(Cts: TaskList[et].Cts);//等待炒锅到投料位置
// robot.MaterialPouringRequest[index].Wait(Cts: TaskList[et].Cts); //等待机器人到投料位置
// robot.AllowPourVegetables(et);//允许机器人开始投料
// robot.MaterialPouringComplete[index].Wait(Cts: TaskList[et].Cts); //等待机器人投料完成
// break;
// case EFunc.炒锅回原点位:
// device.FryingPanHome = true;
// break;
// case EFunc.出餐启动:
// robot.RobotTaskControl("1", et);//取空盆
// robot.DiningOutRequest[index].Wait(Cts: TaskList[et].Cts);//等待机器人到出菜位置
// device.DiningOutStart = true;
// break;
// case EFunc.炒锅清洗:
// device.FryingPanClear = true;
// break;
// case EFunc.炒锅回投料位置:
// device.FryingPanFeedingLoc = true;
// break;
// case EFunc.去指定炒制位:
// device.SetStirFryingLoc(keyValues.Value[0].ParValue);
// break;
// case EFunc.炒制:
// if (int.TryParse(keyValues.Value[0].ParValue, out int time))
// Task.Delay(time * 1000).Wait(TaskList[et].Cts.Token);
// break;
// default:
// break;
// }

//}
}

public override void ReadData()


Ladataan…
Peruuta
Tallenna