diff --git a/BPASmartClient.CustomResource/BPASmartClient.CustomResource.csproj b/BPASmartClient.CustomResource/BPASmartClient.CustomResource.csproj
index 81e148b7..84783f76 100644
--- a/BPASmartClient.CustomResource/BPASmartClient.CustomResource.csproj
+++ b/BPASmartClient.CustomResource/BPASmartClient.CustomResource.csproj
@@ -201,6 +201,7 @@
+
@@ -362,6 +363,7 @@
+
diff --git a/BPASmartClient.CustomResource/Image/组合边框2.png b/BPASmartClient.CustomResource/Image/组合边框2.png
new file mode 100644
index 00000000..8ffa46c3
Binary files /dev/null and b/BPASmartClient.CustomResource/Image/组合边框2.png differ
diff --git a/BPASmartClient.Model/Status.cs b/BPASmartClient.Model/Status.cs
new file mode 100644
index 00000000..b49d9064
--- /dev/null
+++ b/BPASmartClient.Model/Status.cs
@@ -0,0 +1,15 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace BPASmartClient.Model
+{
+ public enum Status
+ {
+ 等待配料,
+ 正在配料,
+ 配料完成
+ }
+}
diff --git a/BPASmartClient.Model/柔性味魔方/RawMaterialModel.cs b/BPASmartClient.Model/柔性味魔方/RawMaterialModel.cs
index 7efb9e6b..7e508ead 100644
--- a/BPASmartClient.Model/柔性味魔方/RawMaterialModel.cs
+++ b/BPASmartClient.Model/柔性味魔方/RawMaterialModel.cs
@@ -104,7 +104,26 @@ namespace BPASmartClient.Model
/// 3:下料完成
///
[Newtonsoft.Json.JsonIgnore]
- public ushort RecipeStatus { get { return _mRecipeStatus; } set { _mRecipeStatus = value; OnPropertyChanged(); } }
+ public ushort RecipeStatus
+ {
+ get { return _mRecipeStatus; }
+ set
+ {
+ _mRecipeStatus = value;
+ if (value == 1) Status = Status.等待配料;
+ else if (value == 2) Status = Status.正在配料;
+ else if (value == 3) Status = Status.配料完成;
+ OnPropertyChanged();
+ }
+ }
private ushort _mRecipeStatus = 1;
+
+ ///
+ /// 配料状态名称
+ ///
+ [Newtonsoft.Json.JsonIgnore]
+ public Status Status { get { return _mStatus; } set { _mStatus = value; OnPropertyChanged(); } }
+ private Status _mStatus;
+
}
}
diff --git a/DosingSystem/Model/DeviceInquire.cs b/DosingSystem/Model/DeviceInquire.cs
index f928ba15..b7218bf7 100644
--- a/DosingSystem/Model/DeviceInquire.cs
+++ b/DosingSystem/Model/DeviceInquire.cs
@@ -81,6 +81,7 @@ namespace BPASmartClient.DosingSystem
devices.Add(new Devices()
{
DeviceName = $"测试设备{i + 1}",
+ DeviceNum = i + 1,
IpAddress = $"192.168.1.{i + 1}",
});
}
@@ -102,6 +103,7 @@ namespace BPASmartClient.DosingSystem
devices.Add(new Devices()
{
DeviceName = $"测试设备{i + 1}",
+ DeviceNum = i + 1,
IpAddress = $"192.168.1.{i + 1}",
});
}
diff --git a/DosingSystem/Model/SiemensPlc/PlcToComputer.cs b/DosingSystem/Model/SiemensPlc/PlcToComputer.cs
index 0bf6dcb9..65ab0fc2 100644
--- a/DosingSystem/Model/SiemensPlc/PlcToComputer.cs
+++ b/DosingSystem/Model/SiemensPlc/PlcToComputer.cs
@@ -17,7 +17,7 @@ namespace BPASmartClient.DosingSystem
public bool Heartbeat { get; set; }
///
- /// 接收完成
+ /// 接收配方完成
///
public bool ResComplete { get; set; }
diff --git a/DosingSystem/View/RecipeControlView.xaml b/DosingSystem/View/RecipeControlView.xaml
index 19187468..bf2c21b4 100644
--- a/DosingSystem/View/RecipeControlView.xaml
+++ b/DosingSystem/View/RecipeControlView.xaml
@@ -338,10 +338,6 @@
ScrollViewer.HorizontalScrollBarVisibility="Disabled">
-
@@ -351,8 +347,8 @@
@@ -715,7 +711,7 @@
-
@@ -777,27 +773,260 @@
-
+
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
diff --git a/DosingSystem/View/RecipeControlView.xaml.cs b/DosingSystem/View/RecipeControlView.xaml.cs
index ca107fff..701a1f1a 100644
--- a/DosingSystem/View/RecipeControlView.xaml.cs
+++ b/DosingSystem/View/RecipeControlView.xaml.cs
@@ -24,33 +24,39 @@ namespace BPASmartClient.DosingSystem.View
public RecipeControlView()
{
InitializeComponent();
- RadioButtonWait_Click(null,null);
+ RadioButtonWait_Click(null, null);
}
-
-
-
private void RadioButtonCompelete_Click(object sender, RoutedEventArgs e)
{
- repiceList.ItemsSource = RecipeControlViewModel.UserTreeCompelete;
- repiceList.Visibility = Visibility.Visible;
- repiceListMaking.Visibility = Visibility.Hidden;
-
-
+ //repiceList.ItemsSource = RecipeControlViewModel.UserTreeCompelete;
+ //repiceList.Visibility = Visibility.Visible;
+ //repiceListMaking.Visibility = Visibility.Hidden;
+ this.Wait.ItemsSource = RecipeControlViewModel.UserTreeCompelete;
+ CookingGrid.Visibility = Visibility.Collapsed;
+ WaitOrCompleteGrid.Visibility = Visibility.Visible;
+ this.Wait.Visibility = Visibility.Hidden;
}
private void RadioButtonWait_Click(object sender, RoutedEventArgs e)
{
- repiceList.ItemsSource = RecipeControlViewModel.UserTreeWait;
- repiceList.Visibility = Visibility.Visible;
- repiceListMaking.Visibility = Visibility.Hidden;
+ //repiceList.ItemsSource = RecipeControlViewModel.UserTreeWait;
+ //repiceList.Visibility = Visibility.Visible;
+ //repiceListMaking.Visibility = Visibility.Hidden;
+ this.Wait.ItemsSource = RecipeControlViewModel.UserTreeWait;
+ CookingGrid.Visibility = Visibility.Collapsed;
+ WaitOrCompleteGrid.Visibility = Visibility.Visible;
+ this.Wait.Visibility = Visibility.Visible;
+
}
private void RadioButtonMaking_Click(object sender, RoutedEventArgs e)
{
- repiceListMaking.Visibility = Visibility.Visible;
- repiceList.Visibility = Visibility.Hidden;
-
+ //repiceListMaking.Visibility = Visibility.Visible;
+ //repiceList.Visibility = Visibility.Hidden;
+ WaitOrCompleteGrid.Visibility = Visibility.Collapsed;
+ this.Wait.Visibility = Visibility.Collapsed;
+ CookingGrid.Visibility = Visibility.Visible;
}
}
}
diff --git a/DosingSystem/ViewModel/DeviceListViewModel.cs b/DosingSystem/ViewModel/DeviceListViewModel.cs
index 5603ea5f..947d2915 100644
--- a/DosingSystem/ViewModel/DeviceListViewModel.cs
+++ b/DosingSystem/ViewModel/DeviceListViewModel.cs
@@ -41,6 +41,12 @@ namespace BPASmartClient.DosingSystem.ViewModel
public string IpAddress { get { return _mIpAddress; } set { _mIpAddress = value; OnPropertyChanged(); } }
private string _mIpAddress;
+ ///
+ /// 设备编号
+ ///
+ public int DeviceNum { get { return _mDeviceNum; } set { _mDeviceNum = value; OnPropertyChanged(); } }
+ private int _mDeviceNum;
+
public string DeviceName { get { return _mDeviceName; } set { _mDeviceName = value; OnPropertyChanged(); } }
private string _mDeviceName;
diff --git a/DosingSystem/ViewModel/RecipeControlViewModel.cs b/DosingSystem/ViewModel/RecipeControlViewModel.cs
index f044d5fd..f4157cee 100644
--- a/DosingSystem/ViewModel/RecipeControlViewModel.cs
+++ b/DosingSystem/ViewModel/RecipeControlViewModel.cs
@@ -15,6 +15,7 @@ using BPASmartClient.CustomResource.UserControls.MessageShow;
using BPASmartClient.CustomResource.UserControls;
using BPASmartClient.Model.柔性味魔方;
using BPASmartClient.Model;
+using System.Diagnostics;
namespace BPASmartClient.DosingSystem.ViewModel
{
@@ -37,11 +38,11 @@ namespace BPASmartClient.DosingSystem.ViewModel
{
string ip = Recipes.ElementAt(index).RawMaterials.ElementAt(i).DeviceIp;
var device = DeviceInquire.GetInstance.GetDevice(ip);
- if (!device.IsConnected)
- {
- MessageNotify.GetInstance.ShowDialog($"设备 【{device.DeviceName}】 未连接,不允许下发此配方", DialogType.Error);
- return;
- }
+ //if (!device.IsConnected)
+ //{
+ // MessageNotify.GetInstance.ShowDialog($"设备 【{device.DeviceName}】 未连接,不允许下发此配方", DialogType.Error);
+ // return;
+ //}
}
}
Recipes.ElementAt(index).IsEnable = false;
@@ -75,27 +76,89 @@ namespace BPASmartClient.DosingSystem.ViewModel
}));
CurrentRecipeName = Recipes.ElementAt(index).RecipeName;
+ #region 配方下发到PLC操作相关
//配方数据写入到输送机
- //SiemensDevice.GetInstance.MySiemens.WriteClass
-
- foreach (var item in Recipes.ElementAt(index).RawMaterials)
+ var res = Json.Data.Recipes.FirstOrDefault(p => p.RecipeName == CurrentRecipeName);
+ List recipeData = new List();
+ if (res != null)
{
- //DeviceInquire.GetInstance.GetDevice(item.DeviceIp)?.Start(item.RawMaterialWeight);//启动并写入每个原料重量
- //var res = DeviceInquire.GetInstance.GetDevice(item.DeviceIp).deviceStatus.DeviceNum;
-
-
-
- App.Current.Dispatcher.Invoke(new Action(() =>
+ var tInfo = res.RawMaterials.GroupBy(p => p.Loc);//获取桶号信息
+ if (tInfo != null)
{
- recipeProcesses.Add(new RawMaterialModel()
+ for (int i = 0; i < tInfo.Count(); i++)
{
- RawMaterialName = item.RawMaterialName,
- RecipeStatus = item.RecipeStatus,
- RawMaterialSource = item.RawMaterialSource,
- RawMaterialId = item.RawMaterialId,
- });
- }));
+ int data = 0;
+ for (int m = 0; m < tInfo.ElementAt(i).Count(); m++)
+ {
+ var TempName = tInfo.ElementAt(i).ElementAt(m).RawMaterialName;
+ var tempDevice = DeviceInquire.GetInstance.devices.FirstOrDefault(p => p.DeviceName == TempName);
+ if (tempDevice != null)
+ {
+ data = data.SetBitValue((byte)tempDevice.DeviceNum, true);
+ }
+ }
+ recipeData.Add(data);
+ }
+ }
}
+ if (recipeData.Count <= 0)
+ {
+ MessageNotify.GetInstance.ShowRunLog("配方数据解析失败");
+ return;
+ }
+ int offset = 2;
+ //写入配方数据
+ MessageNotify.GetInstance.ShowRunLog("开始写入配方数据");
+ recipeData.ForEach(item =>
+ {
+ SiemensDevice.GetInstance.MySiemens.Write($"DB4.DBD{offset}", item);
+ offset = offset += 4;
+ });
+ SiemensDevice.GetInstance.MySiemens.Write("DB4.DBD198", recipeData.Count);//配方使用桶数写入
+ SiemensDevice.GetInstance.MySiemens.Write("DB4.DBX0.1", true);//配方执行启动
+ Stopwatch sw = new Stopwatch();
+ App.Current.Dispatcher.Invoke(() => { recipeProcesses.Add(Recipes.ElementAt(index)); });
+ sw.Restart();
+ while (!GlobalDevice.PlcData.ResComplete)
+ {
+ if (sw.ElapsedMilliseconds >= 3000)
+ {
+ MessageNotify.GetInstance.ShowRunLog("获取配方下发反馈超时");
+ break;
+ }
+ if (GlobalDevice.PlcData.ResComplete) SiemensDevice.GetInstance.MySiemens.Write("DB3.DBX0.1", false);
+ Thread.Sleep(100);
+ }
+ #endregion
+
+ //foreach (var item in Recipes.ElementAt(index).RawMaterials)
+ //{
+ // //DeviceInquire.GetInstance.GetDevice(item.DeviceIp)?.Start(item.RawMaterialWeight);//启动并写入每个原料重量
+ // //var res = DeviceInquire.GetInstance.GetDevice(item.DeviceIp).deviceStatus.DeviceNum;
+ // App.Current.Dispatcher.Invoke(new Action(() =>
+ // {
+
+ // //ObservableCollection rawMaterialModels = new ObservableCollection();
+ // //rawMaterialModels.Add(new RawMaterialModel()
+ // //{
+ // // RawMaterialName = item.RawMaterialName,
+ // // RecipeStatus = item.RecipeStatus,
+ // // RawMaterialSource = item.RawMaterialSource,
+ // // RawMaterialId = item.RawMaterialId,
+ // //});
+
+ // //if (recipeProcesses.Count > 0)
+ // //{
+ // // recipeProcesses.ElementAt(0).RawMaterials.Add(new RawMaterialModel()
+ // // {
+ // // RawMaterialName = item.RawMaterialName,
+ // // RecipeStatus = item.RecipeStatus,
+ // // RawMaterialSource = item.RawMaterialSource,
+ // // RawMaterialId = item.RawMaterialId,
+ // // });
+ // //}
+ // }));
+ //}
Recipes.ElementAt(index).Are.WaitOne();//阻塞,直到当前配方完成
RecipeNames.TryDequeue(out string deviceName);
@@ -126,34 +189,57 @@ namespace BPASmartClient.DosingSystem.ViewModel
//设备状态显示
if (Recipes.ElementAt(i).RecipeName == CurrentRecipeName)
{
- string deviceName = DeviceInquire.GetInstance.GetDevice(Recipes.ElementAt(i).RawMaterials.ElementAt(m).DeviceIp).DeviceName;
- int index = Array.FindIndex(Recipes.ElementAt(i).RawMaterials.ToArray(), p => p.RawMaterialName == deviceName);
-
- if (index >= 0 && index < recipeProcesses.Count)
+ string tempRawMaterialName = DeviceInquire.GetInstance.GetDevice(Recipes.ElementAt(i).RawMaterials.ElementAt(m).DeviceIp).DeviceName;
+ //int index = Array.FindIndex(Recipes.ElementAt(i).RawMaterials.ToArray(), p => p.RawMaterialName == tempRawMaterialName);
+ int recIndex = recipeProcesses.ToList().FindIndex(p => p.RecipeName == CurrentRecipeName);
+ if (recIndex >= 0 && recIndex < recipeProcesses.Count)
{
- App.Current.Dispatcher.Invoke(new Action(() => { recipeProcesses.ElementAt(index).RecipeStatus = RunStatus; }));
- }
- }
-
+ int index = recipeProcesses.ElementAt(recIndex).RawMaterials.ToList().FindIndex(p => p.RawMaterialName == tempRawMaterialName);
+ if (index >= 0 && index < recipeProcesses.ElementAt(recIndex).RawMaterials.Count)
+ {
+ 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; }));
- 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++)
+ var proc = recipeProcesses.ElementAt(recIndex).RawMaterials.Where(p => p.RecipeStatus == 3).ToList();
+ if (proc != null && proc.Count > 0 && proc.Count == recipeProcesses.Count)
{
- DeviceInquire.GetInstance.GetDevice(Recipes.ElementAt(recipIndex).RawMaterials.ElementAt(n).DeviceIp).StatusReset();//完成配料的设备运行状态地址写0
- MessageNotify.GetInstance.ShowRunLog(Recipes.ElementAt(recipIndex).RawMaterials.ElementAt(n).DeviceIp);
+ 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();
+ }
}
- App.Current.Dispatcher.Invoke(new Action(() => { recipeProcesses.Clear(); }));
- Recipes.ElementAt(recipIndex).IsEnable = true;
- Recipes.ElementAt(recipIndex).Are.Set();
+
}
}
+ //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();
+ // }
+ //}
+
@@ -173,15 +259,6 @@ namespace BPASmartClient.DosingSystem.ViewModel
}
Thread.Sleep(100);
}), "RecipeControlViewModelStatusInquire");
- //测试数据
- /* 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 rawMaterials = new ObservableCollection { rawMaterial_1, rawMaterial_2, rawMaterial_3, rawMaterial_4 };
- UserTreeCompelete.Add(new RecipeModel { RecipeName = "完成的香料1", RawMaterials = rawMaterials });
- UserTreeCompelete.Add(new RecipeModel { RecipeName = "完成的香料2", RawMaterials = rawMaterials });*/
-
}
public RelayCommand