Browse Source

代码更新

master
pengliangyang 2 years ago
parent
commit
2704725dd7
28 changed files with 1562 additions and 364 deletions
  1. +8
    -1
      BPASmartClient.JXJFoodBigStation/App.xaml.cs
  2. +3
    -0
      BPASmartClient.JXJFoodBigStation/BPASmartClient.JXJFoodBigStation.csproj
  3. +9
    -6
      BPASmartClient.JXJFoodBigStation/Model/GVL_BigStation.cs
  4. +0
    -1
      BPASmartClient.JXJFoodBigStation/Model/HK_PLC/DB_Read.cs
  5. +0
    -14
      BPASmartClient.JXJFoodBigStation/Model/LocalRecipeDataColl.cs
  6. +121
    -128
      BPASmartClient.JXJFoodBigStation/Model/ProcessControl.cs
  7. +8
    -6
      BPASmartClient.JXJFoodBigStation/Model/Siemens/DL_Status_DB.cs
  8. +0
    -45
      BPASmartClient.JXJFoodBigStation/Model/Siemens/SiemensDeviceStatus.cs
  9. +8
    -0
      BPASmartClient.JXJFoodBigStation/View/RecipeReceiveView.xaml
  10. +3
    -1
      BPASmartClient.JXJFoodBigStation/View/RecipeReceiveView.xaml.cs
  11. +878
    -0
      BPASmartClient.JXJFoodBigStation/View/SiemensRecipeSendDownView.xaml
  12. +54
    -0
      BPASmartClient.JXJFoodBigStation/View/SiemensRecipeSendDownView.xaml.cs
  13. +5
    -3
      BPASmartClient.JXJFoodBigStation/ViewModel/RecipeReceiveViewModel.cs
  14. +0
    -1
      BPASmartClient.JXJFoodBigStation/ViewModel/RecipeSendDownViewModel.cs
  15. +35
    -0
      BPASmartClient.JXJFoodBigStation/ViewModel/SiemensRecipeSendDownViewModel.cs
  16. +11
    -1
      BPASmartClient.JXJFoodSmallStation/Model/GVL_SmallStation.cs
  17. +49
    -22
      BPASmartClient.JXJFoodSmallStation/Model/ProcessControl.cs
  18. +1
    -1
      BPASmartClient.JXJFoodSmallStation/Model/Siemens/RemoteRecipeData.cs
  19. +21
    -27
      BPASmartClient.JXJFoodSmallStation/Model/Siemens/SiemensDeviceStatus.cs
  20. +41
    -19
      BPASmartClient.JXJFoodSmallStation/Model/Siemens/XL_DataColl_DB.cs
  21. +21
    -2
      BPASmartClient.JXJFoodSmallStation/Model/Siemens/XL_Finish_DB.cs
  22. +16
    -3
      BPASmartClient.JXJFoodSmallStation/Model/Siemens/XL_Start_DB.cs
  23. +62
    -16
      BPASmartClient.JXJFoodSmallStation/Model/Siemens/XL_Status_DB.cs
  24. +2
    -2
      BPASmartClient.JXJFoodSmallStation/Model/WindSend/WindSendDeviceStatus.cs
  25. +96
    -27
      BPASmartClient.JXJFoodSmallStation/Model/WindSend/XL_WindSendData_DB.cs
  26. +2
    -0
      DosingSystem/App.xaml.cs
  27. +11
    -7
      DosingSystem/Service/SiemensDevice.cs
  28. +97
    -31
      DosingSystem/ViewModel/RecipeControlViewModel.cs

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

@@ -55,7 +55,7 @@ namespace BPASmartClient.JXJFoodBigStation
ObservableCollection<SubMenumodel> RecipeManage = new ObservableCollection<SubMenumodel>();
RecipeManage.Add(new SubMenumodel()
{
SubMenuName = "本地配方管理",
SubMenuName = "配方管理",
SubMenuPermission = new Permission[] { Permission.管理员 },
AssemblyName = "BPASmartClient.JXJFoodBigStation",
ToggleWindowPath = "View.RecipeReceiveView"
@@ -67,6 +67,13 @@ namespace BPASmartClient.JXJFoodBigStation
AssemblyName = "BPASmartClient.JXJFoodBigStation",
ToggleWindowPath = "View.RecipeSendDownView"
});
RecipeManage.Add(new SubMenumodel()
{
SubMenuName = "西门子配方下发",
SubMenuPermission = new Permission[] { Permission.管理员 },
AssemblyName = "BPASmartClient.JXJFoodBigStation",
ToggleWindowPath = "View.SiemensRecipeSendDownView"
});
MenuManage.GetInstance.menuModels.Add(new MenuModel()
{
MainMenuIcon = "&#xe683;",


+ 3
- 0
BPASmartClient.JXJFoodBigStation/BPASmartClient.JXJFoodBigStation.csproj View File

@@ -28,6 +28,9 @@
<Page Update="View\RecipeReceiveView.xaml">
<XamlRuntime>$(DefaultXamlRuntime)</XamlRuntime>
</Page>
<Page Update="View\SiemensRecipeSendDownView.xaml">
<XamlRuntime>$(DefaultXamlRuntime)</XamlRuntime>
</Page>
</ItemGroup>

</Project>

+ 9
- 6
BPASmartClient.JXJFoodBigStation/Model/GVL_BigStation.cs View File

@@ -11,6 +11,10 @@ namespace BPASmartClient.JXJFoodBigStation.Model
{
public class GVL_BigStation
{
/// <summary>
/// plc心跳上传
/// </summary>
public static bool HeartBeatFromPlc { get; set; }
/// <summary>
/// 往输送带下发配方完成
/// </summary>
@@ -35,15 +39,14 @@ namespace BPASmartClient.JXJFoodBigStation.Model
/// <summary>
/// 配方下发状态 =0:配方未下发 ,1:配方下发给plc ,2:plc成功接收配方
/// </summary>
public int Recipe1DosingStatus { get; set; }
public int Recipe2DosingStatus { get; set; }
public int Recipe3DosingStatus { get; set; }
public int Recipe4DosingStatus { get; set; }
public int Recipe5DosingStatus { get; set; }
public static int Recipe1DosingStatus { get; set; }
public static int Recipe2DosingStatus { get; set; }
public static int Recipe3DosingStatus { get; set; }
public static int Recipe4DosingStatus { get; set; }

/// <summary>
/// 是否处于手动下发配方
/// </summary>
public bool IsAllowManual { get; set; } = true;
public static bool IsUseLocalRecipe { get; set; } = false;
}
}

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

@@ -10,7 +10,6 @@ namespace BPASmartClient.JXJFoodBigStation.Model.HK_PLC
{
public bool HeartBeat { get; set; }
public bool IsAllowIssueRecipe1 { get; set; }

public bool IsAllowIssueRecipe2 { get; set; }
public bool IsAllowIssueRecipe3 { get; set; }
public bool IsAllowIssueRecipe4 { get; set; }


+ 0
- 14
BPASmartClient.JXJFoodBigStation/Model/LocalRecipeDataColl.cs View File

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

namespace BPASmartClient.JXJFoodBigStation.Model
{
public class LocalRecipeDataColl
{
public ObservableCollection<RecipeData> Recipes { get; set; } = new ObservableCollection<RecipeData>();
}
}

+ 121
- 128
BPASmartClient.JXJFoodBigStation/Model/ProcessControl.cs View File

@@ -24,13 +24,12 @@ namespace BPASmartClient.JXJFoodBigStation.Model
public SiemensDeviceStatus SiemensDevice = new SiemensDeviceStatus();
public HKDeviceStatus HKDevice = new HKDeviceStatus();
GVL_BigStation BigStation = new GVL_BigStation();
DL_Finish_DB FinishData = new DL_Finish_DB();

/// <summary>
/// 配方数据
/// </summary>
public ObservableCollection<RecipeData> RemoteRecipes = new ObservableCollection<RecipeData>();
public ObservableCollection<RecipeData> Recipes = new ObservableCollection<RecipeData>();
/// <summary>
/// 配方数据
/// </summary>
@@ -46,13 +45,13 @@ namespace BPASmartClient.JXJFoodBigStation.Model
public ConcurrentQueue<string> RecipeQueue2 = new ConcurrentQueue<string>();
public ConcurrentQueue<string> RecipeQueue3 = new ConcurrentQueue<string>();
public ConcurrentQueue<string> RecipeQueue4 = new ConcurrentQueue<string>();
public ConcurrentQueue<string> RecipeQueue5 = new ConcurrentQueue<string>();
/// <summary>
/// 接收原料数据
/// </summary>
public RecipeRawMaterial RawMaterial;
public void Init()
{
ActionManage.GetInstance.CancelRegister("SiemensSendRecipe");
ActionManage.GetInstance.Register(new Action<object>((res) =>
{
ObservableCollection<RawMaterial> RawMaterials = new ObservableCollection<RawMaterial>();
@@ -102,6 +101,7 @@ namespace BPASmartClient.JXJFoodBigStation.Model
if (SiemensDevice.IsConnected)
{
SiemensDevice.Init();
MessageNotify.GetInstance.ShowRunLog("西门子plc连接成功");
}
}
catch (Exception ex)
@@ -112,66 +112,66 @@ namespace BPASmartClient.JXJFoodBigStation.Model
ActionManage.GetInstance.CancelRegister("ManualSendRecipe");
ActionManage.GetInstance.Register(new Action<Object>((o) =>
{
if (o !=null && o is RecipeData a)
{
Json<LocalRecipeDataColl>.Data.Recipes.Add(a);
for (int i = 0; i < Json<LocalRecipeDataColl>.Data.Recipes.Count; i++)
if (o != null && o is RecipeData a)
{
Json<LocalRecipe>.Data.Recipes.Add(a);
for (int i = 0; i < Json<LocalRecipe>.Data.Recipes.Count; i++)
{
foreach (var item in Json<LocalRecipeDataColl>.Data.Recipes.ElementAt(i).RawMaterial)
foreach (var item in Json<LocalRecipe>.Data.Recipes.ElementAt(i).RawMaterial)
{
item.RawMaterialLocation = Convert.ToInt32(item.RawMaterialName);
}
}
MessageNotify.GetInstance.ShowAlarmLog("海科plc连接失败");
MessageNotify.GetInstance.ShowAlarmLog("手动下发配方完成");
}
}), "ManualSendRecipe", true);
RecipeQueue1.Clear();
ThreadManage.GetInstance().StartLong(new Action(() =>
{
SystemStatus();
ReceviceData();
RecipeInfoToHKPLC();
Thread.Sleep(10);
}), "流程处理", true);
}
private void SystemStatus()
{
GVL_BigStation.HeartBeatFromPlc = HKDevice.PlcRead.HeartBeat;//读取plc心跳
}
private void ReceviceData()
{
if (!BigStation.IsAllowManual && RemoteRecipes.Count == 0)//一个配方执行完成后,再获取配方数据
if (!GVL_BigStation.IsUseLocalRecipe && Recipes.Count == 0)//一个配方执行完成后,再获取配方数据
{
RemoteRecipes = Json<RemoteRecipe>.Data.Recipes;
Recipes = Json<RemoteRecipe>.Data.Recipes;
}
else if (BigStation.IsAllowManual && RemoteRecipes.Count == 0)
else if (GVL_BigStation.IsUseLocalRecipe && Recipes.Count == 0)
{
RemoteRecipes = Json<LocalRecipeDataColl>.Data.Recipes;
Recipes = Json<LocalRecipe>.Data.Recipes;
}
if (RemoteRecipes.Count > 0)
if (Recipes.Count > 0)
{
foreach (var data in RemoteRecipes)
foreach (var data in Recipes)
{
if (data.TrayCode == 1)
if (RecipeQueue1.Count == 0)
{
if (!(RecipeQueue1.Contains(data.RecipeCode)))
RecipeQueue1.Enqueue(data.RecipeCode);
}
else if (data.TrayCode == 2)
else if (RecipeQueue2.Count == 0)
{
if (!(RecipeQueue2.Contains(data.RecipeCode)))
RecipeQueue2.Enqueue(data.RecipeCode);
}
else if (data.TrayCode == 3)
else if (RecipeQueue3.Count == 0)
{
if (!(RecipeQueue3.Contains(data.RecipeCode)))
RecipeQueue3.Enqueue(data.RecipeCode);
}
else if (data.TrayCode == 4)
else if (RecipeQueue4.Count == 0)
{
if (!(RecipeQueue4.Contains(data.RecipeCode)))
RecipeQueue4.Enqueue(data.RecipeCode);
}
else if (data.TrayCode == 5)
{
if (!(RecipeQueue5.Contains(data.RecipeCode)))
RecipeQueue5.Enqueue(data.RecipeCode);
}
}
}
else
@@ -180,44 +180,42 @@ namespace BPASmartClient.JXJFoodBigStation.Model
RecipeQueue2.Clear();
RecipeQueue3.Clear();
RecipeQueue4.Clear();
RecipeQueue5.Clear();
BigStation.Recipe1DosingStatus = 0;
BigStation.Recipe2DosingStatus = 0;
BigStation.Recipe3DosingStatus = 0;
BigStation.Recipe4DosingStatus = 0;
BigStation.Recipe5DosingStatus = 0;
GVL_BigStation.Recipe1DosingStatus = 0;
GVL_BigStation.Recipe2DosingStatus = 0;
GVL_BigStation.Recipe3DosingStatus = 0;
GVL_BigStation.Recipe4DosingStatus = 0;
}
}
private void RecipeInfoToHKPLC()
{
if (RecipeQueue1.Count > 0)
{
int index = Array.FindIndex(RemoteRecipes.ToArray(), p => p.RecipeCode == RecipeQueue1.ElementAt(0));
if (index >= 0 && index < RemoteRecipes.Count)
int index = Array.FindIndex(Recipes.ToArray(), p => p.RecipeCode == RecipeQueue1.ElementAt(0));
if (index >= 0 && index < Recipes.Count)
{
string code = RemoteRecipes.ElementAt(index).RecipeCode;
int trayCode = RemoteRecipes.ElementAt(index).TrayCode;
if (HKDevice.PlcRead.IsAllowIssueRecipe1 && BigStation.Recipe1DosingStatus == 0)//配方1是否允许下发配发
string code = Recipes.ElementAt(index).RecipeCode;
int trayCode = Recipes.ElementAt(index).TrayCode;
if (HKDevice.PlcRead.IsAllowIssueRecipe1 && GVL_BigStation.Recipe1DosingStatus == 0)//配方1是否允许下发配发
{
HKDevice.StockBinPar(RemoteRecipes.ElementAt(index));
HKDevice.StockBinPar(Recipes.ElementAt(index));
HKDevice.PlcWrite.Recipe1IssuedFinish = true;
BigStation.Recipe1DosingStatus = 1;
GVL_BigStation.Recipe1DosingStatus = 1;
MessageNotify.GetInstance.ShowRunLog($"配方编号:{code},托盘编号:{trayCode},下发完成");
}
if (HKDevice.PlcRead.ReceiveFinishRecipe1 && BigStation.Recipe1DosingStatus == 1)
if (HKDevice.PlcRead.ReceiveFinishRecipe1 && GVL_BigStation.Recipe1DosingStatus == 1)
{
BigStation.Recipe1DosingStatus = 2;
GVL_BigStation.Recipe1DosingStatus = 2;
HKDevice.PlcWrite.Recipe1IssuedFinish = false;
StockBinParReset();
MessageNotify.GetInstance.ShowRunLog($"配方编号:{code},托盘编号:{trayCode},PLC接收配方完成");
}
if (BigStation.Recipe1DosingStatus == 2 && HKDevice.PlcRead.Recipe1DosingFinish)
if (GVL_BigStation.Recipe1DosingStatus == 2 && HKDevice.PlcRead.Recipe1DosingFinish)
{
BigStation.Recipe1DosingStatus = 3;
GVL_BigStation.Recipe1DosingStatus = 3;
MessageNotify.GetInstance.ShowRunLog($"配方状态:{code}配料完成");
if (HKDevice.PlcRead.Recipe1TrayCode == 1)
{
foreach (var item in RemoteRecipes.ElementAt(index).RawMaterial)
foreach (var item in Recipes.ElementAt(index).RawMaterial)
{
if (item.RawMaterialLocation == 1)
{
@@ -276,63 +274,62 @@ namespace BPASmartClient.JXJFoodBigStation.Model
item.Laying_Off_Weight = HKDevice.PlcRead.StockBin14ActualWeight;
}
}
FinishData.Order_No = RemoteRecipes.ElementAt(index).RecipeCode;
FinishData.Product_Code = RemoteRecipes.ElementAt(index).RecipeName;
for (int i = 0; i < RemoteRecipes.ElementAt(index).RawMaterial.Count; i++)
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.Material[i] = new UDT1();
FinishData.Material[i].Material_Name = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(i).RawMaterialName;
FinishData.Material[i].Material_BarrelNum = (short)RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(i).RawMaterialBarrelNum;
FinishData.Material[i].Material_Laying_Off_Weight = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(i).Laying_Off_Weight;
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)
{
SiemensDevice.Siemens_PLC_S7.WriteClass<DL_Finish_DB>(FinishData, 3);
SiemensDevice.Siemens_PLC_S7.WriteClass<DL_Finish_DB>(FinishData, 2361);
}
RecipeQueue1.TryDequeue(out code);
IssuedComplete.Add(RemoteRecipes.ElementAt(index));//将该配方添加到下
if (!BigStation.IsAllowManual)
IssuedComplete.Add(Recipes.ElementAt(index));//将配方添加到完成列表
if (!GVL_BigStation.IsUseLocalRecipe)
{
Json<RemoteRecipe>.Data.Recipes.RemoveAt(index);//制作完成,移除当前配方
}
else
{
Json<LocalRecipeDataColl>.Data.Recipes.RemoveAt(index);//制作完成,移除当前配方
Json<LocalRecipe>.Data.Recipes.RemoveAt(index);//制作完成,移除当前配方
}
BigStation.Recipe1DosingStatus = 0;
GVL_BigStation.Recipe1DosingStatus = 0;
}
}
}
if (RecipeQueue2.Count > 0)
{
int index = Array.FindIndex(RemoteRecipes.ToArray(), p => p.RecipeCode == RecipeQueue2.ElementAt(0));
if (index >= 0 && index < RemoteRecipes.Count)
int index = Array.FindIndex(Recipes.ToArray(), p => p.RecipeCode == RecipeQueue2.ElementAt(0));
if (index >= 0 && index < Recipes.Count)
{
string code = RemoteRecipes.ElementAt(index).RecipeCode;
int trayCode = RemoteRecipes.ElementAt(index).TrayCode;
if (HKDevice.PlcRead.IsAllowIssueRecipe2 && BigStation.Recipe2DosingStatus == 0)//配方1是否允许下发配发
string code = Recipes.ElementAt(index).RecipeCode;
int trayCode = Recipes.ElementAt(index).TrayCode;
if (HKDevice.PlcRead.IsAllowIssueRecipe2 && GVL_BigStation.Recipe2DosingStatus == 0)//配方2是否允许下发配发
{
HKDevice.StockBinPar(RemoteRecipes.ElementAt(index));
HKDevice.StockBinPar(Recipes.ElementAt(index));
HKDevice.PlcWrite.Recipe2IssuedFinish = true;
BigStation.Recipe2DosingStatus = 1;
GVL_BigStation.Recipe2DosingStatus = 1;
MessageNotify.GetInstance.ShowRunLog($"配方状态:{code}下发完成");
}
if (HKDevice.PlcRead.ReceiveFinishRecipe2 && BigStation.Recipe2DosingStatus == 1)
if (HKDevice.PlcRead.ReceiveFinishRecipe2 && GVL_BigStation.Recipe2DosingStatus == 1)
{
BigStation.Recipe2DosingStatus = 2;
GVL_BigStation.Recipe2DosingStatus = 2;
HKDevice.PlcWrite.Recipe2IssuedFinish = false;
StockBinParReset();
MessageNotify.GetInstance.ShowRunLog($"配方状态:{code}配方配料");
}
if (BigStation.Recipe2DosingStatus == 2 && HKDevice.PlcRead.Recipe2DosingFinish)
if (GVL_BigStation.Recipe2DosingStatus == 2 && HKDevice.PlcRead.Recipe2DosingFinish)
{
BigStation.Recipe2DosingStatus = 3;
GVL_BigStation.Recipe2DosingStatus = 3;
MessageNotify.GetInstance.ShowRunLog($"配方状态:{code}配料完成");
if (HKDevice.PlcRead.Recipe2TrayCode > 0)
{
foreach (var item in RemoteRecipes.ElementAt(index).RawMaterial)
foreach (var item in Recipes.ElementAt(index).RawMaterial)
{
if (item.RawMaterialLocation == 1)
{
@@ -391,62 +388,62 @@ namespace BPASmartClient.JXJFoodBigStation.Model
item.Laying_Off_Weight = HKDevice.PlcRead.StockBin14ActualWeight;
}
}
FinishData.Order_No = RemoteRecipes.ElementAt(index).RecipeCode;
FinishData.Product_Code = RemoteRecipes.ElementAt(index).RecipeName;
for (int i = 0; i < RemoteRecipes.ElementAt(index).RawMaterial.Count; i++)
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.Material[i] = new UDT1();
FinishData.Material[i].Material_Name = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(i).RawMaterialName;
FinishData.Material[i].Material_BarrelNum = (short)RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(i).RawMaterialBarrelNum;
FinishData.Material[i].Material_Laying_Off_Weight = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(i).Laying_Off_Weight;
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)
{
SiemensDevice.Siemens_PLC_S7.WriteClass<DL_Finish_DB>(FinishData, 3);
SiemensDevice.Siemens_PLC_S7.WriteClass<DL_Finish_DB>(FinishData, 2361);
MessageNotify.GetInstance.ShowRunLog($"配方配料完成,将信号反馈给西门子");
}
RecipeQueue2.TryDequeue(out code);
IssuedComplete.Add(RemoteRecipes.ElementAt(index));//将该配方添加到下
if (!BigStation.IsAllowManual)
IssuedComplete.Add(Recipes.ElementAt(index));//将该配方添加到下
if (!GVL_BigStation.IsUseLocalRecipe)
{
Json<RemoteRecipe>.Data.Recipes.RemoveAt(index);//制作完成,移除当前配方
}
else
{
Json<LocalRecipeDataColl>.Data.Recipes.RemoveAt(index);//制作完成,移除当前配方
Json<LocalRecipe>.Data.Recipes.RemoveAt(index);//制作完成,移除当前配方
}
BigStation.Recipe2DosingStatus = 0;
GVL_BigStation.Recipe2DosingStatus = 0;
}
}
}
if (RecipeQueue3.Count > 0)
{
int index = Array.FindIndex(RemoteRecipes.ToArray(), p => p.RecipeCode == RecipeQueue3.ElementAt(0));
if (index >= 0 && index < RemoteRecipes.Count)
int index = Array.FindIndex(Recipes.ToArray(), p => p.RecipeCode == RecipeQueue3.ElementAt(0));
if (index >= 0 && index < Recipes.Count)
{
string code = RemoteRecipes.ElementAt(index).RecipeCode;
int trayCode = RemoteRecipes.ElementAt(index).TrayCode;
if (HKDevice.PlcRead.IsAllowIssueRecipe3 && BigStation.Recipe3DosingStatus == 0)//配方1是否允许下发配发
string code = Recipes.ElementAt(index).RecipeCode;
int trayCode = Recipes.ElementAt(index).TrayCode;
if (HKDevice.PlcRead.IsAllowIssueRecipe3 && GVL_BigStation.Recipe3DosingStatus == 0)//配方3是否允许下发配发
{
HKDevice.StockBinPar(RemoteRecipes.ElementAt(index));
HKDevice.StockBinPar(Recipes.ElementAt(index));
HKDevice.PlcWrite.Recipe3IssuedFinish = true;
BigStation.Recipe3DosingStatus = 1;
GVL_BigStation.Recipe3DosingStatus = 1;
MessageNotify.GetInstance.ShowRunLog($"配方状态:{code}下发完成");
}
if (HKDevice.PlcRead.ReceiveFinishRecipe3 && BigStation.Recipe3DosingStatus == 1)
if (HKDevice.PlcRead.ReceiveFinishRecipe3 && GVL_BigStation.Recipe3DosingStatus == 1)
{
BigStation.Recipe3DosingStatus = 2;
GVL_BigStation.Recipe3DosingStatus = 2;
StockBinParReset();
MessageNotify.GetInstance.ShowRunLog($"配方状态:{code}配方配料");
}
if (HKDevice.PlcRead.Recipe3DosingFinish && BigStation.Recipe3DosingStatus == 2)
if (HKDevice.PlcRead.Recipe3DosingFinish && GVL_BigStation.Recipe3DosingStatus == 2)
{
BigStation.Recipe3DosingStatus = 3;
GVL_BigStation.Recipe3DosingStatus = 3;
MessageNotify.GetInstance.ShowRunLog($"配方状态:{code}配料完成");
if (HKDevice.PlcRead.Recipe3TrayCode > 0)
{
foreach (var item in RemoteRecipes.ElementAt(index).RawMaterial)
foreach (var item in Recipes.ElementAt(index).RawMaterial)
{
if (item.RawMaterialLocation == 1)
{
@@ -505,66 +502,64 @@ namespace BPASmartClient.JXJFoodBigStation.Model
item.Laying_Off_Weight = HKDevice.PlcRead.StockBin14ActualWeight;
}
}

FinishData.Order_No = RemoteRecipes.ElementAt(index).RecipeCode;
FinishData.Product_Code = RemoteRecipes.ElementAt(index).RecipeName;
for (int i = 0; i < RemoteRecipes.ElementAt(index).RawMaterial.Count; i++)
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.Material[i] = new UDT1();
FinishData.Material[i].Material_Name = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(i).RawMaterialName;
FinishData.Material[i].Material_BarrelNum = (short)RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(i).RawMaterialBarrelNum;
FinishData.Material[i].Material_Laying_Off_Weight = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(i).Laying_Off_Weight;
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)
{
SiemensDevice.Siemens_PLC_S7.WriteClass<DL_Finish_DB>(FinishData, 3);
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(RemoteRecipes.ElementAt(index));//将该配方添加到下
if (!BigStation.IsAllowManual)
IssuedComplete.Add(Recipes.ElementAt(index));//将该配方添加到下
if (!GVL_BigStation.IsUseLocalRecipe)
{
Json<RemoteRecipe>.Data.Recipes.RemoveAt(index);//制作完成,移除当前配方
}
else
{
Json<LocalRecipeDataColl>.Data.Recipes.RemoveAt(index);//制作完成,移除当前配方
Json<LocalRecipe>.Data.Recipes.RemoveAt(index);//制作完成,移除当前配方
}
BigStation.Recipe3DosingStatus = 0;
GVL_BigStation.Recipe3DosingStatus = 0;
}
}
}
if (RecipeQueue4.Count > 0)
{
int index = Array.FindIndex(RemoteRecipes.ToArray(), p => p.RecipeCode == RecipeQueue4.ElementAt(0));
if (index >= 0 && index < RemoteRecipes.Count)
int index = Array.FindIndex(Recipes.ToArray(), p => p.RecipeCode == RecipeQueue4.ElementAt(0));
if (index >= 0 && index < Recipes.Count)
{
string code = RemoteRecipes.ElementAt(index).RecipeCode;
int trayCode = RemoteRecipes.ElementAt(index).TrayCode;
if (HKDevice.PlcRead.IsAllowIssueRecipe4 && BigStation.Recipe4DosingStatus == 0)//配方1是否允许下发配发
string code = Recipes.ElementAt(index).RecipeCode;
int trayCode = Recipes.ElementAt(index).TrayCode;
if (HKDevice.PlcRead.IsAllowIssueRecipe4 && GVL_BigStation.Recipe4DosingStatus == 0)//配方4是否允许下发配发
{
HKDevice.StockBinPar(RemoteRecipes.ElementAt(index));
HKDevice.StockBinPar(Recipes.ElementAt(index));
HKDevice.PlcWrite.Recipe4IssuedFinish = true;
BigStation.Recipe4DosingStatus = 1;
GVL_BigStation.Recipe4DosingStatus = 1;
MessageNotify.GetInstance.ShowRunLog($"配方状态:{code}下发完成");
}
if (HKDevice.PlcRead.ReceiveFinishRecipe4 && BigStation.Recipe4DosingStatus == 1)
if (HKDevice.PlcRead.ReceiveFinishRecipe4 && GVL_BigStation.Recipe4DosingStatus == 1)
{
BigStation.Recipe4DosingStatus = 2;
GVL_BigStation.Recipe4DosingStatus = 2;
HKDevice.PlcWrite.Recipe4IssuedFinish = false;
StockBinParReset();
MessageNotify.GetInstance.ShowRunLog($"配方状态:{code}配方配料");
}
if (BigStation.Recipe4DosingStatus == 2 && HKDevice.PlcRead.Recipe4DosingFinish)
if (GVL_BigStation.Recipe4DosingStatus == 2 && HKDevice.PlcRead.Recipe4DosingFinish)
{
BigStation.Recipe4DosingStatus = 3;
GVL_BigStation.Recipe4DosingStatus = 3;
MessageNotify.GetInstance.ShowRunLog($"配方状态:{code}配料完成");
if (HKDevice.PlcRead.Recipe4TrayCode > 0)
{
foreach (var item in RemoteRecipes.ElementAt(index).RawMaterial)
foreach (var item in Recipes.ElementAt(index).RawMaterial)
{
if (item.RawMaterialLocation == 1)
{
@@ -623,40 +618,38 @@ namespace BPASmartClient.JXJFoodBigStation.Model
item.Laying_Off_Weight = HKDevice.PlcRead.StockBin14ActualWeight;
}
}

FinishData.Order_No = RemoteRecipes.ElementAt(index).RecipeCode;
FinishData.Product_Code = RemoteRecipes.ElementAt(index).RecipeName;
for (int i = 0; i < RemoteRecipes.ElementAt(index).RawMaterial.Count; i++)
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.Material[i] = new UDT1();
FinishData.Material[i].Material_Name = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(i).RawMaterialName;
FinishData.Material[i].Material_BarrelNum = (short)RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(i).RawMaterialBarrelNum;
FinishData.Material[i].Material_Laying_Off_Weight = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(i).Laying_Off_Weight;
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)
{
SiemensDevice.Siemens_PLC_S7.WriteClass<DL_Finish_DB>(FinishData, 3);
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(RemoteRecipes.ElementAt(index));//将该配方添加到下
if (!BigStation.IsAllowManual)
IssuedComplete.Add(Recipes.ElementAt(index));//将该配方添加到下
if (!GVL_BigStation.IsUseLocalRecipe)
{
Json<RemoteRecipe>.Data.Recipes.RemoveAt(index);//制作完成,移除当前配方
}
else
{
Json<LocalRecipeDataColl>.Data.Recipes.RemoveAt(index);//制作完成,移除当前配方
Json<LocalRecipe>.Data.Recipes.RemoveAt(index);//制作完成,移除当前配方
}
BigStation.Recipe4DosingStatus = 0;
GVL_BigStation.Recipe4DosingStatus = 0;
}
}
}
}
/// <summary>
/// 下发配方数据复位
/// 下发plc的配方数据复位
/// </summary>
private void StockBinParReset()
{


+ 8
- 6
BPASmartClient.JXJFoodBigStation/Model/Siemens/DL_Status_DB.cs View File

@@ -16,14 +16,14 @@ namespace BPASmartClient.JXJFoodBigStation.Model.Siemens
/// <summary>
/// 配料开始确认
/// </summary>
public bool Dosing_Confirm { get; set; }
public bool Dosing_Cancel { get; set; }
public bool Dosing_Cancel2 { get; set; }
public bool AGV_Request_Put { get; set; }
public bool AGV_Request_Get { get; set; }
public short AGV_Put_Done { get; set; }

public bool Dosing_Cancel3 { get; set; }
public short AGV_Get_Done { get; set; }

public short a { get; set; }
public short[] Standby { get; set; } = new short[3];
public short AGV_GetPut_Pos { get; set; }
public short[] Standby { get; set; } = new short[1];
[Siemens(16)]
/// <summary>
/// 生产工单
@@ -39,6 +39,8 @@ namespace BPASmartClient.JXJFoodBigStation.Model.Siemens

public short Dosing_Cancel8 { get; set; }

public short Dosing_Cancel9 { get; set; }

public short[] Standby2 { get; set; } = new short[4];
}
}

+ 0
- 45
BPASmartClient.JXJFoodBigStation/Model/Siemens/SiemensDeviceStatus.cs View File

@@ -25,51 +25,6 @@ namespace BPASmartClient.JXJFoodBigStation.Model.Siemens
var res1 = this.Siemens_PLC_S7.ReadClass<DL_Status_DB>(2331);
var res2 = this.Siemens_PLC_S7.ReadClass<DL_Finish_DB>(2361);
var res3 = this.Siemens_PLC_S7.ReadClass<DL_DataColl_DB>(2391);
/*if (res != null && RTrig.GetInstance("RecipeTrig").Start(res.Ask_For_Send_Bit))
{
ActionManage.GetInstance.Send("SiemensSendRecipe", res);
res.Ask_For_Send_Bit = false;//接受配方信号复位
//res.Ack_Ask_For_Send_Bit = true;//配方接受完成
this.Siemens_PLC_S7.WriteClass<DL_Start_DB>(res, 1);
}

if (res1 != null && RTrig.GetInstance("Allow_AGV_Put[0]").Start(res1.))
{
ActionManage.GetInstance.Send("AGVToStation1Sign", res1);
//res1.Allow_AGV_Put[0] = false;
this.Siemens_PLC_S7.WriteClass<DL_Status_DB>(res1, 2);
}
if (res1 != null && RTrig.GetInstance("Allow_AGV_Put[1]").Start(res1.Allow_AGV_Put[1]))
{
ActionManage.GetInstance.Send("AGVToStation2Sign", res1);
res1.Allow_AGV_Put[1] = false;
this.Siemens_PLC_S7.WriteClass<DL_Status_DB>(res1, 2);
}
if (res1 != null && RTrig.GetInstance("Allow_AGV_Put[2]").Start(res1.Allow_AGV_Put[2]))
{
ActionManage.GetInstance.Send("AGVToStation3Sign", res1);
res1.Allow_AGV_Put[2] = false;
this.Siemens_PLC_S7.WriteClass<DL_Status_DB>(res1, 2);
}
if (res1 != null && RTrig.GetInstance("Allow_AGV_Put[3]").Start(res1.Allow_AGV_Put[3]))
{
ActionManage.GetInstance.Send("AGVToStation4Sign", res1);
res1.Allow_AGV_Put[3] = false;
this.Siemens_PLC_S7.WriteClass<DL_Status_DB>(res1, 2);
}
if (res1 != null && RTrig.GetInstance("Allow_AGV_Put[4]").Start(res1.Allow_AGV_Put[4]))
{
ActionManage.GetInstance.Send("AGVToStation5Sign", res1);
res1.Allow_AGV_Put[4] = false;
this.Siemens_PLC_S7.WriteClass<DL_Status_DB>(res1, 2);
}
if (res1 != null && RTrig.GetInstance("Allow_AGV_Put[5]").Start(res1.Allow_AGV_Put[5]))
{
ActionManage.GetInstance.Send("AGVToStation6Sign", res1);
res1.Allow_AGV_Put[5] = false;
this.Siemens_PLC_S7.WriteClass<DL_Status_DB>(res1, 2);
}
*/
if (res2 != null && res2.Ask_For_Finish_PLC)
{
ActionManage.GetInstance.Send("配料完成信号确认完成");


+ 8
- 0
BPASmartClient.JXJFoodBigStation/View/RecipeReceiveView.xaml View File

@@ -156,6 +156,14 @@
<RowDefinition />
</Grid.RowDefinitions>
<StackPanel HorizontalAlignment="Right" Orientation="Horizontal">
<CheckBox
x:Name="IsUseLocalRecipe"
Margin="0,0,10,0"
Content="应用本地配方"
FontFamily="楷体"
VerticalAlignment="Center"
Foreground="Aqua"
IsChecked="{Binding IsUseLocalRecipe}" />
<pry:IcoButton
Width="140"
Margin="10"


+ 3
- 1
BPASmartClient.JXJFoodBigStation/View/RecipeReceiveView.xaml.cs View File

@@ -1,4 +1,5 @@
using System;
using BPASmartClient.JXJFoodBigStation.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
@@ -24,6 +25,7 @@ namespace BPASmartClient.JXJFoodBigStation.View
public RecipeReceiveView()
{
InitializeComponent();
this.IsUseLocalRecipe.Click += (o, e) => { GVL_BigStation.IsUseLocalRecipe = (bool)IsUseLocalRecipe.IsChecked; };
}
}
}

+ 878
- 0
BPASmartClient.JXJFoodBigStation/View/SiemensRecipeSendDownView.xaml View File

@@ -0,0 +1,878 @@
<UserControl x:Class="BPASmartClient.JXJFoodBigStation.View.SiemensRecipeSendDownView"
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:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:con="clr-namespace:BPASmartClient.JXJFoodBigStation.Converter"
xmlns:local="clr-namespace:BPASmartClient.JXJFoodBigStation.View"
xmlns:pry="clr-namespace:BPASmartClient.CustomResource.UserControls;assembly=BPASmartClient.CustomResource"
xmlns:vm="clr-namespace:BPASmartClient.JXJFoodBigStation.ViewModel"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800">
<UserControl.DataContext>
<vm:SiemensRecipeSendDownViewModel/>
</UserControl.DataContext>
<UserControl.Resources>
<con:EnbleConvert x:Key="EnbleConvert"/>
<con:IntToSourceConvert x:Key="IntToSourceConvert"/>
<con:RunStatusConvert x:Key="RunStatusConvert"/>
<Style x:Key="UserItemContainerStyle" TargetType="ListBoxItem">
<Style.Resources>
<!-- SelectedItem with focus -->
<SolidColorBrush
x:Key="{x:Static SystemColors.HighlightBrushKey}"
Opacity=".4"
Color="White" />
<!-- SelectedItem without focus -->
<SolidColorBrush
x:Key="{x:Static SystemColors.ControlBrushKey}"
Opacity=".4"
Color="White" />
</Style.Resources>
<!-- 设置触发器 -->
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="true">
<Setter Property="Background" Value="White" />
<Setter Property="Foreground" Value="White" />
</Trigger>
<Trigger Property="IsFocused" Value="true">
<Setter Property="Background" Value="White" />
<Setter Property="Foreground" Value="White" />
</Trigger>
</Style.Triggers>
</Style>

<Style x:Key="RadioState" TargetType="RadioButton">
<Setter Property="Margin" Value="1" />
<Setter Property="Background" Value="Transparent" />
<Setter Property="Foreground" Value="#ddd" />
<Setter Property="VerticalContentAlignment" Value="Bottom" />
<Setter Property="Margin" Value="2,5" />
<Setter Property="FontSize" Value="16" />
<Setter Property="FontFamily" Value="Consolas" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="RadioButton">
<Border
Name="radiobutton"
Background="{TemplateBinding Background}"
CornerRadius="5"
Opacity="0.85">
<Grid>
<!--<Border
x:Name="back_border"
BorderBrush="Black"
BorderThickness="0"
CornerRadius="1">
<Border.Effect>
<BlurEffect KernelType="Gaussian" Radius="2" />
</Border.Effect>
</Border>
<Border
x:Name="fore_border"
Margin="2"
BorderBrush="White"
BorderThickness="0"
CornerRadius="{Binding ElementName=button, Path=CornerRadius}"
Opacity="0.7">
<Border.Effect>
<BlurEffect KernelType="Gaussian" Radius="2" />
</Border.Effect>
</Border>-->


<ContentPresenter
HorizontalAlignment="Center"
VerticalAlignment="Center"
Content="{TemplateBinding Content}"
TextBlock.FontFamily="{TemplateBinding FontFamily}"
TextBlock.FontSize="{TemplateBinding FontSize}"
TextBlock.Foreground="{TemplateBinding Foreground}" />

<Image
Name="im"
Source="/BPASmartClient.CustomResource;component/Image/按钮/组 8.png"
Stretch="Fill" />
</Grid>
</Border>

<ControlTemplate.Triggers>
<Trigger Property="IsChecked" Value="True">
<!--<Setter TargetName="back_border" Property="BorderThickness" Value="1,0,1,1" />
<Setter TargetName="back_border" Property="CornerRadius" Value="5" />
<Setter TargetName="fore_border" Property="BorderThickness" Value="0,2,0,0" />
<Setter Property="Background" Value=" #4169E1" />-->
<Setter TargetName="im" Property="Source" Value="/BPASmartClient.CustomResource;component/Image/按钮/组 7.png" />

</Trigger>

<Trigger Property="IsChecked" Value="False">
<Setter TargetName="im" Property="Source" Value="/BPASmartClient.CustomResource;component/Image/按钮/组 8.png" />
</Trigger>

<Trigger Property="IsMouseOver" Value="True">
<!--<Setter TargetName="back_border" Property="BorderBrush" Value="white" />
<Setter TargetName="back_border" Property="BorderThickness" Value="1,1,1,1" />-->
<Setter TargetName="radiobutton" Property="Opacity" Value="1" />
<!--<Setter TargetName="im" Property="Source" Value="/BPASmartClient.CustomResource;component/Image/按钮背景蓝色.png" />-->
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>

</Setter.Value>

</Setter>

</Style>
<Style x:Key="materialMakingButton" TargetType="Button">
<Setter Property="Background" Value="Transparent" />
<Setter Property="FontSize" Value="16" />
<Setter Property="Foreground" Value="#CD5555" />
<Setter Property="BorderThickness" Value="0" />
<Setter Property="HorizontalAlignment" Value="Left" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate>
<Border
x:Name="brState"
Padding="2"
BorderBrush="White"
BorderThickness="0">
<TextBlock
x:Name="txState"
Margin="1"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Text="{Binding RecipeStatus, Converter={StaticResource RunStatusConvert}}" />
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsEnabled" Value="True">
<Setter TargetName="brState" Property="BorderThickness" Value="0" />
<Setter TargetName="brState" Property="CornerRadius" Value="5" />
<Setter TargetName="brState" Property="Background" Value="#F0FFFF" />
<Setter TargetName="txState" Property="Foreground" Value="#CD5555" />
</Trigger>
<DataTrigger Binding="{Binding RecipeStatus}" Value="3">
<Setter TargetName="brState" Property="Background" Value="#F0FFFF" />
<Setter TargetName="txState" Property="Foreground" Value="#3CB371" />
</DataTrigger>
<DataTrigger Binding="{Binding RecipeStatus}" Value="2">
<Setter TargetName="txState" Property="Foreground" Value="Aqua" />
</DataTrigger>
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="IsMouseOver" Value="True" />
<Condition Property="IsEnabled" Value="True" />
</MultiTrigger.Conditions>
<Setter TargetName="txState" Property="FontSize" Value="17 " />
</MultiTrigger>
</ControlTemplate.Triggers>
</ControlTemplate>

</Setter.Value>
</Setter>
<Style.Triggers />

</Style>

<DataTemplate x:Key="TreeItemTemplate" DataType="TreeViewItem">
<Grid Height="28" Margin="50,0,0,0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<TextBlock
Margin="10,0"
HorizontalAlignment="Left"
VerticalAlignment="Center"
FontSize="15"
Foreground="#aa2AB2E7"
Text="原料:" />
<TextBlock
Grid.Column="1"
Margin="10,0"
HorizontalAlignment="Left"
VerticalAlignment="Center"
FontSize="15"
Foreground="#aa2AB2E7"
Text="{Binding RawMaterialName}" />
</Grid>
</DataTemplate>

<Style x:Key="recipeTreeItem" TargetType="TreeViewItem">
<Setter Property="Background" Value="Transparent" />
<Setter Property="BorderThickness" Value="0" />
<Setter Property="IsExpanded" Value="True" />
<Setter Property="HeaderTemplate">
<Setter.Value>
<HierarchicalDataTemplate ItemTemplate="{StaticResource TreeItemTemplate}" ItemsSource="{Binding RawMaterials, Mode=TwoWay}">
<StackPanel
Height="28"
HorizontalAlignment="Left"
VerticalAlignment="Center"
Orientation="Horizontal">
<TextBlock
Margin="5,0,0,0"
VerticalAlignment="Center"
FontSize="15"
Foreground="#FF2AB2E7"
Text="配方:" />
<TextBlock
Margin="5,0,0,0"
VerticalAlignment="Center"
FontSize="15"
Foreground="#FF2AB2E7"
Text="{Binding RecipeName}" />
</StackPanel>
</HierarchicalDataTemplate>
</Setter.Value>
</Setter>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type TreeViewItem}">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition />
</Grid.RowDefinitions>
<Border
x:Name="Bd"
Grid.Column="0"
Padding="{TemplateBinding Padding}"
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}">
<ContentPresenter
x:Name="PART_Header"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
ContentSource="Header" />
</Border>
<ItemsPresenter
x:Name="ItemsHost"
Grid.Row="1"
Grid.Column="0"
Grid.ColumnSpan="2"
Visibility="Collapsed" />
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="SelectionStates">
<VisualState x:Name="Selected">
<Storyboard>
<ColorAnimationUsingKeyFrames Storyboard.TargetName="Bd" Storyboard.TargetProperty="(Panel.Background).(SolidColorBrush.Color)">
<EasingColorKeyFrame KeyTime="0" Value="Transparent" />
</ColorAnimationUsingKeyFrames>
</Storyboard>
</VisualState>

<VisualState x:Name="Unselected" />
<VisualState x:Name="SelectedInactive">
<Storyboard>
<ColorAnimationUsingKeyFrames Storyboard.TargetName="Bd" Storyboard.TargetProperty="(Panel.Background).(SolidColorBrush.Color)">
<EasingColorKeyFrame KeyTime="0" Value="Transparent" />
</ColorAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
</VisualStateGroup>
<VisualStateGroup x:Name="ExpansionStates">
<VisualState x:Name="Expanded">
<Storyboard>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="ItemsHost" Storyboard.TargetProperty="(UIElement.Visibility)">
<DiscreteObjectKeyFrame KeyTime="0" Value="{x:Static Visibility.Visible}" />
</ObjectAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
<VisualState x:Name="Collapsed" />
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
</Grid>
<ControlTemplate.Triggers>
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="HasHeader" Value="false" />
<Condition Property="Width" Value="Auto" />
</MultiTrigger.Conditions>
<Setter TargetName="PART_Header" Property="MinWidth" Value="75" />
</MultiTrigger>
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="HasHeader" Value="false" />
<Condition Property="Height" Value="Auto" />
</MultiTrigger.Conditions>
<Setter TargetName="PART_Header" Property="MinHeight" Value="19" />
</MultiTrigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>

<!--#region 下拉列表样式-->
<Style x:Key="ToggleButtonStyle" TargetType="{x:Type ToggleButton}">
<Setter Property="FocusVisualStyle" Value="{x:Null}" />
<!--<Setter Property="Height" Value="10" />-->
<Setter Property="HorizontalContentAlignment" Value="Left" />
<Setter Property="VerticalContentAlignment" Value="Top" />
<Setter Property="Padding" Value="10,10" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ToggleButton}">
<Grid>
<Border
x:Name="border2"
Width="auto"
Margin="{TemplateBinding Padding}"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
Background="{TemplateBinding Background}">
<ContentPresenter
Margin="{TemplateBinding Padding}"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
RecognizesAccessKey="True"
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
</Border>
</Grid>

<ControlTemplate.Triggers>
<!--<Trigger Property="IsPressed" Value="true">
<Setter Property="Background" Value="#FFd2e7f4" />
</Trigger>
<Trigger Property="IsChecked" Value="true">
<Setter TargetName="border2" Property="Background" Value="#191E36" />
</Trigger>
<Trigger Property="IsChecked" Value="false">
<Setter TargetName="border2" Property="Background" Value="#191E36" />
</Trigger>-->
<!--<Trigger Property="IsEnabled" Value="false">
<Setter Property="Foreground" Value="White" />
</Trigger>-->
<Trigger Property="IsMouseOver" Value="True">
<Setter TargetName="border2" Property="Background" Value="#191E36" />
</Trigger>
<Trigger Property="IsMouseOver" Value="False">
<Setter TargetName="border2" Property="Background" Value="Transparent" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>

<Style x:Key="ExpanderStyle" TargetType="{x:Type Expander}">
<Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}" />
<Setter Property="HorizontalContentAlignment" Value="Stretch" />
<Setter Property="VerticalContentAlignment" Value="Stretch" />
<Setter Property="BorderBrush" Value="Transparent" />
<Setter Property="BorderThickness" Value="1" />

<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Expander}">
<DockPanel>
<ToggleButton
x:Name="HeaderSite"
Height="20"
Width="auto"
MinWidth="0"
MinHeight="0"
Margin="1"
Padding="{TemplateBinding Padding}"
Background="Transparent"
HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
Content="{TemplateBinding Header}"
ContentTemplate="{TemplateBinding HeaderTemplate}"
ContentTemplateSelector="{TemplateBinding HeaderTemplateSelector}"
DockPanel.Dock="Top"
FontFamily="{TemplateBinding FontFamily}"
FontSize="{TemplateBinding FontSize}"
FontStretch="{TemplateBinding FontStretch}"
FontStyle="{TemplateBinding FontStyle}"
FontWeight="{TemplateBinding FontWeight}"
Foreground="{TemplateBinding Foreground}"
IsChecked="{Binding IsExpanded, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}"
Style="{StaticResource ToggleButtonStyle}" />
<ContentPresenter
x:Name="ExpandSite"
Margin="{TemplateBinding Padding}"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
DockPanel.Dock="Left"
Focusable="false"
Visibility="Visible" />
</DockPanel>
<ControlTemplate.Triggers>
<Trigger Property="IsExpanded" Value="True">
<Setter TargetName="ExpandSite" Property="Visibility" Value="Collapsed" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<!--#endregion-->
</UserControl.Resources>
<Grid Margin="20">

<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition Width="0.25*" />
</Grid.ColumnDefinitions>

<Grid Name="ggr" Margin="10">

<pry:ImageBorder Width="{Binding ElementName=ggr, Path=ActualWidth}" Height="{Binding ElementName=ggr, Path=ActualHeight}" />

<ListBox
Margin="5"
VerticalAlignment="Top"
Background="Transparent"
BorderThickness="0"
ItemsSource="{Binding Recipes}"
ScrollViewer.HorizontalScrollBarVisibility="Disabled">
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<UniformGrid
HorizontalAlignment="Left"
VerticalAlignment="Top"
Columns="6" />
</ItemsPanelTemplate>
</ListBox.ItemsPanel>

<ListBox.ItemTemplate>
<DataTemplate>

<Grid
Name="tt"
Height="220"
Margin="5">
<Grid.RowDefinitions>
<RowDefinition Height="30" />
<RowDefinition Height="20" />
<RowDefinition Height="128" />
<RowDefinition Height="2" />
<RowDefinition Height="40" />
</Grid.RowDefinitions>

<Image
Grid.RowSpan="5"
Source="/BPASmartClient.CustomResource;component/Image/配方背景/竖背景框.png"
Stretch="Fill" />

<TextBlock
Grid.Row="0"
Margin="2,5,0,0"
HorizontalAlignment="Center"
VerticalAlignment="Top"
FontSize="18"
Foreground="#FF2AB2E7"
Text="{Binding RecipeName}" />

<TextBlock
Grid.Row="1"
FontSize="16"
Margin="5,0,0,0"
VerticalAlignment="Top"
Foreground="#FF2AB2E7"
Text="配方信息:" />

<ScrollViewer
Grid.Row="2"
VerticalAlignment="Top"
Background="Transparent"
HorizontalScrollBarVisibility="Hidden"
VerticalScrollBarVisibility="Hidden">
<ItemsControl ItemsSource="{Binding RawMaterial}">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel/>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate>
<Expander Style="{StaticResource ExpanderStyle}" Margin="40,0,0,0">
<Expander.Header>
<StackPanel Orientation="Horizontal">
<Border Width="15" Height="15" CornerRadius="15" HorizontalAlignment="Left" Margin="0,0,5,0">
<Border.Background>
<RadialGradientBrush>
<GradientStop Color="#FF2AB2E7" Offset="0.5" />
<GradientStop Color="White"/>
</RadialGradientBrush>
</Border.Background>
</Border>
<TextBlock Text="{Binding RawMaterialName }" Foreground="#FF2AB2E7" VerticalAlignment="Center" FontSize="14"/>
</StackPanel>
</Expander.Header>
<Expander.Content>
<StackPanel Margin="36,0,0,0">
<StackPanel Orientation="Horizontal">
<TextBlock Text="托盘编号:" Foreground="#FF2AB2E7"/>
<TextBlock Text="{Binding RawMaterialBarrelNum}" Foreground="#FF2AB2E7"/>
</StackPanel>
<StackPanel Orientation="Horizontal">
<TextBlock Text="原料重量:" Foreground="#FF2AB2E7"/>
<TextBlock Text="{Binding RawMaterialWeight}" Foreground="#FF2AB2E7"/>
</StackPanel>
</StackPanel>

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


</ScrollViewer>

<Image
Grid.Row="3"
Width="{Binding ElementName=tt, Path=ActualWidth}"
Height="2"
VerticalAlignment="Bottom"
Source="/BPASmartClient.CustomResource;component/Image/直线.png"
Stretch="Fill" />

<Grid
Name="gr"
Grid.Row="4"
Height="30"
Margin="0,0,0,10"
VerticalAlignment="Bottom"
Background="Transparent">
<!--<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition />
</Grid.ColumnDefinitions>-->

<!--<Image
Height="2"
Grid.ColumnSpan="2"
Width="{Binding ElementName=gr, Path=ActualWidth}"
VerticalAlignment="Top"
Source="/BPASmartClient.CustomResource;component/Image/直线.png" />-->

<!--<pry:IcoButton
Width="{Binding ElementName=gr, Path=ActualWidth}"
Height="{Binding ElementName=gr, Path=ActualHeight}"
Margin="4,4,4,0"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Background="#222bd06f"
BorderThickness="0"
Command="{Binding DataContext.StartCommand, RelativeSource={RelativeSource AncestorType=ListBox, Mode=FindAncestor}}"
CommandParameter="{Binding RecipeName}"
Content="配方下发"
EnterBackground="#332bd06f"
FontStyle="Normal"
Foreground="#ff2bd06f"
IcoText="&#xe6cf;"
IsEnabled="{Binding IsEnable}"
Style="{StaticResource IcoButtonStyle}" />-->

<!--<pry:IcoButton
Width="{Binding ElementName=gr, Path=ActualWidth}"
Height="{Binding ElementName=gr, Path=ActualHeight}"
Margin="4,4,3,0"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Background="#11F53F62"
BorderThickness="0"
Command="{Binding DataContext.RemoveCommand, RelativeSource={RelativeSource AncestorType=ListBox, Mode=FindAncestor}}"
CommandParameter="{Binding RecipCode}"
Content="删除"
EnterBackground="#22F53F62"
FontStyle="Normal"
Foreground="#FFF53F62"
IcoText="&#xe68e;"
Style="{StaticResource IcoButtonStyle}" />

<pry:IcoButton
Grid.Column="1"
Width="{Binding ElementName=gr, Path=ActualWidth}"
Height="{Binding ElementName=gr, Path=ActualHeight}"
Margin="3,4,4,0"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Background="#112AB2E7"
BorderThickness="0"
Command="{Binding DataContext.DetailsCommand, RelativeSource={RelativeSource AncestorType=ListBox, Mode=FindAncestor}}"
CommandParameter="{Binding RecipCode}"
Content="编辑"
EnterBackground="#222AB2E7"
Foreground="#FF2AB2E7"
IcoText="&#xe636;"
Style="{StaticResource IcoButtonStyle}" />-->

</Grid>
<!--</StackPanel>-->
</Grid>

<!--<Grid Name="tt" Margin="5">
<Grid.RowDefinitions>
<RowDefinition Height="auto" />
<RowDefinition Height="auto" />
<RowDefinition />
<RowDefinition />
</Grid.RowDefinitions>

<Image
Grid.RowSpan="4"
Source="/BPASmartClient.CustomResource;component/Image/配方背景/竖背景框.png"
Stretch="Fill" />

<TextBlock
Grid.Row="0"
Margin="2,5,0,0"
HorizontalAlignment="Center"
VerticalAlignment="Top"
FontSize="18"
Foreground="#FF2AB2E7"
Text="{Binding RecipeName}" />


<TextBlock
Grid.Row="1"
Margin="5,0,0,5"
Foreground="#ffc000"
Text="配方信息:" />

<ScrollViewer
Grid.Row="2"
HorizontalScrollBarVisibility="Hidden"
VerticalScrollBarVisibility="Hidden">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="auto" />
<ColumnDefinition />
</Grid.ColumnDefinitions>

<ItemsControl ItemsSource="{Binding RawMaterials}">
<ItemsControl.ItemTemplate>
<DataTemplate>
<Grid>
<TextBlock
Grid.Row="1"
Margin="5,0,0,0"
HorizontalAlignment="Right"
VerticalAlignment="Center"
Foreground="#aaffc000"
Text="{Binding RawMaterialName}" />
</Grid>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>

<ItemsControl Grid.Column="1" ItemsSource="{Binding RawMaterials}">
<ItemsControl.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">

<TextBlock
Margin="5,0,0,0"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Foreground="#aaffc000"
Text=":" />

<TextBlock
Margin="5,0,0,0"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Foreground="#aaffc000"
Text="{Binding RawMaterialWeight}" />

<TextBlock
Margin="5,0,0,0"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Foreground="#aaffc000"
Text="g" />

</StackPanel>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>

</Grid>

</ScrollViewer>



<Grid
Name="grb"
Grid.Row="3"
Height="30"
Margin="0,0,0,10"
VerticalAlignment="Bottom"
Background="Transparent">

<Image
Width="{Binding ElementName=grb, Path=ActualWidth}"
VerticalAlignment="Top"
StretchDirection="Both"
Source="/BPASmartClient.CustomResource;component/Image/直线.png" />

<pry:IcoButton
Width="{Binding ElementName=grb, Path=ActualWidth}"
Height="{Binding ElementName=grb, Path=ActualHeight}"
Margin="4,4,4,0"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Background="#222bd06f"
BorderThickness="0"
Command="{Binding DataContext.StartCommand, RelativeSource={RelativeSource AncestorType=ListBox, Mode=FindAncestor}}"
CommandParameter="{Binding RecipeName}"
Content="配方下发"
EnterBackground="#332bd06f"
FontStyle="Normal"
Foreground="#ff2bd06f"
IcoText="&#xe6cf;"
IsEnabled="{Binding IsEnable}"
Style="{StaticResource IcoButtonStyle}" />


</Grid>

</Grid>-->
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>

</Grid>

<Grid
Name="gr"
Grid.Column="1"
Margin="10">
<Grid.RowDefinitions>
<RowDefinition Height="50" />
<RowDefinition />
</Grid.RowDefinitions>

<pry:ImageBorder
Grid.RowSpan="2"
Width="{Binding ElementName=gr, Path=ActualWidth}"
Height="{Binding ElementName=gr, Path=ActualHeight}" />

<Grid Margin="5">
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<RadioButton
Click="RadioButtonWait_Click"
Command="{Binding ChangeRecipeStateCommand}"
Content="等待中"
GroupName="state"
IsChecked="True"
Style="{DynamicResource RadioState}" />
<RadioButton
Grid.Column="1"
Click="RadioButtonMaking_Click"
Content="执行中"
GroupName="state"
Style="{DynamicResource RadioState}" />
<RadioButton
Grid.Column="2"
Click="RadioButtonCompelete_Click"
Content="已完成"
GroupName="state"
Style="{DynamicResource RadioState}" />

</Grid>


<ScrollViewer
Grid.Row="1"
HorizontalScrollBarVisibility="Hidden"
VerticalScrollBarVisibility="Hidden">
<Border>
<Grid Grid.Row="1">
<Grid x:Name="repiceListMaking" Margin="5">
<Grid.RowDefinitions>
<RowDefinition Height="30" />
<RowDefinition />
</Grid.RowDefinitions>
<TextBlock
Margin="10,0"
HorizontalAlignment="Left"
VerticalAlignment="Center"
FontSize="18"
Foreground="#FF2AB2E7"
Text="{Binding CurrentRecipeName}" />
<ItemsControl
Grid.Row="1"
Margin="50,0"
ItemsSource="{Binding recipeProcesses}">
<ItemsControl.ItemTemplate>
<DataTemplate>
<Grid Margin="5">
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition Width="16" />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<TextBlock
Margin="10,0,5,0"
HorizontalAlignment="Left"
VerticalAlignment="Center"
FontSize="15"
Foreground="#AA2AB2E7"
Text="{Binding RawMaterialName}"
ToolTip="{Binding RawMaterialSource, Converter={StaticResource IntToSourceConvert}}" />
<TextBlock
Grid.Column="1"
Margin="0,0,5,0"
HorizontalAlignment="Left"
VerticalAlignment="Center"
FontSize="15"
Foreground="#AA2AB2E7"
Text=":" />
<Button
Grid.Column="2"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Command="{Binding DataContext.ChangeRecipeStateCommand, RelativeSource={RelativeSource AncestorType=ItemsControl, Mode=FindAncestor}}"
CommandParameter="{Binding RawMaterialId}"
Content="{Binding RecipeStatus, Converter={StaticResource RunStatusConvert}}"
IsEnabled="{Binding RawMaterialSource, Converter={StaticResource EnbleConvert}}"
Style="{StaticResource materialMakingButton}" />
</Grid>
</DataTemplate>
</ItemsControl.ItemTemplate>

</ItemsControl>

</Grid>
<!--<TreeView x:Name="repiceListMaking" ItemsSource="{Binding RecipeProcesse}"
ScrollViewer.VerticalScrollBarVisibility="Disabled" HorizontalAlignment="Stretch" Background="Wheat" ItemContainerStyle="{StaticResource recipeTreeItem}">
</TreeView>-->

<!-- 等待和已完成 -->

<TreeView
x:Name="repiceList"
HorizontalAlignment="Stretch"
Background="Transparent"
BorderThickness="0"
ItemContainerStyle="{StaticResource recipeTreeItem}"
ItemsSource="{Binding UserTreeWait}"
ScrollViewer.VerticalScrollBarVisibility="Visible" />




</Grid>
</Border>
</ScrollViewer>
</Grid>

</Grid>
</UserControl>

+ 54
- 0
BPASmartClient.JXJFoodBigStation/View/SiemensRecipeSendDownView.xaml.cs View File

@@ -0,0 +1,54 @@
using BPASmartClient.JXJFoodBigStation.ViewModel;
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>
/// RecipeSendDownView.xaml 的交互逻辑
/// </summary>
public partial class SiemensRecipeSendDownView : UserControl
{
public SiemensRecipeSendDownView()
{
InitializeComponent();
}

private void RadioButtonCompelete_Click(object sender, RoutedEventArgs e)
{
repiceList.ItemsSource = RecipeSendDownViewModel.UserTreeCompelete;
repiceList.Visibility = Visibility.Visible;
repiceListMaking.Visibility = Visibility.Hidden;


}

private void RadioButtonWait_Click(object sender, RoutedEventArgs e)
{
repiceList.ItemsSource = RecipeSendDownViewModel.UserTreeWait;
repiceList.Visibility = Visibility.Visible;
repiceListMaking.Visibility = Visibility.Hidden;
}

private void RadioButtonMaking_Click(object sender, RoutedEventArgs e)
{
repiceListMaking.Visibility = Visibility.Visible;
repiceList.Visibility = Visibility.Hidden;

}
}

}

+ 5
- 3
BPASmartClient.JXJFoodBigStation/ViewModel/RecipeReceiveViewModel.cs View File

@@ -26,6 +26,7 @@ namespace BPASmartClient.JXJFoodBigStation.ViewModel
public ObservableCollection<RawMaterial> RawMaterials { get; set; } = new ObservableCollection<RawMaterial>();
public RecipeReceiveViewModel()
{
IsUseLocalRecipe = GVL_BigStation.IsUseLocalRecipe;
Json<LocalRecipe>.Read();
Recipes = Json<LocalRecipe>.Data.Recipes;
DetailsCommand = new RelayCommand<object>((o) =>
@@ -40,8 +41,8 @@ namespace BPASmartClient.JXJFoodBigStation.ViewModel
MessageNotify.GetInstance.ShowUserLog($"查看配方——{res.RecipeName}");
}
});
NewRecipe = new RelayCommand(() => {
NewRecipe = new RelayCommand(() =>
{
RecipeInfosView nrv = new RecipeInfosView();
nrv.ShowDialog();
});
@@ -91,7 +92,7 @@ namespace BPASmartClient.JXJFoodBigStation.ViewModel

RemoveCommand = new RelayCommand<string>((recipeCode) => {

var res = Recipes.FirstOrDefault(p=>p.RecipeCode==recipeCode);
var res = Recipes.FirstOrDefault(p => p.RecipeCode == recipeCode);
if (res != null)
{
Recipes.Remove(res);
@@ -106,6 +107,7 @@ namespace BPASmartClient.JXJFoodBigStation.ViewModel
public RelayCommand ClearAllRecipe { get; set; }

public RelayCommand NewRecipe { get; set; }
public bool IsUseLocalRecipe { get; set; } = true;

public RelayCommand<string> RemoveCommand { get; set; }


+ 0
- 1
BPASmartClient.JXJFoodBigStation/ViewModel/RecipeSendDownViewModel.cs View File

@@ -13,7 +13,6 @@ namespace BPASmartClient.JXJFoodBigStation.ViewModel
{
internal class RecipeSendDownViewModel:ObservableObject
{

public ObservableCollection<RecipeData> Recipes { get; set; } = Json<LocalRecipe>.Data.Recipes;
/// <summary>
/// 当前正在制作的配方


+ 35
- 0
BPASmartClient.JXJFoodBigStation/ViewModel/SiemensRecipeSendDownViewModel.cs View File

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

namespace BPASmartClient.JXJFoodBigStation.ViewModel
{
internal class SiemensRecipeSendDownViewModel : ObservableObject
{
public ObservableCollection<RecipeData> Recipes { get; set; } = Json<RemoteRecipe>.Data.Recipes;
/// <summary>
/// 当前正在制作的配方
/// </summary>
public static ObservableCollection<RawMaterial> recipeProcesses { get; set; } = new ObservableCollection<RawMaterial>();
/// <summary>
/// 等待制作的配方
/// </summary>
public static ObservableCollection<RecipeData> UserTreeWait { get; set; } = new ObservableCollection<RecipeData>();
/// <summary>
/// 已完成的配方
/// </summary>
public static ObservableCollection<RecipeData> UserTreeCompelete { get; set; } = new ObservableCollection<RecipeData>();
public SiemensRecipeSendDownViewModel()
{
}
}
}

+ 11
- 1
BPASmartClient.JXJFoodSmallStation/Model/GVL_SmallStation.cs View File

@@ -14,12 +14,22 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
private volatile static GVL_SmallStation SmallStation;
public static GVL_SmallStation GetInstance => SmallStation ?? (SmallStation = new GVL_SmallStation());
private GVL_SmallStation() { }

/// <summary>
/// 配料站料仓数目
/// </summary>
public const int Max_DosingSotckBinNum = 15;

/// <summary>
/// 风送料仓数目
/// </summary>
public const int Max_PowderSotckBinNum = 15;
public bool HeartBeatToPlc { get; set; } = false;
public bool HeartBeatFromPlc { get; set; } = false;
/// <summary>
/// 是否允许西门子下发配方
/// </summary>
public bool IsAllowSiemensSendRecipe;
public static bool IsAllowSiemensSendRecipe { get; set; } = false;

/// <summary>
/// 往输送带下发配方完成


+ 49
- 22
BPASmartClient.JXJFoodSmallStation/Model/ProcessControl.cs View File

@@ -40,6 +40,9 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
public HKDeviceStatus HKDevice = new HKDeviceStatus();
public WindSendDeviceStatus WindSendDevice = new WindSendDeviceStatus();
XL_Finish_DB RecipeFinishInfo = new XL_Finish_DB();
/// <summary>
/// 风送PLC的DB块
/// </summary>
XL_WindSendData_DB WindSendData = new XL_WindSendData_DB();
/// <summary>
/// 接收原料数据
@@ -61,26 +64,49 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
ActionManage.GetInstance.Register(new Action<object>((res) =>
{
ObservableCollection<RemoteRecipeRawMaterial> RawMaterials = new ObservableCollection<RemoteRecipeRawMaterial>();
ObservableCollection<WindSendRawMaterial> WindSendData = new ObservableCollection<WindSendRawMaterial>();
if (SiemensDevice.IsConnected)
{
if (res != null && res is XL_Start_DB recipe)
{
RawMaterials.Clear();
for (int i = 0; i < 15; i++)
for (int i = 0; i < GVL_SmallStation.Max_DosingSotckBinNum; i++)
{
if (RawMaterialsNamePos.ContainsKey(recipe.Material[i].Material_Name))
if (!string.IsNullOrEmpty(recipe.Material[i].Material_Name))
{
RawMaterials.Add(new RemoteRecipeRawMaterial()
if (RawMaterialsNamePos.ContainsKey(recipe.Material[i].Material_Name))
{
RawMaterialName = recipe.Material[i].Material_Name,
RawMaterialBarrelNum = recipe.Material[i].Material_BarrelNum,
RawMaterialWeight = recipe.Material[i].Material_Weight,
RawMaterialLocation = (int)RawMaterialsNamePos[recipe.Material[i].Material_Name]
});
RawMaterials.Add(new RemoteRecipeRawMaterial()
{
RawMaterialName = recipe.Material[i].Material_Name,
RawMaterialBarrelNum = recipe.Material[i].Material_BarrelNum,
RawMaterialWeight = recipe.Material[i].Material_Weight,
RawMaterialLocation = (int)RawMaterialsNamePos[recipe.Material[i].Material_Name]
});
}
else
{
//MessageNotify.GetInstance.AlarmLog("配方名称与本地不符合");
}
}
else
{
//MessageNotify.GetInstance.AlarmLog("配方名称与本地不符合");
break;
}
}
for (int i = 0; i < GVL_SmallStation.Max_PowderSotckBinNum; i++)
{
if (!string.IsNullOrEmpty(recipe.Powder[i].Powder_Name))
{
WindSendData.Add(new WindSendRawMaterial()
{
RawMaterialName = recipe.Powder[i].Powder_Name,
RawMaterialWeight = recipe.Powder[i].Powder_Weight
});
}
else
{
break;
}
}
Json<RemoteRecipeDataColl>.Data.Recipes.Add(new RemoteRecipeData()
@@ -88,7 +114,8 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
RecipeName = recipe.RecipeName,
RecipeCode = recipe.RecipeCode,
RawMaterial = RawMaterials,
TrayCode = recipe.TrayCode
TrayCode = recipe.TrayCode,
WindSend = WindSendData
});
}
}
@@ -676,25 +703,25 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
{
GVL_SmallStation.GetInstance.IsUseWindSend = false;
WindSendData.TargetRecipeCode = code;
if (RemoteRecipes.ElementAt(index).WindSendRawMaterial.ElementAt(0).RawMaterialName == DeviceName.原料1.ToString())
if (RemoteRecipes.ElementAt(index).WindSend.ElementAt(0).RawMaterialName == DeviceName.原料1.ToString())
{
WindSendData.RawMaterial1_SetWeight = RemoteRecipes.ElementAt(index).WindSendRawMaterial.ElementAt(0).RawMaterialWeight;
WindSendData.RawMaterial1_SetWeight = RemoteRecipes.ElementAt(index).WindSend.ElementAt(0).RawMaterialWeight;
}
if (RemoteRecipes.ElementAt(index).WindSendRawMaterial.ElementAt(1).RawMaterialName == DeviceName.原料2.ToString())
if (RemoteRecipes.ElementAt(index).WindSend.ElementAt(1).RawMaterialName == DeviceName.原料2.ToString())
{
WindSendData.RawMaterial2_SetWeight = RemoteRecipes.ElementAt(index).WindSendRawMaterial.ElementAt(1).RawMaterialWeight;
WindSendData.RawMaterial2_SetWeight = RemoteRecipes.ElementAt(index).WindSend.ElementAt(1).RawMaterialWeight;
}
if (RemoteRecipes.ElementAt(index).WindSendRawMaterial.ElementAt(2).RawMaterialName == DeviceName.原料3.ToString())
if (RemoteRecipes.ElementAt(index).WindSend.ElementAt(2).RawMaterialName == DeviceName.原料3.ToString())
{
WindSendData.RawMaterial3_SetWeight = RemoteRecipes.ElementAt(index).WindSendRawMaterial.ElementAt(2).RawMaterialWeight;
WindSendData.RawMaterial3_SetWeight = RemoteRecipes.ElementAt(index).WindSend.ElementAt(2).RawMaterialWeight;
}
if (RemoteRecipes.ElementAt(index).WindSendRawMaterial.ElementAt(3).RawMaterialName == DeviceName.原料4.ToString())
if (RemoteRecipes.ElementAt(index).WindSend.ElementAt(3).RawMaterialName == DeviceName.原料4.ToString())
{
WindSendData.RawMaterial4_SetWeight = RemoteRecipes.ElementAt(index).WindSendRawMaterial.ElementAt(3).RawMaterialWeight;
WindSendData.RawMaterial4_SetWeight = RemoteRecipes.ElementAt(index).WindSend.ElementAt(3).RawMaterialWeight;
}
if (RemoteRecipes.ElementAt(index).WindSendRawMaterial.ElementAt(4).RawMaterialName == DeviceName.原料5.ToString())
if (RemoteRecipes.ElementAt(index).WindSend.ElementAt(4).RawMaterialName == DeviceName.原料5.ToString())
{
WindSendData.RawMaterial5_SetWeight = RemoteRecipes.ElementAt(index).WindSendRawMaterial.ElementAt(4).RawMaterialWeight;
WindSendData.RawMaterial5_SetWeight = RemoteRecipes.ElementAt(index).WindSend.ElementAt(4).RawMaterialWeight;
}
WindSendDevice.Siemens_PLC_S7.WriteClass<XL_WindSendData_DB>(WindSendData, 5);
}
@@ -840,7 +867,7 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
if (SiemensDevice.IsConnected)
{
RecipeFinishInfo.Ask_For_Finish = true;
SiemensDevice.Siemens_PLC_S7.WriteClass<XL_Finish_DB>(RecipeFinishInfo, 3);
SiemensDevice.Siemens_PLC_S7.WriteClass<XL_Finish_DB>(RecipeFinishInfo, 2261);
}
App.Current.Dispatcher.Invoke(() =>
{
@@ -1009,7 +1036,7 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
if (SiemensDevice.IsConnected)
{
RecipeFinishInfo.Ask_For_Finish = true;
SiemensDevice.Siemens_PLC_S7.WriteClass<XL_Finish_DB>(RecipeFinishInfo, 3);
SiemensDevice.Siemens_PLC_S7.WriteClass<XL_Finish_DB>(RecipeFinishInfo, 2261);
}
App.Current.Dispatcher.Invoke(() =>
{


+ 1
- 1
BPASmartClient.JXJFoodSmallStation/Model/Siemens/RemoteRecipeData.cs View File

@@ -36,7 +36,7 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
/// <summary>
/// 粉料仓的原料数据
/// </summary>
public ObservableCollection<WindSendRawMaterial> WindSendRawMaterial { get; set; } = new ObservableCollection<WindSendRawMaterial>();
public ObservableCollection<WindSendRawMaterial> WindSend { get; set; } = new ObservableCollection<WindSendRawMaterial>();

}
}

+ 21
- 27
BPASmartClient.JXJFoodSmallStation/Model/Siemens/SiemensDeviceStatus.cs View File

@@ -21,41 +21,35 @@ namespace BPASmartClient.JXJFoodSmallStation.Model.Siemens
{
ThreadManage.GetInstance().StartLong(new Action(() =>
{
var res = this.Siemens_PLC_S7.ReadClass<XL_Start_DB>(2201);
var res1 = this.Siemens_PLC_S7.ReadClass<XL_Status_DB>(2231);
var res2 = this.Siemens_PLC_S7.ReadClass<XL_Finish_DB>(2261);
var res4 = this.Siemens_PLC_S7.ReadClass<XL_DataColl_DB>(2291);
if (res != null && res.Order_Request_ACK == false && GVL_SmallStation.GetInstance.IsAllowSiemensSendRecipe)
var Start = this.Siemens_PLC_S7.ReadClass<XL_Start_DB>(2201);
var Status = this.Siemens_PLC_S7.ReadClass<XL_Status_DB>(2231);
var Finish = this.Siemens_PLC_S7.ReadClass<XL_Finish_DB>(2261);
var DataColl = this.Siemens_PLC_S7.ReadClass<XL_DataColl_DB>(2291);
if (Start != null && Start.Order_Request == false && GVL_SmallStation.IsAllowSiemensSendRecipe)
{
res.Order_Request_ACK = true;
this.Siemens_PLC_S7.WriteClass<XL_Start_DB>(res, 1);
Start.Order_Request = true;
this.Siemens_PLC_S7.WriteClass<XL_Start_DB>(Start, 1);
}
if (res != null && RTrig.GetInstance("RecipeTrig").Start(res.Order_Request_ACK))
if (Start != null && RTrig.GetInstance("RecipeTrig").Start(Start.Order_Request_ACK))
{
ActionManage.GetInstance.Send("SiemensRecipeRecive", res);
res.Order_Request_ACK = false;
this.Siemens_PLC_S7.WriteClass<XL_Start_DB>(res, 1);
ActionManage.GetInstance.Send("SiemensRecipeRecive", Start);
Start.Order_Request_ACK = false;
this.Siemens_PLC_S7.WriteClass<XL_Start_DB>(Start, 1);
}
if (res1 != null && RTrig.GetInstance("Allow_AGV_Put[0]").Start(res1.Agv1))
if (Status != null && RTrig.GetInstance("Allow_AGV_Put[0]").Start(Status.AgvRequestPut))
{
ActionManage.GetInstance.Send("AGV到工位1信号",res1);
res1.Agv1 = false;
this.Siemens_PLC_S7.WriteClass<XL_Status_DB>(res1, 2);
ActionManage.GetInstance.Send("AGV放货架到位",Status);
Status.AgvRequestPut = false;
this.Siemens_PLC_S7.WriteClass<XL_Status_DB>(Status, 2);
}
if (res1 != null && RTrig.GetInstance("Allow_AGV_Put[1]").Start(res1.Agv2))
if (Status != null && RTrig.GetInstance("Allow_AGV_Put[1]").Start(Status.AgvRequestGet))
{
ActionManage.GetInstance.Send("AGV到工位2信号",res1);
res1.Agv1 = false;
this.Siemens_PLC_S7.WriteClass<XL_Status_DB>(res1, 2);
}

if (res2 != null && res2.Ask_For_Finish_PLC)
{
ActionManage.GetInstance.Send("配料完成信号确认完成");
res2.Ask_For_Finish_PLC = false;
this.Siemens_PLC_S7.WriteClass<XL_Finish_DB>(res2, 3);
ActionManage.GetInstance.Send("AGV取货架到位", Status);
Status.AgvRequestGet = false;
this.Siemens_PLC_S7.WriteClass<XL_Status_DB>(Status, 2);
}
Thread.Sleep(10);
}),"监听服务数据");
}


+ 41
- 19
BPASmartClient.JXJFoodSmallStation/Model/Siemens/XL_DataColl_DB.cs View File

@@ -13,27 +13,49 @@ namespace BPASmartClient.JXJFoodSmallStation.Model.Siemens
public string RecipeCode { get; set; }
[Siemens(16)]
public string RecipeName { get; set; }
public bool var1 { get; set; }
public bool var2 { get; set; }

public bool var3 { get; set; }

public bool var4 { get; set; }

public bool var5 { get; set; }

public bool var6 { get; set; }

public bool var7 { get; set; }

public bool var8 { get; set; }

public bool var9 { get; set; }
public bool RawMaterialLack { get; set; }
/// <summary>
/// 上游缺料
/// </summary>
public bool TopInComplete { get; set; }
/// <summary>
/// 下游堵料
/// </summary>
public bool DownPutty { get; set; }
/// <summary>
/// 系统启动
/// </summary>
public bool SystemStart { get; set; }
/// <summary>
/// 系统停止
/// </summary>
public bool SystemStop { get; set; }
/// <summary>
/// 系统急停
/// </summary>
public bool SystemEStop { get; set; }
/// <summary>
/// 系统暂停
/// </summary>
public bool SystemPause { get; set; }
/// <summary>
/// 系统故障
/// </summary>
public bool SystemAlarm { get; set; }
/// <summary>
/// PLC心跳
/// </summary>
public bool HeartBeatWithPLC { get; set; }
/// <summary>
/// 系统模式
/// </summary>
public short Mode { get; set; }

/// <summary>
/// 报警
/// </summary>
public bool[] Alarm { get; set; } = new bool[24];
public int Reserved1 { get; set; }
public int Reserved2 { get; set; }
public int Standby1 { get; set; }
public int Standby2 { get; set; }

}
}

+ 21
- 2
BPASmartClient.JXJFoodSmallStation/Model/Siemens/XL_Finish_DB.cs View File

@@ -9,7 +9,6 @@ namespace BPASmartClient.JXJFoodSmallStation.Model.Siemens
{
internal class XL_Finish_DB
{

/// <summary>
/// 配料完成信号确认
/// </summary>
@@ -27,12 +26,18 @@ namespace BPASmartClient.JXJFoodSmallStation.Model.Siemens
/// 产品名称
/// </summary>
public string Product_Code { get; set; }
/// <summary>
/// 工位号
/// </summary>
public short Job_No { get; set; }
public UDT2[] Powder { get; set; } = new UDT2[10];
/// <summary>
/// 原料信息
/// </summary>
public UDT1[] Material { get; set; } = new UDT1[20];
/// <summary>
/// 配料时间
/// </summary>
public short DosingTime { get; set; }
/// <summary>
/// 配料完成信号
@@ -43,16 +48,30 @@ namespace BPASmartClient.JXJFoodSmallStation.Model.Siemens
}
public class UDT1
{

/// <summary>
/// 原料名称
/// </summary>
[Siemens(6)]
public string Material_Name { get; set; }
/// <summary>
/// 原料下料重量
/// </summary>
public float Material_Laying_Off_Weight { get; set; }
/// <summary>
/// 原料的桶号
/// </summary>
public short Material_BarrelNum { get; set; }
}
public class UDT2
{
/// <summary>
/// 粉料仓名称
/// </summary>
[Siemens(6)]
public string Powder_Name { get; set; }
/// <summary>
/// 粉料仓重量
/// </summary>
public float Powder_Weight { get; set; }
}
}

+ 16
- 3
BPASmartClient.JXJFoodSmallStation/Model/Siemens/XL_Start_DB.cs View File

@@ -19,8 +19,13 @@ namespace BPASmartClient.JXJFoodSmallStation.Model.Siemens
/// 配发名称
/// </summary>
public string RecipeName { get; set; }

/// <summary>
/// 工站的编号
/// </summary>
public short StockCode { get; set; }
/// <summary>
/// 托盘编号
/// </summary>
public short TrayCode { get; set; }

public UDT2Start[] Powder { get; set; } = new UDT2Start[10];
@@ -29,11 +34,13 @@ namespace BPASmartClient.JXJFoodSmallStation.Model.Siemens
/// </summary>
public UDTStart[] Material { get; set; } = new UDTStart[20];
/// <summary>
/// plc确认配方接收完成
/// 西门子下发订单
/// </summary>
public bool Order_Request_ACK { get; set; }
public short[] Standby { get; set; } = new short[4];

/// <summary>
/// 上位机订单请求
/// </summary>
public bool Order_Request { get; set; }
public short[] Standby1 { get; set; } = new short[4];

@@ -58,8 +65,14 @@ namespace BPASmartClient.JXJFoodSmallStation.Model.Siemens

public class UDT2Start
{
/// <summary>
/// 粉料仓名称
/// </summary>
[Siemens(6)]
public string Powder_Name { get; set; }
/// <summary>
/// 粉料仓重量
/// </summary>
public float Powder_Weight { get; set; }
}
}

+ 62
- 16
BPASmartClient.JXJFoodSmallStation/Model/Siemens/XL_Status_DB.cs View File

@@ -9,14 +9,34 @@ namespace BPASmartClient.JXJFoodSmallStation.Model.Siemens
{
public class XL_Status_DB
{
/// <summary>
/// 配料开始确认
/// </summary>
public bool Dosing_Confirm { get; set; }
public bool Agv1 { get; set; }
public bool Agv2 { get; set; }
public bool Agv3 { get; set; }
public bool Agv4 { get; set; }
public short AgvPos { get; set; }
public short[] Standby { get; set; } = new short[3];

/// <summary>
/// AGV请求放货架
/// </summary>
public bool AgvRequestPut { get; set; }
/// <summary>
/// AGV请求取货架
/// </summary>
public bool AgvRequestGet { get; set; }
/// <summary>
/// Agv放托盘完成
/// </summary>
public short AgvFinishPut { get; set; }
/// <summary>
/// AGV取托盘完成
/// </summary>
public short AgvFinishGet { get; set; }
/// <summary>
/// AGV取放位置
/// </summary>
public short AgvGetPutPos { get; set; }
/// <summary>
/// 备用
/// </summary>
public short[] Standby { get; set; } = new short[1];
[Siemens(16)]
/// <summary>
/// 生产工单
@@ -26,20 +46,46 @@ namespace BPASmartClient.JXJFoodSmallStation.Model.Siemens
/// 配料开始
/// </summary>
public bool Dosing_Start { get; set; }
public bool Agv5 { get; set; }
public bool Agv6 { get; set; }
public bool Agv7 { get; set; }

public UDTStatus[] Powder { get; set; } = new UDTStatus[10];

public short AgvUse { get; set; }
public short[] StandbyStatus { get; set; } = new short[4];
/// <summary>
/// 工位允许取货架
/// </summary>
public bool StationAllowGet { get; set; }
/// <summary>
/// 工位允许放货架
/// </summary>
public bool StationAllowPut { get; set; }
/// <summary>
/// 工位允许取空货架
/// </summary>
public bool StationAllowGetEmpty { get; set; }
public PowderStatus[] Powder { get; set; } = new PowderStatus[10];
/// <summary>
/// 托盘占用情况
/// </summary>
public short TrayUse { get; set; }
/// <summary>
/// 托盘占用情况
/// </summary>
public short Permit_Pos { get; set; }
/// <summary>
/// 备用
/// </summary>
public short[] StandbyStatus { get; set; } = new short[3];
}
public class UDTStatus
public class PowderStatus
{
/// <summary>
/// 粉料名称
/// </summary>
[Siemens(6)]
public string Powder_Name { get; set; }
/// <summary>
/// 粉料仓剩余重量
/// </summary>
public float Powder_Weight { get; set; }
/// <summary>
/// 粉料仓下料重量
/// </summary>
public float Powder_LayingOff_Weight { get; set; }
}
}

+ 2
- 2
BPASmartClient.JXJFoodSmallStation/Model/WindSend/WindSendDeviceStatus.cs View File

@@ -24,7 +24,7 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
{
ThreadManage.GetInstance().StartLong(new Action(() =>
{
var res = this.Siemens_PLC_S7.ReadClass<XL_WindSendData_DB>(5);
/*var res = this.Siemens_PLC_S7.ReadClass<XL_WindSendData_DB>(5);
if(RTrig.GetInstance("CurrentCompleteSign").Start(res.CurrentCompleteSign))
{
ActionManage.GetInstance.Send("WindSendDosingFinish");
@@ -53,7 +53,7 @@ namespace BPASmartClient.JXJFoodSmallStation.Model
if (res.RawMaterial5_StockBinWeight < weightAlarmStockBin5)
{
NoticeDemoViewModel.OpenMsg(EnumPromptType.Warn, App.MainWindow, "警告", $"料仓5缺料!");
}
}*/
Thread.Sleep(10);
}),"监听服务数据");
}


+ 96
- 27
BPASmartClient.JXJFoodSmallStation/Model/WindSend/XL_WindSendData_DB.cs View File

@@ -1,4 +1,5 @@
using System;
using BPASmartClient.S7Net;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
@@ -8,31 +9,99 @@ namespace BPASmartClient.JXJFoodSmallStation.Model.WindSend
{
public class XL_WindSendData_DB
{
public string TargetRecipeCode;
public string CurrentRecipeCode;
public bool CurrentCompleteSign;
public float RawMaterial1_SetWeight;
public float RawMaterial2_SetWeight;
public float RawMaterial3_SetWeight;
public float RawMaterial4_SetWeight;
public float RawMaterial5_SetWeight;

public float RawMaterial1_FinishWeight;
public float RawMaterial2_FinishWeight;
public float RawMaterial3_FinishWeight;
public float RawMaterial4_FinishWeight;
public float RawMaterial5_FinishWeight;

public float RawMaterial1_CurrentWeight;
public float RawMaterial2_CurrentWeight;
public float RawMaterial3_CurrentWeight;
public float RawMaterial4_CurrentWeight;
public float RawMaterial5_CurrentWeight;

public float RawMaterial1_StockBinWeight;
public float RawMaterial2_StockBinWeight;
public float RawMaterial3_StockBinWeight;
public float RawMaterial4_StockBinWeight;
public float RawMaterial5_StockBinWeight;
/// <summary>
/// 目标配方编码
/// </summary>
[Siemens(6)]
public string TargetRecipeCode { get; set; }
/// <summary>
/// 当前配方编码
/// </summary>
[Siemens(6)]
public string CurrentRecipeCode { get; set; }
/// <summary>
/// 当前制作完成信号
/// </summary>
public bool CurrentCompleteSign { get; set; }
/// <summary>
/// 原料1设定重量
/// </summary>
public float RawMaterial1_SetWeight { get; set; }
/// <summary>
/// 原料2设定重量
/// </summary>
public float RawMaterial2_SetWeight { get; set; }
/// <summary>
/// 原料3设定重量
/// </summary>
public float RawMaterial3_SetWeight { get; set; }
/// <summary>
/// 原料4设定重量
/// </summary>
public float RawMaterial4_SetWeight { get; set; }
/// <summary>
/// 原料5设定重量
/// </summary>
public float RawMaterial5_SetWeight { get; set; }
/// <summary>
/// 原料1下料完成重量
/// </summary>
public float RawMaterial1_FinishWeight { get; set; }
/// <summary>
/// 原料2下料完成重量
/// </summary>
public float RawMaterial2_FinishWeight { get; set; }
/// <summary>
/// 原料3下料完成重量
/// </summary>
public float RawMaterial3_FinishWeight { get; set; }
/// <summary>
/// 原料4下料完成重量
/// </summary>
public float RawMaterial4_FinishWeight { get; set; }
/// <summary>
/// 原料5下料完成重量
/// </summary>
public float RawMaterial5_FinishWeight { get; set; }
/// <summary>
/// 原料1当前出料重量
/// </summary>
public float RawMaterial1_CurrentWeight { get; set; }
/// <summary>
/// 原料2当前出料重量
/// </summary>
public float RawMaterial2_CurrentWeight { get; set; }
/// <summary>
/// 原料3当前出料重量
/// </summary>
public float RawMaterial3_CurrentWeight { get; set; }
/// <summary>
/// 原料4当前出料重量
/// </summary>
public float RawMaterial4_CurrentWeight { get; set; }
/// <summary>
/// 原料5当前出料重量
/// </summary>
public float RawMaterial5_CurrentWeight { get; set; }
/// <summary>
/// 原料1当前出料重量
/// </summary>
public float RawMaterial1_StockBinWeight { get; set; }
/// <summary>
/// 原料2料仓剩余重量
/// </summary>
public float RawMaterial2_StockBinWeight { get; set; }
/// <summary>
/// 原料3料仓剩余重量
/// </summary>
public float RawMaterial3_StockBinWeight { get; set; }
/// <summary>
/// 原料4料仓剩余重量
/// </summary>
public float RawMaterial4_StockBinWeight { get; set; }
/// <summary>
/// 原料5料仓剩余重量
/// </summary>
public float RawMaterial5_StockBinWeight { get; set; }
}
}

+ 2
- 0
DosingSystem/App.xaml.cs View File

@@ -28,6 +28,8 @@ namespace BPASmartClient.DosingSystem
BPASmartClient.Helper.SystemHelper.GetInstance.CreateDesktopShortcut();
MenuInit();
DataInit();
string ip = "192.168.0.15";
SiemensDevice.GetInstance.Connect(ip);
DeviceInquire.GetInstance.Init();//配料机设备上线监听,设备列表初始化
MainView mv = new MainView();



+ 11
- 7
DosingSystem/Service/SiemensDevice.cs View File

@@ -38,15 +38,19 @@ namespace BPASmartClient.DosingSystem

ThreadManage.GetInstance().StartLong(new Action(() =>
{
//GlobalDevice.PlcData = MySiemens.ReadClass<PlcToComputer>(3);//获取PLC到上位机的数据
var res = MySiemens.Read(DataType.DataBlock, 4, 134, VarType.Word, 32);
if (res != null && res is ushort[] ushorts && ushorts.Length == 32)
if (IsConnect)
{
GlobalDevice.MotorSpeed = ushorts;
//测试使用
GlobalDevice.PlcData = MySiemens.ReadClass<PlcToComputer>(3);//获取PLC到上位机的数据
var res = MySiemens.Read(DataType.DataBlock, 4, 134, VarType.Word, 32);
if (res != null && res is ushort[] ushorts && ushorts.Length == 32)
{
GlobalDevice.MotorSpeed = ushorts;
}
GlobalDevice.MotorControl = MySiemens.Read<uint>("DB5.DBD6");//获取输送带控制信号
//GlobalDevice.MotorControlFeedback = MySiemens.Read<uint>("DB3.DBD0");//获取当前输送带运行状态
Thread.Sleep(50);
}
GlobalDevice.MotorControl = MySiemens.Read<uint>("DB5.DBD6");//获取输送带控制信号
//GlobalDevice.MotorControlFeedback = MySiemens.Read<uint>("DB3.DBD0");//获取当前输送带运行状态
Thread.Sleep(50);
}), "读取输送线设备数据", true);

}


+ 97
- 31
DosingSystem/ViewModel/RecipeControlViewModel.cs View File

@@ -128,7 +128,38 @@ namespace BPASmartClient.DosingSystem.ViewModel
SiemensDevice.GetInstance.MySiemens.Write("DB4.DBD198", recipeData.Count);//配方使用桶数写入
SiemensDevice.GetInstance.MySiemens.Write("DB4.DBX0.1", true);//配方执行启动
Stopwatch sw = new Stopwatch();
App.Current.Dispatcher.Invoke(() => { recipeProcesses.Add(Recipes.ElementAt(index)); });
var recipe = Recipes.ElementAt(index);
ObservableCollection<RawMaterialModel> RawMater = new ObservableCollection<RawMaterialModel>();
foreach (var item in recipe.RawMaterials)
{
RawMater.Add(new RawMaterialModel() {
RawMaterialName = item.RawMaterialName,
DeviceIp = item.DeviceIp,
DownLimtFeedback = item.DownLimtFeedback,
Loc = item.Loc,
RawMaterialId = item .RawMaterialId,
RawMaterialSource = item.RawMaterialSource,
RawMaterialType = item.RawMaterialType,
RawMaterialWeight = item.RawMaterialWeight,
RecipeStatus = item.RecipeStatus,
SelectIndex = item.SelectIndex,
Status = item.Status,
UpLimtFeedback = item.UpLimtFeedback,
UpLimtWeightFeedback = item.UpLimtWeightFeedback,
WeightFeedback = item.WeightFeedback,
});
}
App.Current.Dispatcher.Invoke(() =>
{
recipeProcesses.Add(new RecipeModel()
{
RawMaterials = RawMater,
IsEnable = recipe.IsEnable,
RecipeName = recipe.RecipeName,
SerialNum = recipe.SerialNum,
RecipCode = recipe.RecipCode,
});
});
sw.Restart();
while (true)
{
@@ -148,17 +179,45 @@ namespace BPASmartClient.DosingSystem.ViewModel

Recipes.ElementAt(index).Are.WaitOne();//阻塞,直到当前配方完成
RecipeNames.TryDequeue(out string deviceName);
App.Current.Dispatcher.Invoke(new Action(() =>
var recipeComple = Recipes.ElementAt(index);
ObservableCollection<RawMaterialModel> RawMaterComple = new ObservableCollection<RawMaterialModel>();
foreach (var item in recipeComple.RawMaterials)
{
UserTreeCompelete.Add(Recipes.ElementAt(index));//当前配方完成后添加到已完成的配方列表
}));
RawMaterComple.Add(new RawMaterialModel()
{
RawMaterialName = item.RawMaterialName,
DeviceIp = item.DeviceIp,
DownLimtFeedback = item.DownLimtFeedback,
Loc = item.Loc,
RawMaterialId = item.RawMaterialId,
RawMaterialSource = item.RawMaterialSource,
RawMaterialType = item.RawMaterialType,
RawMaterialWeight = item.RawMaterialWeight,
RecipeStatus = item.RecipeStatus,
SelectIndex = item.SelectIndex,
Status = item.Status,
UpLimtFeedback = item.UpLimtFeedback,
UpLimtWeightFeedback = item.UpLimtWeightFeedback,
WeightFeedback = item.WeightFeedback,
});
}
App.Current.Dispatcher.Invoke(() =>
{
UserTreeCompelete.Add(new RecipeModel()
{
RawMaterials = RawMaterComple,
IsEnable = recipeComple.IsEnable,
RecipeName = recipeComple.RecipeName,
SerialNum = UserTreeCompelete.Count + 1,
RecipCode = recipeComple.RecipCode,
});
});
App.Current.Dispatcher.Invoke(new Action(() =>
{
recipeProcesses.Clear();
CurrentRecipeName = string.Empty;
}));//完成后清空当前配方
}

}
Thread.Sleep(100);
}), "启动配方下发");
@@ -186,6 +245,7 @@ namespace BPASmartClient.DosingSystem.ViewModel
int index = recipeProcesses.ElementAt(recIndex).RawMaterials.ToList().FindIndex(p => p.RawMaterialName == tempRawMaterialName);
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++)
@@ -193,36 +253,42 @@ namespace BPASmartClient.DosingSystem.ViewModel
if (GlobalDevice.PlcData.IsAllowIngredients[j])
{
int cnt = j + 1;//获取允许配料信号桶号的料仓位置
float weight = Recipes.ElementAt(i).RawMaterials.ElementAt(Array.FindIndex(Recipes.ElementAt(i).RawMaterials.ToArray(), p => p.Loc == cnt)).RawMaterialWeight;
string deviceName = DeviceInquire.GetInstance.devices.ElementAt(Array.FindIndex(DeviceInquire.GetInstance.devices.ToArray(), p => p.DeviceNum == cnt)).DeviceName;
int loc = Array.FindIndex(Recipes.ElementAt(i).RawMaterials.ToArray(), p => p.RawMaterialName == deviceName);
if (cnt > 0 && loc >= 0 && deviceName != null && weight >= 0)
int Raw_Loc = Array.FindIndex(Recipes.ElementAt(i).RawMaterials.ToArray(), p => p.Loc == cnt);
int Device_Loc = Array.FindIndex(DeviceInquire.GetInstance.devices.ToArray(), p => p.DeviceNum == cnt);
if (Raw_Loc >= 0 && Device_Loc >= 0)
{
int St_index = Array.FindIndex(StockStatus.ToArray(), p => p.MaterialName == deviceName);
if (St_index < 0)
float weight = Recipes.ElementAt(i).RawMaterials.ElementAt(Raw_Loc).RawMaterialWeight;
string deviceName = DeviceInquire.GetInstance.devices.ElementAt(Device_Loc).DeviceName;
int loc = Array.FindIndex(Recipes.ElementAt(i).RawMaterials.ToArray(), p => p.RawMaterialName == deviceName);
if (cnt > 0 && loc >= 0 && deviceName != null && weight >= 0)
{
StockStatus.Add(new StockStatusModel()
int St_index = Array.FindIndex(StockStatus.ToArray(), p => p.MaterialName == deviceName);
if (St_index < 0)
{
MaterialName = deviceName,
IssueWeight = weight,
IssueStatus = 0,
});
}
St_index = Array.FindIndex(StockStatus.ToArray(), p => p.MaterialName == deviceName);
if (St_index >= 0)
{
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);
MessageNotify.GetInstance.ShowRunLog($"柔性味魔方{Recipes.ElementAt(i).RawMaterials.ElementAt(loc).DeviceIp},开始出料");
StockStatus.Add(new StockStatusModel()
{
MaterialName = deviceName,
IssueWeight = weight,
IssueStatus = 0,
});
}
if (recipeProcesses.ElementAt(recIndex).RawMaterials.ElementAt(loc).RecipeStatus == 3 && StockStatus.ElementAt(St_index).IssueStatus == 1)
St_index = Array.FindIndex(StockStatus.ToArray(), p => p.MaterialName == deviceName);
if (St_index >= 0)
{
StockStatus.ElementAt(St_index).IssueStatus = 2;
DeviceInquire.GetInstance.GetDevice(Recipes.ElementAt(i).RawMaterials.ElementAt(loc).DeviceIp).StatusReset();
SiemensDevice.GetInstance.MySiemens.Write("DB4.DBD130", 0.SetBitValue((byte)loc, true));
MessageNotify.GetInstance.ShowRunLog($"柔性味魔方{Recipes.ElementAt(i).RawMaterials.ElementAt(loc).DeviceIp},出料完成,状态复位");
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);
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;//测试使用
StockStatus.ElementAt(St_index).IssueStatus = 2;
DeviceInquire.GetInstance.GetDevice(Recipes.ElementAt(i).RawMaterials.ElementAt(loc).DeviceIp).StatusReset();
SiemensDevice.GetInstance.MySiemens.Write("DB4.DBD130", 0.SetBitValue((byte)loc, true));
MessageNotify.GetInstance.ShowRunLog($"柔性味魔方{Recipes.ElementAt(i).RawMaterials.ElementAt(loc).DeviceIp},出料完成,状态复位");
}
}
}
}
@@ -238,8 +304,8 @@ namespace BPASmartClient.DosingSystem.ViewModel
Recipes.ElementAt(recipIndex).IsEnable = true;
Json<LocaPar>.Data.Recipes.ElementAt(recipIndex).IsEnable = true;
Recipes.ElementAt(recipIndex).Are.Set();
Thread.Sleep(100);
}

}
}
}


Loading…
Cancel
Save