|
|
@@ -28,7 +28,6 @@ namespace BPASmartClient.DosingSystem.ViewModel |
|
|
|
static ObservableCollection<StockStatusModel> StockStatus = new ObservableCollection<StockStatusModel>(); |
|
|
|
public RecipeControlViewModel() |
|
|
|
{ |
|
|
|
|
|
|
|
StartCommand = new BPARelayCommand<object>(RecipeIssued); |
|
|
|
ChangeRecipeStateCommand = new BPARelayCommand<object>(ChangeRecipeState); |
|
|
|
CancelRecipeCommand = new BPARelayCommand<object>(CancelRecipe); |
|
|
@@ -295,7 +294,7 @@ namespace BPASmartClient.DosingSystem.ViewModel |
|
|
|
Thread.Sleep(100); |
|
|
|
}), "启动配方下发", true); |
|
|
|
} |
|
|
|
|
|
|
|
int ComCount = 0; |
|
|
|
/// <summary> |
|
|
|
/// 配方执行状态监听 |
|
|
|
/// </summary> |
|
|
@@ -733,13 +732,13 @@ namespace BPASmartClient.DosingSystem.ViewModel |
|
|
|
if (recIndex >= 0 && recIndex < recipeProcesses.Count) |
|
|
|
{ |
|
|
|
int index = recipeProcesses.ElementAt(recIndex).RawMaterials.ToList().FindIndex(p => p.RawMaterialName == tempRawMaterialName); |
|
|
|
int a11= recipeProcesses.ElementAt(recIndex).RawMaterials.ToList().FindIndex(p => p.RawMaterialName == tempRawMaterialName&&p.RecipeStatus==2); |
|
|
|
int a112 = recipeProcesses.ElementAt(recIndex).RawMaterials.ToList().FindIndex(p => p.RawMaterialName == tempRawMaterialName && p.RecipeStatus == 3); |
|
|
|
if (index >= 0 && index < recipeProcesses.ElementAt(recIndex).RawMaterials.Count) |
|
|
|
{ |
|
|
|
//测试使用 |
|
|
|
recipeProcesses.ElementAt(recIndex).RawMaterials.ElementAt(index).RecipeStatus = RunStatus; |
|
|
|
} |
|
|
|
|
|
|
|
//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++) |
|
|
|
{ |
|
|
|
if (GlobalDevice.PlcData.IsAllowIngredients[j]) |
|
|
@@ -814,29 +813,38 @@ namespace BPASmartClient.DosingSystem.ViewModel |
|
|
|
{ |
|
|
|
StockStatus.ElementAt(St_index).IssueStatus = 1; |
|
|
|
DeviceInquire.GetInstance.GetDevice(Recipes.ElementAt(i).RawMaterials.ElementAt(loc).DeviceIp).Start(weight); |
|
|
|
recipeProcesses.ElementAt(recIndex).RawMaterials.ElementAt(loc).RecipeStatus = 2; |
|
|
|
MessageNotify.GetInstance.ShowRunLog($"设备执行状态:{rrr}"); |
|
|
|
MessageNotify.GetInstance.ShowRunLog($"柔性味魔方{Recipes.ElementAt(i).RawMaterials.ElementAt(loc).DeviceIp},开始出料"); |
|
|
|
} |
|
|
|
if (recipeProcesses.ElementAt(recIndex).RawMaterials.ElementAt(loc).RecipeStatus == 3 && StockStatus.ElementAt(St_index).IssueStatus == 1) |
|
|
|
{ |
|
|
|
//GlobalDevice.PlcData.IsAllowIngredients[j] = false;//测试使用 |
|
|
|
recipeProcesses.ElementAt(recIndex).RawMaterials.ElementAt(loc).RecipeStatus = 3; |
|
|
|
ComCount++; |
|
|
|
StockStatus.ElementAt(St_index).IssueStatus = 2; |
|
|
|
DeviceInquire.GetInstance.GetDevice(Recipes.ElementAt(i).RawMaterials.ElementAt(loc).DeviceIp).StatusReset(); |
|
|
|
int a = 0.SetBitValue((byte)(DeviceNum), true); |
|
|
|
byte[] test1 = a.ToBytes(BPA.Helper.DataFormat.BADC); |
|
|
|
int item = test1.ToInt(); |
|
|
|
//int a = 0.SetBitValue((byte)(DeviceNum), true); |
|
|
|
//byte[] test1 = a.ToBytes(BPA.Helper.DataFormat.BADC); |
|
|
|
//int item = test1.ToInt(); |
|
|
|
//prop1: |
|
|
|
// SiemensDevice.GetInstance.MySiemens.Write("DB4.DBD130", item); |
|
|
|
SiemensDevice.GetInstance.MySiemens.Write($"DB4.DBX130.{DeviceNum - 1}", true); |
|
|
|
//var values = SiemensDevice.GetInstance.MySiemens.Read<int>("DB4.DBD130").Content; |
|
|
|
//if ((values != null && values.ToString() != item.ToString()) || values == null) |
|
|
|
// goto prop1; |
|
|
|
SiemensDevice.GetInstance.MySiemens.Write($"DB4.DBX130.{DeviceNum - 1}", true).OnSuccess(() => |
|
|
|
{ |
|
|
|
MessageNotify.GetInstance.ShowRunLog($"设备完成信号写入成功!DB4.DBX130.{{DeviceNum - 1}}:true\""); |
|
|
|
}).OnFail(s => |
|
|
|
{ |
|
|
|
MessageNotify.GetInstance.ShowRunLog($"设备完成信号写入失败!{s}"); |
|
|
|
}); |
|
|
|
//var values = SiemensDevice.GetInstance.MySiemens.Read<int>("DB4.DBD130").Content; |
|
|
|
//if ((values != null && values.ToString() != item.ToString()) || values == null) |
|
|
|
// goto prop1; |
|
|
|
|
|
|
|
MessageNotify.GetInstance.ShowRunLog($"设备完成信号写入成功!状态值 {item}"); |
|
|
|
//SiemensDevice.GetInstance.MySiemens.Write("DB4.DBD130", item).OnSuccess(() => |
|
|
|
|
|
|
|
//SiemensDevice.GetInstance.MySiemens.Write("DB4.DBD130", true).OnSuccess(() => |
|
|
|
//{ |
|
|
|
// MessageNotify.GetInstance.ShowRunLog($"设备完成信号写入成功!"); |
|
|
|
//}).OnFail(s => |
|
|
|
//}).OnFail(s => |
|
|
|
//{ |
|
|
|
// MessageNotify.GetInstance.ShowRunLog($"设备完成信号写入失败!{s}"); |
|
|
|
//}); |
|
|
@@ -1137,9 +1145,10 @@ namespace BPASmartClient.DosingSystem.ViewModel |
|
|
|
//} |
|
|
|
} |
|
|
|
//int Finish_Count = StockStatus.Where(s => s.IssueStatus == 2).Count(); |
|
|
|
int Finish_Count = recipeProcesses.ElementAt(recIndex).RawMaterials.Where(p => p.RecipeStatus == 3).Count(); |
|
|
|
if ( Finish_Count >= Recipes.ElementAt(i).RawMaterials.Count) //配方配料完成 StockStatus.Count >= Recipes.ElementAt(i).RawMaterials.Count && |
|
|
|
//int Finish_Count = recipeProcesses.ElementAt(recIndex).RawMaterials.Where(p => p.RecipeStatus == 3).Count(); |
|
|
|
if ( ComCount >= Recipes.ElementAt(i).RawMaterials.Count) //配方配料完成 StockStatus.Count >= Recipes.ElementAt(i).RawMaterials.Count && |
|
|
|
{ |
|
|
|
ComCount = 0; |
|
|
|
StockStatus.Clear(); |
|
|
|
MessageNotify.GetInstance.ShowUserLog($"配方:{recipeProcesses.ElementAt(recIndex).RecipeName},配料完成"); |
|
|
|
foreach (var item in recipeProcesses.ElementAt(recIndex).RawMaterials) |
|
|
|