Browse Source

代码更新

master
pengliangyang 2 years ago
parent
commit
0333053dc3
20 changed files with 1046 additions and 165 deletions
  1. +9
    -1
      BPASmartClient.JXJFoodBigStation/App.xaml.cs
  2. +34
    -3
      BPASmartClient.JXJFoodBigStation/Model/HK_PLC/DB_Read.cs
  3. +1
    -0
      BPASmartClient.JXJFoodBigStation/Model/HK_PLC/HKDeviceStatus.cs
  4. +18
    -0
      BPASmartClient.JXJFoodBigStation/Model/HK_PLC/PlcCommAttribute.cs
  5. +14
    -14
      BPASmartClient.JXJFoodBigStation/Model/HK_PLC/StockBinName.cs
  6. +32
    -0
      BPASmartClient.JXJFoodBigStation/Model/PlcVarMonitor.cs
  7. +583
    -115
      BPASmartClient.JXJFoodBigStation/Model/ProcessControl.cs
  8. +155
    -0
      BPASmartClient.JXJFoodBigStation/View/HKPlcCommMonitorView.xaml
  9. +28
    -0
      BPASmartClient.JXJFoodBigStation/View/HKPlcCommMonitorView.xaml.cs
  10. +2
    -2
      BPASmartClient.JXJFoodBigStation/View/RecipeReceiveView.xaml
  11. +1
    -4
      BPASmartClient.JXJFoodBigStation/View/RecipeSendDownView.xaml
  12. +131
    -0
      BPASmartClient.JXJFoodBigStation/ViewModel/HKPlcCommMonitorViewModel.cs
  13. +4
    -8
      BPASmartClient.JXJFoodBigStation/ViewModel/RecipeReceiveViewModel.cs
  14. +23
    -9
      BPASmartClient.JXJFoodBigStation/ViewModel/RecipeSendDownViewModel.cs
  15. +1
    -1
      BPASmartClient.JXJFoodSmallStation/App.xaml.cs
  16. +1
    -0
      BPASmartClient.JXJFoodSmallStation/Model/ProcessControl.cs
  17. +1
    -1
      BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/DeviceInquire.cs
  18. +2
    -2
      BPASmartClient.JXJFoodSmallStation/ViewModel/DeviceListViewModel.cs
  19. +6
    -1
      BPASmartClient.S7Net/SiemensHelper.cs
  20. +0
    -4
      DosingSystem/ViewModel/NewRecipeViewModel.cs

+ 9
- 1
BPASmartClient.JXJFoodBigStation/App.xaml.cs View File

@@ -27,8 +27,8 @@ namespace BPASmartClient.JXJFoodBigStation
base.OnStartup(e);
MenuInit();
DataInit();
ProcessControl.GetInstance.Init();
MainView mv = new MainView();
ProcessControl.GetInstance.Init();
LoginView lv = new LoginView();
var res = lv.ShowDialog();
if (res != null && res == true)
@@ -134,6 +134,14 @@ namespace BPASmartClient.JXJFoodBigStation
AssemblyName = "BPASmartClient.JXJFoodBigStation",
ToggleWindowPath = "View.HardwareStatusView"
});
DeviceMonitor.Add(new SubMenumodel()
{
SubMenuName = "通讯状态",
SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.技术员 },
AssemblyName = "BPASmartClient.JXJFoodBigStation",
ToggleWindowPath = "View.HKPlcCommMonitorView"
});
MenuManage.GetInstance.menuModels.Add(new MenuModel()
{
MainMenuIcon = "",


+ 34
- 3
BPASmartClient.JXJFoodBigStation/Model/HK_PLC/DB_Read.cs View File

@@ -8,55 +8,86 @@ namespace BPASmartClient.JXJFoodBigStation.Model.HK_PLC
{
public class DB_Read
{
[PlcComm("plc心跳上报")]
/// <summary>
/// plc心跳上报
/// </summary>
public bool HeartBeat { get; set; }
[PlcComm("配方1允许下发配方")]
/// <summary>
/// 配方1允许下发配方
/// </summary>
public bool IsAllowIssueRecipe1 { get; set; }

[PlcComm("配方2允许下发配方")]
public bool IsAllowIssueRecipe2 { get; set; }

[PlcComm("配方3允许下发配方")]
public bool IsAllowIssueRecipe3 { get; set; }

[PlcComm("配方4允许下发配方")]
public bool IsAllowIssueRecipe4 { get; set; }

[PlcComm("配方1接收配方完成")]
/// <summary>
/// 配方1 接收配方完成
/// </summary>
public bool ReceiveFinishRecipe1 { get; set; }
[PlcComm("配方2接收配方完成")]
public bool ReceiveFinishRecipe2 { get; set; }
[PlcComm("配方3接收配方完成")]
public bool ReceiveFinishRecipe3 { get; set; }
[PlcComm("配方4接收配方完成")]
public bool ReceiveFinishRecipe4 { get; set; }
[PlcComm("配方1配料完成")]
/// <summary>
/// 配方1 配料完成
/// </summary>
public bool Recipe1DosingFinish { get; set; }
[PlcComm("配方2配料完成")]
public bool Recipe2DosingFinish { get; set; }
[PlcComm("配方3配料完成")]
public bool Recipe3DosingFinish { get; set; }
[PlcComm("配方4配料完成")]
public bool Recipe4DosingFinish { get; set; }
[PlcComm("配方1托盘编号")]
/// <summary>
/// 配方1 托盘编号
/// </summary>
public short Recipe1TrayCode { get; set; }
[PlcComm("配方2托盘编号")]
public short Recipe2TrayCode { get; set; }
[PlcComm("配方3托盘编号")]
public short Recipe3TrayCode { get; set; }
[PlcComm("配方4托盘编号")]
public short Recipe4TrayCode { get; set; }
[PlcComm("料仓1实际下料重量")]
public float StockBin1ActualWeight { get; set; }
[PlcComm("料仓2实际下料重量")]
public float StockBin2ActualWeight { get; set; }
[PlcComm("料仓3实际下料重量")]
public float StockBin3ActualWeight { get; set; }
[PlcComm("料仓4实际下料重量")]
public float StockBin4ActualWeight { get; set; }
[PlcComm("料仓5实际下料重量")]
public float StockBin5ActualWeight { get; set; }
[PlcComm("料仓6实际下料重量")]
public float StockBin6ActualWeight { get; set; }
[PlcComm("料仓7实际下料重量")]
public float StockBin7ActualWeight { get; set; }
[PlcComm("料仓8实际下料重量")]
public float StockBin8ActualWeight { get; set; }
[PlcComm("料仓9实际下料重量")]
public float StockBin9ActualWeight { get; set; }
[PlcComm("料仓10实际下料重量")]
public float StockBin10ActualWeight { get; set; }
[PlcComm("料仓11实际下料重量")]
public float StockBin11ActualWeight { get; set; }
[PlcComm("料仓12实际下料重量")]
public float StockBin12ActualWeight { get; set; }
[PlcComm("料仓13实际下料重量")]
public float StockBin13ActualWeight { get; set; }
[PlcComm("料仓14实际下料重量")]
public float StockBin14ActualWeight { get; set; }
}
}

+ 1
- 0
BPASmartClient.JXJFoodBigStation/Model/HK_PLC/HKDeviceStatus.cs View File

@@ -30,6 +30,7 @@ namespace BPASmartClient.JXJFoodBigStation.Model.HK_PLC
if (res1 != null && res1 is DB_Read data1)
{
PlcRead = data1;
GVL_BigStation.HeartBeatFromPlc = data1.HeartBeat;//读取plc心跳
}
if (res2 != null && res2 is StockBinName data2)
{


+ 18
- 0
BPASmartClient.JXJFoodBigStation/Model/HK_PLC/PlcCommAttribute.cs View File

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

namespace BPASmartClient.JXJFoodBigStation.Model.HK_PLC
{
[AttributeUsage(AttributeTargets.Property)]
public sealed class PlcCommAttribute:Attribute
{
public PlcCommAttribute(string describe)
{
Describe = describe;
}
public string Describe { get; set; }
}
}

+ 14
- 14
BPASmartClient.JXJFoodBigStation/Model/HK_PLC/StockBinName.cs View File

@@ -10,32 +10,32 @@ namespace BPASmartClient.JXJFoodBigStation.Model.HK_PLC
public class StockBinName
{
[Siemens(6)]
public string RawMaterialName1 { get; set; }
public string RawMaterialName1 { get; set; } = "";
[Siemens(6)]
public string RawMaterialName2 { get; set; }
public string RawMaterialName2 { get; set; } = "";
[Siemens(6)]
public string RawMaterialName3 { get; set; }
public string RawMaterialName3 { get; set; } = "";
[Siemens(6)]
public string RawMaterialName4 { get; set; }
public string RawMaterialName4 { get; set; } = "";
[Siemens(6)]
public string RawMaterialName5 { get; set; }
public string RawMaterialName5 { get; set; } = "";
[Siemens(6)]
public string RawMaterialName6 { get; set; }
public string RawMaterialName6 { get; set; } = "";
[Siemens(6)]
public string RawMaterialName7 { get; set; }
public string RawMaterialName7 { get; set; } = "";
[Siemens(6)]
public string RawMaterialName8 { get; set; }
public string RawMaterialName8 { get; set; } = "";
[Siemens(6)]
public string RawMaterialName9 { get; set; }
public string RawMaterialName9 { get; set; } = "";
[Siemens(6)]
public string RawMaterialName10 { get; set; }
public string RawMaterialName10 { get; set; } = "";
[Siemens(6)]
public string RawMaterialName11 { get; set; }
public string RawMaterialName11 { get; set; } = "";
[Siemens(6)]
public string RawMaterialName12 { get; set; }
public string RawMaterialName12 { get; set; } = "";
[Siemens(6)]
public string RawMaterialName13 { get; set; }
public string RawMaterialName13 { get; set; } = "";
[Siemens(6)]
public string RawMaterialName14 { get; set; }
public string RawMaterialName14 { get; set; } = "";
}
}

+ 32
- 0
BPASmartClient.JXJFoodBigStation/Model/PlcVarMonitor.cs View File

@@ -0,0 +1,32 @@
using Microsoft.Toolkit.Mvvm.ComponentModel;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BPASmartClient.JXJFoodBigStation.Model
{
public class PlcVarMonitor: ObservableObject
{
private int _serialNum;
public int SerialNum { get { return _serialNum; } set { _serialNum = value;OnPropertyChanged(); } }

private string _variable;
public string Variable { get { return _variable; } set { _variable = value; OnPropertyChanged(); } }

private string _address;
public string Address { get { return _address; } set { _address = value; OnPropertyChanged(); } }

private string _type;
public string Type { get { return _type; } set { _type = value; OnPropertyChanged(); } }

private string _describe;
public string Describe { get { return _describe; } set { _describe = value; OnPropertyChanged(); } }

private string _nowValue;
public string NowValue { get { return _nowValue; } set { _nowValue = value; OnPropertyChanged(); } }
private string _setValue;
public string SetValue { get { return _setValue; } set { _setValue = value; OnPropertyChanged(); } }
}
}

+ 583
- 115
BPASmartClient.JXJFoodBigStation/Model/ProcessControl.cs View File

@@ -24,27 +24,47 @@ namespace BPASmartClient.JXJFoodBigStation.Model
public HKDeviceStatus HKDevice = new HKDeviceStatus();
DL_Finish_DB FinishData = new DL_Finish_DB();
/// <summary>
/// 配方数据
/// 西门子配方数据
/// </summary>
public ObservableCollection<RecipeData> Recipes = new ObservableCollection<RecipeData>();
public ObservableCollection<RecipeData> SiemensRecipes = new ObservableCollection<RecipeData>();
/// <summary>
/// 配方数据
/// 本地配方数据
/// </summary>
public ObservableCollection<RecipeData> IssuedComplete = new ObservableCollection<RecipeData>();
public ObservableCollection<RecipeData> LocalRecipes = new ObservableCollection<RecipeData>();

/// <summary>
/// 配方等待执行
/// </summary>
public ObservableCollection<RecipeData> RecipeWaitExecute = new ObservableCollection<RecipeData>();
/// <summary>
/// 配方正在执行
/// </summary>
public ObservableCollection<RecipeData> RecipeExecuting = new ObservableCollection<RecipeData>();
/// <summary>
/// 配方执行完成
/// </summary>
public ObservableCollection<RecipeData> RecipeExecuteComple = new ObservableCollection<RecipeData>();
/// <summary>
/// 原料的名称和料仓的位置对应
/// </summary>
public Dictionary<string, short> RawMaterialsNamePos = new Dictionary<string, short>();
/// <summary>
/// 配方队列
/// 西门子配方队列
/// </summary>
public ConcurrentQueue<string> RecipeQueue1 = new ConcurrentQueue<string>();
public ConcurrentQueue<string> RecipeQueue2 = new ConcurrentQueue<string>();
public ConcurrentQueue<string> RecipeQueue3 = new ConcurrentQueue<string>();
public ConcurrentQueue<string> RecipeQueue4 = new ConcurrentQueue<string>();
public ConcurrentQueue<string> SiemensRecipeQueue1 = new ConcurrentQueue<string>();
public ConcurrentQueue<string> SiemensRecipeQueue2 = new ConcurrentQueue<string>();
public ConcurrentQueue<string> SiemensRecipeQueue3 = new ConcurrentQueue<string>();
public ConcurrentQueue<string> SiemensRecipeQueue4 = new ConcurrentQueue<string>();
/// <summary>
/// 本地配方队列
/// </summary>
public ConcurrentQueue<string> LocalRecipeQueue1 = new ConcurrentQueue<string>();
public ConcurrentQueue<string> LocalRecipeQueue2 = new ConcurrentQueue<string>();
public ConcurrentQueue<string> LocalRecipeQueue3 = new ConcurrentQueue<string>();
public ConcurrentQueue<string> LocalRecipeQueue4 = new ConcurrentQueue<string>();
public void Init()
{
testData();
testRawMaterialNameData();//自定义料仓名称
ActionManage.GetInstance.CancelRegister("SiemensSendRecipe");
ActionManage.GetInstance.Register(new Action<object>((res) =>
{
@@ -68,7 +88,7 @@ namespace BPASmartClient.JXJFoodBigStation.Model
}
else
{
//报警,配方的原料名称下发和设备不一致
MessageNotify.GetInstance.ShowAlarmLog($"本地原料名称和西门子下发的原料名称无法对应,原料位置:{i}");
}
}
App.Current.Dispatcher.Invoke(() =>
@@ -89,13 +109,13 @@ namespace BPASmartClient.JXJFoodBigStation.Model
try
{
//HKDevice.HK_PLC_S7.Connect(S7.Net.CpuType.S71500, HK_PLC_IP);
SiemensDevice.Siemens_PLC_S7.Connect(S7.Net.CpuType.S71500, Siemens_PLC_IP);
//SiemensDevice.Siemens_PLC_S7.Connect(S7.Net.CpuType.S71500, Siemens_PLC_IP);
if (HKDevice.IsConnected)
{
HKDevice.Init();
MessageNotify.GetInstance.ShowRunLog("海科plc连接成功");
}
if (SiemensDevice.IsConnected || true)
if (SiemensDevice.IsConnected)
{
SiemensDevice.Init();
MessageNotify.GetInstance.ShowRunLog("西门子plc连接成功");
@@ -105,39 +125,480 @@ namespace BPASmartClient.JXJFoodBigStation.Model
{

}
RecipeQueue1.Clear();
RecipeQueue2.Clear();
RecipeQueue3.Clear();
RecipeQueue4.Clear();
LocalRecipeQueue1.Clear();
LocalRecipeQueue2.Clear();
LocalRecipeQueue3.Clear();
LocalRecipeQueue4.Clear();
SiemensRecipeQueue1.Clear();
SiemensRecipeQueue2.Clear();
SiemensRecipeQueue3.Clear();
SiemensRecipeQueue4.Clear();
ThreadManage.GetInstance().StartLong(new Action(() =>
{
SystemStatus();
ReceviceData();
RecipeInfoToHKPLC();
Thread.Sleep(10);
}), "流程处理", true);
}), "西门子配方执行流程", true);
ThreadManage.GetInstance().StartLong(new Action(() =>
{
if (GVL_BigStation.IsUseLocalRecipe)
{
LocalRecipeRecevice();
LocalRecipeDosing();
}
Thread.Sleep(10);
}), "本地配方执行流程", true);
}
private void SystemStatus()
{
GVL_BigStation.HeartBeatFromPlc = HKDevice.PlcRead.HeartBeat;//读取plc心跳
private void LocalRecipeRecevice()
{
if (LocalRecipes.Count > 0)
{
foreach (var data in LocalRecipes)
{
if (LocalRecipeQueue1.Count == 0 && !LocalRecipeQueue2.Contains(data.RecipeCode) && !LocalRecipeQueue3.Contains(data.RecipeCode) && !LocalRecipeQueue4.Contains(data.RecipeCode))
{
if (!(LocalRecipeQueue1.Contains(data.RecipeCode)))
{
LocalRecipeQueue1.Enqueue(data.RecipeCode);
}
}
else if (LocalRecipeQueue2.Count == 0 && !LocalRecipeQueue1.Contains(data.RecipeCode) && !LocalRecipeQueue3.Contains(data.RecipeCode) && !LocalRecipeQueue4.Contains(data.RecipeCode))
{
if (!(LocalRecipeQueue2.Contains(data.RecipeCode)))
{
LocalRecipeQueue2.Enqueue(data.RecipeCode);
}
}
else if (LocalRecipeQueue3.Count == 0 && !LocalRecipeQueue1.Contains(data.RecipeCode) && !LocalRecipeQueue2.Contains(data.RecipeCode) && !LocalRecipeQueue4.Contains(data.RecipeCode))
{
if (!(LocalRecipeQueue3.Contains(data.RecipeCode)))
{
LocalRecipeQueue3.Enqueue(data.RecipeCode);
}
}
else if (LocalRecipeQueue4.Count == 0 && !LocalRecipeQueue1.Contains(data.RecipeCode) && !LocalRecipeQueue2.Contains(data.RecipeCode) && !LocalRecipeQueue3.Contains(data.RecipeCode))
{
if (!(LocalRecipeQueue4.Contains(data.RecipeCode)))
{
LocalRecipeQueue4.Enqueue(data.RecipeCode);
}
}
}
}
else
{
LocalRecipeQueue1.Clear();
LocalRecipeQueue2.Clear();
LocalRecipeQueue3.Clear();
LocalRecipeQueue4.Clear();
GVL_BigStation.Recipe1DosingStatus = 0;
GVL_BigStation.Recipe2DosingStatus = 0;
GVL_BigStation.Recipe3DosingStatus = 0;
GVL_BigStation.Recipe4DosingStatus = 0;
}
}
private void ReceviceData()
private void LocalRecipeDosing()
{
if (!GVL_BigStation.IsUseLocalRecipe && Recipes.Count == 0)//一个配方执行完成后,再获取配方数据
if (LocalRecipeQueue1.Count > 0)
{
int index = Array.FindIndex(LocalRecipes.ToArray(), p => p.RecipeCode == LocalRecipeQueue1.ElementAt(0));
if (index >= 0 && index < LocalRecipes.Count)
{
string code = LocalRecipes.ElementAt(index).RecipeCode;
int trayCode = LocalRecipes.ElementAt(index).TrayCode;
if (HKDevice.PlcRead.IsAllowIssueRecipe1 && GVL_BigStation.Recipe1DosingStatus == 0)//配方1是否允许下发配发
{
HKDevice.StockBinPar(LocalRecipes.ElementAt(index));
HKDevice.PlcWrite.Recipe1IssuedFinish = true;
GVL_BigStation.Recipe1DosingStatus = 1;
MessageNotify.GetInstance.ShowRunLog($"配方编号:{code},托盘编号:{trayCode},下发完成");
}
if (HKDevice.PlcRead.ReceiveFinishRecipe1 && GVL_BigStation.Recipe1DosingStatus == 1)
{
GVL_BigStation.Recipe1DosingStatus = 2;
HKDevice.PlcWrite.Recipe1IssuedFinish = false;
StockBinParReset();
MessageNotify.GetInstance.ShowRunLog($"配方编号:{code},托盘编号:{trayCode},PLC接收配方完成");
}
if (GVL_BigStation.Recipe1DosingStatus == 2 && HKDevice.PlcRead.Recipe1DosingFinish)
{
GVL_BigStation.Recipe1DosingStatus = 3;
MessageNotify.GetInstance.ShowRunLog($"配方状态:{code}配料完成");
if (HKDevice.PlcRead.Recipe1TrayCode == 1)
{
foreach (var item in LocalRecipes.ElementAt(index).RawMaterial)
{
if (item.RawMaterialLocation == 1)
{
item.Laying_Off_Weight = HKDevice.PlcRead.StockBin1ActualWeight;
}
else if (item.RawMaterialLocation == 2)
{
item.Laying_Off_Weight = HKDevice.PlcRead.StockBin2ActualWeight;
}
else if (item.RawMaterialLocation == 3)
{
item.Laying_Off_Weight = HKDevice.PlcRead.StockBin3ActualWeight;
}
else if (item.RawMaterialLocation == 4)
{
item.Laying_Off_Weight = HKDevice.PlcRead.StockBin4ActualWeight;
}
else if (item.RawMaterialLocation == 5)
{
item.Laying_Off_Weight = HKDevice.PlcRead.StockBin5ActualWeight;
}
else if (item.RawMaterialLocation == 6)
{
item.Laying_Off_Weight = HKDevice.PlcRead.StockBin6ActualWeight;
}
else if (item.RawMaterialLocation == 7)
{
item.Laying_Off_Weight = HKDevice.PlcRead.StockBin7ActualWeight;
}
else if (item.RawMaterialLocation == 8)
{
item.Laying_Off_Weight = HKDevice.PlcRead.StockBin8ActualWeight;
}
else if (item.RawMaterialLocation == 9)
{
item.Laying_Off_Weight = HKDevice.PlcRead.StockBin9ActualWeight;
}
else if (item.RawMaterialLocation == 10)
{
item.Laying_Off_Weight = HKDevice.PlcRead.StockBin10ActualWeight;
}
else if (item.RawMaterialLocation == 11)
{
item.Laying_Off_Weight = HKDevice.PlcRead.StockBin11ActualWeight;
}
else if (item.RawMaterialLocation == 12)
{
item.Laying_Off_Weight = HKDevice.PlcRead.StockBin12ActualWeight;
}
else if (item.RawMaterialLocation == 13)
{
item.Laying_Off_Weight = HKDevice.PlcRead.StockBin13ActualWeight;
}
else if (item.RawMaterialLocation == 14)
{
item.Laying_Off_Weight = HKDevice.PlcRead.StockBin14ActualWeight;
}
}
}
LocalRecipeQueue1.TryDequeue(out code);
RecipeExecuteComple.Add(LocalRecipes.ElementAt(index));//将配方添加到完成列表
//App.Current.Dispatcher.Invoke(() => {
// Json<LocalRecipe>.Data.Recipes.RemoveAt(index);//制作完成,移除当前配方
//});
LocalRecipes.RemoveAt(index);
GVL_BigStation.Recipe1DosingStatus = 0;
}
}
}
if (LocalRecipeQueue2.Count > 0)
{
int index = Array.FindIndex(LocalRecipes.ToArray(), p => p.RecipeCode == LocalRecipeQueue2.ElementAt(0));
if (index >= 0 && index < LocalRecipes.Count)
{
string code = LocalRecipes.ElementAt(index).RecipeCode;
int trayCode = LocalRecipes.ElementAt(index).TrayCode;
if (HKDevice.PlcRead.IsAllowIssueRecipe2 && GVL_BigStation.Recipe2DosingStatus == 0)//配方2是否允许下发配发
{
HKDevice.StockBinPar(LocalRecipes.ElementAt(index));
HKDevice.PlcWrite.Recipe2IssuedFinish = true;
GVL_BigStation.Recipe2DosingStatus = 1;
MessageNotify.GetInstance.ShowRunLog($"配方状态:{code}下发完成");
}
if (HKDevice.PlcRead.ReceiveFinishRecipe2 && GVL_BigStation.Recipe2DosingStatus == 1)
{
GVL_BigStation.Recipe2DosingStatus = 2;
HKDevice.PlcWrite.Recipe2IssuedFinish = false;
StockBinParReset();
MessageNotify.GetInstance.ShowRunLog($"配方状态:{code}配方配料");
}
if (GVL_BigStation.Recipe2DosingStatus == 2 && HKDevice.PlcRead.Recipe2DosingFinish)
{
GVL_BigStation.Recipe2DosingStatus = 3;
MessageNotify.GetInstance.ShowRunLog($"配方状态:{code}配料完成");
if (HKDevice.PlcRead.Recipe2TrayCode > 0)
{
foreach (var item in LocalRecipes.ElementAt(index).RawMaterial)
{
if (item.RawMaterialLocation == 1)
{
item.Laying_Off_Weight = HKDevice.PlcRead.StockBin1ActualWeight;
}
else if (item.RawMaterialLocation == 2)
{
item.Laying_Off_Weight = HKDevice.PlcRead.StockBin2ActualWeight;
}
else if (item.RawMaterialLocation == 3)
{
item.Laying_Off_Weight = HKDevice.PlcRead.StockBin3ActualWeight;
}
else if (item.RawMaterialLocation == 4)
{
item.Laying_Off_Weight = HKDevice.PlcRead.StockBin4ActualWeight;
}
else if (item.RawMaterialLocation == 5)
{
item.Laying_Off_Weight = HKDevice.PlcRead.StockBin5ActualWeight;
}
else if (item.RawMaterialLocation == 6)
{
item.Laying_Off_Weight = HKDevice.PlcRead.StockBin6ActualWeight;
}
else if (item.RawMaterialLocation == 7)
{
item.Laying_Off_Weight = HKDevice.PlcRead.StockBin7ActualWeight;
}
else if (item.RawMaterialLocation == 8)
{
item.Laying_Off_Weight = HKDevice.PlcRead.StockBin8ActualWeight;
}
else if (item.RawMaterialLocation == 9)
{
item.Laying_Off_Weight = HKDevice.PlcRead.StockBin9ActualWeight;
}
else if (item.RawMaterialLocation == 10)
{
item.Laying_Off_Weight = HKDevice.PlcRead.StockBin10ActualWeight;
}
else if (item.RawMaterialLocation == 11)
{
item.Laying_Off_Weight = HKDevice.PlcRead.StockBin11ActualWeight;
}
else if (item.RawMaterialLocation == 12)
{
item.Laying_Off_Weight = HKDevice.PlcRead.StockBin12ActualWeight;
}
else if (item.RawMaterialLocation == 13)
{
item.Laying_Off_Weight = HKDevice.PlcRead.StockBin13ActualWeight;
}
else if (item.RawMaterialLocation == 14)
{
item.Laying_Off_Weight = HKDevice.PlcRead.StockBin14ActualWeight;
}
}
}
LocalRecipeQueue2.TryDequeue(out code);
RecipeExecuteComple.Add(LocalRecipes.ElementAt(index));//将该配方添加到下
//App.Current.Dispatcher.Invoke(() => {
// Json<LocalRecipe>.Data.Recipes.RemoveAt(index);//制作完成,移除当前配方
//});
LocalRecipes.RemoveAt(index);
GVL_BigStation.Recipe2DosingStatus = 0;
}
}
}
if (LocalRecipeQueue3.Count > 0)
{
Recipes = Json<RemoteRecipe>.Data.Recipes;
int index = Array.FindIndex(LocalRecipes.ToArray(), p => p.RecipeCode == LocalRecipeQueue3.ElementAt(0));
if (index >= 0 && index < LocalRecipes.Count)
{
string code = LocalRecipes.ElementAt(index).RecipeCode;
int trayCode = LocalRecipes.ElementAt(index).TrayCode;
if (HKDevice.PlcRead.IsAllowIssueRecipe3 && GVL_BigStation.Recipe3DosingStatus == 0)//配方3是否允许下发配发
{
HKDevice.StockBinPar(LocalRecipes.ElementAt(index));
HKDevice.PlcWrite.Recipe3IssuedFinish = true;
GVL_BigStation.Recipe3DosingStatus = 1;
MessageNotify.GetInstance.ShowRunLog($"配方状态:{code}下发完成");
}
if (HKDevice.PlcRead.ReceiveFinishRecipe3 && GVL_BigStation.Recipe3DosingStatus == 1)
{
GVL_BigStation.Recipe3DosingStatus = 2;
StockBinParReset();
MessageNotify.GetInstance.ShowRunLog($"配方状态:{code}配方配料");
}
if (HKDevice.PlcRead.Recipe3DosingFinish && GVL_BigStation.Recipe3DosingStatus == 2)
{
GVL_BigStation.Recipe3DosingStatus = 3;
MessageNotify.GetInstance.ShowRunLog($"配方状态:{code}配料完成");
if (HKDevice.PlcRead.Recipe3TrayCode > 0)
{
foreach (var item in LocalRecipes.ElementAt(index).RawMaterial)
{
if (item.RawMaterialLocation == 1)
{
item.Laying_Off_Weight = HKDevice.PlcRead.StockBin1ActualWeight;
}
else if (item.RawMaterialLocation == 2)
{
item.Laying_Off_Weight = HKDevice.PlcRead.StockBin2ActualWeight;
}
else if (item.RawMaterialLocation == 3)
{
item.Laying_Off_Weight = HKDevice.PlcRead.StockBin3ActualWeight;
}
else if (item.RawMaterialLocation == 4)
{
item.Laying_Off_Weight = HKDevice.PlcRead.StockBin4ActualWeight;
}
else if (item.RawMaterialLocation == 5)
{
item.Laying_Off_Weight = HKDevice.PlcRead.StockBin5ActualWeight;
}
else if (item.RawMaterialLocation == 6)
{
item.Laying_Off_Weight = HKDevice.PlcRead.StockBin6ActualWeight;
}
else if (item.RawMaterialLocation == 7)
{
item.Laying_Off_Weight = HKDevice.PlcRead.StockBin7ActualWeight;
}
else if (item.RawMaterialLocation == 8)
{
item.Laying_Off_Weight = HKDevice.PlcRead.StockBin8ActualWeight;
}
else if (item.RawMaterialLocation == 9)
{
item.Laying_Off_Weight = HKDevice.PlcRead.StockBin9ActualWeight;
}
else if (item.RawMaterialLocation == 10)
{
item.Laying_Off_Weight = HKDevice.PlcRead.StockBin10ActualWeight;
}
else if (item.RawMaterialLocation == 11)
{
item.Laying_Off_Weight = HKDevice.PlcRead.StockBin11ActualWeight;
}
else if (item.RawMaterialLocation == 12)
{
item.Laying_Off_Weight = HKDevice.PlcRead.StockBin12ActualWeight;
}
else if (item.RawMaterialLocation == 13)
{
item.Laying_Off_Weight = HKDevice.PlcRead.StockBin13ActualWeight;
}
else if (item.RawMaterialLocation == 14)
{
item.Laying_Off_Weight = HKDevice.PlcRead.StockBin14ActualWeight;
}
}
}
HKDevice.HK_PLC_S7.Write<bool>("DB98.DBX1.1", false);
LocalRecipeQueue3.TryDequeue(out code);
RecipeExecuteComple.Add(LocalRecipes.ElementAt(index));//将该配方添加到下
//App.Current.Dispatcher.Invoke(() => {
// Json<LocalRecipe>.Data.Recipes.RemoveAt(index);//制作完成,移除当前配方
//});
LocalRecipes.RemoveAt(index);
GVL_BigStation.Recipe3DosingStatus = 0;
}
}
}
else if (GVL_BigStation.IsUseLocalRecipe && Recipes.Count == 0)
if (LocalRecipeQueue4.Count > 0)
{
Recipes = Json<LocalRecipe>.Data.Recipes;
int index = Array.FindIndex(LocalRecipes.ToArray(), p => p.RecipeCode == LocalRecipeQueue4.ElementAt(0));
if (index >= 0 && index < LocalRecipes.Count)
{
string code = LocalRecipes.ElementAt(index).RecipeCode;
int trayCode = LocalRecipes.ElementAt(index).TrayCode;
if (HKDevice.PlcRead.IsAllowIssueRecipe4 && GVL_BigStation.Recipe4DosingStatus == 0)//配方4是否允许下发配发
{
HKDevice.StockBinPar(LocalRecipes.ElementAt(index));
HKDevice.PlcWrite.Recipe4IssuedFinish = true;
GVL_BigStation.Recipe4DosingStatus = 1;
MessageNotify.GetInstance.ShowRunLog($"配方状态:{code}下发完成");
}
if (HKDevice.PlcRead.ReceiveFinishRecipe4 && GVL_BigStation.Recipe4DosingStatus == 1)
{
GVL_BigStation.Recipe4DosingStatus = 2;
HKDevice.PlcWrite.Recipe4IssuedFinish = false;
StockBinParReset();
MessageNotify.GetInstance.ShowRunLog($"配方状态:{code}配方配料");
}
if (GVL_BigStation.Recipe4DosingStatus == 2 && HKDevice.PlcRead.Recipe4DosingFinish)
{
GVL_BigStation.Recipe4DosingStatus = 3;
MessageNotify.GetInstance.ShowRunLog($"配方状态:{code}配料完成");
if (HKDevice.PlcRead.Recipe4TrayCode > 0)
{
foreach (var item in LocalRecipes.ElementAt(index).RawMaterial)
{
if (item.RawMaterialLocation == 1)
{
item.Laying_Off_Weight = HKDevice.PlcRead.StockBin1ActualWeight;
}
else if (item.RawMaterialLocation == 2)
{
item.Laying_Off_Weight = HKDevice.PlcRead.StockBin2ActualWeight;
}
else if (item.RawMaterialLocation == 3)
{
item.Laying_Off_Weight = HKDevice.PlcRead.StockBin3ActualWeight;
}
else if (item.RawMaterialLocation == 4)
{
item.Laying_Off_Weight = HKDevice.PlcRead.StockBin4ActualWeight;
}
else if (item.RawMaterialLocation == 5)
{
item.Laying_Off_Weight = HKDevice.PlcRead.StockBin5ActualWeight;
}
else if (item.RawMaterialLocation == 6)
{
item.Laying_Off_Weight = HKDevice.PlcRead.StockBin6ActualWeight;
}
else if (item.RawMaterialLocation == 7)
{
item.Laying_Off_Weight = HKDevice.PlcRead.StockBin7ActualWeight;
}
else if (item.RawMaterialLocation == 8)
{
item.Laying_Off_Weight = HKDevice.PlcRead.StockBin8ActualWeight;
}
else if (item.RawMaterialLocation == 9)
{
item.Laying_Off_Weight = HKDevice.PlcRead.StockBin9ActualWeight;
}
else if (item.RawMaterialLocation == 10)
{
item.Laying_Off_Weight = HKDevice.PlcRead.StockBin10ActualWeight;
}
else if (item.RawMaterialLocation == 11)
{
item.Laying_Off_Weight = HKDevice.PlcRead.StockBin11ActualWeight;
}
else if (item.RawMaterialLocation == 12)
{
item.Laying_Off_Weight = HKDevice.PlcRead.StockBin12ActualWeight;
}
else if (item.RawMaterialLocation == 13)
{
item.Laying_Off_Weight = HKDevice.PlcRead.StockBin13ActualWeight;
}
else if (item.RawMaterialLocation == 14)
{
item.Laying_Off_Weight = HKDevice.PlcRead.StockBin14ActualWeight;
}
}
}
HKDevice.HK_PLC_S7.Write<bool>("DB98.DBX1.3", false);
LocalRecipeQueue4.TryDequeue(out code);
RecipeExecuteComple.Add(LocalRecipes.ElementAt(index));//将该配方添加到下
//App.Current.Dispatcher.Invoke(() => {
// Json<LocalRecipe>.Data.Recipes.RemoveAt(index);//制作完成,移除当前配方
//});
LocalRecipes.RemoveAt(index);
GVL_BigStation.Recipe4DosingStatus = 0;
}
}
}
if (Recipes.Count > 0)
}
private void ReceviceData()
{
SiemensRecipes = Json<RemoteRecipe>.Data.Recipes;
if (SiemensRecipes.Count > 0)
{
foreach (var data in Recipes)
foreach (var data in SiemensRecipes)
{
if (RecipeQueue1.Count == 0 && !RecipeQueue2.Contains(data.RecipeCode) && !RecipeQueue3.Contains(data.RecipeCode) && !RecipeQueue4.Contains(data.RecipeCode))
if (SiemensRecipeQueue1.Count == 0 && !SiemensRecipeQueue2.Contains(data.RecipeCode) && !SiemensRecipeQueue3.Contains(data.RecipeCode) && !SiemensRecipeQueue4.Contains(data.RecipeCode))
{
if (!(RecipeQueue1.Contains(data.RecipeCode)))
if (!(SiemensRecipeQueue1.Contains(data.RecipeCode)))
{
if (SiemensDevice.DL_Status is DL_Status_DB status)
{
@@ -161,16 +622,15 @@ namespace BPASmartClient.JXJFoodBigStation.Model
if (SiemensDevice.DL_Status.Dosing_Start_ACK == false)
{
GVL_BigStation.SiemensSendRecipeStatus = 6;
RecipeQueue1.Enqueue(data.RecipeCode);
SiemensRecipeQueue1.Enqueue(data.RecipeCode);
}
}
}

}
}
else if (RecipeQueue2.Count == 0 && !RecipeQueue1.Contains(data.RecipeCode) && !RecipeQueue3.Contains(data.RecipeCode) && !RecipeQueue4.Contains(data.RecipeCode))
else if (SiemensRecipeQueue2.Count == 0 && !SiemensRecipeQueue1.Contains(data.RecipeCode) && !SiemensRecipeQueue3.Contains(data.RecipeCode) && !SiemensRecipeQueue4.Contains(data.RecipeCode))
{
if (!(RecipeQueue2.Contains(data.RecipeCode)))
if (!(SiemensRecipeQueue2.Contains(data.RecipeCode)))
{
if (SiemensDevice.DL_Status is DL_Status_DB status)
{
@@ -194,15 +654,15 @@ namespace BPASmartClient.JXJFoodBigStation.Model
if (SiemensDevice.DL_Status.Dosing_Start_ACK == false)
{
GVL_BigStation.SiemensSendRecipeStatus = 6;
RecipeQueue2.Enqueue(data.RecipeCode);
SiemensRecipeQueue2.Enqueue(data.RecipeCode);
}
}
}
}
}
else if (RecipeQueue3.Count == 0 && !RecipeQueue1.Contains(data.RecipeCode) && !RecipeQueue2.Contains(data.RecipeCode) && !RecipeQueue4.Contains(data.RecipeCode))
else if (SiemensRecipeQueue3.Count == 0 && !SiemensRecipeQueue1.Contains(data.RecipeCode) && !SiemensRecipeQueue2.Contains(data.RecipeCode) && !SiemensRecipeQueue4.Contains(data.RecipeCode))
{
if (!(RecipeQueue3.Contains(data.RecipeCode)))
if (!(SiemensRecipeQueue3.Contains(data.RecipeCode)))
{
if (SiemensDevice.DL_Status is DL_Status_DB status)
{
@@ -226,15 +686,15 @@ namespace BPASmartClient.JXJFoodBigStation.Model
if (SiemensDevice.DL_Status.Dosing_Start_ACK == false)
{
GVL_BigStation.SiemensSendRecipeStatus = 6;
RecipeQueue3.Enqueue(data.RecipeCode);
SiemensRecipeQueue3.Enqueue(data.RecipeCode);
}
}
}
}
}
else if (RecipeQueue4.Count == 0 && !RecipeQueue1.Contains(data.RecipeCode) && !RecipeQueue2.Contains(data.RecipeCode) && !RecipeQueue3.Contains(data.RecipeCode))
else if (SiemensRecipeQueue4.Count == 0 && !SiemensRecipeQueue1.Contains(data.RecipeCode) && !SiemensRecipeQueue2.Contains(data.RecipeCode) && !SiemensRecipeQueue3.Contains(data.RecipeCode))
{
if (!(RecipeQueue4.Contains(data.RecipeCode)))
if (!(SiemensRecipeQueue4.Contains(data.RecipeCode)))
{
if (SiemensDevice.DL_Status is DL_Status_DB status)
{
@@ -258,7 +718,7 @@ namespace BPASmartClient.JXJFoodBigStation.Model
if (SiemensDevice.DL_Status.Dosing_Start_ACK == false)
{
GVL_BigStation.SiemensSendRecipeStatus = 6;
RecipeQueue4.Enqueue(data.RecipeCode);
SiemensRecipeQueue4.Enqueue(data.RecipeCode);
}
}
}
@@ -268,10 +728,10 @@ namespace BPASmartClient.JXJFoodBigStation.Model
}
else
{
RecipeQueue1.Clear();
RecipeQueue2.Clear();
RecipeQueue3.Clear();
RecipeQueue4.Clear();
SiemensRecipeQueue1.Clear();
SiemensRecipeQueue2.Clear();
SiemensRecipeQueue3.Clear();
SiemensRecipeQueue4.Clear();
GVL_BigStation.Recipe1DosingStatus = 0;
GVL_BigStation.Recipe2DosingStatus = 0;
GVL_BigStation.Recipe3DosingStatus = 0;
@@ -280,16 +740,16 @@ namespace BPASmartClient.JXJFoodBigStation.Model
}
private void RecipeInfoToHKPLC()
{
if (RecipeQueue1.Count > 0)
if (SiemensRecipeQueue1.Count > 0)
{
int index = Array.FindIndex(Recipes.ToArray(), p => p.RecipeCode == RecipeQueue1.ElementAt(0));
if (index >= 0 && index < Recipes.Count)
int index = Array.FindIndex(SiemensRecipes.ToArray(), p => p.RecipeCode == SiemensRecipeQueue1.ElementAt(0));
if (index >= 0 && index < SiemensRecipes.Count)
{
string code = Recipes.ElementAt(index).RecipeCode;
int trayCode = Recipes.ElementAt(index).TrayCode;
string code = SiemensRecipes.ElementAt(index).RecipeCode;
int trayCode = SiemensRecipes.ElementAt(index).TrayCode;
if (HKDevice.PlcRead.IsAllowIssueRecipe1 && GVL_BigStation.Recipe1DosingStatus == 0)//配方1是否允许下发配发
{
HKDevice.StockBinPar(Recipes.ElementAt(index));
HKDevice.StockBinPar(SiemensRecipes.ElementAt(index));
HKDevice.PlcWrite.Recipe1IssuedFinish = true;
GVL_BigStation.Recipe1DosingStatus = 1;
MessageNotify.GetInstance.ShowRunLog($"配方编号:{code},托盘编号:{trayCode},下发完成");
@@ -307,7 +767,7 @@ namespace BPASmartClient.JXJFoodBigStation.Model
MessageNotify.GetInstance.ShowRunLog($"配方状态:{code}配料完成");
if (HKDevice.PlcRead.Recipe1TrayCode == 1)
{
foreach (var item in Recipes.ElementAt(index).RawMaterial)
foreach (var item in SiemensRecipes.ElementAt(index).RawMaterial)
{
if (item.RawMaterialLocation == 1)
{
@@ -367,27 +827,27 @@ namespace BPASmartClient.JXJFoodBigStation.Model
}
}
}
FinishData.Order_No = Recipes.ElementAt(index).RecipeCode;
FinishData.Product_Code = Recipes.ElementAt(index).RecipeName;
FinishData.job_No =(short) Recipes.ElementAt(index).TrayCode;
for (int i = 0; i < FinishData.Material.Length; i++)
{
FinishData.Material[i] = new UDT1();
}
for (int i = 0; i < Recipes.ElementAt(index).RawMaterial.Count; i++)
{
FinishData.Material[i].Material_Name = Recipes.ElementAt(index).RawMaterial.ElementAt(i).RawMaterialName;
FinishData.Material[i].Material_BarrelNum = (short)Recipes.ElementAt(index).RawMaterial.ElementAt(i).RawMaterialBarrelNum;
FinishData.Material[i].Material_Laying_Off_Weight = Recipes.ElementAt(index).RawMaterial.ElementAt(i).Laying_Off_Weight;
}
if (SiemensDevice.IsConnected)
{
FinishData.Order_No = SiemensRecipes.ElementAt(index).RecipeCode;
FinishData.Product_Code = SiemensRecipes.ElementAt(index).RecipeName;
FinishData.job_No = (short)SiemensRecipes.ElementAt(index).TrayCode;
for (int i = 0; i < FinishData.Material.Length; i++)
{
FinishData.Material[i] = new UDT1();
}
for (int i = 0; i < SiemensRecipes.ElementAt(index).RawMaterial.Count; i++)
{
FinishData.Material[i].Material_Name = SiemensRecipes.ElementAt(index).RawMaterial.ElementAt(i).RawMaterialName;
FinishData.Material[i].Material_BarrelNum = (short)SiemensRecipes.ElementAt(index).RawMaterial.ElementAt(i).RawMaterialBarrelNum;
FinishData.Material[i].Material_Laying_Off_Weight = SiemensRecipes.ElementAt(index).RawMaterial.ElementAt(i).Laying_Off_Weight;
}
FinishData.Ask_For_Finish = true;
GVL_BigStation.SiemensSendRecipeStatus = 7;
SiemensDevice.Siemens_PLC_S7.WriteClass<DL_Finish_DB>(FinishData, 2361);
}
RecipeQueue1.TryDequeue(out code);
IssuedComplete.Add(Recipes.ElementAt(index));//将配方添加到完成列表
SiemensRecipeQueue1.TryDequeue(out code);
RecipeExecuteComple.Add(SiemensRecipes.ElementAt(index));//将配方添加到完成列表
if (!GVL_BigStation.IsUseLocalRecipe)
{
App.Current.Dispatcher.Invoke(() => {
@@ -404,16 +864,16 @@ namespace BPASmartClient.JXJFoodBigStation.Model
}
}
}
if (RecipeQueue2.Count > 0)
if (SiemensRecipeQueue2.Count > 0)
{
int index = Array.FindIndex(Recipes.ToArray(), p => p.RecipeCode == RecipeQueue2.ElementAt(0));
if (index >= 0 && index < Recipes.Count)
int index = Array.FindIndex(SiemensRecipes.ToArray(), p => p.RecipeCode == SiemensRecipeQueue2.ElementAt(0));
if (index >= 0 && index < SiemensRecipes.Count)
{
string code = Recipes.ElementAt(index).RecipeCode;
int trayCode = Recipes.ElementAt(index).TrayCode;
string code = SiemensRecipes.ElementAt(index).RecipeCode;
int trayCode = SiemensRecipes.ElementAt(index).TrayCode;
if (HKDevice.PlcRead.IsAllowIssueRecipe2 && GVL_BigStation.Recipe2DosingStatus == 0)//配方2是否允许下发配发
{
HKDevice.StockBinPar(Recipes.ElementAt(index));
HKDevice.StockBinPar(SiemensRecipes.ElementAt(index));
HKDevice.PlcWrite.Recipe2IssuedFinish = true;
GVL_BigStation.Recipe2DosingStatus = 1;
MessageNotify.GetInstance.ShowRunLog($"配方状态:{code}下发完成");
@@ -431,7 +891,7 @@ namespace BPASmartClient.JXJFoodBigStation.Model
MessageNotify.GetInstance.ShowRunLog($"配方状态:{code}配料完成");
if (HKDevice.PlcRead.Recipe2TrayCode > 0)
{
foreach (var item in Recipes.ElementAt(index).RawMaterial)
foreach (var item in SiemensRecipes.ElementAt(index).RawMaterial)
{
if (item.RawMaterialLocation == 1)
{
@@ -490,14 +950,17 @@ namespace BPASmartClient.JXJFoodBigStation.Model
item.Laying_Off_Weight = HKDevice.PlcRead.StockBin14ActualWeight;
}
}
FinishData.Order_No = Recipes.ElementAt(index).RecipeCode;
FinishData.Product_Code = Recipes.ElementAt(index).RecipeName;
for (int i = 0; i < Recipes.ElementAt(index).RawMaterial.Count; i++)
FinishData.Order_No = SiemensRecipes.ElementAt(index).RecipeCode;
FinishData.Product_Code = SiemensRecipes.ElementAt(index).RecipeName;
for (int i = 0; i < FinishData.Material.Length; i++)
{
FinishData.Material[i] = new UDT1();
FinishData.Material[i].Material_Name = Recipes.ElementAt(index).RawMaterial.ElementAt(i).RawMaterialName;
FinishData.Material[i].Material_BarrelNum = (short)Recipes.ElementAt(index).RawMaterial.ElementAt(i).RawMaterialBarrelNum;
FinishData.Material[i].Material_Laying_Off_Weight = Recipes.ElementAt(index).RawMaterial.ElementAt(i).Laying_Off_Weight;
}
for (int i = 0; i < SiemensRecipes.ElementAt(index).RawMaterial.Count; i++)
{
FinishData.Material[i].Material_Name = SiemensRecipes.ElementAt(index).RawMaterial.ElementAt(i).RawMaterialName;
FinishData.Material[i].Material_BarrelNum = (short)SiemensRecipes.ElementAt(index).RawMaterial.ElementAt(i).RawMaterialBarrelNum;
FinishData.Material[i].Material_Laying_Off_Weight = SiemensRecipes.ElementAt(index).RawMaterial.ElementAt(i).Laying_Off_Weight;
}
}
if (SiemensDevice.IsConnected)
@@ -505,8 +968,8 @@ namespace BPASmartClient.JXJFoodBigStation.Model
SiemensDevice.Siemens_PLC_S7.WriteClass<DL_Finish_DB>(FinishData, 2361);
MessageNotify.GetInstance.ShowRunLog($"配方配料完成,将信号反馈给西门子");
}
RecipeQueue2.TryDequeue(out code);
IssuedComplete.Add(Recipes.ElementAt(index));//将该配方添加到下
SiemensRecipeQueue2.TryDequeue(out code);
RecipeExecuteComple.Add(SiemensRecipes.ElementAt(index));
if (!GVL_BigStation.IsUseLocalRecipe)
{
Json<RemoteRecipe>.Data.Recipes.RemoveAt(index);//制作完成,移除当前配方
@@ -519,16 +982,16 @@ namespace BPASmartClient.JXJFoodBigStation.Model
}
}
}
if (RecipeQueue3.Count > 0)
if (SiemensRecipeQueue3.Count > 0)
{
int index = Array.FindIndex(Recipes.ToArray(), p => p.RecipeCode == RecipeQueue3.ElementAt(0));
if (index >= 0 && index < Recipes.Count)
int index = Array.FindIndex(SiemensRecipes.ToArray(), p => p.RecipeCode == SiemensRecipeQueue3.ElementAt(0));
if (index >= 0 && index < SiemensRecipes.Count)
{
string code = Recipes.ElementAt(index).RecipeCode;
int trayCode = Recipes.ElementAt(index).TrayCode;
string code = SiemensRecipes.ElementAt(index).RecipeCode;
int trayCode = SiemensRecipes.ElementAt(index).TrayCode;
if (HKDevice.PlcRead.IsAllowIssueRecipe3 && GVL_BigStation.Recipe3DosingStatus == 0)//配方3是否允许下发配发
{
HKDevice.StockBinPar(Recipes.ElementAt(index));
HKDevice.StockBinPar(SiemensRecipes.ElementAt(index));
HKDevice.PlcWrite.Recipe3IssuedFinish = true;
GVL_BigStation.Recipe3DosingStatus = 1;
MessageNotify.GetInstance.ShowRunLog($"配方状态:{code}下发完成");
@@ -545,7 +1008,7 @@ namespace BPASmartClient.JXJFoodBigStation.Model
MessageNotify.GetInstance.ShowRunLog($"配方状态:{code}配料完成");
if (HKDevice.PlcRead.Recipe3TrayCode > 0)
{
foreach (var item in Recipes.ElementAt(index).RawMaterial)
foreach (var item in SiemensRecipes.ElementAt(index).RawMaterial)
{
if (item.RawMaterialLocation == 1)
{
@@ -604,14 +1067,17 @@ namespace BPASmartClient.JXJFoodBigStation.Model
item.Laying_Off_Weight = HKDevice.PlcRead.StockBin14ActualWeight;
}
}
FinishData.Order_No = Recipes.ElementAt(index).RecipeCode;
FinishData.Product_Code = Recipes.ElementAt(index).RecipeName;
for (int i = 0; i < Recipes.ElementAt(index).RawMaterial.Count; i++)
FinishData.Order_No = SiemensRecipes.ElementAt(index).RecipeCode;
FinishData.Product_Code = SiemensRecipes.ElementAt(index).RecipeName;
for (int i = 0; i < FinishData.Material.Length; i++)
{
FinishData.Material[i] = new UDT1();
FinishData.Material[i].Material_Name = Recipes.ElementAt(index).RawMaterial.ElementAt(i).RawMaterialName;
FinishData.Material[i].Material_BarrelNum = (short)Recipes.ElementAt(index).RawMaterial.ElementAt(i).RawMaterialBarrelNum;
FinishData.Material[i].Material_Laying_Off_Weight = Recipes.ElementAt(index).RawMaterial.ElementAt(i).Laying_Off_Weight;
}
for (int i = 0; i < SiemensRecipes.ElementAt(index).RawMaterial.Count; i++)
{
FinishData.Material[i].Material_Name = SiemensRecipes.ElementAt(index).RawMaterial.ElementAt(i).RawMaterialName;
FinishData.Material[i].Material_BarrelNum = (short)SiemensRecipes.ElementAt(index).RawMaterial.ElementAt(i).RawMaterialBarrelNum;
FinishData.Material[i].Material_Laying_Off_Weight = SiemensRecipes.ElementAt(index).RawMaterial.ElementAt(i).Laying_Off_Weight;
}
}
if (SiemensDevice.IsConnected)
@@ -619,8 +1085,8 @@ namespace BPASmartClient.JXJFoodBigStation.Model
SiemensDevice.Siemens_PLC_S7.WriteClass<DL_Finish_DB>(FinishData, 2361);
}
HKDevice.HK_PLC_S7.Write<bool>("DB98.DBX1.1", false);
RecipeQueue3.TryDequeue(out code);
IssuedComplete.Add(Recipes.ElementAt(index));//将该配方添加到下
SiemensRecipeQueue3.TryDequeue(out code);
RecipeExecuteComple.Add(SiemensRecipes.ElementAt(index));//将该配方添加到下
if (!GVL_BigStation.IsUseLocalRecipe)
{
Json<RemoteRecipe>.Data.Recipes.RemoveAt(index);//制作完成,移除当前配方
@@ -633,16 +1099,16 @@ namespace BPASmartClient.JXJFoodBigStation.Model
}
}
}
if (RecipeQueue4.Count > 0)
if (SiemensRecipeQueue4.Count > 0)
{
int index = Array.FindIndex(Recipes.ToArray(), p => p.RecipeCode == RecipeQueue4.ElementAt(0));
if (index >= 0 && index < Recipes.Count)
int index = Array.FindIndex(SiemensRecipes.ToArray(), p => p.RecipeCode == SiemensRecipeQueue4.ElementAt(0));
if (index >= 0 && index < SiemensRecipes.Count)
{
string code = Recipes.ElementAt(index).RecipeCode;
int trayCode = Recipes.ElementAt(index).TrayCode;
string code = SiemensRecipes.ElementAt(index).RecipeCode;
int trayCode = SiemensRecipes.ElementAt(index).TrayCode;
if (HKDevice.PlcRead.IsAllowIssueRecipe4 && GVL_BigStation.Recipe4DosingStatus == 0)//配方4是否允许下发配发
{
HKDevice.StockBinPar(Recipes.ElementAt(index));
HKDevice.StockBinPar(SiemensRecipes.ElementAt(index));
HKDevice.PlcWrite.Recipe4IssuedFinish = true;
GVL_BigStation.Recipe4DosingStatus = 1;
MessageNotify.GetInstance.ShowRunLog($"配方状态:{code}下发完成");
@@ -660,7 +1126,7 @@ namespace BPASmartClient.JXJFoodBigStation.Model
MessageNotify.GetInstance.ShowRunLog($"配方状态:{code}配料完成");
if (HKDevice.PlcRead.Recipe4TrayCode > 0)
{
foreach (var item in Recipes.ElementAt(index).RawMaterial)
foreach (var item in SiemensRecipes.ElementAt(index).RawMaterial)
{
if (item.RawMaterialLocation == 1)
{
@@ -719,14 +1185,17 @@ namespace BPASmartClient.JXJFoodBigStation.Model
item.Laying_Off_Weight = HKDevice.PlcRead.StockBin14ActualWeight;
}
}
FinishData.Order_No = Recipes.ElementAt(index).RecipeCode;
FinishData.Product_Code = Recipes.ElementAt(index).RecipeName;
for (int i = 0; i < Recipes.ElementAt(index).RawMaterial.Count; i++)
FinishData.Order_No = SiemensRecipes.ElementAt(index).RecipeCode;
FinishData.Product_Code = SiemensRecipes.ElementAt(index).RecipeName;
for (int i = 0; i < FinishData.Material.Length; i++)
{
FinishData.Material[i] = new UDT1();
FinishData.Material[i].Material_Name = Recipes.ElementAt(index).RawMaterial.ElementAt(i).RawMaterialName;
FinishData.Material[i].Material_BarrelNum = (short)Recipes.ElementAt(index).RawMaterial.ElementAt(i).RawMaterialBarrelNum;
FinishData.Material[i].Material_Laying_Off_Weight = Recipes.ElementAt(index).RawMaterial.ElementAt(i).Laying_Off_Weight;
}
for (int i = 0; i < SiemensRecipes.ElementAt(index).RawMaterial.Count; i++)
{
FinishData.Material[i].Material_Name = SiemensRecipes.ElementAt(index).RawMaterial.ElementAt(i).RawMaterialName;
FinishData.Material[i].Material_BarrelNum = (short)SiemensRecipes.ElementAt(index).RawMaterial.ElementAt(i).RawMaterialBarrelNum;
FinishData.Material[i].Material_Laying_Off_Weight = SiemensRecipes.ElementAt(index).RawMaterial.ElementAt(i).Laying_Off_Weight;
}
}
if (SiemensDevice.IsConnected)
@@ -734,8 +1203,8 @@ namespace BPASmartClient.JXJFoodBigStation.Model
SiemensDevice.Siemens_PLC_S7.WriteClass<DL_Finish_DB>(FinishData, 2361);
}
HKDevice.HK_PLC_S7.Write<bool>("DB98.DBX1.3", false);
RecipeQueue4.TryDequeue(out code);
IssuedComplete.Add(Recipes.ElementAt(index));//将该配方添加到下
SiemensRecipeQueue4.TryDequeue(out code);
RecipeExecuteComple.Add(SiemensRecipes.ElementAt(index));//将该配方添加到下
if (!GVL_BigStation.IsUseLocalRecipe)
{
Json<RemoteRecipe>.Data.Recipes.RemoveAt(index);//制作完成,移除当前配方
@@ -772,7 +1241,6 @@ namespace BPASmartClient.JXJFoodBigStation.Model
HKDevice.PlcWrite.Bareel1Bin13SetWeight = 0;
HKDevice.PlcWrite.Bareel1Bin14SetWeight = 0;


HKDevice.PlcWrite.Bareel2Bin1SetWeight = 0;
HKDevice.PlcWrite.Bareel2Bin2SetWeight = 0;
HKDevice.PlcWrite.Bareel2Bin3SetWeight = 0;
@@ -818,7 +1286,7 @@ namespace BPASmartClient.JXJFoodBigStation.Model
HKDevice.PlcWrite.Bareel5Bin13SetWeight = 0;
HKDevice.PlcWrite.Bareel5Bin14SetWeight = 0;
}
private void testData()
private void testRawMaterialNameData()
{
RawMaterialsNamePos.Clear();
if (!HKDevice.IsConnected)


+ 155
- 0
BPASmartClient.JXJFoodBigStation/View/HKPlcCommMonitorView.xaml View File

@@ -0,0 +1,155 @@
<UserControl x:Class="BPASmartClient.JXJFoodBigStation.View.HKPlcCommMonitorView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:pry="clr-namespace:BPASmartClient.CustomResource.UserControls;assembly=BPASmartClient.CustomResource"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:vm="clr-namespace:BPASmartClient.JXJFoodBigStation.ViewModel"
mc:Ignorable="d"
d:DesignHeight="1080" d:DesignWidth="1920">
<UserControl.DataContext>
<vm:HKPlcCommMonitorViewModel />
</UserControl.DataContext>
<Grid Margin="10">
<Grid.RowDefinitions>
<RowDefinition Height="80" />
<RowDefinition />
</Grid.RowDefinitions>
<!--#region 表格标题栏设置-->
<Grid
Grid.Row="0"
Margin="0,10,0,0"
Background="#ff0C255F">

<Grid.ColumnDefinitions>
<ColumnDefinition Width="1*"/>
<ColumnDefinition Width="1*"/>
<ColumnDefinition Width="1*"/>
<ColumnDefinition Width="1*"/>
<ColumnDefinition Width="1*"/>
<ColumnDefinition Width="1*"/>
<ColumnDefinition Width="1*"/>
<ColumnDefinition Width="1*"/>
</Grid.ColumnDefinitions>
<Grid Grid.Column="0">
<TextBlock Text="序号" FontSize="24" HorizontalAlignment="Center" VerticalAlignment="Center" Foreground="Aqua"/>
<Border BorderThickness="1,0,1,0" Cursor="SizeWE" />
</Grid>
<TextBlock Grid.Column="1" FontSize="24" Text="变量名" HorizontalAlignment="Center" VerticalAlignment="Center" Foreground="Aqua" />
<TextBlock Grid.Column="2" FontSize="24" Text="地址" HorizontalAlignment="Center" VerticalAlignment="Center" Foreground="Aqua" />
<TextBlock Grid.Column="3" FontSize="24" Text="类型" HorizontalAlignment="Center" VerticalAlignment="Center" Foreground="Aqua" />
<Grid Grid.Column="4">
<TextBlock Text="描述" FontSize="24" HorizontalAlignment="Center" VerticalAlignment="Center" Foreground="Aqua" />
<Border BorderThickness="1,0,1,0" Cursor="SizeWE" />
</Grid>
<TextBlock Grid.Column="5" FontSize="24" Text="当前值" HorizontalAlignment="Center" VerticalAlignment="Center" Foreground="Aqua" />
<Grid Grid.Column="6">
<TextBlock Text="设定值" FontSize="24" HorizontalAlignment="Center" VerticalAlignment="Center" Foreground="Aqua" />
<Border BorderThickness="1,0,1,0" Cursor="SizeWE" />
</Grid>
<TextBlock Grid.Column="7" FontSize="24" Text="功能操作" HorizontalAlignment="Center" VerticalAlignment="Center" Foreground="Aqua" />
<Border Grid.ColumnSpan="10" BorderThickness="1,0,1,0" />
</Grid>
<Grid Grid.Row="1">
<ScrollViewer HorizontalScrollBarVisibility="Hidden" VerticalScrollBarVisibility="Hidden" >
<ItemsControl ItemsSource="{Binding PlcInfo}" Foreground="Aqua">
<ItemsControl.ItemTemplate>
<DataTemplate>
<Grid Name="gr" >
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition />
<ColumnDefinition />
<ColumnDefinition />
<ColumnDefinition />
<ColumnDefinition />
<ColumnDefinition />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<Grid Grid.Column="0">
<TextBlock
FontSize="16"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Text="{Binding SerialNum}" />
<Border
BorderThickness="1,0,1,0"
Cursor="SizeWE" />
</Grid>
<Grid Grid.Column="1">
<TextBlock
FontSize="16"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Text="{Binding Variable}" />
<Border
BorderThickness="1,0,1,0"
Cursor="SizeWE" />
</Grid>
<TextBlock
Grid.Column="2"
FontSize="16"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Text="{Binding Address }" />
<TextBlock
Grid.Column="3"
FontSize="16"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Text="{Binding Type }" />
<Grid Grid.Column="4">
<TextBlock
FontSize="16"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Text="{Binding Describe}" />
<Border
BorderThickness="1,0,1,0"
Cursor="SizeWE" />
</Grid>

<TextBlock
HorizontalAlignment="Center"
VerticalAlignment="Center"
Grid.Column="5"
Text="{Binding NowValue}" FontSize="16" />
<Grid Grid.Column="6">
<TextBox
Text="{Binding SetValue}" Foreground="Aqua" Background="Transparent" FontSize="16" VerticalAlignment="Center" />
<Border
BorderThickness="1,0,1,0"
Cursor="SizeWE" />
</Grid>
<Grid Grid.Column="7">
<pry:IcoButton
Width="100"
Command="{Binding DataContext.SetValueCommand, RelativeSource={RelativeSource AncestorType=ItemsControl, Mode=FindAncestor}}"
CommandParameter="{Binding SetValue}"
Grid.Column="0"
Margin="50,5,50,5"
Content="设置"
FontSize="20"
Foreground="Aqua"
Style="{StaticResource IcoButtonStyle}" />
<Border
BorderThickness="1,0,1,0"
Cursor="SizeWE" />
</Grid>
<Border
Grid.ColumnSpan="10"
BorderThickness="1,0,1,1" />
</Grid>
<DataTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="true">
<Setter TargetName="gr" Property="Background" Value="#112AB2E7" />
</Trigger>
</DataTemplate.Triggers>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</ScrollViewer>
</Grid>
</Grid>
</UserControl>

+ 28
- 0
BPASmartClient.JXJFoodBigStation/View/HKPlcCommMonitorView.xaml.cs View File

@@ -0,0 +1,28 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

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

+ 2
- 2
BPASmartClient.JXJFoodBigStation/View/RecipeReceiveView.xaml View File

@@ -159,7 +159,7 @@
<CheckBox
x:Name="IsUseLocalRecipe"
Margin="0,0,10,0"
Content="应用本地配方"
Content="本地配方"
FontFamily="楷体"
VerticalAlignment="Center"
Foreground="Aqua"
@@ -285,7 +285,7 @@
<Expander.Content>
<StackPanel Margin="36,0,0,0">
<StackPanel Orientation="Horizontal">
<TextBlock Text="托盘桶号:" Foreground="#FF2AB2E7"/>
<TextBlock Text="原料桶号:" Foreground="#FF2AB2E7"/>
<TextBlock Text="{Binding RawMaterialBarrelNum}" Foreground="#FF2AB2E7"/>
</StackPanel>
<StackPanel Orientation="Horizontal">


+ 1
- 4
BPASmartClient.JXJFoodBigStation/View/RecipeSendDownView.xaml View File

@@ -506,7 +506,7 @@
<Expander.Content>
<StackPanel Margin="36,0,0,0">
<StackPanel Orientation="Horizontal">
<TextBlock Text="托盘编号:" Foreground="#FF2AB2E7"/>
<TextBlock Text="原料桶号:" Foreground="#FF2AB2E7"/>
<TextBlock Text="{Binding RawMaterialBarrelNum}" Foreground="#FF2AB2E7"/>
</StackPanel>
<StackPanel Orientation="Horizontal">
@@ -514,14 +514,11 @@
<TextBlock Text="{Binding RawMaterialWeight}" Foreground="#FF2AB2E7"/>
</StackPanel>
</StackPanel>

</Expander.Content>
</Expander>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>


</ScrollViewer>



+ 131
- 0
BPASmartClient.JXJFoodBigStation/ViewModel/HKPlcCommMonitorViewModel.cs View File

@@ -0,0 +1,131 @@
using BPA.Helper;
using BPASmartClient.JXJFoodBigStation.Model;
using BPASmartClient.JXJFoodBigStation.Model.HK_PLC;
using Microsoft.Toolkit.Mvvm.ComponentModel;
using Microsoft.Toolkit.Mvvm.Input;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading;
using System.Threading.Tasks;

namespace BPASmartClient.JXJFoodBigStation.ViewModel
{
public class HKPlcCommMonitorViewModel:ObservableObject
{
HKDeviceStatus DeviceStatus = new HKDeviceStatus();
public HKPlcCommMonitorViewModel()
{
Type type = typeof(DB_Read);
PropertyInfo[] properties = type.GetProperties();
double Offset = 0.0;
string addressPos = "";
ThreadManage.GetInstance().StartLong(new Action(() =>
{
foreach (PropertyInfo mi in properties)
{
PropertyInfo a = DeviceStatus.PlcRead.GetType().GetProperty(mi.Name);
object ab = a.GetValue(DeviceStatus.PlcRead, null);

int index = Array.FindIndex(PlcInfo.ToArray(), p => p.Describe == mi.Name);
if (index != -1)
{
PlcInfo.ElementAt(index).NowValue = ab.ToString();
}
}
Thread.Sleep(10);
}), "plc变量读取");
foreach (PropertyInfo mi in properties)
{
PropertyInfo a = DeviceStatus.PlcRead.GetType().GetProperty(mi.Name);
object ab = a.GetValue(DeviceStatus.PlcRead, null);
if (mi.PropertyType.Name == "Int16")
{
addressPos = "DBD";
Offset = Math.Ceiling(Offset);
if (Offset / 2.0 - Math.Floor(Offset / 2.0) > 0.0)
{
Offset += 1.0;
}
}
else if (mi.PropertyType.Name == "Boolean")
{
addressPos = "DBX";
Offset = Math.Round(Offset, 1);
if ((Offset - Math.Floor(Offset)) >= 0.8)
{
Offset = Math.Ceiling(Offset);
}
}
else if (mi.PropertyType.Name == "Single")
{
addressPos = "DBD";
Offset = Math.Ceiling(Offset);
if (Offset / 2.0 - Math.Floor(Offset / 2.0) > 0.0)
{
Offset += 1.0;
}
}
var num = DeviceStatus.PlcRead;
var res = a.GetCustomAttribute<PlcCommAttribute>();
string describe = "";
if (res != null)
{
describe = res.Describe;
}
else
{
describe = "";
}
PlcInfo.Add(new PlcVarMonitor()
{
SerialNum = PlcInfo.Count + 1,
Variable = mi.Name,
Address = "DB98." + addressPos + string.Format("{0:N1}", Offset),
Type = mi.PropertyType.Name,
Describe = describe,
NowValue = ab.ToString(),
});

if (mi.PropertyType.Name == "Int16")
{
Offset += 2;
}
else if (mi.PropertyType.Name == "Boolean")
{
Offset += 0.1;
}
else if (mi.PropertyType.Name == "Single")
{
Offset += 4;
}
}

SetValueCommand = new RelayCommand<object>((o) =>
{
if (o != null && o is String setValue)
{
int index = Array.FindIndex(PlcInfo.ToArray(), p => p.SetValue == setValue);
if (index != -1)
{
DeviceStatus.HK_PLC_S7.Write(PlcInfo.ElementAt(index).Address, setValue);
}
}
});
}
/*public static string GetPropertyValue<T>( T t,string PropertyName)
{
Type type = typeof(T);

}*/
public ObservableCollection<PlcVarMonitor> PlcInfo { get; set; } = new ObservableCollection<PlcVarMonitor>();

public RelayCommand<object> SetValueCommand { get; set; }

public RelayCommand Connect { get; set; }
}
}

+ 4
- 8
BPASmartClient.JXJFoodBigStation/ViewModel/RecipeReceiveViewModel.cs View File

@@ -90,27 +90,23 @@ namespace BPASmartClient.JXJFoodBigStation.ViewModel
Json<LocalRecipe>.Save();
});

RemoveCommand = new RelayCommand<string>((recipeCode) => {
RemoveCommand = new RelayCommand<string>((recipeCode) =>
{
var res = Recipes.FirstOrDefault(p => p.RecipeCode == recipeCode);
if (res != null)
{
Recipes.Remove(res);
Json<LocalRecipe>.Save();
}
});
}

public RelayCommand<object> DetailsCommand { get; set; }
// public RelayCommand NewSimulateRecipe { get; set; }
public RelayCommand ClearAllRecipe { get; set; }

public RelayCommand NewRecipe { get; set; }
public bool IsUseLocalRecipe { get; set; } = true;
public bool IsUseLocalRecipe { get { return _isUseLocalRecipe; } set { _isUseLocalRecipe = value; OnPropertyChanged(); } }
public bool _isUseLocalRecipe { get; set; }
public RelayCommand<string> RemoveCommand { get; set; }
public ObservableCollection<RecipeData> Recipes { get; set; } = new ObservableCollection<RecipeData>();
}
}

+ 23
- 9
BPASmartClient.JXJFoodBigStation/ViewModel/RecipeSendDownViewModel.cs View File

@@ -1,4 +1,6 @@
using BPASmartClient.CustomResource.Pages.Model;
using BPASmartClient.CustomResource.UserControls;
using BPASmartClient.CustomResource.UserControls.MessageShow;
using BPASmartClient.Helper;
using BPASmartClient.JXJFoodBigStation.Model;
using Microsoft.Toolkit.Mvvm.ComponentModel;
@@ -32,22 +34,34 @@ namespace BPASmartClient.JXJFoodBigStation.ViewModel

public RecipeSendDownViewModel()
{
StartCommand = new RelayCommand<string>((recipeName) => {
StartCommand = new RelayCommand<string>((recipeName) =>
{
if (recipeName != null)
{
//配方下发逻辑
var res = Recipes.FirstOrDefault(p => p.RecipeName == recipeName);
if (res != null)
if (GVL_BigStation.IsUseLocalRecipe)
{
Json<LocalRecipe>.Data.Recipes.Add(res);
for (int i = 0; i < Json<LocalRecipe>.Data.Recipes.Count; i++)
//配方下发逻辑
var res = Recipes.FirstOrDefault(p => p.RecipeName == recipeName);
if (res != null)
{
foreach (var item in Json<LocalRecipe>.Data.Recipes.ElementAt(i).RawMaterial)
//Json<LocalRecipe>.Data.Recipes.Add(res);
//for (int i = 0; i < Json<LocalRecipe>.Data.Recipes.Count; i++)
//{
// foreach (var item in Json<LocalRecipe>.Data.Recipes.ElementAt(i).RawMaterial)
// {
// item.RawMaterialLocation = Convert.ToInt32(item.RawMaterialName);
// }
//}
if (!ProcessControl.GetInstance.LocalRecipes.Contains(res))
{
item.RawMaterialLocation = Convert.ToInt32(item.RawMaterialName);
ProcessControl.GetInstance.LocalRecipes.Add(res);
MessageNotify.GetInstance.ShowAlarmLog($"手动下发配方:{recipeName}完成");
}
}
MessageNotify.GetInstance.ShowAlarmLog("手动下发配方完成");
}
else
{
NoticeDemoViewModel.OpenMsg(EnumPromptType.Warn, App.MainWindow, "警告", $"未处于本地配方模式,无法下发配方");
}
}
});


+ 1
- 1
BPASmartClient.JXJFoodSmallStation/App.xaml.cs View File

@@ -28,7 +28,7 @@ namespace BPASmartClient.JXJFoodSmallStation
base.OnStartup(e);
MenuInit();
DataInit();
//DeviceInquire.GetInstance.Init();//配料机设备上线监听,设备列表初始化
DeviceInquire.GetInstance.Init();//配料机设备上线监听,设备列表初始化
ProcessControl.GetInstance.Init();
MainView mv = new MainView();
LoginView lv = new LoginView();


+ 1
- 0
BPASmartClient.JXJFoodSmallStation/Model/ProcessControl.cs View File

@@ -51,6 +51,7 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
public void Init()
{
testData();
Json<RemoteRecipeDataColl>.Data.Recipes = Json<LocalRecipeDataColl>.Data.Recipes;
for (int i = 0; i < 16; i++)
{
if (DeviceInquire.GetInstance.GetDevice(i).DeviceName != null)


+ 1
- 1
BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/DeviceInquire.cs View File

@@ -103,7 +103,7 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
//AlarmHelper<AlarmInfo>.Init();
//AlarmHelper<AlarmInfo>.Alarm.EStop1 = true;

//TestData();
TestData();
IpAddressLines();
DeviceDataInit();
ThreadManage.GetInstance().StartLong(new Action(() =>


+ 2
- 2
BPASmartClient.JXJFoodSmallStation/ViewModel/DeviceListViewModel.cs View File

@@ -28,11 +28,11 @@ namespace BPASmartClient.JXJFoodSmallStation.ViewModel
}
});
devices = DeviceInquire.GetInstance.devices;
foreach (var device in devices)
/*foreach (var device in devices)
{
device.Serial = Convert.ToInt32(device.DeviceName.Substring(1, device.DeviceName.Length - 1)) / 10;
}
devices = new ObservableCollection<Devices>(devices.OrderBy(item => item.Serial));
devices = new ObservableCollection<Devices>(devices.OrderBy(item => item.Serial));*/
}

public RelayCommand<object> ChangeNameCommand { get; set; }


+ 6
- 1
BPASmartClient.S7Net/SiemensHelper.cs View File

@@ -105,7 +105,12 @@ namespace BPASmartClient.S7Net
return $"失败,地址:{address},值:{value},断开连接";
}
}

/// <summary>
///
/// </summary>
/// <param name="db">DB号</param>
/// <param name="txt">字符串</param>
/// <param name="startAddress">字节偏移地址</param>
public void WriteString(int db, string txt, int startAddress = 0)
{
var temp = Encoding.ASCII.GetBytes(txt);


+ 0
- 4
DosingSystem/ViewModel/NewRecipeViewModel.cs View File

@@ -118,7 +118,6 @@ namespace BPASmartClient.DosingSystem.ViewModel
MessageNotify.GetInstance.ShowDialog("配方名称已经存在!", DialogType.Warning);
return;
}

ObservableCollection<RawMaterialModel> TempRawMaterials = new ObservableCollection<RawMaterialModel>();
RawMaterials.ToList()?.ForEach(item =>
{
@@ -134,7 +133,6 @@ namespace BPASmartClient.DosingSystem.ViewModel
}
TempRawMaterials.Add(item);
});

Json<LocaPar>.Data.Recipes.Add(new RecipeModel()
{
RecipeName = RecipeName,
@@ -143,8 +141,6 @@ namespace BPASmartClient.DosingSystem.ViewModel
Json<LocaPar>.Save();
NoticeDemoViewModel.OpenMsg(EnumPromptType.Success, App.MainWindow, "提示", $"新建配方成功!");
}


ActionManage.GetInstance.Send("CloseNewRecipeView");
});



Loading…
Cancel
Save