Ver a proveniência

Merge branch 'reconfiguration' of http://111.9.47.105:10244/bpa/BPASmartClient into reconfiguration

JXJAgvReake
pry há 1 ano
ascendente
cometimento
b0a1aece7e
33 ficheiros alterados com 1235 adições e 281 eliminações
  1. +3
    -3
      BPASmartClient.Model/柔性味魔方/RawMaterialModel.cs
  2. +75
    -2
      BPASmartClient.MorkCL/Alarm.cs
  3. +4
    -0
      BPASmartClient.MorkCL/BPASmartClient.MorkCL.csproj
  4. +378
    -33
      BPASmartClient.MorkCL/Control_MorkCL.cs
  5. +71
    -16
      BPASmartClient.MorkCL/GVL_MorkCL.cs
  6. +3
    -1
      BPASmartClient.MorkCL/GlobalUsing.cs
  7. +2
    -11
      BPASmartClient.MorkCL/HelpClass/FuncParHelpClass.cs
  8. +0
    -28
      BPASmartClient.MorkCL/HelpClass/FuncSet.cs
  9. +0
    -33
      BPASmartClient.MorkCL/Model/ConnectPar.cs
  10. +21
    -3
      BPASmartClient.MorkCL/Model/Control/FryingPanGet.cs
  11. +31
    -10
      BPASmartClient.MorkCL/Model/Control/FryingPanSet.cs
  12. +8
    -3
      BPASmartClient.MorkCL/Model/Control/RobotGet.cs
  13. +29
    -2
      BPASmartClient.MorkCL/Model/Control/RobotSet.cs
  14. +1
    -1
      BPASmartClient.MorkCL/Model/Func/EFunc.cs
  15. +2
    -2
      BPASmartClient.MorkCL/Model/Func/InitData.cs
  16. +2
    -11
      BPASmartClient.MorkCL/Model/ItemStroage.cs
  17. +45
    -0
      BPASmartClient.MorkCL/Model/Json/ConnectPar.cs
  18. +7
    -3
      BPASmartClient.MorkCL/Server/FryingPanServer.cs
  19. +8
    -7
      BPASmartClient.MorkCL/Server/RobotServer.cs
  20. +77
    -5
      BPASmartClient.MorkCL/View/Debug.xaml
  21. +6
    -4
      BPASmartClient.MorkCL/View/EditFunctionParamView.xaml
  22. +8
    -5
      BPASmartClient.MorkCL/View/EditRecipeView.xaml
  23. +17
    -4
      BPASmartClient.MorkCL/View/ItemStorageView.xaml
  24. +2
    -2
      BPASmartClient.MorkCL/View/RecipeManageView.xaml
  25. +110
    -2
      BPASmartClient.MorkCL/View/Test.xaml
  26. +95
    -0
      BPASmartClient.MorkCL/ViewModel/DebugViewModel.cs
  27. +17
    -2
      BPASmartClient.MorkCL/ViewModel/EditFunctionParamViewModel.cs
  28. +27
    -1
      BPASmartClient.MorkCL/ViewModel/EditRecipeViewModel.cs
  29. +25
    -14
      BPASmartClient.MorkCL/ViewModel/ItemStorageViewModel.cs
  30. +8
    -3
      BPASmartClient.MorkCL/ViewModel/RecipeManageViewModel.cs
  31. +11
    -1
      BPASmartClient.MorkCL/ViewModel/testViewModel.cs
  32. +89
    -45
      DosingSystem/Model/DeviceInquire.cs
  33. +53
    -24
      DosingSystem/ViewModel/RecipeControlViewModel.cs

+ 3
- 3
BPASmartClient.Model/柔性味魔方/RawMaterialModel.cs Ver ficheiro

@@ -114,9 +114,9 @@ namespace BPASmartClient.Model
set
{
_mRecipeStatus = value;
if (value == 1 && Status != Status.配料完成) Status = Status.等待配料;
else if (value == 2) Status = Status.正在配料;
else if (value == 3) Status = Status.配料完成;
//if (value == 1 && Status != Status.配料完成) Status = Status.等待配料;
//else if (value == 2) Status = Status.正在配料;
//else if (value == 3) Status = Status.配料完成;
OnPropertyChanged();
}
}


+ 75
- 2
BPASmartClient.MorkCL/Alarm.cs Ver ficheiro

@@ -9,10 +9,83 @@ namespace BPASmartClient.MorkCL
{
public class Alarm : IAlarm
{
#region 1号炒锅
/// <summary>
/// 急停
/// </summary>
[Alarm("设备急停")]
public bool EStop { get; set; }
[Alarm("1号炒锅-设备急停")]
public bool EStop1 { get; set; }

/// <summary>
/// 炒锅正限位报警。
/// </summary>
[Alarm("1号炒锅-炒锅正限位报警")]
public bool FryingPanFowardLimit1 { get; set; }

/// <summary>
/// 炒锅负限位报警。
/// </summary>
[Alarm("1号炒锅-炒锅负限位报警")]
public bool FryingPanReverseLimit1 { get; set; }

/// <summary>
/// 编码器通信异常。
/// </summary>
[Alarm("1号炒锅-编码器通信异常")]
public bool FryingPanEncoderCommError1 { get; set; }


/// <summary>
/// 搅拌电机通信异常。
/// </summary>
[Alarm("1号炒锅-搅拌电机通信异常")]
public bool StirMotorCommError1 { get; set; }

/// <summary>
/// 翻转电机通信异常。
/// </summary>
[Alarm("1号炒锅-翻转电机通信异常")]
public bool RollingMotorCommError1 { get; set; }
#endregion


#region 2号炒锅
/// <summary>
/// 急停
/// </summary>
[Alarm("2号炒锅-设备急停")]
public bool EStop2 { get; set; }

/// <summary>
/// 炒锅正限位报警。
/// </summary>
[Alarm("2号炒锅-炒锅正限位报警")]
public bool FryingPanFowardLimit2 { get; set; }

/// <summary>
/// 炒锅负限位报警。
/// </summary>
[Alarm("2号炒锅-炒锅负限位报警")]
public bool FryingPanReverseLimit2 { get; set; }

/// <summary>
/// 编码器通信异常。
/// </summary>
[Alarm("2号炒锅-编码器通信异常")]
public bool FryingPanEncoderCommError2 { get; set; }


/// <summary>
/// 搅拌电机通信异常。
/// </summary>
[Alarm("2号炒锅-搅拌电机通信异常")]
public bool StirMotorCommError2 { get; set; }

/// <summary>
/// 翻转电机通信异常。
/// </summary>
[Alarm("2号炒锅-翻转电机通信异常")]
public bool RollingMotorCommError2 { get; set; }
#endregion
}
}

+ 4
- 0
BPASmartClient.MorkCL/BPASmartClient.MorkCL.csproj Ver ficheiro

@@ -6,6 +6,10 @@
<UseWPF>true</UseWPF>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<DefineConstants>$(DefineConstants);FORMAL</DefineConstants>
</PropertyGroup>

<ItemGroup>
<Compile Remove="Model\Recipe\LocalRecipeData.cs" />
</ItemGroup>


+ 378
- 33
BPASmartClient.MorkCL/Control_MorkCL.cs Ver ficheiro

@@ -1,11 +1,15 @@
using BPA.Message.Enum;

using BPA.Message.Enum;
using BPASmartClient.Device;
using BPASmartClient.MorkCL.Model.DB;
using BPASmartClient.MorkCL.Model.Json;
using BPASmartClient.MorkCL.Server;
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;

@@ -27,6 +31,18 @@ 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();
public override void DoMain()
{
MonitorViewModel.DeviceId = DeviceId;
@@ -34,12 +50,24 @@ namespace BPASmartClient.MorkCL
#region 读取本地文件数据
Json<RecipesInfo>.Read();
Json<ItemStorageInfo>.Read();
Json<ConnectPar>.Read();
#endregion

//注册本地配方接收
ActionManage.GetInstance.Register(new Action<object>(o =>
{
if (o != null && o is ControlData cd) morkCL.cds.Enqueue(cd);
DeviceProcessLogShow($"接收到一个新配方任务。");
if (o != null && o is ControlData cd)
{

morkCL.cds.Enqueue(cd);
DeviceProcessLogShow($"新配方任务{cd.Id}解析完成,已加入配方队列。");
}
else
{
DeviceProcessLogShow($"新配方任务解析失败。");
}
}), NotifyTopic.FormulaDistribution);

//初始化通讯对象
@@ -49,35 +77,72 @@ namespace BPASmartClient.MorkCL
devices.TryAdd(EDeviceType.压力锅, new PressureCookerServer());
devices.TryAdd(EDeviceType.外部设备, new OtherServer());

devices[EDeviceType.炒锅1].Init(ConnectPar.FryingPanIP1);
devices[EDeviceType.炒锅2].Init(ConnectPar.FryingPanIP2);
devices[EDeviceType.机器人].Init(ConnectPar.RobotIP);
devices[EDeviceType.压力锅].Init(ConnectPar.PressureCookerIP);
devices[EDeviceType.外部设备].Init(ConnectPar.PPortName);
#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(Json<ConnectPar>.Data.PPortName);

ManualActionRegiester();
#endif
}

public override void MainTask()
{
if (morkCL.cds.Count > 0 && !TaskList.ContainsKey(morkCL.cds.ElementAt(0).DeviceType))
//检查到有任务完成后将对已完成的任务进行清理
var res = TaskList.FirstOrDefault(p => p.Value.IsComplete).Key;
if (TaskList.ContainsKey(res))
TaskList.TryRemove(res, out _);

if (morkCL.cds.Count > 0)
{
if (morkCL.cds.TryDequeue(out ControlData cd))
var dishType = morkCL.cds.ElementAt(0).DishType;
var devieceType = EDeviceType.无;
if (dishType == Model.Recipe.EDishType.炒菜)
{
TaskList.TryAdd(cd.DeviceType, new TaskServer());
TaskList[cd.DeviceType].TaskName = $"{cd.DeviceType.ToString()}-{cd.Name}";
TaskList[cd.DeviceType].RunTask = new Task(new Action(() => { FryingPanControl(cd.DeviceType, cd); }));
TaskList[cd.DeviceType].RunTask.Start();
//如果任务队列里,炒锅1已经有任务了,就看炒锅2是否有任务,没任务就设置为炒锅2执行,如果两个锅都有任务则返回该次任务。
if (TaskList.ContainsKey(EDeviceType.炒锅1))
{
if (TaskList.ContainsKey(EDeviceType.炒锅2))
{
return;
}
else
{ devieceType=EDeviceType.炒锅2; }
}
else
{
devieceType = EDeviceType.炒锅1;
}
}
else
{
devieceType = EDeviceType.压力锅;
}

//这里判定主要是针对压力锅。
if (!TaskList.ContainsKey(devieceType))
{
if (morkCL.cds.TryDequeue(out ControlData cd))
{
cd.DeviceType = devieceType;

TaskList.TryAdd(cd.DeviceType, new TaskServer());
TaskList[cd.DeviceType].TaskName = $"{cd.DeviceType.ToString()}-{cd.Name}";
TaskList[cd.DeviceType].RunTask = new Task(new Action(() => { FryingPanControl(cd.DeviceType, cd); }));
TaskList[cd.DeviceType].RunTask.Start();
}
}
}
//检查到有任务完成后将对已完成的任务进行清理
var res = TaskList.FirstOrDefault(p => p.Value.IsComplete).Key;
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} 任务");
DeviceProcessLogShow($"【{et}】开始执行-{cd.Name} 任务");
if (TaskList.ContainsKey(et) && TaskList[et].Cts.IsCancellationRequested) return;
while (cd.ControlFuncs.Count > 0)
{
@@ -86,74 +151,336 @@ namespace BPASmartClient.MorkCL
var device = (FryingPanServer)devices[et];
var robot = (RobotServer)devices[EDeviceType.机器人];
int index = (ushort)et - 1;
DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-步骤");
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完成。");
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()}-设置加热挡位完成,设置加热启动。");

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.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();
}

break;
case EFunc.添加主料:
DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-查找主料【{fm.funcPars.ElementAt(0).Id}】。");

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.FryingPanFeedingLoc = 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}】完成。");

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

DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-等待炒锅到投料位置。");
device.FeedingLocFB.Wait(Cts: TaskList[et].Cts);//等待炒锅到投料位置
device.FryingPanFeedingLoc = 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
{
//TODO:暂定为直接取消任务,后期再说。
DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-查找主料失败,未查找到【{fm.funcPars.ElementAt(0).Id}】主料。任务取消。");
TaskList[et].Cts.Cancel();
}
}
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);
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); //等待机器人投料完成
MaterialBase mb = SqliteHelper.GetInstance.GetAccessories().FirstOrDefault(p => p.Id == fm.funcPars.ElementAt(0).Id);
if (mb != null)
{
//先复位变量。防止上一次是异常结束,设为True时,不会响应。
device.FryingPanFeedingLoc = 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()}-设置炒锅回投料位置。");
device.FryingPanFeedingLoc = true;
DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-设置炒锅回投料位置完成。");

DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-等待炒锅到投料位置。");
device.FeedingLocFB.Wait(Cts: TaskList[et].Cts);//等待炒锅到投料位置
device.FryingPanFeedingLoc = 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()}-机器人投料完成。");

}
else
{
DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-查找主料失败,未查找到【{fm.funcPars.ElementAt(0).Id}】辅料。任务取消。");
TaskList[et].Cts.Cancel();
}
break;
case EFunc.炒锅回原点位:

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;

break;
case EFunc.出餐启动:
robot.RobotTaskControl("1", et);//取空盆

device.DiningOutStart = false;
DeviceProcessLogShow($"{cd.Name}-任务执行-{fm.eFunc.ToString()}-设置机器人取空盆。");
//TODO:正常应该是哪个有空盆取哪个。
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;
break;
case EFunc.炒锅回投料位置:
device.FryingPanFeedingLoc = true;
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;
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()}】完成。");
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;
}
}
}

DeviceProcessLogShow($"【{et}】任务-{cd.Name} 执行完成");
}


public override void ReadData()
{

var propertyInfos = morkCL.GetType().GetProperties();

var fryingPan1 = (FryingPanServer)devices[EDeviceType.炒锅1];
var fryingPan2 = (FryingPanServer)devices[EDeviceType.炒锅2];
var robot = (RobotServer)devices[EDeviceType.机器人];
var pressureCooker = (PressureCookerServer)devices[EDeviceType.压力锅];
var otherDevice = (OtherServer)devices[EDeviceType.外部设备];

//这两个是字段。直接赋值
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.IsIdle=robot.IsIdle;

#if !FORMAL
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)
{
var att = property.GetCustomAttribute<VariableMonitorAttribute>();
if (att != null)
{
if (att.Notes.Contains("1号炒锅"))
{
var p = fryingPan1.GetType().GetProperty(property.Name.TrimEnd('1'));
if (p != null)
{
property.SetValue(morkCL, p.GetValue(fryingPan1));
}

}
else if (att.Notes.Contains("2号炒锅"))
{
var p = fryingPan2.GetType().GetProperty(property.Name.TrimEnd('2'));
if (p != null)
{
property.SetValue(morkCL, p.GetValue(fryingPan2));
}

}
else if (att.Notes.Contains("机器人"))
{
var p = robot.GetType().GetProperty(property.Name);
if (p != null)
{
property.SetValue(morkCL, p.GetValue(robot));
}
}
else if (att.Notes.Contains("电子秤"))
{
var p = otherDevice.GetType().GetProperty(property.Name);
if (p != null)
{
var res = p.GetValue(otherDevice);
property.SetValue(morkCL, res);
if (p.Name== "CurrentWeight")
{
ActionManage.GetInstance.Send("SendCurrentWeight", res);
}
}
}
else if (att.Notes.Contains("高压锅"))
{
var p = pressureCooker.GetType().GetProperty(property.Name);
if (p != null)
{
property.SetValue(morkCL, p.GetValue(pressureCooker));
}
}
}
}

#endif
}

public override void ResetProgram()
@@ -169,5 +496,23 @@ namespace BPASmartClient.MorkCL
public override void Stop()
{
}


void ManualActionRegiester()
{
ActionManage.GetInstance.Register((object location) =>
{
var loc = location.ToString();
if (!String.IsNullOrEmpty(loc) && loc.Length>=0)
{
var robot = (RobotServer)devices[EDeviceType.机器人];
robot.WarehousingControl(loc);
//会卡死。
//robot.WarehousingComplete[(Convert.ToInt32(loc)-1)].Wait();
}
},"ItemStorage",true);


}
}
}

+ 71
- 16
BPASmartClient.MorkCL/GVL_MorkCL.cs Ver ficheiro

@@ -29,11 +29,17 @@ namespace BPASmartClient.MorkCL
[VariableMonitor("1号炒锅-急停", "LB102")]
public bool EStop1 { get; set; }

/// <summary>
/// 炒锅在调料投料位置反馈。
/// </summary>
[VariableMonitor("1号炒锅-在辅料投料位置反馈", "LB103")]
public bool FeedingSeasoningLocFB1 { get; set; }

/// <summary>
/// 炒制位置反馈(1-4)
/// </summary>
[VariableMonitor("1号炒锅-炒制位置反馈(1-4)", "LB103")]
public bool[] StirFryingLocFB1 { get; set; } = new bool[4];
[VariableMonitor("1号炒锅-炒制位置反馈(1-3)", "LB104")]
public bool[] StirFryingLocFB1 { get; set; } = new bool[3];

/// <summary>
/// 炒锅在出餐位置反馈
@@ -59,6 +65,23 @@ namespace BPASmartClient.MorkCL
[VariableMonitor("1号炒锅-通道出料完成反馈(1-3)", "LB110")]
public bool[] ChannelDisCom1 { get; set; } = new bool[3];

/// <summary>
/// 清洗完成
/// </summary>
[VariableMonitor("1号炒锅-清洗完成", "LB113")]
public bool CleanFinish1 { get; set; }

/// <summary>
/// 倒菜出餐完成。
/// </summary>
[VariableMonitor("1号炒锅-倒菜出餐完成", "LB114")]
public bool OutDinningFinsh1 { get; set; }
/// <summary>
/// 炒锅倒菜减速位
/// </summary>
[VariableMonitor("1号炒锅-倒菜减速位", "LB115")]
public bool OutDinningSlowDownFlag1 { get; set; }

/// <summary>
/// 当前锅底温度
/// </summary>
@@ -97,11 +120,17 @@ namespace BPASmartClient.MorkCL
[VariableMonitor("2号炒锅-急停", "LB102")]
public bool EStop2 { get; set; }

/// <summary>
/// 炒锅在调料投料位置反馈。
/// </summary>
[VariableMonitor("2号炒锅-在辅料投料位置反馈", "LB103")]
public bool FeedingSeasoningLocFB2 { get; set; }

/// <summary>
/// 炒制位置反馈(1-4)
/// </summary>
[VariableMonitor("2号炒锅-炒制位置反馈(1-4)", "LB103")]
public bool[] StirFryingLocFB2 { get; set; } = new bool[4];
[VariableMonitor("2号炒锅-炒制位置反馈(1-3)", "LB104")]
public bool[] StirFryingLocFB2 { get; set; } = new bool[3];

/// <summary>
/// 炒锅在出餐位置反馈
@@ -127,6 +156,24 @@ namespace BPASmartClient.MorkCL
[VariableMonitor("2号炒锅-通道出料完成反馈(1-3)", "LB110")]
public bool[] ChannelDisCom2 { get; set; } = new bool[3];


/// <summary>
/// 清洗完成
/// </summary>
[VariableMonitor("2号炒锅-清洗完成", "LB113")]
public bool CleanFinish2 { get; set; }

/// <summary>
/// 倒菜出餐完成。
/// </summary>
[VariableMonitor("2号炒锅-倒菜出餐完成", "LB114")]
public bool OutDinningFinsh2 { get; set; }

/// <summary>
/// 炒锅倒菜减速位
/// </summary>
[VariableMonitor("2号炒锅-倒菜减速位", "LB115")]
public bool OutDinningSlowDownFlag2 { get; set; }
/// <summary>
/// 当前锅底温度
/// </summary>
@@ -154,31 +201,31 @@ namespace BPASmartClient.MorkCL
/// <summary>
/// 倒料请求
/// </summary>
[VariableMonitor("机器人-倒料请求-[1:1号炒锅,2:2号炒锅,3:高压锅]", "LW22")]
public bool[] MaterialPouringRequest = new bool[3];
[VariableMonitor("机器人-倒料请求-[1,2:炒锅,3:高压锅]", "GM600")]
public bool[] MaterialPouringRequest { get; set; } = new bool[3];

/// <summary>
/// 倒料完成
/// </summary>
[VariableMonitor("机器人-倒料完成-[1:1号炒锅,2:2号炒锅,3:高压锅]", "LW22")]
public bool[] MaterialPouringComplete = new bool[3];
[VariableMonitor("机器人-倒料完成-[1,2:炒锅,3:高压锅]", "GM601")]
public bool[] MaterialPouringComplete { get; set; } = new bool[3];

/// <summary>
/// 出餐请求,机器人到位请求炒锅出餐
/// </summary>
[VariableMonitor("机器人-出餐请求-[1:1号炒锅,2:2号炒锅,3:高压锅]", "LW22")]
[VariableMonitor("机器人-出餐请求-[1,2:炒锅,3:高压锅]", "GM602")]
public bool[] DiningOutRequest { get; set; } = new bool[3];

/// <summary>
/// 入库完成
/// </summary>
[VariableMonitor("机器人-入库完成", "LW22")]
[VariableMonitor("机器人-入库完成", "GM630")]
public bool[] WarehousingComplete { get; set; } = new bool[12];

/// <summary>
/// 机器人原点状态
/// </summary>
[VariableMonitor("机器人-机器人原点状态", "LW22")]
[VariableMonitor("机器人-机器人原点状态", "GM620")]
public bool Home { get; set; }

/// <summary>
@@ -196,13 +243,20 @@ namespace BPASmartClient.MorkCL
/// <summary>
/// 机器人程序运行中
/// </summary>
[VariableMonitor("机器人-机器人程序运行中", "LW22")]
[VariableMonitor("机器人-机器人程序运行中")]
public bool ProgramRuning { get; set; }


/// <summary>
/// 机器人空闲中
/// </summary>
[VariableMonitor("机器人-机器人空闲中")]
public bool IsIdle { get; set; }

/// <summary>
/// 机器人任务反馈
/// </summary>
[VariableMonitor("机器人-机器人任务反馈", "LW22")]
[VariableMonitor("机器人-机器人任务反馈", "GI5")]
public RobotMainTask TaskFeedback { get; set; }
#endregion

@@ -212,12 +266,13 @@ namespace BPASmartClient.MorkCL
/// </summary>
[VariableMonitor("电子秤当前重量", "0")]
public float CurrentWeight { get; set; }
#if !FORMAL
/// <summary>
/// 空箱子检测
/// </summary>
[VariableMonitor("出餐箱子在位检测", "0")]
public bool[] BoxDetection { get; set; } = new bool[4];
//[VariableMonitor("出餐箱子在位检测", "0")]
//public bool[] BoxDetection { get; set; } = new bool[4];
#endif
#endregion
}
}

+ 3
- 1
BPASmartClient.MorkCL/GlobalUsing.cs Ver ficheiro

@@ -1,4 +1,6 @@
global using System;
#define FormalRuntime

global using System;
global using System.Collections.Generic;
global using System.Linq;
global using System.Text;


+ 2
- 11
BPASmartClient.MorkCL/HelpClass/FuncParHelpClass.cs Ver ficheiro

@@ -33,21 +33,12 @@ namespace BPASmartClient.MorkCL.HelpClass
public static Dictionary<string, ObservableCollection<object>> ParOptions { get; } = new Dictionary<string, ObservableCollection<object>>()
{
//{"搅拌速度",new ObservableCollection<object>(){10,20,30,40,50 } },
{"加热档位",new ObservableCollection<object> {1,2,3,4,5,6,7,8} },
//{"加热档位",new ObservableCollection<object> {1,2,3,4,5,6,7,8} },
{"调料名称",new ObservableCollection<object>( SqliteHelper.GetInstance.GetSeasoning()) },
{"主料名称",new ObservableCollection<object>( SqliteHelper.GetInstance.GetIngredients()) },
{"辅料名称",new ObservableCollection<object>( SqliteHelper.GetInstance.GetAccessories()) },
{"设置炒制位",new ObservableCollection<object> {1,2,3,4} },
//{"设置炒制位",new ObservableCollection<object> {1,2,3,4} },

};
private ObservableCollection<object> GetAgitateSpeedOption()
{
var speed = new ObservableCollection<object>();
for (int i = 1; i <=50; i++)
{
speed.Add(i);
}
return speed;
}
}
}

+ 0
- 28
BPASmartClient.MorkCL/HelpClass/FuncSet.cs Ver ficheiro

@@ -1,28 +0,0 @@
using BPASmartClient.MorkCL.Model.Func;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BPASmartClient.MorkCL.HelpClass
{
/// <summary>
/// 该类是对FuncPar的包装类。
/// </summary>
//public class FuncSet
//{
//public int Step { get; set; }

//private string _FuncName;
//public string FuncName
//{
// get { return _FuncName; }
// set { _FuncName = value;
// FuncPars = InitData.FunParInit[(EFunc)Enum.Parse(typeof(EFunc),value)]?.ToList();
// }
//}

//public List<FuncPar> FuncPars { get; set; }
//}
}

+ 0
- 33
BPASmartClient.MorkCL/Model/ConnectPar.cs Ver ficheiro

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

namespace BPASmartClient.MorkCL.Model
{
internal class ConnectPar
{
//1号炒锅
public static string FryingPanIP1 { get; set; }
public static string FryingPanPort1 { get; set; }

//2号炒锅
public static string FryingPanIP2 { get; set; }
public static string FryingPanPort2 { get; set; }

//压力锅
public static string PressureCookerIP { get; set; }
public static string PressureCookerPort { get; set; }

//机器人
public static string RobotIP { get; set; }
public static string RobotPort { get; set; }

//电子秤端口号
public static string ESPortName { get; set; }

//外设端口号
public static string PPortName { get; set; }
}
}

+ 21
- 3
BPASmartClient.MorkCL/Model/Control/FryingPanGet.cs Ver ficheiro

@@ -24,12 +24,17 @@ namespace BPASmartClient.MorkCL.Model.Control
public bool EStop { get; set; }

/// <summary>
/// 炒制位置反馈(1-4)
/// 炒锅在调料投料位置反馈。
/// </summary>
public bool[] StirFryingLocFB { get; set; } = new bool[4];
public bool FeedingSeasoningLocFB;

/// <summary>
/// 炒锅在出餐位置反馈
/// 炒制位置反馈(1-3)
/// </summary>
public bool[] StirFryingLocFB { get; set; } = new bool[3];

/// <summary>
/// 炒锅在出餐位置反馈。
/// </summary>
public bool DiningOutLocFB { get; set; }

@@ -47,7 +52,20 @@ namespace BPASmartClient.MorkCL.Model.Control
/// 通道出料完成反馈(1-3)
/// </summary>
public bool[] ChannelDisCom { get; set; } = new bool[3];
/// <summary>
/// 清洗完成
/// </summary>
public bool CleanFinish;

/// <summary>
/// 倒菜出餐完成。
/// </summary>
public bool OutDinningFinsh;

/// <summary>
/// 炒锅倒菜减速位
/// </summary>
public bool OutDinningSlowDownFlag;
/// <summary>
/// 当前锅底温度
/// </summary>


+ 31
- 10
BPASmartClient.MorkCL/Model/Control/FryingPanSet.cs Ver ficheiro

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

if (ushort.TryParse(Num, out ushort ChannelNum) && ushort.TryParse(demandValue, out ushort value))
if (ChannelNum >= 1 && ChannelNum <= 3)
{
byte[] VWOffset = new byte[3] { 6, 8, 10 };
byte[] LBOffset = new byte[3] { 6, 7, 0 };
MyModbus.Write($"VW10{VWOffset[ChannelNum - 1]}".ToModbusAdd(), value);
byte[] VWOffset = new byte[3] { 3, 4, 5 };
byte[] LBOffset = new byte[3] { 6, 7, 8 };
MyModbus.Write($"LB{LBOffset[ChannelNum - 1]}".ToModbusAdd(), false);
MyModbus.Write($"LW{VWOffset[ChannelNum - 1]}".ToModbusAdd(), value);
MyModbus.Write($"LB{LBOffset[ChannelNum - 1]}".ToModbusAdd(), true);
//扫描周期较短,不等下料完成读为0,就已经过了,添加一个延时。
Task.Delay(50).Wait();
ChannelDisCom[ChannelNum - 1].Wait();
MyModbus.Write($"LB{LBOffset[ChannelNum - 1]}".ToModbusAdd(), false);
}
}

@@ -45,8 +51,10 @@ namespace BPASmartClient.MorkCL.Model.Control
if (ushort.TryParse(value, out ushort Gear))
if (Gear >= 1 && Gear <= 8)
{
MyModbus.Write($"VW100".ToModbusAdd(), Gear);
MyModbus.Write($"LB9".ToModbusAdd(), false);
MyModbus.Write($"LW0".ToModbusAdd(), Gear);
MyModbus.Write($"LB9".ToModbusAdd(), true);
//MyModbus.Write($"LB9".ToModbusAdd(), false);
}
}

@@ -59,8 +67,10 @@ namespace BPASmartClient.MorkCL.Model.Control
if (ushort.TryParse(value, out ushort Frequency))
if (Frequency >= 0 && Frequency <= 50)
{
MyModbus.Write($"VW102".ToModbusAdd(), Frequency);
MyModbus.Write($"LB10".ToModbusAdd(), false);
MyModbus.Write($"LW1".ToModbusAdd(), Frequency*100);
MyModbus.Write($"LB10".ToModbusAdd(), true);
//MyModbus.Write($"LB10".ToModbusAdd(), false);
}
}

@@ -73,8 +83,10 @@ namespace BPASmartClient.MorkCL.Model.Control
if (ushort.TryParse(value, out ushort Frequency))
if (Frequency >= 0 && Frequency <= 50)
{
MyModbus.Write($"VW104".ToModbusAdd(), Frequency);
MyModbus.Write($"LB11".ToModbusAdd(), false);
MyModbus.Write($"LW2".ToModbusAdd(), Frequency);
MyModbus.Write($"LB11".ToModbusAdd(), true);
//MyModbus.Write($"LB11".ToModbusAdd(), false);
}
}

@@ -94,20 +106,29 @@ namespace BPASmartClient.MorkCL.Model.Control
public bool FryingPanClear { get { return default; } set { MyModbus.Write("LB14".ToModbusAdd(), value); } }

/// <summary>
/// 炒锅到投料位置
/// 炒锅到主料辅料投料位置
/// </summary>
public bool FryingPanFeedingLoc { get { return default; } set { MyModbus.Write("LB15".ToModbusAdd(), value); } }

/// <summary>
/// 炒锅到调料投料位置
/// </summary>
public bool FryingPanToSeasoningLoc { get { return default; } set { MyModbus.Write("LB16".ToModbusAdd(), value); } }

/// <summary>
/// 去炒制位控制
/// </summary>
/// <param name="value">炒锅位置,1-4</param>
/// <param name="value">炒锅位置,1-3</param>
public void SetStirFryingLoc(string value)
{
if (ushort.TryParse(value, out ushort loc))
if (loc >= 1 && loc <= 4)
if (loc >= 1 && loc <= 3)
{
MyModbus.Write($"LB{loc + 15}".ToModbusAdd(), true);
MyModbus.Write($"LB{loc + 16}".ToModbusAdd(), false);
MyModbus.Write($"LB{loc + 16}".ToModbusAdd(), true);
Task.Delay(50).Wait();
StirFryingLocFB[loc - 1].Wait();
MyModbus.Write($"LB{loc + 16}".ToModbusAdd(), false);
}
}



+ 8
- 3
BPASmartClient.MorkCL/Model/Control/RobotGet.cs Ver ficheiro

@@ -14,12 +14,12 @@ namespace BPASmartClient.MorkCL.Model.Control
/// <summary>
/// 倒料请求
/// </summary>
public bool[] MaterialPouringRequest = new bool[3];
public bool[] MaterialPouringRequest { get; set; } = new bool[3];

/// <summary>
/// 倒料完成
/// </summary>
public bool[] MaterialPouringComplete = new bool[3];
public bool[] MaterialPouringComplete { get; set; } = new bool[3];

/// <summary>
/// 出餐请求,机器人到位请求炒锅出餐
@@ -49,7 +49,12 @@ namespace BPASmartClient.MorkCL.Model.Control
/// <summary>
/// 机器人程序运行中
/// </summary>
public bool ProgramRuning { get; set; }
public bool ProgramRuning;

/// <summary>
/// 机器人空闲中
/// </summary>
public bool IsIdle;

/// <summary>
/// 机器人任务反馈


+ 29
- 2
BPASmartClient.MorkCL/Model/Control/RobotSet.cs Ver ficheiro

@@ -18,6 +18,7 @@ namespace BPASmartClient.MorkCL.Model.Control
if (ushort.TryParse(MainTask, out ushort mainTask))
if (mainTask >= 0 && mainTask <= 24)
{
IsIdle.Wait();
MyModbus.Write("GI1".ToModbusAdd(), (ushort)SubTask);
MyModbus.Write("GI0".ToModbusAdd(), mainTask);
}
@@ -30,7 +31,13 @@ namespace BPASmartClient.MorkCL.Model.Control
public void WarehousingControl(string Loc)
{
if (ushort.TryParse(Loc, out ushort loc))
if (loc >= 1 && loc <= 12) MyModbus.Write("GI0".ToModbusAdd(), (ushort)(loc + 29));
{
if (loc >= 1 && loc <= 12)
{
IsIdle.Wait();
MyModbus.Write("GI0".ToModbusAdd(), (ushort)(loc + 29));
}
}
}

/// <summary>
@@ -54,7 +61,27 @@ namespace BPASmartClient.MorkCL.Model.Control
break;
}
}

/// <summary>
/// 禁止机器人倒菜到炒锅。
/// </summary>
/// <param name="num">炒锅类型</param>
public void DisablePourVegetables(EDeviceType num)
{
switch (num)
{
case EDeviceType.炒锅1:
MyModbus.Write("GM500".ToModbusAdd(), false);
break;
case EDeviceType.炒锅2:
MyModbus.Write("GM501".ToModbusAdd(), false);
break;
case EDeviceType.压力锅:
MyModbus.Write("GM502".ToModbusAdd(), false);
break;
default:
break;
}
}
/// <summary>
/// 出餐减速到位
/// </summary>


+ 1
- 1
BPASmartClient.MorkCL/Model/Func/EFunc.cs Ver ficheiro

@@ -21,7 +21,7 @@ namespace BPASmartClient.MorkCL.Model.Func
炒锅回原点位,
出餐启动,
炒锅清洗,
炒锅回投料位置,
炒锅回调料投料位置,
去指定炒制位,
炒制
}


+ 2
- 2
BPASmartClient.MorkCL/Model/Func/InitData.cs Ver ficheiro

@@ -30,8 +30,8 @@ namespace BPASmartClient.MorkCL.Model.Func
{ EFunc.炒锅回原点位,new FuncPar[0] },
{ EFunc.出餐启动,new FuncPar[0] },
{ EFunc.炒锅清洗,new FuncPar[0] },
{ EFunc.炒锅回投料位置,new FuncPar[0] },
{ EFunc.去指定炒制位,new FuncPar[] { new FuncPar() { ParName="设置炒制位", ParDescribe="请输入 1--4 选择一个合适的炒制位置"} } },
{ EFunc.炒锅回调料投料位置,new FuncPar[0] },
{ EFunc.去指定炒制位,new FuncPar[] { new FuncPar() { ParName="设置炒制位", ParDescribe="请输入 1--3 选择一个合适的炒制位置"} } },
{ EFunc.炒制,new FuncPar[] { new FuncPar() { ParName="设置炒制时间",ParUnit="秒", ParDescribe="请设置一个合适的炒制时间"} } },
};
}


+ 2
- 11
BPASmartClient.MorkCL/Model/ItemStroage.cs Ver ficheiro

@@ -15,7 +15,6 @@ namespace BPASmartClient.MorkCL.Model
private string materialID;
private string name;
private float weight;
//private object lockobj=new object();
/// <summary>
/// 库位位置。
/// </summary>
@@ -37,16 +36,8 @@ namespace BPASmartClient.MorkCL.Model
get => isEmploy;
set
{
//需要测试是否有问题。
//lock (lockobj)
//{
if (value == false)
{
Weight = 0.0f;
}
isEmploy = value;
OnPropertyChanged();
//}
isEmploy = value;
OnPropertyChanged();
}
}



+ 45
- 0
BPASmartClient.MorkCL/Model/Json/ConnectPar.cs Ver ficheiro

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

namespace BPASmartClient.MorkCL.Model.Json
{
public class ConnectPar
{
/// <summary>
/// 1号炒锅
/// </summary>
public string FryingPanIP1 { get; set; } = "192.168.6.100";
public string FryingPanPort1 { get; set; } = "502";

/// <summary>
/// 2号炒锅
/// </summary>
public string FryingPanIP2 { get; set; } = "192.168.6.101";
public string FryingPanPort2 { get; set; } = "502";

/// <summary>
/// 压力锅
/// </summary>
public string PressureCookerIP { get; set; } = "192.168.6.102";
public string PressureCookerPort { get; set; } = "502";

/// <summary>
/// 机器人
/// </summary>
public string RobotIP { get; set; } = "192.168.6.103";
public string RobotPort { get; set; } = "502";

/// <summary>
/// 电子秤端口号
/// </summary>
public string ESPortName { get; set; } = "COM1";

/// <summary>
/// 外设端口号
/// </summary>
public string PPortName { get; set; } = "COM2";
}
}

+ 7
- 3
BPASmartClient.MorkCL/Server/FryingPanServer.cs Ver ficheiro

@@ -19,19 +19,23 @@ namespace BPASmartClient.MorkCL.Server
{
TaskManage.GetInstance.StartLong(new Action(() =>
{
MyModbus.Read<bool[]>("LB100".ToModbusAdd(), 13).OnSuccess(s =>
MyModbus.Read<bool[]>("LB100".ToModbusAdd(), 16).OnSuccess(s =>
{
InitComplete = s[0];
StatusMode = s[1];
EStop = s[2];
for (byte i = 0; i < 4; i++) StirFryingLocFB[i] = s[i + 3];
FeedingSeasoningLocFB = s[3];
for (byte i = 0; i < 3; i++) StirFryingLocFB[i] = s[i + 4];

DiningOutLocFB = s[7];
FeedingLocFB = s[8];
WashingPotLocFB = s[9];

for (byte i = 0; i < 3; i++) ChannelDisCom[i] = s[i + 10];

CleanFinish = s[13];
OutDinningFinsh = s[14];
OutDinningSlowDownFlag = s[15];
});




+ 8
- 7
BPASmartClient.MorkCL/Server/RobotServer.cs Ver ficheiro

@@ -19,23 +19,24 @@ namespace BPASmartClient.MorkCL.Server
{
TaskManage.GetInstance.StartLong(new Action(() =>
{
MyModbus.Read<bool[]>("M600".ToModbusAdd(), 9).OnSuccess(s =>
{
for (byte i = 0; i < 3; i++)
MyModbus.Read<bool[]>("GM600".ToModbusAdd(), 9).OnSuccess(s =>
{
for (byte i = 0; i < 3; i++)
{
MaterialPouringRequest[i] = s[i * 3];
MaterialPouringComplete[i] = s[i * 3 + 1];
DiningOutRequest[i] = s[i * 3 + 2];
}
});
MyModbus.Read<bool[]>("M630".ToModbusAdd(), 12).OnSuccess(s =>
{
for (byte i = 0; i < s.Length; i++) WarehousingComplete[i] = s[i];
MyModbus.Read<bool>("GM620".ToModbusAdd()).OnSuccess((b)=> { Home = b; });
MyModbus.Read<bool[]>("GM630".ToModbusAdd(), 12).OnSuccess(s =>
{
for (byte i = 0; i < s.Length; i++) WarehousingComplete[i] = s[i];
});

MyModbus.Read<ushort>("GI5".ToModbusAdd(), 1).OnSuccess(s => { TaskFeedback = (RobotMainTask)s; });

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


+ 77
- 5
BPASmartClient.MorkCL/View/Debug.xaml Ver ficheiro

@@ -5,16 +5,88 @@
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"
d:DesignHeight="450"
d:DesignWidth="800" Name="调试界面"
xmlns:vm="clr-namespace:BPASmartClient.MorkCL.ViewModel"
xmlns:pry="clr-namespace:BPASmartClient.CustomResource.UserControls;assembly=BPASmartClient.CustomResource"
d:DesignHeight="900"
d:DesignWidth="1200" Name="调试界面"
mc:Ignorable="d">
<UserControl.DataContext>
<vm:DebugViewModel/>
</UserControl.DataContext>
<UserControl.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="/BPASmartClient.CustomResource;component/Themes/GenricStyle.xaml" />
<ResourceDictionary Source="/BPASmartClient.CustomResource;component/Themes/MyStyle.xaml" />
<ResourceDictionary Source="/BPASmartClient.MorkCL;component/CustomStyle/CustomStyle.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</UserControl.Resources>
<Grid />
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="1*" />
<RowDefinition Height="1*" />
<RowDefinition Height="1*" />
</Grid.RowDefinitions>

<!--#region 炒锅控制 -->
<pry:ImageBorder Margin="10"/>
<StackPanel Orientation="Vertical" Margin="15">
<StackPanel Orientation="Horizontal" Margin="0,0,0,20">
<TextBlock Text="炒锅控制" />
<ComboBox Width="100" FontSize="16" Margin="25,0" SelectedIndex="{Binding FryingPanSelect}">
<ComboBoxItem Content="1#炒锅"/>
<ComboBoxItem Content="2#炒锅"/>
</ComboBox>
</StackPanel>
<StackPanel Orientation="Horizontal" Margin="5">
<TextBlock Text="搅拌设定:"/>
<TextBox Text="{Binding AgitaFrequency}" Width="100" Margin="5,0" FontSize="16"/>
<Button Content="写入参数" Margin="5,0"/>
<Button Content="开始搅拌" Margin="5,0"/>
<Button Content="停止搅拌" Margin="5,0"/>
</StackPanel>
<StackPanel Orientation="Horizontal" Margin="5">
<TextBlock Text="加热设定:"/>
<TextBox Text="{Binding HeatGear}" Width="100" Margin="5,0" FontSize="16"/>
<Button Content="写入参数" Margin="5,0"/>
<Button Content="开始加热" Margin="5,0"/>
<Button Content="停止加热" Margin="5,0"/>
</StackPanel>
<StackPanel Orientation="Horizontal" Margin="5">
<TextBlock Text="通道下料:"/>
<TextBox Text="{Binding Weight}" Width="100" Margin="5,0" FontSize="16"/>
<ComboBox Width="76" Margin="5,0" FontSize="16" SelectedIndex="{Binding ChannelSelect}">
<ComboBoxItem Content="1#通道"/>
<ComboBoxItem Content="2#通道"/>
<ComboBoxItem Content="3#通道"/>
</ComboBox>
<Button Content="开始下料" Margin="5,0"/>
</StackPanel>
<StackPanel Orientation="Horizontal" Margin="5">
<TextBlock Text="去炒制位:"/>
<ComboBox Width="100" Margin="5,0" FontSize="16" SelectedIndex="{Binding StirFryLocSelect}">
<ComboBoxItem Content="1#炒制位"/>
<ComboBoxItem Content="2#炒制位"/>
<ComboBoxItem Content="3#炒制位"/>
</ComboBox>
<Button Content="写入位置" Margin="5,0"/>
</StackPanel>
<WrapPanel Margin="0,5">
<Button Content="炒锅回原点(投料位置)" Margin="5,0" Width="200" HorizontalAlignment="Left"/>
<Button Content="炒锅去调料投料位置" Margin="5,0" Width="200" HorizontalAlignment="Left"/>
<Button Content="出餐启动" Margin="5,0" Width="100" HorizontalAlignment="Left"/>
<Button Content="炒锅清洗" Margin="5,0" Width="100" HorizontalAlignment="Left"/>
</WrapPanel>
</StackPanel>


<!--#endregion-->

<!--#region 机器人控制 -->
<pry:ImageBorder Margin="10" Grid.Row="1"/>
<StackPanel Orientation="Vertical" Margin="15" Grid.Row="1">
</StackPanel>
<!--#endregion-->
</Grid>

</UserControl>

+ 6
- 4
BPASmartClient.MorkCL/View/EditFunctionParamView.xaml Ver ficheiro

@@ -6,6 +6,7 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:converter="clr-namespace:BPASmartClient.MorkCL.Converter"
xmlns:vm="clr-namespace:BPASmartClient.MorkCL.ViewModel"
xmlns:Behavior="http://schemas.microsoft.com/xaml/behaviors"
Title="EditFunctionView"
Width="450"
Height="350"
@@ -25,7 +26,6 @@
</ResourceDictionary.MergedDictionaries>
<converter:Bool2VisibilityConverter x:Key="Bool2VisibilityConverter" />
<converter:Bool2VisibilityReverseConverter x:Key="Bool2VisibilityReverseConverter" />

<DataTemplate x:Key="IntTemplate">
<TextBlock Text="{Binding}" />
</DataTemplate>
@@ -99,17 +99,19 @@
FontSize="18"
IsEditable="False"
ItemsSource="{Binding ComboBoxItemsSource}"
SelectedItem="{Binding ParValue}"
Text="{Binding ParValue}" DisplayMemberPath="Name"
Visibility="{Binding IsUseComboBox, Converter={StaticResource Bool2VisibilityConverter}}">
<ComboBox.Resources>
<!--<ComboBox.Resources>
<converter:MyDataTemplateSelector
x:Key="TemplateSelector"
ClassTemplate="{StaticResource ClassTemplate}"
IntTemplate="{StaticResource IntTemplate}" />
</ComboBox.Resources>
<ComboBox.ItemTemplateSelector>
<StaticResource ResourceKey="TemplateSelector" />
</ComboBox.ItemTemplateSelector>
</ComboBox.ItemTemplateSelector>-->
</ComboBox>
<TextBlock
Margin="5,0"


+ 8
- 5
BPASmartClient.MorkCL/View/EditRecipeView.xaml Ver ficheiro

@@ -1,11 +1,11 @@
<Window
x:Class="BPASmartClient.MorkCL.View.EditRecipeView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:Behaviors="http://schemas.microsoft.com/xaml/behaviors"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:converter="clr-namespace:BPASmartClient.MorkCL.Converter"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:vm="clr-namespace:BPASmartClient.MorkCL.ViewModel"
Title="EditRecipeView"
Width="900"
@@ -59,7 +59,8 @@
DockPanel.Dock="Left"
Text="配方名称:" />
<TextBox
Width="100"
Width="150"
Height="35"
DockPanel.Dock="Left"
FontSize="18"
Foreground="DeepSkyBlue"
@@ -70,6 +71,7 @@
Text="菜品类型:" />
<ComboBox
Width="150"
Height="35"
FontSize="18"
IsReadOnly="True"
ItemsSource="{Binding AllDishType}"
@@ -100,7 +102,7 @@
<RowDefinition Height="1*" />
</Grid.RowDefinitions>
<!--#region 表格标题栏设置-->
<Grid Margin="0,10,0,0" Background="#ff0C255F">
<Grid Margin="0,10,17,0" Background="#ff0C255F">

<Grid.ColumnDefinitions>
<ColumnDefinition Width="50" />
@@ -144,7 +146,7 @@

<!--#region 表格数据-->
<Grid Grid.Row="1">
<ScrollViewer HorizontalScrollBarVisibility="Hidden" VerticalScrollBarVisibility="Hidden">
<ScrollViewer HorizontalScrollBarVisibility="Hidden" VerticalScrollBarVisibility="Visible">
<ItemsControl
x:Name="contentControl"
AlternationCount="{Binding Functions.Count}"
@@ -174,6 +176,7 @@

<Grid Grid.Column="1">
<ComboBox
Height="30"
FontSize="18"
IsReadOnly="True"
ItemsSource="{Binding DataContext.AllFunc, RelativeSource={RelativeSource AncestorType=ItemsControl, Mode=FindAncestor}}"


+ 17
- 4
BPASmartClient.MorkCL/View/ItemStorageView.xaml Ver ficheiro

@@ -8,8 +8,8 @@
xmlns:pry="clr-namespace:BPASmartClient.CustomResource.UserControls;assembly=BPASmartClient.CustomResource"
xmlns:vm="clr-namespace:BPASmartClient.MorkCL.ViewModel"
Name="库位状态"
d:DesignHeight="450"
d:DesignWidth="800"
d:DesignHeight="900"
d:DesignWidth="1200"
mc:Ignorable="d">
<UserControl.DataContext>
<vm:ItemStorageViewModel />
@@ -138,8 +138,15 @@
<UniformGrid
HorizontalAlignment="Center"
VerticalAlignment="Center"
Columns="4"
Rows="3" />
Columns="3"
Rows="4">
<UniformGrid.LayoutTransform>
<TransformGroup>
<RotateTransform Angle="90" />
<ScaleTransform ScaleX="-1" />
</TransformGroup>
</UniformGrid.LayoutTransform>
</UniformGrid>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>

@@ -151,6 +158,12 @@
<RowDefinition />
<RowDefinition />
</Grid.RowDefinitions>
<Grid.LayoutTransform>
<TransformGroup>
<RotateTransform Angle="-90" />
<ScaleTransform ScaleX="1" ScaleY="-1" />
</TransformGroup>
</Grid.LayoutTransform>

<TextBlock
Margin="0,0,0,25"


+ 2
- 2
BPASmartClient.MorkCL/View/RecipeManageView.xaml Ver ficheiro

@@ -110,7 +110,7 @@
</Grid.RowDefinitions>

<!--#region 标题栏设置-->
<Grid Margin="0,10,0,0" Background="#ff0C255F">
<Grid Margin="0,10,17,0" Background="#ff0C255F">

<Grid.ColumnDefinitions>
<ColumnDefinition Width="200" />
@@ -172,7 +172,7 @@

<!--#region 表格数据显示设置-->
<Grid Grid.Row="1">
<ScrollViewer HorizontalScrollBarVisibility="Hidden" VerticalScrollBarVisibility="Hidden">
<ScrollViewer HorizontalScrollBarVisibility="Hidden" VerticalScrollBarVisibility="Visible">
<ItemsControl ItemsSource="{Binding Recipes}">
<ItemsControl.ItemTemplate>
<DataTemplate>


+ 110
- 2
BPASmartClient.MorkCL/View/Test.xaml Ver ficheiro

@@ -15,11 +15,119 @@
<vm:testViewModel />
</UserControl.DataContext>

<Grid>
<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" />
</Grid>
<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
AutoGenerateColumns="False"
CanUserAddRows="False"
CanUserDeleteRows="False"
CanUserReorderColumns="False"
CanUserResizeRows="False"
CanUserSortColumns="False"
ItemsSource="{Binding TBS}" Height="500" IsReadOnly="True" IsHitTestVisible="False">
<DataGrid.Columns>
<DataGridTextColumn Header="ID" Binding="{Binding Id}" Width="350">
</DataGridTextColumn>
<DataGridTextColumn Header="名称" Binding="{Binding Name}" Width="70">
</DataGridTextColumn>
<DataGridTextColumn Header="描述" Binding="{Binding Description}" Width="*">
</DataGridTextColumn>
<DataGridTextColumn Header="位置" Binding="{Binding Loc}" Width="100">
</DataGridTextColumn>
</DataGrid.Columns>
</DataGrid>
</StackPanel>
</UserControl>

+ 95
- 0
BPASmartClient.MorkCL/ViewModel/DebugViewModel.cs Ver ficheiro

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

namespace BPASmartClient.MorkCL.ViewModel
{
public class DebugViewModel : NotifyBase
{
private int heatGear;
private int agitaFrequency;

public DebugViewModel()
{

}


private int fryingPanSelect;
/// <summary>
/// 炒锅选择。
/// </summary>
public int FryingPanSelect
{
get { return fryingPanSelect; }
set { fryingPanSelect = value; OnPropertyChanged(); }
}
/// <summary>
/// 搅拌频率
/// </summary>
public int AgitaFrequency
{
get => agitaFrequency; set
{
if (value >= 50)
agitaFrequency = 50;
else if (value <= 1)
agitaFrequency = 1;
else
agitaFrequency = value;
OnPropertyChanged();
}
}

/// <summary>
/// 加热档位
/// </summary>
public int HeatGear { get => heatGear; set {
if (value>=8)
heatGear = 8;
else if (value<=1)
heatGear = 1;
else
heatGear = value;
OnPropertyChanged(); } }
private float weight;
/// <summary>
/// 下料重量
/// </summary>
public float Weight
{
get { return weight; }
set { weight = value; }
}

private int channelSelect;
/// <summary>
/// 下料通道选择。
/// </summary>
public int ChannelSelect
{
get { return channelSelect; }
set { channelSelect = value; OnPropertyChanged(); }
}

private int stirFryLocSelect;

public int StirFryLocSelect
{
get { return stirFryLocSelect; }
set { stirFryLocSelect = value;OnPropertyChanged(); }
}

public BPARelayCommand WriteAgitaParamCommand { get; set; }
public BPARelayCommand StartAgitateCommand { get; set; }
public BPARelayCommand StopAgitateCommand { get; set; }
public BPARelayCommand WriteHeatParamCommand { get; set; }
public BPARelayCommand StartHeatCommand { get; set; }
public BPARelayCommand StopHeatCommand { get; set; }
public BPARelayCommand ChannelCuttingCommand { get; set; }
}
}

+ 17
- 2
BPASmartClient.MorkCL/ViewModel/EditFunctionParamViewModel.cs Ver ficheiro

@@ -1,5 +1,6 @@
using BPASmartClient.CustomResource.Pages.Model;
using BPASmartClient.MorkCL.HelpClass;
using BPASmartClient.MorkCL.Server;

namespace BPASmartClient.MorkCL.ViewModel
{
@@ -45,10 +46,24 @@ namespace BPASmartClient.MorkCL.ViewModel
MessageNotify.GetInstance.ShowDialog("请输入参数后再重试!", DialogType.Error);
return;
}
if (item.ParValue is MaterialBase)
if (item.IsUseComboBox)
{
item.Id = ((MaterialBase)(item.ParValue)).Id;
switch (FuncName)
{
case EFunc.添加调料:
item.Id = SqliteHelper.GetInstance.GetSeasoning().FirstOrDefault(material => material.Name == item.ParValue.ToString()).Id;
break;
case EFunc.添加主料:
item.Id = SqliteHelper.GetInstance.GetIngredients().FirstOrDefault(material => material.Name == item.ParValue.ToString()).Id;
break;
case EFunc.添加辅料:
item.Id = SqliteHelper.GetInstance.GetAccessories().FirstOrDefault(material => material.Name == item.ParValue.ToString()).Id;
break;
default:
break;
}
}
}
//关闭视图窗口。
ActionManage.GetInstance.Send("CloseFuncParmEditView", true);


+ 27
- 1
BPASmartClient.MorkCL/ViewModel/EditRecipeViewModel.cs Ver ficheiro

@@ -99,6 +99,19 @@ namespace BPASmartClient.MorkCL.ViewModel
break;

case EFunc.加热启动:
if (int.TryParse(item.funcPars[0].ParValue?.ToString(), out int heatGear))
{
if (heatGear > 8 || heatGear <= 0)
{
MessageNotify.GetInstance.ShowDialog($"{item.eFunc}功能的加热档位限值1--8,请修改验证后重试!", DialogType.Error);
return;
}
}
else
{
MessageNotify.GetInstance.ShowDialog($"{item.eFunc}功能的加热档位不是整数,请修改验证后重试!", DialogType.Error);
return;
}
break;

case EFunc.加热停止:
@@ -148,10 +161,23 @@ namespace BPASmartClient.MorkCL.ViewModel
case EFunc.炒锅清洗:
break;

case EFunc.炒锅回投料位置:
case EFunc.炒锅回调料投料位置:
break;

case EFunc.去指定炒制位:
if (int.TryParse(item.funcPars[0].ParValue?.ToString(), out int fryingPanLoc))
{
if (fryingPanLoc > 4 || fryingPanLoc <= 0)
{
MessageNotify.GetInstance.ShowDialog($"{item.eFunc}功能的设定炒制位限值1--4,请修改验证后重试!", DialogType.Error);
return;
}
}
else
{
MessageNotify.GetInstance.ShowDialog($"{item.eFunc}功能的设定炒制不是整数,请修改验证后重试!", DialogType.Error);
return;
}
break;

case EFunc.炒制:


+ 25
- 14
BPASmartClient.MorkCL/ViewModel/ItemStorageViewModel.cs Ver ficheiro

@@ -12,32 +12,41 @@ namespace BPASmartClient.MorkCL.ViewModel
//加载读取数据。
AddTestData();

IngredientsItorage = new ObservableCollection<ItemStorage>(Json<ItemStorageInfo>.Data.IngredientsStorage);
AccessoriesItorage = new ObservableCollection<ItemStorage>(Json<ItemStorageInfo>.Data.AccessoriesStorage);

//IngredientsItorage = new ObservableCollection<ItemStorage>(new ItemStorage[12]);
//AccessoriesItorage = new ObservableCollection<ItemStorage>(new ItemStorage[8]);
ActionManage.GetInstance.Register(() =>
{
IngredientsItorage = new ObservableCollection<ItemStorage>(Json<ItemStorageInfo>.Data.IngredientsStorage);
AccessoriesItorage = new ObservableCollection<ItemStorage>(Json<ItemStorageInfo>.Data.AccessoriesStorage);
},"RefreshItemStorage",true);

ActionManage.GetInstance.Register((() =>
{
Ingredients = new ObservableCollection<IngredientsTB>(SqliteHelper.GetInstance.GetIngredients());
}), "RefreshIngredients", true);
Ingredients = new ObservableCollection<IngredientsTB>(SqliteHelper.GetInstance.GetIngredients());

//for (int i = 0; i < IngredientsItorage.Count; i++)
//{
// IngredientsItorage[i]=new ItemStorage();
//}

//for (int i = 0; i < AccessoriesItorage.Count; i++)
//{
// AccessoriesItorage[i] = new ItemStorage();
//}
ActionManage.GetInstance.Register((object o) =>
{
if (o!=null)
{
#if !FORMAL
// ScaleCurrentWeight = (float)o;
#else
ScaleCurrentWeight = 1.23f;
#endif
}
}, "SendCurrentWeight");

//实例化时调用一次,更新数据。
ActionManage.GetInstance.Send("RefreshItemStorage");
ActionManage.GetInstance.Send("RefreshIngredients");

InStorageCommand = new BPARelayCommand<object>((o) =>
{
if (o != null && o is IngredientsTB ingredients)
{
foreach (ItemStorage item in IngredientsItorage)
{
if (item.IsEmploy == false)
@@ -46,8 +55,10 @@ namespace BPASmartClient.MorkCL.ViewModel
item.Name = ingredients.Name;
item.IsEmploy = true;
item.Weight = ScaleCurrentWeight;
ActionManage.GetInstance.Send("ItemStorage", IngredientsItorage.IndexOf(item)+1);
Json<ItemStorageInfo>.Data.IngredientsStorage = IngredientsItorage.ToArray();
Json<ItemStorageInfo>.Save();
NoticeDemoViewModel.OpenMsg(EnumPromptType.Success, Application.Current.MainWindow, "入库成功", $"物料{ingredients.Name}入库成功。");
return;
}


+ 8
- 3
BPASmartClient.MorkCL/ViewModel/RecipeManageViewModel.cs Ver ficheiro

@@ -1,6 +1,8 @@
using BPASmartClient.CustomResource.Pages.Model;
using BPA.Message;
using BPASmartClient.CustomResource.Pages.Model;
using BPASmartClient.CustomResource.UserControls.MessageShow;
using BPASmartClient.MorkCL.Model.Json;
using Newtonsoft.Json;

namespace BPASmartClient.MorkCL.ViewModel
{
@@ -51,9 +53,12 @@ namespace BPASmartClient.MorkCL.ViewModel
//参数为ControlData,可能需要转换。
if (MessageNotify.GetInstance.ShowDialog("请确认,是否下发订单?"))
{
if (o != null && o is ControlData data)
if (o != null && o is ControlData)
{
ActionManage.GetInstance.Send(NotifyTopic.FormulaDistribution, o);
var jsonString = o.ToJSON();
var data= JsonConvert.DeserializeObject<ControlData>(jsonString);

ActionManage.GetInstance.Send(NotifyTopic.FormulaDistribution, data);
NoticeDemoViewModel.OpenMsg(EnumPromptType.Success, Application.Current.MainWindow, "提示", $"下发订单{data.Name}成功!");
}
}


+ 11
- 1
BPASmartClient.MorkCL/ViewModel/testViewModel.cs Ver ficheiro

@@ -1,4 +1,6 @@
using SqlSugar;
using BPASmartClient.MorkCL.Model.DB;
using BPASmartClient.MorkCL.Server;
using SqlSugar;

namespace BPASmartClient.MorkCL.ViewModel
{
@@ -6,8 +8,14 @@ namespace BPASmartClient.MorkCL.ViewModel
{
public testViewModel()
{

TBS = new(SqliteHelper.GetInstance.GetAccessories());


testCommand = new BPARelayCommand(() =>
{


ControlData cd = new ControlData();
cd.Name = "莲白回锅";
cd.DeviceType = EDeviceType.炒锅1;
@@ -160,5 +168,7 @@ namespace BPASmartClient.MorkCL.ViewModel
}

public BPARelayCommand testCommand { get; set; }

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

+ 89
- 45
DosingSystem/Model/DeviceInquire.cs Ver ficheiro

@@ -401,12 +401,11 @@ namespace BPASmartClient.DosingSystem

public void StatusReset()
{
// prop1:
// prop1:
this.modbusTcp.Write(DeviceAddress.FinfishStatus.ToAdd(), (ushort)1);
//MessageNotify.GetInstance.ShowRunLog($"料仓复位,值:{1}");
//var value = this.modbusTcp.Read<ushort>(DeviceAddress.FinfishStatus.ToAdd(), 1, BPA.Helper.DataFormat.CDAB).Content;
//if (value != null && value.ToString() != 1.ToString()) goto prop1;
//MessageNotify.GetInstance.ShowRunLog($"料仓复位,值:{this.modbusTcp.Read<ushort>(DeviceAddress.FinfishStatus.ToAdd(), 1, BPA.Helper.DataFormat.CDAB).Content}");
}

public void Dispose()
@@ -421,67 +420,112 @@ namespace BPASmartClient.DosingSystem
var res = Json<DevicePar>.Data.deviceParModels.FirstOrDefault(p => p.MaterialName == DeviceName);
if (res != null)
{
//modbusTcp.Write(DeviceAddress.SlowlyAddWeight.ToAdd(), res.SlowlyAddWeight);

//modbusTcp.Write(DeviceAddress.PreCloseValveWeight.ToAdd(), res.PreCloseValveWeight);
//modbusTcp.Write(DeviceAddress.RapidAcceleration.ToAdd(), (uint)res.RapidAcceleration);
//modbusTcp.Write(DeviceAddress.SlowAcceleration.ToAdd(), (uint)res.SlowAcceleration);
//modbusTcp.Write(DeviceAddress.ServoManualSpeed.ToAdd(), (uint)res.ServoManualSpeed);
//modbusTcp.Write(DeviceAddress.SiloUpperLimitWeight.ToAdd(), (uint)res.SiloUpperLimitWeight);
//modbusTcp.Write(DeviceAddress.LowerLimitWeightOfSilo.ToAdd(), (uint)res.LowerLimitWeightOfSilo);
//modbusTcp.Write(DeviceAddress.StirringSpeed.ToAdd(), (uint)res.StirringSpeed);
//MessageNotify.GetInstance.ShowRunLog($"{res.MaterialName},配料参数下发完成");

prop1:
modbusTcp.Write(DeviceAddress.SlowlyAddWeight.ToAdd(), res.SlowlyAddWeight);

MessageNotify.GetInstance.ShowRunLog($"{DeviceName},设置慢加重量:{res.SlowlyAddWeight}");
var value1 = modbusTcp.Read<float>(DeviceAddress.SlowlyAddWeight.ToAdd(), 1, BPA.Helper.DataFormat.CDAB).Content;
if (value1 != null && value1.ToString() != res.SlowlyAddWeight.ToString()) goto prop1;
prop2:
modbusTcp.Write(DeviceAddress.PreCloseValveWeight.ToAdd(), res.PreCloseValveWeight);
MessageNotify.GetInstance.ShowRunLog($"{DeviceName},设置提前关阀重量:{res.PreCloseValveWeight}");
var value2 = modbusTcp.Read<float>(DeviceAddress.PreCloseValveWeight.ToAdd(), 1, BPA.Helper.DataFormat.CDAB).Content;
if (value2 != null && value2.ToString() != res.PreCloseValveWeight.ToString()) goto prop2;
prop3:
modbusTcp.Write(DeviceAddress.RapidAcceleration.ToAdd(), (uint)res.RapidAcceleration);
MessageNotify.GetInstance.ShowRunLog($"{DeviceName},设置快加速度:{res.RapidAcceleration}");
var value3 = modbusTcp.Read<uint>(DeviceAddress.RapidAcceleration.ToAdd(), 1, BPA.Helper.DataFormat.CDAB).Content;
if (value3 != null && value3.ToString() != res.RapidAcceleration.ToString()) goto prop3;
prop4:
modbusTcp.Write(DeviceAddress.SlowAcceleration.ToAdd(), (uint)res.SlowAcceleration);
MessageNotify.GetInstance.ShowRunLog($"{DeviceName},设置慢加速度:{res.SlowAcceleration}");
var value4 = modbusTcp.Read<uint>(DeviceAddress.SlowAcceleration.ToAdd(), 1, BPA.Helper.DataFormat.CDAB).Content;
if (value4 != null && value4.ToString() != res.SlowAcceleration.ToString()) goto prop4;
prop5:
modbusTcp.Write(DeviceAddress.ServoManualSpeed.ToAdd(), (uint)res.ServoManualSpeed);
MessageNotify.GetInstance.ShowRunLog($"{DeviceName},设置伺服手动速度:{res.ServoManualSpeed}");
var value5 = modbusTcp.Read<uint>(DeviceAddress.ServoManualSpeed.ToAdd(), 1, BPA.Helper.DataFormat.CDAB).Content;
if (value5 != null && value5.ToString() != res.ServoManualSpeed.ToString()) goto prop5;

prop6:
modbusTcp.Write(DeviceAddress.SiloUpperLimitWeight.ToAdd(), (uint)res.SiloUpperLimitWeight);
MessageNotify.GetInstance.ShowRunLog($"{DeviceName},设置料仓上限重量:{res.SiloUpperLimitWeight}");
var value6 = modbusTcp.Read<uint>(DeviceAddress.SiloUpperLimitWeight.ToAdd(), 1, BPA.Helper.DataFormat.CDAB).Content;
if (value6 != null && value6.ToString() != res.SiloUpperLimitWeight.ToString()) goto prop6;
prop7:
modbusTcp.Write(DeviceAddress.LowerLimitWeightOfSilo.ToAdd(), (uint)res.LowerLimitWeightOfSilo);
MessageNotify.GetInstance.ShowRunLog($"{DeviceName},设置料仓下限重量:{res.LowerLimitWeightOfSilo}");
var value7 = modbusTcp.Read<uint>(DeviceAddress.LowerLimitWeightOfSilo.ToAdd(), 1, BPA.Helper.DataFormat.CDAB).Content;
if ((value7 != null && value7.ToString() != res.LowerLimitWeightOfSilo.ToString())) goto prop7;
prop8:
modbusTcp.Write(DeviceAddress.StirringSpeed.ToAdd(), (uint)res.StirringSpeed);
// MessageNotify.GetInstance.ShowRunLog($"当前下发重量:{res.SlowlyAddWeight}:{modbusTcp.Read<float>(DeviceAddress.SlowlyAddWeight.ToAdd(), 1, BPA.Helper.DataFormat.CDAB).Content}");
MessageNotify.GetInstance.ShowRunLog($"{DeviceName},设置搅拌速度:{res.StirringSpeed}");
var value8 = modbusTcp.Read<uint>(DeviceAddress.StirringSpeed.ToAdd(), 1, BPA.Helper.DataFormat.CDAB).Content;
if (value8 != null && value8.ToString() != res.StirringSpeed.ToString()) goto prop8;
MessageNotify.GetInstance.ShowRunLog($"{res.MaterialName},配料参数下发完成");

//prop1:
// modbusTcp.Write(DeviceAddress.SlowlyAddWeight.ToAdd(), res.SlowlyAddWeight);
// var value1 = modbusTcp.Read<float>(DeviceAddress.SlowlyAddWeight.ToAdd(), 1, BPA.Helper.DataFormat.CDAB).Content;
// if (value1 != null && value1.ToString() != res.SlowlyAddWeight.ToString()) goto prop1;
// prop2:
// modbusTcp.Write(DeviceAddress.PreCloseValveWeight.ToAdd(), res.PreCloseValveWeight);
// var value2 = modbusTcp.Read<float>(DeviceAddress.PreCloseValveWeight.ToAdd(), 1, BPA.Helper.DataFormat.CDAB).Content;
// if (value2 != null && value2.ToString() != res.PreCloseValveWeight.ToString()) goto prop2;
// prop3:
// modbusTcp.Write(DeviceAddress.RapidAcceleration.ToAdd(), (uint)res.RapidAcceleration);
// var value3 = modbusTcp.Read<uint>(DeviceAddress.RapidAcceleration.ToAdd(), 1, BPA.Helper.DataFormat.CDAB).Content;
// if (value3 != null && value3.ToString() != res.RapidAcceleration.ToString()) goto prop3;
// prop4:
// modbusTcp.Write(DeviceAddress.SlowAcceleration.ToAdd(), (uint)res.SlowAcceleration);
// var value4 = modbusTcp.Read<uint>(DeviceAddress.SlowAcceleration.ToAdd(), 1, BPA.Helper.DataFormat.CDAB).Content;
// if (value4 != null && value4.ToString() != res.SlowAcceleration.ToString()) goto prop4;
// prop5:
// modbusTcp.Write(DeviceAddress.ServoManualSpeed.ToAdd(), (uint)res.ServoManualSpeed);
// var value5 = modbusTcp.Read<uint>(DeviceAddress.ServoManualSpeed.ToAdd(), 1, BPA.Helper.DataFormat.CDAB).Content;
// if (value5 != null && value5.ToString() != res.ServoManualSpeed.ToString()) goto prop5;

// prop6:
// modbusTcp.Write(DeviceAddress.SiloUpperLimitWeight.ToAdd(), (uint)res.SiloUpperLimitWeight);
// var value6 = modbusTcp.Read<uint>(DeviceAddress.SiloUpperLimitWeight.ToAdd(), 1, BPA.Helper.DataFormat.CDAB).Content;
// if (value6 != null && value6.ToString() != res.SiloUpperLimitWeight.ToString()) goto prop6;
// prop7:
// modbusTcp.Write(DeviceAddress.LowerLimitWeightOfSilo.ToAdd(), (uint)res.LowerLimitWeightOfSilo);
// var value7 = modbusTcp.Read<uint>(DeviceAddress.LowerLimitWeightOfSilo.ToAdd(), 1, BPA.Helper.DataFormat.CDAB).Content;
// if ((value7 != null && value7.ToString() != res.LowerLimitWeightOfSilo.ToString())) goto prop7;
// prop8:
// modbusTcp.Write(DeviceAddress.StirringSpeed.ToAdd(), (uint)res.StirringSpeed);
// var value8 = modbusTcp.Read<uint>(DeviceAddress.StirringSpeed.ToAdd(), 1, BPA.Helper.DataFormat.CDAB).Content;
// if (value8 != null && value8.ToString() != res.StirringSpeed.ToString()) goto prop8;
// MessageNotify.GetInstance.ShowRunLog($"{res.MaterialName},配料参数下发完成");
}
prop9:
//modbusTcp.Write(DeviceAddress.WeightSet.ToAdd(), Value);//写入配方重量
//var value9 = modbusTcp.Read<float>(DeviceAddress.WeightSet.ToAdd(), 1, BPA.Helper.DataFormat.CDAB).Content;
//if ((value9 != null && value9.ToString() != Value.ToString()) || value9 == 0) goto prop9;
modbusTcp.Write(DeviceAddress.WeightSet.ToAdd(), Value);//写入配方重量
MessageNotify.GetInstance.ShowRunLog($"{DeviceName},设置重量:{Value}");

var value9 = modbusTcp.Read<float>(DeviceAddress.WeightSet.ToAdd(), 1, BPA.Helper.DataFormat.CDAB).Content;
if ((value9 != null && value9.ToString() != Value.ToString()) || value9 == 0) goto prop9;
//prop10:
//MessageNotify.GetInstance.ShowRunLog($"写入配方重量,值{Value}:{value9}");
//modbusTcp.Write(DeviceAddress.Start.ToAdd(), (ushort)1);//设备启动写入
//var value10 = modbusTcp.Read<ushort>(DeviceAddress.Start.ToAdd(), 1, BPA.Helper.DataFormat.CDAB).Content;
//if ((value10 != null && value10.ToString() != 1.ToString())||value10==0) goto prop10;
modbusTcp.Write(DeviceAddress.WeightSet.ToAdd(), Value);//写入配方重量
//modbusTcp.Write(DeviceAddress.WeightSet.ToAdd(), Value);//写入配方重量
modbusTcp.Write(DeviceAddress.Start.ToAdd(), (ushort)1);//设备启动写入
MessageNotify.GetInstance.ShowRunLog($"设备启动写入,值1:{Value}");
Task.Run(() =>
{
while (true)
{
ushort c = modbusTcp.Read<ushort>(DeviceAddress.DeviceAlarmCode.ToAdd(), 1, BPA.Helper.DataFormat.CDAB).Content;
MessageNotify.GetInstance.ShowRunLog($"{IpAddress}:LW51,值:{modbusTcp.Read<ushort>(DeviceAddress.DeviceAlarmCode.ToAdd(), 1, BPA.Helper.DataFormat.CDAB).Content}");
string str = DecToBinary(c);
if (str[8].ToString() == 0.ToString())
{
modbusTcp.Write(DeviceAddress.Start.ToAdd(), (ushort)1);//设备启动写入
}
else
return;
}


});
MessageNotify.GetInstance.ShowRunLog($"{DeviceName},设置重量:{Value},味魔方启动配料");
}
}
static string DecToBinary(int a)
{
int r;
string s = "";
do
{
r = a % 2;
a /= 2;
s = r + s;
}
while (a != 0);
int length = s.Length;
for (int i = 0; i < 16 - length; i++)
{
s = 0 + s;
}
return s;
}
}
}

+ 53
- 24
DosingSystem/ViewModel/RecipeControlViewModel.cs Ver ficheiro

@@ -19,11 +19,13 @@ using System.Data.SqlClient;
using S7.Net.Types;
using BPA.Communication;
using BPASmartClient.DosingSystem.Model;
using System.Security.Cryptography;

namespace BPASmartClient.DosingSystem.ViewModel
{
public class RecipeControlViewModel : NotifyBase
{
int ComCount = 0;//配料完成计数
static ConcurrentQueue<string> RecipeNames = new ConcurrentQueue<string>();
static ObservableCollection<StockStatusModel> StockStatus = new ObservableCollection<StockStatusModel>();
public RecipeControlViewModel()
@@ -160,7 +162,7 @@ namespace BPASmartClient.DosingSystem.ViewModel
if ((values != null && values.ToString() != (item + item1).ToString()) || values == null)
goto prop1;
if (RE.IsSuccess)
MessageNotify.GetInstance.ShowRunLog($"下发配方DB4.DBD{2 + (tempDevice.DeviceNum - 1) * 4} :{(byte)tInfo.ElementAt(i).ElementAt(m).Loc}-{item+item1}-{(item+item1).ToBinString()}");
MessageNotify.GetInstance.ShowRunLog($"下发配方DB4.DBD{2 + (tempDevice.DeviceNum - 1) * 4} :{(byte)tInfo.ElementAt(i).ElementAt(m).Loc}-{item + item1}-{(item + item1).ToBinString()}");
else
MessageNotify.GetInstance.ShowRunLog($"下发配方DB4.DBD{2 + (tempDevice.DeviceNum - 1) * 4} 失败");
}
@@ -294,7 +296,8 @@ namespace BPASmartClient.DosingSystem.ViewModel
Thread.Sleep(100);
}), "启动配方下发", true);
}
int ComCount = 0;
/// <summary>
/// 配方执行状态监听
/// </summary>
@@ -727,7 +730,7 @@ namespace BPASmartClient.DosingSystem.ViewModel
//设备状态显示
if (Recipes.ElementAt(i).RecipeName == CurrentRecipeName)
{
string tempRawMaterialName = DeviceInquire.GetInstance.GetDevice(Recipes.ElementAt(i).RawMaterials.ElementAt(m).DeviceIp).DeviceName;
string tempRawMaterialName = DeviceInquire.GetInstance.GetDevice(Recipes.ElementAt(i).RawMaterials.ElementAt(m).DeviceIp).DeviceName;
int recIndex = recipeProcesses.ToList().FindIndex(p => p.RecipeName == CurrentRecipeName);
if (recIndex >= 0 && recIndex < recipeProcesses.Count)
{
@@ -735,9 +738,12 @@ namespace BPASmartClient.DosingSystem.ViewModel

if (index >= 0 && index < recipeProcesses.ElementAt(recIndex).RawMaterials.Count)
{

//测试使用
recipeProcesses.ElementAt(recIndex).RawMaterials.ElementAt(index).RecipeStatus = RunStatus;



}
for (int j = 0; j < GlobalDevice.PlcData.IsAllowIngredients.Length; j++)
{
@@ -778,13 +784,12 @@ namespace BPASmartClient.DosingSystem.ViewModel
if (DeviceNum > 0)
{
float weight = Recipes.ElementAt(i).RawMaterials.ElementAt(Location1).RawMaterialWeight;
//测试
// int loc1 = Array.FindIndex(recipeProcesses.ElementAt(recIndex).RawMaterials.ToArray(),p=>p.RawMaterialName==RawName&&p.RecipeStatus==1);
int loc = Array.FindIndex(Recipes.ElementAt(i).RawMaterials.ToArray(), p => (p.RawMaterialName == RawName));
if (loc >= 0 && RawName != null && weight >= 0)
{
int St_index = Array.FindIndex(StockStatus.ToArray(), p => p.MaterialName == RawName);
// int materialCount = recipeProcesses.ElementAt(recIndex).RawMaterials.Where(p => p.RawMaterialName == RawName).Count();
// int materialCount = recipeProcesses.ElementAt(recIndex).RawMaterials.Where(p => p.RawMaterialName == RawName).Count();
if (St_index < 0) //|| (StockStatus.Count < materialCount && St_index > 0)
{
StockStatus.Add(new StockStatusModel()
@@ -794,16 +799,17 @@ namespace BPASmartClient.DosingSystem.ViewModel
IssueStatus = 0,
});
}
St_index = Array.FindIndex(StockStatus.ToArray(), p => p.MaterialName == RawName );//&& p.IssueStatus == 0)
St_index = Array.FindIndex(StockStatus.ToArray(), p => p.MaterialName == RawName);//&& p.IssueStatus == 0)

// int St_index1 = Array.FindIndex(StockStatus.ToArray(), p => (p.MaterialName == RawName && p.IssueStatus == 1));
if (St_index >= 0)
{

if (RTrig.GetInstance($"ac{j}-{St_index}").Start(GlobalDevice.PlcData.IsAllowIngredients[j]))
{
MessageNotify.GetInstance.ShowRunLog($"{St_index}-{j}--》允许配料");
if (StockStatus.ElementAt(St_index).IssueStatus == 2)
{
{
StockStatus.ElementAt(St_index).IssueStatus = 0;
MessageNotify.GetInstance.ShowRunLog($"{St_index}-复位");
}
@@ -811,36 +817,51 @@ namespace BPASmartClient.DosingSystem.ViewModel
var rrr = DeviceInquire.GetInstance.GetDevice(Recipes.ElementAt(i).RawMaterials.ElementAt(loc).DeviceIp).deviceStatus.RunStatus;
if ((recipeProcesses.ElementAt(recIndex).RawMaterials.ElementAt(loc).RecipeStatus == 1 && StockStatus.ElementAt(St_index).IssueStatus == 0))//
{

StockStatus.ElementAt(St_index).IssueStatus = 1;
DeviceInquire.GetInstance.GetDevice(Recipes.ElementAt(i).RawMaterials.ElementAt(loc).DeviceIp).Start(weight);
var res = recipeProcesses.ElementAt(recIndex).RawMaterials.FirstOrDefault(p => p.Status !=Status.正在配料 &&p.Status!=Status.配料完成&& p.RawMaterialName == tempRawMaterialName && p.Loc == j + 1);
if (res != null)
res.Status = Status.正在配料;
MessageNotify.GetInstance.ShowRunLog($"设备执行状态:{rrr}");
MessageNotify.GetInstance.ShowRunLog($"柔性味魔方{Recipes.ElementAt(i).RawMaterials.ElementAt(loc).DeviceIp},开始出料");
}
if (recipeProcesses.ElementAt(recIndex).RawMaterials.ElementAt(loc).RecipeStatus == 3 && StockStatus.ElementAt(St_index).IssueStatus == 1)
{
//GlobalDevice.PlcData.IsAllowIngredients[j] = false;//测试使用
ComCount++;
StockStatus.ElementAt(St_index).IssueStatus = 2;
DeviceInquire.GetInstance.GetDevice(Recipes.ElementAt(i).RawMaterials.ElementAt(loc).DeviceIp).StatusReset();
//int a = 0.SetBitValue((byte)(DeviceNum), true);
//byte[] test1 = a.ToBytes(BPA.Helper.DataFormat.BADC);
//int item = test1.ToInt();
//prop1:
// SiemensDevice.GetInstance.MySiemens.Write("DB4.DBD130", item);
SiemensDevice.GetInstance.MySiemens.Write($"DB4.DBX130.{DeviceNum - 1}", true).OnSuccess(() =>
//prop1:
// SiemensDevice.GetInstance.MySiemens.Write("DB4.DBD130", item);
SiemensDevice.GetInstance.MySiemens.Write($"DB4.DBX130.{DeviceNum - 1}", true);
Task.Run(() =>
{
MessageNotify.GetInstance.ShowRunLog($"设备完成信号写入成功!DB4.DBX130.{{DeviceNum - 1}}:true\"");
}).OnFail(s =>
{
MessageNotify.GetInstance.ShowRunLog($"设备完成信号写入失败!{s}");
});
int cout = DeviceNum - 1;
while (!SiemensDevice.GetInstance.MySiemens.Read<bool>($"DB3.DBX148.{cout}").Content) //DB3.DBX148.0-31 148.0-148.5代表6个料仓位置
{
SiemensDevice.GetInstance.MySiemens.Write($"DB4.DBX130.{cout}", true);
Thread.Sleep(200);
}
while (SiemensDevice.GetInstance.MySiemens.Read<bool>($"DB3.DBX148.{cout}").Content)
{
SiemensDevice.GetInstance.MySiemens.Write($"DB4.DBX130.{cout}", false);
}
MessageNotify.GetInstance.ShowRunLog($"{cout}号气缸复位信号写入成功!");
});
var res = recipeProcesses.ElementAt(recIndex).RawMaterials.FirstOrDefault(p => p.Status != Status.配料完成 && p.RawMaterialName == tempRawMaterialName && p.Loc == j + 1);
if (res != null)
res.Status = Status.配料完成;
//var values = SiemensDevice.GetInstance.MySiemens.Read<int>("DB4.DBD130").Content;
//if ((values != null && values.ToString() != item.ToString()) || values == null)
// goto prop1;

//SiemensDevice.GetInstance.MySiemens.Write("DB4.DBD130", true).OnSuccess(() =>
//{
// MessageNotify.GetInstance.ShowRunLog($"设备完成信号写入成功!");
@@ -848,11 +869,10 @@ namespace BPASmartClient.DosingSystem.ViewModel
//{
// MessageNotify.GetInstance.ShowRunLog($"设备完成信号写入失败!{s}");
//});
//MessageNotify.GetInstance.ShowRunLog($"{res}");
MessageNotify.GetInstance.ShowRunLog($"设备完成执行状态:{rrr}");
MessageNotify.GetInstance.ShowRunLog($"DB4.DBD130:{item.ToBinString()}");
MessageNotify.GetInstance.ShowRunLog($"柔性味魔方{Recipes.ElementAt(i).RawMaterials.ElementAt(loc).DeviceIp},出料完成,状态复位");
}

//测试
@@ -972,7 +992,7 @@ namespace BPASmartClient.DosingSystem.ViewModel
// });
// }
// St_index = Array.FindIndex(StockStatus.ToArray(), p => p.MaterialName == RawName);
// if (St_index >= 0)
// {
// if (RTrig.GetInstance($"ac{j}").Start(GlobalDevice.PlcData.IsAllowIngredients[j]))
@@ -1146,9 +1166,18 @@ namespace BPASmartClient.DosingSystem.ViewModel
}
//int Finish_Count = StockStatus.Where(s => s.IssueStatus == 2).Count();
//int Finish_Count = recipeProcesses.ElementAt(recIndex).RawMaterials.Where(p => p.RecipeStatus == 3).Count();
if ( ComCount >= Recipes.ElementAt(i).RawMaterials.Count) //配方配料完成 StockStatus.Count >= Recipes.ElementAt(i).RawMaterials.Count &&
if (ComCount >= Recipes.ElementAt(i).RawMaterials.Count) //配方配料完成 StockStatus.Count >= Recipes.ElementAt(i).RawMaterials.Count &&
{
int cc = recipeProcesses.ElementAt(recIndex).RawMaterials.OrderBy(p => p.RawMaterialName).Count();
for (int k = 0; k < 32; k++)
{
for (int l = 0; l < cc; l++)
{
RTrig.GetInstance($"ac{k}-{l}").Start(false);
}
}
ComCount = 0;

StockStatus.Clear();
MessageNotify.GetInstance.ShowUserLog($"配方:{recipeProcesses.ElementAt(recIndex).RecipeName},配料完成");
foreach (var item in recipeProcesses.ElementAt(recIndex).RawMaterials)


Carregando…
Cancelar
Guardar