Просмотр исходного кода

修改冒菜机订单状态改变事件推送方式。2. 成都旅游学院调试修改

煮面机(新)
ZhaoGang 1 год назад
Родитель
Сommit
ed1e5c8e3f
21 измененных файлов: 747 добавлений и 611 удалений
  1. +2
    -1
      BPASmartClient.Device/BaseDevice.cs
  2. +327
    -241
      BPASmartClient.MorkCL/Control_MorkCL.cs
  3. +30
    -3
      BPASmartClient.MorkCL/Model/Control/FryingPanSet.cs
  4. +24
    -0
      BPASmartClient.MorkCL/Model/Control/RobotSet.cs
  5. +20
    -0
      BPASmartClient.MorkCL/Model/Json/ConnectPar.cs
  6. +5
    -4
      BPASmartClient.MorkCL/Server/FryingPanServer.cs
  7. +2
    -1
      BPASmartClient.MorkCL/Server/OtherServer.cs
  8. +4
    -2
      BPASmartClient.MorkCL/Server/RobotServer.cs
  9. +2
    -1
      BPASmartClient.MorkCL/Server/TaskServer.cs
  10. +60
    -6
      BPASmartClient.MorkCL/View/Debug.xaml
  11. +19
    -10
      BPASmartClient.MorkCL/View/ItemStorageView.xaml
  12. +1
    -1
      BPASmartClient.MorkCL/View/Monitor.xaml
  13. +9
    -2
      BPASmartClient.MorkCL/View/ParSet.xaml
  14. +0
    -141
      BPASmartClient.MorkCL/View/Test.xaml
  15. +0
    -15
      BPASmartClient.MorkCL/View/Test.xaml.cs
  16. +125
    -10
      BPASmartClient.MorkCL/ViewModel/DebugViewModel.cs
  17. +25
    -5
      BPASmartClient.MorkCL/ViewModel/ItemStorageViewModel.cs
  18. +0
    -166
      BPASmartClient.MorkCL/ViewModel/testViewModel.cs
  19. +77
    -1
      BPASmartClient.MorkMV1/Control_MorkMV1.cs
  20. +14
    -0
      BPASmartClient.MorkMV1/Model/OrderStatusModel.cs
  21. +1
    -1
      BPASmartClient.MorkSUpgradedVer/Control_MorkSUpgradedVer.cs

+ 2
- 1
BPASmartClient.Device/BaseDevice.cs Просмотреть файл

@@ -509,7 +509,8 @@ namespace BPASmartClient.Device
}

//监控列表排序
vm.OrderBy(p => p.VarName).ToList().ForEach(item => { variableMonitors.Add(item); });
//vm.OrderBy(p => p.VarName).ToList().ForEach(item => { variableMonitors.Add(item); });
vm.ForEach(item => { variableMonitors.Add(item); });

}



+ 327
- 241
BPASmartClient.MorkCL/Control_MorkCL.cs Просмотреть файл

@@ -35,18 +35,8 @@ namespace BPASmartClient.MorkCL
/// </summary>
ConcurrentDictionary<EDeviceType, TaskServer> TaskList { get; set; } = new();

/// <summary>
/// 炒锅1任务队列。
/// </summary>
ConcurrentQueue<TaskServer> FryingPan1TaskLsit { get; set; } = new();
/// <summary>
/// 炒锅2任务队列。
/// </summary>
ConcurrentQueue<TaskServer> FryingPan2TaskLsit { get; set; } = new();
/// <summary>
/// 高压锅任务队列。
/// </summary>
ConcurrentQueue<TaskServer> PressureCookerTaskLsit { get; set; } = new();
List<PropertyInfo>? propertyInfos;

public override void DoMain()
{
MonitorViewModel.DeviceId = DeviceId;
@@ -84,14 +74,26 @@ namespace BPASmartClient.MorkCL
devices.TryAdd(EDeviceType.外部设备, new OtherServer());

#if !FORMAL
devices[EDeviceType.炒锅1].Init(Json<ConnectPar>.Data.FryingPanIP1);
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(PortName:Json<ConnectPar>.Data.ESPortName);

if (Json<ConnectPar>.Data.FryPanConnect_1)
{
devices[EDeviceType.炒锅1].Init(Json<ConnectPar>.Data.FryingPanIP1);
}
if (Json<ConnectPar>.Data.FryPanConnect_2)
{
devices[EDeviceType.炒锅2].Init(Json<ConnectPar>.Data.FryingPanIP2);
}
if (Json<ConnectPar>.Data.RobotConnet)
{
devices[EDeviceType.机器人].Init(Json<ConnectPar>.Data.RobotIP);
}
if (Json<ConnectPar>.Data.PressureCookerConnect)
{
devices[EDeviceType.压力锅].Init(Json<ConnectPar>.Data.PressureCookerIP);
}
if (Json<ConnectPar>.Data.OtherDeviceConnect)
{
devices[EDeviceType.外部设备].Init(PortName: Json<ConnectPar>.Data.ESPortName);
}
#endif
ManualActionRegiester();
}
@@ -106,12 +108,10 @@ namespace BPASmartClient.MorkCL
if (TaskList.IsEmpty)
{
morkCL.CanItemStorage = true;
//ActionManage.GetInstance.Send("RefreshCanItemStorage", true);
}
else
{
morkCL.CanItemStorage = false;
//ActionManage.GetInstance.Send("RefreshCanItemStorage", false);
}

//分配任务,这段程序必须写最后。
@@ -435,7 +435,7 @@ namespace BPASmartClient.MorkCL
DeviceProcessLogShow($"【{et}】开始执行-{cd.Name} 任务");
if (TaskList.ContainsKey(et) && TaskList[et].Cts.IsCancellationRequested)
return;
while (cd.ControlFuncs.Count > 0)
while (cd.ControlFuncs.Count > 0 && !TaskList[et].Cts.IsCancellationRequested)
{
if (cd.ControlFuncs.TryDequeue(out FuncModel fm))
{
@@ -444,269 +444,306 @@ namespace BPASmartClient.MorkCL
var otherDevice = (OtherServer)devices[EDeviceType.外部设备];
int index = (ushort)et - 1;
DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}。");
switch (fm.eFunc)
try
{
case EFunc.搅拌启动:
device.StirStartOrStop = false;
//DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-写入搅拌频率-{fm.funcPars.ElementAt(0).ParValue.ToString()}HZ。");
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;
DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-写入开始搅拌完成。");
break;
case EFunc.搅拌停止:
//DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-写入停止搅拌。");
device.StirStartOrStop = false;
DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-写入停止搅拌完成。");
break;
case EFunc.加热启动:
device.HeatStartOrStop = false;
//DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-设置加热挡位-【{fm.funcPars.ElementAt(0).ParValue.ToString()}】。");
device.HeatingGearSet(fm.funcPars.ElementAt(0).ParValue.ToString());
DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-设置加热挡位-【{fm.funcPars.ElementAt(0).ParValue.ToString()}】完成,等待设置加热启动。");
device.HeatStartOrStop = true;
DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-设置加热启动完成。");
break;
case EFunc.加热停止:
//DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-设置加热停止。");
device.HeatStartOrStop = false;
DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-设置加热停止完成。");
break;
case EFunc.添加调料:
DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-查找调料【{fm.funcPars.ElementAt(0).Id}】。");
var Seasoning = SqliteHelper.GetInstance.GetSeasoning().FirstOrDefault(p => p.Id == fm.funcPars.ElementAt(0).Id);
if (Seasoning != null)
{
device.FryingPanToSeasoningLoc = false;
//DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-设置炒锅到调料投料位置。");
device.FryingPanToSeasoningLoc = true;
DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-设置炒锅到调料投料位置完成,等待炒锅到达调料投料位置。");
switch (fm.eFunc)
{
case EFunc.搅拌启动:
device.StirStartOrStop = false;
//DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-写入搅拌频率-{fm.funcPars.ElementAt(0).ParValue.ToString()}HZ。");
device.MixingFrequencySet(fm.funcPars.ElementAt(0).ParValue.ToString());
DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-写入搅拌频率-{fm.funcPars.ElementAt(0).ParValue.ToString()}HZ完成。");
await Task.Delay(400);
//DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-写入开始搅拌。");
device.StirStartOrStop = true;
DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-写入开始搅拌完成。");
break;
case EFunc.搅拌停止:
//DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-写入停止搅拌。");
device.StirStartOrStop = false;
DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-写入停止搅拌完成。");
break;
case EFunc.加热启动:
device.HeatStartOrStop = false;
await Task.Delay(400);
//DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-设置加热挡位-【{fm.funcPars.ElementAt(0).ParValue.ToString()}】。");
device.HeatingGearSet(fm.funcPars.ElementAt(0).ParValue.ToString());
DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-设置加热挡位-【{fm.funcPars.ElementAt(0).ParValue.ToString()}】完成,等待设置加热启动。");
device.HeatStartOrStop = true;
DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-设置加热启动完成。");
break;
case EFunc.加热停止:
//DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-设置加热停止。");
device.HeatStartOrStop = false;
DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-设置加热停止完成。");
break;
case EFunc.添加调料:
DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-查找调料【{fm.funcPars.ElementAt(0).Id}】。");
var Seasoning = SqliteHelper.GetInstance.GetSeasoning().FirstOrDefault(p => p.Id == fm.funcPars.ElementAt(0).Id);
if (Seasoning != null)
{
device.FryingPanToSeasoningLoc = false;
await Task.Delay(400);

//回到投料位置就复位。
//DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-设置炒锅到调料投料位置。");
device.FryingPanToSeasoningLoc = true;
DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-设置炒锅到调料投料位置完成,等待炒锅到达调料投料位置。");

Thread.Sleep(50);
device.FeedingSeasoningLocFB.Wait(Cts: TaskList[et].Cts);
device.FryingPanToSeasoningLoc = false;
DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-炒锅已到达调料投料位置。");
//回到投料位置就复位。

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
{
DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-查找调料失败,未查找到【{fm.funcPars.ElementAt(0).Id}】调料。任务取消。");
TaskList[et].Cts.Cancel();
}
await Task.Delay(400);

break;
case EFunc.添加主料:
DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-查找主料【{fm.funcPars.ElementAt(0).Id}】。");
device.FeedingSeasoningLocFB.Wait(Cts: TaskList[et].Cts);
device.FryingPanToSeasoningLoc = false;
DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-炒锅已到达调料投料位置。");

if (float.TryParse(fm.funcPars.ElementAt(1).ParValue.ToString(), out float weight))
{
//查找主料库位符合条件的物料库位,主要根据物料ID和物料重量查找。
var ingre_index = Array.FindIndex(Json<ItemStorageInfo>.Data.IngredientsStorage,
item => item.MaterialID == fm.funcPars.ElementAt(0).Id/* && item.Weight == weight*/);
if (ingre_index >= 0)
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
{
//device.CuttingControl(Seasoning.Loc.ToString(), fm.funcPars.ElementAt(1).ParValue.ToString());
var ingredientes = Json<ItemStorageInfo>.Data.IngredientsStorage[ingre_index];
MessageNotify.GetInstance.ShowDialog($"任务【{cd.Name}】查找调料失败,未查找到【{fm.funcPars.ElementAt(0).Id}】调料,任务即将取消。", DialogType.Warning);
DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-查找调料失败,未查找到【{fm.funcPars.ElementAt(0).Id}】调料。任务取消。");
TaskList[et].Cts.Cancel();
}

DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-执行下料,控制取{ingre_index + 1}库物料,下料名称:{ingredientes.Name.ToString()},下料重量:【{fm.funcPars.ElementAt(1).ParValue.ToString()}】。");
device.FryingPanHome = false;
break;
case EFunc.添加主料:
DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-查找主料【{fm.funcPars.ElementAt(0).Id}】。");

//DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-设置机器人任务【{(ingre_index + 1).ToString()}】,子任务【{et}】。");
if (float.TryParse(fm.funcPars.ElementAt(1).ParValue.ToString(), out float weight))
{
//查找主料库位符合条件的物料库位,主要根据物料ID和物料重量查找。
var ingre_index = Array.FindIndex(Json<ItemStorageInfo>.Data.IngredientsStorage,
item => item.MaterialID == fm.funcPars.ElementAt(0).Id/* && item.Weight == weight*/);
if (ingre_index >= 0)
{
//device.CuttingControl(Seasoning.Loc.ToString(), fm.funcPars.ElementAt(1).ParValue.ToString());
var ingredientes = Json<ItemStorageInfo>.Data.IngredientsStorage[ingre_index];

DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-执行下料,控制取{ingre_index + 1}库物料,下料名称:{ingredientes.Name.ToString()},下料重量:【{fm.funcPars.ElementAt(1).ParValue.ToString()}】。");
device.FryingPanHome = false;

//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}】完成。");
await Task.Delay(400);

//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);//等待炒锅到投料位置
await Task.Delay(400);

device.FryingPanHome = false;
DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-等待炒锅到投料位置完成。");


DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-等待机器人到投料位置。");
robot.MaterialPouringRequest[index].Wait(Cts: TaskList[et].Cts); //等待机器人到投料位置也就是发出倒料请求。
//DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-等待机器人到投料位置完成。");

//目前程序在炒锅在投料位置时,会自动发出允许倒料信息。
//DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-设置允许机器人开始投料。");
//robot.AllowPourVegetables(et);//允许机器人开始投料
//DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-设置允许机器人开始投料完成。");

DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-机器人已到达投料位置,等待机器人投料完成。");
robot.MaterialPouringComplete[index].Wait(Cts: TaskList[et].Cts); //等待机器人投料完成
DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-机器人投料完成。");

Json<ItemStorageInfo>.Data.IngredientsStorage[ingre_index] = new ItemStorage();
Json<ItemStorageInfo>.Save();
ActionManage.GetInstance.Send("RefreshItemStorage");
}
else
{
MessageNotify.GetInstance.ShowDialog($"任务【{cd.Name}】查找主料失败,未查找到【{fm.funcPars.ElementAt(0).Id}】主料,任务即将取消。", DialogType.Warning);

//TODO:暂定为直接取消任务,后期再说。
DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-查找主料失败,未查找到【{fm.funcPars.ElementAt(0).Id}】主料。任务取消。");
TaskList[et].Cts.Cancel();
}
}
break;
case EFunc.添加辅料:
MaterialBase mb = SqliteHelper.GetInstance.GetAccessories().FirstOrDefault(p => p.Id == fm.funcPars.ElementAt(0).Id);
if (mb != null)
{
//先复位变量。防止上一次是异常结束,设为True时,不会响应。
device.FryingPanHome = false;

robot.RobotTaskControl((ingre_index + 1).ToString(), et);
DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-设置机器人任务【{(ingre_index + 1).ToString()}】,子任务【{et}】完成。");
//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()}-设置炒锅回投料位置。");
await Task.Delay(400);
device.FryingPanHome = true;
DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-设置炒锅回投料位置完成,等待炒锅回到主料辅料投料位置");
DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-设置炒锅回投料位置完成,开始等待炒锅到投料位置");

//DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-等待炒锅到投料位置。");
device.FeedingLocFB.Wait(Cts: TaskList[et].Cts);//等待炒锅到投料位置
await Task.Delay(400);
device.FryingPanHome = false;
DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-等待炒锅到投料位置完成。");
DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-等待炒锅到投料位置完成,等待机器人到投料位置。");

//DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-等待机器人到投料位置。");
robot.MaterialPouringRequest[index].Wait(Cts: TaskList[et].Cts); //等待机器人到投料位置
DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-机器人到达投料位置完成,开始等待机器人投料完成。");

DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-等待机器人到投料位置。");
robot.MaterialPouringRequest[index].Wait(Cts: TaskList[et].Cts); //等待机器人到投料位置也就是发出倒料请求。
//DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-等待机器人到投料位置完成。");

//目前程序在炒锅在投料位置时,会自动发出允许倒料信息。
//DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-设置允许机器人开始投料。");
//robot.AllowPourVegetables(et);//允许机器人开始投料
//DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-设置允许机器人开始投料完成。");

DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-机器人已到达投料位置,等待机器人投料完成。");
//DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-开始等待机器人投料完成。");
robot.MaterialPouringComplete[index].Wait(Cts: TaskList[et].Cts); //等待机器人投料完成
DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-机器人投料完成。");

Json<ItemStorageInfo>.Data.IngredientsStorage[ingre_index] = new ItemStorage();
Json<ItemStorageInfo>.Save();
ActionManage.GetInstance.Send("RefreshItemStorage");
}
else
{
//TODO:暂定为直接取消任务,后期再说。
DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-查找主料失败,未查找到【{fm.funcPars.ElementAt(0).Id}】主料。任务取消。");
MessageNotify.GetInstance.ShowDialog($"任务【{cd.Name}】查找辅料失败,未查找到【{fm.funcPars.ElementAt(0).Id}】辅料,任务即将取消。", DialogType.Warning);
DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-查找辅料失败,未查找到【{fm.funcPars.ElementAt(0).Id}】辅料。任务取消。");
TaskList[et].Cts.Cancel();
}
}
break;
case EFunc.添加辅料:
MaterialBase mb = SqliteHelper.GetInstance.GetAccessories().FirstOrDefault(p => p.Id == fm.funcPars.ElementAt(0).Id);
if (mb != null)
{
//先复位变量。防止上一次是异常结束,设为True时,不会响应。
break;
case EFunc.炒锅回原点位:
device.FryingPanFeedingLoc = false;
device.FryingPanHome = false;

//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()}-设置炒锅回投料位置。");
//DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-设置炒锅回原点。");
await Task.Delay(400);
device.FryingPanHome = true;
DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-设置炒锅回投料位置完成,开始等待炒锅到投料位置。");
DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-设置炒锅回原点完成,等待炒锅回原点。");

//DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-等待炒锅到投料位置。");
device.FeedingLocFB.Wait(Cts: TaskList[et].Cts);//等待炒锅到投料位置
//DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-等待回原点完成。");
device.FeedingLocFB.Wait(Cts: TaskList[et].Cts);
await Task.Delay(400);
device.FryingPanHome = false;
DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-等待炒锅到投料位置完成,等待机器人到投料位置。");
DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-炒锅回原点完成。");
break;
case EFunc.出餐启动:

device.DiningOutStart = false;
DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-设置机器人取空盆。");
//TODO:暂时修改,后期优化。
while (!TaskList[et].Cts.IsCancellationRequested)
{
var emptyPanIndex = Array.FindIndex(otherDevice.BoxDetection, i => i == true);
if (emptyPanIndex >= 0)
{
robot.RobotTaskControl((21 + emptyPanIndex).ToString(), et);//取空盆
break;
}
await Task.Delay(3000);
DeviceProcessLogShow("无空盆,请添加空盆!");
}
//robot.RobotTaskControl("21", et);//取空盆
DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-设置机器人取空盆完成,等待机器人到出菜位置。");

//DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-等待机器人到投料位置。");
robot.MaterialPouringRequest[index].Wait(Cts: TaskList[et].Cts); //等待机器人到投料位置
DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-机器人到达投料位置完成,开始等待机器人投料完成。");
robot.DiningOutRequest[index].Wait(Cts: TaskList[et].Cts);//等待机器人到出菜位置
DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-机器人已到出餐位置,出餐启动。");
await Task.Delay(400);
device.DiningOutStart = true;

//DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-设置允许机器人开始投料。");
//robot.AllowPourVegetables(et);//允许机器人开始投料
//DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-设置允许机器人开始投料完成。");
device.OutDinningSlowDownFlag.Wait(Cts: TaskList[et].Cts);
robot.ModerateInPlace(et);
DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-到达出餐减速位。");

//DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-开始等待机器人投料完成。");
robot.MaterialPouringComplete[index].Wait(Cts: TaskList[et].Cts); //等待机器人投料完成
DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-机器人投料完成。");
device.OutDinningFinsh.Wait(Cts: TaskList[et].Cts);
robot.DiningOutComplete(et);

}
else
{
DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-查找主料失败,未查找到【{fm.funcPars.ElementAt(0).Id}】辅料。任务取消。");
TaskList[et].Cts.Cancel();
}
break;
case EFunc.炒锅回原点位:
device.FryingPanFeedingLoc = false;
device.FryingPanHome = false;
//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.FryingPanHome = false;
DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-炒锅回原点完成。");
break;
case EFunc.出餐启动:

device.DiningOutStart = false;
DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-设置机器人取空盆。");
//TODO:暂时修改,后期优化。
while (true)
{
var emptyPanIndex = Array.FindIndex(otherDevice.BoxDetection, i => i == true);
if (emptyPanIndex >= 0)
DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-出餐完成。");
//回到投料位置就复位。
Thread.Sleep(50);
device.FeedingLocFB.Wait(Cts: TaskList[et].Cts);
await Task.Delay(400);
device.DiningOutStart = false;
break;
case EFunc.炒锅清洗:
device.FryingPanClear = false;

//DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-设置炒锅清洗。");
await Task.Delay(400);
device.FryingPanClear = true;
DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-炒锅清洗已写入,等待炒锅清洗完成。");

Thread.Sleep(500);
device.CleanFinish.Wait(Cts: TaskList[et].Cts);
await Task.Delay(400);
device.FryingPanClear = false;
DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-炒锅清洗完成。");
break;
case EFunc.炒锅回调料投料位置:
device.FryingPanToSeasoningLoc = false;

//DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-设置炒锅到调料投料位置。");
await Task.Delay(400);
device.FryingPanToSeasoningLoc = true;
DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-设置炒锅到调料投料位置完成,等待回到调料投料位置。");

//回到投料位置就复位。

Thread.Sleep(50);
device.FeedingSeasoningLocFB.Wait(Cts: TaskList[et].Cts);
await Task.Delay(400);
device.FryingPanToSeasoningLoc = false;
DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-炒锅回到调料投料位置完成。");
break;
case EFunc.去指定炒制位:
//DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-设置去指定炒制位。");
device.SetStirFryingLoc(fm.funcPars.ElementAt(0).ParValue.ToString());
DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-设置去指定炒制位【{fm.funcPars.ElementAt(0).ParValue.ToString()}】完成。");

//TODO:根据情况看是否需要等待反馈变量。
//device.StirFryingLocFB[int.Parse(fm.funcPars.ElementAt(0).ParValue.ToString())].Wait();
//DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-炒锅到达炒制位【{fm.funcPars.ElementAt(0).ParValue.ToString()}】。");
break;
case EFunc.炒制:

if (int.TryParse(fm.funcPars.ElementAt(0).ParValue.ToString(), out int time))
{
robot.RobotTaskControl((21 + emptyPanIndex).ToString(), et);//取空盆
break;
DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-等待炒制【{time}】秒。");

Task.Delay(time * 1000).Wait(TaskList[et].Cts.Token);
DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-炒制完成。");
}
await Task.Delay(3000);
DeviceProcessLogShow("无空盆,请添加空盆!");
}
//robot.RobotTaskControl("21", et);//取空盆
DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-设置机器人取空盆完成,等待机器人到出菜位置。");

robot.DiningOutRequest[index].Wait(Cts: TaskList[et].Cts);//等待机器人到出菜位置
DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-机器人已到出餐位置,出餐启动。");
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(50);
device.FeedingLocFB.Wait(Cts: TaskList[et].Cts);
device.DiningOutStart = false;
break;
case EFunc.炒锅清洗:
device.FryingPanClear = false;

//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;
DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-炒锅清洗完成。");
break;
case EFunc.炒锅回调料投料位置:
device.FryingPanToSeasoningLoc = false;

//DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-设置炒锅到调料投料位置。");
device.FryingPanToSeasoningLoc = true;
DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-设置炒锅到调料投料位置完成,等待回到调料投料位置。");

//回到投料位置就复位。

Thread.Sleep(50);
device.FeedingSeasoningLocFB.Wait(Cts: TaskList[et].Cts);
device.FryingPanToSeasoningLoc = false;
DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-炒锅回到调料投料位置完成。");
break;
case EFunc.去指定炒制位:
//DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-设置去指定炒制位。");
device.SetStirFryingLoc(fm.funcPars.ElementAt(0).ParValue.ToString());
DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-设置去指定炒制位【{fm.funcPars.ElementAt(0).ParValue.ToString()}】完成。");

//TODO:根据情况看是否需要等待反馈变量。
//device.StirFryingLocFB[int.Parse(fm.funcPars.ElementAt(0).ParValue.ToString())].Wait();
//DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-炒锅到达炒制位【{fm.funcPars.ElementAt(0).ParValue.ToString()}】。");
break;
case EFunc.炒制:

if (int.TryParse(fm.funcPars.ElementAt(0).ParValue.ToString(), out int time))
{
DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-等待炒制【{time}】秒。");
Task.Delay(time * 1000).Wait(TaskList[et].Cts.Token);
}

DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-炒制完成。");
break;
default:
break;
break;
default:
break;
}
}

catch (TaskCanceledException)
{
DeviceProcessLogShow($"{cd.Name}-任务被取消。");
}
catch (OperationCanceledException)
{
DeviceProcessLogShow($"{cd.Name}-任务被手动取消。");
}
}
}
DeviceProcessLogShow($"【{et}】任务-{cd.Name} 执行完成");
TaskList[et].IsComplete = true;
}
#endregion

public override void ReadData()
{
if (propertyInfos is null || propertyInfos.Count==0)
{
propertyInfos = morkCL.GetType().GetProperties().ToList();
}
var propertyInfos = morkCL.GetType().GetProperties();

var fryingPan1 = (FryingPanServer)devices[EDeviceType.炒锅1];
var fryingPan2 = (FryingPanServer)devices[EDeviceType.炒锅2];
@@ -733,14 +770,21 @@ namespace BPASmartClient.MorkCL
alarm.TurnMotorError2 = fryingPan2.TurnMotorErrorCode != "无故障" ? true : false;

//这是字段。直接赋值
morkCL.FeedingSeasoningLocFB1 = fryingPan1.FeedingSeasoningLocFB;
morkCL.FeedingSeasoningLocFB2 = fryingPan2.FeedingSeasoningLocFB;

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;

morkCL.BoxDetection = otherDevice.BoxDetection;
morkCL.IsIdle = robot.IsIdle;

@@ -847,6 +891,12 @@ namespace BPASmartClient.MorkCL
NoticeDemoViewModel.OpenMsg(EnumPromptType.Error, Application.Current.MainWindow, "入库失败", $"物料入库失败,当前正在制作菜品。");
return;
}
var robot = (RobotServer)devices[EDeviceType.机器人];
if (robot.IsIdle==false)
{
MessageNotify.GetInstance.ShowDialog("当前机器人未在空闲状态,稍后再试。", DialogType.Warning);
return;
}
TaskManage.GetInstance.Start(() =>
{
if (o != null && o is IngredientsTB ingredients)
@@ -863,20 +913,17 @@ namespace BPASmartClient.MorkCL
item.Weight = ((OtherServer)devices[EDeviceType.外部设备]).CurrentWeight;

var loc = (index + 1).ToString();
//var robot = (RobotServer)devices[EDeviceType.机器人];
//robot.WarehousingControl(loc);
//robot.WarehousingComplete[(Convert.ToInt32(loc) - 1)].Wait();

var robot = (RobotServer)devices[EDeviceType.机器人];
#if !FORMAL
robot.WarehousingControl(loc);
DeviceProcessLogShow($"已下发机器人物料入{loc}号库任务,等待机器人入库操作完成");
robot.WarehousingComplete[(Convert.ToInt32(loc) - 1)].Wait();
#endif
Json<ItemStorageInfo>.Save();

ActionManage.GetInstance.Send("RefreshItemStorage");

DeviceProcessLogShow($"物料{ingredients.Name},ID:[{ingredients.Id}]入库成功。");
DeviceProcessLogShow($"物料[{ingredients.Name}],ID:[{ingredients.Id}]入库成功。");
Application.Current.Dispatcher.Invoke(() =>
{
NoticeDemoViewModel.OpenMsg(EnumPromptType.Success, Application.Current.MainWindow, "入库成功", $"物料{ingredients.Name}入库成功。");
@@ -918,6 +965,45 @@ namespace BPASmartClient.MorkCL
}, "ItemStorage", true);
#endregion

ActionManage.GetInstance.Register((object[] o) =>
{
if (o is not null && o is object[] para)
{
var device =(EDeviceType)Enum.Parse(typeof(EDeviceType), para[0].ToString());
var channelIndex = para[1].ToString();
var demandValue = para[2].ToString();
((FryingPanServer)devices[device]).CuttingControl(channelIndex, demandValue);
}
},"DeviceCuttingControl",true);

ActionManage.GetInstance.Register((object o) =>
{
if (o is not null)
{
var device = (EDeviceType)Enum.Parse(typeof(EDeviceType), o.ToString());
if (TaskList.ContainsKey(device))
{
TaskList[device].Cts.Cancel();
DeviceProcessLogShow($"取消{device}当前任务成功。");
}
else
{
DeviceProcessLogShow($"[{device}]当前无任务。");
}
}
}, "CancelFryPanTask", true);

ActionManage.GetInstance.Register((object o) =>
{
if (o is not null)
{
var device = (EDeviceType)Enum.Parse(typeof(EDeviceType), o.ToString());
//TODO : 把所有属于该炒锅的任务全部删除。
}

}, "ClearFryPanTask", true);

ActionManage.GetInstance.Register((object o) =>
{
if (o!=null && o is WriteModel<bool> write)


+ 30
- 3
BPASmartClient.MorkCL/Model/Control/FryingPanSet.cs Просмотреть файл

@@ -26,7 +26,10 @@ namespace BPASmartClient.MorkCL.Model.Control
/// <param name="demandValue">通道需求值</param>
public void CuttingControl(string Num, string demandValue)
{

if (!MyModbus.IsConnected())
{
return;
}
if (ushort.TryParse(Num, out ushort ChannelNum) && ushort.TryParse(demandValue, out ushort value))
if (ChannelNum >= 1 && ChannelNum <= 3)
{
@@ -34,9 +37,10 @@ namespace BPASmartClient.MorkCL.Model.Control
byte[] LBOffset = new byte[3] { 6, 7, 8 };
MyModbus.Write($"LB{LBOffset[ChannelNum - 1]}".ToModbusAdd(), false);
MyModbus.Write($"LW{VWOffset[ChannelNum - 1]}".ToModbusAdd(), value);
Thread.Sleep(400);
MyModbus.Write($"LB{LBOffset[ChannelNum - 1]}".ToModbusAdd(), true);
//扫描周期较短,不等下料完成读为0,就已经过了,添加一个延时。
Thread.Sleep(500);
Thread.Sleep(400);
ChannelDisCom[ChannelNum - 1].Wait();
MyModbus.Write($"LB{LBOffset[ChannelNum - 1]}".ToModbusAdd(), false);
}
@@ -48,12 +52,18 @@ namespace BPASmartClient.MorkCL.Model.Control
/// <param name="value">档位,1-8挡</param>
public void HeatingGearSet(string value)
{
if (!MyModbus.IsConnected())
{
return;
}
if (ushort.TryParse(value, out ushort Gear))
if (Gear >= 1 && Gear <= 8)
{
MyModbus.Write($"LB9".ToModbusAdd(), false);
MyModbus.Write($"LW0".ToModbusAdd(), Gear);
Thread.Sleep(400);
MyModbus.Write($"LB9".ToModbusAdd(), true);
Thread.Sleep(400);
MyModbus.Write($"LB9".ToModbusAdd(), false);
}
}
@@ -64,12 +74,18 @@ namespace BPASmartClient.MorkCL.Model.Control
/// <param name="value">频率,0-50HZ</param>
public void MixingFrequencySet(string value)
{
if (!MyModbus.IsConnected())
{
return;
}
if (ushort.TryParse(value, out ushort Frequency))
if (Frequency >= 0 && Frequency <= 50)
{
MyModbus.Write($"LB10".ToModbusAdd(), false);
MyModbus.Write($"LW1".ToModbusAdd(), Frequency*100);
Thread.Sleep(400);
MyModbus.Write($"LB10".ToModbusAdd(), true);
Thread.Sleep(400);
MyModbus.Write($"LB10".ToModbusAdd(), false);
}
}
@@ -80,12 +96,18 @@ namespace BPASmartClient.MorkCL.Model.Control
/// <param name="value">频率,0-50HZ</param>
public void OverturnFrequencySet(string value)
{
if (!MyModbus.IsConnected())
{
return;
}
if (ushort.TryParse(value, out ushort Frequency))
if (Frequency >= 0 && Frequency <= 50)
{
MyModbus.Write($"LB11".ToModbusAdd(), false);
MyModbus.Write($"LW2".ToModbusAdd(), Frequency);
Thread.Sleep(400);
MyModbus.Write($"LB11".ToModbusAdd(), true);
Thread.Sleep(400);
MyModbus.Write($"LB11".ToModbusAdd(), false);
}
}
@@ -121,12 +143,17 @@ namespace BPASmartClient.MorkCL.Model.Control
/// <param name="value">炒锅位置,1-3</param>
public void SetStirFryingLoc(string value)
{
if (!MyModbus.IsConnected())
{
return;
}
if (ushort.TryParse(value, out ushort loc))
if (loc >= 1 && loc <= 3)
{
MyModbus.Write($"LB{loc + 16}".ToModbusAdd(), false);
Thread.Sleep(400);
MyModbus.Write($"LB{loc + 16}".ToModbusAdd(), true);
Thread.Sleep(500);
Thread.Sleep(400);
StirFryingLocFB[loc - 1].Wait();
MyModbus.Write($"LB{loc + 16}".ToModbusAdd(), false);
}


+ 24
- 0
BPASmartClient.MorkCL/Model/Control/RobotSet.cs Просмотреть файл

@@ -15,6 +15,10 @@ namespace BPASmartClient.MorkCL.Model.Control
/// <param name="SubTask"></param>
public void RobotTaskControl(string MainTask, EDeviceType SubTask)
{
if (MyModbus is null || !MyModbus.IsConnected())
{
return;
}
if (ushort.TryParse(MainTask, out ushort mainTask))
if (mainTask >= 0 && mainTask <= 24)
{
@@ -30,6 +34,10 @@ namespace BPASmartClient.MorkCL.Model.Control
/// <param name="Loc"></param>
public void WarehousingControl(string Loc)
{
if (MyModbus is null || !MyModbus.IsConnected())
{
return;
}
if (ushort.TryParse(Loc, out ushort loc))
{
if (loc >= 1 && loc <= 12)
@@ -46,6 +54,10 @@ namespace BPASmartClient.MorkCL.Model.Control
/// <param name="num">炒锅类型</param>
public void AllowPourVegetables(EDeviceType num)
{
if (MyModbus is null || !MyModbus.IsConnected())
{
return;
}
switch (num)
{
case EDeviceType.炒锅1:
@@ -67,6 +79,10 @@ namespace BPASmartClient.MorkCL.Model.Control
/// <param name="num">炒锅类型</param>
public void DisablePourVegetables(EDeviceType num)
{
if (MyModbus is null || !MyModbus.IsConnected())
{
return;
}
switch (num)
{
case EDeviceType.炒锅1:
@@ -88,6 +104,10 @@ namespace BPASmartClient.MorkCL.Model.Control
/// <param name="num">炒锅类型</param>
public void ModerateInPlace(EDeviceType num)
{
if (MyModbus is null || !MyModbus.IsConnected())
{
return;
}
switch (num)
{
case EDeviceType.炒锅1:
@@ -110,6 +130,10 @@ namespace BPASmartClient.MorkCL.Model.Control
/// <param name="num">炒锅类型</param>
public void DiningOutComplete(EDeviceType num)
{
if (MyModbus is null || !MyModbus.IsConnected())
{
return;
}
switch (num)
{
case EDeviceType.炒锅1:


+ 20
- 0
BPASmartClient.MorkCL/Model/Json/ConnectPar.cs Просмотреть файл

@@ -8,6 +8,26 @@ namespace BPASmartClient.MorkCL.Model.Json
{
public class ConnectPar
{
/// <summary>
/// 1#炒锅是否连接。
/// </summary>
public bool FryPanConnect_1 { get; set; } = true;
/// <summary>
/// 2#炒锅是否连接。
/// </summary>
public bool FryPanConnect_2 { get; set; } = true;
/// <summary>
/// 高压锅是否连接。
/// </summary>
public bool PressureCookerConnect { get; set; } = false;
/// <summary>
/// 机器人是否链接。
/// </summary>
public bool RobotConnet { get; set; } = true;
/// <summary>
/// 其他设备是否连接。
/// </summary>
public bool OtherDeviceConnect { get; set; } = true;
/// <summary>
/// 1号炒锅
/// </summary>


+ 5
- 4
BPASmartClient.MorkCL/Server/FryingPanServer.cs Просмотреть файл

@@ -18,6 +18,7 @@ namespace BPASmartClient.MorkCL.Server
MyModbus = new ModbusTcp();
MyModbus.WithModbusTcp(IP, Port).UseConnected(() =>
{
TaskManage.GetInstance.StartLong(new Action(() =>
{
MyModbus.Read<bool[]>("LB100".ToModbusAdd(), 16).OnSuccess(s =>
@@ -39,14 +40,14 @@ namespace BPASmartClient.MorkCL.Server
OutDinningSlowDownFlag = s[15];
});

Thread.Sleep(20);
MyModbus.Read<ushort[]>("LW20".ToModbusAdd(), 3).OnSuccess(s =>
{
CurrentTemperature = s[0] * 10.0F;
CurrentSpeed = s[1];
HeatingGear = s[2];
});
Thread.Sleep(20);
MyModbus.Read<ushort[]>("LW30".ToModbusAdd(), 10).OnSuccess(s =>
{
StirMotorFreq = s[0];
@@ -62,7 +63,7 @@ namespace BPASmartClient.MorkCL.Server
TurnMotorErrorCode = MotorAlarm.AlarmDic[s[9]];

});
Thread.Sleep(20);
MyModbus.Read<ushort>("LW49".ToModbusAdd()).OnSuccess(s =>
{
EStopAlarm = s.GetBitValue(1);
@@ -74,7 +75,7 @@ namespace BPASmartClient.MorkCL.Server
StirMotorCommError=s.GetBitValue(7);
RollingMotorCommError = s.GetBitValue(8);
});
Thread.Sleep(100);
Thread.Sleep(20);
}), $"炒锅服务-{IP}", true);
});
}


+ 2
- 1
BPASmartClient.MorkCL/Server/OtherServer.cs Просмотреть файл

@@ -35,11 +35,12 @@ namespace BPASmartClient.MorkCL.Server
BoxDetection[i] = s.GetBitValue((byte)(i+1));
}
});
Thread.Sleep(50);
myDevice.SlaveAddress = 2;

myDevice.Read<float>("LW8".ToModbusAdd()).OnSuccess(s => { CurrentWeight = s; });

Thread.Sleep(100);
Thread.Sleep(50);
}), $"其它外部设备-{PortName}", true);
});
}


+ 4
- 2
BPASmartClient.MorkCL/Server/RobotServer.cs Просмотреть файл

@@ -28,16 +28,18 @@ namespace BPASmartClient.MorkCL.Server
DiningOutRequest[i] = s[i * 3 + 2];
}
});
Thread.Sleep(20);
MyModbus.Read<bool>("GM620".ToModbusAdd()).OnSuccess((b)=> { Home = b; });
Thread.Sleep(20);
MyModbus.Read<bool[]>("GM630".ToModbusAdd(), 12).OnSuccess(s =>
{
for (byte i = 0; i < s.Length; i++) WarehousingComplete[i] = s[i];
});
Thread.Sleep(20);
MyModbus.Read<ushort>("GI5".ToModbusAdd(), 1).OnSuccess(s => { TaskFeedback = (RobotMainTask)s; });

IsIdle = (TaskFeedback == RobotMainTask.无任务 && Home);
Thread.Sleep(100);
Thread.Sleep(20);
}), $"机器人服务-{IP}", true);
});
}


+ 2
- 1
BPASmartClient.MorkCL/Server/TaskServer.cs Просмотреть файл

@@ -11,7 +11,8 @@ namespace BPASmartClient.MorkCL.Server
/// <summary>
/// 获取任务是否执行完成
/// </summary>
public bool IsComplete => RunTask == null ? false : RunTask.IsCompleted;
//public bool IsComplete => RunTask == null ? false : RunTask.IsCompleted;
public bool IsComplete { get; set; }

/// <summary>
/// 任务取消标识


+ 60
- 6
BPASmartClient.MorkCL/View/Debug.xaml Просмотреть файл

@@ -40,21 +40,30 @@
Margin="25,0"
FontSize="16"
ItemsSource="{Binding DeviceTypes}"
SelectedItem="{Binding FryingPanSelect}">
</ComboBox>
SelectedItem="{Binding FryingPanSelect}" />
</StackPanel>
<StackPanel Margin="5" Orientation="Horizontal">
<Button Margin="0,0,20,0" Content="设为自动模式" />
<Button Margin="10,0" Content="设为手动模式" />
<Button Margin="10,0" Content="初始化设备" />
<Button
Margin="0,0,20,0"
Command="{Binding SetAutoModeCommand}"
Content="设为自动模式" />
<Button
Margin="10,0"
Command="{Binding SetManualModeCommand}"
Content="设为手动模式" />
<Button
Margin="10,0"
Command="{Binding InitalDeviceCommand}"
Content="初始化设备" />
<Button
Width="100"
Margin="10,0"
Command="{Binding ResetDeviceCommand}"
Content="复位" />
<Button
Width="100"
Margin="10,0"
Command="{Binding StopDeviceCommand}"
Content="停止" />
</StackPanel>
<StackPanel Margin="5" Orientation="Horizontal">
@@ -172,6 +181,51 @@
Margin="15"
Orientation="Vertical" />
<!--#endregion-->

<!--#region 系统任务控制-->
<pry:ImageBorder Grid.Row="2" Margin="10" />
<StackPanel
Grid.Row="2"
Margin="15"
Orientation="Vertical">
<StackPanel Orientation="Horizontal">
<Button
Width="150"
Height="35"
Margin="5"
Command="{Binding CancelFryPanTaskCommand}"
CommandParameter="炒锅1"
Content="取消当前1#炒锅任务" />
<Button
Width="150"
Height="35"
Margin="5"
Command="{Binding CancelFryPanTaskCommand}"
CommandParameter="炒锅2"
Content="取消当前2#炒锅任务" />

</StackPanel>

<StackPanel Orientation="Horizontal">
<Button
Width="150"
Height="35"
Margin="5"
Command="{Binding ClearFryPanTaskCommand_1}"
Content="清空1#炒锅任务"
Visibility="Collapsed" />
<Button
Width="150"
Height="35"
Margin="5"
Command="{Binding ClearFryPanTaskCommand_2}"
Content="清空2#炒锅任务"
Visibility="Collapsed" />

</StackPanel>

</StackPanel>
<!--#endregion-->
</Grid>

</UserControl>

+ 19
- 10
BPASmartClient.MorkCL/View/ItemStorageView.xaml Просмотреть файл

@@ -35,6 +35,12 @@
<pry:ImageBorder Margin="5,15" />
<StackPanel Margin="15,20">
<TextBlock Width="200" Text="{Binding ScaleCurrentWeight, StringFormat=当前重量:{0:F2} g}" />


<Button
Margin="0,30"
Command="{Binding InitialStorageCommand}"
Content="清空库位" />
</StackPanel>
<!--#endregion-->

@@ -56,16 +62,17 @@
Command="{Binding InStorageCommand}"
CommandParameter="{Binding ElementName=cmbSelectName, Path=SelectedItem}"
Content="入库" />

</StackPanel>
<!--#endregion-->
<!--#region 辅料仓-->
<pry:ImageBorder Grid.Column="1" Margin="15" />
<!--#region 辅料仓不需要显示,整体注释。-->
<!--<pry:ImageBorder Grid.Column="1" Margin="15" Visibility="Collapsed"/>
<ItemsControl
Grid.Column="1"
Margin="3"
Background="Transparent"
BorderThickness="1"
ItemsSource="{Binding AccessoriesItorage}"
ItemsSource="{Binding AccessoriesItorage}" Visibility="Collapsed"
ScrollViewer.HorizontalScrollBarVisibility="Disabled">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
@@ -119,15 +126,17 @@
</Border>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</ItemsControl>-->
<!--#endregion-->
<!--#region 原料仓-->
<pry:ImageBorder
Grid.Row="1"
Grid.Row="0"
Grid.RowSpan="2"
Grid.Column="1"
Margin="15" />
<ItemsControl
Grid.Row="1"
Grid.Row="0"
Grid.RowSpan="2"
Grid.Column="1"
Margin="3"
Background="Transparent"
@@ -153,7 +162,7 @@
<ItemsControl.ItemTemplate>
<DataTemplate>
<Border Margin="5" Background="Transparent">
<Grid Height="180">
<Grid>
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition />
@@ -166,7 +175,7 @@
</Grid.LayoutTransform>

<TextBlock
Margin="0,0,0,25"
Margin="0,0,0,55"
HorizontalAlignment="Center"
VerticalAlignment="Bottom"
FontSize="25"
@@ -181,7 +190,7 @@
Foreground="#FF0084FF"
Text="{Binding Weight, StringFormat={}{0} g}" />

<StackPanel
<!--<StackPanel
Grid.Row="1"
Margin="0,25"
HorizontalAlignment="Center"
@@ -190,7 +199,7 @@
FontSize="20"
Foreground="#FF0084FF"
Text="{Binding ID, StringFormat={}{0} 号仓}" />
</StackPanel>
</StackPanel>-->
<Image
Grid.RowSpan="2"
Source="/BPASmartClient.CustomResource;component/Image/光柱.png"


+ 1
- 1
BPASmartClient.MorkCL/View/Monitor.xaml Просмотреть файл

@@ -135,7 +135,7 @@
<ScrollViewer
Grid.Row="1"
HorizontalScrollBarVisibility="Hidden"
VerticalScrollBarVisibility="Hidden">
VerticalScrollBarVisibility="Auto">
<ItemsControl ItemsSource="{Binding VariableMonitors}">
<ItemsControl.ItemTemplate>
<DataTemplate>


+ 9
- 2
BPASmartClient.MorkCL/View/ParSet.xaml Просмотреть файл

@@ -5,8 +5,10 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:BPASmartClient.MorkCL.View"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:pry="clr-namespace:BPASmartClient.CustomResource.UserControls;assembly=BPASmartClient.CustomResource"
Name="参数设置"
d:DesignHeight="450"
d:DesignWidth="800" Name="参数设置"
d:DesignWidth="800"
mc:Ignorable="d">
<UserControl.Resources>
<ResourceDictionary>
@@ -16,5 +18,10 @@
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</UserControl.Resources>
<Grid />

<Grid>
<pry:ImageBorder Margin="10" />
<TextBlock HorizontalAlignment="Center" Text="暂时没有参数需要调整" />
</Grid>

</UserControl>

+ 0
- 141
BPASmartClient.MorkCL/View/Test.xaml Просмотреть файл

@@ -1,141 +0,0 @@
<UserControl
x:Class="BPASmartClient.MorkCL.View.Test"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:BPASmartClient.MorkCL.View"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:vm="clr-namespace:BPASmartClient.MorkCL.ViewModel"
Name="测试"
d:DesignHeight="450"
d:DesignWidth="800"
mc:Ignorable="d">

<UserControl.DataContext>
<vm:testViewModel />
</UserControl.DataContext>

<UserControl.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="/BPASmartClient.MorkCL;component/CustomStyle/CustomStyle.xaml" />
</ResourceDictionary.MergedDictionaries>
<Style TargetType="DataGridCell">
<Setter Property="FontSize" Value="16" />
<Setter Property="VerticalAlignment" Value="Center" />
<Setter Property="Background" Value="Transparent" />
<Setter Property="Foreground" Value="{StaticResource FontColor}" />
<Setter Property="BorderBrush" Value="{StaticResource bordColor}" />
</Style>
<Style TargetType="DataGridColumnHeader">
<Setter Property="FontSize" Value="22" />
<Setter Property="FontWeight" Value="Bold" />
<Setter Property="VerticalAlignment" Value="Center" />
<Setter Property="Background" Value="Transparent" />
<Setter Property="Foreground" Value="{StaticResource FontColor}" />
<Setter Property="BorderBrush" Value="{StaticResource TitleBorderColor}" />
<Setter Property="BorderThickness" Value="1" />
</Style>
</ResourceDictionary>
</UserControl.Resources>

<StackPanel Orientation="Vertical">
<Button
Width="100"
Height="30"
Command="{Binding testCommand}"
Content="Init" />
<ListView Height="100" ItemsSource="{Binding TBS}">

<ListView.View>
<GridView>
<GridView.Columns>
<GridViewColumn Width="200">
<GridViewColumn.CellTemplate>
<DataTemplate>
<TextBlock Text="{Binding Id}" />
</DataTemplate>
</GridViewColumn.CellTemplate>
<GridViewColumnHeader
HorizontalContentAlignment="Center"
Content="ID"
IsHitTestVisible="False" />
</GridViewColumn>

<GridViewColumn Width="200">
<GridViewColumn.CellTemplate>
<DataTemplate>
<TextBlock Text="{Binding Name}" />
</DataTemplate>
</GridViewColumn.CellTemplate>
<GridViewColumnHeader
HorizontalContentAlignment="Center"
Content="Name"
IsHitTestVisible="False" />
</GridViewColumn>

<GridViewColumn Width="Auto">
<GridViewColumn.CellTemplate>
<DataTemplate>
<TextBlock Text="{Binding Description}" />
</DataTemplate>
</GridViewColumn.CellTemplate>
<GridViewColumnHeader
HorizontalContentAlignment="Center"
Content="描述"
IsHitTestVisible="False" />
</GridViewColumn>

<GridViewColumn Width="200">
<GridViewColumn.CellTemplate>
<DataTemplate>
<TextBlock Text="{Binding Loc}" />
</DataTemplate>
</GridViewColumn.CellTemplate>
<GridViewColumnHeader
HorizontalContentAlignment="Center"
Content="位置"
IsHitTestVisible="False" />
</GridViewColumn>
</GridView.Columns>
</GridView>
</ListView.View>

</ListView>
<DataGrid
Height="500"
AutoGenerateColumns="False"
CanUserAddRows="False"
CanUserDeleteRows="False"
CanUserReorderColumns="False"
CanUserResizeRows="False"
CanUserSortColumns="False"
IsHitTestVisible="False"
IsReadOnly="True"
ItemsSource="{Binding TBS}"
RowHeaderWidth="0">
<DataGrid.Columns>
<DataGridTextColumn
Width="350"
Binding="{Binding Id}"
Header="ID" />

<DataGridTextColumn
Width="70"
Binding="{Binding Name}"
Header="名称" />

<DataGridTextColumn
Width="*"
Binding="{Binding Description}"
Header="描述" />

<DataGridTextColumn
Width="100"
Binding="{Binding Loc}"
Header="位置" />
</DataGrid.Columns>
</DataGrid>

</StackPanel>
</UserControl>

+ 0
- 15
BPASmartClient.MorkCL/View/Test.xaml.cs Просмотреть файл

@@ -1,15 +0,0 @@
using System.Windows.Controls;

namespace BPASmartClient.MorkCL.View
{
/// <summary>
/// Test.xaml 的交互逻辑
/// </summary>
public partial class Test : UserControl
{
public Test()
{
InitializeComponent();
}
}
}

+ 125
- 10
BPASmartClient.MorkCL/ViewModel/DebugViewModel.cs Просмотреть файл

@@ -1,4 +1,7 @@
using BPASmartClient.MorkCL.HelpClass;
using BPASmartClient.CustomResource.UserControls.MessageShow;
using BPASmartClient.MorkCL.HelpClass;
using System.Reflection.Metadata;
using System.Windows.Markup;

namespace BPASmartClient.MorkCL.ViewModel
{
@@ -11,18 +14,22 @@ namespace BPASmartClient.MorkCL.ViewModel
{
WriteAgitaParamCommand = new(async () =>
{
ActionManage.GetInstance.Send("WriteUshort", new WriteModel<ushort>(FryingPanSelect, "LW1", AgitaFrequency));
ActionManage.GetInstance.Send("WriteUshort", new WriteModel<ushort>(FryingPanSelect, "LW1", (ushort)(AgitaFrequency*100)));

await SendWriteRequest("LB10");

ShowNotify($"写入搅拌参数成功。");
});

StartAgitateCommand = new(() =>
{
ActionManage.GetInstance.Send("WriteBool", new WriteModel<bool>(FryingPanSelect, "LB0", true));
ShowNotify($"写入搅拌启动成功。");
});
StopAgitateCommand = new(() =>
{
ActionManage.GetInstance.Send("WriteBool", new WriteModel<bool>(FryingPanSelect, "LB0", false));
ShowNotify($"写入搅拌停止成功。");
});

WriteHeatParamCommand = new(async () =>
@@ -30,17 +37,38 @@ namespace BPASmartClient.MorkCL.ViewModel
ActionManage.GetInstance.Send("WriteUshort", new WriteModel<ushort>(FryingPanSelect, "LW0", HeatGear));

await SendWriteRequest("LB9");
ShowNotify($"写入加热参数成功。");
});

StartHeatCommand = new(() =>
{
ActionManage.GetInstance.Send("WriteBool", new WriteModel<bool>(FryingPanSelect, "LB3", true));
ShowNotify($"写入加热启动成功。");
});

StopHeatCommand = new(() =>
{
ActionManage.GetInstance.Send("WriteBool", new WriteModel<bool>(FryingPanSelect, "LB3", false));
ShowNotify($"写入加热停止成功。");
});

ChannelCuttingCommand = new(async () =>
{
var channelIndex = ChannelSelect;
var weight = Convert.ToUInt16(Weight);
byte[] LWOffset = new byte[3] { 3, 4, 5 };
byte[] LBOffset = new byte[3] { 6, 7, 8 };
//var channelIndex = ChannelSelect;
//var weight = Convert.ToUInt16(Weight);
//byte[] LWOffset = new byte[3] { 3, 4, 5 };
//byte[] LBOffset = new byte[3] { 6, 7, 8 };

//ActionManage.GetInstance.Send("WriteUshort", new WriteModel<ushort>(FryingPanSelect, $"LW{LWOffset[channelIndex]}", weight));
//await SendWriteRequest($"LB{LBOffset[channelIndex]}");

object[] para = new object[3];
para[0]= FryingPanSelect;
para[1] = ChannelSelect+1;
para[2] = Convert.ToUInt16(Weight);

ActionManage.GetInstance.Send("WriteUshort", new WriteModel<ushort>(FryingPanSelect, $"LW{LWOffset[channelIndex]}", weight));
await SendWriteRequest($"LB{LBOffset[channelIndex]}");
await Task.Run(() => ActionManage.GetInstance.Send("DeviceCuttingControl", para));
ShowNotify($"写入通道下料控制成功。");
});

GoFryLocCommand = new(async () =>
@@ -48,24 +76,74 @@ namespace BPASmartClient.MorkCL.ViewModel
var loc = StirFryLocSelect + 17;

await SendWriteRequest($"LB{loc}");
ShowNotify($"写入去炒制位成功。");
});
GoHomeCommand = new(async () =>
{
await SendWriteRequest("LB12");
ShowNotify($"写入回原点成功。");
});
GoSeasoningFeddLocCommand = new(async () =>
{
await SendWriteRequest("LB16");
ShowNotify($"写入去调料投料位成功。");
});

OutDiningStartCommand = new(async () =>
{
await SendWriteRequest("LB13");
ShowNotify($"写入出餐启动成功。");
});

FryPanCleanCommand = new(async () =>
{
await SendWriteRequest("LB14");
ShowNotify($"写入炒锅清洗成功。");
});

SetAutoModeCommand = new(() =>
{
ActionManage.GetInstance.Send("WriteBool", new WriteModel<bool>(FryingPanSelect, "LB20", true));
ShowNotify($"设置设备自动模式成功。");
});

SetManualModeCommand = new(() =>
{
ActionManage.GetInstance.Send("WriteBool", new WriteModel<bool>(FryingPanSelect, "LB20", false));
ShowNotify($"设置设备手动模式成功。");
});
InitalDeviceCommand = new(async () =>
{
await SendWriteRequest("LB21");
ShowNotify($"设置设备初始化成功。");
});

StopDeviceCommand = new(async () =>
{
await SendWriteRequest("LB22");
ShowNotify($"设置设备停止成功。");
});

ResetDeviceCommand = new(async () =>
{
await SendWriteRequest("LB23");
ShowNotify($"设置设备复位成功。");
});

CancelFryPanTaskCommand = new((string device) =>
{
ActionManage.GetInstance.Send("CancelFryPanTask", device);
ShowNotify($"[{device}#]取消当前任务成功");
});

ClearFryPanTaskCommand_1 = new(() =>
{

});
ClearFryPanTaskCommand_2 = new(() =>
{

});
}

@@ -74,12 +152,17 @@ namespace BPASmartClient.MorkCL.ViewModel
private async Task SendWriteRequest(string address)
{
ActionManage.GetInstance.Send("WriteBool", new WriteModel<bool>(FryingPanSelect, address, false));
await Task.Delay(50);
await Task.Delay(400);
ActionManage.GetInstance.Send("WriteBool", new WriteModel<bool>(FryingPanSelect, address, true));
await Task.Delay(50);
await Task.Delay(400);
ActionManage.GetInstance.Send("WriteBool", new WriteModel<bool>(FryingPanSelect, address, false));
}

private void ShowNotify(string info)
{
NoticeDemoViewModel.OpenMsg(EnumPromptType.Success, Application.Current.MainWindow, "提示", info);
}

#endregion 私有方法

#region 属性
@@ -191,6 +274,38 @@ namespace BPASmartClient.MorkCL.ViewModel

/// <summary>炒锅清洗。</summary>
public BPARelayCommand FryPanCleanCommand { get; set; }
/// <summary>
/// 设为自动模式。
/// </summary>
public BPARelayCommand SetAutoModeCommand { get; set; }
/// <summary>
/// 设为手动模式。
/// </summary>
public BPARelayCommand SetManualModeCommand { get; set; }
/// <summary>
/// 初始化设备。
/// </summary>
public BPARelayCommand InitalDeviceCommand { get; set; }
/// <summary>
/// 设备停止。
/// </summary>
public BPARelayCommand StopDeviceCommand { get; set; }
/// <summary>
/// 设备复位。
/// </summary>
public BPARelayCommand ResetDeviceCommand { get; set; }
/// <summary>
/// 取消指定炒锅当前任务。
/// </summary>
public BPARelayCommand<string> CancelFryPanTaskCommand { get; set; }
/// <summary>
/// 清空1#炒锅所有任务。
/// </summary>
public BPARelayCommand ClearFryPanTaskCommand_1 { get; set; }
/// <summary>
/// 清空2#炒锅所有任务。
/// </summary>
public BPARelayCommand ClearFryPanTaskCommand_2 { get; set; }

#endregion 命令
}

+ 25
- 5
BPASmartClient.MorkCL/ViewModel/ItemStorageViewModel.cs Просмотреть файл

@@ -1,4 +1,6 @@
using BPASmartClient.MorkCL.Model.DB;
using BPASmartClient.CustomResource.Pages.Model;
using BPASmartClient.CustomResource.UserControls.MessageShow;
using BPASmartClient.MorkCL.Model.DB;
using BPASmartClient.MorkCL.Model.Json;
using BPASmartClient.MorkCL.Server;

@@ -34,10 +36,10 @@ namespace BPASmartClient.MorkCL.ViewModel
}
}, "SendCurrentWeight");

ActionManage.GetInstance.Register((object o) =>
{
CanItemStorage = (bool)o;
}, "RefreshCanItemStorage", true);
//ActionManage.GetInstance.Register((object o) =>
//{
// CanItemStorage = (bool)o;
//}, "RefreshCanItemStorage", true);

//实例化时调用一次,更新数据。
ActionManage.GetInstance.Send("RefreshItemStorage");
@@ -97,6 +99,20 @@ namespace BPASmartClient.MorkCL.ViewModel

#endregion 暂时弃用
});

InitialStorageCommand = new(() =>
{
if (MessageNotify.GetInstance.ShowDialog($"确定清空所有仓位吗?"))
{
for (int i = 0; i < Json<ItemStorageInfo>.Data.IngredientsStorage.Length; i++)
{
Json<ItemStorageInfo>.Data.IngredientsStorage[i] = new();
}
Json<ItemStorageInfo>.Save();
ActionManage.GetInstance.Send("RefreshItemStorage");
NoticeDemoViewModel.OpenMsg(EnumPromptType.Success, Application.Current.MainWindow, "成功", "清空仓位信息成功。");
}
});
}

private void AddTestData()
@@ -165,5 +181,9 @@ namespace BPASmartClient.MorkCL.ViewModel
get { return _CanItemStorage; }
set { _CanItemStorage = value; OnPropertyChanged(); }
}
/// <summary>
/// 初始化库位。
/// </summary>
public BPARelayCommand InitialStorageCommand { get; set; }
}
}

+ 0
- 166
BPASmartClient.MorkCL/ViewModel/testViewModel.cs Просмотреть файл

@@ -1,166 +0,0 @@
using BPASmartClient.MorkCL.Model.DB;
using BPASmartClient.MorkCL.Server;
using SqlSugar;

namespace BPASmartClient.MorkCL.ViewModel
{
public class testViewModel : NotifyBase
{
public testViewModel()
{
TBS = new(SqliteHelper.GetInstance.GetAccessories());

testCommand = new BPARelayCommand(() =>
{
ControlData cd = new ControlData();
cd.Name = "莲白回锅";
cd.DeviceType = EDeviceType.炒锅1;

cd.ControlFuncs.Enqueue(new FuncModel()
{
eFunc = EFunc.加热启动,
funcPars = new FuncPar[1] { new FuncPar() { ParValue = 1.ToString() } }.ToList()
});

cd.ControlFuncs.Enqueue(new FuncModel()
{
eFunc = EFunc.炒制,
funcPars = new FuncPar[1] { new FuncPar() { ParValue = 10.ToString() } }.ToList()
});

cd.ControlFuncs.Enqueue(new FuncModel()
{
eFunc = EFunc.搅拌启动,
funcPars = new FuncPar[1] { new FuncPar() { ParValue = 30.ToString() } }.ToList()
});

cd.ControlFuncs.Enqueue(new FuncModel()
{
eFunc = EFunc.添加调料,
funcPars = new FuncPar[1] { new FuncPar() { ParValue = 30.ToString(), Id = "" } }.ToList()
});

cd.ControlFuncs.Enqueue(new FuncModel()
{
eFunc = EFunc.添加调料,
funcPars = new FuncPar[1] { new FuncPar() { ParValue = 30.ToString(), Id = "" } }.ToList()
});

cd.ControlFuncs.Enqueue(new FuncModel()
{
eFunc = EFunc.添加调料,
funcPars = new FuncPar[1] { new FuncPar() { ParValue = 30.ToString(), Id = "" } }.ToList()
});

cd.ControlFuncs.Enqueue(new FuncModel()
{
eFunc = EFunc.添加辅料,
funcPars = new FuncPar[1] { new FuncPar() { ParValue = 30.ToString(), Id = "" } }.ToList()
});

cd.ControlFuncs.Enqueue(new FuncModel()
{
eFunc = EFunc.添加辅料,
funcPars = new FuncPar[1] { new FuncPar() { ParValue = 30.ToString(), Id = "" } }.ToList()
});

cd.ControlFuncs.Enqueue(new FuncModel()
{
eFunc = EFunc.添加主料,
funcPars = new FuncPar[1] { new FuncPar() { ParValue = 30.ToString(), Id = "" } }.ToList()
});

cd.ControlFuncs.Enqueue(new FuncModel()
{
eFunc = EFunc.添加主料,
funcPars = new FuncPar[1] { new FuncPar() { ParValue = 30.ToString(), Id = "" } }.ToList()
});

cd.ControlFuncs.Enqueue(new FuncModel()
{
eFunc = EFunc.炒制,
funcPars = new FuncPar[1] { new FuncPar() { ParValue = 30.ToString() } }.ToList()
});

cd.ControlFuncs.Enqueue(new FuncModel()
{
eFunc = EFunc.出餐启动,
funcPars = new FuncPar[1] { new FuncPar() { ParValue = 30.ToString() } }.ToList()
});

ActionManage.GetInstance.Send(NotifyTopic.FormulaDistribution, cd);
//ActionManage.GetInstance.Register(new Action<object>(o =>
//{
// if (o != null && o is ControlData cd) morkCL.cds.Enqueue(cd);
//}), NotifyTopic.FormulaDistribution);

//SqliteHelper.GetInstance.Init();

//for (int i = 0; i < 10; i++)
//{
// SqliteHelper.GetInstance.AddAccessories(new Model.DB.AccessoriesTB()
// {
// Description = "AccessoriesTB",
// Loc = 1,
// Name = $"AccessoriesTB{i}"
// });

// SqliteHelper.GetInstance.AddIngredients(new Model.DB.IngredientsTB() {
// Description = "IngredientsTB", Loc = 1, Name = $"IngredientsTB{i}" });

// SqliteHelper.GetInstance.AddSeasoning(new Model.DB.SeasoningTB()
// {
// Description = "SeasoningTB",
// Loc = 1,
// Name = $"SeasoningTB{i}"
// });
//}

//var Accessories = SqliteHelper.GetInstance.GetAccessories();
//var Ingredients = SqliteHelper.GetInstance.GetIngredients();
//var Seasoning = SqliteHelper.GetInstance.GetSeasoning();

//Accessories?.ForEach(x =>
//{
// SqliteHelper.GetInstance.EditAccessories(new Model.DB.AccessoriesTB()
// {
// Description = "AccessoriesTB1111",
// Loc = x.Loc,
// Name = x.Name,
// Id = x.Id
// });
//});

//Ingredients?.ForEach(x =>
//{
// SqliteHelper.GetInstance.EditIngredients(new Model.DB.IngredientsTB()
// {
// Description = "IngredientsTB1111",
// Loc = x.Loc,
// Name = x.Name,
// Id = x.Id
// });
//});

//Seasoning?.ForEach(x =>
//{
// SqliteHelper.GetInstance.EditSeasoning(new Model.DB.SeasoningTB()
// {
// Description = "SeasoningTB1111",
// Loc = x.Loc,
// Name = x.Name,
// Id = x.Id
// });
//});

//var Accessories1 = SqliteHelper.GetInstance.GetAccessories();
//var Ingredients1 = SqliteHelper.GetInstance.GetIngredients();
//var Seasoning1 = SqliteHelper.GetInstance.GetSeasoning();
});
}

public BPARelayCommand testCommand { get; set; }

public ObservableCollection<AccessoriesTB> TBS { get; set; }
}
}

+ 77
- 1
BPASmartClient.MorkMV1/Control_MorkMV1.cs Просмотреть файл

@@ -26,6 +26,7 @@ using BPASmartClient.CustomResource;
using Microsoft.EntityFrameworkCore.Metadata.Internal;
using static BPA.Helper.EventBus;
using BPASmartClient.MorkMV1.Event;
using System.Collections.Concurrent;
//using BPA.Helper;

namespace BPASmartClient.MorkMV1
@@ -157,12 +158,15 @@ namespace BPASmartClient.MorkMV1
recipeBoms = recipe.recipeBoms;
}
});
OrderNotifyInit();

}

private void OrderChange(string subid, ORDER_STATUS oRDER_STATUS)
{
osm.Enqueue(new OrderStatusModel() { SubOrderId = subid, Status = oRDER_STATUS });
return;

var res = mORKM.doOrderEvents.FirstOrDefault(p => p.MorkOrder.SuborderId == subid);
string goodName = string.Empty;
string SortNum = string.Empty;
@@ -211,6 +215,78 @@ namespace BPASmartClient.MorkMV1
}
}


#region 接口通知任务处理
ConcurrentQueue<OrderStatusModel> osm = new ConcurrentQueue<OrderStatusModel>();
private void OrderNotifyInit()
{
TaskManage.GetInstance.StartLong(() =>
{
while (osm.Count > 0)
{
TempOrderChange(osm.ElementAt(0).SubOrderId, osm.ElementAt(0).Status, () =>
{
osm.TryDequeue(out OrderStatusModel tempOSM);
DeviceProcessLogShow($"订单:【{tempOSM.SubOrderId}】, 状态:【{tempOSM.Status}】, API状态修改成功");
});
}
Thread.Sleep(100);
}, $"订单状态更新接口{DeviceId}", true);
}

private void TempOrderChange(string subid, ORDER_STATUS oRDER_STATUS, Action complete)
{
var res = mORKM.doOrderEvents.FirstOrDefault(p => p.MorkOrder.SuborderId == subid);
string goodName = string.Empty;
string SortNum = string.Empty;
if (res != null)
{
goodName = res.MorkOrder.GoodsName;
SortNum = res.MorkOrder.SortNum.ToString();
}
if (!string.IsNullOrEmpty(goodName) && !string.IsNullOrEmpty(SortNum))
{
EventBus.GetInstance().Publish(new OrderStatusChangedEvent() { SortNum = SortNum, GoodName = goodName, Status = oRDER_STATUS, SubOrderId = subid, deviceClientType = DeviceType }, e => { complete?.Invoke(); });
var index = DataServer.GetInstance.morkS.MakeOrder.FindIndex(p => p.SortNum == SortNum);
if (index >= 0 && index < DataServer.GetInstance.morkS.MakeOrder.Count)
{
if (oRDER_STATUS == ORDER_STATUS.COMPLETED_COOK)
{
DataServer.GetInstance.morkS.MakeOrder.RemoveAt(index);
DataServer.GetInstance.morkS.MakeOrderOver.Add(new OrderMakeModel()
{
Status = oRDER_STATUS,
GoodName = goodName,
SortNum = SortNum,
StopTime = DateTime.Now.ToString("HH:mm:ss")
});
}
else if (oRDER_STATUS == ORDER_STATUS.COMPLETED_TAKE)
{
var temp = DataServer.GetInstance.morkS.MakeOrderOver.FirstOrDefault(p => p.SortNum == SortNum);
if (temp != null)
DataServer.GetInstance.morkS.MakeOrderOver.Remove(temp);
}
else
{
DataServer.GetInstance.morkS.MakeOrder.ElementAt(index).Status = oRDER_STATUS;
}
}
else
{
DataServer.GetInstance.morkS.MakeOrder.Add(new OrderMakeModel()
{
Status = oRDER_STATUS,
GoodName = goodName,
SortNum = SortNum,
StartTime = DateTime.Now.ToString("HH:mm:ss")
});
}
}
}
#endregion

private void GetStatus(string key, Action<object> action)
{
if (peripheralStatus.ContainsKey(key))


+ 14
- 0
BPASmartClient.MorkMV1/Model/OrderStatusModel.cs Просмотреть файл

@@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BPASmartClient.MorkMV1.Model
{
public class OrderStatusModel
{
public string SubOrderId { get; set; }
public ORDER_STATUS Status { get; set; }
}
}

+ 1
- 1
BPASmartClient.MorkSUpgradedVer/Control_MorkSUpgradedVer.cs Просмотреть файл

@@ -120,7 +120,7 @@ namespace BPASmartClient.MorkSUpgradedVer
TempOrderChange(osm.ElementAt(0).SubOrderId, osm.ElementAt(0).Status, () =>
{
osm.TryDequeue(out OrderStatusModel tempOSM);
DeviceProcessLogShow($"订单:{tempOSM.SubOrderId}, 状态:{tempOSM.Status}, API状态修改成功");
DeviceProcessLogShow($"订单:{tempOSM.SubOrderId}, 状态:{tempOSM.Status}, API状态修改成功");
});
}
Thread.Sleep(100);


Загрузка…
Отмена
Сохранить