|
|
@@ -20,7 +20,7 @@ namespace BPASmartClient.DosingSystem.ViewModel |
|
|
|
public class RecipeControlViewModel : NotifyBase |
|
|
|
{ |
|
|
|
ConcurrentQueue<string> RecipeNames = new ConcurrentQueue<string>(); |
|
|
|
|
|
|
|
ObservableCollection<StockStatusModel> StockStatus = new ObservableCollection<StockStatusModel>(); |
|
|
|
public RecipeControlViewModel() |
|
|
|
{ |
|
|
|
StartCommand = new RelayCommand<object>((o) => |
|
|
@@ -48,10 +48,8 @@ namespace BPASmartClient.DosingSystem.ViewModel |
|
|
|
MessageNotify.GetInstance.ShowUserLog($"下发工单 {Recipes.ElementAt(index).RecipeName}"); |
|
|
|
RecipeNames.Enqueue(deviceName); |
|
|
|
var res = Recipes.FirstOrDefault(p => p.RecipeName == deviceName); |
|
|
|
UserTreeWait.Add(new RecipeModel { RecipeName = deviceName, RawMaterials = res.RawMaterials }); |
|
|
|
UserTreeWait.Add(new RecipeModel {SerialNum= UserTreeWait.Count + 1, RecipeName = deviceName, RawMaterials = res.RawMaterials }); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
NoticeDemoViewModel.OpenMsg(EnumPromptType.Success, App.MainWindow, "提示", $"配方下发成功!"); |
|
|
|
MessageNotify.GetInstance.ShowUserLog($"下发工单 {Guid.NewGuid().ToString()}"); |
|
|
|
}); |
|
|
@@ -67,6 +65,7 @@ namespace BPASmartClient.DosingSystem.ViewModel |
|
|
|
{ |
|
|
|
Recipes.ElementAt(index).Are.Reset(); |
|
|
|
Recipes.ElementAt(index).IsEnable = false; |
|
|
|
StockStatus.Clear(); |
|
|
|
App.Current.Dispatcher.Invoke(new Action(() => |
|
|
|
{ |
|
|
|
recipeProcesses.Clear(); |
|
|
@@ -180,8 +179,6 @@ namespace BPASmartClient.DosingSystem.ViewModel |
|
|
|
}), "启动配方下发"); |
|
|
|
|
|
|
|
|
|
|
|
List<string> RawMaterialNameFinish = new List<string>();//配料完成料仓名称的集合 |
|
|
|
bool[] SingleRawMater = new bool[32];//单次配料 |
|
|
|
ThreadManage.GetInstance().StartLong(new Action(() => |
|
|
|
{ |
|
|
|
for (int i = 0; i < Recipes.Count; i++) |
|
|
@@ -214,25 +211,39 @@ namespace BPASmartClient.DosingSystem.ViewModel |
|
|
|
int loc = Array.FindIndex(Recipes.ElementAt(i).RawMaterials.ToArray(), p => p.RawMaterialName == deviceName); |
|
|
|
if (cnt > 0 && loc > 0 && deviceName != null && weight > 0) |
|
|
|
{ |
|
|
|
if (recipeProcesses.ElementAt(recIndex).RawMaterials.ElementAt(loc).RecipeStatus == 1 && !SingleRawMater[j]) |
|
|
|
int St_index = Array.FindIndex(StockStatus.ToArray(), p => p.MaterialName == deviceName); |
|
|
|
if (St_index < 0) |
|
|
|
{ |
|
|
|
SingleRawMater[j] = true; |
|
|
|
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 (RTrig.GetInstance("StatusReset").Start(recipeProcesses.ElementAt(recIndex).RawMaterials.ElementAt(loc).RecipeStatus == 3)) |
|
|
|
else |
|
|
|
{ |
|
|
|
DeviceInquire.GetInstance.GetDevice(Recipes.ElementAt(i).RawMaterials.ElementAt(loc).DeviceIp).StatusReset(); |
|
|
|
RawMaterialNameFinish.Add(Recipes.ElementAt(i).RawMaterials.ElementAt(loc).RawMaterialName); |
|
|
|
SiemensDevice.GetInstance.MySiemens.Write("DB4.DBD130", loc.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 (RTrig.GetInstance("StatusReset").Start(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(); |
|
|
|
SiemensDevice.GetInstance.MySiemens.Write("DB4.DBD130", 0.SetBitValue((byte)loc, true)); |
|
|
|
MessageNotify.GetInstance.ShowRunLog($"柔性味魔方{Recipes.ElementAt(i).RawMaterials.ElementAt(loc).DeviceIp},出料完成,状态复位"); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
if (RawMaterialNameFinish.Count >= Recipes.ElementAt(i).RawMaterials.Count) //配方配料完成 |
|
|
|
if (StockStatus.Count >= Recipes.ElementAt(i).RawMaterials.Count) //配方配料完成 |
|
|
|
{ |
|
|
|
RawMaterialNameFinish.Clear(); |
|
|
|
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; |
|
|
@@ -240,40 +251,6 @@ namespace BPASmartClient.DosingSystem.ViewModel |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
//var proc = recipeProcesses.Where(p => p.RecipeStatus == 3).ToList(); |
|
|
|
//var proc = recipeProcesses.Where(p => p.RecipeStatus == 3).ToList(); |
|
|
|
//if (proc != null && proc.Count > 0 && proc.Count == recipeProcesses.Count) |
|
|
|
//{ |
|
|
|
// int recipIndex = Array.FindIndex(Recipes.ToArray(), p => p.RecipeName == CurrentRecipeName); |
|
|
|
// if (recipIndex >= 0 && recipIndex < Recipes.Count) |
|
|
|
// { |
|
|
|
// for (int n = 0; n < recipeProcesses.Count; n++) |
|
|
|
// { |
|
|
|
// DeviceInquire.GetInstance.GetDevice(Recipes.ElementAt(recipIndex).RawMaterials.ElementAt(n).DeviceIp).StatusReset();//完成配料的设备运行状态地址写0 |
|
|
|
// MessageNotify.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).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); |
|
|
|