Explorar el Código

流程更新

master
pengliangyang hace 2 años
padre
commit
80ee127af1
Se han modificado 2 ficheros con 44 adiciones y 57 borrados
  1. +17
    -6
      DosingSystem/Model/StockStatusModel.cs
  2. +27
    -51
      DosingSystem/ViewModel/RecipeControlViewModel.cs

+ 17
- 6
DosingSystem/Model/StockStatusModel.cs Ver fichero

@@ -12,26 +12,27 @@ namespace BPASmartClient.DosingSystem
/// <summary>
/// 料仓物料重量
/// </summary>
private double _materialWeight;
public double MaterialWeight { get { return _materialWeight; } set { _materialWeight = value; OnPropertyChanged(); } }
private double _materialWeight;
/// <summary>
/// 料仓物料名称
/// </summary>
private string _materialName;
public string MaterialName { get { return _materialName; } set { _materialName = value; OnPropertyChanged(); } }
private string _materialName;
/// <summary>
/// 是否真在运行
/// </summary>
private bool _isRunning;
public bool IsRunning { get { return _isRunning; } set { _isRunning = value; OnPropertyChanged(); } }
private bool _isRunning;

/// <summary>
/// 是否正在下料
/// </summary>
private bool _isLayOff;
public bool IsLayOff { get { return _isLayOff; } set { _isLayOff = value; OnPropertyChanged(); } }
private bool _isLayOff;

/// <summary>
/// 打开状态
/// 是否开盖
/// </summary>
public bool IsOpen { get { return _mIsOpen; } set { _mIsOpen = value; OnPropertyChanged(); } }
private bool _mIsOpen;
@@ -39,8 +40,18 @@ namespace BPASmartClient.DosingSystem
/// <summary>
/// 是否故障报警
/// </summary>
public bool IsFault { get { return _isFault; } set { _isFault = value; OnPropertyChanged(); } }
private bool _isFault;
public bool IsFault { get { return _isFault; } set { _isFault = value; OnPropertyChanged(); } }

/// <summary>
/// 下料状态 0:未出料 1:出料指令下发 2:出料完成
/// </summary>
public int IssueStatus { get { return _isIssueStatus; } set { _isIssueStatus = value; OnPropertyChanged(); } }
private int _isIssueStatus;
/// <summary>
/// 下料重量
/// </summary>
public double IssueWeight { get { return _IssueWeight; } set { _IssueWeight = value; OnPropertyChanged(); } }
private double _IssueWeight;
}
}

+ 27
- 51
DosingSystem/ViewModel/RecipeControlViewModel.cs Ver fichero

@@ -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) =>
@@ -50,8 +50,6 @@ namespace BPASmartClient.DosingSystem.ViewModel
var res = Recipes.FirstOrDefault(p => p.RecipeName == deviceName);
UserTreeWait.Add(new RecipeModel { 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++)
@@ -202,7 +199,6 @@ namespace BPASmartClient.DosingSystem.ViewModel
{
App.Current.Dispatcher.Invoke(new Action(() => { recipeProcesses.ElementAt(recIndex).RawMaterials.ElementAt(index).RecipeStatus = RunStatus; }));
}
//App.Current.Dispatcher.Invoke(new Action(() => { recipeProcesses.ElementAt(index).RecipeStatus = RunStatus; }));
for (int j = 0; j < GlobalDevice.PlcData.IsAllowIngredients.Length; j++)
{
if (GlobalDevice.PlcData.IsAllowIngredients[j])
@@ -213,25 +209,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;
@@ -239,40 +249,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);


Cargando…
Cancelar
Guardar