|
|
@@ -19,8 +19,8 @@ namespace BPASmartClient.DosingSystem.ViewModel |
|
|
|
{ |
|
|
|
public class RecipeControlViewModel : NotifyBase |
|
|
|
{ |
|
|
|
ConcurrentQueue<string> RecipeNames = new ConcurrentQueue<string>(); |
|
|
|
ObservableCollection<StockStatusModel> StockStatus = new ObservableCollection<StockStatusModel>(); |
|
|
|
public static ConcurrentQueue<string> RecipeNames = new ConcurrentQueue<string>(); |
|
|
|
public static ObservableCollection<StockStatusModel> StockStatus = new ObservableCollection<StockStatusModel>(); |
|
|
|
public RecipeControlViewModel() |
|
|
|
{ |
|
|
|
StartCommand = new RelayCommand<object>(RecipeIssued); |
|
|
@@ -53,9 +53,11 @@ namespace BPASmartClient.DosingSystem.ViewModel |
|
|
|
} |
|
|
|
} |
|
|
|
Recipes.ElementAt(index).IsEnable = false; |
|
|
|
Json<LocaPar>.Data.Recipes.ElementAt(index).IsEnable = false; |
|
|
|
} |
|
|
|
MessageNotify.GetInstance.ShowUserLog($"下发工单 {Recipes.ElementAt(index).RecipeName}"); |
|
|
|
RecipeNames.Enqueue(deviceName); |
|
|
|
var t = RecipeNames.GetHashCode(); |
|
|
|
var res = Recipes.FirstOrDefault(p => p.RecipeName == deviceName); |
|
|
|
UserTreeWait.Add(new RecipeModel { SerialNum = UserTreeWait.Count + 1, RecipeName = deviceName, RawMaterials = res.RawMaterials }); |
|
|
|
} |
|
|
@@ -184,17 +186,17 @@ 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; |
|
|
|
//recipeProcesses.ElementAt(recIndex).RawMaterials.ElementAt(index).RecipeStatus = RunStatus; |
|
|
|
} |
|
|
|
for (int j = 0; j < GlobalDevice.PlcData.IsAllowIngredients.Length; j++) |
|
|
|
{ |
|
|
|
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 == j)).RawMaterialWeight; |
|
|
|
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) |
|
|
|
if (cnt > 0 && loc >= 0 && deviceName != null && weight >= 0) |
|
|
|
{ |
|
|
|
int St_index = Array.FindIndex(StockStatus.ToArray(), p => p.MaterialName == deviceName); |
|
|
|
if (St_index < 0) |
|
|
@@ -206,7 +208,8 @@ namespace BPASmartClient.DosingSystem.ViewModel |
|
|
|
IssueStatus = 0, |
|
|
|
}); |
|
|
|
} |
|
|
|
else |
|
|
|
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) |
|
|
|
{ |
|
|
@@ -214,7 +217,7 @@ namespace BPASmartClient.DosingSystem.ViewModel |
|
|
|
DeviceInquire.GetInstance.GetDevice(Recipes.ElementAt(i).RawMaterials.ElementAt(loc).DeviceIp).Start(weight); |
|
|
|
MessageNotify.GetInstance.ShowRunLog($"柔性味魔方{Recipes.ElementAt(i).RawMaterials.ElementAt(loc).DeviceIp},开始出料"); |
|
|
|
} |
|
|
|
if (RTrig.GetInstance("StatusReset").Start(recipeProcesses.ElementAt(recIndex).RawMaterials.ElementAt(loc).RecipeStatus == 3) && StockStatus.ElementAt(St_index).IssueStatus == 1) |
|
|
|
if (recipeProcesses.ElementAt(recIndex).RawMaterials.ElementAt(loc).RecipeStatus == 3 && StockStatus.ElementAt(St_index).IssueStatus == 1) |
|
|
|
{ |
|
|
|
StockStatus.ElementAt(St_index).IssueStatus = 2; |
|
|
|
DeviceInquire.GetInstance.GetDevice(Recipes.ElementAt(i).RawMaterials.ElementAt(loc).DeviceIp).StatusReset(); |
|
|
@@ -225,15 +228,18 @@ namespace BPASmartClient.DosingSystem.ViewModel |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
if (StockStatus.Count >= Recipes.ElementAt(i).RawMaterials.Count) //配方配料完成 |
|
|
|
int Finish_Count = StockStatus.Where(s => s.IssueStatus == 2).Count(); |
|
|
|
if (StockStatus.Count >= Recipes.ElementAt(i).RawMaterials.Count && Finish_Count >= Recipes.ElementAt(i).RawMaterials.Count) //配方配料完成 |
|
|
|
{ |
|
|
|
StockStatus.Clear(); |
|
|
|
SiemensDevice.GetInstance.MySiemens.Write("DB4.DBX202.1", true);//配方使用桶数写入 |
|
|
|
int recipIndex = Array.FindIndex(Recipes.ToArray(), p => p.RecipeName == CurrentRecipeName); |
|
|
|
App.Current.Dispatcher.Invoke(new Action(() => { recipeProcesses.Clear(); })); |
|
|
|
Recipes.ElementAt(recipIndex).IsEnable = true; |
|
|
|
Json<LocaPar>.Data.Recipes.ElementAt(recipIndex).IsEnable = true; |
|
|
|
Recipes.ElementAt(recipIndex).Are.Set(); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@@ -248,7 +254,7 @@ namespace BPASmartClient.DosingSystem.ViewModel |
|
|
|
|
|
|
|
public static ObservableCollection<RecipeModel> Recipes { get; set; } = Json<LocaPar>.Data.Recipes; |
|
|
|
|
|
|
|
public string CurrentRecipeName { get { return _RecipeName; } set { _RecipeName = value; OnPropertyChanged(); } } |
|
|
|
public static string CurrentRecipeName { get { return _RecipeName; } set { _RecipeName = value; OnStaticPropertyChanged(); } } |
|
|
|
private static string _RecipeName; |
|
|
|
|
|
|
|
/// <summary> |
|
|
|