@@ -95,7 +95,7 @@ namespace BPASmartClient.JXJFoodBigStation.Model.HK_PLC | |||
/// <summary> | |||
/// 工位上是否有小车 | |||
/// </summary> | |||
public static string StationIsExistCar { get; set; } = "M4007"; | |||
public static string StationIsExistTray { get; set; } = "M4007"; | |||
#endregion | |||
} | |||
} |
@@ -106,7 +106,7 @@ namespace BPASmartClient.JXJFoodBigStation.Model | |||
string Siemens_PLC_IP = ConfigurationManager.AppSettings["Siemens_IP"]; | |||
try | |||
{ | |||
//HKDevice.HK_PLC_S7.Connect(S7.Net.CpuType.S7200Smart, HK_PLC_IP); | |||
//HKDevice.HK_PLC_S7.Connect(S7.Net.CpuType.S71500, HK_PLC_IP); | |||
//SiemensDevice.Siemens_PLC_S7.Connect(S7.Net.CpuType.S71500, Siemens_PLC_IP); | |||
if (HKDevice.IsConnected) | |||
{ | |||
@@ -190,28 +190,28 @@ namespace BPASmartClient.JXJFoodBigStation.Model | |||
/// <param name="bitNum"></param> | |||
private void AGV_Pick(int bitNum) | |||
{ | |||
if (ReadSiemens("M4003"+ bitNum) is bool && BigStation.AgvPickUpPosition == 0) | |||
if (ReadSiemens("M4003."+ bitNum) is bool && BigStation.AgvPickUpPosition == 0) | |||
{ | |||
BigStation.AgvPickUpPosition = 1; | |||
WriteHKPLC("M4003" + bitNum, true); | |||
WriteSiemens("M4003" + bitNum, false); | |||
WriteHKPLC("M4003." + bitNum, true); | |||
WriteSiemens("M4003." + bitNum, false); | |||
} | |||
if (ReadHK("M5003" + bitNum) is bool && BigStation.AgvPickUpPosition == 1) | |||
if (ReadHK("M5003." + bitNum) is bool && BigStation.AgvPickUpPosition == 1) | |||
{ | |||
BigStation.AgvPickUpPosition = 2; | |||
WriteSiemens("M5003" + bitNum, true); | |||
WriteHKPLC("M5003" + bitNum,false); | |||
WriteSiemens("M5003." + bitNum, true); | |||
WriteHKPLC("M5003." + bitNum,false); | |||
} | |||
if (ReadSiemens("M4006" + bitNum) is bool && BigStation.AgvPickUpPosition == 2) | |||
if (ReadSiemens("M4006." + bitNum) is bool && BigStation.AgvPickUpPosition == 2) | |||
{ | |||
BigStation.AgvPickUpPosition = 3; | |||
WriteHKPLC("M4006" + bitNum, true); | |||
WriteSiemens("M4006" + bitNum, false); | |||
WriteHKPLC("M4006." + bitNum, true); | |||
WriteSiemens("M4006." + bitNum, false); | |||
} | |||
if (ReadHK("M5006" + bitNum) is bool && BigStation.AgvPickUpPosition == 3) | |||
if (ReadHK("M5006." + bitNum) is bool && BigStation.AgvPickUpPosition == 3) | |||
{ | |||
WriteSiemens("M5006" + bitNum, true); | |||
WriteHKPLC("M5006" + bitNum, false); | |||
WriteSiemens("M5006." + bitNum, true); | |||
WriteHKPLC("M5006." + bitNum, false); | |||
} | |||
} | |||
/// <summary> | |||
@@ -221,26 +221,26 @@ namespace BPASmartClient.JXJFoodBigStation.Model | |||
{ | |||
//获取工位上是否有小车 | |||
SiemensDevice.Siemens_PLC_S7.Write(SiemensCommAddress.StationIsExistCar, (bool) | |||
HKDevice.HK_PLC_S7.Read(HKPlcCommAddress.StationIsExistCar)); | |||
HKDevice.HK_PLC_S7.Read(HKPlcCommAddress.StationIsExistTray)); | |||
//检测AGV到站信号 | |||
if (AGVToWorkStationQueue.Count > 0) | |||
{ | |||
int index = Array.FindIndex(RemoteRecipes.ToArray(), p => p.RecipeCode == AGVToWorkStationQueue.ElementAt(0)); | |||
int TrayLocation = RemoteRecipes.ElementAt(index).TrayCode;//根据配方编号,找到托盘的ID 托盘ID1-6 | |||
int recipe = (int)RemoteRecipes.ElementAt(index).RecipeCode; | |||
int RecipeCode = (int)RemoteRecipes.ElementAt(index).RecipeCode; | |||
if (TrayLocation > 0 && TrayLocation < 7) | |||
{ | |||
AGV_Delivery(TrayLocation - 1); | |||
if (BigStation.AgvDeliveryPosition == 5) | |||
{ | |||
BigStation.AgvDeliveryPosition = 0; | |||
AGVToWorkStationQueue.TryDequeue(out recipe); | |||
//AGVToWorkStationQueue.TryDequeue(out RecipeCode); | |||
} | |||
AGV_Pick(TrayLocation - 1); | |||
if (BigStation.AgvPickUpPosition == 3) | |||
{ | |||
BigStation.AgvPickUpPosition = 0; | |||
AGVToWorkStationQueue.TryDequeue(out recipe); | |||
AGVToWorkStationQueue.TryDequeue(out RecipeCode); | |||
} | |||
} | |||
} | |||
@@ -293,6 +293,8 @@ namespace BPASmartClient.JXJFoodBigStation.Model | |||
} | |||
public ConcurrentDictionary<string, Object> ReadHKPLCData = new ConcurrentDictionary<string, object>(); | |||
public ConcurrentDictionary<string, Object> ReadSiemensData = new ConcurrentDictionary<string, object>(); | |||
private void ReadSiemensCommData() | |||
{ | |||
if (SiemensDevice.IsConnected) | |||
@@ -310,7 +312,13 @@ namespace BPASmartClient.JXJFoodBigStation.Model | |||
{ | |||
if (HKDevice.IsConnected) | |||
{ | |||
GetSiemensStatus("", new Action<object>((obj) => | |||
{ | |||
if (obj is bool[] bools && bools.Length > 0) | |||
{ | |||
} | |||
})); | |||
} | |||
} | |||
private void GetHKStatus(string key,Action<object> action) | |||
@@ -105,6 +105,25 @@ namespace BPASmartClient.JXJFoodSmallStation | |||
}); | |||
#endregion | |||
#region 手动控制 | |||
ObservableCollection<SubMenumodel> ManualControl = new ObservableCollection<SubMenumodel>(); | |||
ManualControl.Add(new SubMenumodel() | |||
{ | |||
SubMenuName = "手动控制", | |||
SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.技术员 }, | |||
AssemblyName = "BPASmartClient.JXJFoodSmallStation", | |||
ToggleWindowPath = "View.ManualControlView" | |||
}); | |||
MenuManage.GetInstance.menuModels.Add(new MenuModel() | |||
{ | |||
MainMenuIcon = "", | |||
MainMenuName = "手动控制", | |||
Alias = "Parameter Set", | |||
subMenumodels = ManualControl, | |||
}); | |||
#endregion | |||
#region 消息日志 | |||
ObservableCollection<SubMenumodel> InfoLog = new ObservableCollection<SubMenumodel>(); | |||
InfoLog.Add(new SubMenumodel() | |||
@@ -32,6 +32,9 @@ | |||
<Page Update="View\HardwareStatusView.xaml"> | |||
<XamlRuntime>$(DefaultXamlRuntime)</XamlRuntime> | |||
</Page> | |||
<Page Update="View\ManualControlView.xaml"> | |||
<XamlRuntime>$(DefaultXamlRuntime)</XamlRuntime> | |||
</Page> | |||
<Page Update="View\NewMaterialView.xaml"> | |||
<XamlRuntime>$(DefaultXamlRuntime)</XamlRuntime> | |||
</Page> | |||
@@ -11,20 +11,25 @@ namespace BPASmartClient.JXJFoodSmallStation.Model | |||
{ | |||
public class GVL_SmallStation | |||
{ | |||
/// <summary> | |||
/// 往输送带下发配方完成 | |||
/// </summary> | |||
public bool IssueRecipeFinishStation1 { get; set; } = false; | |||
/// <summary> | |||
/// 配方数据 | |||
/// 托盘1配方下发状态 =0:配方未下发 ,1:配方下发给plc ,2:plc成功接收配方 | |||
/// </summary> | |||
public ObservableCollection<RemoteRecipeData> RemoteRecipes = new ObservableCollection<RemoteRecipeData>(); | |||
public int RecipeStatusIDTray1 { get; set; } = 0; | |||
/// <summary> | |||
/// 配方队列 | |||
/// 托盘2配方下发状态 =0:配方未下发 ,1:配方下发给plc ,2:plc成功接收配方 | |||
/// </summary> | |||
public ConcurrentQueue<long> RecipeQueue = new ConcurrentQueue<long>(); | |||
public int RecipeStatusIDTray2 { get; set; } = 0; | |||
/// <summary> | |||
/// 往输送带下发配方完成 | |||
/// </summary> | |||
public bool IssueRecipeFinish { get; set; } = false; | |||
public bool IssueRecipeFinishStation2 { get; set; } = false; | |||
public bool IsAllow { get; set; } = false; | |||
public bool IsAllowOut { set; get; } = false; | |||
@@ -45,5 +50,11 @@ namespace BPASmartClient.JXJFoodSmallStation.Model | |||
/// 记录AGV进站取货的指令顺序 | |||
/// </summary> | |||
public int AgvPickUpPosition { get; set; } = 0; | |||
#region AGV进出站 从HK PLC读取 | |||
public bool Agv { get; set; } = false; | |||
#endregion | |||
} | |||
} |
@@ -44,11 +44,11 @@ namespace BPASmartClient.JXJFoodSmallStation.Model.HK_PLC | |||
public static string RecipeDosingFinish { get; set; } = ""; | |||
#endregion | |||
#region AGV进出站 | |||
#region AGV进出站1 | |||
/// <summary> | |||
/// Agv送货 进站申请 | |||
/// </summary> | |||
public static string DeliveryAGVApply { get; set; } = ""; | |||
public static string DeliveryAGVApply { get; set; } = "DB3.DBX0.1"; | |||
/// <summary> | |||
/// Agv送货 进站申请 | |||
/// </summary> | |||
@@ -88,7 +88,53 @@ namespace BPASmartClient.JXJFoodSmallStation.Model.HK_PLC | |||
/// <summary> | |||
/// 工位上是否有小车 | |||
/// </summary> | |||
public static string StationIsExistCar { get; set; } = ""; | |||
public static string StationIsExistTray { get; set; } = ""; | |||
#endregion | |||
#region AGV进出站2 | |||
/// <summary> | |||
/// Agv送货 进站申请 | |||
/// </summary> | |||
public static string DeliveryAGVApplyStation2 { get; set; } = ""; | |||
/// <summary> | |||
/// Agv送货 进站申请 | |||
/// </summary> | |||
public static string DeliveryAGVIsApplyStation2 { get; set; } = ""; | |||
/// <summary> | |||
/// Agv送货 进站顶升申请 | |||
/// </summary> | |||
public static string DeliveryAGVApplyJackStation2 { get; set; } = ""; | |||
/// <summary> | |||
/// Agv送货 进站顶升申请 | |||
/// </summary> | |||
public static string DeliveryAGVIsApplyJackStation2 { get; set; } = ""; | |||
/// <summary> | |||
/// Agv送货 送货完成 | |||
/// </summary> | |||
public static string DeliveryAGVFinsihStation2 { get; set; } = ""; | |||
/// <summary> | |||
/// Agv送货 工位上有货架 | |||
/// </summary> | |||
public static string StationHaveCargoStation2 { get; set; } = ""; | |||
/// <summary> | |||
/// Agv送货 进站申请 | |||
/// </summary> | |||
public static string PickAGVApplyStation2 { get; set; } = ""; | |||
/// <summary> | |||
/// Agv送货 进站申请 | |||
/// </summary> | |||
public static string PickAGVIsApplyStation2 { get; set; } = ""; | |||
/// <summary> | |||
/// Agv送货 取货架完成 | |||
/// </summary> | |||
public static string PickCargoAGVFinishStation2 { get; set; } = ""; | |||
/// <summary> | |||
/// Agv送货 取料完成 | |||
/// </summary> | |||
public static string PickAGVFinishStation2 { get; set; } = ""; | |||
/// <summary> | |||
/// 工位上是否有货架 | |||
/// </summary> | |||
public static string StationIsExistTrayStation2 { get; set; } = ""; | |||
#endregion | |||
} | |||
} |
@@ -1,4 +1,5 @@ | |||
using BPASmartClient.Helper; | |||
using BPASmartClient.CustomResource.Pages.Model; | |||
using BPASmartClient.Helper; | |||
using BPASmartClient.JXJFoodSmallStation.Model.HK_PLC; | |||
using BPASmartClient.JXJFoodSmallStation.Model.Siemens; | |||
using BPASmartClient.Modbus; | |||
@@ -21,6 +22,18 @@ namespace BPASmartClient.JXJFoodSmallStation.Model | |||
private ProcessControl() { } | |||
public ObservableCollection<RemoteRecipeRawMaterial> RawMaterials { get; set; } = new ObservableCollection<RemoteRecipeRawMaterial>(); | |||
/// <summary> | |||
/// 配方数据 | |||
/// </summary> | |||
public ObservableCollection<RemoteRecipeData> RemoteRecipes = new ObservableCollection<RemoteRecipeData>(); | |||
/// <summary> | |||
/// 托盘1 配方队列 | |||
/// </summary> | |||
public ConcurrentQueue<long> RecipeTray1Queue = new ConcurrentQueue<long>(); | |||
/// <summary> | |||
/// 托盘2 配方队列 | |||
/// </summary> | |||
public ConcurrentQueue<long> RecipeTray2Queue = new ConcurrentQueue<long>(); | |||
public SiemensDeviceStatus SiemensDevice = new SiemensDeviceStatus(); | |||
public HKDeviceStatus HKDevice = new HKDeviceStatus(); | |||
@@ -96,7 +109,7 @@ namespace BPASmartClient.JXJFoodSmallStation.Model | |||
{ | |||
} | |||
SmallStation.RecipeQueue.Clear(); | |||
RecipeTray1Queue.Clear(); | |||
//Json<RemoteRecipeDataColl>.Data.Recipes = TestData.GetInstance.Recipes;//添加测试数据 | |||
ThreadManage.GetInstance().StartLong(new Action(() => | |||
{ | |||
@@ -113,6 +126,287 @@ namespace BPASmartClient.JXJFoodSmallStation.Model | |||
} | |||
Thread.Sleep(10); | |||
}), "AGV进站送取货", true); | |||
ThreadManage.GetInstance().StartLong(new Action(() => | |||
{ | |||
if (HKDevice.IsConnected) | |||
{ | |||
ManualOpen(); | |||
ManualClose(); | |||
} | |||
Thread.Sleep(10); | |||
}), "手动操作", true); | |||
} | |||
private void ManualOpen() | |||
{ | |||
ActionManage.GetInstance.Register(new Action<object>((o) => | |||
{ | |||
if (o != null) | |||
{ | |||
if (o.ToString().Contains("升降气缸")) | |||
{ | |||
int index = Convert.ToInt16(o.ToString().Substring(o.ToString().Length - 1)); | |||
switch (index) | |||
{ | |||
case 1: | |||
HKDevice.HK_PLC_S7.Write("", true); | |||
break; | |||
case 2: | |||
HKDevice.HK_PLC_S7.Write("", true); | |||
break; | |||
case 3: | |||
HKDevice.HK_PLC_S7.Write("", true); | |||
break; | |||
case 4: | |||
HKDevice.HK_PLC_S7.Write("", true); | |||
break; | |||
case 5: | |||
HKDevice.HK_PLC_S7.Write("", true); | |||
break; | |||
case 6: | |||
HKDevice.HK_PLC_S7.Write("", true); | |||
break; | |||
case 7: | |||
HKDevice.HK_PLC_S7.Write("", true); | |||
break; | |||
case 8: | |||
HKDevice.HK_PLC_S7.Write("", true); | |||
break; | |||
case 9: | |||
HKDevice.HK_PLC_S7.Write("", true); | |||
break; | |||
case 10: | |||
HKDevice.HK_PLC_S7.Write("", true); | |||
break; | |||
case 11: | |||
HKDevice.HK_PLC_S7.Write("", true); | |||
break; | |||
case 12: | |||
HKDevice.HK_PLC_S7.Write("", true); | |||
break; | |||
case 13: | |||
HKDevice.HK_PLC_S7.Write("", true); | |||
break; | |||
case 14: | |||
HKDevice.HK_PLC_S7.Write("", true); | |||
break; | |||
case 15: | |||
HKDevice.HK_PLC_S7.Write("", true); | |||
break; | |||
default: | |||
break; | |||
} | |||
} | |||
else if (o.ToString().Contains("阻挡气缸")) | |||
{ | |||
int index = Convert.ToInt16(o.ToString().Substring(o.ToString().Length - 1)); | |||
switch (index) | |||
{ | |||
case 1: | |||
HKDevice.HK_PLC_S7.Write("", true); | |||
break; | |||
case 2: | |||
HKDevice.HK_PLC_S7.Write("", true); | |||
break; | |||
case 3: | |||
HKDevice.HK_PLC_S7.Write("", true); | |||
break; | |||
case 4: | |||
HKDevice.HK_PLC_S7.Write("", true); | |||
break; | |||
case 5: | |||
HKDevice.HK_PLC_S7.Write("", true); | |||
break; | |||
case 6: | |||
HKDevice.HK_PLC_S7.Write("", true); | |||
break; | |||
case 7: | |||
HKDevice.HK_PLC_S7.Write("", true); | |||
break; | |||
case 8: | |||
HKDevice.HK_PLC_S7.Write("", true); | |||
break; | |||
case 9: | |||
HKDevice.HK_PLC_S7.Write("", true); | |||
break; | |||
case 10: | |||
HKDevice.HK_PLC_S7.Write("", true); | |||
break; | |||
case 11: | |||
HKDevice.HK_PLC_S7.Write("", true); | |||
break; | |||
case 12: | |||
HKDevice.HK_PLC_S7.Write("", true); | |||
break; | |||
case 13: | |||
HKDevice.HK_PLC_S7.Write("", true); | |||
break; | |||
case 14: | |||
HKDevice.HK_PLC_S7.Write("", true); | |||
break; | |||
case 15: | |||
HKDevice.HK_PLC_S7.Write("", true); | |||
break; | |||
default: | |||
break; | |||
} | |||
} | |||
else if (o.ToString().Contains("托盘气缸")) | |||
{ | |||
int index = Convert.ToInt16(o.ToString().Substring(o.ToString().Length - 1)); | |||
switch (index) | |||
{ | |||
case 1: | |||
HKDevice.HK_PLC_S7.Write("", true); | |||
break; | |||
case 2: | |||
HKDevice.HK_PLC_S7.Write("", true); | |||
break; | |||
default: | |||
break; | |||
} | |||
} | |||
} | |||
}), "ManualOpen", true);//根据下发的配方ID将 托盘的位置信息添加到配方中 | |||
} | |||
private void ManualClose() | |||
{ | |||
ActionManage.GetInstance.Register(new Action<object>((o) => | |||
{ | |||
if (o != null) | |||
{ | |||
if (o.ToString().Contains("升降气缸")) | |||
{ | |||
int index = Convert.ToInt16(o.ToString().Substring(o.ToString().Length - 1)); | |||
switch (index) | |||
{ | |||
case 1: | |||
HKDevice.HK_PLC_S7.Write("", false); | |||
break; | |||
case 2: | |||
HKDevice.HK_PLC_S7.Write("", false); | |||
break; | |||
case 3: | |||
HKDevice.HK_PLC_S7.Write("", false); | |||
break; | |||
case 4: | |||
HKDevice.HK_PLC_S7.Write("", false); | |||
break; | |||
case 5: | |||
HKDevice.HK_PLC_S7.Write("", false); | |||
break; | |||
case 6: | |||
HKDevice.HK_PLC_S7.Write("", false); | |||
break; | |||
case 7: | |||
HKDevice.HK_PLC_S7.Write("", false); | |||
break; | |||
case 8: | |||
HKDevice.HK_PLC_S7.Write("", false); | |||
break; | |||
case 9: | |||
HKDevice.HK_PLC_S7.Write("", false); | |||
break; | |||
case 10: | |||
HKDevice.HK_PLC_S7.Write("", false); | |||
break; | |||
case 11: | |||
HKDevice.HK_PLC_S7.Write("", false); | |||
break; | |||
case 12: | |||
HKDevice.HK_PLC_S7.Write("", false); | |||
break; | |||
case 13: | |||
HKDevice.HK_PLC_S7.Write("", false); | |||
break; | |||
case 14: | |||
HKDevice.HK_PLC_S7.Write("", false); | |||
break; | |||
case 15: | |||
HKDevice.HK_PLC_S7.Write("", false); | |||
break; | |||
default: | |||
break; | |||
} | |||
} | |||
else if (o.ToString().Contains("阻挡气缸")) | |||
{ | |||
int index = Convert.ToInt16(o.ToString().Substring(o.ToString().Length - 1)); | |||
switch (index) | |||
{ | |||
case 1: | |||
HKDevice.HK_PLC_S7.Write("", false); | |||
break; | |||
case 2: | |||
HKDevice.HK_PLC_S7.Write("", false); | |||
break; | |||
case 3: | |||
HKDevice.HK_PLC_S7.Write("", false); | |||
break; | |||
case 4: | |||
HKDevice.HK_PLC_S7.Write("", false); | |||
break; | |||
case 5: | |||
HKDevice.HK_PLC_S7.Write("", false); | |||
break; | |||
case 6: | |||
HKDevice.HK_PLC_S7.Write("", false); | |||
break; | |||
case 7: | |||
HKDevice.HK_PLC_S7.Write("", false); | |||
break; | |||
case 8: | |||
HKDevice.HK_PLC_S7.Write("", false); | |||
break; | |||
case 9: | |||
HKDevice.HK_PLC_S7.Write("", false); | |||
break; | |||
case 10: | |||
HKDevice.HK_PLC_S7.Write("", false); | |||
break; | |||
case 11: | |||
HKDevice.HK_PLC_S7.Write("", false); | |||
break; | |||
case 12: | |||
HKDevice.HK_PLC_S7.Write("", false); | |||
break; | |||
case 13: | |||
HKDevice.HK_PLC_S7.Write("", false); | |||
break; | |||
case 14: | |||
HKDevice.HK_PLC_S7.Write("", false); | |||
break; | |||
case 15: | |||
HKDevice.HK_PLC_S7.Write("", false); | |||
break; | |||
default: | |||
break; | |||
} | |||
} | |||
else if (o.ToString().Contains("托盘气缸")) | |||
{ | |||
int index = Convert.ToInt16(o.ToString().Substring(o.ToString().Length - 1)); | |||
switch (index) | |||
{ | |||
case 1: | |||
HKDevice.HK_PLC_S7.Write("", false); | |||
break; | |||
case 2: | |||
HKDevice.HK_PLC_S7.Write("", false); | |||
break; | |||
default: | |||
break; | |||
} | |||
} | |||
} | |||
}), "ManualClose", true);//根据下发的配方ID将 托盘的位置信息添加到配方中 | |||
} | |||
/// <summary> | |||
/// AGV进站送货 | |||
@@ -168,7 +462,7 @@ namespace BPASmartClient.JXJFoodSmallStation.Model | |||
} | |||
//获取工位上是否有小车 | |||
SiemensDevice.Siemens_PLC_S7.Write(SiemensCommAddress.StationIsExistCar, (bool) | |||
HKDevice.HK_PLC_S7.Read(HKPlcCommAddress.StationIsExistCar)); | |||
HKDevice.HK_PLC_S7.Read(HKPlcCommAddress.StationIsExistTray)); | |||
} | |||
/// <summary> | |||
/// AGV进站取货 | |||
@@ -211,59 +505,252 @@ namespace BPASmartClient.JXJFoodSmallStation.Model | |||
} | |||
private void ReceviceData() | |||
{ | |||
SmallStation.RemoteRecipes = Json<RemoteRecipeDataColl>.Data.Recipes; | |||
if (Json<RemoteRecipeDataColl>.Data.Recipes.Count > 0) | |||
RemoteRecipes = Json<RemoteRecipeDataColl>.Data.Recipes; | |||
if (RemoteRecipes.Count > 0) | |||
{ | |||
foreach (var data in Json<RemoteRecipeDataColl>.Data.Recipes) | |||
foreach (var data in RemoteRecipes) | |||
{ | |||
if(!(SmallStation.RecipeQueue.Contains(data.RecipeCode))) | |||
SmallStation.RecipeQueue.Enqueue(data.RecipeCode); | |||
if (data.TrayCode == 1) | |||
{ | |||
if (!(RecipeTray1Queue.Contains(data.RecipeCode))) | |||
RecipeTray1Queue.Enqueue(data.RecipeCode); | |||
} | |||
else if (data.TrayCode == 2) | |||
{ | |||
if (!(RecipeTray2Queue.Contains(data.RecipeCode))) | |||
RecipeTray2Queue.Enqueue(data.RecipeCode); | |||
} | |||
} | |||
} | |||
} | |||
private void RecipeInfoToHKPLC() | |||
{ | |||
if (SmallStation.RecipeQueue.Count > 0) | |||
if (RecipeTray1Queue.Count > 0) | |||
{ | |||
int index = Array.FindIndex(SmallStation.RemoteRecipes.ToArray(), p => p.RecipeCode == SmallStation.RecipeQueue.ElementAt(0)); | |||
if (index >= 0 && index <= SmallStation.RemoteRecipes.Count) | |||
int index = Array.FindIndex(RemoteRecipes.ToArray(), p => p.RecipeCode == RecipeTray1Queue.ElementAt(0)); | |||
if (index >= 0 && index < RemoteRecipes.Count) | |||
{ | |||
long code = SmallStation.RemoteRecipes.ElementAt(index).RecipeCode; | |||
if (RTrig.GetInstance("IsAllowDosing").Start(HKDevice.HK_PLC_S7.Read(HKPlcCommAddress.IsAllowDosing) is bool a)) | |||
long code = RemoteRecipes.ElementAt(index).RecipeCode; | |||
int trayCode = RemoteRecipes.ElementAt(index).TrayCode; | |||
if (trayCode == 1 && SmallStation.RecipeStatusIDTray1 == 0) | |||
{ | |||
foreach (var item in SmallStation.RemoteRecipes.ElementAt(index).RawMaterial) | |||
if (HKDevice.HK_PLC_S7.Read("DB3.DBX1.5") is bool && SmallStation.RecipeStatusIDTray1 == 0) | |||
{ | |||
HKDevice.StockBinPar((uint)item.RawMaterialBarrelNum, (ushort)item.RawMaterialLocation); | |||
foreach (var item in RemoteRecipes.ElementAt(index).RawMaterial) | |||
{ | |||
HKDevice.StockBinPar((uint)item.RawMaterialBarrelNum, (ushort)item.RawMaterialLocation); | |||
} | |||
HKDevice.HK_PLC_S7.Write("DB3.DBX1.5", false); | |||
HKDevice.HK_PLC_S7.Write("DB4.DBX1.3", true); | |||
SmallStation.RecipeStatusIDTray1 = 1; | |||
} | |||
HKDevice.AllowDosingSignReset(); | |||
SmallStation.IssueRecipeFinish = true; | |||
} | |||
if (RTrig.GetInstance("StockState").Start(HKDevice.HK_PLC_S7.Read(HKPlcCommAddress.StockState) is bool) && SmallStation.IssueRecipeFinish) | |||
{ | |||
var res = HKDevice.HK_PLC_S7.Read(HKPlcCommAddress.StockBinLocation); | |||
if (res != null && res is int loc) | |||
if (HKDevice.HK_PLC_S7.Read("DB3.DBX1.3") is bool && SmallStation.RecipeStatusIDTray1 == 1) | |||
{ | |||
int loc_index = Array.FindIndex(SmallStation.RemoteRecipes.ElementAt(index).RawMaterial.ToArray(), p => p.RawMaterialLocation == loc); | |||
double weight = SmallStation.RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(loc_index).RawMaterialWeight; | |||
if (loc_index >= 1 && loc_index <= 15) | |||
HKDevice.HK_PLC_S7.Write("DB3.DBX1.3", false); | |||
SmallStation.RecipeStatusIDTray1 = 2; | |||
} | |||
if (SmallStation.RecipeStatusIDTray1 == 2) | |||
{ | |||
if (HKDevice.HK_PLC_S7.Read("DB3.DBX50.0") is bool) | |||
{ | |||
var res = HKDevice.HK_PLC_S7.Read("DB3.DBD10"); | |||
if (res != null && res is float loc) | |||
{ | |||
int loc_index = Array.FindIndex(RemoteRecipes.ElementAt(index).RawMaterial.ToArray(), p => p.RawMaterialLocation == loc); | |||
double weight = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(loc_index).RawMaterialWeight; | |||
if (loc_index >= 1 && loc_index <= 15) | |||
{ | |||
DeviceInquire.GetInstance.GetDevice(loc_index)?.Start((uint)weight);//根据料仓编号 启动并写入每个原料重量 | |||
SmallStation.StockInIsWork = loc_index; | |||
HKDevice.HK_PLC_S7.Write("DB3.DBX50.0", false); | |||
} | |||
} | |||
} | |||
else if(HKDevice.HK_PLC_S7.Read("DB3.DBX50.1") is bool) | |||
{ | |||
var res = HKDevice.HK_PLC_S7.Read("DB3.DBD14"); | |||
if (res != null && res is float loc) | |||
{ | |||
int loc_index = Array.FindIndex(RemoteRecipes.ElementAt(index).RawMaterial.ToArray(), p => p.RawMaterialLocation == loc); | |||
double weight = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(loc_index).RawMaterialWeight; | |||
if (loc_index >= 1 && loc_index <= 15) | |||
{ | |||
DeviceInquire.GetInstance.GetDevice(loc_index)?.Start((uint)weight);//启动并写入每个原料重量 | |||
SmallStation.StockInIsWork = loc_index; | |||
HKDevice.HK_PLC_S7.Write("DB3.DBX50.1", false); | |||
} | |||
} | |||
} | |||
else if (HKDevice.HK_PLC_S7.Read("DB3.DBX50.2") is bool) | |||
{ | |||
var res = HKDevice.HK_PLC_S7.Read("DB3.DBD18"); | |||
if (res != null && res is float loc) | |||
{ | |||
int loc_index = Array.FindIndex(RemoteRecipes.ElementAt(index).RawMaterial.ToArray(), p => p.RawMaterialLocation == loc); | |||
double weight = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(loc_index).RawMaterialWeight; | |||
if (loc_index >= 1 && loc_index <= 15) | |||
{ | |||
DeviceInquire.GetInstance.GetDevice(loc_index)?.Start((uint)weight);//启动并写入每个原料重量 | |||
SmallStation.StockInIsWork = loc_index; | |||
HKDevice.HK_PLC_S7.Write("DB3.DBX50.2", false); | |||
} | |||
} | |||
} | |||
else if (HKDevice.HK_PLC_S7.Read("DB3.DBX50.3") is bool) | |||
{ | |||
var res = HKDevice.HK_PLC_S7.Read("DB3.DBD22"); | |||
if (res != null && res is float loc) | |||
{ | |||
int loc_index = Array.FindIndex(RemoteRecipes.ElementAt(index).RawMaterial.ToArray(), p => p.RawMaterialLocation == loc); | |||
double weight = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(loc_index).RawMaterialWeight; | |||
if (loc_index >= 1 && loc_index <= 15) | |||
{ | |||
DeviceInquire.GetInstance.GetDevice(loc_index)?.Start((uint)weight);//启动并写入每个原料重量 | |||
SmallStation.StockInIsWork = loc_index; | |||
HKDevice.HK_PLC_S7.Write("DB3.DBX50.3", false); | |||
} | |||
} | |||
} | |||
for (int i = 1; i < 16; i++) | |||
{ | |||
//DeviceInquire.GetInstance.GetDeviceObject(loc_index)?.Start((uint)weight);//启动并写入每个原料重量 | |||
SmallStation.StockInIsWork = loc_index; | |||
HKDevice.StockStateSignReset(); | |||
if (DeviceInquire.GetInstance.GetDevice(i).deviceStatus.RunStatus == 3) | |||
{ | |||
DeviceInquire.GetInstance.GetDevice(i).StatusReset(); | |||
if (i >= 1 && i <= 8) | |||
{ | |||
HKDevice.HK_PLC_S7.Write("DB4.DBX30."+ (i-1), true); | |||
} | |||
else if (i >= 9 && i <= 15) | |||
{ | |||
HKDevice.HK_PLC_S7.Write("DB4.DBX31." + (i - 9), true); | |||
} | |||
} | |||
} | |||
if (HKDevice.HK_PLC_S7.Read("DB3.DBX1.1") is bool) | |||
{ | |||
var res = Json<RemoteRecipeDataColl>.Data.Recipes.FirstOrDefault(p => p.RecipeCode == code); | |||
MessageLog.GetInstance.ShowRunLog($"托盘1 配方{res.RecipeName}配料完成"); | |||
Json<RemoteRecipeDataColl>.Data.Recipes.Remove(res); | |||
RecipeTray1Queue.TryDequeue(out code); | |||
HKDevice.HK_PLC_S7.Write("DB3.DBX1.1", false); | |||
SmallStation.RecipeStatusIDTray1 = 0; | |||
} | |||
} | |||
} | |||
/*if (RTrig.GetInstance("OutRawMaterialFinish").Start(DeviceInquire.GetInstance.GetDeviceObject(SmallStation.StockInIsWork).modbusTcp.Read(DeviceAddress.OutRawMaterialFinish) is bool)) | |||
} | |||
} | |||
} | |||
if (RecipeTray2Queue.Count > 0) | |||
{ | |||
int index = Array.FindIndex(RemoteRecipes.ToArray(), p => p.RecipeCode == RecipeTray2Queue.ElementAt(0)); | |||
if (index >= 0 && index < RemoteRecipes.Count) | |||
{ | |||
long code = RemoteRecipes.ElementAt(index).RecipeCode; | |||
int trayCode = RemoteRecipes.ElementAt(index).TrayCode; | |||
if (trayCode == 2 && SmallStation.RecipeStatusIDTray2 == 0) | |||
{ | |||
HKDevice.SingleDosing((uint)SmallStation.StockInIsWork); | |||
DeviceInquire.GetInstance.GetDeviceObject(SmallStation.StockInIsWork).OutRawMaterialReset(); | |||
if (HKDevice.HK_PLC_S7.Read("DB3.DBX1.6") is bool && SmallStation.RecipeStatusIDTray2 == 0) | |||
{ | |||
foreach (var item in RemoteRecipes.ElementAt(index).RawMaterial) | |||
{ | |||
HKDevice.StockBinPar((uint)item.RawMaterialBarrelNum, (ushort)item.RawMaterialLocation); | |||
} | |||
HKDevice.HK_PLC_S7.Write("DB3.DBX1.6", false); | |||
HKDevice.HK_PLC_S7.Write("DB4.DBX1.4", true); | |||
SmallStation.RecipeStatusIDTray2 = 1; | |||
} | |||
if (HKDevice.HK_PLC_S7.Read("DB3.DBX1.4") is bool && SmallStation.RecipeStatusIDTray2 == 1) | |||
{ | |||
HKDevice.HK_PLC_S7.Write("DB3.DBX1.4", false); | |||
SmallStation.RecipeStatusIDTray2 = 2; | |||
} | |||
if (SmallStation.RecipeStatusIDTray2 == 2) | |||
{ | |||
if (HKDevice.HK_PLC_S7.Read("DB3.DBX50.4") is bool) | |||
{ | |||
var res = HKDevice.HK_PLC_S7.Read("DB3.DBD26"); | |||
if (res != null && res is float loc) | |||
{ | |||
int loc_index = Array.FindIndex(RemoteRecipes.ElementAt(index).RawMaterial.ToArray(), p => p.RawMaterialLocation == loc); | |||
double weight = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(loc_index).RawMaterialWeight; | |||
if (loc_index >= 1 && loc_index <= 15) | |||
{ | |||
DeviceInquire.GetInstance.GetDevice(loc_index)?.Start((uint)weight);//根据料仓编号 启动并写入每个原料重量 | |||
SmallStation.StockInIsWork = loc_index; | |||
HKDevice.HK_PLC_S7.Write("DB3.DBX50.4", false); | |||
} | |||
} | |||
} | |||
else if (HKDevice.HK_PLC_S7.Read("DB3.DBX50.5") is bool) | |||
{ | |||
var res = HKDevice.HK_PLC_S7.Read("DB3.DBD30"); | |||
if (res != null && res is float loc) | |||
{ | |||
int loc_index = Array.FindIndex(RemoteRecipes.ElementAt(index).RawMaterial.ToArray(), p => p.RawMaterialLocation == loc); | |||
double weight = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(loc_index).RawMaterialWeight; | |||
if (loc_index >= 1 && loc_index <= 15) | |||
{ | |||
DeviceInquire.GetInstance.GetDevice(loc_index)?.Start((uint)weight);//启动并写入每个原料重量 | |||
SmallStation.StockInIsWork = loc_index; | |||
HKDevice.HK_PLC_S7.Write("DB3.DBX50.5", false); | |||
} | |||
} | |||
} | |||
else if (HKDevice.HK_PLC_S7.Read("DB3.DBX50.6") is bool) | |||
{ | |||
var res = HKDevice.HK_PLC_S7.Read("DB3.DBD34"); | |||
if (res != null && res is float loc) | |||
{ | |||
int loc_index = Array.FindIndex(RemoteRecipes.ElementAt(index).RawMaterial.ToArray(), p => p.RawMaterialLocation == loc); | |||
double weight = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(loc_index).RawMaterialWeight; | |||
if (loc_index >= 1 && loc_index <= 15) | |||
{ | |||
DeviceInquire.GetInstance.GetDevice(loc_index)?.Start((uint)weight);//启动并写入每个原料重量 | |||
SmallStation.StockInIsWork = loc_index; | |||
HKDevice.HK_PLC_S7.Write("DB3.DBX50.6", false); | |||
} | |||
} | |||
} | |||
else if (HKDevice.HK_PLC_S7.Read("DB3.DBX50.7") is bool) | |||
{ | |||
var res = HKDevice.HK_PLC_S7.Read("DB3.DBD38"); | |||
if (res != null && res is float loc) | |||
{ | |||
int loc_index = Array.FindIndex(RemoteRecipes.ElementAt(index).RawMaterial.ToArray(), p => p.RawMaterialLocation == loc); | |||
double weight = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(loc_index).RawMaterialWeight; | |||
if (loc_index >= 1 && loc_index <= 15) | |||
{ | |||
DeviceInquire.GetInstance.GetDevice(loc_index)?.Start((uint)weight);//启动并写入每个原料重量 | |||
SmallStation.StockInIsWork = loc_index; | |||
HKDevice.HK_PLC_S7.Write("DB3.DBX50.7", false); | |||
} | |||
} | |||
} | |||
for (int i = 1; i < 16; i++) | |||
{ | |||
if (DeviceInquire.GetInstance.GetDevice(i).deviceStatus.RunStatus == 3) | |||
{ | |||
DeviceInquire.GetInstance.GetDevice(i).StatusReset(); | |||
if (i >= 1 && i <= 8) | |||
{ | |||
HKDevice.HK_PLC_S7.Write("DB4.DBX30." + (i - 1), true); | |||
} | |||
else if (i >= 9 && i <= 15) | |||
{ | |||
HKDevice.HK_PLC_S7.Write("DB4.DBX31." + (i - 9), true); | |||
} | |||
} | |||
} | |||
if (HKDevice.HK_PLC_S7.Read("DB3.DBX1.2") is bool) | |||
{ | |||
var res = Json<RemoteRecipeDataColl>.Data.Recipes.FirstOrDefault(p => p.RecipeCode == code); | |||
MessageLog.GetInstance.ShowRunLog($"托盘2 配方{res.RecipeName}配料完成"); | |||
Json<RemoteRecipeDataColl>.Data.Recipes.Remove(res); | |||
RecipeTray1Queue.TryDequeue(out code); | |||
HKDevice.HK_PLC_S7.Write("DB3.DBX1.2", false); | |||
SmallStation.RecipeStatusIDTray2 = 0; | |||
} | |||
} | |||
} | |||
if (RTrig.GetInstance("StockState").Start(HKDevice.HK_PLC_S7.Read(HKPlcCommAddress.RecipeDosingFinish) is bool)) | |||
{ | |||
HKDevice.RecipeDosingFinishReset(); | |||
SmallStation.RecipeQueue.TryDequeue(out code); | |||
Json<RemoteRecipeDataColl>.Data.Recipes.RemoveAt(index);//制作完成,移除当前配方 | |||
}*/ | |||
} | |||
} | |||
} | |||
@@ -0,0 +1,28 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
using Microsoft.Toolkit.Mvvm.ComponentModel; | |||
using Microsoft.Toolkit.Mvvm.Input; | |||
namespace BPASmartClient.JXJFoodSmallStation.Model | |||
{ | |||
public class ActionMenu : ObservableObject | |||
{ | |||
public string CommandParameter { get { return _mCommandParameter; } set { _mCommandParameter = value; OnPropertyChanged(); } } | |||
private string _mCommandParameter; | |||
//public Permission[] permission { get { return _mpermission; } set { _mpermission = value; OnPropertyChanged(); } } | |||
//private Permission[] _mpermission; | |||
public string MenuName { get { return _mMenuName; } set { _mMenuName = value; OnPropertyChanged(); } } | |||
private string _mMenuName; | |||
//public string NameSpace { get { return _mNameSpace; } set { _mNameSpace = value; OnPropertyChanged(); } } | |||
//private string _mNameSpace; | |||
} | |||
} |
@@ -0,0 +1,17 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
using Microsoft.Toolkit.Mvvm.ComponentModel; | |||
namespace BPASmartClient.JXJFoodSmallStation.Model | |||
{ | |||
public class ConveyorServer | |||
{ | |||
public ConveyorServer() | |||
{ | |||
} | |||
} | |||
} |
@@ -0,0 +1,27 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
using Microsoft.Toolkit.Mvvm.ComponentModel; | |||
namespace BPASmartClient.JXJFoodSmallStation.Model | |||
{ | |||
public class CylinderStatusModel : ObservableObject | |||
{ | |||
/// <summary> | |||
/// 气缸原点信号 | |||
/// </summary> | |||
public bool HomeStatus { get { return _mHomeStatus; } set { _mHomeStatus = value; OnPropertyChanged(); } } | |||
private bool _mHomeStatus; | |||
/// <summary> | |||
/// 气缸到位信号 | |||
/// </summary> | |||
public bool InPlace { get { return _mInPlace; } set { _mInPlace = value; OnPropertyChanged(); } } | |||
private bool _mInPlace; | |||
} | |||
} |
@@ -54,6 +54,11 @@ namespace BPASmartClient.JXJFoodSmallStation.Model | |||
/// </summary> | |||
public static string RunStatus { get; set; } = "LW60"; | |||
/// <summary> | |||
/// 出料完成,置位该信号,plc复位运行状态 | |||
/// </summary> | |||
public static string FinfishStatus { get; set; } = "LW40"; | |||
/// <summary> | |||
/// 慢加重量 | |||
/// </summary> | |||
@@ -5,7 +5,7 @@ using System.Text; | |||
using System.Threading.Tasks; | |||
using Microsoft.Toolkit.Mvvm.ComponentModel; | |||
namespace BPASmartClient.JXJFoodSmallStation | |||
namespace BPASmartClient.JXJFoodSmallStation.Model | |||
{ | |||
public class DeviceCurrentStatus : ObservableObject | |||
{ | |||
@@ -1,19 +1,16 @@ | |||
using BPASmartClient.Helper; | |||
using BPASmartClient.Modbus; | |||
using BPASmartClient.CustomResource.Pages.Model; | |||
using BPASmartClient.JXJFoodSmallStation.ViewModel; | |||
using BPASmartClient.Helper; | |||
using BPASmartClient.Modbus; | |||
using BPASmartClient.Model; | |||
using System; | |||
using System.Collections.Concurrent; | |||
using System.Collections.Generic; | |||
using System.Diagnostics; | |||
using System.Collections.ObjectModel; | |||
using System.Linq; | |||
using System.Net.NetworkInformation; | |||
using System.Text; | |||
using System.Threading; | |||
using System.Threading.Tasks; | |||
using BPASmartClient.CustomResource.UserControls.MessageShow; | |||
using BPASmartClient.CustomResource.Pages.Model; | |||
using System.Collections.ObjectModel; | |||
using BPASmartClient.Model; | |||
namespace BPASmartClient.JXJFoodSmallStation.Model | |||
{ | |||
@@ -54,10 +51,10 @@ namespace BPASmartClient.JXJFoodSmallStation.Model | |||
BottomDeviceCurrentStatuses.ElementAt(BottomIndex).DeviceNum = DeviceLists.ElementAt(i).Value.deviceStatus.DeviceNum; | |||
} | |||
int deviceIndex = Array.FindIndex(devices.ToArray(), p => p.IpAddress == DeviceLists.ElementAt(i).Key); | |||
int deviceIndex = Array.FindIndex(devices.ToArray(), p => p.IpAddress == DeviceLists.ElementAt(i).Key && p.DeviceName != DeviceLists.ElementAt(i).Value.DeviceName); | |||
if (deviceIndex >= 0 && deviceIndex < devices.Count) | |||
{ | |||
devices.ElementAt(i).DeviceName = DeviceLists.ElementAt(i).Value.DeviceName; | |||
devices.ElementAt(deviceIndex).DeviceName = DeviceLists.ElementAt(i).Value.DeviceName; | |||
} | |||
} | |||
Thread.Sleep(200); | |||
@@ -66,7 +63,6 @@ namespace BPASmartClient.JXJFoodSmallStation.Model | |||
public void Init() | |||
{ | |||
devices.Add(new Devices() { DeviceName = "测试", IpAddress = "192.168.0.1" }); | |||
IpAddressLines(); | |||
DeviceDataInit(); | |||
ThreadManage.GetInstance().StartLong(new Action(() => | |||
@@ -91,6 +87,15 @@ namespace BPASmartClient.JXJFoodSmallStation.Model | |||
} | |||
return new DeviceStatus(); | |||
} | |||
public DeviceStatus GetDevice(int location) | |||
{ | |||
if (location > 0 && location < 16) | |||
{ | |||
var res = DeviceLists.Values.FirstOrDefault(p => p.deviceStatus.DeviceNum == location); | |||
if (res != null) return res; | |||
} | |||
return new DeviceStatus(); | |||
} | |||
public List<DeviceStatus> GetDevice() | |||
{ | |||
@@ -150,7 +155,7 @@ namespace BPASmartClient.JXJFoodSmallStation.Model | |||
devices.Add(new Devices() { DeviceName = DeviceName, IpAddress = ip }); | |||
if (TopDeviceCurrentStatuses.Count <= 8) | |||
if (TopDeviceCurrentStatuses.Count <= 7) | |||
TopDeviceCurrentStatuses.Add(new DeviceCurrentStatus() { DeviceName = DeviceName }); | |||
else | |||
BottomDeviceCurrentStatuses.Add(new DeviceCurrentStatus() { DeviceName = DeviceName }); | |||
@@ -170,7 +175,7 @@ namespace BPASmartClient.JXJFoodSmallStation.Model | |||
{ | |||
if (Global.DeviceRawMaterials.FirstOrDefault(p => p.RawMaterialName == DeviceName) == null) | |||
{ | |||
Global.DeviceRawMaterials.Add(new RawMaterialModel() { RawMaterialName = DeviceName, DeviceIp = ip, RawMaterialSource = 1 }); | |||
Global.DeviceRawMaterials.Add(new RawMaterialModel() { RawMaterialName = DeviceName, DeviceIp = ip, RawMaterialSource = 1}); | |||
} | |||
} | |||
else | |||
@@ -235,7 +240,6 @@ namespace BPASmartClient.JXJFoodSmallStation.Model | |||
#region 对象属性声明 | |||
public string DeviceName = String.Empty; | |||
public string IpAddress => modbusTcp.IPAdress; | |||
/// <summary> | |||
/// 设备状态 | |||
/// </summary> | |||
@@ -276,6 +280,7 @@ namespace BPASmartClient.JXJFoodSmallStation.Model | |||
AlarmHelper<AlarmInfo>.Alarm.EStop2 = deviceStatus.DeviceAlarmCode.Get16bitValue(7); | |||
AlarmHelper<AlarmInfo>.Alarm.SiloUpperLimit = deviceStatus.DeviceAlarmCode.Get16bitValue(8); | |||
AlarmHelper<AlarmInfo>.Alarm.SiloLowerLimit = deviceStatus.DeviceAlarmCode.Get16bitValue(9); | |||
AlarmHelper<AlarmInfo>.Alarm.EStop1 = true; | |||
Thread.Sleep(100); | |||
}), $"{DeviceName} 开始监听", true); | |||
} | |||
@@ -289,7 +294,8 @@ namespace BPASmartClient.JXJFoodSmallStation.Model | |||
public void StatusReset() | |||
{ | |||
this.modbusTcp.Write(DeviceAddress.RunStatus, (ushort)0); | |||
this.modbusTcp.Write(DeviceAddress.FinfishStatus, (ushort)1); | |||
//var res = modbusTcp.Read(DeviceAddress.RunStatus); | |||
} | |||
public void Dispose() | |||
@@ -314,7 +320,7 @@ namespace BPASmartClient.JXJFoodSmallStation.Model | |||
modbusTcp.SetUint(DeviceAddress.ServoManualSpeed, (uint)res.ServoManualSpeed); | |||
modbusTcp.SetUint(DeviceAddress.SiloUpperLimitWeight, (uint)res.SiloUpperLimitWeight); | |||
modbusTcp.SetUint(DeviceAddress.LowerLimitWeightOfSilo, (uint)res.LowerLimitWeightOfSilo); | |||
modbusTcp.SetUint(DeviceAddress.StirringSpeed, (uint)res.StirringSpeed); | |||
modbusTcp.SetUint(DeviceAddress.StirringSpeed, (uint)res.StirringSpeed * 100); | |||
} | |||
} | |||
} |
@@ -6,7 +6,7 @@ using System.Threading.Tasks; | |||
using Microsoft.Toolkit.Mvvm.ComponentModel; | |||
using System.Collections.ObjectModel; | |||
namespace BPASmartClient.JXJFoodSmallStation | |||
namespace BPASmartClient.JXJFoodSmallStation.Model | |||
{ | |||
public class DevicePar | |||
{ | |||
@@ -5,7 +5,7 @@ using System.Text; | |||
using System.Threading.Tasks; | |||
using Microsoft.Toolkit.Mvvm.ComponentModel; | |||
namespace BPASmartClient.JXJFoodSmallStation | |||
namespace BPASmartClient.JXJFoodSmallStation.Model | |||
{ | |||
public class DeviceParModel : ObservableObject | |||
{ | |||
@@ -0,0 +1,20 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
using Microsoft.Toolkit.Mvvm.ComponentModel; | |||
namespace BPASmartClient.JXJFoodSmallStation.Model | |||
{ | |||
public class RecipeProcess : ObservableObject | |||
{ | |||
public string RawMaterialName { get { return _mRawMaterialName; } set { _mRawMaterialName = value; OnPropertyChanged(); } } | |||
private string _mRawMaterialName; | |||
public int RawMaterialStatus { get { return _mRawMaterialStatus; } set { _mRawMaterialStatus = value; OnPropertyChanged(); } } | |||
private int _mRawMaterialStatus; | |||
} | |||
} |
@@ -8,9 +8,11 @@ namespace BPASmartClient.JXJFoodSmallStation.Model | |||
{ | |||
public class RemoteRecipeRawMaterial | |||
{ | |||
private int _mIp; | |||
public int DeviceIp { get { return _mIp; } set { _mIp = value; }} | |||
private int _mIp; | |||
public int RawMaterialName { get { return _mRawMaterialName; } set { _mRawMaterialName = value; } } | |||
private int _mRawMaterialName; | |||
/// <summary> | |||
/// 原料对应的桶号 | |||
/// </summary> | |||
@@ -60,7 +60,7 @@ | |||
<UniformGrid | |||
HorizontalAlignment="Left" | |||
VerticalAlignment="Top" | |||
Columns="4" /> | |||
Columns="8" /> | |||
</ItemsPanelTemplate> | |||
</ListView.ItemsPanel> | |||
@@ -68,7 +68,9 @@ | |||
<DataTemplate> | |||
<Border | |||
Name="ShadowElement" | |||
Width="200" | |||
Height="150" | |||
Margin="10" | |||
VerticalAlignment="Top" | |||
BorderBrush="#00BEFA" | |||
BorderThickness="0" | |||
@@ -125,8 +127,8 @@ | |||
Grid.Row="2" | |||
Width="130" | |||
Height="30" | |||
VerticalAlignment="Top" | |||
Margin="0,0,0,0" | |||
VerticalAlignment="Top" | |||
Command="{Binding DataContext.ChangeNameCommand, RelativeSource={RelativeSource AncestorType=ListView, Mode=FindAncestor}}" | |||
CommandParameter="{Binding IpAddress}" | |||
Content="修改原料名称" | |||
@@ -17,7 +17,8 @@ | |||
<UserControl.Resources> | |||
<SolidColorBrush x:Key="tabColor" Color="#FF2AB2E7" /> | |||
<SolidColorBrush x:Key="bordColor" Color="#33ffffff" /> | |||
<!--<SolidColorBrush x:Key="bordColor" Color="#33ffffff" />--> | |||
<SolidColorBrush x:Key="bordColor" Color="#332AB2E7" /> | |||
<con:DataTableRedundantConverter x:Key="tabConvert" /> | |||
<Style x:Key="RowRadioButtonStyle" TargetType="{x:Type RadioButton}"> | |||
@@ -0,0 +1,379 @@ | |||
<UserControl | |||
x:Class="BPASmartClient.JXJFoodSmallStation.View.ManualControlView" | |||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | |||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | |||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | |||
xmlns:local="clr-namespace:BPASmartClient.JXJFoodSmallStation.View" | |||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | |||
xmlns:pry="clr-namespace:BPASmartClient.CustomResource.UserControls;assembly=BPASmartClient.CustomResource" | |||
xmlns:vm="clr-namespace:BPASmartClient.JXJFoodSmallStation.ViewModel" | |||
d:DesignHeight="450" | |||
d:DesignWidth="800" | |||
mc:Ignorable="d"> | |||
<UserControl.Resources> | |||
<Style x:Key="radioButtonStyle" TargetType="RadioButton"> | |||
<Setter Property="Template"> | |||
<Setter.Value> | |||
<ControlTemplate TargetType="RadioButton"> | |||
<Grid Name="gr" Opacity="0.8"> | |||
<ContentControl | |||
Margin="{TemplateBinding Margin}" | |||
HorizontalAlignment="Center" | |||
VerticalAlignment="Center" | |||
HorizontalContentAlignment="Center" | |||
VerticalContentAlignment="Center" | |||
Content="{TemplateBinding Content}" | |||
FontSize="{TemplateBinding FontSize}" | |||
Foreground="{TemplateBinding Foreground}" /> | |||
<Image | |||
Name="image" | |||
Source="/BPASmartClient.CustomResource;component/Image/边框线.png" | |||
Stretch="Fill" /> | |||
</Grid> | |||
<ControlTemplate.Triggers> | |||
<Trigger Property="IsChecked" Value="False"> | |||
<Setter TargetName="image" Property="Source" Value="/BPASmartClient.CustomResource;component/Image/边框线.png" /> | |||
</Trigger> | |||
<Trigger Property="IsChecked" Value="True"> | |||
<Setter TargetName="image" Property="Source" Value="/BPASmartClient.CustomResource;component/Image/透明背景.png" /> | |||
</Trigger> | |||
<Trigger Property="IsMouseOver" Value="True"> | |||
<Setter TargetName="gr" Property="Opacity" Value="1" /> | |||
</Trigger> | |||
</ControlTemplate.Triggers> | |||
</ControlTemplate> | |||
</Setter.Value> | |||
</Setter> | |||
</Style> | |||
</UserControl.Resources> | |||
<UserControl.DataContext> | |||
<vm:ManualControlViewModel /> | |||
</UserControl.DataContext> | |||
<Grid Margin="8"> | |||
<Grid.RowDefinitions> | |||
<RowDefinition /> | |||
<RowDefinition /> | |||
<RowDefinition /> | |||
</Grid.RowDefinitions> | |||
<!--#region 升降气缸--> | |||
<Grid | |||
Name="cy" | |||
Grid.Row="0" | |||
Margin="5"> | |||
<Grid.RowDefinitions> | |||
<RowDefinition Height="40" /> | |||
<RowDefinition /> | |||
</Grid.RowDefinitions> | |||
<pry:ImageBorder | |||
Grid.RowSpan="2" | |||
Width="{Binding ElementName=cy, Path=ActualWidth}" | |||
Height="{Binding ElementName=cy, Path=ActualHeight}" /> | |||
<Image | |||
Margin="2,3,0,0" | |||
HorizontalAlignment="Left" | |||
Source="/BPASmartClient.CustomResource;component/Image/标签.png" /> | |||
<TextBlock | |||
Margin="10,0,0,0" | |||
VerticalAlignment="Center" | |||
FontSize="16" | |||
Foreground="Aqua" | |||
Text="升降气缸控制" /> | |||
<ListView | |||
Grid.Row="1" | |||
Background="Transparent" | |||
BorderBrush="#00BEFA" | |||
BorderThickness="0" | |||
ItemsSource="{Binding cylinderModels}" | |||
ScrollViewer.HorizontalScrollBarVisibility="Disabled"> | |||
<ListView.ItemsPanel> | |||
<ItemsPanelTemplate> | |||
<UniformGrid | |||
HorizontalAlignment="Left" | |||
VerticalAlignment="Top" | |||
Columns="8" /> | |||
</ItemsPanelTemplate> | |||
</ListView.ItemsPanel> | |||
<ListView.ItemTemplate> | |||
<DataTemplate> | |||
<Grid | |||
Width="200" | |||
Height="100" | |||
Margin="0,0,0,15" | |||
Background="Transparent"> | |||
<Grid.RowDefinitions> | |||
<RowDefinition Height="30" /> | |||
<RowDefinition /> | |||
<RowDefinition Height="30" /> | |||
</Grid.RowDefinitions> | |||
<Grid.ColumnDefinitions> | |||
<ColumnDefinition Width="0.5*" /> | |||
<ColumnDefinition /> | |||
<ColumnDefinition /> | |||
</Grid.ColumnDefinitions> | |||
<TextBlock | |||
Grid.Column="1" | |||
Grid.ColumnSpan="2" | |||
HorizontalAlignment="Center" | |||
VerticalAlignment="Center" | |||
Foreground="Aqua" | |||
Text="{Binding Name}" /> | |||
<pry:Cylinder | |||
Grid.Row="1" | |||
Grid.ColumnSpan="3" | |||
Width="200" | |||
Height="50" | |||
HorizontalAlignment="Center" | |||
VerticalAlignment="Center" | |||
LeftTogIsChecked="{Binding LeftTog}" | |||
RightTogIsChecked="{Binding RightTog}" /> | |||
<RadioButton | |||
Grid.Row="2" | |||
Grid.Column="1" | |||
Command="{Binding DataContext.Open, RelativeSource={RelativeSource AncestorType=ListView, Mode=FindAncestor}}" | |||
CommandParameter="{Binding Name}" | |||
Content="伸出" | |||
Foreground="Aqua" | |||
IsChecked="True" | |||
Style="{StaticResource radioButtonStyle}" /> | |||
<RadioButton | |||
Grid.Row="2" | |||
Grid.Column="2" | |||
Command="{Binding DataContext.Close, RelativeSource={RelativeSource AncestorType=ListView, Mode=FindAncestor}}" | |||
CommandParameter="{Binding Name}" | |||
Content="缩回" | |||
Foreground="Aqua" | |||
IsChecked="False" | |||
Style="{StaticResource radioButtonStyle}" /> | |||
</Grid> | |||
</DataTemplate> | |||
</ListView.ItemTemplate> | |||
</ListView> | |||
</Grid> | |||
<!--#endregion--> | |||
<!--#region 阻挡气缸--> | |||
<Grid | |||
Name="zd" | |||
Grid.Row="1" | |||
Margin="5"> | |||
<Grid.RowDefinitions> | |||
<RowDefinition Height="40" /> | |||
<RowDefinition /> | |||
</Grid.RowDefinitions> | |||
<pry:ImageBorder | |||
Grid.RowSpan="2" | |||
Width="{Binding ElementName=zd, Path=ActualWidth}" | |||
Height="{Binding ElementName=zd, Path=ActualHeight}" /> | |||
<Image | |||
Margin="2,3,0,0" | |||
HorizontalAlignment="Left" | |||
Source="/BPASmartClient.CustomResource;component/Image/标签.png" /> | |||
<TextBlock | |||
Margin="10,0,0,0" | |||
VerticalAlignment="Center" | |||
FontSize="16" | |||
Foreground="Aqua" | |||
Text="阻挡气缸控制" /> | |||
<ListView | |||
Grid.Row="1" | |||
Margin="10" | |||
Background="Transparent" | |||
BorderBrush="#00BEFA" | |||
BorderThickness="0" | |||
ItemsSource="{Binding BlockCylinders}" | |||
ScrollViewer.HorizontalScrollBarVisibility="Disabled"> | |||
<ListView.ItemsPanel> | |||
<ItemsPanelTemplate> | |||
<UniformGrid | |||
HorizontalAlignment="Left" | |||
VerticalAlignment="Top" | |||
Columns="8" /> | |||
</ItemsPanelTemplate> | |||
</ListView.ItemsPanel> | |||
<ListView.ItemTemplate> | |||
<DataTemplate> | |||
<Grid | |||
Width="200" | |||
Height="100" | |||
Margin="0,0,0,15" | |||
Background="Transparent"> | |||
<Grid.RowDefinitions> | |||
<RowDefinition Height="30" /> | |||
<RowDefinition /> | |||
<RowDefinition Height="30" /> | |||
</Grid.RowDefinitions> | |||
<Grid.ColumnDefinitions> | |||
<ColumnDefinition Width="0.5*" /> | |||
<ColumnDefinition /> | |||
<ColumnDefinition /> | |||
</Grid.ColumnDefinitions> | |||
<TextBlock | |||
Grid.Column="1" | |||
Grid.ColumnSpan="2" | |||
HorizontalAlignment="Center" | |||
VerticalAlignment="Center" | |||
Foreground="Aqua" | |||
Text="{Binding Name}" /> | |||
<pry:Cylinder | |||
Grid.Row="1" | |||
Grid.ColumnSpan="3" | |||
Width="200" | |||
Height="50" | |||
HorizontalAlignment="Center" | |||
VerticalAlignment="Center" | |||
LeftTogIsChecked="{Binding LeftTog}" | |||
RightTogIsChecked="{Binding RightTog}" /> | |||
<RadioButton | |||
Grid.Row="2" | |||
Grid.Column="1" | |||
Command="{Binding DataContext.Open, RelativeSource={RelativeSource AncestorType=ListView, Mode=FindAncestor}}" | |||
CommandParameter="{Binding Name}" | |||
Content="伸出" | |||
Foreground="Aqua" | |||
IsChecked="True" | |||
Style="{StaticResource radioButtonStyle}" /> | |||
<RadioButton | |||
Grid.Row="2" | |||
Grid.Column="2" | |||
Command="{Binding DataContext.Close, RelativeSource={RelativeSource AncestorType=ListView, Mode=FindAncestor}}" | |||
CommandParameter="{Binding Name}" | |||
Content="缩回" | |||
Foreground="Aqua" | |||
IsChecked="False" | |||
Style="{StaticResource radioButtonStyle}" /> | |||
</Grid> | |||
</DataTemplate> | |||
</ListView.ItemTemplate> | |||
</ListView> | |||
</Grid> | |||
<!--#endregion--> | |||
<!--#region 托盘气缸--> | |||
<Grid | |||
Name="tp" | |||
Grid.Row="2" | |||
Margin="5"> | |||
<Grid.RowDefinitions> | |||
<RowDefinition Height="40" /> | |||
<RowDefinition /> | |||
</Grid.RowDefinitions> | |||
<pry:ImageBorder | |||
Grid.RowSpan="2" | |||
Width="{Binding ElementName=tp, Path=ActualWidth}" | |||
Height="{Binding ElementName=tp, Path=ActualHeight}" /> | |||
<Image | |||
Margin="2,3,0,0" | |||
HorizontalAlignment="Left" | |||
Source="/BPASmartClient.CustomResource;component/Image/标签.png" /> | |||
<TextBlock | |||
Margin="10,0,0,0" | |||
VerticalAlignment="Center" | |||
FontSize="16" | |||
Foreground="Aqua" | |||
Text="托盘气缸控制" /> | |||
<ListView | |||
Grid.Row="2" | |||
Margin="10" | |||
Background="Transparent" | |||
BorderBrush="#00BEFA" | |||
BorderThickness="0" | |||
ItemsSource="{Binding PalletCylinders}" | |||
ScrollViewer.HorizontalScrollBarVisibility="Disabled"> | |||
<ListView.ItemsPanel> | |||
<ItemsPanelTemplate> | |||
<UniformGrid | |||
HorizontalAlignment="Left" | |||
VerticalAlignment="Top" | |||
Columns="8" /> | |||
</ItemsPanelTemplate> | |||
</ListView.ItemsPanel> | |||
<ListView.ItemTemplate> | |||
<DataTemplate> | |||
<Grid | |||
Width="200" | |||
Height="100" | |||
Margin="0,0,0,15" | |||
Background="Transparent"> | |||
<Grid.RowDefinitions> | |||
<RowDefinition Height="30" /> | |||
<RowDefinition /> | |||
<RowDefinition Height="30" /> | |||
</Grid.RowDefinitions> | |||
<Grid.ColumnDefinitions> | |||
<ColumnDefinition Width="0.5*" /> | |||
<ColumnDefinition /> | |||
<ColumnDefinition /> | |||
</Grid.ColumnDefinitions> | |||
<TextBlock | |||
Grid.Column="1" | |||
Grid.ColumnSpan="2" | |||
HorizontalAlignment="Center" | |||
VerticalAlignment="Center" | |||
Foreground="Aqua" | |||
Text="{Binding Name}" /> | |||
<pry:Cylinder | |||
Grid.Row="1" | |||
Grid.ColumnSpan="3" | |||
Width="200" | |||
Height="50" | |||
HorizontalAlignment="Center" | |||
VerticalAlignment="Center" | |||
LeftTogIsChecked="{Binding LeftTog}" | |||
RightTogIsChecked="{Binding RightTog}" /> | |||
<RadioButton | |||
Grid.Row="2" | |||
Grid.Column="1" | |||
Command="{Binding DataContext.Open, RelativeSource={RelativeSource AncestorType=ListView, Mode=FindAncestor}}" | |||
CommandParameter="{Binding Name}" | |||
Content="伸出" | |||
Foreground="Aqua" | |||
IsChecked="True" | |||
Style="{StaticResource radioButtonStyle}" /> | |||
<RadioButton | |||
Grid.Row="2" | |||
Grid.Column="2" | |||
Command="{Binding DataContext.Close, RelativeSource={RelativeSource AncestorType=ListView, Mode=FindAncestor}}" | |||
CommandParameter="{Binding Name}" | |||
Content="缩回" | |||
Foreground="Aqua" | |||
IsChecked="False" | |||
Style="{StaticResource radioButtonStyle}" /> | |||
</Grid> | |||
</DataTemplate> | |||
</ListView.ItemTemplate> | |||
</ListView> | |||
</Grid> | |||
<!--#endregion--> | |||
</Grid> | |||
</UserControl> |
@@ -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.JXJFoodSmallStation.View | |||
{ | |||
/// <summary> | |||
/// ManualControlView.xaml 的交互逻辑 | |||
/// </summary> | |||
public partial class ManualControlView : UserControl | |||
{ | |||
public ManualControlView() | |||
{ | |||
InitializeComponent(); | |||
} | |||
} | |||
} |
@@ -24,7 +24,6 @@ | |||
<Setter Property="FontFamily" Value="楷体" /> | |||
<Setter Property="FontSize" Value="20" /> | |||
<Setter Property="Background" Value="Transparent" /> | |||
<!--<Setter Property="Foreground" Value="{StaticResource FontColor}" />--> | |||
<Setter Property="VerticalAlignment" Value="Center" /> | |||
<Setter Property="HorizontalAlignment" Value="Center" /> | |||
</Style> | |||
@@ -37,6 +36,8 @@ | |||
<Setter Property="BorderThickness" Value="0" /> | |||
</Style> | |||
<Style x:Key="ListViewStyle" TargetType="ListView" /> | |||
</UserControl.Resources> | |||
<UserControl.DataContext> | |||
@@ -90,322 +91,199 @@ | |||
</StackPanel> | |||
<!--#endregion--> | |||
<!--#region 表格标题栏设置--> | |||
<!--<Grid Grid.Row="1" Background="#dd2AB2E7"> | |||
<Grid.ColumnDefinitions> | |||
<ColumnDefinition Width="0.3*" /> | |||
<ColumnDefinition /> | |||
<ColumnDefinition Width="0.7*" /> | |||
<ColumnDefinition Width="0.7*" /> | |||
<ColumnDefinition Width="0" /> | |||
<ColumnDefinition Width="0.7*" /> | |||
<ColumnDefinition Width="0.5*" /> | |||
</Grid.ColumnDefinitions> | |||
<TextBlock | |||
Grid.Column="0" | |||
HorizontalAlignment="Center" | |||
VerticalAlignment="Center" | |||
FontSize="16" | |||
Foreground="{StaticResource TitleFontColor}" | |||
Text="序号" /> | |||
<Grid Grid.Column="1"> | |||
<TextBlock | |||
HorizontalAlignment="Center" | |||
VerticalAlignment="Center" | |||
FontSize="16" | |||
Foreground="{StaticResource TitleFontColor}" | |||
Text="配方名称" /> | |||
<Border BorderBrush="{StaticResource TitleBorderColor}" BorderThickness="1,0,1,0" /> | |||
</Grid> | |||
<TextBlock | |||
Grid.Column="2" | |||
HorizontalAlignment="Center" | |||
VerticalAlignment="Center" | |||
FontSize="16" | |||
Foreground="{StaticResource TitleFontColor}" | |||
Text="编码" /> | |||
<Grid Grid.Column="3"> | |||
<TextBlock | |||
HorizontalAlignment="Center" | |||
VerticalAlignment="Center" | |||
FontSize="16" | |||
Foreground="{StaticResource TitleFontColor}" | |||
Text="结束时间" /> | |||
<Border BorderBrush="{StaticResource TitleBorderColor}" BorderThickness="1,0,1,0" /> | |||
</Grid> | |||
<Grid Grid.Column="5"> | |||
<TextBlock | |||
HorizontalAlignment="Center" | |||
VerticalAlignment="Center" | |||
FontSize="16" | |||
Foreground="{StaticResource TitleFontColor}" | |||
Text="制作状态" /> | |||
<Border BorderBrush="{StaticResource TitleBorderColor}" BorderThickness="0,0,1,0" /> | |||
</Grid> | |||
<TextBlock | |||
Grid.Column="6" | |||
HorizontalAlignment="Center" | |||
VerticalAlignment="Center" | |||
FontSize="16" | |||
Foreground="{StaticResource TitleFontColor}" | |||
Text="完成时间" /> | |||
</Grid>--> | |||
<!--#endregion--> | |||
<ListBox | |||
Grid.Row="2" | |||
Margin="5" | |||
VerticalAlignment="Top" | |||
Background="Transparent" | |||
BorderThickness="0" | |||
ItemsSource="{Binding Recipes}" | |||
ScrollViewer.HorizontalScrollBarVisibility="Disabled"> | |||
<ListBox.ItemsPanel> | |||
<ItemsPanelTemplate> | |||
<UniformGrid | |||
HorizontalAlignment="Left" | |||
VerticalAlignment="Top" | |||
Columns="8" /> | |||
</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}" /> | |||
<ScrollViewer Grid.Row="2" HorizontalScrollBarVisibility="Disabled"> | |||
<ListView | |||
Margin="5" | |||
VerticalAlignment="Top" | |||
Background="Transparent" | |||
BorderThickness="0" | |||
ItemsSource="{Binding Recipes}" | |||
ScrollViewer.HorizontalScrollBarVisibility="Disabled"> | |||
<ListView.ItemsPanel> | |||
<ItemsPanelTemplate> | |||
<UniformGrid | |||
HorizontalAlignment="Left" | |||
<TextBlock | |||
Grid.Row="1" | |||
Margin="5,0,0,0" | |||
VerticalAlignment="Top" | |||
Columns="8" /> | |||
</ItemsPanelTemplate> | |||
</ListView.ItemsPanel> | |||
Foreground="#FF2AB2E7" | |||
Text="配方信息:" /> | |||
<ListView.ItemTemplate> | |||
<DataTemplate> | |||
<Border Margin="5" Background="LightSkyBlue"> | |||
<ScrollViewer | |||
Grid.Row="2" | |||
VerticalAlignment="Top" | |||
Background="Transparent" | |||
HorizontalScrollBarVisibility="Hidden" | |||
VerticalScrollBarVisibility="Hidden"> | |||
<Grid> | |||
<Grid.RowDefinitions> | |||
<RowDefinition /> | |||
<RowDefinition Height="0.25*" /> | |||
<RowDefinition Height="0.2*" /> | |||
</Grid.RowDefinitions> | |||
<Image Source="/BPASmartClient.CustomResource;component/Image/AGV/炒锅.png" /> | |||
<TextBlock | |||
Grid.Row="1" | |||
Margin="2,0,0,0" | |||
HorizontalAlignment="Center" | |||
VerticalAlignment="Center" | |||
Foreground="#dd000000" | |||
Text="{Binding RecipeName}" /> | |||
<Grid | |||
Name="gr" | |||
Grid.Row="2" | |||
Height="30"> | |||
<Grid.ColumnDefinitions> | |||
<ColumnDefinition /> | |||
<ColumnDefinition /> | |||
</Grid.ColumnDefinitions> | |||
<pry:IcoButton | |||
Width="{Binding ElementName=gr, Path=ActualWidth}" | |||
Height="{Binding ElementName=gr, Path=ActualHeight}" | |||
HorizontalAlignment="Center" | |||
VerticalAlignment="Center" | |||
BorderThickness="0" | |||
Command="{Binding DataContext.RemoveCommand, RelativeSource={RelativeSource AncestorType=ListView, Mode=FindAncestor}}" | |||
CommandParameter="{Binding RecipCode}" | |||
Content="删除" | |||
EnterBackground="Red" | |||
FontStyle="Normal" | |||
Foreground="#dd000000" | |||
IcoText="" | |||
Style="{StaticResource IcoButtonStyle}" /> | |||
<pry:IcoButton | |||
Grid.Column="1" | |||
Width="{Binding ElementName=gr, Path=ActualWidth}" | |||
Height="{Binding ElementName=gr, Path=ActualHeight}" | |||
HorizontalAlignment="Center" | |||
VerticalAlignment="Center" | |||
BorderThickness="0" | |||
Command="{Binding DataContext.DetailsCommand, RelativeSource={RelativeSource AncestorType=ListView, Mode=FindAncestor}}" | |||
CommandParameter="{Binding RecipCode}" | |||
Content="编辑" | |||
EnterBackground="#FF2AB2E7" | |||
Foreground="#dd000000" | |||
IcoText="" | |||
Style="{StaticResource IcoButtonStyle}" /> | |||
</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="#aa2AB2E7" | |||
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="#aa2AB2E7" | |||
Text=":" /> | |||
<TextBlock | |||
Margin="5,0,0,0" | |||
HorizontalAlignment="Center" | |||
VerticalAlignment="Center" | |||
Foreground="#aa2AB2E7" | |||
Text="{Binding RawMaterialWeight}" /> | |||
<TextBlock | |||
Margin="5,0,0,0" | |||
HorizontalAlignment="Center" | |||
VerticalAlignment="Center" | |||
Foreground="#aa2AB2E7" | |||
Text="g" /> | |||
</StackPanel> | |||
</DataTemplate> | |||
</ItemsControl.ItemTemplate> | |||
</ItemsControl> | |||
</Grid> | |||
</Border> | |||
</DataTemplate> | |||
</ListView.ItemTemplate> | |||
</ListView> | |||
</ScrollViewer> | |||
<!--<UniformGrid | |||
Grid.Row="2" | |||
Height="200" | |||
VerticalAlignment="Top" | |||
Columns="10"> | |||
<Border | |||
Margin="10" | |||
Background="LightSkyBlue" | |||
BorderThickness="1"> | |||
<Grid> | |||
<Grid.RowDefinitions> | |||
<RowDefinition /> | |||
<RowDefinition Height="0.25*" /> | |||
<RowDefinition Height="0.2*" /> | |||
</Grid.RowDefinitions> | |||
<Image Source="/BPASmartClient.CustomResource;component/Image/AGV/炒锅.png" /> | |||
<TextBlock | |||
Grid.Row="1" | |||
Margin="2,0,0,0" | |||
HorizontalAlignment="Center" | |||
VerticalAlignment="Center" | |||
Foreground="#dd000000" | |||
Text="配方名称" /> | |||
<Grid Name="gr" Grid.Row="2"> | |||
<Grid.ColumnDefinitions> | |||
<ColumnDefinition /> | |||
<ColumnDefinition /> | |||
</Grid.ColumnDefinitions> | |||
<pry:IcoButton | |||
Width="{Binding ElementName=gr, Path=ActualWidth}" | |||
Height="{Binding ElementName=gr, Path=ActualHeight}" | |||
HorizontalAlignment="Center" | |||
VerticalAlignment="Center" | |||
BorderThickness="0" | |||
Content="删除" | |||
EnterBackground="Red" | |||
FontStyle="Normal" | |||
Foreground="#dd000000" | |||
IcoText="" | |||
Style="{StaticResource IcoButtonStyle}" /> | |||
<pry:IcoButton | |||
Grid.Column="1" | |||
Width="{Binding ElementName=gr, Path=ActualWidth}" | |||
Height="{Binding ElementName=gr, Path=ActualHeight}" | |||
HorizontalAlignment="Center" | |||
VerticalAlignment="Center" | |||
BorderThickness="0" | |||
Content="编辑" | |||
EnterBackground="#FF2AB2E7" | |||
Foreground="#dd000000" | |||
IcoText="" | |||
Style="{StaticResource IcoButtonStyle}" /> | |||
</ScrollViewer> | |||
<!--<Grid | |||
Grid.Row="3" | |||
Height="2" | |||
VerticalAlignment="Bottom"> | |||
<Grid.Background> | |||
<ImageBrush ImageSource="/BPASmartClient.CustomResource;component/Image/直线.png" Stretch="Fill" /> | |||
</Grid.Background> | |||
</Grid>--> | |||
<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,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="" | |||
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="" | |||
Style="{StaticResource IcoButtonStyle}" /> | |||
</Grid> | |||
<!--</StackPanel>--> | |||
</Grid> | |||
</Grid> | |||
</Border> | |||
</UniformGrid>--> | |||
</DataTemplate> | |||
</ListBox.ItemTemplate> | |||
</ListBox> | |||
<!--#region 表格数据显示--> | |||
<!--<ScrollViewer | |||
Grid.Row="2" | |||
Visibility="Collapsed" | |||
HorizontalScrollBarVisibility="Hidden" | |||
VerticalScrollBarVisibility="Hidden"> | |||
<ItemsControl ItemsSource="{Binding Recipes}"> | |||
<ItemsControl.ItemTemplate> | |||
<DataTemplate> | |||
<RadioButton Background="Transparent" GroupName="all"> | |||
<RadioButton.Template> | |||
<ControlTemplate TargetType="RadioButton"> | |||
<Grid Name="gr" Height="30"> | |||
<Grid.ColumnDefinitions> | |||
<ColumnDefinition Width="0.3*" /> | |||
<ColumnDefinition /> | |||
<ColumnDefinition Width="0.7*" /> | |||
<ColumnDefinition Width="0.7*" /> | |||
<ColumnDefinition Width="0" /> | |||
<ColumnDefinition Width="0.7*" /> | |||
<ColumnDefinition Width="0.5*" /> | |||
</Grid.ColumnDefinitions> | |||
<TextBlock | |||
Grid.Column="0" | |||
Foreground="#ff00ccff" | |||
Style="{StaticResource TextBlockStyle}" | |||
Text="{Binding SerialNum}" /> | |||
<Grid Grid.Column="1"> | |||
<TextBlock | |||
Margin="5,0,0,0" | |||
HorizontalAlignment="Left" | |||
Foreground="#ff00ccff" | |||
Style="{StaticResource TextBlockStyle}" | |||
Text="{Binding RecipeName}" /> | |||
</Grid> | |||
<TextBlock | |||
Grid.Column="2" | |||
Foreground="#ff00ccff" | |||
Style="{StaticResource TextBlockStyle}" | |||
Text="{Binding RecipCode}" /> | |||
--> | |||
<!--<Grid Grid.Column="3"> | |||
<Button | |||
Command="{Binding DataContext.EditCommand, RelativeSource={RelativeSource AncestorType=ItemsControl, Mode=FindAncestor}}" | |||
CommandParameter="{Binding RecipCode}" | |||
Content="编辑" | |||
Style="{StaticResource buttonStyle}" /> | |||
</Grid>--> | |||
<!-- | |||
<Grid Grid.Column="5"> | |||
<Button | |||
Command="{Binding DataContext.DetailsCommand, RelativeSource={RelativeSource AncestorType=ItemsControl, Mode=FindAncestor}}" | |||
CommandParameter="{Binding RecipCode}" | |||
Content="详情" | |||
Style="{StaticResource buttonStyle}" /> | |||
</Grid> | |||
<Grid Grid.Column="6"> | |||
<Button | |||
Command="{Binding DataContext.RemoveCommand, RelativeSource={RelativeSource AncestorType=ItemsControl, Mode=FindAncestor}}" | |||
CommandParameter="{Binding RecipCode}" | |||
Content="删除" | |||
Style="{StaticResource buttonStyle}" /> | |||
</Grid> | |||
</Grid> | |||
<ControlTemplate.Triggers> | |||
<Trigger Property="IsChecked" Value="True"> | |||
<Setter TargetName="gr" Property="Background" Value="#3300ccff" /> | |||
</Trigger> | |||
<Trigger Property="IsMouseOver" Value="true"> | |||
<Setter TargetName="gr" Property="Background" Value="#3300ccff" /> | |||
</Trigger> | |||
</ControlTemplate.Triggers> | |||
</ControlTemplate> | |||
</RadioButton.Template> | |||
</RadioButton> | |||
</DataTemplate> | |||
</ItemsControl.ItemTemplate> | |||
</ItemsControl> | |||
</ScrollViewer>--> | |||
<!--#endregion--> | |||
</Grid> | |||
</UserControl> |
@@ -28,25 +28,28 @@ namespace BPASmartClient.JXJFoodSmallStation.ViewModel | |||
ErrorInfo = "设备名称不能为空"; | |||
return; | |||
} | |||
int index = Array.FindIndex(DeviceListViewModel.devices.ToArray(), p => p.IpAddress == IpAddress); | |||
if (index >= 0 && index < DeviceListViewModel.devices.Count) | |||
int index = Array.FindIndex(DeviceInquire.GetInstance.devices.ToArray(), p => p.IpAddress == IpAddress); | |||
if (index >= 0 && index < DeviceInquire.GetInstance.devices.Count) | |||
{ | |||
if (DeviceListViewModel.devices.FirstOrDefault(p => p.DeviceName == DeviceName) != null) | |||
if (DeviceInquire.GetInstance.devices.FirstOrDefault(p => p.DeviceName == DeviceName) != null) | |||
ErrorInfo = "设备名称已存在"; | |||
else | |||
{ | |||
var res = Global.DeviceRawMaterials.FirstOrDefault(p => p.RawMaterialName == DeviceListViewModel.devices.ElementAt(index).DeviceName); | |||
res.RawMaterialName = DeviceName; | |||
DeviceListViewModel.devices.ElementAt(index).DeviceName = DeviceName; | |||
DeviceInquire.GetInstance.GetDevice(IpAddress).SetDeviceName(DeviceName);//设置PLC名称 | |||
for (int i = 0; i < Json<LocaPar>.Data.Recipes.Count; i++) | |||
var res = Global.DeviceRawMaterials.FirstOrDefault(p => p.RawMaterialName == DeviceInquire.GetInstance.devices.ElementAt(index).DeviceName); | |||
if (res != null) | |||
{ | |||
for (int m = 0; m < Json<LocaPar>.Data.Recipes.ElementAt(i).RawMaterials.Count; m++) | |||
res.RawMaterialName = DeviceName; | |||
DeviceInquire.GetInstance.devices.ElementAt(index).DeviceName = DeviceName; | |||
DeviceInquire.GetInstance.GetDevice(IpAddress).SetDeviceName(DeviceName);//设置PLC名称 | |||
for (int i = 0; i < Json<LocaPar>.Data.Recipes.Count; i++) | |||
{ | |||
Json<LocaPar>.Data.Recipes.ElementAt(i).RawMaterials.ElementAt(m).RawMaterialName = DeviceName; | |||
for (int m = 0; m < Json<LocaPar>.Data.Recipes.ElementAt(i).RawMaterials.Count; m++) | |||
{ | |||
Json<LocaPar>.Data.Recipes.ElementAt(i).RawMaterials.ElementAt(m).RawMaterialName = DeviceName; | |||
} | |||
} | |||
ActionManage.GetInstance.Send("ChangeDeviceNameViewClose"); | |||
} | |||
ActionManage.GetInstance.Send("ChangeDeviceNameViewClose"); | |||
} | |||
} | |||
@@ -33,7 +33,7 @@ namespace BPASmartClient.JXJFoodSmallStation.ViewModel | |||
public RelayCommand<object> ChangeNameCommand { get; set; } | |||
//public static ObservableCollection<Devices> devices { get; set; } = new ObservableCollection<Devices>(); | |||
public static ObservableCollection<Devices> devices { get; set; } | |||
public ObservableCollection<Devices> devices { get; set; } | |||
} | |||
public class Devices : ObservableObject | |||
@@ -0,0 +1,92 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
using Microsoft.Toolkit.Mvvm.ComponentModel; | |||
using System.Collections.ObjectModel; | |||
using Microsoft.Toolkit.Mvvm.Input; | |||
using BPASmartClient.Helper; | |||
namespace BPASmartClient.JXJFoodSmallStation.ViewModel | |||
{ | |||
public class ManualControlViewModel : ObservableObject | |||
{ | |||
public ManualControlViewModel() | |||
{ | |||
for (int i = 0; i < 15; i++) | |||
{ | |||
cylinderModels.Add(new CylinderModel() | |||
{ | |||
Name = $"升降气缸 {i + 1}", | |||
LeftTog = false, | |||
RightTog = false, | |||
}); | |||
BlockCylinders.Add(new CylinderModel() | |||
{ | |||
Name = $"阻挡气缸 {i + 1}", | |||
LeftTog = false, | |||
RightTog = false, | |||
}); | |||
} | |||
for (int i = 0; i < 2; i++) | |||
{ | |||
PalletCylinders.Add(new CylinderModel() | |||
{ | |||
Name = $"托盘气缸 {i + 1}", | |||
LeftTog = false, | |||
RightTog = false, | |||
}); | |||
} | |||
Open = new RelayCommand<object>((o) => | |||
{ | |||
ActionManage.GetInstance.Send("ManualOpen", o); | |||
}); | |||
Close = new RelayCommand<object>((o) => | |||
{ | |||
ActionManage.GetInstance.Send("ManualClose", o); | |||
}); | |||
} | |||
/// <summary> | |||
/// 升降气缸 | |||
/// </summary> | |||
public ObservableCollection<CylinderModel> cylinderModels { get; set; } = new ObservableCollection<CylinderModel>(); | |||
/// <summary> | |||
/// 阻挡气缸 | |||
/// </summary> | |||
public ObservableCollection<CylinderModel> BlockCylinders { get; set; } = new ObservableCollection<CylinderModel>(); | |||
/// <summary> | |||
/// 托盘气缸 | |||
/// </summary> | |||
public ObservableCollection<CylinderModel> PalletCylinders { get; set; } = new ObservableCollection<CylinderModel>(); | |||
public RelayCommand<object> Open { get; set; } | |||
public RelayCommand<object> Close { get; set; } | |||
} | |||
public class CylinderModel : ObservableObject | |||
{ | |||
public bool LeftTog { get { return _mLeftTog; } set { _mLeftTog = value; OnPropertyChanged(); } } | |||
private bool _mLeftTog; | |||
public bool RightTog { get { return _mRightTog; } set { _mRightTog = value; OnPropertyChanged(); } } | |||
private bool _mRightTog; | |||
public string Name { get { return _mName; } set { _mName = value; OnPropertyChanged(); } } | |||
private string _mName; | |||
} | |||
} |
@@ -59,14 +59,14 @@ namespace BPASmartClient.JXJFoodSmallStation.ViewModel | |||
if (RecipeName == String.Empty) { ErrorInfo = "配方名称未填写"; return; } | |||
for (int i = 0; i < RawMaterials.Count; i++) | |||
{ | |||
var res = DeviceListViewModel.devices.FirstOrDefault(p => p.DeviceName == RawMaterials.ElementAt(i).RawMaterialName); | |||
var res = DeviceInquire.GetInstance.devices.FirstOrDefault(p => p.DeviceName == RawMaterials.ElementAt(i).RawMaterialName); | |||
if (res != null) | |||
{ | |||
RawMaterials.ElementAt(i).DeviceIp = res.IpAddress;//根据设备名称和原料名称的唯一匹配关系,给原料配置IP | |||
RawMaterials.ElementAt(i).RawMaterialSource = 1; | |||
} | |||
var su = Global.DeviceRawMaterials.FirstOrDefault(p => p.RawMaterialName == RawMaterials.ElementAt(i).RawMaterialName); | |||
if(su != null) | |||
if (su != null) | |||
{ | |||
RawMaterials.ElementAt(i).RawMaterialSource = su.RawMaterialSource; | |||
} | |||
@@ -179,7 +179,7 @@ namespace BPASmartClient.JXJFoodSmallStation.ViewModel | |||
public RelayCommand SaveCommand { get; set; } | |||
public ObservableCollection<RawMaterialModel> RawMaterials { get; set; } = new ObservableCollection<RawMaterialModel> (); | |||
public ObservableCollection<RawMaterialModel> RawMaterials { get; set; } = new ObservableCollection<RawMaterialModel>(); | |||
public ObservableCollection<string> RawMaterialNames { get; set; } = new ObservableCollection<string>(); | |||
@@ -78,13 +78,18 @@ namespace BPASmartClient.JXJFoodSmallStation.ViewModel | |||
RawMaterialId = item.RawMaterialId, | |||
}); | |||
})); | |||
} | |||
Recipes.ElementAt(index).Are.WaitOne();//阻塞,直到当前配方完成 | |||
devices.TryDequeue(out string deviceName); | |||
UserTreeCompelete.Add(Recipes.ElementAt(index));//当前配方完成后添加到已完成的配方列表 | |||
App.Current.Dispatcher.Invoke(new Action(() => { recipeProcesses.Clear(); }));//完成后清空当前配方 | |||
devices.TryDequeue(out string deviceName); | |||
App.Current.Dispatcher.Invoke(new Action(() => | |||
{ | |||
UserTreeCompelete.Add(Recipes.ElementAt(index));//当前配方完成后添加到已完成的配方列表 | |||
})); | |||
App.Current.Dispatcher.Invoke(new Action(() => { | |||
recipeProcesses.Clear(); | |||
CurrentRecipeName = string.Empty; | |||
}));//完成后清空当前配方 | |||
} | |||
} | |||
@@ -112,30 +117,52 @@ namespace BPASmartClient.JXJFoodSmallStation.ViewModel | |||
} | |||
} | |||
Recipes.ElementAt(i).RawMaterials.ElementAt(m).RecipeStatus = RunStatus; | |||
var res = Recipes.ElementAt(i).RawMaterials.Where(p => p.RecipeStatus == 3).ToList(); | |||
if (res != null && res.Count == Recipes.ElementAt(i).RawMaterials.Count)//配方所有配料完成下料 | |||
var proc = recipeProcesses.Where(p=>p.RecipeStatus==3).ToList(); | |||
if (proc != null && proc.Count > 0 && proc.Count== recipeProcesses.Count) | |||
{ | |||
for (int r = 0; r < Recipes.ElementAt(i).RawMaterials.Count; r++) | |||
int recipIndex = Array.FindIndex(Recipes.ToArray(), p => p.RecipeName == CurrentRecipeName); | |||
if (recipIndex >= 0 && recipIndex < Recipes.Count) | |||
{ | |||
DeviceInquire.GetInstance.GetDevice(Recipes.ElementAt(i).RawMaterials.ElementAt(r).DeviceIp).StatusReset();//完成配料的设备运行状态地址写0 | |||
App.Current.Dispatcher.Invoke(new Action(() => { recipeProcesses.Clear(); })); | |||
for (int n = 0; n < recipeProcesses.Count; n++) | |||
{ | |||
DeviceInquire.GetInstance.GetDevice(Recipes.ElementAt(recipIndex).RawMaterials.ElementAt(n).DeviceIp).StatusReset();//完成配料的设备运行状态地址写0 | |||
MessageLog.GetInstance.ShowRunLog(Recipes.ElementAt(recipIndex).RawMaterials.ElementAt(n).DeviceIp); | |||
} | |||
App.Current.Dispatcher.Invoke(new Action(() => { recipeProcesses.Clear(); })); | |||
Recipes.ElementAt(recipIndex).IsEnable = true; | |||
Recipes.ElementAt(recipIndex).Are.Set(); | |||
} | |||
Recipes.ElementAt(i).IsEnable = true; | |||
Recipes.ElementAt(i).Are.Set(); | |||
} | |||
} | |||
//Recipes.ElementAt(i).RawMaterials.ElementAt(m).RecipeStatus = RunStatus; | |||
//var res = Recipes.ElementAt(i).RawMaterials.Where(p => p.RecipeStatus == 3).ToList(); | |||
//if (res != null && res.Count == Recipes.ElementAt(i).RawMaterials.Count)//配方所有配料完成下料 | |||
//{ | |||
// for (int r = 0; r < Recipes.ElementAt(i).RawMaterials.Count; r++) | |||
// { | |||
// DeviceInquire.GetInstance.GetDevice(Recipes.ElementAt(i).RawMaterials.ElementAt(r).DeviceIp).StatusReset();//完成配料的设备运行状态地址写0 | |||
// App.Current.Dispatcher.Invoke(new Action(() => { recipeProcesses.Clear(); })); | |||
// } | |||
// Recipes.ElementAt(i).IsEnable = true; | |||
// Recipes.ElementAt(i).Are.Set(); | |||
//} | |||
} | |||
} | |||
Thread.Sleep(100); | |||
}), "RecipeControlViewModelStatusInquire"); | |||
//测试数据 | |||
RawMaterialModel rawMaterial_1 = new RawMaterialModel { RawMaterialName = "香料_1" }; | |||
/* RawMaterialModel rawMaterial_1 = new RawMaterialModel { RawMaterialName = "香料_1" }; | |||
RawMaterialModel rawMaterial_2 = new RawMaterialModel { RawMaterialName = "香料_2" }; | |||
RawMaterialModel rawMaterial_3 = new RawMaterialModel { RawMaterialName = "香料_3" }; | |||
RawMaterialModel rawMaterial_4 = new RawMaterialModel { RawMaterialName = "香料_4" }; | |||
ObservableCollection<RawMaterialModel> rawMaterials = new ObservableCollection<RawMaterialModel> { rawMaterial_1, rawMaterial_2, rawMaterial_3, rawMaterial_4 }; | |||
UserTreeCompelete.Add(new RecipeModel { RecipeName = "完成的香料1", RawMaterials = rawMaterials }); | |||
UserTreeCompelete.Add(new RecipeModel { RecipeName = "完成的香料2", RawMaterials = rawMaterials }); | |||
UserTreeCompelete.Add(new RecipeModel { RecipeName = "完成的香料2", RawMaterials = rawMaterials });*/ | |||
} | |||